import { BaseClient } from "../base.js";
//#region src/client/assistants/index.ts
var AssistantsClient = class extends BaseClient {
	/**
	* Get an assistant by ID.
	*
	* @param assistantId The ID of the assistant.
	* @returns Assistant
	*/
	async get(assistantId, options) {
		return this.fetch(`/assistants/${assistantId}`, { signal: options?.signal });
	}
	/**
	* Get the JSON representation of the graph assigned to a runnable
	* @param assistantId The ID of the assistant.
	* @param options.xray Whether to include subgraphs in the serialized graph representation. If an integer value is provided, only subgraphs with a depth less than or equal to the value will be included.
	* @returns Serialized graph
	*/
	async getGraph(assistantId, options) {
		return this.fetch(`/assistants/${assistantId}/graph`, {
			params: { xray: options?.xray },
			signal: options?.signal
		});
	}
	/**
	* Get the state and config schema of the graph assigned to a runnable
	* @param assistantId The ID of the assistant.
	* @returns Graph schema
	*/
	async getSchemas(assistantId, options) {
		return this.fetch(`/assistants/${assistantId}/schemas`, { signal: options?.signal });
	}
	/**
	* Get the schemas of an assistant by ID.
	*
	* @param assistantId The ID of the assistant to get the schema of.
	* @param options Additional options for getting subgraphs, such as namespace or recursion extraction.
	* @returns The subgraphs of the assistant.
	*/
	async getSubgraphs(assistantId, options) {
		if (options?.namespace) return this.fetch(`/assistants/${assistantId}/subgraphs/${options.namespace}`, {
			params: { recurse: options?.recurse },
			signal: options?.signal
		});
		return this.fetch(`/assistants/${assistantId}/subgraphs`, {
			params: { recurse: options?.recurse },
			signal: options?.signal
		});
	}
	/**
	* Create a new assistant.
	* @param payload Payload for creating an assistant.
	* @returns The created assistant.
	*/
	async create(payload) {
		return this.fetch("/assistants", {
			method: "POST",
			json: {
				graph_id: payload.graphId,
				config: payload.config,
				context: payload.context,
				metadata: payload.metadata,
				assistant_id: payload.assistantId,
				if_exists: payload.ifExists,
				name: payload.name,
				description: payload.description
			},
			signal: payload.signal
		});
	}
	/**
	* Update an assistant.
	* @param assistantId ID of the assistant.
	* @param payload Payload for updating the assistant.
	* @returns The updated assistant.
	*/
	async update(assistantId, payload) {
		return this.fetch(`/assistants/${assistantId}`, {
			method: "PATCH",
			json: {
				graph_id: payload.graphId,
				config: payload.config,
				context: payload.context,
				metadata: payload.metadata,
				name: payload.name,
				description: payload.description
			},
			signal: payload.signal
		});
	}
	/**
	* Delete an assistant.
	*
	* @param assistantId ID of the assistant.
	* @param deleteThreads If true, delete all threads with `metadata.assistant_id` equal to `assistantId`. Defaults to false.
	*/
	async delete(assistantId, options) {
		return this.fetch(`/assistants/${assistantId}?delete_threads=${options?.deleteThreads ?? false}`, {
			method: "DELETE",
			signal: options?.signal
		});
	}
	async search(query) {
		const json = {
			graph_id: query?.graphId ?? void 0,
			name: query?.name ?? void 0,
			metadata: query?.metadata ?? void 0,
			limit: query?.limit ?? 10,
			offset: query?.offset ?? 0,
			sort_by: query?.sortBy ?? void 0,
			sort_order: query?.sortOrder ?? void 0,
			select: query?.select ?? void 0
		};
		const [assistants, response] = await this.fetch("/assistants/search", {
			method: "POST",
			json,
			withResponse: true,
			signal: query?.signal
		});
		if (query?.includePagination) return {
			assistants,
			next: response.headers.get("X-Pagination-Next")
		};
		return assistants;
	}
	/**
	* Count assistants matching filters.
	*
	* @param query.metadata Metadata to filter by. Exact match for each key/value.
	* @param query.graphId Optional graph id to filter by.
	* @param query.name Optional name to filter by.
	* @returns Number of assistants matching the criteria.
	*/
	async count(query) {
		return this.fetch(`/assistants/count`, {
			method: "POST",
			json: {
				metadata: query?.metadata ?? void 0,
				graph_id: query?.graphId ?? void 0,
				name: query?.name ?? void 0
			},
			signal: query?.signal
		});
	}
	/**
	* List all versions of an assistant.
	*
	* @param assistantId ID of the assistant.
	* @returns List of assistant versions.
	*/
	async getVersions(assistantId, payload) {
		return this.fetch(`/assistants/${assistantId}/versions`, {
			method: "POST",
			json: {
				metadata: payload?.metadata ?? void 0,
				limit: payload?.limit ?? 10,
				offset: payload?.offset ?? 0
			},
			signal: payload?.signal
		});
	}
	/**
	* Change the version of an assistant.
	*
	* @param assistantId ID of the assistant.
	* @param version The version to change to.
	* @returns The updated assistant.
	*/
	async setLatest(assistantId, version, options) {
		return this.fetch(`/assistants/${assistantId}/latest`, {
			method: "POST",
			json: { version },
			signal: options?.signal
		});
	}
};
//#endregion
export { AssistantsClient };

//# sourceMappingURL=index.js.map