import { init_workspace_path, normalizeWorkspaceDir } from "../config/workspace-path.js";
import { init_agent_scope, resolveUserPath } from "../agent/agent-scope.js";
import { resolveEffectiveAgentProfileForSession } from "../config/agent-profile.js";
//#region src/session/session-workspace.ts
init_agent_scope();
init_workspace_path();
/**
* Normalize user input for `workingDirectoryOverride`. Rejects empty and filesystem roots.
*/
function normalizeWorkingDirectoryInput(raw) {
	const trimmed = raw.trim();
	if (!trimmed) return {
		ok: false,
		error: "working directory is empty"
	};
	const normalized = normalizeWorkspaceDir(resolveUserPath(trimmed));
	if (!normalized) return {
		ok: false,
		error: "invalid working directory path"
	};
	return {
		ok: true,
		path: normalized
	};
}
/**
* Resolved markdown workspace for tools/shell: session override or merged agent profile default.
*/
function effectiveWorkspacePathForSession(cfg, sessionKey, sessionAgentConfig) {
	const base = resolveEffectiveAgentProfileForSession(cfg, sessionKey).resolvedWorkspacePath;
	const o = sessionAgentConfig?.workingDirectoryOverride?.trim();
	if (!o) return base;
	return normalizeWorkspaceDir(resolveUserPath(o)) ?? base;
}
//#endregion
export { effectiveWorkspacePathForSession, normalizeWorkingDirectoryInput };

//# sourceMappingURL=session-workspace.js.map