import { WorkspaceScopedResource, extractData } from './base.js';
/**
 * Manage context graphs — structured conversation flow definitions (HSM).
 * Context graphs define the states, transitions, and conditions that
 * govern how an agent moves through a conversation.
 */
export class ContextGraphsResource extends WorkspaceScopedResource {
    async create(body) {
        return extractData(await this.client.POST('/v1/{workspace_id}/context-graphs', {
            params: { path: { workspace_id: this.workspaceId } },
            body,
        }));
    }
    async list(params) {
        return extractData(await this.client.GET('/v1/{workspace_id}/context-graphs', {
            params: { path: { workspace_id: this.workspaceId }, query: params },
        }));
    }
    listAutoPaging(params) {
        return this.iteratePaginatedList((pageParams) => this.list(pageParams), params);
    }
    async get(contextGraphId) {
        return extractData(await this.client.GET('/v1/{workspace_id}/context-graphs/{context_graph_id}', {
            params: {
                path: { workspace_id: this.workspaceId, context_graph_id: contextGraphId },
            },
        }));
    }
    async update(contextGraphId, body) {
        return extractData(await this.client.PUT('/v1/{workspace_id}/context-graphs/{context_graph_id}', {
            params: {
                path: { workspace_id: this.workspaceId, context_graph_id: contextGraphId },
            },
            body,
        }));
    }
    async delete(contextGraphId) {
        await this.client.DELETE('/v1/{workspace_id}/context-graphs/{context_graph_id}', {
            params: {
                path: { workspace_id: this.workspaceId, context_graph_id: contextGraphId },
            },
        });
    }
    /** Create a version snapshot of the current context graph */
    async createVersion(contextGraphId, body) {
        return extractData(await this.client.POST('/v1/{workspace_id}/context-graphs/{context_graph_id}/versions', {
            params: {
                path: { workspace_id: this.workspaceId, context_graph_id: contextGraphId },
            },
            body,
        }));
    }
    /** List all versions of a context graph */
    async listVersions(contextGraphId, params) {
        return extractData(await this.client.GET('/v1/{workspace_id}/context-graphs/{context_graph_id}/versions', {
            params: {
                path: { workspace_id: this.workspaceId, context_graph_id: contextGraphId },
                query: params,
            },
        }));
    }
    listVersionsAutoPaging(contextGraphId, params) {
        return this.iteratePaginatedList((pageParams) => this.listVersions(contextGraphId, pageParams), params);
    }
    /** Get a specific version by number, or pass "latest" for the most recent */
    async getVersion(contextGraphId, version) {
        return extractData(await this.client.GET('/v1/{workspace_id}/context-graphs/{context_graph_id}/versions/{version}', {
            params: {
                path: {
                    workspace_id: this.workspaceId,
                    context_graph_id: contextGraphId,
                    version,
                },
            },
        }));
    }
}
//# sourceMappingURL=context-graphs.js.map