File size: 1,514 Bytes
e81f4e4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
export type AttachmentFileRef =
	| string
	| {
			ref?: string;
			fileRef?: string;
			id?: string;
			name?: string;
			filename?: string;
	  };

export type AttachmentKind = "image" | "file";

export type AttachmentRole = "request" | "context";

export type AttachmentSource =
	| { type: "base64"; data: unknown }
	| { type: "bytes"; bytes: Uint8Array };

export type AttachmentCandidate = {
	id: string;
	kind: AttachmentKind;
	role: AttachmentRole;
	source: AttachmentSource;
	filename?: string;
	mime?: string;
};

export type AttachmentDropReason =
	| "invalid_image_input"
	| "invalid_file_input"
	| "invalid_base64"
	| "invalid_remote_url"
	| "file_too_large"
	| "image_too_large"
	| "too_many_files"
	| "upload_failed";

export type AttachmentDrop = {
	kind: AttachmentKind;
	code: AttachmentDropReason;
	message: string;
	filename?: string;
};

export type AttachmentPlan = {
	candidates: AttachmentCandidate[];
	existingFileRefs: AttachmentFileRef[] | null;
	dropped: AttachmentDrop[];
	maxFiles: number;
};

export type AttachmentUsage = {
	uploadedFiles: number;
	dedupedFiles: number;
	uploadedBytes: number;
	fileRefBytes: number;
	inlinedFiles: number;
	inlinedBytes: number;
	droppedFiles: number;
	multipartUploads: number;
};

export type AttachmentUploadResult = {
	fileRefs: AttachmentFileRef[] | null;
	imageFileRefs: AttachmentFileRef[] | null;
	genericFileRefs: AttachmentFileRef[] | null;
	promptText: string;
	droppedNote: string;
	supportsFileRefs: boolean;
	usage: AttachmentUsage;
};