@demicodes/core 0.10.1 → 0.10.3
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/dist/index.d.mts +8 -54
- package/dist/index.mjs +1 -87
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -11,14 +11,6 @@ type ImageSource = {
|
|
|
11
11
|
type: 'url';
|
|
12
12
|
url: string;
|
|
13
13
|
};
|
|
14
|
-
type VideoSource = {
|
|
15
|
-
type: 'binary';
|
|
16
|
-
data: Uint8Array;
|
|
17
|
-
mediaType: string;
|
|
18
|
-
} | {
|
|
19
|
-
type: 'url';
|
|
20
|
-
url: string;
|
|
21
|
-
};
|
|
22
14
|
interface DocumentSource {
|
|
23
15
|
data: Uint8Array;
|
|
24
16
|
mediaType: string;
|
|
@@ -30,9 +22,6 @@ type UserContentBlock = {
|
|
|
30
22
|
} | {
|
|
31
23
|
type: 'image';
|
|
32
24
|
source: ImageSource;
|
|
33
|
-
} | {
|
|
34
|
-
type: 'video';
|
|
35
|
-
source: VideoSource;
|
|
36
25
|
} | {
|
|
37
26
|
type: 'document';
|
|
38
27
|
source: DocumentSource;
|
|
@@ -44,19 +33,12 @@ interface Base64ImageSource {
|
|
|
44
33
|
mediaType: string;
|
|
45
34
|
data: string;
|
|
46
35
|
}
|
|
47
|
-
interface Base64VideoSource {
|
|
48
|
-
mediaType: string;
|
|
49
|
-
data: string;
|
|
50
|
-
}
|
|
51
36
|
type ToolResultContentBlock = {
|
|
52
37
|
type: 'text';
|
|
53
38
|
text: string;
|
|
54
39
|
} | {
|
|
55
40
|
type: 'image';
|
|
56
41
|
source: Base64ImageSource;
|
|
57
|
-
} | {
|
|
58
|
-
type: 'video';
|
|
59
|
-
source: Base64VideoSource;
|
|
60
42
|
};
|
|
61
43
|
interface TokenUsage {
|
|
62
44
|
inputTokens: number;
|
|
@@ -66,10 +48,7 @@ interface TokenUsage {
|
|
|
66
48
|
}
|
|
67
49
|
/** A `TokenUsage` with every counter at zero. */
|
|
68
50
|
declare function zeroUsage(): TokenUsage;
|
|
69
|
-
type
|
|
70
|
-
type VideoFileExtension = 'mp4' | 'mov' | 'webm' | 'm4v';
|
|
71
|
-
type FileExtension = ImageFileExtension | VideoFileExtension | 'pdf';
|
|
72
|
-
declare const VIDEO_FILE_EXTENSIONS: readonly VideoFileExtension[];
|
|
51
|
+
type FileExtension = 'png' | 'jpg' | 'jpeg' | 'gif' | 'webp' | 'pdf';
|
|
73
52
|
type ThinkingEffort = string;
|
|
74
53
|
type ThinkingSummary = 'auto' | 'concise' | 'detailed' | 'off' | 'on';
|
|
75
54
|
type ThinkingCapability = {
|
|
@@ -111,21 +90,6 @@ interface Model {
|
|
|
111
90
|
thinking: ThinkingCapability[];
|
|
112
91
|
acceptedExtensions: FileExtension[];
|
|
113
92
|
}
|
|
114
|
-
declare function modelAcceptsVideo(model: Model): boolean;
|
|
115
|
-
type ModelMediaKind = 'image' | 'video';
|
|
116
|
-
interface ModelMediaType {
|
|
117
|
-
mediaType: string;
|
|
118
|
-
kind: ModelMediaKind;
|
|
119
|
-
extension: ImageFileExtension | VideoFileExtension;
|
|
120
|
-
}
|
|
121
|
-
declare function modelMediaTypeFor(mediaType: string): ModelMediaType | null;
|
|
122
|
-
/** Whether this model accepts the given media type natively (per its catalog extensions). */
|
|
123
|
-
declare function modelAcceptsMediaType(model: Model, mediaType: string): boolean;
|
|
124
|
-
/**
|
|
125
|
-
* Detect a model-media type from a byte stream's magic numbers. Returns null
|
|
126
|
-
* for anything outside the closed set — callers must not guess further.
|
|
127
|
-
*/
|
|
128
|
-
declare function sniffModelMediaType(bytes: Uint8Array): ModelMediaType | null;
|
|
129
93
|
interface ModelSelection {
|
|
130
94
|
providerId: string;
|
|
131
95
|
model: Model;
|
|
@@ -133,14 +97,6 @@ interface ModelSelection {
|
|
|
133
97
|
serviceTierId?: string | null;
|
|
134
98
|
}
|
|
135
99
|
type ToolCallStatus = 'executing' | 'completed' | 'error';
|
|
136
|
-
interface ProviderErrorDiagnostics {
|
|
137
|
-
source: 'http' | 'stream' | 'transport' | 'unknown';
|
|
138
|
-
clientRequestId?: string;
|
|
139
|
-
providerRequestId?: string;
|
|
140
|
-
providerResponseId?: string;
|
|
141
|
-
providerCode?: string;
|
|
142
|
-
httpStatus?: number;
|
|
143
|
-
}
|
|
144
100
|
type Block = {
|
|
145
101
|
type: 'user';
|
|
146
102
|
id: string;
|
|
@@ -194,13 +150,7 @@ type Block = {
|
|
|
194
150
|
status: ToolCallStatus;
|
|
195
151
|
streamingOutput: ToolResultContentBlock[];
|
|
196
152
|
output: ToolResultContentBlock[];
|
|
197
|
-
|
|
198
|
-
* Bounded UI-facing enhancement data, typed by the tool's owning layer.
|
|
199
|
-
* Never replayed to the model. Must not embed unbounded payloads (full
|
|
200
|
-
* command output, file bodies, raw or base64 bytes) — anything unbounded
|
|
201
|
-
* lives in a command artifact or blob and is referenced by id.
|
|
202
|
-
*/
|
|
203
|
-
view: unknown | null;
|
|
153
|
+
metadata: unknown | null;
|
|
204
154
|
} | {
|
|
205
155
|
type: 'response';
|
|
206
156
|
id: string;
|
|
@@ -214,7 +164,6 @@ type Block = {
|
|
|
214
164
|
model: ModelSelection;
|
|
215
165
|
message: string;
|
|
216
166
|
code: string | null;
|
|
217
|
-
diagnostics?: ProviderErrorDiagnostics;
|
|
218
167
|
} | {
|
|
219
168
|
type: 'abort';
|
|
220
169
|
id: string;
|
|
@@ -251,5 +200,10 @@ interface QueuedMessage {
|
|
|
251
200
|
interface Transcript {
|
|
252
201
|
blocks: Block[];
|
|
253
202
|
}
|
|
203
|
+
interface AgentSessionCoreState {
|
|
204
|
+
transcript: Transcript;
|
|
205
|
+
phase: SessionPhase;
|
|
206
|
+
queue: QueuedMessage[];
|
|
207
|
+
}
|
|
254
208
|
//#endregion
|
|
255
|
-
export {
|
|
209
|
+
export { AgentSessionCoreState, Base64ImageSource, Block, BlockMeta, DocumentSource, FileExtension, ImageSource, Model, ModelSelection, QueuedMessage, SessionPhase, ThinkingCapability, ThinkingConfig, ThinkingEffort, ThinkingSummary, TokenUsage, ToolCallStatus, ToolResultContentBlock, Transcript, UserContentBlock, zeroUsage };
|
package/dist/index.mjs
CHANGED
|
@@ -8,91 +8,5 @@ function zeroUsage() {
|
|
|
8
8
|
cacheWriteTokens: 0
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
-
const VIDEO_FILE_EXTENSIONS = [
|
|
12
|
-
"mp4",
|
|
13
|
-
"mov",
|
|
14
|
-
"webm",
|
|
15
|
-
"m4v"
|
|
16
|
-
];
|
|
17
|
-
function modelAcceptsVideo(model) {
|
|
18
|
-
return VIDEO_FILE_EXTENSIONS.some((extension) => model.acceptedExtensions.includes(extension));
|
|
19
|
-
}
|
|
20
|
-
const MODEL_MEDIA_TYPES = [
|
|
21
|
-
{
|
|
22
|
-
mediaType: "image/png",
|
|
23
|
-
kind: "image",
|
|
24
|
-
extension: "png"
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
mediaType: "image/jpeg",
|
|
28
|
-
kind: "image",
|
|
29
|
-
extension: "jpeg"
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
mediaType: "image/gif",
|
|
33
|
-
kind: "image",
|
|
34
|
-
extension: "gif"
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
mediaType: "image/webp",
|
|
38
|
-
kind: "image",
|
|
39
|
-
extension: "webp"
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
mediaType: "video/mp4",
|
|
43
|
-
kind: "video",
|
|
44
|
-
extension: "mp4"
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
mediaType: "video/x-m4v",
|
|
48
|
-
kind: "video",
|
|
49
|
-
extension: "m4v"
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
mediaType: "video/quicktime",
|
|
53
|
-
kind: "video",
|
|
54
|
-
extension: "mov"
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
mediaType: "video/webm",
|
|
58
|
-
kind: "video",
|
|
59
|
-
extension: "webm"
|
|
60
|
-
}
|
|
61
|
-
];
|
|
62
|
-
function modelMediaTypeFor(mediaType) {
|
|
63
|
-
return MODEL_MEDIA_TYPES.find((entry) => entry.mediaType === mediaType) ?? null;
|
|
64
|
-
}
|
|
65
|
-
/** Whether this model accepts the given media type natively (per its catalog extensions). */
|
|
66
|
-
function modelAcceptsMediaType(model, mediaType) {
|
|
67
|
-
const entry = modelMediaTypeFor(mediaType);
|
|
68
|
-
if (!entry) return false;
|
|
69
|
-
if (model.acceptedExtensions.includes(entry.extension)) return true;
|
|
70
|
-
return entry.extension === "jpeg" && model.acceptedExtensions.includes("jpg");
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Detect a model-media type from a byte stream's magic numbers. Returns null
|
|
74
|
-
* for anything outside the closed set — callers must not guess further.
|
|
75
|
-
*/
|
|
76
|
-
function sniffModelMediaType(bytes) {
|
|
77
|
-
if (bytes.length < 12) return null;
|
|
78
|
-
const at = (index) => bytes[index] ?? 0;
|
|
79
|
-
const ascii = (start, length) => {
|
|
80
|
-
let out = "";
|
|
81
|
-
for (let i = start; i < start + length && i < bytes.length; i += 1) out += String.fromCharCode(at(i));
|
|
82
|
-
return out;
|
|
83
|
-
};
|
|
84
|
-
if (at(0) === 137 && ascii(1, 3) === "PNG") return modelMediaTypeFor("image/png");
|
|
85
|
-
if (at(0) === 255 && at(1) === 216 && at(2) === 255) return modelMediaTypeFor("image/jpeg");
|
|
86
|
-
if (ascii(0, 6) === "GIF87a" || ascii(0, 6) === "GIF89a") return modelMediaTypeFor("image/gif");
|
|
87
|
-
if (ascii(0, 4) === "RIFF" && ascii(8, 4) === "WEBP") return modelMediaTypeFor("image/webp");
|
|
88
|
-
if (at(0) === 26 && at(1) === 69 && at(2) === 223 && at(3) === 163) return modelMediaTypeFor("video/webm");
|
|
89
|
-
if (ascii(4, 4) === "ftyp") {
|
|
90
|
-
const brand = ascii(8, 4);
|
|
91
|
-
if (brand === "qt ") return modelMediaTypeFor("video/quicktime");
|
|
92
|
-
if (brand.startsWith("M4V")) return modelMediaTypeFor("video/x-m4v");
|
|
93
|
-
return modelMediaTypeFor("video/mp4");
|
|
94
|
-
}
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
11
|
//#endregion
|
|
98
|
-
export {
|
|
12
|
+
export { zeroUsage };
|