@capybara-hq/kernel 0.1.0-rc.106 → 0.1.0-rc.108

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 (190) hide show
  1. package/bootstrap.json +13 -13
  2. package/dist/admin/admin.schemas.d.ts +3 -0
  3. package/dist/catalog/marketplaces.service.d.ts +1 -1
  4. package/dist/channels/channels.module.js +4 -3
  5. package/dist/channels/file-delivery.d.ts +26 -11
  6. package/dist/channels/file-delivery.js +32 -11
  7. package/dist/channels/outbound.d.ts +3 -3
  8. package/dist/channels/outbound.js +15 -13
  9. package/dist/config/schema.d.ts +3 -0
  10. package/dist/config/schema.js +12 -0
  11. package/dist/conversations/artifacts.d.ts +20 -17
  12. package/dist/conversations/artifacts.js +30 -37
  13. package/dist/conversations/attachments.controller.d.ts +6 -19
  14. package/dist/conversations/attachments.controller.js +8 -59
  15. package/dist/conversations/attachments.service.d.ts +30 -74
  16. package/dist/conversations/attachments.service.js +51 -193
  17. package/dist/conversations/conversations.module.js +4 -0
  18. package/dist/conversations/conversations.service.d.ts +10 -9
  19. package/dist/conversations/conversations.service.js +28 -11
  20. package/dist/conversations/event-log.d.ts +1 -0
  21. package/dist/conversations/events.d.ts +49 -27
  22. package/dist/conversations/events.js +54 -7
  23. package/dist/conversations/files.d.ts +66 -64
  24. package/dist/conversations/files.js +127 -147
  25. package/dist/conversations/prompt-suggestion-request.js +2 -1
  26. package/dist/conversations/prompt-suggestions.d.ts +3 -3
  27. package/dist/conversations/prompt-suggestions.js +11 -10
  28. package/dist/conversations/queue.service.js +7 -2
  29. package/dist/ctx/create-ctx.d.ts +3 -1
  30. package/dist/ctx/create-ctx.js +19 -1
  31. package/dist/db/kernel-schema.d.ts +80 -2
  32. package/dist/errors.d.ts +19 -0
  33. package/dist/errors.js +19 -0
  34. package/dist/evals/canonical-json.d.ts +7 -0
  35. package/dist/evals/canonical-json.js +21 -0
  36. package/dist/evals/reconstruct.js +13 -1
  37. package/dist/evals/recorded-tools.d.ts +0 -2
  38. package/dist/evals/recorded-tools.js +1 -16
  39. package/dist/evals/snapshot.d.ts +26 -3
  40. package/dist/evals/snapshot.js +110 -57
  41. package/dist/evals/worker.d.ts +4 -3
  42. package/dist/evals/worker.js +8 -4
  43. package/dist/extensions/host.d.ts +3 -1
  44. package/dist/extensions/host.js +2 -0
  45. package/dist/extensions/instance.d.ts +3 -1
  46. package/dist/extensions/instance.js +4 -0
  47. package/dist/extensions/ledger.d.ts +1 -1
  48. package/dist/files/blob-objects.d.ts +124 -0
  49. package/dist/files/blob-objects.js +341 -0
  50. package/dist/files/blob-sweep.job.d.ts +122 -0
  51. package/dist/files/blob-sweep.job.js +389 -0
  52. package/dist/files/blobs.service.d.ts +135 -0
  53. package/dist/files/blobs.service.js +300 -0
  54. package/dist/files/conversation-media.d.ts +41 -0
  55. package/dist/files/conversation-media.js +124 -0
  56. package/dist/files/deliveries.d.ts +64 -0
  57. package/dist/files/deliveries.js +156 -0
  58. package/dist/files/deliveries.module.d.ts +6 -0
  59. package/dist/files/deliveries.module.js +24 -0
  60. package/dist/files/draft-cleanup.job.d.ts +26 -0
  61. package/dist/files/draft-cleanup.job.js +93 -0
  62. package/dist/files/files.module.d.ts +1 -1
  63. package/dist/files/files.module.js +3 -2
  64. package/dist/files/hash-job.d.ts +127 -0
  65. package/dist/files/hash-job.js +447 -0
  66. package/dist/files/library-backfill.d.ts +63 -0
  67. package/dist/files/library-backfill.js +143 -0
  68. package/dist/files/library-files.service.d.ts +255 -0
  69. package/dist/files/library-files.service.js +883 -0
  70. package/dist/files/library-jobs.module.d.ts +8 -0
  71. package/dist/files/library-jobs.module.js +27 -0
  72. package/dist/files/library-query.d.ts +127 -0
  73. package/dist/files/library-query.js +322 -0
  74. package/dist/files/library-read.module.d.ts +9 -0
  75. package/dist/files/library-read.module.js +30 -0
  76. package/dist/files/library.controller.d.ts +77 -0
  77. package/dist/files/library.controller.js +235 -0
  78. package/dist/files/library.module.d.ts +9 -0
  79. package/dist/files/library.module.js +29 -0
  80. package/dist/files/library.schemas.d.ts +46 -0
  81. package/dist/files/library.schemas.js +49 -0
  82. package/dist/files/previewers.controller.d.ts +20 -0
  83. package/dist/files/previewers.controller.js +47 -0
  84. package/dist/files/previewers.d.ts +25 -11
  85. package/dist/files/previewers.js +43 -27
  86. package/dist/files/referenced-files.d.ts +150 -0
  87. package/dist/files/referenced-files.js +234 -0
  88. package/dist/html/html-document.controller.d.ts +8 -1
  89. package/dist/html/html-document.controller.js +19 -1
  90. package/dist/html/html-document.service.d.ts +19 -4
  91. package/dist/html/html-document.service.js +43 -22
  92. package/dist/html/html-token.d.ts +10 -1
  93. package/dist/html/html-token.js +14 -0
  94. package/dist/html/html.module.js +8 -1
  95. package/dist/http/api.module.js +5 -0
  96. package/dist/identity/settings.d.ts +26 -0
  97. package/dist/identity/settings.js +33 -2
  98. package/dist/infra/outbox/registry.d.ts +82 -0
  99. package/dist/infra/outbox/registry.js +74 -2
  100. package/dist/infra/throttler/named-throttlers.d.ts +2 -0
  101. package/dist/infra/throttler/named-throttlers.js +14 -0
  102. package/dist/lifecycle/kernel-lifecycle.js +6 -0
  103. package/dist/models/purposes.js +1 -1
  104. package/dist/orgs/offboarding.js +1 -1
  105. package/dist/orgs/settings.service.d.ts +48 -2
  106. package/dist/orgs/settings.service.js +63 -3
  107. package/dist/platform/exclusions.js +45 -8
  108. package/dist/platform/file-ref.d.ts +18 -3
  109. package/dist/platform/file-ref.js +22 -11
  110. package/dist/platform/operation.js +4 -0
  111. package/dist/platform/ops/admin.ops.js +5 -2
  112. package/dist/platform/ops/files.ops.d.ts +18 -0
  113. package/dist/platform/ops/files.ops.js +267 -0
  114. package/dist/platform/ops/org-settings.ops.js +6 -2
  115. package/dist/platform/ops/orgs.ops.js +1 -0
  116. package/dist/platform/ops/shares.ops.js +2 -2
  117. package/dist/platform/platform-ops.module.d.ts +2 -1
  118. package/dist/platform/platform-ops.module.js +5 -0
  119. package/dist/platform/route-schemas.js +3 -0
  120. package/dist/roles/worker.module.js +15 -1
  121. package/dist/runtime/compaction-settings.service.d.ts +13 -1
  122. package/dist/runtime/compaction-settings.service.js +16 -1
  123. package/dist/runtime/compaction.service.d.ts +3 -1
  124. package/dist/runtime/compaction.service.js +3 -1
  125. package/dist/runtime/context/build.d.ts +18 -1
  126. package/dist/runtime/context/build.js +19 -8
  127. package/dist/runtime/context/cache-expiry.d.ts +31 -0
  128. package/dist/runtime/context/cache-expiry.js +60 -0
  129. package/dist/runtime/context/cache-ttl.d.ts +18 -0
  130. package/dist/runtime/context/cache-ttl.js +30 -0
  131. package/dist/runtime/context/compaction.d.ts +9 -2
  132. package/dist/runtime/context/compaction.js +50 -17
  133. package/dist/runtime/context/in-context-compaction.d.ts +156 -0
  134. package/dist/runtime/context/in-context-compaction.js +310 -0
  135. package/dist/runtime/hook-calls.d.ts +2 -1
  136. package/dist/runtime/hook-calls.js +5 -2
  137. package/dist/runtime/maintenance.d.ts +10 -2
  138. package/dist/runtime/maintenance.js +48 -8
  139. package/dist/runtime/model-call.d.ts +34 -5
  140. package/dist/runtime/model-call.js +207 -22
  141. package/dist/runtime/providers.js +11 -1
  142. package/dist/runtime/run-steps.d.ts +4 -2
  143. package/dist/runtime/run-steps.js +10 -5
  144. package/dist/runtime/runtime.module.js +3 -0
  145. package/dist/shares/liveness.d.ts +26 -12
  146. package/dist/shares/liveness.js +79 -20
  147. package/dist/shares/revoke.d.ts +16 -11
  148. package/dist/shares/revoke.js +18 -14
  149. package/dist/shares/share-objects.d.ts +16 -21
  150. package/dist/shares/share-objects.js +25 -55
  151. package/dist/shares/share-open.service.d.ts +8 -4
  152. package/dist/shares/share-open.service.js +14 -11
  153. package/dist/shares/shares.controller.d.ts +16 -5
  154. package/dist/shares/shares.controller.js +39 -5
  155. package/dist/shares/shares.module.d.ts +4 -4
  156. package/dist/shares/shares.module.js +7 -6
  157. package/dist/shares/shares.schemas.d.ts +4 -0
  158. package/dist/shares/shares.schemas.js +2 -0
  159. package/dist/shares/shares.service.d.ts +93 -54
  160. package/dist/shares/shares.service.js +292 -131
  161. package/dist/shares/sweep.job.d.ts +18 -39
  162. package/dist/shares/sweep.job.js +47 -206
  163. package/dist/tools/builtins/artifacts.d.ts +21 -13
  164. package/dist/tools/builtins/artifacts.js +81 -51
  165. package/dist/tools/builtins/builtin-tools.d.ts +7 -1
  166. package/dist/tools/builtins/builtin-tools.js +17 -6
  167. package/dist/tools/builtins/conversation-files.d.ts +23 -13
  168. package/dist/tools/builtins/conversation-files.js +62 -83
  169. package/dist/tools/builtins/image/generate.d.ts +7 -1
  170. package/dist/tools/builtins/image/generate.js +1 -1
  171. package/dist/tools/builtins/platform.js +1 -0
  172. package/dist/tools/builtins/sandbox/common.d.ts +6 -2
  173. package/dist/tools/builtins/sandbox/deliver.js +6 -7
  174. package/dist/tools/builtins/sandbox/fetch-attachment.d.ts +6 -5
  175. package/dist/tools/builtins/sandbox/fetch-attachment.js +19 -12
  176. package/dist/tools/tools.module.js +6 -0
  177. package/dist/ui/call-extension.d.ts +6 -4
  178. package/dist/ui/call-extension.js +5 -4
  179. package/dist/ui/embed-token.js +6 -3
  180. package/dist/ui/registry.d.ts +21 -5
  181. package/dist/ui/registry.js +24 -6
  182. package/dist/ui/ui.schemas.d.ts +22 -0
  183. package/dist/ui/ui.schemas.js +22 -4
  184. package/dist/ui/views.controller.d.ts +13 -3
  185. package/dist/ui/views.controller.js +33 -2
  186. package/dist/ui/views.d.ts +29 -1
  187. package/dist/ui/views.js +131 -7
  188. package/package.json +3 -3
  189. package/src/migrations/0190_file_library.sql +285 -0
  190. package/src/migrations/0191_file_library_copy.sql +4 -0
package/bootstrap.json CHANGED
@@ -3,15 +3,15 @@
3
3
  "schemaVersion": 1,
4
4
  "marketplace": {
5
5
  "url": "https://github.com/capybara-hq/plugins.git",
6
- "commit": "87ca221485218c947d592a6642e441620f1f27cc"
6
+ "commit": "5ace2e570721d3ab278f7fd2bffc3d40ec88503a"
7
7
  },
8
8
  "plugins": [
9
9
  {
10
10
  "name": "openai-compatible",
11
11
  "source": "npm",
12
12
  "npm": "@capybara-hq/plugin-openai-compatible",
13
- "version": "0.1.0-rc.14",
14
- "integrity": "sha512-BbB4lSBy4kEZA2kLOBDz00oOOjmQ4IaPPthmho00M15ZGcvDRMTuilw+244lbYPALZ3Kxzo1zNPWFI8STqUyDw==",
13
+ "version": "0.1.0-rc.15",
14
+ "integrity": "sha512-GwDNf+46SwFdDOodWGJokorOWQCvO+0QJx5NhsXChWCnpezmLFiXxgmIuG2V1KNQnRSCvH1SJBUE5EsOTFRvKA==",
15
15
  "required": false
16
16
  },
17
17
  {
@@ -26,40 +26,40 @@
26
26
  "name": "anthropic",
27
27
  "source": "npm",
28
28
  "npm": "@capybara-hq/plugin-anthropic",
29
- "version": "0.1.0-rc.11",
30
- "integrity": "sha512-du0wCj2z3asIZk1mpDOBAtlZSmqB1WQTr8doHb8uPSKGCqfkcCgSVrJWP8dbqW//BHO8un0uWLs74TBvk+f9ug==",
29
+ "version": "0.1.0-rc.12",
30
+ "integrity": "sha512-ABCkExMaGJUxcbDClv2mip931CmQGvbPcy9KV73vYEWUFGf/chU9I1irEKItIbx0I/yJRG1144GkpO3hfcmGrQ==",
31
31
  "required": false
32
32
  },
33
33
  {
34
34
  "name": "openai",
35
35
  "source": "npm",
36
36
  "npm": "@capybara-hq/plugin-openai",
37
- "version": "0.1.0-rc.14",
38
- "integrity": "sha512-Ybde3qfkz0PruixbxzgxrlVYTahz2eplRj4ioeTP20yFQcoPTLbm5hoBuj64nZTKlvTtmYQ+gvK6ofYUWY2NTw==",
37
+ "version": "0.1.0-rc.15",
38
+ "integrity": "sha512-D6iGu0lJMoXxHAPubBxPdF7NK8qxZhzF4DP27fI3p2oA3OvEaysQlU3EhMiGYgB31zjl9dqJMjIgVBaXHL711Q==",
39
39
  "required": false
40
40
  },
41
41
  {
42
42
  "name": "deepseek",
43
43
  "source": "npm",
44
44
  "npm": "@capybara-hq/plugin-deepseek",
45
- "version": "0.1.0-rc.12",
46
- "integrity": "sha512-bDl3SWO/SO23PaY7Jc9km79kctaGYKqjWOTaXcb+olJNHCNwP4lEXuAY7jylBMaDxL3WttWdHDS6c/QjHFbUeA==",
45
+ "version": "0.1.0-rc.13",
46
+ "integrity": "sha512-i6cPL8gTGCvPRdC5UzlKnJdYjrGfPUQHrpdJDp8q8cekMu6GReJQHBFb5dt3U+zlUfOX75IwoIlTPfeJwr/ACg==",
47
47
  "required": false
48
48
  },
49
49
  {
50
50
  "name": "bailian",
51
51
  "source": "npm",
52
52
  "npm": "@capybara-hq/plugin-bailian",
53
- "version": "0.1.0-rc.13",
54
- "integrity": "sha512-TglGdOPeJTUVSxm+KQOdWDrxRnjhFVEatvfQFVkSwOElxocNyEFBm7K3GSQmmuY2ISgxJQceA7Yvjlb0JNpKiA==",
53
+ "version": "0.1.0-rc.14",
54
+ "integrity": "sha512-m1e6FaD0ouHq/2vJkyQPyj3pz4PH7QpYNRlftOJYBaKve8EqKGz/uH44UGBtI+tROmDhdnZ5xn3FFlyyQIYCkA==",
55
55
  "required": false
56
56
  },
57
57
  {
58
58
  "name": "ark",
59
59
  "source": "npm",
60
60
  "npm": "@capybara-hq/plugin-ark",
61
- "version": "0.1.0-rc.14",
62
- "integrity": "sha512-sMyvv8eTeOHnR5WzxRxdYCXMnIn3uiS1kQokSFvojWy8Jk70t/kqMshUgisL+Tl8g3C0SFGwJYqvonWK+NI2jQ==",
61
+ "version": "0.1.0-rc.15",
62
+ "integrity": "sha512-IgsN+PARqkaO6wt5ndM+28UESleVEp0btmH/rUvNAsWp47IghYObGOikYkjHWVlWTApuFefKLkro+fKsS5HHPQ==",
63
63
  "required": false
64
64
  },
65
65
  {
@@ -89,6 +89,9 @@ export declare const DeploymentSettingsBody: z.ZodObject<{
89
89
  reserveTokens: z.ZodOptional<z.ZodNumber>;
90
90
  maxOutputTokens: z.ZodOptional<z.ZodNumber>;
91
91
  }, z.core.$strict>>;
92
+ promptCache: z.ZodOptional<z.ZodObject<{
93
+ longTtl: z.ZodOptional<z.ZodBoolean>;
94
+ }, z.core.$strict>>;
92
95
  externalSharing: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
93
96
  allow: "allow";
94
97
  deny: "deny";
@@ -208,7 +208,7 @@ export declare function headsToResolve(entries: readonly MarketplaceEntry[], imp
208
208
  /** The host versions (an entry's `minKernel` is judged against them). */
209
209
  export declare const HOST_VERSIONS: {
210
210
  readonly kernel: string;
211
- readonly sdk: "0.1.0-rc.85";
211
+ readonly sdk: "0.1.0-rc.86";
212
212
  };
213
213
  /** Whether this deployment satisfies the entry's `minKernel`. */
214
214
  export declare const entryCompatible: (e: Pick<MarketplaceEntry, "minKernel">) => boolean;
@@ -16,6 +16,7 @@ import { ConversationsModule } from "../conversations/conversations.module.js";
16
16
  import { EventLogModule } from "../conversations/event-log.js";
17
17
  import { DevicesModule } from "../devices/devices.module.js";
18
18
  import { ExtensionsModule } from "../extensions/extensions.module.js";
19
+ import { LibraryFilesModule } from "../files/library.module.js";
19
20
  import { IdentityModule } from "../identity/identity.module.js";
20
21
  import { configuredProcessor, } from "../infra/queue/configured-processor.js";
21
22
  import { QueueModule } from "../infra/queue/queue.module.js";
@@ -23,7 +24,6 @@ import { runJob } from "../infra/queue/run-job.js";
23
24
  import { OrgLockModule } from "../orgs/org-lock.js";
24
25
  import { OrgsModule } from "../orgs/orgs.module.js";
25
26
  import { RuntimeModule } from "../runtime/runtime.module.js";
26
- import { StorageModule } from "../storage/storage.module.js";
27
27
  import { ToolsModule } from "../tools/tools.module.js";
28
28
  import { ChannelConnections } from "./connections.service.js";
29
29
  import { ChannelInbound } from "./inbound.js";
@@ -55,8 +55,9 @@ ChannelsModule = __decorate([
55
55
  RuntimeModule,
56
56
  // outbound pauses the automation of a run whose chat is gone (scheduled tasks spec §8)
57
57
  AutomationsModule,
58
- // outbound reads conversation files to send them into the chat (channel file delivery §4.2)
59
- StorageModule,
58
+ // outbound reads conversation files from their blobs to send them into the chat (channel
59
+ // file delivery §4.2, file library spec §4)
60
+ LibraryFilesModule,
60
61
  CHANNEL_QUEUE_MODULE,
61
62
  ],
62
63
  providers: [
@@ -1,5 +1,7 @@
1
- import { type Channel, type ObjectStore } from "@capybara-hq/plugin-sdk";
1
+ import { type Channel, type ObjectHead } from "@capybara-hq/plugin-sdk";
2
2
  import type { ConversationEvent } from "../conversations/events.js";
3
+ import type { KernelSchemaDb } from "../db/kernel-schema.js";
4
+ import type { BlobRef } from "../files/blobs.service.js";
3
5
  import { type ChannelLocale } from "./phrases.js";
4
6
  type ArtifactPayload = Extract<ConversationEvent, {
5
7
  type: "artifact_created";
@@ -11,16 +13,18 @@ export type FileDeliveryPlan = {
11
13
  cap: number;
12
14
  } | {
13
15
  mode: "link";
14
- reason: "unsupported" | "disabled" | "too_large" | "empty" | "foreign_key";
16
+ reason: "unsupported" | "disabled" | "too_large" | "empty" | "unreferenced";
15
17
  };
16
18
  /**
17
- * Decides native upload or a link line for one artifact. Order: a key outside the conversation's
18
- * `artifacts/<conversationId>/` prefix, an empty file, a channel without `sendFile`, the deployment
19
- * switch (`fileMaxBytes` 0), then the size cap (the smaller of the channel's and the deployment's).
19
+ * Decides native upload or a link line for one artifact. Order: a file the conversation does not
20
+ * reference ({@link referencedBlob}: file library spec §4), an empty file, a channel without
21
+ * `sendFile`, the deployment switch (`fileMaxBytes` 0), then the size cap (the smaller of the
22
+ * channel's and the deployment's).
20
23
  */
21
24
  export declare function planFileDelivery(input: {
22
- conversationId: string;
23
- artifact: Pick<ArtifactPayload, "objectKey" | "size" | "contentType">;
25
+ /** Whether the conversation references the artifact's file (a ready file on a ready blob). */
26
+ referenced: boolean;
27
+ artifact: Pick<ArtifactPayload, "size" | "contentType">;
24
28
  features: Channel["features"];
25
29
  canSendFile: boolean;
26
30
  fileMaxBytes: number;
@@ -48,6 +52,12 @@ export declare function fileLinkText(input: {
48
52
  }): string;
49
53
  /** The root message text of a native file delivery. */
50
54
  export declare function fileRootText(name: string, locale: ChannelLocale): string;
55
+ /**
56
+ * The blob of the file `fileId` when the conversation references it (a `conversation_files` row
57
+ * in the org) and both the file and its blob are ready; null otherwise. A channel sends only
58
+ * such a file (file library spec §4 "Channel delivery").
59
+ */
60
+ export declare function referencedBlob(db: KernelSchemaDb, orgId: string, conversationId: string, fileId: string): Promise<BlobRef | null>;
51
61
  export type CappedRead = {
52
62
  kind: "ok";
53
63
  data: Uint8Array;
@@ -58,12 +68,17 @@ export type CappedRead = {
58
68
  } | {
59
69
  kind: "unavailable";
60
70
  };
71
+ /** Opens the bytes to read: null when they are gone (a blob read checks size and etag). */
72
+ export type OpenBytes = (signal: AbortSignal) => Promise<{
73
+ head: ObjectHead;
74
+ body: ReadableStream<Uint8Array>;
75
+ } | null>;
61
76
  /**
62
- * Reads an object into memory, never more than `cap` bytes: a larger head, or a body that passes
63
- * `cap` while streaming, is `too_large` (the body is cancelled). A missing object is `missing`, a
64
- * store that is not there `unavailable`; any other error is rethrown (retryable).
77
+ * Reads bytes into memory, never more than `cap` bytes: a larger head, or a body that passes
78
+ * `cap` while streaming, is `too_large` (the body is cancelled). Bytes that are gone are
79
+ * `missing`, a store that is not there `unavailable`; any other error is rethrown (retryable).
65
80
  */
66
- export declare function readArtifactCapped(store: ObjectStore, key: string, cap: number, signal: AbortSignal): Promise<CappedRead>;
81
+ export declare function readArtifactCapped(open: OpenBytes, cap: number, signal: AbortSignal): Promise<CappedRead>;
67
82
  /** A counting semaphore with a FIFO of waiters; one per worker replica (not a provider). */
68
83
  export declare class FileSlots {
69
84
  private free;
@@ -3,15 +3,15 @@ import { isStorageUnavailable } from "../storage/storage.service.js";
3
3
  import { conversationUrl } from "./cards.js";
4
4
  import { phrase } from "./phrases.js";
5
5
  /**
6
- * Decides native upload or a link line for one artifact. Order: a key outside the conversation's
7
- * `artifacts/<conversationId>/` prefix, an empty file, a channel without `sendFile`, the deployment
8
- * switch (`fileMaxBytes` 0), then the size cap (the smaller of the channel's and the deployment's).
6
+ * Decides native upload or a link line for one artifact. Order: a file the conversation does not
7
+ * reference ({@link referencedBlob}: file library spec §4), an empty file, a channel without
8
+ * `sendFile`, the deployment switch (`fileMaxBytes` 0), then the size cap (the smaller of the
9
+ * channel's and the deployment's).
9
10
  */
10
11
  export function planFileDelivery(input) {
11
12
  const { artifact, features, fileMaxBytes } = input;
12
- if (!artifact.objectKey.startsWith(`artifacts/${input.conversationId}/`)) {
13
- return { mode: "link", reason: "foreign_key" };
14
- }
13
+ if (!input.referenced)
14
+ return { mode: "link", reason: "unreferenced" };
15
15
  if (artifact.size === 0)
16
16
  return { mode: "link", reason: "empty" };
17
17
  const files = features.files;
@@ -87,13 +87,34 @@ export function fileRootText(name, locale) {
87
87
  return fill(phrase("fileRoot", locale), { name: asCode(name), size: "", url: "" });
88
88
  }
89
89
  /**
90
- * Reads an object into memory, never more than `cap` bytes: a larger head, or a body that passes
91
- * `cap` while streaming, is `too_large` (the body is cancelled). A missing object is `missing`, a
92
- * store that is not there `unavailable`; any other error is rethrown (retryable).
90
+ * The blob of the file `fileId` when the conversation references it (a `conversation_files` row
91
+ * in the org) and both the file and its blob are ready; null otherwise. A channel sends only
92
+ * such a file (file library spec §4 "Channel delivery").
93
+ */
94
+ export async function referencedBlob(db, orgId, conversationId, fileId) {
95
+ const row = await db
96
+ .selectFrom("conversation_files as cf")
97
+ .innerJoin("files as f", (j) => j.onRef("f.id", "=", "cf.file_id").onRef("f.org_id", "=", "cf.org_id"))
98
+ .innerJoin("blobs as b", (j) => j.onRef("b.id", "=", "f.blob_id").onRef("b.org_id", "=", "cf.org_id"))
99
+ .select(["b.id", "b.object_key", "b.size", "b.etag"])
100
+ .where("cf.org_id", "=", orgId)
101
+ .where("cf.conversation_id", "=", conversationId)
102
+ .where("cf.file_id", "=", fileId)
103
+ .where("f.status", "=", "ready")
104
+ .where("b.status", "=", "ready")
105
+ .executeTakeFirst();
106
+ if (!row)
107
+ return null;
108
+ return { id: row.id, objectKey: row.object_key, size: Number(row.size), etag: row.etag };
109
+ }
110
+ /**
111
+ * Reads bytes into memory, never more than `cap` bytes: a larger head, or a body that passes
112
+ * `cap` while streaming, is `too_large` (the body is cancelled). Bytes that are gone are
113
+ * `missing`, a store that is not there `unavailable`; any other error is rethrown (retryable).
93
114
  */
94
- export async function readArtifactCapped(store, key, cap, signal) {
115
+ export async function readArtifactCapped(open, cap, signal) {
95
116
  try {
96
- const got = await store.get(key, { signal });
117
+ const got = await open(signal);
97
118
  if (got === null)
98
119
  return { kind: "missing" };
99
120
  const reader = got.body.getReader();
@@ -3,12 +3,12 @@ import { type Job, type Worker } from "bullmq";
3
3
  import { AutomationsService } from "../automations/automations.service.js";
4
4
  import { EventLog } from "../conversations/event-log.js";
5
5
  import type { KernelSchemaDb } from "../db/kernel-schema.js";
6
+ import { BlobsService } from "../files/blobs.service.js";
6
7
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
7
8
  import { KernelDb } from "../infra/database/kernel-db.js";
8
9
  import { TransactionHost } from "../infra/database/transaction-host.js";
9
10
  import { ConversationLock } from "../runtime/conversation-lock.js";
10
11
  import type { StreamBus } from "../runtime/stream.js";
11
- import { StorageService } from "../storage/storage.service.js";
12
12
  import { ApprovalsService } from "../tools/approvals.service.js";
13
13
  import { QuestionsService } from "../tools/questions.service.js";
14
14
  import { ToolRegistry } from "../tools/registry.js";
@@ -120,8 +120,8 @@ export declare class ChannelOutbound {
120
120
  inbound: Pick<ChannelInbound, "handle">, jobs: Pick<ChannelJobs, "enqueue" | "resumeConnection">, config: Pick<KernelConfigService, "get">, log: Pick<Logger, "error" | "warn" | "info">, txHost: TransactionHost,
121
121
  /** Pauses the task of a scheduled run whose chat is gone (scheduled tasks spec §8). */
122
122
  automations: Pick<AutomationsService, "pauseFor">,
123
- /** Conversation files sent into the chat (channel file delivery spec §4.2). */
124
- storage: Pick<StorageService, "kernel">);
123
+ /** The blobs of conversation files sent into the chat (channel file delivery spec §4.2). */
124
+ blobs: Pick<BlobsService, "open">);
125
125
  /**
126
126
  * Starts consuming (worker role only): `worker` is the `@Processor` worker of the channel queue
127
127
  * (its job lock and stalled detection follow the run queue's config).
@@ -17,13 +17,13 @@ import { productName } from "../config/product-name.js";
17
17
  import { conversationTopic, EventLog, } from "../conversations/event-log.js";
18
18
  import { recipientLocale } from "../conversations/message-context.js";
19
19
  import { ApiError } from "../errors.js";
20
+ import { BlobsService } from "../files/blobs.service.js";
20
21
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
21
22
  import { KernelDb } from "../infra/database/kernel-db.js";
22
23
  import { TransactionHost } from "../infra/database/transaction-host.js";
23
24
  import { Transactional } from "../infra/database/transactional.decorator.js";
24
25
  import { KERNEL_BUS, KERNEL_LOGGER } from "../infra/tokens.js";
25
26
  import { ConversationLock, } from "../runtime/conversation-lock.js";
26
- import { StorageService } from "../storage/storage.service.js";
27
27
  import { ApprovalsService } from "../tools/approvals.service.js";
28
28
  import { toolInfo } from "../tools/info.js";
29
29
  import { QuestionsService } from "../tools/questions.service.js";
@@ -31,7 +31,7 @@ import { ToolRegistry } from "../tools/registry.js";
31
31
  import { approvalCard, callSummary, cardMessage, connectUrl, conversationUrl, personFieldsCard, questionCard, webBase, } from "./cards.js";
32
32
  import { ChannelConnections, FILE_CALL_TIMEOUT_MS, } from "./connections.service.js";
33
33
  import { processDisplayOf, progressCardMessage } from "./features.js";
34
- import { FileSlots, fileKind, fileLinkText, fileRootText, planFileDelivery, pluginFileName, readArtifactCapped, } from "./file-delivery.js";
34
+ import { FileSlots, fileKind, fileLinkText, fileRootText, planFileDelivery, pluginFileName, readArtifactCapped, referencedBlob, } from "./file-delivery.js";
35
35
  import { ChannelInbound } from "./inbound.js";
36
36
  import { ChannelJobs, INBOUND_JOB, idempotencyKey, RESUME_JOB, } from "./jobs.js";
37
37
  import { phrase } from "./phrases.js";
@@ -195,8 +195,8 @@ let ChannelOutbound = class ChannelOutbound {
195
195
  inbound, jobs, config, log, txHost,
196
196
  /** Pauses the task of a scheduled run whose chat is gone (scheduled tasks spec §8). */
197
197
  automations,
198
- /** Conversation files sent into the chat (channel file delivery spec §4.2). */
199
- storage) {
198
+ /** The blobs of conversation files sent into the chat (channel file delivery spec §4.2). */
199
+ blobs) {
200
200
  this.kdb = kdb;
201
201
  this.inbound = inbound;
202
202
  this.jobs = jobs;
@@ -217,7 +217,7 @@ let ChannelOutbound = class ChannelOutbound {
217
217
  questions,
218
218
  config,
219
219
  log,
220
- storage,
220
+ blobs,
221
221
  // one per process: it bounds this replica's memory (not shared state)
222
222
  fileSlots: new FileSlots(config.get().channels.fileConcurrency),
223
223
  writes: this,
@@ -544,7 +544,7 @@ ChannelOutbound = __decorate([
544
544
  __param(11, Inject(KERNEL_LOGGER)),
545
545
  __param(12, Inject(TransactionHost)),
546
546
  __param(13, Inject(AutomationsService)),
547
- __param(14, Inject(StorageService))
547
+ __param(14, Inject(BlobsService))
548
548
  ], ChannelOutbound);
549
549
  export { ChannelOutbound };
550
550
  /** One `bind` card per handoff link, in one message (process blocks spec §6.2). */
@@ -1170,16 +1170,18 @@ class Delivery {
1170
1170
  */
1171
1171
  async deliverArtifact(e) {
1172
1172
  const a = e.payload;
1173
+ // the file the event created (its id is the artifact id; earlier events name no fileId)
1174
+ const blob = await referencedBlob(this.d.db, this.s.row.orgId, this.conversationId, a.fileId ?? a.artifactId);
1173
1175
  const plan = planFileDelivery({
1174
- conversationId: this.conversationId,
1176
+ referenced: blob !== null,
1175
1177
  artifact: a,
1176
1178
  features: this.s.features,
1177
1179
  canSendFile: this.s.sendFile !== undefined,
1178
1180
  fileMaxBytes: this.d.config.get().channels.fileMaxBytes,
1179
1181
  });
1180
- if (plan.mode === "link") {
1181
- if (plan.reason === "foreign_key") {
1182
- this.d.log.warn("channel file outside the conversation's artifacts sent as a link", {
1182
+ if (plan.mode === "link" || blob === null) {
1183
+ if (blob === null) {
1184
+ this.d.log.warn("channel file not referenced by the conversation sent as a link", {
1183
1185
  conversationId: this.conversationId,
1184
1186
  seq: e.seq,
1185
1187
  });
@@ -1198,7 +1200,7 @@ class Delivery {
1198
1200
  }
1199
1201
  let sent;
1200
1202
  try {
1201
- sent = await this.sendNative(e.seq, a, plan);
1203
+ sent = await this.sendNative(e.seq, a, blob, plan);
1202
1204
  }
1203
1205
  finally {
1204
1206
  release();
@@ -1211,7 +1213,7 @@ class Delivery {
1211
1213
  * Reads and sends one file while holding a file slot; false when the link line stands in for it
1212
1214
  * (see {@link deliverArtifact}).
1213
1215
  */
1214
- async sendNative(seq, a, plan) {
1216
+ async sendNative(seq, a, blob, plan) {
1215
1217
  // the replica stopped while this delivery waited for its slot: hand the job back untouched
1216
1218
  if (this.stopping.aborted)
1217
1219
  throw new DeliveryShutdownError();
@@ -1225,7 +1227,7 @@ class Delivery {
1225
1227
  let read;
1226
1228
  try {
1227
1229
  // the read stops with the replica: nothing has reached the platform yet
1228
- read = await readArtifactCapped(this.d.storage.kernel(this.s.row.orgId), a.objectKey, plan.cap, AbortSignal.any([this.stopping, AbortSignal.timeout(FILE_CALL_TIMEOUT_MS)]));
1230
+ read = await readArtifactCapped((signal) => this.d.blobs.open(this.s.row.orgId, blob, { signal }), plan.cap, AbortSignal.any([this.stopping, AbortSignal.timeout(FILE_CALL_TIMEOUT_MS)]));
1229
1231
  }
1230
1232
  catch (err) {
1231
1233
  if (this.stopping.aborted)
@@ -199,6 +199,9 @@ export declare const KernelConfigSchema: z.ZodObject<{
199
199
  storage: z.ZodDefault<z.ZodObject<{
200
200
  purgeDeletedOrgsAfterDays: z.ZodDefault<z.ZodNumber>;
201
201
  }, z.core.$strict>>;
202
+ files: z.ZodDefault<z.ZodObject<{
203
+ deletedRetentionDays: z.ZodDefault<z.ZodNumber>;
204
+ }, z.core.$strict>>;
202
205
  attachments: z.ZodPrefault<z.ZodObject<{
203
206
  maxBytes: z.ZodDefault<z.ZodNumber>;
204
207
  allowedTypes: z.ZodDefault<z.ZodArray<z.ZodString>>;
@@ -1164,6 +1164,18 @@ export const KernelConfigSchema = z.strictObject({
1164
1164
  })),
1165
1165
  })
1166
1166
  .default({ purgeDeletedOrgsAfterDays: 30 }),
1167
+ files: z
1168
+ .strictObject({
1169
+ deletedRetentionDays: z
1170
+ .number()
1171
+ .int()
1172
+ .positive()
1173
+ .default(30)
1174
+ .meta(meta({
1175
+ description: "Days a deleted file keeps its bytes before the blob sweep may delete them.",
1176
+ })),
1177
+ })
1178
+ .default({ deletedRetentionDays: 30 }),
1167
1179
  attachments: z
1168
1180
  .strictObject({
1169
1181
  maxBytes: z
@@ -1,4 +1,4 @@
1
- import { KernelDb } from "../infra/database/kernel-db.js";
1
+ import { ReferencedFiles } from "../files/referenced-files.js";
2
2
  import { StorageService } from "../storage/storage.service.js";
3
3
  import { ConversationAccess } from "./access.js";
4
4
  /** 产物下载跳转的预签名有效期(秒)。 */
@@ -20,27 +20,30 @@ export interface ArtifactPreview {
20
20
  truncated: boolean;
21
21
  }
22
22
  /**
23
- * 产物(M5 T8 / T11):agent 经 `Deliver` 交付的文件。先按会话流的规则判定会话可见
24
- * (不可见 → `conversation.not_found`),再只在这个会话的日志里找 `artifact_created`
25
- * (没有 → `conversation.artifact_not_found`)。
23
+ * A conversation's files by id (M5 T8 / T11; file library spec §2): any file the conversation
24
+ * refers to (a delivery or an upload sent in it). The conversation must be visible by the event
25
+ * stream's rule (else `conversation.not_found`); the file must be one the conversation refers to,
26
+ * not deleted, its blob readable (else `conversation.artifact_not_found`). Bytes are read through
27
+ * the file's blob (size and etag checked), never an event's `objectKey`.
26
28
  *
27
- * - 下载:302 到预签名地址,默认 `attachment`(带交付时的文件名与类型);`inline` 只对位图生效
28
- * (网页的缩略图),其余类型即使要求 inline 也仍是 `attachment`。
29
- * - 文本预览:`text/*` 等文本类,按 Range 读开头 {@link ARTIFACT_PREVIEW_MAX_BYTES} 字节、
30
- * 至多 {@link ARTIFACT_PREVIEW_MAX_LINES} 行,以 JSON 字符串返回(网页按纯文本显示);
31
- * 其他类型、或读到的开头里有 NUL 字节(其实是二进制)→ `conversation.artifact_not_previewable`。
32
- *
33
- * 查找走 `conversation_events` 的主键 `(conversation_id, seq)` 前缀,在 SQL 里按 `type` 与
34
- * `payload->>'artifactId'` 过滤、`LIMIT 1`(只扫这一个会话的事件,不在 JS 里扫日志;不加迁移)。
29
+ * - Download: a 302 to a presigned address, `attachment` by default (with the file's name and
30
+ * type); `inline` only takes effect for bitmaps (the web's thumbnails).
31
+ * - Text preview: `text/*` and the text formats, the first {@link ARTIFACT_PREVIEW_MAX_BYTES} bytes
32
+ * by range, at most {@link ARTIFACT_PREVIEW_MAX_LINES} lines, as a JSON string (shown as plain
33
+ * text); other types, or NUL bytes in the head (binary after all) →
34
+ * `conversation.artifact_not_previewable`.
35
35
  */
36
36
  export declare class ConversationArtifacts {
37
- private readonly db;
38
37
  private readonly storage;
39
- /** 会话可见性(与会话 SSE 流同一判定)。 */
38
+ /** Conversation visibility (the same rule as the conversation's SSE stream). */
40
39
  private readonly access;
41
- constructor(db: KernelDb, storage: Pick<StorageService, "kernel">,
42
- /** 会话可见性(与会话 SSE 流同一判定)。 */
43
- access: Pick<ConversationAccess, "isAccessible">);
40
+ /** The files the conversation refers to, and their bytes. */
41
+ private readonly files;
42
+ constructor(storage: Pick<StorageService, "kernel">,
43
+ /** Conversation visibility (the same rule as the conversation's SSE stream). */
44
+ access: Pick<ConversationAccess, "isAccessible">,
45
+ /** The files the conversation refers to, and their bytes. */
46
+ files: Pick<ReferencedFiles, "references" | "open" | "head">);
44
47
  private find;
45
48
  downloadUrl(orgId: string, conversationId: string, viewerAccountId: string, artifactId: string, opts?: {
46
49
  inline?: boolean;
@@ -8,9 +8,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
8
8
  return function (target, key) { decorator(target, key, paramIndex); }
9
9
  };
10
10
  import { Inject, Injectable } from "@nestjs/common";
11
- import { sql } from "kysely";
12
11
  import { ApiError } from "../errors.js";
13
- import { KernelDb } from "../infra/database/kernel-db.js";
12
+ import { isLive, ReferencedFiles } from "../files/referenced-files.js";
14
13
  import { StorageService } from "../storage/storage.service.js";
15
14
  import { UUID_RE } from "../ui/registry.js";
16
15
  import { ConversationAccess } from "./access.js";
@@ -62,29 +61,31 @@ async function readPrefix(body, max) {
62
61
  return out.subarray(0, n);
63
62
  }
64
63
  /**
65
- * 产物(M5 T8 / T11):agent 经 `Deliver` 交付的文件。先按会话流的规则判定会话可见
66
- * (不可见 → `conversation.not_found`),再只在这个会话的日志里找 `artifact_created`
67
- * (没有 → `conversation.artifact_not_found`)。
64
+ * A conversation's files by id (M5 T8 / T11; file library spec §2): any file the conversation
65
+ * refers to (a delivery or an upload sent in it). The conversation must be visible by the event
66
+ * stream's rule (else `conversation.not_found`); the file must be one the conversation refers to,
67
+ * not deleted, its blob readable (else `conversation.artifact_not_found`). Bytes are read through
68
+ * the file's blob (size and etag checked), never an event's `objectKey`.
68
69
  *
69
- * - 下载:302 到预签名地址,默认 `attachment`(带交付时的文件名与类型);`inline` 只对位图生效
70
- * (网页的缩略图),其余类型即使要求 inline 也仍是 `attachment`。
71
- * - 文本预览:`text/*` 等文本类,按 Range 读开头 {@link ARTIFACT_PREVIEW_MAX_BYTES} 字节、
72
- * 至多 {@link ARTIFACT_PREVIEW_MAX_LINES} 行,以 JSON 字符串返回(网页按纯文本显示);
73
- * 其他类型、或读到的开头里有 NUL 字节(其实是二进制)→ `conversation.artifact_not_previewable`。
74
- *
75
- * 查找走 `conversation_events` 的主键 `(conversation_id, seq)` 前缀,在 SQL 里按 `type` 与
76
- * `payload->>'artifactId'` 过滤、`LIMIT 1`(只扫这一个会话的事件,不在 JS 里扫日志;不加迁移)。
70
+ * - Download: a 302 to a presigned address, `attachment` by default (with the file's name and
71
+ * type); `inline` only takes effect for bitmaps (the web's thumbnails).
72
+ * - Text preview: `text/*` and the text formats, the first {@link ARTIFACT_PREVIEW_MAX_BYTES} bytes
73
+ * by range, at most {@link ARTIFACT_PREVIEW_MAX_LINES} lines, as a JSON string (shown as plain
74
+ * text); other types, or NUL bytes in the head (binary after all) →
75
+ * `conversation.artifact_not_previewable`.
77
76
  */
78
77
  let ConversationArtifacts = class ConversationArtifacts {
79
- db;
80
78
  storage;
81
79
  access;
82
- constructor(db, storage,
83
- /** 会话可见性(与会话 SSE 流同一判定)。 */
84
- access) {
85
- this.db = db;
80
+ files;
81
+ constructor(storage,
82
+ /** Conversation visibility (the same rule as the conversation's SSE stream). */
83
+ access,
84
+ /** The files the conversation refers to, and their bytes. */
85
+ files) {
86
86
  this.storage = storage;
87
87
  this.access = access;
88
+ this.files = files;
88
89
  }
89
90
  async find(orgId, conversationId, viewerAccountId, artifactId) {
90
91
  if (!UUID_RE.test(conversationId))
@@ -94,25 +95,17 @@ let ConversationArtifacts = class ConversationArtifacts {
94
95
  }
95
96
  if (!UUID_RE.test(artifactId))
96
97
  throw artifactNotFound();
97
- const row = await this.db
98
- .selectFrom("conversation_events")
99
- .select("payload")
100
- .where("conversation_id", "=", conversationId)
101
- .where("type", "=", "artifact_created")
102
- .where(sql `payload->>'artifactId'`, "=", artifactId)
103
- .limit(1)
104
- .executeTakeFirst();
105
- if (!row)
98
+ const [f] = await this.files.references(orgId, [conversationId], { ids: [artifactId] });
99
+ if (!f || !isLive(f))
106
100
  throw artifactNotFound();
107
- return row.payload;
101
+ return f;
108
102
  }
109
103
  async downloadUrl(orgId, conversationId, viewerAccountId, artifactId, opts = {}) {
110
104
  const a = await this.find(orgId, conversationId, viewerAccountId, artifactId);
111
- const store = this.storage.kernel(orgId);
112
- if (!(await store.head(a.objectKey)))
105
+ if (!(await this.files.head(orgId, a)))
113
106
  throw artifactNotFound();
114
107
  const inline = opts.inline === true && isInlineArtifactType(a.contentType);
115
- const url = await store.presignGet(a.objectKey, {
108
+ const url = await this.storage.kernel(orgId).presignGet(a.blob.objectKey, {
116
109
  ttlSeconds: ARTIFACT_DOWNLOAD_TTL_SECONDS,
117
110
  downloadName: a.name,
118
111
  disposition: inline ? "inline" : "attachment",
@@ -125,9 +118,9 @@ let ConversationArtifacts = class ConversationArtifacts {
125
118
  if (!isTextArtifactType(a.contentType)) {
126
119
  throw new ApiError("conversation.artifact_not_previewable", "Only text artifacts have a preview");
127
120
  }
128
- const got = await this.storage
129
- .kernel(orgId)
130
- .get(a.objectKey, { range: { start: 0, end: ARTIFACT_PREVIEW_MAX_BYTES - 1 } });
121
+ const got = await this.files.open(orgId, a, {
122
+ range: { start: 0, end: ARTIFACT_PREVIEW_MAX_BYTES - 1 },
123
+ });
131
124
  if (!got)
132
125
  throw artifactNotFound();
133
126
  const bytes = await readPrefix(got.body, ARTIFACT_PREVIEW_MAX_BYTES);
@@ -156,8 +149,8 @@ let ConversationArtifacts = class ConversationArtifacts {
156
149
  };
157
150
  ConversationArtifacts = __decorate([
158
151
  Injectable(),
159
- __param(0, Inject(KernelDb)),
160
- __param(1, Inject(StorageService)),
161
- __param(2, Inject(ConversationAccess))
152
+ __param(0, Inject(StorageService)),
153
+ __param(1, Inject(ConversationAccess)),
154
+ __param(2, Inject(ReferencedFiles))
162
155
  ], ConversationArtifacts);
163
156
  export { ConversationArtifacts };
@@ -2,35 +2,22 @@ import type { FastifyReply } from "fastify";
2
2
  import { z } from "zod";
3
3
  import { type Principal } from "../identity/principal.js";
4
4
  import { type OrgContext } from "../orgs/org.guard.js";
5
- import { type AttachmentLimits, AttachmentsService, type AttachmentView, type CreatedAttachment } from "./attachments.service.js";
6
- declare const CreateBody: z.ZodObject<{
7
- name: z.ZodString;
8
- contentType: z.ZodString;
9
- size: z.ZodNumber;
10
- }, z.core.$strict>;
5
+ import { AttachmentsService } from "./attachments.service.js";
11
6
  declare const DownloadQuery: z.ZodObject<{
12
7
  as: z.ZodOptional<z.ZodEnum<{
13
8
  url: "url";
14
9
  }>>;
15
10
  }, z.core.$strip>;
16
11
  /**
17
- * 对话附件(`/api/v1/orgs/:orgId/attachments`,`agents.use`,只接受人类用户):
18
- * 1. `POST /` 登记并取预签名上传(`upload.method` 为 `POST` 时按 multipart 表单:先放 `fields`,最后放 `file`);
19
- * 2. 浏览器直传对象存储;
20
- * 3. `POST /:id/finalize` 核对大小与类型;
21
- * 4. 发消息时在 `files` 里引用 id。
22
- * Download: `GET /:id/download` redirects (302) to the presigned URL (`Cache-Control: private,
23
- * max-age=60`); `?as=url` answers `{ url }` with that address instead. Limits: `GET /limits` (types,
24
- * per-file size, files per message, the media budget per request, whether storage is available; for the
25
- * web's pre-checks; needs no object store). Without an object store the other routes answer 503
26
- * `storage.unavailable`.
12
+ * Attachment downloads (`/api/v1/orgs/:orgId/attachments`, `agents.use`, people only): `GET
13
+ * /:id/download` redirects (302) to the presigned URL (`Cache-Control: private, max-age=60`) of a
14
+ * `read` copy (an image a tool showed the agent); `?as=url` answers `{ url }`
15
+ * with that address instead. Without an object store it answers 503 `storage.unavailable`. A
16
+ * person's uploads go through the file library (`/files`).
27
17
  */
28
18
  export declare class AttachmentsController {
29
19
  private readonly attachments;
30
20
  constructor(attachments: AttachmentsService);
31
- limits(principal: Principal): AttachmentLimits;
32
- create(principal: Principal, org: OrgContext, body: z.infer<typeof CreateBody>): Promise<CreatedAttachment>;
33
- finalize(principal: Principal, org: OrgContext, id: string): Promise<AttachmentView>;
34
21
  download(principal: Principal, org: OrgContext, id: string, q: z.infer<typeof DownloadQuery>, reply: FastifyReply): Promise<void>;
35
22
  }
36
23
  export {};