import type { Agent } from './simple'; import type { Task } from './types'; import type { ContextManager } from '../context/manager'; import type { Plan, TodoList } from '../planning'; import { type TeamCompletionChecker, type TeamContextInput, type TeamExecutionInput, type TeamHooksInput, type TeamTaskCompleteHook, type TeamTaskStartHook } from './team-options'; import { type TeamMemory, type TeamMemoryInput, type TeamMemoryStore } from './team-memory'; import { type TeamPlanningInput } from './team-planning'; /** * How an AgentTeam runs its tasks. `workflow` runs like `sequential`; * `hierarchical` puts a manager agent on `managerLlm` in charge of choosing * which task runs next and on which member (see {@link AgentTeamConfig.managerLlm}). */ export type AgentTeamProcess = 'sequential' | 'parallel' | 'workflow' | 'hierarchical'; /** * Configuration for multi-agent orchestration */ export interface AgentTeamConfig { agents: Agent[]; /** * Prompts to run, one per agent, or Task objects: a Task's `description` is * the prompt, its `expected_output` is appended, and its `agent` (when set) * runs it. Python parity: tasks. */ tasks?: (string | Task)[]; verbose?: boolean; pretty?: boolean; /** Python parity: process (default "sequential"). */ process?: AgentTeamProcess; /** * Python parity: manager_llm. Model for the hierarchical manager: with * `process: 'hierarchical'` a Manager agent on this model decides which task * runs next and which member runs it. Defaults to `OPENAI_MODEL_NAME`, then * `gpt-4o-mini`. */ managerLlm?: string; /** Python parity: name (Optional[str]). */ name?: string; /** * Python parity: variables (Optional[Dict[str, Any]]). `{{key}}` * placeholders in task prompts are replaced with these values. */ variables?: Record; /** Python parity: llm (Optional[str]). Default model for agents constructed without one. */ llm?: string; /** Python parity: model (Optional[str]). Alias of `llm`; wins when both are given. */ model?: string; /** * Python parity: memory (Optional[Any], default false). One shared memory for * the whole team: what it recalls is appended to each task's prompt, and each * task's result is written back. `true` uses an in-process store; pass a * MemoryConfig, a `.json`/`.jsonl` path, or your own store. */ memory?: TeamMemoryInput; /** * Python parity: planning (Optional[Any], default false). Plan first: the * task descriptions become one request, a planner turns it into steps, and * the steps are what run. `true` uses gpt-4o-mini; a string names the * planner's model. */ planning?: TeamPlanningInput; /** * Python parity: context (Optional[Any], default false). One shared * ContextManager for the run: every task's prompt and result is recorded on * it, and each task is handed the accumulated context of all the tasks before * it rather than only the previous result. */ context?: TeamContextInput; /** * Python parity: output (Optional[Any]). Output preset: "silent" hides the * per-task result printing, "verbose" forces it. */ output?: unknown; /** * Python parity: execution (Optional[Any]). Iteration and retry limits, as a * preset ("fast" | "balanced" | "thorough" | "unlimited"), an object * (`{ maxIter, maxRetries }`) or `[preset, overrides]`. */ execution?: TeamExecutionInput; /** * Python parity: hooks (Optional[Any]). Team lifecycle callbacks: * `onTaskStart`, `onTaskComplete` and `completionChecker` (returning false * from the checker retries the task). */ hooks?: TeamHooksInput; /** Python parity: autonomy (Optional[Any]). */ autonomy?: unknown; /** Python parity: knowledge (Optional[Any]). */ knowledge?: unknown; /** Python parity: guardrails (Optional[Any]). */ guardrails?: unknown; /** Python parity: web (Optional[Any]). */ web?: unknown; /** Python parity: reflection (Optional[Any]). */ reflection?: unknown; /** Python parity: caching (Optional[Any]). */ caching?: unknown; /** Python parity: learn (Optional[Any]). */ learn?: unknown; /** Python parity: tools_run_on (Optional[Any]). */ toolsRunOn?: unknown; /** * Python parity: run_on (Optional[Any]). Refused on a team: `runOn` hands one * agent's whole loop to a managed runtime, and a team orchestrates several * agents locally. Passing it throws, as it does in Python. */ runOn?: unknown; } /** * Options for {@link AgentTeam.start}. With `returnDict` unset (or false) the * results come back as an ordered array; pass {@link AgentTeamStartDictOptions} * (`returnDict: true`) for a map keyed by task name. */ export interface AgentTeamStartOptions { /** * Python parity: return_dict (default false). `true` (see * {@link AgentTeamStartDictOptions}) returns the results as a map keyed by * task name (a Task's `name`, else `task_`) instead of an ordered array. */ returnDict?: false; /** Python parity: output. Output preset for this run: "silent" | "verbose" | "normal". */ output?: unknown; } /** {@link AgentTeam.start} options selecting the map-shaped result (Python `return_dict=True`). */ export interface AgentTeamStartDictOptions { returnDict: true; /** Python parity: output. Output preset for this run: "silent" | "verbose" | "normal". */ output?: unknown; } /** Either form of {@link AgentTeam.start} options. */ export type AgentTeamStartOptionsInput = AgentTeamStartOptions | AgentTeamStartDictOptions; /** * @deprecated Use AgentTeamConfig instead. This is a silent alias for backward compatibility. */ export type PraisonAIAgentsConfig = AgentTeamConfig; /** * @deprecated Use AgentTeamConfig instead. This is a silent alias for backward compatibility. */ export type AgentsConfig = AgentTeamConfig; /** * Multi-agent orchestration class * * @example Simple array syntax * ```typescript * import { Agent, Agents } from 'praisonai'; * * const researcher = new Agent({ instructions: "Research the topic" }); * const writer = new Agent({ instructions: "Write based on research" }); * * const agents = new Agents([researcher, writer]); * await agents.start(); * ``` * * @example Config object syntax * ```typescript * const agents = new Agents({ * agents: [researcher, writer], * process: 'parallel' * }); * ``` */ export declare class AgentTeam { private agents; private tasks; private verbose; private pretty; private process; /** Python parity: name (Optional[str]). */ readonly name?: string; /** Python parity: variables (Optional[Dict[str, Any]]). */ readonly variables?: Record; /** Python parity: manager_llm, as supplied. */ readonly managerLlm?: string; /** Python parity: llm / model. The default model applied to member agents. */ readonly llm?: string; /** Python parity: memory (default false). */ readonly memory: unknown; /** Python parity: planning (default false). */ readonly planning: unknown; /** Python parity: context (default false). */ readonly context: unknown; /** Python parity: output. */ readonly output?: unknown; /** Python parity: execution. */ readonly execution?: unknown; /** Python parity: hooks. */ readonly hooks?: unknown; /** Python parity: autonomy. */ readonly autonomy?: unknown; /** Python parity: knowledge. */ readonly knowledge?: unknown; /** Python parity: guardrails. */ readonly guardrails?: unknown; /** Python parity: web. */ readonly web?: unknown; /** Python parity: reflection. */ readonly reflection?: unknown; /** Python parity: caching. */ readonly caching?: unknown; /** Python parity: learn. */ readonly learn?: unknown; /** Python parity: tools_run_on. */ readonly toolsRunOn?: unknown; /** The one place every member's tools share, when the team set toolsRunOn. */ private _sharedToolPlace?; /** Python parity: run_on. Always undefined: a team refuses the option (see the config docs). */ readonly runOn?: unknown; /** Python parity: max_iter. The hierarchical manager's iteration ceiling. */ readonly maxIter: number; /** Python parity: max_retries. Attempts per task before it is left failed (never below 3). */ readonly maxRetries: number; /** Python parity: on_task_start. Fired before each task runs. */ onTaskStart?: TeamTaskStartHook; /** Python parity: on_task_complete. Fired after each task completes. */ onTaskComplete?: TeamTaskCompleteHook; /** Python parity: completion_checker. Returning false retries the task. */ completionChecker: TeamCompletionChecker; /** Python parity: user_id (default "praison"). */ readonly userId: string; /** Python parity: shared_memory. The team's shared memory, when `memory` is on. */ readonly sharedMemory?: TeamMemory; /** Python parity: context_manager. The shared context, when `context` is on. */ readonly contextManager?: ContextManager; /** Python parity: planning_llm. */ readonly planningLlm: string; /** Python parity: auto_approve_plan. */ readonly autoApprovePlan: boolean; /** * Variables published by a task `handler` during the run (Python * `StepResult.variables`). They join the team's own for `{{placeholder}}` * substitution and for evaluating a later task's `when` condition. */ private runVariables; /** Set when a handler returned `stopWorkflow`: the run ends after that task. */ private stopRequested; /** The `content` the current run was started with, handed to task handlers. */ private runContent?; private readonly planningSettings; /** Python parity: _current_plan. Set once a planning run has produced a plan. */ private currentPlan?; /** Python parity: _todo_list. */ private todoList?; /** * How many assistant entries the shared context held when this run began, so * `inputSoFar` hands a task only what THIS run produced (Python resets * per-task state each run: `_reset_task_state_for_item`). */ private contextRunOffset; /** * Create a multi-agent orchestration * @param configOrAgents - Either an array of agents or a config object */ constructor(configOrAgents: AgentTeamConfig | Agent[]); /** The team's shared memory store, when `memory` is on. Python parity: shared_memory. */ getSharedMemory(): TeamMemoryStore | undefined; /** The shared ContextManager, when `context` is on. Python parity: context_manager. */ getContextManager(): ContextManager | undefined; /** The plan a planning run produced, if any. Python parity: _current_plan. */ getPlan(): Plan | undefined; /** The todo list tracking that plan. Python parity: _todo_list. */ getTodoList(): TodoList | undefined; /** * Python parity: `default_completion_checker`'s freeform branch -- an answer * with content in it finishes the task. Python additionally fails a task * closed when structured output was requested and not produced; that rule * belongs to Task.outputJson rather than to any team option, so it is left * to `hooks: { completionChecker }` here rather than changed underneath * existing callers. */ private defaultCompletionChecker; /** * Apply the engine's plan-time fan-out to every Task in the list: a task with * an `inputFile` becomes one task per row, a task with `loopOver` becomes one * task per item. Everything else passes through untouched. */ private expandTasks; /** Turn a prompt string or Task object into a TeamTask, applying `variables`. */ private normaliseTask; /** The hook's view of one task. */ private refFor; /** * Run one task on `agent`, keeping the originating Task's status and * callbacks in step. * * Python parity: `run_task` -- the on_task_start hook, the retry loop bounded * by `max_retries` and driven by `completion_checker`, the shared-memory * context and write-back, and the on_task_complete hook. * * This is also where the per-task half of the execution engine * (`agent/engine/`) is applied, in the order Python applies it: the `rerun` * gate and the dependency-failure gate before anything runs, then the task's * own start hook, its `handler` in place of the model, its memory and * knowledge folded into the prompt, its `images` carried on the call, its * cache consulted around the call, the engine's TaskOutput built from the * answer, and its memory written back. */ private runTask; /** * The TaskOutput for an entry that came from a prompt string rather than a * Task: there is no Task to ask, so the shape the team always built stands. */ private rawOutput; private substituteVariables; private generateTasks; /** * The agent that runs task `i`: a manager's pick, the Task's own agent, an * agent built from its `agentConfig`, else the i-th (or last) member. * * Python parity: `Agents._create_agent_from_config` -- a task that names no * agent but carries an `agentConfig` gets one constructed from it, and the * constructed agent is assigned back onto the task. */ private agentFor; private resolveAgentFor; /** * Run the task at `index`, assembling its prompt first. * * @param isFirst - the first task to execute in this run gets no "input so * far" block, exactly as the plain sequential loop always behaved. */ private runOne; /** * The prompt one task runs. * * `retainFullContext` is the switch: with it the upstream block is the * engine's, which folds in EVERY earlier result; without it the team's * long-standing "here is the input" line carries only the most recent one * (Python `Process._build_task_context`). */ private promptFor; /** `content` (Python parity) is added to every task's context. */ private withContent; /** * What a task is handed as "the input so far". With a shared ContextManager * that is everything the team has produced; without one it is the previous * task's result, as before. */ private inputSoFar; /** * Run the tasks in order. * * `asyncExecution` is what makes this more than a for-loop: the engine plans * the list into steps, collapsing a run of async tasks into one parallel * batch and flushing that batch before a synchronous task or an in-batch * dependency (Python `Agents.arun_all_tasks` / `_depends_on_pending`). */ private executeSequential; /** * Follow the workflow graph instead of the list order. * * Python parity: `process.workflow()` -- `isStart` (or the task nothing points * at) is the entry point, and each finished task's `condition`/`routing` * table, `when`/`thenTask`/`elseTask` pair or `nextTasks` picks the next one. * `exit`, an unroutable name, or no route at all ends the run, and `maxIter` * bounds it so a cycle cannot spin forever. */ private executeWorkflow; /** * Run the tasks under a manager on `managerLlm` (Python parity: * `Process.hierarchical`). The manager chooses the order and the member; * a task it never reaches keeps an empty result. */ private executeHierarchical; /** * Planning mode (Python parity: `_run_with_planning`). The task descriptions * become one request, the planner turns it into steps, and -- once approved * -- the steps replace the tasks for this run. Returns false when the plan * was rejected, which abandons the run; null-ish planning falls through to * normal execution. */ private applyPlanning; /** * Clear per-run task state so a reused team starts fresh (Python parity: * `_reset_task_state_for_item` -- without it a task seen `completed` from the * previous run is skipped and its stale result is returned). */ private resetTaskState; /** * Run every task. * * @param content - Python parity: content. Added to every task's context. * @param options - Python parity: return_dict (map keyed by task name * instead of an array) and output (preset for this run). */ start(content?: string, options?: AgentTeamStartOptions): Promise; start(content: string | undefined, options: AgentTeamStartDictOptions): Promise>; start(content?: string, options?: AgentTeamStartOptionsInput): Promise>; chat(content?: string, options?: AgentTeamStartOptions): Promise; chat(content: string | undefined, options: AgentTeamStartDictOptions): Promise>; chat(content?: string, options?: AgentTeamStartOptionsInput): Promise>; } /** * PraisonAIAgents - Silent alias for AgentTeam (backward compatibility) * @deprecated Use AgentTeam instead */ export declare const PraisonAIAgents: typeof AgentTeam; /** * Agents - Silent alias for AgentTeam (backward compatibility) * @deprecated Use AgentTeam instead * * @example * ```typescript * import { Agent, AgentTeam } from 'praisonai'; * * const team = new AgentTeam([ * new Agent({ instructions: "Research the topic" }), * new Agent({ instructions: "Write based on research" }) * ]); * await team.start(); * ``` */ export declare const Agents: typeof AgentTeam;