deepagents 1.9.1 → 1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +363 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +273 -15
- package/dist/index.d.ts +273 -15
- package/dist/index.js +354 -10
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as _$zod_v30 from "zod/v3";
|
|
2
2
|
import * as _langchain from "langchain";
|
|
3
|
-
import { AgentMiddleware, AgentMiddleware as AgentMiddleware$1, AgentTypeConfig, CreateAgentParams, HumanMessage, InferMiddlewareStates, InterruptOnConfig, ProviderStrategy, ReactAgent, ResponseFormat, ResponseFormatUndefined, Runtime, StructuredTool, SystemMessage, ToolMessage, ToolRuntime, ToolStrategy } from "langchain";
|
|
3
|
+
import { AgentMiddleware, AgentMiddleware as AgentMiddleware$1, AgentRunStream, AgentTypeConfig, CreateAgentParams, HumanMessage, InferMiddlewareStates, InterruptOnConfig, ProviderStrategy, ReactAgent, ResponseFormat, ResponseFormatUndefined, Runtime, StructuredTool, SystemMessage, ToolCallStreamUnion, ToolMessage, ToolRuntime, ToolStrategy } from "langchain";
|
|
4
4
|
import * as _langgraph from "@langchain/langgraph";
|
|
5
|
-
import { AnnotationRoot, Command, ReducedValue, StateSchema } from "@langchain/langgraph";
|
|
5
|
+
import { AnnotationRoot, ChatModelStream, Command, Namespace, NativeStreamTransformer, ReducedValue, StateSchema, StreamTransformer } from "@langchain/langgraph";
|
|
6
6
|
import { z } from "zod/v4";
|
|
7
7
|
import { BaseCheckpointSaver, BaseStore } from "@langchain/langgraph-checkpoint";
|
|
8
8
|
import * as _messages from "@langchain/core/messages";
|
|
@@ -13,7 +13,7 @@ import * as _$_langchain_core_tools0 from "@langchain/core/tools";
|
|
|
13
13
|
import { ClientTool, ServerTool, StructuredTool as StructuredTool$1 } from "@langchain/core/tools";
|
|
14
14
|
import { InteropZodObject } from "@langchain/core/utils/types";
|
|
15
15
|
import { BaseLanguageModel, LanguageModelLike } from "@langchain/core/language_models/base";
|
|
16
|
-
import { CreateSandboxOptions, Sandbox } from "langsmith/experimental/sandbox";
|
|
16
|
+
import { CaptureSnapshotOptions, CaptureSnapshotOptions as LangSmithCaptureSnapshotOptions, CreateSandboxOptions, Sandbox, Snapshot, Snapshot as LangSmithSnapshot, StartSandboxOptions, StartSandboxOptions as LangSmithStartSandboxOptions } from "langsmith/experimental/sandbox";
|
|
17
17
|
import { Runnable } from "@langchain/core/runnables";
|
|
18
18
|
import { BaseChatModel } from "@langchain/core/language_models/chat_models";
|
|
19
19
|
//#region src/backends/v1/protocol.d.ts
|
|
@@ -709,6 +709,35 @@ interface FilesystemPermission {
|
|
|
709
709
|
}
|
|
710
710
|
//#endregion
|
|
711
711
|
//#region src/middleware/fs.d.ts
|
|
712
|
+
/**
|
|
713
|
+
* Tools that should be excluded from the large result eviction logic.
|
|
714
|
+
*
|
|
715
|
+
* This array contains tools that should NOT have their results evicted to the filesystem
|
|
716
|
+
* when they exceed token limits. Tools are excluded for different reasons:
|
|
717
|
+
*
|
|
718
|
+
* 1. Tools with built-in truncation (ls, glob, grep):
|
|
719
|
+
* These tools truncate their own output when it becomes too large. When these tools
|
|
720
|
+
* produce truncated output due to many matches, it typically indicates the query
|
|
721
|
+
* needs refinement rather than full result preservation. In such cases, the truncated
|
|
722
|
+
* matches are potentially more like noise and the LLM should be prompted to narrow
|
|
723
|
+
* its search criteria instead.
|
|
724
|
+
*
|
|
725
|
+
* 2. Tools with problematic truncation behavior (read_file):
|
|
726
|
+
* read_file is tricky to handle as the failure mode here is single long lines
|
|
727
|
+
* (e.g., imagine a jsonl file with very long payloads on each line). If we try to
|
|
728
|
+
* truncate the result of read_file, the agent may then attempt to re-read the
|
|
729
|
+
* truncated file using read_file again, which won't help.
|
|
730
|
+
*
|
|
731
|
+
* 3. Tools that never exceed limits (edit_file, write_file):
|
|
732
|
+
* These tools return minimal confirmation messages and are never expected to produce
|
|
733
|
+
* output large enough to exceed token limits, so checking them would be unnecessary.
|
|
734
|
+
*/
|
|
735
|
+
/**
|
|
736
|
+
* All tool names registered by FilesystemMiddleware.
|
|
737
|
+
* This is the single source of truth — used by createDeepAgent to detect
|
|
738
|
+
* collisions with user-supplied tools at construction time.
|
|
739
|
+
*/
|
|
740
|
+
declare const FILESYSTEM_TOOL_NAMES: readonly ["ls", "read_file", "write_file", "edit_file", "glob", "grep", "execute"];
|
|
712
741
|
/**
|
|
713
742
|
* Type for the files state record.
|
|
714
743
|
*/
|
|
@@ -1674,10 +1703,17 @@ interface LangSmithSandboxOptions {
|
|
|
1674
1703
|
defaultTimeout?: number;
|
|
1675
1704
|
}
|
|
1676
1705
|
/** Options for the `LangSmithSandbox.create()` static factory. */
|
|
1677
|
-
interface LangSmithSandboxCreateOptions extends Omit<CreateSandboxOptions, "name" | "timeout" | "waitForReady"> {
|
|
1706
|
+
interface LangSmithSandboxCreateOptions extends Omit<CreateSandboxOptions, "name" | "timeout" | "waitForReady" | "snapshotName"> {
|
|
1707
|
+
/**
|
|
1708
|
+
* Snapshot ID to boot from.
|
|
1709
|
+
* Mutually exclusive with `templateName`.
|
|
1710
|
+
*/
|
|
1711
|
+
snapshotId?: string;
|
|
1678
1712
|
/**
|
|
1679
1713
|
* Name of the LangSmith sandbox template to use.
|
|
1680
|
-
*
|
|
1714
|
+
* Mutually exclusive with `snapshotId`.
|
|
1715
|
+
* @deprecated Use `snapshotId` instead. Template-based creation will be
|
|
1716
|
+
* removed in a future release.
|
|
1681
1717
|
*/
|
|
1682
1718
|
templateName?: string;
|
|
1683
1719
|
/**
|
|
@@ -1736,6 +1772,33 @@ declare class LangSmithSandbox extends BaseSandbox {
|
|
|
1736
1772
|
* cannot be used again.
|
|
1737
1773
|
*/
|
|
1738
1774
|
close(): Promise<void>;
|
|
1775
|
+
/**
|
|
1776
|
+
* Start a stopped sandbox and wait until it is ready.
|
|
1777
|
+
*
|
|
1778
|
+
* After calling this, `isRunning` will be `true` and the sandbox
|
|
1779
|
+
* can be used for command execution and file operations again.
|
|
1780
|
+
*
|
|
1781
|
+
* @param options - Start options (timeout, signal).
|
|
1782
|
+
*/
|
|
1783
|
+
start(options?: StartSandboxOptions): Promise<void>;
|
|
1784
|
+
/**
|
|
1785
|
+
* Stop the sandbox without deleting it.
|
|
1786
|
+
*
|
|
1787
|
+
* Sandbox files are preserved and the sandbox can be restarted later
|
|
1788
|
+
* with `start()`. After calling this, `isRunning` will be `false`.
|
|
1789
|
+
*/
|
|
1790
|
+
stop(): Promise<void>;
|
|
1791
|
+
/**
|
|
1792
|
+
* Capture a snapshot from this running sandbox.
|
|
1793
|
+
*
|
|
1794
|
+
* Snapshots can be used to create new sandboxes via
|
|
1795
|
+
* `LangSmithSandbox.create({ snapshotId })`.
|
|
1796
|
+
*
|
|
1797
|
+
* @param name - Name for the snapshot.
|
|
1798
|
+
* @param options - Capture options (checkpoint, timeout).
|
|
1799
|
+
* @returns The created Snapshot in "ready" status.
|
|
1800
|
+
*/
|
|
1801
|
+
captureSnapshot(name: string, options?: CaptureSnapshotOptions): Promise<Snapshot>;
|
|
1739
1802
|
/**
|
|
1740
1803
|
* Create and return a new LangSmithSandbox in one step.
|
|
1741
1804
|
*
|
|
@@ -1744,7 +1807,10 @@ declare class LangSmithSandbox extends BaseSandbox {
|
|
|
1744
1807
|
*
|
|
1745
1808
|
* @example
|
|
1746
1809
|
* ```typescript
|
|
1747
|
-
* const sandbox = await LangSmithSandbox.create({
|
|
1810
|
+
* const sandbox = await LangSmithSandbox.create({
|
|
1811
|
+
* snapshotId: "abc-123",
|
|
1812
|
+
* });
|
|
1813
|
+
*
|
|
1748
1814
|
* try {
|
|
1749
1815
|
* const agent = createDeepAgent({ model, backend: sandbox });
|
|
1750
1816
|
* await agent.invoke({ messages: [...] });
|
|
@@ -1753,7 +1819,7 @@ declare class LangSmithSandbox extends BaseSandbox {
|
|
|
1753
1819
|
* }
|
|
1754
1820
|
* ```
|
|
1755
1821
|
*/
|
|
1756
|
-
static create(options
|
|
1822
|
+
static create(options: LangSmithSandboxCreateOptions): Promise<LangSmithSandbox>;
|
|
1757
1823
|
}
|
|
1758
1824
|
//#endregion
|
|
1759
1825
|
//#region src/backends/utils.d.ts
|
|
@@ -2473,6 +2539,19 @@ interface AsyncTask {
|
|
|
2473
2539
|
/** ISO timestamp of the most recent status poll via the check tool. */
|
|
2474
2540
|
checkedAt?: string;
|
|
2475
2541
|
}
|
|
2542
|
+
/**
|
|
2543
|
+
* Task statuses that will never change.
|
|
2544
|
+
*
|
|
2545
|
+
* When listing tasks, live-status fetches are skipped for tasks whose
|
|
2546
|
+
* cached status is in this set, since they are guaranteed to be final.
|
|
2547
|
+
*/
|
|
2548
|
+
/**
|
|
2549
|
+
* Names of the tools added by the async subagent middleware.
|
|
2550
|
+
*
|
|
2551
|
+
* Exported so `agent.ts` can include them in `BUILTIN_TOOL_NAMES` and
|
|
2552
|
+
* surface a `ConfigurationError` if a user-provided tool collides.
|
|
2553
|
+
*/
|
|
2554
|
+
declare const ASYNC_TASK_TOOL_NAMES: readonly ["start_async_task", "check_async_task", "update_async_task", "cancel_async_task", "list_async_tasks"];
|
|
2476
2555
|
/**
|
|
2477
2556
|
* Options for creating async subagent middleware.
|
|
2478
2557
|
*/
|
|
@@ -2574,8 +2653,100 @@ declare function createAsyncSubAgentMiddleware(options: AsyncSubAgentMiddlewareO
|
|
|
2574
2653
|
statusFilter?: string | null | undefined;
|
|
2575
2654
|
}, string | Command<unknown, Record<string, unknown>, string>, unknown, "list_async_tasks">)[]>;
|
|
2576
2655
|
//#endregion
|
|
2656
|
+
//#region src/stream.d.ts
|
|
2657
|
+
/**
|
|
2658
|
+
* Represents a single subagent invocation observed during a deep agent run.
|
|
2659
|
+
*
|
|
2660
|
+
* @typeParam TOutput - The subagent's output state type. Defaults to
|
|
2661
|
+
* `unknown`; inferred to the subagent's `MergedAgentState` for
|
|
2662
|
+
* `CompiledSubAgent` via {@link SubagentRunStreamUnion}.
|
|
2663
|
+
*/
|
|
2664
|
+
interface SubagentRunStream<TOutput = unknown, TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]> {
|
|
2665
|
+
readonly name: string;
|
|
2666
|
+
readonly taskInput: Promise<string>;
|
|
2667
|
+
readonly output: Promise<TOutput>;
|
|
2668
|
+
readonly messages: AsyncIterable<ChatModelStream>;
|
|
2669
|
+
readonly toolCalls: AsyncIterable<ToolCallStreamUnion<TTools>>;
|
|
2670
|
+
readonly subagents: AsyncIterable<SubagentRunStream>;
|
|
2671
|
+
}
|
|
2672
|
+
/**
|
|
2673
|
+
* Extract the output state type from a subagent spec.
|
|
2674
|
+
* For `CompiledSubAgent<ReactAgent<Types>>`, resolves to the agent's
|
|
2675
|
+
* invoke return type. Falls back to `unknown` for `SubAgent` and
|
|
2676
|
+
* `AsyncSubAgent`.
|
|
2677
|
+
*/
|
|
2678
|
+
type SubagentOutputOf<T extends AnySubAgent> = T extends CompiledSubAgent<infer R> ? R extends ReactAgent<infer Types> ? Awaited<ReturnType<ReactAgent<Types>["invoke"]>> : unknown : unknown;
|
|
2679
|
+
/**
|
|
2680
|
+
* Extract the tools tuple from a subagent spec.
|
|
2681
|
+
* For `CompiledSubAgent<ReactAgent<Types>>`, resolves to `Types["Tools"]`.
|
|
2682
|
+
* Falls back to the default `(ClientTool | ServerTool)[]` for `SubAgent`
|
|
2683
|
+
* and `AsyncSubAgent`.
|
|
2684
|
+
*/
|
|
2685
|
+
type SubagentToolsOf<T extends AnySubAgent> = T extends CompiledSubAgent<infer R> ? R extends ReactAgent<infer Types> ? Types["Tools"] : readonly (ClientTool | ServerTool)[] : readonly (ClientTool | ServerTool)[];
|
|
2686
|
+
/**
|
|
2687
|
+
* A typed `SubagentRunStream` variant for a single subagent spec.
|
|
2688
|
+
* Narrows `.name` to the literal string type, `.output` to the
|
|
2689
|
+
* inferred state type, and `.toolCalls` to the subagent's tools
|
|
2690
|
+
* when available.
|
|
2691
|
+
*/
|
|
2692
|
+
type NamedSubagentRunStream<T extends AnySubAgent> = T extends {
|
|
2693
|
+
name: infer N extends string;
|
|
2694
|
+
} ? SubagentRunStream<SubagentOutputOf<T>, SubagentToolsOf<T>> & {
|
|
2695
|
+
readonly name: N;
|
|
2696
|
+
} : SubagentRunStream;
|
|
2697
|
+
/**
|
|
2698
|
+
* Discriminated union of {@link SubagentRunStream} variants, one per
|
|
2699
|
+
* subagent in `TSubagents`. Enables TypeScript to narrow `.output`
|
|
2700
|
+
* when the consumer checks `sub.name === "someSubagentName"`.
|
|
2701
|
+
*/
|
|
2702
|
+
type SubagentRunStreamUnion<TSubagents extends readonly AnySubAgent[]> = { [K in keyof TSubagents]: NamedSubagentRunStream<TSubagents[K]> }[number];
|
|
2703
|
+
/**
|
|
2704
|
+
* An {@link AgentRunStream} with native deep-agent projections assigned
|
|
2705
|
+
* directly on the instance by `createGraphRunStream` (via `__native`
|
|
2706
|
+
* transformers).
|
|
2707
|
+
*
|
|
2708
|
+
* This is a pure type overlay — no runtime class exists. The
|
|
2709
|
+
* `subagents` property is populated at runtime by the
|
|
2710
|
+
* `createSubagentTransformer` registered at compile time.
|
|
2711
|
+
*/
|
|
2712
|
+
type DeepAgentRunStream<TValues = Record<string, unknown>, TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[], TSubagents extends readonly AnySubAgent[] = readonly AnySubAgent[], TExtensions extends Record<string, unknown> = Record<string, unknown>> = AgentRunStream<TValues, TTools, TExtensions> & {
|
|
2713
|
+
/** Subagent invocation streams from the native SubagentTransformer. */subagents: AsyncIterable<SubagentRunStreamUnion<TSubagents>>;
|
|
2714
|
+
};
|
|
2715
|
+
interface SubagentProjection {
|
|
2716
|
+
subagents: AsyncIterable<SubagentRunStream>;
|
|
2717
|
+
}
|
|
2718
|
+
/**
|
|
2719
|
+
* Native transformer that correlates `task` tool calls into
|
|
2720
|
+
* {@link SubagentRunStream} objects and routes child-namespace
|
|
2721
|
+
* `tools` and `messages` events into per-subagent channels.
|
|
2722
|
+
*
|
|
2723
|
+
* Marked `__native: true` — the `subagents` projection key lands
|
|
2724
|
+
* directly on the `GraphRunStream` instance as `run.subagents`.
|
|
2725
|
+
*/
|
|
2726
|
+
declare function createSubagentTransformer(path: Namespace): () => NativeStreamTransformer<SubagentProjection>;
|
|
2727
|
+
//#endregion
|
|
2577
2728
|
//#region src/types.d.ts
|
|
2578
2729
|
type AnyAnnotationRoot = AnnotationRoot<any>;
|
|
2730
|
+
/**
|
|
2731
|
+
* Literal union of all built-in deep agent tool names.
|
|
2732
|
+
* These are always present on the agent regardless of user-provided tools.
|
|
2733
|
+
*/
|
|
2734
|
+
type DeepAgentBuiltinToolName = (typeof FILESYSTEM_TOOL_NAMES)[number] | (typeof ASYNC_TASK_TOOL_NAMES)[number] | "task" | "write_todos";
|
|
2735
|
+
/**
|
|
2736
|
+
* A placeholder StructuredTool type with a literal `name` for each
|
|
2737
|
+
* built-in tool. Used to thread built-in tool names into the
|
|
2738
|
+
* `ToolCallStreamUnion` so they appear in `run.toolCalls` alongside
|
|
2739
|
+
* user-provided tools.
|
|
2740
|
+
*/
|
|
2741
|
+
type BuiltinToolPlaceholder<N extends string> = {
|
|
2742
|
+
name: N;
|
|
2743
|
+
} & StructuredTool$1;
|
|
2744
|
+
/**
|
|
2745
|
+
* Tuple of placeholder tool types for all built-in deep agent tools.
|
|
2746
|
+
* Combined with `TTypes["Tools"]` in the `DeepAgentRunStream` return type.
|
|
2747
|
+
*/
|
|
2748
|
+
type DeepAgentBuiltinToolsTuple = { [K in DeepAgentBuiltinToolName]: BuiltinToolPlaceholder<K> }[DeepAgentBuiltinToolName][];
|
|
2749
|
+
type InferDeepAgentStreamExtensions<T extends ReadonlyArray<() => StreamTransformer<any>>> = T extends readonly [] ? Record<string, never> : T extends readonly [() => StreamTransformer<infer P>, ...infer Rest extends ReadonlyArray<() => StreamTransformer<any>>] ? P & InferDeepAgentStreamExtensions<Rest> : Record<string, unknown>;
|
|
2579
2750
|
/** Any subagent specification — sync, compiled, or async. */
|
|
2580
2751
|
type AnySubAgent = SubAgent | CompiledSubAgent | AsyncSubAgent;
|
|
2581
2752
|
interface TypedToolStrategy<T = unknown> extends Array<ToolStrategy<any>> {
|
|
@@ -2656,7 +2827,7 @@ type InferStructuredResponse<T extends SupportedResponseFormat> = SupportedRespo
|
|
|
2656
2827
|
* type Types = InferDeepAgentType<typeof agent, "Subagents">;
|
|
2657
2828
|
* ```
|
|
2658
2829
|
*/
|
|
2659
|
-
interface DeepAgentTypeConfig<TResponse extends Record<string, any> | ResponseFormatUndefined = Record<string, any> | ResponseFormatUndefined, TState extends AnyAnnotationRoot | InteropZodObject | undefined = AnyAnnotationRoot | InteropZodObject | undefined, TContext extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot | InteropZodObject, TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[], TSubagents extends readonly AnySubAgent[] = readonly AnySubAgent[]
|
|
2830
|
+
interface DeepAgentTypeConfig<TResponse extends Record<string, any> | ResponseFormatUndefined = Record<string, any> | ResponseFormatUndefined, TState extends AnyAnnotationRoot | InteropZodObject | undefined = AnyAnnotationRoot | InteropZodObject | undefined, TContext extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot | InteropZodObject, TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[], TSubagents extends readonly AnySubAgent[] = readonly AnySubAgent[], TStreamTransformers extends ReadonlyArray<() => StreamTransformer<any>> = ReadonlyArray<() => StreamTransformer<any>>> extends AgentTypeConfig<TResponse, TState, TContext, TMiddleware, TTools, TStreamTransformers> {
|
|
2660
2831
|
/** The subagents array type for type-safe streaming */
|
|
2661
2832
|
Subagents: TSubagents;
|
|
2662
2833
|
}
|
|
@@ -2671,6 +2842,7 @@ interface DefaultDeepAgentTypeConfig extends DeepAgentTypeConfig {
|
|
|
2671
2842
|
Middleware: readonly AgentMiddleware[];
|
|
2672
2843
|
Tools: readonly (ClientTool | ServerTool)[];
|
|
2673
2844
|
Subagents: readonly AnySubAgent[];
|
|
2845
|
+
StreamTransformers: readonly [];
|
|
2674
2846
|
}
|
|
2675
2847
|
/**
|
|
2676
2848
|
* DeepAgent extends ReactAgent with additional subagent type information.
|
|
@@ -2688,9 +2860,86 @@ interface DefaultDeepAgentTypeConfig extends DeepAgentTypeConfig {
|
|
|
2688
2860
|
* type Subagents = InferDeepAgentSubagents<typeof agent>;
|
|
2689
2861
|
* ```
|
|
2690
2862
|
*/
|
|
2691
|
-
|
|
2692
|
-
/** Type brand for DeepAgent type inference */
|
|
2693
|
-
|
|
2863
|
+
interface DeepAgent<TTypes extends DeepAgentTypeConfig = DeepAgentTypeConfig> extends ReactAgent<TTypes> {
|
|
2864
|
+
/** Type brand for DeepAgent type inference */
|
|
2865
|
+
readonly "~deepAgentTypes": TTypes;
|
|
2866
|
+
/**
|
|
2867
|
+
* Executes the agent with the v3 streaming interface, returning an
|
|
2868
|
+
* {@link DeepAgentRunStream} that provides ergonomic, typed projections for
|
|
2869
|
+
* messages, tool calls, subagents, and middleware events.
|
|
2870
|
+
*
|
|
2871
|
+
* Pass `version: "v3"` to opt into this projection-oriented stream. Omitting
|
|
2872
|
+
* `version` preserves the legacy internal LangGraph event-stream behavior
|
|
2873
|
+
* for compatibility with LangGraph Platform integrations.
|
|
2874
|
+
*
|
|
2875
|
+
* This v3 stream is experimental and its API may change in future releases.
|
|
2876
|
+
* It will become the default in a future major release.
|
|
2877
|
+
*
|
|
2878
|
+
* @param state - The initial state for the agent execution. Can be:
|
|
2879
|
+
* - An object containing `messages` array and any middleware-specific state properties
|
|
2880
|
+
* - A Command object for more advanced control flow
|
|
2881
|
+
*
|
|
2882
|
+
* @param config - Runtime configuration including:
|
|
2883
|
+
* @param config.version - Must be `"v3"` to use the {@link DeepAgentRunStream}
|
|
2884
|
+
* interface. The default legacy event stream is maintained for internal
|
|
2885
|
+
* integrations and should not be used for new user-facing agent streaming.
|
|
2886
|
+
* @param config.context - The context for the agent execution.
|
|
2887
|
+
* @param config.configurable - LangGraph configuration options like `thread_id`, `run_id`, etc.
|
|
2888
|
+
* @param config.store - The store for the agent execution for persisting state.
|
|
2889
|
+
* @param config.signal - An optional AbortSignal for the agent execution.
|
|
2890
|
+
* @param config.recursionLimit - The recursion limit for the agent execution.
|
|
2891
|
+
*
|
|
2892
|
+
* @returns A Promise that resolves to an {@link DeepAgentRunStream} providing:
|
|
2893
|
+
* - `run.messages` — all AI message lifecycles with streaming `.text` and `.reasoning`
|
|
2894
|
+
* - `run.toolCalls` — individual tool call streams with `.input`, `.output`, `.status`
|
|
2895
|
+
* - `run.subagents` — subagent delegation streams
|
|
2896
|
+
* - `run.middleware` — middleware lifecycle events (before/after agent/model)
|
|
2897
|
+
* - `run.values` — state snapshots (async iterable + promise-like)
|
|
2898
|
+
* - `run.output` — final agent state when the run completes
|
|
2899
|
+
* - `run.subgraphs` — child subgraph run streams
|
|
2900
|
+
* - `run.extensions` — merged projections from user-supplied transformers
|
|
2901
|
+
*
|
|
2902
|
+
* @example
|
|
2903
|
+
* ```typescript
|
|
2904
|
+
* const run = await agent.streamEvents(
|
|
2905
|
+
* {
|
|
2906
|
+
* messages: [{ role: "user", content: "What's the weather in Paris?" }],
|
|
2907
|
+
* },
|
|
2908
|
+
* { version: "v3" }
|
|
2909
|
+
* );
|
|
2910
|
+
*
|
|
2911
|
+
* // Stream all messages
|
|
2912
|
+
* for await (const msg of run.messages) {
|
|
2913
|
+
* for await (const token of msg.text) {
|
|
2914
|
+
* process.stdout.write(token);
|
|
2915
|
+
* }
|
|
2916
|
+
* }
|
|
2917
|
+
*
|
|
2918
|
+
* // Observe tool calls
|
|
2919
|
+
* for await (const call of run.toolCalls) {
|
|
2920
|
+
* console.log(`Tool: ${call.name}`, call.input);
|
|
2921
|
+
* console.log(`Result:`, await call.output);
|
|
2922
|
+
* }
|
|
2923
|
+
*
|
|
2924
|
+
* // Observe subagent delegations
|
|
2925
|
+
* for await (const subagent of run.subagents) {
|
|
2926
|
+
* console.log(`Subagent: ${subagent.name}`);
|
|
2927
|
+
*
|
|
2928
|
+
* for await (const msg of subagent.messages) {
|
|
2929
|
+
* for await (const token of msg.text) {
|
|
2930
|
+
* process.stdout.write(token);
|
|
2931
|
+
* }
|
|
2932
|
+
* }
|
|
2933
|
+
* }
|
|
2934
|
+
*
|
|
2935
|
+
* // Get final state
|
|
2936
|
+
* const state = await run.output;
|
|
2937
|
+
* ```
|
|
2938
|
+
*/
|
|
2939
|
+
streamEvents: ((state: Parameters<ReactAgent<TTypes>["invoke"]>[0], config: NonNullable<Parameters<ReactAgent<TTypes>["invoke"]>[1]> & {
|
|
2940
|
+
version: "v3";
|
|
2941
|
+
}) => Promise<DeepAgentRunStream<Awaited<ReturnType<ReactAgent<TTypes>["invoke"]>>, readonly [...TTypes["Tools"], ...DeepAgentBuiltinToolsTuple], TTypes["Subagents"], InferDeepAgentStreamExtensions<TTypes["StreamTransformers"]>>>) & ReactAgent<TTypes>["streamEvents"];
|
|
2942
|
+
}
|
|
2694
2943
|
/**
|
|
2695
2944
|
* Helper type to resolve a DeepAgentTypeConfig from either:
|
|
2696
2945
|
* - A DeepAgentTypeConfig directly
|
|
@@ -2770,8 +3019,9 @@ type InferSubagentReactAgentType<TSubagent extends SubAgent | CompiledSubAgent>
|
|
|
2770
3019
|
* @typeParam TMiddleware - The middleware array type for proper type inference
|
|
2771
3020
|
* @typeParam TSubagents - The subagents array type for extracting subagent middleware states
|
|
2772
3021
|
* @typeParam TTools - The tools array type
|
|
3022
|
+
* @typeParam TStreamTransformers - Custom stream transformer factories
|
|
2773
3023
|
*/
|
|
2774
|
-
interface CreateDeepAgentParams<TResponse extends SupportedResponseFormat = SupportedResponseFormat, ContextSchema extends AnnotationRoot<any> | InteropZodObject = AnnotationRoot<any>, TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], TSubagents extends readonly AnySubAgent[] = readonly AnySubAgent[], TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]> {
|
|
3024
|
+
interface CreateDeepAgentParams<TResponse extends SupportedResponseFormat = SupportedResponseFormat, ContextSchema extends AnnotationRoot<any> | InteropZodObject = AnnotationRoot<any>, TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], TSubagents extends readonly AnySubAgent[] = readonly AnySubAgent[], TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[], TStreamTransformers extends ReadonlyArray<() => StreamTransformer<any>> = readonly []> {
|
|
2775
3025
|
/** The model to use (model name string or LanguageModelLike instance). Defaults to claude-sonnet-4-5-20250929 */
|
|
2776
3026
|
model?: BaseLanguageModel | string;
|
|
2777
3027
|
/** Tools the agent should have access to */
|
|
@@ -2866,6 +3116,14 @@ interface CreateDeepAgentParams<TResponse extends SupportedResponseFormat = Supp
|
|
|
2866
3116
|
* ```
|
|
2867
3117
|
*/
|
|
2868
3118
|
permissions?: FilesystemPermission[];
|
|
3119
|
+
/**
|
|
3120
|
+
* Optional {@link StreamTransformer} factories to register with the underlying agent.
|
|
3121
|
+
*
|
|
3122
|
+
* Deepagents always registers its built-in subagent transformer; custom
|
|
3123
|
+
* transformers are appended after it and are exposed on `run.extensions`
|
|
3124
|
+
* when using `streamEvents(..., { version: "v3" })`.
|
|
3125
|
+
*/
|
|
3126
|
+
streamTransformers?: TStreamTransformers;
|
|
2869
3127
|
}
|
|
2870
3128
|
//#endregion
|
|
2871
3129
|
//#region src/agent.d.ts
|
|
@@ -2899,7 +3157,7 @@ interface CreateDeepAgentParams<TResponse extends SupportedResponseFormat = Supp
|
|
|
2899
3157
|
* // result.research is properly typed as string
|
|
2900
3158
|
* ```
|
|
2901
3159
|
*/
|
|
2902
|
-
declare function createDeepAgent<TResponse extends SupportedResponseFormat = SupportedResponseFormat, ContextSchema extends InteropZodObject = InteropZodObject, const TMiddleware extends readonly AgentMiddleware[] = readonly [], const TSubagents extends readonly AnySubAgent[] = readonly [], const TTools extends readonly (ClientTool | ServerTool)[] = readonly []>(params?: CreateDeepAgentParams<TResponse, ContextSchema, TMiddleware, TSubagents, TTools>): DeepAgent<DeepAgentTypeConfig<InferStructuredResponse<TResponse>, undefined, ContextSchema, readonly [AgentMiddleware<_$zod_v30.ZodObject<{
|
|
3160
|
+
declare function createDeepAgent<TResponse extends SupportedResponseFormat = SupportedResponseFormat, ContextSchema extends InteropZodObject = InteropZodObject, const TMiddleware extends readonly AgentMiddleware[] = readonly [], const TSubagents extends readonly AnySubAgent[] = readonly [], const TTools extends readonly (ClientTool | ServerTool)[] = readonly [], const TStreamTransformers extends ReadonlyArray<() => StreamTransformer<any>> = readonly []>(params?: CreateDeepAgentParams<TResponse, ContextSchema, TMiddleware, TSubagents, TTools, TStreamTransformers>): DeepAgent<DeepAgentTypeConfig<InferStructuredResponse<TResponse>, undefined, ContextSchema, readonly [AgentMiddleware<_$zod_v30.ZodObject<{
|
|
2903
3161
|
todos: _$zod_v30.ZodDefault<_$zod_v30.ZodArray<_$zod_v30.ZodObject<{
|
|
2904
3162
|
content: _$zod_v30.ZodString;
|
|
2905
3163
|
status: _$zod_v30.ZodEnum<["pending", "in_progress", "completed"]>;
|
|
@@ -3057,7 +3315,7 @@ declare function createDeepAgent<TResponse extends SupportedResponseFormat = Sup
|
|
|
3057
3315
|
summaryMessage: z$2.ZodCustom<_messages.HumanMessage<_messages.MessageStructure<_messages.MessageToolSet>>, _messages.HumanMessage<_messages.MessageStructure<_messages.MessageToolSet>>>;
|
|
3058
3316
|
filePath: z$2.ZodNullable<z$2.ZodString>;
|
|
3059
3317
|
}, _$zod_v4_core0.$strip>>;
|
|
3060
|
-
}, _$zod_v4_core0.$strip>, undefined, unknown, readonly (ClientTool | ServerTool)[]>, AgentMiddleware<undefined, undefined, unknown, readonly (ClientTool | ServerTool)[]>, ...TMiddleware, ...FlattenSubAgentMiddleware<TSubagents>], TTools, TSubagents>>;
|
|
3318
|
+
}, _$zod_v4_core0.$strip>, undefined, unknown, readonly (ClientTool | ServerTool)[]>, AgentMiddleware<undefined, undefined, unknown, readonly (ClientTool | ServerTool)[]>, ...TMiddleware, ...FlattenSubAgentMiddleware<TSubagents>], TTools, TSubagents, TStreamTransformers>>;
|
|
3061
3319
|
//#endregion
|
|
3062
3320
|
//#region src/errors.d.ts
|
|
3063
3321
|
/**
|
|
@@ -3304,5 +3562,5 @@ declare function parseSkillMetadata(skillMdPath: string, source: "user" | "proje
|
|
|
3304
3562
|
*/
|
|
3305
3563
|
declare function listSkills(options: ListSkillsOptions): SkillMetadata[];
|
|
3306
3564
|
//#endregion
|
|
3307
|
-
export { type AgentMemoryMiddlewareOptions, type AnyBackendProtocol, type AnySubAgent, type AsyncSubAgent, type AsyncSubAgentMiddlewareOptions, type AsyncTask, type AsyncTaskStatus, type BackendFactory, type BackendProtocol, type BackendProtocolV1, type BackendProtocolV2, type BackendRuntime, BaseSandbox, type CompiledSubAgent, type CompletionCallbackOptions, CompositeBackend, ConfigurationError, type ConfigurationErrorCode, type CreateDeepAgentParams, DEFAULT_GENERAL_PURPOSE_DESCRIPTION, DEFAULT_SUBAGENT_PROMPT, type DeepAgent, type DeepAgentTypeConfig, type DefaultDeepAgentTypeConfig, type EditResult, type ExecuteResponse, type ExtractSubAgentMiddleware, type FileData, type FileDownloadResponse, type FileInfo, type FileOperationError, type FileUploadResponse, FilesystemBackend, type FilesystemMiddlewareOptions, type FilesystemOperation, type FilesystemPermission, type FlattenSubAgentMiddleware, GENERAL_PURPOSE_SUBAGENT, type GlobResult, type GrepMatch, type GrepResult, type InferDeepAgentSubagents, type InferDeepAgentType, type InferStructuredResponse, type InferSubAgentMiddlewareStates, type InferSubagentByName, type InferSubagentReactAgentType, LangSmithSandbox, type LangSmithSandboxOptions, type ListSkillsOptions, type SkillMetadata as LoaderSkillMetadata, LocalShellBackend, type LocalShellBackendOptions, type LsResult, MAX_SKILL_DESCRIPTION_LENGTH, MAX_SKILL_FILE_SIZE, MAX_SKILL_NAME_LENGTH, type MaybePromise, type MemoryMiddlewareOptions, type MergedDeepAgentState, type PermissionMode, type ReadRawResult, type ReadResult, type ResolveDeepAgentTypeConfig, type SandboxBackendProtocol, type SandboxBackendProtocolV1, type SandboxBackendProtocolV2, type SandboxDeleteOptions, SandboxError, type SandboxErrorCode, type SandboxGetOrCreateOptions, type SandboxInfo, type SandboxListOptions, type SandboxListResponse, type Settings, type SettingsOptions, type SkillMetadata$1 as SkillMetadata, type SkillsMiddlewareOptions, type StateAndStore, StateBackend, StoreBackend, type StoreBackendContext, type StoreBackendNamespaceFactory, type StoreBackendOptions, type SubAgent, type SubAgentMiddlewareOptions, type SupportedResponseFormat, TASK_SYSTEM_PROMPT, type WriteResult, adaptBackendProtocol, adaptSandboxProtocol, computeSummarizationDefaults, createAgentMemoryMiddleware, createAsyncSubAgentMiddleware, createCompletionCallbackMiddleware, createDeepAgent, createFilesystemMiddleware, createMemoryMiddleware, createPatchToolCallsMiddleware, createSettings, createSkillsMiddleware, createSubAgentMiddleware, createSummarizationMiddleware, filesValue, findProjectRoot, isAsyncSubAgent, isSandboxBackend, isSandboxProtocol, listSkills, parseSkillMetadata, resolveBackend };
|
|
3565
|
+
export { type AgentMemoryMiddlewareOptions, type AnyBackendProtocol, type AnySubAgent, type AsyncSubAgent, type AsyncSubAgentMiddlewareOptions, type AsyncTask, type AsyncTaskStatus, type BackendFactory, type BackendProtocol, type BackendProtocolV1, type BackendProtocolV2, type BackendRuntime, BaseSandbox, type CompiledSubAgent, type CompletionCallbackOptions, CompositeBackend, ConfigurationError, type ConfigurationErrorCode, type CreateDeepAgentParams, DEFAULT_GENERAL_PURPOSE_DESCRIPTION, DEFAULT_SUBAGENT_PROMPT, type DeepAgent, type DeepAgentRunStream, type DeepAgentTypeConfig, type DefaultDeepAgentTypeConfig, type EditResult, type ExecuteResponse, type ExtractSubAgentMiddleware, type FileData, type FileDownloadResponse, type FileInfo, type FileOperationError, type FileUploadResponse, FilesystemBackend, type FilesystemMiddlewareOptions, type FilesystemOperation, type FilesystemPermission, type FlattenSubAgentMiddleware, GENERAL_PURPOSE_SUBAGENT, type GlobResult, type GrepMatch, type GrepResult, type InferDeepAgentSubagents, type InferDeepAgentType, type InferStructuredResponse, type InferSubAgentMiddlewareStates, type InferSubagentByName, type InferSubagentReactAgentType, type LangSmithCaptureSnapshotOptions, LangSmithSandbox, type LangSmithSandboxCreateOptions, type LangSmithSandboxOptions, type LangSmithSnapshot, type LangSmithStartSandboxOptions, type ListSkillsOptions, type SkillMetadata as LoaderSkillMetadata, LocalShellBackend, type LocalShellBackendOptions, type LsResult, MAX_SKILL_DESCRIPTION_LENGTH, MAX_SKILL_FILE_SIZE, MAX_SKILL_NAME_LENGTH, type MaybePromise, type MemoryMiddlewareOptions, type MergedDeepAgentState, type PermissionMode, type ReadRawResult, type ReadResult, type ResolveDeepAgentTypeConfig, type SandboxBackendProtocol, type SandboxBackendProtocolV1, type SandboxBackendProtocolV2, type SandboxDeleteOptions, SandboxError, type SandboxErrorCode, type SandboxGetOrCreateOptions, type SandboxInfo, type SandboxListOptions, type SandboxListResponse, type Settings, type SettingsOptions, type SkillMetadata$1 as SkillMetadata, type SkillsMiddlewareOptions, type StateAndStore, StateBackend, StoreBackend, type StoreBackendContext, type StoreBackendNamespaceFactory, type StoreBackendOptions, type SubAgent, type SubAgentMiddlewareOptions, type SubagentRunStream, type SupportedResponseFormat, TASK_SYSTEM_PROMPT, type WriteResult, adaptBackendProtocol, adaptSandboxProtocol, computeSummarizationDefaults, createAgentMemoryMiddleware, createAsyncSubAgentMiddleware, createCompletionCallbackMiddleware, createDeepAgent, createFilesystemMiddleware, createMemoryMiddleware, createPatchToolCallsMiddleware, createSettings, createSkillsMiddleware, createSubAgentMiddleware, createSubagentTransformer, createSummarizationMiddleware, filesValue, findProjectRoot, isAsyncSubAgent, isSandboxBackend, isSandboxProtocol, listSkills, parseSkillMetadata, resolveBackend };
|
|
3308
3566
|
//# sourceMappingURL=index.d.cts.map
|