diff --git a/src/index.ts b/src/index.ts index c0880e7..f62517d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,6 +12,16 @@ import { join } from "path"; import { existsSync } from "fs"; import { DatabaseSync } from "node:sqlite"; +// Type for command invocation +interface CommandInvocation { + sessionID: string; + prompt: { + text: string; + // other prompt properties + }; + delivery: "steer" | "queue"; +} + interface Session { id: string; project_id: string; @@ -123,25 +133,28 @@ export default define({ id: "oc-session-all", async setup(ctx) { - console.log("[oc-session-all] V2 plugin loaded, registering tool..."); + console.log("[oc-session-all] V2 plugin loaded, registering command..."); - // Register the sessions-all tool - await ctx.tool.transform((editor) => { + // Register the sessions-all command + await ctx.command.transform((editor) => { editor.add({ name: "sessions-all", description: "显示所有项目的会话记录,绕过目录过滤限制。Show all sessions from all projects.", - input: {}, // No input parameters required - async execute(input) { - console.log("[oc-session-all] Tool executed"); + async execute(invocation: CommandInvocation) { + console.log("[oc-session-all] Command executed"); const sessions = getAllSessionsFromDb(); const output = formatSessions(sessions); - return { - content: output, - }; + + // Send the output as a prompt to the session + await ctx.session.prompt({ + sessionID: invocation.sessionID, + text: output, + delivery: invocation.delivery, + }); }, }); }); - console.log("[oc-session-all] Tool registered successfully"); + console.log("[oc-session-all] Command registered successfully"); }, }); \ No newline at end of file