import "./paths-D7t4DWPT.js";
import "./registry-BAroooHo.js";
import { c as resolveDefaultAgentId, r as resolveAgentDir, s as resolveAgentWorkspaceDir } from "./agent-scope-vwdi_iPU.js";
import "./subsystem-CT4qQN_5.js";
import "./workspace-BfiC270B.js";
import "./replies-CJI7bTwf.js";
import { t as runEmbeddedPiAgent } from "./pi-embedded-esdL_uIH.js";
import "./plugins-CKverisB.js";
import "./accounts-D_f61n_2.js";
import "./boolean-B8-BqKGQ.js";
import "./command-format-B1Qy0nEy.js";
import "./bindings-B2zCGVlh.js";
import "./send-vFbB1oyW.js";
import "./send-D9deKfXG.js";
import "./accounts-DjS9pck5.js";
import "./send-BcbXsRYf.js";
import "./fetch-zQFnmTQp.js";
import "./model-auth-JizwQYrQ.js";
import "./runner-C1FeLLBX.js";
import "./message-channel-B2_fQxU-.js";
import "./config-CuIQfnYC.js";
import "./chrome-D1MdAC58.js";
import "./frontmatter-DeJqLCGD.js";
import "./redact-CvtgU1ru.js";
import "./errors-DTJD7QVU.js";
import "./store-CHKRvmCy.js";
import "./accounts-D0MI8r0c.js";
import "./paths-DPyv1NZk.js";
import "./gemini-auth-BkihAcak.js";
import "./tool-images-CN0uVQmf.js";
import "./reply-prefix-iAma0Qkf.js";
import "./manager-C4a-cmap.js";
import "./sqlite-BMqXhBTv.js";
import "./retry-uzmocd9P.js";
import "./common-Cq4cGI7g.js";
import "./chunk-DURdKVm7.js";
import "./markdown-tables-CpPOBj_4.js";
import "./ir-CrIjysE5.js";
import "./render-BDQg502o.js";
import "./send-CUOB2x8m.js";
import "./outbound-attachment-D9LojwCI.js";
import "./fetch-C6gLETXy.js";
import "./send-B_dAoGjq.js";
import "./resolve-route-DdEto-MF.js";
import "./channel-activity-CYXdIJlC.js";
import "./tables-JCssucvN.js";
import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";

//#region src/hooks/llm-slug-generator.ts
/**
* LLM-based slug generator for session memory filenames
*/
/**
* Generate a short 1-2 word filename slug from session content using LLM
*/
async function generateSlugViaLLM(params) {
	let tempSessionFile = null;
	try {
		const agentId = resolveDefaultAgentId(params.cfg);
		const workspaceDir = resolveAgentWorkspaceDir(params.cfg, agentId);
		const agentDir = resolveAgentDir(params.cfg, agentId);
		const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "coderclaw-slug-"));
		tempSessionFile = path.join(tempDir, "session.jsonl");
		const prompt = `Based on this conversation, generate a short 1-2 word filename slug (lowercase, hyphen-separated, no file extension).

Conversation summary:
${params.sessionContent.slice(0, 2e3)}

Reply with ONLY the slug, nothing else. Examples: "vendor-pitch", "api-design", "bug-fix"`;
		const result = await runEmbeddedPiAgent({
			sessionId: `slug-generator-${Date.now()}`,
			sessionKey: "temp:slug-generator",
			agentId,
			sessionFile: tempSessionFile,
			workspaceDir,
			agentDir,
			config: params.cfg,
			prompt,
			timeoutMs: 15e3,
			runId: `slug-gen-${Date.now()}`
		});
		if (result.payloads && result.payloads.length > 0) {
			const text = result.payloads[0]?.text;
			if (text) return text.trim().toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").slice(0, 30) || null;
		}
		return null;
	} catch (err) {
		console.error("[llm-slug-generator] Failed to generate slug:", err);
		return null;
	} finally {
		if (tempSessionFile) try {
			await fs.rm(path.dirname(tempSessionFile), {
				recursive: true,
				force: true
			});
		} catch {}
	}
}

//#endregion
export { generateSlugViaLLM };