import "./pi-embedded-utils-CPkknmhn.js";
import "./paths-BVqcPirq.js";
import { t as createSubsystemLogger } from "./subsystem-CBhYrL33.js";
import "./exec-DJFSSNca.js";
import { C as ensureAgentWorkspace, c as resolveAgentWorkspaceDir, r as resolveAgentDir, u as resolveSessionAgentId } from "./agent-scope-BzfnY0io.js";
import { $ as DEFAULT_MODEL, et as DEFAULT_PROVIDER, m as resolveThinkingDefault } from "./model-selection-C249ZOnu.js";
import { i as resolveAgentIdentity } from "./response-prefix-template-CUxsjWM3.js";
import "./hybrid-0SH6eiv4.js";
import "./sqlite-DUluVPN0.js";
import { n as createKnowledgeGraphTools, t as KnowledgeGraphSession } from "./knowledge-graph-Czaa5Qlk.js";
import "./config-CCV5uD38.js";
import "./pi-embedded-helpers-DeAatnaU.js";
import "./chat-trace-586uSnqt.js";
import "./manifest-registry-UHh68MLw.js";
import { $ as runEmbeddedPiAgent, Q as resolveAgentTimeoutMs, t as resolvePluginTools } from "./tools-B5lBxhIt.js";
import "./reliability-CdCvEXPM.js";
import "./send-BsHWR0r1.js";
import "./tool-tracking-D1HWsfb6.js";
import "./manager-SXNS5Id-.js";
import "./redact-Bd6ytMDA.js";
import "./errors-3Ywmlvcu.js";
import "./github-copilot-token-CDLg4MOs.js";
import "./env-CNGYrGXP.js";
import "./gemini-auth-DN_apfBL.js";
import "./session-files-BUcenoTs.js";
import "./retry-BPq5kcyX.js";
import { n as resolveSessionFilePath, s as resolveStorePath } from "./paths-DKqd8NBB.js";
import "./image-ops-CkVtcgS9.js";
import "./tool-images-tBLbhG0w.js";
import "./common-D7lLwt9D.js";
import "./accounts-B804h91p.js";
import "./normalize-C-uc4MlX.js";
import "./replies-CBLkcSfT.js";
import "./targets-Cn2eLkjl.js";
import "./chunk-Yn3En_fz.js";
import "./message-channel-B5UwhWVn.js";
import "./bindings-Dob3ua1b.js";
import "./plugins-BBDtlgEl.js";
import "./helpers-BZiqjMxc.js";
import "./markdown-tables-PVZnUZW7.js";
import "./ssrf-BPZndZer.js";
import "./fetch-guard-DkWDyNHr.js";
import "./fetch-D-HE1qU2.js";
import "./media-IKchB7_u.js";
import "./ir-DmyUuTXh.js";
import "./render-D8ijUhi5.js";
import "./dock-DkvmDNZE.js";
import "./commands-registry-BDgdcyjq.js";
import "./thinking-z4_linel.js";
import "./tokens-CFbBnfQY.js";
import "./heartbeat-DMphKxXr.js";
import "./diagnostic-CGUvOJ7B.js";
import "./diagnostic-session-state-BC3ofBSx.js";
import "./lanes-DagJGRd8.js";
import "./route-reply-Ck5Q_wn4.js";
import "./tts-B7WgbKJ9.js";
import "./pi-model-discovery-DGABDrxC.js";
import "./chrome-B4N0bMCd.js";
import "./server-context-Az6ygVCq.js";
import "./skills-BEdkiMY1.js";
import { i as loadSessionStore, s as saveSessionStore } from "./sessions-ByypVr-c.js";
import "./image-tool.helpers-D7iUmlqH.js";
import "./call-BliLbuG-.js";
import "./gateway-CKFg1Dnv.js";
import "./nodes-utils-BKzhXH7q.js";
import { c as resolveWorkspaceRoot } from "./model-fallback-BWc7ddLG.js";
import "./runner-s3AgbzXc.js";
import "./resolve-route-twk0QWtH.js";
import "./sessions-helpers-CoESOybi.js";
import "./external-content-Ptl4MUui.js";
import "./image-BTygPHlb.js";
import "./skill-commands-DzyG2UOD.js";
import "./active-listener-D2wRal7F.js";
import "./reply-prefix-E3WnxiPD.js";
import "./proxy-te6-RByu.js";
import { n as createAgentsListTool } from "./agents-list-tool-BQ6ls41Z.js";
import "./client-CN9Ndlef.js";
import { n as createBrowserTool } from "./browser-tool-BOx6MV7_.js";
import "./typebox-Dqngjw-j.js";
import "./nodes-camera-VOSANyOd.js";
import { n as createCanvasTool } from "./canvas-tool-DnIWg7wo.js";
import { t as createCronTool } from "./cron-tool-BA0MTe_Z.js";
import { t as createGatewayTool } from "./gateway-tool-BGaZ_eCb.js";
import { t as createImageTool } from "./image-tool-Cj0MSjoB.js";
import { t as createMessageTool } from "./message-tool-DsMDf-tO.js";
import "./deliver-DACUBWDa.js";
import { t as createNodesTool } from "./nodes-tool-BwzNqfZ3.js";
import { t as createSessionStatusTool } from "./session-status-tool-BSEWLrOF.js";
import { t as createSessionsHistoryTool } from "./sessions-history-tool-CSgK-0Dg.js";
import { t as createSessionsListTool } from "./sessions-list-tool-Bqa9nXjY.js";
import { t as createSessionsSendTool } from "./sessions-send-tool-Dju2WqTR.js";
import { t as createSessionsSpawnTool } from "./sessions-spawn-tool-BGjZEZME.js";
import { t as createSubagentsTool } from "./subagents-tool-Bjk4_5Eu.js";
import { t as createTtsTool } from "./tts-tool-DMZG0r4M.js";
import { t as createWebFetchTool } from "./web-fetch-BI2e7v7i.js";
import { t as createWebSearchTool } from "./web-search-CRp8OEtE.js";

//#region src/agents/minion-tools.ts
const log = createSubsystemLogger("agents/tools");
function createOpenClawTools(options) {
	const workspaceDir = resolveWorkspaceRoot(options?.workspaceDir);
	const agentId = resolveSessionAgentId({
		sessionKey: options?.agentSessionKey,
		config: options?.config
	});
	let kgSession;
	try {
		kgSession = KnowledgeGraphSession.forAgent(agentId);
	} catch (err) {
		log.warn(`KG DB open failed for agent ${agentId}: ${String(err)}`);
	}
	const imageTool = options?.agentDir?.trim() ? createImageTool({
		config: options?.config,
		agentDir: options.agentDir,
		workspaceDir,
		sandbox: options?.sandboxRoot && options?.sandboxFsBridge ? {
			root: options.sandboxRoot,
			bridge: options.sandboxFsBridge
		} : void 0,
		modelHasVision: options?.modelHasVision
	}) : null;
	const webSearchTool = createWebSearchTool({
		config: options?.config,
		sandboxed: options?.sandboxed
	});
	const webFetchTool = createWebFetchTool({
		config: options?.config,
		sandboxed: options?.sandboxed
	});
	const messageTool = options?.disableMessageTool ? null : createMessageTool({
		agentAccountId: options?.agentAccountId,
		agentSessionKey: options?.agentSessionKey,
		config: options?.config,
		currentChannelId: options?.currentChannelId,
		currentChannelProvider: options?.agentChannel,
		currentThreadTs: options?.currentThreadTs,
		replyToMode: options?.replyToMode,
		hasRepliedRef: options?.hasRepliedRef,
		sandboxRoot: options?.sandboxRoot,
		requireExplicitTarget: options?.requireExplicitMessageTarget
	});
	const tools = [
		createBrowserTool({
			sandboxBridgeUrl: options?.sandboxBrowserBridgeUrl,
			allowHostControl: options?.allowHostBrowserControl
		}),
		createCanvasTool(),
		createNodesTool({
			agentSessionKey: options?.agentSessionKey,
			config: options?.config
		}),
		createCronTool({ agentSessionKey: options?.agentSessionKey }),
		...messageTool ? [messageTool] : [],
		createTtsTool({
			agentChannel: options?.agentChannel,
			config: options?.config
		}),
		createGatewayTool({
			agentSessionKey: options?.agentSessionKey,
			config: options?.config
		}),
		createAgentsListTool({
			agentSessionKey: options?.agentSessionKey,
			requesterAgentIdOverride: options?.requesterAgentIdOverride
		}),
		createSessionsListTool({
			agentSessionKey: options?.agentSessionKey,
			sandboxed: options?.sandboxed
		}),
		createSessionsHistoryTool({
			agentSessionKey: options?.agentSessionKey,
			sandboxed: options?.sandboxed
		}),
		createSessionsSendTool({
			agentSessionKey: options?.agentSessionKey,
			agentChannel: options?.agentChannel,
			sandboxed: options?.sandboxed
		}),
		createSessionsSpawnTool({
			agentSessionKey: options?.agentSessionKey,
			agentChannel: options?.agentChannel,
			agentAccountId: options?.agentAccountId,
			agentTo: options?.agentTo,
			agentThreadId: options?.agentThreadId,
			agentGroupId: options?.agentGroupId,
			agentGroupChannel: options?.agentGroupChannel,
			agentGroupSpace: options?.agentGroupSpace,
			sandboxed: options?.sandboxed,
			requesterAgentIdOverride: options?.requesterAgentIdOverride
		}),
		createSubagentsTool({ agentSessionKey: options?.agentSessionKey }),
		createSessionStatusTool({
			agentSessionKey: options?.agentSessionKey,
			config: options?.config
		}),
		...webSearchTool ? [webSearchTool] : [],
		...webFetchTool ? [webFetchTool] : [],
		...imageTool ? [imageTool] : [],
		...createKnowledgeGraphTools(kgSession)
	];
	const pluginTools = resolvePluginTools({
		context: {
			config: options?.config,
			workspaceDir,
			agentDir: options?.agentDir,
			agentId,
			sessionKey: options?.agentSessionKey,
			messageChannel: options?.agentChannel,
			agentAccountId: options?.agentAccountId,
			sandboxed: options?.sandboxed
		},
		existingToolNames: new Set(tools.map((tool) => tool.name)),
		toolAllowlist: options?.pluginToolAllowlist
	});
	return [...tools, ...pluginTools];
}

//#endregion
export { DEFAULT_MODEL, DEFAULT_PROVIDER, createOpenClawTools, ensureAgentWorkspace, loadSessionStore, resolveAgentDir, resolveAgentIdentity, resolveAgentTimeoutMs, resolveAgentWorkspaceDir, resolveSessionFilePath, resolveStorePath, resolveThinkingDefault, runEmbeddedPiAgent, saveSessionStore };