Skip to content

Commit f70afbe

Browse files
chore: generate
1 parent b275b12 commit f70afbe

4 files changed

Lines changed: 148 additions & 57 deletions

File tree

packages/opencode/src/server/routes/instance/httpapi/handlers/v2/message.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,23 @@ export const messageHandlers = HttpApiBuilder.group(InstanceHttpApi, "v2.message
4242
catch: () => new InvalidCursorError({ message: "Invalid cursor" }),
4343
})
4444
const order = decoded?.order ?? ctx.query.order ?? "desc"
45-
const messages = yield* session.messages({
46-
sessionID: ctx.params.sessionID,
47-
limit: ctx.query.limit ?? DefaultMessagesLimit,
48-
order,
49-
cursor: decoded ? { id: decoded.id, time: decoded.time, direction: decoded.direction } : undefined,
50-
}).pipe(
51-
Effect.catchTag("Session.NotFoundError", (error) =>
52-
Effect.fail(
53-
new SessionNotFoundError({
54-
sessionID: error.sessionID,
55-
message: `Session not found: ${error.sessionID}`,
56-
}),
45+
const messages = yield* session
46+
.messages({
47+
sessionID: ctx.params.sessionID,
48+
limit: ctx.query.limit ?? DefaultMessagesLimit,
49+
order,
50+
cursor: decoded ? { id: decoded.id, time: decoded.time, direction: decoded.direction } : undefined,
51+
})
52+
.pipe(
53+
Effect.catchTag("Session.NotFoundError", (error) =>
54+
Effect.fail(
55+
new SessionNotFoundError({
56+
sessionID: error.sessionID,
57+
message: `Session not found: ${error.sessionID}`,
58+
}),
59+
),
5760
),
58-
),
59-
)
61+
)
6062
const first = messages[0]
6163
const last = messages.at(-1)
6264
return {

packages/opencode/src/server/routes/instance/httpapi/handlers/v2/session.ts

Lines changed: 39 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -133,27 +133,12 @@ export const sessionHandlers = HttpApiBuilder.group(InstanceHttpApi, "v2.session
133133
.handle(
134134
"prompt",
135135
Effect.fn(function* (ctx) {
136-
return yield* session.prompt({
137-
sessionID: ctx.params.sessionID,
138-
prompt: ctx.payload.prompt,
139-
delivery: ctx.payload.delivery ?? SessionV2.DefaultDelivery,
140-
}).pipe(
141-
Effect.catchTag("Session.NotFoundError", (error) =>
142-
Effect.fail(
143-
new SessionNotFoundError({
144-
sessionID: error.sessionID,
145-
message: `Session not found: ${error.sessionID}`,
146-
}),
147-
),
148-
),
149-
)
150-
}),
151-
)
152-
.handle(
153-
"compact",
154-
Effect.fn(function* (ctx) {
155-
yield* session
156-
.compact(ctx.params.sessionID)
136+
return yield* session
137+
.prompt({
138+
sessionID: ctx.params.sessionID,
139+
prompt: ctx.payload.prompt,
140+
delivery: ctx.payload.delivery ?? SessionV2.DefaultDelivery,
141+
})
157142
.pipe(
158143
Effect.catchTag("Session.NotFoundError", (error) =>
159144
Effect.fail(
@@ -164,42 +149,53 @@ export const sessionHandlers = HttpApiBuilder.group(InstanceHttpApi, "v2.session
164149
),
165150
),
166151
)
152+
}),
153+
)
154+
.handle(
155+
"compact",
156+
Effect.fn(function* (ctx) {
157+
yield* session.compact(ctx.params.sessionID).pipe(
158+
Effect.catchTag("Session.NotFoundError", (error) =>
159+
Effect.fail(
160+
new SessionNotFoundError({
161+
sessionID: error.sessionID,
162+
message: `Session not found: ${error.sessionID}`,
163+
}),
164+
),
165+
),
166+
)
167167
return HttpApiSchema.NoContent.make()
168168
}),
169169
)
170170
.handle(
171171
"wait",
172172
Effect.fn(function* (ctx) {
173-
yield* session
174-
.wait(ctx.params.sessionID)
175-
.pipe(
176-
Effect.catchTag("Session.NotFoundError", (error) =>
177-
Effect.fail(
178-
new SessionNotFoundError({
179-
sessionID: error.sessionID,
180-
message: `Session not found: ${error.sessionID}`,
181-
}),
182-
),
173+
yield* session.wait(ctx.params.sessionID).pipe(
174+
Effect.catchTag("Session.NotFoundError", (error) =>
175+
Effect.fail(
176+
new SessionNotFoundError({
177+
sessionID: error.sessionID,
178+
message: `Session not found: ${error.sessionID}`,
179+
}),
183180
),
184-
)
181+
),
182+
)
185183
return HttpApiSchema.NoContent.make()
186184
}),
187185
)
188186
.handle(
189187
"context",
190188
Effect.fn(function* (ctx) {
191-
return yield* session
192-
.context(ctx.params.sessionID)
193-
.pipe(
194-
Effect.catchTag("Session.NotFoundError", (error) =>
195-
Effect.fail(
196-
new SessionNotFoundError({
197-
sessionID: error.sessionID,
198-
message: `Session not found: ${error.sessionID}`,
199-
}),
200-
),
189+
return yield* session.context(ctx.params.sessionID).pipe(
190+
Effect.catchTag("Session.NotFoundError", (error) =>
191+
Effect.fail(
192+
new SessionNotFoundError({
193+
sessionID: error.sessionID,
194+
message: `Session not found: ${error.sessionID}`,
195+
}),
201196
),
202-
)
197+
),
198+
)
203199
}),
204200
)
205201
}),

packages/sdk/js/src/v2/gen/types.gen.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,6 +1823,12 @@ export type UnauthorizedError = {
18231823
message: string
18241824
}
18251825

1826+
export type SessionNotFoundError = {
1827+
_tag: "SessionNotFoundError"
1828+
sessionID: string
1829+
message: string
1830+
}
1831+
18261832
export type V2SessionMessagesResponse = {
18271833
items: Array<SessionMessage>
18281834
cursor: {
@@ -7174,6 +7180,10 @@ export type V2SessionPromptErrors = {
71747180
* UnauthorizedError
71757181
*/
71767182
401: UnauthorizedError
7183+
/**
7184+
* SessionNotFoundError
7185+
*/
7186+
404: SessionNotFoundError
71777187
}
71787188

71797189
export type V2SessionPromptError = V2SessionPromptErrors[keyof V2SessionPromptErrors]
@@ -7208,6 +7218,10 @@ export type V2SessionCompactErrors = {
72087218
* UnauthorizedError
72097219
*/
72107220
401: UnauthorizedError
7221+
/**
7222+
* SessionNotFoundError
7223+
*/
7224+
404: SessionNotFoundError
72117225
}
72127226

72137227
export type V2SessionCompactError = V2SessionCompactErrors[keyof V2SessionCompactErrors]
@@ -7242,6 +7256,10 @@ export type V2SessionWaitErrors = {
72427256
* UnauthorizedError
72437257
*/
72447258
401: UnauthorizedError
7259+
/**
7260+
* SessionNotFoundError
7261+
*/
7262+
404: SessionNotFoundError
72457263
}
72467264

72477265
export type V2SessionWaitError = V2SessionWaitErrors[keyof V2SessionWaitErrors]
@@ -7276,6 +7294,10 @@ export type V2SessionContextErrors = {
72767294
* UnauthorizedError
72777295
*/
72787296
401: UnauthorizedError
7297+
/**
7298+
* SessionNotFoundError
7299+
*/
7300+
404: SessionNotFoundError
72797301
}
72807302

72817303
export type V2SessionContextError = V2SessionContextErrors[keyof V2SessionContextErrors]
@@ -7316,6 +7338,10 @@ export type V2SessionMessagesErrors = {
73167338
* UnauthorizedError
73177339
*/
73187340
401: UnauthorizedError
7341+
/**
7342+
* SessionNotFoundError
7343+
*/
7344+
404: SessionNotFoundError
73197345
}
73207346

73217347
export type V2SessionMessagesError = V2SessionMessagesErrors[keyof V2SessionMessagesErrors]

packages/sdk/openapi.json

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8217,6 +8217,16 @@
82178217
}
82188218
}
82198219
}
8220+
},
8221+
"404": {
8222+
"description": "SessionNotFoundError",
8223+
"content": {
8224+
"application/json": {
8225+
"schema": {
8226+
"$ref": "#/components/schemas/SessionNotFoundError"
8227+
}
8228+
}
8229+
}
82208230
}
82218231
},
82228232
"description": "Create a v2 session message and queue it for the agent loop.",
@@ -8303,6 +8313,16 @@
83038313
}
83048314
}
83058315
}
8316+
},
8317+
"404": {
8318+
"description": "SessionNotFoundError",
8319+
"content": {
8320+
"application/json": {
8321+
"schema": {
8322+
"$ref": "#/components/schemas/SessionNotFoundError"
8323+
}
8324+
}
8325+
}
83068326
}
83078327
},
83088328
"description": "Compact a v2 session conversation.",
@@ -8370,6 +8390,16 @@
83708390
}
83718391
}
83728392
}
8393+
},
8394+
"404": {
8395+
"description": "SessionNotFoundError",
8396+
"content": {
8397+
"application/json": {
8398+
"schema": {
8399+
"$ref": "#/components/schemas/SessionNotFoundError"
8400+
}
8401+
}
8402+
}
83738403
}
83748404
},
83758405
"description": "Wait for a v2 session agent loop to become idle.",
@@ -8447,6 +8477,16 @@
84478477
}
84488478
}
84498479
}
8480+
},
8481+
"404": {
8482+
"description": "SessionNotFoundError",
8483+
"content": {
8484+
"application/json": {
8485+
"schema": {
8486+
"$ref": "#/components/schemas/SessionNotFoundError"
8487+
}
8488+
}
8489+
}
84508490
}
84518491
},
84528492
"description": "Retrieve the active context messages for a v2 session (all messages after the last compaction).",
@@ -8554,6 +8594,16 @@
85548594
}
85558595
}
85568596
}
8597+
},
8598+
"404": {
8599+
"description": "SessionNotFoundError",
8600+
"content": {
8601+
"application/json": {
8602+
"schema": {
8603+
"$ref": "#/components/schemas/SessionNotFoundError"
8604+
}
8605+
}
8606+
}
85578607
}
85588608
},
85598609
"description": "Retrieve projected v2 messages for a session. Items keep the requested order across pages; use cursor.next or cursor.previous to move through the ordered timeline.",
@@ -15618,6 +15668,23 @@
1561815668
"required": ["_tag", "message"],
1561915669
"additionalProperties": false
1562015670
},
15671+
"SessionNotFoundError": {
15672+
"type": "object",
15673+
"properties": {
15674+
"_tag": {
15675+
"type": "string",
15676+
"enum": ["SessionNotFoundError"]
15677+
},
15678+
"sessionID": {
15679+
"type": "string"
15680+
},
15681+
"message": {
15682+
"type": "string"
15683+
}
15684+
},
15685+
"required": ["_tag", "sessionID", "message"],
15686+
"additionalProperties": false
15687+
},
1562115688
"V2SessionMessagesResponse": {
1562215689
"type": "object",
1562315690
"properties": {

0 commit comments

Comments
 (0)