import { tool } from "@opencode-ai/plugin";
import { createRun, getActiveRun, getRun } from "../../features/run-state/index.js";
import { sanitizeJson } from "../../shared/index.js";
export async function requireSeedRun(store, context, runId) {
    const existing = await getRun(store, runId);
    if (existing)
        return existing;
    const active = await getActiveRun(store);
    if (active && !runId) {
        const run = await getRun(store, active.run_id);
        if (run)
            return run;
    }
    return createRun(store, {
        goal: "Ad hoc SEED tool run",
        sessionId: context.sessionID,
    });
}
export function jsonToolOutput(title, value) {
    return { title, output: JSON.stringify(value, null, 2), metadata: sanitizeJson(value) };
}
export function activeRunArg() {
    return tool.schema.string().optional().describe("Run id. Defaults to the active SEED run.");
}
//# sourceMappingURL=common.js.map