slash commands (#2157)

Co-authored-by: adamdotdevin <2363879+adamdottv@users.noreply.github.com>
This commit is contained in:
Dax
2025-08-22 17:04:28 -04:00
committed by GitHub
parent 74c1085103
commit 133fe41cd5
32 changed files with 874 additions and 69 deletions

View File

@@ -21,6 +21,7 @@ import { Permission } from "../permission"
import { lazy } from "../util/lazy"
import { Agent } from "../agent/agent"
import { Auth } from "../auth"
import { Command } from "../command"
const ERRORS = {
400: {
@@ -611,10 +612,12 @@ export namespace Server {
description: "Created message",
content: {
"application/json": {
schema: resolver(z.object({
schema: resolver(
z.object({
info: MessageV2.Assistant,
parts: MessageV2.Part.array(),
})),
}),
),
},
},
},
@@ -634,6 +637,41 @@ export namespace Server {
return c.json(msg)
},
)
.post(
"/session/:id/command",
describeRoute({
description: "Send a new command to a session",
operationId: "session.command",
responses: {
200: {
description: "Created message",
content: {
"application/json": {
schema: resolver(
z.object({
info: MessageV2.Assistant,
parts: MessageV2.Part.array(),
}),
),
},
},
},
},
}),
zValidator(
"param",
z.object({
id: z.string().openapi({ description: "Session ID" }),
}),
),
zValidator("json", Session.CommandInput.omit({ sessionID: true })),
async (c) => {
const sessionID = c.req.valid("param").id
const body = c.req.valid("json")
const msg = await Session.command({ ...body, sessionID })
return c.json(msg)
},
)
.post(
"/session/:id/shell",
describeRoute({
@@ -656,7 +694,7 @@ export namespace Server {
id: z.string().openapi({ description: "Session ID" }),
}),
),
zValidator("json", Session.CommandInput.omit({ sessionID: true })),
zValidator("json", Session.ShellInput.omit({ sessionID: true })),
async (c) => {
const sessionID = c.req.valid("param").id
const body = c.req.valid("json")
@@ -753,6 +791,27 @@ export namespace Server {
return c.json(true)
},
)
.get(
"/command",
describeRoute({
description: "List all commands",
operationId: "command.list",
responses: {
200: {
description: "List of commands",
content: {
"application/json": {
schema: resolver(Command.Info.array()),
},
},
},
},
}),
async (c) => {
const commands = await Command.list()
return c.json(commands)
},
)
.get(
"/config/providers",
describeRoute({