summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-10-06 18:51:57 -0400
committerDax Raad <[email protected]>2025-10-06 18:51:57 -0400
commit6417edf99806b5aa93625622ba1726feae1a11fd (patch)
treed78622554ffc86b99c94b9d60aeb21732c75535f
parent9a0735de76bd43743073263a13408a1791f26fd1 (diff)
downloadopencode-6417edf99806b5aa93625622ba1726feae1a11fd.tar.gz
opencode-6417edf99806b5aa93625622ba1726feae1a11fd.zip
Add todo list and session forking API endpoints
-rw-r--r--packages/opencode/src/server/server.ts60
1 files changed, 60 insertions, 0 deletions
diff --git a/packages/opencode/src/server/server.ts b/packages/opencode/src/server/server.ts
index 7020a2aaa..cba186dd9 100644
--- a/packages/opencode/src/server/server.ts
+++ b/packages/opencode/src/server/server.ts
@@ -29,7 +29,9 @@ import { SessionPrompt } from "../session/prompt"
import { SessionCompaction } from "../session/compaction"
import { SessionRevert } from "../session/revert"
import { lazy } from "../util/lazy"
+import { Todo } from "../session/todo"
import { InstanceBootstrap } from "../project/bootstrap"
+import { Identifier } from "@/id/id"
const ERRORS = {
400: {
@@ -343,6 +345,34 @@ export namespace Server {
return c.json(session)
},
)
+ .get(
+ "/session/:id/todo",
+ describeRoute({
+ description: "Get the todo list for a session",
+ operationId: "session.todo",
+ responses: {
+ 200: {
+ description: "Todo list",
+ content: {
+ "application/json": {
+ schema: resolver(Todo.Info.array()),
+ },
+ },
+ },
+ },
+ }),
+ validator(
+ "param",
+ z.object({
+ id: z.string().meta({ description: "Session ID" }),
+ }),
+ ),
+ async (c) => {
+ const sessionID = c.req.valid("param").id
+ const todos = await Todo.get(sessionID)
+ return c.json(todos)
+ },
+ )
.post(
"/session",
describeRoute({
@@ -481,6 +511,36 @@ export namespace Server {
},
)
.post(
+ "/session/:id/fork",
+ describeRoute({
+ description: "Fork an existing session at a specific message",
+ operationId: "session.fork",
+ responses: {
+ 200: {
+ description: "200",
+ content: {
+ "application/json": {
+ schema: resolver(Session.Info),
+ },
+ },
+ },
+ },
+ }),
+ validator(
+ "param",
+ z.object({
+ id: Identifier.schema("session").meta({ description: "Session ID" }),
+ }),
+ ),
+ validator("json", Session.fork.schema.omit({ sessionID: true })),
+ async (c) => {
+ const sessionID = c.req.valid("param").id
+ const body = c.req.valid("json")
+ const result = await Session.fork({ ...body, sessionID })
+ return c.json(result)
+ },
+ )
+ .post(
"/session/:id/abort",
describeRoute({
description: "Abort a session",