@promptbook/utils
Version:
Promptbook: Run AI apps in plain human language across multiple models and platforms
62 lines (61 loc) • 2.62 kB
TypeScript
import type { string_book } from '../../agent-source/string_book';
import type { AgentModelRequirements } from './AgentModelRequirements';
/**
* Creates model requirements for an agent based on its source
* Results are cached to improve performance for repeated calls with the same agentSource and modelName
*
* There are 2 similar functions:
* - `parseAgentSource` which is a lightweight parser for agent source, it parses basic information and its purpose is to be quick and synchronous. The commitments there are hardcoded.
* - `createAgentModelRequirements` which is an asynchronous function that creates model requirements it applies each commitment one by one and works asynchronously.
*
* @public exported from `@promptbook/core`
*/
export declare function createAgentModelRequirements(agentSource: string_book, modelName?: string): Promise<AgentModelRequirements>;
/**
* Clears the cache for createAgentModelRequirements
* Useful when agent sources are updated and cached results should be invalidated
*
* @private
*/
export declare function clearAgentModelRequirementsCache(): void;
/**
* Removes cache entries for a specific agent source (all model variants)
* @param agentSource The agent source to remove from cache
* @private
*/
export declare function invalidateAgentModelRequirementsCache(agentSource: string_book): void;
/**
* Gets the current cache size (for debugging/monitoring)
*
* @private
*/
export declare function getAgentModelRequirementsCacheSize(): number;
/**
* Extracts MCP servers from agent source
*
* @param agentSource The agent source string that may contain MCP lines
* @returns Array of MCP server identifiers
*
* @private TODO: [🧠] Maybe should be public
*/
export declare function extractMcpServers(agentSource: string_book): string[];
/**
* Creates a system message for an agent based on its source
* @deprecated Use createAgentModelRequirements instead
* @private
*/
export declare function createAgentSystemMessage(agentSource: string_book): Promise<string>;
/**
* Extracts the agent name from the first line of the agent source
* @deprecated Use parseAgentSource instead
* @private
*/
export declare function extractAgentName(agentSource: string_book): string;
/**
* Extracts the profile image URL from agent source or returns gravatar fallback
* @param agentSource The agent source string that may contain META IMAGE line
* @returns Profile image URL (from source or gravatar fallback)
* @deprecated Use parseAgentSource instead
* @private
*/
export declare function extractAgentProfileImage(agentSource: string_book): string;