import { Agent } from "../agent/Agent"; import type { WireObject } from "../agent/wire"; import { Tool } from "../tools/Tool"; export declare const AGENTS_FILE = "agents.json"; export declare const TOOLS_FILE = "tools.json"; export declare const AGENT_CONFIGS_DIR = "agent_configs"; export declare const TOOL_CONFIGS_DIR = "tool_configs"; /** One entry in `agents.json`, as the CLI writes it. */ export interface AgentEntry { /** Path to the agent's config file, relative to the project root. */ config: string; id?: string; branch_id?: string; version_id?: string; branches?: Record; } /** One entry in `tools.json`, as the CLI writes it. */ export interface ToolEntry { /** `"webhook"` or `"client"`. */ type: string; /** Path to the tool's config file, relative to the project root. */ config: string; id?: string; } /** Thrown when a project's files can't be read: a missing or malformed file, or a format the SDK can't read yet. */ export declare class AgentProjectError extends Error { constructor(message: string); } interface AgentSlot { entry: AgentEntry; agent: Agent; } interface ToolSlot { entry: ToolEntry; tool: Tool; /** The config as loaded, in API format, sent as-is while the tool is unchanged so unmodeled fields survive. */ raw?: WireObject; /** `tool.toJSON()` as loaded, to tell whether the tool was edited since. */ baseline?: string; } /** * An agents-as-code project in the CLI's layout: `agents.json` and `tools.json` list the agents and tools with their * ids, and each one's config sits in `agent_configs/` or `tool_configs/` in API format. A project made by * `elevenlabs agents init` / `pull` works here, and one written here works with the CLI. * * Pass it to `agents.push(agent, { project })` and `agents.pull(agentId, { project })`: the project records which * agent and tools on the server each definition is, so pushing again updates them instead of making copies. * * @example * const project = await AgentProject.open("."); * const agent = project.agent("Support line"); * agent.update({ prompt: "..." }); * await client.conversationalAi.agents.push(agent, { project }); */ export declare class AgentProject { /** The directory the project was opened from, if any. `save()` writes there. */ readonly dir: string | undefined; private readonly _files; private readonly _agents; private readonly _tools; /** Paths written since loading, with their new contents. */ private readonly _changed; /** Paths in use on disk, so new files don't overwrite one the project doesn't list. */ private readonly _taken; /** @internal */ constructor(files: Record, dir?: string, taken?: Iterable); /** * A project from file contents, keyed by path relative to the project root. Only `agents.json`, `tools.json` and * the config files they list are read. Missing index files mean an empty project. */ static fromFiles(files: Record): AgentProject; /** * Reads the project in `dir` (Node.js only). A directory without `agents.json` and `tools.json` opens as an empty * project, and `save()` creates them. */ static open(dir: string): Promise; /** Every agent in the project, in `agents.json` order. */ agents(): Agent[]; /** * The agent named `name`. The same object every time, so edits to it are what `agents.push(agent, { project })` * sends. * * @throws {AgentProjectError} if no agent, or more than one, has that name */ agent(name: string): Agent; /** Every tool in `tools.json`, in order. */ tools(): Tool[]; /** The id `agents.json` records for this agent, if it was pushed or pulled. */ agentId(agent: Agent): string | undefined; /** The id `tools.json` records for this tool, if it was pushed or pulled. */ toolId(tool: Tool): string | undefined; /** * The project's files, keyed by path: the index files and every config they list, with what push and pull wrote * since loading. Files nothing changed keep their exact text. */ toFiles(): Record; /** The paths push and pull changed since the project was loaded or last saved. */ get changedFiles(): string[]; /** * Writes the files push and pull changed to the project's directory (Node.js only). `agents.push()` and * `agents.pull()` call this themselves for a project opened with `open()`. */ save(): Promise; /** @internal The entry for an agent: the one it was loaded from, else the only one with its name. */ _agentSlot(agent: Agent): AgentSlot | undefined; /** @internal The entry for a tool: the one it was loaded from, else the only one with its name. */ _toolSlot(tool: Tool): ToolSlot | undefined; /** * @internal The loaded config to send for a tool whose definition matches its project entry (the loaded object, or * one rebuilt in code with the same name), so fields this SDK doesn't model survive. */ _unchangedRaw(tool: Tool): WireObject | undefined; /** * @internal Records a tool's id and the config now on the server, adding an entry if it's new. Push finds the * entry by definition; pull, by id. */ _recordTool(tool: Tool, id: string, config: WireObject, matchBy?: "definition" | "id"): void; /** @internal Records an agent's id and its config, adding an entry if it's new. Push matches like `_recordTool`. */ _recordAgent(agent: Agent, id: string, config: WireObject, options?: { branchId?: string; versionId?: string; matchBy?: "definition" | "id"; }): void; /** * @internal Rejects a branch the project has no file for, before anything is written: its settings would otherwise * land in the main branch's file, and a later CLI push would send them to the main branch. */ _checkBranch(agent: Agent, branchId: string | undefined): void; /** @internal `_checkBranch` for `pull`, which finds the agent by id. */ _checkBranchById(agentId: string, branchId: string | undefined): void; private _checkBranchOf; private _write; private _load; private _readIndex; private _readConfig; private _agentsIndex; private _toolsIndex; } export {};