fix(sdk): type SSE event payloads
Patch Effect OpenAPI generation so data-mode SSE responses expose their JSON payload schema instead of the raw data-line string wrapper. Regenerate legacy SDK types so V2Event and SessionDurableEvent remain the public payload unions. Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
This commit is contained in:
parent
5a55135d89
commit
6dbd516466
5 changed files with 40 additions and 14 deletions
1
bun.lock
1
bun.lock
|
|
@ -1051,6 +1051,7 @@
|
|||
"@modelcontextprotocol/sdk@1.29.0": "patches/@modelcontextprotocol%2Fsdk@1.29.0.patch",
|
||||
"gcp-metadata@8.1.2": "patches/gcp-metadata@8.1.2.patch",
|
||||
"@standard-community/standard-openapi@0.2.9": "patches/@standard-community%2Fstandard-openapi@0.2.9.patch",
|
||||
"effect@4.0.0-beta.83": "patches/effect@4.0.0-beta.83.patch",
|
||||
"@npmcli/agent@4.0.2": "patches/@npmcli%2Fagent@4.0.2.patch",
|
||||
"@silvia-odwyer/photon-node@0.3.4": "patches/@silvia-odwyer%2Fphoton-node@0.3.4.patch",
|
||||
"@tanstack/solid-virtual@3.13.28": "patches/@tanstack%2Fsolid-virtual@3.13.28.patch",
|
||||
|
|
|
|||
|
|
@ -153,6 +153,7 @@
|
|||
"@tanstack/solid-virtual@3.13.28": "patches/@tanstack%2Fsolid-virtual@3.13.28.patch",
|
||||
"@pierre/trees@1.0.0-beta.4": "patches/@pierre%2Ftrees@1.0.0-beta.4.patch",
|
||||
"@modelcontextprotocol/sdk@1.29.0": "patches/@modelcontextprotocol%2Fsdk@1.29.0.patch",
|
||||
"@tanstack/virtual-core@3.17.0": "patches/@tanstack%2Fvirtual-core@3.17.0.patch"
|
||||
"@tanstack/virtual-core@3.17.0": "patches/@tanstack%2Fvirtual-core@3.17.0.patch",
|
||||
"effect@4.0.0-beta.83": "patches/effect@4.0.0-beta.83.patch"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2766,8 +2766,6 @@ export type SessionHistory = {
|
|||
hasMore: boolean
|
||||
}
|
||||
|
||||
export type SessionDurableEvent1 = string
|
||||
|
||||
export type SessionMessagesResponse = {
|
||||
data: Array<SessionMessage>
|
||||
cursor: {
|
||||
|
|
@ -2847,7 +2845,7 @@ export type QuestionRejected2 = {
|
|||
}
|
||||
}
|
||||
|
||||
export type V2Event1 =
|
||||
export type V2Event =
|
||||
| ModelsDevRefreshed
|
||||
| IntegrationUpdated
|
||||
| IntegrationConnectionUpdated
|
||||
|
|
@ -2937,8 +2935,6 @@ export type V2Event1 =
|
|||
| ServerConnected
|
||||
| GlobalDisposed
|
||||
|
||||
export type V2Event = string
|
||||
|
||||
export type ForbiddenError = {
|
||||
_tag: "ForbiddenError"
|
||||
message: string
|
||||
|
|
@ -11898,11 +11894,7 @@ export type V2SessionEventsResponses = {
|
|||
/**
|
||||
* Success
|
||||
*/
|
||||
200: {
|
||||
id: string
|
||||
event: string
|
||||
data: SessionDurableEvent1
|
||||
}
|
||||
200: SessionDurableEvent
|
||||
}
|
||||
|
||||
export type V2SessionEventsResponse = V2SessionEventsResponses[keyof V2SessionEventsResponses]
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import type {
|
|||
SessionMessageAssistantTool,
|
||||
SessionV2Info,
|
||||
SkillV2Info,
|
||||
V2Event1,
|
||||
V2Event,
|
||||
} from "@opencode-ai/sdk/v2"
|
||||
import { createStore, produce } from "solid-js/store"
|
||||
import { createSimpleContext } from "./helper"
|
||||
|
|
@ -121,7 +121,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
|
|||
},
|
||||
}
|
||||
|
||||
function handleEvent(event: V2Event1) {
|
||||
function handleEvent(event: V2Event) {
|
||||
switch (event.type) {
|
||||
case "catalog.updated":
|
||||
void Promise.all([
|
||||
|
|
@ -408,7 +408,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
|
|||
...event,
|
||||
data: event.properties,
|
||||
location: { directory: metadata.directory, workspaceID: metadata.workspace },
|
||||
} as V2Event1)
|
||||
} as V2Event)
|
||||
})
|
||||
onCleanup(unsub)
|
||||
})
|
||||
|
|
|
|||
32
patches/effect@4.0.0-beta.83.patch
Normal file
32
patches/effect@4.0.0-beta.83.patch
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
diff --git a/dist/unstable/httpapi/OpenApi.js b/dist/unstable/httpapi/OpenApi.js
|
||||
index 8292ab7..9c4fd5e 100644
|
||||
--- a/dist/unstable/httpapi/OpenApi.js
|
||||
+++ b/dist/unstable/httpapi/OpenApi.js
|
||||
@@ -335,7 +335,7 @@ export function fromApi(api) {
|
||||
if (HttpApiSchema.isStreamSse(stream)) {
|
||||
pathOps.push({
|
||||
_tag: "schema",
|
||||
- ast: SchemaAST.getAST(stream.events),
|
||||
+ ast: stream.sseMode === "data" ? streamDataAst(stream.events) : SchemaAST.getAST(stream.events),
|
||||
path: ["paths", path, method, "responses", String(status), "content", contentType, "schema"]
|
||||
});
|
||||
pathOps.push({
|
||||
@@ -501,6 +501,18 @@ export function fromApi(api) {
|
||||
return spec;
|
||||
}
|
||||
const reservedStreamFailureEvent = "effect/httpapi/stream/failure";
|
||||
+function streamDataAst(events) {
|
||||
+ const ast = SchemaAST.getAST(events);
|
||||
+ if (!SchemaAST.isObjects(ast)) {
|
||||
+ return ast;
|
||||
+ }
|
||||
+ const data = ast.propertySignatures.find(field => field.name === "data")?.type;
|
||||
+ if (data === undefined) {
|
||||
+ return ast;
|
||||
+ }
|
||||
+ const contentSchema = data.encoding?.at(-1)?.to.annotations?.contentSchema;
|
||||
+ return SchemaAST.isAST(contentSchema) ? contentSchema : data;
|
||||
+}
|
||||
function extractSuccessResponseBodies(endpoint) {
|
||||
return extractResponseBodies(HttpApiEndpoint.getSuccessSchemas(endpoint), HttpApiSchema.getStatusSuccess, resolveDescriptionOrIdentifier);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue