@opencode/ai 0.0.0-dev-21133 → 0.0.0-dev-21141

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.
@@ -205,7 +205,7 @@ export declare const protocol: Protocol<{
205
205
  readonly id?: string | undefined;
206
206
  readonly call_id?: string | undefined;
207
207
  readonly name?: string | undefined;
208
- readonly namespace?: string | null | undefined;
208
+ readonly namespace?: string | undefined;
209
209
  readonly arguments?: string | undefined;
210
210
  readonly encrypted_content?: string | null | undefined;
211
211
  } | null | undefined;
@@ -222,7 +222,7 @@ export declare const protocol: Protocol<{
222
222
  readonly id?: string | undefined;
223
223
  readonly call_id?: string | undefined;
224
224
  readonly name?: string | undefined;
225
- readonly namespace?: string | null | undefined;
225
+ readonly namespace?: string | undefined;
226
226
  readonly arguments?: string | undefined;
227
227
  readonly encrypted_content?: string | null | undefined;
228
228
  }[] | undefined;
@@ -216,7 +216,7 @@ export declare const protocol: Protocol<{
216
216
  readonly id?: string | undefined;
217
217
  readonly call_id?: string | undefined;
218
218
  readonly name?: string | undefined;
219
- readonly namespace?: string | null | undefined;
219
+ readonly namespace?: string | undefined;
220
220
  readonly arguments?: string | undefined;
221
221
  readonly encrypted_content?: string | null | undefined;
222
222
  } | null | undefined;
@@ -233,7 +233,7 @@ export declare const protocol: Protocol<{
233
233
  readonly id?: string | undefined;
234
234
  readonly call_id?: string | undefined;
235
235
  readonly name?: string | undefined;
236
- readonly namespace?: string | null | undefined;
236
+ readonly namespace?: string | undefined;
237
237
  readonly arguments?: string | undefined;
238
238
  readonly encrypted_content?: string | null | undefined;
239
239
  }[] | undefined;
@@ -560,78 +560,121 @@ export declare const OpenResponsesBody: Schema.Struct<{
560
560
  }>;
561
561
  export type OpenResponsesBody = Schema.Schema.Type<typeof OpenResponsesBody>;
562
562
  export declare const OpenResponsesUsage: Schema.StructWithRest<Schema.Struct<{
563
- readonly input_tokens: Schema.optional<Schema.Number>;
563
+ readonly input_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
564
564
  readonly input_tokens_details: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
565
- readonly cached_tokens: Schema.optional<Schema.Number>;
566
- readonly cache_write_tokens: Schema.optional<Schema.Number>;
565
+ readonly cached_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
566
+ readonly cache_write_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
567
567
  }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>;
568
- readonly output_tokens: Schema.optional<Schema.Number>;
568
+ readonly output_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
569
569
  readonly output_tokens_details: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
570
- readonly reasoning_tokens: Schema.optional<Schema.Number>;
570
+ readonly reasoning_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
571
571
  }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>;
572
- readonly total_tokens: Schema.optional<Schema.Number>;
572
+ readonly total_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
573
573
  }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>;
574
574
  type OpenResponsesUsage = Schema.Schema.Type<typeof OpenResponsesUsage>;
575
575
  export declare const StreamItem: Schema.StructWithRest<Schema.Struct<{
576
576
  readonly type: Schema.String;
577
- readonly id: Schema.optional<Schema.String>;
578
- readonly call_id: Schema.optional<Schema.String>;
579
- readonly name: Schema.optional<Schema.String>;
580
- readonly namespace: Schema.optional<Schema.NullOr<Schema.String>>;
581
- readonly arguments: Schema.optional<Schema.String>;
577
+ readonly id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
578
+ readonly call_id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
579
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
580
+ readonly namespace: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
581
+ readonly arguments: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
582
582
  readonly encrypted_content: Schema.optional<Schema.NullOr<Schema.String>>;
583
583
  }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>;
584
584
  export type StreamItem = Schema.Schema.Type<typeof StreamItem>;
585
585
  export type OutputItem = StreamItem & {
586
586
  readonly id: string;
587
- readonly namespace?: string;
588
587
  };
589
588
  export declare const Event: Schema.Union<readonly [Schema.StructWithRest<Schema.Struct<{
590
589
  readonly type: Schema.String;
591
- readonly delta: Schema.optional<Schema.String>;
592
- readonly arguments: Schema.optional<Schema.String>;
593
- readonly text: Schema.optional<Schema.String>;
590
+ readonly delta: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
591
+ readonly arguments: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
592
+ readonly text: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
594
593
  readonly item_id: Schema.optional<Schema.String>;
595
- readonly output_index: Schema.optional<Schema.Number>;
596
- readonly summary_index: Schema.optional<Schema.Number>;
594
+ readonly output_index: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Number>>, Schema.optional<Schema.NullOr<Schema.Number>>, never, never>;
595
+ readonly summary_index: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Number>>, Schema.optional<Schema.NullOr<Schema.Number>>, never, never>;
597
596
  readonly item: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
598
597
  readonly type: Schema.String;
599
- readonly id: Schema.optional<Schema.String>;
600
- readonly call_id: Schema.optional<Schema.String>;
601
- readonly name: Schema.optional<Schema.String>;
602
- readonly namespace: Schema.optional<Schema.NullOr<Schema.String>>;
603
- readonly arguments: Schema.optional<Schema.String>;
598
+ readonly id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
599
+ readonly call_id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
600
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
601
+ readonly namespace: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
602
+ readonly arguments: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
604
603
  readonly encrypted_content: Schema.optional<Schema.NullOr<Schema.String>>;
605
604
  }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>;
606
- readonly response: Schema.optional<Schema.StructWithRest<Schema.Struct<{
607
- readonly id: Schema.optional<Schema.String>;
605
+ readonly response: Schema.decodeTo<Schema.optional<Schema.toType<Schema.StructWithRest<Schema.Struct<{
606
+ readonly id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
608
607
  readonly service_tier: Schema.optional<Schema.NullOr<Schema.String>>;
609
608
  readonly incomplete_details: Schema.optional<Schema.NullOr<Schema.Struct<{
610
- readonly reason: Schema.optional<Schema.String>;
609
+ readonly reason: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
611
610
  }>>>;
612
- readonly output: Schema.optional<Schema.$Array<Schema.StructWithRest<Schema.Struct<{
611
+ readonly output: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.StructWithRest<Schema.Struct<{
612
+ readonly type: Schema.String;
613
+ readonly id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
614
+ readonly call_id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
615
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
616
+ readonly namespace: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
617
+ readonly arguments: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
618
+ readonly encrypted_content: Schema.optional<Schema.NullOr<Schema.String>>;
619
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>>, Schema.optional<Schema.NullOr<Schema.$Array<Schema.StructWithRest<Schema.Struct<{
613
620
  readonly type: Schema.String;
614
- readonly id: Schema.optional<Schema.String>;
615
- readonly call_id: Schema.optional<Schema.String>;
616
- readonly name: Schema.optional<Schema.String>;
617
- readonly namespace: Schema.optional<Schema.NullOr<Schema.String>>;
618
- readonly arguments: Schema.optional<Schema.String>;
621
+ readonly id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
622
+ readonly call_id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
623
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
624
+ readonly namespace: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
625
+ readonly arguments: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
619
626
  readonly encrypted_content: Schema.optional<Schema.NullOr<Schema.String>>;
627
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>>, never, never>;
628
+ readonly usage: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
629
+ readonly input_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
630
+ readonly input_tokens_details: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
631
+ readonly cached_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
632
+ readonly cache_write_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
633
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>;
634
+ readonly output_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
635
+ readonly output_tokens_details: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
636
+ readonly reasoning_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
637
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>;
638
+ readonly total_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
620
639
  }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>;
640
+ readonly error: Schema.optional<Schema.Unknown>;
641
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>, Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
642
+ readonly id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
643
+ readonly service_tier: Schema.optional<Schema.NullOr<Schema.String>>;
644
+ readonly incomplete_details: Schema.optional<Schema.NullOr<Schema.Struct<{
645
+ readonly reason: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
646
+ }>>>;
647
+ readonly output: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.StructWithRest<Schema.Struct<{
648
+ readonly type: Schema.String;
649
+ readonly id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
650
+ readonly call_id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
651
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
652
+ readonly namespace: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
653
+ readonly arguments: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
654
+ readonly encrypted_content: Schema.optional<Schema.NullOr<Schema.String>>;
655
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>>, Schema.optional<Schema.NullOr<Schema.$Array<Schema.StructWithRest<Schema.Struct<{
656
+ readonly type: Schema.String;
657
+ readonly id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
658
+ readonly call_id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
659
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
660
+ readonly namespace: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
661
+ readonly arguments: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
662
+ readonly encrypted_content: Schema.optional<Schema.NullOr<Schema.String>>;
663
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>>, never, never>;
621
664
  readonly usage: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
622
- readonly input_tokens: Schema.optional<Schema.Number>;
665
+ readonly input_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
623
666
  readonly input_tokens_details: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
624
- readonly cached_tokens: Schema.optional<Schema.Number>;
625
- readonly cache_write_tokens: Schema.optional<Schema.Number>;
667
+ readonly cached_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
668
+ readonly cache_write_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
626
669
  }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>;
627
- readonly output_tokens: Schema.optional<Schema.Number>;
670
+ readonly output_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
628
671
  readonly output_tokens_details: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
629
- readonly reasoning_tokens: Schema.optional<Schema.Number>;
672
+ readonly reasoning_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
630
673
  }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>;
631
- readonly total_tokens: Schema.optional<Schema.Number>;
674
+ readonly total_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
632
675
  }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>;
633
676
  readonly error: Schema.optional<Schema.Unknown>;
634
- }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>;
677
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>, never, never>;
635
678
  readonly code: Schema.optional<Schema.Unknown>;
636
679
  readonly message: Schema.optional<Schema.Unknown>;
637
680
  readonly error: Schema.optional<Schema.Unknown>;
@@ -639,50 +682,94 @@ export declare const Event: Schema.Union<readonly [Schema.StructWithRest<Schema.
639
682
  readonly status_code: Schema.optional<Schema.Unknown>;
640
683
  }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>, Schema.decodeTo<Schema.StructWithRest<Schema.Struct<{
641
684
  readonly type: Schema.String;
642
- readonly delta: Schema.optional<Schema.String>;
643
- readonly arguments: Schema.optional<Schema.String>;
644
- readonly text: Schema.optional<Schema.String>;
685
+ readonly delta: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
686
+ readonly arguments: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
687
+ readonly text: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
645
688
  readonly item_id: Schema.optional<Schema.String>;
646
- readonly output_index: Schema.optional<Schema.Number>;
647
- readonly summary_index: Schema.optional<Schema.Number>;
689
+ readonly output_index: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Number>>, Schema.optional<Schema.NullOr<Schema.Number>>, never, never>;
690
+ readonly summary_index: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Number>>, Schema.optional<Schema.NullOr<Schema.Number>>, never, never>;
648
691
  readonly item: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
649
692
  readonly type: Schema.String;
650
- readonly id: Schema.optional<Schema.String>;
651
- readonly call_id: Schema.optional<Schema.String>;
652
- readonly name: Schema.optional<Schema.String>;
653
- readonly namespace: Schema.optional<Schema.NullOr<Schema.String>>;
654
- readonly arguments: Schema.optional<Schema.String>;
693
+ readonly id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
694
+ readonly call_id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
695
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
696
+ readonly namespace: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
697
+ readonly arguments: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
655
698
  readonly encrypted_content: Schema.optional<Schema.NullOr<Schema.String>>;
656
699
  }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>;
657
- readonly response: Schema.optional<Schema.StructWithRest<Schema.Struct<{
658
- readonly id: Schema.optional<Schema.String>;
700
+ readonly response: Schema.decodeTo<Schema.optional<Schema.toType<Schema.StructWithRest<Schema.Struct<{
701
+ readonly id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
659
702
  readonly service_tier: Schema.optional<Schema.NullOr<Schema.String>>;
660
703
  readonly incomplete_details: Schema.optional<Schema.NullOr<Schema.Struct<{
661
- readonly reason: Schema.optional<Schema.String>;
704
+ readonly reason: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
662
705
  }>>>;
663
- readonly output: Schema.optional<Schema.$Array<Schema.StructWithRest<Schema.Struct<{
706
+ readonly output: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.StructWithRest<Schema.Struct<{
664
707
  readonly type: Schema.String;
665
- readonly id: Schema.optional<Schema.String>;
666
- readonly call_id: Schema.optional<Schema.String>;
667
- readonly name: Schema.optional<Schema.String>;
668
- readonly namespace: Schema.optional<Schema.NullOr<Schema.String>>;
669
- readonly arguments: Schema.optional<Schema.String>;
708
+ readonly id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
709
+ readonly call_id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
710
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
711
+ readonly namespace: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
712
+ readonly arguments: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
670
713
  readonly encrypted_content: Schema.optional<Schema.NullOr<Schema.String>>;
714
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>>, Schema.optional<Schema.NullOr<Schema.$Array<Schema.StructWithRest<Schema.Struct<{
715
+ readonly type: Schema.String;
716
+ readonly id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
717
+ readonly call_id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
718
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
719
+ readonly namespace: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
720
+ readonly arguments: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
721
+ readonly encrypted_content: Schema.optional<Schema.NullOr<Schema.String>>;
722
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>>, never, never>;
723
+ readonly usage: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
724
+ readonly input_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
725
+ readonly input_tokens_details: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
726
+ readonly cached_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
727
+ readonly cache_write_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
728
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>;
729
+ readonly output_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
730
+ readonly output_tokens_details: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
731
+ readonly reasoning_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
732
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>;
733
+ readonly total_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
671
734
  }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>;
735
+ readonly error: Schema.optional<Schema.Unknown>;
736
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>, Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
737
+ readonly id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
738
+ readonly service_tier: Schema.optional<Schema.NullOr<Schema.String>>;
739
+ readonly incomplete_details: Schema.optional<Schema.NullOr<Schema.Struct<{
740
+ readonly reason: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
741
+ }>>>;
742
+ readonly output: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.StructWithRest<Schema.Struct<{
743
+ readonly type: Schema.String;
744
+ readonly id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
745
+ readonly call_id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
746
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
747
+ readonly namespace: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
748
+ readonly arguments: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
749
+ readonly encrypted_content: Schema.optional<Schema.NullOr<Schema.String>>;
750
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>>, Schema.optional<Schema.NullOr<Schema.$Array<Schema.StructWithRest<Schema.Struct<{
751
+ readonly type: Schema.String;
752
+ readonly id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
753
+ readonly call_id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
754
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
755
+ readonly namespace: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
756
+ readonly arguments: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optional<Schema.NullOr<Schema.String>>, never, never>;
757
+ readonly encrypted_content: Schema.optional<Schema.NullOr<Schema.String>>;
758
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>>, never, never>;
672
759
  readonly usage: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
673
- readonly input_tokens: Schema.optional<Schema.Number>;
760
+ readonly input_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
674
761
  readonly input_tokens_details: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
675
- readonly cached_tokens: Schema.optional<Schema.Number>;
676
- readonly cache_write_tokens: Schema.optional<Schema.Number>;
762
+ readonly cached_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
763
+ readonly cache_write_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
677
764
  }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>;
678
- readonly output_tokens: Schema.optional<Schema.Number>;
765
+ readonly output_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
679
766
  readonly output_tokens_details: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
680
- readonly reasoning_tokens: Schema.optional<Schema.Number>;
767
+ readonly reasoning_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
681
768
  }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>;
682
- readonly total_tokens: Schema.optional<Schema.Number>;
769
+ readonly total_tokens: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
683
770
  }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>;
684
771
  readonly error: Schema.optional<Schema.Unknown>;
685
- }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>;
772
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>, never, never>;
686
773
  readonly code: Schema.optional<Schema.Unknown>;
687
774
  readonly message: Schema.optional<Schema.Unknown>;
688
775
  readonly error: Schema.optional<Schema.Unknown>;
@@ -709,7 +796,7 @@ export declare const decodeChannelEvent: (input: unknown, options?: import("effe
709
796
  readonly id?: string | undefined;
710
797
  readonly call_id?: string | undefined;
711
798
  readonly name?: string | undefined;
712
- readonly namespace?: string | null | undefined;
799
+ readonly namespace?: string | undefined;
713
800
  readonly arguments?: string | undefined;
714
801
  readonly encrypted_content?: string | null | undefined;
715
802
  } | null | undefined;
@@ -726,7 +813,7 @@ export declare const decodeChannelEvent: (input: unknown, options?: import("effe
726
813
  readonly id?: string | undefined;
727
814
  readonly call_id?: string | undefined;
728
815
  readonly name?: string | undefined;
729
- readonly namespace?: string | null | undefined;
816
+ readonly namespace?: string | undefined;
730
817
  readonly arguments?: string | undefined;
731
818
  readonly encrypted_content?: string | null | undefined;
732
819
  }[] | undefined;
@@ -1764,7 +1851,7 @@ export declare const protocol: Protocol<{
1764
1851
  readonly id?: string | undefined;
1765
1852
  readonly call_id?: string | undefined;
1766
1853
  readonly name?: string | undefined;
1767
- readonly namespace?: string | null | undefined;
1854
+ readonly namespace?: string | undefined;
1768
1855
  readonly arguments?: string | undefined;
1769
1856
  readonly encrypted_content?: string | null | undefined;
1770
1857
  } | null | undefined;
@@ -1781,7 +1868,7 @@ export declare const protocol: Protocol<{
1781
1868
  readonly id?: string | undefined;
1782
1869
  readonly call_id?: string | undefined;
1783
1870
  readonly name?: string | undefined;
1784
- readonly namespace?: string | null | undefined;
1871
+ readonly namespace?: string | undefined;
1785
1872
  readonly arguments?: string | undefined;
1786
1873
  readonly encrypted_content?: string | null | undefined;
1787
1874
  }[] | undefined;
@@ -2,7 +2,7 @@ import { Effect, Option, Schema } from "effect";
2
2
  import { HttpTransport } from "../route/transport/index.js";
3
3
  import { Protocol } from "../route/protocol.js";
4
4
  import { AIError, LLMEvent, ProviderInternalError, Usage, } from "../schema/index.js";
5
- import { JsonObject, optionalArray, optionalNull, ProviderShared, withUntypedFrames } from "./shared.js";
5
+ import { JsonObject, lenient, optionalArray, optionalNull, optionalNullish, ProviderShared, withUntypedFrames, } from "./shared.js";
6
6
  import { classifyProviderFailure } from "../provider-error.js";
7
7
  import { effortUpdate } from "../effort-updates.js";
8
8
  import { OpenResponsesOptions } from "./utils/open-responses-options.js";
@@ -222,14 +222,14 @@ export const OpenResponsesBody = Schema.Struct({
222
222
  stream: Schema.Literal(true),
223
223
  });
224
224
  export const OpenResponsesUsage = Schema.StructWithRest(Schema.Struct({
225
- input_tokens: Schema.optional(Schema.Number),
225
+ input_tokens: lenient(Schema.Number),
226
226
  input_tokens_details: optionalNull(Schema.StructWithRest(Schema.Struct({
227
- cached_tokens: Schema.optional(Schema.Number),
228
- cache_write_tokens: Schema.optional(Schema.Number),
227
+ cached_tokens: lenient(Schema.Number),
228
+ cache_write_tokens: lenient(Schema.Number),
229
229
  }), [JsonObject])),
230
- output_tokens: Schema.optional(Schema.Number),
231
- output_tokens_details: optionalNull(Schema.StructWithRest(Schema.Struct({ reasoning_tokens: Schema.optional(Schema.Number) }), [JsonObject])),
232
- total_tokens: Schema.optional(Schema.Number),
230
+ output_tokens: lenient(Schema.Number),
231
+ output_tokens_details: optionalNull(Schema.StructWithRest(Schema.Struct({ reasoning_tokens: lenient(Schema.Number) }), [JsonObject])),
232
+ total_tokens: lenient(Schema.Number),
233
233
  }), [JsonObject]);
234
234
  // The spec requires `id` on every output item, but some gateways drop it from
235
235
  // later item events (Bedrock Mantle renames it to `item_id` on
@@ -238,11 +238,11 @@ export const OpenResponsesUsage = Schema.StructWithRest(Schema.Struct({
238
238
  // https://www.openresponses.org/specification#extending-items
239
239
  export const StreamItem = Schema.StructWithRest(Schema.Struct({
240
240
  type: Schema.String,
241
- id: Schema.optional(Schema.String),
242
- call_id: Schema.optional(Schema.String),
243
- name: Schema.optional(Schema.String),
244
- namespace: optionalNull(Schema.String),
245
- arguments: Schema.optional(Schema.String),
241
+ id: optionalNullish(Schema.String),
242
+ call_id: optionalNullish(Schema.String),
243
+ name: optionalNullish(Schema.String),
244
+ namespace: optionalNullish(Schema.String),
245
+ arguments: optionalNullish(Schema.String),
246
246
  encrypted_content: optionalNull(Schema.String),
247
247
  }), [Schema.Record(Schema.String, Schema.Unknown)]);
248
248
  // Responses-compatible providers put error details at the top level, under `error`, or under
@@ -253,19 +253,20 @@ export const StreamItem = Schema.StructWithRest(Schema.Struct({
253
253
  const asText = (value) => typeof value === "string" && value.length > 0 ? value : typeof value === "number" ? String(value) : undefined;
254
254
  const TypedEvent = Schema.StructWithRest(Schema.Struct({
255
255
  type: Schema.String,
256
- delta: Schema.optional(Schema.String),
257
- arguments: Schema.optional(Schema.String),
258
- text: Schema.optional(Schema.String),
256
+ delta: optionalNullish(Schema.String),
257
+ arguments: optionalNullish(Schema.String),
258
+ text: optionalNullish(Schema.String),
259
+ // Kept strict: item-scoped events always carry an id, so null means a broken stream.
259
260
  item_id: Schema.optional(Schema.String),
260
- output_index: Schema.optional(Schema.Number),
261
- summary_index: Schema.optional(Schema.Number),
261
+ output_index: optionalNullish(Schema.Number),
262
+ summary_index: optionalNullish(Schema.Number),
262
263
  // OutputItemAdded/Done permit a null item in the Open Responses OpenAPI schema.
263
264
  item: optionalNull(StreamItem),
264
- response: Schema.optional(Schema.StructWithRest(Schema.Struct({
265
- id: Schema.optional(Schema.String),
265
+ response: optionalNullish(Schema.StructWithRest(Schema.Struct({
266
+ id: optionalNullish(Schema.String),
266
267
  service_tier: optionalNull(Schema.String),
267
- incomplete_details: optionalNull(Schema.Struct({ reason: Schema.optional(Schema.String) })),
268
- output: Schema.optional(Schema.Array(StreamItem)),
268
+ incomplete_details: optionalNull(Schema.Struct({ reason: optionalNullish(Schema.String) })),
269
+ output: optionalNullish(Schema.Array(StreamItem)),
269
270
  usage: optionalNull(OpenResponsesUsage),
270
271
  error: Schema.optional(Schema.Unknown),
271
272
  }), [Schema.Record(Schema.String, Schema.Unknown)])),
@@ -647,7 +648,7 @@ export const mapUsage = (usage, providerMetadataKey) => {
647
648
  };
648
649
  const mapFinishReason = (event, hasFunctionCall) => {
649
650
  const reason = event.response?.incomplete_details?.reason;
650
- if (reason === undefined || reason === null) {
651
+ if (reason === undefined) {
651
652
  if (hasFunctionCall)
652
653
  return "tool-calls";
653
654
  if (event.type === "response.incomplete")
@@ -707,8 +708,6 @@ const ITEM_ID_PREFIX = {
707
708
  // otherwise it gets a locally minted one.
708
709
  const resolveItem = (state, item, index) => ({
709
710
  ...item,
710
- // Some gateways serialize an absent namespace as null.
711
- namespace: item.namespace ?? undefined,
712
711
  id: item.id ??
713
712
  (index === undefined ? undefined : state.outputItems[index]) ??
714
713
  `${ITEM_ID_PREFIX[item.type] ?? "item"}_${crypto.randomUUID().replaceAll("-", "")}`,
@@ -421,7 +421,7 @@ export declare const protocol: Protocol<{
421
421
  readonly id?: string | undefined;
422
422
  readonly call_id?: string | undefined;
423
423
  readonly name?: string | undefined;
424
- readonly namespace?: string | null | undefined;
424
+ readonly namespace?: string | undefined;
425
425
  readonly arguments?: string | undefined;
426
426
  readonly encrypted_content?: string | null | undefined;
427
427
  } | null | undefined;
@@ -438,7 +438,7 @@ export declare const protocol: Protocol<{
438
438
  readonly id?: string | undefined;
439
439
  readonly call_id?: string | undefined;
440
440
  readonly name?: string | undefined;
441
- readonly namespace?: string | null | undefined;
441
+ readonly namespace?: string | undefined;
442
442
  readonly arguments?: string | undefined;
443
443
  readonly encrypted_content?: string | null | undefined;
444
444
  }[] | undefined;
@@ -9,6 +9,8 @@ export { Json, decodeJson, encodeJson, isRecord };
9
9
  export declare const JsonObject: Schema.$Record<Schema.String, Schema.Unknown>;
10
10
  export declare const optionalArray: <const S extends Schema.Top>(schema: S) => Schema.optional<Schema.$Array<S>>;
11
11
  export declare const optionalNull: <const S extends Schema.Top>(schema: S) => Schema.optional<Schema.NullOr<S>>;
12
+ /** Optional provider field where an explicit `null` means absent, so decoding never yields `null`. */
13
+ export declare const optionalNullish: <const S extends Schema.Top>(schema: S) => Schema.decodeTo<Schema.optional<Schema.toType<S>>, Schema.optional<Schema.NullOr<S>>, never, never>;
12
14
  /** Optional field whose malformed value decodes to `undefined` instead of failing the enclosing struct. */
13
15
  export declare const lenient: <const S extends Schema.Top>(schema: S) => Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<S>, S["DecodingServices"]>>;
14
16
  /**
@@ -1,5 +1,5 @@
1
1
  import { Tool } from "@opencode/schema/tool";
2
- import { Effect, Option, Schema, SchemaGetter } from "effect";
2
+ import { Effect, Option, Predicate, Schema, SchemaGetter, SchemaTransformation } from "effect";
3
3
  import { Headers, HttpClientRequest } from "effect/http";
4
4
  import { Media } from "../media.js";
5
5
  import { InvalidProviderOutputError, InvalidRequestError, UnsupportedOperationError, AIError, LLMRequest, Message, ToolDefinition, } from "../schema/index.js";
@@ -10,6 +10,11 @@ const isJson = Schema.is(Schema.Json);
10
10
  export const JsonObject = Schema.Record(Schema.String, Schema.Unknown);
11
11
  export const optionalArray = (schema) => Schema.optional(Schema.Array(schema));
12
12
  export const optionalNull = (schema) => Schema.optional(Schema.NullOr(schema));
13
+ /** Optional provider field where an explicit `null` means absent, so decoding never yields `null`. */
14
+ export const optionalNullish = (schema) => Schema.optional(Schema.NullOr(schema)).pipe(Schema.decodeTo(Schema.optional(Schema.toType(schema)), SchemaTransformation.transformOptional({
15
+ decode: Option.filter(Predicate.isNotNullish),
16
+ encode: (value) => value,
17
+ })));
13
18
  /** Optional field whose malformed value decodes to `undefined` instead of failing the enclosing struct. */
14
19
  export const lenient = (schema) => Schema.optionalKey(Schema.UndefinedOr(schema).pipe(Schema.catchDecoding(() => Effect.succeed(Option.some(undefined)))));
15
20
  /**
@@ -192,7 +192,7 @@ export declare const protocol: Protocol<{
192
192
  readonly id?: string | undefined;
193
193
  readonly call_id?: string | undefined;
194
194
  readonly name?: string | undefined;
195
- readonly namespace?: string | null | undefined;
195
+ readonly namespace?: string | undefined;
196
196
  readonly arguments?: string | undefined;
197
197
  readonly encrypted_content?: string | null | undefined;
198
198
  } | null | undefined;
@@ -209,7 +209,7 @@ export declare const protocol: Protocol<{
209
209
  readonly id?: string | undefined;
210
210
  readonly call_id?: string | undefined;
211
211
  readonly name?: string | undefined;
212
- readonly namespace?: string | null | undefined;
212
+ readonly namespace?: string | undefined;
213
213
  readonly arguments?: string | undefined;
214
214
  readonly encrypted_content?: string | null | undefined;
215
215
  }[] | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "0.0.0-dev-21133",
3
+ "version": "0.0.0-dev-21141",
4
4
  "name": "@opencode/ai",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -34,7 +34,7 @@
34
34
  "devDependencies": {
35
35
  "@clack/prompts": "1.0.0-alpha.1",
36
36
  "@effect/platform-node": "4.0.1",
37
- "@opencode/http-recorder": "0.0.0-dev-21133",
37
+ "@opencode/http-recorder": "0.0.0-dev-21141",
38
38
  "@tsconfig/bun": "1.0.9",
39
39
  "@types/bun": "1.4.0",
40
40
  "@typescript/native": "npm:typescript@7.0.2",
@@ -44,7 +44,7 @@
44
44
  "@aws-sdk/credential-providers": "3.1057.0",
45
45
  "@smithy/eventstream-codec": "4.2.14",
46
46
  "@smithy/util-utf8": "4.2.2",
47
- "@opencode/schema": "0.0.0-dev-21133",
47
+ "@opencode/schema": "0.0.0-dev-21141",
48
48
  "aws4fetch": "1.0.20",
49
49
  "effect": "4.0.1",
50
50
  "google-auth-library": "10.5.0"