@runtypelabs/persona 3.26.0 → 3.27.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.
@@ -701,6 +701,556 @@ interface AgentWidgetPlugin {
701
701
  onUnregister?: () => void;
702
702
  }
703
703
 
704
+ type RuntypeAgentSSEEvent = {
705
+ agentId: string;
706
+ agentName: string;
707
+ config?: {
708
+ enableReflection?: boolean;
709
+ model?: string;
710
+ };
711
+ executionId: string;
712
+ maxTurns: number;
713
+ seq: number;
714
+ startedAt: string;
715
+ type: "agent_start";
716
+ } | {
717
+ executionId: string;
718
+ iteration: number;
719
+ maxTurns: number;
720
+ seq: number;
721
+ startedAt: string;
722
+ totalCost?: number;
723
+ type: "agent_iteration_start";
724
+ } | ({
725
+ executionId: string;
726
+ iteration: number;
727
+ role: "user" | "assistant" | "system";
728
+ seq: number;
729
+ turnId: string;
730
+ turnIndex: number;
731
+ type: "agent_turn_start";
732
+ }) | ({
733
+ contentType: "text" | "thinking" | "tool_input";
734
+ delta: string;
735
+ executionId: string;
736
+ iteration: number;
737
+ seq: number;
738
+ turnId: string;
739
+ type: "agent_turn_delta";
740
+ }) | ({
741
+ completedAt: string;
742
+ content?: string;
743
+ cost?: number;
744
+ estimatedContextBreakdown?: {
745
+ categories: Record<string, {
746
+ chars: number;
747
+ estimatedTokens: number;
748
+ }>;
749
+ contextWindowSize?: number;
750
+ estimatedTotalTokens: number;
751
+ estimatedUtilizationPercent?: number;
752
+ };
753
+ executionId: string;
754
+ iteration: number;
755
+ role: "user" | "assistant" | "system";
756
+ seq: number;
757
+ stopReason?: "end_turn" | "max_tool_calls" | "length" | "content_filter" | "error" | "unknown";
758
+ tokens?: {
759
+ input: number;
760
+ output: number;
761
+ };
762
+ turnId: string;
763
+ type: "agent_turn_complete";
764
+ }) | ({
765
+ executionId: string;
766
+ iteration: number;
767
+ origin?: "webmcp" | "sdk";
768
+ pageOrigin?: string;
769
+ parameters?: Record<string, unknown>;
770
+ seq: number;
771
+ toolCallId: string;
772
+ toolName: string;
773
+ toolType: "flow" | "mcp" | "builtin" | "custom" | "external" | "advisor" | "subagent" | "local";
774
+ type: "agent_tool_start";
775
+ }) | {
776
+ delta: string;
777
+ executionId: string;
778
+ iteration: number;
779
+ seq: number;
780
+ toolCallId: string;
781
+ type: "agent_tool_delta";
782
+ } | {
783
+ delta: string;
784
+ executionId: string;
785
+ iteration: number;
786
+ seq: number;
787
+ toolCallId: string;
788
+ type: "agent_tool_input_delta";
789
+ } | {
790
+ executionId: string;
791
+ hiddenParameterNames?: Array<string>;
792
+ iteration: number;
793
+ parameters: Record<string, unknown>;
794
+ seq: number;
795
+ toolCallId: string;
796
+ toolName: string;
797
+ type: "agent_tool_input_complete";
798
+ } | {
799
+ executionId: string;
800
+ executionTime?: number;
801
+ iteration: number;
802
+ result?: unknown;
803
+ seq: number;
804
+ success: boolean;
805
+ toolCallId: string;
806
+ toolName: string;
807
+ type: "agent_tool_complete";
808
+ } | ({
809
+ executionId?: string;
810
+ iteration: number;
811
+ media: Array<({
812
+ annotations?: {
813
+ audience?: Array<"user" | "assistant">;
814
+ };
815
+ data: string;
816
+ mediaType: string;
817
+ type: "media";
818
+ }) | ({
819
+ annotations?: {
820
+ audience?: Array<"user" | "assistant">;
821
+ };
822
+ mediaType?: string;
823
+ type: "image-url";
824
+ url: string;
825
+ }) | ({
826
+ annotations?: {
827
+ audience?: Array<"user" | "assistant">;
828
+ };
829
+ mediaType: string;
830
+ type: "file-url";
831
+ url: string;
832
+ })>;
833
+ seq?: number;
834
+ toolCallId: string;
835
+ toolName: string;
836
+ type: "agent_media";
837
+ }) | {
838
+ approvalId: string;
839
+ description: string;
840
+ executionId: string;
841
+ externalAgent?: {
842
+ contextId?: string;
843
+ taskId?: string;
844
+ };
845
+ iteration?: number;
846
+ parameters?: Record<string, unknown>;
847
+ seq: number;
848
+ startedAt: string;
849
+ timeout: number;
850
+ toolCallId: string;
851
+ toolName: string;
852
+ toolType: string;
853
+ type: "agent_approval_start";
854
+ } | ({
855
+ approvalId: string;
856
+ completedAt: string;
857
+ decision: "approved" | "denied" | "timeout";
858
+ executionId: string;
859
+ resolvedBy: "user" | "system";
860
+ seq: number;
861
+ type: "agent_approval_complete";
862
+ }) | ({
863
+ awaitedAt: string;
864
+ executionId: string;
865
+ origin?: "webmcp" | "sdk";
866
+ pageOrigin?: string;
867
+ parameters?: Record<string, unknown>;
868
+ seq: number;
869
+ toolCallId?: string;
870
+ toolId: string;
871
+ toolName: string;
872
+ type: "agent_await";
873
+ }) | {
874
+ completedAt: string;
875
+ cost?: number;
876
+ duration?: number;
877
+ estimatedContextBreakdown?: {
878
+ categories: Record<string, {
879
+ chars: number;
880
+ estimatedTokens: number;
881
+ }>;
882
+ contextWindowSize?: number;
883
+ estimatedTotalTokens: number;
884
+ estimatedUtilizationPercent?: number;
885
+ };
886
+ executionId: string;
887
+ iteration: number;
888
+ output?: string;
889
+ runningTotalCost?: number;
890
+ seq: number;
891
+ stopConditionMet: boolean;
892
+ tokens?: {
893
+ input: number;
894
+ output: number;
895
+ };
896
+ toolCallsMade: number;
897
+ type: "agent_iteration_complete";
898
+ } | {
899
+ executionId: string;
900
+ iteration: number;
901
+ reflection?: string;
902
+ seq: number;
903
+ type: "agent_reflection";
904
+ } | {
905
+ activatedCapabilities: Array<string>;
906
+ executionId: string;
907
+ iteration: number;
908
+ seq: number;
909
+ skill: string;
910
+ toolCallId: string;
911
+ type: "agent_skill_loaded";
912
+ } | ({
913
+ executionId: string;
914
+ iteration: number;
915
+ outcome: "pending_approval" | "auto_published";
916
+ proposalId?: string;
917
+ seq: number;
918
+ skill: string;
919
+ toolCallId: string;
920
+ type: "agent_skill_proposed";
921
+ }) | ({
922
+ agentId: string;
923
+ completedAt: string;
924
+ duration?: number;
925
+ error?: string;
926
+ executionId: string;
927
+ externalAgent?: {
928
+ contextId?: string;
929
+ taskId?: string;
930
+ };
931
+ finalOutput?: string;
932
+ iterations: number;
933
+ seq: number;
934
+ stopReason: "complete" | "end_turn" | "max_turns" | "max_cost" | "timeout" | "error";
935
+ success: boolean;
936
+ totalCost?: number;
937
+ totalTokens?: {
938
+ input: number;
939
+ output: number;
940
+ };
941
+ type: "agent_complete";
942
+ }) | {
943
+ error: {
944
+ code: string;
945
+ details?: Record<string, unknown>;
946
+ message: string;
947
+ };
948
+ executionId: string;
949
+ iteration?: number;
950
+ recoverable: boolean;
951
+ seq: number;
952
+ type: "agent_error";
953
+ } | {
954
+ executionId: string;
955
+ seq: number;
956
+ timestamp: string;
957
+ type: "agent_ping";
958
+ };
959
+ type RuntypeFlowSSEEvent = {
960
+ executionContext?: Record<string, unknown>;
961
+ executionId?: string;
962
+ flowId: string;
963
+ flowName?: string;
964
+ input?: unknown;
965
+ seq?: number;
966
+ source?: string;
967
+ startedAt: string;
968
+ toolContext?: {
969
+ executionId: string;
970
+ stepId: string;
971
+ toolId: string;
972
+ };
973
+ totalSteps?: number;
974
+ type: "flow_start";
975
+ } | {
976
+ completedAt?: string;
977
+ completedSteps?: number;
978
+ duration?: number;
979
+ executionContext?: Record<string, unknown>;
980
+ executionId?: string;
981
+ executionTime?: number;
982
+ failedSteps?: number;
983
+ finalOutput?: string;
984
+ flowId?: string;
985
+ output?: unknown;
986
+ seq?: number;
987
+ source?: string;
988
+ success?: boolean;
989
+ successfulSteps?: number;
990
+ toolContext?: {
991
+ executionId: string;
992
+ stepId: string;
993
+ toolId: string;
994
+ };
995
+ totalSteps?: number;
996
+ totalTokensUsed?: number;
997
+ type: "flow_complete";
998
+ } | ({
999
+ code?: string;
1000
+ error: string | {
1001
+ code: string;
1002
+ message: string;
1003
+ stepId?: string;
1004
+ stepType?: string;
1005
+ };
1006
+ executionId?: string;
1007
+ executionTime?: number;
1008
+ flowId?: string;
1009
+ seq?: number;
1010
+ timestamp?: string;
1011
+ toolContext?: {
1012
+ executionId: string;
1013
+ stepId: string;
1014
+ toolId: string;
1015
+ };
1016
+ type: "flow_error";
1017
+ upgradeUrl?: string;
1018
+ }) | ({
1019
+ awaitedAt: string;
1020
+ executionId?: string;
1021
+ flowId: string;
1022
+ origin?: "webmcp" | "sdk";
1023
+ pageOrigin?: string;
1024
+ parameters?: Record<string, unknown>;
1025
+ seq?: number;
1026
+ toolCallId?: string;
1027
+ toolId?: string;
1028
+ toolName?: string;
1029
+ type: "flow_await";
1030
+ }) | {
1031
+ estimatedTokens?: number;
1032
+ executionId?: string;
1033
+ id?: string;
1034
+ index?: number;
1035
+ name?: string;
1036
+ seq?: number;
1037
+ startedAt: string;
1038
+ stepId?: string;
1039
+ stepName?: string;
1040
+ stepType?: string;
1041
+ toolContext?: {
1042
+ executionId: string;
1043
+ stepId: string;
1044
+ toolId: string;
1045
+ };
1046
+ totalSteps?: number;
1047
+ type: "step_start";
1048
+ } | {
1049
+ delta?: string;
1050
+ executionId?: string;
1051
+ id?: string;
1052
+ messageId?: string;
1053
+ partId?: string;
1054
+ seq?: number;
1055
+ text?: string;
1056
+ toolContext?: {
1057
+ executionId: string;
1058
+ stepId: string;
1059
+ toolId: string;
1060
+ };
1061
+ toolId?: string;
1062
+ type: "step_delta";
1063
+ } | ({
1064
+ completedAt?: string;
1065
+ duration?: number;
1066
+ durationMs?: number;
1067
+ error?: string;
1068
+ executionId?: string;
1069
+ executionTime?: number;
1070
+ id?: string;
1071
+ index?: number;
1072
+ name?: string;
1073
+ output?: unknown;
1074
+ result?: unknown;
1075
+ seq?: number;
1076
+ stepId?: string;
1077
+ stepName?: string;
1078
+ stepType?: string;
1079
+ stopReason?: "end_turn" | "max_tool_calls" | "length" | "content_filter" | "error" | "unknown";
1080
+ success?: boolean;
1081
+ tokensUsed?: number;
1082
+ toolContext?: {
1083
+ executionId: string;
1084
+ stepId: string;
1085
+ toolId: string;
1086
+ };
1087
+ type: "step_complete";
1088
+ }) | {
1089
+ error: string;
1090
+ executionId?: string;
1091
+ executionTime?: number;
1092
+ id?: string;
1093
+ index?: number;
1094
+ name?: string;
1095
+ seq?: number;
1096
+ stepType?: string;
1097
+ type: "step_error";
1098
+ } | {
1099
+ error?: string;
1100
+ executionId?: string;
1101
+ id: string;
1102
+ index?: number;
1103
+ name?: string;
1104
+ seq?: number;
1105
+ skippedAt: string;
1106
+ stepType: string;
1107
+ totalSteps: number;
1108
+ type: "step_skip";
1109
+ when: string;
1110
+ } | {
1111
+ executionId?: string;
1112
+ seq?: number;
1113
+ type: "step_await";
1114
+ [key: string]: unknown;
1115
+ } | ({
1116
+ agentContext?: {
1117
+ executionId: string;
1118
+ iteration: number;
1119
+ seq: number;
1120
+ };
1121
+ executionId?: string;
1122
+ hiddenParameterNames?: Array<string>;
1123
+ name?: string;
1124
+ parameters?: Record<string, unknown>;
1125
+ providerOptions?: Record<string, unknown>;
1126
+ seq?: number;
1127
+ startedAt?: string;
1128
+ stepId?: string;
1129
+ toolCallId?: string;
1130
+ toolId?: string;
1131
+ toolName?: string;
1132
+ toolType: "flow" | "mcp" | "builtin" | "custom" | "external" | "advisor" | "subagent" | "local";
1133
+ type: "tool_start";
1134
+ [key: string]: unknown;
1135
+ }) | {
1136
+ delta?: string;
1137
+ executionId?: string;
1138
+ seq?: number;
1139
+ toolId?: string;
1140
+ type: "tool_delta";
1141
+ [key: string]: unknown;
1142
+ } | {
1143
+ delta: string;
1144
+ executionId?: string;
1145
+ seq?: number;
1146
+ stepId?: string;
1147
+ toolCallId?: string;
1148
+ toolId?: string;
1149
+ type: "tool_input_delta";
1150
+ } | {
1151
+ executionId?: string;
1152
+ hiddenParameterNames?: Array<string>;
1153
+ parameters: Record<string, unknown>;
1154
+ providerOptions?: Record<string, unknown>;
1155
+ seq?: number;
1156
+ stepId?: string;
1157
+ toolCallId?: string;
1158
+ toolId?: string;
1159
+ toolName?: string;
1160
+ type: "tool_input_complete";
1161
+ } | {
1162
+ agentContext?: {
1163
+ executionId: string;
1164
+ iteration: number;
1165
+ seq: number;
1166
+ };
1167
+ completedAt?: string;
1168
+ error?: string;
1169
+ executionId?: string;
1170
+ executionTime?: number;
1171
+ name?: string;
1172
+ result?: unknown;
1173
+ seq?: number;
1174
+ stepId?: string;
1175
+ success: boolean;
1176
+ toolCallId?: string;
1177
+ toolCost?: number;
1178
+ toolId?: string;
1179
+ toolName?: string;
1180
+ type: "tool_complete";
1181
+ } | {
1182
+ agentContext?: {
1183
+ executionId: string;
1184
+ iteration: number;
1185
+ seq: number;
1186
+ };
1187
+ error: string;
1188
+ executionId?: string;
1189
+ executionTime?: number;
1190
+ failedAt?: string;
1191
+ name: string;
1192
+ seq?: number;
1193
+ toolId: string;
1194
+ type: "tool_error";
1195
+ } | {
1196
+ executionId?: string;
1197
+ id: string;
1198
+ seq?: number;
1199
+ text: string;
1200
+ type: "chunk";
1201
+ } | {
1202
+ executionId?: string;
1203
+ seq?: number;
1204
+ type: "text_start";
1205
+ [key: string]: unknown;
1206
+ } | {
1207
+ executionId?: string;
1208
+ seq?: number;
1209
+ type: "text_end";
1210
+ [key: string]: unknown;
1211
+ } | {
1212
+ executionId?: string;
1213
+ seq?: number;
1214
+ type: "reason_start";
1215
+ [key: string]: unknown;
1216
+ } | {
1217
+ executionId?: string;
1218
+ seq?: number;
1219
+ type: "reason_delta";
1220
+ [key: string]: unknown;
1221
+ } | {
1222
+ executionId?: string;
1223
+ seq?: number;
1224
+ type: "reason_complete";
1225
+ [key: string]: unknown;
1226
+ } | {
1227
+ executionId?: string;
1228
+ seq?: number;
1229
+ type: "source";
1230
+ [key: string]: unknown;
1231
+ } | {
1232
+ executionId?: string;
1233
+ seq?: number;
1234
+ type: "fallback_start";
1235
+ [key: string]: unknown;
1236
+ } | {
1237
+ executionId?: string;
1238
+ seq?: number;
1239
+ type: "fallback_complete";
1240
+ [key: string]: unknown;
1241
+ } | {
1242
+ executionId?: string;
1243
+ seq?: number;
1244
+ type: "fallback_exhausted";
1245
+ [key: string]: unknown;
1246
+ };
1247
+ type RuntypeStreamEventOf<U, T extends string> = Extract<U, {
1248
+ type: T;
1249
+ }>;
1250
+ type RuntypeAgentTurnCompleteEvent = RuntypeStreamEventOf<RuntypeAgentSSEEvent, "agent_turn_complete">;
1251
+ type RuntypeStepCompleteEvent = RuntypeStreamEventOf<RuntypeFlowSSEEvent, "step_complete">;
1252
+ type RuntypeStopReasonKind = NonNullable<RuntypeAgentTurnCompleteEvent["stopReason"] | RuntypeStepCompleteEvent["stopReason"]>;
1253
+
704
1254
  /**
705
1255
  * Text content part for multi-modal messages
706
1256
  */
@@ -4103,7 +4653,7 @@ type AgentWidgetMessageVariant = "assistant" | "reasoning" | "tool" | "approval"
4103
4653
  *
4104
4654
  * Absent (`undefined`) means "not reported" — distinct from `'unknown'`.
4105
4655
  */
4106
- type StopReasonKind = 'end_turn' | 'max_tool_calls' | 'length' | 'content_filter' | 'error' | 'unknown';
4656
+ type StopReasonKind = RuntypeStopReasonKind;
4107
4657
  /**
4108
4658
  * Represents a message in the chat conversation.
4109
4659
  *