@mastra/core
Version:
40 lines • 1.67 kB
TypeScript
import type { Agent } from '../agent/index.js';
import type { Mastra } from '.';
/**
* Outcome of a registry-then-editor agent lookup.
*
* - `found` — the agent was resolved (from either source).
* - `missing` — neither the registry nor the editor knows the agent. This is
* a *confirmed* miss: callers may safely treat the agent as gone (e.g.
* reclaim schedule rows that target it).
* - `error` — the registry missed and the editor lookup threw. This proves
* nothing about the agent's existence (transient storage failure,
* hydration error, editor initialization race), so callers MUST NOT take
* destructive action on it.
*/
export type ResolveAgentByIdResult = {
status: 'found';
agent: Agent;
} | {
status: 'missing';
} | {
status: 'error';
error: unknown;
};
/**
* Resolve an agent by id the same way server handlers do: in-memory registry
* first, then the editor for stored agents.
*
* Stored (editor) agents aren't registered on the Mastra instance until
* they've been hydrated once in the current process, so a registry miss does
* not mean the agent is gone — especially on a cold start. Editor hydration
* via `getById` also re-registers the agent, so subsequent lookups take the
* fast registry path.
*
* Every internal call site that needs "does this agent exist / give it to
* me" semantics should go through this helper so the fallback (and the
* confirmed-miss vs. transient-error distinction) can't drift between call
* sites.
*/
export declare function resolveAgentById(mastra: Mastra, agentId: string): Promise<ResolveAgentByIdResult>;
//# sourceMappingURL=resolve-agent.d.ts.map