import "./tool-display-B7qTeoCS.js";
import "./paths-D4_LjrY7.js";
import "./utils-BnlaT0eO.js";
import "./theme-CG-K7m8u.js";
import "./thinking-CKGMvVgd.js";
import { _ as spawnSubagentDirect } from "./reply-DbpXq1MH.js";
import "./subsystem-ocBR131w.js";
import "./runtime-CRvfzclG.js";
import "./exec-CZr_EJHt.js";
import "./agent-scope-CVnlY0oG.js";
import "./model-selection-p6J3l4qF.js";
import "./github-copilot-token-CjSKohyA.js";
import "./emitter-oHo8y9ow.js";
import "./sqlite-wYNyDR1B.js";
import "./reliability-Dl7hbRzF.js";
import "./boolean-DGGu1sGA.js";
import "./env-CvUd308i.js";
import "./validation-p1IK70TM.js";
import "./config-DJ3A5x_1.js";
import "./manifest-registry-U2EDFVP4.js";
import "./runner-BZrNCxMY.js";
import "./image-tool.helpers-tqRivaKA.js";
import "./models-config-DLUtus3b.js";
import "./pi-model-discovery-4-XyjjxG.js";
import "./pi-embedded-utils-BraP32ED.js";
import "./redact-DcYCKU6u.js";
import "./pi-embedded-helpers-CLkeTWAT.js";
import "./sandbox-C5rKvtrA.js";
import "./chrome-BQkAVfz8.js";
import "./tailscale-CcUMoDkd.js";
import "./auth-BxKMeEw-.js";
import "./server-context-s_zNpSdX.js";
import "./frontmatter-VFr0KMAQ.js";
import "./skills-CHYyY1lO.js";
import "./routes-CT0DmotX.js";
import "./errors-DbYSuCgv.js";
import "./paths-Ct4sqLyX.js";
import "./ssrf-tneKFjA6.js";
import "./image-ops-C0D77XHD.js";
import "./store-Cdm3Z5cQ.js";
import "./ports-DvLDsgl0.js";
import "./trash-BRBQoy9m.js";
import "./sessions-Ct2d_bGl.js";
import "./message-channel-DSU96OKy.js";
import "./dock-DY0TWaYa.js";
import "./normalize-DgwtBdm-.js";
import "./accounts-BZv5WxME.js";
import "./accounts-DFaskvEN.js";
import "./accounts-T7o73ZSN.js";
import "./bindings-BbaWTQJM.js";
import "./logging-wfRfbMvt.js";
import "./client-36a9DTBg.js";
import "./plugins-DYgcd4QJ.js";
import "./targets-qjNLO5UC.js";
import "./paths-DRyRQF9o.js";
import "./tool-images-CRPqucMe.js";
import "./image-Dx_UDO2W.js";
import "./fetch-guard-C12KgXTM.js";
import "./api-key-rotation-Bl9Larnz.js";
import "./fetch-Dy3Y7lWo.js";
import "./session-files-DroWN-X3.js";
import "./model-catalog-DyP7lvDH.js";
import "./tokens-DuLZdp8u.js";
import "./heartbeat-BJ0mtjXV.js";
import "./helpers-DAXsRcXO.js";
import "./targets-D3Hd_LiZ.js";
import "./with-timeout-BeRjsuGt.js";
import "./diagnostic-Ct9JySKv.js";
import "./diagnostic-session-state-CjvcsE8F.js";
import "./lanes-s-MZ35vD.js";
import "./reply-payloads-Idpqh_HL.js";
import "./route-reply-C3GnJgPP.js";
import "./tts-pLGM3rbp.js";
import "./audio-Cf4_M2_g.js";
import "./model-p-v6-khS.js";
import "./chat-trace-DE0u11RV.js";
import "./response-prefix-template-ZNVQwQzJ.js";
import "./tool-tracking-BeyzFfAx.js";
import "./memory-cli-D_iCajsu.js";
import "./manager-Be4wtySp.js";
import "./retry-BR_e19Qc.js";
import "./hybrid-oFciuzzr.js";
import { a as jsonResult, u as readStringParam } from "./common-oaZdjdal.js";
import "./send-BFMLircB.js";
import "./chunk-CF0Wb8FK.js";
import "./markdown-tables-BkkSACKz.js";
import "./media-Ce9mjBUa.js";
import "./ir-DDJn3mJR.js";
import "./render-Cz3PVxTW.js";
import "./commands-registry-CvAV0O7w.js";
import "./client-DNPnFy4E.js";
import "./call-C206Z-zx.js";
import "./sessions-helpers-DYJnJN3U.js";
import "./external-content-CNcZgk3W.js";
import "./send-BQth8hb0.js";
import "./channel-activity-C8K3u-iy.js";
import "./fetch-CdBeMr8t.js";
import "./tables-GfMspQYU.js";
import "./server-startup-users-Bb0MWaNU.js";
import "./resolve-route-D-YVS8mL.js";
import "./pairing-store-Z_SXyT9W.js";
import "./replies-AgkcH9tU.js";
import "./reply-prefix-DB7HiPpn.js";
import "./workspace-dirs-C1v5ssUA.js";
import "./skill-commands-vM7RDRiG.js";
import "./pi-tools.policy-C7_kjOAN.js";
import "./send-BKH82oGz.js";
import "./onboard-helpers-B0CkVZ2U.js";
import "./prompt-style-D4OL61iD.js";
import "./onboard-helpers-BvqKOAqv.js";
import "./outbound-attachment-DzzKBoks.js";
import "./targets-B17-mYQK.js";
import "./pairing-labels-BoIZlK5l.js";
import "./send-C5tjqyuP.js";
import "./session-cost-usage-UDBgjJvw.js";
import "./send-XU_khFvN.js";
import "./proxy-CjhP7CG1.js";
import "./links-G4gKCCcI.js";
import "./cli-utils-Cps3tWFt.js";
import "./help-format-DukcHIxz.js";
import "./progress-WmzCxxhb.js";
import "./active-listener-CEwpUvTV.js";
import "./exec-approvals-C7AUcy3J.js";
import "./gateway-DKSm1BrZ.js";
import "./nodes-utils-yMGpHJYN.js";
import "./model-fallback-BPqOLk8z.js";
import "./typed-schema-4lv655ii.js";
import "./knowledge-graph-D4-b38d_.js";
import { r as optionalStringEnum } from "./typebox-BNGTpPE2.js";
import { Type } from "@sinclair/typebox";

//#region src/agents/tools/sessions/sessions-spawn-tool.ts
const SessionsSpawnToolSchema = Type.Object({
	task: Type.String(),
	label: Type.Optional(Type.String()),
	agentId: Type.Optional(Type.String()),
	model: Type.Optional(Type.String()),
	thinking: Type.Optional(Type.String()),
	template: Type.Optional(Type.String()),
	runTimeoutSeconds: Type.Optional(Type.Number({ minimum: 0 })),
	timeoutSeconds: Type.Optional(Type.Number({ minimum: 0 })),
	cleanup: optionalStringEnum(["delete", "keep"])
});
function createSessionsSpawnTool(opts) {
	return {
		label: "Sessions",
		name: "sessions_spawn",
		description: "Spawn a session with another agent or a sub-agent. Use agentId to target a specific agent (e.g. agentId='carla_bot'). The spawned agent runs the given task and announces results back. Use this when you want to talk to or delegate work to another agent on the gateway.",
		parameters: SessionsSpawnToolSchema,
		execute: async (_toolCallId, args) => {
			const params = args;
			const task = readStringParam(params, "task", { required: true });
			const label = typeof params.label === "string" ? params.label.trim() : "";
			const requestedAgentId = readStringParam(params, "agentId");
			const modelOverride = readStringParam(params, "model");
			const thinkingOverrideRaw = readStringParam(params, "thinking");
			const templateName = readStringParam(params, "template");
			const cleanup = params.cleanup === "keep" || params.cleanup === "delete" ? params.cleanup : "keep";
			const timeoutSecondsCandidate = typeof params.runTimeoutSeconds === "number" ? params.runTimeoutSeconds : typeof params.timeoutSeconds === "number" ? params.timeoutSeconds : void 0;
			return jsonResult(await spawnSubagentDirect({
				task,
				label: label || void 0,
				agentId: requestedAgentId,
				model: modelOverride,
				thinking: thinkingOverrideRaw,
				template: templateName,
				runTimeoutSeconds: typeof timeoutSecondsCandidate === "number" && Number.isFinite(timeoutSecondsCandidate) ? Math.max(0, Math.floor(timeoutSecondsCandidate)) : void 0,
				cleanup,
				expectsCompletionMessage: true
			}, {
				agentSessionKey: opts?.agentSessionKey,
				agentChannel: opts?.agentChannel,
				agentAccountId: opts?.agentAccountId,
				agentTo: opts?.agentTo,
				agentThreadId: opts?.agentThreadId,
				agentGroupId: opts?.agentGroupId,
				agentGroupChannel: opts?.agentGroupChannel,
				agentGroupSpace: opts?.agentGroupSpace,
				requesterAgentIdOverride: opts?.requesterAgentIdOverride
			}));
		}
	};
}

//#endregion
export { createSessionsSpawnTool };