@librechat/agents 4.0.2 → 4.0.4
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/structuredChat.cjs +2 -8
- package/dist/cjs/decisions/structuredChat.cjs.map +1 -1
- package/dist/cjs/decisions/structuredOutput.cjs +18 -0
- package/dist/cjs/decisions/structuredOutput.cjs.map +1 -0
- package/dist/cjs/graphs/Graph.cjs +25 -9
- package/dist/cjs/graphs/Graph.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 +18 -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/run.cjs +7 -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/GitHubCompare.cjs +181 -0
- package/dist/cjs/tools/GitHubCompare.cjs.map +1 -0
- 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/subagent/SubagentExecutionRegistry.cjs +2 -2
- package/dist/cjs/tools/subagent/SubagentExecutionRegistry.cjs.map +1 -1
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs +66 -16
- 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 +48 -5
- 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 +1 -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/structuredChat.mjs +2 -8
- package/dist/esm/decisions/structuredChat.mjs.map +1 -1
- package/dist/esm/decisions/structuredOutput.mjs +18 -0
- package/dist/esm/decisions/structuredOutput.mjs.map +1 -0
- package/dist/esm/graphs/Graph.mjs +25 -9
- package/dist/esm/graphs/Graph.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 +6 -3
- 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/run.mjs +7 -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/GitHubCompare.mjs +175 -0
- package/dist/esm/tools/GitHubCompare.mjs.map +1 -0
- 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/subagent/SubagentExecutionRegistry.mjs +2 -2
- package/dist/esm/tools/subagent/SubagentExecutionRegistry.mjs.map +1 -1
- package/dist/esm/tools/subagent/SubagentExecutor.mjs +66 -16
- 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 +46 -6
- 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 +1 -0
- package/dist/esm/tools/toolErrorContent.mjs +1 -1
- package/dist/types/decisions/structuredChat.d.ts +3 -2
- package/dist/types/decisions/structuredOutput.d.ts +4 -0
- package/dist/types/graphs/Graph.d.ts +6 -3
- package/dist/types/index.d.ts +3 -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/run.d.ts +1 -0
- package/dist/types/tools/BashExecutor.d.ts +4 -0
- package/dist/types/tools/CodeExecutor.d.ts +4 -0
- package/dist/types/tools/GitHubCompare.d.ts +104 -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/subagent/SubagentExecutionRegistry.d.ts +2 -0
- package/dist/types/tools/subagent/SubagentExecutor.d.ts +10 -2
- package/dist/types/tools/subagent/SubagentReplay.d.ts +3 -1
- package/dist/types/tools/subagent/diagnostics.d.ts +27 -3
- package/dist/types/tools/subagent/hostArgs.d.ts +57 -0
- package/dist/types/tools/subagent/index.d.ts +3 -2
- package/dist/types/types/graph.d.ts +36 -0
- package/dist/types/types/run.d.ts +4 -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/structuredChat.ts +9 -15
- package/src/decisions/structuredOutput.ts +25 -0
- package/src/graphs/Graph.ts +53 -9
- package/src/index.ts +8 -0
- 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/run.ts +9 -0
- package/src/stream.ts +33 -7
- package/src/summarization/node.ts +32 -14
- package/src/tools/GitHubCompare.ts +319 -0
- package/src/tools/SubagentTool.ts +14 -3
- package/src/tools/ToolNode.ts +7 -3
- package/src/tools/subagent/SubagentExecutionRegistry.ts +6 -2
- package/src/tools/subagent/SubagentExecutor.ts +145 -18
- package/src/tools/subagent/SubagentReplay.ts +10 -3
- package/src/tools/subagent/childGraphConfig.ts +12 -1
- package/src/tools/subagent/diagnostics.ts +98 -6
- package/src/tools/subagent/hostArgs.ts +413 -0
- package/src/tools/subagent/index.ts +9 -0
- package/src/types/graph.ts +41 -0
- package/src/types/run.ts +4 -2
- package/src/types/tools.ts +6 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"childGraphConfig.mjs","names":[],"sources":["../../../../src/tools/subagent/childGraphConfig.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"childGraphConfig.mjs","names":[],"sources":["../../../../src/tools/subagent/childGraphConfig.ts"],"mappings":";;;AAmBA,MAAM,4BAA4B,IAAI,IAAI;CACxC;CACA;CACA;CACA;CACA;AACF,CAAC;AAmDD,SAAS,SAAS,OAAiC;CACjD,OAAO,SAAS,QAAQ,OAAO,UAAU;AAC3C;AAEA,SAAS,iBAAiB,OAAiC;CACzD,OAAO,OAAO,UAAU,YAAY,MAAM,KAAK,MAAM;AACvD;AAEA,SAAgB,sBACd,QAC+B;CAC/B,OAAQ,OAA8B,SAAS;AACjD;AAEA,SAAS,+BACP,OACiD;CACjD,IAAI,CAAC,SAAS,KAAK,GACjB,MAAM,IAAI,MAAM,0CAA0C;CAE5D,MAAM,YAAY;CAClB,MAAM,aAAa,iBAAiB,UAAU,IAAI,IAC9C,UAAU,OACV;CAC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AAI,IAChB,OAAO,KAAK,gBAAgB,CAAC,YAAY,SAAS,WAAW,CAAC,CAChE;GACA,OAAO,OAAO,MAAM,KAAK,UAAU;IACjC,GAAG;IACH,MAAM,MAAM,QAAQ,KAAK,IAAI,IAAI,CAAC,GAAG,KAAK,IAAI,IAAI,KAAK;IACvD,IAAI,MAAM,QAAQ,KAAK,EAAE,IAAI,CAAC,GAAG,KAAK,EAAE,IAAI,KAAK;GACnD,EAAE;GACF,cAAc,OAAO;GACrB,eAAe,OAAO;EACxB;CACF;CAEA,MAAM,eACJ,OAAO,YAAY,WACnB,GAAG,iBAAiB,QAAQ,OAAO;CACrC,MAAM,cAAc,iBAClB,QACA,cACA,gBACA,mBACF;CACA,OAAO;EACL,MAAM;EACN,gBAAgB;EAChB,kBAAkB;EAClB,QAAQ,CAAC,WAAW;EACpB,cAAc,IAAI,IAAI,CAAC,CAAC,cAAc,WAAW,CAAC,CAAC;CACrD;AACF"}
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
import { SubagentDefinitionBindingError, SubagentExecutionInvalidatedError, SubagentInvocationBindingError, SubagentSettlementBindingError } from "./SubagentExecutionRegistry.mjs";
|
|
2
2
|
import { describeCodeApiError } from "../diagnostics.mjs";
|
|
3
|
+
import { isSubagentHostArgName } from "./hostArgs.mjs";
|
|
3
4
|
//#region src/tools/subagent/diagnostics.ts
|
|
5
|
+
var SubagentHostArgumentError = class extends Error {
|
|
6
|
+
argument;
|
|
7
|
+
rejection;
|
|
8
|
+
constructor(argument, rejection) {
|
|
9
|
+
super("Subagent host argument was rejected.");
|
|
10
|
+
this.name = "SubagentHostArgumentError";
|
|
11
|
+
this.argument = argument;
|
|
12
|
+
this.rejection = rejection;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
4
15
|
const SUBAGENT_ERROR_TYPES = [
|
|
16
|
+
["SubagentHostArgumentError", SubagentHostArgumentError],
|
|
5
17
|
["SubagentExecutionInvalidatedError", SubagentExecutionInvalidatedError],
|
|
6
18
|
["SubagentDefinitionBindingError", SubagentDefinitionBindingError],
|
|
7
19
|
["SubagentInvocationBindingError", SubagentInvocationBindingError],
|
|
@@ -12,6 +24,7 @@ const SUBAGENT_RESOLUTION_MESSAGES = {
|
|
|
12
24
|
agent_unavailable: "Subagent error: Agent not found or not accessible.",
|
|
13
25
|
model_unavailable: "Subagent error: Model or provider unavailable.",
|
|
14
26
|
configuration_changed: "Subagent error: Subagent configuration changed. Start a new execution.",
|
|
27
|
+
host_argument_rejected: "Subagent error: A requested subagent argument is not available. Omit it to let the host choose, or pass a different value.",
|
|
15
28
|
unknown: "Subagent error: Unable to initialize the selected subagent."
|
|
16
29
|
};
|
|
17
30
|
function normalizeResolutionCause(cause) {
|
|
@@ -19,21 +32,42 @@ function normalizeResolutionCause(cause) {
|
|
|
19
32
|
case "workspace_unavailable":
|
|
20
33
|
case "agent_unavailable":
|
|
21
34
|
case "model_unavailable":
|
|
22
|
-
case "configuration_changed":
|
|
35
|
+
case "configuration_changed":
|
|
36
|
+
case "host_argument_rejected": return cause;
|
|
23
37
|
default: return "unknown";
|
|
24
38
|
}
|
|
25
39
|
}
|
|
26
40
|
function getSubagentResolutionFailureMessage(cause) {
|
|
27
41
|
return SUBAGENT_RESOLUTION_MESSAGES[normalizeResolutionCause(cause)];
|
|
28
42
|
}
|
|
43
|
+
function getSubagentHostArgumentFailure(error, suppliedHostArgs) {
|
|
44
|
+
try {
|
|
45
|
+
if (!(error instanceof SubagentHostArgumentError) || suppliedHostArgs == null) return;
|
|
46
|
+
const { argument, rejection } = error;
|
|
47
|
+
if (typeof argument !== "string" || !isSubagentHostArgName(argument) || !Object.prototype.hasOwnProperty.call(suppliedHostArgs, argument)) return;
|
|
48
|
+
return {
|
|
49
|
+
argument,
|
|
50
|
+
rejection: rejection === "unavailable" ? "unavailable" : "not_allowed"
|
|
51
|
+
};
|
|
52
|
+
} catch {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function getSubagentHostArgumentFailureMessage(failure) {
|
|
57
|
+
const { argument } = failure;
|
|
58
|
+
const omit = `Omit "${argument}" to let the host choose, or pass a different value.`;
|
|
59
|
+
return failure.rejection === "unavailable" ? `Subagent error: The requested "${argument}" is unavailable right now. ${omit}` : `Subagent error: The requested "${argument}" is not allowed for this subagent. ${omit}`;
|
|
60
|
+
}
|
|
29
61
|
var SubagentResolutionError = class extends Error {
|
|
30
62
|
phase;
|
|
31
63
|
resolutionCause;
|
|
32
|
-
|
|
33
|
-
|
|
64
|
+
hostArgument;
|
|
65
|
+
constructor(phase, cause, hostArgument) {
|
|
66
|
+
super(hostArgument == null ? getSubagentResolutionFailureMessage(cause) : getSubagentHostArgumentFailureMessage(hostArgument));
|
|
34
67
|
this.name = "SubagentResolutionError";
|
|
35
68
|
this.phase = phase;
|
|
36
69
|
this.resolutionCause = normalizeResolutionCause(cause);
|
|
70
|
+
if (hostArgument != null) this.hostArgument = hostArgument;
|
|
37
71
|
}
|
|
38
72
|
};
|
|
39
73
|
function describeSubagentError(error) {
|
|
@@ -44,7 +78,7 @@ function describeSubagentError(error) {
|
|
|
44
78
|
}
|
|
45
79
|
return describeCodeApiError(error).type;
|
|
46
80
|
}
|
|
47
|
-
function logSubagentResolutionFailure(phase, subagentType, signal, error, context, onResolutionFailure) {
|
|
81
|
+
function logSubagentResolutionFailure(phase, subagentType, signal, error, context, onResolutionFailure, suppliedHostArgs) {
|
|
48
82
|
const detail = {
|
|
49
83
|
...context,
|
|
50
84
|
phase,
|
|
@@ -54,8 +88,14 @@ function logSubagentResolutionFailure(phase, subagentType, signal, error, contex
|
|
|
54
88
|
cause: "unknown",
|
|
55
89
|
message: SUBAGENT_RESOLUTION_MESSAGES.unknown
|
|
56
90
|
};
|
|
91
|
+
const hostArgumentRejected = getSubagentHostArgumentFailure(error, suppliedHostArgs) != null;
|
|
92
|
+
if (hostArgumentRejected) {
|
|
93
|
+
detail.cause = "host_argument_rejected";
|
|
94
|
+
detail.message = SUBAGENT_RESOLUTION_MESSAGES.host_argument_rejected;
|
|
95
|
+
}
|
|
57
96
|
if (onResolutionFailure != null) try {
|
|
58
|
-
const
|
|
97
|
+
const reported = onResolutionFailure(Object.freeze({ ...detail }), error);
|
|
98
|
+
const cause = hostArgumentRejected ? detail.cause : normalizeResolutionCause(reported);
|
|
59
99
|
return {
|
|
60
100
|
...detail,
|
|
61
101
|
cause,
|
|
@@ -66,6 +106,6 @@ function logSubagentResolutionFailure(phase, subagentType, signal, error, contex
|
|
|
66
106
|
return detail;
|
|
67
107
|
}
|
|
68
108
|
//#endregion
|
|
69
|
-
export { SubagentResolutionError, getSubagentResolutionFailureMessage, logSubagentResolutionFailure };
|
|
109
|
+
export { SubagentHostArgumentError, SubagentResolutionError, getSubagentHostArgumentFailure, getSubagentHostArgumentFailureMessage, getSubagentResolutionFailureMessage, logSubagentResolutionFailure };
|
|
70
110
|
|
|
71
111
|
//# sourceMappingURL=diagnostics.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostics.mjs","names":[],"sources":["../../../../src/tools/subagent/diagnostics.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"diagnostics.mjs","names":[],"sources":["../../../../src/tools/subagent/diagnostics.ts"],"mappings":";;;;AAqBA,IAAa,4BAAb,cAA+C,MAAM;CACnD;CACA;CAEA,YAAY,UAAkB,WAA0C;EACtE,MAAM,sCAAsC;EAC5C,KAAK,OAAO;EACZ,KAAK,WAAW;EAChB,KAAK,YAAY;CACnB;AACF;AAQA,MAAM,uBAAuB;CAC3B,CAAC,6BAA6B,yBAAyB;CACvD,CAAC,qCAAqC,iCAAiC;CACvE,CAAC,kCAAkC,8BAA8B;CACjE,CAAC,kCAAkC,8BAA8B;CACjE,CAAC,kCAAkC,8BAA8B;AACnE;AAMA,MAAM,+BAA+B;CACnC,uBACE;CACF,mBAAmB;CACnB,mBAAmB;CACnB,uBACE;CACF,wBACE;CACF,SAAS;AACX;AA+BA,SAAS,yBACP,OACyB;CACzB,QAAQ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AK;EACjC,OAAO;EACP,SAAS,6BAA6B;CACxC;CACA,MAAM,uBACJ,+BAA+B,OAAO,gBAAgB,KAAK;CAC7D,IAAI,sBAAsB;EACxB,OAAO,QAAQ;EACf,OAAO,UAAU,6BAA6B;CAChD;CACA,IAAI,uBAAuB,MACzB,IAAI;EACF,MAAM,WAAW,oBAAoB,OAAO,OAAO,EAAE,GAAG,OAAO,CAAC,GAAG,KAAK;EACxE,MAAM,QAAQ,uBACV,OAAO,QACP,yBAAyB,QAAQ;EACrC,OAAO;GACL,GAAG;GACH;GACA,SAAS,oCAAoC,KAAK;EACpD;CACF,QAAQ,CAER;CAGF,QAAQ,KAAK,iDAAiD,MAAM;CACpE,OAAO;AACT"}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { createHash } from "crypto";
|
|
2
|
+
//#region src/tools/subagent/hostArgs.ts
|
|
3
|
+
const SUBAGENT_HOST_ARG_LIMITS = Object.freeze({
|
|
4
|
+
argsPerSubagent: 8,
|
|
5
|
+
distinctArgs: 16,
|
|
6
|
+
enumValues: 64,
|
|
7
|
+
mergedEnumValues: 256,
|
|
8
|
+
valueLength: 256,
|
|
9
|
+
descriptionLength: 1024
|
|
10
|
+
});
|
|
11
|
+
const HOST_ARG_NAME_PATTERN = /^[a-z][a-z0-9_]{0,63}$/;
|
|
12
|
+
const FREE_FORM_SCHEMA_PATTERN = "^[^\\u0000-\\u001f\\u007f]*$";
|
|
13
|
+
const RESERVED_HOST_ARG_NAMES = new Set([
|
|
14
|
+
"intent",
|
|
15
|
+
"description",
|
|
16
|
+
"subagent_type",
|
|
17
|
+
"run_in_background",
|
|
18
|
+
"subagent_thread_id"
|
|
19
|
+
]);
|
|
20
|
+
function isSubagentHostArgName(name) {
|
|
21
|
+
return HOST_ARG_NAME_PATTERN.test(name) && !RESERVED_HOST_ARG_NAMES.has(name);
|
|
22
|
+
}
|
|
23
|
+
function countCodePoints(value) {
|
|
24
|
+
let count = 0;
|
|
25
|
+
for (const _ of value) count += 1;
|
|
26
|
+
return count;
|
|
27
|
+
}
|
|
28
|
+
function hasControlCharacter(value) {
|
|
29
|
+
for (let i = 0; i < value.length; i++) {
|
|
30
|
+
const code = value.charCodeAt(i);
|
|
31
|
+
if (code < 32 || code === 127) return true;
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
function isBoundedText(value, maxLength) {
|
|
36
|
+
return typeof value === "string" && value.trim().length > 0 && countCodePoints(value) <= maxLength && !hasControlCharacter(value);
|
|
37
|
+
}
|
|
38
|
+
function getFreeFormMaxLength(spec) {
|
|
39
|
+
return spec.maxLength ?? SUBAGENT_HOST_ARG_LIMITS.valueLength;
|
|
40
|
+
}
|
|
41
|
+
function validateEnum(label, values) {
|
|
42
|
+
if (!Array.isArray(values) || values.length === 0 || values.length > SUBAGENT_HOST_ARG_LIMITS.enumValues) throw new Error(`${label} enum must list 1-${SUBAGENT_HOST_ARG_LIMITS.enumValues} values.`);
|
|
43
|
+
const seen = /* @__PURE__ */ new Set();
|
|
44
|
+
for (const value of values) {
|
|
45
|
+
if (!isBoundedText(value, SUBAGENT_HOST_ARG_LIMITS.valueLength)) throw new Error(`${label} enum values must be non-blank strings of at most ${SUBAGENT_HOST_ARG_LIMITS.valueLength} characters without control characters.`);
|
|
46
|
+
if (seen.has(value)) throw new Error(`${label} enum values must be unique.`);
|
|
47
|
+
seen.add(value);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function validateFreeForm(label, spec) {
|
|
51
|
+
const maxLength = getFreeFormMaxLength(spec);
|
|
52
|
+
if (!Number.isSafeInteger(maxLength) || maxLength < 1 || maxLength > SUBAGENT_HOST_ARG_LIMITS.valueLength) throw new Error(`${label} maxLength must be an integer from 1 to ${SUBAGENT_HOST_ARG_LIMITS.valueLength}.`);
|
|
53
|
+
}
|
|
54
|
+
function validateSpec(type, name, spec) {
|
|
55
|
+
const label = `Subagent "${type}" host argument "${name}"`;
|
|
56
|
+
if (!isSubagentHostArgName(name)) throw new Error(`${label} must match ${HOST_ARG_NAME_PATTERN.source} and must not reuse a built-in subagent argument name.`);
|
|
57
|
+
if (spec == null) throw new Error(`${label} must be an object.`);
|
|
58
|
+
if (spec.pattern !== void 0) throw new Error(`${label} cannot declare a pattern; validate the format in the resolver.`);
|
|
59
|
+
if (typeof spec.description !== "string" || spec.description.trim().length === 0 || spec.description.length > SUBAGENT_HOST_ARG_LIMITS.descriptionLength) throw new Error(`${label} needs a description of at most ${SUBAGENT_HOST_ARG_LIMITS.descriptionLength} characters.`);
|
|
60
|
+
if (spec.enum == null) {
|
|
61
|
+
validateFreeForm(label, spec);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (spec.maxLength != null) throw new Error(`${label} cannot combine enum with maxLength.`);
|
|
65
|
+
validateEnum(label, spec.enum);
|
|
66
|
+
}
|
|
67
|
+
function getSubagentHostArgSpecs(config) {
|
|
68
|
+
const { hostArgs } = config;
|
|
69
|
+
if (hostArgs == null) return [];
|
|
70
|
+
if (typeof hostArgs !== "object" || Array.isArray(hostArgs)) throw new Error(`Subagent "${config.type}" hostArgs must be an object.`);
|
|
71
|
+
const entries = Object.entries(hostArgs);
|
|
72
|
+
if (entries.length > SUBAGENT_HOST_ARG_LIMITS.argsPerSubagent) throw new Error(`Subagent "${config.type}" declares more than ${SUBAGENT_HOST_ARG_LIMITS.argsPerSubagent} host arguments.`);
|
|
73
|
+
for (const [name, spec] of entries) validateSpec(config.type, name, spec);
|
|
74
|
+
return entries;
|
|
75
|
+
}
|
|
76
|
+
function collectSubagentHostArgNames(configs) {
|
|
77
|
+
const names = /* @__PURE__ */ new Set();
|
|
78
|
+
for (const config of configs) for (const [name] of getSubagentHostArgSpecs(config)) names.add(name);
|
|
79
|
+
if (names.size > SUBAGENT_HOST_ARG_LIMITS.distinctArgs) throw new Error(`Subagents declare more than ${SUBAGENT_HOST_ARG_LIMITS.distinctArgs} distinct host arguments.`);
|
|
80
|
+
return names;
|
|
81
|
+
}
|
|
82
|
+
function mergeSpec(merged, name, spec) {
|
|
83
|
+
let entry = merged.get(name);
|
|
84
|
+
if (entry == null) {
|
|
85
|
+
entry = {
|
|
86
|
+
description: spec.description,
|
|
87
|
+
values: [],
|
|
88
|
+
seenValues: /* @__PURE__ */ new Set(),
|
|
89
|
+
freeForm: false,
|
|
90
|
+
maxLength: 0
|
|
91
|
+
};
|
|
92
|
+
merged.set(name, entry);
|
|
93
|
+
}
|
|
94
|
+
if (spec.enum == null) {
|
|
95
|
+
entry.freeForm = true;
|
|
96
|
+
entry.maxLength = Math.max(entry.maxLength, getFreeFormMaxLength(spec));
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
for (const value of spec.enum) {
|
|
100
|
+
entry.maxLength = Math.max(entry.maxLength, countCodePoints(value));
|
|
101
|
+
if (!entry.seenValues.has(value)) {
|
|
102
|
+
entry.seenValues.add(value);
|
|
103
|
+
entry.values.push(value);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (entry.values.length > SUBAGENT_HOST_ARG_LIMITS.mergedEnumValues) throw new Error(`Subagent host argument "${name}" lists more than ${SUBAGENT_HOST_ARG_LIMITS.mergedEnumValues} distinct values across subagents.`);
|
|
107
|
+
}
|
|
108
|
+
function toPropertySchema(entry) {
|
|
109
|
+
if (!entry.freeForm) return {
|
|
110
|
+
type: "string",
|
|
111
|
+
description: entry.description,
|
|
112
|
+
enum: entry.values
|
|
113
|
+
};
|
|
114
|
+
return {
|
|
115
|
+
type: "string",
|
|
116
|
+
description: entry.description,
|
|
117
|
+
maxLength: entry.maxLength,
|
|
118
|
+
pattern: FREE_FORM_SCHEMA_PATTERN
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function summarizeSpecs(entries) {
|
|
122
|
+
return entries.map(([name, spec]) => `${name}: ${spec.enum == null ? `any text up to ${getFreeFormMaxLength(spec)} characters` : spec.enum.join(" | ")}`).join("; ");
|
|
123
|
+
}
|
|
124
|
+
function buildSubagentHostArgProperties(configs) {
|
|
125
|
+
const merged = /* @__PURE__ */ new Map();
|
|
126
|
+
const summaries = /* @__PURE__ */ new Map();
|
|
127
|
+
for (const config of configs) {
|
|
128
|
+
const entries = getSubagentHostArgSpecs(config);
|
|
129
|
+
if (entries.length === 0) continue;
|
|
130
|
+
for (const [name, spec] of entries) mergeSpec(merged, name, spec);
|
|
131
|
+
summaries.set(config.type, summarizeSpecs(entries));
|
|
132
|
+
}
|
|
133
|
+
if (merged.size > SUBAGENT_HOST_ARG_LIMITS.distinctArgs) throw new Error(`Subagents declare more than ${SUBAGENT_HOST_ARG_LIMITS.distinctArgs} distinct host arguments.`);
|
|
134
|
+
const properties = {};
|
|
135
|
+
for (const [name, entry] of merged) properties[name] = toPropertySchema(entry);
|
|
136
|
+
return {
|
|
137
|
+
properties,
|
|
138
|
+
summaries
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function pickSubagentHostArgInput(input, names) {
|
|
142
|
+
if (names.size === 0) return { ok: true };
|
|
143
|
+
const values = input;
|
|
144
|
+
const picked = {};
|
|
145
|
+
let count = 0;
|
|
146
|
+
for (const name of names) {
|
|
147
|
+
if (!Object.prototype.hasOwnProperty.call(values, name)) continue;
|
|
148
|
+
const value = values[name];
|
|
149
|
+
if (value == null) continue;
|
|
150
|
+
if (typeof value !== "string") return {
|
|
151
|
+
ok: false,
|
|
152
|
+
message: `Error: "${name}" must be a string.`
|
|
153
|
+
};
|
|
154
|
+
if (value.trim() === "") continue;
|
|
155
|
+
picked[name] = value;
|
|
156
|
+
count += 1;
|
|
157
|
+
}
|
|
158
|
+
return count === 0 ? { ok: true } : {
|
|
159
|
+
ok: true,
|
|
160
|
+
hostArgs: picked
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function checkValue(type, name, spec, value) {
|
|
164
|
+
const omit = `Omit "${name}" to let the host choose.`;
|
|
165
|
+
if (spec.enum != null) return spec.enum.includes(value) ? void 0 : `Error: "${name}" for subagent "${type}" must be one of: ${spec.enum.join(", ")}. ${omit}`;
|
|
166
|
+
const maxLength = getFreeFormMaxLength(spec);
|
|
167
|
+
return isBoundedText(value, maxLength) ? void 0 : `Error: "${name}" for subagent "${type}" must be at most ${maxLength} characters without control characters. ${omit}`;
|
|
168
|
+
}
|
|
169
|
+
function resolveSubagentHostArgs(config, hostArgs) {
|
|
170
|
+
if (hostArgs == null) return { ok: true };
|
|
171
|
+
const names = Object.keys(hostArgs).sort();
|
|
172
|
+
if (names.length === 0) return { ok: true };
|
|
173
|
+
const specs = new Map(getSubagentHostArgSpecs(config));
|
|
174
|
+
const resolved = {};
|
|
175
|
+
for (const name of names) {
|
|
176
|
+
const spec = specs.get(name);
|
|
177
|
+
if (spec == null) return {
|
|
178
|
+
ok: false,
|
|
179
|
+
message: isSubagentHostArgName(name) ? `Error: Subagent "${config.type}" does not accept "${name}". Omit it for this subagent type.` : `Error: Subagent "${config.type}" received an unsupported argument.`
|
|
180
|
+
};
|
|
181
|
+
const value = hostArgs[name];
|
|
182
|
+
if (typeof value !== "string") return {
|
|
183
|
+
ok: false,
|
|
184
|
+
message: `Error: "${name}" must be a string.`
|
|
185
|
+
};
|
|
186
|
+
const error = checkValue(config.type, name, spec, value);
|
|
187
|
+
if (error != null) return {
|
|
188
|
+
ok: false,
|
|
189
|
+
message: error
|
|
190
|
+
};
|
|
191
|
+
resolved[name] = value;
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
ok: true,
|
|
195
|
+
hostArgs: Object.freeze(resolved)
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function getSubagentHostArgsDigest(hostArgs) {
|
|
199
|
+
if (hostArgs == null) return;
|
|
200
|
+
const entries = Object.entries(hostArgs).sort(([left], [right]) => left < right ? -1 : 1);
|
|
201
|
+
if (entries.length === 0) return;
|
|
202
|
+
return createHash("sha256").update(JSON.stringify(entries)).digest("hex");
|
|
203
|
+
}
|
|
204
|
+
//#endregion
|
|
205
|
+
export { SUBAGENT_HOST_ARG_LIMITS, buildSubagentHostArgProperties, collectSubagentHostArgNames, getSubagentHostArgSpecs, getSubagentHostArgsDigest, isSubagentHostArgName, pickSubagentHostArgInput, resolveSubagentHostArgs };
|
|
206
|
+
|
|
207
|
+
//# sourceMappingURL=hostArgs.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostArgs.mjs","names":[],"sources":["../../../../src/tools/subagent/hostArgs.ts"],"mappings":";;AASA,MAAa,2BAA2B,OAAO,OAAO;CACpD,iBAAiB;CACjB,cAAc;CACd,YAAY;CACZ,kBAAkB;CAClB,aAAa;CACb,mBAAmB;AACrB,CAAC;AAED,MAAM,wBAAwB;AAE9B,MAAM,2BAA2B;AACjC,MAAM,0BAA+C,IAAI,IAAI;CAC3D;CACA;CACA;CACA;CACA;AACF,CAAC;AAuBD,SAAgB,sBAAsB,MAAuB;CAC3D,OAAO,sBAAsB,KAAK,IAAI,KAAK,CAAC,wBAAwB,IAAI,IAAI;AAC9E;AAGA,SAAS,gBAAgB,OAAuB;CAC9C,IAAI,QAAQ;CACZ,KAAK,MAAM,KAAK,OACd,SAAS;CAEX,OAAO;AACT;AAEA,SAAS,oBAAoB,OAAwB;CACnD,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACrC,MAAM,OAAO,MAAM,WAAW,CAAC;EAC/B,IAAI,OAAO,MAAQ,SAAS,KAC1B,OAAO;CAEX;CACA,OAAO;AACT;AAEA,SAAS,cAAc,OAAgB,WAAoC;CACzE,OACE,OAAO,UAAU,YACjB,MAAM,KAAK,CAAC,CAAC,SAAS,KACtB,gBAAgB,KAAK,KAAK,aAC1B,CAAC,oBAAoB,KAAK;AAE9B;AAEA,SAAS,qBAAqB,MAAmC;CAC/D,OAAO,KAAK,aAAa,yBAAyB;AACpD;AAEA,SAAS,aAAa,OAAe,QAAiC;CACpE,IACE,CAAC,MAAM,QAAQ,MAAM,KACrB,OAAO,WAAW,KAClB,OAAO,SAAS,yBAAyB,YAEzC,MAAM,IAA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S,WAAW,KAAK;EAAqB;EAEpE,MAAM,QAAQ,WAAW,OAAO,MAAM,MAAM,MAAM,KAAK;EACvD,IAAI,SAAS,MACX,OAAO;GAAE,IAAI;GAAO,SAAS;EAAM;EAErC,SAAS,QAAQ;CACnB;CACA,OAAO;EAAE,IAAI;EAAM,UAAU,OAAO,OAAO,QAAQ;CAAE;AACvD;AAGA,SAAgB,0BACd,UACoB;CACpB,IAAI,YAAY,MACd;CAEF,MAAM,UAAU,OAAO,QAAQ,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,WACtD,OAAO,QAAQ,KAAK,CACtB;CACA,IAAI,QAAQ,WAAW,GACrB;CAEF,OAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,KAAK,UAAU,OAAO,CAAC,CAAC,CAAC,OAAO,KAAK;AAC1E"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { truncateToolResultContent } from "../utils/truncation.mjs";
|
|
2
|
-
import { StreamLimitExceededError } from "../llm/streamLimits.mjs";
|
|
3
2
|
import { PreparedSubagentError } from "./preparedSubagents.mjs";
|
|
3
|
+
import { StreamLimitExceededError } from "../llm/streamLimits.mjs";
|
|
4
4
|
//#region src/tools/toolErrorContent.ts
|
|
5
5
|
const STOPPED_RUN_TOOL_ERROR = "STOP. The user doesn't want to proceed with this tool use. The run was stopped; the tool may not have completed, and its effects should not be assumed. STOP what you are doing and wait for the user to tell you how to proceed.";
|
|
6
6
|
function isStoppedRunToolError(message, signal, error) {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
2
2
|
import type { DecisionModel, DecisionResult } from './types';
|
|
3
|
+
import type { DecisionOutputMethod } from './structuredOutput';
|
|
3
4
|
export declare function readChatUsage(raw: unknown): DecisionResult['usage'];
|
|
4
5
|
export interface StructuredChatDecisionModelOptions {
|
|
5
6
|
/** An already configured chat model whose chosen method enforces strict schemas. */
|
|
6
7
|
model: BaseChatModel;
|
|
7
8
|
modelId: string;
|
|
8
9
|
providerId?: string;
|
|
9
|
-
/** Verified OpenAI strict modes or Anthropic strict
|
|
10
|
-
method:
|
|
10
|
+
/** Verified OpenAI/Azure strict modes or Anthropic strict tools; other paths fail closed. */
|
|
11
|
+
method: DecisionOutputMethod;
|
|
11
12
|
timeoutMs?: number;
|
|
12
13
|
maxQuestions?: number;
|
|
13
14
|
onAnswered?: (label: string, ms: number) => void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
2
|
+
export type DecisionOutputMethod = 'jsonSchema' | 'functionCalling';
|
|
3
|
+
/** Binds only verified enforcement paths; a model profile alone is not a strict-output guarantee. */
|
|
4
|
+
export declare function withDecisionStructuredOutput(model: BaseChatModel, schema: Record<string, unknown>, method: DecisionOutputMethod): ReturnType<BaseChatModel['withStructuredOutput']>;
|
|
@@ -11,6 +11,7 @@ import type { HookRegistry } from '@/hooks';
|
|
|
11
11
|
import type * as t from '@/types';
|
|
12
12
|
import { StreamLimitExceededError } from '@/llm/streamLimits';
|
|
13
13
|
import { SubagentExecutor } from '@/tools/subagent';
|
|
14
|
+
import { ProviderTextProtectionError } from '@/protection/providerText';
|
|
14
15
|
import { ToolOutputReferenceRegistry } from '@/tools/toolOutputReferences';
|
|
15
16
|
import { PreparedSubagents, PreparedSubagentError } from '@/tools/preparedSubagents';
|
|
16
17
|
import { ToolNode as CustomToolNode } from '@/tools/ToolNode';
|
|
@@ -314,6 +315,8 @@ export declare class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode>
|
|
|
314
315
|
* these on every streamed chunk event.
|
|
315
316
|
*/
|
|
316
317
|
streamLimits: ResolvedStreamLimits;
|
|
318
|
+
/** Default-off mandatory provider prose release. */
|
|
319
|
+
providerTextProtection?: t.StandardGraphInput['providerTextProtection'];
|
|
317
320
|
/**
|
|
318
321
|
* Cumulative streamed argument bytes per in-flight tool call, keyed by
|
|
319
322
|
* generation key + chunk index (see `resolveGenerationKey`). Per-run
|
|
@@ -352,12 +355,12 @@ export declare class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode>
|
|
|
352
355
|
* `StreamLimitState.activeStreamLimitGenerations`). Lazily created by the
|
|
353
356
|
* attempt lease; spans resets on purpose. */
|
|
354
357
|
activeStreamLimitGenerations?: Set<string>;
|
|
355
|
-
/** The
|
|
358
|
+
/** The safety error behind an already-fired breaker, whether this
|
|
356
359
|
* graph's own controller tripped or a parent run's breaker arrived through
|
|
357
360
|
* the composed constructor signal (child graphs own separate controllers).
|
|
358
361
|
* Providers can translate either abort into a generic error, and recovery
|
|
359
362
|
* paths must not run in that state. */
|
|
360
|
-
protected resolveTrippedBreakerReason(breakerSignal?: AbortSignal): StreamLimitExceededError | PreparedSubagentError | undefined;
|
|
363
|
+
protected resolveTrippedBreakerReason(breakerSignal?: AbortSignal): StreamLimitExceededError | PreparedSubagentError | ProviderTextProtectionError | undefined;
|
|
361
364
|
/**
|
|
362
365
|
* Seals charged against `preemption.maxSeals`. Per-turn: cleared by both
|
|
363
366
|
* reset paths so a fresh turn gets a fresh budget, while a HITL resume —
|
|
@@ -442,7 +445,7 @@ export declare class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode>
|
|
|
442
445
|
* from a discard.
|
|
443
446
|
*/
|
|
444
447
|
private preemptRestartPending;
|
|
445
|
-
constructor({ runId, signal, agents, langfuse, tokenCounter, indexTokenCountMap, calibrationRatio, fadingTier, fadingTiers, subagentUsageSink, subagentTasks, subagentScope, subagentExecutionContext, subagentContext, onSubagentResolutionFailure, preemption, streamLimits, toolExecution, clientDelegatedToolNames, }: t.StandardGraphInput, dependencies?: GraphFactoryDependencies);
|
|
448
|
+
constructor({ runId, signal, agents, langfuse, tokenCounter, indexTokenCountMap, calibrationRatio, fadingTier, fadingTiers, subagentUsageSink, subagentTasks, subagentScope, subagentExecutionContext, subagentContext, onSubagentResolutionFailure, preemption, streamLimits, providerTextProtection, toolExecution, clientDelegatedToolNames, }: t.StandardGraphInput, dependencies?: GraphFactoryDependencies);
|
|
446
449
|
/**
|
|
447
450
|
* A compaction applies its remove-all inside the agent subgraph, so the
|
|
448
451
|
* subgraph's result carries only the retained tail, and an outer reducer
|
package/dist/types/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './graphs';
|
|
|
7
7
|
export * from './agents/projection';
|
|
8
8
|
export * from './summarization';
|
|
9
9
|
export * from './tools/Calculator';
|
|
10
|
+
export * from './tools/GitHubCompare';
|
|
10
11
|
export * from './tools/CodeExecutor';
|
|
11
12
|
export * from './tools/BashExecutor';
|
|
12
13
|
export * from './tools/ProgrammaticToolCalling';
|
|
@@ -61,3 +62,5 @@ export { DEFAULT_MAX_TOOL_CALL_ARG_BYTES, StreamLimitExceededError, resolveStrea
|
|
|
61
62
|
export type { StreamedToolCallArgTally, ResolvedStreamLimits, StreamLimitState, StreamLimitKind, } from './llm/streamLimits';
|
|
62
63
|
export * from './decisions';
|
|
63
64
|
export * from './rerank';
|
|
65
|
+
export { PROVIDER_TEXT_PROTECTION_VERSION, ProviderTextProtectionError } from './protection/providerText';
|
|
66
|
+
export type { ProviderTextProtection, ProviderTextProtectionResult, ProviderTextProtectionErrorCode, } from './protection/providerText';
|
|
@@ -3,6 +3,7 @@ import type { RunnableConfig } from '@langchain/core/runnables';
|
|
|
3
3
|
import type { BaseMessage } from '@langchain/core/messages';
|
|
4
4
|
import type { ToolOutputReferenceRegistry } from '@/tools/toolOutputReferences';
|
|
5
5
|
import type { PreparedProviderRequest } from '@/llm/prepareProviderRequest';
|
|
6
|
+
import type { ProviderTextProtection } from '@/protection/providerText';
|
|
6
7
|
import type { ContextOverflowContext } from '@/utils/errors';
|
|
7
8
|
import type { StreamLimitState } from '@/llm/streamLimits';
|
|
8
9
|
import type * as t from '@/types';
|
|
@@ -59,6 +60,7 @@ export type OnChunk = (chunk: AIMessageChunk, metadata?: Record<string, unknown>
|
|
|
59
60
|
*/
|
|
60
61
|
interface AttemptInvokeCommonParams {
|
|
61
62
|
context?: InvokeContext;
|
|
63
|
+
providerTextProtection?: ProviderTextProtection;
|
|
62
64
|
onChunk?: OnChunk;
|
|
63
65
|
/**
|
|
64
66
|
* The agent lane this attempt belongs to, as the model node names it. Only
|
|
@@ -123,7 +125,7 @@ export declare function getFallbackOverflowCandidates(error: unknown): FallbackO
|
|
|
123
125
|
* behind a later unrelated error would surface a dead end instead. Ordinary
|
|
124
126
|
* failures still throw last-error-wins.
|
|
125
127
|
*/
|
|
126
|
-
export declare function tryFallbackProviders({ fallbacks, tools, messages, config, primaryError, context, onChunk, streamLimitState, preemptAgentId, overflowContext, prepareProviderRequest: prepareFallbackRequest, prepareProviderMessages, }: {
|
|
128
|
+
export declare function tryFallbackProviders({ fallbacks, tools, messages, config, primaryError, context, onChunk, streamLimitState, providerTextProtection, preemptAgentId, overflowContext, prepareProviderRequest: prepareFallbackRequest, prepareProviderMessages, }: {
|
|
127
129
|
fallbacks: t.FallbackConfig[];
|
|
128
130
|
tools?: t.GraphTools;
|
|
129
131
|
messages: BaseMessage[];
|
|
@@ -134,6 +136,7 @@ export declare function tryFallbackProviders({ fallbacks, tools, messages, confi
|
|
|
134
136
|
/** Accounting-lease owner forwarded to each fallback attempt (see
|
|
135
137
|
* `AttemptInvokeParams.streamLimitState`). */
|
|
136
138
|
streamLimitState?: StreamLimitState;
|
|
139
|
+
providerTextProtection?: ProviderTextProtection;
|
|
137
140
|
/** Forwarded so a fallback-served attempt records a discarded turn in the
|
|
138
141
|
* SAME lane the primary would have (see
|
|
139
142
|
* `AttemptInvokeParams.preemptAgentId`). Dropping it here would leave the
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ProviderTextProtection } from '@/protection/providerText';
|
|
2
|
+
import type { ChatModel, ProviderName } from '@/types';
|
|
3
|
+
/** Clone only known runnable shells. Never mutate a shared provider or its callback configuration. */
|
|
4
|
+
export declare function withProviderTextBoundary(model: ChatModel, policy: ProviderTextProtection, provider?: ProviderName): ChatModel;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AIMessageChunk } from '@langchain/core/messages';
|
|
2
|
+
import type { AIMessageChunkFields } from '@langchain/core/messages';
|
|
3
|
+
type ChunkConstructor = new (fields: AIMessageChunkFields) => AIMessageChunk;
|
|
4
|
+
/** Internal certification for SDK-owned aggregation semantics, not arbitrary provider subclasses. */
|
|
5
|
+
export declare function registerProviderTextChunkConstructor(constructor: ChunkConstructor): void;
|
|
6
|
+
export declare function createProviderTextChunk(source: object, fields: AIMessageChunkFields): AIMessageChunk;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AIMessageChunk } from '@langchain/core/messages';
|
|
2
|
+
import type { ProviderTextAttempt } from '@/protection/providerText';
|
|
3
|
+
export declare const GEMINI_SIGNATURES = "__gemini_function_call_thought_signatures__";
|
|
4
|
+
export declare const RESPONSES_POSITIONS = "__openai_responses_replay_positions__";
|
|
5
|
+
export declare function keys(value: unknown, allowed: readonly string[]): value is Record<string, unknown>;
|
|
6
|
+
export declare function stringMap(value: unknown): boolean;
|
|
7
|
+
export declare function safetyRatings(value: unknown): boolean;
|
|
8
|
+
export declare function replayPositions(value: unknown): boolean;
|
|
9
|
+
/** One certified prose output. Unknown structured outputs and alternate aliases stay gated. */
|
|
10
|
+
export declare class ResponsesTextProjection {
|
|
11
|
+
private readonly attempt;
|
|
12
|
+
private metadata?;
|
|
13
|
+
private hasOutputAlias;
|
|
14
|
+
private output?;
|
|
15
|
+
constructor(attempt: ProviderTextAttempt);
|
|
16
|
+
strip(metadata: AIMessageChunk['response_metadata']): AIMessageChunk['response_metadata'];
|
|
17
|
+
canonical(content: string): AIMessageChunk['response_metadata'] | undefined;
|
|
18
|
+
}
|
|
@@ -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
|
+
}
|
package/dist/types/run.d.ts
CHANGED