|
|
@@ -26,6 +26,7 @@ import { errors } from "../error"
|
|
|
import { lazy } from "../../util/lazy"
|
|
|
import { Bus } from "../../bus"
|
|
|
import { NamedError } from "@opencode-ai/shared/util/error"
|
|
|
+import { jsonRequest } from "./trace"
|
|
|
|
|
|
const log = Log.create({ service: "server" })
|
|
|
|
|
|
@@ -94,10 +95,11 @@ export const SessionRoutes = lazy(() =>
|
|
|
...errors(400),
|
|
|
},
|
|
|
}),
|
|
|
- async (c) => {
|
|
|
- const result = await AppRuntime.runPromise(SessionStatus.Service.use((svc) => svc.list()))
|
|
|
- return c.json(Object.fromEntries(result))
|
|
|
- },
|
|
|
+ async (c) =>
|
|
|
+ jsonRequest("SessionRoutes.status", c, function* () {
|
|
|
+ const svc = yield* SessionStatus.Service
|
|
|
+ return Object.fromEntries(yield* svc.list())
|
|
|
+ }),
|
|
|
)
|
|
|
.get(
|
|
|
"/:sessionID",
|
|
|
@@ -126,8 +128,10 @@ export const SessionRoutes = lazy(() =>
|
|
|
),
|
|
|
async (c) => {
|
|
|
const sessionID = c.req.valid("param").sessionID
|
|
|
- const session = await AppRuntime.runPromise(Session.Service.use((svc) => svc.get(sessionID)))
|
|
|
- return c.json(session)
|
|
|
+ return jsonRequest("SessionRoutes.get", c, function* () {
|
|
|
+ const session = yield* Session.Service
|
|
|
+ return yield* session.get(sessionID)
|
|
|
+ })
|
|
|
},
|
|
|
)
|
|
|
.get(
|
|
|
@@ -157,8 +161,10 @@ export const SessionRoutes = lazy(() =>
|
|
|
),
|
|
|
async (c) => {
|
|
|
const sessionID = c.req.valid("param").sessionID
|
|
|
- const session = await AppRuntime.runPromise(Session.Service.use((svc) => svc.children(sessionID)))
|
|
|
- return c.json(session)
|
|
|
+ return jsonRequest("SessionRoutes.children", c, function* () {
|
|
|
+ const session = yield* Session.Service
|
|
|
+ return yield* session.children(sessionID)
|
|
|
+ })
|
|
|
},
|
|
|
)
|
|
|
.get(
|
|
|
@@ -187,8 +193,10 @@ export const SessionRoutes = lazy(() =>
|
|
|
),
|
|
|
async (c) => {
|
|
|
const sessionID = c.req.valid("param").sessionID
|
|
|
- const todos = await AppRuntime.runPromise(Todo.Service.use((svc) => svc.get(sessionID)))
|
|
|
- return c.json(todos)
|
|
|
+ return jsonRequest("SessionRoutes.todo", c, function* () {
|
|
|
+ const todo = yield* Todo.Service
|
|
|
+ return yield* todo.get(sessionID)
|
|
|
+ })
|
|
|
},
|
|
|
)
|
|
|
.post(
|