refactor(tools): unify tool APIs and result handling (#38367)
This commit is contained in:
parent
8cac010bac
commit
79c1544072
133 changed files with 3602 additions and 2770 deletions
|
|
@ -110,27 +110,24 @@ export interface ToolStateRunning extends Schema.Schema.Type<typeof ToolStateRun
|
|||
export const ToolStateRunning = Schema.Struct({
|
||||
status: Schema.tag("running"),
|
||||
input: Schema.Record(Schema.String, Schema.Unknown),
|
||||
structured: Schema.Record(Schema.String, Schema.Unknown),
|
||||
content: ToolContent.pipe(Schema.Array),
|
||||
metadata: Schema.Record(Schema.String, Schema.Json),
|
||||
}).annotate({ identifier: "Session.Message.ToolState.Running" })
|
||||
|
||||
export interface ToolStateCompleted extends Schema.Schema.Type<typeof ToolStateCompleted> {}
|
||||
export const ToolStateCompleted = Schema.Struct({
|
||||
status: Schema.tag("completed"),
|
||||
input: Schema.Record(Schema.String, Schema.Unknown),
|
||||
content: ToolContent.pipe(Schema.Array),
|
||||
structured: Schema.Record(Schema.String, Schema.Unknown),
|
||||
result: Schema.Unknown.pipe(optional),
|
||||
content: Schema.NonEmptyArray(ToolContent),
|
||||
metadata: Schema.Record(Schema.String, Schema.Json).pipe(optional),
|
||||
}).annotate({ identifier: "Session.Message.ToolState.Completed" })
|
||||
|
||||
export interface ToolStateError extends Schema.Schema.Type<typeof ToolStateError> {}
|
||||
export const ToolStateError = Schema.Struct({
|
||||
status: Schema.tag("error"),
|
||||
input: Schema.Record(Schema.String, Schema.Unknown),
|
||||
content: ToolContent.pipe(Schema.Array),
|
||||
structured: Schema.Record(Schema.String, Schema.Unknown),
|
||||
error: SessionError.Error,
|
||||
result: Schema.Unknown.pipe(optional),
|
||||
content: Schema.NonEmptyArray(ToolContent).pipe(optional),
|
||||
metadata: Schema.Record(Schema.String, Schema.Json).pipe(optional),
|
||||
}).annotate({ identifier: "Session.Message.ToolState.Error" })
|
||||
|
||||
export const ToolState = Schema.Union([ToolStateStreaming, ToolStateRunning, ToolStateCompleted, ToolStateError]).pipe(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue