@librechat/agents 4.0.1 → 4.0.3
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/agents/AgentContext.cjs +3 -2
- package/dist/cjs/agents/AgentContext.cjs.map +1 -1
- package/dist/cjs/decisions/deadline.cjs +52 -0
- package/dist/cjs/decisions/deadline.cjs.map +1 -0
- package/dist/cjs/decisions/dialect.cjs +88 -0
- package/dist/cjs/decisions/dialect.cjs.map +1 -0
- package/dist/cjs/decisions/http.cjs +77 -0
- package/dist/cjs/decisions/http.cjs.map +1 -0
- package/dist/cjs/decisions/index.cjs +7 -0
- package/dist/cjs/decisions/presets.cjs +82 -0
- package/dist/cjs/decisions/presets.cjs.map +1 -0
- package/dist/cjs/decisions/questions.cjs +70 -0
- package/dist/cjs/decisions/questions.cjs.map +1 -0
- package/dist/cjs/decisions/structuredChat.cjs +172 -0
- package/dist/cjs/decisions/structuredChat.cjs.map +1 -0
- package/dist/cjs/decisions/structuredOutput.cjs +18 -0
- package/dist/cjs/decisions/structuredOutput.cjs.map +1 -0
- package/dist/cjs/decisions/traceMarker.cjs +6 -0
- package/dist/cjs/decisions/traceMarker.cjs.map +1 -0
- package/dist/cjs/decisions/transport.cjs +166 -0
- package/dist/cjs/decisions/transport.cjs.map +1 -0
- package/dist/cjs/decisions/types.cjs +44 -0
- package/dist/cjs/decisions/types.cjs.map +1 -0
- package/dist/cjs/graphs/Graph.cjs +28 -9
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/langfuseToolOutputTracing.cjs +6 -1
- package/dist/cjs/langfuseToolOutputTracing.cjs.map +1 -1
- package/dist/cjs/llm/google/index.cjs +1 -1
- package/dist/cjs/llm/invoke.cjs +34 -12
- package/dist/cjs/llm/invoke.cjs.map +1 -1
- package/dist/cjs/llm/openai/index.cjs +7 -0
- package/dist/cjs/llm/openai/index.cjs.map +1 -1
- package/dist/cjs/llm/providerTextBoundary.cjs +355 -0
- package/dist/cjs/llm/providerTextBoundary.cjs.map +1 -0
- package/dist/cjs/llm/providerTextChunk.cjs +14 -0
- package/dist/cjs/llm/providerTextChunk.cjs.map +1 -0
- package/dist/cjs/llm/providerTextControls.cjs +236 -0
- package/dist/cjs/llm/providerTextControls.cjs.map +1 -0
- package/dist/cjs/llm/stream/smoother.cjs +2 -1
- package/dist/cjs/llm/stream/smoother.cjs.map +1 -1
- package/dist/cjs/main.cjs +49 -1
- package/dist/cjs/protection/providerText.cjs +224 -0
- package/dist/cjs/protection/providerText.cjs.map +1 -0
- package/dist/cjs/protection/providerTextInput.cjs +25 -0
- package/dist/cjs/protection/providerTextInput.cjs.map +1 -0
- package/dist/cjs/rerank/index.cjs +2 -0
- package/dist/cjs/rerank/search.cjs +45 -0
- package/dist/cjs/rerank/search.cjs.map +1 -0
- package/dist/cjs/rerank/systemone.cjs +70 -0
- package/dist/cjs/rerank/systemone.cjs.map +1 -0
- package/dist/cjs/run.cjs +11 -1
- package/dist/cjs/run.cjs.map +1 -1
- package/dist/cjs/stream.cjs +42 -14
- package/dist/cjs/stream.cjs.map +1 -1
- package/dist/cjs/summarization/node.cjs +26 -8
- package/dist/cjs/summarization/node.cjs.map +1 -1
- package/dist/cjs/tools/SubagentTool.cjs +11 -3
- package/dist/cjs/tools/SubagentTool.cjs.map +1 -1
- package/dist/cjs/tools/ToolNode.cjs +6 -5
- package/dist/cjs/tools/ToolNode.cjs.map +1 -1
- package/dist/cjs/tools/search/rerankers.cjs +1 -0
- package/dist/cjs/tools/search/search.cjs +3 -3
- package/dist/cjs/tools/search/search.cjs.map +1 -1
- package/dist/cjs/tools/search/tool.cjs +4 -3
- package/dist/cjs/tools/search/tool.cjs.map +1 -1
- package/dist/cjs/tools/subagent/SubagentExecutionRegistry.cjs +13 -2
- package/dist/cjs/tools/subagent/SubagentExecutionRegistry.cjs.map +1 -1
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs +149 -26
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs.map +1 -1
- package/dist/cjs/tools/subagent/SubagentReplay.cjs +4 -2
- package/dist/cjs/tools/subagent/SubagentReplay.cjs.map +1 -1
- package/dist/cjs/tools/subagent/childGraphConfig.cjs +3 -1
- package/dist/cjs/tools/subagent/childGraphConfig.cjs.map +1 -1
- package/dist/cjs/tools/subagent/diagnostics.cjs +88 -2
- package/dist/cjs/tools/subagent/diagnostics.cjs.map +1 -1
- package/dist/cjs/tools/subagent/hostArgs.cjs +214 -0
- package/dist/cjs/tools/subagent/hostArgs.cjs.map +1 -0
- package/dist/cjs/tools/subagent/index.cjs +2 -0
- package/dist/cjs/tools/toolErrorContent.cjs +1 -1
- package/dist/esm/agents/AgentContext.mjs +3 -2
- package/dist/esm/agents/AgentContext.mjs.map +1 -1
- package/dist/esm/decisions/deadline.mjs +52 -0
- package/dist/esm/decisions/deadline.mjs.map +1 -0
- package/dist/esm/decisions/dialect.mjs +87 -0
- package/dist/esm/decisions/dialect.mjs.map +1 -0
- package/dist/esm/decisions/http.mjs +75 -0
- package/dist/esm/decisions/http.mjs.map +1 -0
- package/dist/esm/decisions/index.mjs +8 -0
- package/dist/esm/decisions/presets.mjs +77 -0
- package/dist/esm/decisions/presets.mjs.map +1 -0
- package/dist/esm/decisions/questions.mjs +67 -0
- package/dist/esm/decisions/questions.mjs.map +1 -0
- package/dist/esm/decisions/structuredChat.mjs +172 -0
- package/dist/esm/decisions/structuredChat.mjs.map +1 -0
- package/dist/esm/decisions/structuredOutput.mjs +18 -0
- package/dist/esm/decisions/structuredOutput.mjs.map +1 -0
- package/dist/esm/decisions/traceMarker.mjs +6 -0
- package/dist/esm/decisions/traceMarker.mjs.map +1 -0
- package/dist/esm/decisions/transport.mjs +164 -0
- package/dist/esm/decisions/transport.mjs.map +1 -0
- package/dist/esm/decisions/types.mjs +39 -0
- package/dist/esm/decisions/types.mjs.map +1 -0
- package/dist/esm/graphs/Graph.mjs +28 -9
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/langfuseToolOutputTracing.mjs +6 -1
- package/dist/esm/langfuseToolOutputTracing.mjs.map +1 -1
- package/dist/esm/llm/google/index.mjs +1 -1
- package/dist/esm/llm/invoke.mjs +34 -12
- package/dist/esm/llm/invoke.mjs.map +1 -1
- package/dist/esm/llm/openai/index.mjs +7 -0
- package/dist/esm/llm/openai/index.mjs.map +1 -1
- package/dist/esm/llm/providerTextBoundary.mjs +355 -0
- package/dist/esm/llm/providerTextBoundary.mjs.map +1 -0
- package/dist/esm/llm/providerTextChunk.mjs +13 -0
- package/dist/esm/llm/providerTextChunk.mjs.map +1 -0
- package/dist/esm/llm/providerTextControls.mjs +230 -0
- package/dist/esm/llm/providerTextControls.mjs.map +1 -0
- package/dist/esm/llm/stream/smoother.mjs +2 -1
- package/dist/esm/llm/stream/smoother.mjs.map +1 -1
- package/dist/esm/main.mjs +16 -2
- package/dist/esm/protection/providerText.mjs +218 -0
- package/dist/esm/protection/providerText.mjs.map +1 -0
- package/dist/esm/protection/providerTextInput.mjs +24 -0
- package/dist/esm/protection/providerTextInput.mjs.map +1 -0
- package/dist/esm/rerank/index.mjs +3 -0
- package/dist/esm/rerank/search.mjs +45 -0
- package/dist/esm/rerank/search.mjs.map +1 -0
- package/dist/esm/rerank/systemone.mjs +70 -0
- package/dist/esm/rerank/systemone.mjs.map +1 -0
- package/dist/esm/run.mjs +11 -1
- package/dist/esm/run.mjs.map +1 -1
- package/dist/esm/stream.mjs +42 -14
- package/dist/esm/stream.mjs.map +1 -1
- package/dist/esm/summarization/node.mjs +26 -8
- package/dist/esm/summarization/node.mjs.map +1 -1
- package/dist/esm/tools/SubagentTool.mjs +11 -3
- package/dist/esm/tools/SubagentTool.mjs.map +1 -1
- package/dist/esm/tools/ToolNode.mjs +6 -5
- package/dist/esm/tools/ToolNode.mjs.map +1 -1
- package/dist/esm/tools/search/rerankers.mjs +1 -1
- package/dist/esm/tools/search/search.mjs +3 -3
- package/dist/esm/tools/search/search.mjs.map +1 -1
- package/dist/esm/tools/search/tool.mjs +4 -3
- package/dist/esm/tools/search/tool.mjs.map +1 -1
- package/dist/esm/tools/subagent/SubagentExecutionRegistry.mjs +13 -2
- package/dist/esm/tools/subagent/SubagentExecutionRegistry.mjs.map +1 -1
- package/dist/esm/tools/subagent/SubagentExecutor.mjs +149 -26
- package/dist/esm/tools/subagent/SubagentExecutor.mjs.map +1 -1
- package/dist/esm/tools/subagent/SubagentReplay.mjs +4 -2
- package/dist/esm/tools/subagent/SubagentReplay.mjs.map +1 -1
- package/dist/esm/tools/subagent/childGraphConfig.mjs +3 -1
- package/dist/esm/tools/subagent/childGraphConfig.mjs.map +1 -1
- package/dist/esm/tools/subagent/diagnostics.mjs +84 -3
- package/dist/esm/tools/subagent/diagnostics.mjs.map +1 -1
- package/dist/esm/tools/subagent/hostArgs.mjs +207 -0
- package/dist/esm/tools/subagent/hostArgs.mjs.map +1 -0
- package/dist/esm/tools/subagent/index.mjs +2 -0
- package/dist/esm/tools/toolErrorContent.mjs +1 -1
- package/dist/types/decisions/deadline.d.ts +3 -0
- package/dist/types/decisions/dialect.d.ts +11 -0
- package/dist/types/decisions/http.d.ts +22 -0
- package/dist/types/decisions/index.d.ts +10 -0
- package/dist/types/decisions/presets.d.ts +17 -0
- package/dist/types/decisions/questions.d.ts +8 -0
- package/dist/types/decisions/structuredChat.d.ts +17 -0
- package/dist/types/decisions/structuredOutput.d.ts +4 -0
- package/dist/types/decisions/traceMarker.d.ts +2 -0
- package/dist/types/decisions/transport.d.ts +29 -0
- package/dist/types/decisions/types.d.ts +119 -0
- package/dist/types/graphs/Graph.d.ts +7 -3
- package/dist/types/index.d.ts +4 -0
- package/dist/types/llm/invoke.d.ts +4 -1
- package/dist/types/llm/providerTextBoundary.d.ts +4 -0
- package/dist/types/llm/providerTextChunk.d.ts +7 -0
- package/dist/types/llm/providerTextControls.d.ts +18 -0
- package/dist/types/protection/providerText.d.ts +77 -0
- package/dist/types/protection/providerTextInput.d.ts +3 -0
- package/dist/types/rerank/index.d.ts +4 -0
- package/dist/types/rerank/search.d.ts +7 -0
- package/dist/types/rerank/systemone.d.ts +13 -0
- package/dist/types/rerank/types.d.ts +24 -0
- package/dist/types/run.d.ts +2 -0
- package/dist/types/tools/BashExecutor.d.ts +4 -0
- package/dist/types/tools/CodeExecutor.d.ts +4 -0
- package/dist/types/tools/ReadFile.d.ts +4 -0
- package/dist/types/tools/SkillTool.d.ts +4 -0
- package/dist/types/tools/SubagentTool.d.ts +2 -0
- package/dist/types/tools/ToolSearch.d.ts +4 -0
- package/dist/types/tools/search/schema.d.ts +4 -0
- package/dist/types/tools/search/types.d.ts +3 -1
- package/dist/types/tools/subagent/SubagentExecutionRegistry.d.ts +6 -0
- package/dist/types/tools/subagent/SubagentExecutor.d.ts +22 -1
- package/dist/types/tools/subagent/SubagentReplay.d.ts +3 -1
- package/dist/types/tools/subagent/diagnostics.d.ts +56 -8
- package/dist/types/tools/subagent/hostArgs.d.ts +57 -0
- package/dist/types/tools/subagent/index.d.ts +3 -0
- package/dist/types/types/graph.d.ts +39 -0
- package/dist/types/types/run.d.ts +6 -2
- package/dist/types/types/tools.d.ts +2 -0
- package/package.json +4 -4
- package/src/agents/AgentContext.ts +3 -2
- package/src/decisions/deadline.ts +92 -0
- package/src/decisions/dialect.ts +200 -0
- package/src/decisions/http.ts +175 -0
- package/src/decisions/index.ts +14 -0
- package/src/decisions/presets.ts +111 -0
- package/src/decisions/questions.ts +128 -0
- package/src/decisions/structuredChat.ts +358 -0
- package/src/decisions/structuredOutput.ts +25 -0
- package/src/decisions/traceMarker.ts +2 -0
- package/src/decisions/transport.ts +335 -0
- package/src/decisions/types.ts +193 -0
- package/src/graphs/Graph.ts +57 -9
- package/src/index.ts +9 -0
- package/src/langfuseToolOutputTracing.ts +8 -1
- package/src/llm/invoke.ts +48 -7
- package/src/llm/openai/index.ts +8 -0
- package/src/llm/providerTextBoundary.ts +446 -0
- package/src/llm/providerTextChunk.ts +15 -0
- package/src/llm/providerTextControls.ts +173 -0
- package/src/llm/stream/smoother.ts +4 -2
- package/src/protection/providerText.ts +325 -0
- package/src/protection/providerTextInput.ts +21 -0
- package/src/rerank/index.ts +4 -0
- package/src/rerank/search.ts +85 -0
- package/src/rerank/systemone.ts +140 -0
- package/src/rerank/types.ts +28 -0
- package/src/run.ts +13 -0
- package/src/stream.ts +33 -7
- package/src/summarization/node.ts +32 -14
- package/src/tools/SubagentTool.ts +14 -3
- package/src/tools/ToolNode.ts +7 -3
- package/src/tools/search/search.ts +4 -4
- package/src/tools/search/tool.ts +27 -25
- package/src/tools/search/types.ts +4 -1
- package/src/tools/subagent/SubagentExecutionRegistry.ts +27 -2
- package/src/tools/subagent/SubagentExecutor.ts +323 -28
- package/src/tools/subagent/SubagentReplay.ts +10 -3
- package/src/tools/subagent/childGraphConfig.ts +12 -1
- package/src/tools/subagent/diagnostics.ts +180 -9
- package/src/tools/subagent/hostArgs.ts +413 -0
- package/src/tools/subagent/index.ts +20 -0
- package/src/types/graph.ts +44 -0
- package/src/types/run.ts +6 -2
- package/src/types/tools.ts +6 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export declare const PROVIDER_TEXT_PROTECTION_VERSION = 1;
|
|
2
|
+
export type ProviderTextProtectionErrorCode = 'blocked' | 'unavailable' | 'timeout' | 'overflow' | 'cancelled' | 'unsupported' | 'incompatible';
|
|
3
|
+
export type ProviderTextProtectionResult = {
|
|
4
|
+
readonly version: 1;
|
|
5
|
+
readonly ok: true;
|
|
6
|
+
readonly value: {
|
|
7
|
+
readonly content: string;
|
|
8
|
+
readonly replacements: number;
|
|
9
|
+
readonly categories: readonly {
|
|
10
|
+
readonly category: string;
|
|
11
|
+
readonly count: number;
|
|
12
|
+
}[];
|
|
13
|
+
};
|
|
14
|
+
} | {
|
|
15
|
+
readonly version: 1;
|
|
16
|
+
readonly ok: false;
|
|
17
|
+
readonly error: {
|
|
18
|
+
readonly code: ProviderTextProtectionErrorCode;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
/** Trusted host adapter. Classification must reject code, JSON and ambiguous text. */
|
|
22
|
+
export interface ProviderTextProtection {
|
|
23
|
+
readonly version: 1;
|
|
24
|
+
readonly timeoutMs: number;
|
|
25
|
+
readonly maxAttemptBytes: number;
|
|
26
|
+
/** Shared across all attempts using this policy, including child graphs. */
|
|
27
|
+
readonly maxBufferedBytes: number;
|
|
28
|
+
readonly classify: (content: string) => 'prose' | 'unsupported';
|
|
29
|
+
readonly inspect: (input: {
|
|
30
|
+
readonly version: 1;
|
|
31
|
+
readonly content: string;
|
|
32
|
+
readonly target: {
|
|
33
|
+
readonly source: 'message';
|
|
34
|
+
readonly field: 'text';
|
|
35
|
+
readonly provenance: 'model';
|
|
36
|
+
};
|
|
37
|
+
readonly signal: AbortSignal;
|
|
38
|
+
}) => ProviderTextProtectionResult | Promise<ProviderTextProtectionResult>;
|
|
39
|
+
}
|
|
40
|
+
export declare class ProviderTextProtectionError extends Error {
|
|
41
|
+
readonly code: ProviderTextProtectionErrorCode;
|
|
42
|
+
constructor(code: ProviderTextProtectionErrorCode);
|
|
43
|
+
}
|
|
44
|
+
/** Internal control flow, never a host policy decision or public capability. */
|
|
45
|
+
export declare function createProviderTextRestartCancellation(): ProviderTextProtectionError;
|
|
46
|
+
export declare function isProviderTextRestartCancellation(error: unknown): boolean;
|
|
47
|
+
/** Provider smoothing must stay lazy while the release boundary owns raw text. */
|
|
48
|
+
export declare function isProtectedProviderTextSignal(signal?: AbortSignal): boolean;
|
|
49
|
+
export declare function validateProviderTextProtection(policy: ProviderTextProtection): void;
|
|
50
|
+
/** A lease stays charged while a cancellation-ignoring producer/handler still owns raw text. */
|
|
51
|
+
export declare class ProviderTextAttempt {
|
|
52
|
+
private readonly policy;
|
|
53
|
+
private readonly parent?;
|
|
54
|
+
private readonly controller;
|
|
55
|
+
private readonly budget;
|
|
56
|
+
private readonly deadline;
|
|
57
|
+
private bytes;
|
|
58
|
+
private textLength;
|
|
59
|
+
private readonly fragments;
|
|
60
|
+
private readonly pending;
|
|
61
|
+
private readonly timer;
|
|
62
|
+
private readonly abort;
|
|
63
|
+
private finished;
|
|
64
|
+
constructor(policy: ProviderTextProtection, parent?: AbortSignal | undefined);
|
|
65
|
+
get signal(): AbortSignal;
|
|
66
|
+
check(): void;
|
|
67
|
+
private charge;
|
|
68
|
+
append(text: string, cumulativeReplay?: boolean): void;
|
|
69
|
+
/** Compare buffered fragments without allocating an uncharged joined copy. */
|
|
70
|
+
private hasCandidatePrefix;
|
|
71
|
+
matchesText(text: string): boolean;
|
|
72
|
+
retain(bytes: number): void;
|
|
73
|
+
observeChunk(): void;
|
|
74
|
+
wait<T>(work: Promise<T>): Promise<T>;
|
|
75
|
+
release(): Promise<string>;
|
|
76
|
+
finish(): void;
|
|
77
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Logger, SearchReranker } from '@/tools/search/types';
|
|
2
|
+
import type { Reranker } from './types';
|
|
3
|
+
/** Adapts index-based rankings to web-search highlights and its existing metrics/fallback policy. */
|
|
4
|
+
export declare function createWebSearchReranker(reranker: Reranker, options?: {
|
|
5
|
+
timeoutMs?: number;
|
|
6
|
+
logger?: Logger;
|
|
7
|
+
}): SearchReranker;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Reranker } from './types';
|
|
2
|
+
import type { DecisionModel } from '@/decisions';
|
|
3
|
+
export interface SystemOneRerankerOptions {
|
|
4
|
+
/** Inject a configured Jev/Laya HTTP decision model; chat cannot produce expected scores. */
|
|
5
|
+
model: DecisionModel;
|
|
6
|
+
/** Relevance levels from least to most relevant; evaluate this rubric for the checkpoint. */
|
|
7
|
+
rubric: readonly string[];
|
|
8
|
+
/** Reject oversized batches instead of silently dropping candidates. Defaults to 128. */
|
|
9
|
+
maxDocuments?: number;
|
|
10
|
+
timeoutMs?: number;
|
|
11
|
+
}
|
|
12
|
+
/** One shared query/candidate state and one score question per candidate, in one request. */
|
|
13
|
+
export declare function createSystemOneReranker(options: SystemOneRerankerOptions): Reranker;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { DecisionUsage } from '@/decisions';
|
|
2
|
+
export interface RerankRequest {
|
|
3
|
+
query: string;
|
|
4
|
+
documents: readonly string[];
|
|
5
|
+
topK?: number;
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
timeoutMs?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface RankedDocument {
|
|
10
|
+
/** Index into the submitted documents, not an identity derived from text. */
|
|
11
|
+
index: number;
|
|
12
|
+
/** Provider-specific relevance score, ordered descending; not a portable threshold. */
|
|
13
|
+
score: number;
|
|
14
|
+
}
|
|
15
|
+
export interface RerankResult {
|
|
16
|
+
results: RankedDocument[];
|
|
17
|
+
model: string;
|
|
18
|
+
usage: DecisionUsage | null;
|
|
19
|
+
}
|
|
20
|
+
/** Rankings retain candidate identity; failures reject rather than fabricate scores. */
|
|
21
|
+
export interface Reranker {
|
|
22
|
+
readonly id: string;
|
|
23
|
+
rerank(request: RerankRequest): Promise<RerankResult>;
|
|
24
|
+
}
|
package/dist/types/run.d.ts
CHANGED
|
@@ -21,9 +21,11 @@ export declare class Run<_T extends t.BaseGraphState> {
|
|
|
21
21
|
private subagentUsageSink?;
|
|
22
22
|
private preemption?;
|
|
23
23
|
private maxStopContinuations;
|
|
24
|
+
private providerTextProtection?;
|
|
24
25
|
private streamLimits?;
|
|
25
26
|
private subagentTasks?;
|
|
26
27
|
private subagentContext?;
|
|
28
|
+
private onSubagentResolutionFailure?;
|
|
27
29
|
private indexTokenCountMap?;
|
|
28
30
|
calibrationRatio: number;
|
|
29
31
|
fadingTier?: t.FadingTier;
|
|
@@ -11,6 +11,8 @@ export declare const BashExecutionToolSchema: {
|
|
|
11
11
|
readonly properties?: Record<string, t.JsonSchemaType>;
|
|
12
12
|
readonly required?: string[];
|
|
13
13
|
readonly description?: string;
|
|
14
|
+
readonly pattern?: string;
|
|
15
|
+
readonly maxLength?: number;
|
|
14
16
|
readonly additionalProperties?: boolean | t.JsonSchemaType;
|
|
15
17
|
};
|
|
16
18
|
readonly command: {
|
|
@@ -89,6 +91,8 @@ export declare const BashExecutionToolDefinition: {
|
|
|
89
91
|
readonly properties?: Record<string, t.JsonSchemaType>;
|
|
90
92
|
readonly required?: string[];
|
|
91
93
|
readonly description?: string;
|
|
94
|
+
readonly pattern?: string;
|
|
95
|
+
readonly maxLength?: number;
|
|
92
96
|
readonly additionalProperties?: boolean | t.JsonSchemaType;
|
|
93
97
|
};
|
|
94
98
|
readonly command: {
|
|
@@ -23,6 +23,8 @@ export declare const CodeExecutionToolSchema: {
|
|
|
23
23
|
readonly properties?: Record<string, t.JsonSchemaType>;
|
|
24
24
|
readonly required?: string[];
|
|
25
25
|
readonly description?: string;
|
|
26
|
+
readonly pattern?: string;
|
|
27
|
+
readonly maxLength?: number;
|
|
26
28
|
readonly additionalProperties?: boolean | t.JsonSchemaType;
|
|
27
29
|
};
|
|
28
30
|
readonly lang: {
|
|
@@ -107,6 +109,8 @@ export declare const CodeExecutionToolDefinition: {
|
|
|
107
109
|
readonly properties?: Record<string, t.JsonSchemaType>;
|
|
108
110
|
readonly required?: string[];
|
|
109
111
|
readonly description?: string;
|
|
112
|
+
readonly pattern?: string;
|
|
113
|
+
readonly maxLength?: number;
|
|
110
114
|
readonly additionalProperties?: boolean | t.JsonSchemaType;
|
|
111
115
|
};
|
|
112
116
|
readonly lang: {
|
|
@@ -11,6 +11,8 @@ export declare const ReadFileToolSchema: {
|
|
|
11
11
|
readonly properties?: Record<string, import("..").JsonSchemaType>;
|
|
12
12
|
readonly required?: string[];
|
|
13
13
|
readonly description?: string;
|
|
14
|
+
readonly pattern?: string;
|
|
15
|
+
readonly maxLength?: number;
|
|
14
16
|
readonly additionalProperties?: boolean | import("..").JsonSchemaType;
|
|
15
17
|
};
|
|
16
18
|
readonly path: {
|
|
@@ -33,6 +35,8 @@ export declare const ReadFileToolDefinition: {
|
|
|
33
35
|
readonly properties?: Record<string, import("..").JsonSchemaType>;
|
|
34
36
|
readonly required?: string[];
|
|
35
37
|
readonly description?: string;
|
|
38
|
+
readonly pattern?: string;
|
|
39
|
+
readonly maxLength?: number;
|
|
36
40
|
readonly additionalProperties?: boolean | import("..").JsonSchemaType;
|
|
37
41
|
};
|
|
38
42
|
readonly path: {
|
|
@@ -16,6 +16,8 @@ export declare const SkillToolSchema: {
|
|
|
16
16
|
readonly properties?: Record<string, import("..").JsonSchemaType>;
|
|
17
17
|
readonly required?: string[];
|
|
18
18
|
readonly description?: string;
|
|
19
|
+
readonly pattern?: string;
|
|
20
|
+
readonly maxLength?: number;
|
|
19
21
|
readonly additionalProperties?: boolean | import("..").JsonSchemaType;
|
|
20
22
|
};
|
|
21
23
|
readonly skillName: {
|
|
@@ -42,6 +44,8 @@ export declare const SkillToolDefinition: {
|
|
|
42
44
|
readonly properties?: Record<string, import("..").JsonSchemaType>;
|
|
43
45
|
readonly required?: string[];
|
|
44
46
|
readonly description?: string;
|
|
47
|
+
readonly pattern?: string;
|
|
48
|
+
readonly maxLength?: number;
|
|
45
49
|
readonly additionalProperties?: boolean | import("..").JsonSchemaType;
|
|
46
50
|
};
|
|
47
51
|
readonly skillName: {
|
|
@@ -13,6 +13,8 @@ export declare const SubagentToolSchema: {
|
|
|
13
13
|
readonly properties?: Record<string, JsonSchemaType>;
|
|
14
14
|
readonly required?: string[];
|
|
15
15
|
readonly description?: string;
|
|
16
|
+
readonly pattern?: string;
|
|
17
|
+
readonly maxLength?: number;
|
|
16
18
|
readonly additionalProperties?: boolean | JsonSchemaType;
|
|
17
19
|
};
|
|
18
20
|
readonly description: {
|
|
@@ -13,6 +13,8 @@ export declare const ToolSearchToolSchema: {
|
|
|
13
13
|
readonly properties?: Record<string, t.JsonSchemaType>;
|
|
14
14
|
readonly required?: string[];
|
|
15
15
|
readonly description?: string;
|
|
16
|
+
readonly pattern?: string;
|
|
17
|
+
readonly maxLength?: number;
|
|
16
18
|
readonly additionalProperties?: boolean | t.JsonSchemaType;
|
|
17
19
|
};
|
|
18
20
|
readonly query: {
|
|
@@ -64,6 +66,8 @@ export declare const ToolSearchToolDefinition: {
|
|
|
64
66
|
readonly properties?: Record<string, t.JsonSchemaType>;
|
|
65
67
|
readonly required?: string[];
|
|
66
68
|
readonly description?: string;
|
|
69
|
+
readonly pattern?: string;
|
|
70
|
+
readonly maxLength?: number;
|
|
67
71
|
readonly additionalProperties?: boolean | t.JsonSchemaType;
|
|
68
72
|
};
|
|
69
73
|
readonly query: {
|
|
@@ -43,6 +43,8 @@ export declare const WebSearchToolSchema: {
|
|
|
43
43
|
readonly properties?: Record<string, import("../..").JsonSchemaType>;
|
|
44
44
|
readonly required?: string[];
|
|
45
45
|
readonly description?: string;
|
|
46
|
+
readonly pattern?: string;
|
|
47
|
+
readonly maxLength?: number;
|
|
46
48
|
readonly additionalProperties?: boolean | import("../..").JsonSchemaType;
|
|
47
49
|
};
|
|
48
50
|
readonly query: {
|
|
@@ -88,6 +90,8 @@ export declare const WebSearchToolDefinition: {
|
|
|
88
90
|
readonly properties?: Record<string, import("../..").JsonSchemaType>;
|
|
89
91
|
readonly required?: string[];
|
|
90
92
|
readonly description?: string;
|
|
93
|
+
readonly pattern?: string;
|
|
94
|
+
readonly maxLength?: number;
|
|
91
95
|
readonly additionalProperties?: boolean | import("../..").JsonSchemaType;
|
|
92
96
|
};
|
|
93
97
|
readonly query: {
|
|
@@ -239,6 +239,8 @@ export interface ScrapeResult {
|
|
|
239
239
|
references?: References;
|
|
240
240
|
highlights?: Highlight[];
|
|
241
241
|
}
|
|
242
|
+
/** Host implementations need only the public ranking seam, not BaseReranker's private state. */
|
|
243
|
+
export type SearchReranker = Pick<BaseReranker, 'provider' | 'rerank'>;
|
|
242
244
|
export interface ProcessSourcesConfig {
|
|
243
245
|
topResults?: number;
|
|
244
246
|
/** Max chars of scraped content stored per source and passed to the
|
|
@@ -258,7 +260,7 @@ export interface ProcessSourcesConfig {
|
|
|
258
260
|
separatorExpandBy?: number;
|
|
259
261
|
strategies?: string[];
|
|
260
262
|
filterContent?: boolean;
|
|
261
|
-
reranker?:
|
|
263
|
+
reranker?: SearchReranker;
|
|
262
264
|
logger?: Logger;
|
|
263
265
|
}
|
|
264
266
|
export interface FirecrawlConfig {
|
|
@@ -44,6 +44,8 @@ export type SubagentInvocationBinding = Readonly<{
|
|
|
44
44
|
description: string;
|
|
45
45
|
subagentType: string;
|
|
46
46
|
configId?: string;
|
|
47
|
+
/** Value-free identity of the call's validated host arguments. */
|
|
48
|
+
hostArgsDigest?: string;
|
|
47
49
|
}>;
|
|
48
50
|
export type SubagentSettlementBinding = Readonly<{
|
|
49
51
|
definitionAuthority: 'provisional' | 'effective';
|
|
@@ -98,6 +100,7 @@ export declare class SubagentSettlementBindingError extends Error {
|
|
|
98
100
|
export declare class SubagentExecutionRecord<TResult, TResolvedConfig, TActiveRun, TSettledOutput = never> {
|
|
99
101
|
readonly address: SubagentExecutionAddress;
|
|
100
102
|
private identityValue?;
|
|
103
|
+
private attemptedIdentityValue?;
|
|
101
104
|
private bindingValue?;
|
|
102
105
|
private bindingAuthority?;
|
|
103
106
|
private invocationValue?;
|
|
@@ -118,6 +121,9 @@ export declare class SubagentExecutionRecord<TResult, TResolvedConfig, TActiveRu
|
|
|
118
121
|
constructor(address: SubagentExecutionAddress, resumeExecution?: SubagentResumeExecution);
|
|
119
122
|
get snapshot(): ExecutionSnapshot<TResult, TResolvedConfig, TActiveRun>;
|
|
120
123
|
get identity(): SubagentExecutionIdentity | undefined;
|
|
124
|
+
/** Correlation only; never committed identity or resume authority. */
|
|
125
|
+
get attemptedIdentity(): SubagentExecutionIdentity | undefined;
|
|
126
|
+
recordIdentityAttempt(identity: SubagentExecutionIdentity): void;
|
|
121
127
|
get binding(): SubagentDefinitionBinding | undefined;
|
|
122
128
|
get resumeExecution(): SubagentResumeExecution | undefined;
|
|
123
129
|
get invocation(): SubagentInvocationBinding | undefined;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { BaseMessage } from '@langchain/core/messages';
|
|
2
2
|
import type { RunnableConfig } from '@langchain/core/runnables';
|
|
3
3
|
import type { ToolCall } from '@langchain/core/messages/tool';
|
|
4
|
-
import type { MultiAgentGraphState, HumanInTheLoopConfig, StandardGraphInput, ExecutableSubagentConfigEntry, SubagentExecutionContext, SubagentContextAdapter, SubagentContextResult, SubagentTaskConfig, SubagentTaskRuntime, SubagentUsageSink, TokenCounter } from '@/types';
|
|
4
|
+
import type { MultiAgentGraphState, HumanInTheLoopConfig, StandardGraphInput, ExecutableSubagentConfigEntry, SubagentExecutionContext, SubagentContextAdapter, SubagentContextResult, SubagentTaskConfig, SubagentTaskRuntime, SubagentHostArgs, SubagentUsageSink, TokenCounter } from '@/types';
|
|
5
|
+
import type { SubagentResolutionPhase, SubagentResolutionCause, SubagentHostArgumentFailure, SubagentResolutionFailureHandler } from './diagnostics';
|
|
5
6
|
import type { SubagentResumeManifest, SettledSubagentToolOutput } from './SubagentReplay';
|
|
6
7
|
import type { GraphFactory } from '@/graphs/graphFactory';
|
|
7
8
|
import type { StandardGraph } from '@/graphs/Graph';
|
|
@@ -70,10 +71,21 @@ export type SubagentExecuteParams = {
|
|
|
70
71
|
taskRuntime?: SubagentTaskRuntime;
|
|
71
72
|
/** Host-restored child transcript for a fresh continuation run. @internal */
|
|
72
73
|
initialMessages?: BaseMessage[];
|
|
74
|
+
/**
|
|
75
|
+
* Values for the selected subagent's declared `hostArgs`. Checked against
|
|
76
|
+
* the declaration before an execution opens, then bound to it.
|
|
77
|
+
*/
|
|
78
|
+
hostArgs?: SubagentHostArgs;
|
|
73
79
|
};
|
|
74
80
|
export type SubagentExecuteResult = SubagentContextResult & {
|
|
75
81
|
/** Tagged internal failure; foreground callers retain the legacy content. */
|
|
76
82
|
error?: string;
|
|
83
|
+
/** Safe startup classification retained for detached host delivery. */
|
|
84
|
+
resolutionFailure?: {
|
|
85
|
+
phase: SubagentResolutionPhase;
|
|
86
|
+
cause: SubagentResolutionCause;
|
|
87
|
+
hostArgument?: SubagentHostArgumentFailure;
|
|
88
|
+
};
|
|
77
89
|
/** Completed child work whose host projection must be retried without re-execution. */
|
|
78
90
|
retryableDelivery?: true;
|
|
79
91
|
};
|
|
@@ -114,6 +126,7 @@ export type SubagentExecutorOptions = {
|
|
|
114
126
|
* graph's own resolved limits; without this the child would silently
|
|
115
127
|
* revert to the defaults.
|
|
116
128
|
*/
|
|
129
|
+
providerTextProtection?: StandardGraphInput['providerTextProtection'];
|
|
117
130
|
streamLimits?: StandardGraphInput['streamLimits'];
|
|
118
131
|
humanInTheLoop?: HumanInTheLoopConfig;
|
|
119
132
|
/** Shared durable saver used to recover outer tool lifecycle results before
|
|
@@ -161,6 +174,8 @@ export type SubagentExecutorOptions = {
|
|
|
161
174
|
/** Host-owned process-local task namespace for detached execution. */
|
|
162
175
|
taskConfig?: SubagentTaskConfig;
|
|
163
176
|
subagentContext?: SubagentContextAdapter;
|
|
177
|
+
/** Host diagnostic sink and safe cause classifier for startup failures. */
|
|
178
|
+
onResolutionFailure?: SubagentResolutionFailureHandler;
|
|
164
179
|
};
|
|
165
180
|
export declare class SubagentExecutor {
|
|
166
181
|
private readonly configs;
|
|
@@ -179,6 +194,7 @@ export declare class SubagentExecutor {
|
|
|
179
194
|
private readonly executionContext;
|
|
180
195
|
private readonly langfuse?;
|
|
181
196
|
private readonly tokenCounter?;
|
|
197
|
+
private readonly providerTextProtection?;
|
|
182
198
|
private readonly streamLimits?;
|
|
183
199
|
private readonly humanInTheLoop?;
|
|
184
200
|
private readonly checkpointer?;
|
|
@@ -189,6 +205,7 @@ export declare class SubagentExecutor {
|
|
|
189
205
|
private readonly usageSink?;
|
|
190
206
|
private readonly taskConfig?;
|
|
191
207
|
private readonly subagentContext?;
|
|
208
|
+
private readonly onResolutionFailure?;
|
|
192
209
|
private readonly executions;
|
|
193
210
|
private replayCheckpointWorkflow?;
|
|
194
211
|
private readonly resolveParentHandlerRegistry?;
|
|
@@ -264,9 +281,13 @@ export declare class SubagentExecutor {
|
|
|
264
281
|
clearHeavyState(): void;
|
|
265
282
|
private getResumeCheckpointMarker;
|
|
266
283
|
getSettledToolOutput(call: ToolCall, config: RunnableConfig): Promise<SettledSubagentToolOutput | undefined>;
|
|
284
|
+
private restoreSettledToolOutput;
|
|
267
285
|
persistSettledToolOutput(call: ToolCall, config: RunnableConfig, settled: SettledSubagentToolOutput): Promise<void>;
|
|
268
286
|
private persistChildCheckpointMarker;
|
|
269
287
|
execute(params: SubagentExecuteParams): Promise<SubagentExecuteResult>;
|
|
288
|
+
private getReplaySignal;
|
|
289
|
+
private createReplayResolutionError;
|
|
290
|
+
private createResolutionFailure;
|
|
270
291
|
private executeOnce;
|
|
271
292
|
private completeHostContext;
|
|
272
293
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ToolCall, ToolMessage } from '@langchain/core/messages/tool';
|
|
2
2
|
import type { RunnableConfig } from '@langchain/core/runnables';
|
|
3
|
+
import type { FadingTier, FadingTiers, RunStepResumeState, ToolSessionContext } from '@/types';
|
|
3
4
|
import type { ToolOutputReferenceState } from '@/tools/toolOutputReferences';
|
|
4
5
|
import type { ToolApprovalReplaySnapshot } from '@/hooks';
|
|
5
|
-
import type { FadingTier, FadingTiers, RunStepResumeState, ToolSessionContext } from '@/types';
|
|
6
6
|
export declare const SUBAGENT_RESUME_MANIFEST_CONFIG_KEY = "__librechat_subagent_resume_manifest";
|
|
7
7
|
export declare const SUBAGENT_RESUME_ATTEMPT_CONFIG_KEY = "__librechat_subagent_resume_attempt";
|
|
8
8
|
export declare const SUBAGENT_PARENT_BATCH_CONFIG_KEY = "__librechat_subagent_parent_batch";
|
|
@@ -56,6 +56,8 @@ export interface SubagentResumeExecution {
|
|
|
56
56
|
subagentType?: string;
|
|
57
57
|
/** Lazy child revision bound when this execution first resolved. */
|
|
58
58
|
configId?: string;
|
|
59
|
+
/** SHA-256 identity of the host arguments bound to this execution; never the values. */
|
|
60
|
+
hostArgsDigest?: string;
|
|
59
61
|
approvalExecutionScope: string;
|
|
60
62
|
checkpoints: SubagentCheckpointReference[];
|
|
61
63
|
graphState: SubagentGraphResumeState;
|
|
@@ -1,20 +1,68 @@
|
|
|
1
|
+
import type { SubagentHostArgs } from '@/types/graph';
|
|
1
2
|
import { SubagentSettlementBindingError, SubagentDefinitionBindingError, SubagentInvocationBindingError, SubagentExecutionInvalidatedError } from './SubagentExecutionRegistry';
|
|
2
3
|
import { describeCodeApiError } from '@/tools/diagnostics';
|
|
3
4
|
/** Which step of child start-up failed: execution identity, then host config resolution. */
|
|
4
5
|
export type SubagentResolutionPhase = 'identity' | 'config';
|
|
5
|
-
|
|
6
|
-
type
|
|
6
|
+
/** Why a host resolver refused a declared host argument value. */
|
|
7
|
+
export type SubagentHostArgumentRejection = 'unavailable' | 'not_allowed';
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* operator account of it; the host logs its own error text where it throws.
|
|
9
|
+
* Thrown by a lazy resolver to refuse one declared host argument value. The
|
|
10
|
+
* parent model receives a fixed message naming the argument; the value and
|
|
11
|
+
* any error text stay private.
|
|
12
12
|
*/
|
|
13
|
+
export declare class SubagentHostArgumentError extends Error {
|
|
14
|
+
readonly argument: string;
|
|
15
|
+
readonly rejection: SubagentHostArgumentRejection;
|
|
16
|
+
constructor(argument: string, rejection: SubagentHostArgumentRejection);
|
|
17
|
+
}
|
|
18
|
+
/** Safe host-argument refusal retained across the detached delivery boundary. */
|
|
19
|
+
export type SubagentHostArgumentFailure = {
|
|
20
|
+
argument: string;
|
|
21
|
+
rejection: SubagentHostArgumentRejection;
|
|
22
|
+
};
|
|
23
|
+
declare const SUBAGENT_ERROR_TYPES: readonly [readonly ["SubagentHostArgumentError", typeof SubagentHostArgumentError], readonly ["SubagentExecutionInvalidatedError", typeof SubagentExecutionInvalidatedError], readonly ["SubagentDefinitionBindingError", typeof SubagentDefinitionBindingError], readonly ["SubagentInvocationBindingError", typeof SubagentInvocationBindingError], readonly ["SubagentSettlementBindingError", typeof SubagentSettlementBindingError]];
|
|
24
|
+
type SubagentErrorLabel = (typeof SUBAGENT_ERROR_TYPES)[number][0] | ReturnType<typeof describeCodeApiError>['type'];
|
|
25
|
+
declare const SUBAGENT_RESOLUTION_MESSAGES: {
|
|
26
|
+
readonly workspace_unavailable: "Subagent error: Workspace unavailable. Retry later or choose another workspace.";
|
|
27
|
+
readonly agent_unavailable: "Subagent error: Agent not found or not accessible.";
|
|
28
|
+
readonly model_unavailable: "Subagent error: Model or provider unavailable.";
|
|
29
|
+
readonly configuration_changed: "Subagent error: Subagent configuration changed. Start a new execution.";
|
|
30
|
+
readonly host_argument_rejected: "Subagent error: A requested subagent argument is not available. Omit it to let the host choose, or pass a different value.";
|
|
31
|
+
readonly unknown: "Subagent error: Unable to initialize the selected subagent.";
|
|
32
|
+
};
|
|
33
|
+
/** Host classifications accepted at the public failure boundary. */
|
|
34
|
+
export type SubagentResolutionCause = keyof typeof SUBAGENT_RESOLUTION_MESSAGES;
|
|
35
|
+
export type SubagentResolutionContext = {
|
|
36
|
+
parentRunId: string;
|
|
37
|
+
parentAgentId?: string;
|
|
38
|
+
parentToolCallId?: string;
|
|
39
|
+
threadId?: string;
|
|
40
|
+
childRunId: string;
|
|
41
|
+
childThreadId: string;
|
|
42
|
+
taskId?: string;
|
|
43
|
+
};
|
|
44
|
+
/** No received error text, writable error names, or stacks enter this payload. */
|
|
13
45
|
export type SubagentResolutionDiagnostic = {
|
|
14
46
|
phase: SubagentResolutionPhase;
|
|
15
47
|
subagentType: string;
|
|
16
48
|
aborted: boolean;
|
|
17
49
|
type: SubagentErrorLabel;
|
|
18
|
-
|
|
19
|
-
|
|
50
|
+
cause: SubagentResolutionCause;
|
|
51
|
+
message: (typeof SUBAGENT_RESOLUTION_MESSAGES)[SubagentResolutionCause];
|
|
52
|
+
} & Partial<SubagentResolutionContext>;
|
|
53
|
+
/** The original error is private. Return a classification, never error text. */
|
|
54
|
+
export type SubagentResolutionFailureHandler = (detail: Readonly<SubagentResolutionDiagnostic>, error: unknown) => SubagentResolutionCause | void;
|
|
55
|
+
export declare function getSubagentResolutionFailureMessage(cause: SubagentResolutionCause): SubagentResolutionDiagnostic['message'];
|
|
56
|
+
/** Returns a resolver's typed host-argument refusal when its name is safe to show. */
|
|
57
|
+
export declare function getSubagentHostArgumentFailure(error: unknown, suppliedHostArgs: SubagentHostArgs | undefined): SubagentHostArgumentFailure | undefined;
|
|
58
|
+
/** Model-facing message for a refused host argument. */
|
|
59
|
+
export declare function getSubagentHostArgumentFailureMessage(failure: SubagentHostArgumentFailure): string;
|
|
60
|
+
/** Safe typed failure retained when detached execution crosses the host boundary. */
|
|
61
|
+
export declare class SubagentResolutionError extends Error {
|
|
62
|
+
readonly phase: SubagentResolutionPhase;
|
|
63
|
+
readonly resolutionCause: SubagentResolutionCause;
|
|
64
|
+
readonly hostArgument?: SubagentHostArgumentFailure;
|
|
65
|
+
constructor(phase: SubagentResolutionPhase, cause: SubagentResolutionCause, hostArgument?: SubagentHostArgumentFailure);
|
|
66
|
+
}
|
|
67
|
+
export declare function logSubagentResolutionFailure(phase: SubagentResolutionPhase, subagentType: string, signal: AbortSignal, error: unknown, context?: SubagentResolutionContext, onResolutionFailure?: SubagentResolutionFailureHandler, suppliedHostArgs?: SubagentHostArgs): SubagentResolutionDiagnostic;
|
|
20
68
|
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { SubagentHostArgs, SubagentHostArgSpec, SubagentHostArgSpecs } from '@/types/graph';
|
|
2
|
+
import type { JsonSchemaType } from '@/types/tools';
|
|
3
|
+
/** Bounds on host-declared subagent call arguments and their values. */
|
|
4
|
+
export declare const SUBAGENT_HOST_ARG_LIMITS: Readonly<{
|
|
5
|
+
argsPerSubagent: 8;
|
|
6
|
+
distinctArgs: 16;
|
|
7
|
+
enumValues: 64;
|
|
8
|
+
mergedEnumValues: 256;
|
|
9
|
+
valueLength: 256;
|
|
10
|
+
descriptionLength: 1024;
|
|
11
|
+
}>;
|
|
12
|
+
/** Any subagent entry that may declare host arguments. */
|
|
13
|
+
export type SubagentHostArgDeclaration = {
|
|
14
|
+
type: string;
|
|
15
|
+
hostArgs?: SubagentHostArgSpecs;
|
|
16
|
+
};
|
|
17
|
+
export type SubagentHostArgsResult = {
|
|
18
|
+
ok: true;
|
|
19
|
+
hostArgs?: SubagentHostArgs;
|
|
20
|
+
} | {
|
|
21
|
+
ok: false;
|
|
22
|
+
message: string;
|
|
23
|
+
};
|
|
24
|
+
type HostArgEntry = readonly [string, SubagentHostArgSpec];
|
|
25
|
+
/** A name a host may declare: lowercase snake case, not a built-in subagent argument. */
|
|
26
|
+
export declare function isSubagentHostArgName(name: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Returns a subagent's validated host argument declarations in declaration
|
|
29
|
+
* order. Throws on a malformed or oversized declaration.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getSubagentHostArgSpecs(config: SubagentHostArgDeclaration): readonly HostArgEntry[];
|
|
32
|
+
/** Every host argument name declared by at least one subagent. */
|
|
33
|
+
export declare function collectSubagentHostArgNames(configs: readonly SubagentHostArgDeclaration[]): ReadonlySet<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Builds one optional tool property per declared host argument plus a
|
|
36
|
+
* per-type summary of the values each subagent accepts. The first
|
|
37
|
+
* declaration's description wins; enums are unioned across subagents.
|
|
38
|
+
*/
|
|
39
|
+
export declare function buildSubagentHostArgProperties(configs: readonly SubagentHostArgDeclaration[]): {
|
|
40
|
+
properties: Record<string, JsonSchemaType>;
|
|
41
|
+
summaries: ReadonlyMap<string, string>;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Reads the declared host argument properties from raw tool input. Missing,
|
|
45
|
+
* null, and blank values count as omitted; other non-string values are
|
|
46
|
+
* rejected rather than coerced.
|
|
47
|
+
*/
|
|
48
|
+
export declare function pickSubagentHostArgInput(input: object, names: ReadonlySet<string>): SubagentHostArgsResult;
|
|
49
|
+
/**
|
|
50
|
+
* Checks call values against the selected subagent's declarations and
|
|
51
|
+
* returns them frozen in canonical key order. Rejects arguments the selected
|
|
52
|
+
* subagent does not declare, including ones declared by a sibling.
|
|
53
|
+
*/
|
|
54
|
+
export declare function resolveSubagentHostArgs(config: SubagentHostArgDeclaration, hostArgs: SubagentHostArgs | undefined): SubagentHostArgsResult;
|
|
55
|
+
/** Opaque, value-free identity of a call's host arguments for replay records. */
|
|
56
|
+
export declare function getSubagentHostArgsDigest(hostArgs: SubagentHostArgs | undefined): string | undefined;
|
|
57
|
+
export {};
|
|
@@ -2,3 +2,6 @@ export { DEFAULT_SUBAGENT_DESCRIPTION, SubagentExecutor, filterSubagentResult, f
|
|
|
2
2
|
export type { SubagentExecuteParams, SubagentExecuteResult, SubagentExecutorOptions, ChildGraphFactory, } from './SubagentExecutor';
|
|
3
3
|
export { InMemorySubagentTaskStore } from './InMemorySubagentTaskStore';
|
|
4
4
|
export type { InMemorySubagentTaskStoreOptions } from './InMemorySubagentTaskStore';
|
|
5
|
+
export { SubagentResolutionError, SubagentHostArgumentError, getSubagentResolutionFailureMessage, getSubagentHostArgumentFailureMessage, } from './diagnostics';
|
|
6
|
+
export { SUBAGENT_HOST_ARG_LIMITS, buildSubagentHostArgProperties, resolveSubagentHostArgs, } from './hostArgs';
|
|
7
|
+
export type { SubagentHostArgumentFailure, SubagentHostArgumentRejection, SubagentResolutionPhase, SubagentResolutionCause, SubagentResolutionContext, SubagentResolutionDiagnostic, SubagentResolutionFailureHandler, } from './diagnostics';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ProviderTextProtection } from '@/protection/providerText';
|
|
1
2
|
import type { BaseMessage, AIMessageChunk, SystemMessage, UsageMetadata } from '@langchain/core/messages';
|
|
2
3
|
import type { BindToolsInput } from '@langchain/core/language_models/chat_models';
|
|
3
4
|
import type { START, StateGraph, StateGraphArgs } from '@langchain/langgraph';
|
|
@@ -8,6 +9,7 @@ import type { RunStep, ModelResponseEvent, ModelToolsClaimedEvent, RunStepDeltaE
|
|
|
8
9
|
import type { SummarizationNodeInput, SummarizeCompleteEvent, CompactionSemanticIndex, SummarizationConfig, SummarizeStartEvent, SummarizeDeltaEvent } from '@/types/summarize';
|
|
9
10
|
import type { ToolMap, ToolSessionMap, ToolEndEvent, GenericTool, LCTool, ToolExecutionConfig, ToolExecuteBatchRequest } from '@/types/tools';
|
|
10
11
|
import type { TokenCounter, StreamLimits, StreamPreemption, TokenBudgetBreakdown } from '@/types/run';
|
|
12
|
+
import type { SubagentResolutionFailureHandler } from '@/tools/subagent/diagnostics';
|
|
11
13
|
import type { SubagentTaskConfig } from '@/types/subagentTasks';
|
|
12
14
|
import type { StandardGraph, MultiAgentGraph } from '@/graphs';
|
|
13
15
|
import type { ProviderClientOptionsConfig } from '@/types/llm';
|
|
@@ -286,6 +288,7 @@ export type ModelEndData = (StreamEventData & {
|
|
|
286
288
|
}) | undefined;
|
|
287
289
|
export type GraphTools = GenericTool[] | BindToolsInput[] | GoogleAIToolType[];
|
|
288
290
|
export type StandardGraphInput = {
|
|
291
|
+
providerTextProtection?: ProviderTextProtection;
|
|
289
292
|
runId?: string;
|
|
290
293
|
signal?: AbortSignal;
|
|
291
294
|
agents: AgentInputs[];
|
|
@@ -320,6 +323,8 @@ export type StandardGraphInput = {
|
|
|
320
323
|
subagentTasks?: SubagentTaskConfig;
|
|
321
324
|
/** Host-owned context and result projection for each isolated child execution. */
|
|
322
325
|
subagentContext?: SubagentContextAdapter;
|
|
326
|
+
/** Receives private startup errors; returns only an SDK-owned public cause. */
|
|
327
|
+
onSubagentResolutionFailure?: SubagentResolutionFailureHandler;
|
|
323
328
|
/**
|
|
324
329
|
* True when this graph IS a subagent child run (set by `SubagentExecutor`
|
|
325
330
|
* when it constructs the child graph). Drives the hook-input `agentId`
|
|
@@ -433,6 +438,26 @@ export interface SubagentResolveConfigurable {
|
|
|
433
438
|
user?: Readonly<SubagentResolveUserContext>;
|
|
434
439
|
user_id?: string;
|
|
435
440
|
}
|
|
441
|
+
/**
|
|
442
|
+
* Optional string argument a host lets the parent model pass on a subagent
|
|
443
|
+
* call, such as where the child should run. The SDK checks the declared shape
|
|
444
|
+
* before resolution; the host still authorizes the value in its resolver.
|
|
445
|
+
*/
|
|
446
|
+
export interface SubagentHostArgSpec {
|
|
447
|
+
/** Model-facing explanation of the argument and when to pass it. */
|
|
448
|
+
description: string;
|
|
449
|
+
/**
|
|
450
|
+
* Values this subagent accepts. Omit to accept a bounded free-form string,
|
|
451
|
+
* whose format the resolver must check.
|
|
452
|
+
*/
|
|
453
|
+
enum?: readonly string[];
|
|
454
|
+
/** Maximum length of a free-form value (at most 256). */
|
|
455
|
+
maxLength?: number;
|
|
456
|
+
}
|
|
457
|
+
/** Host argument declarations keyed by tool-call property name. */
|
|
458
|
+
export type SubagentHostArgSpecs = Readonly<Record<string, SubagentHostArgSpec>>;
|
|
459
|
+
/** Validated host argument values from one subagent call. */
|
|
460
|
+
export type SubagentHostArgs = Readonly<Record<string, string>>;
|
|
436
461
|
/** Runtime context supplied when a host lazily resolves a selected subagent. */
|
|
437
462
|
export interface SubagentResolveContext {
|
|
438
463
|
/** Stable subagent identity selected by the model. */
|
|
@@ -451,6 +476,13 @@ export interface SubagentResolveContext {
|
|
|
451
476
|
signal: AbortSignal;
|
|
452
477
|
/** Stable, sanitized host context from the parent tool invocation. */
|
|
453
478
|
configurable?: Readonly<SubagentResolveConfigurable>;
|
|
479
|
+
/**
|
|
480
|
+
* Values the parent passed for this subagent's declared `hostArgs`, already
|
|
481
|
+
* checked against the declaration. Omitted when the call passed none. Bound
|
|
482
|
+
* to the execution: a reconstruction with different values is rejected
|
|
483
|
+
* before the resolver runs.
|
|
484
|
+
*/
|
|
485
|
+
hostArgs?: SubagentHostArgs;
|
|
454
486
|
}
|
|
455
487
|
/** Host contract for resolving a selected subagent's full graph inputs. */
|
|
456
488
|
export type SubagentAgentInputsResolver = (context: SubagentResolveContext) => Promise<AgentInputs>;
|
|
@@ -477,6 +509,12 @@ export interface SubagentConfig extends SubagentConfigBase {
|
|
|
477
509
|
* `(context.executionId, context.descriptor.configId)`.
|
|
478
510
|
*/
|
|
479
511
|
resolveAgentInputs?: SubagentAgentInputsResolver;
|
|
512
|
+
/**
|
|
513
|
+
* Optional per-call arguments the parent model may pass for this subagent,
|
|
514
|
+
* delivered to `resolveAgentInputs` as `context.hostArgs`. Only lazy
|
|
515
|
+
* configs accept them. Declaring none leaves the tool schema unchanged.
|
|
516
|
+
*/
|
|
517
|
+
hostArgs?: SubagentHostArgSpecs;
|
|
480
518
|
/** When true, reuse the parent's AgentInputs (context isolation without separate config). */
|
|
481
519
|
self?: boolean;
|
|
482
520
|
}
|
|
@@ -491,6 +529,7 @@ export interface GraphSubagentConfig extends SubagentConfigBase {
|
|
|
491
529
|
kind: 'graph';
|
|
492
530
|
configId?: never;
|
|
493
531
|
resolveAgentInputs?: never;
|
|
532
|
+
hostArgs?: never;
|
|
494
533
|
allowNested?: false;
|
|
495
534
|
agents: AgentInputs[];
|
|
496
535
|
/**
|