import { z } from "zod";
import { tool } from "@anthropic-ai/claude-agent-sdk";
import { getActiveSession } from "../agent/mailbox.js";
export const switchSessionTool = tool("switch_session", `Switch between the general and coding sessions. Use this when a message or task belongs in the other session.

- Switch to "coding" when you receive a task that requires sustained multi-step coding work (refactoring, debugging, feature implementation, etc.).
- Switch to "general" when you are in the coding session and receive an unrelated message (chat, question, status check, simple task), or when the coding task is complete.

The memo field is passed to the other session as context. Include enough detail for the other session to understand what's happening (e.g. the user's request, current progress, decisions made).

The reason field signals intent:
- "handoff": Temporarily hand off to the other session (e.g. forwarding an unrelated message). The coding session remains active and can be resumed.
- "complete": The coding task is finished. Use this when switching coding→general after completing the task.

After calling this tool, end your turn immediately — the system will resume the target session.`, {
    target: z
        .enum(["general", "coding"])
        .describe('The session to switch to: "general" or "coding"'),
    memo: z
        .string()
        .describe("Context memo for the target session explaining what it needs to know"),
    reason: z
        .enum(["handoff", "complete"])
        .default("handoff")
        .describe('"handoff" for temporary switch, "complete" when the coding task is finished'),
    forward_message: z
        .string()
        .optional()
        .describe("The user message to forward to the target session (if any)"),
    cwd: z
        .string()
        .optional()
        .describe("Working directory for the coding session. When switching to coding, pass the absolute path of the project directory so Bash commands default to that location."),
}, (args) => {
    const currentSession = getActiveSession();
    if (args.target === currentSession) {
        return Promise.resolve({
            content: [
                {
                    type: "text",
                    text: `You are already in the ${currentSession} session. No switch needed — continue working in the current session.`,
                },
            ],
        });
    }
    return Promise.resolve({
        content: [
            {
                type: "text",
                text: `Switching to ${args.target} session (reason: ${args.reason}). Memo: ${args.memo}\n\nIMPORTANT: The session switch is being processed. End your turn immediately — do NOT call any more tools.`,
            },
        ],
    });
});
//# sourceMappingURL=switch-session.js.map