@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.
- package/bootstrap.json +13 -13
- package/dist/admin/admin.schemas.d.ts +3 -0
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/channels/channels.module.js +4 -3
- package/dist/channels/file-delivery.d.ts +26 -11
- package/dist/channels/file-delivery.js +32 -11
- package/dist/channels/outbound.d.ts +3 -3
- package/dist/channels/outbound.js +15 -13
- package/dist/config/schema.d.ts +3 -0
- package/dist/config/schema.js +12 -0
- package/dist/conversations/artifacts.d.ts +20 -17
- package/dist/conversations/artifacts.js +30 -37
- package/dist/conversations/attachments.controller.d.ts +6 -19
- package/dist/conversations/attachments.controller.js +8 -59
- package/dist/conversations/attachments.service.d.ts +30 -74
- package/dist/conversations/attachments.service.js +51 -193
- package/dist/conversations/conversations.module.js +4 -0
- package/dist/conversations/conversations.service.d.ts +10 -9
- package/dist/conversations/conversations.service.js +28 -11
- package/dist/conversations/event-log.d.ts +1 -0
- package/dist/conversations/events.d.ts +49 -27
- package/dist/conversations/events.js +54 -7
- package/dist/conversations/files.d.ts +66 -64
- package/dist/conversations/files.js +127 -147
- package/dist/conversations/prompt-suggestion-request.js +2 -1
- package/dist/conversations/prompt-suggestions.d.ts +3 -3
- package/dist/conversations/prompt-suggestions.js +11 -10
- package/dist/conversations/queue.service.js +7 -2
- package/dist/ctx/create-ctx.d.ts +3 -1
- package/dist/ctx/create-ctx.js +19 -1
- package/dist/db/kernel-schema.d.ts +80 -2
- package/dist/errors.d.ts +19 -0
- package/dist/errors.js +19 -0
- package/dist/evals/canonical-json.d.ts +7 -0
- package/dist/evals/canonical-json.js +21 -0
- package/dist/evals/reconstruct.js +13 -1
- package/dist/evals/recorded-tools.d.ts +0 -2
- package/dist/evals/recorded-tools.js +1 -16
- package/dist/evals/snapshot.d.ts +26 -3
- package/dist/evals/snapshot.js +110 -57
- package/dist/evals/worker.d.ts +4 -3
- package/dist/evals/worker.js +8 -4
- package/dist/extensions/host.d.ts +3 -1
- package/dist/extensions/host.js +2 -0
- package/dist/extensions/instance.d.ts +3 -1
- package/dist/extensions/instance.js +4 -0
- package/dist/extensions/ledger.d.ts +1 -1
- package/dist/files/blob-objects.d.ts +124 -0
- package/dist/files/blob-objects.js +341 -0
- package/dist/files/blob-sweep.job.d.ts +122 -0
- package/dist/files/blob-sweep.job.js +389 -0
- package/dist/files/blobs.service.d.ts +135 -0
- package/dist/files/blobs.service.js +300 -0
- package/dist/files/conversation-media.d.ts +41 -0
- package/dist/files/conversation-media.js +124 -0
- package/dist/files/deliveries.d.ts +64 -0
- package/dist/files/deliveries.js +156 -0
- package/dist/files/deliveries.module.d.ts +6 -0
- package/dist/files/deliveries.module.js +24 -0
- package/dist/files/draft-cleanup.job.d.ts +26 -0
- package/dist/files/draft-cleanup.job.js +93 -0
- package/dist/files/files.module.d.ts +1 -1
- package/dist/files/files.module.js +3 -2
- package/dist/files/hash-job.d.ts +127 -0
- package/dist/files/hash-job.js +447 -0
- package/dist/files/library-backfill.d.ts +63 -0
- package/dist/files/library-backfill.js +143 -0
- package/dist/files/library-files.service.d.ts +255 -0
- package/dist/files/library-files.service.js +883 -0
- package/dist/files/library-jobs.module.d.ts +8 -0
- package/dist/files/library-jobs.module.js +27 -0
- package/dist/files/library-query.d.ts +127 -0
- package/dist/files/library-query.js +322 -0
- package/dist/files/library-read.module.d.ts +9 -0
- package/dist/files/library-read.module.js +30 -0
- package/dist/files/library.controller.d.ts +77 -0
- package/dist/files/library.controller.js +235 -0
- package/dist/files/library.module.d.ts +9 -0
- package/dist/files/library.module.js +29 -0
- package/dist/files/library.schemas.d.ts +46 -0
- package/dist/files/library.schemas.js +49 -0
- package/dist/files/previewers.controller.d.ts +20 -0
- package/dist/files/previewers.controller.js +47 -0
- package/dist/files/previewers.d.ts +25 -11
- package/dist/files/previewers.js +43 -27
- package/dist/files/referenced-files.d.ts +150 -0
- package/dist/files/referenced-files.js +234 -0
- package/dist/html/html-document.controller.d.ts +8 -1
- package/dist/html/html-document.controller.js +19 -1
- package/dist/html/html-document.service.d.ts +19 -4
- package/dist/html/html-document.service.js +43 -22
- package/dist/html/html-token.d.ts +10 -1
- package/dist/html/html-token.js +14 -0
- package/dist/html/html.module.js +8 -1
- package/dist/http/api.module.js +5 -0
- package/dist/identity/settings.d.ts +26 -0
- package/dist/identity/settings.js +33 -2
- package/dist/infra/outbox/registry.d.ts +82 -0
- package/dist/infra/outbox/registry.js +74 -2
- package/dist/infra/throttler/named-throttlers.d.ts +2 -0
- package/dist/infra/throttler/named-throttlers.js +14 -0
- package/dist/lifecycle/kernel-lifecycle.js +6 -0
- package/dist/models/purposes.js +1 -1
- package/dist/orgs/offboarding.js +1 -1
- package/dist/orgs/settings.service.d.ts +48 -2
- package/dist/orgs/settings.service.js +63 -3
- package/dist/platform/exclusions.js +45 -8
- package/dist/platform/file-ref.d.ts +18 -3
- package/dist/platform/file-ref.js +22 -11
- package/dist/platform/operation.js +4 -0
- package/dist/platform/ops/admin.ops.js +5 -2
- package/dist/platform/ops/files.ops.d.ts +18 -0
- package/dist/platform/ops/files.ops.js +267 -0
- package/dist/platform/ops/org-settings.ops.js +6 -2
- package/dist/platform/ops/orgs.ops.js +1 -0
- package/dist/platform/ops/shares.ops.js +2 -2
- package/dist/platform/platform-ops.module.d.ts +2 -1
- package/dist/platform/platform-ops.module.js +5 -0
- package/dist/platform/route-schemas.js +3 -0
- package/dist/roles/worker.module.js +15 -1
- package/dist/runtime/compaction-settings.service.d.ts +13 -1
- package/dist/runtime/compaction-settings.service.js +16 -1
- package/dist/runtime/compaction.service.d.ts +3 -1
- package/dist/runtime/compaction.service.js +3 -1
- package/dist/runtime/context/build.d.ts +18 -1
- package/dist/runtime/context/build.js +19 -8
- package/dist/runtime/context/cache-expiry.d.ts +31 -0
- package/dist/runtime/context/cache-expiry.js +60 -0
- package/dist/runtime/context/cache-ttl.d.ts +18 -0
- package/dist/runtime/context/cache-ttl.js +30 -0
- package/dist/runtime/context/compaction.d.ts +9 -2
- package/dist/runtime/context/compaction.js +50 -17
- package/dist/runtime/context/in-context-compaction.d.ts +156 -0
- package/dist/runtime/context/in-context-compaction.js +310 -0
- package/dist/runtime/hook-calls.d.ts +2 -1
- package/dist/runtime/hook-calls.js +5 -2
- package/dist/runtime/maintenance.d.ts +10 -2
- package/dist/runtime/maintenance.js +48 -8
- package/dist/runtime/model-call.d.ts +34 -5
- package/dist/runtime/model-call.js +207 -22
- package/dist/runtime/providers.js +11 -1
- package/dist/runtime/run-steps.d.ts +4 -2
- package/dist/runtime/run-steps.js +10 -5
- package/dist/runtime/runtime.module.js +3 -0
- package/dist/shares/liveness.d.ts +26 -12
- package/dist/shares/liveness.js +79 -20
- package/dist/shares/revoke.d.ts +16 -11
- package/dist/shares/revoke.js +18 -14
- package/dist/shares/share-objects.d.ts +16 -21
- package/dist/shares/share-objects.js +25 -55
- package/dist/shares/share-open.service.d.ts +8 -4
- package/dist/shares/share-open.service.js +14 -11
- package/dist/shares/shares.controller.d.ts +16 -5
- package/dist/shares/shares.controller.js +39 -5
- package/dist/shares/shares.module.d.ts +4 -4
- package/dist/shares/shares.module.js +7 -6
- package/dist/shares/shares.schemas.d.ts +4 -0
- package/dist/shares/shares.schemas.js +2 -0
- package/dist/shares/shares.service.d.ts +93 -54
- package/dist/shares/shares.service.js +292 -131
- package/dist/shares/sweep.job.d.ts +18 -39
- package/dist/shares/sweep.job.js +47 -206
- package/dist/tools/builtins/artifacts.d.ts +21 -13
- package/dist/tools/builtins/artifacts.js +81 -51
- package/dist/tools/builtins/builtin-tools.d.ts +7 -1
- package/dist/tools/builtins/builtin-tools.js +17 -6
- package/dist/tools/builtins/conversation-files.d.ts +23 -13
- package/dist/tools/builtins/conversation-files.js +62 -83
- package/dist/tools/builtins/image/generate.d.ts +7 -1
- package/dist/tools/builtins/image/generate.js +1 -1
- package/dist/tools/builtins/platform.js +1 -0
- package/dist/tools/builtins/sandbox/common.d.ts +6 -2
- package/dist/tools/builtins/sandbox/deliver.js +6 -7
- package/dist/tools/builtins/sandbox/fetch-attachment.d.ts +6 -5
- package/dist/tools/builtins/sandbox/fetch-attachment.js +19 -12
- package/dist/tools/tools.module.js +6 -0
- package/dist/ui/call-extension.d.ts +6 -4
- package/dist/ui/call-extension.js +5 -4
- package/dist/ui/embed-token.js +6 -3
- package/dist/ui/registry.d.ts +21 -5
- package/dist/ui/registry.js +24 -6
- package/dist/ui/ui.schemas.d.ts +22 -0
- package/dist/ui/ui.schemas.js +22 -4
- package/dist/ui/views.controller.d.ts +13 -3
- package/dist/ui/views.controller.js +33 -2
- package/dist/ui/views.d.ts +29 -1
- package/dist/ui/views.js +131 -7
- package/package.json +3 -3
- package/src/migrations/0190_file_library.sql +285 -0
- 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 {
|
|
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 {
|
|
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
|
|
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
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
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 {
|
|
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 `
|
|
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
|
-
*
|
|
135
|
-
*
|
|
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
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
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
|
|
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
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
246
|
-
*
|
|
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
|
|
271
|
-
*
|
|
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 `
|
|
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).
|