@promptbook/google
Version:
Promptbook: Turn your company's scattered knowledge into AI ready books
105 lines (104 loc) • 4.28 kB
TypeScript
import type { SupabaseClient } from '@supabase/supabase-js';
import type { AgentBasicInformation } from '../../../../book-2.0/agent-source/AgentBasicInformation';
import type { string_book } from '../../../../book-2.0/agent-source/string_book';
import type { string_agent_name, string_agent_permanent_id } from '../../../../types/typeAliases';
import { AgentCollectionInSupabaseOptions } from './AgentCollectionInSupabaseOptions';
import type { AgentsDatabaseSchema } from './AgentsDatabaseSchema';
/**
* Options for creating a new agent entry.
*/
type CreateAgentOptions = {
/**
* Folder identifier to assign the new agent to.
*/
readonly folderId?: number | null;
/**
* Sort order for the agent within its parent folder.
*/
readonly sortOrder?: number;
};
/**
* Agent collection stored in a Supabase table.
*
* This class provides a way to manage a collection of agents (pipelines) using Supabase
* as the storage backend. It supports listing, creating, updating, and soft-deleting agents.
*
* Note: This object can work both from Node.js and browser environment depending on the Supabase client provided.
*
* @public exported from `@promptbook/core`
* <- TODO: [🐱🚀] Move to `@promptbook/supabase` package
*/
export declare class AgentCollectionInSupabase {
private readonly supabaseClient;
readonly options?: AgentCollectionInSupabaseOptions | undefined;
/**
* @param supabaseClient - The initialized Supabase client
* @param options - Configuration options for the collection (e.g., table prefix, verbosity)
*/
constructor(supabaseClient: SupabaseClient<AgentsDatabaseSchema>, options?: AgentCollectionInSupabaseOptions | undefined);
/**
* Gets all agents in the collection
*/
listAgents(): Promise<ReadonlyArray<AgentBasicInformation>>;
/**
* Retrieves the permanent ID of an agent by its name or permanent ID.
*/
getAgentPermanentId(agentNameOrPermanentId: string_agent_name | string_agent_permanent_id): Promise<string_agent_permanent_id>;
/**
* Retrieves the source code of an agent by its name or permanent ID.
*/
getAgentSource(agentNameOrPermanentId: string_agent_name | string_agent_permanent_id): Promise<string_book>;
/**
* Creates a new agent in the collection
*
* Note: You can set 'PARENT' in the agent source to inherit from another agent in the collection.
*
* @param agentSource - Source content of the agent.
* @param options - Optional folder placement and ordering data.
*/
createAgent(agentSource: string_book, options?: CreateAgentOptions): Promise<AgentBasicInformation & Required<Pick<AgentBasicInformation, 'permanentId'>>>;
/**
* Updates an existing agent in the collection
*/
updateAgentSource(permanentId: string_agent_permanent_id, agentSource: string_book): Promise<void>;
/**
* List agents that are soft deleted (deletedAt IS NOT NULL)
*/
listDeletedAgents(): Promise<ReadonlyArray<AgentBasicInformation>>;
/**
* List history of an agent
*/
listAgentHistory(permanentId: string_agent_permanent_id): Promise<ReadonlyArray<{
id: number;
createdAt: string;
agentHash: string;
promptbookEngineVersion: string;
}>>;
/**
* Restore a soft-deleted agent by setting deletedAt to NULL
*/
restoreAgent(permanentId: string_agent_permanent_id): Promise<void>;
/**
* Restore an agent from a specific history entry
*
* This will update the current agent with the source from the history entry
*/
restoreAgentFromHistory(historyId: number): Promise<void>;
/**
* Soft delete an agent by setting deletedAt to current timestamp
*/
deleteAgent(permanentId: string_agent_permanent_id): Promise<void>;
/**
* Get the Supabase table name with prefix
*
* @param tableName - The original table name
* @returns The prefixed table name
*/
private getTableName;
}
export {};
/**
* TODO: [🐱🚀] Implement it here correctly and update JSDoc comments here, and on interface + other implementations
* TODO: Write unit test
* TODO: [🧠][🚙] `AgentXxx` vs `AgentsXxx` naming convention
*/