@ai-sdk/harness-deepagents 1.0.92 → 1.0.94
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 +26 -0
- package/README.md +4 -4
- package/dist/bridge/index.mjs +359 -160
- 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 +6 -1
- package/dist/index.js +26 -28
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/bridge/index.ts +84 -42
- package/src/bridge/package.json +6 -6
- package/src/bridge/persistent-memory-saver.ts +137 -0
- package/src/bridge/pnpm-lock.yaml +68 -68
- package/src/deepagents-bridge-protocol.ts +1 -0
- package/src/deepagents-harness.ts +43 -40
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:
|
|
1398
|
+
exitBehavior: z10.enum(["error", "end"]).optional()
|
|
1326
1399
|
});
|
|
1327
|
-
var stateSchema3 =
|
|
1328
|
-
threadModelCallCount:
|
|
1329
|
-
runModelCallCount:
|
|
1330
|
-
});
|
|
1331
|
-
|
|
1332
|
-
// ../../node_modules/.pnpm/langchain@1.5.3_@langchain+core@1.2.3_@opentelemetry+api@1.9.1_@opentelemetry+exporter-_b22186a8bf4af5c6409ec6eeb0354a26/node_modules/langchain/dist/agents/middleware/constants.js
|
|
1333
|
-
import { z as z10 } from "zod/v3";
|
|
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";
|
|
1427
1465
|
|
|
1428
|
-
// ../../node_modules/.pnpm/langchain@1.5.
|
|
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";
|
|
1469
|
+
|
|
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";
|
|
@@ -1850,10 +1892,128 @@ function createLocalShellBackend({
|
|
|
1850
1892
|
});
|
|
1851
1893
|
}
|
|
1852
1894
|
|
|
1895
|
+
// src/bridge/persistent-memory-saver.ts
|
|
1896
|
+
import { mkdir as mkdir2, readFile, rename, rm, writeFile as writeFile2 } from "fs/promises";
|
|
1897
|
+
import { dirname } from "path";
|
|
1898
|
+
var SNAPSHOT_HEADER = "deepagents-memory-saver-v1";
|
|
1899
|
+
function encodeString(value) {
|
|
1900
|
+
return Buffer.from(value, "utf8").toString("base64");
|
|
1901
|
+
}
|
|
1902
|
+
function decodeString(value) {
|
|
1903
|
+
return Buffer.from(value, "base64").toString("utf8");
|
|
1904
|
+
}
|
|
1905
|
+
function encodeBytes(value) {
|
|
1906
|
+
return Buffer.from(value).toString("base64");
|
|
1907
|
+
}
|
|
1908
|
+
function decodeBytes(value) {
|
|
1909
|
+
return Buffer.from(value, "base64");
|
|
1910
|
+
}
|
|
1911
|
+
async function loadMemorySaver({
|
|
1912
|
+
path,
|
|
1913
|
+
saver
|
|
1914
|
+
}) {
|
|
1915
|
+
let snapshot;
|
|
1916
|
+
try {
|
|
1917
|
+
snapshot = await readFile(path, "utf8");
|
|
1918
|
+
} catch (error) {
|
|
1919
|
+
if (error.code === "ENOENT") return;
|
|
1920
|
+
throw error;
|
|
1921
|
+
}
|
|
1922
|
+
const [header, ...lines] = snapshot.split("\n");
|
|
1923
|
+
if (header !== SNAPSHOT_HEADER) {
|
|
1924
|
+
throw new Error("Unsupported Deep Agents conversation checkpoint format");
|
|
1925
|
+
}
|
|
1926
|
+
const storage = /* @__PURE__ */ Object.create(null);
|
|
1927
|
+
const writes = /* @__PURE__ */ Object.create(null);
|
|
1928
|
+
for (const line of lines) {
|
|
1929
|
+
if (line === "") continue;
|
|
1930
|
+
const fields = line.split(" ");
|
|
1931
|
+
if (fields[0] === "S" && fields.length === 7) {
|
|
1932
|
+
const [, threadIdValue, namespaceValue, checkpointIdValue] = fields;
|
|
1933
|
+
const threadId = decodeString(threadIdValue);
|
|
1934
|
+
const namespace = decodeString(namespaceValue);
|
|
1935
|
+
const checkpointId = decodeString(checkpointIdValue);
|
|
1936
|
+
storage[threadId] ??= /* @__PURE__ */ Object.create(null);
|
|
1937
|
+
storage[threadId][namespace] ??= /* @__PURE__ */ Object.create(null);
|
|
1938
|
+
storage[threadId][namespace][checkpointId] = [
|
|
1939
|
+
decodeBytes(fields[4]),
|
|
1940
|
+
decodeBytes(fields[5]),
|
|
1941
|
+
fields[6] === "" ? void 0 : decodeString(fields[6])
|
|
1942
|
+
];
|
|
1943
|
+
continue;
|
|
1944
|
+
}
|
|
1945
|
+
if (fields[0] === "W" && fields.length === 6) {
|
|
1946
|
+
const [, keyValue, indexValue, taskIdValue, channelValue, value] = fields;
|
|
1947
|
+
const key = decodeString(keyValue);
|
|
1948
|
+
const index = decodeString(indexValue);
|
|
1949
|
+
writes[key] ??= /* @__PURE__ */ Object.create(null);
|
|
1950
|
+
writes[key][index] = [
|
|
1951
|
+
decodeString(taskIdValue),
|
|
1952
|
+
decodeString(channelValue),
|
|
1953
|
+
decodeBytes(value)
|
|
1954
|
+
];
|
|
1955
|
+
continue;
|
|
1956
|
+
}
|
|
1957
|
+
throw new Error("Invalid Deep Agents conversation checkpoint");
|
|
1958
|
+
}
|
|
1959
|
+
saver.storage = storage;
|
|
1960
|
+
saver.writes = writes;
|
|
1961
|
+
}
|
|
1962
|
+
async function saveMemorySaver({
|
|
1963
|
+
path,
|
|
1964
|
+
saver
|
|
1965
|
+
}) {
|
|
1966
|
+
const lines = [SNAPSHOT_HEADER];
|
|
1967
|
+
for (const [threadId, namespaces] of Object.entries(saver.storage)) {
|
|
1968
|
+
for (const [namespace, checkpoints] of Object.entries(namespaces)) {
|
|
1969
|
+
for (const [
|
|
1970
|
+
checkpointId,
|
|
1971
|
+
[checkpoint, metadata, parentCheckpointId]
|
|
1972
|
+
] of Object.entries(checkpoints)) {
|
|
1973
|
+
lines.push(
|
|
1974
|
+
[
|
|
1975
|
+
"S",
|
|
1976
|
+
encodeString(threadId),
|
|
1977
|
+
encodeString(namespace),
|
|
1978
|
+
encodeString(checkpointId),
|
|
1979
|
+
encodeBytes(checkpoint),
|
|
1980
|
+
encodeBytes(metadata),
|
|
1981
|
+
parentCheckpointId == null ? "" : encodeString(parentCheckpointId)
|
|
1982
|
+
].join(" ")
|
|
1983
|
+
);
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1987
|
+
for (const [key, indexedWrites] of Object.entries(saver.writes)) {
|
|
1988
|
+
for (const [index, [taskId, channel, value]] of Object.entries(
|
|
1989
|
+
indexedWrites
|
|
1990
|
+
)) {
|
|
1991
|
+
lines.push(
|
|
1992
|
+
[
|
|
1993
|
+
"W",
|
|
1994
|
+
encodeString(key),
|
|
1995
|
+
encodeString(index),
|
|
1996
|
+
encodeString(taskId),
|
|
1997
|
+
encodeString(channel),
|
|
1998
|
+
encodeBytes(value)
|
|
1999
|
+
].join(" ")
|
|
2000
|
+
);
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
await mkdir2(dirname(path), { recursive: true });
|
|
2004
|
+
const temporaryPath = `${path}.${process.pid}.tmp`;
|
|
2005
|
+
await writeFile2(temporaryPath, `${lines.join("\n")}
|
|
2006
|
+
`, "utf8");
|
|
2007
|
+
await rename(temporaryPath, path);
|
|
2008
|
+
}
|
|
2009
|
+
async function removeMemorySaverSnapshot(path) {
|
|
2010
|
+
await rm(path, { force: true });
|
|
2011
|
+
}
|
|
2012
|
+
|
|
1853
2013
|
// src/bridge/tool-filtering.ts
|
|
1854
2014
|
import {
|
|
1855
2015
|
AIMessage as AIMessage18,
|
|
1856
|
-
ToolMessage as
|
|
2016
|
+
ToolMessage as ToolMessage19
|
|
1857
2017
|
} from "@langchain/core/messages";
|
|
1858
2018
|
var MIDDLEWARE_BRAND2 = /* @__PURE__ */ Symbol.for("AgentMiddleware");
|
|
1859
2019
|
function getBuiltinToolFilteringDenialReason(input) {
|
|
@@ -1910,7 +2070,7 @@ function createBuiltinToolFilteringMiddleware(input) {
|
|
|
1910
2070
|
result: reason
|
|
1911
2071
|
});
|
|
1912
2072
|
deniedToolMessages.push(
|
|
1913
|
-
new
|
|
2073
|
+
new ToolMessage19({
|
|
1914
2074
|
content: reason,
|
|
1915
2075
|
name: nativeName,
|
|
1916
2076
|
tool_call_id: toolCall.id,
|
|
@@ -1966,14 +2126,22 @@ function buildModel({
|
|
|
1966
2126
|
} : {}
|
|
1967
2127
|
});
|
|
1968
2128
|
}
|
|
1969
|
-
function
|
|
1970
|
-
thinking,
|
|
1971
|
-
effort
|
|
1972
|
-
}) {
|
|
1973
|
-
if (!thinking && !effort) return void 0;
|
|
2129
|
+
function createModelMiddleware() {
|
|
1974
2130
|
return createMiddleware({
|
|
1975
|
-
name: "
|
|
2131
|
+
name: "harnessModel",
|
|
1976
2132
|
wrapModelCall: async (request, handler) => {
|
|
2133
|
+
if (!activeModel && !activeThinking && !activeEffort) {
|
|
2134
|
+
return handler(request);
|
|
2135
|
+
}
|
|
2136
|
+
if (activeModel) {
|
|
2137
|
+
const configuredModel2 = buildModel({
|
|
2138
|
+
rawModel: activeModel,
|
|
2139
|
+
thinking: activeThinking,
|
|
2140
|
+
effort: activeEffort
|
|
2141
|
+
});
|
|
2142
|
+
if (!configuredModel2) throw new Error("Deep Agents model is missing");
|
|
2143
|
+
return handler({ ...request, model: configuredModel2 });
|
|
2144
|
+
}
|
|
1977
2145
|
let model = request.model;
|
|
1978
2146
|
if ("_getModelInstance" in model && typeof model._getModelInstance === "function") {
|
|
1979
2147
|
model = await model._getModelInstance();
|
|
@@ -1983,8 +2151,8 @@ function createReasoningMiddleware({
|
|
|
1983
2151
|
}
|
|
1984
2152
|
const configuredModel = buildModel({
|
|
1985
2153
|
rawModel: model.model,
|
|
1986
|
-
thinking,
|
|
1987
|
-
effort
|
|
2154
|
+
thinking: activeThinking,
|
|
2155
|
+
effort: activeEffort
|
|
1988
2156
|
});
|
|
1989
2157
|
if (!configuredModel) throw new Error("Deep Agents model is missing");
|
|
1990
2158
|
return handler({ ...request, model: configuredModel });
|
|
@@ -1998,11 +2166,26 @@ if (!workdir || !bridgeStateDir) {
|
|
|
1998
2166
|
console.error("deepagents bridge: missing --workdir / --bridge-state-dir");
|
|
1999
2167
|
process.exit(1);
|
|
2000
2168
|
}
|
|
2169
|
+
var conversationCheckpointPath = `${bridgeStateDir}/conversation.checkpoint`;
|
|
2001
2170
|
var agent;
|
|
2002
2171
|
var currentTurn;
|
|
2003
2172
|
var mcpClient;
|
|
2004
2173
|
var mcpToolNames = /* @__PURE__ */ new Set();
|
|
2005
2174
|
var currentResponseFormat;
|
|
2175
|
+
var checkpointer = new MemorySaver2();
|
|
2176
|
+
if (args.resume === "true") {
|
|
2177
|
+
await loadMemorySaver({
|
|
2178
|
+
path: conversationCheckpointPath,
|
|
2179
|
+
saver: checkpointer
|
|
2180
|
+
});
|
|
2181
|
+
} else {
|
|
2182
|
+
await removeMemorySaverSnapshot(conversationCheckpointPath);
|
|
2183
|
+
}
|
|
2184
|
+
var agentConfigurationSignature;
|
|
2185
|
+
var activeModel;
|
|
2186
|
+
var activeThinking;
|
|
2187
|
+
var activeEffort;
|
|
2188
|
+
var modelMiddleware = createModelMiddleware();
|
|
2006
2189
|
var responseFormatMiddleware = createMiddleware({
|
|
2007
2190
|
name: "HarnessResponseFormat",
|
|
2008
2191
|
wrapModelCall(request, handler) {
|
|
@@ -2039,22 +2222,34 @@ function buildHostTools(toolSchemas) {
|
|
|
2039
2222
|
}
|
|
2040
2223
|
async function runTurn(start, turn) {
|
|
2041
2224
|
currentTurn = turn;
|
|
2225
|
+
if (start.model) activeModel = start.model;
|
|
2226
|
+
activeThinking = start.thinking;
|
|
2227
|
+
activeEffort = start.effort;
|
|
2042
2228
|
currentResponseFormat = start.responseFormat?.type === "json" && start.responseFormat.schema != null ? toolStrategy(start.responseFormat.schema) : void 0;
|
|
2043
2229
|
const emit = (event) => turn.emit(event);
|
|
2044
2230
|
const interruptOn = buildInterruptOn(
|
|
2045
2231
|
start.permissionMode,
|
|
2046
2232
|
start.builtinToolFiltering
|
|
2047
2233
|
);
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2234
|
+
const config = {
|
|
2235
|
+
version: "v2",
|
|
2236
|
+
configurable: { thread_id: "bridge-session" },
|
|
2237
|
+
...start.recursionLimit != null ? { recursionLimit: start.recursionLimit } : {},
|
|
2238
|
+
signal: turn.abortSignal
|
|
2239
|
+
};
|
|
2240
|
+
const nextAgentConfigurationSignature = JSON.stringify({
|
|
2241
|
+
instructions: start.instructions,
|
|
2242
|
+
tools: start.tools,
|
|
2243
|
+
skillsPaths: start.skillsPaths
|
|
2244
|
+
});
|
|
2245
|
+
const rebuildAgent = agent == null || agentConfigurationSignature !== nextAgentConfigurationSignature || start.skillsChanged === true;
|
|
2246
|
+
if (rebuildAgent) {
|
|
2247
|
+
if (agent != null && start.skillsChanged === true) {
|
|
2248
|
+
await agent.updateState(config, {
|
|
2249
|
+
skillsMetadata: new Overwrite([])
|
|
2250
|
+
});
|
|
2251
|
+
}
|
|
2252
|
+
await closeMcpClient();
|
|
2058
2253
|
const builtinToolFilteringMiddleware = createBuiltinToolFilteringMiddleware(
|
|
2059
2254
|
{
|
|
2060
2255
|
builtinToolFiltering: start.builtinToolFiltering,
|
|
@@ -2067,7 +2262,7 @@ async function runTurn(start, turn) {
|
|
|
2067
2262
|
);
|
|
2068
2263
|
const middleware = [
|
|
2069
2264
|
responseFormatMiddleware,
|
|
2070
|
-
|
|
2265
|
+
modelMiddleware,
|
|
2071
2266
|
...builtinToolFilteringMiddleware ? [builtinToolFilteringMiddleware] : []
|
|
2072
2267
|
];
|
|
2073
2268
|
const hostTools = buildHostTools(start.tools);
|
|
@@ -2080,8 +2275,6 @@ async function runTurn(start, turn) {
|
|
|
2080
2275
|
);
|
|
2081
2276
|
mcpToolNames = new Set(mcpTools.map((mcpTool) => mcpTool.name));
|
|
2082
2277
|
agent = createDeepAgent({
|
|
2083
|
-
// Defer to Deep Agents's own default when the host configured no model.
|
|
2084
|
-
...model ? { model } : {},
|
|
2085
2278
|
tools: [...mcpTools, ...hostTools],
|
|
2086
2279
|
backend: createLocalShellBackend({ rootDir: workdir }),
|
|
2087
2280
|
systemPrompt: start.instructions ? { suffix: start.instructions } : void 0,
|
|
@@ -2091,14 +2284,19 @@ async function runTurn(start, turn) {
|
|
|
2091
2284
|
// Gate built-in tools behind HITL approval when the permission mode requires it.
|
|
2092
2285
|
...interruptOn ? { interruptOn } : {},
|
|
2093
2286
|
// Real instance (LangGraph rejects `true` for root graphs); gives multi-turn memory.
|
|
2094
|
-
checkpointer
|
|
2287
|
+
checkpointer
|
|
2095
2288
|
});
|
|
2289
|
+
agentConfigurationSignature = nextAgentConfigurationSignature;
|
|
2290
|
+
}
|
|
2291
|
+
const activeAgent = agent;
|
|
2292
|
+
if (activeAgent == null) {
|
|
2293
|
+
throw new Error("Deep Agents runtime was not initialized");
|
|
2096
2294
|
}
|
|
2097
2295
|
const hostToolNames = new Set((start.tools ?? []).map((t) => t.name));
|
|
2098
2296
|
const streamEventState = createDeepAgentsStreamEventState();
|
|
2099
2297
|
const emitStreamEvent = createEmitStreamEvent({
|
|
2100
2298
|
state: streamEventState,
|
|
2101
|
-
configuredModel:
|
|
2299
|
+
configuredModel: activeModel,
|
|
2102
2300
|
hostToolNames,
|
|
2103
2301
|
mcpToolNames,
|
|
2104
2302
|
structuredOutputToolNames: new Set(
|
|
@@ -2106,15 +2304,9 @@ async function runTurn(start, turn) {
|
|
|
2106
2304
|
),
|
|
2107
2305
|
emit
|
|
2108
2306
|
});
|
|
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
2307
|
const readPendingApprovals = async () => {
|
|
2116
2308
|
try {
|
|
2117
|
-
const state = await
|
|
2309
|
+
const state = await activeAgent.getState({
|
|
2118
2310
|
configurable: { thread_id: "bridge-session" }
|
|
2119
2311
|
});
|
|
2120
2312
|
return collectActionRequests(
|
|
@@ -2129,7 +2321,7 @@ async function runTurn(start, turn) {
|
|
|
2129
2321
|
};
|
|
2130
2322
|
let emittedStructuredOutput = false;
|
|
2131
2323
|
while (true) {
|
|
2132
|
-
const stream = await
|
|
2324
|
+
const stream = await activeAgent.streamEvents(resumeInput, config);
|
|
2133
2325
|
for await (const event of stream) {
|
|
2134
2326
|
emitStreamEvent(event);
|
|
2135
2327
|
const streamEvent = event;
|
|
@@ -2207,9 +2399,16 @@ await runBridge({
|
|
|
2207
2399
|
onStart: runTurn,
|
|
2208
2400
|
onStop: async () => {
|
|
2209
2401
|
await closeMcpClient();
|
|
2402
|
+
await saveMemorySaver({
|
|
2403
|
+
path: conversationCheckpointPath,
|
|
2404
|
+
saver: checkpointer
|
|
2405
|
+
});
|
|
2210
2406
|
return {};
|
|
2211
2407
|
},
|
|
2212
|
-
onDestroy:
|
|
2408
|
+
onDestroy: async () => {
|
|
2409
|
+
await closeMcpClient();
|
|
2410
|
+
await removeMemorySaverSnapshot(conversationCheckpointPath);
|
|
2411
|
+
}
|
|
2213
2412
|
});
|
|
2214
2413
|
async function loadMcpTools({
|
|
2215
2414
|
mcpServers
|