@goodtiming/baton-sdk 0.5.0 → 0.5.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/README.md +19 -0
- package/dist/index.cjs +66 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +134 -28
- package/dist/index.d.ts +134 -28
- package/dist/index.js +64 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
declare const SDK_VERSION = "ts-0.5.
|
|
3
|
+
declare const SDK_VERSION = "ts-0.5.1";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Zod schemas + TS types for the Baton event stream per SPEC §11.4.
|
|
@@ -133,7 +133,8 @@ type SurfaceSnapshotPayload = z.infer<typeof SurfaceSnapshotPayloadSchema>;
|
|
|
133
133
|
*/
|
|
134
134
|
declare const DEFAULT_CONSENT_TOKEN = "customer-consented";
|
|
135
135
|
/** The principal as emitted — `{id, source, form}`, all three REQUIRED
|
|
136
|
-
* together (SPEC §11.4). The runtime shape
|
|
136
|
+
* together, plus an optional `display_name` (SPEC §11.4). The runtime shape
|
|
137
|
+
* of `identity.PrincipalWire`.
|
|
137
138
|
*
|
|
138
139
|
* `.strict()` mirrors Python's `extra="forbid"`: a member this producer does
|
|
139
140
|
* not know about is a malformed object, not a richer one.
|
|
@@ -152,6 +153,7 @@ declare const PrincipalWireSchema: z.ZodObject<{
|
|
|
152
153
|
id: z.ZodString;
|
|
153
154
|
source: z.ZodString;
|
|
154
155
|
form: z.ZodString;
|
|
156
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
155
157
|
}, z.core.$strict>;
|
|
156
158
|
declare const EventTypeSchema: z.ZodEnum<{
|
|
157
159
|
tool_call_start: "tool_call_start";
|
|
@@ -313,6 +315,7 @@ declare const ToolCallStartEventSchema: z.ZodObject<{
|
|
|
313
315
|
id: z.ZodString;
|
|
314
316
|
source: z.ZodString;
|
|
315
317
|
form: z.ZodString;
|
|
318
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
316
319
|
}, z.core.$strict>>>;
|
|
317
320
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
318
321
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -340,6 +343,7 @@ declare const ToolCallEndEventSchema: z.ZodObject<{
|
|
|
340
343
|
id: z.ZodString;
|
|
341
344
|
source: z.ZodString;
|
|
342
345
|
form: z.ZodString;
|
|
346
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
343
347
|
}, z.core.$strict>>>;
|
|
344
348
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
345
349
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -370,6 +374,7 @@ declare const ToolCallErrorEventSchema: z.ZodObject<{
|
|
|
370
374
|
id: z.ZodString;
|
|
371
375
|
source: z.ZodString;
|
|
372
376
|
form: z.ZodString;
|
|
377
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
373
378
|
}, z.core.$strict>>>;
|
|
374
379
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
375
380
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -401,6 +406,7 @@ declare const AnnotationEventSchema: z.ZodObject<{
|
|
|
401
406
|
id: z.ZodString;
|
|
402
407
|
source: z.ZodString;
|
|
403
408
|
form: z.ZodString;
|
|
409
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
404
410
|
}, z.core.$strict>>>;
|
|
405
411
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
406
412
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -430,6 +436,7 @@ declare const SurfaceSnapshotEventSchema: z.ZodObject<{
|
|
|
430
436
|
id: z.ZodString;
|
|
431
437
|
source: z.ZodString;
|
|
432
438
|
form: z.ZodString;
|
|
439
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
433
440
|
}, z.core.$strict>>>;
|
|
434
441
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
435
442
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -452,6 +459,7 @@ declare const ResourceListStartEventSchema: z.ZodObject<{
|
|
|
452
459
|
id: z.ZodString;
|
|
453
460
|
source: z.ZodString;
|
|
454
461
|
form: z.ZodString;
|
|
462
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
455
463
|
}, z.core.$strict>>>;
|
|
456
464
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
457
465
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -477,6 +485,7 @@ declare const ResourceListEndEventSchema: z.ZodObject<{
|
|
|
477
485
|
id: z.ZodString;
|
|
478
486
|
source: z.ZodString;
|
|
479
487
|
form: z.ZodString;
|
|
488
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
480
489
|
}, z.core.$strict>>>;
|
|
481
490
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
482
491
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -503,6 +512,7 @@ declare const ResourceListErrorEventSchema: z.ZodObject<{
|
|
|
503
512
|
id: z.ZodString;
|
|
504
513
|
source: z.ZodString;
|
|
505
514
|
form: z.ZodString;
|
|
515
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
506
516
|
}, z.core.$strict>>>;
|
|
507
517
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
508
518
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -528,6 +538,7 @@ declare const ResourceReadStartEventSchema: z.ZodObject<{
|
|
|
528
538
|
id: z.ZodString;
|
|
529
539
|
source: z.ZodString;
|
|
530
540
|
form: z.ZodString;
|
|
541
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
531
542
|
}, z.core.$strict>>>;
|
|
532
543
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
533
544
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -553,6 +564,7 @@ declare const ResourceReadEndEventSchema: z.ZodObject<{
|
|
|
553
564
|
id: z.ZodString;
|
|
554
565
|
source: z.ZodString;
|
|
555
566
|
form: z.ZodString;
|
|
567
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
556
568
|
}, z.core.$strict>>>;
|
|
557
569
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
558
570
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -580,6 +592,7 @@ declare const ResourceReadErrorEventSchema: z.ZodObject<{
|
|
|
580
592
|
id: z.ZodString;
|
|
581
593
|
source: z.ZodString;
|
|
582
594
|
form: z.ZodString;
|
|
595
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
583
596
|
}, z.core.$strict>>>;
|
|
584
597
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
585
598
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -602,6 +615,7 @@ declare const PromptListStartEventSchema: z.ZodObject<{
|
|
|
602
615
|
id: z.ZodString;
|
|
603
616
|
source: z.ZodString;
|
|
604
617
|
form: z.ZodString;
|
|
618
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
605
619
|
}, z.core.$strict>>>;
|
|
606
620
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
607
621
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -627,6 +641,7 @@ declare const PromptListEndEventSchema: z.ZodObject<{
|
|
|
627
641
|
id: z.ZodString;
|
|
628
642
|
source: z.ZodString;
|
|
629
643
|
form: z.ZodString;
|
|
644
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
630
645
|
}, z.core.$strict>>>;
|
|
631
646
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
632
647
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -653,6 +668,7 @@ declare const PromptListErrorEventSchema: z.ZodObject<{
|
|
|
653
668
|
id: z.ZodString;
|
|
654
669
|
source: z.ZodString;
|
|
655
670
|
form: z.ZodString;
|
|
671
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
656
672
|
}, z.core.$strict>>>;
|
|
657
673
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
658
674
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -678,6 +694,7 @@ declare const PromptGetStartEventSchema: z.ZodObject<{
|
|
|
678
694
|
id: z.ZodString;
|
|
679
695
|
source: z.ZodString;
|
|
680
696
|
form: z.ZodString;
|
|
697
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
681
698
|
}, z.core.$strict>>>;
|
|
682
699
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
683
700
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -703,6 +720,7 @@ declare const PromptGetEndEventSchema: z.ZodObject<{
|
|
|
703
720
|
id: z.ZodString;
|
|
704
721
|
source: z.ZodString;
|
|
705
722
|
form: z.ZodString;
|
|
723
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
706
724
|
}, z.core.$strict>>>;
|
|
707
725
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
708
726
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -730,6 +748,7 @@ declare const PromptGetErrorEventSchema: z.ZodObject<{
|
|
|
730
748
|
id: z.ZodString;
|
|
731
749
|
source: z.ZodString;
|
|
732
750
|
form: z.ZodString;
|
|
751
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
733
752
|
}, z.core.$strict>>>;
|
|
734
753
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
735
754
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -759,6 +778,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
759
778
|
id: z.ZodString;
|
|
760
779
|
source: z.ZodString;
|
|
761
780
|
form: z.ZodString;
|
|
781
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
762
782
|
}, z.core.$strict>>>;
|
|
763
783
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
764
784
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -784,6 +804,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
784
804
|
id: z.ZodString;
|
|
785
805
|
source: z.ZodString;
|
|
786
806
|
form: z.ZodString;
|
|
807
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
787
808
|
}, z.core.$strict>>>;
|
|
788
809
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
789
810
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -812,6 +833,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
812
833
|
id: z.ZodString;
|
|
813
834
|
source: z.ZodString;
|
|
814
835
|
form: z.ZodString;
|
|
836
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
815
837
|
}, z.core.$strict>>>;
|
|
816
838
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
817
839
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -841,6 +863,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
841
863
|
id: z.ZodString;
|
|
842
864
|
source: z.ZodString;
|
|
843
865
|
form: z.ZodString;
|
|
866
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
844
867
|
}, z.core.$strict>>>;
|
|
845
868
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
846
869
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -868,6 +891,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
868
891
|
id: z.ZodString;
|
|
869
892
|
source: z.ZodString;
|
|
870
893
|
form: z.ZodString;
|
|
894
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
871
895
|
}, z.core.$strict>>>;
|
|
872
896
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
873
897
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -888,6 +912,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
888
912
|
id: z.ZodString;
|
|
889
913
|
source: z.ZodString;
|
|
890
914
|
form: z.ZodString;
|
|
915
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
891
916
|
}, z.core.$strict>>>;
|
|
892
917
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
893
918
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -911,6 +936,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
911
936
|
id: z.ZodString;
|
|
912
937
|
source: z.ZodString;
|
|
913
938
|
form: z.ZodString;
|
|
939
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
914
940
|
}, z.core.$strict>>>;
|
|
915
941
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
916
942
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -935,6 +961,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
935
961
|
id: z.ZodString;
|
|
936
962
|
source: z.ZodString;
|
|
937
963
|
form: z.ZodString;
|
|
964
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
938
965
|
}, z.core.$strict>>>;
|
|
939
966
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
940
967
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -958,6 +985,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
958
985
|
id: z.ZodString;
|
|
959
986
|
source: z.ZodString;
|
|
960
987
|
form: z.ZodString;
|
|
988
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
961
989
|
}, z.core.$strict>>>;
|
|
962
990
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
963
991
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -981,6 +1009,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
981
1009
|
id: z.ZodString;
|
|
982
1010
|
source: z.ZodString;
|
|
983
1011
|
form: z.ZodString;
|
|
1012
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
984
1013
|
}, z.core.$strict>>>;
|
|
985
1014
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
986
1015
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -1006,6 +1035,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1006
1035
|
id: z.ZodString;
|
|
1007
1036
|
source: z.ZodString;
|
|
1008
1037
|
form: z.ZodString;
|
|
1038
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1009
1039
|
}, z.core.$strict>>>;
|
|
1010
1040
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1011
1041
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -1026,6 +1056,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1026
1056
|
id: z.ZodString;
|
|
1027
1057
|
source: z.ZodString;
|
|
1028
1058
|
form: z.ZodString;
|
|
1059
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1029
1060
|
}, z.core.$strict>>>;
|
|
1030
1061
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1031
1062
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -1049,6 +1080,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1049
1080
|
id: z.ZodString;
|
|
1050
1081
|
source: z.ZodString;
|
|
1051
1082
|
form: z.ZodString;
|
|
1083
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1052
1084
|
}, z.core.$strict>>>;
|
|
1053
1085
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1054
1086
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -1073,6 +1105,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1073
1105
|
id: z.ZodString;
|
|
1074
1106
|
source: z.ZodString;
|
|
1075
1107
|
form: z.ZodString;
|
|
1108
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1076
1109
|
}, z.core.$strict>>>;
|
|
1077
1110
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1078
1111
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -1096,6 +1129,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1096
1129
|
id: z.ZodString;
|
|
1097
1130
|
source: z.ZodString;
|
|
1098
1131
|
form: z.ZodString;
|
|
1132
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1099
1133
|
}, z.core.$strict>>>;
|
|
1100
1134
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1101
1135
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -1119,6 +1153,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1119
1153
|
id: z.ZodString;
|
|
1120
1154
|
source: z.ZodString;
|
|
1121
1155
|
form: z.ZodString;
|
|
1156
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1122
1157
|
}, z.core.$strict>>>;
|
|
1123
1158
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1124
1159
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -1144,6 +1179,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1144
1179
|
id: z.ZodString;
|
|
1145
1180
|
source: z.ZodString;
|
|
1146
1181
|
form: z.ZodString;
|
|
1182
|
+
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1147
1183
|
}, z.core.$strict>>>;
|
|
1148
1184
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1149
1185
|
call_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -1413,6 +1449,12 @@ interface Principal {
|
|
|
1413
1449
|
* it, so two identity providers behind one vendor can hand the same subject
|
|
1414
1450
|
* to different people. */
|
|
1415
1451
|
issuer?: string | null | undefined;
|
|
1452
|
+
/** What a page shows for this principal — `principalFromOAuthEmail` puts
|
|
1453
|
+
* the part of the address before the last `@` here. **Sent verbatim, in
|
|
1454
|
+
* every mode, hashed included, and never through the scrubber** (SPEC
|
|
1455
|
+
* §11.4): the vendor chooses what is safe to show. An unusable value is
|
|
1456
|
+
* dropped alone — see `wireDisplayName`. */
|
|
1457
|
+
displayName?: string | null | undefined;
|
|
1416
1458
|
}
|
|
1417
1459
|
/** HMAC-SHA256 a raw principal into a console-safe, per-tenant `principal.id`.
|
|
1418
1460
|
*
|
|
@@ -1432,32 +1474,34 @@ declare function hashPrincipalId(rawPrincipal: string, options: {
|
|
|
1432
1474
|
issuer?: string | null | undefined;
|
|
1433
1475
|
}): string;
|
|
1434
1476
|
|
|
1435
|
-
/**
|
|
1477
|
+
/** A validated access token, as both majors declare it
|
|
1478
|
+
* (`@modelcontextprotocol/sdk` 1.x `server/auth/types.d.ts`,
|
|
1479
|
+
* `@modelcontextprotocol/server` 2.0.0 `createMcpHandler-*.d.mts:751` — the
|
|
1480
|
+
* same six members). Declared structurally for the reason {@link Extra} is.
|
|
1481
|
+
*
|
|
1482
|
+
* ⚠ **There is no `claims` member.** Whatever a verifier knows about the
|
|
1483
|
+
* subject goes in the free-form `extra` bag, and only the vendor's verifier
|
|
1484
|
+
* decides what is there. */
|
|
1485
|
+
interface AuthInfo {
|
|
1486
|
+
token: string;
|
|
1487
|
+
clientId: string;
|
|
1488
|
+
scopes: string[];
|
|
1489
|
+
expiresAt?: number | undefined;
|
|
1490
|
+
resource?: URL | undefined;
|
|
1491
|
+
extra?: Record<string, unknown> | undefined;
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
/** `BatonConfig.resolvePrincipal` — the ONLY identity provenance (SPEC §11.4).
|
|
1495
|
+
*
|
|
1496
|
+
* **The producer never reads the token itself** (SPEC §11.4, §13 2026-10-02 —
|
|
1497
|
+
* Python's own token rung was removed the same day), so every principal this
|
|
1498
|
+
* SDK emits is `source: "asserted"`. The hook's context carries the validated
|
|
1499
|
+
* `authInfo`, and `oauthHooks.ts` ships the two ready-made OAuth hooks.
|
|
1436
1500
|
*
|
|
1437
1501
|
* The TypeScript half of Python's `integrations/identity_adapter.py`, built to
|
|
1438
1502
|
* close register D6: the field (`user_id` until 0.3.5) had been on this SDK's
|
|
1439
1503
|
* envelope since 0.3.0 and NOTHING could populate it, so a partition that
|
|
1440
1504
|
* works on one of two SDKs is not a partition.
|
|
1441
|
-
*
|
|
1442
|
-
* **Hook only — there is deliberately no ATTESTED rung here yet**, so every
|
|
1443
|
-
* principal this SDK emits carries `source: "asserted"`.
|
|
1444
|
-
*
|
|
1445
|
-
* ⚠ **The missing rung has no shape on the value, and never will again.** This
|
|
1446
|
-
* note said "saying `no h1: rung` would be false, because this SDK does emit
|
|
1447
|
-
* `h1:`" — true until 0.4.1, when the tag came off the value entirely (SPEC
|
|
1448
|
-
* §11.4, §13 entry 0.8.11). A hashed principal is now the bare digest, so there
|
|
1449
|
-
* is no prefix to be right or wrong about: the missing thing is the
|
|
1450
|
-
* `source: "attested"` VALUE, and a consumer reads `source` to learn it. SPEC
|
|
1451
|
-
* §11.4 forbids presenting an asserted principal as verified, and this arm has
|
|
1452
|
-
* only asserted to present.
|
|
1453
|
-
*
|
|
1454
|
-
* Python reads `claims["sub"]` off a verified access token; TypeScript's
|
|
1455
|
-
* `AuthInfo` has no `claims` field at all (it is
|
|
1456
|
-
* `{token, clientId, scopes, expiresAt?, resource?, extra?}`), so the nearest
|
|
1457
|
-
* carrier is the untyped `extra` bag and nothing specifies that `sub` lives
|
|
1458
|
-
* there. Reading it would mean guessing where a subject lives, vendor by
|
|
1459
|
-
* vendor — and a wrong guess is how two people end up as one actor. Recorded
|
|
1460
|
-
* as a divergence rather than filled with a guess.
|
|
1461
1505
|
*/
|
|
1462
1506
|
|
|
1463
1507
|
/** What a vendor's `resolvePrincipal` hook is handed.
|
|
@@ -1488,6 +1532,14 @@ interface PrincipalResolutionContext {
|
|
|
1488
1532
|
/** The call's arguments, AFTER Baton's injected intent params are stripped,
|
|
1489
1533
|
* so a hook sees exactly what the vendor's own handler will. */
|
|
1490
1534
|
arguments: Record<string, unknown>;
|
|
1535
|
+
/** The validated access token for this request, read from wherever this
|
|
1536
|
+
* major keeps it — see `extraAuthInfo`. `null` on stdio and on any
|
|
1537
|
+
* unauthenticated request. `principalFromOAuthSub` and
|
|
1538
|
+
* `principalFromOAuthEmail` read it, and so can a vendor's own hook.
|
|
1539
|
+
*
|
|
1540
|
+
* Optional so a vendor hand-building a context in their own tests keeps
|
|
1541
|
+
* compiling, as Python's defaulted `claims` keeps theirs running. */
|
|
1542
|
+
authInfo?: AuthInfo | null | undefined;
|
|
1491
1543
|
}
|
|
1492
1544
|
/** A vendor's per-request identity resolver. Sync or async; returning `null`
|
|
1493
1545
|
* means "no opinion about this caller", which is not an error. */
|
|
@@ -1650,10 +1702,11 @@ interface BatonConfig {
|
|
|
1650
1702
|
* tool name, and the arguments the vendor's own handler will see. Return a
|
|
1651
1703
|
* `Principal`, or `null` for "no opinion about this caller".
|
|
1652
1704
|
*
|
|
1653
|
-
* **This is the only identity mechanism on
|
|
1654
|
-
*
|
|
1655
|
-
*
|
|
1656
|
-
*
|
|
1705
|
+
* **This is the only identity mechanism, on both SDKs** (SPEC §11.4): unset,
|
|
1706
|
+
* no event carries a `principal`. For OAuth, pass `principalFromOAuthSub` or
|
|
1707
|
+
* `principalFromOAuthEmail`, which read the validated token the context
|
|
1708
|
+
* carries as `authInfo`. MCP auth is HTTP middleware, so on stdio there is no
|
|
1709
|
+
* token and a hook names the user from whatever the vendor authenticated.
|
|
1657
1710
|
*
|
|
1658
1711
|
* Never fails a tool call: a hook that throws or returns junk yields an
|
|
1659
1712
|
* anonymous call. ⚠ It is awaited INLINE with no timeout — a blocking hook
|
|
@@ -1802,4 +1855,57 @@ interface SupportedMcpServer {
|
|
|
1802
1855
|
/** Install Baton into an `McpServer`. See module docstring for usage. */
|
|
1803
1856
|
declare function withBaton(server: SupportedMcpServer, supplied?: BatonConfig): BatonHandle;
|
|
1804
1857
|
|
|
1805
|
-
|
|
1858
|
+
/** Ready-made `resolvePrincipal` hooks for a server running OAuth.
|
|
1859
|
+
*
|
|
1860
|
+
* Pass one as `BatonConfig.resolvePrincipal`. Each reads a claim off the
|
|
1861
|
+
* validated token the context carries as `authInfo`, and returns `null` when
|
|
1862
|
+
* the claim is not there — so they compose:
|
|
1863
|
+
*
|
|
1864
|
+
* ```ts
|
|
1865
|
+
* resolvePrincipal: (ctx) => principalFromOAuthEmail(ctx) ?? principalFromOAuthSub(ctx)
|
|
1866
|
+
* ```
|
|
1867
|
+
*
|
|
1868
|
+
* They are ordinary hooks: what they return is `source: "asserted"` like any
|
|
1869
|
+
* other (SPEC §11.4). The Python twins are `principal_from_oauth_sub` and
|
|
1870
|
+
* `principal_from_oauth_email`, and the two must agree on one token.
|
|
1871
|
+
*
|
|
1872
|
+
* ⚠ **They read the claims from `authInfo.extra`, and that is a convention,
|
|
1873
|
+
* not a contract.** Neither MCP major's `AuthInfo` has a `claims` member — the
|
|
1874
|
+
* only place a verifier can put the token's subject is the free-form `extra`
|
|
1875
|
+
* bag, and nothing specifies the keys. These hooks expect the standard JWT
|
|
1876
|
+
* claim names (`sub`, `iss`, `email`) at the top of `extra`, which is what a
|
|
1877
|
+
* verifier that spreads its decoded payload into `extra` produces. A verifier
|
|
1878
|
+
* that nests them, renames them or omits them gets `null` here, and its vendor
|
|
1879
|
+
* writes a three-line hook reading wherever their verifier put them. Python
|
|
1880
|
+
* reads a typed `claims` field instead, which is why the two arms describe the
|
|
1881
|
+
* same hooks differently.
|
|
1882
|
+
*
|
|
1883
|
+
* ⚠ **Never `clientId`.** It names the OAuth APPLICATION, not the person, and
|
|
1884
|
+
* is identical for every user of one app; keying on it merges all of them.
|
|
1885
|
+
*
|
|
1886
|
+
* HTTP only: MCP auth is HTTP middleware, so a stdio call has no token and both
|
|
1887
|
+
* hooks return `null` there.
|
|
1888
|
+
*/
|
|
1889
|
+
|
|
1890
|
+
/** The token's `sub`, keyed with its `iss` — a subject is unique only per
|
|
1891
|
+
* issuer, so two identity providers can hand two people the same one. */
|
|
1892
|
+
declare function principalFromOAuthSub(context: PrincipalResolutionContext): Principal | null;
|
|
1893
|
+
/** The token's `email`, as the WHOLE address and with NO issuer.
|
|
1894
|
+
*
|
|
1895
|
+
* `principalId` is the whole address and `displayName` the part before the
|
|
1896
|
+
* last `@`. The local part alone is not an id — `alice@acme.com` and
|
|
1897
|
+
* `alice@contoso.com` are two people. `displayName` IS sent, in every mode: a
|
|
1898
|
+
* vendor who hashes ids and does not want `alice` on the wire writes their
|
|
1899
|
+
* own hook.
|
|
1900
|
+
*
|
|
1901
|
+
* No issuer, unlike the `sub` hook: a subject is unique only per issuer, an
|
|
1902
|
+
* address on its own, and folding `iss` in would give one person a new
|
|
1903
|
+
* pseudonym the day their identity provider changes its issuer URL.
|
|
1904
|
+
*
|
|
1905
|
+
* ⚠ `email` is not a standard ACCESS-token claim (OIDC puts it in the ID
|
|
1906
|
+
* token), so it is here only if the identity provider adds it and the verifier
|
|
1907
|
+
* keeps it. `email_verified` is not consulted: whether an unverified address is
|
|
1908
|
+
* good enough is the vendor's call. */
|
|
1909
|
+
declare function principalFromOAuthEmail(context: PrincipalResolutionContext): Principal | null;
|
|
1910
|
+
|
|
1911
|
+
export { type AnnotationEvent, AnnotationEventSchema, type AnnotationPayload, AnnotationPayloadSchema, type AuthInfo, type BatonConfig, BatonHandle, DEFAULT_CONSENT_TOKEN, DEPTH_LIMIT, type Event, EventSchema, type EventType, EventTypeSchema, HttpSink, type HttpSinkOptions, PRINCIPAL_FORM_HASHED, PRINCIPAL_FORM_RAW, PRINCIPAL_SOURCE_ASSERTED, type Principal, type PrincipalIdMode, type PrincipalResolutionContext, PrincipalWireSchema, type PromptGetEndEvent, PromptGetEndEventSchema, type PromptGetEndPayload, PromptGetEndPayloadSchema, type PromptGetErrorEvent, PromptGetErrorEventSchema, type PromptGetErrorPayload, PromptGetErrorPayloadSchema, type PromptGetStartEvent, PromptGetStartEventSchema, type PromptGetStartPayload, PromptGetStartPayloadSchema, type PromptListEndEvent, PromptListEndEventSchema, type PromptListEndPayload, PromptListEndPayloadSchema, type PromptListErrorEvent, PromptListErrorEventSchema, type PromptListErrorPayload, PromptListErrorPayloadSchema, type PromptListStartEvent, PromptListStartEventSchema, type PromptListStartPayload, PromptListStartPayloadSchema, type ResolvePrincipalHook, type ResourceListEndEvent, ResourceListEndEventSchema, type ResourceListEndPayload, ResourceListEndPayloadSchema, type ResourceListErrorEvent, ResourceListErrorEventSchema, type ResourceListErrorPayload, ResourceListErrorPayloadSchema, type ResourceListStartEvent, ResourceListStartEventSchema, type ResourceListStartPayload, ResourceListStartPayloadSchema, type ResourceReadEndEvent, ResourceReadEndEventSchema, type ResourceReadEndPayload, ResourceReadEndPayloadSchema, type ResourceReadErrorEvent, ResourceReadErrorEventSchema, type ResourceReadErrorPayload, ResourceReadErrorPayloadSchema, type ResourceReadStartEvent, ResourceReadStartEventSchema, type ResourceReadStartPayload, ResourceReadStartPayloadSchema, type ResultCaptureMode, SDK_VERSION, Scrubber, type Sink, StdoutSink, type StdoutSinkOptions, type SupportedMcpServer, type SurfaceSnapshotEvent, SurfaceSnapshotEventSchema, type SurfaceSnapshotPayload, SurfaceSnapshotPayloadSchema, type ToolCallEndEvent, ToolCallEndEventSchema, type ToolCallEndPayload, ToolCallEndPayloadSchema, type ToolCallErrorEvent, ToolCallErrorEventSchema, type ToolCallErrorPayload, ToolCallErrorPayloadSchema, type ToolCallStartEvent, ToolCallStartEventSchema, type ToolCallStartPayload, ToolCallStartPayloadSchema, hashPrincipalId, identityScrub, principalFromOAuthEmail, principalFromOAuthSub, safeWrite, withBaton };
|