cognitive-modules-cli 1.4.1 → 2.2.0
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/modules/runner.d.ts +2 -44
- package/dist/modules/runner.js +2 -604
- package/dist/providers/base.d.ts +1 -45
- package/dist/providers/base.js +0 -67
- package/dist/providers/openai.d.ts +3 -27
- package/dist/providers/openai.js +3 -175
- package/dist/types.d.ts +1 -308
- package/dist/types.js +1 -120
- package/package.json +1 -1
- package/src/modules/runner.ts +3 -797
- package/src/providers/base.ts +1 -86
- package/src/providers/openai.ts +4 -226
- package/src/types.ts +1 -454
package/dist/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Cognitive Runtime - Core Types
|
|
3
|
-
* Version 2.
|
|
3
|
+
* Version 2.2 - With Control/Data plane separation, tier, overflow, extensible enums
|
|
4
4
|
*/
|
|
5
5
|
// =============================================================================
|
|
6
6
|
// Utility Types
|
|
@@ -90,122 +90,3 @@ export function shouldEscalate(response, confidenceThreshold = 0.7) {
|
|
|
90
90
|
}
|
|
91
91
|
return false;
|
|
92
92
|
}
|
|
93
|
-
/** Magic bytes for media type detection */
|
|
94
|
-
export const MEDIA_MAGIC_BYTES = {
|
|
95
|
-
'image/jpeg': ['ffd8ff'],
|
|
96
|
-
'image/png': ['89504e470d0a1a0a'],
|
|
97
|
-
'image/gif': ['47494638'],
|
|
98
|
-
'image/webp': ['52494646'],
|
|
99
|
-
'audio/mpeg': ['fffb', 'fffa', '494433'],
|
|
100
|
-
'audio/wav': ['52494646'],
|
|
101
|
-
'audio/ogg': ['4f676753'],
|
|
102
|
-
'video/mp4': ['0000001866747970', '0000002066747970'],
|
|
103
|
-
'video/webm': ['1a45dfa3'],
|
|
104
|
-
'application/pdf': ['25504446'],
|
|
105
|
-
};
|
|
106
|
-
/** Media size limits in bytes */
|
|
107
|
-
export const MEDIA_SIZE_LIMITS = {
|
|
108
|
-
'image': 20 * 1024 * 1024, // 20MB
|
|
109
|
-
'audio': 25 * 1024 * 1024, // 25MB
|
|
110
|
-
'video': 100 * 1024 * 1024, // 100MB
|
|
111
|
-
'document': 50 * 1024 * 1024, // 50MB
|
|
112
|
-
};
|
|
113
|
-
/** Media dimension limits */
|
|
114
|
-
export const MEDIA_DIMENSION_LIMITS = {
|
|
115
|
-
max_width: 8192,
|
|
116
|
-
max_height: 8192,
|
|
117
|
-
min_width: 10,
|
|
118
|
-
min_height: 10,
|
|
119
|
-
max_pixels: 67108864, // 8192 x 8192
|
|
120
|
-
};
|
|
121
|
-
/** Supported image MIME types */
|
|
122
|
-
export const SUPPORTED_IMAGE_TYPES = [
|
|
123
|
-
'image/jpeg',
|
|
124
|
-
'image/png',
|
|
125
|
-
'image/webp',
|
|
126
|
-
'image/gif'
|
|
127
|
-
];
|
|
128
|
-
/** Supported audio MIME types */
|
|
129
|
-
export const SUPPORTED_AUDIO_TYPES = [
|
|
130
|
-
'audio/mpeg',
|
|
131
|
-
'audio/wav',
|
|
132
|
-
'audio/ogg',
|
|
133
|
-
'audio/webm'
|
|
134
|
-
];
|
|
135
|
-
/** Supported video MIME types */
|
|
136
|
-
export const SUPPORTED_VIDEO_TYPES = [
|
|
137
|
-
'video/mp4',
|
|
138
|
-
'video/webm',
|
|
139
|
-
'video/quicktime'
|
|
140
|
-
];
|
|
141
|
-
// =============================================================================
|
|
142
|
-
// v2.5 Error Codes
|
|
143
|
-
// =============================================================================
|
|
144
|
-
/** v2.5 Error codes for streaming and multimodal */
|
|
145
|
-
export const ErrorCodesV25 = {
|
|
146
|
-
// Media errors (E1xxx)
|
|
147
|
-
UNSUPPORTED_MEDIA_TYPE: 'E1010',
|
|
148
|
-
MEDIA_TOO_LARGE: 'E1011',
|
|
149
|
-
MEDIA_FETCH_FAILED: 'E1012',
|
|
150
|
-
MEDIA_DECODE_FAILED: 'E1013',
|
|
151
|
-
MEDIA_TYPE_MISMATCH: 'E1014',
|
|
152
|
-
MEDIA_DIMENSION_EXCEEDED: 'E1015',
|
|
153
|
-
MEDIA_DIMENSION_TOO_SMALL: 'E1016',
|
|
154
|
-
MEDIA_PIXEL_LIMIT: 'E1017',
|
|
155
|
-
UPLOAD_EXPIRED: 'E1018',
|
|
156
|
-
UPLOAD_NOT_FOUND: 'E1019',
|
|
157
|
-
CHECKSUM_MISMATCH: 'E1020',
|
|
158
|
-
// Streaming errors (E2xxx)
|
|
159
|
-
STREAM_INTERRUPTED: 'E2010',
|
|
160
|
-
STREAM_TIMEOUT: 'E2011',
|
|
161
|
-
// Capability errors (E4xxx)
|
|
162
|
-
STREAMING_NOT_SUPPORTED: 'E4010',
|
|
163
|
-
MULTIMODAL_NOT_SUPPORTED: 'E4011',
|
|
164
|
-
RECOVERY_NOT_SUPPORTED: 'E4012',
|
|
165
|
-
SESSION_EXPIRED: 'E4013',
|
|
166
|
-
CHECKPOINT_INVALID: 'E4014',
|
|
167
|
-
};
|
|
168
|
-
/** Default runtime capabilities */
|
|
169
|
-
export const DEFAULT_RUNTIME_CAPABILITIES = {
|
|
170
|
-
streaming: true,
|
|
171
|
-
multimodal: {
|
|
172
|
-
input: ['text', 'image'],
|
|
173
|
-
output: ['text']
|
|
174
|
-
},
|
|
175
|
-
max_media_size_mb: 20,
|
|
176
|
-
supported_transports: ['sse', 'ndjson']
|
|
177
|
-
};
|
|
178
|
-
/** Type guard for v2.5 provider */
|
|
179
|
-
export function isProviderV25(provider) {
|
|
180
|
-
return 'invokeStream' in provider || 'supportsStreaming' in provider;
|
|
181
|
-
}
|
|
182
|
-
/** Type guard for v2.5 module */
|
|
183
|
-
export function isModuleV25(module) {
|
|
184
|
-
return 'response' in module || 'modalities' in module;
|
|
185
|
-
}
|
|
186
|
-
/** Check if module supports streaming */
|
|
187
|
-
export function moduleSupportsStreaming(module) {
|
|
188
|
-
if (!isModuleV25(module))
|
|
189
|
-
return false;
|
|
190
|
-
const mode = module.response?.mode;
|
|
191
|
-
return mode === 'streaming' || mode === 'both';
|
|
192
|
-
}
|
|
193
|
-
/** Check if module supports multimodal input */
|
|
194
|
-
export function moduleSupportsMultimodal(module) {
|
|
195
|
-
if (!isModuleV25(module))
|
|
196
|
-
return false;
|
|
197
|
-
const modalities = module.modalities?.input ?? ['text'];
|
|
198
|
-
return modalities.some(m => m !== 'text');
|
|
199
|
-
}
|
|
200
|
-
/** Get supported input modalities for module */
|
|
201
|
-
export function getModuleInputModalities(module) {
|
|
202
|
-
if (!isModuleV25(module))
|
|
203
|
-
return ['text'];
|
|
204
|
-
return module.modalities?.input ?? ['text'];
|
|
205
|
-
}
|
|
206
|
-
/** Get supported output modalities for module */
|
|
207
|
-
export function getModuleOutputModalities(module) {
|
|
208
|
-
if (!isModuleV25(module))
|
|
209
|
-
return ['text'];
|
|
210
|
-
return module.modalities?.output ?? ['text'];
|
|
211
|
-
}
|