import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
import {
  loadConfig
} from "../../chunk-YG6MLLGL.js";
import "../../chunk-JSK7L46L.js";
import {
  readStdin
} from "../../chunk-CQ4RKK67.js";
import {
  DaemonClient
} from "../../chunk-CPVXNRGW.js";
import "../../chunk-CK24O5YQ.js";
import {
  resolveVaultDir
} from "../../chunk-N33KUCFP.js";
import "../../chunk-RNWALAFP.js";
import "../../chunk-WBLTISAK.js";
import "../../chunk-PZUWP5VK.js";

// src/hooks/stop.ts
import fs from "fs";
import path from "path";
async function main() {
  const VAULT_DIR = resolveVaultDir();
  if (!fs.existsSync(path.join(VAULT_DIR, "myco.yaml"))) return;
  try {
    const input = JSON.parse(await readStdin());
    const sessionId = input.session_id ?? process.env.MYCO_SESSION_ID;
    if (!sessionId) return;
    const config = loadConfig(VAULT_DIR);
    const client = new DaemonClient(VAULT_DIR);
    await client.ensureRunning({ checkStale: false });
    await client.post("/events/stop", {
      session_id: sessionId,
      user: config.team.user || void 0,
      transcript_path: input.transcript_path,
      last_assistant_message: input.last_assistant_message
    });
  } catch (error) {
    process.stderr.write(`[myco] stop error: ${error.message}
`);
  }
}
main();
//# sourceMappingURL=stop.js.map