GeezerVison is showing github.com — fix(session): support assistant message content updates (#45015) · anomalyco/opencode@e82aa92
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/client/src/effect/api/api.ts +26Lines changed: 26 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -974,6 +974,19 @@ export type SessionLogOutput = | 974 | 974 | readonly location?: Location.Ref | undefined | 975 | 975 | readonly data: { readonly sessionID: Session.ID; readonly to: SessionMessage.ID } | 976 | 976 | } | | 977 | + | { | | 978 | + readonly id: Event.ID | | 979 | + readonly created: number | | 980 | + readonly metadata?: { readonly [x: string]: unknown } | undefined | | 981 | + readonly type: "session.message.content.updated" | | 982 | + readonly durable: { readonly aggregateID: string; readonly seq: Event.Seq; readonly version: Event.Version } | | 983 | + readonly location?: Location.Ref | undefined | | 984 | + readonly data: { | | 985 | + readonly sessionID: Session.ID | | 986 | + readonly messageID: SessionMessage.ID | | 987 | + readonly content: ReadonlyArray<SessionMessage.AssistantContentEncoded> | | 988 | + } | | 989 | + } | 977 | 990 | | { | 978 | 991 | readonly id: Event.ID | 979 | 992 | readonly created: number | @@ -1013,6 +1026,18 @@ export type SessionMessageInput = { readonly sessionID: Session.ID; readonly mes | 1013 | 1026 | export type SessionMessageOutput = SessionMessage.Info | 1014 | 1027 | export type SessionMessageOperation<E = never> = (input: SessionMessageInput) => Effect.Effect<SessionMessageOutput, E> | 1015 | 1028 |
| | 1029 | +export type SessionMessageUpdateInput = { | | 1030 | + readonly sessionID: Session.ID | | 1031 | + readonly messageID: SessionMessage.ID | | 1032 | + readonly content: ReadonlyArray< | | 1033 | + SessionMessage.AssistantText | SessionMessage.AssistantReasoning | SessionMessage.AssistantTool | | 1034 | + > | | 1035 | +} | | 1036 | +export type SessionMessageUpdateOutput = SessionMessage.Assistant | | 1037 | +export type SessionMessageUpdateOperation<E = never> = ( | | 1038 | + input: SessionMessageUpdateInput, | | 1039 | +) => Effect.Effect<SessionMessageUpdateOutput, E> | | 1040 | + | 1016 | 1041 | export type SessionEnvironmentInput = { | 1017 | 1042 | readonly sessionID: Session.ID | 1018 | 1043 | readonly variables: { readonly [x: string]: string } | @@ -1071,6 +1096,7 @@ export interface SessionApi<E = never> { | 1071 | 1096 | readonly interrupt: SessionInterruptOperation<E> | 1072 | 1097 | readonly background: SessionBackgroundOperation<E> | 1073 | 1098 | readonly message: SessionMessageOperation<E> | | 1099 | + readonly messageUpdate: SessionMessageUpdateOperation<E> | 1074 | 1100 | readonly environment: SessionEnvironmentOperation<E> | 1075 | 1101 | readonly view: SessionViewOperation<E> | 1076 | 1102 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/client/src/effect/generated/client.ts +14Lines changed: 14 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -86,6 +86,8 @@ import type { | 86 | 86 | SessionBackgroundOutput, | 87 | 87 | SessionMessageInput, | 88 | 88 | SessionMessageOutput, | | 89 | + SessionMessageUpdateInput, | | 90 | + SessionMessageUpdateOutput, | 89 | 91 | SessionEnvironmentInput, | 90 | 92 | SessionEnvironmentOutput, | 91 | 93 | SessionViewInput, | @@ -651,6 +653,17 @@ const EndpointSessionMessage = (raw: RawClient["server.session"]) => (input: Ses | 651 | 653 | ), | 652 | 654 | ) | 653 | 655 |
| | 656 | +const EndpointSessionMessageUpdate = (raw: RawClient["server.session"]) => (input: SessionMessageUpdateInput) => | | 657 | + preserveEffect<SessionMessageUpdateOutput>()( | | 658 | + raw["session.messageUpdate"]({ | | 659 | + params: { sessionID: input["sessionID"], messageID: input["messageID"] }, | | 660 | + payload: { content: input["content"] }, | | 661 | + }).pipe( | | 662 | + Effect.mapError(mapClientError), | | 663 | + Effect.map((value) => value.data), | | 664 | + ), | | 665 | + ) | | 666 | + | 654 | 667 | const EndpointSessionEnvironment = (raw: RawClient["server.session"]) => (input: SessionEnvironmentInput) => | 655 | 668 | preserveEffect<SessionEnvironmentOutput>()( | 656 | 669 | raw["session.environment"]({ | @@ -711,6 +724,7 @@ const adaptGroupSession = (raw: RawClient["server.session"]) => ({ | 711 | 724 | interrupt: EndpointSessionInterrupt(raw), | 712 | 725 | background: EndpointSessionBackground(raw), | 713 | 726 | message: EndpointSessionMessage(raw), | | 727 | + messageUpdate: EndpointSessionMessageUpdate(raw), | 714 | 728 | environment: EndpointSessionEnvironment(raw), | 715 | 729 | view: EndpointSessionView(raw), | 716 | 730 | }) | |
Collapse file Copy file name to clipboardExpand all lines: packages/client/src/promise/generated/client.ts +14Lines changed: 14 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -80,6 +80,8 @@ import type { | 80 | 80 | SessionBackgroundOutput, | 81 | 81 | SessionMessageInput, | 82 | 82 | SessionMessageOutput, | | 83 | + SessionMessageUpdateInput, | | 84 | + SessionMessageUpdateOutput, | 83 | 85 | SessionEnvironmentInput, | 84 | 86 | SessionEnvironmentOutput, | 85 | 87 | SessionViewInput, | @@ -929,6 +931,18 @@ export function make(options: ClientOptions) { | 929 | 931 | }, | 930 | 932 | requestOptions, | 931 | 933 | ).then((value) => value.data), | | 934 | + messageUpdate: (input: SessionMessageUpdateInput, requestOptions?: RequestOptions) => | | 935 | + request<{ readonly data: SessionMessageUpdateOutput }>( | | 936 | + { | | 937 | + method: "PATCH", | | 938 | + path: `/api/session/${encodeURIComponent(input.sessionID)}/message/${encodeURIComponent(input.messageID)}`, | | 939 | + body: { content: input["content"] }, | | 940 | + successStatus: 200, | | 941 | + declaredStatuses: [404, 400, 409, 401], | | 942 | + empty: false, | | 943 | + }, | | 944 | + requestOptions, | | 945 | + ).then((value) => value.data), | 932 | 946 | environment: (input: SessionEnvironmentInput, requestOptions?: RequestOptions) => | 933 | 947 | request<SessionEnvironmentOutput>( | 934 | 948 | { | |
|