@codeworksh/plugin 0.3.0 → 0.4.0
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/{event-6sTQ_4bq.d.mts → event-CmzS4aGe.d.mts} +328 -23
- package/event.d.mts +2 -2
- package/event.mjs +15 -3
- package/event.mjs.map +1 -1
- package/{ids-CHjmAdTc.d.mts → ids-CpPeP5Ks.d.mts} +11 -3
- package/ids.d.mts +2 -2
- package/ids.mjs +7 -2
- package/ids.mjs.map +1 -1
- package/index.d.mts +2 -2
- package/index.mjs +1 -1
- package/mcp-DEWhnBQw.d.mts +122 -0
- package/package.json +7 -2
- package/plugin/mcp.d.mts +2 -0
- package/plugin/mcp.mjs +7 -0
- package/plugin/mcp.mjs.map +1 -0
- package/plugin/section.mjs +1 -0
- package/plugin/section.mjs.map +1 -1
- package/plugin/tool.d.mts +1 -1
- package/plugin/tool.mjs +2 -1
- package/plugin/tool.mjs.map +1 -1
- package/{plugin-XaYYRsX-.mjs → plugin-C3Qy4-Yx.mjs} +9 -3
- package/plugin-C3Qy4-Yx.mjs.map +1 -0
- package/{plugin-Dcv5TWNr.d.mts → plugin-aMOw2zJZ.d.mts} +23 -14
- package/plugin.d.mts +4 -3
- package/plugin.mjs +3 -2
- package/schema.d.mts +2 -0
- package/schema.mjs +3 -1
- package/schema.mjs.map +1 -1
- package/{settings-DGYWREuu.d.mts → settings-CxiAtEXT.d.mts} +22 -2
- package/settings.d.mts +2 -2
- package/settings.mjs +4 -0
- package/settings.mjs.map +1 -1
- package/tool/progress.d.mts +1 -1
- package/{tool-_ajVYIY5.d.mts → tool-C7gcMoga.d.mts} +33 -3
- package/{tool-D4_I_rzy.d.mts → tool-C9TzQ9nG.d.mts} +10 -10
- package/tool.d.mts +2 -2
- package/tool.mjs +49 -3
- package/tool.mjs.map +1 -1
- package/plugin-XaYYRsX-.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
declare namespace event_d_exports {
|
|
3
|
-
export { AikitAssistantMessage, AikitToolCallTerminalPart, Data, Definition, event_d_exports as EventSchema, ID, Payload, PublishOptions, define, durable, inventory, latest, versionedType };
|
|
3
|
+
export { AikitAssistantMessage, AikitAssistantPart, AikitToolCallTerminalPart, Data, Definition, event_d_exports as EventSchema, ID, Payload, PublishOptions, define, durable, inventory, latest, versionedType };
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
6
|
* Effect Schema adapter for aikit's TypeBox assistant message. Durable LLM
|
|
@@ -144,6 +144,17 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
144
144
|
retryAfterMs?: number;
|
|
145
145
|
_tag: "Unknown";
|
|
146
146
|
};
|
|
147
|
+
diagnostics?: {
|
|
148
|
+
type: string;
|
|
149
|
+
timestamp: number;
|
|
150
|
+
error?: {
|
|
151
|
+
name?: string;
|
|
152
|
+
message: string;
|
|
153
|
+
stack?: string;
|
|
154
|
+
code?: string | number;
|
|
155
|
+
};
|
|
156
|
+
details?: Record<string, unknown>;
|
|
157
|
+
}[];
|
|
147
158
|
time: {
|
|
148
159
|
created: number;
|
|
149
160
|
completed: number;
|
|
@@ -162,7 +173,6 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
162
173
|
thinkingSignature?: string;
|
|
163
174
|
redacted?: boolean;
|
|
164
175
|
} | {
|
|
165
|
-
addedToolNames?: string[];
|
|
166
176
|
arguments: Record<string, any>;
|
|
167
177
|
callID: string;
|
|
168
178
|
name: string;
|
|
@@ -187,7 +197,6 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
187
197
|
};
|
|
188
198
|
type: "toolCall";
|
|
189
199
|
} | {
|
|
190
|
-
addedToolNames?: string[];
|
|
191
200
|
arguments: Record<string, any>;
|
|
192
201
|
callID: string;
|
|
193
202
|
name: string;
|
|
@@ -213,7 +222,6 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
213
222
|
};
|
|
214
223
|
type: "toolCall";
|
|
215
224
|
} | {
|
|
216
|
-
addedToolNames?: string[];
|
|
217
225
|
arguments: Record<string, any>;
|
|
218
226
|
callID: string;
|
|
219
227
|
name: string;
|
|
@@ -239,7 +247,6 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
239
247
|
};
|
|
240
248
|
type: "toolCall";
|
|
241
249
|
} | {
|
|
242
|
-
addedToolNames?: string[];
|
|
243
250
|
arguments: Record<string, any>;
|
|
244
251
|
callID: string;
|
|
245
252
|
name: string;
|
|
@@ -265,7 +272,6 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
265
272
|
};
|
|
266
273
|
type: "toolCall";
|
|
267
274
|
} | {
|
|
268
|
-
addedToolNames?: string[];
|
|
269
275
|
arguments: Record<string, any>;
|
|
270
276
|
callID: string;
|
|
271
277
|
name: string;
|
|
@@ -297,7 +303,6 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
297
303
|
arguments: Record<string, any>;
|
|
298
304
|
thoughtSignature?: string;
|
|
299
305
|
namespace?: string;
|
|
300
|
-
addedToolNames?: string[];
|
|
301
306
|
time: {
|
|
302
307
|
start: number;
|
|
303
308
|
end: number;
|
|
@@ -446,6 +451,17 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
446
451
|
retryAfterMs?: number;
|
|
447
452
|
_tag: "Unknown";
|
|
448
453
|
};
|
|
454
|
+
diagnostics?: {
|
|
455
|
+
type: string;
|
|
456
|
+
timestamp: number;
|
|
457
|
+
error?: {
|
|
458
|
+
name?: string;
|
|
459
|
+
message: string;
|
|
460
|
+
stack?: string;
|
|
461
|
+
code?: string | number;
|
|
462
|
+
};
|
|
463
|
+
details?: Record<string, unknown>;
|
|
464
|
+
}[];
|
|
449
465
|
time: {
|
|
450
466
|
created: number;
|
|
451
467
|
completed: number;
|
|
@@ -464,7 +480,6 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
464
480
|
thinkingSignature?: string;
|
|
465
481
|
redacted?: boolean;
|
|
466
482
|
} | {
|
|
467
|
-
addedToolNames?: string[];
|
|
468
483
|
arguments: Record<string, any>;
|
|
469
484
|
callID: string;
|
|
470
485
|
name: string;
|
|
@@ -489,7 +504,6 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
489
504
|
};
|
|
490
505
|
type: "toolCall";
|
|
491
506
|
} | {
|
|
492
|
-
addedToolNames?: string[];
|
|
493
507
|
arguments: Record<string, any>;
|
|
494
508
|
callID: string;
|
|
495
509
|
name: string;
|
|
@@ -515,7 +529,6 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
515
529
|
};
|
|
516
530
|
type: "toolCall";
|
|
517
531
|
} | {
|
|
518
|
-
addedToolNames?: string[];
|
|
519
532
|
arguments: Record<string, any>;
|
|
520
533
|
callID: string;
|
|
521
534
|
name: string;
|
|
@@ -541,7 +554,6 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
541
554
|
};
|
|
542
555
|
type: "toolCall";
|
|
543
556
|
} | {
|
|
544
|
-
addedToolNames?: string[];
|
|
545
557
|
arguments: Record<string, any>;
|
|
546
558
|
callID: string;
|
|
547
559
|
name: string;
|
|
@@ -567,7 +579,6 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
567
579
|
};
|
|
568
580
|
type: "toolCall";
|
|
569
581
|
} | {
|
|
570
|
-
addedToolNames?: string[];
|
|
571
582
|
arguments: Record<string, any>;
|
|
572
583
|
callID: string;
|
|
573
584
|
name: string;
|
|
@@ -599,7 +610,6 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
599
610
|
arguments: Record<string, any>;
|
|
600
611
|
thoughtSignature?: string;
|
|
601
612
|
namespace?: string;
|
|
602
|
-
addedToolNames?: string[];
|
|
603
613
|
time: {
|
|
604
614
|
start: number;
|
|
605
615
|
end: number;
|
|
@@ -612,8 +622,310 @@ declare const AikitAssistantMessage: Schema.decodeTo<Schema.declare<{
|
|
|
612
622
|
messageId: string;
|
|
613
623
|
}>, Schema.Unknown, never, never>;
|
|
614
624
|
type AikitAssistantMessage = typeof AikitAssistantMessage.Type;
|
|
625
|
+
/** One part of an aikit assistant message, streaming-only fields stripped like {@link AikitAssistantMessage}. */
|
|
626
|
+
declare const AikitAssistantPart: Schema.decodeTo<Schema.declare<{
|
|
627
|
+
type: "text";
|
|
628
|
+
text: string;
|
|
629
|
+
textSignature?: string;
|
|
630
|
+
} | {
|
|
631
|
+
type: "image";
|
|
632
|
+
data: string;
|
|
633
|
+
mimeType: string;
|
|
634
|
+
} | {
|
|
635
|
+
type: "thinking";
|
|
636
|
+
thinking: string;
|
|
637
|
+
thinkingSignature?: string;
|
|
638
|
+
redacted?: boolean;
|
|
639
|
+
} | {
|
|
640
|
+
arguments: Record<string, any>;
|
|
641
|
+
callID: string;
|
|
642
|
+
name: string;
|
|
643
|
+
namespace?: string;
|
|
644
|
+
partial?: {
|
|
645
|
+
content?: ({
|
|
646
|
+
type: "text";
|
|
647
|
+
text: string;
|
|
648
|
+
textSignature?: string;
|
|
649
|
+
} | {
|
|
650
|
+
type: "image";
|
|
651
|
+
data: string;
|
|
652
|
+
mimeType: string;
|
|
653
|
+
})[];
|
|
654
|
+
details?: any;
|
|
655
|
+
};
|
|
656
|
+
status: "running";
|
|
657
|
+
thoughtSignature?: string;
|
|
658
|
+
time: {
|
|
659
|
+
start: number;
|
|
660
|
+
end: number;
|
|
661
|
+
};
|
|
662
|
+
type: "toolCall";
|
|
663
|
+
} | {
|
|
664
|
+
arguments: Record<string, any>;
|
|
665
|
+
callID: string;
|
|
666
|
+
name: string;
|
|
667
|
+
namespace?: string;
|
|
668
|
+
result: {
|
|
669
|
+
content: ({
|
|
670
|
+
type: "text";
|
|
671
|
+
text: string;
|
|
672
|
+
textSignature?: string;
|
|
673
|
+
} | {
|
|
674
|
+
type: "image";
|
|
675
|
+
data: string;
|
|
676
|
+
mimeType: string;
|
|
677
|
+
})[];
|
|
678
|
+
details?: any;
|
|
679
|
+
isError: false;
|
|
680
|
+
};
|
|
681
|
+
status: "completed";
|
|
682
|
+
thoughtSignature?: string;
|
|
683
|
+
time: {
|
|
684
|
+
start: number;
|
|
685
|
+
end: number;
|
|
686
|
+
};
|
|
687
|
+
type: "toolCall";
|
|
688
|
+
} | {
|
|
689
|
+
arguments: Record<string, any>;
|
|
690
|
+
callID: string;
|
|
691
|
+
name: string;
|
|
692
|
+
namespace?: string;
|
|
693
|
+
result: {
|
|
694
|
+
content: ({
|
|
695
|
+
type: "text";
|
|
696
|
+
text: string;
|
|
697
|
+
textSignature?: string;
|
|
698
|
+
} | {
|
|
699
|
+
type: "image";
|
|
700
|
+
data: string;
|
|
701
|
+
mimeType: string;
|
|
702
|
+
})[];
|
|
703
|
+
details?: any;
|
|
704
|
+
isError: true;
|
|
705
|
+
};
|
|
706
|
+
status: "error";
|
|
707
|
+
thoughtSignature?: string;
|
|
708
|
+
time: {
|
|
709
|
+
start: number;
|
|
710
|
+
end: number;
|
|
711
|
+
};
|
|
712
|
+
type: "toolCall";
|
|
713
|
+
} | {
|
|
714
|
+
arguments: Record<string, any>;
|
|
715
|
+
callID: string;
|
|
716
|
+
name: string;
|
|
717
|
+
namespace?: string;
|
|
718
|
+
result: {
|
|
719
|
+
content: ({
|
|
720
|
+
type: "text";
|
|
721
|
+
text: string;
|
|
722
|
+
textSignature?: string;
|
|
723
|
+
} | {
|
|
724
|
+
type: "image";
|
|
725
|
+
data: string;
|
|
726
|
+
mimeType: string;
|
|
727
|
+
})[];
|
|
728
|
+
details?: any;
|
|
729
|
+
isError: true;
|
|
730
|
+
};
|
|
731
|
+
status: "skipped";
|
|
732
|
+
thoughtSignature?: string;
|
|
733
|
+
time: {
|
|
734
|
+
start: number;
|
|
735
|
+
end: number;
|
|
736
|
+
};
|
|
737
|
+
type: "toolCall";
|
|
738
|
+
} | {
|
|
739
|
+
arguments: Record<string, any>;
|
|
740
|
+
callID: string;
|
|
741
|
+
name: string;
|
|
742
|
+
namespace?: string;
|
|
743
|
+
result: {
|
|
744
|
+
content: ({
|
|
745
|
+
type: "text";
|
|
746
|
+
text: string;
|
|
747
|
+
textSignature?: string;
|
|
748
|
+
} | {
|
|
749
|
+
type: "image";
|
|
750
|
+
data: string;
|
|
751
|
+
mimeType: string;
|
|
752
|
+
})[];
|
|
753
|
+
details?: any;
|
|
754
|
+
isError: true;
|
|
755
|
+
};
|
|
756
|
+
status: "aborted";
|
|
757
|
+
thoughtSignature?: string;
|
|
758
|
+
time: {
|
|
759
|
+
start: number;
|
|
760
|
+
end: number;
|
|
761
|
+
};
|
|
762
|
+
type: "toolCall";
|
|
763
|
+
} | ({
|
|
764
|
+
type: "toolCall";
|
|
765
|
+
callID: string;
|
|
766
|
+
name: string;
|
|
767
|
+
arguments: Record<string, any>;
|
|
768
|
+
thoughtSignature?: string;
|
|
769
|
+
namespace?: string;
|
|
770
|
+
time: {
|
|
771
|
+
start: number;
|
|
772
|
+
end: number;
|
|
773
|
+
};
|
|
774
|
+
} & {
|
|
775
|
+
status: "pending";
|
|
776
|
+
}), {
|
|
777
|
+
type: "text";
|
|
778
|
+
text: string;
|
|
779
|
+
textSignature?: string;
|
|
780
|
+
} | {
|
|
781
|
+
type: "image";
|
|
782
|
+
data: string;
|
|
783
|
+
mimeType: string;
|
|
784
|
+
} | {
|
|
785
|
+
type: "thinking";
|
|
786
|
+
thinking: string;
|
|
787
|
+
thinkingSignature?: string;
|
|
788
|
+
redacted?: boolean;
|
|
789
|
+
} | {
|
|
790
|
+
arguments: Record<string, any>;
|
|
791
|
+
callID: string;
|
|
792
|
+
name: string;
|
|
793
|
+
namespace?: string;
|
|
794
|
+
partial?: {
|
|
795
|
+
content?: ({
|
|
796
|
+
type: "text";
|
|
797
|
+
text: string;
|
|
798
|
+
textSignature?: string;
|
|
799
|
+
} | {
|
|
800
|
+
type: "image";
|
|
801
|
+
data: string;
|
|
802
|
+
mimeType: string;
|
|
803
|
+
})[];
|
|
804
|
+
details?: any;
|
|
805
|
+
};
|
|
806
|
+
status: "running";
|
|
807
|
+
thoughtSignature?: string;
|
|
808
|
+
time: {
|
|
809
|
+
start: number;
|
|
810
|
+
end: number;
|
|
811
|
+
};
|
|
812
|
+
type: "toolCall";
|
|
813
|
+
} | {
|
|
814
|
+
arguments: Record<string, any>;
|
|
815
|
+
callID: string;
|
|
816
|
+
name: string;
|
|
817
|
+
namespace?: string;
|
|
818
|
+
result: {
|
|
819
|
+
content: ({
|
|
820
|
+
type: "text";
|
|
821
|
+
text: string;
|
|
822
|
+
textSignature?: string;
|
|
823
|
+
} | {
|
|
824
|
+
type: "image";
|
|
825
|
+
data: string;
|
|
826
|
+
mimeType: string;
|
|
827
|
+
})[];
|
|
828
|
+
details?: any;
|
|
829
|
+
isError: false;
|
|
830
|
+
};
|
|
831
|
+
status: "completed";
|
|
832
|
+
thoughtSignature?: string;
|
|
833
|
+
time: {
|
|
834
|
+
start: number;
|
|
835
|
+
end: number;
|
|
836
|
+
};
|
|
837
|
+
type: "toolCall";
|
|
838
|
+
} | {
|
|
839
|
+
arguments: Record<string, any>;
|
|
840
|
+
callID: string;
|
|
841
|
+
name: string;
|
|
842
|
+
namespace?: string;
|
|
843
|
+
result: {
|
|
844
|
+
content: ({
|
|
845
|
+
type: "text";
|
|
846
|
+
text: string;
|
|
847
|
+
textSignature?: string;
|
|
848
|
+
} | {
|
|
849
|
+
type: "image";
|
|
850
|
+
data: string;
|
|
851
|
+
mimeType: string;
|
|
852
|
+
})[];
|
|
853
|
+
details?: any;
|
|
854
|
+
isError: true;
|
|
855
|
+
};
|
|
856
|
+
status: "error";
|
|
857
|
+
thoughtSignature?: string;
|
|
858
|
+
time: {
|
|
859
|
+
start: number;
|
|
860
|
+
end: number;
|
|
861
|
+
};
|
|
862
|
+
type: "toolCall";
|
|
863
|
+
} | {
|
|
864
|
+
arguments: Record<string, any>;
|
|
865
|
+
callID: string;
|
|
866
|
+
name: string;
|
|
867
|
+
namespace?: string;
|
|
868
|
+
result: {
|
|
869
|
+
content: ({
|
|
870
|
+
type: "text";
|
|
871
|
+
text: string;
|
|
872
|
+
textSignature?: string;
|
|
873
|
+
} | {
|
|
874
|
+
type: "image";
|
|
875
|
+
data: string;
|
|
876
|
+
mimeType: string;
|
|
877
|
+
})[];
|
|
878
|
+
details?: any;
|
|
879
|
+
isError: true;
|
|
880
|
+
};
|
|
881
|
+
status: "skipped";
|
|
882
|
+
thoughtSignature?: string;
|
|
883
|
+
time: {
|
|
884
|
+
start: number;
|
|
885
|
+
end: number;
|
|
886
|
+
};
|
|
887
|
+
type: "toolCall";
|
|
888
|
+
} | {
|
|
889
|
+
arguments: Record<string, any>;
|
|
890
|
+
callID: string;
|
|
891
|
+
name: string;
|
|
892
|
+
namespace?: string;
|
|
893
|
+
result: {
|
|
894
|
+
content: ({
|
|
895
|
+
type: "text";
|
|
896
|
+
text: string;
|
|
897
|
+
textSignature?: string;
|
|
898
|
+
} | {
|
|
899
|
+
type: "image";
|
|
900
|
+
data: string;
|
|
901
|
+
mimeType: string;
|
|
902
|
+
})[];
|
|
903
|
+
details?: any;
|
|
904
|
+
isError: true;
|
|
905
|
+
};
|
|
906
|
+
status: "aborted";
|
|
907
|
+
thoughtSignature?: string;
|
|
908
|
+
time: {
|
|
909
|
+
start: number;
|
|
910
|
+
end: number;
|
|
911
|
+
};
|
|
912
|
+
type: "toolCall";
|
|
913
|
+
} | ({
|
|
914
|
+
type: "toolCall";
|
|
915
|
+
callID: string;
|
|
916
|
+
name: string;
|
|
917
|
+
arguments: Record<string, any>;
|
|
918
|
+
thoughtSignature?: string;
|
|
919
|
+
namespace?: string;
|
|
920
|
+
time: {
|
|
921
|
+
start: number;
|
|
922
|
+
end: number;
|
|
923
|
+
};
|
|
924
|
+
} & {
|
|
925
|
+
status: "pending";
|
|
926
|
+
})>, Schema.Unknown, never, never>;
|
|
927
|
+
type AikitAssistantPart = typeof AikitAssistantPart.Type;
|
|
615
928
|
declare const AikitToolCallTerminalPart: Schema.decodeTo<Schema.declare<{
|
|
616
|
-
addedToolNames?: string[];
|
|
617
929
|
arguments: Record<string, any>;
|
|
618
930
|
callID: string;
|
|
619
931
|
name: string;
|
|
@@ -639,7 +951,6 @@ declare const AikitToolCallTerminalPart: Schema.decodeTo<Schema.declare<{
|
|
|
639
951
|
};
|
|
640
952
|
type: "toolCall";
|
|
641
953
|
} | {
|
|
642
|
-
addedToolNames?: string[];
|
|
643
954
|
arguments: Record<string, any>;
|
|
644
955
|
callID: string;
|
|
645
956
|
name: string;
|
|
@@ -665,7 +976,6 @@ declare const AikitToolCallTerminalPart: Schema.decodeTo<Schema.declare<{
|
|
|
665
976
|
};
|
|
666
977
|
type: "toolCall";
|
|
667
978
|
} | {
|
|
668
|
-
addedToolNames?: string[];
|
|
669
979
|
arguments: Record<string, any>;
|
|
670
980
|
callID: string;
|
|
671
981
|
name: string;
|
|
@@ -691,7 +1001,6 @@ declare const AikitToolCallTerminalPart: Schema.decodeTo<Schema.declare<{
|
|
|
691
1001
|
};
|
|
692
1002
|
type: "toolCall";
|
|
693
1003
|
} | {
|
|
694
|
-
addedToolNames?: string[];
|
|
695
1004
|
arguments: Record<string, any>;
|
|
696
1005
|
callID: string;
|
|
697
1006
|
name: string;
|
|
@@ -717,7 +1026,6 @@ declare const AikitToolCallTerminalPart: Schema.decodeTo<Schema.declare<{
|
|
|
717
1026
|
};
|
|
718
1027
|
type: "toolCall";
|
|
719
1028
|
}, {
|
|
720
|
-
addedToolNames?: string[];
|
|
721
1029
|
arguments: Record<string, any>;
|
|
722
1030
|
callID: string;
|
|
723
1031
|
name: string;
|
|
@@ -743,7 +1051,6 @@ declare const AikitToolCallTerminalPart: Schema.decodeTo<Schema.declare<{
|
|
|
743
1051
|
};
|
|
744
1052
|
type: "toolCall";
|
|
745
1053
|
} | {
|
|
746
|
-
addedToolNames?: string[];
|
|
747
1054
|
arguments: Record<string, any>;
|
|
748
1055
|
callID: string;
|
|
749
1056
|
name: string;
|
|
@@ -769,7 +1076,6 @@ declare const AikitToolCallTerminalPart: Schema.decodeTo<Schema.declare<{
|
|
|
769
1076
|
};
|
|
770
1077
|
type: "toolCall";
|
|
771
1078
|
} | {
|
|
772
|
-
addedToolNames?: string[];
|
|
773
1079
|
arguments: Record<string, any>;
|
|
774
1080
|
callID: string;
|
|
775
1081
|
name: string;
|
|
@@ -795,7 +1101,6 @@ declare const AikitToolCallTerminalPart: Schema.decodeTo<Schema.declare<{
|
|
|
795
1101
|
};
|
|
796
1102
|
type: "toolCall";
|
|
797
1103
|
} | {
|
|
798
|
-
addedToolNames?: string[];
|
|
799
1104
|
arguments: Record<string, any>;
|
|
800
1105
|
callID: string;
|
|
801
1106
|
name: string;
|
|
@@ -895,5 +1200,5 @@ declare function versionedType(type: string, version: number): string;
|
|
|
895
1200
|
declare function durable<const Definitions extends ReadonlyArray<Definition>>(definitions: Definitions): ReadonlyMap<string, Definitions[number]>;
|
|
896
1201
|
declare function latest(definitions: ReadonlyArray<Definition>): ReadonlyMap<string, Definition<string, Schema.Codec<unknown, unknown, never, never>>>;
|
|
897
1202
|
//#endregion
|
|
898
|
-
export {
|
|
899
|
-
//# sourceMappingURL=event-
|
|
1203
|
+
export { Definition as a, PublishOptions as c, event_d_exports as d, inventory as f, Data as i, define as l, versionedType as m, AikitAssistantPart as n, ID as o, latest as p, AikitToolCallTerminalPart as r, Payload as s, AikitAssistantMessage as t, durable as u };
|
|
1204
|
+
//# sourceMappingURL=event-CmzS4aGe.d.mts.map
|
package/event.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { AikitAssistantMessage, AikitToolCallTerminalPart, Data, Definition, event_d_exports as EventSchema, ID, Payload, PublishOptions, define, durable, inventory, latest, versionedType };
|
|
1
|
+
import { a as Definition, c as PublishOptions, d as event_d_exports, f as inventory, i as Data, l as define, m as versionedType, n as AikitAssistantPart, o as ID, p as latest, r as AikitToolCallTerminalPart, s as Payload, t as AikitAssistantMessage, u as durable } from "./event-CmzS4aGe.mjs";
|
|
2
|
+
export { AikitAssistantMessage, AikitAssistantPart, AikitToolCallTerminalPart, Data, Definition, event_d_exports as EventSchema, ID, Payload, PublishOptions, define, durable, inventory, latest, versionedType };
|
package/event.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import { isAikitAssistantMessage, isAikitToolCallTerminalPart, optional, validateAikitAssistantMessage, validateAikitToolCallTerminalPart, withStatics } from "./schema.mjs";
|
|
2
|
+
import { isAikitAssistantMessage, isAikitAssistantPart, isAikitToolCallTerminalPart, optional, validateAikitAssistantMessage, validateAikitAssistantPart, validateAikitToolCallTerminalPart, withStatics } from "./schema.mjs";
|
|
3
3
|
import "@codeworksh/aikit";
|
|
4
4
|
import { Effect, Schema, SchemaGetter, SchemaIssue } from "effect";
|
|
5
5
|
import { uuidv7 } from "uuidv7";
|
|
6
6
|
//#region src/event.ts
|
|
7
7
|
var event_exports = /* @__PURE__ */ __exportAll({
|
|
8
8
|
AikitAssistantMessage: () => AikitAssistantMessage,
|
|
9
|
+
AikitAssistantPart: () => AikitAssistantPart,
|
|
9
10
|
AikitToolCallTerminalPart: () => AikitToolCallTerminalPart,
|
|
10
11
|
EventSchema: () => event_exports,
|
|
11
12
|
ID: () => ID,
|
|
@@ -28,9 +29,10 @@ const omit = (value, keys) => {
|
|
|
28
29
|
for (const key of keys) delete copy[key];
|
|
29
30
|
return copy;
|
|
30
31
|
};
|
|
32
|
+
const canonicalizeAikitAssistantPart = (part) => omit(part, aikitTransientFields[part.type]);
|
|
31
33
|
const canonicalizeAikitAssistantMessage = (message) => ({
|
|
32
34
|
...message,
|
|
33
|
-
parts: message.parts.map(
|
|
35
|
+
parts: message.parts.map(canonicalizeAikitAssistantPart)
|
|
34
36
|
});
|
|
35
37
|
const reasonOf = (cause) => cause instanceof Error ? cause.message : String(cause);
|
|
36
38
|
const decodeAikitAssistantMessage = (value, options) => Effect.try({
|
|
@@ -46,6 +48,16 @@ const AikitAssistantMessage = Schema.Unknown.pipe(Schema.decodeTo(aikitAssistant
|
|
|
46
48
|
decode: SchemaGetter.transformEffect(decodeAikitAssistantMessage),
|
|
47
49
|
encode: SchemaGetter.transformEffect(decodeAikitAssistantMessage)
|
|
48
50
|
}));
|
|
51
|
+
const decodeAikitAssistantPart = (value, options) => Effect.try({
|
|
52
|
+
try: () => canonicalizeAikitAssistantPart(validateAikitAssistantPart(value, "aikit assistant part")),
|
|
53
|
+
catch: (cause) => new SchemaIssue.InvalidValue({ message: reasonOf(cause) }, value, options)
|
|
54
|
+
});
|
|
55
|
+
const aikitAssistantPartDeclared = Schema.declare(isAikitAssistantPart, { expected: "aikit assistant part" });
|
|
56
|
+
/** One part of an aikit assistant message, streaming-only fields stripped like {@link AikitAssistantMessage}. */
|
|
57
|
+
const AikitAssistantPart = Schema.Unknown.pipe(Schema.decodeTo(aikitAssistantPartDeclared, {
|
|
58
|
+
decode: SchemaGetter.transformEffect(decodeAikitAssistantPart),
|
|
59
|
+
encode: SchemaGetter.transformEffect(decodeAikitAssistantPart)
|
|
60
|
+
}));
|
|
49
61
|
const decodeAikitToolCallTerminalPart = (value, options) => Effect.try({
|
|
50
62
|
try: () => validateAikitToolCallTerminalPart(value, "aikit terminal toolcall part"),
|
|
51
63
|
catch: (cause) => new SchemaIssue.InvalidValue({ message: reasonOf(cause) }, value, options)
|
|
@@ -120,6 +132,6 @@ function latest(definitions) {
|
|
|
120
132
|
}, /* @__PURE__ */ new Map()));
|
|
121
133
|
}
|
|
122
134
|
//#endregion
|
|
123
|
-
export { AikitAssistantMessage, AikitToolCallTerminalPart, event_exports as EventSchema, ID, define, durable, inventory, latest, versionedType };
|
|
135
|
+
export { AikitAssistantMessage, AikitAssistantPart, AikitToolCallTerminalPart, event_exports as EventSchema, ID, define, durable, inventory, latest, versionedType };
|
|
124
136
|
|
|
125
137
|
//# sourceMappingURL=event.mjs.map
|
package/event.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.mjs","names":[],"sources":["../../src/event.ts"],"sourcesContent":["import { Message } from \"@codeworksh/aikit\";\nimport { Effect, Schema, type SchemaAST, SchemaGetter, SchemaIssue } from \"effect\";\nimport { uuidv7 } from \"uuidv7\";\nimport {\n\tisAikitAssistantMessage,\n\tisAikitToolCallTerminalPart,\n\toptional,\n\tvalidateAikitAssistantMessage,\n\tvalidateAikitToolCallTerminalPart,\n\twithStatics,\n} from \"./schema.ts\";\n\ntype AikitAssistantPart = Message.AssistantMessage[\"parts\"][number];\n\n/** Undeclared fields used only while aikit is assembling a streamed part. */\nconst aikitTransientFields: Readonly<Record<AikitAssistantPart[\"type\"], ReadonlyArray<string>>> = {\n\ttext: [\"streamId\"],\n\timage: [],\n\tthinking: [\"streamId\"],\n\ttoolCall: [\"partialJson\"],\n};\n\nconst omit = <T extends object>(value: T, keys: ReadonlyArray<string>): T => {\n\tif (!keys.some((key) => key in value)) return value;\n\tconst copy = { ...value } as T & Record<string, unknown>;\n\tfor (const key of keys) delete copy[key];\n\treturn copy;\n};\n\nconst canonicalizeAikitAssistantMessage = (message: Message.AssistantMessage): Message.AssistantMessage => ({\n\t...message,\n\tparts: message.parts.map((part) => omit(part, aikitTransientFields[part.type])),\n});\n\nconst reasonOf = (cause: unknown): string => (cause instanceof Error ? cause.message : String(cause));\n\nconst decodeAikitAssistantMessage = (value: unknown, options: SchemaAST.ParseOptions) =>\n\tEffect.try({\n\t\ttry: () => canonicalizeAikitAssistantMessage(validateAikitAssistantMessage(value, \"aikit assistant message\")),\n\t\tcatch: (cause) => new SchemaIssue.InvalidValue({ message: reasonOf(cause) }, value, options),\n\t});\n\nconst aikitAssistantMessageDeclared = Schema.declare<Message.AssistantMessage>(isAikitAssistantMessage, {\n\texpected: \"aikit AssistantMessage\",\n});\n\n/**\n * Effect Schema adapter for aikit's TypeBox assistant message. Durable LLM\n * events use it to validate their payload and strip streaming-only fields.\n */\nexport const AikitAssistantMessage = Schema.Unknown.pipe(\n\tSchema.decodeTo(aikitAssistantMessageDeclared, {\n\t\tdecode: SchemaGetter.transformEffect(decodeAikitAssistantMessage),\n\t\tencode: SchemaGetter.transformEffect(decodeAikitAssistantMessage),\n\t}),\n);\nexport type AikitAssistantMessage = typeof AikitAssistantMessage.Type;\n\nconst decodeAikitToolCallTerminalPart = (value: unknown, options: SchemaAST.ParseOptions) =>\n\tEffect.try({\n\t\ttry: () => validateAikitToolCallTerminalPart(value, \"aikit terminal toolcall part\"),\n\t\tcatch: (cause) => new SchemaIssue.InvalidValue({ message: reasonOf(cause) }, value, options),\n\t});\n\nconst aikitToolCallTerminalPartDeclared = Schema.declare<Message.ToolCallTerminalPart>(isAikitToolCallTerminalPart, {\n\texpected: \"aikit terminal toolcall part\",\n});\n\nexport const AikitToolCallTerminalPart = Schema.Unknown.pipe(\n\tSchema.decodeTo(aikitToolCallTerminalPartDeclared, {\n\t\tdecode: SchemaGetter.transformEffect(decodeAikitToolCallTerminalPart),\n\t\tencode: SchemaGetter.transformEffect(decodeAikitToolCallTerminalPart),\n\t}),\n);\nexport type AikitToolCallTerminalPart = typeof AikitToolCallTerminalPart.Type;\n\nexport const ID = Schema.String.pipe(\n\tSchema.brand(\"Event.ID\"),\n\twithStatics((schema) => ({\n\t\tcreate: () => schema.make(`evt_${uuidv7()}`),\n\t})),\n);\nexport type ID = typeof ID.Type;\n\nexport type Definition<\n\tType extends string = string,\n\tDataSchema extends Schema.Codec<unknown, unknown> = Schema.Codec<unknown, unknown>,\n> = Schema.Top & {\n\treadonly type: Type;\n\treadonly durable?: {\n\t\treadonly version: number; // event versioning for decoding in later time\n\t\treadonly aggregate: string;\n\t};\n\treadonly data: DataSchema;\n};\n\nexport type Data<D extends Definition> = Schema.Schema.Type<D[\"data\"]>;\n\n/** Publish-time options. Lives beside the definition so the plugin-facing publisher can name it. */\nexport interface PublishOptions {\n\t/** Caller-supplied event ID. Publishing the same ID twice is a defect, not an upsert. */\n\treadonly id?: ID;\n\t/**\n\t * Publish-time context — correlation, tracing — carried to projectors on the\n\t * in-memory payload and deliberately not stored in the event row. A projector\n\t * persists it into its own projection if it means something there; the log\n\t * records what happened, not who asked. It therefore does not survive a\n\t * durable reread or a rebuild, which `event.test.ts` pins explicitly.\n\t */\n\treadonly metadata?: Record<string, string>;\n}\n\nexport type Payload<D extends Definition = Definition> = {\n\treadonly id: ID;\n\treadonly type: D[\"type\"];\n\treadonly data: Data<D>;\n\treadonly durable?: {\n\t\treadonly aggregateId: string;\n\t\treadonly seq: number;\n\t\treadonly version: number;\n\t};\n\treadonly metadata?: Record<string, string>;\n};\n\nexport function define<\n\tconst Type extends string,\n\tconst Fields extends Readonly<Record<PropertyKey, Schema.Codec<unknown, unknown>>>,\n>(input: {\n\treadonly type: Type;\n\treadonly durable?: {\n\t\treadonly version: number;\n\t\treadonly aggregate: string;\n\t};\n\treadonly schema: Fields;\n}) {\n\tconst data = Schema.Struct(input.schema);\n\treturn Schema.Struct({\n\t\tid: ID,\n\t\tmetadata: optional(Schema.Record(Schema.String, Schema.String)),\n\t\ttype: Schema.Literal(input.type),\n\t\tdurable: optional(Schema.Struct({ aggregateId: Schema.String, seq: Schema.Int, version: Schema.Int })),\n\t\tdata,\n\t})\n\t\t.annotate({ identifier: input.type })\n\t\t.pipe(\n\t\t\twithStatics(() => ({\n\t\t\t\ttype: input.type,\n\t\t\t\t...(input.durable === undefined ? {} : { durable: input.durable }),\n\t\t\t\tdata,\n\t\t\t})),\n\t\t) satisfies Definition<Type, typeof data>;\n}\n\n// Register all the event definitions.\nexport function inventory<const Definitions extends ReadonlyArray<Definition>>(...definitions: Definitions) {\n\treturn Object.freeze(definitions);\n}\n\nexport function versionedType(type: string, version: number) {\n\treturn `${type}.${version}`;\n}\n\nexport function durable<const Definitions extends ReadonlyArray<Definition>>(definitions: Definitions) {\n\treturn readonlyMap(\n\t\tdefinitions.reduce((result, definition) => {\n\t\t\tif (!definition.durable) return result;\n\t\t\tconst key = versionedType(definition.type, definition.durable.version);\n\t\t\tif (result.has(key)) throw new Error(`duplicate durable event definition for ${key}`);\n\t\t\tresult.set(key, definition);\n\t\t\treturn result;\n\t\t}, new Map<string, Definitions[number]>()),\n\t);\n}\n\nfunction readonlyMap<Key, Value>(map: Map<Key, Value>): ReadonlyMap<Key, Value> {\n\tconst result: ReadonlyMap<Key, Value> = Object.freeze({\n\t\tget size() {\n\t\t\treturn map.size;\n\t\t},\n\t\tentries: () => map.entries(),\n\t\tforEach: (callback: (value: Value, key: Key, map: ReadonlyMap<Key, Value>) => void, thisArg?: unknown) =>\n\t\t\tmap.forEach((value, key) => callback.call(thisArg, value, key, result)),\n\t\tget: (key: Key) => map.get(key),\n\t\thas: (key: Key) => map.has(key),\n\t\tkeys: () => map.keys(),\n\t\tvalues: () => map.values(),\n\t\t[Symbol.iterator]: () => map[Symbol.iterator](),\n\t});\n\treturn result;\n}\n\nexport function latest(definitions: ReadonlyArray<Definition>) {\n\treturn readonlyMap(\n\t\tdefinitions.reduce((result, definition) => {\n\t\t\tconst existing = result.get(definition.type);\n\t\t\tif (!existing) {\n\t\t\t\tresult.set(definition.type, definition);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tif (definition.durable && existing.durable && definition.durable.version !== existing.durable.version) {\n\t\t\t\tif (definition.durable.version > existing.durable.version) result.set(definition.type, definition);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tif (definition !== existing) throw new Error(`duplicate latest event definition for ${definition.type}`);\n\t\t\treturn result;\n\t\t}, new Map<string, Definition>()),\n\t);\n}\n\nexport * as EventSchema from \"./event.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAeA,MAAM,uBAA4F;CACjG,MAAM,CAAC,UAAU;CACjB,OAAO,CAAC;CACR,UAAU,CAAC,UAAU;CACrB,UAAU,CAAC,aAAa;AACzB;AAEA,MAAM,QAA0B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,SAAS,OAAO,KAAK,MAAM,CAAC;EACvE,MAAM,QAAa,IAAI,IAAI,GAAG;EAC9B,MAAM,QAAa,IAAI,IAAI,GAAG;EAC9B,YAAY,IAAI,KAAK;EACrB,cAAc,IAAI,OAAO;GACxB,OAAO,iBAAiB,IAAI,OAAO,SAAS,CAAC;CAC/C,CAAC;CACD,OAAO;AACR;AAEA,SAAgB,OAAO,aAAwC;CAC9D,OAAO,YACN,YAAY,QAAQ,QAAQ,eAAe;EAC1C,MAAM,WAAW,OAAO,IAAI,WAAW,IAAI;EAC3C,IAAI,CAAC,UAAU;GACd,OAAO,IAAI,WAAW,MAAM,UAAU;GACtC,OAAO;EACR;EACA,IAAI,WAAW,WAAW,SAAS,WAAW,WAAW,QAAQ,YAAY,SAAS,QAAQ,SAAS;GACtG,IAAI,WAAW,QAAQ,UAAU,SAAS,QAAQ,SAAS,OAAO,IAAI,WAAW,MAAM,UAAU;GACjG,OAAO;EACR;EACA,IAAI,eAAe,UAAU,MAAM,IAAI,MAAM,yCAAyC,WAAW,MAAM;EACvG,OAAO;CACR,mBAAG,IAAI,IAAwB,CAAC,CACjC;AACD"}
|
|
1
|
+
{"version":3,"file":"event.mjs","names":[],"sources":["../../src/event.ts"],"sourcesContent":["import { Message } from \"@codeworksh/aikit\";\nimport { Effect, Schema, type SchemaAST, SchemaGetter, SchemaIssue } from \"effect\";\nimport { uuidv7 } from \"uuidv7\";\nimport {\n\tisAikitAssistantMessage,\n\tisAikitAssistantPart,\n\tisAikitToolCallTerminalPart,\n\toptional,\n\tvalidateAikitAssistantMessage,\n\tvalidateAikitAssistantPart,\n\tvalidateAikitToolCallTerminalPart,\n\twithStatics,\n} from \"./schema.ts\";\n\ntype AssistantPart = Message.AssistantMessage[\"parts\"][number];\n\n/** Undeclared fields used only while aikit is assembling a streamed part. */\nconst aikitTransientFields: Readonly<Record<AssistantPart[\"type\"], ReadonlyArray<string>>> = {\n\ttext: [\"streamId\"],\n\timage: [],\n\tthinking: [\"streamId\"],\n\ttoolCall: [\"partialJson\"],\n};\n\nconst omit = <T extends object>(value: T, keys: ReadonlyArray<string>): T => {\n\tif (!keys.some((key) => key in value)) return value;\n\tconst copy = { ...value } as T & Record<string, unknown>;\n\tfor (const key of keys) delete copy[key];\n\treturn copy;\n};\n\nconst canonicalizeAikitAssistantPart = (part: AssistantPart): AssistantPart =>\n\tomit(part, aikitTransientFields[part.type]);\n\nconst canonicalizeAikitAssistantMessage = (message: Message.AssistantMessage): Message.AssistantMessage => ({\n\t...message,\n\tparts: message.parts.map(canonicalizeAikitAssistantPart),\n});\n\nconst reasonOf = (cause: unknown): string => (cause instanceof Error ? cause.message : String(cause));\n\nconst decodeAikitAssistantMessage = (value: unknown, options: SchemaAST.ParseOptions) =>\n\tEffect.try({\n\t\ttry: () => canonicalizeAikitAssistantMessage(validateAikitAssistantMessage(value, \"aikit assistant message\")),\n\t\tcatch: (cause) => new SchemaIssue.InvalidValue({ message: reasonOf(cause) }, value, options),\n\t});\n\nconst aikitAssistantMessageDeclared = Schema.declare<Message.AssistantMessage>(isAikitAssistantMessage, {\n\texpected: \"aikit AssistantMessage\",\n});\n\n/**\n * Effect Schema adapter for aikit's TypeBox assistant message. Durable LLM\n * events use it to validate their payload and strip streaming-only fields.\n */\nexport const AikitAssistantMessage = Schema.Unknown.pipe(\n\tSchema.decodeTo(aikitAssistantMessageDeclared, {\n\t\tdecode: SchemaGetter.transformEffect(decodeAikitAssistantMessage),\n\t\tencode: SchemaGetter.transformEffect(decodeAikitAssistantMessage),\n\t}),\n);\nexport type AikitAssistantMessage = typeof AikitAssistantMessage.Type;\n\nconst decodeAikitAssistantPart = (value: unknown, options: SchemaAST.ParseOptions) =>\n\tEffect.try({\n\t\ttry: () => canonicalizeAikitAssistantPart(validateAikitAssistantPart(value, \"aikit assistant part\")),\n\t\tcatch: (cause) => new SchemaIssue.InvalidValue({ message: reasonOf(cause) }, value, options),\n\t});\n\nconst aikitAssistantPartDeclared = Schema.declare<AssistantPart>(isAikitAssistantPart, {\n\texpected: \"aikit assistant part\",\n});\n\n/** One part of an aikit assistant message, streaming-only fields stripped like {@link AikitAssistantMessage}. */\nexport const AikitAssistantPart = Schema.Unknown.pipe(\n\tSchema.decodeTo(aikitAssistantPartDeclared, {\n\t\tdecode: SchemaGetter.transformEffect(decodeAikitAssistantPart),\n\t\tencode: SchemaGetter.transformEffect(decodeAikitAssistantPart),\n\t}),\n);\nexport type AikitAssistantPart = typeof AikitAssistantPart.Type;\n\nconst decodeAikitToolCallTerminalPart = (value: unknown, options: SchemaAST.ParseOptions) =>\n\tEffect.try({\n\t\ttry: () => validateAikitToolCallTerminalPart(value, \"aikit terminal toolcall part\"),\n\t\tcatch: (cause) => new SchemaIssue.InvalidValue({ message: reasonOf(cause) }, value, options),\n\t});\n\nconst aikitToolCallTerminalPartDeclared = Schema.declare<Message.ToolCallTerminalPart>(isAikitToolCallTerminalPart, {\n\texpected: \"aikit terminal toolcall part\",\n});\n\nexport const AikitToolCallTerminalPart = Schema.Unknown.pipe(\n\tSchema.decodeTo(aikitToolCallTerminalPartDeclared, {\n\t\tdecode: SchemaGetter.transformEffect(decodeAikitToolCallTerminalPart),\n\t\tencode: SchemaGetter.transformEffect(decodeAikitToolCallTerminalPart),\n\t}),\n);\nexport type AikitToolCallTerminalPart = typeof AikitToolCallTerminalPart.Type;\n\nexport const ID = Schema.String.pipe(\n\tSchema.brand(\"Event.ID\"),\n\twithStatics((schema) => ({\n\t\tcreate: () => schema.make(`evt_${uuidv7()}`),\n\t})),\n);\nexport type ID = typeof ID.Type;\n\nexport type Definition<\n\tType extends string = string,\n\tDataSchema extends Schema.Codec<unknown, unknown> = Schema.Codec<unknown, unknown>,\n> = Schema.Top & {\n\treadonly type: Type;\n\treadonly durable?: {\n\t\treadonly version: number; // event versioning for decoding in later time\n\t\treadonly aggregate: string;\n\t};\n\treadonly data: DataSchema;\n};\n\nexport type Data<D extends Definition> = Schema.Schema.Type<D[\"data\"]>;\n\n/** Publish-time options. Lives beside the definition so the plugin-facing publisher can name it. */\nexport interface PublishOptions {\n\t/** Caller-supplied event ID. Publishing the same ID twice is a defect, not an upsert. */\n\treadonly id?: ID;\n\t/**\n\t * Publish-time context — correlation, tracing — carried to projectors on the\n\t * in-memory payload and deliberately not stored in the event row. A projector\n\t * persists it into its own projection if it means something there; the log\n\t * records what happened, not who asked. It therefore does not survive a\n\t * durable reread or a rebuild, which `event.test.ts` pins explicitly.\n\t */\n\treadonly metadata?: Record<string, string>;\n}\n\nexport type Payload<D extends Definition = Definition> = {\n\treadonly id: ID;\n\treadonly type: D[\"type\"];\n\treadonly data: Data<D>;\n\treadonly durable?: {\n\t\treadonly aggregateId: string;\n\t\treadonly seq: number;\n\t\treadonly version: number;\n\t};\n\treadonly metadata?: Record<string, string>;\n};\n\nexport function define<\n\tconst Type extends string,\n\tconst Fields extends Readonly<Record<PropertyKey, Schema.Codec<unknown, unknown>>>,\n>(input: {\n\treadonly type: Type;\n\treadonly durable?: {\n\t\treadonly version: number;\n\t\treadonly aggregate: string;\n\t};\n\treadonly schema: Fields;\n}) {\n\tconst data = Schema.Struct(input.schema);\n\treturn Schema.Struct({\n\t\tid: ID,\n\t\tmetadata: optional(Schema.Record(Schema.String, Schema.String)),\n\t\ttype: Schema.Literal(input.type),\n\t\tdurable: optional(Schema.Struct({ aggregateId: Schema.String, seq: Schema.Int, version: Schema.Int })),\n\t\tdata,\n\t})\n\t\t.annotate({ identifier: input.type })\n\t\t.pipe(\n\t\t\twithStatics(() => ({\n\t\t\t\ttype: input.type,\n\t\t\t\t...(input.durable === undefined ? {} : { durable: input.durable }),\n\t\t\t\tdata,\n\t\t\t})),\n\t\t) satisfies Definition<Type, typeof data>;\n}\n\n// Register all the event definitions.\nexport function inventory<const Definitions extends ReadonlyArray<Definition>>(...definitions: Definitions) {\n\treturn Object.freeze(definitions);\n}\n\nexport function versionedType(type: string, version: number) {\n\treturn `${type}.${version}`;\n}\n\nexport function durable<const Definitions extends ReadonlyArray<Definition>>(definitions: Definitions) {\n\treturn readonlyMap(\n\t\tdefinitions.reduce((result, definition) => {\n\t\t\tif (!definition.durable) return result;\n\t\t\tconst key = versionedType(definition.type, definition.durable.version);\n\t\t\tif (result.has(key)) throw new Error(`duplicate durable event definition for ${key}`);\n\t\t\tresult.set(key, definition);\n\t\t\treturn result;\n\t\t}, new Map<string, Definitions[number]>()),\n\t);\n}\n\nfunction readonlyMap<Key, Value>(map: Map<Key, Value>): ReadonlyMap<Key, Value> {\n\tconst result: ReadonlyMap<Key, Value> = Object.freeze({\n\t\tget size() {\n\t\t\treturn map.size;\n\t\t},\n\t\tentries: () => map.entries(),\n\t\tforEach: (callback: (value: Value, key: Key, map: ReadonlyMap<Key, Value>) => void, thisArg?: unknown) =>\n\t\t\tmap.forEach((value, key) => callback.call(thisArg, value, key, result)),\n\t\tget: (key: Key) => map.get(key),\n\t\thas: (key: Key) => map.has(key),\n\t\tkeys: () => map.keys(),\n\t\tvalues: () => map.values(),\n\t\t[Symbol.iterator]: () => map[Symbol.iterator](),\n\t});\n\treturn result;\n}\n\nexport function latest(definitions: ReadonlyArray<Definition>) {\n\treturn readonlyMap(\n\t\tdefinitions.reduce((result, definition) => {\n\t\t\tconst existing = result.get(definition.type);\n\t\t\tif (!existing) {\n\t\t\t\tresult.set(definition.type, definition);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tif (definition.durable && existing.durable && definition.durable.version !== existing.durable.version) {\n\t\t\t\tif (definition.durable.version > existing.durable.version) result.set(definition.type, definition);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tif (definition !== existing) throw new Error(`duplicate latest event definition for ${definition.type}`);\n\t\t\treturn result;\n\t\t}, new Map<string, Definition>()),\n\t);\n}\n\nexport * as EventSchema from \"./event.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiBA,MAAM,uBAAuF;CAC5F,MAAM,CAAC,UAAU;CACjB,OAAO,CAAC;CACR,UAAU,CAAC,UAAU;CACrB,UAAU,CAAC,aAAa;AACzB;AAEA,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cross the plugin boundary.
|
|
5
5
|
*
|
|
6
|
-
* A plugin reads a session id off its context and a message id off every tool call, so both
|
|
6
|
+
* A plugin reads a session and thread id off its context and a message id off every tool call, so both
|
|
7
7
|
* brands have to be the ones the harness itself mints -- a structurally identical brand declared
|
|
8
8
|
* twice is two types, and a plugin would have to cast to hand either back. They live here, in the
|
|
9
9
|
* package both sides depend on, rather than being re-declared on each side.
|
|
@@ -13,6 +13,14 @@ declare const SessionID: Schema.brand<Schema.String, "Session.ID"> & {
|
|
|
13
13
|
create: () => string & import("effect/Brand").Brand<"Session.ID">;
|
|
14
14
|
};
|
|
15
15
|
type SessionID = typeof SessionID.Type;
|
|
16
|
+
/**
|
|
17
|
+
* Thread identity: one linear transcript inside a session. Every session has a `main` thread;
|
|
18
|
+
* forks add more. Also the provider session and prompt-cache key, so it is fresh per thread.
|
|
19
|
+
*/
|
|
20
|
+
declare const ThreadID: Schema.brand<Schema.String, "Thread.ID"> & {
|
|
21
|
+
create: () => string & import("effect/Brand").Brand<"Thread.ID">;
|
|
22
|
+
};
|
|
23
|
+
type ThreadID = typeof ThreadID.Type;
|
|
16
24
|
/**
|
|
17
25
|
* A conversation message id.
|
|
18
26
|
*
|
|
@@ -39,5 +47,5 @@ declare const MessageID: Schema.brand<Schema.String, "Message.ID"> & {
|
|
|
39
47
|
};
|
|
40
48
|
type MessageID = typeof MessageID.Type;
|
|
41
49
|
//#endregion
|
|
42
|
-
export { SessionID as n, MessageID as t };
|
|
43
|
-
//# sourceMappingURL=ids-
|
|
50
|
+
export { SessionID as n, ThreadID as r, MessageID as t };
|
|
51
|
+
//# sourceMappingURL=ids-CpPeP5Ks.d.mts.map
|
package/ids.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as SessionID, t as MessageID } from "./ids-
|
|
2
|
-
export { MessageID, SessionID };
|
|
1
|
+
import { n as SessionID, r as ThreadID, t as MessageID } from "./ids-CpPeP5Ks.mjs";
|
|
2
|
+
export { MessageID, SessionID, ThreadID };
|
package/ids.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { uuidv7 } from "uuidv7";
|
|
|
5
5
|
/**
|
|
6
6
|
* The identifiers that cross the plugin boundary.
|
|
7
7
|
*
|
|
8
|
-
* A plugin reads a session id off its context and a message id off every tool call, so both
|
|
8
|
+
* A plugin reads a session and thread id off its context and a message id off every tool call, so both
|
|
9
9
|
* brands have to be the ones the harness itself mints -- a structurally identical brand declared
|
|
10
10
|
* twice is two types, and a plugin would have to cast to hand either back. They live here, in the
|
|
11
11
|
* package both sides depend on, rather than being re-declared on each side.
|
|
@@ -19,6 +19,11 @@ const SessionID = Schema.String.check(Schema.isStartingWith("ses")).pipe(Schema.
|
|
|
19
19
|
create: () => schema.make("ses_" + uuidv7())
|
|
20
20
|
})));
|
|
21
21
|
/**
|
|
22
|
+
* Thread identity: one linear transcript inside a session. Every session has a `main` thread;
|
|
23
|
+
* forks add more. Also the provider session and prompt-cache key, so it is fresh per thread.
|
|
24
|
+
*/
|
|
25
|
+
const ThreadID = Schema.String.check(Schema.isStartingWith("thr")).pipe(Schema.brand("Thread.ID"), withStatics((schema) => ({ create: () => schema.make("thr_" + uuidv7()) })));
|
|
26
|
+
/**
|
|
22
27
|
* A conversation message id.
|
|
23
28
|
*
|
|
24
29
|
* Deliberately unprefixed. aikit mints assistant message ids itself, as bare
|
|
@@ -43,6 +48,6 @@ const MessageID = Schema.String.pipe(Schema.brand("Message.ID"), withStatics((sc
|
|
|
43
48
|
from: (id) => schema.make(id)
|
|
44
49
|
})));
|
|
45
50
|
//#endregion
|
|
46
|
-
export { MessageID, SessionID };
|
|
51
|
+
export { MessageID, SessionID, ThreadID };
|
|
47
52
|
|
|
48
53
|
//# sourceMappingURL=ids.mjs.map
|