File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed
typescript-sdk/packages/client/src/legacy Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import {
1818 StateDeltaEvent ,
1919 MessagesSnapshotEvent ,
2020 ToolCall ,
21+ RunErrorEvent ,
2122} from "@ag-ui/core" ;
2223import { Observable } from "rxjs" ;
2324import {
@@ -36,6 +37,7 @@ import {
3637 LegacyActionExecutionMessage ,
3738 LegacyResultMessage ,
3839 LegacyActionExecutionResult ,
40+ LegacyRunError
3941} from "./types" ;
4042import untruncateJson from "untruncate-json" ;
4143
@@ -317,9 +319,14 @@ export const convertToLegacyEvents =
317319 ] ;
318320 }
319321 case EventType . RUN_ERROR : {
320- // legacy protocol does not have an event for errors
321- console . error ( "Run error" , event ) ;
322- return [ ] ;
322+ const errorEvent = event as RunErrorEvent ;
323+ return [
324+ {
325+ type : LegacyRuntimeEventTypes . enum . RunError ,
326+ message : errorEvent . message ,
327+ code : errorEvent . code ,
328+ } as LegacyRunError ,
329+ ] ;
323330 }
324331 case EventType . STEP_STARTED : {
325332 const stepStarted = event as StepStartedEvent ;
Original file line number Diff line number Diff line change @@ -84,6 +84,13 @@ export const LegacyMetaEvent = z.object({
8484 value : z . any ( ) ,
8585} ) ;
8686
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+
8794export const LegacyRuntimeProtocolEvent = z . discriminatedUnion ( "type" , [
8895 LegacyTextMessageStart ,
8996 LegacyTextMessageContent ,
@@ -94,6 +101,7 @@ export const LegacyRuntimeProtocolEvent = z.discriminatedUnion("type", [
94101 LegacyActionExecutionResult ,
95102 LegacyAgentStateMessage ,
96103 LegacyMetaEvent ,
104+ LegacyRunError ,
97105] ) ;
98106
99107// Protocol Event type exports
@@ -109,6 +117,7 @@ export type LegacyActionExecutionResult = z.infer<typeof LegacyActionExecutionRe
109117export type LegacyAgentStateMessage = z . infer < typeof LegacyAgentStateMessage > ;
110118export type LegacyMetaEvent = z . infer < typeof LegacyMetaEvent > ;
111119export type LegacyRuntimeProtocolEvent = z . infer < typeof LegacyRuntimeProtocolEvent > ;
120+ export type LegacyRunError = z . infer < typeof LegacyRunError > ;
112121
113122// Message schemas (with kind discriminator)
114123export const LegacyTextMessageSchema = z . object ( {
You can’t perform that action at this time.
0 commit comments