@librechat/agents 3.1.77 → 3.1.78-dev.0
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/cjs/common/enum.cjs +54 -0
- package/dist/cjs/common/enum.cjs.map +1 -1
- package/dist/cjs/graphs/Graph.cjs +148 -4
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/hooks/createWorkspacePolicyHook.cjs +291 -0
- package/dist/cjs/hooks/createWorkspacePolicyHook.cjs.map +1 -0
- package/dist/cjs/main.cjs +90 -0
- package/dist/cjs/main.cjs.map +1 -1
- package/dist/cjs/messages/anthropicToolCache.cjs +102 -0
- package/dist/cjs/messages/anthropicToolCache.cjs.map +1 -0
- package/dist/cjs/messages/prune.cjs +27 -0
- package/dist/cjs/messages/prune.cjs.map +1 -1
- package/dist/cjs/messages/recency.cjs +99 -0
- package/dist/cjs/messages/recency.cjs.map +1 -0
- package/dist/cjs/run.cjs +30 -0
- package/dist/cjs/run.cjs.map +1 -1
- package/dist/cjs/summarization/node.cjs +100 -6
- package/dist/cjs/summarization/node.cjs.map +1 -1
- package/dist/cjs/tools/ToolNode.cjs +635 -23
- package/dist/cjs/tools/ToolNode.cjs.map +1 -1
- package/dist/cjs/tools/local/CompileCheckTool.cjs +227 -0
- package/dist/cjs/tools/local/CompileCheckTool.cjs.map +1 -0
- package/dist/cjs/tools/local/FileCheckpointer.cjs +90 -0
- package/dist/cjs/tools/local/FileCheckpointer.cjs.map +1 -0
- package/dist/cjs/tools/local/LocalCodingTools.cjs +1098 -0
- package/dist/cjs/tools/local/LocalCodingTools.cjs.map +1 -0
- package/dist/cjs/tools/local/LocalExecutionEngine.cjs +1042 -0
- package/dist/cjs/tools/local/LocalExecutionEngine.cjs.map +1 -0
- package/dist/cjs/tools/local/LocalExecutionTools.cjs +122 -0
- package/dist/cjs/tools/local/LocalExecutionTools.cjs.map +1 -0
- package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs +453 -0
- package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs.map +1 -0
- package/dist/cjs/tools/local/attachments.cjs +183 -0
- package/dist/cjs/tools/local/attachments.cjs.map +1 -0
- package/dist/cjs/tools/local/bashAst.cjs +129 -0
- package/dist/cjs/tools/local/bashAst.cjs.map +1 -0
- package/dist/cjs/tools/local/editStrategies.cjs +188 -0
- package/dist/cjs/tools/local/editStrategies.cjs.map +1 -0
- package/dist/cjs/tools/local/resolveLocalExecutionTools.cjs +141 -0
- package/dist/cjs/tools/local/resolveLocalExecutionTools.cjs.map +1 -0
- package/dist/cjs/tools/local/syntaxCheck.cjs +182 -0
- package/dist/cjs/tools/local/syntaxCheck.cjs.map +1 -0
- package/dist/cjs/tools/local/textEncoding.cjs +30 -0
- package/dist/cjs/tools/local/textEncoding.cjs.map +1 -0
- package/dist/cjs/tools/local/workspaceFS.cjs +51 -0
- package/dist/cjs/tools/local/workspaceFS.cjs.map +1 -0
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs +1 -0
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs.map +1 -1
- package/dist/esm/common/enum.mjs +53 -1
- package/dist/esm/common/enum.mjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +149 -5
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/hooks/createWorkspacePolicyHook.mjs +289 -0
- package/dist/esm/hooks/createWorkspacePolicyHook.mjs.map +1 -0
- package/dist/esm/main.mjs +17 -2
- package/dist/esm/main.mjs.map +1 -1
- package/dist/esm/messages/anthropicToolCache.mjs +99 -0
- package/dist/esm/messages/anthropicToolCache.mjs.map +1 -0
- package/dist/esm/messages/prune.mjs +26 -1
- package/dist/esm/messages/prune.mjs.map +1 -1
- package/dist/esm/messages/recency.mjs +97 -0
- package/dist/esm/messages/recency.mjs.map +1 -0
- package/dist/esm/run.mjs +30 -0
- package/dist/esm/run.mjs.map +1 -1
- package/dist/esm/summarization/node.mjs +100 -6
- package/dist/esm/summarization/node.mjs.map +1 -1
- package/dist/esm/tools/ToolNode.mjs +635 -23
- package/dist/esm/tools/ToolNode.mjs.map +1 -1
- package/dist/esm/tools/local/CompileCheckTool.mjs +223 -0
- package/dist/esm/tools/local/CompileCheckTool.mjs.map +1 -0
- package/dist/esm/tools/local/FileCheckpointer.mjs +87 -0
- package/dist/esm/tools/local/FileCheckpointer.mjs.map +1 -0
- package/dist/esm/tools/local/LocalCodingTools.mjs +1075 -0
- package/dist/esm/tools/local/LocalCodingTools.mjs.map +1 -0
- package/dist/esm/tools/local/LocalExecutionEngine.mjs +1022 -0
- package/dist/esm/tools/local/LocalExecutionEngine.mjs.map +1 -0
- package/dist/esm/tools/local/LocalExecutionTools.mjs +117 -0
- package/dist/esm/tools/local/LocalExecutionTools.mjs.map +1 -0
- package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs +448 -0
- package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs.map +1 -0
- package/dist/esm/tools/local/attachments.mjs +180 -0
- package/dist/esm/tools/local/attachments.mjs.map +1 -0
- package/dist/esm/tools/local/bashAst.mjs +126 -0
- package/dist/esm/tools/local/bashAst.mjs.map +1 -0
- package/dist/esm/tools/local/editStrategies.mjs +185 -0
- package/dist/esm/tools/local/editStrategies.mjs.map +1 -0
- package/dist/esm/tools/local/resolveLocalExecutionTools.mjs +137 -0
- package/dist/esm/tools/local/resolveLocalExecutionTools.mjs.map +1 -0
- package/dist/esm/tools/local/syntaxCheck.mjs +179 -0
- package/dist/esm/tools/local/syntaxCheck.mjs.map +1 -0
- package/dist/esm/tools/local/textEncoding.mjs +27 -0
- package/dist/esm/tools/local/textEncoding.mjs.map +1 -0
- package/dist/esm/tools/local/workspaceFS.mjs +49 -0
- package/dist/esm/tools/local/workspaceFS.mjs.map +1 -0
- package/dist/esm/tools/subagent/SubagentExecutor.mjs +1 -0
- package/dist/esm/tools/subagent/SubagentExecutor.mjs.map +1 -1
- package/dist/types/common/enum.d.ts +39 -1
- package/dist/types/graphs/Graph.d.ts +34 -0
- package/dist/types/hooks/createWorkspacePolicyHook.d.ts +95 -0
- package/dist/types/hooks/index.d.ts +2 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/messages/anthropicToolCache.d.ts +51 -0
- package/dist/types/messages/index.d.ts +2 -0
- package/dist/types/messages/prune.d.ts +11 -0
- package/dist/types/messages/recency.d.ts +64 -0
- package/dist/types/run.d.ts +21 -0
- package/dist/types/tools/ToolNode.d.ts +145 -2
- package/dist/types/tools/local/CompileCheckTool.d.ts +31 -0
- package/dist/types/tools/local/FileCheckpointer.d.ts +39 -0
- package/dist/types/tools/local/LocalCodingTools.d.ts +57 -0
- package/dist/types/tools/local/LocalExecutionEngine.d.ts +149 -0
- package/dist/types/tools/local/LocalExecutionTools.d.ts +9 -0
- package/dist/types/tools/local/LocalProgrammaticToolCalling.d.ts +21 -0
- package/dist/types/tools/local/attachments.d.ts +84 -0
- package/dist/types/tools/local/bashAst.d.ts +11 -0
- package/dist/types/tools/local/editStrategies.d.ts +28 -0
- package/dist/types/tools/local/index.d.ts +12 -0
- package/dist/types/tools/local/resolveLocalExecutionTools.d.ts +38 -0
- package/dist/types/tools/local/syntaxCheck.d.ts +42 -0
- package/dist/types/tools/local/textEncoding.d.ts +21 -0
- package/dist/types/tools/local/workspaceFS.d.ts +49 -0
- package/dist/types/types/hitl.d.ts +56 -27
- package/dist/types/types/run.d.ts +8 -1
- package/dist/types/types/summarize.d.ts +30 -0
- package/dist/types/types/tools.d.ts +341 -6
- package/package.json +21 -2
- package/src/common/enum.ts +54 -0
- package/src/graphs/Graph.ts +164 -6
- package/src/hooks/__tests__/compactHooks.test.ts +38 -2
- package/src/hooks/__tests__/createWorkspacePolicyHook.test.ts +393 -0
- package/src/hooks/createWorkspacePolicyHook.ts +355 -0
- package/src/hooks/index.ts +6 -0
- package/src/index.ts +1 -0
- package/src/messages/__tests__/anthropicToolCache.test.ts +125 -0
- package/src/messages/__tests__/recency.test.ts +267 -0
- package/src/messages/anthropicToolCache.ts +116 -0
- package/src/messages/index.ts +2 -0
- package/src/messages/prune.ts +27 -1
- package/src/messages/recency.ts +155 -0
- package/src/run.ts +31 -0
- package/src/scripts/compare_pi_vs_ours.ts +840 -0
- package/src/scripts/local_engine.ts +166 -0
- package/src/scripts/local_engine_checkpointer.ts +205 -0
- package/src/scripts/local_engine_compile.ts +263 -0
- package/src/scripts/local_engine_hooks.ts +226 -0
- package/src/scripts/local_engine_image.ts +201 -0
- package/src/scripts/local_engine_ptc.ts +151 -0
- package/src/scripts/local_engine_workspace.ts +258 -0
- package/src/scripts/summarization-recency.ts +462 -0
- package/src/specs/prune.test.ts +39 -0
- package/src/summarization/__tests__/node.test.ts +499 -3
- package/src/summarization/node.ts +124 -7
- package/src/tools/ToolNode.ts +769 -20
- package/src/tools/__tests__/LocalExecutionTools.test.ts +2647 -0
- package/src/tools/__tests__/ProgrammaticToolCalling.test.ts +175 -0
- package/src/tools/__tests__/ToolNode.outputReferences.test.ts +114 -0
- package/src/tools/__tests__/ToolNode.session.test.ts +84 -0
- package/src/tools/__tests__/directToolHITLResumeScope.test.ts +467 -0
- package/src/tools/__tests__/directToolHooks.test.ts +411 -0
- package/src/tools/__tests__/localToolNames.test.ts +73 -0
- package/src/tools/__tests__/workspaceSeam.test.ts +134 -0
- package/src/tools/local/CompileCheckTool.ts +278 -0
- package/src/tools/local/FileCheckpointer.ts +93 -0
- package/src/tools/local/LocalCodingTools.ts +1342 -0
- package/src/tools/local/LocalExecutionEngine.ts +1329 -0
- package/src/tools/local/LocalExecutionTools.ts +167 -0
- package/src/tools/local/LocalProgrammaticToolCalling.ts +594 -0
- package/src/tools/local/__tests__/FileCheckpointer.test.ts +120 -0
- package/src/tools/local/__tests__/editStrategies.test.ts +134 -0
- package/src/tools/local/attachments.ts +251 -0
- package/src/tools/local/bashAst.ts +151 -0
- package/src/tools/local/editStrategies.ts +188 -0
- package/src/tools/local/index.ts +12 -0
- package/src/tools/local/resolveLocalExecutionTools.ts +208 -0
- package/src/tools/local/syntaxCheck.ts +243 -0
- package/src/tools/local/textEncoding.ts +37 -0
- package/src/tools/local/workspaceFS.ts +89 -0
- package/src/types/hitl.ts +56 -27
- package/src/types/run.ts +12 -1
- package/src/types/summarize.ts +31 -0
- package/src/types/tools.ts +359 -7
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type * as t from '@/types';
|
|
2
|
+
type ResolveLocalToolsResult = {
|
|
3
|
+
toolMap: t.ToolMap;
|
|
4
|
+
directToolNames: Set<string>;
|
|
5
|
+
/**
|
|
6
|
+
* Set when `local.fileCheckpointing === true` AND the auto-bind
|
|
7
|
+
* coding suite is in use. ToolNode stashes this on the node and
|
|
8
|
+
* exposes it via `getFileCheckpointer()` so the host can call
|
|
9
|
+
* `rewind()` after a failed batch. Manual review (finding E)
|
|
10
|
+
* flagged that the config flag was previously a no-op in the
|
|
11
|
+
* Run/ToolNode auto-bind path — only direct
|
|
12
|
+
* `createLocalCodingToolBundle()` callers could access the
|
|
13
|
+
* checkpointer.
|
|
14
|
+
*/
|
|
15
|
+
fileCheckpointer?: t.LocalFileCheckpointer;
|
|
16
|
+
};
|
|
17
|
+
export declare function resolveLocalToolsForBinding(args: {
|
|
18
|
+
tools?: t.GraphTools;
|
|
19
|
+
toolExecution?: t.ToolExecutionConfig;
|
|
20
|
+
}): t.GraphTools | undefined;
|
|
21
|
+
export declare function resolveLocalToolRegistry(args: {
|
|
22
|
+
toolRegistry?: t.LCToolRegistry;
|
|
23
|
+
toolExecution?: t.ToolExecutionConfig;
|
|
24
|
+
}): t.LCToolRegistry | undefined;
|
|
25
|
+
export declare function resolveLocalExecutionTools(args: {
|
|
26
|
+
toolMap: t.ToolMap;
|
|
27
|
+
toolExecution?: t.ToolExecutionConfig;
|
|
28
|
+
/**
|
|
29
|
+
* Caller-provided checkpointer that overrides the bundle's
|
|
30
|
+
* auto-created one. The Graph layer threads a single per-Run
|
|
31
|
+
* instance so every ToolNode it compiles shares one snapshot
|
|
32
|
+
* store — without that, a multi-agent graph would each get a
|
|
33
|
+
* private checkpointer and `Run.rewindFiles()` couldn't reach
|
|
34
|
+
* any of them.
|
|
35
|
+
*/
|
|
36
|
+
fileCheckpointer?: t.LocalFileCheckpointer;
|
|
37
|
+
}): ResolveLocalToolsResult;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-file syntax check used by `edit_file` / `write_file` to surface
|
|
3
|
+
* obvious errors immediately after the write — strictly cheaper than
|
|
4
|
+
* full LSP integration and catches the bulk of "you broke the file"
|
|
5
|
+
* regressions a vision-less agent loop would otherwise miss until
|
|
6
|
+
* the next call.
|
|
7
|
+
*
|
|
8
|
+
* Each checker is a tiny shell-out (or in-process function) keyed on
|
|
9
|
+
* file extension. Failures are returned as a single short message;
|
|
10
|
+
* the wiring layer decides whether to append it to the tool result
|
|
11
|
+
* advisorily (`auto`) or to throw and force the model to react
|
|
12
|
+
* (`strict`).
|
|
13
|
+
*
|
|
14
|
+
* We deliberately do NOT cover TypeScript here because per-file `tsc`
|
|
15
|
+
* is slow and per-file syntax (without type info) misses most TS
|
|
16
|
+
* errors anyway. Use the project-level `compile_check` tool for that.
|
|
17
|
+
*/
|
|
18
|
+
import type * as t from '@/types';
|
|
19
|
+
export type SyntaxCheckOutcome = {
|
|
20
|
+
ok: true;
|
|
21
|
+
} | {
|
|
22
|
+
ok: false;
|
|
23
|
+
checker: string;
|
|
24
|
+
output: string;
|
|
25
|
+
};
|
|
26
|
+
export type SyntaxChecker = (path: string, config: t.LocalExecutionConfig) => Promise<SyntaxCheckOutcome>;
|
|
27
|
+
/**
|
|
28
|
+
* Test-only reset hook. Clears the per-backend probe cache so tests
|
|
29
|
+
* can swap in mocked spawn backends and reprobe deterministically.
|
|
30
|
+
*
|
|
31
|
+
* @internal Not part of the public SDK surface.
|
|
32
|
+
*/
|
|
33
|
+
export declare function _resetSyntaxCheckProbeCacheForTests(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Run the post-edit syntax check for `absolutePath`. Returns
|
|
36
|
+
* `null` when no checker matches the extension (most files), or a
|
|
37
|
+
* `SyntaxCheckOutcome`.
|
|
38
|
+
*
|
|
39
|
+
* Truncates `output` to `maxOutputChars` (default 4096) so a
|
|
40
|
+
* 10MB-of-errors transpiler dump can't blow the model context.
|
|
41
|
+
*/
|
|
42
|
+
export declare function runPostEditSyntaxCheck(absolutePath: string, config: t.LocalExecutionConfig): Promise<SyntaxCheckOutcome | null>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BOM and line-ending preservation helpers for the local engine's
|
|
3
|
+
* file-mutating tools. We never *introduce* a BOM or change line
|
|
4
|
+
* endings — only preserve what was already on disk so a Windows-
|
|
5
|
+
* checked-in source file stays CRLF and a UTF-8-with-BOM JSON file
|
|
6
|
+
* keeps its BOM after an edit.
|
|
7
|
+
*
|
|
8
|
+
* Inspired by opencode's `Bom` helper. Trimmed to the cases that
|
|
9
|
+
* actually matter for editing source code (UTF-8 BOM only;
|
|
10
|
+
* UTF-16/UTF-32 are out of scope).
|
|
11
|
+
*/
|
|
12
|
+
export interface EncodedFile {
|
|
13
|
+
/** File contents with BOM stripped. */
|
|
14
|
+
text: string;
|
|
15
|
+
/** Whether the on-disk file started with a UTF-8 BOM. */
|
|
16
|
+
hasBom: boolean;
|
|
17
|
+
/** Detected newline style. CRLF wins if any CRLF is present. */
|
|
18
|
+
newline: '\n' | '\r\n';
|
|
19
|
+
}
|
|
20
|
+
export declare function decodeFile(raw: string): EncodedFile;
|
|
21
|
+
export declare function encodeFile(text: string, encoding: EncodedFile): string;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine-agnostic filesystem seam for the local-coding tool suite.
|
|
3
|
+
*
|
|
4
|
+
* The current "local" engine maps every operation to Node's
|
|
5
|
+
* `fs/promises` against the host machine. A future engine — e.g. a
|
|
6
|
+
* stateful remote sandbox (e2b / Modal / Daytona / ssh-jail) —
|
|
7
|
+
* supplies its own `WorkspaceFS` implementation and reuses every
|
|
8
|
+
* tool factory unchanged. Same fuzzy-match `edit_file`, same
|
|
9
|
+
* checkpointer, same syntax-check, same image attachments — only
|
|
10
|
+
* the underlying I/O changes.
|
|
11
|
+
*
|
|
12
|
+
* Path semantics belong to the implementation. The local engine
|
|
13
|
+
* interprets paths as host filesystem paths; a remote engine would
|
|
14
|
+
* interpret them as remote-namespace paths. Tool factories don't
|
|
15
|
+
* inspect the strings beyond passing them through.
|
|
16
|
+
*
|
|
17
|
+
* Keep this surface minimal. Add a method only when an existing
|
|
18
|
+
* tool genuinely needs it; resist the temptation to mirror all of
|
|
19
|
+
* `fs/promises`.
|
|
20
|
+
*/
|
|
21
|
+
import type { MakeDirectoryOptions, Stats, WriteFileOptions } from 'fs';
|
|
22
|
+
import type { FileHandle } from 'fs/promises';
|
|
23
|
+
export type ReaddirEntry = {
|
|
24
|
+
name: string;
|
|
25
|
+
isFile(): boolean;
|
|
26
|
+
isDirectory(): boolean;
|
|
27
|
+
isSymbolicLink(): boolean;
|
|
28
|
+
};
|
|
29
|
+
export interface WorkspaceFS {
|
|
30
|
+
readFile(path: string, encoding: 'utf8'): Promise<string>;
|
|
31
|
+
readFile(path: string): Promise<Buffer>;
|
|
32
|
+
writeFile(path: string, content: string | Buffer, options?: WriteFileOptions): Promise<void>;
|
|
33
|
+
stat(path: string): Promise<Stats>;
|
|
34
|
+
readdir(path: string, options: {
|
|
35
|
+
withFileTypes: true;
|
|
36
|
+
}): Promise<ReaddirEntry[]>;
|
|
37
|
+
readdir(path: string): Promise<string[]>;
|
|
38
|
+
mkdir(path: string, options?: MakeDirectoryOptions): Promise<void>;
|
|
39
|
+
realpath(path: string): Promise<string>;
|
|
40
|
+
unlink(path: string): Promise<void>;
|
|
41
|
+
/** Open a file for low-level read access (used by binary detection). */
|
|
42
|
+
open(path: string, flags: 'r'): Promise<FileHandle>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Default `WorkspaceFS` backed by Node's `fs/promises` module.
|
|
46
|
+
* Returned by `getWorkspaceFS(config)` when the host hasn't supplied
|
|
47
|
+
* an override on `local.exec.fs`.
|
|
48
|
+
*/
|
|
49
|
+
export declare const nodeWorkspaceFS: WorkspaceFS;
|
|
@@ -203,39 +203,68 @@ export declare function isAskUserQuestionInterrupt(payload: unknown): payload is
|
|
|
203
203
|
* matches the pre-HITL behavior so existing hosts upgrading the SDK
|
|
204
204
|
* see no change until they're ready to wire the resume UI.
|
|
205
205
|
*
|
|
206
|
-
* ## Scope:
|
|
206
|
+
* ## Scope: every tool the ToolNode runs
|
|
207
207
|
*
|
|
208
|
-
* The interrupt path is wired into `
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
208
|
+
* The interrupt path is wired into both `dispatchToolEvents` (the
|
|
209
|
+
* event-driven path) and `runDirectToolWithLifecycleHooks` (the
|
|
210
|
+
* direct path used by `directToolNames` entries — graph-managed
|
|
211
|
+
* handoff/subagent tools and every in-process `graphTool` instance).
|
|
212
|
+
* `PreToolUse` hooks fire for every tool the ToolNode invokes, and
|
|
213
|
+
* HITL approval gates every tool whose hook returns `'ask'` —
|
|
214
|
+
* regardless of whether the tool is dispatched as an event or
|
|
215
|
+
* invoked in-process. This convergence happened in two follow-up
|
|
216
|
+
* commits to the original HITL surface (see `Graph.ts` —
|
|
217
|
+
* `hookRegistry`/`humanInTheLoop` are passed in both
|
|
218
|
+
* event-driven and legacy branches; and `ToolNode.runDirectToolWithLifecycleHooks`
|
|
219
|
+
* — direct-path tools build their own single-tool `tool_approval`
|
|
220
|
+
* payload and raise `interrupt()` the same way the event path does).
|
|
216
221
|
*
|
|
217
222
|
* Practical implications:
|
|
218
|
-
* -
|
|
219
|
-
*
|
|
220
|
-
* -
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
223
|
+
* - Every host gets the full HITL surface across every tool the
|
|
224
|
+
* model calls — event-dispatched, direct, mixed.
|
|
225
|
+
* - `createToolPolicyHook` and `createWorkspacePolicyHook` apply
|
|
226
|
+
* uniformly. A hook can be registered without knowing or caring
|
|
227
|
+
* which path the tool will take.
|
|
228
|
+
* - Direct tools that the host opted into via `directToolNames` no
|
|
229
|
+
* longer bypass policy. If you need a tool to skip the hook
|
|
230
|
+
* surface entirely, omit it from any registered matcher.
|
|
231
|
+
*
|
|
232
|
+
* ## Resume re-execution: every tool in the interrupted batch
|
|
233
|
+
*
|
|
234
|
+
* LangGraph rolls back to the start of the interrupted node on
|
|
235
|
+
* resume. That means **every tool in the same batch as the one that
|
|
236
|
+
* interrupted re-runs from the top on the resume pass**, not just
|
|
237
|
+
* the interrupting tool, and not just the direct half (this used to
|
|
238
|
+
* be framed as a direct-tool-specific concern; it is not — it
|
|
239
|
+
* applies to event-dispatched siblings too). Practical contract:
|
|
240
|
+
*
|
|
241
|
+
* - The body of the interrupting tool itself runs **once** total
|
|
242
|
+
* (the first pass interrupted *before* the body, the resume pass
|
|
243
|
+
* ran the body after the host's decision was applied).
|
|
244
|
+
* - The body of any sibling tool that already executed in the
|
|
245
|
+
* same batch before the interrupting tool runs **twice** — once
|
|
246
|
+
* on the first pass, once on the resume pass.
|
|
247
|
+
* - `PreToolUse` hooks fire **once per pass per tool**. A hook
|
|
248
|
+
* that always returns `'ask'` will loop forever on resume; real
|
|
249
|
+
* hooks should be deterministic w.r.t. inputs and use the
|
|
250
|
+
* `'ask' → host approves → resume → hook returns 'allow'`
|
|
251
|
+
* pattern, where the second-pass `allow` reflects the host
|
|
252
|
+
* having recorded the approval (e.g., a session-scoped approved-
|
|
253
|
+
* paths set keyed by `runId`).
|
|
254
|
+
*
|
|
255
|
+
* Consequence: any tool with side effects MUST be idempotent if
|
|
256
|
+
* there's any chance another tool in the same batch could trigger
|
|
257
|
+
* an interrupt. This applies equally to direct tools (handoffs,
|
|
258
|
+
* subagents) and to event tools.
|
|
232
259
|
*
|
|
233
260
|
* ## Note on idempotency
|
|
234
261
|
*
|
|
235
|
-
*
|
|
236
|
-
* from the start on resume, which
|
|
237
|
-
* Hooks that produce side effects
|
|
238
|
-
* two invocations per
|
|
262
|
+
* Same root cause as the resume re-execution above: LangGraph
|
|
263
|
+
* re-runs the interrupted node from the start on resume, which
|
|
264
|
+
* fires `PreToolUse` hooks again. Hooks that produce side effects
|
|
265
|
+
* (logging, external calls) will see at least two invocations per
|
|
266
|
+
* paused turn — exactly two for the interrupting tool, possibly
|
|
267
|
+
* more across siblings.
|
|
239
268
|
*/
|
|
240
269
|
export interface HumanInTheLoopConfig {
|
|
241
270
|
/**
|
|
@@ -7,7 +7,7 @@ import type * as s from '@/types/stream';
|
|
|
7
7
|
import type * as e from '@/common/enum';
|
|
8
8
|
import type * as g from '@/types/graph';
|
|
9
9
|
import type * as l from '@/types/llm';
|
|
10
|
-
import type { ToolSessionMap, ToolOutputReferencesConfig } from '@/types/tools';
|
|
10
|
+
import type { ToolSessionMap, ToolExecutionConfig, ToolOutputReferencesConfig } from '@/types/tools';
|
|
11
11
|
import type { HumanInTheLoopConfig } from '@/types/hitl';
|
|
12
12
|
import type { HookRegistry } from '@/hooks';
|
|
13
13
|
export type ZodObjectAny = z.ZodObject<any, any, any, any>;
|
|
@@ -145,6 +145,13 @@ export type RunConfig = {
|
|
|
145
145
|
* placeholders. Disabled by default so existing runs are unaffected.
|
|
146
146
|
*/
|
|
147
147
|
toolOutputReferences?: ToolOutputReferencesConfig;
|
|
148
|
+
/**
|
|
149
|
+
* Selects the execution backend for built-in code tools. Omit this to keep
|
|
150
|
+
* the remote LibreChat Code API sandbox. Set `{ engine: 'local' }` to run
|
|
151
|
+
* code execution locally and auto-bind the local coding tool suite unless
|
|
152
|
+
* `local.includeCodingTools` is set to `false`.
|
|
153
|
+
*/
|
|
154
|
+
toolExecution?: ToolExecutionConfig;
|
|
148
155
|
/**
|
|
149
156
|
* First-class human-in-the-loop (HITL) flow for this run.
|
|
150
157
|
*
|
|
@@ -4,6 +4,29 @@ export type SummarizationTrigger = {
|
|
|
4
4
|
type: 'token_ratio' | 'remaining_tokens' | 'messages_to_refine' | (string & {});
|
|
5
5
|
value: number;
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Controls how many recent messages are preserved verbatim during
|
|
9
|
+
* compaction. The most recent user-led turn is always preserved
|
|
10
|
+
* regardless of these caps, so a single oversized first message is
|
|
11
|
+
* never destroyed by summarization.
|
|
12
|
+
*/
|
|
13
|
+
export type RetainRecentConfig = {
|
|
14
|
+
/**
|
|
15
|
+
* Maximum number of recent user-led turns to keep in the tail. A turn
|
|
16
|
+
* begins at a HumanMessage and includes every following AIMessage and
|
|
17
|
+
* ToolMessage up to (but not including) the next HumanMessage. Cutting
|
|
18
|
+
* at turn boundaries guarantees tool_use / tool_result pairs are never
|
|
19
|
+
* split. Set to `0` to disable the recency window (legacy behavior:
|
|
20
|
+
* summarize everything). Defaults to `2`.
|
|
21
|
+
*/
|
|
22
|
+
turns?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Optional cap on retained-recent tokens beyond the most recent turn.
|
|
25
|
+
* Older turns are added whole only while cumulative tokens stay below
|
|
26
|
+
* the cap. Defaults to undefined (no cap; bounded only by `turns`).
|
|
27
|
+
*/
|
|
28
|
+
tokens?: number;
|
|
29
|
+
};
|
|
7
30
|
export type SummarizationConfig = {
|
|
8
31
|
provider?: Providers;
|
|
9
32
|
model?: string;
|
|
@@ -14,6 +37,13 @@ export type SummarizationConfig = {
|
|
|
14
37
|
maxSummaryTokens?: number;
|
|
15
38
|
/** Fraction of the token budget reserved as headroom (0–1). Defaults to 0.05. */
|
|
16
39
|
reserveRatio?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Recent-message preservation policy. When unset, defaults to
|
|
42
|
+
* `{ turns: 2 }` so the last two user-led turns are kept verbatim
|
|
43
|
+
* while older content is summarized. Setting `{ turns: 0 }` reverts
|
|
44
|
+
* to the legacy behavior of summarizing every message.
|
|
45
|
+
*/
|
|
46
|
+
retainRecent?: RetainRecentConfig;
|
|
17
47
|
};
|
|
18
48
|
export interface SummarizeResult {
|
|
19
49
|
text: string;
|