import type { AnySubAgent, CreateDeepAgentParams, InferStructuredResponse, ResolveDeepAgentTypeConfig, SupportedResponseFormat, createDeepAgent } from "deepagents"; import type { ClientTool, ServerTool } from "@langchain/core/tools"; import type { InteropZodObject } from "@langchain/core/utils/types"; import type { AnyStateSchema } from "@langchain/langgraph"; import type { AgentMiddleware, ResponseFormatUndefined } from "langchain"; /** * Properties the managed runtime owns. Agent authors never set these — MDA * wires the backend, store, checkpointer, memory, skills, and system prompt at * deploy time. */ export type ManagedDeepAgentKey = "backend" | "store" | "checkpointer" | "systemPrompt" | "memory" | "skills"; /** * Configuration accepted by {@link defineDeepAgent}. * * This is the full `createDeepAgent` parameter surface minus the managed keys. * Setting a managed key is a compile-time error, pointing authors at the * managed `sandbox/`, store, checkpointer, and `instructions.md` wiring instead. * * Type args are widened past `CreateDeepAgentParams` defaults so callers can * still pass `stateSchema` / `middleware` / `tools` (those default type params * otherwise collapse to `undefined` / empty tuples). */ export type DefineDeepAgentConfig = Omit, ManagedDeepAgentKey> & { /** * Required agent name. Used as the LangGraph graph / assistant id and as the * default LangSmith deployment name (unless `mda deploy -n` overrides it). * Must be a static string matching `[a-zA-Z][a-zA-Z0-9_-]*`. */ name: string; /** Managed: the runtime owns the backend. Configure it under `sandbox/`. */ backend?: never; /** Managed: the runtime owns the durable store. */ store?: never; /** Managed: the runtime owns the checkpointer. */ checkpointer?: never; /** Managed: agent memory is stored under Context Hub `memories/`. */ memory?: never; /** Managed: skills are loaded from Context Hub `skills/`. */ skills?: never; /** * Managed: the system prompt is embedded from `instructions.md` next to the * agent file at deploy time. Write your prompt there instead. */ systemPrompt?: never; /** * Removed: durable memory is declared in `memory.ts` with * `defineMemory({ scope: "agent" })` and is off unless declared. Typed `never` * so the old opt-out fails at the type level, not only at runtime. */ disableMemory?: never; /** * Optional LangSmith/LangGraph run metadata applied after `createDeepAgent` * via `.withConfig({ metadata })`. Use this for root-trace fields such as * prompt provenance — nested middleware cannot reliably reach the root run. */ metadata?: Record; }; /** Structured response type from an authored `responseFormat`, when set. */ type InferConfigResponse = C extends { responseFormat: infer R extends SupportedResponseFormat; } ? InferStructuredResponse : ResponseFormatUndefined; /** * Built-in middleware stack that `createDeepAgent()` always prepends (todos, * filesystem, summarization, subagents, …). Used so `useStream` / InferStateType * see the same channels as a compiled Deep Agent. */ type DeepAgentBuiltInMiddleware = ResolveDeepAgentTypeConfig>["Middleware"]; type AuthoredMiddleware = C extends { middleware: infer M extends readonly AgentMiddleware[]; } ? M : readonly []; /** Built-in Deep Agent middleware followed by any authored middleware. */ type InferConfigMiddleware = DeepAgentBuiltInMiddleware extends readonly [ ...infer BuiltIn ] ? AuthoredMiddleware extends readonly [...infer Authored] ? readonly [...BuiltIn, ...Authored] : DeepAgentBuiltInMiddleware : AuthoredMiddleware; /** * Lightweight agent type bag attached to {@link DeepAgentDefinition} so * `useStream` / InferStateType can treat `typeof agent` like a compiled agent. * Avoids instantiating `createDeepAgent`'s full return type (too heavy for IDE / * `tsc`). */ type MdaAgentTypeConfig = { Response: InferConfigResponse; State: C extends { stateSchema: infer S; } ? S : undefined; Context: InteropZodObject; Middleware: InferConfigMiddleware; Tools: C extends { tools: infer T extends readonly (ClientTool | ServerTool)[]; } ? T : readonly []; StreamTransformers: readonly []; Subagents: C extends { subagents: infer S extends readonly AnySubAgent[]; } ? S : readonly []; }; /** * The pre-runtime spec returned by {@link defineDeepAgent}. * * It is intentionally *not* a compiled graph: the CLI generates an entry module * that hands this definition to the managed runtime, which injects the managed * backend/store/checkpointer and compiles it into a Deep Agent. * * Phantom `~agentTypes` / `~deepAgentTypes` brands mirror a compiled agent so * helpers like `useStream` can accept `typeof agent`. * `TConfig` is preserved (not widened) so custom `stateSchema` / middleware * fields remain recoverable. * * @typeParam TConfig - Authored config object type (const-inferred). */ export type DeepAgentDefinition = { readonly kind: "deep-agent"; readonly config: TConfig; readonly "~agentTypes": MdaAgentTypeConfig; readonly "~deepAgentTypes": MdaAgentTypeConfig; }; /** * Destination for schedule/channel delivery. Schedules cannot use * `current_thread` (no originating thread); see {@link ScheduleDeliveryTarget}. * * Re-exported from the channel-neutral contract. */ export type { ChannelDestination } from "./channels/types.js"; export { normalizeChannelDestination } from "./channels/types.js"; //# sourceMappingURL=types.d.ts.map