chore: generate
This commit is contained in:
@@ -42,21 +42,23 @@ export const messageHandlers = HttpApiBuilder.group(InstanceHttpApi, "v2.message
|
|||||||
catch: () => new InvalidCursorError({ message: "Invalid cursor" }),
|
catch: () => new InvalidCursorError({ message: "Invalid cursor" }),
|
||||||
})
|
})
|
||||||
const order = decoded?.order ?? ctx.query.order ?? "desc"
|
const order = decoded?.order ?? ctx.query.order ?? "desc"
|
||||||
const messages = yield* session.messages({
|
const messages = yield* session
|
||||||
sessionID: ctx.params.sessionID,
|
.messages({
|
||||||
limit: ctx.query.limit ?? DefaultMessagesLimit,
|
sessionID: ctx.params.sessionID,
|
||||||
order,
|
limit: ctx.query.limit ?? DefaultMessagesLimit,
|
||||||
cursor: decoded ? { id: decoded.id, time: decoded.time, direction: decoded.direction } : undefined,
|
order,
|
||||||
}).pipe(
|
cursor: decoded ? { id: decoded.id, time: decoded.time, direction: decoded.direction } : undefined,
|
||||||
Effect.catchTag("Session.NotFoundError", (error) =>
|
})
|
||||||
Effect.fail(
|
.pipe(
|
||||||
new SessionNotFoundError({
|
Effect.catchTag("Session.NotFoundError", (error) =>
|
||||||
sessionID: error.sessionID,
|
Effect.fail(
|
||||||
message: `Session not found: ${error.sessionID}`,
|
new SessionNotFoundError({
|
||||||
}),
|
sessionID: error.sessionID,
|
||||||
|
message: `Session not found: ${error.sessionID}`,
|
||||||
|
}),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
)
|
|
||||||
const first = messages[0]
|
const first = messages[0]
|
||||||
const last = messages.at(-1)
|
const last = messages.at(-1)
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -133,11 +133,60 @@ export const sessionHandlers = HttpApiBuilder.group(InstanceHttpApi, "v2.session
|
|||||||
.handle(
|
.handle(
|
||||||
"prompt",
|
"prompt",
|
||||||
Effect.fn(function* (ctx) {
|
Effect.fn(function* (ctx) {
|
||||||
return yield* session.prompt({
|
return yield* session
|
||||||
sessionID: ctx.params.sessionID,
|
.prompt({
|
||||||
prompt: ctx.payload.prompt,
|
sessionID: ctx.params.sessionID,
|
||||||
delivery: ctx.payload.delivery ?? SessionV2.DefaultDelivery,
|
prompt: ctx.payload.prompt,
|
||||||
}).pipe(
|
delivery: ctx.payload.delivery ?? SessionV2.DefaultDelivery,
|
||||||
|
})
|
||||||
|
.pipe(
|
||||||
|
Effect.catchTag("Session.NotFoundError", (error) =>
|
||||||
|
Effect.fail(
|
||||||
|
new SessionNotFoundError({
|
||||||
|
sessionID: error.sessionID,
|
||||||
|
message: `Session not found: ${error.sessionID}`,
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.handle(
|
||||||
|
"compact",
|
||||||
|
Effect.fn(function* (ctx) {
|
||||||
|
yield* session.compact(ctx.params.sessionID).pipe(
|
||||||
|
Effect.catchTag("Session.NotFoundError", (error) =>
|
||||||
|
Effect.fail(
|
||||||
|
new SessionNotFoundError({
|
||||||
|
sessionID: error.sessionID,
|
||||||
|
message: `Session not found: ${error.sessionID}`,
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
return HttpApiSchema.NoContent.make()
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.handle(
|
||||||
|
"wait",
|
||||||
|
Effect.fn(function* (ctx) {
|
||||||
|
yield* session.wait(ctx.params.sessionID).pipe(
|
||||||
|
Effect.catchTag("Session.NotFoundError", (error) =>
|
||||||
|
Effect.fail(
|
||||||
|
new SessionNotFoundError({
|
||||||
|
sessionID: error.sessionID,
|
||||||
|
message: `Session not found: ${error.sessionID}`,
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
return HttpApiSchema.NoContent.make()
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.handle(
|
||||||
|
"context",
|
||||||
|
Effect.fn(function* (ctx) {
|
||||||
|
return yield* session.context(ctx.params.sessionID).pipe(
|
||||||
Effect.catchTag("Session.NotFoundError", (error) =>
|
Effect.catchTag("Session.NotFoundError", (error) =>
|
||||||
Effect.fail(
|
Effect.fail(
|
||||||
new SessionNotFoundError({
|
new SessionNotFoundError({
|
||||||
@@ -149,58 +198,5 @@ export const sessionHandlers = HttpApiBuilder.group(InstanceHttpApi, "v2.session
|
|||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.handle(
|
|
||||||
"compact",
|
|
||||||
Effect.fn(function* (ctx) {
|
|
||||||
yield* session
|
|
||||||
.compact(ctx.params.sessionID)
|
|
||||||
.pipe(
|
|
||||||
Effect.catchTag("Session.NotFoundError", (error) =>
|
|
||||||
Effect.fail(
|
|
||||||
new SessionNotFoundError({
|
|
||||||
sessionID: error.sessionID,
|
|
||||||
message: `Session not found: ${error.sessionID}`,
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
return HttpApiSchema.NoContent.make()
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.handle(
|
|
||||||
"wait",
|
|
||||||
Effect.fn(function* (ctx) {
|
|
||||||
yield* session
|
|
||||||
.wait(ctx.params.sessionID)
|
|
||||||
.pipe(
|
|
||||||
Effect.catchTag("Session.NotFoundError", (error) =>
|
|
||||||
Effect.fail(
|
|
||||||
new SessionNotFoundError({
|
|
||||||
sessionID: error.sessionID,
|
|
||||||
message: `Session not found: ${error.sessionID}`,
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
return HttpApiSchema.NoContent.make()
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.handle(
|
|
||||||
"context",
|
|
||||||
Effect.fn(function* (ctx) {
|
|
||||||
return yield* session
|
|
||||||
.context(ctx.params.sessionID)
|
|
||||||
.pipe(
|
|
||||||
Effect.catchTag("Session.NotFoundError", (error) =>
|
|
||||||
Effect.fail(
|
|
||||||
new SessionNotFoundError({
|
|
||||||
sessionID: error.sessionID,
|
|
||||||
message: `Session not found: ${error.sessionID}`,
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1823,6 +1823,12 @@ export type UnauthorizedError = {
|
|||||||
message: string
|
message: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type SessionNotFoundError = {
|
||||||
|
_tag: "SessionNotFoundError"
|
||||||
|
sessionID: string
|
||||||
|
message: string
|
||||||
|
}
|
||||||
|
|
||||||
export type V2SessionMessagesResponse = {
|
export type V2SessionMessagesResponse = {
|
||||||
items: Array<SessionMessage>
|
items: Array<SessionMessage>
|
||||||
cursor: {
|
cursor: {
|
||||||
@@ -7174,6 +7180,10 @@ export type V2SessionPromptErrors = {
|
|||||||
* UnauthorizedError
|
* UnauthorizedError
|
||||||
*/
|
*/
|
||||||
401: UnauthorizedError
|
401: UnauthorizedError
|
||||||
|
/**
|
||||||
|
* SessionNotFoundError
|
||||||
|
*/
|
||||||
|
404: SessionNotFoundError
|
||||||
}
|
}
|
||||||
|
|
||||||
export type V2SessionPromptError = V2SessionPromptErrors[keyof V2SessionPromptErrors]
|
export type V2SessionPromptError = V2SessionPromptErrors[keyof V2SessionPromptErrors]
|
||||||
@@ -7208,6 +7218,10 @@ export type V2SessionCompactErrors = {
|
|||||||
* UnauthorizedError
|
* UnauthorizedError
|
||||||
*/
|
*/
|
||||||
401: UnauthorizedError
|
401: UnauthorizedError
|
||||||
|
/**
|
||||||
|
* SessionNotFoundError
|
||||||
|
*/
|
||||||
|
404: SessionNotFoundError
|
||||||
}
|
}
|
||||||
|
|
||||||
export type V2SessionCompactError = V2SessionCompactErrors[keyof V2SessionCompactErrors]
|
export type V2SessionCompactError = V2SessionCompactErrors[keyof V2SessionCompactErrors]
|
||||||
@@ -7242,6 +7256,10 @@ export type V2SessionWaitErrors = {
|
|||||||
* UnauthorizedError
|
* UnauthorizedError
|
||||||
*/
|
*/
|
||||||
401: UnauthorizedError
|
401: UnauthorizedError
|
||||||
|
/**
|
||||||
|
* SessionNotFoundError
|
||||||
|
*/
|
||||||
|
404: SessionNotFoundError
|
||||||
}
|
}
|
||||||
|
|
||||||
export type V2SessionWaitError = V2SessionWaitErrors[keyof V2SessionWaitErrors]
|
export type V2SessionWaitError = V2SessionWaitErrors[keyof V2SessionWaitErrors]
|
||||||
@@ -7276,6 +7294,10 @@ export type V2SessionContextErrors = {
|
|||||||
* UnauthorizedError
|
* UnauthorizedError
|
||||||
*/
|
*/
|
||||||
401: UnauthorizedError
|
401: UnauthorizedError
|
||||||
|
/**
|
||||||
|
* SessionNotFoundError
|
||||||
|
*/
|
||||||
|
404: SessionNotFoundError
|
||||||
}
|
}
|
||||||
|
|
||||||
export type V2SessionContextError = V2SessionContextErrors[keyof V2SessionContextErrors]
|
export type V2SessionContextError = V2SessionContextErrors[keyof V2SessionContextErrors]
|
||||||
@@ -7316,6 +7338,10 @@ export type V2SessionMessagesErrors = {
|
|||||||
* UnauthorizedError
|
* UnauthorizedError
|
||||||
*/
|
*/
|
||||||
401: UnauthorizedError
|
401: UnauthorizedError
|
||||||
|
/**
|
||||||
|
* SessionNotFoundError
|
||||||
|
*/
|
||||||
|
404: SessionNotFoundError
|
||||||
}
|
}
|
||||||
|
|
||||||
export type V2SessionMessagesError = V2SessionMessagesErrors[keyof V2SessionMessagesErrors]
|
export type V2SessionMessagesError = V2SessionMessagesErrors[keyof V2SessionMessagesErrors]
|
||||||
|
|||||||
@@ -8217,6 +8217,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "SessionNotFoundError",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/SessionNotFoundError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"description": "Create a v2 session message and queue it for the agent loop.",
|
"description": "Create a v2 session message and queue it for the agent loop.",
|
||||||
@@ -8303,6 +8313,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "SessionNotFoundError",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/SessionNotFoundError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"description": "Compact a v2 session conversation.",
|
"description": "Compact a v2 session conversation.",
|
||||||
@@ -8370,6 +8390,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "SessionNotFoundError",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/SessionNotFoundError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"description": "Wait for a v2 session agent loop to become idle.",
|
"description": "Wait for a v2 session agent loop to become idle.",
|
||||||
@@ -8447,6 +8477,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "SessionNotFoundError",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/SessionNotFoundError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"description": "Retrieve the active context messages for a v2 session (all messages after the last compaction).",
|
"description": "Retrieve the active context messages for a v2 session (all messages after the last compaction).",
|
||||||
@@ -8554,6 +8594,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "SessionNotFoundError",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/SessionNotFoundError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"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.",
|
"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 @@
|
|||||||
"required": ["_tag", "message"],
|
"required": ["_tag", "message"],
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
},
|
},
|
||||||
|
"SessionNotFoundError": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"_tag": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["SessionNotFoundError"]
|
||||||
|
},
|
||||||
|
"sessionID": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"message": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["_tag", "sessionID", "message"],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
"V2SessionMessagesResponse": {
|
"V2SessionMessagesResponse": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
Reference in New Issue
Block a user