|
@@ -23,6 +23,7 @@ import { PermissionID } from "@/permission/schema"
|
|
|
import { ModelID, ProviderID } from "@/provider/schema"
|
|
import { ModelID, ProviderID } from "@/provider/schema"
|
|
|
import { errors } from "../../error"
|
|
import { errors } from "../../error"
|
|
|
import { lazy } from "@/util/lazy"
|
|
import { lazy } from "@/util/lazy"
|
|
|
|
|
+import { zodObject } from "@/util/effect-zod"
|
|
|
import { Bus } from "@/bus"
|
|
import { Bus } from "@/bus"
|
|
|
import { NamedError } from "@opencode-ai/shared/util/error"
|
|
import { NamedError } from "@opencode-ai/shared/util/error"
|
|
|
import { jsonRequest, runRequest } from "./trace"
|
|
import { jsonRequest, runRequest } from "./trace"
|
|
@@ -42,7 +43,7 @@ export const SessionRoutes = lazy(() =>
|
|
|
description: "List of sessions",
|
|
description: "List of sessions",
|
|
|
content: {
|
|
content: {
|
|
|
"application/json": {
|
|
"application/json": {
|
|
|
- schema: resolver(Session.Info.array()),
|
|
|
|
|
|
|
+ schema: resolver(Session.Info.zod.array()),
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
@@ -87,7 +88,7 @@ export const SessionRoutes = lazy(() =>
|
|
|
description: "Get session status",
|
|
description: "Get session status",
|
|
|
content: {
|
|
content: {
|
|
|
"application/json": {
|
|
"application/json": {
|
|
|
- schema: resolver(z.record(z.string(), SessionStatus.Info)),
|
|
|
|
|
|
|
+ schema: resolver(z.record(z.string(), SessionStatus.Info.zod)),
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
@@ -112,7 +113,7 @@ export const SessionRoutes = lazy(() =>
|
|
|
description: "Get session",
|
|
description: "Get session",
|
|
|
content: {
|
|
content: {
|
|
|
"application/json": {
|
|
"application/json": {
|
|
|
- schema: resolver(Session.Info),
|
|
|
|
|
|
|
+ schema: resolver(Session.Info.zod),
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
@@ -122,7 +123,7 @@ export const SessionRoutes = lazy(() =>
|
|
|
validator(
|
|
validator(
|
|
|
"param",
|
|
"param",
|
|
|
z.object({
|
|
z.object({
|
|
|
- sessionID: Session.GetInput,
|
|
|
|
|
|
|
+ sessionID: Session.GetInput.zod,
|
|
|
}),
|
|
}),
|
|
|
),
|
|
),
|
|
|
async (c) => {
|
|
async (c) => {
|
|
@@ -145,7 +146,7 @@ export const SessionRoutes = lazy(() =>
|
|
|
description: "List of children",
|
|
description: "List of children",
|
|
|
content: {
|
|
content: {
|
|
|
"application/json": {
|
|
"application/json": {
|
|
|
- schema: resolver(Session.Info.array()),
|
|
|
|
|
|
|
+ schema: resolver(Session.Info.zod.array()),
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
@@ -155,7 +156,7 @@ export const SessionRoutes = lazy(() =>
|
|
|
validator(
|
|
validator(
|
|
|
"param",
|
|
"param",
|
|
|
z.object({
|
|
z.object({
|
|
|
- sessionID: Session.ChildrenInput,
|
|
|
|
|
|
|
+ sessionID: Session.ChildrenInput.zod,
|
|
|
}),
|
|
}),
|
|
|
),
|
|
),
|
|
|
async (c) => {
|
|
async (c) => {
|
|
@@ -177,7 +178,7 @@ export const SessionRoutes = lazy(() =>
|
|
|
description: "Todo list",
|
|
description: "Todo list",
|
|
|
content: {
|
|
content: {
|
|
|
"application/json": {
|
|
"application/json": {
|
|
|
- schema: resolver(Todo.Info.array()),
|
|
|
|
|
|
|
+ schema: resolver(Todo.Info.zod.array()),
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
@@ -210,13 +211,13 @@ export const SessionRoutes = lazy(() =>
|
|
|
description: "Successfully created session",
|
|
description: "Successfully created session",
|
|
|
content: {
|
|
content: {
|
|
|
"application/json": {
|
|
"application/json": {
|
|
|
- schema: resolver(Session.Info),
|
|
|
|
|
|
|
+ schema: resolver(Session.Info.zod),
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
}),
|
|
}),
|
|
|
- validator("json", Session.CreateInput),
|
|
|
|
|
|
|
+ validator("json", Session.CreateInput.zod),
|
|
|
async (c) =>
|
|
async (c) =>
|
|
|
jsonRequest("SessionRoutes.create", c, function* () {
|
|
jsonRequest("SessionRoutes.create", c, function* () {
|
|
|
const body = c.req.valid("json") ?? {}
|
|
const body = c.req.valid("json") ?? {}
|
|
@@ -245,7 +246,7 @@ export const SessionRoutes = lazy(() =>
|
|
|
validator(
|
|
validator(
|
|
|
"param",
|
|
"param",
|
|
|
z.object({
|
|
z.object({
|
|
|
- sessionID: Session.RemoveInput,
|
|
|
|
|
|
|
+ sessionID: Session.RemoveInput.zod,
|
|
|
}),
|
|
}),
|
|
|
),
|
|
),
|
|
|
async (c) =>
|
|
async (c) =>
|
|
@@ -267,7 +268,7 @@ export const SessionRoutes = lazy(() =>
|
|
|
description: "Successfully updated session",
|
|
description: "Successfully updated session",
|
|
|
content: {
|
|
content: {
|
|
|
"application/json": {
|
|
"application/json": {
|
|
|
- schema: resolver(Session.Info),
|
|
|
|
|
|
|
+ schema: resolver(Session.Info.zod),
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
@@ -375,7 +376,7 @@ export const SessionRoutes = lazy(() =>
|
|
|
description: "200",
|
|
description: "200",
|
|
|
content: {
|
|
content: {
|
|
|
"application/json": {
|
|
"application/json": {
|
|
|
- schema: resolver(Session.Info),
|
|
|
|
|
|
|
+ schema: resolver(Session.Info.zod),
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
@@ -384,14 +385,14 @@ export const SessionRoutes = lazy(() =>
|
|
|
validator(
|
|
validator(
|
|
|
"param",
|
|
"param",
|
|
|
z.object({
|
|
z.object({
|
|
|
- sessionID: Session.ForkInput.shape.sessionID,
|
|
|
|
|
|
|
+ sessionID: SessionID.zod,
|
|
|
}),
|
|
}),
|
|
|
),
|
|
),
|
|
|
- validator("json", Session.ForkInput.omit({ sessionID: true })),
|
|
|
|
|
|
|
+ validator("json", zodObject(Session.ForkInput).omit({ sessionID: true })),
|
|
|
async (c) =>
|
|
async (c) =>
|
|
|
jsonRequest("SessionRoutes.fork", c, function* () {
|
|
jsonRequest("SessionRoutes.fork", c, function* () {
|
|
|
const sessionID = c.req.valid("param").sessionID
|
|
const sessionID = c.req.valid("param").sessionID
|
|
|
- const body = c.req.valid("json")
|
|
|
|
|
|
|
+ const body = c.req.valid("json") as { messageID?: MessageID }
|
|
|
const svc = yield* Session.Service
|
|
const svc = yield* Session.Service
|
|
|
return yield* svc.fork({ ...body, sessionID })
|
|
return yield* svc.fork({ ...body, sessionID })
|
|
|
}),
|
|
}),
|
|
@@ -438,7 +439,7 @@ export const SessionRoutes = lazy(() =>
|
|
|
description: "Successfully shared session",
|
|
description: "Successfully shared session",
|
|
|
content: {
|
|
content: {
|
|
|
"application/json": {
|
|
"application/json": {
|
|
|
- schema: resolver(Session.Info),
|
|
|
|
|
|
|
+ schema: resolver(Session.Info.zod),
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
@@ -480,18 +481,13 @@ export const SessionRoutes = lazy(() =>
|
|
|
validator(
|
|
validator(
|
|
|
"param",
|
|
"param",
|
|
|
z.object({
|
|
z.object({
|
|
|
- sessionID: SessionSummary.DiffInput.shape.sessionID,
|
|
|
|
|
- }),
|
|
|
|
|
- ),
|
|
|
|
|
- validator(
|
|
|
|
|
- "query",
|
|
|
|
|
- z.object({
|
|
|
|
|
- messageID: SessionSummary.DiffInput.shape.messageID,
|
|
|
|
|
|
|
+ sessionID: SessionID.zod,
|
|
|
}),
|
|
}),
|
|
|
),
|
|
),
|
|
|
|
|
+ validator("query", zodObject(SessionSummary.DiffInput).omit({ sessionID: true })),
|
|
|
async (c) =>
|
|
async (c) =>
|
|
|
jsonRequest("SessionRoutes.diff", c, function* () {
|
|
jsonRequest("SessionRoutes.diff", c, function* () {
|
|
|
- const query = c.req.valid("query")
|
|
|
|
|
|
|
+ const query = c.req.valid("query") as Omit<SessionSummary.DiffInput, "sessionID">
|
|
|
const params = c.req.valid("param")
|
|
const params = c.req.valid("param")
|
|
|
const summary = yield* SessionSummary.Service
|
|
const summary = yield* SessionSummary.Service
|
|
|
return yield* summary.diff({
|
|
return yield* summary.diff({
|
|
@@ -511,7 +507,7 @@ export const SessionRoutes = lazy(() =>
|
|
|
description: "Successfully unshared session",
|
|
description: "Successfully unshared session",
|
|
|
content: {
|
|
content: {
|
|
|
"application/json": {
|
|
"application/json": {
|
|
|
- schema: resolver(Session.Info),
|
|
|
|
|
|
|
+ schema: resolver(Session.Info.zod),
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
@@ -872,7 +868,7 @@ export const SessionRoutes = lazy(() =>
|
|
|
sessionID: SessionID.zod,
|
|
sessionID: SessionID.zod,
|
|
|
}),
|
|
}),
|
|
|
),
|
|
),
|
|
|
- validator("json", SessionPrompt.PromptInput.omit({ sessionID: true })),
|
|
|
|
|
|
|
+ validator("json", zodObject(SessionPrompt.PromptInput).omit({ sessionID: true })),
|
|
|
async (c) => {
|
|
async (c) => {
|
|
|
c.status(200)
|
|
c.status(200)
|
|
|
c.header("Content-Type", "application/json")
|
|
c.header("Content-Type", "application/json")
|
|
@@ -910,7 +906,7 @@ export const SessionRoutes = lazy(() =>
|
|
|
sessionID: SessionID.zod,
|
|
sessionID: SessionID.zod,
|
|
|
}),
|
|
}),
|
|
|
),
|
|
),
|
|
|
- validator("json", SessionPrompt.PromptInput.omit({ sessionID: true })),
|
|
|
|
|
|
|
+ validator("json", zodObject(SessionPrompt.PromptInput).omit({ sessionID: true })),
|
|
|
async (c) => {
|
|
async (c) => {
|
|
|
const sessionID = c.req.valid("param").sessionID
|
|
const sessionID = c.req.valid("param").sessionID
|
|
|
const body = c.req.valid("json")
|
|
const body = c.req.valid("json")
|
|
@@ -960,11 +956,11 @@ export const SessionRoutes = lazy(() =>
|
|
|
sessionID: SessionID.zod,
|
|
sessionID: SessionID.zod,
|
|
|
}),
|
|
}),
|
|
|
),
|
|
),
|
|
|
- validator("json", SessionPrompt.CommandInput.omit({ sessionID: true })),
|
|
|
|
|
|
|
+ validator("json", zodObject(SessionPrompt.CommandInput).omit({ sessionID: true })),
|
|
|
async (c) =>
|
|
async (c) =>
|
|
|
jsonRequest("SessionRoutes.command", c, function* () {
|
|
jsonRequest("SessionRoutes.command", c, function* () {
|
|
|
const sessionID = c.req.valid("param").sessionID
|
|
const sessionID = c.req.valid("param").sessionID
|
|
|
- const body = c.req.valid("json")
|
|
|
|
|
|
|
+ const body = c.req.valid("json") as Omit<SessionPrompt.CommandInput, "sessionID">
|
|
|
const svc = yield* SessionPrompt.Service
|
|
const svc = yield* SessionPrompt.Service
|
|
|
return yield* svc.command({ ...body, sessionID })
|
|
return yield* svc.command({ ...body, sessionID })
|
|
|
}),
|
|
}),
|
|
@@ -993,11 +989,11 @@ export const SessionRoutes = lazy(() =>
|
|
|
sessionID: SessionID.zod,
|
|
sessionID: SessionID.zod,
|
|
|
}),
|
|
}),
|
|
|
),
|
|
),
|
|
|
- validator("json", SessionPrompt.ShellInput.omit({ sessionID: true })),
|
|
|
|
|
|
|
+ validator("json", zodObject(SessionPrompt.ShellInput).omit({ sessionID: true })),
|
|
|
async (c) =>
|
|
async (c) =>
|
|
|
jsonRequest("SessionRoutes.shell", c, function* () {
|
|
jsonRequest("SessionRoutes.shell", c, function* () {
|
|
|
const sessionID = c.req.valid("param").sessionID
|
|
const sessionID = c.req.valid("param").sessionID
|
|
|
- const body = c.req.valid("json")
|
|
|
|
|
|
|
+ const body = c.req.valid("json") as Omit<SessionPrompt.ShellInput, "sessionID">
|
|
|
const svc = yield* SessionPrompt.Service
|
|
const svc = yield* SessionPrompt.Service
|
|
|
return yield* svc.shell({ ...body, sessionID })
|
|
return yield* svc.shell({ ...body, sessionID })
|
|
|
}),
|
|
}),
|
|
@@ -1013,7 +1009,7 @@ export const SessionRoutes = lazy(() =>
|
|
|
description: "Updated session",
|
|
description: "Updated session",
|
|
|
content: {
|
|
content: {
|
|
|
"application/json": {
|
|
"application/json": {
|
|
|
- schema: resolver(Session.Info),
|
|
|
|
|
|
|
+ schema: resolver(Session.Info.zod),
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
@@ -1026,16 +1022,14 @@ export const SessionRoutes = lazy(() =>
|
|
|
sessionID: SessionID.zod,
|
|
sessionID: SessionID.zod,
|
|
|
}),
|
|
}),
|
|
|
),
|
|
),
|
|
|
- validator("json", SessionRevert.RevertInput.omit({ sessionID: true })),
|
|
|
|
|
|
|
+ validator("json", zodObject(SessionRevert.RevertInput).omit({ sessionID: true })),
|
|
|
async (c) => {
|
|
async (c) => {
|
|
|
const sessionID = c.req.valid("param").sessionID
|
|
const sessionID = c.req.valid("param").sessionID
|
|
|
- log.info("revert", c.req.valid("json"))
|
|
|
|
|
|
|
+ const body = c.req.valid("json") as Omit<SessionRevert.RevertInput, "sessionID">
|
|
|
|
|
+ log.info("revert", body)
|
|
|
return jsonRequest("SessionRoutes.revert", c, function* () {
|
|
return jsonRequest("SessionRoutes.revert", c, function* () {
|
|
|
const svc = yield* SessionRevert.Service
|
|
const svc = yield* SessionRevert.Service
|
|
|
- return yield* svc.revert({
|
|
|
|
|
- sessionID,
|
|
|
|
|
- ...c.req.valid("json"),
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ return yield* svc.revert({ sessionID, ...body })
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
)
|
|
)
|
|
@@ -1050,7 +1044,7 @@ export const SessionRoutes = lazy(() =>
|
|
|
description: "Updated session",
|
|
description: "Updated session",
|
|
|
content: {
|
|
content: {
|
|
|
"application/json": {
|
|
"application/json": {
|
|
|
- schema: resolver(Session.Info),
|
|
|
|
|
|
|
+ schema: resolver(Session.Info.zod),
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|