From 2508aa45eabc8b1f485d97870d09f04cd05e88be Mon Sep 17 00:00:00 2001 From: Tat Dat Duong Date: Mon, 30 Jun 2025 13:51:32 +0200 Subject: [PATCH] Use published package --- libs/sdk-js/package.json | 7 ++----- libs/sdk-js/src/tests/stream.test.tsx | 23 ++++++++++++++--------- libs/sdk-js/yarn.lock | 17 +++++++++-------- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/libs/sdk-js/package.json b/libs/sdk-js/package.json index a1e1c63b0..43d8852b8 100644 --- a/libs/sdk-js/package.json +++ b/libs/sdk-js/package.json @@ -22,7 +22,7 @@ "uuid": "^9.0.0" }, "devDependencies": { - "@langchain/langgraph-api": "http://localhost:3123/1750722568240/@langchain/langgraph-api", + "@langchain/langgraph-api": "~0.0.41", "@langchain/core": "^0.3.61", "@langchain/langgraph": "^0.3.5", "@langchain/scripts": "^0.1.4", @@ -143,8 +143,5 @@ "react-ui/server.js", "react-ui/server.d.ts", "react-ui/server.d.cts" - ], - "resolutions": { - "@langchain/langgraph-api": "http://localhost:3123/1750722568240/@langchain/langgraph-api" - } + ] } diff --git a/libs/sdk-js/src/tests/stream.test.tsx b/libs/sdk-js/src/tests/stream.test.tsx index 5d20fde8a..cc3265f37 100644 --- a/libs/sdk-js/src/tests/stream.test.tsx +++ b/libs/sdk-js/src/tests/stream.test.tsx @@ -1,3 +1,5 @@ +import "@testing-library/jest-dom/vitest"; + import { describe, it, expect, beforeEach, afterEach, vi } from "vitest"; import { render, screen, waitFor } from "@testing-library/react"; import { userEvent } from "@testing-library/user-event"; @@ -9,8 +11,10 @@ import { StateGraph, MessagesAnnotation, START } from "@langchain/langgraph"; import { MemorySaver } from "@langchain/langgraph-checkpoint"; import { FakeStreamingChatModel } from "@langchain/core/utils/testing"; import { AIMessage, BaseMessageLike } from "@langchain/core/messages"; -import "@testing-library/jest-dom/vitest"; -import { createServer } from "@langchain/langgraph-api/embed"; + +import { Hono } from "hono"; +import { logger } from "hono/logger"; +import { createEmbedServer } from "@langchain/langgraph-api/experimental/embed"; const threads = (() => { const THREADS: Record< @@ -26,6 +30,9 @@ const threads = (() => { ) => { THREADS[threadId] = { thread_id: threadId, metadata: metadata ?? {} }; }, + delete: async (threadId: string) => { + delete THREADS[threadId]; + }, }; })(); @@ -40,11 +47,11 @@ const agent = new StateGraph(MessagesAnnotation) .addEdge(START, "agent") .compile(); -const app = createServer({ - graph: { agent }, - checkpointer, - threads, -}); +const app = new Hono(); +app.use(logger()); +app.route("/", createEmbedServer({ graph: { agent }, checkpointer, threads })); + +const server = setupServer(http.all("*", (ctx) => app.fetch(ctx.request))); function TestChatComponent() { const { messages, isLoading, error, submit, stop } = useStream({ @@ -82,8 +89,6 @@ function TestChatComponent() { ); } -const server = setupServer(http.all("*", (ctx) => app.fetch(ctx.request))); - describe("useStream", () => { beforeEach(() => server.listen()); diff --git a/libs/sdk-js/yarn.lock b/libs/sdk-js/yarn.lock index 0f378159a..0e4e00cc2 100644 --- a/libs/sdk-js/yarn.lock +++ b/libs/sdk-js/yarn.lock @@ -678,14 +678,15 @@ zod "^3.25.32" zod-to-json-schema "^3.22.3" -"@langchain/langgraph-api@http://localhost:3123/1750722568240/@langchain/langgraph-api": - version "0.0.40" - resolved "http://localhost:3123/1750722568240/@langchain/langgraph-api#f14b373a947881c7d113ff96a2329eba31c589ce" +"@langchain/langgraph-api@~0.0.41": + version "0.0.41" + resolved "https://registry.yarnpkg.com/@langchain/langgraph-api/-/langgraph-api-0.0.41.tgz#a8219651dfd097225e66129ce367ef8e0ae23d45" + integrity sha512-LxiVspoVRB5AYBoC04XmigFTjYtEut3Unf9dlwuMgdRMxfyiN/oI3Wuun9Q/Tfn7jYt3E8FVtUqCLgT1QUG3Rw== dependencies: "@babel/code-frame" "^7.26.2" "@hono/node-server" "^1.12.0" "@hono/zod-validator" "^0.2.2" - "@langchain/langgraph-ui" "workspace:*" + "@langchain/langgraph-ui" "0.0.41" "@types/json-schema" "^7.0.15" "@typescript/vfs" "^1.6.0" dedent "^1.5.3" @@ -720,10 +721,10 @@ p-retry "4" uuid "^9.0.0" -"@langchain/langgraph-ui@workspace:*": - version "0.0.40" - resolved "https://registry.yarnpkg.com/@langchain/langgraph-ui/-/langgraph-ui-0.0.40.tgz#d60aa72ddfbdeb1f523e34776778a8eb9f90f2d0" - integrity sha512-QEpda8dejhhT/BwcJ+jdkI4pioag5AEQaA9rtDeC83G4ZPOTXIODlgGSzDDFoi2Z97mNFiGiVRRDze+IOTGEqA== +"@langchain/langgraph-ui@0.0.41": + version "0.0.41" + resolved "https://registry.yarnpkg.com/@langchain/langgraph-ui/-/langgraph-ui-0.0.41.tgz#6c581f150274b397031b687b6a569a220532cb85" + integrity sha512-7PSSYCgijNRrDbYDj0VuxzPMgUSh4uAO0Z35p4GuB0CZliztUaZVtSGET0mRscT7+98HeWdt4GnpP1fLZt8bxg== dependencies: "@commander-js/extra-typings" "^13.0.0" commander "^13.0.0"