feat(core): port v2 command invocation (#34849)

This commit is contained in:
Aiden Cline 2026-07-02 11:22:04 -05:00 committed by GitHub
commit c176baee82
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 1445 additions and 179 deletions

View file

@ -6,6 +6,8 @@ import { Api } from "../api"
import { SessionsCursor } from "@opencode-ai/protocol/groups/session"
import {
ConflictError,
CommandEvaluationError,
CommandNotFoundError,
InvalidCursorError,
MessageNotFoundError,
ServiceUnavailableError,
@ -216,6 +218,60 @@ export const SessionHandler = HttpApiBuilder.group(Api, "server.session", (handl
}
}),
)
.handle(
"session.command",
Effect.fn(function* (ctx) {
return {
data: yield* session
.command({
sessionID: ctx.params.sessionID,
id: ctx.payload.id,
command: ctx.payload.command,
arguments: ctx.payload.arguments,
agent: ctx.payload.agent,
model: ctx.payload.model,
files: ctx.payload.files,
agents: ctx.payload.agents,
delivery: ctx.payload.delivery,
resume: ctx.payload.resume,
})
.pipe(
Effect.catchTag("Session.NotFoundError", (error) =>
Effect.fail(
new SessionNotFoundError({
sessionID: error.sessionID,
message: `Session not found: ${error.sessionID}`,
}),
),
),
Effect.catchTag("Command.NotFoundError", (error) =>
Effect.fail(
new CommandNotFoundError({
command: error.command,
message: error.message,
}),
),
),
Effect.catchTag("Command.EvaluationError", (error) =>
Effect.fail(
new CommandEvaluationError({
command: error.command,
message: error.message,
}),
),
),
Effect.catchTag("Session.PromptConflictError", (error) =>
Effect.fail(
new ConflictError({
message: `Prompt message ID conflicts with an existing durable record: ${error.messageID}`,
resource: error.messageID,
}),
),
),
),
}
}),
)
.handle(
"session.skill",
Effect.fn(function* (ctx) {