File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
typescript-sdk/packages/client/src/legacy Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import {
18
18
StateDeltaEvent ,
19
19
MessagesSnapshotEvent ,
20
20
ToolCall ,
21
+ RunErrorEvent ,
21
22
} from "@ag-ui/core" ;
22
23
import { Observable } from "rxjs" ;
23
24
import {
@@ -36,6 +37,7 @@ import {
36
37
LegacyActionExecutionMessage ,
37
38
LegacyResultMessage ,
38
39
LegacyActionExecutionResult ,
40
+ LegacyRunError
39
41
} from "./types" ;
40
42
import untruncateJson from "untruncate-json" ;
41
43
@@ -319,7 +321,14 @@ export const convertToLegacyEvents =
319
321
case EventType . RUN_ERROR : {
320
322
// legacy protocol does not have an event for errors
321
323
console . error ( "Run error" , event ) ;
322
- return [ ] ;
324
+ const errorEvent = event as RunErrorEvent ;
325
+ return [
326
+ {
327
+ type : LegacyRuntimeEventTypes . enum . RunError ,
328
+ message : errorEvent . message ,
329
+ code : errorEvent . code ,
330
+ } as LegacyRunError ,
331
+ ] ;
323
332
}
324
333
case EventType . STEP_STARTED : {
325
334
const stepStarted = event as StepStartedEvent ;
Original file line number Diff line number Diff line change @@ -84,6 +84,13 @@ export const LegacyMetaEvent = z.object({
84
84
value : z . any ( ) ,
85
85
} ) ;
86
86
87
+
88
+ export const LegacyRunError = z . object ( {
89
+ type : z . literal ( LegacyRuntimeEventTypes . enum . RunError ) ,
90
+ message : z . string ( ) ,
91
+ code : z . string ( ) . optional ( ) ,
92
+ } ) ;
93
+
87
94
export const LegacyRuntimeProtocolEvent = z . discriminatedUnion ( "type" , [
88
95
LegacyTextMessageStart ,
89
96
LegacyTextMessageContent ,
@@ -94,6 +101,7 @@ export const LegacyRuntimeProtocolEvent = z.discriminatedUnion("type", [
94
101
LegacyActionExecutionResult ,
95
102
LegacyAgentStateMessage ,
96
103
LegacyMetaEvent ,
104
+ LegacyRunError ,
97
105
] ) ;
98
106
99
107
// Protocol Event type exports
@@ -109,6 +117,7 @@ export type LegacyActionExecutionResult = z.infer<typeof LegacyActionExecutionRe
109
117
export type LegacyAgentStateMessage = z . infer < typeof LegacyAgentStateMessage > ;
110
118
export type LegacyMetaEvent = z . infer < typeof LegacyMetaEvent > ;
111
119
export type LegacyRuntimeProtocolEvent = z . infer < typeof LegacyRuntimeProtocolEvent > ;
120
+ export type LegacyRunError = z . infer < typeof LegacyRunError > ;
112
121
113
122
// Message schemas (with kind discriminator)
114
123
export const LegacyTextMessageSchema = z . object ( {
You can’t perform that action at this time.
0 commit comments