import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
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/session-end.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;
    const client = new DaemonClient(VAULT_DIR);
    if (sessionId) {
      await client.post("/sessions/unregister", { session_id: sessionId });
    }
  } catch (error) {
    process.stderr.write(`[myco] session-end error: ${error.message}
`);
  }
}
main();
//# sourceMappingURL=session-end.js.map