UNPKG

@just-every/task

Version:
128 lines 4.4 kB
/** * Task State management * * This module manages the state for the Task system. * It provides a central state container and methods to modify the system's behavior at runtime. */ import type { MetaFrequency, ThoughtDelay } from '../utils/constants.js'; type MetamemoryOptions = any; /** * State container for the Task system */ export interface TaskState { /** Counter for LLM requests to trigger meta-cognition */ llmRequestCount: number; /** How often meta-cognition should run (every N LLM requests) */ metaFrequency: MetaFrequency; /** Set of model IDs that have been temporarily disabled */ disabledModels: Set<string>; /** Model effectiveness scores (0-100) - higher scores mean the model is selected more often */ modelScores: Record<string, number>; /** Metamemory configuration for conversation compaction */ metamemoryOptions?: MetamemoryOptions; /** Whether metamemory is enabled globally */ metamemoryEnabled: boolean; } export type { MetaFrequency, ThoughtDelay }; export type { ToolFunction, Agent } from '@just-every/ensemble'; /** * Global state container for the Task system * * Manages meta-cognition frequency, model performance scores, and disabled models. * This state persists across Task executions and influences model selection behavior. * Changes to this state affect all subsequent Task operations. * * @example * ```typescript * // Check current state * console.log(`LLM requests: ${taskState.llmRequestCount}`); * console.log(`Meta frequency: ${taskState.metaFrequency}`); * console.log(`Disabled models: ${taskState.disabledModels.size}`); * * // View model scores * console.log(listModelScores()); * ``` */ export declare const taskState: TaskState; /** * Get a formatted list of currently disabled models * * Provides a human-readable summary of which models are currently * excluded from the rotation algorithm. Useful for debugging * model selection issues. * * @returns Human-readable string listing disabled models or "No models disabled" * * @example * ```typescript * console.log(listDisabledModels()); * // Output: "gpt-4\nclaude-3\n2 models disabled" * ``` */ export declare function listDisabledModels(): string; /** * Get a formatted list of model scores for performance monitoring * * Shows current performance scores for all models. * Higher scores indicate better performance and increase selection probability. * * @returns Human-readable string listing model scores * * @example * ```typescript * console.log(listModelScores()); * // Output: "- gpt-4: 85\n- claude-3: 90" * ``` */ export declare function listModelScores(): string; /** * Set how often meta-cognition should run (every N LLM requests) * @param frequency - The frequency to set (5, 10, 20, or 40) * @returns The new frequency or error message */ export declare const set_meta_frequency: (frequency: string) => string; /** * Set the score for a specific model * @param modelId - The model ID to score * @param score - Score between 0-100 * @returns Success message or error */ export declare const set_model_score: (modelId: string, score: string) => string; /** * Disable a model so it won't be selected * @param modelId - The model ID to disable * @param disabled - Optional boolean to enable/disable (default: true) * @returns Status message */ export declare function disable_model(modelId: string, disabled?: boolean): string; /** * Get the score for a model * @param modelId - The model ID to get the score for * @returns The model's score (0-100) */ export declare function getModelScore(modelId: string): number; /** * Increment the LLM request counter * @returns The new count and whether meta-cognition should trigger */ export declare function incrementLLMRequestCount(): { count: number; shouldTriggerMeta: boolean; }; /** * Reset the LLM request counter */ export declare function resetLLMRequestCount(): void; /** * Configure metamemory options * @param options - Metamemory configuration options * @returns Success message */ export declare function configureMetamemory(options: MetamemoryOptions): string; /** * Enable or disable metamemory globally * @param enabled - Whether to enable metamemory * @returns Status message */ export declare function setMetamemoryEnabled(enabled: boolean): string; //# sourceMappingURL=state.d.ts.map