@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
@@ -7,61 +7,30 @@ 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 { hasControlChars, MEDIA_NAME_MAX_CHARS } from "@capybara-hq/plugin-sdk";
11
- import { Controller, Get, HttpCode, Inject, Param, Post, Res } from "@nestjs/common";
10
+ import { Controller, Get, Inject, Param, Res } from "@nestjs/common";
12
11
  import { z } from "zod";
13
12
  import { CurrentPrincipal, requireUser } from "../identity/principal.js";
14
13
  import { createZodDto } from "../infra/validation/create-zod-dto.js";
15
- import { ZBody, ZQuery } from "../infra/validation/zod-params.js";
14
+ import { ZQuery } from "../infra/validation/zod-params.js";
16
15
  import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
17
- import { ATTACHMENT_DOWNLOAD_CACHE_SECONDS, AttachmentsService, } from "./attachments.service.js";
16
+ import { ATTACHMENT_DOWNLOAD_CACHE_SECONDS, AttachmentsService } from "./attachments.service.js";
18
17
  import { DOWNLOAD_AS } from "./conversations.schemas.js";
19
- const CreateBody = z
20
- .object({
21
- name: z
22
- .string()
23
- .min(1)
24
- .max(MEDIA_NAME_MAX_CHARS)
25
- .refine((s) => !hasControlChars(s), "name must not contain control characters"),
26
- contentType: z.string().min(1).max(200),
27
- size: z.number().int().min(1).max(Number.MAX_SAFE_INTEGER),
28
- })
29
- .strict();
30
- class AttachmentCreateBodyDto extends createZodDto(CreateBody, "AttachmentCreateBody") {
31
- }
32
18
  // Not strict: the web adds a cache-busting `retry=1` when it reloads a failed image.
33
19
  const DownloadQuery = z.object({ as: DOWNLOAD_AS.optional() });
34
20
  class AttachmentDownloadQueryDto extends createZodDto(DownloadQuery, "AttachmentDownloadQuery") {
35
21
  }
36
22
  /**
37
- * 对话附件(`/api/v1/orgs/:orgId/attachments`,`agents.use`,只接受人类用户):
38
- * 1. `POST /` 登记并取预签名上传(`upload.method` 为 `POST` 时按 multipart 表单:先放 `fields`,最后放 `file`);
39
- * 2. 浏览器直传对象存储;
40
- * 3. `POST /:id/finalize` 核对大小与类型;
41
- * 4. 发消息时在 `files` 里引用 id。
42
- * Download: `GET /:id/download` redirects (302) to the presigned URL (`Cache-Control: private,
43
- * max-age=60`); `?as=url` answers `{ url }` with that address instead. Limits: `GET /limits` (types,
44
- * per-file size, files per message, the media budget per request, whether storage is available; for the
45
- * web's pre-checks; needs no object store). Without an object store the other routes answer 503
46
- * `storage.unavailable`.
23
+ * Attachment downloads (`/api/v1/orgs/:orgId/attachments`, `agents.use`, people only): `GET
24
+ * /:id/download` redirects (302) to the presigned URL (`Cache-Control: private, max-age=60`) of a
25
+ * `read` copy (an image a tool showed the agent); `?as=url` answers `{ url }`
26
+ * with that address instead. Without an object store it answers 503 `storage.unavailable`. A
27
+ * person's uploads go through the file library (`/files`).
47
28
  */
48
29
  let AttachmentsController = class AttachmentsController {
49
30
  attachments;
50
31
  constructor(attachments) {
51
32
  this.attachments = attachments;
52
33
  }
53
- limits(principal) {
54
- requireUser(principal);
55
- return this.attachments.limits();
56
- }
57
- async create(principal, org, body) {
58
- const p = requireUser(principal);
59
- return this.attachments.create(org.orgId, p.account.id, body);
60
- }
61
- async finalize(principal, org, id) {
62
- const p = requireUser(principal);
63
- return this.attachments.finalize(org.orgId, p.account.id, id);
64
- }
65
34
  async download(principal, org, id, q, reply) {
66
35
  const p = requireUser(principal);
67
36
  const location = await this.attachments.downloadUrl(org.orgId, p.account.id, id);
@@ -75,26 +44,6 @@ let AttachmentsController = class AttachmentsController {
75
44
  .redirect(location, 302);
76
45
  }
77
46
  };
78
- __decorate([
79
- Get("limits"),
80
- OrgAction("agents.use"),
81
- __param(0, CurrentPrincipal())
82
- ], AttachmentsController.prototype, "limits", null);
83
- __decorate([
84
- Post(),
85
- OrgAction("agents.use"),
86
- __param(0, CurrentPrincipal()),
87
- __param(1, CurrentOrg()),
88
- __param(2, ZBody(AttachmentCreateBodyDto))
89
- ], AttachmentsController.prototype, "create", null);
90
- __decorate([
91
- Post(":id/finalize"),
92
- HttpCode(200),
93
- OrgAction("agents.use"),
94
- __param(0, CurrentPrincipal()),
95
- __param(1, CurrentOrg()),
96
- __param(2, Param("id"))
97
- ], AttachmentsController.prototype, "finalize", null);
98
47
  __decorate([
99
48
  Get(":id/download"),
100
49
  OrgAction("agents.use"),
@@ -1,5 +1,4 @@
1
- import { type PresignedUpload } from "@capybara-hq/plugin-sdk";
2
- import type { AttachmentPurpose } from "../db/kernel-schema.js";
1
+ import type { PresignedUpload } from "@capybara-hq/plugin-sdk";
3
2
  import { CacheService } from "../infra/cache/cache.service.js";
4
3
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
5
4
  import { KernelDb } from "../infra/database/kernel-db.js";
@@ -9,15 +8,12 @@ import type { KernelLogger } from "../log.js";
9
8
  import type { MediaBytes, MediaInfo } from "../runtime/context/build.js";
10
9
  import { StorageService } from "../storage/storage.service.js";
11
10
  import { ConversationAccess } from "./access.js";
12
- import type { LogContentBlock } from "./events.js";
13
11
  /** 预签名上传的有效期(秒)。尽量短:表单在有效期内可被再次使用(内容替换由 etag 核对兜底)。 */
14
12
  export declare const ATTACHMENT_UPLOAD_TTL_SECONDS = 300;
15
13
  /** 下载跳转的预签名有效期(秒);不短于 {@link ATTACHMENT_DOWNLOAD_CACHE_SECONDS}(浏览器缓存的跳转仍可用)。 */
16
14
  export declare const ATTACHMENT_DOWNLOAD_TTL_SECONDS = 300;
17
15
  /** 下载 302 的 `Cache-Control: private, max-age=…`(秒):同一页面里缩略图可复用跳转地址。 */
18
16
  export declare const ATTACHMENT_DOWNLOAD_CACHE_SECONDS = 60;
19
- /** 同一账号在一个组织里最多的未 finalize 附件数(超过 → 429 `attachment.too_many_pending`)。 */
20
- export declare const MAX_PENDING_ATTACHMENTS = 50;
21
17
  /** 技能包 zip 的内容类型(上传时一律按它签名,finalize 时核对 zip 文件头)。 */
22
18
  export declare const SKILL_PACKAGE_CONTENT_TYPE = "application/zip";
23
19
  /** 技能包 zip 的大小上限(字节)。 */
@@ -48,6 +44,8 @@ export declare const skillFilesPrefix: (uploadId: string) => string;
48
44
  export declare const ATTACHMENT_CLEANUP_JOB = "attachment-cleanup";
49
45
  /** The hourly purge of `read` copies whose conversation was deleted long enough ago. */
50
46
  export declare const ATTACHMENT_READ_PURGE_JOB = "attachments-read-purge";
47
+ /** The purposes registered through {@link AttachmentsService.create} (a presigned upload). */
48
+ export type UploadPurpose = "agent-avatar" | "skill-package";
51
49
  /** {@link AttachmentsService.storeRead}'s result: the bound copy, or refused by the cap. */
52
50
  export type StoreReadResult = {
53
51
  ok: true;
@@ -64,23 +62,6 @@ export interface AttachmentView {
64
62
  contentType: string;
65
63
  size: number;
66
64
  }
67
- /** 附件上限(`GET /attachments/limits`):网页据此在上传前预检。 */
68
- export interface AttachmentLimits {
69
- /** 允许的内容类型。 */
70
- types: string[];
71
- /** 与 `types` 并列的允许扩展名(小写、不带点)。 */
72
- extensions: string[];
73
- /** 非图片的单个上限(字节)。 */
74
- maxBytes: number;
75
- /** 图片的单个上限(字节,另受 `MEDIA_LIMITS.imageBytes` 限制)。 */
76
- imageMaxBytes: number;
77
- /** 单条消息最多附件数。 */
78
- maxPerMessage: number;
79
- /** 单次模型请求里媒体原始字节的预算(网页据此在发送前提醒总大小)。 */
80
- requestMediaBytes: number;
81
- /** 部署是否配置了对象存储;为 false 时上传不可用。 */
82
- available: boolean;
83
- }
84
65
  /** {@link AttachmentsService.openForConversation} 的结果。 */
85
66
  export interface OpenedAttachment {
86
67
  name: string;
@@ -88,7 +69,7 @@ export interface OpenedAttachment {
88
69
  size: number;
89
70
  body: ReadableStream<Uint8Array>;
90
71
  }
91
- /** A ready `chat` attachment bound to a conversation ({@link AttachmentsService.boundRows}). */
72
+ /** A ready `read` copy bound to a conversation ({@link AttachmentsService.boundRows}). */
92
73
  export interface BoundAttachment {
93
74
  id: string;
94
75
  name: string;
@@ -131,9 +112,11 @@ export declare function sniffMatches(contentType: string, head: Uint8Array): boo
131
112
  */
132
113
  export declare function countPdfPages(bytes: Uint8Array): number;
133
114
  /**
134
- * 对话附件(M5 T3):登记 → 浏览器按预签名直传对象存储 → finalize 核对 → 发消息时绑定到会话。
135
- * 字节只在对象存储(`kernel/<orgId>/attachments/<id>`),日志里只有引用;构建模型请求时经 {@link fetchMedia} 取字节。
136
- * 无进程内状态,可多副本共用。
115
+ * Uploads that are not a person's files (agent avatars, skill packages: register → the browser
116
+ * uploads with the presigned form → finalize checks) and the `read` copies of images the agent was
117
+ * shown (bound to their conversation; request building reads them through {@link fetchMedia}). A
118
+ * person's files are the file library's (`LibraryFilesService`, `ReferencedFiles`). Bytes live only
119
+ * in the object store; logs hold refs. No process state.
137
120
  */
138
121
  export declare class AttachmentsService {
139
122
  private readonly db;
@@ -150,21 +133,18 @@ export declare class AttachmentsService {
150
133
  access: Pick<ConversationAccess, "isAccessible">, log: Pick<KernelLogger, "info" | "warn">, txHost: TransactionHost,
151
134
  /** where the model-sized copies of images are kept between steps ({@link fetchMedia}) */
152
135
  cache: Pick<CacheService, "get" | "set">);
153
- /** 单个附件的大小上限:配置的 `maxBytes`,图片再受 `MEDIA_LIMITS.imageBytes` 限制。 */
154
- private limitFor;
155
- /** 当前配置下的上限(不需要对象存储)。 */
156
- limits(): AttachmentLimits;
157
136
  /**
158
- * 登记一个附件(`pending`)并返回预签名上传:存储端按声明的大小与类型限制上传。
159
- * 类型不在 `attachments.allowedTypes` → `attachment.type_not_allowed`;超过上限 → `attachment.too_large`;
160
- * 该账号在组织里已有 {@link MAX_PENDING_ATTACHMENTS} 个未 finalize 的附件 → `attachment.too_many_pending`
161
- * (软上限:并发登记可能略超);没有对象存储 → `storage.unavailable`。
137
+ * Registers an agent avatar or skill package upload (`pending`) and returns its presigned form;
138
+ * the store enforces the declared size and type. A type or size the purpose does not take →
139
+ * `attachment.type_not_allowed` / `attachment.too_large`; too many unfinished uploads of the
140
+ * purpose → `attachment.too_many_pending` (a soft cap); no object store → `storage.unavailable`.
141
+ * A person's files go through the file library (`LibraryFilesService`), never here.
162
142
  */
163
143
  create(orgId: string, accountId: string, input: {
164
144
  name: string;
165
145
  contentType: string;
166
146
  size: number;
167
- }, purpose?: AttachmentPurpose): Promise<CreatedAttachment>;
147
+ }, purpose: UploadPurpose): Promise<CreatedAttachment>;
168
148
  /**
169
149
  * The checks of registering an upload of `purpose` (type, size, the account's unfinished uploads
170
150
  * of that purpose) and its expiry. `countStored`: uploads already stored but not yet used (ready,
@@ -207,29 +187,19 @@ export declare class AttachmentsService {
207
187
  */
208
188
  finalize(orgId: string, accountId: string, id: string): Promise<AttachmentView>;
209
189
  /**
210
- * 下载地址(预签名,{@link ATTACHMENT_DOWNLOAD_TTL_SECONDS} 秒):已绑定的附件要求能访问其会话,
211
- * 未绑定的只有上传者;否则 `attachment.not_found`。只有图片与 PDF 以 `inline` 打开,其余一律 `attachment`
212
- * (即使存储里的类型被改成 text/html 也不会在页面里渲染);响应类型按 finalize 核对过的类型返回。
213
- * A `read` copy (an image a tool showed the agent) is served the same way to whoever can open its
214
- * conversation, so the web can show it on the call's row (tool result images design §4); it is
215
- * still never listed (lists and the device's attachments stay `chat` only).
190
+ * The download address (presigned, {@link ATTACHMENT_DOWNLOAD_TTL_SECONDS} seconds) of a `read`
191
+ * copy (an image a tool showed the agent), for whoever can open its conversation, so the web can
192
+ * show it on the call's row (tool result images design §4); anything else →
193
+ * `attachment.not_found` (a person's files are downloaded through the file library). Only images
194
+ * and PDFs open `inline`; the response type is the recorded one.
216
195
  */
217
196
  downloadUrl(orgId: string, accountId: string, id: string): Promise<string>;
218
197
  /**
219
- * 绑定在该会话、已 ready 的附件(id 与原始文件名),按上传时间、id 排序(沙箱同步按这个顺序分配文件名)。
198
+ * The ready `read` copies bound to the conversation in this org (vision-read design §1.1), oldest
199
+ * first, then id; with `id`, only that one. Nothing here checks who reads them: callers check the
200
+ * conversation's access first.
220
201
  */
221
- listForConversation(orgId: string, conversationId: string): Promise<{
222
- id: string;
223
- name: string;
224
- }[]>;
225
- /**
226
- * The ready `chat` attachments bound to the conversation in this org (never another purpose, a
227
- * pending or an unbound upload), oldest first by upload time, then id; with `id`, only that one.
228
- * Nothing here checks who reads them: callers check the conversation's access first. `purposes`
229
- * widens it for a model-facing lookup only (`read` copies; vision-read design §1.1): every
230
- * person- or device-facing caller keeps the default.
231
- */
232
- boundRows(orgId: string, conversationId: string, id?: string, purposes?: readonly ("chat" | "read")[]): Promise<BoundAttachment[]>;
202
+ boundRows(orgId: string, conversationId: string, id?: string): Promise<BoundAttachment[]>;
233
203
  /**
234
204
  * {@link attachmentContentMatches} for a bound attachment's stored object (`null`: gone), with
235
205
  * the warning logged when the content was replaced after finalize.
@@ -242,40 +212,26 @@ export declare class AttachmentsService {
242
212
  conversationId?: string;
243
213
  }): boolean;
244
214
  /**
245
- * 读取一个绑定在该会话、已 ready 的附件(沙箱同步等内核内部用途):没有行、未绑定到该会话、对象已不在、
246
- * 大小或 etag 与 finalize 时不符 → null。其余错误(存储不可用等)照常抛出。调用方负责读完或取消 `body`。
215
+ * Opens a ready `read` copy bound to the conversation (the model-facing file lookup): no row, not
216
+ * bound to it, the object gone, or its size or etag not the recorded one → null. Other errors
217
+ * (storage unavailable) throw. The caller reads or cancels `body`.
247
218
  */
248
219
  openForConversation(orgId: string, conversationId: string, attachmentId: string, opts?: {
249
- /**
250
- * Also `read` copies (the model-facing file lookup only, vision-read design §1.1); the
251
- * default is `chat` attachments, which is all a person or a device may see.
252
- */
253
- purposes?: readonly ("chat" | "read")[];
254
220
  /** Read at most this many bytes (a range read; a store that ignores it serves the whole). */
255
221
  maxBytes?: number;
256
222
  signal?: AbortSignal;
257
223
  }): Promise<OpenedAttachment | null>;
258
- /**
259
- * 发消息时在调用方事务里绑定附件(行锁),返回写进 user_message 的媒体块(`ref`,按 ids 顺序):
260
- * - 超过 `attachments.maxPerMessage`、或同一个 id 出现多次 → `validation_failed`;
261
- * - 不存在、不是发送者上传的、已绑定到别的会话、未绑定且已过期 → `attachment.not_found`;
262
- * - 还没 finalize → `attachment.not_ready`。
263
- * 后两种的 details 为 `[{ path: "files", message, attachmentId }]`,网页据此标出对应条目。
264
- * 已绑定到本会话的(重试)照常返回块。
265
- */
266
- bindForMessage(orgId: string, conversationId: string, accountId: string, ids: readonly string[]): Promise<LogContentBlock[]>;
267
224
  /** 下载 / 取字节时核对 etag:finalize 记下的与当前对象的不一致 → 内容被替换(记 warn)。没有记录时不核对。 */
268
225
  private sameContent;
269
226
  /**
270
- * The recorded facts request building needs about attachments (only ready `chat` or `read` rows
271
- * bound to this conversation): size, PDF page count, and the object's unsigned reference
227
+ * The recorded facts request building needs about `read` copies (only ready rows bound to this
228
+ * conversation; `ConversationMedia` asks here for the refs that are not library files): size, PDF page count, and the object's unsigned reference
272
229
  * (`ObjectStore.uri`, falling back to `capybara://attachments/<id>`). An id with no row is left
273
230
  * out; a failed query throws.
274
231
  */
275
232
  mediaInfo(orgId: string, conversationId: string, ids: readonly string[]): Promise<Map<string, MediaInfo>>;
276
233
  /**
277
- * The bytes request building sends, only of ready `chat` or `read` rows bound to this
278
- * conversation. Null only when certainly gone: no row, the object missing, or its size or etag
234
+ * The bytes request building sends, only of ready `read` copies bound to this conversation. Null only when certainly gone: no row, the object missing, or its size or etag
279
235
  * not the recorded one (content replaced, logged as a warning). Every other error (storage
280
236
  * unavailable, network) throws (Ruling M4) for the caller to treat as retryable, never a
281
237
  * placeholder. An id in `caps` is read by range up to that many leading bytes (the `text/*` cap).