@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
@@ -7,6 +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 { UI_CONTRIBUTION_KEY_RE } from "@capybara-hq/plugin-sdk";
10
11
  import { Inject, Injectable, Module, Optional } from "@nestjs/common";
11
12
  import { ModuleRef } from "@nestjs/core";
12
13
  import { z } from "zod";
@@ -14,7 +15,7 @@ import { readPlatformAttribution, } from "../attribution/platform-attribution.js
14
15
  import { DeviceProviderName } from "../devices/default-provider-setting.js";
15
16
  import { ApiError } from "../errors.js";
16
17
  import { audit } from "../identity/audit.js";
17
- import { COMPACTION_SETTINGS_PARTIAL, COMPACTION_SETTINGS_PATCH, readPlatformCompactionSettings, readPromptSuggestions, readSandboxLimitOverride, } from "../identity/settings.js";
18
+ import { COMPACTION_SETTINGS_PARTIAL, COMPACTION_SETTINGS_PATCH, PROMPT_CACHE_SETTINGS_PARTIAL, PROMPT_CACHE_SETTINGS_PATCH, readPlatformCompactionSettings, readPlatformPromptCacheSettings, readPromptSuggestions, readSandboxLimitOverride, } from "../identity/settings.js";
18
19
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
19
20
  import { KernelDb } from "../infra/database/kernel-db.js";
20
21
  import { TransactionHost, withOrderedLocks } from "../infra/database/transaction-host.js";
@@ -66,6 +67,8 @@ import { OrgLock, OrgLockModule } from "./org-lock.js";
66
67
  * absent (or an invalid stored value) = follow the platform, personal picks allowed.
67
68
  * - `uiArrangement`: per slot, the extension contributions the org hides and their order (UI slots
68
69
  * spec §5); a slot with no entry follows the platform's; an invalid stored value reads as absent.
70
+ * - `navigation`: where the org's plugin pages sit in the navigation (`pluginPages`: per contribution
71
+ * key the section an admin chose, at most 3 primary); absent follows each page's `nav` suggestion.
69
72
  * - `gitGateway`: the org's git gateway switch and host sources (sandbox git credentials spec §9);
70
73
  * not in the PATCH yet; an invalid stored value reads as `{ enabled: false }` (fails closed).
71
74
  */
@@ -94,22 +97,36 @@ export const DEFAULT_ORG_THEME = { id: null, personal: "allowed" };
94
97
  const posInt = (max, def) => z.number().int().min(1).max(max).default(def).catch(def);
95
98
  /** A stored `forbiddenTools` entry worth keeping: a tool key of the length the PATCH accepts. */
96
99
  const isForbiddenToolEntry = (v) => typeof v === "string" && v.length >= 1 && v.length <= 200;
100
+ /** A stored `eventSourcesOff` entry worth keeping: an extension name of the length the PATCH accepts. */
101
+ const isEventSourceEntry = (v) => typeof v === "string" && v.length >= 1 && v.length <= 214;
97
102
  /**
98
- * Org settings of scheduled tasks (spec §9); every field reads leniently (invalid = default,
103
+ * Org settings of automations (spec §9); every field reads leniently (invalid = default,
99
104
  * except `forbiddenTools`, which keeps its valid entries). A stored `forbiddenTools` that is not a
100
105
  * list (or a group that is not an object) reads as `[]` here, for display; enforcement checks
101
106
  * {@link invalidStoredForbiddenTools} and fails unattended runs instead (never wider).
102
107
  */
103
- export const ScheduledTasksSettingsSchema = z.object({
108
+ export const AutomationsSettingsSchema = z.object({
104
109
  enabled: z.boolean().default(true).catch(true),
105
110
  minIntervalMinutes: posInt(1_000_000, 60),
106
111
  maxTasksPerMember: posInt(1_000_000, 20),
107
112
  maxTasksPerOrg: posInt(1_000_000, 200),
113
+ // the runs one member's automations may start per hour (collaboration spec §4.7: per person)
108
114
  maxRunsPerHour: posInt(1_000_000, 60),
109
115
  defaultExpiryDays: z.number().int().min(1).max(36_500).nullable().default(null).catch(null),
110
116
  catchUpWindowMinutes: posInt(1_000_000, 60),
111
117
  unattendedAsk: z.enum(["fail", "wait"]).default("fail").catch("fail"),
112
118
  pauseAfterFailures: posInt(1000, 5),
119
+ // event automations (collaboration spec §4.7): the chain depth past which an event is stored
120
+ // but not dispatched, the window that coalesces one subject's events into one run, and how many
121
+ // runs (up to this many, not skipped) one automation may make for one subject per hour
122
+ maxEventDepth: posInt(1000, 8),
123
+ coalesceSeconds: posInt(86_400, 30),
124
+ maxEventRunsPerSubjectPerHour: posInt(1_000_000, 12),
125
+ // the trigger sources (extension names) whose events fire no automation of the org; an invalid
126
+ // entry is dropped, the valid ones stay off
127
+ eventSourcesOff: z
128
+ .preprocess((v) => (Array.isArray(v) ? v.filter(isEventSourceEntry).slice(0, 200) : v), z.array(z.string()).max(200).default([]))
129
+ .catch([]),
113
130
  // fail-safe: an invalid entry is dropped, the valid ones stay forbidden (never reset to []);
114
131
  // past the PATCH's 500 the list is truncated
115
132
  forbiddenTools: z
@@ -120,7 +137,7 @@ export const ScheduledTasksSettingsSchema = z.object({
120
137
  * The PATCH form: a partial merge into the group (fields left out keep their stored value; see
121
138
  * `OrgSettingsService.update`). A field given replaces that field whole, `forbiddenTools` too.
122
139
  */
123
- export const ScheduledTasksPatchSchema = z
140
+ export const AutomationsPatchSchema = z
124
141
  .object({
125
142
  enabled: z.boolean(),
126
143
  minIntervalMinutes: z.number().int().min(1).max(1_000_000),
@@ -131,6 +148,10 @@ export const ScheduledTasksPatchSchema = z
131
148
  catchUpWindowMinutes: z.number().int().min(1).max(1_000_000),
132
149
  unattendedAsk: z.enum(["fail", "wait"]),
133
150
  pauseAfterFailures: z.number().int().min(1).max(1000),
151
+ maxEventDepth: z.number().int().min(1).max(1000),
152
+ coalesceSeconds: z.number().int().min(1).max(86_400),
153
+ maxEventRunsPerSubjectPerHour: z.number().int().min(1).max(1_000_000),
154
+ eventSourcesOff: z.array(z.string().min(1).max(214)).max(200),
134
155
  forbiddenTools: z.array(z.string().min(1).max(200)).max(500),
135
156
  })
136
157
  .partial()
@@ -147,6 +168,31 @@ export const GitGatewaySettingSchema = z.object({
147
168
  });
148
169
  /** What an invalid stored `gitGateway` reads as: the gateway off for the org. */
149
170
  export const GIT_GATEWAY_INVALID = { enabled: false };
171
+ /** At most this many plugin pages in the primary navigation (plugin full pages spec §9). */
172
+ export const NAV_PRIMARY_MAX = 3;
173
+ /**
174
+ * The org's placement of plugin pages in the navigation (plugin full pages spec §9): per
175
+ * contribution key `<plugin>/<id>` the section an org admin chose. A page with no entry follows
176
+ * the contribution's `nav` suggestion (default `more`). Replaced whole by the PATCH; at most
177
+ * {@link NAV_PRIMARY_MAX} entries with section `primary`.
178
+ */
179
+ export const NavigationSettingSchema = z
180
+ .object({
181
+ pluginPages: z
182
+ .array(z
183
+ .object({
184
+ contribution: z
185
+ .string()
186
+ .regex(UI_CONTRIBUTION_KEY_RE, "must be a contribution key <plugin>/<id>"),
187
+ section: z.enum(["primary", "more"]),
188
+ })
189
+ .strict())
190
+ .max(200)
191
+ .refine((l) => new Set(l.map((e) => e.contribution)).size === l.length, {
192
+ message: "a contribution is listed once",
193
+ }),
194
+ })
195
+ .strict();
150
196
  const ExternalSharingSetting = z.enum(["on", "off"]);
151
197
  const PromptSuggestionsSetting = z.enum(["on", "off"]);
152
198
  /** Whether prompt suggestions run for an org: the platform is on and the org has not turned it off. */
@@ -173,15 +219,19 @@ export const OrgSettingsSchema = z.object({
173
219
  theme: OrgThemeSettingSchema.optional().catch(undefined),
174
220
  /** Hidden and ordered extension contributions per slot; absent = follow the platform. */
175
221
  uiArrangement: UiArrangementSchema.optional().catch(undefined),
222
+ /** Where the org's plugin pages sit in the navigation; absent = follow the suggestions. */
223
+ navigation: NavigationSettingSchema.optional().catch(undefined),
176
224
  /** The org's git gateway switch and host sources; absent = on, sources chosen by default. */
177
225
  gitGateway: GitGatewaySettingSchema.optional().catch({ ...GIT_GATEWAY_INVALID }),
178
- /** Scheduled tasks (spec §9); the platform bounds clamp it, see `effectiveScheduleSettings`. */
179
- scheduledTasks: ScheduledTasksSettingsSchema.prefault({}).catch(ScheduledTasksSettingsSchema.parse({})),
226
+ /** Automations (spec §9); the platform bounds clamp it, see `effectiveAutomationSettings`. */
227
+ automations: AutomationsSettingsSchema.prefault({}).catch(AutomationsSettingsSchema.parse({})),
180
228
  /**
181
229
  * Conversation compaction overrides (context compaction spec §4.8): every field given wins, the
182
230
  * rest follow the platform; absent (or an invalid stored value) follows the platform entirely.
183
231
  */
184
232
  compaction: COMPACTION_SETTINGS_PARTIAL.optional().catch(undefined),
233
+ /** Prompt cache override (idle compaction spec): absent or invalid follows the platform. */
234
+ promptCache: PROMPT_CACHE_SETTINGS_PARTIAL.optional().catch(undefined),
185
235
  /**
186
236
  * The org's external sharing switch (file sharing spec §8); absent = off. An invalid stored
187
237
  * value reads as `off` (never wider). The platform's switch must allow it too.
@@ -197,7 +247,7 @@ export const OrgSettingsSchema = z.object({
197
247
  const viewOf = (settings, raw) => invalidStoredForbiddenTools(raw)
198
248
  ? {
199
249
  ...settings,
200
- scheduledTasks: { ...settings.scheduledTasks, forbiddenToolsUnreadable: true },
250
+ automations: { ...settings.automations, forbiddenToolsUnreadable: true },
201
251
  }
202
252
  : settings;
203
253
  /** PATCH 体:只改给出的字段;未知字段 → 400。 */
@@ -237,14 +287,21 @@ export const OrgSettingsPatchSchema = z
237
287
  * null removes a slot's entry (it follows the platform again). `platform.page` is refused.
238
288
  */
239
289
  uiArrangement: OrgUiArrangementPatchSchema.optional(),
240
- /** Fields to change in the scheduled-tasks group; the rest keep their value. */
241
- scheduledTasks: ScheduledTasksPatchSchema.optional(),
290
+ /**
291
+ * Where the org's plugin pages sit in the navigation, replaced whole; null clears it (every
292
+ * page follows its suggestion). More than 3 primary -> 400 `org_settings.nav_primary_limit`.
293
+ */
294
+ navigation: NavigationSettingSchema.nullable().optional(),
295
+ /** Fields to change in the automations group; the rest keep their value. */
296
+ automations: AutomationsPatchSchema.optional(),
242
297
  /**
243
298
  * Conversation compaction overrides (context compaction spec §4.8): a partial object merges
244
299
  * into the stored fields (absent fields keep their value); null clears the whole override
245
300
  * (follow the platform again). Strict: a misspelled field is a 400, not a silent no-op.
246
301
  */
247
302
  compaction: COMPACTION_SETTINGS_PATCH.nullable().optional(),
303
+ /** Prompt cache override: a partial object merges; null clears it (follow the platform). */
304
+ promptCache: PROMPT_CACHE_SETTINGS_PATCH.nullable().optional(),
248
305
  /**
249
306
  * The org's external sharing switch; null clears it (off). `on` while the platform denies it
250
307
  * -> 400 `org.external_sharing_not_allowed`; through the Platform tool or an API token it may
@@ -324,13 +381,13 @@ export function invalidStoredSandboxToolPolicy(raw) {
324
381
  return v !== undefined && !OrgSettingsPatchSchema.shape.sandboxToolPolicy.safeParse(v).success;
325
382
  }
326
383
  /**
327
- * Whether the stored scheduled-task `forbiddenTools` cannot be read: the group or the field is
384
+ * Whether the stored automation `forbiddenTools` cannot be read: the group or the field is
328
385
  * present but not an object / a list. Unattended runs of such an org fail
329
386
  * ({@link FORBIDDEN_TOOLS_UNREADABLE_ERROR}) rather than run with nothing forbidden. Invalid
330
387
  * entries inside a list are dropped instead (the valid ones stay forbidden).
331
388
  */
332
389
  export function invalidStoredForbiddenTools(raw) {
333
- const group = asObject(raw).scheduledTasks;
390
+ const group = asObject(raw).automations;
334
391
  if (group === undefined)
335
392
  return false;
336
393
  if (group === null || typeof group !== "object" || Array.isArray(group))
@@ -339,9 +396,9 @@ export function invalidStoredForbiddenTools(raw) {
339
396
  return v !== undefined && !Array.isArray(v);
340
397
  }
341
398
  /** The refusal of an unattended run of an org whose `forbiddenTools` cannot be read. */
342
- export const FORBIDDEN_TOOLS_UNREADABLE_ERROR = "The organization's forbidden tool list for scheduled tasks is unreadable, so this scheduled run cannot continue; an org admin must save the list again in the organization's scheduled task settings.";
399
+ export const FORBIDDEN_TOOLS_UNREADABLE_ERROR = "The organization's forbidden tool list for automations is unreadable, so this scheduled run cannot continue; an org admin must save the list again in the organization's automation settings.";
343
400
  /** The refusal of a new task grant while the org's `forbiddenTools` cannot be read. */
344
- export const FORBIDDEN_TOOLS_UNREADABLE_GRANT_ERROR = "The organization's forbidden tool list for scheduled tasks is unreadable, so no tool can be approved for a task now; an org admin must save the list again in the organization's scheduled task settings.";
401
+ export const FORBIDDEN_TOOLS_UNREADABLE_GRANT_ERROR = "The organization's forbidden tool list for automations is unreadable, so no tool can be approved for a task now; an org admin must save the list again in the organization's automation settings.";
345
402
  /**
346
403
  * Logs (through `log`, at the caller's level) the security settings a stored value reads narrower
347
404
  * than written, with the org id.
@@ -351,7 +408,7 @@ export function logUnreadableSecuritySettings(log, orgId, raw) {
351
408
  log("org settings: stored sandboxToolPolicy is invalid; it reads as ask", { orgId });
352
409
  }
353
410
  if (invalidStoredForbiddenTools(raw)) {
354
- log("org settings: stored scheduledTasks.forbiddenTools is unreadable; unattended runs fail until an org admin saves it again", { orgId });
411
+ log("org settings: stored automations.forbiddenTools is unreadable; unattended runs fail until an org admin saves it again", { orgId });
355
412
  }
356
413
  }
357
414
  const outsideSandboxNotAllowed = (message) => new ApiError("org.outside_sandbox_not_allowed", message);
@@ -479,10 +536,11 @@ let OrgSettingsService = class OrgSettingsService {
479
536
  /** The deployment defaults (what "follow the platform" means on the settings page). */
480
537
  async deployment() {
481
538
  const lim = this.config.get().sandbox.limits;
482
- const [deviceSandbox, attribution, compaction, externalSharing, shareMaxExpiry, promptSuggestions,] = await Promise.all([
539
+ const [deviceSandbox, attribution, compaction, promptCache, externalSharing, shareMaxExpiry, promptSuggestions,] = await Promise.all([
483
540
  readDeviceSandboxSettingsView(this.db.db, this.config, this.log),
484
541
  readPlatformAttribution(this.db.db, this.config, this.log),
485
542
  readPlatformCompactionSettings(this.db.db),
543
+ readPlatformPromptCacheSettings(this.db.db),
486
544
  readExternalSharing(this.db.db, this.config, this.log),
487
545
  readShareMaxExpiry(this.db.db, this.config, this.log),
488
546
  readPromptSuggestions(this.db.db, this.log),
@@ -498,6 +556,7 @@ let OrgSettingsService = class OrgSettingsService {
498
556
  attribution,
499
557
  publicUrl: this.config.get().http.publicUrl !== undefined,
500
558
  compaction,
559
+ promptCache,
501
560
  externalSharing,
502
561
  shareMaxExpiryDays: shareMaxExpiry.value,
503
562
  promptSuggestions,
@@ -569,6 +628,10 @@ let OrgSettingsService = class OrgSettingsService {
569
628
  throw networkNotAllowed(`The platform limits device networks to the allowlist, so the organization's network ${field} cannot be open; a super admin sets devices.network.ceiling`, field);
570
629
  }
571
630
  }
631
+ const primary = patch.navigation?.pluginPages.filter((e) => e.section === "primary").length;
632
+ if (primary !== undefined && primary > NAV_PRIMARY_MAX) {
633
+ throw new ApiError("org_settings.nav_primary_limit", `At most ${NAV_PRIMARY_MAX} plugin pages can be in the primary navigation`, [{ path: "navigation.pluginPages" }]);
634
+ }
572
635
  if (patch.externalSharing === "on") {
573
636
  const platform = await readExternalSharing(this.db.db, this.config, this.log);
574
637
  if (platform.value !== "allow") {
@@ -693,14 +756,16 @@ let OrgSettingsService = class OrgSettingsService {
693
756
  .map(([k, v]) => [k, v === null ? undefined : v]));
694
757
  const arrangementPatch = patch.uiArrangement;
695
758
  const compactionPatch = patch.compaction;
759
+ const promptCachePatch = patch.promptCache;
760
+ delete changes.promptCache;
696
761
  delete changes.uiArrangement;
697
- delete changes.scheduledTasks;
762
+ delete changes.automations;
698
763
  delete changes.compaction;
699
764
  const after = { ...before, ...changes };
700
- if (patch.scheduledTasks !== undefined) {
701
- after.scheduledTasks = ScheduledTasksSettingsSchema.parse({
702
- ...before.scheduledTasks,
703
- ...Object.fromEntries(Object.entries(patch.scheduledTasks).filter(([, v]) => v !== undefined)),
765
+ if (patch.automations !== undefined) {
766
+ after.automations = AutomationsSettingsSchema.parse({
767
+ ...before.automations,
768
+ ...Object.fromEntries(Object.entries(patch.automations).filter(([, v]) => v !== undefined)),
704
769
  });
705
770
  }
706
771
  if (compactionPatch !== undefined) {
@@ -710,6 +775,12 @@ let OrgSettingsService = class OrgSettingsService {
710
775
  else
711
776
  after.compaction = { ...before.compaction, ...compactionPatch };
712
777
  }
778
+ if (promptCachePatch !== undefined) {
779
+ if (promptCachePatch === null)
780
+ delete after.promptCache;
781
+ else
782
+ after.promptCache = { ...before.promptCache, ...promptCachePatch };
783
+ }
713
784
  if (arrangementPatch !== undefined) {
714
785
  after.uiArrangement = mergeArrangement(before.uiArrangement, arrangementPatch);
715
786
  if (Object.keys(after.uiArrangement).length === 0)
@@ -734,6 +805,8 @@ let OrgSettingsService = class OrgSettingsService {
734
805
  delete after.theme;
735
806
  if (after.uiArrangement === undefined)
736
807
  delete after.uiArrangement;
808
+ if (after.navigation === undefined)
809
+ delete after.navigation;
737
810
  if (after.gitGateway === undefined)
738
811
  delete after.gitGateway;
739
812
  // an empty compaction override is the same as none: follow the platform
@@ -742,12 +815,17 @@ let OrgSettingsService = class OrgSettingsService {
742
815
  }
743
816
  if (after.compaction === undefined)
744
817
  delete after.compaction;
818
+ if (after.promptCache !== undefined && Object.keys(after.promptCache).length === 0) {
819
+ delete after.promptCache;
820
+ }
821
+ if (after.promptCache === undefined)
822
+ delete after.promptCache;
745
823
  if (after.externalSharing === undefined)
746
824
  delete after.externalSharing;
747
825
  if (after.promptSuggestions === undefined)
748
826
  delete after.promptSuggestions;
749
827
  // saving an unreadable security setting writes it even when it equals what it read as
750
- const repairs = (invalidStoredForbiddenTools(stored) && patch.scheduledTasks?.forbiddenTools !== undefined) ||
828
+ const repairs = (invalidStoredForbiddenTools(stored) && patch.automations?.forbiddenTools !== undefined) ||
751
829
  (invalidStoredSandboxToolPolicy(stored) && patch.sandboxToolPolicy !== undefined);
752
830
  if (!repairs && sameSettings(before, after))
753
831
  return viewOf(before, stored);
@@ -758,15 +836,15 @@ let OrgSettingsService = class OrgSettingsService {
758
836
  }
759
837
  // Merge with the stored value: keep the keys this version does not know (a cleared
760
838
  // outsideSandbox / deviceNetwork is not kept; the old keys are rewritten in step)
761
- const { autoMode: _legacyAutoMode, fullAccess: _legacyFullAccess, cloudNetwork: _legacyNetwork, outsideSandbox: _oldOutside, deviceNetwork: _oldNetwork, deviceDefaultProvider: _oldDeviceProvider, wakeOnBackgroundTask: _oldWake, timeZone: _oldZone, theme: _oldTheme, uiArrangement: _oldArrangement, scheduledTasks: _oldScheduled, compaction: _oldCompaction, externalSharing: _oldExternalSharing, promptSuggestions: _oldPromptSuggestions, ...rest } = stored;
839
+ const { autoMode: _legacyAutoMode, fullAccess: _legacyFullAccess, cloudNetwork: _legacyNetwork, outsideSandbox: _oldOutside, deviceNetwork: _oldNetwork, deviceDefaultProvider: _oldDeviceProvider, wakeOnBackgroundTask: _oldWake, timeZone: _oldZone, theme: _oldTheme, uiArrangement: _oldArrangement, navigation: _oldNavigation, automations: _oldAutomations, compaction: _oldCompaction, promptCache: _oldPromptCache, externalSharing: _oldExternalSharing, promptSuggestions: _oldPromptSuggestions, ...rest } = stored;
762
840
  const written = { ...rest, ...after };
763
841
  keepOrgLegacyKeysInStep(written, stored);
764
842
  // An unreadable forbiddenTools reads as [] for display only: a write that does not replace the
765
843
  // list keeps it unreadable (never healed to "nothing forbidden"); saving the list fixes it
766
- if (invalidStoredForbiddenTools(stored) && patch.scheduledTasks?.forbiddenTools === undefined) {
767
- const group = asObject(stored.scheduledTasks);
768
- written.scheduledTasks = {
769
- ...after.scheduledTasks,
844
+ if (invalidStoredForbiddenTools(stored) && patch.automations?.forbiddenTools === undefined) {
845
+ const group = asObject(stored.automations);
846
+ written.automations = {
847
+ ...after.automations,
770
848
  forbiddenTools: group.forbiddenTools ?? null,
771
849
  };
772
850
  }
@@ -193,22 +193,43 @@ export const PLATFORM_EXCLUSIONS = [
193
193
  reason: "Confirms a staged plugin review (reached by the link card of the staged plugin), a trust decision by the person",
194
194
  },
195
195
  // channels
196
- // attachments
196
+ // files (the composer's upload helpers; list, details, usage, add and delete are operations)
197
197
  {
198
- route: "GET /api/v1/orgs/:orgId/attachments/limits",
198
+ route: "GET /api/v1/orgs/:orgId/files/limits",
199
199
  category: "internal",
200
- reason: "The composer's size check for a person's file into a conversation; an agent gets files by file reference, not by attaching",
200
+ reason: "The composer's size check for a person's file into a conversation; an agent gets files by file reference, not by uploading",
201
201
  },
202
202
  {
203
- route: "POST /api/v1/orgs/:orgId/attachments",
203
+ route: "DELETE /api/v1/orgs/:orgId/files/:id/draft",
204
204
  category: "internal",
205
- reason: "Registers a person's file into a conversation from the composer; an agent gets files by file reference (fileId), not through attachments",
205
+ reason: "Composer housekeeping: drops a draft the person removed before sending; an agent never holds a draft",
206
206
  },
207
207
  {
208
- route: "POST /api/v1/orgs/:orgId/attachments/:id/finalize",
209
- category: "internal",
210
- reason: "Finishes a person's file into a conversation from the composer; an agent gets files by file reference (fileId), not through attachments",
208
+ route: "GET /api/v1/orgs/:orgId/files/:id/content",
209
+ category: "transport",
210
+ reason: "Serves a library file's text bytes for the Files page's preview",
211
211
  },
212
+ {
213
+ route: "GET /api/v1/orgs/:orgId/files/:id/download",
214
+ category: "transport",
215
+ reason: "Serves a library file's bytes",
216
+ },
217
+ {
218
+ route: "GET /api/v1/orgs/:orgId/files/:id/previewers",
219
+ category: "transport",
220
+ reason: "Previewer lookup feeding the Files page's viewer",
221
+ },
222
+ {
223
+ route: "GET /api/v1/orgs/:orgId/files/:id/previews/:plugin/:previewerId",
224
+ category: "transport",
225
+ reason: "Serves a rendered library file preview",
226
+ },
227
+ {
228
+ route: "POST /api/v1/orgs/:orgId/files/:id/html-token",
229
+ category: "transport",
230
+ reason: "Mints the HTML document's load token for the Files page",
231
+ },
232
+ // attachments
212
233
  {
213
234
  route: "GET /api/v1/orgs/:orgId/attachments/:id/download",
214
235
  category: "transport",
@@ -356,6 +377,17 @@ export const PLATFORM_EXCLUSIONS = [
356
377
  category: "internal",
357
378
  reason: "The right panel's per-file view; conversations.list-shares lists the same shares",
358
379
  },
380
+ // shares of library files (file library spec §6)
381
+ {
382
+ route: "POST /api/v1/orgs/:orgId/files/:fileId/shares",
383
+ category: "human-only",
384
+ reason: "Publishing a file outside the library is a person's act",
385
+ },
386
+ {
387
+ route: "GET /api/v1/orgs/:orgId/files/:fileId/shares",
388
+ category: "internal",
389
+ reason: "The Files page's share dialog; conversations.list-shares lists the same shares",
390
+ },
359
391
  // the HTML document (file sharing spec §4, §10)
360
392
  {
361
393
  route: "POST /api/v1/orgs/:orgId/conversations/:id/files/:fileId/html-token",
@@ -703,6 +735,11 @@ export const PLATFORM_EXCLUSIONS = [
703
735
  category: "transport",
704
736
  reason: "Runs an extension UI action from the web app",
705
737
  },
738
+ {
739
+ route: "POST /api/v1/orgs/:orgId/ui/query/:plugin/:id",
740
+ category: "transport",
741
+ reason: "the web's channel for plugin components; agents use the plugin's tools",
742
+ },
706
743
  {
707
744
  route: "POST /api/v1/orgs/:orgId/ui/embeds/:plugin/:id/token",
708
745
  category: "transport",
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { AttachmentsService } from "../conversations/attachments.service.js";
3
+ import { ReferencedFiles } from "../files/referenced-files.js";
3
4
  import { KernelDb } from "../infra/database/kernel-db.js";
4
- import { StorageService } from "../storage/storage.service.js";
5
5
  /**
6
6
  * File references (platform web parity spec §5): a `Platform` write the web does with an upload
7
7
  * takes a file the agent already has instead, a conversation file (`fileId`: an attachment, a
@@ -22,6 +22,14 @@ export declare const FileRefSchema: z.ZodType<FileRef>;
22
22
  export interface FileLimits {
23
23
  maxBytes: number;
24
24
  contentTypes?: readonly string[];
25
+ /** A lower byte limit per content type (normalized), e.g. images smaller than documents. */
26
+ typeMaxBytes?: Readonly<Record<string, number>>;
27
+ /**
28
+ * `true`: a library file of an account other than the context's `actorAccountId` is refused
29
+ * ({@link OTHERS_FILE_TEXT}): a file has one owner (file library spec §2). A `read` copy is no
30
+ * library file and stays allowed.
31
+ */
32
+ ownFilesOnly?: boolean;
25
33
  }
26
34
  /** A resolved reference: the bytes and what the card shows of them. */
27
35
  export interface ResolvedFile {
@@ -48,6 +56,8 @@ export interface FileRefContext {
48
56
  conversationId: string;
49
57
  /** The root of the conversation tree, from the call's context. */
50
58
  rootConversationId: string;
59
+ /** The account the call acts as (checked by {@link FileLimits.ownFilesOnly}). */
60
+ actorAccountId?: string;
51
61
  signal: AbortSignal;
52
62
  }
53
63
  /** Ruling R9: the thumbnail's longest edge, quality and the most the data URL may take. */
@@ -63,6 +73,8 @@ export declare const THUMBNAIL_MAX_INPUT_PIXELS = 40000000;
63
73
  export declare const fileTooLargeText: (size: number, max: number) => string;
64
74
  /** Model-visible: the referenced file's type is not one the operation takes. */
65
75
  export declare const fileTypeText: (contentType: string, types: readonly string[]) => string;
76
+ /** Model-visible: the referenced library file is another account's ({@link FileLimits.ownFilesOnly}). */
77
+ export declare const OTHERS_FILE_TEXT = "This file belongs to another person; ask them to add it to their files.";
66
78
  /** Model-visible: the bytes at run time differ from the ones the person confirmed. */
67
79
  export declare const FILE_CHANGED_TEXT = "The file changed after the person confirmed it; call the operation again.";
68
80
  /** The card's view of a resolved file, with a thumbnail for an image (R9). */
@@ -83,8 +95,11 @@ export declare function thumbnailOf(file: Pick<ResolvedFile, "contentType" | "by
83
95
  export declare class FileRefs {
84
96
  private readonly db;
85
97
  private readonly attachments;
86
- private readonly storage;
87
- constructor(db: KernelDb, attachments: AttachmentsService, storage: StorageService);
98
+ /** The library files the conversation set refers to (file library spec §2). */
99
+ private readonly files;
100
+ constructor(db: KernelDb, attachments: AttachmentsService,
101
+ /** The library files the conversation set refers to (file library spec §2). */
102
+ files: ReferencedFiles);
88
103
  resolve(ref: FileRef, limits: FileLimits, ctx: FileRefContext): Promise<ResolvedFile>;
89
104
  private conversationFile;
90
105
  }
@@ -13,8 +13,8 @@ import { Inject, Injectable } from "@nestjs/common";
13
13
  import sharp from "sharp";
14
14
  import { z } from "zod";
15
15
  import { AttachmentsService, normalizeContentType, sniffMatches, } from "../conversations/attachments.service.js";
16
+ import { ReferencedFiles } from "../files/referenced-files.js";
16
17
  import { KernelDb } from "../infra/database/kernel-db.js";
17
- import { StorageService } from "../storage/storage.service.js";
18
18
  import { findConversationFile } from "../tools/builtins/conversation-files.js";
19
19
  /** Model-visible: a device path where a file reference is expected. */
20
20
  export const FILE_REF_PATH_TEXT = "Deliver the file first, then pass its fileId.";
@@ -44,6 +44,8 @@ const THUMBNAIL_TYPES = new Set(["image/png", "image/jpeg", "image/webp", "image
44
44
  export const fileTooLargeText = (size, max) => `The file is ${size} bytes; this operation takes at most ${max}.`;
45
45
  /** Model-visible: the referenced file's type is not one the operation takes. */
46
46
  export const fileTypeText = (contentType, types) => `The file is ${contentType}; this operation takes ${types.join(", ")}.`;
47
+ /** Model-visible: the referenced library file is another account's ({@link FileLimits.ownFilesOnly}). */
48
+ export const OTHERS_FILE_TEXT = "This file belongs to another person; ask them to add it to their files.";
47
49
  /** Model-visible: the bytes at run time differ from the ones the person confirmed. */
48
50
  export const FILE_CHANGED_TEXT = "The file changed after the person confirmed it; call the operation again.";
49
51
  const notFoundText = (id) => `File ${id} is not a file of this conversation. Pass the id of an attachment, a generated image or a delivered file of this conversation, or Deliver a device file first and pass its fileId.`;
@@ -100,11 +102,13 @@ export async function thumbnailOf(file) {
100
102
  let FileRefs = class FileRefs {
101
103
  db;
102
104
  attachments;
103
- storage;
104
- constructor(db, attachments, storage) {
105
+ files;
106
+ constructor(db, attachments,
107
+ /** The library files the conversation set refers to (file library spec §2). */
108
+ files) {
105
109
  this.db = db;
106
110
  this.attachments = attachments;
107
- this.storage = storage;
111
+ this.files = files;
108
112
  }
109
113
  async resolve(ref, limits, ctx) {
110
114
  const got = await this.conversationFile(ref.fileId, limits, ctx);
@@ -119,7 +123,7 @@ let FileRefs = class FileRefs {
119
123
  }
120
124
  async conversationFile(id, limits, ctx) {
121
125
  const db = this.db.db;
122
- const file = await findConversationFile({ db, attachments: this.attachments, storage: this.storage }, {
126
+ const file = await findConversationFile({ db, attachments: this.attachments, files: this.files }, {
123
127
  orgId: ctx.orgId,
124
128
  conversationId: ctx.conversationId,
125
129
  rootConversationId: ctx.rootConversationId,
@@ -130,20 +134,27 @@ let FileRefs = class FileRefs {
130
134
  });
131
135
  if (file === null)
132
136
  throw new ToolError(notFoundText(id));
133
- if (file.size > limits.maxBytes) {
137
+ if (limits.ownFilesOnly === true &&
138
+ file.accountId !== undefined &&
139
+ file.accountId !== ctx.actorAccountId) {
134
140
  await file.discard();
135
- throw new ToolError(fileTooLargeText(file.size, limits.maxBytes));
141
+ throw new ToolError(OTHERS_FILE_TEXT);
136
142
  }
137
143
  const types = limits.contentTypes;
138
144
  const declared = normalizeContentType(file.contentType);
145
+ const max = Math.min(limits.maxBytes, limits.typeMaxBytes?.[declared] ?? limits.maxBytes);
146
+ if (file.size > max) {
147
+ await file.discard();
148
+ throw new ToolError(fileTooLargeText(file.size, max));
149
+ }
139
150
  if (types !== undefined && !types.includes(declared)) {
140
151
  await file.discard();
141
152
  throw new ToolError(fileTypeText(declared, types));
142
153
  }
143
- const bytes = await file.open({ maxBytes: limits.maxBytes + 1 });
144
- if (bytes.byteLength > limits.maxBytes) {
154
+ const bytes = await file.open({ maxBytes: max + 1 });
155
+ if (bytes.byteLength > max) {
145
156
  await file.discard();
146
- throw new ToolError(fileTooLargeText(bytes.byteLength, limits.maxBytes));
157
+ throw new ToolError(fileTooLargeText(bytes.byteLength, max));
147
158
  }
148
159
  // the bytes must be what the type says (the upload routes sniff the same way)
149
160
  if (types !== undefined && !sniffMatches(declared, bytes.subarray(0, 4096))) {
@@ -157,6 +168,6 @@ FileRefs = __decorate([
157
168
  Injectable(),
158
169
  __param(0, Inject(KernelDb)),
159
170
  __param(1, Inject(AttachmentsService)),
160
- __param(2, Inject(StorageService))
171
+ __param(2, Inject(ReferencedFiles))
161
172
  ], FileRefs);
162
173
  export { FileRefs };
@@ -47,6 +47,10 @@ export const PLATFORM_DOMAINS = [
47
47
  id: "conversations",
48
48
  description: "Your own conversations: list, read, rename, archive, delete, read their events, list and stop their background tasks, list and revoke shared file links.",
49
49
  },
50
+ {
51
+ id: "files",
52
+ description: "Your file library (uploads and the files agents delivered to you): list, read, storage usage, adding a file of this conversation, and asking to delete one (the person confirms on the Files page).",
53
+ },
50
54
  {
51
55
  id: "orgs",
52
56
  description: "This org (read, rename, members and invitations, its audit log) and, for the super admin, every org and its limits.",
@@ -92,8 +96,8 @@ export const PLATFORM_DOMAINS = [
92
96
  description: "Your own cloud devices (the workspaces your conversations run in): list, read, create, rename, narrow the sandbox network, delete, wipe the files.",
93
97
  },
94
98
  {
95
- id: "schedules",
96
- description: "Your scheduled tasks (an agent runs a prompt on a schedule, as you, unattended): list, read, create, edit, pause, resume, delete, run now or as a trial, run history, and the tools approved for a task.",
99
+ id: "automations",
100
+ description: "Your automations (an agent runs a prompt on a schedule, as you, unattended): list, read, create, edit, pause, resume, delete, run now or as a trial, run history, and the tools approved for a task.",
97
101
  },
98
102
  {
99
103
  id: "setup",
@@ -52,6 +52,7 @@ const SettingsInput = DEPLOYMENT_SETTINGS_PATCH.pick({
52
52
  externalSharing: true,
53
53
  shareMaxExpiryDays: true,
54
54
  promptSuggestions: true,
55
+ promptCache: true,
55
56
  htmlRenderCdnAllowlist: true,
56
57
  }).strict();
57
58
  /** `login-sources.update`: the source and the fields to change. */
@@ -251,7 +252,7 @@ let AdminOperations = class AdminOperations {
251
252
  }),
252
253
  defineOperation({
253
254
  id: "admin.update-settings",
254
- description: "Change deployment settings (super admin); give only the keys to change: orgCreation (anyone or super_admin), priceCurrency (ISO 4217 code), customConnectors / customSkills (allow or deny: whether orgs may create their own instead of installing from the catalog), orgMarketplaceBrowse (true or false), uiTheme ({ id }: the platform default theme, a platform theme whose scope is all, or null for the built-in theme; it is what every org falls back to and what the sign-in pages show), uiArrangement ({ <slot>: { hidden, order } } for a list slot, { <slot>: { use } } for a single slot: the platform default arrangement of UI slots, with contribution keys <extension>/<contribution>; hidden ones are not listed but still open by URL; use names the contribution that replaces the built-in, null for the built-in; null for a slot removes its entry), clientExtensions ({ enabled?, disabled? }: the kill switch of plugin client code; enabled false stops every plugin's interface code in every browser, disabled is the whole list of plugins whose interface code alone is stopped while their tools keep working; read the current list from admin.settings first), devicesOutsideSandbox ({ permission }: whether a device may be granted running a call outside its sandbox, allowed or off; null clears it back to the default, allowed; through this tool it may only be turned off, never allowed, and a value set in the startup config is read-only), devicesNetwork ({ default?, ceiling? }: the device sandbox network, open or allowlist; null clears a field back to the default, open; the default may not be above the ceiling; through this tool either may only be narrowed to allowlist, never opened, and a field set in the startup config is read-only), devicesDefaultProvider ({ provider }: the device provider extension that makes a person's default device; null clears it back to none; read-only when set in the startup config), attribution ({ commit?, pr?, sessionUrl? }: the platform's defaults for agent-created git commits and pull requests; null clears a field back to its default, an empty string turns that line off, and fields set in the startup config are read-only), externalSharing (allow or deny: whether orgs may turn on public links to conversation files; null clears it back to the default, deny; externalSharing may only be turned off through this tool, and a value set in the startup config is read-only), shareMaxExpiryDays (1 to 365: the longest expiry a share may take, in days; null clears it back to 30; through this tool it may only be lowered, never raised, and it is read-only when set in the startup config), htmlRenderCdnAllowlist (the whole list of https origins, scheme and host with an optional port and nothing else, that a rendered HTML file may load from; at most 50; through this tool origins may only be removed, never added, so read the current list from admin.settings first and send it without the ones to drop). promptSuggestions (on or off; null clears it, absent meaning on: whether the composer suggests the person's next message after a completed run; an org's own promptSuggestions must be on too) may be set either way. Per-org limits are orgs.set-limits.",
255
+ description: "Change deployment settings (super admin); give only the keys to change: orgCreation (anyone or super_admin), priceCurrency (ISO 4217 code), customConnectors / customSkills (allow or deny: whether orgs may create their own instead of installing from the catalog), orgMarketplaceBrowse (true or false), uiTheme ({ id }: the platform default theme, a platform theme whose scope is all, or null for the built-in theme; it is what every org falls back to and what the sign-in pages show), uiArrangement ({ <slot>: { hidden, order } } for a list slot, { <slot>: { use } } for a single slot: the platform default arrangement of UI slots, with contribution keys <extension>/<contribution>; hidden ones are not listed but still open by URL; use names the contribution that replaces the built-in, null for the built-in; null for a slot removes its entry), clientExtensions ({ enabled?, disabled? }: the kill switch of plugin client code; enabled false stops every plugin's interface code in every browser, disabled is the whole list of plugins whose interface code alone is stopped while their tools keep working; read the current list from admin.settings first), devicesOutsideSandbox ({ permission }: whether a device may be granted running a call outside its sandbox, allowed or off; null clears it back to the default, allowed; through this tool it may only be turned off, never allowed, and a value set in the startup config is read-only), devicesNetwork ({ default?, ceiling? }: the device sandbox network, open or allowlist; null clears a field back to the default, open; the default may not be above the ceiling; through this tool either may only be narrowed to allowlist, never opened, and a field set in the startup config is read-only), devicesDefaultProvider ({ provider }: the device provider extension that makes a person's default device; null clears it back to none; read-only when set in the startup config), attribution ({ commit?, pr?, sessionUrl? }: the platform's defaults for agent-created git commits and pull requests; null clears a field back to its default, an empty string turns that line off, and fields set in the startup config are read-only), externalSharing (allow or deny: whether orgs may turn on public links to conversation files; null clears it back to the default, deny; externalSharing may only be turned off through this tool, and a value set in the startup config is read-only), shareMaxExpiryDays (1 to 365: the longest expiry a share may take, in days; null clears it back to 30; through this tool it may only be lowered, never raised, and it is read-only when set in the startup config), htmlRenderCdnAllowlist (the whole list of https origins, scheme and host with an optional port and nothing else, that a rendered HTML file may load from; at most 50; through this tool origins may only be removed, never added, so read the current list from admin.settings first and send it without the ones to drop). promptSuggestions (on or off; null clears it, absent meaning on: whether the composer suggests the person's next message after a completed run; an org's own promptSuggestions must be on too) may be set either way. promptCache ({ longTtl }: true or false; whether requests use the model's prompt cache tier of at least 30 minutes, such as 1 hour, where cache writes cost more; an org may override it) may be set either way. Per-org limits are orgs.set-limits.",
255
256
  input: SettingsInput.refine((b) => Object.keys(b).length > 0, {
256
257
  message: "at least one setting is required",
257
258
  }),
@@ -315,7 +316,7 @@ let AdminOperations = class AdminOperations {
315
316
  });
316
317
  },
317
318
  summary: async (i) => {
318
- const { uiTheme, uiArrangement, clientExtensions, devicesOutsideSandbox, devicesNetwork, devicesDefaultProvider, attribution, htmlRenderCdnAllowlist, ...rest } = i;
319
+ const { uiTheme, uiArrangement, clientExtensions, devicesOutsideSandbox, devicesNetwork, devicesDefaultProvider, attribution, htmlRenderCdnAllowlist, promptCache, ...rest } = i;
319
320
  const parts = Object.entries(rest).map(([k, v]) => `${k}=${String(v)}`);
320
321
  if (htmlRenderCdnAllowlist !== undefined) {
321
322
  parts.push(`htmlRenderCdnAllowlist=[${htmlRenderCdnAllowlist.join(", ")}]`);
@@ -330,6 +331,8 @@ let AdminOperations = class AdminOperations {
330
331
  }
331
332
  if (devicesDefaultProvider !== undefined)
332
333
  parts.push(`devicesDefaultProvider=${String(devicesDefaultProvider.provider)}`);
334
+ if (promptCache?.longTtl !== undefined)
335
+ parts.push(`promptCache.longTtl=${String(promptCache.longTtl)}`);
333
336
  const zh = [...parts];
334
337
  const en = [...parts];
335
338
  if (attribution !== undefined) {
@@ -1,18 +1,18 @@
1
1
  import { type OnModuleInit } from "@nestjs/common";
2
- import { ScheduledTasksService } from "../../schedules/scheduled-tasks.service.js";
2
+ import { AutomationsService } from "../../automations/automations.service.js";
3
3
  import { PlatformOperations } from "../registry.js";
4
4
  /**
5
- * Scheduled-task operations of the `Platform` tool (scheduled tasks spec §10): the same service
5
+ * Automation operations of the `Platform` tool (scheduled tasks spec §10): the same service
6
6
  * as the HTTP routes. Writes are `personal`. Creating or changing a task and its approved tools
7
7
  * are never remembered (`rememberable: false`): an approval, remembered or granted to a task,
8
8
  * must never let an unattended run create or widen a task. Delete, run and resume are never
9
9
  * remembered either. List, pause and delete are `org.read` like their routes: a creator demoted
10
10
  * to guest can still see and stop their own tasks (the service decides by ownership).
11
11
  */
12
- export declare class SchedulesOperations implements OnModuleInit {
12
+ export declare class AutomationsOperations implements OnModuleInit {
13
13
  private readonly registry;
14
14
  private readonly tasks;
15
- constructor(registry: PlatformOperations, tasks: ScheduledTasksService);
15
+ constructor(registry: PlatformOperations, tasks: AutomationsService);
16
16
  /** The caller as the service expects (it reads the live role itself). */
17
17
  private actor;
18
18
  /** The task's name for a card; its id when it cannot be read. */