cognitive-modules-cli 1.4.0 → 1.4.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.
package/dist/types.d.ts CHANGED
@@ -299,6 +299,8 @@ export interface MetaChunk {
299
299
  ok: true;
300
300
  streaming: true;
301
301
  session_id: string;
302
+ resumed?: boolean;
303
+ resume_from_seq?: number;
302
304
  meta: Partial<EnvelopeMeta>;
303
305
  }
304
306
  /** Delta chunk - incremental content */
@@ -308,6 +310,7 @@ export interface DeltaChunk {
308
310
  type: 'delta';
309
311
  field?: string;
310
312
  delta: string;
313
+ checkpoint?: Checkpoint;
311
314
  };
312
315
  }
313
316
  /** Snapshot chunk - full state replacement */
@@ -338,16 +341,32 @@ export interface FinalChunk {
338
341
  total_tokens: number;
339
342
  };
340
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
+ }
341
364
  /** Error chunk during streaming */
342
365
  export interface ErrorChunk {
343
366
  ok: false;
344
367
  streaming: true;
345
368
  session_id?: string;
346
- error: {
347
- code: string;
348
- message: string;
349
- recoverable?: boolean;
350
- };
369
+ error: ErrorWithRecovery;
351
370
  partial_data?: unknown;
352
371
  }
353
372
  /** Union of all streaming chunk types */
@@ -360,6 +379,36 @@ export interface StreamingSession {
360
379
  chunks_sent: number;
361
380
  accumulated_data: Record<string, unknown>;
362
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[];
363
412
  }
364
413
  /** Supported modality types */
365
414
  export type ModalityType = 'text' | 'image' | 'audio' | 'video' | 'document';
@@ -397,8 +446,49 @@ export interface FileMediaInput {
397
446
  type: 'file';
398
447
  path: string;
399
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
+ }
400
455
  /** Union of media input types */
401
- export type MediaInput = UrlMediaInput | Base64MediaInput | FileMediaInput;
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
+ };
402
492
  /** Media output with metadata */
403
493
  export interface MediaOutput {
404
494
  type: 'url' | 'base64' | 'file';
@@ -424,10 +514,20 @@ export declare const ErrorCodesV25: {
424
514
  readonly MEDIA_TOO_LARGE: "E1011";
425
515
  readonly MEDIA_FETCH_FAILED: "E1012";
426
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";
427
524
  readonly STREAM_INTERRUPTED: "E2010";
428
525
  readonly STREAM_TIMEOUT: "E2011";
429
526
  readonly STREAMING_NOT_SUPPORTED: "E4010";
430
527
  readonly MULTIMODAL_NOT_SUPPORTED: "E4011";
528
+ readonly RECOVERY_NOT_SUPPORTED: "E4012";
529
+ readonly SESSION_EXPIRED: "E4013";
530
+ readonly CHECKPOINT_INVALID: "E4014";
431
531
  };
432
532
  export type ErrorCodeV25 = typeof ErrorCodesV25[keyof typeof ErrorCodesV25];
433
533
  /** Runtime capability declaration */
package/dist/types.js CHANGED
@@ -90,6 +90,34 @@ 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
+ };
93
121
  /** Supported image MIME types */
94
122
  export const SUPPORTED_IMAGE_TYPES = [
95
123
  'image/jpeg',
@@ -120,12 +148,22 @@ export const ErrorCodesV25 = {
120
148
  MEDIA_TOO_LARGE: 'E1011',
121
149
  MEDIA_FETCH_FAILED: 'E1012',
122
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',
123
158
  // Streaming errors (E2xxx)
124
159
  STREAM_INTERRUPTED: 'E2010',
125
160
  STREAM_TIMEOUT: 'E2011',
126
161
  // Capability errors (E4xxx)
127
162
  STREAMING_NOT_SUPPORTED: 'E4010',
128
163
  MULTIMODAL_NOT_SUPPORTED: 'E4011',
164
+ RECOVERY_NOT_SUPPORTED: 'E4012',
165
+ SESSION_EXPIRED: 'E4013',
166
+ CHECKPOINT_INVALID: 'E4014',
129
167
  };
130
168
  /** Default runtime capabilities */
131
169
  export const DEFAULT_RUNTIME_CAPABILITIES = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cognitive-modules-cli",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Cognitive Modules - Structured AI Task Execution with version management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/types.ts CHANGED
@@ -518,6 +518,8 @@ export interface MetaChunk {
518
518
  ok: true;
519
519
  streaming: true;
520
520
  session_id: string;
521
+ resumed?: boolean;
522
+ resume_from_seq?: number;
521
523
  meta: Partial<EnvelopeMeta>;
522
524
  }
523
525
 
@@ -528,6 +530,7 @@ export interface DeltaChunk {
528
530
  type: 'delta';
529
531
  field?: string;
530
532
  delta: string;
533
+ checkpoint?: Checkpoint;
531
534
  };
532
535
  }
533
536
 
@@ -562,16 +565,35 @@ export interface FinalChunk {
562
565
  };
563
566
  }
564
567
 
568
+ /** Recovery checkpoint for stream resume */
569
+ export interface Checkpoint {
570
+ offset: number;
571
+ hash: string; // First 6 chars of SHA256
572
+ }
573
+
574
+ /** Recovery information in error */
575
+ export interface RecoveryInfo {
576
+ last_seq: number;
577
+ last_checkpoint?: Checkpoint;
578
+ retry_after_ms?: number;
579
+ max_retries?: number;
580
+ }
581
+
582
+ /** Error with optional recovery information */
583
+ export interface ErrorWithRecovery {
584
+ code: string;
585
+ message: string;
586
+ recoverable?: boolean;
587
+ recovery?: RecoveryInfo;
588
+ details?: Record<string, unknown>;
589
+ }
590
+
565
591
  /** Error chunk during streaming */
566
592
  export interface ErrorChunk {
567
593
  ok: false;
568
594
  streaming: true;
569
595
  session_id?: string;
570
- error: {
571
- code: string;
572
- message: string;
573
- recoverable?: boolean;
574
- };
596
+ error: ErrorWithRecovery;
575
597
  partial_data?: unknown;
576
598
  }
577
599
 
@@ -592,6 +614,45 @@ export interface StreamingSession {
592
614
  chunks_sent: number;
593
615
  accumulated_data: Record<string, unknown>;
594
616
  accumulated_text: Record<string, string>;
617
+ last_checkpoint?: Checkpoint;
618
+ }
619
+
620
+ // =============================================================================
621
+ // v2.5 Response Mode Negotiation
622
+ // =============================================================================
623
+
624
+ /** Request options for response mode negotiation */
625
+ export interface RequestOptions {
626
+ response_mode?: ResponseMode;
627
+ chunk_type?: ChunkType;
628
+ }
629
+
630
+ /** Recovery context for stream retry */
631
+ export interface RecoveryContext {
632
+ session_id: string;
633
+ last_seq: number;
634
+ last_checkpoint?: Checkpoint;
635
+ }
636
+
637
+ /** Warning in response (for fallback scenarios) */
638
+ export interface ResponseWarning {
639
+ code: string;
640
+ message: string;
641
+ fallback_used?: string;
642
+ }
643
+
644
+ /** Execute options with negotiation support */
645
+ export interface ExecuteOptionsV25 {
646
+ input: Record<string, unknown>;
647
+ _options?: RequestOptions;
648
+ _recovery?: RecoveryContext;
649
+ }
650
+
651
+ /** Negotiation result */
652
+ export interface NegotiationResult {
653
+ mode: ResponseMode;
654
+ reason: 'header' | 'body_option' | 'query_param' | 'accept_header' | 'module_default';
655
+ warnings?: ResponseWarning[];
595
656
  }
596
657
 
597
658
  // =============================================================================
@@ -640,8 +701,72 @@ export interface FileMediaInput {
640
701
  path: string;
641
702
  }
642
703
 
704
+ /** Media input - Upload reference (for pre-uploaded files) */
705
+ export interface UploadRefMediaInput {
706
+ type: 'upload_ref';
707
+ upload_id: string;
708
+ media_type?: string;
709
+ }
710
+
643
711
  /** Union of media input types */
644
- export type MediaInput = UrlMediaInput | Base64MediaInput | FileMediaInput;
712
+ export type MediaInput = UrlMediaInput | Base64MediaInput | FileMediaInput | UploadRefMediaInput;
713
+
714
+ /** Checksum for media integrity */
715
+ export interface MediaChecksum {
716
+ algorithm: 'sha256' | 'md5' | 'crc32';
717
+ value: string;
718
+ }
719
+
720
+ /** Media validation result */
721
+ export interface MediaValidationResult {
722
+ index: number;
723
+ media_type: string;
724
+ size_bytes: number;
725
+ dimensions?: {
726
+ width: number;
727
+ height: number;
728
+ };
729
+ duration_ms?: number;
730
+ valid: boolean;
731
+ errors?: string[];
732
+ }
733
+
734
+ /** Media validation summary in meta */
735
+ export interface MediaValidationSummary {
736
+ input_count: number;
737
+ validated: MediaValidationResult[];
738
+ }
739
+
740
+ /** Magic bytes for media type detection */
741
+ export const MEDIA_MAGIC_BYTES: Record<string, string[]> = {
742
+ 'image/jpeg': ['ffd8ff'],
743
+ 'image/png': ['89504e470d0a1a0a'],
744
+ 'image/gif': ['47494638'],
745
+ 'image/webp': ['52494646'],
746
+ 'audio/mpeg': ['fffb', 'fffa', '494433'],
747
+ 'audio/wav': ['52494646'],
748
+ 'audio/ogg': ['4f676753'],
749
+ 'video/mp4': ['0000001866747970', '0000002066747970'],
750
+ 'video/webm': ['1a45dfa3'],
751
+ 'application/pdf': ['25504446'],
752
+ };
753
+
754
+ /** Media size limits in bytes */
755
+ export const MEDIA_SIZE_LIMITS: Record<string, number> = {
756
+ 'image': 20 * 1024 * 1024, // 20MB
757
+ 'audio': 25 * 1024 * 1024, // 25MB
758
+ 'video': 100 * 1024 * 1024, // 100MB
759
+ 'document': 50 * 1024 * 1024, // 50MB
760
+ };
761
+
762
+ /** Media dimension limits */
763
+ export const MEDIA_DIMENSION_LIMITS = {
764
+ max_width: 8192,
765
+ max_height: 8192,
766
+ min_width: 10,
767
+ min_height: 10,
768
+ max_pixels: 67108864, // 8192 x 8192
769
+ };
645
770
 
646
771
  /** Media output with metadata */
647
772
  export interface MediaOutput {
@@ -691,6 +816,13 @@ export const ErrorCodesV25 = {
691
816
  MEDIA_TOO_LARGE: 'E1011',
692
817
  MEDIA_FETCH_FAILED: 'E1012',
693
818
  MEDIA_DECODE_FAILED: 'E1013',
819
+ MEDIA_TYPE_MISMATCH: 'E1014',
820
+ MEDIA_DIMENSION_EXCEEDED: 'E1015',
821
+ MEDIA_DIMENSION_TOO_SMALL: 'E1016',
822
+ MEDIA_PIXEL_LIMIT: 'E1017',
823
+ UPLOAD_EXPIRED: 'E1018',
824
+ UPLOAD_NOT_FOUND: 'E1019',
825
+ CHECKSUM_MISMATCH: 'E1020',
694
826
 
695
827
  // Streaming errors (E2xxx)
696
828
  STREAM_INTERRUPTED: 'E2010',
@@ -699,6 +831,9 @@ export const ErrorCodesV25 = {
699
831
  // Capability errors (E4xxx)
700
832
  STREAMING_NOT_SUPPORTED: 'E4010',
701
833
  MULTIMODAL_NOT_SUPPORTED: 'E4011',
834
+ RECOVERY_NOT_SUPPORTED: 'E4012',
835
+ SESSION_EXPIRED: 'E4013',
836
+ CHECKPOINT_INVALID: 'E4014',
702
837
  } as const;
703
838
 
704
839
  export type ErrorCodeV25 = typeof ErrorCodesV25[keyof typeof ErrorCodesV25];