@goodtiming/baton-sdk 0.5.3 → 0.5.5
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 +4 -1
- package/dist/index.cjs +68 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +54 -11
- package/dist/index.d.ts +54 -11
- package/dist/index.js +68 -48
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
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.5";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Zod schemas + TS types for the Baton event stream per SPEC §11.4.
|
|
@@ -90,13 +90,13 @@ declare const ToolCallErrorPayloadSchema: z.ZodObject<{
|
|
|
90
90
|
failure_kind: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
91
91
|
}, z.core.$strict>;
|
|
92
92
|
type ToolCallErrorPayload = z.infer<typeof ToolCallErrorPayloadSchema>;
|
|
93
|
-
/** Agent-supplied context
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* populate `signal_type`/`suggested_improvement`. */
|
|
93
|
+
/** Agent-supplied context, all nullable. An annotation with `what_happened`
|
|
94
|
+
* filled is a report; one without is a note (SPEC §11.4). `signal_type` is
|
|
95
|
+
* kept for events from older producers: this SDK always sends it null. */
|
|
97
96
|
declare const AnnotationPayloadSchema: z.ZodObject<{
|
|
98
97
|
intent: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
99
98
|
expected_outcome: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
99
|
+
what_happened: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
100
100
|
signal_type: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
101
101
|
workflow: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
102
102
|
suggested_improvement: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -340,6 +340,7 @@ declare const ToolCallStartEventSchema: z.ZodObject<{
|
|
|
340
340
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
341
341
|
}, z.core.$strict>>>;
|
|
342
342
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
343
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
343
344
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
344
345
|
info: z.ZodOptional<z.ZodObject<{
|
|
345
346
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -378,6 +379,7 @@ declare const ToolCallEndEventSchema: z.ZodObject<{
|
|
|
378
379
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
379
380
|
}, z.core.$strict>>>;
|
|
380
381
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
382
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
381
383
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
382
384
|
info: z.ZodOptional<z.ZodObject<{
|
|
383
385
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -419,6 +421,7 @@ declare const ToolCallErrorEventSchema: z.ZodObject<{
|
|
|
419
421
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
420
422
|
}, z.core.$strict>>>;
|
|
421
423
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
424
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
422
425
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
423
426
|
info: z.ZodOptional<z.ZodObject<{
|
|
424
427
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -437,6 +440,7 @@ declare const AnnotationEventSchema: z.ZodObject<{
|
|
|
437
440
|
payload: z.ZodObject<{
|
|
438
441
|
intent: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
439
442
|
expected_outcome: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
443
|
+
what_happened: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
440
444
|
signal_type: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
441
445
|
workflow: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
442
446
|
suggested_improvement: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -460,6 +464,7 @@ declare const AnnotationEventSchema: z.ZodObject<{
|
|
|
460
464
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
461
465
|
}, z.core.$strict>>>;
|
|
462
466
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
467
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
463
468
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
464
469
|
info: z.ZodOptional<z.ZodObject<{
|
|
465
470
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -500,6 +505,7 @@ declare const SurfaceSnapshotEventSchema: z.ZodObject<{
|
|
|
500
505
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
501
506
|
}, z.core.$strict>>>;
|
|
502
507
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
508
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
503
509
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
504
510
|
info: z.ZodOptional<z.ZodObject<{
|
|
505
511
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -533,6 +539,7 @@ declare const ResourceListStartEventSchema: z.ZodObject<{
|
|
|
533
539
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
534
540
|
}, z.core.$strict>>>;
|
|
535
541
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
542
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
536
543
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
537
544
|
info: z.ZodOptional<z.ZodObject<{
|
|
538
545
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -569,6 +576,7 @@ declare const ResourceListEndEventSchema: z.ZodObject<{
|
|
|
569
576
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
570
577
|
}, z.core.$strict>>>;
|
|
571
578
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
579
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
572
580
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
573
581
|
info: z.ZodOptional<z.ZodObject<{
|
|
574
582
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -606,6 +614,7 @@ declare const ResourceListErrorEventSchema: z.ZodObject<{
|
|
|
606
614
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
607
615
|
}, z.core.$strict>>>;
|
|
608
616
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
617
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
609
618
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
610
619
|
info: z.ZodOptional<z.ZodObject<{
|
|
611
620
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -642,6 +651,7 @@ declare const ResourceReadStartEventSchema: z.ZodObject<{
|
|
|
642
651
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
643
652
|
}, z.core.$strict>>>;
|
|
644
653
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
654
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
645
655
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
646
656
|
info: z.ZodOptional<z.ZodObject<{
|
|
647
657
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -678,6 +688,7 @@ declare const ResourceReadEndEventSchema: z.ZodObject<{
|
|
|
678
688
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
679
689
|
}, z.core.$strict>>>;
|
|
680
690
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
691
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
681
692
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
682
693
|
info: z.ZodOptional<z.ZodObject<{
|
|
683
694
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -716,6 +727,7 @@ declare const ResourceReadErrorEventSchema: z.ZodObject<{
|
|
|
716
727
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
717
728
|
}, z.core.$strict>>>;
|
|
718
729
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
730
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
719
731
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
720
732
|
info: z.ZodOptional<z.ZodObject<{
|
|
721
733
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -749,6 +761,7 @@ declare const PromptListStartEventSchema: z.ZodObject<{
|
|
|
749
761
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
750
762
|
}, z.core.$strict>>>;
|
|
751
763
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
764
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
752
765
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
753
766
|
info: z.ZodOptional<z.ZodObject<{
|
|
754
767
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -785,6 +798,7 @@ declare const PromptListEndEventSchema: z.ZodObject<{
|
|
|
785
798
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
786
799
|
}, z.core.$strict>>>;
|
|
787
800
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
801
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
788
802
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
789
803
|
info: z.ZodOptional<z.ZodObject<{
|
|
790
804
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -822,6 +836,7 @@ declare const PromptListErrorEventSchema: z.ZodObject<{
|
|
|
822
836
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
823
837
|
}, z.core.$strict>>>;
|
|
824
838
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
839
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
825
840
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
826
841
|
info: z.ZodOptional<z.ZodObject<{
|
|
827
842
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -858,6 +873,7 @@ declare const PromptGetStartEventSchema: z.ZodObject<{
|
|
|
858
873
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
859
874
|
}, z.core.$strict>>>;
|
|
860
875
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
876
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
861
877
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
862
878
|
info: z.ZodOptional<z.ZodObject<{
|
|
863
879
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -894,6 +910,7 @@ declare const PromptGetEndEventSchema: z.ZodObject<{
|
|
|
894
910
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
895
911
|
}, z.core.$strict>>>;
|
|
896
912
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
913
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
897
914
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
898
915
|
info: z.ZodOptional<z.ZodObject<{
|
|
899
916
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -932,6 +949,7 @@ declare const PromptGetErrorEventSchema: z.ZodObject<{
|
|
|
932
949
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
933
950
|
}, z.core.$strict>>>;
|
|
934
951
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
952
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
935
953
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
936
954
|
info: z.ZodOptional<z.ZodObject<{
|
|
937
955
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -965,6 +983,7 @@ declare const ToolListStartEventSchema: z.ZodObject<{
|
|
|
965
983
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
966
984
|
}, z.core.$strict>>>;
|
|
967
985
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
986
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
968
987
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
969
988
|
info: z.ZodOptional<z.ZodObject<{
|
|
970
989
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -1001,6 +1020,7 @@ declare const ToolListEndEventSchema: z.ZodObject<{
|
|
|
1001
1020
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1002
1021
|
}, z.core.$strict>>>;
|
|
1003
1022
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1023
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1004
1024
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1005
1025
|
info: z.ZodOptional<z.ZodObject<{
|
|
1006
1026
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -1038,6 +1058,7 @@ declare const ToolListErrorEventSchema: z.ZodObject<{
|
|
|
1038
1058
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1039
1059
|
}, z.core.$strict>>>;
|
|
1040
1060
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1061
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1041
1062
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1042
1063
|
info: z.ZodOptional<z.ZodObject<{
|
|
1043
1064
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -1079,6 +1100,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1079
1100
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1080
1101
|
}, z.core.$strict>>>;
|
|
1081
1102
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1103
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1082
1104
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1083
1105
|
info: z.ZodOptional<z.ZodObject<{
|
|
1084
1106
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -1115,6 +1137,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1115
1137
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1116
1138
|
}, z.core.$strict>>>;
|
|
1117
1139
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1140
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1118
1141
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1119
1142
|
info: z.ZodOptional<z.ZodObject<{
|
|
1120
1143
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -1154,6 +1177,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1154
1177
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1155
1178
|
}, z.core.$strict>>>;
|
|
1156
1179
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1180
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1157
1181
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1158
1182
|
info: z.ZodOptional<z.ZodObject<{
|
|
1159
1183
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -1170,6 +1194,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1170
1194
|
payload: z.ZodObject<{
|
|
1171
1195
|
intent: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1172
1196
|
expected_outcome: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1197
|
+
what_happened: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1173
1198
|
signal_type: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1174
1199
|
workflow: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1175
1200
|
suggested_improvement: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -1193,6 +1218,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1193
1218
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1194
1219
|
}, z.core.$strict>>>;
|
|
1195
1220
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1221
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1196
1222
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1197
1223
|
info: z.ZodOptional<z.ZodObject<{
|
|
1198
1224
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -1231,6 +1257,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1231
1257
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1232
1258
|
}, z.core.$strict>>>;
|
|
1233
1259
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1260
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1234
1261
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1235
1262
|
info: z.ZodOptional<z.ZodObject<{
|
|
1236
1263
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -1262,6 +1289,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1262
1289
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1263
1290
|
}, z.core.$strict>>>;
|
|
1264
1291
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1292
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1265
1293
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1266
1294
|
info: z.ZodOptional<z.ZodObject<{
|
|
1267
1295
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -1296,6 +1324,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1296
1324
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1297
1325
|
}, z.core.$strict>>>;
|
|
1298
1326
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1327
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1299
1328
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1300
1329
|
info: z.ZodOptional<z.ZodObject<{
|
|
1301
1330
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -1331,6 +1360,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1331
1360
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1332
1361
|
}, z.core.$strict>>>;
|
|
1333
1362
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1363
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1334
1364
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1335
1365
|
info: z.ZodOptional<z.ZodObject<{
|
|
1336
1366
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -1365,6 +1395,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1365
1395
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1366
1396
|
}, z.core.$strict>>>;
|
|
1367
1397
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1398
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1368
1399
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1369
1400
|
info: z.ZodOptional<z.ZodObject<{
|
|
1370
1401
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -1399,6 +1430,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1399
1430
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1400
1431
|
}, z.core.$strict>>>;
|
|
1401
1432
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1433
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1402
1434
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1403
1435
|
info: z.ZodOptional<z.ZodObject<{
|
|
1404
1436
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -1435,6 +1467,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1435
1467
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1436
1468
|
}, z.core.$strict>>>;
|
|
1437
1469
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1470
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1438
1471
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1439
1472
|
info: z.ZodOptional<z.ZodObject<{
|
|
1440
1473
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -1466,6 +1499,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1466
1499
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1467
1500
|
}, z.core.$strict>>>;
|
|
1468
1501
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1502
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1469
1503
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1470
1504
|
info: z.ZodOptional<z.ZodObject<{
|
|
1471
1505
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -1500,6 +1534,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1500
1534
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1501
1535
|
}, z.core.$strict>>>;
|
|
1502
1536
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1537
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1503
1538
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1504
1539
|
info: z.ZodOptional<z.ZodObject<{
|
|
1505
1540
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -1535,6 +1570,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1535
1570
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1536
1571
|
}, z.core.$strict>>>;
|
|
1537
1572
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1573
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1538
1574
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1539
1575
|
info: z.ZodOptional<z.ZodObject<{
|
|
1540
1576
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -1569,6 +1605,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1569
1605
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1570
1606
|
}, z.core.$strict>>>;
|
|
1571
1607
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1608
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1572
1609
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1573
1610
|
info: z.ZodOptional<z.ZodObject<{
|
|
1574
1611
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -1603,6 +1640,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1603
1640
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1604
1641
|
}, z.core.$strict>>>;
|
|
1605
1642
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1643
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1606
1644
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1607
1645
|
info: z.ZodOptional<z.ZodObject<{
|
|
1608
1646
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -1639,6 +1677,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1639
1677
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1640
1678
|
}, z.core.$strict>>>;
|
|
1641
1679
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1680
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1642
1681
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1643
1682
|
info: z.ZodOptional<z.ZodObject<{
|
|
1644
1683
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -1670,6 +1709,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1670
1709
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1671
1710
|
}, z.core.$strict>>>;
|
|
1672
1711
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1712
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1673
1713
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1674
1714
|
info: z.ZodOptional<z.ZodObject<{
|
|
1675
1715
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -1704,6 +1744,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1704
1744
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1705
1745
|
}, z.core.$strict>>>;
|
|
1706
1746
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1747
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1707
1748
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1708
1749
|
info: z.ZodOptional<z.ZodObject<{
|
|
1709
1750
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -1739,6 +1780,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1739
1780
|
display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1740
1781
|
}, z.core.$strict>>>;
|
|
1741
1782
|
transport_observed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1783
|
+
session_id_origin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1742
1784
|
client_observed: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1743
1785
|
info: z.ZodOptional<z.ZodObject<{
|
|
1744
1786
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -2060,11 +2102,11 @@ interface PrincipalResolutionContext {
|
|
|
2060
2102
|
meta: Record<string, unknown> | null;
|
|
2061
2103
|
/** The tool being called — the annotation tool's own name on that path, so a
|
|
2062
2104
|
* hook can answer differently per call rather than per install. `null` on a
|
|
2063
|
-
*
|
|
2105
|
+
* request that is not a tool call. */
|
|
2064
2106
|
toolName: string | null;
|
|
2065
2107
|
/** The call's arguments, AFTER Baton's injected intent params are stripped,
|
|
2066
2108
|
* so a hook sees exactly what the vendor's own handler will. Empty on a
|
|
2067
|
-
*
|
|
2109
|
+
* request that is not a tool call. */
|
|
2068
2110
|
arguments: Record<string, unknown>;
|
|
2069
2111
|
/** The validated access token for this request, read from wherever this
|
|
2070
2112
|
* major keeps it — see `extraAuthInfo`. `null` on stdio and on any
|
|
@@ -2228,12 +2270,13 @@ interface BatonConfig {
|
|
|
2228
2270
|
* envelope's `principal` (SPEC §11.4 rung 0), which emits
|
|
2229
2271
|
* `source: "asserted"`. It is the only provenance this SDK has.
|
|
2230
2272
|
*
|
|
2231
|
-
* Called on every captured tool call, on the annotation tool
|
|
2232
|
-
* `tools/list` request, with an
|
|
2273
|
+
* Called on every captured tool call, on the annotation tool, on every
|
|
2274
|
+
* `tools/list` request and on every resource and prompt request, with an
|
|
2275
|
+
* adapter-neutral
|
|
2233
2276
|
* {@link PrincipalResolutionContext}: headers folded to ONE case-insensitive
|
|
2234
2277
|
* shape across both SDK majors, the request's `_meta`, the tool name, and
|
|
2235
|
-
* the arguments the vendor's own handler will see. On a
|
|
2236
|
-
* the tool name is `null` and the arguments are empty. Return a `Principal`,
|
|
2278
|
+
* the arguments the vendor's own handler will see. On a request that is not
|
|
2279
|
+
* a tool call the tool name is `null` and the arguments are empty. Return a `Principal`,
|
|
2237
2280
|
* or `null` for "no opinion about this caller".
|
|
2238
2281
|
*
|
|
2239
2282
|
* **This is the only identity mechanism, on both SDKs** (SPEC §11.4): unset,
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
var SDK_VERSION = "ts-0.5.
|
|
2
|
+
var SDK_VERSION = "ts-0.5.5";
|
|
3
3
|
|
|
4
4
|
// src/events.ts
|
|
5
5
|
import { z } from "zod";
|
|
@@ -105,6 +105,7 @@ var ToolCallErrorPayloadSchema = z.object({
|
|
|
105
105
|
var AnnotationPayloadSchema = z.object({
|
|
106
106
|
intent: z.string().nullable().default(null),
|
|
107
107
|
expected_outcome: z.string().nullable().default(null),
|
|
108
|
+
what_happened: z.string().nullable().default(null),
|
|
108
109
|
signal_type: z.string().nullable().default(null),
|
|
109
110
|
workflow: z.string().nullable().default(null),
|
|
110
111
|
suggested_improvement: z.string().nullable().default(null),
|
|
@@ -145,6 +146,7 @@ var envelopeShape = {
|
|
|
145
146
|
agent_runtime: z.string().default("unknown"),
|
|
146
147
|
principal: PrincipalWireSchema.nullable().default(null),
|
|
147
148
|
transport_observed: z.string().nullable().default(null),
|
|
149
|
+
session_id_origin: z.string().nullable().default(null),
|
|
148
150
|
client_observed: ClientObservedSchema.nullable().default(null),
|
|
149
151
|
call_id: z.string().nullable().default(null),
|
|
150
152
|
runtime_meta: z.record(z.string(), z.unknown()).nullable().default(null)
|
|
@@ -770,30 +772,21 @@ function principalFor(principal, onUnregisteredForm) {
|
|
|
770
772
|
// src/integrations/mcp/llmText.ts
|
|
771
773
|
var SERVER_INSTRUCTIONS_TEMPLATE = (vendorDisplayName, annotationToolName) => `This server is wrapped in the ${vendorDisplayName} usage and friction SDK. Use \`${annotationToolName}\` to report when a ${vendorDisplayName} tool call goes wrong, or when a tool you needed does not exist, so ${vendorDisplayName} can improve their product. See that tool's description for field-level detail.
|
|
772
774
|
|
|
773
|
-
AFTER any ${vendorDisplayName} tool errors, times out, returns an unhelpful or contradictory result, or the user shows signs of giving up, you MUST call \`${annotationToolName}\`
|
|
775
|
+
AFTER any ${vendorDisplayName} tool errors, times out, returns an unhelpful or contradictory result, or the user shows signs of giving up, you MUST call \`${annotationToolName}\` with what_happened (REQUIRED, your own words, NOT a category), tool_name (REQUIRED) and suggested_improvement (REQUIRED whenever you can articulate one).
|
|
774
776
|
|
|
775
|
-
IF a ${vendorDisplayName} tool response lacks a structured field for what the user asked about, OR you satisfied the user's intent via a workaround because no tool matched what they asked for, OR the user asked for something this server can't do \u2014 you MUST call \`${annotationToolName}\` with
|
|
777
|
+
IF a ${vendorDisplayName} tool response lacks a structured field for what the user asked about, OR you satisfied the user's intent via a workaround because no tool matched what they asked for, OR the user asked for something this server can't do \u2014 you MUST call \`${annotationToolName}\` once per user request, not per call, with what_happened and tool_name (none if no tool) AND still answer the user with your best inference. Filing the annotation does NOT replace answering.`;
|
|
776
778
|
var ANNOTATION_TOOL_DESCRIPTION_TEMPLATE = (vendorDisplayName) => `Report a ${vendorDisplayName} tool call that went wrong \u2014 call this AFTER a call returns an unhelpful, empty, failed or contradictory result, or when no tool covers what the user asked for. Do NOT call it before a tool call or to narrate normal successful work.
|
|
777
779
|
|
|
778
780
|
Fields:
|
|
779
781
|
- user_goal: one sentence on what the user is trying to accomplish.
|
|
782
|
+
- what_happened: REQUIRED on a report. 1-2 plain sentences in YOUR OWN WORDS: what you asked for, what came back, and why it was unusable. Do NOT pick a category or invent a label \u2014 describe it.
|
|
783
|
+
- tool_name: REQUIRED on a report. The ${vendorDisplayName} tool that went wrong. Write none if no tool exists for the request.
|
|
780
784
|
- expected_result: what a successful result should look like, so a silent/thin failure can be told apart from success.
|
|
781
785
|
- overall_task: short stable label for the broader task this call serves, e.g., 'morning meeting prep', 'pre-outreach research'. REPEAT the exact same string on every call serving the same task; change it only when the user starts a different task.
|
|
782
|
-
-
|
|
783
|
-
-
|
|
784
|
-
- context: supplementary info not covered above. Common keys: plan, alternatives_considered, likely_cause, user_impact, error_class, downstream_blocked, confidence_in_intent. For signal_type='feature_gap' also missing_capability_field and requested_capability.`;
|
|
786
|
+
- suggested_improvement: A concrete sentence about what product change would have helped.
|
|
787
|
+
- context: supplementary info not covered above. Common keys: plan, alternatives_considered, likely_cause, user_impact, error_class, downstream_blocked, confidence_in_intent. When no tool covers the request also missing_capability_field and requested_capability.`;
|
|
785
788
|
var CLAUDE_CODE_TRUNCATION_CAP = 2087;
|
|
786
789
|
var INSTRUCTIONS_LENGTH_CAP = 1500;
|
|
787
|
-
var SIGNAL_TYPES = [
|
|
788
|
-
"failure",
|
|
789
|
-
"retry_loop",
|
|
790
|
-
"dead_end",
|
|
791
|
-
"parameter_confusion",
|
|
792
|
-
"slow_performance",
|
|
793
|
-
"abandonment",
|
|
794
|
-
"feature_gap",
|
|
795
|
-
"other"
|
|
796
|
-
];
|
|
797
790
|
function renderServerInstructions(options) {
|
|
798
791
|
return SERVER_INSTRUCTIONS_TEMPLATE(options.vendorDisplayName, options.annotationToolName);
|
|
799
792
|
}
|
|
@@ -1127,11 +1120,27 @@ function observeClient(extra, options) {
|
|
|
1127
1120
|
|
|
1128
1121
|
// src/integrations/mcp/sessionResolution.ts
|
|
1129
1122
|
async function resolveSessionId(fallbackSessionId, extra) {
|
|
1130
|
-
if (typeof extra.sessionId === "string" && extra.sessionId)
|
|
1131
|
-
|
|
1123
|
+
if (typeof extra.sessionId === "string" && extra.sessionId) {
|
|
1124
|
+
return { sessionId: extra.sessionId, origin: "observed" };
|
|
1125
|
+
}
|
|
1126
|
+
const fromHeader = sessionIdFromHeader(extra);
|
|
1127
|
+
if (fromHeader !== null) return { sessionId: fromHeader, origin: "observed" };
|
|
1128
|
+
return { sessionId: fallbackSessionId, origin: "minted" };
|
|
1129
|
+
}
|
|
1130
|
+
function sessionIdFromHeader(extra) {
|
|
1131
|
+
try {
|
|
1132
|
+
const value = extraHeaders(extra)?.get("mcp-session-id")?.trim();
|
|
1133
|
+
return value ? value : null;
|
|
1134
|
+
} catch {
|
|
1135
|
+
return null;
|
|
1136
|
+
}
|
|
1132
1137
|
}
|
|
1133
1138
|
|
|
1134
1139
|
// src/integrations/mcp/annotation.ts
|
|
1140
|
+
var TOOL_NAME_PARAM_NAME = "tool_name";
|
|
1141
|
+
function isReport(whatHappened) {
|
|
1142
|
+
return typeof whatHappened === "string" && whatHappened.trim() !== "";
|
|
1143
|
+
}
|
|
1135
1144
|
function registerAnnotationTool(server, options) {
|
|
1136
1145
|
const name = deriveAnnotationToolName(options.vendorId, options.annotationToolName);
|
|
1137
1146
|
const description = buildAnnotationToolDescription({
|
|
@@ -1144,23 +1153,38 @@ function registerAnnotationTool(server, options) {
|
|
|
1144
1153
|
inputSchema: {
|
|
1145
1154
|
user_goal: z2.string(),
|
|
1146
1155
|
expected_result: z2.string().optional(),
|
|
1147
|
-
|
|
1156
|
+
what_happened: z2.string().optional(),
|
|
1157
|
+
// Nullable so a report whose agent sends an explicit null is taken,
|
|
1158
|
+
// not rejected by validation.
|
|
1159
|
+
tool_name: z2.string().nullable().optional(),
|
|
1148
1160
|
overall_task: z2.string().optional(),
|
|
1149
1161
|
suggested_improvement: z2.string().optional(),
|
|
1150
1162
|
context: z2.record(z2.string(), z2.unknown()).optional()
|
|
1151
1163
|
}
|
|
1152
1164
|
},
|
|
1153
1165
|
async (args, extra) => {
|
|
1166
|
+
const whatHappened = args.what_happened;
|
|
1167
|
+
if (!isReport(whatHappened)) {
|
|
1168
|
+
return {
|
|
1169
|
+
content: [
|
|
1170
|
+
{
|
|
1171
|
+
type: "text",
|
|
1172
|
+
text: JSON.stringify({
|
|
1173
|
+
ok: false,
|
|
1174
|
+
error: `${name} is reactive-only on this server. Call it only AFTER a tool call returns an unhelpful, empty, failed or contradictory result, or when no tool covers what the user asked for. What the user is trying to do is already recorded on each tool call, so no pre-call annotation is needed \u2014 nothing was lost. If a tool call really went wrong, or no tool covers the request, call this again and say what_happened. If neither is true, do NOT re-send: that would file a report for a call that did not go wrong.`
|
|
1175
|
+
})
|
|
1176
|
+
}
|
|
1177
|
+
]
|
|
1178
|
+
};
|
|
1179
|
+
}
|
|
1180
|
+
const reportedTool = args.tool_name ?? null;
|
|
1154
1181
|
const meta = extraMeta(extra);
|
|
1155
1182
|
const scrubbedMeta = scrubOrNull(
|
|
1156
1183
|
options.scrubber,
|
|
1157
1184
|
meta ? roundMetaCoordinates(meta) : null,
|
|
1158
1185
|
"_meta"
|
|
1159
1186
|
);
|
|
1160
|
-
const sessionId = await resolveSessionId(options.fallbackSessionId, extra);
|
|
1161
|
-
if (args.signal_type === void 0) {
|
|
1162
|
-
options.tracker?.mark(sessionId);
|
|
1163
|
-
}
|
|
1187
|
+
const { sessionId, origin } = await resolveSessionId(options.fallbackSessionId, extra);
|
|
1164
1188
|
const principal = await resolveCallPrincipal(
|
|
1165
1189
|
options.resolvePrincipal,
|
|
1166
1190
|
{ extra, toolName: name, arguments: args }
|
|
@@ -1176,6 +1200,7 @@ function registerAnnotationTool(server, options) {
|
|
|
1176
1200
|
consent_token: options.consentToken,
|
|
1177
1201
|
principal,
|
|
1178
1202
|
transport_observed: observeTransport(extra),
|
|
1203
|
+
session_id_origin: origin,
|
|
1179
1204
|
client_observed: observeClient(extra, { server, scrubber: options.scrubber }),
|
|
1180
1205
|
runtime_meta: scrubbedMeta,
|
|
1181
1206
|
payload: {
|
|
@@ -1185,15 +1210,10 @@ function registerAnnotationTool(server, options) {
|
|
|
1185
1210
|
// eslint-disable-next-line no-restricted-syntax -- inside the emit() build thunk: a throw is already contained, and null here would fabricate a shape
|
|
1186
1211
|
intent: options.scrubber(args.user_goal),
|
|
1187
1212
|
expected_outcome: args.expected_result ? options.scrubber(args.expected_result) : null,
|
|
1188
|
-
//
|
|
1189
|
-
|
|
1190
|
-
//
|
|
1191
|
-
|
|
1192
|
-
// gap found 2026-08-11, fixed here and flagged for the sibling
|
|
1193
|
-
// rather than mirrored. Not a wire divergence: scrubbing changes
|
|
1194
|
-
// content, not shape, and it's deterministic, so the
|
|
1195
|
-
// exact-string continuity rung 3b groups on survives.
|
|
1196
|
-
signal_type: args.signal_type ?? null,
|
|
1213
|
+
// eslint-disable-next-line no-restricted-syntax -- inside the emit() build thunk: a throw is already contained, and null here would fabricate a shape
|
|
1214
|
+
what_happened: options.scrubber(whatHappened),
|
|
1215
|
+
// eslint-disable-next-line no-restricted-syntax -- inside the emit() build thunk: a throw is already contained, and null here would fabricate a shape
|
|
1216
|
+
tool_name: reportedTool ? options.scrubber(reportedTool) : reportedTool,
|
|
1197
1217
|
// Agent-facing param `overall_task` -> wire key `workflow`, the same
|
|
1198
1218
|
// split the injected params use (`overall_task` -> `call_workflow`):
|
|
1199
1219
|
// renaming the param must not move the key the console groups on.
|
|
@@ -1663,11 +1683,6 @@ var ProactiveTracker = class {
|
|
|
1663
1683
|
this.emitted.add(sessionId);
|
|
1664
1684
|
return true;
|
|
1665
1685
|
}
|
|
1666
|
-
/** Mark the slot claimed without emitting here (the annotation tool's own
|
|
1667
|
-
* handler already emitted the annotation event itself). */
|
|
1668
|
-
mark(sessionId) {
|
|
1669
|
-
this.emitted.add(sessionId);
|
|
1670
|
-
}
|
|
1671
1686
|
};
|
|
1672
1687
|
|
|
1673
1688
|
// src/integrations/mcp/sessionCounter.ts
|
|
@@ -1945,12 +1960,12 @@ function messageOf(err) {
|
|
|
1945
1960
|
async function resolveEnvelopeParts(ctx, extra) {
|
|
1946
1961
|
const meta = extraMeta(extra);
|
|
1947
1962
|
const scrubbedMeta = scrubOrNull(ctx.scrubber, meta ? roundMetaCoordinates(meta) : null, "_meta");
|
|
1948
|
-
const
|
|
1949
|
-
return {
|
|
1963
|
+
const session = await resolveSessionId(ctx.fallbackSessionId, extra);
|
|
1964
|
+
return { ...session, scrubbedMeta };
|
|
1950
1965
|
}
|
|
1951
1966
|
async function openCall(ctx, toolName, extra, params, registered = true) {
|
|
1952
1967
|
await maybeEmitSurfaceSnapshot(ctx);
|
|
1953
|
-
const { sessionId, scrubbedMeta } = await resolveEnvelopeParts(ctx, extra);
|
|
1968
|
+
const { sessionId, origin, scrubbedMeta } = await resolveEnvelopeParts(ctx, extra);
|
|
1954
1969
|
const dispositions = ctx.paramRegistry.get(toolName);
|
|
1955
1970
|
const rawIntent = extractGoalParam(params, USER_GOAL_PARAM_NAME, toolName, dispositions, registered);
|
|
1956
1971
|
const rawExpected = extractGoalParam(
|
|
@@ -1979,6 +1994,7 @@ async function openCall(ctx, toolName, extra, params, registered = true) {
|
|
|
1979
1994
|
// outside any call, so it has no caller, transport or client to name.
|
|
1980
1995
|
principal,
|
|
1981
1996
|
transport_observed: observeTransport(extra),
|
|
1997
|
+
session_id_origin: origin,
|
|
1982
1998
|
client_observed: observeClient(extra, ctx),
|
|
1983
1999
|
runtime_meta: scrubbedMeta
|
|
1984
2000
|
};
|
|
@@ -2279,8 +2295,8 @@ function installRequestSeam(lowLevel, method, seamTag, wrap) {
|
|
|
2279
2295
|
};
|
|
2280
2296
|
}
|
|
2281
2297
|
function installToolsListSeam(lowLevel, ctx) {
|
|
2282
|
-
const names = requiredParamNames(ctx.intentParamMode);
|
|
2283
|
-
const isInjected = (toolName, paramName) => ctx.paramRegistry.get(toolName)?.[paramName] === "injected";
|
|
2298
|
+
const names = [...requiredParamNames(ctx.intentParamMode), TOOL_NAME_PARAM_NAME];
|
|
2299
|
+
const isInjected = (toolName, paramName) => toolName === ctx.annotationToolName ? paramName === TOOL_NAME_PARAM_NAME : ctx.paramRegistry.get(toolName)?.[paramName] === "injected";
|
|
2284
2300
|
const advertise = (result) => {
|
|
2285
2301
|
try {
|
|
2286
2302
|
return advertiseIntentParamsRequired(result, names, isInjected);
|
|
@@ -2349,7 +2365,11 @@ function installLifecycleSeam(lowLevel, ctx, spec) {
|
|
|
2349
2365
|
async function openLifecycleCall(ctx, spec, requestParams, extra) {
|
|
2350
2366
|
try {
|
|
2351
2367
|
const parts = await resolveEnvelopeParts(ctx, extra);
|
|
2352
|
-
const principal =
|
|
2368
|
+
const principal = await resolveCallPrincipal(ctx.resolvePrincipal, {
|
|
2369
|
+
extra,
|
|
2370
|
+
toolName: null,
|
|
2371
|
+
arguments: {}
|
|
2372
|
+
});
|
|
2353
2373
|
return {
|
|
2354
2374
|
sessionId: parts.sessionId,
|
|
2355
2375
|
subject: spec.subjectKey === void 0 ? {} : { [spec.subjectKey]: stringSubject(requestParams[spec.subjectKey]) },
|
|
@@ -2360,6 +2380,7 @@ async function openLifecycleCall(ctx, spec, requestParams, extra) {
|
|
|
2360
2380
|
consent_token: ctx.consentToken,
|
|
2361
2381
|
principal,
|
|
2362
2382
|
transport_observed: observeTransport(extra),
|
|
2383
|
+
session_id_origin: parts.origin,
|
|
2363
2384
|
client_observed: observeClient(extra, ctx),
|
|
2364
2385
|
runtime_meta: parts.scrubbedMeta
|
|
2365
2386
|
}
|
|
@@ -2443,8 +2464,7 @@ var LIFECYCLE_SPECS = [
|
|
|
2443
2464
|
error: ToolListErrorEventSchema
|
|
2444
2465
|
},
|
|
2445
2466
|
countKey: "tools",
|
|
2446
|
-
startParams: NO_PARAMS
|
|
2447
|
-
resolvesPrincipal: true
|
|
2467
|
+
startParams: NO_PARAMS
|
|
2448
2468
|
}
|
|
2449
2469
|
];
|
|
2450
2470
|
function installLifecycleSeams(lowLevel, ctx) {
|
|
@@ -2698,6 +2718,7 @@ function install(server, supplied, resolved, emittedSurfaceHashes) {
|
|
|
2698
2718
|
tenant_id: tenantId,
|
|
2699
2719
|
vendor_id: config.vendorId,
|
|
2700
2720
|
session_id: sessionId,
|
|
2721
|
+
session_id_origin: "minted",
|
|
2701
2722
|
consent_token: config.consentToken,
|
|
2702
2723
|
sequence_number: counter2.next(sessionId),
|
|
2703
2724
|
captured_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -2774,7 +2795,7 @@ function install(server, supplied, resolved, emittedSurfaceHashes) {
|
|
|
2774
2795
|
intentParamMode
|
|
2775
2796
|
});
|
|
2776
2797
|
internals.server._instructions = instructions;
|
|
2777
|
-
|
|
2798
|
+
installToolsListSeam(internals.server, ctx);
|
|
2778
2799
|
installToolsCallSeam(
|
|
2779
2800
|
internals.server,
|
|
2780
2801
|
// ⚠ `Object.hasOwn`, never a bare index. `_registeredTools` is a plain
|
|
@@ -2804,8 +2825,7 @@ function install(server, supplied, resolved, emittedSurfaceHashes) {
|
|
|
2804
2825
|
// The RESOLVED name, never `config.annotationToolName`: handing over the
|
|
2805
2826
|
// raw override and letting the registration re-derive would register
|
|
2806
2827
|
// `srv-..._annotate` while the instructions name the server-derived one.
|
|
2807
|
-
annotationToolName
|
|
2808
|
-
tracker
|
|
2828
|
+
annotationToolName
|
|
2809
2829
|
});
|
|
2810
2830
|
const existing = internals._registeredTools;
|
|
2811
2831
|
if (existing) {
|