@goodtiming/baton-sdk 0.5.0 → 0.5.2
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 +113 -118
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +152 -93
- package/dist/index.d.ts +152 -93
- package/dist/index.js +109 -115
- 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.2";
|
|
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>>;
|
|
@@ -1371,24 +1407,15 @@ declare class HttpSink implements Sink {
|
|
|
1371
1407
|
private sendWithRetry;
|
|
1372
1408
|
}
|
|
1373
1409
|
|
|
1374
|
-
/** Principal identity —
|
|
1410
|
+
/** Principal identity — what a vendor's resolver hands back, and how it goes
|
|
1411
|
+
* on the wire.
|
|
1375
1412
|
*
|
|
1376
1413
|
* The TypeScript half of Python's `baton/identity.py`. Baton attaches the
|
|
1377
1414
|
* resolved principal to every event so the Console can group by
|
|
1378
1415
|
* `(tenant_id, vendor_id, principal.id)`, at whatever grain the vendor
|
|
1379
|
-
* resolved (SPEC §11.4).
|
|
1380
|
-
*
|
|
1381
|
-
*
|
|
1382
|
-
* the HASH — raw identity must never leave the capture edge. So hashing
|
|
1383
|
-
* happens HERE, before an event reaches any console-bound sink.
|
|
1384
|
-
*
|
|
1385
|
-
* ⚠ **This file and Python's must produce byte-identical digests**, and that
|
|
1386
|
-
* is asserted rather than believed: `test/identity.test.ts` runs a corpus
|
|
1387
|
-
* GENERATED from Python (`test/identityVectors.json`, regenerated by
|
|
1388
|
-
* `scripts/gen_identity_vectors.py`) and compares strings. Same discipline as
|
|
1389
|
-
* `scrub.ts` — though NOT its method, which was a hand-mirrored matrix, not a
|
|
1390
|
-
* generated corpus — for the same reason: one person reaching two SDKs must be one
|
|
1391
|
-
* actor downstream, and nothing but a differential corpus can prove it.
|
|
1416
|
+
* resolved (SPEC §11.4). The resolver decides everything about the value: who
|
|
1417
|
+
* it names, whether it is hashed, what a page shows for it. The SDK sends it
|
|
1418
|
+
* on as stated.
|
|
1392
1419
|
*/
|
|
1393
1420
|
/** Where a principal came from. `"asserted"` is a vendor's own resolver,
|
|
1394
1421
|
* which nothing in the protocol checks, and is the only value this SDK
|
|
@@ -1399,65 +1426,52 @@ declare const PRINCIPAL_SOURCE_ASSERTED = "asserted";
|
|
|
1399
1426
|
* SPEC §11.4 lets a consumer classify on. */
|
|
1400
1427
|
declare const PRINCIPAL_FORM_HASHED = "hashed";
|
|
1401
1428
|
declare const PRINCIPAL_FORM_RAW = "raw";
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
type PrincipalIdMode = typeof PRINCIPAL_ID_MODE_HASHED | typeof PRINCIPAL_ID_MODE_RAW;
|
|
1405
|
-
/** A raw, UNHASHED principal, as a resolver produced it. */
|
|
1429
|
+
type PrincipalForm = typeof PRINCIPAL_FORM_HASHED | typeof PRINCIPAL_FORM_RAW;
|
|
1430
|
+
/** A principal as a vendor's resolver produced it. */
|
|
1406
1431
|
interface Principal {
|
|
1407
|
-
/**
|
|
1408
|
-
*
|
|
1409
|
-
*
|
|
1432
|
+
/** A stable identifier from the vendor's own system. Never an application
|
|
1433
|
+
* id: that names the app and is identical for every one of its users, which
|
|
1434
|
+
* merges them into one actor. */
|
|
1410
1435
|
principalId: string;
|
|
1411
|
-
/**
|
|
1412
|
-
* the
|
|
1413
|
-
*
|
|
1414
|
-
*
|
|
1415
|
-
|
|
1436
|
+
/** What `principalId` is: `"raw"`, a real identity, or `"hashed"`, a
|
|
1437
|
+
* pseudonym the resolver derived itself. A consumer treats anything not
|
|
1438
|
+
* `"hashed"` as personal data, so leave it unset unless the resolver hashed
|
|
1439
|
+
* the value. */
|
|
1440
|
+
form?: PrincipalForm | undefined;
|
|
1441
|
+
/** What a page shows for this principal — `principalFromOAuthEmail` puts
|
|
1442
|
+
* the part of the address before the last `@` here. Sent verbatim and never
|
|
1443
|
+
* through the scrubber (SPEC §11.4): the vendor chooses what is safe to
|
|
1444
|
+
* show, and it is personal data whatever `form` says. An unusable value is
|
|
1445
|
+
* dropped alone — see `wireDisplayName`. */
|
|
1446
|
+
displayName?: string | null | undefined;
|
|
1416
1447
|
}
|
|
1417
|
-
/** HMAC-SHA256 a raw principal into a console-safe, per-tenant `principal.id`.
|
|
1418
|
-
*
|
|
1419
|
-
* `tenantId` is folded into the HMAC MESSAGE (not just the key) so the same
|
|
1420
|
-
* principal under two tenants can never collide or be cross-tenant-correlated.
|
|
1421
|
-
* Returns the BARE lowercase hex digest — no tag, no prefix, no scheme. It
|
|
1422
|
-
* returned `"h1:<hex>"` until 0.4.1; the tag was never part of the HMAC
|
|
1423
|
-
* message, so taking it off moved no digit of the digest.
|
|
1424
|
-
*
|
|
1425
|
-
* ⚠ **`issuer` null/undefined MUST hash byte-identically to the pre-issuer
|
|
1426
|
-
* form** — the append-only message layout is what guarantees it, and every
|
|
1427
|
-
* hash baton-proxy and baton-extmcp have produced since 0.5.0 was issuer-less.
|
|
1428
|
-
*/
|
|
1429
|
-
declare function hashPrincipalId(rawPrincipal: string, options: {
|
|
1430
|
-
tenantId: string;
|
|
1431
|
-
key: Uint8Array | string;
|
|
1432
|
-
issuer?: string | null | undefined;
|
|
1433
|
-
}): string;
|
|
1434
1448
|
|
|
1435
|
-
/**
|
|
1436
|
-
*
|
|
1437
|
-
*
|
|
1438
|
-
*
|
|
1439
|
-
* envelope since 0.3.0 and NOTHING could populate it, so a partition that
|
|
1440
|
-
* works on one of two SDKs is not a partition.
|
|
1449
|
+
/** A validated access token, as both majors declare it
|
|
1450
|
+
* (`@modelcontextprotocol/sdk` 1.x `server/auth/types.d.ts`,
|
|
1451
|
+
* `@modelcontextprotocol/server` 2.0.0 `createMcpHandler-*.d.mts:751` — the
|
|
1452
|
+
* same six members). Declared structurally for the reason {@link Extra} is.
|
|
1441
1453
|
*
|
|
1442
|
-
* **
|
|
1443
|
-
*
|
|
1454
|
+
* ⚠ **There is no `claims` member.** Whatever a verifier knows about the
|
|
1455
|
+
* subject goes in the free-form `extra` bag, and only the vendor's verifier
|
|
1456
|
+
* decides what is there. */
|
|
1457
|
+
interface AuthInfo {
|
|
1458
|
+
token: string;
|
|
1459
|
+
clientId: string;
|
|
1460
|
+
scopes: string[];
|
|
1461
|
+
expiresAt?: number | undefined;
|
|
1462
|
+
resource?: URL | undefined;
|
|
1463
|
+
extra?: Record<string, unknown> | undefined;
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
/** `BatonConfig.resolvePrincipal` — the ONLY identity provenance (SPEC §11.4).
|
|
1444
1467
|
*
|
|
1445
|
-
*
|
|
1446
|
-
*
|
|
1447
|
-
*
|
|
1448
|
-
*
|
|
1449
|
-
*
|
|
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.
|
|
1468
|
+
* The producer never reads the token itself and never derives the value: who
|
|
1469
|
+
* the person is, and whether the id is hashed, are the hook's to state. Every
|
|
1470
|
+
* principal this SDK emits is `source: "asserted"`. The hook's context carries
|
|
1471
|
+
* the validated `authInfo`, and `oauthHooks.ts` ships the two ready-made
|
|
1472
|
+
* OAuth hooks.
|
|
1453
1473
|
*
|
|
1454
|
-
*
|
|
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.
|
|
1474
|
+
* The TypeScript half of Python's `integrations/identity_adapter.py`.
|
|
1461
1475
|
*/
|
|
1462
1476
|
|
|
1463
1477
|
/** What a vendor's `resolvePrincipal` hook is handed.
|
|
@@ -1488,6 +1502,14 @@ interface PrincipalResolutionContext {
|
|
|
1488
1502
|
/** The call's arguments, AFTER Baton's injected intent params are stripped,
|
|
1489
1503
|
* so a hook sees exactly what the vendor's own handler will. */
|
|
1490
1504
|
arguments: Record<string, unknown>;
|
|
1505
|
+
/** The validated access token for this request, read from wherever this
|
|
1506
|
+
* major keeps it — see `extraAuthInfo`. `null` on stdio and on any
|
|
1507
|
+
* unauthenticated request. `principalFromOAuthSub` and
|
|
1508
|
+
* `principalFromOAuthEmail` read it, and so can a vendor's own hook.
|
|
1509
|
+
*
|
|
1510
|
+
* Optional so a vendor hand-building a context in their own tests keeps
|
|
1511
|
+
* compiling, as Python's defaulted `claims` keeps theirs running. */
|
|
1512
|
+
authInfo?: AuthInfo | null | undefined;
|
|
1491
1513
|
}
|
|
1492
1514
|
/** A vendor's per-request identity resolver. Sync or async; returning `null`
|
|
1493
1515
|
* means "no opinion about this caller", which is not an error. */
|
|
@@ -1496,10 +1518,8 @@ type ResolvePrincipalHook = (context: PrincipalResolutionContext) => Principal |
|
|
|
1496
1518
|
/** The registered values of `resultCaptureMode` (SPEC §11.4), and the single
|
|
1497
1519
|
* source of truth for them.
|
|
1498
1520
|
*
|
|
1499
|
-
*
|
|
1500
|
-
*
|
|
1501
|
-
* happen to agree", which is the prose-shaped binding that pattern exists to
|
|
1502
|
-
* replace. `config.ts` builds its validator set from THIS array rather than
|
|
1521
|
+
* A second hand-written list would make the guarantee "two lists happen to
|
|
1522
|
+
* agree". `config.ts` builds its validator set from THIS array rather than
|
|
1503
1523
|
* restating the literals, so a mode cannot be accepted at the door without
|
|
1504
1524
|
* someone having given it a payload shape below. */
|
|
1505
1525
|
declare const RESULT_CAPTURE_MODES: readonly ["full", "off"];
|
|
@@ -1650,30 +1670,21 @@ interface BatonConfig {
|
|
|
1650
1670
|
* tool name, and the arguments the vendor's own handler will see. Return a
|
|
1651
1671
|
* `Principal`, or `null` for "no opinion about this caller".
|
|
1652
1672
|
*
|
|
1653
|
-
* **This is the only identity mechanism on
|
|
1654
|
-
*
|
|
1655
|
-
*
|
|
1656
|
-
*
|
|
1673
|
+
* **This is the only identity mechanism, on both SDKs** (SPEC §11.4): unset,
|
|
1674
|
+
* no event carries a `principal`. For OAuth, pass `principalFromOAuthSub` or
|
|
1675
|
+
* `principalFromOAuthEmail`, which read the validated token the context
|
|
1676
|
+
* carries as `authInfo`. MCP auth is HTTP middleware, so on stdio there is no
|
|
1677
|
+
* token and a hook names the user from whatever the vendor authenticated.
|
|
1657
1678
|
*
|
|
1658
1679
|
* Never fails a tool call: a hook that throws or returns junk yields an
|
|
1659
1680
|
* anonymous call. ⚠ It is awaited INLINE with no timeout — a blocking hook
|
|
1660
|
-
* stalls its own request.
|
|
1661
|
-
resolvePrincipal?: ResolvePrincipalHook;
|
|
1662
|
-
/** `"hashed"` (default) emits a per-tenant HMAC pseudonym and
|
|
1663
|
-
* `form: "hashed"`; `"raw"` emits the subject VERBATIM and `form: "raw"`.
|
|
1664
|
-
*
|
|
1665
|
-
* `"raw"` puts real identity in the collector's database and is the vendor's
|
|
1666
|
-
* deliberate choice. ⚠ A consumer classifies on `form`, never on this
|
|
1667
|
-
* setting — `PrincipalWireSchema` carries the rule and why it is stated that
|
|
1668
|
-
* way round. */
|
|
1669
|
-
principalIdMode?: PrincipalIdMode;
|
|
1670
|
-
/** The HMAC secret for hashed mode. Resolved explicit →
|
|
1671
|
-
* `BATON_PRINCIPAL_ID_HMAC_KEY` → unset.
|
|
1681
|
+
* stalls its own request.
|
|
1672
1682
|
*
|
|
1673
|
-
*
|
|
1674
|
-
*
|
|
1675
|
-
*
|
|
1676
|
-
|
|
1683
|
+
* The SDK sends what the hook returns and does nothing else to it: the id
|
|
1684
|
+
* as given, `form` to say whether the hook hashed it, and `displayName` for
|
|
1685
|
+
* what a page shows. A vendor who must not send real identities hashes
|
|
1686
|
+
* inside the hook and returns `form: "hashed"`. */
|
|
1687
|
+
resolvePrincipal?: ResolvePrincipalHook;
|
|
1677
1688
|
}
|
|
1678
1689
|
|
|
1679
1690
|
/**
|
|
@@ -1802,4 +1813,52 @@ interface SupportedMcpServer {
|
|
|
1802
1813
|
/** Install Baton into an `McpServer`. See module docstring for usage. */
|
|
1803
1814
|
declare function withBaton(server: SupportedMcpServer, supplied?: BatonConfig): BatonHandle;
|
|
1804
1815
|
|
|
1805
|
-
|
|
1816
|
+
/** Ready-made `resolvePrincipal` hooks for a server running OAuth.
|
|
1817
|
+
*
|
|
1818
|
+
* Pass one as `BatonConfig.resolvePrincipal`. Each reads a claim off the
|
|
1819
|
+
* validated token the context carries as `authInfo`, and returns `null` when
|
|
1820
|
+
* the claim is not there — so they compose:
|
|
1821
|
+
*
|
|
1822
|
+
* ```ts
|
|
1823
|
+
* resolvePrincipal: (ctx) => principalFromOAuthEmail(ctx) ?? principalFromOAuthSub(ctx)
|
|
1824
|
+
* ```
|
|
1825
|
+
*
|
|
1826
|
+
* They are ordinary hooks: what they return is `source: "asserted"` like any
|
|
1827
|
+
* other (SPEC §11.4). The Python twins are `principal_from_oauth_sub` and
|
|
1828
|
+
* `principal_from_oauth_email`, and the two must agree on one token.
|
|
1829
|
+
*
|
|
1830
|
+
* ⚠ **They read the claims from `authInfo.extra`, and that is a convention,
|
|
1831
|
+
* not a contract.** Neither MCP major's `AuthInfo` has a `claims` member — the
|
|
1832
|
+
* only place a verifier can put the token's subject is the free-form `extra`
|
|
1833
|
+
* bag, and nothing specifies the keys. These hooks expect the standard JWT
|
|
1834
|
+
* claim names (`sub`, `iss`, `email`) at the top of `extra`, which is what a
|
|
1835
|
+
* verifier that spreads its decoded payload into `extra` produces. A verifier
|
|
1836
|
+
* that nests them, renames them or omits them gets `null` here, and its vendor
|
|
1837
|
+
* writes a three-line hook reading wherever their verifier put them. Python
|
|
1838
|
+
* reads a typed `claims` field instead, which is why the two arms describe the
|
|
1839
|
+
* same hooks differently.
|
|
1840
|
+
*
|
|
1841
|
+
* ⚠ **Never `clientId`.** It names the OAuth APPLICATION, not the person, and
|
|
1842
|
+
* is identical for every user of one app; keying on it merges all of them.
|
|
1843
|
+
*
|
|
1844
|
+
* HTTP only: MCP auth is HTTP middleware, so a stdio call has no token and both
|
|
1845
|
+
* hooks return `null` there.
|
|
1846
|
+
*/
|
|
1847
|
+
|
|
1848
|
+
/** The token's `sub`. A subject is unique only per issuer: a vendor running
|
|
1849
|
+
* two identity providers writes a hook that combines it with `iss`. */
|
|
1850
|
+
declare function principalFromOAuthSub(context: PrincipalResolutionContext): Principal | null;
|
|
1851
|
+
/** The token's `email`, as the WHOLE address.
|
|
1852
|
+
*
|
|
1853
|
+
* `principalId` is the whole address and `displayName` the part before the
|
|
1854
|
+
* last `@`. The local part alone is not an id — `alice@acme.com` and
|
|
1855
|
+
* `alice@contoso.com` are two people. A vendor who does not want `alice` on
|
|
1856
|
+
* the wire writes their own hook.
|
|
1857
|
+
*
|
|
1858
|
+
* ⚠ `email` is not a standard ACCESS-token claim (OIDC puts it in the ID
|
|
1859
|
+
* token), so it is here only if the identity provider adds it and the verifier
|
|
1860
|
+
* keeps it. `email_verified` is not consulted: whether an unverified address is
|
|
1861
|
+
* good enough is the vendor's call. */
|
|
1862
|
+
declare function principalFromOAuthEmail(context: PrincipalResolutionContext): Principal | null;
|
|
1863
|
+
|
|
1864
|
+
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 PrincipalForm, 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, identityScrub, principalFromOAuthEmail, principalFromOAuthSub, safeWrite, withBaton };
|