@capybara-hq/kernel 0.1.0-rc.105 → 0.1.0-rc.107

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 (359) hide show
  1. package/dist/admin/admin.schemas.d.ts +3 -0
  2. package/dist/agents/agents.schemas.d.ts +9 -9
  3. package/dist/{schedules/schedules.controller.d.ts → automations/automations.controller.d.ts} +37 -32
  4. package/dist/{schedules/schedules.controller.js → automations/automations.controller.js} +68 -57
  5. package/dist/automations/automations.module.d.ts +16 -0
  6. package/dist/{schedules/schedules.module.js → automations/automations.module.js} +18 -15
  7. package/dist/{schedules/schedules.schemas.d.ts → automations/automations.schemas.d.ts} +151 -50
  8. package/dist/automations/automations.schemas.js +253 -0
  9. package/dist/{schedules/scheduled-tasks.service.d.ts → automations/automations.service.d.ts} +99 -52
  10. package/dist/{schedules/scheduled-tasks.service.js → automations/automations.service.js} +303 -134
  11. package/dist/{schedules → automations}/calendar.d.ts +8 -8
  12. package/dist/{schedules → automations}/calendar.js +2 -2
  13. package/dist/automations/effective-settings.d.ts +28 -0
  14. package/dist/automations/effective-settings.js +25 -0
  15. package/dist/automations/errors.d.ts +19 -0
  16. package/dist/automations/errors.js +19 -0
  17. package/dist/automations/events/coalesce.d.ts +28 -0
  18. package/dist/automations/events/coalesce.js +131 -0
  19. package/dist/automations/events/deadline.d.ts +10 -0
  20. package/dist/automations/events/deadline.js +24 -0
  21. package/dist/automations/events/dispatcher.d.ts +74 -0
  22. package/dist/automations/events/dispatcher.js +353 -0
  23. package/dist/automations/events/events.module.d.ts +7 -0
  24. package/dist/automations/events/events.module.js +26 -0
  25. package/dist/automations/events/guards.d.ts +32 -0
  26. package/dist/automations/events/guards.js +87 -0
  27. package/dist/automations/events/sweep.job.d.ts +49 -0
  28. package/dist/automations/events/sweep.job.js +202 -0
  29. package/dist/automations/events/token.d.ts +5 -0
  30. package/dist/automations/events/token.js +5 -0
  31. package/dist/automations/events/trigger-events.service.d.ts +47 -0
  32. package/dist/automations/events/trigger-events.service.js +254 -0
  33. package/dist/{schedules → automations}/fire.d.ts +57 -17
  34. package/dist/{schedules → automations}/fire.js +311 -79
  35. package/dist/{schedules → automations}/grant-rules.d.ts +1 -1
  36. package/dist/{schedules → automations}/grant-rules.js +5 -5
  37. package/dist/automations/job-ids.d.ts +113 -0
  38. package/dist/automations/job-ids.js +117 -0
  39. package/dist/{schedules → automations}/pause.d.ts +3 -3
  40. package/dist/{schedules → automations}/pause.js +3 -3
  41. package/dist/{schedules → automations}/run-tracker.d.ts +21 -10
  42. package/dist/{schedules → automations}/run-tracker.js +68 -56
  43. package/dist/{schedules → automations}/scan.job.d.ts +12 -8
  44. package/dist/{schedules → automations}/scan.job.js +39 -23
  45. package/dist/{schedules → automations}/schedule-math.d.ts +19 -12
  46. package/dist/{schedules → automations}/schedule-math.js +17 -7
  47. package/dist/{schedules → automations}/store.d.ts +57 -27
  48. package/dist/{schedules → automations}/store.js +102 -52
  49. package/dist/automations/store.module.d.ts +6 -0
  50. package/dist/{schedules → automations}/store.module.js +9 -9
  51. package/dist/automations/types.d.ts +178 -0
  52. package/dist/{schedules → automations}/unattended.d.ts +22 -11
  53. package/dist/{schedules → automations}/unattended.js +53 -30
  54. package/dist/catalog/marketplaces.service.d.ts +1 -1
  55. package/dist/channels/channels.module.js +7 -6
  56. package/dist/channels/file-delivery.d.ts +26 -11
  57. package/dist/channels/file-delivery.js +32 -11
  58. package/dist/channels/outbound.d.ts +8 -8
  59. package/dist/channels/outbound.js +32 -30
  60. package/dist/channels/threads.d.ts +1 -1
  61. package/dist/channels/threads.js +1 -1
  62. package/dist/config/schema.d.ts +8 -1
  63. package/dist/config/schema.js +56 -6
  64. package/dist/conversations/approval-profile.d.ts +2 -2
  65. package/dist/conversations/approval-profile.js +3 -3
  66. package/dist/conversations/artifacts.d.ts +20 -17
  67. package/dist/conversations/artifacts.js +30 -37
  68. package/dist/conversations/attachments.controller.d.ts +6 -19
  69. package/dist/conversations/attachments.controller.js +8 -59
  70. package/dist/conversations/attachments.service.d.ts +30 -74
  71. package/dist/conversations/attachments.service.js +51 -193
  72. package/dist/conversations/conversations.controller.d.ts +7 -1
  73. package/dist/conversations/conversations.controller.js +26 -10
  74. package/dist/conversations/conversations.module.js +4 -0
  75. package/dist/conversations/conversations.service.d.ts +112 -35
  76. package/dist/conversations/conversations.service.js +160 -43
  77. package/dist/conversations/event-log.d.ts +1 -0
  78. package/dist/conversations/events.d.ts +95 -27
  79. package/dist/conversations/events.js +108 -10
  80. package/dist/conversations/files.d.ts +66 -64
  81. package/dist/conversations/files.js +127 -147
  82. package/dist/conversations/message-context.d.ts +2 -2
  83. package/dist/conversations/message-context.js +1 -1
  84. package/dist/conversations/permission-profile-store.d.ts +2 -1
  85. package/dist/conversations/permission-profiles.controller.d.ts +3 -0
  86. package/dist/conversations/permission-profiles.service.js +1 -1
  87. package/dist/conversations/prompt-suggestion-request.d.ts +1 -1
  88. package/dist/conversations/prompt-suggestion-request.js +4 -2
  89. package/dist/conversations/prompt-suggestions.d.ts +3 -3
  90. package/dist/conversations/prompt-suggestions.js +11 -10
  91. package/dist/conversations/queue.d.ts +7 -4
  92. package/dist/conversations/queue.js +6 -2
  93. package/dist/conversations/queue.service.d.ts +5 -5
  94. package/dist/conversations/queue.service.js +27 -16
  95. package/dist/ctx/create-ctx.d.ts +23 -2
  96. package/dist/ctx/create-ctx.js +78 -3
  97. package/dist/db/kernel-schema.d.ts +184 -27
  98. package/dist/devices/device-project-files.service.d.ts +88 -0
  99. package/dist/devices/device-project-files.service.js +249 -0
  100. package/dist/devices/device-projects.service.d.ts +40 -0
  101. package/dist/devices/device-projects.service.js +16 -13
  102. package/dist/devices/devices.controller.d.ts +9 -3
  103. package/dist/devices/devices.controller.js +27 -5
  104. package/dist/devices/devices.module.js +9 -1
  105. package/dist/devices/devices.schemas.js +6 -1
  106. package/dist/devices/dto.d.ts +15 -0
  107. package/dist/devices/dto.js +11 -0
  108. package/dist/devices/project-paths.d.ts +29 -0
  109. package/dist/devices/project-paths.js +66 -0
  110. package/dist/devices/project-rules.d.ts +5 -1
  111. package/dist/devices/project-rules.js +5 -1
  112. package/dist/errors.d.ts +53 -13
  113. package/dist/errors.js +53 -13
  114. package/dist/evals/canonical-json.d.ts +7 -0
  115. package/dist/evals/canonical-json.js +21 -0
  116. package/dist/evals/reconstruct.d.ts +10 -1
  117. package/dist/evals/reconstruct.js +20 -1
  118. package/dist/evals/recorded-tools.d.ts +0 -2
  119. package/dist/evals/recorded-tools.js +1 -16
  120. package/dist/evals/snapshot.d.ts +26 -3
  121. package/dist/evals/snapshot.js +110 -57
  122. package/dist/evals/worker.d.ts +4 -3
  123. package/dist/evals/worker.js +8 -4
  124. package/dist/extensions/host.d.ts +9 -2
  125. package/dist/extensions/host.js +12 -0
  126. package/dist/extensions/instance.d.ts +3 -1
  127. package/dist/extensions/instance.js +4 -0
  128. package/dist/extensions/ledger.d.ts +1 -1
  129. package/dist/extensions/permission-set.d.ts +17 -1
  130. package/dist/extensions/permission-set.js +13 -1
  131. package/dist/extensions/permission-view.d.ts +1 -1
  132. package/dist/extensions/permission-view.js +4 -1
  133. package/dist/files/blob-objects.d.ts +124 -0
  134. package/dist/files/blob-objects.js +341 -0
  135. package/dist/files/blob-sweep.job.d.ts +122 -0
  136. package/dist/files/blob-sweep.job.js +389 -0
  137. package/dist/files/blobs.service.d.ts +135 -0
  138. package/dist/files/blobs.service.js +300 -0
  139. package/dist/files/conversation-media.d.ts +41 -0
  140. package/dist/files/conversation-media.js +124 -0
  141. package/dist/files/deliveries.d.ts +64 -0
  142. package/dist/files/deliveries.js +156 -0
  143. package/dist/files/deliveries.module.d.ts +6 -0
  144. package/dist/files/deliveries.module.js +24 -0
  145. package/dist/files/draft-cleanup.job.d.ts +26 -0
  146. package/dist/files/draft-cleanup.job.js +93 -0
  147. package/dist/files/files.module.d.ts +1 -1
  148. package/dist/files/files.module.js +3 -2
  149. package/dist/files/hash-job.d.ts +127 -0
  150. package/dist/files/hash-job.js +447 -0
  151. package/dist/files/library-backfill.d.ts +63 -0
  152. package/dist/files/library-backfill.js +143 -0
  153. package/dist/files/library-files.service.d.ts +255 -0
  154. package/dist/files/library-files.service.js +883 -0
  155. package/dist/files/library-jobs.module.d.ts +8 -0
  156. package/dist/files/library-jobs.module.js +27 -0
  157. package/dist/files/library-query.d.ts +127 -0
  158. package/dist/files/library-query.js +322 -0
  159. package/dist/files/library-read.module.d.ts +9 -0
  160. package/dist/files/library-read.module.js +30 -0
  161. package/dist/files/library.controller.d.ts +77 -0
  162. package/dist/files/library.controller.js +235 -0
  163. package/dist/files/library.module.d.ts +9 -0
  164. package/dist/files/library.module.js +29 -0
  165. package/dist/files/library.schemas.d.ts +46 -0
  166. package/dist/files/library.schemas.js +49 -0
  167. package/dist/files/previewers.controller.d.ts +20 -0
  168. package/dist/files/previewers.controller.js +47 -0
  169. package/dist/files/previewers.d.ts +25 -11
  170. package/dist/files/previewers.js +43 -27
  171. package/dist/files/referenced-files.d.ts +150 -0
  172. package/dist/files/referenced-files.js +234 -0
  173. package/dist/git/gateway.js +2 -2
  174. package/dist/html/html-document.controller.d.ts +8 -1
  175. package/dist/html/html-document.controller.js +19 -1
  176. package/dist/html/html-document.service.d.ts +19 -4
  177. package/dist/html/html-document.service.js +43 -22
  178. package/dist/html/html-token.d.ts +10 -1
  179. package/dist/html/html-token.js +14 -0
  180. package/dist/html/html.module.js +8 -1
  181. package/dist/http/api.module.js +10 -5
  182. package/dist/http/request-signal.d.ts +8 -0
  183. package/dist/http/request-signal.js +14 -0
  184. package/dist/identity/settings.d.ts +26 -0
  185. package/dist/identity/settings.js +33 -2
  186. package/dist/inbox/inbox.module.js +2 -2
  187. package/dist/inbox/inbox.service.d.ts +8 -8
  188. package/dist/inbox/inbox.service.js +7 -7
  189. package/dist/infra/config/kernel-config.service.js +10 -5
  190. package/dist/infra/outbox/registry.d.ts +111 -2
  191. package/dist/infra/outbox/registry.js +104 -9
  192. package/dist/infra/throttler/named-throttlers.d.ts +2 -0
  193. package/dist/infra/throttler/named-throttlers.js +14 -0
  194. package/dist/kernel.module.js +3 -0
  195. package/dist/lifecycle/kernel-lifecycle.js +6 -0
  196. package/dist/models/purposes.js +1 -1
  197. package/dist/orgs/offboarding.js +1 -1
  198. package/dist/orgs/roles.d.ts +1 -1
  199. package/dist/orgs/roles.js +3 -3
  200. package/dist/orgs/settings.controller.d.ts +1 -1
  201. package/dist/orgs/settings.service.d.ts +75 -13
  202. package/dist/orgs/settings.service.js +104 -26
  203. package/dist/platform/exclusions.js +45 -8
  204. package/dist/platform/file-ref.d.ts +18 -3
  205. package/dist/platform/file-ref.js +22 -11
  206. package/dist/platform/operation.js +6 -2
  207. package/dist/platform/ops/admin.ops.js +5 -2
  208. package/dist/platform/ops/{schedules.ops.d.ts → automations.ops.d.ts} +4 -4
  209. package/dist/platform/ops/automations.ops.js +560 -0
  210. package/dist/platform/ops/devices.ops.d.ts +3 -1
  211. package/dist/platform/ops/devices.ops.js +77 -3
  212. package/dist/platform/ops/files.ops.d.ts +18 -0
  213. package/dist/platform/ops/files.ops.js +267 -0
  214. package/dist/platform/ops/inbox.ops.js +4 -4
  215. package/dist/platform/ops/org-settings.ops.js +6 -2
  216. package/dist/platform/ops/orgs.ops.js +2 -1
  217. package/dist/platform/ops/platform.ops.js +4 -4
  218. package/dist/platform/ops/shares.ops.js +2 -2
  219. package/dist/platform/platform-ops.module.d.ts +3 -2
  220. package/dist/platform/platform-ops.module.js +10 -5
  221. package/dist/platform/route-schemas.js +6 -3
  222. package/dist/push/jobs.d.ts +3 -3
  223. package/dist/push/jobs.js +2 -2
  224. package/dist/push/preferences.service.js +1 -1
  225. package/dist/push/push-owed.d.ts +3 -3
  226. package/dist/push/push-owed.js +6 -6
  227. package/dist/push/push.schemas.d.ts +4 -4
  228. package/dist/push/push.schemas.js +3 -3
  229. package/dist/push/recipients.d.ts +4 -4
  230. package/dist/push/recipients.js +23 -23
  231. package/dist/push/texts.d.ts +3 -3
  232. package/dist/push/texts.js +2 -2
  233. package/dist/push/triggers.d.ts +1 -1
  234. package/dist/roles/worker.module.js +18 -4
  235. package/dist/runtime/compaction-settings.service.d.ts +13 -1
  236. package/dist/runtime/compaction-settings.service.js +16 -1
  237. package/dist/runtime/compaction.service.d.ts +3 -1
  238. package/dist/runtime/compaction.service.js +3 -1
  239. package/dist/runtime/context/build.d.ts +24 -1
  240. package/dist/runtime/context/build.js +33 -11
  241. package/dist/runtime/context/cache-expiry.d.ts +31 -0
  242. package/dist/runtime/context/cache-expiry.js +60 -0
  243. package/dist/runtime/context/cache-ttl.d.ts +18 -0
  244. package/dist/runtime/context/cache-ttl.js +30 -0
  245. package/dist/runtime/context/compaction.d.ts +9 -2
  246. package/dist/runtime/context/compaction.js +64 -21
  247. package/dist/runtime/context/in-context-compaction.d.ts +156 -0
  248. package/dist/runtime/context/in-context-compaction.js +310 -0
  249. package/dist/runtime/context/run-context.d.ts +38 -0
  250. package/dist/runtime/context/run-context.js +54 -0
  251. package/dist/runtime/hook-calls.d.ts +2 -1
  252. package/dist/runtime/hook-calls.js +5 -2
  253. package/dist/runtime/maintenance.d.ts +16 -4
  254. package/dist/runtime/maintenance.js +79 -18
  255. package/dist/runtime/model-call.d.ts +34 -5
  256. package/dist/runtime/model-call.js +207 -22
  257. package/dist/runtime/providers.js +11 -1
  258. package/dist/runtime/run-finish.d.ts +4 -4
  259. package/dist/runtime/run-finish.js +3 -3
  260. package/dist/runtime/run-queue.js +12 -7
  261. package/dist/runtime/run-steps.d.ts +4 -2
  262. package/dist/runtime/run-steps.js +10 -5
  263. package/dist/runtime/run-worker.js +7 -1
  264. package/dist/runtime/runtime.module.js +6 -3
  265. package/dist/runtime/subagents/dispatch.js +11 -3
  266. package/dist/sandbox/browse-roots.d.ts +8 -0
  267. package/dist/sandbox/browse-roots.js +22 -0
  268. package/dist/sandbox/network-grants.d.ts +4 -4
  269. package/dist/sandbox/network-grants.js +7 -7
  270. package/dist/sandbox/operation-authority.d.ts +10 -3
  271. package/dist/sandbox/operation-authority.js +20 -10
  272. package/dist/sandbox/operation-intents.d.ts +3 -1
  273. package/dist/sandbox/operation-intents.js +11 -4
  274. package/dist/sandbox/permission-call-grants.js +2 -2
  275. package/dist/sandbox/permission-facts.js +1 -1
  276. package/dist/sandbox/review/classifier.d.ts +2 -2
  277. package/dist/sandbox/review/classifier.js +22 -11
  278. package/dist/sandbox/review/permission-candidate.d.ts +1 -1
  279. package/dist/sandbox/review/permission-candidate.js +1 -1
  280. package/dist/sandbox/sandbox.service.d.ts +15 -5
  281. package/dist/sandbox/sandbox.service.js +14 -8
  282. package/dist/shares/liveness.d.ts +26 -12
  283. package/dist/shares/liveness.js +79 -20
  284. package/dist/shares/revoke.d.ts +16 -11
  285. package/dist/shares/revoke.js +18 -14
  286. package/dist/shares/share-objects.d.ts +16 -21
  287. package/dist/shares/share-objects.js +25 -55
  288. package/dist/shares/share-open.service.d.ts +8 -4
  289. package/dist/shares/share-open.service.js +14 -11
  290. package/dist/shares/shares.controller.d.ts +16 -5
  291. package/dist/shares/shares.controller.js +39 -5
  292. package/dist/shares/shares.module.d.ts +4 -4
  293. package/dist/shares/shares.module.js +7 -6
  294. package/dist/shares/shares.schemas.d.ts +4 -0
  295. package/dist/shares/shares.schemas.js +2 -0
  296. package/dist/shares/shares.service.d.ts +93 -54
  297. package/dist/shares/shares.service.js +292 -131
  298. package/dist/shares/sweep.job.d.ts +18 -39
  299. package/dist/shares/sweep.job.js +47 -206
  300. package/dist/storage/purge.d.ts +1 -1
  301. package/dist/storage/purge.js +2 -2
  302. package/dist/tools/approvals.service.d.ts +6 -6
  303. package/dist/tools/approvals.service.js +19 -19
  304. package/dist/tools/builtin-names.d.ts +12 -12
  305. package/dist/tools/builtin-names.js +29 -29
  306. package/dist/tools/builtins/artifacts.d.ts +21 -13
  307. package/dist/tools/builtins/artifacts.js +81 -51
  308. package/dist/tools/builtins/{schedules.d.ts → automations.d.ts} +35 -33
  309. package/dist/tools/builtins/{schedules.js → automations.js} +236 -105
  310. package/dist/tools/builtins/builtin-tools.d.ts +15 -9
  311. package/dist/tools/builtins/builtin-tools.js +33 -22
  312. package/dist/tools/builtins/conversation-files.d.ts +23 -13
  313. package/dist/tools/builtins/conversation-files.js +62 -83
  314. package/dist/tools/builtins/image/generate.d.ts +7 -1
  315. package/dist/tools/builtins/image/generate.js +1 -1
  316. package/dist/tools/builtins/platform.js +1 -0
  317. package/dist/tools/builtins/sandbox/common.d.ts +6 -2
  318. package/dist/tools/builtins/sandbox/deliver.js +6 -7
  319. package/dist/tools/builtins/sandbox/fetch-attachment.d.ts +6 -5
  320. package/dist/tools/builtins/sandbox/fetch-attachment.js +19 -12
  321. package/dist/tools/call-scope.d.ts +1 -1
  322. package/dist/tools/git-asks.js +1 -1
  323. package/dist/tools/git-push-policy.d.ts +3 -3
  324. package/dist/tools/git-push-policy.js +6 -6
  325. package/dist/tools/network-asks.d.ts +3 -3
  326. package/dist/tools/network-asks.js +3 -3
  327. package/dist/tools/pipeline.d.ts +4 -4
  328. package/dist/tools/pipeline.js +2 -2
  329. package/dist/tools/policy.d.ts +3 -3
  330. package/dist/tools/policy.js +3 -3
  331. package/dist/tools/tools.module.js +15 -9
  332. package/dist/ui/call-extension.d.ts +6 -4
  333. package/dist/ui/call-extension.js +5 -4
  334. package/dist/ui/embed-token.js +6 -3
  335. package/dist/ui/registry.d.ts +21 -5
  336. package/dist/ui/registry.js +24 -6
  337. package/dist/ui/ui.schemas.d.ts +22 -0
  338. package/dist/ui/ui.schemas.js +22 -4
  339. package/dist/ui/views.controller.d.ts +13 -3
  340. package/dist/ui/views.controller.js +33 -2
  341. package/dist/ui/views.d.ts +29 -1
  342. package/dist/ui/views.js +131 -7
  343. package/package.json +3 -3
  344. package/src/migrations/0188_automations_rename.sql +309 -0
  345. package/src/migrations/0189_event_automations.sql +136 -0
  346. package/src/migrations/0190_file_library.sql +285 -0
  347. package/src/migrations/0191_file_library_copy.sql +4 -0
  348. package/dist/platform/ops/schedules.ops.js +0 -509
  349. package/dist/schedules/effective-settings.d.ts +0 -22
  350. package/dist/schedules/effective-settings.js +0 -18
  351. package/dist/schedules/errors.d.ts +0 -8
  352. package/dist/schedules/errors.js +0 -8
  353. package/dist/schedules/job-ids.d.ts +0 -81
  354. package/dist/schedules/job-ids.js +0 -95
  355. package/dist/schedules/schedules.module.d.ts +0 -16
  356. package/dist/schedules/schedules.schemas.js +0 -213
  357. package/dist/schedules/store.module.d.ts +0 -6
  358. package/dist/schedules/types.d.ts +0 -110
  359. /package/dist/{schedules → automations}/types.js +0 -0
@@ -33,6 +33,13 @@ export declare const ViewQuery: z.ZodObject<{
33
33
  callId: z.ZodOptional<z.ZodString>;
34
34
  key: z.ZodOptional<z.ZodString>;
35
35
  }, z.core.$strip>;
36
+ /** The UTF-8 bytes of a value serialized as JSON (the measure of every UI payload limit). */
37
+ export declare const jsonBytes: (v: unknown) => number;
38
+ /**
39
+ * An action's body. `payload` is capped here at the component limit
40
+ * (`UI_LIMITS.componentActionPayloadBytes`); a view's action keeps `UI_LIMITS.payloadBytes`, which
41
+ * `UiViews.act` checks once it knows the contribution's kind.
42
+ */
36
43
  export declare const ActionBody: z.ZodObject<{
37
44
  actionId: z.ZodString;
38
45
  payload: z.ZodOptional<z.ZodUnknown>;
@@ -44,6 +51,21 @@ export declare const ActionBody: z.ZodObject<{
44
51
  zh: "zh";
45
52
  }>>;
46
53
  }, z.core.$strip>;
54
+ /**
55
+ * `POST query/:plugin/:id`: a component's named query. `params` is any JSON (default `null`), at
56
+ * most `UI_LIMITS.componentQueryParamsBytes` as JSON (checked by the service: 413
57
+ * `ui.query_params_too_large`); the context ids are those of the component's slot, as for an action.
58
+ */
59
+ export declare const QueryBody: z.ZodObject<{
60
+ query: z.ZodString;
61
+ params: z.ZodOptional<z.ZodUnknown>;
62
+ conversationId: z.ZodOptional<z.ZodString>;
63
+ agentId: z.ZodOptional<z.ZodUUID>;
64
+ locale: z.ZodDefault<z.ZodEnum<{
65
+ en: "en";
66
+ zh: "zh";
67
+ }>>;
68
+ }, z.core.$strip>;
47
69
  export declare const EmbedTokenBody: z.ZodDefault<z.ZodObject<{
48
70
  conversationId: z.ZodOptional<z.ZodString>;
49
71
  agentId: z.ZodOptional<z.ZodUUID>;
@@ -33,15 +33,20 @@ const FormAnswerSchema = z
33
33
  .refine((a) => Object.keys(a).length <= UI_LIMITS.tableRows, {
34
34
  message: `answer must have at most ${UI_LIMITS.tableRows} fields`,
35
35
  });
36
- /** 按钮 payload 的 JSON 序列化后 UTF-8 字节数(与 `validateUiView` 对按钮 payload 的上限一致)。 */
37
- const payloadBytes = (v) => Buffer.byteLength(JSON.stringify(v) ?? "", "utf8");
36
+ /** The UTF-8 bytes of a value serialized as JSON (the measure of every UI payload limit). */
37
+ export const jsonBytes = (v) => Buffer.byteLength(JSON.stringify(v) ?? "", "utf8");
38
+ /**
39
+ * An action's body. `payload` is capped here at the component limit
40
+ * (`UI_LIMITS.componentActionPayloadBytes`); a view's action keeps `UI_LIMITS.payloadBytes`, which
41
+ * `UiViews.act` checks once it knows the contribution's kind.
42
+ */
38
43
  export const ActionBody = z.object({
39
44
  actionId: z.string().min(1).max(200),
40
45
  payload: z
41
46
  .unknown()
42
47
  .optional()
43
- .refine((v) => v === undefined || payloadBytes(v) <= UI_LIMITS.payloadBytes, {
44
- message: `payload must be at most ${UI_LIMITS.payloadBytes} bytes as JSON`,
48
+ .refine((v) => v === undefined || jsonBytes(v) <= UI_LIMITS.componentActionPayloadBytes, {
49
+ message: `payload must be at most ${UI_LIMITS.componentActionPayloadBytes} bytes as JSON`,
45
50
  }),
46
51
  answer: FormAnswerSchema.optional(),
47
52
  conversationId: z.string().min(1).max(100).optional(),
@@ -49,6 +54,19 @@ export const ActionBody = z.object({
49
54
  agentId: z.uuid().optional(),
50
55
  locale: Locale,
51
56
  });
57
+ /**
58
+ * `POST query/:plugin/:id`: a component's named query. `params` is any JSON (default `null`), at
59
+ * most `UI_LIMITS.componentQueryParamsBytes` as JSON (checked by the service: 413
60
+ * `ui.query_params_too_large`); the context ids are those of the component's slot, as for an action.
61
+ */
62
+ export const QueryBody = z.object({
63
+ query: z.string().min(1).max(200),
64
+ params: z.unknown().optional(),
65
+ conversationId: z.string().min(1).max(100).optional(),
66
+ /** Only a component of `agent.detail.section`. */
67
+ agentId: z.uuid().optional(),
68
+ locale: Locale,
69
+ });
52
70
  export const EmbedTokenBody = z
53
71
  .object({
54
72
  conversationId: z.string().min(1).max(100).optional(),
@@ -1,4 +1,4 @@
1
- import type { UiActionResult, UiView } from "@capybara-hq/plugin-sdk";
1
+ import type { JsonValue, UiActionResult, UiView } from "@capybara-hq/plugin-sdk";
2
2
  import type { FastifyReply, FastifyRequest } from "fastify";
3
3
  import type { z } from "zod";
4
4
  import { ApiTokenService } from "../identity/api-tokens.js";
@@ -6,7 +6,7 @@ import { type Principal } from "../identity/principal.js";
6
6
  import { SessionService } from "../identity/sessions.js";
7
7
  import { type OrgContext } from "../orgs/org.guard.js";
8
8
  import { EmbedTokens } from "./embed-token.js";
9
- import { ActionBody, ContributionParams, ContributionsQuery, EmbedTokenBody, ViewQuery } from "./ui.schemas.js";
9
+ import { ActionBody, ContributionParams, ContributionsQuery, EmbedTokenBody, QueryBody, ViewQuery } from "./ui.schemas.js";
10
10
  import { OrgUiStreams } from "./ui-stream.js";
11
11
  import { type UiArrangementSlot, type UiContributionItem, UiViews } from "./views.js";
12
12
  export declare const BEARER_RE: RegExp;
@@ -27,10 +27,17 @@ export declare const embedSrc: (plugin: string, path: string) => string;
27
27
  * → `{ view }`(`item`: the panel item to scroll to; `callId` / `key`: an inline card's tool call);
28
28
  * - `POST /api/v1/orgs/:orgId/ui/actions/:plugin/:id`
29
29
  * (`{ actionId, payload?, answer?, conversationId?, agentId?, locale? }`)→ `{ toast }` | `{ view }`;
30
+ * `payload` ≤ `UI_LIMITS.componentActionPayloadBytes` for a component, `payloadBytes` for a view;
31
+ * - `POST /api/v1/orgs/:orgId/ui/query/:plugin/:id` (`{ query, params?, conversationId?, agentId?,
32
+ * locale? }`) → `{ data }`: a component's named query (`ctx.ui.query`, plugin full pages spec
33
+ * §4.1), gated like the component's view; 404 `ui.query_not_found`, 413
34
+ * `ui.query_params_too_large`, 502 `ui.query_failed` / `ui.query_result_too_large`, 504
35
+ * `ui.query_timeout` (10 s);
30
36
  * - `GET /api/v1/orgs/:orgId/ui/stream`:组织级刷新 SSE(`event: ui`,`data: {"plugin","contribution"}`),
31
37
  * member and above;
32
38
  * - `POST /api/v1/orgs/:orgId/ui/embeds/:plugin/:id/token` (`{ conversationId?, agentId?, fileId? }`,
33
- * or for a skill file's previewer `{ skillId, version?, path }`)
39
+ * `{ fileId }` alone for a library file's previewer, or for a skill file's previewer
40
+ * `{ skillId, version?, path }`)
34
41
  * → `{ token, src: "/plugin-ui/<plugin>/<path without /ui/>", expiresAt, expiresIn }`: an embed
35
42
  * token (300 seconds, `expiresIn` in seconds, see `embed-token.ts`; `agentId` goes into the
36
43
  * claims, a skill file as `skillFile` with its resolved version). The token is only for the
@@ -60,6 +67,9 @@ export declare class UiController {
60
67
  view: UiView;
61
68
  }>;
62
69
  action(principal: Principal, org: OrgContext, { plugin, id }: z.infer<typeof ContributionParams>, body: z.infer<typeof ActionBody>): Promise<UiActionResult>;
70
+ query(principal: Principal, org: OrgContext, { plugin, id }: z.infer<typeof ContributionParams>, body: z.infer<typeof QueryBody>): Promise<{
71
+ data: JsonValue;
72
+ }>;
63
73
  embedToken(principal: Principal, org: OrgContext, { plugin, id }: z.infer<typeof ContributionParams>, body: z.infer<typeof EmbedTokenBody>): Promise<{
64
74
  token: string;
65
75
  src: string;
@@ -17,7 +17,7 @@ import { createZodDto } from "../infra/validation/create-zod-dto.js";
17
17
  import { ZBody, ZParam, ZQuery } from "../infra/validation/zod-params.js";
18
18
  import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
19
19
  import { EMBED_TOKEN_TTL_SECONDS, EmbedTokens } from "./embed-token.js";
20
- import { ActionBody, ContributionParams, ContributionsQuery, EmbedTokenBody, ViewQuery, } from "./ui.schemas.js";
20
+ import { ActionBody, ContributionParams, ContributionsQuery, EmbedTokenBody, QueryBody, ViewQuery, } from "./ui.schemas.js";
21
21
  import { OrgUiStreams } from "./ui-stream.js";
22
22
  import { UiViews } from "./views.js";
23
23
  export const BEARER_RE = /^Bearer\s+(\S+)$/i;
@@ -31,6 +31,8 @@ class UiViewQueryDto extends createZodDto(ViewQuery, "UiViewQuery") {
31
31
  }
32
32
  class UiActionBodyDto extends createZodDto(ActionBody, "UiActionBody") {
33
33
  }
34
+ class UiQueryBodyDto extends createZodDto(QueryBody, "UiQueryBody") {
35
+ }
34
36
  class UiEmbedTokenBodyDto extends createZodDto(EmbedTokenBody, "UiEmbedTokenBody") {
35
37
  }
36
38
  /**
@@ -48,10 +50,17 @@ class UiEmbedTokenBodyDto extends createZodDto(EmbedTokenBody, "UiEmbedTokenBody
48
50
  * → `{ view }`(`item`: the panel item to scroll to; `callId` / `key`: an inline card's tool call);
49
51
  * - `POST /api/v1/orgs/:orgId/ui/actions/:plugin/:id`
50
52
  * (`{ actionId, payload?, answer?, conversationId?, agentId?, locale? }`)→ `{ toast }` | `{ view }`;
53
+ * `payload` ≤ `UI_LIMITS.componentActionPayloadBytes` for a component, `payloadBytes` for a view;
54
+ * - `POST /api/v1/orgs/:orgId/ui/query/:plugin/:id` (`{ query, params?, conversationId?, agentId?,
55
+ * locale? }`) → `{ data }`: a component's named query (`ctx.ui.query`, plugin full pages spec
56
+ * §4.1), gated like the component's view; 404 `ui.query_not_found`, 413
57
+ * `ui.query_params_too_large`, 502 `ui.query_failed` / `ui.query_result_too_large`, 504
58
+ * `ui.query_timeout` (10 s);
51
59
  * - `GET /api/v1/orgs/:orgId/ui/stream`:组织级刷新 SSE(`event: ui`,`data: {"plugin","contribution"}`),
52
60
  * member and above;
53
61
  * - `POST /api/v1/orgs/:orgId/ui/embeds/:plugin/:id/token` (`{ conversationId?, agentId?, fileId? }`,
54
- * or for a skill file's previewer `{ skillId, version?, path }`)
62
+ * `{ fileId }` alone for a library file's previewer, or for a skill file's previewer
63
+ * `{ skillId, version?, path }`)
55
64
  * → `{ token, src: "/plugin-ui/<plugin>/<path without /ui/>", expiresAt, expiresIn }`: an embed
56
65
  * token (300 seconds, `expiresIn` in seconds, see `embed-token.ts`; `agentId` goes into the
57
66
  * claims, a skill file as `skillFile` with its resolved version). The token is only for the
@@ -120,6 +129,19 @@ let UiController = class UiController {
120
129
  ...(body.answer !== undefined && { answer: body.answer }),
121
130
  });
122
131
  }
132
+ async query(principal, org, { plugin, id }, body) {
133
+ const p = requireUser(principal);
134
+ return this.views.query({
135
+ orgId: org.orgId,
136
+ accountId: p.account.id,
137
+ role: org.role,
138
+ plugin,
139
+ id,
140
+ ...(body.conversationId !== undefined && { conversationId: body.conversationId }),
141
+ ...(body.agentId !== undefined && { agentId: body.agentId }),
142
+ locale: body.locale,
143
+ }, { query: body.query, ...(body.params !== undefined && { params: body.params }) });
144
+ }
123
145
  async embedToken(principal, org, { plugin, id }, body) {
124
146
  const p = requireUser(principal);
125
147
  if ((body.skillId === undefined) !== (body.path === undefined)) {
@@ -236,6 +258,15 @@ __decorate([
236
258
  __param(2, ZParam(UiContributionParamsDto)),
237
259
  __param(3, ZBody(UiActionBodyDto))
238
260
  ], UiController.prototype, "action", null);
261
+ __decorate([
262
+ Post("query/:plugin/:id"),
263
+ HttpCode(200),
264
+ OrgAction("ui.use"),
265
+ __param(0, CurrentPrincipal()),
266
+ __param(1, CurrentOrg()),
267
+ __param(2, ZParam(UiContributionParamsDto)),
268
+ __param(3, ZBody(UiQueryBodyDto))
269
+ ], UiController.prototype, "query", null);
239
270
  __decorate([
240
271
  Post("embeds/:plugin/:id/token"),
241
272
  HttpCode(200),
@@ -1,4 +1,4 @@
1
- import { type CompactForm, type FormAnswer, type Logger, type UiActionResult, type UiContribution, type UiIcon, type UiSlotId, type UiView } from "@capybara-hq/plugin-sdk";
1
+ import { type CompactForm, type FormAnswer, type JsonValue, type Logger, type UiActionResult, type UiContribution, type UiIcon, type UiPageFrame, type UiPageNav, type UiSlotId, type UiView } from "@capybara-hq/plugin-sdk";
2
2
  import { ConversationsService } from "../conversations/conversations.service.js";
3
3
  import type { KernelSchemaDb } from "../db/kernel-schema.js";
4
4
  import { EffectiveConfigs } from "../extensions/effective-config.js";
@@ -9,6 +9,8 @@ import { type OrgRole } from "../orgs/roles.js";
9
9
  export { callExtension } from "./call-extension.js";
10
10
  /** 插件 render / action 的时限(spec §4.2:慢的插件只让那个标签失败)。 */
11
11
  export declare const UI_CALL_TIMEOUT_MS = 5000;
12
+ /** The time limit of a component query (plugin full pages spec §4.1). */
13
+ export declare const UI_QUERY_TIMEOUT_MS = 10000;
12
14
  /** 列出贡献接口的一项。 */
13
15
  export interface UiContributionItem {
14
16
  plugin: string;
@@ -25,6 +27,10 @@ export interface UiContributionItem {
25
27
  icon: UiIcon;
26
28
  /** The form on a compact screen: the slot's, narrowed by the contribution's (spec §5.6). */
27
29
  compact: CompactForm;
30
+ /** `org.page` component only, when the manifest names it: who draws the page frame. */
31
+ frame?: UiPageFrame;
32
+ /** `org.page` component only, when the manifest names it: the suggested navigation section. */
33
+ nav?: UiPageNav;
28
34
  }
29
35
  /** A list slot of an arrangement listing: where its entry comes from and its items in order. */
30
36
  export interface UiArrangementListSlot {
@@ -189,6 +195,14 @@ export declare class UiViews {
189
195
  * else is 404.
190
196
  */
191
197
  private skillFileEmbed;
198
+ /**
199
+ * A `file.preview` embed for one of the caller's own library files (file library spec §6; no
200
+ * conversation or agent): the caller's role may use agents (`agents.use`) and the slot, the
201
+ * contribution is a loaded `file.preview` embed of an extension enabled in the org, and an
202
+ * enabled previewer of that extension with `embed: <this contribution>` takes the file (another
203
+ * account's file throws 404 `file.not_found`); anything else is 404.
204
+ */
205
+ private libraryFileEmbed;
192
206
  /**
193
207
  * The path of a loaded `file.preview` embed contribution (a share page's embed previewer, file
194
208
  * sharing spec §7), else 404 `ui.not_found`. Whether the previewer takes the share's snapshot
@@ -203,6 +217,20 @@ export declare class UiViews {
203
217
  payload?: unknown;
204
218
  answer?: FormAnswer;
205
219
  }): Promise<UiActionResult>;
220
+ /**
221
+ * Runs a component's named query (`ctx.ui.query`, plugin full pages spec §4.1): the same gate
222
+ * and args as the component's view, plus `{ query, params, signal }`. Not offered (or no
223
+ * handler) is 404 `ui.query_not_found`; params over `UI_LIMITS.componentQueryParamsBytes` 413
224
+ * `ui.query_params_too_large`; 10 s 504 `ui.query_timeout`; a throw 502 `ui.query_failed`; a
225
+ * result that is not JSON or over `UI_LIMITS.componentQueryBytes` 502
226
+ * `ui.query_result_too_large`.
227
+ */
228
+ query(t: UiOrgTarget, input: {
229
+ query: string;
230
+ params?: unknown;
231
+ }): Promise<{
232
+ data: JsonValue;
233
+ }>;
206
234
  /** Ids of the extension's live `panel` contributions. */
207
235
  private panels;
208
236
  /**
package/dist/ui/views.js CHANGED
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __param = (this && this.__param) || function (paramIndex, decorator) {
8
8
  return function (target, key) { decorator(target, key, paramIndex); }
9
9
  };
10
- import { effectiveCompact, UI_ARRANGEABLE_SLOTS, validateUiView, } from "@capybara-hq/plugin-sdk";
10
+ import { effectiveCompact, UI_ARRANGEABLE_SLOTS, UI_LIMITS, validateUiView, } from "@capybara-hq/plugin-sdk";
11
11
  import { Inject, Injectable } from "@nestjs/common";
12
12
  import { sql } from "kysely";
13
13
  import { isAgentVisibleIn } from "../agents/agent-lookup.js";
@@ -24,9 +24,12 @@ import { readOrgSettings } from "../orgs/settings.service.js";
24
24
  import { arrange, arrangeBySlot, effectiveEntry, isSingle, keyOf, ORG_ARRANGEABLE, orderItems, resolveSingleSlot, storedUse, } from "./arrangement.js";
25
25
  import { callExtension } from "./call-extension.js";
26
26
  import { canUseSlot, UUID_RE } from "./registry.js";
27
+ import { jsonBytes } from "./ui.schemas.js";
27
28
  export { callExtension } from "./call-extension.js";
28
29
  /** 插件 render / action 的时限(spec §4.2:慢的插件只让那个标签失败)。 */
29
30
  export const UI_CALL_TIMEOUT_MS = 5_000;
31
+ /** The time limit of a component query (plugin full pages spec §4.1). */
32
+ export const UI_QUERY_TIMEOUT_MS = 10_000;
30
33
  /** The log field naming where a target is: its org, or the platform scope. */
31
34
  const whereOf = (t) => t.scope === "platform" ? { scope: "platform" } : { orgId: t.orgId };
32
35
  /**
@@ -93,6 +96,8 @@ function listed(entries) {
93
96
  ...(c.kind === "embed" && c.path !== undefined && { path: c.path }),
94
97
  icon: c.icon ?? "puzzle",
95
98
  compact: effectiveCompact(s.compact, c.compact),
99
+ ...(c.frame !== undefined && { frame: c.frame }),
100
+ ...(c.nav !== undefined && { nav: c.nav }),
96
101
  }));
97
102
  }
98
103
  /** The candidates of a single slot in an arrangement listing. */
@@ -112,13 +117,24 @@ const TOAST_MAX = 500;
112
117
  const MAX_LOGGED_PROBLEMS = 10;
113
118
  const notFound = () => new ApiError("ui.not_found", "UI contribution not found");
114
119
  const isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
120
+ /** At most this many query names in an action result's `invalidate`. */
121
+ const INVALIDATE_MAX = 50;
115
122
  /**
116
- * 校验动作结果,返回问题列表(空 = 合法)。A new `view` may carry `data` only for a component
123
+ * Checks an action result and returns its problems (empty = valid). A new `view` may carry
124
+ * `data`, and `invalidate` (query names the host refetches) is read, only for a component
117
125
  * (`component`).
118
126
  */
119
127
  function actionResultProblems(r, component) {
120
128
  if (!isObj(r))
121
129
  return ["action result must be an object"];
130
+ if (component && r.invalidate !== undefined) {
131
+ const inv = r.invalidate;
132
+ if (!Array.isArray(inv) ||
133
+ inv.length > INVALIDATE_MAX ||
134
+ !inv.every((q) => typeof q === "string" && q !== "" && q.length <= 200)) {
135
+ return [`invalidate must be at most ${INVALIDATE_MAX} query names of 1-200 characters`];
136
+ }
137
+ }
122
138
  if (r.view !== undefined)
123
139
  return validateUiView(r.view, { component }).map((p) => `view: ${p}`);
124
140
  if (r.toast === undefined)
@@ -277,6 +293,12 @@ let UiViews = class UiViews {
277
293
  const { fileId: f, skillFile, ...org } = t;
278
294
  if (skillFile !== undefined)
279
295
  return this.skillFileEmbed({ ...org, skillFile }, f);
296
+ if (f !== undefined && org.conversationId === undefined) {
297
+ if (org.agentId !== undefined) {
298
+ throw new ApiError("validation_failed", "fileId is not allowed with agentId");
299
+ }
300
+ return this.libraryFileEmbed(org, f);
301
+ }
280
302
  fileId = f;
281
303
  target = { ...org, locale: "en" };
282
304
  }
@@ -354,6 +376,39 @@ let UiViews = class UiViews {
354
376
  throw notFound();
355
377
  return { plugin: t.plugin, contribution: t.id, path, skillFile: file };
356
378
  }
379
+ /**
380
+ * A `file.preview` embed for one of the caller's own library files (file library spec §6; no
381
+ * conversation or agent): the caller's role may use agents (`agents.use`) and the slot, the
382
+ * contribution is a loaded `file.preview` embed of an extension enabled in the org, and an
383
+ * enabled previewer of that extension with `embed: <this contribution>` takes the file (another
384
+ * account's file throws 404 `file.not_found`); anything else is 404.
385
+ */
386
+ async libraryFileEmbed(t, fileId) {
387
+ const entry = this.d.host
388
+ .uiContributions()
389
+ .find((c) => c.plugin === t.plugin &&
390
+ c.contribution.id === t.id &&
391
+ c.contribution.kind === "embed" &&
392
+ c.slot.id === "file.preview");
393
+ const path = entry?.contribution.path;
394
+ if (entry === undefined || path === undefined)
395
+ throw notFound();
396
+ if (!canUseSlot(entry.slot, t.role) || !can(t.role, "agents.use"))
397
+ throw notFound();
398
+ if (!(await this.d.enabledPlugins(t.orgId)).has(t.plugin))
399
+ throw notFound();
400
+ const allowed = this.d.previewEmbedAllowed !== undefined &&
401
+ (await this.d.previewEmbedAllowed({
402
+ orgId: t.orgId,
403
+ accountId: t.accountId,
404
+ fileId,
405
+ plugin: t.plugin,
406
+ contribution: t.id,
407
+ }));
408
+ if (!allowed)
409
+ throw notFound();
410
+ return { plugin: t.plugin, contribution: t.id, path, fileId };
411
+ }
357
412
  /**
358
413
  * The path of a loaded `file.preview` embed contribution (a share page's embed previewer, file
359
414
  * sharing spec §7), else 404 `ui.not_found`. Whether the previewer takes the share's snapshot
@@ -383,6 +438,12 @@ let UiViews = class UiViews {
383
438
  /** 执行动作:调用插件 `action`(视图里的按钮 / 表单提交),校验返回的提示或新视图。 */
384
439
  async act(t, input) {
385
440
  const { entry, args } = await this.resolve(t, "action");
441
+ // a component's action takes a form-sized payload; a view's button keeps the view limit
442
+ if (entry.contribution.kind !== "component" &&
443
+ input.payload !== undefined &&
444
+ jsonBytes(input.payload) > UI_LIMITS.payloadBytes) {
445
+ throw new ApiError("validation_failed", `payload must be at most ${UI_LIMITS.payloadBytes} bytes as JSON`);
446
+ }
386
447
  const action = entry.action;
387
448
  const r = await this.call(t, "action", (signal) => action({
388
449
  ...args,
@@ -391,11 +452,74 @@ let UiViews = class UiViews {
391
452
  ...(input.payload !== undefined && { payload: input.payload }),
392
453
  ...(input.answer !== undefined && { answer: input.answer }),
393
454
  }));
394
- this.check(t, "action", actionResultProblems(r, entry.contribution.kind === "component"));
455
+ const component = entry.contribution.kind === "component";
456
+ this.check(t, "action", actionResultProblems(r, component));
395
457
  const res = r;
396
- if (res.view !== undefined)
397
- return { view: dropForeignOpens(res.view, this.panels(t.plugin)) };
398
- return res.toast !== undefined ? { toast: { zh: res.toast.zh, en: res.toast.en } } : {};
458
+ // the query names to refetch: a component's only (plugin full pages spec §4.1)
459
+ const inv = component && res.invalidate !== undefined ? { invalidate: [...res.invalidate] } : {};
460
+ if (res.view !== undefined) {
461
+ return { view: dropForeignOpens(res.view, this.panels(t.plugin)), ...inv };
462
+ }
463
+ return res.toast !== undefined
464
+ ? { toast: { zh: res.toast.zh, en: res.toast.en }, ...inv }
465
+ : inv;
466
+ }
467
+ /**
468
+ * Runs a component's named query (`ctx.ui.query`, plugin full pages spec §4.1): the same gate
469
+ * and args as the component's view, plus `{ query, params, signal }`. Not offered (or no
470
+ * handler) is 404 `ui.query_not_found`; params over `UI_LIMITS.componentQueryParamsBytes` 413
471
+ * `ui.query_params_too_large`; 10 s 504 `ui.query_timeout`; a throw 502 `ui.query_failed`; a
472
+ * result that is not JSON or over `UI_LIMITS.componentQueryBytes` 502
473
+ * `ui.query_result_too_large`.
474
+ */
475
+ async query(t, input) {
476
+ let resolved;
477
+ try {
478
+ resolved = await this.resolve(t, "query");
479
+ }
480
+ catch (e) {
481
+ if (e instanceof ApiError && e.code === "ui.not_found") {
482
+ throw new ApiError("ui.query_not_found", "UI component query not found");
483
+ }
484
+ throw e;
485
+ }
486
+ const params = (input.params ?? null);
487
+ if (jsonBytes(params) > UI_LIMITS.componentQueryParamsBytes) {
488
+ throw new ApiError("ui.query_params_too_large", `params must be at most ${UI_LIMITS.componentQueryParamsBytes} bytes as JSON`);
489
+ }
490
+ const handler = resolved.entry.query;
491
+ // an org target always resolves to org args
492
+ const args = resolved.args;
493
+ const data = await callExtension({
494
+ log: this.d.log,
495
+ plugin: t.plugin,
496
+ what: "query",
497
+ fields: { plugin: t.plugin, contribution: t.id, query: input.query, orgId: t.orgId },
498
+ timeoutMs: UI_QUERY_TIMEOUT_MS,
499
+ failCode: "ui.query_failed",
500
+ timeoutCode: "ui.query_timeout",
501
+ failMessage: `Plugin ${t.plugin} failed to answer query ${input.query} of ${t.id}`,
502
+ fn: (signal) => handler({ ...args, query: input.query, params, signal }),
503
+ });
504
+ let json;
505
+ try {
506
+ json = JSON.stringify(data);
507
+ }
508
+ catch {
509
+ json = undefined;
510
+ }
511
+ const bytes = json === undefined ? undefined : Buffer.byteLength(json, "utf8");
512
+ if (bytes === undefined || bytes > UI_LIMITS.componentQueryBytes) {
513
+ this.d.log.warn("plugin ui query returned a result that is not JSON or too large", {
514
+ plugin: t.plugin,
515
+ contribution: t.id,
516
+ query: input.query,
517
+ orgId: t.orgId,
518
+ ...(bytes !== undefined && { bytes }),
519
+ });
520
+ throw new ApiError("ui.query_result_too_large", `Plugin ${t.plugin} returned a query result that is not JSON of at most ${UI_LIMITS.componentQueryBytes} bytes`);
521
+ }
522
+ return { data };
399
523
  }
400
524
  /** Ids of the extension's live `panel` contributions. */
401
525
  panels(plugin) {
@@ -421,7 +545,7 @@ let UiViews = class UiViews {
421
545
  c.contribution.id === t.id &&
422
546
  (need === "embed"
423
547
  ? c.contribution.kind === "embed"
424
- : // a view, or a component's server view (served like a view of its slot)
548
+ : // a view, or a component's server view or query (served like a view of its slot)
425
549
  (c.contribution.kind === "view" || c.contribution.kind === "component") &&
426
550
  c[need] !== undefined));
427
551
  if (t.scope === "platform") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capybara-hq/kernel",
3
- "version": "0.1.0-rc.105",
3
+ "version": "0.1.0-rc.107",
4
4
  "description": "Capybara kernel: config, database, plugin host and HTTP API of the Capybara agent platform",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -66,7 +66,7 @@
66
66
  "yaml": "^2.9.1",
67
67
  "yauzl": "3.4.0",
68
68
  "zod": "^4.6.7",
69
- "@capybara-hq/plugin-sdk": "^0.1.0-rc.84"
69
+ "@capybara-hq/plugin-sdk": "^0.1.0-rc.86"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@langchain/langgraph-checkpoint-validation": "^1.2.0",
@@ -75,7 +75,7 @@
75
75
  "@types/ws": "^8.18.2",
76
76
  "@types/yauzl": "3.4.0",
77
77
  "ws": "^8.22.0",
78
- "@capybara-hq/testing": "0.1.0-rc.46"
78
+ "@capybara-hq/testing": "0.1.0-rc.48"
79
79
  },
80
80
  "scripts": {
81
81
  "build": "tsc -b"