deepagents 1.9.0-alpha.1 → 1.9.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.d.cts CHANGED
@@ -670,6 +670,44 @@ type BackendFactory = (runtime: BackendRuntime) => MaybePromise<AnyBackendProtoc
670
670
  */
671
671
  declare function resolveBackend(backend: AnyBackendProtocol | BackendFactory, runtime: BackendRuntime | ToolRuntime): Promise<BackendProtocolV2>;
672
672
  //#endregion
673
+ //#region src/permissions/types.d.ts
674
+ /**
675
+ * The filesystem operations a permission rule can govern.
676
+ */
677
+ type FilesystemOperation = "read" | "write";
678
+ /**
679
+ * Whether a matched rule permits or blocks the operation.
680
+ */
681
+ type PermissionMode = "allow" | "deny";
682
+ /**
683
+ * A single filesystem permission rule.
684
+ *
685
+ * Rules are evaluated in declaration order; the first rule whose
686
+ * `operations` includes the requested operation AND whose `paths`
687
+ * glob-matches the target path determines the outcome. If no rule
688
+ * matches, access is **allowed** (permissive default).
689
+ *
690
+ * All `paths` must be absolute glob patterns (start with `/`, no `..` or `~`).
691
+ * Supports `**` (any depth), `*` (within one segment), and `{a,b}` brace expansion.
692
+ * Paths are validated when passed to {@link createFilesystemMiddleware}.
693
+ */
694
+ interface FilesystemPermission {
695
+ /**
696
+ * The operations this rule applies to.
697
+ */
698
+ operations: readonly FilesystemOperation[];
699
+ /**
700
+ * Absolute glob patterns for paths this rule matches.
701
+ * Must start with `/`; must not contain `..` or `~`.
702
+ * Supports `**` (any depth), `*` (within one segment), and `{a,b}` brace expansion.
703
+ */
704
+ paths: string[];
705
+ /**
706
+ * Whether matching paths are permitted or blocked. Defaults to `"allow"`.
707
+ */
708
+ mode?: PermissionMode;
709
+ }
710
+ //#endregion
673
711
  //#region src/middleware/fs.d.ts
674
712
  /**
675
713
  * Type for the files state record.
@@ -693,6 +731,22 @@ interface FilesystemMiddlewareOptions {
693
731
  toolTokenLimitBeforeEvict?: number | null;
694
732
  /** Optional token limit before evicting a HumanMessage to the filesystem (default: 50000 tokens, ~200KB) */
695
733
  humanMessageTokenLimitBeforeEvict?: number | null;
734
+ /**
735
+ * Filesystem permission rules enforced on every tool call.
736
+ *
737
+ * Rules are evaluated in declaration order; first match wins; permissive
738
+ * default. Applies to `ls`, `read_file`, `write_file`, `edit_file`,
739
+ * `glob`, and `grep`.
740
+ *
741
+ * **Note on `execute`**: permissions are not enforced on `execute` because
742
+ * shell commands can access any path regardless of path-based rules. Using
743
+ * permissions with an execution-capable backend (one where `isSandboxBackend`
744
+ * returns `true`) throws a `ConfigurationError` unless the backend is a
745
+ * `CompositeBackend` and every permission path is scoped to a route prefix.
746
+ *
747
+ * When omitted or empty, all filesystem operations are permitted.
748
+ */
749
+ permissions?: FilesystemPermission[];
696
750
  }
697
751
  /**
698
752
  * Create filesystem middleware with all tools and features.
@@ -815,10 +869,10 @@ declare class StateBackend implements BackendProtocolV2 {
815
869
  * Get files from current state.
816
870
  *
817
871
  * In legacy mode, reads from the injected {@link BackendRuntime}.
818
- * In zero-arg mode, reads from the LangGraph execution context via
819
- * {@link getCurrentTaskInput}.
872
+ * In zero-arg mode, reads via {@link PREGEL_READ_KEY} with fresh=true,
873
+ * which applies any pending task writes through the reducer before returning.
820
874
  */
821
- private getFiles;
875
+ private get files();
822
876
  /**
823
877
  * Push a files state update through LangGraph's internal send channel.
824
878
  *
@@ -898,32 +952,76 @@ declare class StateBackend implements BackendProtocolV2 {
898
952
  }
899
953
  //#endregion
900
954
  //#region src/backends/store.d.ts
955
+ /**
956
+ * Context provided to dynamic namespace factory functions.
957
+ */
958
+ interface StoreBackendContext<StateT = unknown> {
959
+ /**
960
+ * Current graph state, when available.
961
+ *
962
+ * In legacy factory mode this is the injected runtime state. In zero-arg mode
963
+ * this is read from the current LangGraph execution context.
964
+ */
965
+ state: StateT;
966
+ /**
967
+ * Runnable config, when available.
968
+ *
969
+ * This mirrors the Python implementation's access to config metadata for
970
+ * namespace resolution.
971
+ */
972
+ config?: {
973
+ metadata?: Record<string, unknown>;
974
+ configurable?: Record<string, unknown>;
975
+ };
976
+ /**
977
+ * Legacy assistant identifier, resolved from config metadata first and then
978
+ * from the injected runtime for backwards compatibility.
979
+ */
980
+ assistantId?: string;
981
+ }
982
+ type StoreBackendNamespaceFactory<StateT = unknown> = (context: StoreBackendContext<StateT>) => string[];
901
983
  /**
902
984
  * Options for StoreBackend constructor.
903
985
  */
904
- interface StoreBackendOptions extends BackendOptions {
986
+ interface StoreBackendOptions<StateT = unknown> extends BackendOptions {
987
+ /**
988
+ * Explicit store instance to use for persistence.
989
+ *
990
+ * This mirrors the Python API and allows constructing a backend directly with
991
+ * a store instance, e.g. `new StoreBackend({ store })`.
992
+ *
993
+ * When omitted, the backend uses the legacy injected runtime store or the
994
+ * LangGraph execution-context store.
995
+ */
996
+ store?: BaseStore;
905
997
  /**
906
998
  * Custom namespace for store operations.
907
999
  *
908
- * Determines where files are stored in the LangGraph store, enabling
909
- * user-scoped, org-scoped, or any custom isolation pattern.
1000
+ * Accepts either a static namespace array or a factory that derives the
1001
+ * namespace from the current backend context.
910
1002
  *
911
- * If not provided, falls back to legacy behavior using assistantId from {@link BackendRuntime}.
1003
+ * If not provided, falls back to legacy assistant-id detection from config
1004
+ * metadata, then the injected runtime's `assistantId`, and finally
1005
+ * `["filesystem"]`.
912
1006
  *
913
1007
  * @example
914
1008
  * ```typescript
915
- * // User-scoped storage
916
- * new StoreBackend(runtime, {
1009
+ * // Static namespace
1010
+ * new StoreBackend({
917
1011
  * namespace: ["memories", orgId, userId, "filesystem"],
918
1012
  * });
919
1013
  *
920
- * // Org-scoped storage
921
- * new StoreBackend(runtime, {
922
- * namespace: ["memories", orgId, "filesystem"],
1014
+ * // Dynamic namespace
1015
+ * new StoreBackend({
1016
+ * namespace: ({ state }) => [
1017
+ * "memories",
1018
+ * (state as { userId: string }).userId,
1019
+ * "filesystem",
1020
+ * ],
923
1021
  * });
924
1022
  * ```
925
1023
  */
926
- namespace?: string[];
1024
+ namespace?: string[] | StoreBackendNamespaceFactory<StateT>;
927
1025
  }
928
1026
  /**
929
1027
  * Backend that stores files in LangGraph's BaseStore (persistent).
@@ -937,6 +1035,7 @@ interface StoreBackendOptions extends BackendOptions {
937
1035
  */
938
1036
  declare class StoreBackend implements BackendProtocolV2 {
939
1037
  private stateAndStore;
1038
+ private storeOverride;
940
1039
  private _namespace;
941
1040
  private fileFormat;
942
1041
  constructor(options?: StoreBackendOptions);
@@ -955,15 +1054,28 @@ declare class StoreBackend implements BackendProtocolV2 {
955
1054
  * @throws Error if no store is available in either mode
956
1055
  */
957
1056
  private getStore;
1057
+ /**
1058
+ * Get the current graph state when available.
1059
+ */
1060
+ private getState;
1061
+ /**
1062
+ * Get the most relevant runnable config for namespace resolution.
1063
+ */
1064
+ private getNamespaceConfig;
1065
+ /**
1066
+ * Legacy assistant-id detection compatible with both Python and the
1067
+ * historical TypeScript `assistantId` runtime property.
1068
+ */
1069
+ private getLegacyAssistantId;
958
1070
  /**
959
1071
  * Get the namespace for store operations.
960
1072
  *
961
1073
  * Resolution order:
962
- * 1. Explicit namespace from constructor options (both modes)
963
- * 2. Legacy mode: `[assistantId, "filesystem"]` fallback from {@link StateAndStore}
964
- * 3. Zero-arg mode without namespace: `["filesystem"]` with a deprecation warning
965
- * nudging callers to pass an explicit namespace
966
- * 4. Legacy mode without assistantId: `["filesystem"]`
1074
+ * 1. Explicit namespace from constructor options
1075
+ * 2. Namespace factory resolved from the current backend context
1076
+ * 3. Assistant ID from runtime config / LangGraph config metadata
1077
+ * 4. Legacy `assistantId` from the injected runtime
1078
+ * 5. `["filesystem"]`
967
1079
  */
968
1080
  protected getNamespace(): string[];
969
1081
  /**
@@ -1185,6 +1297,15 @@ declare class CompositeBackend implements BackendProtocolV2 {
1185
1297
  constructor(defaultBackend: AnyBackendProtocol, routes: Record<string, AnyBackendProtocol>);
1186
1298
  /** Delegates to default backend's id if it is a sandbox, otherwise empty string. */
1187
1299
  get id(): string;
1300
+ /** Route prefixes registered on this backend (e.g. `["/workspace"]`). */
1301
+ get routePrefixes(): string[];
1302
+ /**
1303
+ * Type guard — returns true if `backend` is a {@link CompositeBackend}.
1304
+ *
1305
+ * Uses duck-typing on `routePrefixes` so it works across module boundaries
1306
+ * where `instanceof` may fail.
1307
+ */
1308
+ static isInstance(backend: unknown): backend is CompositeBackend;
1188
1309
  /**
1189
1310
  * Determine which backend handles this key and strip prefix.
1190
1311
  *
@@ -1577,6 +1698,8 @@ interface LangSmithSandboxCreateOptions extends Omit<CreateSandboxOptions, "name
1577
1698
  *
1578
1699
  * Use the static `LangSmithSandbox.create()` factory for the simplest setup,
1579
1700
  * or construct directly with an existing `Sandbox` instance.
1701
+ *
1702
+ * @experimental This feature is experimental, and breaking changes are expected.
1580
1703
  */
1581
1704
  declare class LangSmithSandbox extends BaseSandbox {
1582
1705
  #private;
@@ -1795,6 +1918,27 @@ interface SubAgent {
1795
1918
  * ```
1796
1919
  */
1797
1920
  responseFormat?: CreateAgentParams["responseFormat"];
1921
+ /**
1922
+ * Filesystem permission rules for this subagent.
1923
+ *
1924
+ * When specified, these rules **replace** the parent agent's permissions
1925
+ * for all tool calls made by this subagent. When omitted, the subagent
1926
+ * inherits the parent agent's permissions.
1927
+ *
1928
+ * Subagent permissions are a full replacement, not a merge.
1929
+ *
1930
+ * @example
1931
+ * ```ts
1932
+ * // Parent denies /restricted/**; this subagent can read it.
1933
+ * const reader: SubAgent = {
1934
+ * name: "reader",
1935
+ * permissions: [
1936
+ * { operations: ["read"], paths: ["/restricted/**"] },
1937
+ * ],
1938
+ * };
1939
+ * ```
1940
+ */
1941
+ permissions?: FilesystemPermission[];
1798
1942
  }
1799
1943
  /**
1800
1944
  * Base specification for the general-purpose subagent.
@@ -2028,6 +2172,11 @@ interface SkillMetadata$1 {
2028
2172
  * - Space-delimited list of tool names
2029
2173
  */
2030
2174
  allowedTools?: string[];
2175
+ /**
2176
+ * Path to a JS/TS entrypoint file for a QuickJS REPL module, relative to the skill
2177
+ * directory.
2178
+ */
2179
+ module?: string;
2031
2180
  }
2032
2181
  /**
2033
2182
  * Options for the skills middleware.
@@ -2076,6 +2225,7 @@ declare function createSkillsMiddleware(options: SkillsMiddlewareOptions): Agent
2076
2225
  compatibility?: string | null | undefined;
2077
2226
  metadata?: Record<string, string> | undefined;
2078
2227
  allowedTools?: string[] | undefined;
2228
+ module?: string | undefined;
2079
2229
  }[] | undefined, {
2080
2230
  name: string;
2081
2231
  description: string;
@@ -2084,6 +2234,7 @@ declare function createSkillsMiddleware(options: SkillsMiddlewareOptions): Agent
2084
2234
  compatibility?: string | null | undefined;
2085
2235
  metadata?: Record<string, string> | undefined;
2086
2236
  allowedTools?: string[] | undefined;
2237
+ module?: string | undefined;
2087
2238
  }[] | undefined>;
2088
2239
  files: ReducedValue<FilesRecord | undefined, FilesRecordUpdate | undefined>;
2089
2240
  }>, undefined, unknown, readonly (_$_langchain_core_tools0.ClientTool | _$_langchain_core_tools0.ServerTool)[]>;
@@ -2187,8 +2338,9 @@ interface SummarizationMiddlewareOptions {
2187
2338
  /**
2188
2339
  * The language model to use for generating summaries.
2189
2340
  * Can be a model string (e.g., "gpt-4o-mini") or a language model instance.
2341
+ * If omitted, middleware will use the active request model.
2190
2342
  */
2191
- model: string | BaseChatModel | BaseLanguageModel;
2343
+ model?: string | BaseChatModel | BaseLanguageModel;
2192
2344
  /**
2193
2345
  * Backend instance or factory for persisting conversation history.
2194
2346
  */
@@ -2695,6 +2847,25 @@ interface CreateDeepAgentParams<TResponse extends SupportedResponseFormat = Supp
2695
2847
  * ```
2696
2848
  */
2697
2849
  skills?: string[];
2850
+ /**
2851
+ * Filesystem permission rules for this agent.
2852
+ *
2853
+ * Rules are evaluated in declaration order; first match wins; permissive
2854
+ * default. Applied to `ls`, `read_file`, `write_file`, `edit_file`, `glob`,
2855
+ * and `grep`. Subagents inherit these rules unless they specify their own
2856
+ * `permissions` field.
2857
+ *
2858
+ * @example
2859
+ * ```ts
2860
+ * createDeepAgent({
2861
+ * permissions: [
2862
+ * { operations: ["read"], paths: ["/workspace/**"] },
2863
+ * { operations: ["read"], paths: ["/**"], mode: "deny" },
2864
+ * ],
2865
+ * });
2866
+ * ```
2867
+ */
2868
+ permissions?: FilesystemPermission[];
2698
2869
  }
2699
2870
  //#endregion
2700
2871
  //#region src/agent.d.ts
@@ -3133,5 +3304,5 @@ declare function parseSkillMetadata(skillMdPath: string, source: "user" | "proje
3133
3304
  */
3134
3305
  declare function listSkills(options: ListSkillsOptions): SkillMetadata[];
3135
3306
  //#endregion
3136
- 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 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 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 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 };
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 };
3137
3308
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -672,6 +672,44 @@ type BackendFactory = (runtime: BackendRuntime) => MaybePromise<AnyBackendProtoc
672
672
  */
673
673
  declare function resolveBackend(backend: AnyBackendProtocol | BackendFactory, runtime: BackendRuntime | ToolRuntime): Promise<BackendProtocolV2>;
674
674
  //#endregion
675
+ //#region src/permissions/types.d.ts
676
+ /**
677
+ * The filesystem operations a permission rule can govern.
678
+ */
679
+ type FilesystemOperation = "read" | "write";
680
+ /**
681
+ * Whether a matched rule permits or blocks the operation.
682
+ */
683
+ type PermissionMode = "allow" | "deny";
684
+ /**
685
+ * A single filesystem permission rule.
686
+ *
687
+ * Rules are evaluated in declaration order; the first rule whose
688
+ * `operations` includes the requested operation AND whose `paths`
689
+ * glob-matches the target path determines the outcome. If no rule
690
+ * matches, access is **allowed** (permissive default).
691
+ *
692
+ * All `paths` must be absolute glob patterns (start with `/`, no `..` or `~`).
693
+ * Supports `**` (any depth), `*` (within one segment), and `{a,b}` brace expansion.
694
+ * Paths are validated when passed to {@link createFilesystemMiddleware}.
695
+ */
696
+ interface FilesystemPermission {
697
+ /**
698
+ * The operations this rule applies to.
699
+ */
700
+ operations: readonly FilesystemOperation[];
701
+ /**
702
+ * Absolute glob patterns for paths this rule matches.
703
+ * Must start with `/`; must not contain `..` or `~`.
704
+ * Supports `**` (any depth), `*` (within one segment), and `{a,b}` brace expansion.
705
+ */
706
+ paths: string[];
707
+ /**
708
+ * Whether matching paths are permitted or blocked. Defaults to `"allow"`.
709
+ */
710
+ mode?: PermissionMode;
711
+ }
712
+ //#endregion
675
713
  //#region src/middleware/fs.d.ts
676
714
  /**
677
715
  * Type for the files state record.
@@ -695,6 +733,22 @@ interface FilesystemMiddlewareOptions {
695
733
  toolTokenLimitBeforeEvict?: number | null;
696
734
  /** Optional token limit before evicting a HumanMessage to the filesystem (default: 50000 tokens, ~200KB) */
697
735
  humanMessageTokenLimitBeforeEvict?: number | null;
736
+ /**
737
+ * Filesystem permission rules enforced on every tool call.
738
+ *
739
+ * Rules are evaluated in declaration order; first match wins; permissive
740
+ * default. Applies to `ls`, `read_file`, `write_file`, `edit_file`,
741
+ * `glob`, and `grep`.
742
+ *
743
+ * **Note on `execute`**: permissions are not enforced on `execute` because
744
+ * shell commands can access any path regardless of path-based rules. Using
745
+ * permissions with an execution-capable backend (one where `isSandboxBackend`
746
+ * returns `true`) throws a `ConfigurationError` unless the backend is a
747
+ * `CompositeBackend` and every permission path is scoped to a route prefix.
748
+ *
749
+ * When omitted or empty, all filesystem operations are permitted.
750
+ */
751
+ permissions?: FilesystemPermission[];
698
752
  }
699
753
  /**
700
754
  * Create filesystem middleware with all tools and features.
@@ -817,10 +871,10 @@ declare class StateBackend implements BackendProtocolV2 {
817
871
  * Get files from current state.
818
872
  *
819
873
  * In legacy mode, reads from the injected {@link BackendRuntime}.
820
- * In zero-arg mode, reads from the LangGraph execution context via
821
- * {@link getCurrentTaskInput}.
874
+ * In zero-arg mode, reads via {@link PREGEL_READ_KEY} with fresh=true,
875
+ * which applies any pending task writes through the reducer before returning.
822
876
  */
823
- private getFiles;
877
+ private get files();
824
878
  /**
825
879
  * Push a files state update through LangGraph's internal send channel.
826
880
  *
@@ -900,32 +954,76 @@ declare class StateBackend implements BackendProtocolV2 {
900
954
  }
901
955
  //#endregion
902
956
  //#region src/backends/store.d.ts
957
+ /**
958
+ * Context provided to dynamic namespace factory functions.
959
+ */
960
+ interface StoreBackendContext<StateT = unknown> {
961
+ /**
962
+ * Current graph state, when available.
963
+ *
964
+ * In legacy factory mode this is the injected runtime state. In zero-arg mode
965
+ * this is read from the current LangGraph execution context.
966
+ */
967
+ state: StateT;
968
+ /**
969
+ * Runnable config, when available.
970
+ *
971
+ * This mirrors the Python implementation's access to config metadata for
972
+ * namespace resolution.
973
+ */
974
+ config?: {
975
+ metadata?: Record<string, unknown>;
976
+ configurable?: Record<string, unknown>;
977
+ };
978
+ /**
979
+ * Legacy assistant identifier, resolved from config metadata first and then
980
+ * from the injected runtime for backwards compatibility.
981
+ */
982
+ assistantId?: string;
983
+ }
984
+ type StoreBackendNamespaceFactory<StateT = unknown> = (context: StoreBackendContext<StateT>) => string[];
903
985
  /**
904
986
  * Options for StoreBackend constructor.
905
987
  */
906
- interface StoreBackendOptions extends BackendOptions {
988
+ interface StoreBackendOptions<StateT = unknown> extends BackendOptions {
989
+ /**
990
+ * Explicit store instance to use for persistence.
991
+ *
992
+ * This mirrors the Python API and allows constructing a backend directly with
993
+ * a store instance, e.g. `new StoreBackend({ store })`.
994
+ *
995
+ * When omitted, the backend uses the legacy injected runtime store or the
996
+ * LangGraph execution-context store.
997
+ */
998
+ store?: BaseStore;
907
999
  /**
908
1000
  * Custom namespace for store operations.
909
1001
  *
910
- * Determines where files are stored in the LangGraph store, enabling
911
- * user-scoped, org-scoped, or any custom isolation pattern.
1002
+ * Accepts either a static namespace array or a factory that derives the
1003
+ * namespace from the current backend context.
912
1004
  *
913
- * If not provided, falls back to legacy behavior using assistantId from {@link BackendRuntime}.
1005
+ * If not provided, falls back to legacy assistant-id detection from config
1006
+ * metadata, then the injected runtime's `assistantId`, and finally
1007
+ * `["filesystem"]`.
914
1008
  *
915
1009
  * @example
916
1010
  * ```typescript
917
- * // User-scoped storage
918
- * new StoreBackend(runtime, {
1011
+ * // Static namespace
1012
+ * new StoreBackend({
919
1013
  * namespace: ["memories", orgId, userId, "filesystem"],
920
1014
  * });
921
1015
  *
922
- * // Org-scoped storage
923
- * new StoreBackend(runtime, {
924
- * namespace: ["memories", orgId, "filesystem"],
1016
+ * // Dynamic namespace
1017
+ * new StoreBackend({
1018
+ * namespace: ({ state }) => [
1019
+ * "memories",
1020
+ * (state as { userId: string }).userId,
1021
+ * "filesystem",
1022
+ * ],
925
1023
  * });
926
1024
  * ```
927
1025
  */
928
- namespace?: string[];
1026
+ namespace?: string[] | StoreBackendNamespaceFactory<StateT>;
929
1027
  }
930
1028
  /**
931
1029
  * Backend that stores files in LangGraph's BaseStore (persistent).
@@ -939,6 +1037,7 @@ interface StoreBackendOptions extends BackendOptions {
939
1037
  */
940
1038
  declare class StoreBackend implements BackendProtocolV2 {
941
1039
  private stateAndStore;
1040
+ private storeOverride;
942
1041
  private _namespace;
943
1042
  private fileFormat;
944
1043
  constructor(options?: StoreBackendOptions);
@@ -957,15 +1056,28 @@ declare class StoreBackend implements BackendProtocolV2 {
957
1056
  * @throws Error if no store is available in either mode
958
1057
  */
959
1058
  private getStore;
1059
+ /**
1060
+ * Get the current graph state when available.
1061
+ */
1062
+ private getState;
1063
+ /**
1064
+ * Get the most relevant runnable config for namespace resolution.
1065
+ */
1066
+ private getNamespaceConfig;
1067
+ /**
1068
+ * Legacy assistant-id detection compatible with both Python and the
1069
+ * historical TypeScript `assistantId` runtime property.
1070
+ */
1071
+ private getLegacyAssistantId;
960
1072
  /**
961
1073
  * Get the namespace for store operations.
962
1074
  *
963
1075
  * Resolution order:
964
- * 1. Explicit namespace from constructor options (both modes)
965
- * 2. Legacy mode: `[assistantId, "filesystem"]` fallback from {@link StateAndStore}
966
- * 3. Zero-arg mode without namespace: `["filesystem"]` with a deprecation warning
967
- * nudging callers to pass an explicit namespace
968
- * 4. Legacy mode without assistantId: `["filesystem"]`
1076
+ * 1. Explicit namespace from constructor options
1077
+ * 2. Namespace factory resolved from the current backend context
1078
+ * 3. Assistant ID from runtime config / LangGraph config metadata
1079
+ * 4. Legacy `assistantId` from the injected runtime
1080
+ * 5. `["filesystem"]`
969
1081
  */
970
1082
  protected getNamespace(): string[];
971
1083
  /**
@@ -1187,6 +1299,15 @@ declare class CompositeBackend implements BackendProtocolV2 {
1187
1299
  constructor(defaultBackend: AnyBackendProtocol, routes: Record<string, AnyBackendProtocol>);
1188
1300
  /** Delegates to default backend's id if it is a sandbox, otherwise empty string. */
1189
1301
  get id(): string;
1302
+ /** Route prefixes registered on this backend (e.g. `["/workspace"]`). */
1303
+ get routePrefixes(): string[];
1304
+ /**
1305
+ * Type guard — returns true if `backend` is a {@link CompositeBackend}.
1306
+ *
1307
+ * Uses duck-typing on `routePrefixes` so it works across module boundaries
1308
+ * where `instanceof` may fail.
1309
+ */
1310
+ static isInstance(backend: unknown): backend is CompositeBackend;
1190
1311
  /**
1191
1312
  * Determine which backend handles this key and strip prefix.
1192
1313
  *
@@ -1579,6 +1700,8 @@ interface LangSmithSandboxCreateOptions extends Omit<CreateSandboxOptions, "name
1579
1700
  *
1580
1701
  * Use the static `LangSmithSandbox.create()` factory for the simplest setup,
1581
1702
  * or construct directly with an existing `Sandbox` instance.
1703
+ *
1704
+ * @experimental This feature is experimental, and breaking changes are expected.
1582
1705
  */
1583
1706
  declare class LangSmithSandbox extends BaseSandbox {
1584
1707
  #private;
@@ -1797,6 +1920,27 @@ interface SubAgent {
1797
1920
  * ```
1798
1921
  */
1799
1922
  responseFormat?: CreateAgentParams["responseFormat"];
1923
+ /**
1924
+ * Filesystem permission rules for this subagent.
1925
+ *
1926
+ * When specified, these rules **replace** the parent agent's permissions
1927
+ * for all tool calls made by this subagent. When omitted, the subagent
1928
+ * inherits the parent agent's permissions.
1929
+ *
1930
+ * Subagent permissions are a full replacement, not a merge.
1931
+ *
1932
+ * @example
1933
+ * ```ts
1934
+ * // Parent denies /restricted/**; this subagent can read it.
1935
+ * const reader: SubAgent = {
1936
+ * name: "reader",
1937
+ * permissions: [
1938
+ * { operations: ["read"], paths: ["/restricted/**"] },
1939
+ * ],
1940
+ * };
1941
+ * ```
1942
+ */
1943
+ permissions?: FilesystemPermission[];
1800
1944
  }
1801
1945
  /**
1802
1946
  * Base specification for the general-purpose subagent.
@@ -2030,6 +2174,11 @@ interface SkillMetadata$1 {
2030
2174
  * - Space-delimited list of tool names
2031
2175
  */
2032
2176
  allowedTools?: string[];
2177
+ /**
2178
+ * Path to a JS/TS entrypoint file for a QuickJS REPL module, relative to the skill
2179
+ * directory.
2180
+ */
2181
+ module?: string;
2033
2182
  }
2034
2183
  /**
2035
2184
  * Options for the skills middleware.
@@ -2078,6 +2227,7 @@ declare function createSkillsMiddleware(options: SkillsMiddlewareOptions): Agent
2078
2227
  compatibility?: string | null | undefined;
2079
2228
  metadata?: Record<string, string> | undefined;
2080
2229
  allowedTools?: string[] | undefined;
2230
+ module?: string | undefined;
2081
2231
  }[] | undefined, {
2082
2232
  name: string;
2083
2233
  description: string;
@@ -2086,6 +2236,7 @@ declare function createSkillsMiddleware(options: SkillsMiddlewareOptions): Agent
2086
2236
  compatibility?: string | null | undefined;
2087
2237
  metadata?: Record<string, string> | undefined;
2088
2238
  allowedTools?: string[] | undefined;
2239
+ module?: string | undefined;
2089
2240
  }[] | undefined>;
2090
2241
  files: ReducedValue<FilesRecord | undefined, FilesRecordUpdate | undefined>;
2091
2242
  }>, undefined, unknown, readonly (_$_langchain_core_tools0.ClientTool | _$_langchain_core_tools0.ServerTool)[]>;
@@ -2189,8 +2340,9 @@ interface SummarizationMiddlewareOptions {
2189
2340
  /**
2190
2341
  * The language model to use for generating summaries.
2191
2342
  * Can be a model string (e.g., "gpt-4o-mini") or a language model instance.
2343
+ * If omitted, middleware will use the active request model.
2192
2344
  */
2193
- model: string | BaseChatModel | BaseLanguageModel;
2345
+ model?: string | BaseChatModel | BaseLanguageModel;
2194
2346
  /**
2195
2347
  * Backend instance or factory for persisting conversation history.
2196
2348
  */
@@ -2697,6 +2849,25 @@ interface CreateDeepAgentParams<TResponse extends SupportedResponseFormat = Supp
2697
2849
  * ```
2698
2850
  */
2699
2851
  skills?: string[];
2852
+ /**
2853
+ * Filesystem permission rules for this agent.
2854
+ *
2855
+ * Rules are evaluated in declaration order; first match wins; permissive
2856
+ * default. Applied to `ls`, `read_file`, `write_file`, `edit_file`, `glob`,
2857
+ * and `grep`. Subagents inherit these rules unless they specify their own
2858
+ * `permissions` field.
2859
+ *
2860
+ * @example
2861
+ * ```ts
2862
+ * createDeepAgent({
2863
+ * permissions: [
2864
+ * { operations: ["read"], paths: ["/workspace/**"] },
2865
+ * { operations: ["read"], paths: ["/**"], mode: "deny" },
2866
+ * ],
2867
+ * });
2868
+ * ```
2869
+ */
2870
+ permissions?: FilesystemPermission[];
2700
2871
  }
2701
2872
  //#endregion
2702
2873
  //#region src/agent.d.ts
@@ -3135,5 +3306,5 @@ declare function parseSkillMetadata(skillMdPath: string, source: "user" | "proje
3135
3306
  */
3136
3307
  declare function listSkills(options: ListSkillsOptions): SkillMetadata[];
3137
3308
  //#endregion
3138
- 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 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 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 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 };
3309
+ 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 };
3139
3310
  //# sourceMappingURL=index.d.ts.map