@ai-sdk/langchain 3.0.0-beta.87 → 3.0.0-beta.89

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 CHANGED
@@ -1,5 +1,24 @@
1
1
  # @ai-sdk/langchain
2
2
 
3
+ ## 3.0.0-beta.89
4
+
5
+ ### Patch Changes
6
+
7
+ - ff5eba1: feat: roll `image-*` tool output types into their equivalent `file-*` types
8
+ - Updated dependencies [ff5eba1]
9
+ - ai@7.0.0-beta.89
10
+
11
+ ## 3.0.0-beta.88
12
+
13
+ ### Major Changes
14
+
15
+ - ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [ef992f8]
20
+ - ai@7.0.0-beta.88
21
+
3
22
  ## 3.0.0-beta.87
4
23
 
5
24
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1,38 +1,18 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- LangSmithDeploymentTransport: () => LangSmithDeploymentTransport,
24
- convertModelMessages: () => convertModelMessages,
25
- toBaseMessages: () => toBaseMessages,
26
- toUIMessageStream: () => toUIMessageStream
27
- });
28
- module.exports = __toCommonJS(index_exports);
29
-
30
1
  // src/adapter.ts
31
- var import_messages2 = require("@langchain/core/messages");
32
- var import_ai = require("ai");
2
+ import {
3
+ SystemMessage
4
+ } from "@langchain/core/messages";
5
+ import {
6
+ convertToModelMessages
7
+ } from "ai";
33
8
 
34
9
  // src/utils.ts
35
- var import_messages = require("@langchain/core/messages");
10
+ import {
11
+ AIMessage,
12
+ HumanMessage,
13
+ ToolMessage,
14
+ AIMessageChunk
15
+ } from "@langchain/core/messages";
36
16
  function parseLangGraphEvent(event) {
37
17
  return event.length === 3 ? [event[1], event[2]] : [event[0], event[1]];
38
18
  }
@@ -54,14 +34,14 @@ function convertToolResultPart(block) {
54
34
  }
55
35
  return "";
56
36
  })();
57
- return new import_messages.ToolMessage({
37
+ return new ToolMessage({
58
38
  tool_call_id: block.toolCallId,
59
39
  content
60
40
  });
61
41
  }
62
42
  function convertAssistantContent(content) {
63
43
  if (typeof content === "string") {
64
- return new import_messages.AIMessage({ content });
44
+ return new AIMessage({ content });
65
45
  }
66
46
  const textParts = [];
67
47
  const toolCalls = [];
@@ -76,7 +56,7 @@ function convertAssistantContent(content) {
76
56
  });
77
57
  }
78
58
  }
79
- return new import_messages.AIMessage({
59
+ return new AIMessage({
80
60
  content: textParts.join(""),
81
61
  tool_calls: toolCalls.length > 0 ? toolCalls : void 0
82
62
  });
@@ -88,7 +68,7 @@ function getDefaultFilename(mediaType, prefix = "file") {
88
68
  function convertUserContent(content) {
89
69
  var _a;
90
70
  if (typeof content === "string") {
91
- return new import_messages.HumanMessage({ content });
71
+ return new HumanMessage({ content });
92
72
  }
93
73
  const contentBlocks = [];
94
74
  for (const part of content) {
@@ -215,11 +195,11 @@ function convertUserContent(content) {
215
195
  }
216
196
  }
217
197
  if (contentBlocks.every((block) => block.type === "text")) {
218
- return new import_messages.HumanMessage({
198
+ return new HumanMessage({
219
199
  content: contentBlocks.map((block) => block.text).join("")
220
200
  });
221
201
  }
222
- return new import_messages.HumanMessage({ content: contentBlocks });
202
+ return new HumanMessage({ content: contentBlocks });
223
203
  }
224
204
  function isToolResultPart(item) {
225
205
  return item != null && typeof item === "object" && "type" in item && item.type === "tool-result";
@@ -304,7 +284,7 @@ function getMessageId(msg) {
304
284
  return void 0;
305
285
  }
306
286
  function isAIMessageChunk(msg) {
307
- if (import_messages.AIMessageChunk.isInstance(msg)) return true;
287
+ if (AIMessageChunk.isInstance(msg)) return true;
308
288
  if (isPlainMessageObject(msg)) {
309
289
  const obj = msg;
310
290
  if ("type" in obj && obj.type === "ai") return true;
@@ -315,7 +295,7 @@ function isAIMessageChunk(msg) {
315
295
  return false;
316
296
  }
317
297
  function isToolMessageType(msg) {
318
- if (import_messages.ToolMessage.isInstance(msg)) return true;
298
+ if (ToolMessage.isInstance(msg)) return true;
319
299
  if (isPlainMessageObject(msg)) {
320
300
  const obj = msg;
321
301
  if ("type" in obj && obj.type === "tool") return true;
@@ -327,7 +307,7 @@ function isToolMessageType(msg) {
327
307
  }
328
308
  function getMessageText(msg) {
329
309
  var _a;
330
- if (import_messages.AIMessageChunk.isInstance(msg)) {
310
+ if (AIMessageChunk.isInstance(msg)) {
331
311
  return (_a = msg.text) != null ? _a : "";
332
312
  }
333
313
  if (msg == null || typeof msg !== "object") return "";
@@ -511,7 +491,7 @@ function processLangGraphEvent(event, state, controller) {
511
491
  controller.enqueue({ type: "start-step" });
512
492
  state.currentStep = langgraphStep;
513
493
  }
514
- if (import_messages.AIMessageChunk.isInstance(msg)) {
494
+ if (AIMessageChunk.isInstance(msg)) {
515
495
  if (messageConcat[msgId]) {
516
496
  messageConcat[msgId] = messageConcat[msgId].concat(
517
497
  msg
@@ -683,7 +663,7 @@ function processLangGraphEvent(event, state, controller) {
683
663
  const msgId = getMessageId(msg);
684
664
  if (!msgId) continue;
685
665
  let toolCalls;
686
- if (import_messages.AIMessageChunk.isInstance(msg) || import_messages.AIMessage.isInstance(msg)) {
666
+ if (AIMessageChunk.isInstance(msg) || AIMessage.isInstance(msg)) {
687
667
  toolCalls = msg.tool_calls;
688
668
  } else if (isPlainMessageObject(msg)) {
689
669
  const obj = msg;
@@ -806,7 +786,7 @@ function processLangGraphEvent(event, state, controller) {
806
786
 
807
787
  // src/adapter.ts
808
788
  async function toBaseMessages(messages) {
809
- const modelMessages = await (0, import_ai.convertToModelMessages)(messages);
789
+ const modelMessages = await convertToModelMessages(messages);
810
790
  return convertModelMessages(modelMessages);
811
791
  }
812
792
  function convertModelMessages(modelMessages) {
@@ -826,7 +806,7 @@ function convertModelMessages(modelMessages) {
826
806
  break;
827
807
  }
828
808
  case "system": {
829
- result.push(new import_messages2.SystemMessage({ content: message.content }));
809
+ result.push(new SystemMessage({ content: message.content }));
830
810
  break;
831
811
  }
832
812
  case "user": {
@@ -1092,11 +1072,13 @@ function toUIMessageStream(stream, callbacks) {
1092
1072
  }
1093
1073
 
1094
1074
  // src/transport.ts
1095
- var import_remote = require("@langchain/langgraph/remote");
1075
+ import {
1076
+ RemoteGraph
1077
+ } from "@langchain/langgraph/remote";
1096
1078
  var LangSmithDeploymentTransport = class {
1097
1079
  constructor(options) {
1098
1080
  var _a;
1099
- this.graph = new import_remote.RemoteGraph({
1081
+ this.graph = new RemoteGraph({
1100
1082
  ...options,
1101
1083
  graphId: (_a = options.graphId) != null ? _a : "agent"
1102
1084
  });
@@ -1115,11 +1097,10 @@ var LangSmithDeploymentTransport = class {
1115
1097
  throw new Error("Method not implemented.");
1116
1098
  }
1117
1099
  };
1118
- // Annotate the CommonJS export names for ESM import in node:
1119
- 0 && (module.exports = {
1100
+ export {
1120
1101
  LangSmithDeploymentTransport,
1121
1102
  convertModelMessages,
1122
1103
  toBaseMessages,
1123
1104
  toUIMessageStream
1124
- });
1105
+ };
1125
1106
  //# sourceMappingURL=index.js.map