cognitive-modules-cli 1.4.1 → 2.2.1

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.
Files changed (45) hide show
  1. package/dist/cli.js +65 -12
  2. package/dist/commands/compose.d.ts +31 -0
  3. package/dist/commands/compose.js +148 -0
  4. package/dist/commands/index.d.ts +1 -0
  5. package/dist/commands/index.js +1 -0
  6. package/dist/index.d.ts +2 -2
  7. package/dist/index.js +5 -1
  8. package/dist/modules/composition.d.ts +251 -0
  9. package/dist/modules/composition.js +1265 -0
  10. package/dist/modules/composition.test.d.ts +11 -0
  11. package/dist/modules/composition.test.js +450 -0
  12. package/dist/modules/index.d.ts +2 -0
  13. package/dist/modules/index.js +2 -0
  14. package/dist/modules/loader.d.ts +22 -2
  15. package/dist/modules/loader.js +167 -4
  16. package/dist/modules/policy.test.d.ts +10 -0
  17. package/dist/modules/policy.test.js +369 -0
  18. package/dist/modules/runner.d.ts +348 -34
  19. package/dist/modules/runner.js +1263 -708
  20. package/dist/modules/subagent.js +2 -0
  21. package/dist/modules/validator.d.ts +28 -0
  22. package/dist/modules/validator.js +629 -0
  23. package/dist/providers/base.d.ts +1 -45
  24. package/dist/providers/base.js +0 -67
  25. package/dist/providers/openai.d.ts +3 -27
  26. package/dist/providers/openai.js +3 -175
  27. package/dist/types.d.ts +93 -316
  28. package/dist/types.js +1 -120
  29. package/package.json +2 -1
  30. package/src/cli.ts +73 -12
  31. package/src/commands/compose.ts +185 -0
  32. package/src/commands/index.ts +1 -0
  33. package/src/index.ts +35 -0
  34. package/src/modules/composition.test.ts +558 -0
  35. package/src/modules/composition.ts +1674 -0
  36. package/src/modules/index.ts +2 -0
  37. package/src/modules/loader.ts +196 -6
  38. package/src/modules/policy.test.ts +455 -0
  39. package/src/modules/runner.ts +1692 -998
  40. package/src/modules/subagent.ts +2 -0
  41. package/src/modules/validator.ts +700 -0
  42. package/src/providers/base.ts +1 -86
  43. package/src/providers/openai.ts +4 -226
  44. package/src/types.ts +113 -462
  45. package/tsconfig.json +1 -1
package/dist/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Cognitive Runtime - Core Types
3
- * Version 2.5 - With streaming response and multimodal support
3
+ * Version 2.2 - With Control/Data plane separation, tier, overflow, extensible enums
4
4
  */
5
5
  export interface Provider {
6
6
  name: string;
@@ -35,6 +35,77 @@ export type RiskLevel = 'none' | 'low' | 'medium' | 'high';
35
35
  export type EnumStrategy = 'strict' | 'extensible';
36
36
  /** Risk aggregation rule */
37
37
  export type RiskRule = 'max_changes_risk' | 'max_issues_risk' | 'explicit';
38
+ /** Composition pattern types */
39
+ export type CompositionPattern = 'sequential' | 'parallel' | 'conditional' | 'iterative';
40
+ /** Aggregation strategy for combining multiple outputs */
41
+ export type AggregationStrategy = 'merge' | 'array' | 'first' | 'custom';
42
+ /** Semver-like version matching pattern */
43
+ export type VersionPattern = string;
44
+ /** Dependency declaration for composition.requires */
45
+ export interface DependencyDeclaration {
46
+ /** Module name */
47
+ name: string;
48
+ /** Semver version pattern */
49
+ version?: VersionPattern;
50
+ /** Whether dependency is optional */
51
+ optional?: boolean;
52
+ /** Fallback module if unavailable */
53
+ fallback?: string | null;
54
+ /** Per-module timeout (ms) */
55
+ timeout_ms?: number;
56
+ }
57
+ /** Dataflow mapping expression */
58
+ export interface DataflowMapping {
59
+ [key: string]: string;
60
+ }
61
+ /** Dataflow step configuration */
62
+ export interface DataflowStep {
63
+ /** Source of data: 'input' or 'module-name.output' */
64
+ from: string | string[];
65
+ /** Destination: module name or 'output' */
66
+ to: string | string[];
67
+ /** Field mapping expressions */
68
+ mapping?: DataflowMapping;
69
+ /** Condition for execution */
70
+ condition?: string;
71
+ /** Aggregation strategy when from is an array */
72
+ aggregate?: AggregationStrategy;
73
+ /** Custom aggregation function name */
74
+ aggregator?: string;
75
+ }
76
+ /** Conditional routing rule */
77
+ export interface RoutingRule {
78
+ /** Condition expression */
79
+ condition: string;
80
+ /** Next module to execute (null means use current result) */
81
+ next: string | null;
82
+ }
83
+ /** Iteration configuration */
84
+ export interface IterationConfig {
85
+ /** Maximum iterations */
86
+ max_iterations?: number;
87
+ /** Condition to continue iterating */
88
+ continue_condition?: string;
89
+ /** Condition to stop iterating */
90
+ stop_condition?: string;
91
+ }
92
+ /** Full composition configuration (from module.yaml) */
93
+ export interface CompositionConfig {
94
+ /** Composition pattern */
95
+ pattern: CompositionPattern;
96
+ /** Required dependencies */
97
+ requires?: DependencyDeclaration[];
98
+ /** Dataflow configuration */
99
+ dataflow?: DataflowStep[];
100
+ /** Conditional routing rules */
101
+ routing?: RoutingRule[];
102
+ /** Maximum composition depth */
103
+ max_depth?: number;
104
+ /** Total timeout for composition (ms) */
105
+ timeout_ms?: number;
106
+ /** Iteration configuration */
107
+ iteration?: IterationConfig;
108
+ }
38
109
  export interface CognitiveModule {
39
110
  name: string;
40
111
  version: string;
@@ -52,6 +123,7 @@ export interface CognitiveModule {
52
123
  enums?: EnumConfig;
53
124
  compat?: CompatConfig;
54
125
  metaConfig?: MetaConfig;
126
+ composition?: CompositionConfig;
55
127
  context?: 'fork' | 'main';
56
128
  prompt: string;
57
129
  inputSchema?: object;
@@ -148,20 +220,34 @@ export interface EnvelopeMeta {
148
220
  /** Execution latency in milliseconds */
149
221
  latency_ms?: number;
150
222
  }
223
+ /**
224
+ * Enhanced error structure with retry and recovery info (v2.2.1).
225
+ */
226
+ export interface EnvelopeError {
227
+ /** Error code (e.g., "INVALID_INPUT", "PARSE_ERROR") */
228
+ code: string;
229
+ /** Human-readable error message */
230
+ message: string;
231
+ /** Whether the error can be retried */
232
+ recoverable?: boolean;
233
+ /** Suggested wait time before retry (in milliseconds) */
234
+ retry_after_ms?: number;
235
+ /** Additional error context */
236
+ details?: Record<string, unknown>;
237
+ }
151
238
  /** Success response in v2.2 envelope format */
152
239
  export interface EnvelopeSuccessV22<T = unknown> {
153
240
  ok: true;
241
+ version?: string;
154
242
  meta: EnvelopeMeta;
155
243
  data: T;
156
244
  }
157
245
  /** Error response in v2.2 envelope format */
158
246
  export interface EnvelopeErrorV22 {
159
247
  ok: false;
248
+ version?: string;
160
249
  meta: EnvelopeMeta;
161
- error: {
162
- code: string;
163
- message: string;
164
- };
250
+ error: EnvelopeError;
165
251
  partial_data?: unknown;
166
252
  }
167
253
  /** v2.2 envelope response (union type) */
@@ -217,12 +303,10 @@ export interface ModuleResultData {
217
303
  /** v2.2 module result with meta and data separation */
218
304
  export interface ModuleResultV22 {
219
305
  ok: boolean;
306
+ version?: string;
220
307
  meta: EnvelopeMeta;
221
308
  data?: ModuleResultData;
222
- error?: {
223
- code: string;
224
- message: string;
225
- };
309
+ error?: EnvelopeError;
226
310
  partial_data?: unknown;
227
311
  raw?: string;
228
312
  }
@@ -282,310 +366,3 @@ export declare function extractMeta<T>(response: EnvelopeResponse<T>, riskRule?:
282
366
  export declare function aggregateRisk(data: Record<string, unknown>, riskRule?: RiskRule): RiskLevel;
283
367
  /** Check if result should be escalated to human review */
284
368
  export declare function shouldEscalate<T>(response: EnvelopeResponse<T>, confidenceThreshold?: number): boolean;
285
- /** Response mode configuration */
286
- export type ResponseMode = 'sync' | 'streaming' | 'both';
287
- /** Chunk type for streaming */
288
- export type ChunkType = 'delta' | 'snapshot';
289
- /** Response configuration in module.yaml */
290
- export interface ResponseConfig {
291
- mode: ResponseMode;
292
- chunk_type?: ChunkType;
293
- buffer_size?: number;
294
- heartbeat_interval_ms?: number;
295
- max_duration_ms?: number;
296
- }
297
- /** Meta chunk - initial streaming response */
298
- export interface MetaChunk {
299
- ok: true;
300
- streaming: true;
301
- session_id: string;
302
- resumed?: boolean;
303
- resume_from_seq?: number;
304
- meta: Partial<EnvelopeMeta>;
305
- }
306
- /** Delta chunk - incremental content */
307
- export interface DeltaChunk {
308
- chunk: {
309
- seq: number;
310
- type: 'delta';
311
- field?: string;
312
- delta: string;
313
- checkpoint?: Checkpoint;
314
- };
315
- }
316
- /** Snapshot chunk - full state replacement */
317
- export interface SnapshotChunk {
318
- chunk: {
319
- seq: number;
320
- type: 'snapshot';
321
- field?: string;
322
- data: unknown;
323
- };
324
- }
325
- /** Progress chunk - progress update */
326
- export interface ProgressChunk {
327
- progress: {
328
- percent: number;
329
- stage?: string;
330
- message?: string;
331
- };
332
- }
333
- /** Final chunk - completion signal */
334
- export interface FinalChunk {
335
- final: true;
336
- meta: EnvelopeMeta;
337
- data: ModuleResultData;
338
- usage?: {
339
- input_tokens: number;
340
- output_tokens: number;
341
- total_tokens: number;
342
- };
343
- }
344
- /** Recovery checkpoint for stream resume */
345
- export interface Checkpoint {
346
- offset: number;
347
- hash: string;
348
- }
349
- /** Recovery information in error */
350
- export interface RecoveryInfo {
351
- last_seq: number;
352
- last_checkpoint?: Checkpoint;
353
- retry_after_ms?: number;
354
- max_retries?: number;
355
- }
356
- /** Error with optional recovery information */
357
- export interface ErrorWithRecovery {
358
- code: string;
359
- message: string;
360
- recoverable?: boolean;
361
- recovery?: RecoveryInfo;
362
- details?: Record<string, unknown>;
363
- }
364
- /** Error chunk during streaming */
365
- export interface ErrorChunk {
366
- ok: false;
367
- streaming: true;
368
- session_id?: string;
369
- error: ErrorWithRecovery;
370
- partial_data?: unknown;
371
- }
372
- /** Union of all streaming chunk types */
373
- export type StreamingChunk = MetaChunk | DeltaChunk | SnapshotChunk | ProgressChunk | FinalChunk | ErrorChunk;
374
- /** Streaming session state */
375
- export interface StreamingSession {
376
- session_id: string;
377
- module_name: string;
378
- started_at: number;
379
- chunks_sent: number;
380
- accumulated_data: Record<string, unknown>;
381
- accumulated_text: Record<string, string>;
382
- last_checkpoint?: Checkpoint;
383
- }
384
- /** Request options for response mode negotiation */
385
- export interface RequestOptions {
386
- response_mode?: ResponseMode;
387
- chunk_type?: ChunkType;
388
- }
389
- /** Recovery context for stream retry */
390
- export interface RecoveryContext {
391
- session_id: string;
392
- last_seq: number;
393
- last_checkpoint?: Checkpoint;
394
- }
395
- /** Warning in response (for fallback scenarios) */
396
- export interface ResponseWarning {
397
- code: string;
398
- message: string;
399
- fallback_used?: string;
400
- }
401
- /** Execute options with negotiation support */
402
- export interface ExecuteOptionsV25 {
403
- input: Record<string, unknown>;
404
- _options?: RequestOptions;
405
- _recovery?: RecoveryContext;
406
- }
407
- /** Negotiation result */
408
- export interface NegotiationResult {
409
- mode: ResponseMode;
410
- reason: 'header' | 'body_option' | 'query_param' | 'accept_header' | 'module_default';
411
- warnings?: ResponseWarning[];
412
- }
413
- /** Supported modality types */
414
- export type ModalityType = 'text' | 'image' | 'audio' | 'video' | 'document';
415
- /** Modalities configuration in module.yaml */
416
- export interface ModalitiesConfig {
417
- input: ModalityType[];
418
- output: ModalityType[];
419
- constraints?: MediaConstraints;
420
- }
421
- /** Media size/duration constraints */
422
- export interface MediaConstraints {
423
- max_image_size_mb?: number;
424
- max_audio_size_mb?: number;
425
- max_video_size_mb?: number;
426
- max_audio_duration_s?: number;
427
- max_video_duration_s?: number;
428
- allowed_image_types?: string[];
429
- allowed_audio_types?: string[];
430
- allowed_video_types?: string[];
431
- }
432
- /** Media input - URL reference */
433
- export interface UrlMediaInput {
434
- type: 'url';
435
- url: string;
436
- media_type?: string;
437
- }
438
- /** Media input - Base64 inline */
439
- export interface Base64MediaInput {
440
- type: 'base64';
441
- media_type: string;
442
- data: string;
443
- }
444
- /** Media input - File path */
445
- export interface FileMediaInput {
446
- type: 'file';
447
- path: string;
448
- }
449
- /** Media input - Upload reference (for pre-uploaded files) */
450
- export interface UploadRefMediaInput {
451
- type: 'upload_ref';
452
- upload_id: string;
453
- media_type?: string;
454
- }
455
- /** Union of media input types */
456
- export type MediaInput = UrlMediaInput | Base64MediaInput | FileMediaInput | UploadRefMediaInput;
457
- /** Checksum for media integrity */
458
- export interface MediaChecksum {
459
- algorithm: 'sha256' | 'md5' | 'crc32';
460
- value: string;
461
- }
462
- /** Media validation result */
463
- export interface MediaValidationResult {
464
- index: number;
465
- media_type: string;
466
- size_bytes: number;
467
- dimensions?: {
468
- width: number;
469
- height: number;
470
- };
471
- duration_ms?: number;
472
- valid: boolean;
473
- errors?: string[];
474
- }
475
- /** Media validation summary in meta */
476
- export interface MediaValidationSummary {
477
- input_count: number;
478
- validated: MediaValidationResult[];
479
- }
480
- /** Magic bytes for media type detection */
481
- export declare const MEDIA_MAGIC_BYTES: Record<string, string[]>;
482
- /** Media size limits in bytes */
483
- export declare const MEDIA_SIZE_LIMITS: Record<string, number>;
484
- /** Media dimension limits */
485
- export declare const MEDIA_DIMENSION_LIMITS: {
486
- max_width: number;
487
- max_height: number;
488
- min_width: number;
489
- min_height: number;
490
- max_pixels: number;
491
- };
492
- /** Media output with metadata */
493
- export interface MediaOutput {
494
- type: 'url' | 'base64' | 'file';
495
- media_type: string;
496
- url?: string;
497
- data?: string;
498
- path?: string;
499
- width?: number;
500
- height?: number;
501
- duration_ms?: number;
502
- expires_at?: string;
503
- generation_params?: Record<string, unknown>;
504
- }
505
- /** Supported image MIME types */
506
- export declare const SUPPORTED_IMAGE_TYPES: readonly ["image/jpeg", "image/png", "image/webp", "image/gif"];
507
- /** Supported audio MIME types */
508
- export declare const SUPPORTED_AUDIO_TYPES: readonly ["audio/mpeg", "audio/wav", "audio/ogg", "audio/webm"];
509
- /** Supported video MIME types */
510
- export declare const SUPPORTED_VIDEO_TYPES: readonly ["video/mp4", "video/webm", "video/quicktime"];
511
- /** v2.5 Error codes for streaming and multimodal */
512
- export declare const ErrorCodesV25: {
513
- readonly UNSUPPORTED_MEDIA_TYPE: "E1010";
514
- readonly MEDIA_TOO_LARGE: "E1011";
515
- readonly MEDIA_FETCH_FAILED: "E1012";
516
- readonly MEDIA_DECODE_FAILED: "E1013";
517
- readonly MEDIA_TYPE_MISMATCH: "E1014";
518
- readonly MEDIA_DIMENSION_EXCEEDED: "E1015";
519
- readonly MEDIA_DIMENSION_TOO_SMALL: "E1016";
520
- readonly MEDIA_PIXEL_LIMIT: "E1017";
521
- readonly UPLOAD_EXPIRED: "E1018";
522
- readonly UPLOAD_NOT_FOUND: "E1019";
523
- readonly CHECKSUM_MISMATCH: "E1020";
524
- readonly STREAM_INTERRUPTED: "E2010";
525
- readonly STREAM_TIMEOUT: "E2011";
526
- readonly STREAMING_NOT_SUPPORTED: "E4010";
527
- readonly MULTIMODAL_NOT_SUPPORTED: "E4011";
528
- readonly RECOVERY_NOT_SUPPORTED: "E4012";
529
- readonly SESSION_EXPIRED: "E4013";
530
- readonly CHECKPOINT_INVALID: "E4014";
531
- };
532
- export type ErrorCodeV25 = typeof ErrorCodesV25[keyof typeof ErrorCodesV25];
533
- /** Runtime capability declaration */
534
- export interface RuntimeCapabilities {
535
- streaming: boolean;
536
- multimodal: {
537
- input: ModalityType[];
538
- output: ModalityType[];
539
- };
540
- max_media_size_mb: number;
541
- supported_transports: ('sse' | 'websocket' | 'ndjson')[];
542
- }
543
- /** Default runtime capabilities */
544
- export declare const DEFAULT_RUNTIME_CAPABILITIES: RuntimeCapabilities;
545
- /** Extended invoke params with streaming support */
546
- export interface InvokeParamsV25 extends InvokeParams {
547
- stream?: boolean;
548
- images?: MediaInput[];
549
- audio?: MediaInput[];
550
- video?: MediaInput[];
551
- }
552
- /** Streaming invoke result */
553
- export interface StreamingInvokeResult {
554
- stream: AsyncIterable<string>;
555
- usage?: {
556
- promptTokens: number;
557
- completionTokens: number;
558
- totalTokens: number;
559
- };
560
- }
561
- /** Extended provider interface for v2.5 */
562
- export interface ProviderV25 extends Provider {
563
- /** Check if provider supports streaming */
564
- supportsStreaming?(): boolean;
565
- /** Check if provider supports multimodal input */
566
- supportsMultimodal?(): {
567
- input: ModalityType[];
568
- output: ModalityType[];
569
- };
570
- /** Invoke with streaming */
571
- invokeStream?(params: InvokeParamsV25): Promise<StreamingInvokeResult>;
572
- }
573
- /** Type guard for v2.5 provider */
574
- export declare function isProviderV25(provider: Provider): provider is ProviderV25;
575
- /** Extended module interface for v2.5 */
576
- export interface CognitiveModuleV25 extends CognitiveModule {
577
- /** v2.5: Response configuration */
578
- response?: ResponseConfig;
579
- /** v2.5: Modalities configuration */
580
- modalities?: ModalitiesConfig;
581
- }
582
- /** Type guard for v2.5 module */
583
- export declare function isModuleV25(module: CognitiveModule): module is CognitiveModuleV25;
584
- /** Check if module supports streaming */
585
- export declare function moduleSupportsStreaming(module: CognitiveModule): boolean;
586
- /** Check if module supports multimodal input */
587
- export declare function moduleSupportsMultimodal(module: CognitiveModule): boolean;
588
- /** Get supported input modalities for module */
589
- export declare function getModuleInputModalities(module: CognitiveModule): ModalityType[];
590
- /** Get supported output modalities for module */
591
- export declare function getModuleOutputModalities(module: CognitiveModule): ModalityType[];
package/dist/types.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Cognitive Runtime - Core Types
3
- * Version 2.5 - With streaming response and multimodal support
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
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cognitive-modules-cli",
3
- "version": "1.4.1",
3
+ "version": "2.2.1",
4
4
  "description": "Cognitive Modules - Structured AI Task Execution with version management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -37,6 +37,7 @@
37
37
  "node": ">=18.0.0"
38
38
  },
39
39
  "dependencies": {
40
+ "ajv": "^8.12.0",
40
41
  "js-yaml": "^4.1.1"
41
42
  },
42
43
  "optionalDependencies": {