import { a as multiEdit, b as shell, i as readFile, n as createSpawnTool, o as listFiles, p as waitTask, r as shellKill, t as writeFile, u as edit } from "./tools-NxnEmzYg.js";
//#region src/presets/basic.ts
/**
* Core tools available in every basic preset (without spawn).
*
* `edit` and `multi_edit` ship in the basic set because surgical edits are the
* default modality for production agents — `write_file` is for full overwrites.
* `glob` and `grep` are exported but opt-in: not every agent needs codebase
* search, and shipping them by default would force `tool:gate` work onto
* consumers that prefer the model to use `shell` + classic Unix tools.
*/
const basicTools = {
	shell,
	shellKill,
	waitTask,
	readFile,
	writeFile,
	listFiles,
	edit,
	multiEdit
};
var basic_default = definePreset({
	name: "basic",
	system: "You are a helpful assistant with access to shell, file reading, file writing, surgical and multi-edit tools, directory listing, and sub-agent spawning. Prefer `edit` / `multi_edit` for in-place changes and `write_file` for full file overwrites. Use them to accomplish tasks in the project directory.",
	get tools() {
		return {
			...basicTools,
			spawn: createSpawnTool({ persist: true })
		};
	}
});
//#endregion
//#region src/presets/index.ts
/**
* Identity helper for type inference when defining a preset.
*/
function definePreset(config) {
	return config;
}
/**
* Field-aware composition of presets. Right-most preset wins for scalar fields;
* objects shallow-merge; arrays and hook handler lists concatenate. Designed so
* stacking presets does the obvious thing without the spread-collision footgun:
*
* - `name`, `system`, `eager`, `skills`              → last-defined wins
* - `tools`, `toolAliases`, `behavior`               → shallow-merge (later keys override)
* - `behavior.dedupTools`, `behavior.toolBudgets`    → **deep-merge** (per-tool-name; later wins on collision)
* - `mcpServers`                                     → concat with last-wins on `name` collision
* - `hooks`                                          → per-event concat; every handler fires
*
* `hooks` always emerges as `event → handler[]` so downstream registration
* (in `createAgent`) sees a uniform shape. Order of handlers within an event
* follows preset order: earlier presets register first.
*
* `mcpServers` is deduped by `name` because shipping two servers with the same
* name would trip the connector at runtime — a later preset overriding an
* earlier preset's `github` server is the practical intent.
*
* `behavior.dedupTools` and `behavior.toolBudgets` get the same per-key deep-merge
* because they are tool-name-keyed records — a preset that ships a dedup hasher
* for one tool should not erase a hasher another preset ships for a different
* tool. Last-wins still applies on a per-tool collision so a downstream preset
* can override an upstream preset's policy for one specific tool. Other
* `behavior` fields keep last-wins semantics.
*/
function composePresets(...presets) {
	const out = {};
	const hooksByEvent = {};
	const mcpByName = /* @__PURE__ */ new Map();
	for (const p of presets) {
		if (p.name !== void 0) out.name = p.name;
		if (p.system !== void 0) out.system = p.system;
		if (p.eager !== void 0) out.eager = p.eager;
		if (p.skills !== void 0) out.skills = p.skills;
		if (p.tools) out.tools = {
			...out.tools,
			...p.tools
		};
		if (p.toolAliases) out.toolAliases = {
			...out.toolAliases,
			...p.toolAliases
		};
		if (p.behavior) {
			const merged = {
				...out.behavior,
				...p.behavior
			};
			if (out.behavior?.dedupTools || p.behavior.dedupTools) merged.dedupTools = {
				...out.behavior?.dedupTools,
				...p.behavior.dedupTools
			};
			if (out.behavior?.toolBudgets || p.behavior.toolBudgets) merged.toolBudgets = {
				...out.behavior?.toolBudgets,
				...p.behavior.toolBudgets
			};
			out.behavior = merged;
		}
		if (p.mcpServers) for (const server of p.mcpServers) mcpByName.set(server.name, server);
		if (p.hooks) for (const [event, handler] of Object.entries(p.hooks)) {
			if (handler === void 0) continue;
			const list = Array.isArray(handler) ? handler : [handler];
			const key = event;
			(hooksByEvent[key] ??= []).push(...list);
		}
	}
	if (mcpByName.size > 0) out.mcpServers = [...mcpByName.values()];
	if (Object.keys(hooksByEvent).length > 0) out.hooks = hooksByEvent;
	return out;
}
//#endregion
export { basic_default as i, definePreset as n, basicTools as r, composePresets as t };

//# sourceMappingURL=presets-Cm2BPJaU.js.map