@ai-sdk/harness-deepagents 1.0.91 → 1.0.93
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/CHANGELOG.md +23 -0
- package/README.md +9 -10
- package/dist/bridge/index.mjs +199 -138
- package/dist/bridge/index.mjs.map +1 -1
- package/dist/bridge/package.json +6 -6
- package/dist/bridge/pnpm-lock.yaml +68 -68
- package/dist/index.d.ts +10 -21
- package/dist/index.js +49 -72
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/bridge/index.ts +35 -14
- package/src/bridge/package.json +6 -6
- package/src/bridge/pnpm-lock.yaml +68 -68
- package/src/deepagents-auth.ts +27 -74
- package/src/deepagents-bridge-protocol.ts +1 -0
- package/src/deepagents-harness.ts +44 -40
- package/src/index.ts +1 -4
package/dist/bridge/index.mjs
CHANGED
|
@@ -145,6 +145,7 @@ var ENV_TRUTHY = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
|
|
|
145
145
|
var WS_OPEN = 1;
|
|
146
146
|
async function runBridge(options) {
|
|
147
147
|
const { bridgeType, bridgeStateDir: bridgeStateDir2, onStart, onStop, onDestroy } = options;
|
|
148
|
+
const teardownGraceMs = options.turnTeardownGraceMs ?? 1e4;
|
|
148
149
|
const expectedToken = options.token ?? procEnv.BRIDGE_CHANNEL_TOKEN ?? "";
|
|
149
150
|
const bridgeWsPort = options.port ?? parseInt(procEnv.BRIDGE_WS_PORT ?? "0", 10);
|
|
150
151
|
const bridgeMetaPath = `${bridgeStateDir2}/bridge-meta.json`;
|
|
@@ -161,6 +162,7 @@ async function runBridge(options) {
|
|
|
161
162
|
let isFirstTurn = true;
|
|
162
163
|
let turnAbort;
|
|
163
164
|
let currentUserMessages;
|
|
165
|
+
let activeTurn;
|
|
164
166
|
let debugConfig;
|
|
165
167
|
let consoleCaptureInstalled = false;
|
|
166
168
|
const envDebugEnabled = ENV_TRUTHY.has(
|
|
@@ -351,10 +353,28 @@ async function runBridge(options) {
|
|
|
351
353
|
const handleInbound = async (msg, ws) => {
|
|
352
354
|
switch (msg.type) {
|
|
353
355
|
case "start": {
|
|
356
|
+
for (; ; ) {
|
|
357
|
+
const pendingTurn = activeTurn;
|
|
358
|
+
if (pendingTurn == null) break;
|
|
359
|
+
turnAbort?.abort();
|
|
360
|
+
currentUserMessages?.close(
|
|
361
|
+
new Error("A new bridge turn replaced the active turn.")
|
|
362
|
+
);
|
|
363
|
+
let graceTimer;
|
|
364
|
+
const settled = await Promise.race([
|
|
365
|
+
pendingTurn.then(() => true),
|
|
366
|
+
new Promise((resolve) => {
|
|
367
|
+
graceTimer = setTimeout(() => resolve(false), teardownGraceMs);
|
|
368
|
+
graceTimer.unref?.();
|
|
369
|
+
})
|
|
370
|
+
]);
|
|
371
|
+
clearTimeout(graceTimer);
|
|
372
|
+
if (!settled) break;
|
|
373
|
+
}
|
|
374
|
+
let turnFinished;
|
|
375
|
+
const thisTurn = new Promise((resolve) => turnFinished = resolve);
|
|
376
|
+
activeTurn = thisTurn;
|
|
354
377
|
activeSocket = ws;
|
|
355
|
-
currentUserMessages?.close(
|
|
356
|
-
new Error("A new bridge turn replaced the active turn.")
|
|
357
|
-
);
|
|
358
378
|
const firstTurn = isFirstTurn;
|
|
359
379
|
isFirstTurn = false;
|
|
360
380
|
eventLog = [];
|
|
@@ -411,8 +431,12 @@ async function runBridge(options) {
|
|
|
411
431
|
if (currentUserMessages === userMessages) {
|
|
412
432
|
currentUserMessages = void 0;
|
|
413
433
|
}
|
|
414
|
-
|
|
415
|
-
|
|
434
|
+
if (activeTurn === thisTurn) {
|
|
435
|
+
activeTurn = void 0;
|
|
436
|
+
currentTurnState = "waiting";
|
|
437
|
+
void writeBridgeMeta("waiting");
|
|
438
|
+
}
|
|
439
|
+
turnFinished();
|
|
416
440
|
}
|
|
417
441
|
return;
|
|
418
442
|
}
|
|
@@ -597,17 +621,19 @@ function serialiseError(err) {
|
|
|
597
621
|
// src/bridge/index.ts
|
|
598
622
|
import { ChatAnthropic } from "@langchain/anthropic";
|
|
599
623
|
import { tool as tool3 } from "@langchain/core/tools";
|
|
600
|
-
import { Command as Command5, MemorySaver as MemorySaver2 } from "@langchain/langgraph";
|
|
624
|
+
import { Command as Command5, MemorySaver as MemorySaver2, Overwrite } from "@langchain/langgraph";
|
|
601
625
|
import {
|
|
602
626
|
MultiServerMCPClient
|
|
603
627
|
} from "@langchain/mcp-adapters";
|
|
604
628
|
import { createDeepAgent } from "deepagents";
|
|
605
629
|
|
|
606
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
630
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/chat_models/universal.js
|
|
607
631
|
import { BaseChatModel } from "@langchain/core/language_models/chat_models";
|
|
608
632
|
import { RunnableBinding, ensureConfig } from "@langchain/core/runnables";
|
|
609
633
|
import { AsyncGeneratorWithSetup, IterableReadableStream } from "@langchain/core/utils/stream";
|
|
610
634
|
import { ChatModelStream } from "@langchain/core/language_models/stream";
|
|
635
|
+
import { DEFAULT_LANGSMITH_GATEWAY, resolveLangSmithGatewayConfig } from "@langchain/core/utils/gateway";
|
|
636
|
+
import { getEnvironmentVariable } from "@langchain/core/utils/env";
|
|
611
637
|
var MODEL_PROVIDER_CONFIG = {
|
|
612
638
|
openai: {
|
|
613
639
|
package: "@langchain/openai",
|
|
@@ -621,6 +647,10 @@ var MODEL_PROVIDER_CONFIG = {
|
|
|
621
647
|
package: "@langchain/openai",
|
|
622
648
|
className: "AzureChatOpenAI"
|
|
623
649
|
},
|
|
650
|
+
langsmith: {
|
|
651
|
+
package: "@langchain/openai",
|
|
652
|
+
className: "ChatOpenAI"
|
|
653
|
+
},
|
|
624
654
|
cohere: {
|
|
625
655
|
package: "@langchain/cohere",
|
|
626
656
|
className: "ChatCohere"
|
|
@@ -693,10 +723,10 @@ var MODEL_PROVIDER_CONFIG = {
|
|
|
693
723
|
};
|
|
694
724
|
var SUPPORTED_PROVIDERS = Object.keys(MODEL_PROVIDER_CONFIG);
|
|
695
725
|
|
|
696
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
726
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/tools/headless.js
|
|
697
727
|
import { tool } from "@langchain/core/tools";
|
|
698
728
|
|
|
699
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
729
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/errors.js
|
|
700
730
|
import { isGraphBubbleUp } from "@langchain/langgraph";
|
|
701
731
|
var StructuredOutputParsingError = class extends Error {
|
|
702
732
|
toolName;
|
|
@@ -709,18 +739,21 @@ var StructuredOutputParsingError = class extends Error {
|
|
|
709
739
|
}
|
|
710
740
|
};
|
|
711
741
|
|
|
712
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
742
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/model.js
|
|
713
743
|
function isBaseChatModel(model) {
|
|
714
744
|
return "invoke" in model && typeof model.invoke === "function" && "_streamResponseChunks" in model;
|
|
715
745
|
}
|
|
716
746
|
|
|
717
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
747
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/responses.js
|
|
718
748
|
import { isInteropZodObject, isInteropZodSchema } from "@langchain/core/utils/types";
|
|
719
749
|
import { Validator, toJsonSchema } from "@langchain/core/utils/json_schema";
|
|
720
750
|
import { isSerializableSchema } from "@langchain/core/utils/standard_schema";
|
|
721
751
|
var PROVIDER_STRATEGY_DEFAULT_STRICT = true;
|
|
722
752
|
var bindingIdentifier = 0;
|
|
723
753
|
var ToolStrategy = class ToolStrategy2 {
|
|
754
|
+
schema;
|
|
755
|
+
tool;
|
|
756
|
+
options;
|
|
724
757
|
constructor(schema, tool4, options) {
|
|
725
758
|
this.schema = schema;
|
|
726
759
|
this.tool = tool4;
|
|
@@ -734,16 +767,17 @@ var ToolStrategy = class ToolStrategy2 {
|
|
|
734
767
|
return name ?? `extract-${++bindingIdentifier}`;
|
|
735
768
|
}
|
|
736
769
|
if (isSerializableSchema(schema) || isInteropZodSchema(schema)) {
|
|
737
|
-
const
|
|
738
|
-
|
|
770
|
+
const asJsonSchema2 = toJsonSchema(schema);
|
|
771
|
+
const tool4 = {
|
|
739
772
|
type: "function",
|
|
740
773
|
function: {
|
|
741
|
-
name: getFunctionName(
|
|
774
|
+
name: getFunctionName(asJsonSchema2.title),
|
|
742
775
|
strict: false,
|
|
743
|
-
description:
|
|
744
|
-
parameters:
|
|
776
|
+
description: asJsonSchema2.description ?? "Tool for extracting structured output from the model's response.",
|
|
777
|
+
parameters: asJsonSchema2
|
|
745
778
|
}
|
|
746
|
-
}
|
|
779
|
+
};
|
|
780
|
+
return new ToolStrategy2(asJsonSchema2, tool4, outputOptions);
|
|
747
781
|
}
|
|
748
782
|
let functionDefinition;
|
|
749
783
|
if (typeof schema.name === "string" && typeof schema.parameters === "object" && schema.parameters != null) functionDefinition = schema;
|
|
@@ -752,7 +786,8 @@ var ToolStrategy = class ToolStrategy2 {
|
|
|
752
786
|
description: schema.description ?? "",
|
|
753
787
|
parameters: schema.schema || schema
|
|
754
788
|
};
|
|
755
|
-
|
|
789
|
+
const asJsonSchema = toJsonSchema(schema);
|
|
790
|
+
return new ToolStrategy2(asJsonSchema, {
|
|
756
791
|
type: "function",
|
|
757
792
|
function: functionDefinition
|
|
758
793
|
}, outputOptions);
|
|
@@ -791,7 +826,8 @@ var ProviderStrategy = class ProviderStrategy2 {
|
|
|
791
826
|
}
|
|
792
827
|
}
|
|
793
828
|
static fromSchema(schema, strict) {
|
|
794
|
-
|
|
829
|
+
const asJsonSchema = toJsonSchema(schema);
|
|
830
|
+
return new ProviderStrategy2(asJsonSchema, strict);
|
|
795
831
|
}
|
|
796
832
|
/**
|
|
797
833
|
* Parse tool arguments according to the schema. If the response is not valid, return undefined.
|
|
@@ -842,22 +878,22 @@ function hasSupportForJsonSchemaOutput(model) {
|
|
|
842
878
|
return "structuredOutput" in model.profile && model.profile.structuredOutput === true;
|
|
843
879
|
}
|
|
844
880
|
|
|
845
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
881
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/middleware/utils.js
|
|
846
882
|
import { AIMessage, ToolMessage } from "@langchain/core/messages";
|
|
847
883
|
import { isLangChainTool } from "@langchain/core/tools";
|
|
848
884
|
import { convertToOpenAITool } from "@langchain/core/utils/function_calling";
|
|
849
885
|
|
|
850
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
886
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/transformers/tool-call.js
|
|
851
887
|
import { ToolMessage as ToolMessage2 } from "@langchain/core/messages";
|
|
852
888
|
import { StreamChannel } from "@langchain/langgraph";
|
|
853
889
|
|
|
854
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
890
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/transformers/subagent.js
|
|
855
891
|
import { StreamChannel as StreamChannel2, createMessagesTransformer } from "@langchain/langgraph";
|
|
856
892
|
|
|
857
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
893
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/middleware/types.js
|
|
858
894
|
var MIDDLEWARE_BRAND = /* @__PURE__ */ Symbol.for("AgentMiddleware");
|
|
859
895
|
|
|
860
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
896
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/middleware.js
|
|
861
897
|
function createMiddleware(config) {
|
|
862
898
|
return {
|
|
863
899
|
[MIDDLEWARE_BRAND]: true,
|
|
@@ -875,25 +911,25 @@ function createMiddleware(config) {
|
|
|
875
911
|
};
|
|
876
912
|
}
|
|
877
913
|
|
|
878
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
914
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/tests/utils.js
|
|
879
915
|
import { AIMessage as AIMessage2, HumanMessage } from "@langchain/core/messages";
|
|
880
916
|
import { BaseChatModel as BaseChatModel2 } from "@langchain/core/language_models/chat_models";
|
|
881
917
|
import { RunnableLambda } from "@langchain/core/runnables";
|
|
882
918
|
import "@langchain/core/tools";
|
|
883
919
|
|
|
884
|
-
// ../../node_modules/.pnpm/@langchain+langgraph-checkpoint@1.1.
|
|
920
|
+
// ../../node_modules/.pnpm/@langchain+langgraph-checkpoint@1.1.5_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@o_bdeb98e8f76a9cbfb62f56483c8f2407/node_modules/@langchain/langgraph-checkpoint/dist/id.js
|
|
885
921
|
import { v5, v6 } from "@langchain/core/utils/uuid";
|
|
886
922
|
|
|
887
|
-
// ../../node_modules/.pnpm/@langchain+langgraph-checkpoint@1.1.
|
|
923
|
+
// ../../node_modules/.pnpm/@langchain+langgraph-checkpoint@1.1.5_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@o_bdeb98e8f76a9cbfb62f56483c8f2407/node_modules/@langchain/langgraph-checkpoint/dist/serde/types.js
|
|
888
924
|
var ERROR = "__error__";
|
|
889
925
|
var SCHEDULED = "__scheduled__";
|
|
890
926
|
var INTERRUPT = "__interrupt__";
|
|
891
927
|
var RESUME = "__resume__";
|
|
892
928
|
|
|
893
|
-
// ../../node_modules/.pnpm/@langchain+langgraph-checkpoint@1.1.
|
|
929
|
+
// ../../node_modules/.pnpm/@langchain+langgraph-checkpoint@1.1.5_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@o_bdeb98e8f76a9cbfb62f56483c8f2407/node_modules/@langchain/langgraph-checkpoint/dist/serde/jsonplus.js
|
|
894
930
|
import { load } from "@langchain/core/load";
|
|
895
931
|
|
|
896
|
-
// ../../node_modules/.pnpm/@langchain+langgraph-checkpoint@1.1.
|
|
932
|
+
// ../../node_modules/.pnpm/@langchain+langgraph-checkpoint@1.1.5_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@o_bdeb98e8f76a9cbfb62f56483c8f2407/node_modules/@langchain/langgraph-checkpoint/dist/base.js
|
|
897
933
|
var WRITES_IDX_MAP = {
|
|
898
934
|
[ERROR]: -1,
|
|
899
935
|
[SCHEDULED]: -2,
|
|
@@ -901,52 +937,52 @@ var WRITES_IDX_MAP = {
|
|
|
901
937
|
[RESUME]: -4
|
|
902
938
|
};
|
|
903
939
|
|
|
904
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
940
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/tests/utils.js
|
|
905
941
|
import "zod/v3";
|
|
906
942
|
|
|
907
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
943
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/annotation.js
|
|
908
944
|
import { MessagesValue, ReducedValue, StateSchema, UntrackedValue } from "@langchain/langgraph";
|
|
909
945
|
import { schemaMetaRegistry } from "@langchain/langgraph/zod";
|
|
910
946
|
import { getInteropZodObjectShape, isInteropZodObject as isInteropZodObject2, isZodSchemaV4 } from "@langchain/core/utils/types";
|
|
911
947
|
|
|
912
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
948
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/utils.js
|
|
913
949
|
import { AIMessage as AIMessage3, AIMessageChunk, SystemMessage, ToolMessage as ToolMessage3 } from "@langchain/core/messages";
|
|
914
950
|
import { Runnable, RunnableBinding as RunnableBinding2, RunnableSequence } from "@langchain/core/runnables";
|
|
915
951
|
import { StateSchema as StateSchema2, isCommand } from "@langchain/langgraph";
|
|
916
952
|
import { interopParse, isInteropZodSchema as isInteropZodSchema2 } from "@langchain/core/utils/types";
|
|
917
953
|
|
|
918
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
954
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/nodes/utils.js
|
|
919
955
|
import { END, ReducedValue as ReducedValue2, StateSchema as StateSchema3 } from "@langchain/langgraph";
|
|
920
956
|
import { getInteropZodObjectShape as getInteropZodObjectShape2, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, isInteropZodObject as isInteropZodObject3, isZodSchemaV4 as isZodSchemaV42 } from "@langchain/core/utils/types";
|
|
921
957
|
import { z } from "zod/v4";
|
|
922
958
|
|
|
923
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
959
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/RunnableCallable.js
|
|
924
960
|
import { Runnable as Runnable2, mergeConfigs } from "@langchain/core/runnables";
|
|
925
961
|
import { AsyncLocalStorageProviderSingleton } from "@langchain/core/singletons";
|
|
926
962
|
|
|
927
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
963
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/withAgentName.js
|
|
928
964
|
import { RunnableLambda as RunnableLambda2, RunnableSequence as RunnableSequence2 } from "@langchain/core/runnables";
|
|
929
965
|
|
|
930
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
966
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/nodes/AgentNode.js
|
|
931
967
|
import { AIMessage as AIMessage4, SystemMessage as SystemMessage2, ToolMessage as ToolMessage4 } from "@langchain/core/messages";
|
|
932
968
|
import { raceWithSignal } from "@langchain/core/runnables";
|
|
933
969
|
import { Command, isCommand as isCommand2 } from "@langchain/langgraph";
|
|
934
970
|
import { getSchemaDescription, interopParse as interopParse2 } from "@langchain/core/utils/types";
|
|
935
971
|
|
|
936
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
972
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/nodes/ToolNode.js
|
|
937
973
|
import { AIMessage as AIMessage5, BaseMessage, ToolMessage as ToolMessage5 } from "@langchain/core/messages";
|
|
938
974
|
import { ToolInputParsingException } from "@langchain/core/tools";
|
|
939
975
|
import { Command as Command2, Send, isCommand as isCommand3, isGraphInterrupt } from "@langchain/langgraph";
|
|
940
976
|
|
|
941
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
977
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/nodes/middleware.js
|
|
942
978
|
import { getInteropZodObjectShape as getInteropZodObjectShape3, interopParse as interopParse3, isInteropZodObject as isInteropZodObject4 } from "@langchain/core/utils/types";
|
|
943
979
|
|
|
944
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
980
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/ReactAgent.js
|
|
945
981
|
import { AIMessage as AIMessage6, ToolMessage as ToolMessage6 } from "@langchain/core/messages";
|
|
946
982
|
import { mergeConfigs as mergeConfigs2 } from "@langchain/core/runnables";
|
|
947
983
|
import { Command as Command3, END as END2, START, Send as Send2, StateGraph } from "@langchain/langgraph";
|
|
948
984
|
|
|
949
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
985
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/middleware/hitl.js
|
|
950
986
|
import { AIMessage as AIMessage7, ToolMessage as ToolMessage7 } from "@langchain/core/messages";
|
|
951
987
|
import { interrupt } from "@langchain/langgraph";
|
|
952
988
|
import { interopParse as interopParse4 } from "@langchain/core/utils/types";
|
|
@@ -1056,12 +1092,49 @@ var contextSchema = z2.object({
|
|
|
1056
1092
|
descriptionPrefix: z2.string().default("Tool execution requires approval")
|
|
1057
1093
|
});
|
|
1058
1094
|
|
|
1059
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
1095
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/middleware/constants.js
|
|
1096
|
+
import { z as z3 } from "zod/v3";
|
|
1097
|
+
import { getRetryable } from "@langchain/core/errors";
|
|
1098
|
+
var RetrySchema = z3.object({
|
|
1099
|
+
/**
|
|
1100
|
+
* Maximum number of retry attempts after the initial call.
|
|
1101
|
+
* Default is 2 retries (3 total attempts). Must be >= 0.
|
|
1102
|
+
*/
|
|
1103
|
+
maxRetries: z3.number().min(0).default(2),
|
|
1104
|
+
/**
|
|
1105
|
+
* Either an array of error constructors to retry on, or a function
|
|
1106
|
+
* that takes an error and returns `true` if it should be retried.
|
|
1107
|
+
* Default is to retry unless the error is marked non-retryable.
|
|
1108
|
+
*/
|
|
1109
|
+
retryOn: z3.union([z3.function().args(z3.instanceof(Error)).returns(z3.boolean()), z3.array(z3.custom())]).default(() => (error) => getRetryable(error) ?? true),
|
|
1110
|
+
/**
|
|
1111
|
+
* Multiplier for exponential backoff. Each retry waits
|
|
1112
|
+
* `initialDelayMs * (backoffFactor ** retryNumber)` milliseconds.
|
|
1113
|
+
* Set to 0.0 for constant delay. Default is 2.0.
|
|
1114
|
+
*/
|
|
1115
|
+
backoffFactor: z3.number().min(0).default(2),
|
|
1116
|
+
/**
|
|
1117
|
+
* Initial delay in milliseconds before first retry. Default is 1000 (1 second).
|
|
1118
|
+
*/
|
|
1119
|
+
initialDelayMs: z3.number().min(0).default(1e3),
|
|
1120
|
+
/**
|
|
1121
|
+
* Maximum delay in milliseconds between retries. Caps exponential
|
|
1122
|
+
* backoff growth. Default is 60000 (60 seconds).
|
|
1123
|
+
*/
|
|
1124
|
+
maxDelayMs: z3.number().min(0).default(6e4),
|
|
1125
|
+
/**
|
|
1126
|
+
* Whether to add random jitter (±25%) to delay to avoid thundering herd.
|
|
1127
|
+
* Default is `true`.
|
|
1128
|
+
*/
|
|
1129
|
+
jitter: z3.boolean().default(true)
|
|
1130
|
+
});
|
|
1131
|
+
|
|
1132
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/middleware/summarization.js
|
|
1060
1133
|
import { AIMessage as AIMessage8, HumanMessage as HumanMessage2, RemoveMessage, SystemMessage as SystemMessage3, ToolMessage as ToolMessage8, getBufferString, trimMessages } from "@langchain/core/messages";
|
|
1061
1134
|
import { mergeConfigs as mergeConfigs3, pickRunnableConfigKeys } from "@langchain/core/runnables";
|
|
1062
1135
|
import { REMOVE_ALL_MESSAGES } from "@langchain/langgraph";
|
|
1063
1136
|
import { interopSafeParse } from "@langchain/core/utils/types";
|
|
1064
|
-
import { z as
|
|
1137
|
+
import { z as z4 } from "zod/v4";
|
|
1065
1138
|
import { z as z$1 } from "zod/v3";
|
|
1066
1139
|
import { v4 } from "@langchain/core/utils/uuid";
|
|
1067
1140
|
import { getModelContextSize } from "@langchain/core/language_models/base";
|
|
@@ -1183,71 +1256,71 @@ var contextSchema2 = z$1.object({
|
|
|
1183
1256
|
messagesToKeep: z$1.number().optional()
|
|
1184
1257
|
});
|
|
1185
1258
|
|
|
1186
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
1259
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/middleware/dynamicSystemPrompt.js
|
|
1187
1260
|
import { SystemMessage as SystemMessage4 } from "@langchain/core/messages";
|
|
1188
1261
|
|
|
1189
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
1262
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/middleware/llmToolSelector.js
|
|
1190
1263
|
import { HumanMessage as HumanMessage3 } from "@langchain/core/messages";
|
|
1191
1264
|
import { mergeConfigs as mergeConfigs4, pickRunnableConfigKeys as pickRunnableConfigKeys2 } from "@langchain/core/runnables";
|
|
1192
|
-
import { z as
|
|
1265
|
+
import { z as z5 } from "zod/v3";
|
|
1193
1266
|
import { BaseLanguageModel } from "@langchain/core/language_models/base";
|
|
1194
|
-
var LLMToolSelectorOptionsSchema =
|
|
1267
|
+
var LLMToolSelectorOptionsSchema = z5.object({
|
|
1195
1268
|
/**
|
|
1196
1269
|
* The language model to use for tool selection (default: the provided model from the agent options).
|
|
1197
1270
|
*/
|
|
1198
|
-
model:
|
|
1271
|
+
model: z5.string().or(z5.instanceof(BaseLanguageModel)).optional(),
|
|
1199
1272
|
/**
|
|
1200
1273
|
* System prompt for the tool selection model.
|
|
1201
1274
|
*/
|
|
1202
|
-
systemPrompt:
|
|
1275
|
+
systemPrompt: z5.string().optional(),
|
|
1203
1276
|
/**
|
|
1204
1277
|
* Maximum number of tools to select. If the model selects more,
|
|
1205
1278
|
* only the first maxTools will be used. No limit if not specified.
|
|
1206
1279
|
*/
|
|
1207
|
-
maxTools:
|
|
1280
|
+
maxTools: z5.number().optional(),
|
|
1208
1281
|
/**
|
|
1209
1282
|
* Tool names to always include regardless of selection.
|
|
1210
1283
|
* These do not count against the maxTools limit.
|
|
1211
1284
|
*/
|
|
1212
|
-
alwaysInclude:
|
|
1285
|
+
alwaysInclude: z5.array(z5.string()).optional()
|
|
1213
1286
|
});
|
|
1214
1287
|
|
|
1215
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
1288
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/middleware/pii.js
|
|
1216
1289
|
import { AIMessage as AIMessage9, HumanMessage as HumanMessage4, ToolMessage as ToolMessage9 } from "@langchain/core/messages";
|
|
1217
|
-
import { z as
|
|
1290
|
+
import { z as z6 } from "zod/v3";
|
|
1218
1291
|
import { sha256 } from "@langchain/core/utils/hash";
|
|
1219
|
-
var contextSchema3 =
|
|
1292
|
+
var contextSchema3 = z6.object({
|
|
1220
1293
|
/**
|
|
1221
1294
|
* Whether to check user messages before model call
|
|
1222
1295
|
*/
|
|
1223
|
-
applyToInput:
|
|
1296
|
+
applyToInput: z6.boolean().optional(),
|
|
1224
1297
|
/**
|
|
1225
1298
|
* Whether to check AI messages after model call
|
|
1226
1299
|
*/
|
|
1227
|
-
applyToOutput:
|
|
1300
|
+
applyToOutput: z6.boolean().optional(),
|
|
1228
1301
|
/**
|
|
1229
1302
|
* Whether to check tool result messages after tool execution
|
|
1230
1303
|
*/
|
|
1231
|
-
applyToToolResults:
|
|
1304
|
+
applyToToolResults: z6.boolean().optional()
|
|
1232
1305
|
});
|
|
1233
1306
|
|
|
1234
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
1307
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/middleware/piiRedaction.js
|
|
1235
1308
|
import { AIMessage as AIMessage10, HumanMessage as HumanMessage5, RemoveMessage as RemoveMessage2, SystemMessage as SystemMessage5, ToolMessage as ToolMessage10 } from "@langchain/core/messages";
|
|
1236
|
-
import { z as
|
|
1237
|
-
var contextSchema4 =
|
|
1309
|
+
import { z as z7 } from "zod/v3";
|
|
1310
|
+
var contextSchema4 = z7.object({
|
|
1238
1311
|
/**
|
|
1239
1312
|
* A record of PII detection rules to apply
|
|
1240
1313
|
* @default DEFAULT_PII_RULES (with enabled rules only)
|
|
1241
1314
|
*/
|
|
1242
|
-
rules:
|
|
1315
|
+
rules: z7.record(z7.string(), z7.instanceof(RegExp).describe("Regular expression pattern to match PII")).optional()
|
|
1243
1316
|
});
|
|
1244
1317
|
|
|
1245
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
1318
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/middleware/contextEditing.js
|
|
1246
1319
|
import { AIMessage as AIMessage11, SystemMessage as SystemMessage6, ToolMessage as ToolMessage11 } from "@langchain/core/messages";
|
|
1247
1320
|
|
|
1248
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
1321
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/middleware/toolCallLimit.js
|
|
1249
1322
|
import { AIMessage as AIMessage12, ToolMessage as ToolMessage12 } from "@langchain/core/messages";
|
|
1250
|
-
import { z as
|
|
1323
|
+
import { z as z8 } from "zod/v4";
|
|
1251
1324
|
import { z as z$12 } from "zod/v3";
|
|
1252
1325
|
var VALID_EXIT_BEHAVIORS = [
|
|
1253
1326
|
"continue",
|
|
@@ -1288,87 +1361,51 @@ var stateSchema = z$12.object({
|
|
|
1288
1361
|
runToolCallCount: z$12.record(z$12.string(), z$12.number()).default({})
|
|
1289
1362
|
});
|
|
1290
1363
|
|
|
1291
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
1364
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/middleware/todoListMiddleware.js
|
|
1292
1365
|
import { AIMessage as AIMessage13, ToolMessage as ToolMessage13 } from "@langchain/core/messages";
|
|
1293
1366
|
import { tool as tool2 } from "@langchain/core/tools";
|
|
1294
1367
|
import { Command as Command4 } from "@langchain/langgraph";
|
|
1295
|
-
import { z as
|
|
1296
|
-
var TodoStatus =
|
|
1368
|
+
import { z as z9 } from "zod/v3";
|
|
1369
|
+
var TodoStatus = z9.enum([
|
|
1297
1370
|
"pending",
|
|
1298
1371
|
"in_progress",
|
|
1299
1372
|
"completed"
|
|
1300
1373
|
]).describe("Status of the todo");
|
|
1301
|
-
var TodoSchema =
|
|
1302
|
-
content:
|
|
1374
|
+
var TodoSchema = z9.object({
|
|
1375
|
+
content: z9.string().describe("Content of the todo item"),
|
|
1303
1376
|
status: TodoStatus
|
|
1304
1377
|
});
|
|
1305
|
-
var stateSchema2 =
|
|
1378
|
+
var stateSchema2 = z9.object({ todos: z9.array(TodoSchema).default([]) });
|
|
1306
1379
|
|
|
1307
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
1380
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/middleware/modelCallLimit.js
|
|
1308
1381
|
import { AIMessage as AIMessage14 } from "@langchain/core/messages";
|
|
1309
|
-
import { z as
|
|
1310
|
-
var contextSchema5 =
|
|
1382
|
+
import { z as z10 } from "zod/v3";
|
|
1383
|
+
var contextSchema5 = z10.object({
|
|
1311
1384
|
/**
|
|
1312
1385
|
* The maximum number of model calls allowed per thread.
|
|
1313
1386
|
*/
|
|
1314
|
-
threadLimit:
|
|
1387
|
+
threadLimit: z10.number().optional(),
|
|
1315
1388
|
/**
|
|
1316
1389
|
* The maximum number of model calls allowed per run.
|
|
1317
1390
|
*/
|
|
1318
|
-
runLimit:
|
|
1391
|
+
runLimit: z10.number().optional(),
|
|
1319
1392
|
/**
|
|
1320
1393
|
* The behavior to take when the limit is exceeded.
|
|
1321
1394
|
* - "error" will throw an error and stop the agent.
|
|
1322
1395
|
* - "end" will end the agent.
|
|
1323
1396
|
* @default "end"
|
|
1324
1397
|
*/
|
|
1325
|
-
exitBehavior:
|
|
1326
|
-
});
|
|
1327
|
-
var stateSchema3 = z9.object({
|
|
1328
|
-
threadModelCallCount: z9.number().default(0),
|
|
1329
|
-
runModelCallCount: z9.number().default(0)
|
|
1398
|
+
exitBehavior: z10.enum(["error", "end"]).optional()
|
|
1330
1399
|
});
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
var RetrySchema = z10.object({
|
|
1335
|
-
/**
|
|
1336
|
-
* Maximum number of retry attempts after the initial call.
|
|
1337
|
-
* Default is 2 retries (3 total attempts). Must be >= 0.
|
|
1338
|
-
*/
|
|
1339
|
-
maxRetries: z10.number().min(0).default(2),
|
|
1340
|
-
/**
|
|
1341
|
-
* Either an array of error constructors to retry on, or a function
|
|
1342
|
-
* that takes an error and returns `true` if it should be retried.
|
|
1343
|
-
* Default is to retry on all errors.
|
|
1344
|
-
*/
|
|
1345
|
-
retryOn: z10.union([z10.function().args(z10.instanceof(Error)).returns(z10.boolean()), z10.array(z10.custom())]).default(() => () => true),
|
|
1346
|
-
/**
|
|
1347
|
-
* Multiplier for exponential backoff. Each retry waits
|
|
1348
|
-
* `initialDelayMs * (backoffFactor ** retryNumber)` milliseconds.
|
|
1349
|
-
* Set to 0.0 for constant delay. Default is 2.0.
|
|
1350
|
-
*/
|
|
1351
|
-
backoffFactor: z10.number().min(0).default(2),
|
|
1352
|
-
/**
|
|
1353
|
-
* Initial delay in milliseconds before first retry. Default is 1000 (1 second).
|
|
1354
|
-
*/
|
|
1355
|
-
initialDelayMs: z10.number().min(0).default(1e3),
|
|
1356
|
-
/**
|
|
1357
|
-
* Maximum delay in milliseconds between retries. Caps exponential
|
|
1358
|
-
* backoff growth. Default is 60000 (60 seconds).
|
|
1359
|
-
*/
|
|
1360
|
-
maxDelayMs: z10.number().min(0).default(6e4),
|
|
1361
|
-
/**
|
|
1362
|
-
* Whether to add random jitter (±25%) to delay to avoid thundering herd.
|
|
1363
|
-
* Default is `true`.
|
|
1364
|
-
*/
|
|
1365
|
-
jitter: z10.boolean().default(true)
|
|
1400
|
+
var stateSchema3 = z10.object({
|
|
1401
|
+
threadModelCallCount: z10.number().default(0),
|
|
1402
|
+
runModelCallCount: z10.number().default(0)
|
|
1366
1403
|
});
|
|
1367
1404
|
|
|
1368
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
1405
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/middleware/error.js
|
|
1369
1406
|
import { z as z11 } from "zod/v4";
|
|
1370
1407
|
|
|
1371
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
1408
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/middleware/modelRetry.js
|
|
1372
1409
|
import { AIMessage as AIMessage15 } from "@langchain/core/messages";
|
|
1373
1410
|
import { z as z12 } from "zod/v3";
|
|
1374
1411
|
var ModelRetryMiddlewareOptionsSchema = z12.object({
|
|
@@ -1387,7 +1424,7 @@ var ModelRetryMiddlewareOptionsSchema = z12.object({
|
|
|
1387
1424
|
]).default("continue")
|
|
1388
1425
|
}).merge(RetrySchema);
|
|
1389
1426
|
|
|
1390
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
1427
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/middleware/toolRetry.js
|
|
1391
1428
|
import { ToolMessage as ToolMessage14 } from "@langchain/core/messages";
|
|
1392
1429
|
import { z as z13 } from "zod/v3";
|
|
1393
1430
|
var ToolRetryMiddlewareOptionsSchema = z13.object({
|
|
@@ -1422,16 +1459,21 @@ var ToolRetryMiddlewareOptionsSchema = z13.object({
|
|
|
1422
1459
|
]).default("continue")
|
|
1423
1460
|
}).merge(RetrySchema);
|
|
1424
1461
|
|
|
1425
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
1426
|
-
import {
|
|
1462
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/middleware/toolError.js
|
|
1463
|
+
import { ToolMessage as ToolMessage15 } from "@langchain/core/messages";
|
|
1464
|
+
import { isGraphBubbleUp as isGraphBubbleUp2 } from "@langchain/langgraph";
|
|
1465
|
+
|
|
1466
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/middleware/toolEmulator.js
|
|
1467
|
+
import { HumanMessage as HumanMessage6, ToolMessage as ToolMessage16 } from "@langchain/core/messages";
|
|
1468
|
+
import { mergeConfigs as mergeConfigs5, pickRunnableConfigKeys as pickRunnableConfigKeys3 } from "@langchain/core/runnables";
|
|
1427
1469
|
|
|
1428
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
1470
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/middleware/providerToolSearch.js
|
|
1429
1471
|
import { isLangChainTool as isLangChainTool2 } from "@langchain/core/utils/function_calling";
|
|
1430
1472
|
|
|
1431
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
1432
|
-
import { AIMessage as AIMessage16, HumanMessage as HumanMessage7, ToolMessage as
|
|
1473
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/middleware/provider/openai/moderation.js
|
|
1474
|
+
import { AIMessage as AIMessage16, HumanMessage as HumanMessage7, ToolMessage as ToolMessage17 } from "@langchain/core/messages";
|
|
1433
1475
|
|
|
1434
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
1476
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/middleware/provider/anthropic/promptCaching.js
|
|
1435
1477
|
import { z as z14 } from "zod/v3";
|
|
1436
1478
|
var contextSchema6 = z14.object({
|
|
1437
1479
|
/**
|
|
@@ -1463,7 +1505,7 @@ var contextSchema6 = z14.object({
|
|
|
1463
1505
|
]).optional()
|
|
1464
1506
|
});
|
|
1465
1507
|
|
|
1466
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
1508
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/agents/middleware/provider/aws/promptCaching.js
|
|
1467
1509
|
import { z as z15 } from "zod/v3";
|
|
1468
1510
|
var contextSchema7 = z15.object({
|
|
1469
1511
|
/**
|
|
@@ -1495,8 +1537,8 @@ var contextSchema7 = z15.object({
|
|
|
1495
1537
|
]).optional()
|
|
1496
1538
|
});
|
|
1497
1539
|
|
|
1498
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
1499
|
-
import { AIMessage as AIMessage17, AIMessageChunk as AIMessageChunk2, BaseMessage as BaseMessage2, BaseMessageChunk, HumanMessage as HumanMessage8, HumanMessageChunk, SystemMessage as SystemMessage7, SystemMessageChunk, ToolMessage as
|
|
1540
|
+
// ../../node_modules/.pnpm/langchain@1.5.10_@langchain+core@1.2.9_@opentelemetry+api@1.9.1_@opentelemetry+exporter_2b1d5d6713e462e285c736d49161abb1/node_modules/langchain/dist/index.js
|
|
1541
|
+
import { AIMessage as AIMessage17, AIMessageChunk as AIMessageChunk2, BaseMessage as BaseMessage2, BaseMessageChunk, HumanMessage as HumanMessage8, HumanMessageChunk, SystemMessage as SystemMessage7, SystemMessageChunk, ToolMessage as ToolMessage18, ToolMessageChunk, filterMessages, trimMessages as trimMessages2 } from "@langchain/core/messages";
|
|
1500
1542
|
import { DynamicStructuredTool, DynamicTool, StructuredTool, Tool } from "@langchain/core/tools";
|
|
1501
1543
|
import { context } from "@langchain/core/utils/context";
|
|
1502
1544
|
import { InMemoryStore as InMemoryStore2 } from "@langchain/core/stores";
|
|
@@ -1853,7 +1895,7 @@ function createLocalShellBackend({
|
|
|
1853
1895
|
// src/bridge/tool-filtering.ts
|
|
1854
1896
|
import {
|
|
1855
1897
|
AIMessage as AIMessage18,
|
|
1856
|
-
ToolMessage as
|
|
1898
|
+
ToolMessage as ToolMessage19
|
|
1857
1899
|
} from "@langchain/core/messages";
|
|
1858
1900
|
var MIDDLEWARE_BRAND2 = /* @__PURE__ */ Symbol.for("AgentMiddleware");
|
|
1859
1901
|
function getBuiltinToolFilteringDenialReason(input) {
|
|
@@ -1910,7 +1952,7 @@ function createBuiltinToolFilteringMiddleware(input) {
|
|
|
1910
1952
|
result: reason
|
|
1911
1953
|
});
|
|
1912
1954
|
deniedToolMessages.push(
|
|
1913
|
-
new
|
|
1955
|
+
new ToolMessage19({
|
|
1914
1956
|
content: reason,
|
|
1915
1957
|
name: nativeName,
|
|
1916
1958
|
tool_call_id: toolCall.id,
|
|
@@ -2003,6 +2045,8 @@ var currentTurn;
|
|
|
2003
2045
|
var mcpClient;
|
|
2004
2046
|
var mcpToolNames = /* @__PURE__ */ new Set();
|
|
2005
2047
|
var currentResponseFormat;
|
|
2048
|
+
var checkpointer = new MemorySaver2();
|
|
2049
|
+
var agentConfigurationSignature;
|
|
2006
2050
|
var responseFormatMiddleware = createMiddleware({
|
|
2007
2051
|
name: "HarnessResponseFormat",
|
|
2008
2052
|
wrapModelCall(request, handler) {
|
|
@@ -2045,7 +2089,25 @@ async function runTurn(start, turn) {
|
|
|
2045
2089
|
start.permissionMode,
|
|
2046
2090
|
start.builtinToolFiltering
|
|
2047
2091
|
);
|
|
2048
|
-
|
|
2092
|
+
const config = {
|
|
2093
|
+
version: "v2",
|
|
2094
|
+
configurable: { thread_id: "bridge-session" },
|
|
2095
|
+
...start.recursionLimit != null ? { recursionLimit: start.recursionLimit } : {},
|
|
2096
|
+
signal: turn.abortSignal
|
|
2097
|
+
};
|
|
2098
|
+
const nextAgentConfigurationSignature = JSON.stringify({
|
|
2099
|
+
instructions: start.instructions,
|
|
2100
|
+
tools: start.tools,
|
|
2101
|
+
skillsPaths: start.skillsPaths
|
|
2102
|
+
});
|
|
2103
|
+
const rebuildAgent = agent == null || agentConfigurationSignature !== nextAgentConfigurationSignature || start.skillsChanged === true;
|
|
2104
|
+
if (rebuildAgent) {
|
|
2105
|
+
if (agent != null && start.skillsChanged === true) {
|
|
2106
|
+
await agent.updateState(config, {
|
|
2107
|
+
skillsMetadata: new Overwrite([])
|
|
2108
|
+
});
|
|
2109
|
+
}
|
|
2110
|
+
await closeMcpClient();
|
|
2049
2111
|
const model = buildModel({
|
|
2050
2112
|
rawModel: start.model,
|
|
2051
2113
|
thinking: start.thinking,
|
|
@@ -2091,8 +2153,13 @@ async function runTurn(start, turn) {
|
|
|
2091
2153
|
// Gate built-in tools behind HITL approval when the permission mode requires it.
|
|
2092
2154
|
...interruptOn ? { interruptOn } : {},
|
|
2093
2155
|
// Real instance (LangGraph rejects `true` for root graphs); gives multi-turn memory.
|
|
2094
|
-
checkpointer
|
|
2156
|
+
checkpointer
|
|
2095
2157
|
});
|
|
2158
|
+
agentConfigurationSignature = nextAgentConfigurationSignature;
|
|
2159
|
+
}
|
|
2160
|
+
const activeAgent = agent;
|
|
2161
|
+
if (activeAgent == null) {
|
|
2162
|
+
throw new Error("Deep Agents runtime was not initialized");
|
|
2096
2163
|
}
|
|
2097
2164
|
const hostToolNames = new Set((start.tools ?? []).map((t) => t.name));
|
|
2098
2165
|
const streamEventState = createDeepAgentsStreamEventState();
|
|
@@ -2106,15 +2173,9 @@ async function runTurn(start, turn) {
|
|
|
2106
2173
|
),
|
|
2107
2174
|
emit
|
|
2108
2175
|
});
|
|
2109
|
-
const config = {
|
|
2110
|
-
version: "v2",
|
|
2111
|
-
configurable: { thread_id: "bridge-session" },
|
|
2112
|
-
...start.recursionLimit != null ? { recursionLimit: start.recursionLimit } : {},
|
|
2113
|
-
signal: turn.abortSignal
|
|
2114
|
-
};
|
|
2115
2176
|
const readPendingApprovals = async () => {
|
|
2116
2177
|
try {
|
|
2117
|
-
const state = await
|
|
2178
|
+
const state = await activeAgent.getState({
|
|
2118
2179
|
configurable: { thread_id: "bridge-session" }
|
|
2119
2180
|
});
|
|
2120
2181
|
return collectActionRequests(
|
|
@@ -2129,7 +2190,7 @@ async function runTurn(start, turn) {
|
|
|
2129
2190
|
};
|
|
2130
2191
|
let emittedStructuredOutput = false;
|
|
2131
2192
|
while (true) {
|
|
2132
|
-
const stream = await
|
|
2193
|
+
const stream = await activeAgent.streamEvents(resumeInput, config);
|
|
2133
2194
|
for await (const event of stream) {
|
|
2134
2195
|
emitStreamEvent(event);
|
|
2135
2196
|
const streamEvent = event;
|