@copilotkit/shared 0.0.0-main-20260406172622 → 0.0.0-main-20260407183406
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/CHANGELOG.md +2 -1
- package/dist/attachments/types.d.cts +54 -0
- package/dist/attachments/types.d.cts.map +1 -0
- package/dist/attachments/types.d.mts +54 -0
- package/dist/attachments/types.d.mts.map +1 -0
- package/dist/attachments/utils.cjs +134 -0
- package/dist/attachments/utils.cjs.map +1 -0
- package/dist/attachments/utils.d.cts +42 -0
- package/dist/attachments/utils.d.cts.map +1 -0
- package/dist/attachments/utils.d.mts +42 -0
- package/dist/attachments/utils.d.mts.map +1 -0
- package/dist/attachments/utils.mjs +126 -0
- package/dist/attachments/utils.mjs.map +1 -0
- package/dist/index.cjs +9 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +4 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +137 -0
- package/dist/index.umd.js.map +1 -1
- package/dist/types/message.d.cts +15 -4
- package/dist/types/message.d.cts.map +1 -1
- package/dist/types/message.d.mts +15 -4
- package/dist/types/message.d.mts.map +1 -1
- package/package.json +5 -5
- package/src/attachments/__tests__/utils.test.ts +198 -0
- package/src/attachments/index.ts +19 -0
- package/src/attachments/types.ts +67 -0
- package/src/attachments/utils.ts +164 -0
- package/src/index.ts +1 -0
- package/src/types/__tests__/message.test.ts +62 -0
- package/src/types/message.ts +27 -3
- package/dist/constants/index.d.ts +0 -11
- package/dist/constants/index.d.ts.map +0 -1
- package/dist/finalize-events.d.ts +0 -11
- package/dist/finalize-events.d.ts.map +0 -1
- package/dist/index.d.ts +0 -41
- package/dist/index.d.ts.map +0 -1
- package/dist/logger.d.ts +0 -5
- package/dist/logger.d.ts.map +0 -1
- package/dist/standard-schema.d.ts +0 -32
- package/dist/standard-schema.d.ts.map +0 -1
- package/dist/telemetry/events.d.ts +0 -39
- package/dist/telemetry/events.d.ts.map +0 -1
- package/dist/telemetry/telemetry-client.d.ts +0 -48
- package/dist/telemetry/telemetry-client.d.ts.map +0 -1
- package/dist/transcription-errors.d.ts +0 -52
- package/dist/transcription-errors.d.ts.map +0 -1
- package/dist/types/action.d.ts +0 -59
- package/dist/types/action.d.ts.map +0 -1
- package/dist/types/copilot-cloud-config.d.ts +0 -15
- package/dist/types/copilot-cloud-config.d.ts.map +0 -1
- package/dist/types/error.d.ts +0 -57
- package/dist/types/error.d.ts.map +0 -1
- package/dist/types/message.d.ts +0 -31
- package/dist/types/message.d.ts.map +0 -1
- package/dist/types/openai-assistant.d.ts +0 -55
- package/dist/types/openai-assistant.d.ts.map +0 -1
- package/dist/types/utility.d.ts +0 -6
- package/dist/types/utility.d.ts.map +0 -1
- package/dist/utils/conditions.d.ts +0 -31
- package/dist/utils/conditions.d.ts.map +0 -1
- package/dist/utils/console-styling.d.ts +0 -65
- package/dist/utils/console-styling.d.ts.map +0 -1
- package/dist/utils/errors.d.ts +0 -312
- package/dist/utils/errors.d.ts.map +0 -1
- package/dist/utils/index.d.ts +0 -53
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/json-schema.d.ts +0 -36
- package/dist/utils/json-schema.d.ts.map +0 -1
- package/dist/utils/random-id.d.ts +0 -8
- package/dist/utils/random-id.d.ts.map +0 -1
- package/dist/utils/requests.d.ts +0 -12
- package/dist/utils/requests.d.ts.map +0 -1
- package/dist/utils/types.d.ts +0 -33
- package/dist/utils/types.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# @copilotkit/shared
|
|
2
2
|
|
|
3
|
-
## 0.0.0-main-
|
|
3
|
+
## 0.0.0-main-20260407183406
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
7
7
|
- 1ceb963: refactor: consolidate V1/V2 packages into flat @copilotkit/\* structure
|
|
8
|
+
- 5289791: feat: add multimodal attachment support to the builtin agent
|
|
8
9
|
|
|
9
10
|
### Patch Changes
|
|
10
11
|
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { InputContentDataSource, InputContentUrlSource } from "@ag-ui/core";
|
|
2
|
+
|
|
3
|
+
//#region src/attachments/types.d.ts
|
|
4
|
+
interface AttachmentUploadDataResult {
|
|
5
|
+
type: "data";
|
|
6
|
+
value: string;
|
|
7
|
+
mimeType: string;
|
|
8
|
+
/** Custom metadata to include in the InputContent part (merged with auto-generated metadata like filename). */
|
|
9
|
+
metadata?: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
interface AttachmentUploadUrlResult {
|
|
12
|
+
type: "url";
|
|
13
|
+
value: string;
|
|
14
|
+
mimeType?: string;
|
|
15
|
+
/** Custom metadata to include in the InputContent part (merged with auto-generated metadata like filename). */
|
|
16
|
+
metadata?: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
type AttachmentUploadResult = AttachmentUploadDataResult | AttachmentUploadUrlResult;
|
|
19
|
+
type AttachmentUploadErrorReason = "file-too-large" | "invalid-type" | "upload-failed";
|
|
20
|
+
interface AttachmentUploadError {
|
|
21
|
+
/** Why the upload failed. */
|
|
22
|
+
reason: AttachmentUploadErrorReason;
|
|
23
|
+
/** The file that failed to upload. */
|
|
24
|
+
file: File;
|
|
25
|
+
/** Human-readable error message. */
|
|
26
|
+
message: string;
|
|
27
|
+
}
|
|
28
|
+
interface AttachmentsConfig {
|
|
29
|
+
/** Enable file attachments in the chat input */
|
|
30
|
+
enabled: boolean;
|
|
31
|
+
/** MIME type filter for the file input, default all files */
|
|
32
|
+
accept?: string;
|
|
33
|
+
/** Maximum file size in bytes, default 20MB (20 * 1024 * 1024) */
|
|
34
|
+
maxSize?: number;
|
|
35
|
+
/** Custom upload handler. Return an InputContentSource with optional metadata. */
|
|
36
|
+
onUpload?: (file: File) => AttachmentUploadResult | Promise<AttachmentUploadResult>;
|
|
37
|
+
/** Called when an attachment fails validation or upload. Use this to show a toast or inline error. */
|
|
38
|
+
onUploadFailed?: (error: AttachmentUploadError) => void;
|
|
39
|
+
}
|
|
40
|
+
type AttachmentModality = "image" | "audio" | "video" | "document";
|
|
41
|
+
interface Attachment {
|
|
42
|
+
id: string;
|
|
43
|
+
type: AttachmentModality;
|
|
44
|
+
source: InputContentDataSource | InputContentUrlSource;
|
|
45
|
+
filename?: string;
|
|
46
|
+
size?: number;
|
|
47
|
+
status: "uploading" | "ready";
|
|
48
|
+
thumbnail?: string;
|
|
49
|
+
/** Custom metadata from onUpload, included in the InputContent part. */
|
|
50
|
+
metadata?: Record<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { Attachment, AttachmentModality, AttachmentUploadError, AttachmentUploadErrorReason, AttachmentUploadResult, AttachmentsConfig };
|
|
54
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/attachments/types.ts"],"mappings":";;;UAKiB,0BAAA;EACf,IAAA;EACA,KAAA;EACA,QAAA;;EAEA,QAAA,GAAW,MAAA;AAAA;AAAA,UAGI,yBAAA;EACf,IAAA;EACA,KAAA;EACA,QAAA;EANiB;EAQjB,QAAA,GAAW,MAAA;AAAA;AAAA,KAGD,sBAAA,GACR,0BAAA,GACA,yBAAA;AAAA,KAEQ,2BAAA;AAAA,UAKK,qBAAA;EAhBf;EAkBA,MAAA,EAAQ,2BAAA;EAhBR;EAkBA,IAAA,EAAM,IAAA;EAhBK;EAkBX,OAAA;AAAA;AAAA,UAGe,iBAAA;EAlBiB;EAoBhC,OAAA;EAnBE;EAqBF,MAAA;EAlBU;EAoBV,OAAA;;EAEA,QAAA,IACE,IAAA,EAAM,IAAA,KACH,sBAAA,GAAyB,OAAA,CAAQ,sBAAA;EAxBD;EA0BrC,cAAA,IAAkB,KAAA,EAAO,qBAAA;AAAA;AAAA,KAGf,kBAAA;AAAA,UAEK,UAAA;EACf,EAAA;EACA,IAAA,EAAM,kBAAA;EACN,MAAA,EAAQ,sBAAA,GAAyB,qBAAA;EACjC,QAAA;EACA,IAAA;EACA,MAAA;EACA,SAAA;EAxBe;EA0Bf,QAAA,GAAW,MAAA;AAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { InputContentDataSource, InputContentUrlSource } from "@ag-ui/core";
|
|
2
|
+
|
|
3
|
+
//#region src/attachments/types.d.ts
|
|
4
|
+
interface AttachmentUploadDataResult {
|
|
5
|
+
type: "data";
|
|
6
|
+
value: string;
|
|
7
|
+
mimeType: string;
|
|
8
|
+
/** Custom metadata to include in the InputContent part (merged with auto-generated metadata like filename). */
|
|
9
|
+
metadata?: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
interface AttachmentUploadUrlResult {
|
|
12
|
+
type: "url";
|
|
13
|
+
value: string;
|
|
14
|
+
mimeType?: string;
|
|
15
|
+
/** Custom metadata to include in the InputContent part (merged with auto-generated metadata like filename). */
|
|
16
|
+
metadata?: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
type AttachmentUploadResult = AttachmentUploadDataResult | AttachmentUploadUrlResult;
|
|
19
|
+
type AttachmentUploadErrorReason = "file-too-large" | "invalid-type" | "upload-failed";
|
|
20
|
+
interface AttachmentUploadError {
|
|
21
|
+
/** Why the upload failed. */
|
|
22
|
+
reason: AttachmentUploadErrorReason;
|
|
23
|
+
/** The file that failed to upload. */
|
|
24
|
+
file: File;
|
|
25
|
+
/** Human-readable error message. */
|
|
26
|
+
message: string;
|
|
27
|
+
}
|
|
28
|
+
interface AttachmentsConfig {
|
|
29
|
+
/** Enable file attachments in the chat input */
|
|
30
|
+
enabled: boolean;
|
|
31
|
+
/** MIME type filter for the file input, default all files */
|
|
32
|
+
accept?: string;
|
|
33
|
+
/** Maximum file size in bytes, default 20MB (20 * 1024 * 1024) */
|
|
34
|
+
maxSize?: number;
|
|
35
|
+
/** Custom upload handler. Return an InputContentSource with optional metadata. */
|
|
36
|
+
onUpload?: (file: File) => AttachmentUploadResult | Promise<AttachmentUploadResult>;
|
|
37
|
+
/** Called when an attachment fails validation or upload. Use this to show a toast or inline error. */
|
|
38
|
+
onUploadFailed?: (error: AttachmentUploadError) => void;
|
|
39
|
+
}
|
|
40
|
+
type AttachmentModality = "image" | "audio" | "video" | "document";
|
|
41
|
+
interface Attachment {
|
|
42
|
+
id: string;
|
|
43
|
+
type: AttachmentModality;
|
|
44
|
+
source: InputContentDataSource | InputContentUrlSource;
|
|
45
|
+
filename?: string;
|
|
46
|
+
size?: number;
|
|
47
|
+
status: "uploading" | "ready";
|
|
48
|
+
thumbnail?: string;
|
|
49
|
+
/** Custom metadata from onUpload, included in the InputContent part. */
|
|
50
|
+
metadata?: Record<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { Attachment, AttachmentModality, AttachmentUploadError, AttachmentUploadErrorReason, AttachmentUploadResult, AttachmentsConfig };
|
|
54
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/attachments/types.ts"],"mappings":";;;UAKiB,0BAAA;EACf,IAAA;EACA,KAAA;EACA,QAAA;;EAEA,QAAA,GAAW,MAAA;AAAA;AAAA,UAGI,yBAAA;EACf,IAAA;EACA,KAAA;EACA,QAAA;EANiB;EAQjB,QAAA,GAAW,MAAA;AAAA;AAAA,KAGD,sBAAA,GACR,0BAAA,GACA,yBAAA;AAAA,KAEQ,2BAAA;AAAA,UAKK,qBAAA;EAhBf;EAkBA,MAAA,EAAQ,2BAAA;EAhBR;EAkBA,IAAA,EAAM,IAAA;EAhBK;EAkBX,OAAA;AAAA;AAAA,UAGe,iBAAA;EAlBiB;EAoBhC,OAAA;EAnBE;EAqBF,MAAA;EAlBU;EAoBV,OAAA;;EAEA,QAAA,IACE,IAAA,EAAM,IAAA,KACH,sBAAA,GAAyB,OAAA,CAAQ,sBAAA;EAxBD;EA0BrC,cAAA,IAAkB,KAAA,EAAO,qBAAA;AAAA;AAAA,KAGf,kBAAA;AAAA,UAEK,UAAA;EACf,EAAA;EACA,IAAA,EAAM,kBAAA;EACN,MAAA,EAAQ,sBAAA,GAAyB,qBAAA;EACjC,QAAA;EACA,IAAA;EACA,MAAA;EACA,SAAA;EAxBe;EA0Bf,QAAA,GAAW,MAAA;AAAA"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/attachments/utils.ts
|
|
3
|
+
const DEFAULT_MAX_SIZE = 20 * 1024 * 1024;
|
|
4
|
+
/**
|
|
5
|
+
* Derive the attachment modality from a MIME type string.
|
|
6
|
+
*/
|
|
7
|
+
function getModalityFromMimeType(mimeType) {
|
|
8
|
+
if (mimeType.startsWith("image/")) return "image";
|
|
9
|
+
if (mimeType.startsWith("audio/")) return "audio";
|
|
10
|
+
if (mimeType.startsWith("video/")) return "video";
|
|
11
|
+
return "document";
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Format a byte count as a human-readable file size string.
|
|
15
|
+
*/
|
|
16
|
+
function formatFileSize(bytes) {
|
|
17
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
18
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
19
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Check if a file exceeds the maximum allowed size.
|
|
23
|
+
*/
|
|
24
|
+
function exceedsMaxSize(file, maxSize = DEFAULT_MAX_SIZE) {
|
|
25
|
+
return file.size > maxSize;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Read a File as a base64 string (without the data URL prefix).
|
|
29
|
+
*/
|
|
30
|
+
function readFileAsBase64(file) {
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
const reader = new FileReader();
|
|
33
|
+
reader.onload = (e) => {
|
|
34
|
+
const base64 = (e.target?.result)?.split(",")[1];
|
|
35
|
+
if (base64) resolve(base64);
|
|
36
|
+
else reject(/* @__PURE__ */ new Error("Failed to read file as base64"));
|
|
37
|
+
};
|
|
38
|
+
reader.onerror = reject;
|
|
39
|
+
reader.readAsDataURL(file);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Generate a thumbnail data URL from a video file by capturing a frame near the start (at 0.1s).
|
|
44
|
+
* Returns undefined if thumbnail generation fails or if called outside a browser environment.
|
|
45
|
+
*/
|
|
46
|
+
function generateVideoThumbnail(file) {
|
|
47
|
+
if (typeof document === "undefined") return Promise.resolve(void 0);
|
|
48
|
+
return new Promise((resolve) => {
|
|
49
|
+
let resolved = false;
|
|
50
|
+
const video = document.createElement("video");
|
|
51
|
+
const canvas = document.createElement("canvas");
|
|
52
|
+
const url = URL.createObjectURL(file);
|
|
53
|
+
const cleanup = (result) => {
|
|
54
|
+
if (resolved) return;
|
|
55
|
+
resolved = true;
|
|
56
|
+
URL.revokeObjectURL(url);
|
|
57
|
+
resolve(result);
|
|
58
|
+
};
|
|
59
|
+
const timeout = setTimeout(() => {
|
|
60
|
+
console.warn(`[CopilotKit] generateVideoThumbnail: timed out for file "${file.name}"`);
|
|
61
|
+
cleanup(void 0);
|
|
62
|
+
}, 1e4);
|
|
63
|
+
video.preload = "metadata";
|
|
64
|
+
video.muted = true;
|
|
65
|
+
video.playsInline = true;
|
|
66
|
+
video.onloadeddata = () => {
|
|
67
|
+
video.currentTime = .1;
|
|
68
|
+
};
|
|
69
|
+
video.onseeked = () => {
|
|
70
|
+
clearTimeout(timeout);
|
|
71
|
+
canvas.width = video.videoWidth;
|
|
72
|
+
canvas.height = video.videoHeight;
|
|
73
|
+
const ctx = canvas.getContext("2d");
|
|
74
|
+
if (ctx) {
|
|
75
|
+
ctx.drawImage(video, 0, 0);
|
|
76
|
+
cleanup(canvas.toDataURL("image/jpeg", .7));
|
|
77
|
+
} else {
|
|
78
|
+
console.warn("[CopilotKit] generateVideoThumbnail: could not get 2d canvas context");
|
|
79
|
+
cleanup(void 0);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
video.onerror = () => {
|
|
83
|
+
clearTimeout(timeout);
|
|
84
|
+
console.warn(`[CopilotKit] generateVideoThumbnail: video element error for file "${file.name}"`);
|
|
85
|
+
cleanup(void 0);
|
|
86
|
+
};
|
|
87
|
+
video.src = url;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Check if a file's MIME type matches an accept filter string.
|
|
92
|
+
* Handles file extensions (e.g. ".pdf"), MIME wildcards ("image/*"), and comma-separated lists.
|
|
93
|
+
*/
|
|
94
|
+
function matchesAcceptFilter(file, accept) {
|
|
95
|
+
if (!accept || accept === "*/*") return true;
|
|
96
|
+
return accept.split(",").map((f) => f.trim()).some((filter) => {
|
|
97
|
+
if (filter.startsWith(".")) return (file.name ?? "").toLowerCase().endsWith(filter.toLowerCase());
|
|
98
|
+
if (filter.endsWith("/*")) {
|
|
99
|
+
const prefix = filter.slice(0, -2);
|
|
100
|
+
return file.type.startsWith(prefix + "/");
|
|
101
|
+
}
|
|
102
|
+
return file.type === filter;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Convert an InputContentSource to a usable URL string.
|
|
107
|
+
* For data sources, returns a base64 data URL; for URL sources, returns the URL directly.
|
|
108
|
+
*/
|
|
109
|
+
function getSourceUrl(source) {
|
|
110
|
+
if (source.type === "url") return source.value;
|
|
111
|
+
return `data:${source.mimeType};base64,${source.value}`;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Return a short human-readable label for a document MIME type (e.g. "PDF", "DOC").
|
|
115
|
+
*/
|
|
116
|
+
function getDocumentIcon(mimeType) {
|
|
117
|
+
if (mimeType.includes("pdf")) return "PDF";
|
|
118
|
+
if (mimeType.includes("sheet") || mimeType.includes("excel")) return "XLS";
|
|
119
|
+
if (mimeType.includes("presentation") || mimeType.includes("powerpoint")) return "PPT";
|
|
120
|
+
if (mimeType.includes("word") || mimeType.includes("document")) return "DOC";
|
|
121
|
+
if (mimeType.includes("text/")) return "TXT";
|
|
122
|
+
return "FILE";
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
//#endregion
|
|
126
|
+
exports.exceedsMaxSize = exceedsMaxSize;
|
|
127
|
+
exports.formatFileSize = formatFileSize;
|
|
128
|
+
exports.generateVideoThumbnail = generateVideoThumbnail;
|
|
129
|
+
exports.getDocumentIcon = getDocumentIcon;
|
|
130
|
+
exports.getModalityFromMimeType = getModalityFromMimeType;
|
|
131
|
+
exports.getSourceUrl = getSourceUrl;
|
|
132
|
+
exports.matchesAcceptFilter = matchesAcceptFilter;
|
|
133
|
+
exports.readFileAsBase64 = readFileAsBase64;
|
|
134
|
+
//# sourceMappingURL=utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":[],"sources":["../../src/attachments/utils.ts"],"sourcesContent":["import type { AttachmentModality } from \"./types\";\nimport type { InputContentSource } from \"../types/message\";\n\nconst DEFAULT_MAX_SIZE = 20 * 1024 * 1024; // 20MB\n\n/**\n * Derive the attachment modality from a MIME type string.\n */\nexport function getModalityFromMimeType(mimeType: string): AttachmentModality {\n if (mimeType.startsWith(\"image/\")) return \"image\";\n if (mimeType.startsWith(\"audio/\")) return \"audio\";\n if (mimeType.startsWith(\"video/\")) return \"video\";\n return \"document\";\n}\n\n/**\n * Format a byte count as a human-readable file size string.\n */\nexport function formatFileSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n\n/**\n * Check if a file exceeds the maximum allowed size.\n */\nexport function exceedsMaxSize(\n file: File,\n maxSize: number = DEFAULT_MAX_SIZE,\n): boolean {\n return file.size > maxSize;\n}\n\n/**\n * Read a File as a base64 string (without the data URL prefix).\n */\nexport function readFileAsBase64(file: File): Promise<string> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = (e) => {\n const result = e.target?.result as string;\n const base64 = result?.split(\",\")[1];\n if (base64) {\n resolve(base64);\n } else {\n reject(new Error(\"Failed to read file as base64\"));\n }\n };\n reader.onerror = reject;\n reader.readAsDataURL(file);\n });\n}\n\n/**\n * Generate a thumbnail data URL from a video file by capturing a frame near the start (at 0.1s).\n * Returns undefined if thumbnail generation fails or if called outside a browser environment.\n */\nexport function generateVideoThumbnail(\n file: File,\n): Promise<string | undefined> {\n if (typeof document === \"undefined\") {\n return Promise.resolve(undefined);\n }\n return new Promise((resolve) => {\n let resolved = false;\n const video = document.createElement(\"video\");\n const canvas = document.createElement(\"canvas\");\n const url = URL.createObjectURL(file);\n\n const cleanup = (result: string | undefined) => {\n if (resolved) return;\n resolved = true;\n URL.revokeObjectURL(url);\n resolve(result);\n };\n\n const timeout = setTimeout(() => {\n console.warn(\n `[CopilotKit] generateVideoThumbnail: timed out for file \"${file.name}\"`,\n );\n cleanup(undefined);\n }, 10000);\n\n video.preload = \"metadata\";\n video.muted = true;\n video.playsInline = true;\n\n video.onloadeddata = () => {\n video.currentTime = 0.1;\n };\n\n video.onseeked = () => {\n clearTimeout(timeout);\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n const ctx = canvas.getContext(\"2d\");\n if (ctx) {\n ctx.drawImage(video, 0, 0);\n const thumbnail = canvas.toDataURL(\"image/jpeg\", 0.7);\n cleanup(thumbnail);\n } else {\n console.warn(\n \"[CopilotKit] generateVideoThumbnail: could not get 2d canvas context\",\n );\n cleanup(undefined);\n }\n };\n\n video.onerror = () => {\n clearTimeout(timeout);\n console.warn(\n `[CopilotKit] generateVideoThumbnail: video element error for file \"${file.name}\"`,\n );\n cleanup(undefined);\n };\n\n video.src = url;\n });\n}\n\n/**\n * Check if a file's MIME type matches an accept filter string.\n * Handles file extensions (e.g. \".pdf\"), MIME wildcards (\"image/*\"), and comma-separated lists.\n */\nexport function matchesAcceptFilter(file: File, accept: string): boolean {\n if (!accept || accept === \"*/*\") return true;\n\n const filters = accept.split(\",\").map((f) => f.trim());\n return filters.some((filter) => {\n if (filter.startsWith(\".\")) {\n return (file.name ?? \"\").toLowerCase().endsWith(filter.toLowerCase());\n }\n if (filter.endsWith(\"/*\")) {\n const prefix = filter.slice(0, -2);\n return file.type.startsWith(prefix + \"/\");\n }\n return file.type === filter;\n });\n}\n\n/**\n * Convert an InputContentSource to a usable URL string.\n * For data sources, returns a base64 data URL; for URL sources, returns the URL directly.\n */\nexport function getSourceUrl(source: InputContentSource): string {\n if (source.type === \"url\") {\n return source.value;\n }\n return `data:${source.mimeType};base64,${source.value}`;\n}\n\n/**\n * Return a short human-readable label for a document MIME type (e.g. \"PDF\", \"DOC\").\n */\nexport function getDocumentIcon(mimeType: string): string {\n if (mimeType.includes(\"pdf\")) return \"PDF\";\n if (mimeType.includes(\"sheet\") || mimeType.includes(\"excel\")) return \"XLS\";\n if (mimeType.includes(\"presentation\") || mimeType.includes(\"powerpoint\"))\n return \"PPT\";\n if (mimeType.includes(\"word\") || mimeType.includes(\"document\")) return \"DOC\";\n if (mimeType.includes(\"text/\")) return \"TXT\";\n return \"FILE\";\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { InputContentSource } from "../types/message.cjs";
|
|
2
|
+
import { AttachmentModality } from "./types.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/attachments/utils.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Derive the attachment modality from a MIME type string.
|
|
7
|
+
*/
|
|
8
|
+
declare function getModalityFromMimeType(mimeType: string): AttachmentModality;
|
|
9
|
+
/**
|
|
10
|
+
* Format a byte count as a human-readable file size string.
|
|
11
|
+
*/
|
|
12
|
+
declare function formatFileSize(bytes: number): string;
|
|
13
|
+
/**
|
|
14
|
+
* Check if a file exceeds the maximum allowed size.
|
|
15
|
+
*/
|
|
16
|
+
declare function exceedsMaxSize(file: File, maxSize?: number): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Read a File as a base64 string (without the data URL prefix).
|
|
19
|
+
*/
|
|
20
|
+
declare function readFileAsBase64(file: File): Promise<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Generate a thumbnail data URL from a video file by capturing a frame near the start (at 0.1s).
|
|
23
|
+
* Returns undefined if thumbnail generation fails or if called outside a browser environment.
|
|
24
|
+
*/
|
|
25
|
+
declare function generateVideoThumbnail(file: File): Promise<string | undefined>;
|
|
26
|
+
/**
|
|
27
|
+
* Check if a file's MIME type matches an accept filter string.
|
|
28
|
+
* Handles file extensions (e.g. ".pdf"), MIME wildcards ("image/*"), and comma-separated lists.
|
|
29
|
+
*/
|
|
30
|
+
declare function matchesAcceptFilter(file: File, accept: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Convert an InputContentSource to a usable URL string.
|
|
33
|
+
* For data sources, returns a base64 data URL; for URL sources, returns the URL directly.
|
|
34
|
+
*/
|
|
35
|
+
declare function getSourceUrl(source: InputContentSource): string;
|
|
36
|
+
/**
|
|
37
|
+
* Return a short human-readable label for a document MIME type (e.g. "PDF", "DOC").
|
|
38
|
+
*/
|
|
39
|
+
declare function getDocumentIcon(mimeType: string): string;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { exceedsMaxSize, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getSourceUrl, matchesAcceptFilter, readFileAsBase64 };
|
|
42
|
+
//# sourceMappingURL=utils.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.cts","names":[],"sources":["../../src/attachments/utils.ts"],"mappings":";;;;;;AAQA;iBAAgB,uBAAA,CAAwB,QAAA,WAAmB,kBAAA;;;;iBAU3C,cAAA,CAAe,KAAA;;;;iBASf,cAAA,CACd,IAAA,EAAM,IAAA,EACN,OAAA;AAFF;;;AAAA,iBAUgB,gBAAA,CAAiB,IAAA,EAAM,IAAA,GAAO,OAAA;;;;;iBAqB9B,sBAAA,CACd,IAAA,EAAM,IAAA,GACL,OAAA;AAvBH;;;;AAAA,iBAwFgB,mBAAA,CAAoB,IAAA,EAAM,IAAA,EAAM,MAAA;;;;;iBAoBhC,YAAA,CAAa,MAAA,EAAQ,kBAAA;;;;iBAUrB,eAAA,CAAgB,QAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { InputContentSource } from "../types/message.mjs";
|
|
2
|
+
import { AttachmentModality } from "./types.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/attachments/utils.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Derive the attachment modality from a MIME type string.
|
|
7
|
+
*/
|
|
8
|
+
declare function getModalityFromMimeType(mimeType: string): AttachmentModality;
|
|
9
|
+
/**
|
|
10
|
+
* Format a byte count as a human-readable file size string.
|
|
11
|
+
*/
|
|
12
|
+
declare function formatFileSize(bytes: number): string;
|
|
13
|
+
/**
|
|
14
|
+
* Check if a file exceeds the maximum allowed size.
|
|
15
|
+
*/
|
|
16
|
+
declare function exceedsMaxSize(file: File, maxSize?: number): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Read a File as a base64 string (without the data URL prefix).
|
|
19
|
+
*/
|
|
20
|
+
declare function readFileAsBase64(file: File): Promise<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Generate a thumbnail data URL from a video file by capturing a frame near the start (at 0.1s).
|
|
23
|
+
* Returns undefined if thumbnail generation fails or if called outside a browser environment.
|
|
24
|
+
*/
|
|
25
|
+
declare function generateVideoThumbnail(file: File): Promise<string | undefined>;
|
|
26
|
+
/**
|
|
27
|
+
* Check if a file's MIME type matches an accept filter string.
|
|
28
|
+
* Handles file extensions (e.g. ".pdf"), MIME wildcards ("image/*"), and comma-separated lists.
|
|
29
|
+
*/
|
|
30
|
+
declare function matchesAcceptFilter(file: File, accept: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Convert an InputContentSource to a usable URL string.
|
|
33
|
+
* For data sources, returns a base64 data URL; for URL sources, returns the URL directly.
|
|
34
|
+
*/
|
|
35
|
+
declare function getSourceUrl(source: InputContentSource): string;
|
|
36
|
+
/**
|
|
37
|
+
* Return a short human-readable label for a document MIME type (e.g. "PDF", "DOC").
|
|
38
|
+
*/
|
|
39
|
+
declare function getDocumentIcon(mimeType: string): string;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { exceedsMaxSize, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getSourceUrl, matchesAcceptFilter, readFileAsBase64 };
|
|
42
|
+
//# sourceMappingURL=utils.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.mts","names":[],"sources":["../../src/attachments/utils.ts"],"mappings":";;;;;;AAQA;iBAAgB,uBAAA,CAAwB,QAAA,WAAmB,kBAAA;;;;iBAU3C,cAAA,CAAe,KAAA;;;;iBASf,cAAA,CACd,IAAA,EAAM,IAAA,EACN,OAAA;AAFF;;;AAAA,iBAUgB,gBAAA,CAAiB,IAAA,EAAM,IAAA,GAAO,OAAA;;;;;iBAqB9B,sBAAA,CACd,IAAA,EAAM,IAAA,GACL,OAAA;AAvBH;;;;AAAA,iBAwFgB,mBAAA,CAAoB,IAAA,EAAM,IAAA,EAAM,MAAA;;;;;iBAoBhC,YAAA,CAAa,MAAA,EAAQ,kBAAA;;;;iBAUrB,eAAA,CAAgB,QAAA"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
//#region src/attachments/utils.ts
|
|
2
|
+
const DEFAULT_MAX_SIZE = 20 * 1024 * 1024;
|
|
3
|
+
/**
|
|
4
|
+
* Derive the attachment modality from a MIME type string.
|
|
5
|
+
*/
|
|
6
|
+
function getModalityFromMimeType(mimeType) {
|
|
7
|
+
if (mimeType.startsWith("image/")) return "image";
|
|
8
|
+
if (mimeType.startsWith("audio/")) return "audio";
|
|
9
|
+
if (mimeType.startsWith("video/")) return "video";
|
|
10
|
+
return "document";
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Format a byte count as a human-readable file size string.
|
|
14
|
+
*/
|
|
15
|
+
function formatFileSize(bytes) {
|
|
16
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
17
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
18
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Check if a file exceeds the maximum allowed size.
|
|
22
|
+
*/
|
|
23
|
+
function exceedsMaxSize(file, maxSize = DEFAULT_MAX_SIZE) {
|
|
24
|
+
return file.size > maxSize;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Read a File as a base64 string (without the data URL prefix).
|
|
28
|
+
*/
|
|
29
|
+
function readFileAsBase64(file) {
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
const reader = new FileReader();
|
|
32
|
+
reader.onload = (e) => {
|
|
33
|
+
const base64 = (e.target?.result)?.split(",")[1];
|
|
34
|
+
if (base64) resolve(base64);
|
|
35
|
+
else reject(/* @__PURE__ */ new Error("Failed to read file as base64"));
|
|
36
|
+
};
|
|
37
|
+
reader.onerror = reject;
|
|
38
|
+
reader.readAsDataURL(file);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Generate a thumbnail data URL from a video file by capturing a frame near the start (at 0.1s).
|
|
43
|
+
* Returns undefined if thumbnail generation fails or if called outside a browser environment.
|
|
44
|
+
*/
|
|
45
|
+
function generateVideoThumbnail(file) {
|
|
46
|
+
if (typeof document === "undefined") return Promise.resolve(void 0);
|
|
47
|
+
return new Promise((resolve) => {
|
|
48
|
+
let resolved = false;
|
|
49
|
+
const video = document.createElement("video");
|
|
50
|
+
const canvas = document.createElement("canvas");
|
|
51
|
+
const url = URL.createObjectURL(file);
|
|
52
|
+
const cleanup = (result) => {
|
|
53
|
+
if (resolved) return;
|
|
54
|
+
resolved = true;
|
|
55
|
+
URL.revokeObjectURL(url);
|
|
56
|
+
resolve(result);
|
|
57
|
+
};
|
|
58
|
+
const timeout = setTimeout(() => {
|
|
59
|
+
console.warn(`[CopilotKit] generateVideoThumbnail: timed out for file "${file.name}"`);
|
|
60
|
+
cleanup(void 0);
|
|
61
|
+
}, 1e4);
|
|
62
|
+
video.preload = "metadata";
|
|
63
|
+
video.muted = true;
|
|
64
|
+
video.playsInline = true;
|
|
65
|
+
video.onloadeddata = () => {
|
|
66
|
+
video.currentTime = .1;
|
|
67
|
+
};
|
|
68
|
+
video.onseeked = () => {
|
|
69
|
+
clearTimeout(timeout);
|
|
70
|
+
canvas.width = video.videoWidth;
|
|
71
|
+
canvas.height = video.videoHeight;
|
|
72
|
+
const ctx = canvas.getContext("2d");
|
|
73
|
+
if (ctx) {
|
|
74
|
+
ctx.drawImage(video, 0, 0);
|
|
75
|
+
cleanup(canvas.toDataURL("image/jpeg", .7));
|
|
76
|
+
} else {
|
|
77
|
+
console.warn("[CopilotKit] generateVideoThumbnail: could not get 2d canvas context");
|
|
78
|
+
cleanup(void 0);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
video.onerror = () => {
|
|
82
|
+
clearTimeout(timeout);
|
|
83
|
+
console.warn(`[CopilotKit] generateVideoThumbnail: video element error for file "${file.name}"`);
|
|
84
|
+
cleanup(void 0);
|
|
85
|
+
};
|
|
86
|
+
video.src = url;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Check if a file's MIME type matches an accept filter string.
|
|
91
|
+
* Handles file extensions (e.g. ".pdf"), MIME wildcards ("image/*"), and comma-separated lists.
|
|
92
|
+
*/
|
|
93
|
+
function matchesAcceptFilter(file, accept) {
|
|
94
|
+
if (!accept || accept === "*/*") return true;
|
|
95
|
+
return accept.split(",").map((f) => f.trim()).some((filter) => {
|
|
96
|
+
if (filter.startsWith(".")) return (file.name ?? "").toLowerCase().endsWith(filter.toLowerCase());
|
|
97
|
+
if (filter.endsWith("/*")) {
|
|
98
|
+
const prefix = filter.slice(0, -2);
|
|
99
|
+
return file.type.startsWith(prefix + "/");
|
|
100
|
+
}
|
|
101
|
+
return file.type === filter;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Convert an InputContentSource to a usable URL string.
|
|
106
|
+
* For data sources, returns a base64 data URL; for URL sources, returns the URL directly.
|
|
107
|
+
*/
|
|
108
|
+
function getSourceUrl(source) {
|
|
109
|
+
if (source.type === "url") return source.value;
|
|
110
|
+
return `data:${source.mimeType};base64,${source.value}`;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Return a short human-readable label for a document MIME type (e.g. "PDF", "DOC").
|
|
114
|
+
*/
|
|
115
|
+
function getDocumentIcon(mimeType) {
|
|
116
|
+
if (mimeType.includes("pdf")) return "PDF";
|
|
117
|
+
if (mimeType.includes("sheet") || mimeType.includes("excel")) return "XLS";
|
|
118
|
+
if (mimeType.includes("presentation") || mimeType.includes("powerpoint")) return "PPT";
|
|
119
|
+
if (mimeType.includes("word") || mimeType.includes("document")) return "DOC";
|
|
120
|
+
if (mimeType.includes("text/")) return "TXT";
|
|
121
|
+
return "FILE";
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
//#endregion
|
|
125
|
+
export { exceedsMaxSize, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getSourceUrl, matchesAcceptFilter, readFileAsBase64 };
|
|
126
|
+
//# sourceMappingURL=utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":[],"sources":["../../src/attachments/utils.ts"],"sourcesContent":["import type { AttachmentModality } from \"./types\";\nimport type { InputContentSource } from \"../types/message\";\n\nconst DEFAULT_MAX_SIZE = 20 * 1024 * 1024; // 20MB\n\n/**\n * Derive the attachment modality from a MIME type string.\n */\nexport function getModalityFromMimeType(mimeType: string): AttachmentModality {\n if (mimeType.startsWith(\"image/\")) return \"image\";\n if (mimeType.startsWith(\"audio/\")) return \"audio\";\n if (mimeType.startsWith(\"video/\")) return \"video\";\n return \"document\";\n}\n\n/**\n * Format a byte count as a human-readable file size string.\n */\nexport function formatFileSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n\n/**\n * Check if a file exceeds the maximum allowed size.\n */\nexport function exceedsMaxSize(\n file: File,\n maxSize: number = DEFAULT_MAX_SIZE,\n): boolean {\n return file.size > maxSize;\n}\n\n/**\n * Read a File as a base64 string (without the data URL prefix).\n */\nexport function readFileAsBase64(file: File): Promise<string> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = (e) => {\n const result = e.target?.result as string;\n const base64 = result?.split(\",\")[1];\n if (base64) {\n resolve(base64);\n } else {\n reject(new Error(\"Failed to read file as base64\"));\n }\n };\n reader.onerror = reject;\n reader.readAsDataURL(file);\n });\n}\n\n/**\n * Generate a thumbnail data URL from a video file by capturing a frame near the start (at 0.1s).\n * Returns undefined if thumbnail generation fails or if called outside a browser environment.\n */\nexport function generateVideoThumbnail(\n file: File,\n): Promise<string | undefined> {\n if (typeof document === \"undefined\") {\n return Promise.resolve(undefined);\n }\n return new Promise((resolve) => {\n let resolved = false;\n const video = document.createElement(\"video\");\n const canvas = document.createElement(\"canvas\");\n const url = URL.createObjectURL(file);\n\n const cleanup = (result: string | undefined) => {\n if (resolved) return;\n resolved = true;\n URL.revokeObjectURL(url);\n resolve(result);\n };\n\n const timeout = setTimeout(() => {\n console.warn(\n `[CopilotKit] generateVideoThumbnail: timed out for file \"${file.name}\"`,\n );\n cleanup(undefined);\n }, 10000);\n\n video.preload = \"metadata\";\n video.muted = true;\n video.playsInline = true;\n\n video.onloadeddata = () => {\n video.currentTime = 0.1;\n };\n\n video.onseeked = () => {\n clearTimeout(timeout);\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n const ctx = canvas.getContext(\"2d\");\n if (ctx) {\n ctx.drawImage(video, 0, 0);\n const thumbnail = canvas.toDataURL(\"image/jpeg\", 0.7);\n cleanup(thumbnail);\n } else {\n console.warn(\n \"[CopilotKit] generateVideoThumbnail: could not get 2d canvas context\",\n );\n cleanup(undefined);\n }\n };\n\n video.onerror = () => {\n clearTimeout(timeout);\n console.warn(\n `[CopilotKit] generateVideoThumbnail: video element error for file \"${file.name}\"`,\n );\n cleanup(undefined);\n };\n\n video.src = url;\n });\n}\n\n/**\n * Check if a file's MIME type matches an accept filter string.\n * Handles file extensions (e.g. \".pdf\"), MIME wildcards (\"image/*\"), and comma-separated lists.\n */\nexport function matchesAcceptFilter(file: File, accept: string): boolean {\n if (!accept || accept === \"*/*\") return true;\n\n const filters = accept.split(\",\").map((f) => f.trim());\n return filters.some((filter) => {\n if (filter.startsWith(\".\")) {\n return (file.name ?? \"\").toLowerCase().endsWith(filter.toLowerCase());\n }\n if (filter.endsWith(\"/*\")) {\n const prefix = filter.slice(0, -2);\n return file.type.startsWith(prefix + \"/\");\n }\n return file.type === filter;\n });\n}\n\n/**\n * Convert an InputContentSource to a usable URL string.\n * For data sources, returns a base64 data URL; for URL sources, returns the URL directly.\n */\nexport function getSourceUrl(source: InputContentSource): string {\n if (source.type === \"url\") {\n return source.value;\n }\n return `data:${source.mimeType};base64,${source.value}`;\n}\n\n/**\n * Return a short human-readable label for a document MIME type (e.g. \"PDF\", \"DOC\").\n */\nexport function getDocumentIcon(mimeType: string): string {\n if (mimeType.includes(\"pdf\")) return \"PDF\";\n if (mimeType.includes(\"sheet\") || mimeType.includes(\"excel\")) return \"XLS\";\n if (mimeType.includes(\"presentation\") || mimeType.includes(\"powerpoint\"))\n return \"PPT\";\n if (mimeType.includes(\"word\") || mimeType.includes(\"document\")) return \"DOC\";\n if (mimeType.includes(\"text/\")) return \"TXT\";\n return \"FILE\";\n}\n"],"mappings":"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"}
|
package/dist/index.cjs
CHANGED
|
@@ -11,6 +11,7 @@ const require_index$1 = require('./constants/index.cjs');
|
|
|
11
11
|
const require_package = require('./package.cjs');
|
|
12
12
|
const require_telemetry_client = require('./telemetry/telemetry-client.cjs');
|
|
13
13
|
const require_standard_schema = require('./standard-schema.cjs');
|
|
14
|
+
const require_utils = require('./attachments/utils.cjs');
|
|
14
15
|
const require_logger = require('./logger.cjs');
|
|
15
16
|
const require_finalize_events = require('./finalize-events.cjs');
|
|
16
17
|
const require_transcription_errors = require('./transcription-errors.cjs');
|
|
@@ -72,9 +73,15 @@ exports.convertJsonSchemaToZodSchema = require_json_schema.convertJsonSchemaToZo
|
|
|
72
73
|
exports.createLicenseContextValue = createLicenseContextValue;
|
|
73
74
|
exports.dataToUUID = require_random_id.dataToUUID;
|
|
74
75
|
exports.ensureStructuredError = require_errors.ensureStructuredError;
|
|
76
|
+
exports.exceedsMaxSize = require_utils.exceedsMaxSize;
|
|
75
77
|
exports.executeConditions = require_conditions.executeConditions;
|
|
76
78
|
exports.finalizeRunEvents = require_finalize_events.finalizeRunEvents;
|
|
79
|
+
exports.formatFileSize = require_utils.formatFileSize;
|
|
80
|
+
exports.generateVideoThumbnail = require_utils.generateVideoThumbnail;
|
|
81
|
+
exports.getDocumentIcon = require_utils.getDocumentIcon;
|
|
82
|
+
exports.getModalityFromMimeType = require_utils.getModalityFromMimeType;
|
|
77
83
|
exports.getPossibleVersionMismatch = require_errors.getPossibleVersionMismatch;
|
|
84
|
+
exports.getSourceUrl = require_utils.getSourceUrl;
|
|
78
85
|
exports.getZodParameters = require_json_schema.getZodParameters;
|
|
79
86
|
exports.isMacOS = require_index.isMacOS;
|
|
80
87
|
exports.isStructuredCopilotKitError = require_errors.isStructuredCopilotKitError;
|
|
@@ -84,6 +91,7 @@ exports.jsonSchemaToActionParameters = require_json_schema.jsonSchemaToActionPar
|
|
|
84
91
|
exports.logCopilotKitPlatformMessage = require_console_styling.logCopilotKitPlatformMessage;
|
|
85
92
|
exports.logStyled = require_console_styling.logStyled;
|
|
86
93
|
exports.logger = require_logger.logger;
|
|
94
|
+
exports.matchesAcceptFilter = require_utils.matchesAcceptFilter;
|
|
87
95
|
exports.parseJson = require_index.parseJson;
|
|
88
96
|
exports.partialJSONParse = require_index.partialJSONParse;
|
|
89
97
|
exports.phoenixExponentialBackoff = require_index.phoenixExponentialBackoff;
|
|
@@ -91,6 +99,7 @@ exports.publicApiKeyRequired = require_console_styling.publicApiKeyRequired;
|
|
|
91
99
|
exports.randomId = require_random_id.randomId;
|
|
92
100
|
exports.randomUUID = require_random_id.randomUUID;
|
|
93
101
|
exports.readBody = require_requests.readBody;
|
|
102
|
+
exports.readFileAsBase64 = require_utils.readFileAsBase64;
|
|
94
103
|
exports.safeParseToolArgs = require_index.safeParseToolArgs;
|
|
95
104
|
exports.schemaToJsonSchema = require_standard_schema.schemaToJsonSchema;
|
|
96
105
|
exports.styledConsole = require_console_styling.styledConsole;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["export * from \"./types\";\nexport * from \"./utils\";\nexport * from \"./constants\";\nexport * from \"./telemetry\";\nexport * from \"./standard-schema\";\n\nexport { logger } from \"./logger\";\nexport { finalizeRunEvents } from \"./finalize-events\";\n\nexport {\n TranscriptionErrorCode,\n TranscriptionErrors,\n type TranscriptionErrorResponse,\n} from \"./transcription-errors\";\n\nimport * as packageJson from \"../package.json\";\nexport const COPILOTKIT_VERSION = packageJson.version;\n\n// Re-export only types from license-verifier (types are erased at compile time,\n// so they don't pull in the Node-only `crypto` dependency into client bundles).\n// Server-side packages (e.g. @copilotkit/runtime) should import runtime functions\n// like createLicenseChecker and getLicenseWarningHeader directly from\n// @copilotkit/license-verifier.\nexport type {\n LicenseContextValue,\n LicenseChecker,\n LicenseStatus,\n LicensePayload,\n LicenseFeatures,\n LicenseTier,\n LicenseOwner,\n LicenseMode,\n} from \"@copilotkit/license-verifier\";\n\n/**\n * Client-safe license context factory.\n *\n * When status is null (no token provided), all features return true\n * (unlicensed = unrestricted, with branding). This is inlined here to\n * avoid importing the full license-verifier bundle (which depends on\n * Node's `crypto`) into browser bundles.\n */\nexport function createLicenseContextValue(status: null): {\n status: null;\n license: null;\n checkFeature: (feature: string) => boolean;\n getLimit: (feature: string) => number | null;\n} {\n return {\n status: null,\n license: null,\n checkFeature: () => true,\n getLimit: () => null,\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["export * from \"./types\";\nexport * from \"./utils\";\nexport * from \"./constants\";\nexport * from \"./telemetry\";\nexport * from \"./standard-schema\";\nexport * from \"./attachments\";\n\nexport { logger } from \"./logger\";\nexport { finalizeRunEvents } from \"./finalize-events\";\n\nexport {\n TranscriptionErrorCode,\n TranscriptionErrors,\n type TranscriptionErrorResponse,\n} from \"./transcription-errors\";\n\nimport * as packageJson from \"../package.json\";\nexport const COPILOTKIT_VERSION = packageJson.version;\n\n// Re-export only types from license-verifier (types are erased at compile time,\n// so they don't pull in the Node-only `crypto` dependency into client bundles).\n// Server-side packages (e.g. @copilotkit/runtime) should import runtime functions\n// like createLicenseChecker and getLicenseWarningHeader directly from\n// @copilotkit/license-verifier.\nexport type {\n LicenseContextValue,\n LicenseChecker,\n LicenseStatus,\n LicensePayload,\n LicenseFeatures,\n LicenseTier,\n LicenseOwner,\n LicenseMode,\n} from \"@copilotkit/license-verifier\";\n\n/**\n * Client-safe license context factory.\n *\n * When status is null (no token provided), all features return true\n * (unlicensed = unrestricted, with branding). This is inlined here to\n * avoid importing the full license-verifier bundle (which depends on\n * Node's `crypto`) into browser bundles.\n */\nexport function createLicenseContextValue(status: null): {\n status: null;\n license: null;\n checkFeature: (feature: string) => boolean;\n getLimit: (feature: string) => number | null;\n} {\n return {\n status: null,\n license: null,\n checkFeature: () => true,\n getLimit: () => null,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiBA,MAAa;;;;;;;;;AA0Bb,SAAgB,0BAA0B,QAKxC;AACA,QAAO;EACL,QAAQ;EACR,SAAS;EACT,oBAAoB;EACpB,gBAAgB;EACjB"}
|
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,7 @@ import { Action, MappedParameterTypes, Parameter } from "./types/action.cjs";
|
|
|
3
3
|
import { CopilotCloudConfig } from "./types/copilot-cloud-config.cjs";
|
|
4
4
|
import { PartialBy, RequiredBy } from "./types/utility.cjs";
|
|
5
5
|
import { CopilotErrorEvent, CopilotErrorHandler, CopilotRequestContext } from "./types/error.cjs";
|
|
6
|
-
import { AIMessage, ActivityMessage, DeveloperMessage, ImageData, Message, ReasoningMessage, Role, SystemMessage, ToolCall, ToolResult, UserMessage } from "./types/message.cjs";
|
|
6
|
+
import { AIMessage, ActivityMessage, AudioInputPart, DeveloperMessage, DocumentInputPart, ImageData, ImageInputPart, InputContent, InputContentDataSource, InputContentSource, InputContentUrlSource, Message, ReasoningMessage, Role, SystemMessage, TextInputPart, ToolCall, ToolResult, UserMessage, VideoInputPart } from "./types/message.cjs";
|
|
7
7
|
import { BaseCondition, ComparisonCondition, ComparisonRule, Condition, ExistenceCondition, ExistenceRule, LogicalCondition, LogicalRule, Rule, executeConditions } from "./utils/conditions.cjs";
|
|
8
8
|
import { ConsoleColors, ConsoleStyles, logCopilotKitPlatformMessage, logStyled, publicApiKeyRequired, styledConsole } from "./utils/console-styling.cjs";
|
|
9
9
|
import { BANNER_ERROR_NAMES, COPILOT_CLOUD_ERROR_NAMES, ConfigurationError, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, CopilotKitVersionMismatchError, ERROR_CONFIG, ERROR_NAMES, ErrorVisibility, MissingPublicApiKeyError, ResolvedCopilotKitError, Severity, UpgradeRequiredError, ensureStructuredError, getPossibleVersionMismatch, isStructuredCopilotKitError } from "./utils/errors.cjs";
|
|
@@ -15,6 +15,8 @@ import { isMacOS, parseJson, partialJSONParse, phoenixExponentialBackoff, safePa
|
|
|
15
15
|
import { AG_UI_CHANNEL_EVENT, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION, DEFAULT_AGENT_ID } from "./constants/index.cjs";
|
|
16
16
|
import { TelemetryClient, isTelemetryDisabled } from "./telemetry/telemetry-client.cjs";
|
|
17
17
|
import { InferSchemaOutput, SchemaToJsonSchemaOptions, StandardJSONSchemaV1, StandardSchemaV1, schemaToJsonSchema } from "./standard-schema.cjs";
|
|
18
|
+
import { Attachment, AttachmentModality, AttachmentUploadError, AttachmentUploadErrorReason, AttachmentUploadResult, AttachmentsConfig } from "./attachments/types.cjs";
|
|
19
|
+
import { exceedsMaxSize, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getSourceUrl, matchesAcceptFilter, readFileAsBase64 } from "./attachments/utils.cjs";
|
|
18
20
|
import { logger } from "./logger.cjs";
|
|
19
21
|
import { finalizeRunEvents } from "./finalize-events.cjs";
|
|
20
22
|
import { TranscriptionErrorCode, TranscriptionErrorResponse, TranscriptionErrors } from "./transcription-errors.cjs";
|
|
@@ -37,5 +39,5 @@ declare function createLicenseContextValue(status: null): {
|
|
|
37
39
|
getLimit: (feature: string) => number | null;
|
|
38
40
|
};
|
|
39
41
|
//#endregion
|
|
40
|
-
export { AG_UI_CHANNEL_EVENT, AIMessage, Action, ActivityMessage, AgentDescription, AssistantMessage, BANNER_ERROR_NAMES, BaseCondition, COPILOTKIT_VERSION, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_ERROR_NAMES, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION, CoAgentStateRenderHandler, CoAgentStateRenderHandlerArguments, ComparisonCondition, ComparisonRule, Condition, ConfigurationError, ConsoleColors, ConsoleStyles, CopilotCloudConfig, CopilotErrorEvent, CopilotErrorHandler, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, CopilotKitVersionMismatchError, CopilotRequestContext, DEFAULT_AGENT_ID, DeveloperMessage, ERROR_CONFIG, ERROR_NAMES, ErrorVisibility, ExistenceCondition, ExistenceRule, FunctionCallHandler, FunctionCallHandlerArguments, FunctionDefinition, ImageData, InferSchemaOutput, IntelligenceRuntimeInfo, JSONSchema, JSONSchemaArray, JSONSchemaBoolean, JSONSchemaNumber, JSONSchemaObject, JSONSchemaString, JSONValue, type LicenseChecker, type LicenseContextValue, type LicenseFeatures, type LicenseMode, type LicenseOwner, type LicensePayload, type LicenseStatus, type LicenseTier, LogicalCondition, LogicalRule, MappedParameterTypes, MaybePromise, Message, MissingPublicApiKeyError, NonEmptyRecord, Parameter, PartialBy, RUNTIME_MODE_INTELLIGENCE, RUNTIME_MODE_SSE, ReasoningMessage, RequiredBy, ResolvedCopilotKitError, Role, Rule, RuntimeInfo, RuntimeLicenseStatus, RuntimeMode, SchemaToJsonSchemaOptions, Severity, StandardJSONSchemaV1, StandardSchemaV1, SystemMessage, TelemetryClient, ToolCall, ToolDefinition, ToolResult, TranscriptionErrorCode, type TranscriptionErrorResponse, TranscriptionErrors, UpgradeRequiredError, UserMessage, actionParametersToJsonSchema, convertJsonSchemaToZodSchema, createLicenseContextValue, dataToUUID, ensureStructuredError, executeConditions, finalizeRunEvents, getPossibleVersionMismatch, getZodParameters, isMacOS, isStructuredCopilotKitError, isTelemetryDisabled, isValidUUID, jsonSchemaToActionParameters, logCopilotKitPlatformMessage, logStyled, logger, parseJson, partialJSONParse, phoenixExponentialBackoff, publicApiKeyRequired, randomId, randomUUID, readBody, safeParseToolArgs, schemaToJsonSchema, styledConsole, tryMap };
|
|
42
|
+
export { AG_UI_CHANNEL_EVENT, AIMessage, Action, ActivityMessage, AgentDescription, AssistantMessage, Attachment, AttachmentModality, AttachmentUploadError, AttachmentUploadErrorReason, AttachmentUploadResult, AttachmentsConfig, AudioInputPart, BANNER_ERROR_NAMES, BaseCondition, COPILOTKIT_VERSION, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_ERROR_NAMES, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION, CoAgentStateRenderHandler, CoAgentStateRenderHandlerArguments, ComparisonCondition, ComparisonRule, Condition, ConfigurationError, ConsoleColors, ConsoleStyles, CopilotCloudConfig, CopilotErrorEvent, CopilotErrorHandler, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, CopilotKitVersionMismatchError, CopilotRequestContext, DEFAULT_AGENT_ID, DeveloperMessage, DocumentInputPart, ERROR_CONFIG, ERROR_NAMES, ErrorVisibility, ExistenceCondition, ExistenceRule, FunctionCallHandler, FunctionCallHandlerArguments, FunctionDefinition, ImageData, ImageInputPart, InferSchemaOutput, InputContent, InputContentDataSource, InputContentSource, InputContentUrlSource, IntelligenceRuntimeInfo, JSONSchema, JSONSchemaArray, JSONSchemaBoolean, JSONSchemaNumber, JSONSchemaObject, JSONSchemaString, JSONValue, type LicenseChecker, type LicenseContextValue, type LicenseFeatures, type LicenseMode, type LicenseOwner, type LicensePayload, type LicenseStatus, type LicenseTier, LogicalCondition, LogicalRule, MappedParameterTypes, MaybePromise, Message, MissingPublicApiKeyError, NonEmptyRecord, Parameter, PartialBy, RUNTIME_MODE_INTELLIGENCE, RUNTIME_MODE_SSE, ReasoningMessage, RequiredBy, ResolvedCopilotKitError, Role, Rule, RuntimeInfo, RuntimeLicenseStatus, RuntimeMode, SchemaToJsonSchemaOptions, Severity, StandardJSONSchemaV1, StandardSchemaV1, SystemMessage, TelemetryClient, TextInputPart, ToolCall, ToolDefinition, ToolResult, TranscriptionErrorCode, type TranscriptionErrorResponse, TranscriptionErrors, UpgradeRequiredError, UserMessage, VideoInputPart, actionParametersToJsonSchema, convertJsonSchemaToZodSchema, createLicenseContextValue, dataToUUID, ensureStructuredError, exceedsMaxSize, executeConditions, finalizeRunEvents, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getPossibleVersionMismatch, getSourceUrl, getZodParameters, isMacOS, isStructuredCopilotKitError, isTelemetryDisabled, isValidUUID, jsonSchemaToActionParameters, logCopilotKitPlatformMessage, logStyled, logger, matchesAcceptFilter, parseJson, partialJSONParse, phoenixExponentialBackoff, publicApiKeyRequired, randomId, randomUUID, readBody, readFileAsBase64, safeParseToolArgs, schemaToJsonSchema, styledConsole, tryMap };
|
|
41
43
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;cAiBa,kBAAA;;;;;;;;;iBA0BG,yBAAA,CAA0B,MAAA;EACxC,MAAA;EACA,OAAA;EACA,YAAA,GAAe,OAAA;EACf,QAAA,GAAW,OAAA;AAAA"}
|