@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,11 +33,11 @@ const goneText = (name) => `Attachment "${clip(name, 200)}" is no longer in this
33
33
  const storageText = (name) => `File storage is unavailable, so "${clip(name, 200)}" could not be copied; ask an administrator to check the deployment's object store, then retry.`;
34
34
  const copyFailedText = (name) => `Copying "${clip(name, 200)}" into the device failed (a temporary error); retry the call, or check that the device has free space.`;
35
35
  /**
36
- * The attachment `file` names, among the conversation's ready ones (the caller's list): the exact
37
- * file name, then the name the copy assigns it (a sanitized or de-duplicated name shown in an
38
- * earlier result's path), then the bare attachment id or a reference whose last path segment is the
39
- * id (`s3://<bucket>/<key>/attachments/<id>`, `capybara://attachments/<id>`). Names are exact and
40
- * case-sensitive; nothing else resolves.
36
+ * The attachment `file` names, among the files sent into the conversation (the caller's list): the
37
+ * exact file name, then the name the copy assigns it (a sanitized or de-duplicated name shown in an
38
+ * earlier result's path), then the unsigned reference a reference line showed (the file's blob
39
+ * `s3://<bucket>/<key>`, or `capybara://attachments/<id>`), then the bare file id or a reference
40
+ * whose last path segment is the id. Names are exact and case-sensitive; nothing else resolves.
41
41
  */
42
42
  function resolveAttachment(file, list, assigned) {
43
43
  const byName = list.find((a) => a.name === file);
@@ -46,6 +46,9 @@ function resolveAttachment(file, list, assigned) {
46
46
  const byAssigned = list.find((a) => assigned.get(a.id) === file);
47
47
  if (byAssigned !== undefined)
48
48
  return byAssigned;
49
+ const byUri = list.find((a) => a.uri === file);
50
+ if (byUri !== undefined)
51
+ return byUri;
49
52
  const tail = file.slice(file.lastIndexOf("/") + 1);
50
53
  if (!ATTACHMENT_ID.test(tail))
51
54
  return undefined;
@@ -53,11 +56,12 @@ function resolveAttachment(file, list, assigned) {
53
56
  return list.find((a) => a.id.toLowerCase() === id);
54
57
  }
55
58
  /**
56
- * The builtin `FetchAttachment`: copy one attachment of this conversation into the device
57
- * ({@link attachmentsDir}); it runs nothing. Names come from the conversation's whole attachment
58
- * list ({@link assignAttachmentNames}), so a given attachment always lands on the same path;
59
- * copying it twice writes the same bytes and returns the same path. A failure is an ordinary tool
60
- * error and the run continues.
59
+ * The builtin `FetchAttachment`: copy one file sent into this conversation (its root's: the files
60
+ * its messages attached, file library spec §5) into the device ({@link attachmentsDir}); it runs
61
+ * nothing. A library file the person never attached to the conversation is not in the list.
62
+ * Names come from the conversation's whole attachment list ({@link assignAttachmentNames}), so a
63
+ * given attachment always lands on the same path; copying it twice writes the same bytes and
64
+ * returns the same path. A failure is an ordinary tool error and the run continues.
61
65
  */
62
66
  export function sandboxFetchAttachmentTool(deps) {
63
67
  return {
@@ -69,8 +73,11 @@ export function sandboxFetchAttachmentTool(deps) {
69
73
  const file = input.file;
70
74
  const conv = sandboxConversationOf(ctx);
71
75
  // the list is read before any device is touched: an unknown file starts no device
72
- const list = await deps.attachments.listForConversation(ctx.orgId, conv);
73
- const assigned = assignAttachmentNames(list, new Set());
76
+ const all = await deps.attachments.listForConversation(ctx.orgId, conv);
77
+ // names over every file ever sent here (a deleted one keeps its name taken), copies of the
78
+ // available ones only
79
+ const assigned = assignAttachmentNames(all, new Set());
80
+ const list = all.filter((a) => a.available !== false);
74
81
  const attachment = resolveAttachment(file, list, assigned);
75
82
  if (attachment === undefined) {
76
83
  if (list.length === 0)
@@ -15,7 +15,7 @@ export interface CallFacts {
15
15
  step: number;
16
16
  /** The root conversation of the run's tree (a sub-agent works in its root's device). */
17
17
  rootConversationId: string;
18
- /** An unattended run (a scheduled task): nobody is there to answer an ask. */
18
+ /** An unattended run (an automation): nobody is there to answer an ask. */
19
19
  unattended: boolean;
20
20
  agentVersion: number;
21
21
  conversationKind?: ConversationKindForHooks;
@@ -1,5 +1,5 @@
1
+ import { gitPushGrantKey, normalizeGitRepo } from "../automations/grant-rules.js";
1
2
  import { GIT_ASK_MAX_REFS, GIT_REF_MAX_CHARS } from "../conversations/events.js";
2
- import { gitPushGrantKey, normalizeGitRepo } from "../schedules/grant-rules.js";
3
3
  import { GIT_ASK_CANCELLED_NOTE } from "./approvals.service.js";
4
4
  import { clipKeptWith } from "./network-asks.js";
5
5
  /**
@@ -1,6 +1,6 @@
1
+ import { type UnattendedRun } from "../automations/unattended.js";
1
2
  import type { KernelSchemaDb } from "../db/kernel-schema.js";
2
3
  import type { KernelConfigService } from "../infra/config/kernel-config.service.js";
3
- import { type UnattendedRun } from "../schedules/unattended.js";
4
4
  import { type GitRunState } from "./git-asks.js";
5
5
  import type { ToolPolicy } from "./registry.js";
6
6
  /** Why {@link decideGitPush} decided as it did. */
@@ -11,7 +11,7 @@ export type GitPushReason =
11
11
  | "member_allow"
12
12
  /** An approved 「这次允许」 of the run tree for the repository. */
13
13
  | "run_grant"
14
- /** The scheduled task's `git:push` / `git:push:<owner>/<repo>` grant (unattended run). */
14
+ /** The automation's `git:push` / `git:push:<owner>/<repo>` grant (unattended run). */
15
15
  | "task_grant"
16
16
  /** The policy asks the actor. */
17
17
  | "ask"
@@ -55,7 +55,7 @@ export interface GitPushInput {
55
55
  /** `<owner>/<repo>` (a trailing `.git` and case are normalized here). */
56
56
  repo: string;
57
57
  /**
58
- * The scheduled task context of the run, when the caller has it (`unattendedRunOf`); undefined:
58
+ * The automation context of the run, when the caller has it (`unattendedRunOf`); undefined:
59
59
  * read here. Null: an attended run.
60
60
  */
61
61
  unattended?: UnattendedRun | null;
@@ -1,7 +1,7 @@
1
1
  import { sql } from "kysely";
2
+ import { GIT_PUSH_GRANT, gitPushForbidden, gitPushGrantKey, normalizeGitRepo, } from "../automations/grant-rules.js";
3
+ import { unattendedRules, unattendedRunOf } from "../automations/unattended.js";
2
4
  import { budgetRunOf } from "../runtime/subagents/limits.js";
3
- import { GIT_PUSH_GRANT, gitPushForbidden, gitPushGrantKey, normalizeGitRepo, } from "../schedules/grant-rules.js";
4
- import { unattendedRules, unattendedRunOf } from "../schedules/unattended.js";
5
5
  import { gitPushPolicyName, personalAuth } from "./connector-account-policies.js";
6
6
  import { gitRepoKey } from "./git-asks.js";
7
7
  import { connectorPolicy } from "./policy.js";
@@ -13,8 +13,8 @@ import { connectorPolicy } from "./policy.js";
13
13
  * Storage (no new table): the org's default is `connectors.git_push_policy` (default `ask`); a
14
14
  * member's standing allow (or deny) for one repository is their `connector_tool_account_policies`
15
15
  * row `git_push:<host>/<owner>/<repo>` (a personal connector only: an org connector's push acts as the
16
- * org); a run grant is an approved `once` git ask of the run tree; a scheduled task's grants are
17
- * `git:push` and `git:push:<owner>/<repo>` in `scheduled_task_grants`.
16
+ * org); a run grant is an approved `once` git ask of the run tree; an automation's grants are
17
+ * `git:push` and `git:push:<owner>/<repo>` in `automation_grants`.
18
18
  */
19
19
  /** The statuses of a run that has not ended: its run grants still apply. */
20
20
  const LIVE_RUN = ["queued", "running", "waiting"];
@@ -92,9 +92,9 @@ export async function decideGitPush(db, config, input) {
92
92
  }
93
93
  if (rules !== null) {
94
94
  const granted = await db
95
- .selectFrom("scheduled_task_grants")
95
+ .selectFrom("automation_grants")
96
96
  .select("tool_key")
97
- .where("task_id", "=", rules.taskId)
97
+ .where("automation_id", "=", rules.taskId)
98
98
  .where("tool_key", "in", [GIT_PUSH_GRANT, key])
99
99
  .executeTakeFirst();
100
100
  if (granted !== undefined)
@@ -1,6 +1,6 @@
1
1
  import { type NetworkBlockedHost } from "@capybara-hq/plugin-sdk";
2
+ import { type UnattendedRun } from "../automations/unattended.js";
2
3
  import type { NetworkRunState } from "../sandbox/network-grants.js";
3
- import { type UnattendedRun } from "../schedules/unattended.js";
4
4
  import { type ApprovalRecord, type NetworkAppliesAt } from "./approvals.service.js";
5
5
  /**
6
6
  * Network asks in the tool pipeline (network ask-to-allow spec §6.2, §6.6–§6.9, §8.3): what a
@@ -154,7 +154,7 @@ export interface NetworkPlanContext {
154
154
  * is never asked about.
155
155
  */
156
156
  offer?: (hosts: string[]) => NetworkAskOffer | null;
157
- /** The scheduled task run the run serves (null / undefined: attended). */
157
+ /** The automation run the run serves (null / undefined: attended). */
158
158
  unattended: UnattendedRun | null | undefined;
159
159
  /**
160
160
  * Whether a host is beyond the platform's ceiling (`sandbox.limits.orgHosts: within`, org egress
@@ -245,7 +245,7 @@ export declare function blockedEventHosts(blocked: readonly NetworkBlockedHost[]
245
245
  * carried that list (`ctx.deviceBlocks`): a note saying so, never asked;
246
246
  * - a `device` host the device's settings already allow (`ctx.onList`: not yet applied to the
247
247
  * instance): a note saying when it applies, never asked again;
248
- * - approved by the scheduled task the run serves (`run.taskGranted`) yet refused: a note that
248
+ * - approved by the automation the run serves (`run.taskGranted`) yet refused: a note that
249
249
  * the device ignores the task's grants (never asked, never a missing grant);
250
250
  * - refused earlier in the run tree: the denied note; an unattended run in `fail` mode: its note
251
251
  * and a missing grant;
@@ -1,8 +1,8 @@
1
1
  import { validateAllowHost } from "@capybara-hq/plugin-sdk";
2
+ import { networkGrantKey, unattendedFails, unattendedRules, } from "../automations/unattended.js";
2
3
  import { NETWORK_ASK_MAX_HOSTS, NETWORK_HOST_MAX_CHARS } from "../conversations/events.js";
3
4
  import { coversHost } from "../sandbox/modes.js";
4
5
  import { ESCALATION_UNATTENDED_WHY } from "../sandbox/review/permission-candidate.js";
5
- import { networkGrantKey, unattendedFails, unattendedRules, } from "../schedules/unattended.js";
6
6
  import { NETWORK_ASK_CANCELLED_NOTE, networkAskHosts, } from "./approvals.service.js";
7
7
  /**
8
8
  * Network asks in the tool pipeline (network ask-to-allow spec §6.2, §6.6–§6.9, §8.3): what a
@@ -191,7 +191,7 @@ export const unavailableHostNote = (host, why) => `[network] ${host} was blocked
191
191
  * provider did not apply the task's network grant. Not asked, not a missing grant: the device's
192
192
  * owner adds the host to the device's network list on its page.
193
193
  */
194
- export const taskGrantIgnoredNote = (hosts) => `${blockedLead(hosts)} The scheduled task approves ${pron(hosts)}, but this device did not apply the task's network grant. The device owner can add ${pron(hosts)} to the device's network list on its page. Continue without ${pron(hosts)}.`;
194
+ export const taskGrantIgnoredNote = (hosts) => `${blockedLead(hosts)} The automation approves ${pron(hosts)}, but this device did not apply the task's network grant. The device owner can add ${pron(hosts)} to the device's network list on its page. Continue without ${pron(hosts)}.`;
195
195
  /** An unattended run in `fail` mode (spec §8.3): no ask, the creator can add a task grant. */
196
196
  export const unattendedNetworkNote = (hosts) => `[network] ${list(hosts)} ${one(hosts) ? "is" : "are"} blocked on this device and this scheduled run cannot ask for network access. The task's owner can add ${pron(hosts)} to the task's approved domains. Continue without ${pron(hosts)}.`;
197
197
  /**
@@ -239,7 +239,7 @@ export function blockedEventHosts(blocked) {
239
239
  * carried that list (`ctx.deviceBlocks`): a note saying so, never asked;
240
240
  * - a `device` host the device's settings already allow (`ctx.onList`: not yet applied to the
241
241
  * instance): a note saying when it applies, never asked again;
242
- * - approved by the scheduled task the run serves (`run.taskGranted`) yet refused: a note that
242
+ * - approved by the automation the run serves (`run.taskGranted`) yet refused: a note that
243
243
  * the device ignores the task's grants (never asked, never a missing grant);
244
244
  * - refused earlier in the run tree: the denied note; an unattended run in `fail` mode: its note
245
245
  * and a missing grant;
@@ -1,5 +1,6 @@
1
1
  import { type ConversationSource, type FormAnswer, type InputForm, type Logger, type ServiceBlockedHost, type ToolCallContext, type ToolDisplay } from "@capybara-hq/plugin-sdk";
2
2
  import type { AgentDefinition } from "../agents/definition.js";
3
+ import { type UnattendedRun } from "../automations/unattended.js";
3
4
  import { ConversationApprovalProfile } from "../conversations/approval-profile.js";
4
5
  import { AttachmentsService } from "../conversations/attachments.service.js";
5
6
  import { EventLog } from "../conversations/event-log.js";
@@ -25,7 +26,6 @@ import { PermissionAutoGrants } from "../sandbox/permission-auto-grants.js";
25
26
  import { PermissionCallGrants } from "../sandbox/permission-call-grants.js";
26
27
  import { type CommandReview } from "../sandbox/review/index.js";
27
28
  import { SandboxService } from "../sandbox/sandbox.service.js";
28
- import { type UnattendedRun } from "../schedules/unattended.js";
29
29
  import { ApprovalsService, type NetworkAskDetail } from "./approvals.service.js";
30
30
  import { Breaker } from "./breaker.js";
31
31
  import { Credentials } from "./credentials.js";
@@ -90,7 +90,7 @@ export declare const INPUT_SKIPPED_TEXT = "The user did not provide the requeste
90
90
  */
91
91
  export declare const WAIT_SKIPPED_TEXT = "The user sent a message while this wait was running, which ended it; read the message below and continue. Call the tool again only if the wait is still needed.";
92
92
  /** A watched ask over `tools.maxWatchedWaitsPerAccount` (spec §5.2). */
93
- export declare const TOO_MANY_WATCHED_WAITS_TEXT = "Too many waits are running for this user; end one, or finish and let a scheduled task check later.";
93
+ export declare const TOO_MANY_WATCHED_WAITS_TEXT = "Too many waits are running for this user; end one, or finish and let an automation check later.";
94
94
  /** A tool asked for a watched wait without a registered watcher (spec §5.2). */
95
95
  export declare const watchWithoutWatcherText: (key: string) => string;
96
96
  /** 同一调用连续请求输入超过上限。 */
@@ -208,7 +208,7 @@ export interface PolicyContext {
208
208
  */
209
209
  callPolicy?: CallPolicy | null;
210
210
  /**
211
- * The scheduled task run the run serves, unattended or trial (scheduled tasks spec §7); unset or
211
+ * The automation run the run serves, unattended or trial (scheduled tasks spec §7); unset or
212
212
  * null: an attended run.
213
213
  */
214
214
  unattended?: UnattendedRun | null;
@@ -344,7 +344,7 @@ export interface ToolStepContext {
344
344
  */
345
345
  parent?: SubagentParent;
346
346
  /**
347
- * The scheduled task run this run serves (scheduled tasks spec §7); filled by `runStep` once per
347
+ * The automation run this run serves (scheduled tasks spec §7); filled by `runStep` once per
348
348
  * step from PG (`unattendedRunOf`), null when attended. Callers leave it unset.
349
349
  */
350
350
  unattended?: UnattendedRun | null;
@@ -10,6 +10,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
10
10
  import { CARD_BADGE_MAX, CARD_TEXT_MAX, DeviceAccessError, ToolError, validateInputForm, validateToolDisplay, } from "@capybara-hq/plugin-sdk";
11
11
  import { Inject, Injectable, Optional } from "@nestjs/common";
12
12
  import { sql } from "kysely";
13
+ import { appendMissingGrant, connectionGrantKey, UNATTENDED_CONNECTION_ERROR, UNATTENDED_ELICITATION_NOTE, UNATTENDED_QUESTION_ERROR, unattendedFails, unattendedRules, unattendedRunOf, } from "../automations/unattended.js";
13
14
  import { backgroundMaxSeconds } from "../background/launch.js";
14
15
  import { ConversationApprovalProfile } from "../conversations/approval-profile.js";
15
16
  import { AttachmentsService } from "../conversations/attachments.service.js";
@@ -49,7 +50,6 @@ import { isSessionGrantableRule, } from "../sandbox/review/index.js";
49
50
  import { approverForCrossing, buildPermissionCandidate, crossingOfCandidate, ESCALATION_RETRY_HINT, ESCALATION_UNATTENDED_WHY, escalationRefusedText, isEscalatedCall, } from "../sandbox/review/permission-candidate.js";
50
51
  import { CommandReviewService } from "../sandbox/review/review.service.js";
51
52
  import { SandboxService } from "../sandbox/sandbox.service.js";
52
- import { appendMissingGrant, connectionGrantKey, UNATTENDED_CONNECTION_ERROR, UNATTENDED_ELICITATION_NOTE, UNATTENDED_QUESTION_ERROR, unattendedFails, unattendedRules, unattendedRunOf, } from "../schedules/unattended.js";
53
53
  import { skillLoadOfferedIn } from "../skills/catalog.js";
54
54
  import { ApprovalsService, } from "./approvals.service.js";
55
55
  import { Breaker, breakerOpenMessage } from "./breaker.js";
@@ -144,7 +144,7 @@ export const INPUT_SKIPPED_TEXT = "The user did not provide the requested input
144
144
  */
145
145
  export const WAIT_SKIPPED_TEXT = "The user sent a message while this wait was running, which ended it; read the message below and continue. Call the tool again only if the wait is still needed.";
146
146
  /** A watched ask over `tools.maxWatchedWaitsPerAccount` (spec §5.2). */
147
- export const TOO_MANY_WATCHED_WAITS_TEXT = "Too many waits are running for this user; end one, or finish and let a scheduled task check later.";
147
+ export const TOO_MANY_WATCHED_WAITS_TEXT = "Too many waits are running for this user; end one, or finish and let an automation check later.";
148
148
  /** A tool asked for a watched wait without a registered watcher (spec §5.2). */
149
149
  export const watchWithoutWatcherText = (key) => `Tool ${key} asked for a watched wait but registers no watcher.`;
150
150
  /** 同一调用连续请求输入超过上限。 */
@@ -6,7 +6,7 @@ export { R3_FIXED_ASK_TOOL_KEYS } from "./builtin-names.js";
6
6
  export { isFixedAsk } from "./fixed-ask.js";
7
7
  /**
8
8
  * What allowed an ask without an approval: this conversation's grant, an "always" grant, or a
9
- * scheduled task's grant (its unattended runs, scheduled tasks spec §7).
9
+ * automation's grant (its unattended runs, scheduled tasks spec §7).
10
10
  */
11
11
  export type GrantKind = "session" | "always" | "task";
12
12
  /** 取更严的策略(`allow < ask < deny`)。 */
@@ -16,10 +16,10 @@ export interface PolicyInput {
16
16
  connectorDefault: ToolPolicy;
17
17
  /** agent 负责人的收紧(`definition.toolPolicies[key]`)。 */
18
18
  agentOverride?: "ask" | "deny";
19
- /** `requiresUserInteraction`。 */
19
+ /** `requiresUserInteraction`. */
20
20
  fixedAsk: boolean;
21
21
  /**
22
- * 已记住且 specHash 与当前一致的授权; `task`: a scheduled task's grant in its unattended run.
22
+ * A remembered grant whose specHash matches the current one; `task`: an automation's grant in its unattended run.
23
23
  */
24
24
  grant: GrantKind | null;
25
25
  }
@@ -1,10 +1,10 @@
1
1
  import { sql } from "kysely";
2
2
  import { normalizeStoredDefinition } from "../agents/definition.js";
3
+ import { grantRefusalOf } from "../automations/grant-rules.js";
4
+ import { findTaskGrant } from "../automations/store.js";
5
+ import { changesAgentSkills, UNATTENDED_ASK_ERROR, UNATTENDED_FIXED_ASK_ERROR, UNATTENDED_QUESTION_ERROR, unattendedRules, } from "../automations/unattended.js";
3
6
  import { roleAtLeast } from "../orgs/roles.js";
4
7
  import { FORBIDDEN_TOOLS_UNREADABLE_ERROR, readOrgSettings } from "../orgs/settings.service.js";
5
- import { grantRefusalOf } from "../schedules/grant-rules.js";
6
- import { findTaskGrant } from "../schedules/store.js";
7
- import { changesAgentSkills, UNATTENDED_ASK_ERROR, UNATTENDED_FIXED_ASK_ERROR, UNATTENDED_QUESTION_ERROR, unattendedRules, } from "../schedules/unattended.js";
8
8
  import { BUILTIN, SANDBOX_ASK_TOOL_NAMES } from "./builtin-names.js";
9
9
  import { personalAuth } from "./connector-account-policies.js";
10
10
  import { isFixedAsk } from "./fixed-ask.js";
@@ -5,6 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { Module } from "@nestjs/common";
8
+ import { AutomationStoreModule } from "../automations/store.module.js";
8
9
  import { BackgroundModule } from "../background/background.module.js";
9
10
  import { ConversationAccessModule } from "../conversations/access.js";
10
11
  import { ConversationApprovalProfileModule } from "../conversations/approval-profile.js";
@@ -13,6 +14,8 @@ import { EventLogModule } from "../conversations/event-log.js";
13
14
  import { ConversationLeakCheckModule } from "../conversations/leak-check.js";
14
15
  import { DevicesModule } from "../devices/devices.module.js";
15
16
  import { ExtensionsModule } from "../extensions/extensions.module.js";
17
+ import { FileDeliveriesModule } from "../files/deliveries.module.js";
18
+ import { LibraryReadModule } from "../files/library-read.module.js";
16
19
  import { QueueModule } from "../infra/queue/queue.module.js";
17
20
  import { ModelsModule } from "../models/models.module.js";
18
21
  import { OrgLockModule } from "../orgs/org-lock.js";
@@ -29,14 +32,13 @@ import { OperationAuthorityModule } from "../sandbox/operation-authority.module.
29
32
  import { PermissionAuthorityModule } from "../sandbox/permission-authority.module.js";
30
33
  import { PermissionCallGrantsModule } from "../sandbox/permission-call-grants.module.js";
31
34
  import { SandboxModule } from "../sandbox/sandbox.module.js";
32
- import { ScheduledTaskStoreModule } from "../schedules/store.module.js";
33
35
  import { SkillsModule } from "../skills/skills.module.js";
34
36
  import { StorageModule } from "../storage/storage.module.js";
35
37
  import { AdminConnectors } from "./admin-connectors.js";
36
38
  import { ApprovalsService } from "./approvals.service.js";
37
39
  import { Breaker } from "./breaker.js";
40
+ import { AutomationToolsPort, AutomationUpdates } from "./builtins/automations.js";
38
41
  import { BuiltinTools } from "./builtins/builtin-tools.js";
39
- import { ScheduleToolsPort, ScheduleUpdates } from "./builtins/schedules.js";
40
42
  import { WebPages } from "./builtins/web/page-cache.js";
41
43
  import { ConnectorAccountPolicies } from "./connector-account-policies.js";
42
44
  import { ConnectorContent } from "./connector-content.js";
@@ -77,8 +79,12 @@ ToolsModule = __decorate([
77
79
  // the approval decision's leak check of a person's card values
78
80
  ConversationLeakCheckModule,
79
81
  AttachmentsModule,
82
+ // the library files a conversation refers to (`Read`, `Deliver`, `FetchAttachment`, file refs)
83
+ LibraryReadModule,
80
84
  ExtensionsModule,
81
85
  StorageModule,
86
+ // `Deliver` and `GenerateImage` store files as library files on shared blobs
87
+ FileDeliveriesModule,
82
88
  SkillsModule,
83
89
  OrgLockModule,
84
90
  // the `Agent` tool's dispatch
@@ -108,8 +114,8 @@ ToolsModule = __decorate([
108
114
  // ConnectorToolsProcessor)
109
115
  ConnectorToolsQueueModule,
110
116
  ToolWatchQueueModule,
111
- // a trial run's approvals become its scheduled task's grants (scheduled tasks spec §7)
112
- ScheduledTaskStoreModule,
117
+ // a trial run's approvals become its automation's grants (scheduled tasks spec §7)
118
+ AutomationStoreModule,
113
119
  // connector credentials (also the git gateway's, without importing this module)
114
120
  CredentialsModule,
115
121
  ],
@@ -119,10 +125,10 @@ ToolsModule = __decorate([
119
125
  BuiltinTools,
120
126
  // a Platform write's file reference (a conversation file)
121
127
  FileRefs,
122
- // `ScheduleUpdate`'s write in one transaction (scheduled tasks spec §11)
123
- ScheduleUpdates,
124
- // where `SchedulesModule` binds the task service for the schedule tools (no provider cycle)
125
- ScheduleToolsPort,
128
+ // `AutomationUpdate`'s write in one transaction (scheduled tasks spec §11)
129
+ AutomationUpdates,
130
+ // where `AutomationsModule` binds the task service for the automation tools (no provider cycle)
131
+ AutomationToolsPort,
126
132
  WebPages,
127
133
  ToolRegistry,
128
134
  ApprovalsService,
@@ -144,7 +150,7 @@ ToolsModule = __decorate([
144
150
  ],
145
151
  exports: [
146
152
  PermissionApprovalJobs,
147
- ScheduleToolsPort,
153
+ AutomationToolsPort,
148
154
  CredentialsModule,
149
155
  ToolOutputs,
150
156
  BuiltinTools,
@@ -1,8 +1,9 @@
1
1
  import type { Logger } from "@capybara-hq/plugin-sdk";
2
2
  /**
3
- * Calls an extension with a time limit and an abort signal (plugin views, actions and file
4
- * previewers): over the limit the signal aborts and the call is 504 `ui.timeout`; a throw is
5
- * `failCode` (502) without echoing the extension's message. An `ApiError` thrown by `fn` passes.
3
+ * Calls an extension with a time limit and an abort signal (plugin views, actions, component
4
+ * queries and file previewers): over the limit the signal aborts and the call is 504
5
+ * `timeoutCode` (default `ui.timeout`); a throw is `failCode` (502) without echoing the
6
+ * extension's message. An `ApiError` thrown by `fn` passes.
6
7
  */
7
8
  export declare function callExtension<T>(o: {
8
9
  log: Pick<Logger, "warn">;
@@ -10,7 +11,8 @@ export declare function callExtension<T>(o: {
10
11
  what: string;
11
12
  fields: Record<string, unknown>;
12
13
  timeoutMs: number;
13
- failCode: "ui.render_failed" | "ui.action_failed";
14
+ failCode: "ui.render_failed" | "ui.action_failed" | "ui.query_failed";
15
+ timeoutCode?: "ui.timeout" | "ui.query_timeout";
14
16
  failMessage: string;
15
17
  fn: (signal: AbortSignal) => Promise<T>;
16
18
  }): Promise<T>;
@@ -1,8 +1,9 @@
1
1
  import { ApiError } from "../errors.js";
2
2
  /**
3
- * Calls an extension with a time limit and an abort signal (plugin views, actions and file
4
- * previewers): over the limit the signal aborts and the call is 504 `ui.timeout`; a throw is
5
- * `failCode` (502) without echoing the extension's message. An `ApiError` thrown by `fn` passes.
3
+ * Calls an extension with a time limit and an abort signal (plugin views, actions, component
4
+ * queries and file previewers): over the limit the signal aborts and the call is 504
5
+ * `timeoutCode` (default `ui.timeout`); a throw is `failCode` (502) without echoing the
6
+ * extension's message. An `ApiError` thrown by `fn` passes.
6
7
  */
7
8
  export async function callExtension(o) {
8
9
  const ac = new AbortController();
@@ -22,7 +23,7 @@ export async function callExtension(o) {
22
23
  ]);
23
24
  if (r === "timeout") {
24
25
  o.log.warn(`plugin ui ${o.what} timed out`, { ...o.fields, timeoutMs: o.timeoutMs });
25
- throw new ApiError("ui.timeout", `Plugin ${o.plugin} did not respond within ${o.timeoutMs / 1000}s`);
26
+ throw new ApiError(o.timeoutCode ?? "ui.timeout", `Plugin ${o.plugin} did not respond within ${o.timeoutMs / 1000}s`);
26
27
  }
27
28
  return r.value;
28
29
  }
@@ -76,7 +76,8 @@ function decodeStrict(s) {
76
76
  /**
77
77
  * 逐字段核对声明:只认已知字段、类型正确,返回只含已知字段的新对象。The scope decides the shape:
78
78
  * `"platform"` exactly when `orgId` is absent and `role` is `"superAdmin"`, with no
79
- * `conversationId` / `agentId` / `fileId`; `"org"` needs an `orgId` and one of the org roles;
79
+ * `conversationId` / `agentId` / `fileId`; `"org"` needs an `orgId` and one of the org roles (a
80
+ * `fileId` names a file of `conversationId`, or without one a library file of the account's own);
80
81
  * `"share"` (file sharing spec §7) see {@link parseShareClaims}. `shareId` / `generation` only in
81
82
  * the share scope. `skillFile` (a skill file's previewer, skill file browser spec) only in the org
82
83
  * scope and never with `conversationId`, `agentId` or `fileId`.
@@ -124,12 +125,14 @@ function parseClaims(v) {
124
125
  return null;
125
126
  if (c.agentId !== undefined && (!isId(c.agentId) || c.conversationId !== undefined))
126
127
  return null;
127
- if (c.fileId !== undefined && (!isId(c.fileId) || c.conversationId === undefined))
128
+ // a file of the conversation, or without one a library file of the account's own
129
+ if (c.fileId !== undefined && (!isId(c.fileId) || c.agentId !== undefined))
128
130
  return null;
129
131
  let skillFile;
130
132
  if (c.skillFile !== undefined) {
131
- if (c.conversationId !== undefined || c.agentId !== undefined)
133
+ if (c.conversationId !== undefined || c.agentId !== undefined || c.fileId !== undefined) {
132
134
  return null;
135
+ }
133
136
  skillFile = parseSkillFile(c.skillFile) ?? undefined;
134
137
  if (skillFile === undefined)
135
138
  return null;
@@ -1,4 +1,4 @@
1
- import type { ExtensionManifest, UiActionArgs, UiActionResult, UiRenderArgs, UiSlotSpec, UiView } from "@capybara-hq/plugin-sdk";
1
+ import type { ExtensionManifest, JsonValue, UiActionArgs, UiActionResult, UiQueryArgs, UiRenderArgs, UiSlotSpec, UiView } from "@capybara-hq/plugin-sdk";
2
2
  import { type OrgRole } from "../orgs/roles.js";
3
3
  /** 会话 id 的格式(UUID)。 */
4
4
  export declare const UUID_RE: RegExp;
@@ -10,7 +10,9 @@ export declare const UUID_RE: RegExp;
10
10
  export declare function canUseSlot(slot: UiSlotSpec, role: OrgRole): boolean;
11
11
  /** 插件视图的 render 函数(`ctx.ui.view` 注册)。 */
12
12
  export type UiRender = (args: UiRenderArgs) => Promise<UiView>;
13
- /** 插件视图的动作处理函数(`ctx.ui.action` 注册)。 */
13
+ /** The handler of a `ctx.ui.query` registration (a component's named queries, by `args.query`). */
14
+ export type UiQueryHandler = (args: UiQueryArgs) => Promise<JsonValue>;
15
+ /** The action handler of a plugin view (registered with `ctx.ui.action`). */
14
16
  export type UiActionHandler = (args: UiActionArgs) => Promise<UiActionResult>;
15
17
  /**
16
18
  * 组织级界面刷新的内核 bus 主题(命名空间 `kernel`):`org-ui.<orgId>`。
@@ -32,15 +34,20 @@ export type UiInvalidateTarget = {
32
34
  scope: "platform";
33
35
  contribution: string;
34
36
  };
35
- /** 界面刷新消息:`conv.<id>`、`org-ui.<orgId>` 与 `platform-ui` 上的 `{ kind: "ui", plugin, contribution }`。 */
37
+ /**
38
+ * The UI refresh message on `conv.<id>`, `org-ui.<orgId>` and `platform-ui`:
39
+ * `{ kind: "ui", plugin, contribution, queries? }`. `queries: true` (every `ctx.ui.invalidate`)
40
+ * tells the web to refetch the contribution's component queries too (plugin full pages spec §4.1).
41
+ */
36
42
  export interface UiBusMessage {
37
43
  kind: "ui";
38
44
  plugin: string;
39
45
  contribution: string;
46
+ queries?: true;
40
47
  }
41
48
  /** 是否为界面刷新消息(bus 上的消息来自其他副本,按形状核对)。 */
42
49
  export declare function isUiBusMessage(m: unknown): m is UiBusMessage;
43
- /** SSE 帧 `event: ui`,数据 `{ plugin, contribution }`。 */
50
+ /** The SSE frame `event: ui`, data `{ plugin, contribution, queries? }`. */
44
51
  export declare const uiFrame: (m: UiBusMessage) => string;
45
52
  /**
46
53
  * 单个插件在 setup 期间注册的视图与动作:进程内的静态登记(同 `ctx.tools.register`),
@@ -58,7 +65,11 @@ export declare class PluginUiRegistration {
58
65
  private readonly deny;
59
66
  readonly views: Map<string, UiRender>;
60
67
  readonly actions: Map<string, UiActionHandler>;
68
+ /** Query handlers registered by `ctx.ui.query`, by component id. */
69
+ readonly queries: Map<string, UiQueryHandler>;
61
70
  private readonly declaredViews;
71
+ /** `permissions.ui.components`: the only ids `ctx.ui.query` accepts. */
72
+ private readonly declaredComponents;
62
73
  private readonly contributions;
63
74
  /** The ids of the manifest's `component` contributions: their permission is `ui.components`. */
64
75
  private readonly components;
@@ -69,10 +80,15 @@ export declare class PluginUiRegistration {
69
80
  * throws ExtensionPermissionError and writes an audit entry.
70
81
  */
71
82
  deny: (item: string) => never);
72
- /** setup 结束后调用:此后 view / action 抛错。 */
83
+ /** Called when setup ends: view / action / query throw from then on. */
73
84
  seal(): void;
74
85
  view(id: string, render: UiRender): void;
75
86
  action(id: string, handler: UiActionHandler): void;
87
+ /**
88
+ * The named queries of a component (`usePluginQuery`, served by `POST …/ui/query/:plugin/:id`):
89
+ * only an id in `permissions.ui.components`.
90
+ */
91
+ query(id: string, handler: UiQueryHandler): void;
76
92
  /**
77
93
  * 校验 invalidate 的目标。A contribution in `platform` (the ids of the extension's `platform.page`
78
94
  * contributions) takes no `orgId` and no `conversationId`; every other contribution needs an
@@ -26,8 +26,12 @@ export function isUiBusMessage(m) {
26
26
  const x = m;
27
27
  return x.kind === "ui" && typeof x.plugin === "string" && typeof x.contribution === "string";
28
28
  }
29
- /** SSE 帧 `event: ui`,数据 `{ plugin, contribution }`。 */
30
- export const uiFrame = (m) => `event: ui\ndata: ${JSON.stringify({ plugin: m.plugin, contribution: m.contribution })}\n\n`;
29
+ /** The SSE frame `event: ui`, data `{ plugin, contribution, queries? }`. */
30
+ export const uiFrame = (m) => `event: ui\ndata: ${JSON.stringify({
31
+ plugin: m.plugin,
32
+ contribution: m.contribution,
33
+ ...(m.queries === true && { queries: true }),
34
+ })}\n\n`;
31
35
  /**
32
36
  * 单个插件在 setup 期间注册的视图与动作:进程内的静态登记(同 `ctx.tools.register`),
33
37
  * 不是跨请求的共享状态——各副本加载同一插件得到同样的登记。
@@ -40,7 +44,11 @@ export class PluginUiRegistration {
40
44
  deny;
41
45
  views = new Map();
42
46
  actions = new Map();
47
+ /** Query handlers registered by `ctx.ui.query`, by component id. */
48
+ queries = new Map();
43
49
  declaredViews;
50
+ /** `permissions.ui.components`: the only ids `ctx.ui.query` accepts. */
51
+ declaredComponents;
44
52
  contributions;
45
53
  /** The ids of the manifest's `component` contributions: their permission is `ui.components`. */
46
54
  components;
@@ -55,10 +63,11 @@ export class PluginUiRegistration {
55
63
  this.deny = deny;
56
64
  const ui = manifest.permissions?.ui;
57
65
  this.declaredViews = new Set([...(ui?.views ?? []), ...(ui?.components ?? [])]);
66
+ this.declaredComponents = new Set(ui?.components ?? []);
58
67
  this.contributions = new Set((manifest.ui ?? []).map((c) => c.id));
59
68
  this.components = new Set((manifest.ui ?? []).filter((c) => c.kind === "component").map((c) => c.id));
60
69
  }
61
- /** setup 结束后调用:此后 view / action 抛错。 */
70
+ /** Called when setup ends: view / action / query throw from then on. */
62
71
  seal() {
63
72
  this.sealed = true;
64
73
  }
@@ -68,6 +77,13 @@ export class PluginUiRegistration {
68
77
  action(id, handler) {
69
78
  this.register("action", this.actions, id, handler);
70
79
  }
80
+ /**
81
+ * The named queries of a component (`usePluginQuery`, served by `POST …/ui/query/:plugin/:id`):
82
+ * only an id in `permissions.ui.components`.
83
+ */
84
+ query(id, handler) {
85
+ this.register("query", this.queries, id, handler, this.declaredComponents);
86
+ }
71
87
  /**
72
88
  * 校验 invalidate 的目标。A contribution in `platform` (the ids of the extension's `platform.page`
73
89
  * contributions) takes no `orgId` and no `conversationId`; every other contribution needs an
@@ -102,14 +118,16 @@ export class PluginUiRegistration {
102
118
  contribution: x.contribution,
103
119
  };
104
120
  }
105
- register(what, map, id, fn) {
121
+ register(what, map, id, fn, declared = this.declaredViews) {
106
122
  const name = this.manifest.name;
107
123
  if (this.sealed) {
108
124
  throw new Error(`plugin ${name}: ui.${what} is only allowed during setup; setup has completed`);
109
125
  }
110
- if (typeof id !== "string" || !this.declaredViews.has(id)) {
126
+ if (typeof id !== "string" || !declared.has(id)) {
111
127
  // name the list the id belongs in: a component's server view is declared under components
112
- const list = typeof id === "string" && this.components.has(id) ? "components" : "views";
128
+ const list = declared === this.declaredComponents || (typeof id === "string" && this.components.has(id))
129
+ ? "components"
130
+ : "views";
113
131
  this.deny(`permissions.ui.${list} ${String(id)}`);
114
132
  }
115
133
  if (typeof fn !== "function") {