@langchain/langgraph-sdk 1.4.4 → 1.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/rolldown_runtime.cjs +29 -0
- package/dist/auth/error.cjs +79 -0
- package/dist/auth/error.cjs.map +1 -0
- package/dist/auth/error.d.cts +13 -0
- package/dist/auth/error.d.cts.map +1 -0
- package/dist/auth/error.d.ts +13 -0
- package/dist/auth/error.d.ts.map +1 -0
- package/dist/auth/error.js +78 -0
- package/dist/auth/error.js.map +1 -0
- package/dist/auth/index.cjs +39 -0
- package/dist/auth/index.cjs.map +1 -0
- package/dist/auth/index.d.cts +29 -0
- package/dist/auth/index.d.cts.map +1 -0
- package/dist/auth/index.d.ts +29 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +37 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/types.d.cts +294 -0
- package/dist/auth/types.d.cts.map +1 -0
- package/dist/auth/types.d.ts +294 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/client.cjs +1210 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +799 -0
- package/dist/client.d.cts.map +1 -0
- package/dist/client.d.ts +799 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +1203 -0
- package/dist/client.js.map +1 -0
- package/dist/index.cjs +6 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +4 -0
- package/dist/logging/index.cjs +35 -0
- package/dist/logging/index.cjs.map +1 -0
- package/dist/logging/index.d.cts +46 -0
- package/dist/logging/index.d.cts.map +1 -0
- package/dist/logging/index.d.ts +46 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +34 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/react/index.cjs +5 -0
- package/dist/react/index.d.cts +5 -0
- package/dist/react/index.d.ts +5 -0
- package/dist/react/index.js +4 -0
- package/dist/react/stream.cjs +18 -0
- package/dist/react/stream.cjs.map +1 -0
- package/dist/react/stream.custom.cjs +135 -0
- package/dist/react/stream.custom.cjs.map +1 -0
- package/dist/react/stream.custom.d.cts +40 -0
- package/dist/react/stream.custom.d.cts.map +1 -0
- package/dist/react/stream.custom.d.ts +40 -0
- package/dist/react/stream.custom.d.ts.map +1 -0
- package/dist/react/stream.custom.js +133 -0
- package/dist/react/stream.custom.js.map +1 -0
- package/dist/react/stream.d.cts +155 -0
- package/dist/react/stream.d.cts.map +1 -0
- package/dist/react/stream.d.ts +155 -0
- package/dist/react/stream.d.ts.map +1 -0
- package/dist/react/stream.js +17 -0
- package/dist/react/stream.js.map +1 -0
- package/dist/react/stream.lgp.cjs +448 -0
- package/dist/react/stream.lgp.cjs.map +1 -0
- package/dist/react/stream.lgp.js +447 -0
- package/dist/react/stream.lgp.js.map +1 -0
- package/dist/react/thread.cjs +21 -0
- package/dist/react/thread.cjs.map +1 -0
- package/dist/react/thread.js +20 -0
- package/dist/react/thread.js.map +1 -0
- package/dist/react/types.d.cts +152 -0
- package/dist/react/types.d.cts.map +1 -0
- package/dist/react/types.d.ts +152 -0
- package/dist/react/types.d.ts.map +1 -0
- package/dist/react-ui/client.cjs +138 -0
- package/dist/react-ui/client.cjs.map +1 -0
- package/dist/react-ui/client.d.cts +73 -0
- package/dist/react-ui/client.d.cts.map +1 -0
- package/dist/react-ui/client.d.ts +73 -0
- package/dist/react-ui/client.d.ts.map +1 -0
- package/dist/react-ui/client.js +132 -0
- package/dist/react-ui/client.js.map +1 -0
- package/dist/react-ui/index.cjs +14 -0
- package/dist/react-ui/index.cjs.map +1 -0
- package/dist/react-ui/index.d.cts +3 -0
- package/dist/react-ui/index.d.ts +3 -0
- package/dist/react-ui/index.js +9 -0
- package/dist/react-ui/index.js.map +1 -0
- package/dist/react-ui/server/index.cjs +5 -0
- package/dist/react-ui/server/index.d.cts +3 -0
- package/dist/react-ui/server/index.d.ts +3 -0
- package/dist/react-ui/server/index.js +4 -0
- package/dist/react-ui/server/server.cjs +57 -0
- package/dist/react-ui/server/server.cjs.map +1 -0
- package/dist/react-ui/server/server.d.cts +55 -0
- package/dist/react-ui/server/server.d.cts.map +1 -0
- package/dist/react-ui/server/server.d.ts +55 -0
- package/dist/react-ui/server/server.d.ts.map +1 -0
- package/dist/react-ui/server/server.js +56 -0
- package/dist/react-ui/server/server.js.map +1 -0
- package/dist/react-ui/types.cjs +38 -0
- package/dist/react-ui/types.cjs.map +1 -0
- package/dist/react-ui/types.d.cts +25 -0
- package/dist/react-ui/types.d.cts.map +1 -0
- package/dist/react-ui/types.d.ts +25 -0
- package/dist/react-ui/types.d.ts.map +1 -0
- package/dist/react-ui/types.js +35 -0
- package/dist/react-ui/types.js.map +1 -0
- package/dist/schema.d.cts +284 -0
- package/dist/schema.d.cts.map +1 -0
- package/dist/schema.d.ts +284 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/singletons/fetch.cjs +24 -0
- package/dist/singletons/fetch.cjs.map +1 -0
- package/dist/singletons/fetch.d.cts +14 -0
- package/dist/singletons/fetch.d.cts.map +1 -0
- package/dist/singletons/fetch.d.ts +14 -0
- package/dist/singletons/fetch.d.ts.map +1 -0
- package/dist/singletons/fetch.js +22 -0
- package/dist/singletons/fetch.js.map +1 -0
- package/dist/types.d.cts +187 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.ts +187 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.messages.d.cts +264 -0
- package/dist/types.messages.d.cts.map +1 -0
- package/dist/types.messages.d.ts +264 -0
- package/dist/types.messages.d.ts.map +1 -0
- package/dist/types.stream.d.cts +233 -0
- package/dist/types.stream.d.cts.map +1 -0
- package/dist/types.stream.d.ts +233 -0
- package/dist/types.stream.d.ts.map +1 -0
- package/dist/types.template.d.cts +19 -0
- package/dist/types.template.d.cts.map +1 -0
- package/dist/types.template.d.ts +19 -0
- package/dist/types.template.d.ts.map +1 -0
- package/dist/ui/branching.cjs +153 -0
- package/dist/ui/branching.cjs.map +1 -0
- package/dist/ui/branching.d.cts +19 -0
- package/dist/ui/branching.d.cts.map +1 -0
- package/dist/ui/branching.d.ts +19 -0
- package/dist/ui/branching.d.ts.map +1 -0
- package/dist/ui/branching.js +152 -0
- package/dist/ui/branching.js.map +1 -0
- package/dist/ui/errors.cjs +15 -0
- package/dist/ui/errors.cjs.map +1 -0
- package/dist/ui/errors.js +14 -0
- package/dist/ui/errors.js.map +1 -0
- package/dist/ui/manager.cjs +188 -0
- package/dist/ui/manager.cjs.map +1 -0
- package/dist/ui/manager.js +188 -0
- package/dist/ui/manager.js.map +1 -0
- package/dist/ui/messages.cjs +70 -0
- package/dist/ui/messages.cjs.map +1 -0
- package/dist/ui/messages.js +68 -0
- package/dist/ui/messages.js.map +1 -0
- package/dist/ui/types.d.cts +420 -0
- package/dist/ui/types.d.cts.map +1 -0
- package/dist/ui/types.d.ts +420 -0
- package/dist/ui/types.d.ts.map +1 -0
- package/dist/ui/utils.cjs +13 -0
- package/dist/ui/utils.cjs.map +1 -0
- package/dist/ui/utils.js +11 -0
- package/dist/ui/utils.js.map +1 -0
- package/dist/utils/async_caller.cjs +119 -0
- package/dist/utils/async_caller.cjs.map +1 -0
- package/dist/utils/async_caller.d.cts +51 -0
- package/dist/utils/async_caller.d.cts.map +1 -0
- package/dist/utils/async_caller.d.ts +51 -0
- package/dist/utils/async_caller.d.ts.map +1 -0
- package/dist/utils/async_caller.js +116 -0
- package/dist/utils/async_caller.js.map +1 -0
- package/dist/utils/env.cjs +13 -0
- package/dist/utils/env.cjs.map +1 -0
- package/dist/utils/env.js +12 -0
- package/dist/utils/env.js.map +1 -0
- package/dist/utils/error.cjs +17 -0
- package/dist/utils/error.cjs.map +1 -0
- package/dist/utils/error.js +16 -0
- package/dist/utils/error.js.map +1 -0
- package/dist/utils/signals.cjs +20 -0
- package/dist/utils/signals.cjs.map +1 -0
- package/dist/utils/signals.js +19 -0
- package/dist/utils/signals.js.map +1 -0
- package/dist/utils/sse.cjs +124 -0
- package/dist/utils/sse.cjs.map +1 -0
- package/dist/utils/sse.js +122 -0
- package/dist/utils/sse.js.map +1 -0
- package/dist/utils/stream.cjs +174 -0
- package/dist/utils/stream.cjs.map +1 -0
- package/dist/utils/stream.js +173 -0
- package/dist/utils/stream.js.map +1 -0
- package/dist/utils/tools.cjs +52 -0
- package/dist/utils/tools.cjs.map +1 -0
- package/dist/utils/tools.js +51 -0
- package/dist/utils/tools.js.map +1 -0
- package/package.json +1 -1
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { Checkpoint, Config, Metadata } from "./schema.js";
|
|
2
|
+
import { StreamMode } from "./types.stream.js";
|
|
3
|
+
import { LangChainTracer } from "@langchain/core/tracers/tracer_langchain";
|
|
4
|
+
|
|
5
|
+
//#region src/types.d.ts
|
|
6
|
+
type MultitaskStrategy = "reject" | "interrupt" | "rollback" | "enqueue";
|
|
7
|
+
type OnConflictBehavior = "raise" | "do_nothing";
|
|
8
|
+
type OnCompletionBehavior = "complete" | "continue";
|
|
9
|
+
type DisconnectMode = "cancel" | "continue";
|
|
10
|
+
type Durability = "exit" | "async" | "sync";
|
|
11
|
+
type StreamEvent = "events" | "metadata" | "debug" | "updates" | "values" | "messages/partial" | "messages/metadata" | "messages/complete" | "messages" | (string & {});
|
|
12
|
+
interface Send {
|
|
13
|
+
node: string;
|
|
14
|
+
input: unknown | null;
|
|
15
|
+
}
|
|
16
|
+
interface Command {
|
|
17
|
+
/**
|
|
18
|
+
* An object to update the thread state with.
|
|
19
|
+
*/
|
|
20
|
+
update?: Record<string, unknown> | [string, unknown][] | null;
|
|
21
|
+
/**
|
|
22
|
+
* The value to return from an `interrupt` function call.
|
|
23
|
+
*/
|
|
24
|
+
resume?: unknown;
|
|
25
|
+
/**
|
|
26
|
+
* Determine the next node to navigate to. Can be one of the following:
|
|
27
|
+
* - Name(s) of the node names to navigate to next.
|
|
28
|
+
* - `Send` command(s) to execute node(s) with provided input.
|
|
29
|
+
*/
|
|
30
|
+
goto?: Send | Send[] | string | string[];
|
|
31
|
+
}
|
|
32
|
+
interface RunsInvokePayload {
|
|
33
|
+
/**
|
|
34
|
+
* Input to the run. Pass `null` to resume from the current state of the thread.
|
|
35
|
+
*/
|
|
36
|
+
input?: Record<string, unknown> | null;
|
|
37
|
+
/**
|
|
38
|
+
* Metadata for the run.
|
|
39
|
+
*/
|
|
40
|
+
metadata?: Metadata;
|
|
41
|
+
/**
|
|
42
|
+
* Additional configuration for the run.
|
|
43
|
+
*/
|
|
44
|
+
config?: Config;
|
|
45
|
+
/**
|
|
46
|
+
* Static context to add to the assistant.
|
|
47
|
+
* @remarks Added in LangGraph.js 0.4
|
|
48
|
+
*/
|
|
49
|
+
context?: unknown;
|
|
50
|
+
/**
|
|
51
|
+
* Checkpoint ID for when creating a new run.
|
|
52
|
+
*/
|
|
53
|
+
checkpointId?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Checkpoint for when creating a new run.
|
|
56
|
+
*/
|
|
57
|
+
checkpoint?: Omit<Checkpoint, "thread_id">;
|
|
58
|
+
/**
|
|
59
|
+
* Whether to checkpoint during the run (or only at the end/interruption).
|
|
60
|
+
* @deprecated Use `durability` instead.
|
|
61
|
+
*/
|
|
62
|
+
checkpointDuring?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Whether to checkpoint during the run (or only at the end/interruption).
|
|
65
|
+
* - `"async"`: Save checkpoint asynchronously while the next step executes (default).
|
|
66
|
+
* - `"sync"`: Save checkpoint synchronously before the next step starts.
|
|
67
|
+
* - `"exit"`: Save checkpoint only when the graph exits.
|
|
68
|
+
* @default "async"
|
|
69
|
+
*/
|
|
70
|
+
durability?: Durability;
|
|
71
|
+
/**
|
|
72
|
+
* Interrupt execution before entering these nodes.
|
|
73
|
+
*/
|
|
74
|
+
interruptBefore?: "*" | string[];
|
|
75
|
+
/**
|
|
76
|
+
* Interrupt execution after leaving these nodes.
|
|
77
|
+
*/
|
|
78
|
+
interruptAfter?: "*" | string[];
|
|
79
|
+
/**
|
|
80
|
+
* Strategy to handle concurrent runs on the same thread. Only relevant if
|
|
81
|
+
* there is a pending/inflight run on the same thread. One of:
|
|
82
|
+
* - "reject": Reject the new run.
|
|
83
|
+
* - "interrupt": Interrupt the current run, keeping steps completed until now,
|
|
84
|
+
and start a new one.
|
|
85
|
+
* - "rollback": Cancel and delete the existing run, rolling back the thread to
|
|
86
|
+
the state before it had started, then start the new run.
|
|
87
|
+
* - "enqueue": Queue up the new run to start after the current run finishes.
|
|
88
|
+
*/
|
|
89
|
+
multitaskStrategy?: MultitaskStrategy;
|
|
90
|
+
/**
|
|
91
|
+
* Abort controller signal to cancel the run.
|
|
92
|
+
*/
|
|
93
|
+
signal?: AbortController["signal"];
|
|
94
|
+
/**
|
|
95
|
+
* Behavior to handle run completion. Only relevant if
|
|
96
|
+
* there is a pending/inflight run on the same thread. One of:
|
|
97
|
+
* - "complete": Complete the run.
|
|
98
|
+
* - "continue": Continue the run.
|
|
99
|
+
*/
|
|
100
|
+
onCompletion?: OnCompletionBehavior;
|
|
101
|
+
/**
|
|
102
|
+
* Webhook to call when the run is complete.
|
|
103
|
+
*/
|
|
104
|
+
webhook?: string;
|
|
105
|
+
/**
|
|
106
|
+
* Behavior to handle disconnection. Only relevant if
|
|
107
|
+
* there is a pending/inflight run on the same thread. One of:
|
|
108
|
+
* - "cancel": Cancel the run.
|
|
109
|
+
* - "continue": Continue the run.
|
|
110
|
+
*/
|
|
111
|
+
onDisconnect?: DisconnectMode;
|
|
112
|
+
/**
|
|
113
|
+
* The number of seconds to wait before starting the run.
|
|
114
|
+
* Use to schedule future runs.
|
|
115
|
+
*/
|
|
116
|
+
afterSeconds?: number;
|
|
117
|
+
/**
|
|
118
|
+
* Behavior if the specified run doesn't exist. Defaults to "reject".
|
|
119
|
+
*/
|
|
120
|
+
ifNotExists?: "create" | "reject";
|
|
121
|
+
/**
|
|
122
|
+
* One or more commands to invoke the graph with.
|
|
123
|
+
*/
|
|
124
|
+
command?: Command;
|
|
125
|
+
/**
|
|
126
|
+
* Callback when a run is created.
|
|
127
|
+
*/
|
|
128
|
+
onRunCreated?: (params: {
|
|
129
|
+
run_id: string;
|
|
130
|
+
thread_id?: string;
|
|
131
|
+
}) => void;
|
|
132
|
+
/**
|
|
133
|
+
* @internal
|
|
134
|
+
* For LangSmith tracing purposes only. Not part of the public API.
|
|
135
|
+
*/
|
|
136
|
+
_langsmithTracer?: LangChainTracer;
|
|
137
|
+
}
|
|
138
|
+
interface RunsStreamPayload<TStreamMode extends StreamMode | StreamMode[] = [], TSubgraphs extends boolean = false> extends RunsInvokePayload {
|
|
139
|
+
/**
|
|
140
|
+
* One of `"values"`, `"messages"`, `"messages-tuple"`, `"updates"`, `"events"`, `"debug"`, `"custom"`.
|
|
141
|
+
*/
|
|
142
|
+
streamMode?: TStreamMode;
|
|
143
|
+
/**
|
|
144
|
+
* Stream output from subgraphs. By default, streams only the top graph.
|
|
145
|
+
*/
|
|
146
|
+
streamSubgraphs?: TSubgraphs;
|
|
147
|
+
/**
|
|
148
|
+
* Whether the stream is considered resumable.
|
|
149
|
+
* If true, the stream can be resumed and replayed in its entirety even after disconnection.
|
|
150
|
+
*/
|
|
151
|
+
streamResumable?: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Pass one or more feedbackKeys if you want to request short-lived signed URLs
|
|
154
|
+
* for submitting feedback to LangSmith with this key for this run.
|
|
155
|
+
*/
|
|
156
|
+
feedbackKeys?: string[];
|
|
157
|
+
}
|
|
158
|
+
interface RunsCreatePayload extends RunsInvokePayload {
|
|
159
|
+
/**
|
|
160
|
+
* One of `"values"`, `"messages"`, `"messages-tuple"`, `"updates"`, `"events"`, `"debug"`, `"custom"`.
|
|
161
|
+
*/
|
|
162
|
+
streamMode?: StreamMode | Array<StreamMode>;
|
|
163
|
+
/**
|
|
164
|
+
* Stream output from subgraphs. By default, streams only the top graph.
|
|
165
|
+
*/
|
|
166
|
+
streamSubgraphs?: boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Whether the stream is considered resumable.
|
|
169
|
+
* If true, the stream can be resumed and replayed in its entirety even after disconnection.
|
|
170
|
+
*/
|
|
171
|
+
streamResumable?: boolean;
|
|
172
|
+
}
|
|
173
|
+
interface CronsCreatePayload extends RunsCreatePayload {
|
|
174
|
+
/**
|
|
175
|
+
* Schedule for running the Cron Job
|
|
176
|
+
*/
|
|
177
|
+
schedule: string;
|
|
178
|
+
}
|
|
179
|
+
interface RunsWaitPayload extends RunsStreamPayload {
|
|
180
|
+
/**
|
|
181
|
+
* Raise errors returned by the run. Default is `true`.
|
|
182
|
+
*/
|
|
183
|
+
raiseError?: boolean;
|
|
184
|
+
}
|
|
185
|
+
//#endregion
|
|
186
|
+
export { Command, CronsCreatePayload, DisconnectMode, Durability, MultitaskStrategy, OnCompletionBehavior, OnConflictBehavior, RunsCreatePayload, RunsInvokePayload, RunsStreamPayload, RunsWaitPayload, StreamEvent };
|
|
187
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":["LangChainTracer","Checkpoint","Config","Metadata","StreamMode","MultitaskStrategy","OnConflictBehavior","OnCompletionBehavior","DisconnectMode","Durability","StreamEvent","Send","Command","Record","RunsInvokePayload","Omit","AbortController","RunsStreamPayload","TStreamMode","TSubgraphs","RunsCreatePayload","Array","CronsCreatePayload","RunsWaitPayload"],"sources":["../src/types.d.ts"],"sourcesContent":["import { LangChainTracer } from \"@langchain/core/tracers/tracer_langchain\";\nimport { Checkpoint, Config, Metadata } from \"./schema.js\";\nimport { StreamMode } from \"./types.stream.js\";\nexport type MultitaskStrategy = \"reject\" | \"interrupt\" | \"rollback\" | \"enqueue\";\nexport type OnConflictBehavior = \"raise\" | \"do_nothing\";\nexport type OnCompletionBehavior = \"complete\" | \"continue\";\nexport type DisconnectMode = \"cancel\" | \"continue\";\nexport type Durability = \"exit\" | \"async\" | \"sync\";\nexport type StreamEvent = \"events\" | \"metadata\" | \"debug\" | \"updates\" | \"values\" | \"messages/partial\" | \"messages/metadata\" | \"messages/complete\" | \"messages\" | (string & {});\nexport interface Send {\n node: string;\n input: unknown | null;\n}\nexport interface Command {\n /**\n * An object to update the thread state with.\n */\n update?: Record<string, unknown> | [string, unknown][] | null;\n /**\n * The value to return from an `interrupt` function call.\n */\n resume?: unknown;\n /**\n * Determine the next node to navigate to. Can be one of the following:\n * - Name(s) of the node names to navigate to next.\n * - `Send` command(s) to execute node(s) with provided input.\n */\n goto?: Send | Send[] | string | string[];\n}\nexport interface RunsInvokePayload {\n /**\n * Input to the run. Pass `null` to resume from the current state of the thread.\n */\n input?: Record<string, unknown> | null;\n /**\n * Metadata for the run.\n */\n metadata?: Metadata;\n /**\n * Additional configuration for the run.\n */\n config?: Config;\n /**\n * Static context to add to the assistant.\n * @remarks Added in LangGraph.js 0.4\n */\n context?: unknown;\n /**\n * Checkpoint ID for when creating a new run.\n */\n checkpointId?: string;\n /**\n * Checkpoint for when creating a new run.\n */\n checkpoint?: Omit<Checkpoint, \"thread_id\">;\n /**\n * Whether to checkpoint during the run (or only at the end/interruption).\n * @deprecated Use `durability` instead.\n */\n checkpointDuring?: boolean;\n /**\n * Whether to checkpoint during the run (or only at the end/interruption).\n * - `\"async\"`: Save checkpoint asynchronously while the next step executes (default).\n * - `\"sync\"`: Save checkpoint synchronously before the next step starts.\n * - `\"exit\"`: Save checkpoint only when the graph exits.\n * @default \"async\"\n */\n durability?: Durability;\n /**\n * Interrupt execution before entering these nodes.\n */\n interruptBefore?: \"*\" | string[];\n /**\n * Interrupt execution after leaving these nodes.\n */\n interruptAfter?: \"*\" | string[];\n /**\n * Strategy to handle concurrent runs on the same thread. Only relevant if\n * there is a pending/inflight run on the same thread. One of:\n * - \"reject\": Reject the new run.\n * - \"interrupt\": Interrupt the current run, keeping steps completed until now,\n and start a new one.\n * - \"rollback\": Cancel and delete the existing run, rolling back the thread to\n the state before it had started, then start the new run.\n * - \"enqueue\": Queue up the new run to start after the current run finishes.\n */\n multitaskStrategy?: MultitaskStrategy;\n /**\n * Abort controller signal to cancel the run.\n */\n signal?: AbortController[\"signal\"];\n /**\n * Behavior to handle run completion. Only relevant if\n * there is a pending/inflight run on the same thread. One of:\n * - \"complete\": Complete the run.\n * - \"continue\": Continue the run.\n */\n onCompletion?: OnCompletionBehavior;\n /**\n * Webhook to call when the run is complete.\n */\n webhook?: string;\n /**\n * Behavior to handle disconnection. Only relevant if\n * there is a pending/inflight run on the same thread. One of:\n * - \"cancel\": Cancel the run.\n * - \"continue\": Continue the run.\n */\n onDisconnect?: DisconnectMode;\n /**\n * The number of seconds to wait before starting the run.\n * Use to schedule future runs.\n */\n afterSeconds?: number;\n /**\n * Behavior if the specified run doesn't exist. Defaults to \"reject\".\n */\n ifNotExists?: \"create\" | \"reject\";\n /**\n * One or more commands to invoke the graph with.\n */\n command?: Command;\n /**\n * Callback when a run is created.\n */\n onRunCreated?: (params: {\n run_id: string;\n thread_id?: string;\n }) => void;\n /**\n * @internal\n * For LangSmith tracing purposes only. Not part of the public API.\n */\n _langsmithTracer?: LangChainTracer;\n}\nexport interface RunsStreamPayload<TStreamMode extends StreamMode | StreamMode[] = [], TSubgraphs extends boolean = false> extends RunsInvokePayload {\n /**\n * One of `\"values\"`, `\"messages\"`, `\"messages-tuple\"`, `\"updates\"`, `\"events\"`, `\"debug\"`, `\"custom\"`.\n */\n streamMode?: TStreamMode;\n /**\n * Stream output from subgraphs. By default, streams only the top graph.\n */\n streamSubgraphs?: TSubgraphs;\n /**\n * Whether the stream is considered resumable.\n * If true, the stream can be resumed and replayed in its entirety even after disconnection.\n */\n streamResumable?: boolean;\n /**\n * Pass one or more feedbackKeys if you want to request short-lived signed URLs\n * for submitting feedback to LangSmith with this key for this run.\n */\n feedbackKeys?: string[];\n}\nexport interface RunsCreatePayload extends RunsInvokePayload {\n /**\n * One of `\"values\"`, `\"messages\"`, `\"messages-tuple\"`, `\"updates\"`, `\"events\"`, `\"debug\"`, `\"custom\"`.\n */\n streamMode?: StreamMode | Array<StreamMode>;\n /**\n * Stream output from subgraphs. By default, streams only the top graph.\n */\n streamSubgraphs?: boolean;\n /**\n * Whether the stream is considered resumable.\n * If true, the stream can be resumed and replayed in its entirety even after disconnection.\n */\n streamResumable?: boolean;\n}\nexport interface CronsCreatePayload extends RunsCreatePayload {\n /**\n * Schedule for running the Cron Job\n */\n schedule: string;\n}\nexport interface RunsWaitPayload extends RunsStreamPayload {\n /**\n * Raise errors returned by the run. Default is `true`.\n */\n raiseError?: boolean;\n}\n"],"mappings":";;;;;KAGYK,iBAAAA;KACAC,kBAAAA;AADAD,KAEAE,oBAAAA,GAFiB,UAAA,GAAA,UAAA;AACjBD,KAEAE,cAAAA,GAFkB,QAAA,GAAA,UAAA;AAClBD,KAEAE,UAAAA,GAFAF,MAAoB,GAAA,OAAA,GAAA,MAAA;AACpBC,KAEAE,WAAAA,GAFc,QAAA,GAAA,UAAA,GAAA,OAAA,GAAA,SAAA,GAAA,QAAA,GAAA,kBAAA,GAAA,mBAAA,GAAA,mBAAA,GAAA,UAAA,GAAA,CAAA,MAAA,GAAA,CAAA,CAAA,CAAA;AACdD,UAEKE,IAAAA,CAFK;EACVD,IAAAA,EAAAA,MAAAA;EACKC,KAAAA,EAAI,OAAA,GAAA,IAAA;AAIrB;AAAwB,UAAPC,OAAAA,CAAO;;;;EAcF,MAAA,CAAA,EAVTC,MAUS,CAAA,MAAA,EAAA,OAAA,CAAA,GAAA,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,GAAA,IAAA;EAELC;;;QAQFX,CAAAA,EAAAA,OAAAA;;;;;;MAqDFa,CAAAA,EA/DFL,IA+DEK,GA/DKL,IA+DLK,EAAAA,GAAAA,MAAAA,GAAAA,MAAAA,EAAAA;;AAkBMR,UA/EFM,iBAAAA,CA+EEN;;;;EA2BFS,KAAAA,CAAAA,EAtGLJ,MAsGKI,CAAAA,MAAiB,EAAA,OAAA,CAAA,GAAA,IAAA;EAAA;;;UAIjBC,CAAAA,EAtGFf,QAsGEe;;;;EAgBAE,MAAAA,CAAAA,EAlHJlB,MAkHIkB;EAAiB;;;;SAASN,CAAAA,EAAAA,OAAAA;EAAiB;AAe5D;AAMA;;;;;eA1HiBC,KAAKd;;;;;;;;;;;;;eAaLQ;;;;;;;;;;;;;;;;;;;sBAmBOJ;;;;WAIXW;;;;;;;iBAOMT;;;;;;;;;;;iBAWAC;;;;;;;;;;;;;YAaLI;;;;;;;;;;;;qBAYSZ;;UAENiB,sCAAsCb,aAAaA,+DAA+DU;;;;eAIlHI;;;;oBAIKC;;;;;;;;;;;;UAYLC,iBAAAA,SAA0BN;;;;eAI1BV,aAAaiB,MAAMjB;;;;;;;;;;;UAWnBkB,kBAAAA,SAA2BF;;;;;;UAM3BG,eAAAA,SAAwBN"}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
//#region src/types.messages.d.ts
|
|
2
|
+
type ImageDetail = "auto" | "low" | "high";
|
|
3
|
+
type MessageContentImageUrl = {
|
|
4
|
+
type: "image_url";
|
|
5
|
+
image_url: string | {
|
|
6
|
+
url: string;
|
|
7
|
+
detail?: ImageDetail | undefined;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
type MessageContentText = {
|
|
11
|
+
type: "text";
|
|
12
|
+
text: string;
|
|
13
|
+
};
|
|
14
|
+
type MessageContentComplex = MessageContentText | MessageContentImageUrl;
|
|
15
|
+
type MessageContent = string | MessageContentComplex[];
|
|
16
|
+
/**
|
|
17
|
+
* Model-specific additional kwargs, which is passed back to the underlying LLM.
|
|
18
|
+
*/
|
|
19
|
+
type MessageAdditionalKwargs = Record<string, unknown>;
|
|
20
|
+
type BaseMessage = {
|
|
21
|
+
additional_kwargs?: MessageAdditionalKwargs | undefined;
|
|
22
|
+
content: MessageContent;
|
|
23
|
+
id?: string | undefined;
|
|
24
|
+
name?: string | undefined;
|
|
25
|
+
response_metadata?: Record<string, unknown> | undefined;
|
|
26
|
+
};
|
|
27
|
+
type HumanMessage = BaseMessage & {
|
|
28
|
+
type: "human";
|
|
29
|
+
example?: boolean | undefined;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Default tool call type when no specific tool definitions are provided.
|
|
33
|
+
*/
|
|
34
|
+
type DefaultToolCall = {
|
|
35
|
+
name: string;
|
|
36
|
+
args: {
|
|
37
|
+
[x: string]: any;
|
|
38
|
+
};
|
|
39
|
+
id?: string | undefined;
|
|
40
|
+
type?: "tool_call" | undefined;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Invalid tool call type.
|
|
44
|
+
*/
|
|
45
|
+
type InvalidToolCall = {
|
|
46
|
+
name?: string | undefined;
|
|
47
|
+
args?: string | undefined;
|
|
48
|
+
id?: string | undefined;
|
|
49
|
+
error?: string | undefined;
|
|
50
|
+
type?: "invalid_tool_call" | undefined;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Usage metadata for AI messages.
|
|
54
|
+
*/
|
|
55
|
+
type UsageMetadata = {
|
|
56
|
+
input_tokens: number;
|
|
57
|
+
output_tokens: number;
|
|
58
|
+
total_tokens: number;
|
|
59
|
+
input_token_details?: {
|
|
60
|
+
audio?: number | undefined;
|
|
61
|
+
cache_read?: number | undefined;
|
|
62
|
+
cache_creation?: number | undefined;
|
|
63
|
+
} | undefined;
|
|
64
|
+
output_token_details?: {
|
|
65
|
+
audio?: number | undefined;
|
|
66
|
+
reasoning?: number | undefined;
|
|
67
|
+
} | undefined;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* AI message type that can be parameterized with custom tool call types.
|
|
71
|
+
*
|
|
72
|
+
* @template ToolCall The type of tool calls, defaults to DefaultToolCall.
|
|
73
|
+
* Provide a discriminated union for type-safe tool call handling.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* // Define typed tool calls as a discriminated union
|
|
78
|
+
* type MyToolCalls =
|
|
79
|
+
* | { name: "get_weather"; args: { location: string }; id?: string }
|
|
80
|
+
* | { name: "search"; args: { query: string; limit?: number }; id?: string };
|
|
81
|
+
*
|
|
82
|
+
* // Use with AIMessage
|
|
83
|
+
* const message: AIMessage<MyToolCalls> = ...;
|
|
84
|
+
*
|
|
85
|
+
* // Now tool.name === "get_weather" narrows tool.args type
|
|
86
|
+
* if (message.tool_calls) {
|
|
87
|
+
* for (const tool of message.tool_calls) {
|
|
88
|
+
* if (tool.name === "get_weather") {
|
|
89
|
+
* // tool.args is now { location: string }
|
|
90
|
+
* console.log(tool.args.location);
|
|
91
|
+
* }
|
|
92
|
+
* }
|
|
93
|
+
* }
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
type AIMessage<ToolCall = DefaultToolCall> = BaseMessage & {
|
|
97
|
+
type: "ai";
|
|
98
|
+
example?: boolean | undefined;
|
|
99
|
+
tool_calls?: ToolCall[] | undefined;
|
|
100
|
+
invalid_tool_calls?: InvalidToolCall[] | undefined;
|
|
101
|
+
usage_metadata?: UsageMetadata | undefined;
|
|
102
|
+
};
|
|
103
|
+
type ToolMessage = BaseMessage & {
|
|
104
|
+
type: "tool";
|
|
105
|
+
status?: "error" | "success" | undefined;
|
|
106
|
+
tool_call_id: string;
|
|
107
|
+
/**
|
|
108
|
+
* Artifact of the Tool execution which is not meant to be sent to the model.
|
|
109
|
+
*
|
|
110
|
+
* Should only be specified if it is different from the message content, e.g. if only
|
|
111
|
+
* a subset of the full tool output is being passed as message content but the full
|
|
112
|
+
* output is needed in other parts of the code.
|
|
113
|
+
*/
|
|
114
|
+
artifact?: any;
|
|
115
|
+
};
|
|
116
|
+
type SystemMessage = BaseMessage & {
|
|
117
|
+
type: "system";
|
|
118
|
+
};
|
|
119
|
+
type FunctionMessage = BaseMessage & {
|
|
120
|
+
type: "function";
|
|
121
|
+
};
|
|
122
|
+
type RemoveMessage = BaseMessage & {
|
|
123
|
+
type: "remove";
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Union of all message types.
|
|
127
|
+
*
|
|
128
|
+
* @template ToolCall The type of tool calls for AIMessage, defaults to DefaultToolCall.
|
|
129
|
+
*/
|
|
130
|
+
type Message<ToolCall = DefaultToolCall> = HumanMessage | AIMessage<ToolCall> | ToolMessage | SystemMessage | FunctionMessage | RemoveMessage;
|
|
131
|
+
/**
|
|
132
|
+
* Helper type to infer schema input type, supporting both Zod v3 and v4.
|
|
133
|
+
* - Zod v4 uses `_zod.input` property
|
|
134
|
+
* - Zod v3 uses `_input` property
|
|
135
|
+
*
|
|
136
|
+
* Note: Zod v4 is checked first as it's the more specific structure.
|
|
137
|
+
*/
|
|
138
|
+
type InferSchemaInput<S> = S extends {
|
|
139
|
+
_zod: {
|
|
140
|
+
input: infer Args;
|
|
141
|
+
};
|
|
142
|
+
} ? Args : S extends {
|
|
143
|
+
_input: infer Args;
|
|
144
|
+
} ? Args : never;
|
|
145
|
+
/**
|
|
146
|
+
* Helper type to extract the input type from a DynamicStructuredTool's _call method.
|
|
147
|
+
* This is more reliable than trying to infer from the schema directly because
|
|
148
|
+
* DynamicStructuredTool has the input type baked into its _call signature.
|
|
149
|
+
*/
|
|
150
|
+
type InferToolInput<T> = T extends {
|
|
151
|
+
_call: (arg: infer Args, ...rest: any[]) => any;
|
|
152
|
+
} ? Args : T extends {
|
|
153
|
+
schema: infer S;
|
|
154
|
+
} ? InferSchemaInput<S> : never;
|
|
155
|
+
/**
|
|
156
|
+
* Infer a tool call type from a single tool.
|
|
157
|
+
* Works with tools created via `tool()` from `@langchain/core/tools`.
|
|
158
|
+
*
|
|
159
|
+
* For DynamicStructuredTool, this extracts the input type from the _call method,
|
|
160
|
+
* which is the most reliable source as it's the pre-computed input type.
|
|
161
|
+
*
|
|
162
|
+
* @template T The tool type (e.g., DynamicStructuredTool)
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```ts
|
|
166
|
+
* import { tool } from "@langchain/core/tools";
|
|
167
|
+
* import { z } from "zod";
|
|
168
|
+
*
|
|
169
|
+
* const getWeather = tool(
|
|
170
|
+
* async ({ location }) => `Weather in ${location}`,
|
|
171
|
+
* { name: "get_weather", schema: z.object({ location: z.string() }) }
|
|
172
|
+
* );
|
|
173
|
+
*
|
|
174
|
+
* // Infer: { name: "get_weather"; args: { location: string }; id?: string; type?: "tool_call" }
|
|
175
|
+
* type WeatherToolCall = ToolCallFromTool<typeof getWeather>;
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
type ToolCallFromTool<T> = T extends {
|
|
179
|
+
name: infer N;
|
|
180
|
+
} ? InferToolInput<T> extends infer Args ? Args extends never ? never : Args extends Record<string, any> ? {
|
|
181
|
+
name: N;
|
|
182
|
+
args: Args;
|
|
183
|
+
id?: string;
|
|
184
|
+
type?: "tool_call";
|
|
185
|
+
} : never : never : never;
|
|
186
|
+
/**
|
|
187
|
+
* Infer a union of tool call types from an array of tools.
|
|
188
|
+
* Works with tools created via `tool()` from `@langchain/core/tools`.
|
|
189
|
+
*
|
|
190
|
+
* @template T A tuple/array of tools
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* ```ts
|
|
194
|
+
* import { tool } from "@langchain/core/tools";
|
|
195
|
+
* import { z } from "zod";
|
|
196
|
+
*
|
|
197
|
+
* const getWeather = tool(
|
|
198
|
+
* async ({ location }) => `Weather in ${location}`,
|
|
199
|
+
* { name: "get_weather", schema: z.object({ location: z.string() }) }
|
|
200
|
+
* );
|
|
201
|
+
*
|
|
202
|
+
* const search = tool(
|
|
203
|
+
* async ({ query }) => `Results for ${query}`,
|
|
204
|
+
* { name: "search", schema: z.object({ query: z.string() }) }
|
|
205
|
+
* );
|
|
206
|
+
*
|
|
207
|
+
* const tools = [getWeather, search] as const;
|
|
208
|
+
*
|
|
209
|
+
* // Infer union:
|
|
210
|
+
* // | { name: "get_weather"; args: { location: string }; id?: string; type?: "tool_call" }
|
|
211
|
+
* // | { name: "search"; args: { query: string }; id?: string; type?: "tool_call" }
|
|
212
|
+
* type MyToolCalls = ToolCallsFromTools<typeof tools>;
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
type ToolCallsFromTools<T extends readonly unknown[]> = T extends readonly [infer First, ...infer Rest] ? ToolCallFromTool<First> | ToolCallsFromTools<Rest> : never;
|
|
216
|
+
/**
|
|
217
|
+
* The lifecycle state of a tool call.
|
|
218
|
+
*
|
|
219
|
+
* - `pending`: Tool call received, awaiting result
|
|
220
|
+
* - `completed`: Tool execution finished successfully
|
|
221
|
+
* - `error`: Tool execution failed (result.status === "error")
|
|
222
|
+
*/
|
|
223
|
+
type ToolCallState = "pending" | "completed" | "error";
|
|
224
|
+
/**
|
|
225
|
+
* Represents a tool call paired with its result.
|
|
226
|
+
* Useful for rendering tool invocations and their outputs together.
|
|
227
|
+
*
|
|
228
|
+
* @template ToolCall The type of the tool call.
|
|
229
|
+
*/
|
|
230
|
+
type ToolCallWithResult<ToolCall = DefaultToolCall> = {
|
|
231
|
+
/**
|
|
232
|
+
* Unique identifier for this tool call.
|
|
233
|
+
* Uses the tool call's id if available, otherwise generates one from aiMessage.id and index.
|
|
234
|
+
*/
|
|
235
|
+
id: string;
|
|
236
|
+
/**
|
|
237
|
+
* The tool call from the AI message.
|
|
238
|
+
*/
|
|
239
|
+
call: ToolCall;
|
|
240
|
+
/**
|
|
241
|
+
* The result message from tool execution.
|
|
242
|
+
* `undefined` if the tool is still being executed or no result was received.
|
|
243
|
+
*/
|
|
244
|
+
result: ToolMessage | undefined;
|
|
245
|
+
/**
|
|
246
|
+
* The AI message that initiated this tool call.
|
|
247
|
+
*/
|
|
248
|
+
aiMessage: AIMessage<ToolCall>;
|
|
249
|
+
/**
|
|
250
|
+
* Index of this tool call within the AI message's tool_calls array.
|
|
251
|
+
*/
|
|
252
|
+
index: number;
|
|
253
|
+
/**
|
|
254
|
+
* The current lifecycle state of the tool call.
|
|
255
|
+
*
|
|
256
|
+
* - `pending`: No result yet
|
|
257
|
+
* - `completed`: Has result with success status
|
|
258
|
+
* - `error`: Has result with error status
|
|
259
|
+
*/
|
|
260
|
+
state: ToolCallState;
|
|
261
|
+
};
|
|
262
|
+
//#endregion
|
|
263
|
+
export { AIMessage, DefaultToolCall, FunctionMessage, HumanMessage, Message, RemoveMessage, SystemMessage, ToolCallFromTool, ToolCallState, ToolCallWithResult, ToolCallsFromTools, ToolMessage };
|
|
264
|
+
//# sourceMappingURL=types.messages.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.messages.d.cts","names":["ImageDetail","MessageContentImageUrl","MessageContentText","MessageContentComplex","MessageContent","MessageAdditionalKwargs","Record","BaseMessage","HumanMessage","DefaultToolCall","InvalidToolCall","UsageMetadata","AIMessage","ToolCall","ToolMessage","SystemMessage","FunctionMessage","RemoveMessage","Message","InferSchemaInput","S","Args","InferToolInput","T","ToolCallFromTool","N","ToolCallsFromTools","First","Rest","ToolCallState","ToolCallWithResult"],"sources":["../src/types.messages.d.ts"],"sourcesContent":["type ImageDetail = \"auto\" | \"low\" | \"high\";\ntype MessageContentImageUrl = {\n type: \"image_url\";\n image_url: string | {\n url: string;\n detail?: ImageDetail | undefined;\n };\n};\ntype MessageContentText = {\n type: \"text\";\n text: string;\n};\ntype MessageContentComplex = MessageContentText | MessageContentImageUrl;\ntype MessageContent = string | MessageContentComplex[];\n/**\n * Model-specific additional kwargs, which is passed back to the underlying LLM.\n */\ntype MessageAdditionalKwargs = Record<string, unknown>;\ntype BaseMessage = {\n additional_kwargs?: MessageAdditionalKwargs | undefined;\n content: MessageContent;\n id?: string | undefined;\n name?: string | undefined;\n response_metadata?: Record<string, unknown> | undefined;\n};\nexport type HumanMessage = BaseMessage & {\n type: \"human\";\n example?: boolean | undefined;\n};\n/**\n * Default tool call type when no specific tool definitions are provided.\n */\nexport type DefaultToolCall = {\n name: string;\n args: {\n [x: string]: any;\n };\n id?: string | undefined;\n type?: \"tool_call\" | undefined;\n};\n/**\n * Invalid tool call type.\n */\nexport type InvalidToolCall = {\n name?: string | undefined;\n args?: string | undefined;\n id?: string | undefined;\n error?: string | undefined;\n type?: \"invalid_tool_call\" | undefined;\n};\n/**\n * Usage metadata for AI messages.\n */\nexport type UsageMetadata = {\n input_tokens: number;\n output_tokens: number;\n total_tokens: number;\n input_token_details?: {\n audio?: number | undefined;\n cache_read?: number | undefined;\n cache_creation?: number | undefined;\n } | undefined;\n output_token_details?: {\n audio?: number | undefined;\n reasoning?: number | undefined;\n } | undefined;\n};\n/**\n * AI message type that can be parameterized with custom tool call types.\n *\n * @template ToolCall The type of tool calls, defaults to DefaultToolCall.\n * Provide a discriminated union for type-safe tool call handling.\n *\n * @example\n * ```ts\n * // Define typed tool calls as a discriminated union\n * type MyToolCalls =\n * | { name: \"get_weather\"; args: { location: string }; id?: string }\n * | { name: \"search\"; args: { query: string; limit?: number }; id?: string };\n *\n * // Use with AIMessage\n * const message: AIMessage<MyToolCalls> = ...;\n *\n * // Now tool.name === \"get_weather\" narrows tool.args type\n * if (message.tool_calls) {\n * for (const tool of message.tool_calls) {\n * if (tool.name === \"get_weather\") {\n * // tool.args is now { location: string }\n * console.log(tool.args.location);\n * }\n * }\n * }\n * ```\n */\nexport type AIMessage<ToolCall = DefaultToolCall> = BaseMessage & {\n type: \"ai\";\n example?: boolean | undefined;\n tool_calls?: ToolCall[] | undefined;\n invalid_tool_calls?: InvalidToolCall[] | undefined;\n usage_metadata?: UsageMetadata | undefined;\n};\nexport type ToolMessage = BaseMessage & {\n type: \"tool\";\n status?: \"error\" | \"success\" | undefined;\n tool_call_id: string;\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n artifact?: any;\n};\nexport type SystemMessage = BaseMessage & {\n type: \"system\";\n};\nexport type FunctionMessage = BaseMessage & {\n type: \"function\";\n};\nexport type RemoveMessage = BaseMessage & {\n type: \"remove\";\n};\n/**\n * Union of all message types.\n *\n * @template ToolCall The type of tool calls for AIMessage, defaults to DefaultToolCall.\n */\nexport type Message<ToolCall = DefaultToolCall> = HumanMessage | AIMessage<ToolCall> | ToolMessage | SystemMessage | FunctionMessage | RemoveMessage;\n/**\n * Helper type to infer schema input type, supporting both Zod v3 and v4.\n * - Zod v4 uses `_zod.input` property\n * - Zod v3 uses `_input` property\n *\n * Note: Zod v4 is checked first as it's the more specific structure.\n */\ntype InferSchemaInput<S> = S extends {\n _zod: {\n input: infer Args;\n };\n} ? Args : S extends {\n _input: infer Args;\n} ? Args : never;\n/**\n * Helper type to extract the input type from a DynamicStructuredTool's _call method.\n * This is more reliable than trying to infer from the schema directly because\n * DynamicStructuredTool has the input type baked into its _call signature.\n */\ntype InferToolInput<T> = T extends {\n _call: (arg: infer Args, ...rest: any[]) => any;\n} ? Args : T extends {\n schema: infer S;\n} ? InferSchemaInput<S> : never;\n/**\n * Infer a tool call type from a single tool.\n * Works with tools created via `tool()` from `@langchain/core/tools`.\n *\n * For DynamicStructuredTool, this extracts the input type from the _call method,\n * which is the most reliable source as it's the pre-computed input type.\n *\n * @template T The tool type (e.g., DynamicStructuredTool)\n *\n * @example\n * ```ts\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n *\n * const getWeather = tool(\n * async ({ location }) => `Weather in ${location}`,\n * { name: \"get_weather\", schema: z.object({ location: z.string() }) }\n * );\n *\n * // Infer: { name: \"get_weather\"; args: { location: string }; id?: string; type?: \"tool_call\" }\n * type WeatherToolCall = ToolCallFromTool<typeof getWeather>;\n * ```\n */\nexport type ToolCallFromTool<T> = T extends {\n name: infer N;\n} ? InferToolInput<T> extends infer Args ? Args extends never ? never : Args extends Record<string, any> ? {\n name: N;\n args: Args;\n id?: string;\n type?: \"tool_call\";\n} : never : never : never;\n/**\n * Infer a union of tool call types from an array of tools.\n * Works with tools created via `tool()` from `@langchain/core/tools`.\n *\n * @template T A tuple/array of tools\n *\n * @example\n * ```ts\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n *\n * const getWeather = tool(\n * async ({ location }) => `Weather in ${location}`,\n * { name: \"get_weather\", schema: z.object({ location: z.string() }) }\n * );\n *\n * const search = tool(\n * async ({ query }) => `Results for ${query}`,\n * { name: \"search\", schema: z.object({ query: z.string() }) }\n * );\n *\n * const tools = [getWeather, search] as const;\n *\n * // Infer union:\n * // | { name: \"get_weather\"; args: { location: string }; id?: string; type?: \"tool_call\" }\n * // | { name: \"search\"; args: { query: string }; id?: string; type?: \"tool_call\" }\n * type MyToolCalls = ToolCallsFromTools<typeof tools>;\n * ```\n */\nexport type ToolCallsFromTools<T extends readonly unknown[]> = T extends readonly [infer First, ...infer Rest] ? ToolCallFromTool<First> | ToolCallsFromTools<Rest> : never;\n/**\n * The lifecycle state of a tool call.\n *\n * - `pending`: Tool call received, awaiting result\n * - `completed`: Tool execution finished successfully\n * - `error`: Tool execution failed (result.status === \"error\")\n */\nexport type ToolCallState = \"pending\" | \"completed\" | \"error\";\n/**\n * Represents a tool call paired with its result.\n * Useful for rendering tool invocations and their outputs together.\n *\n * @template ToolCall The type of the tool call.\n */\nexport type ToolCallWithResult<ToolCall = DefaultToolCall> = {\n /**\n * Unique identifier for this tool call.\n * Uses the tool call's id if available, otherwise generates one from aiMessage.id and index.\n */\n id: string;\n /**\n * The tool call from the AI message.\n */\n call: ToolCall;\n /**\n * The result message from tool execution.\n * `undefined` if the tool is still being executed or no result was received.\n */\n result: ToolMessage | undefined;\n /**\n * The AI message that initiated this tool call.\n */\n aiMessage: AIMessage<ToolCall>;\n /**\n * Index of this tool call within the AI message's tool_calls array.\n */\n index: number;\n /**\n * The current lifecycle state of the tool call.\n *\n * - `pending`: No result yet\n * - `completed`: Has result with success status\n * - `error`: Has result with error status\n */\n state: ToolCallState;\n};\nexport {};\n"],"mappings":"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"}
|