@langgraph-js/sdk 3.7.0 → 3.8.0
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/README.md +29 -0
- package/dist/History.d.ts +115 -0
- package/dist/History.js +226 -0
- package/dist/LangGraphClient.d.ts +23 -2
- package/dist/LangGraphClient.js +118 -80
- package/dist/MessageProcessor.js +18 -24
- package/dist/SpendTime.js +4 -9
- package/dist/TestKit.d.ts +1 -1
- package/dist/TestKit.js +16 -15
- package/dist/ToolManager.js +4 -7
- package/dist/artifacts/index.js +1 -1
- package/dist/client/LanggraphServer.js +1 -1
- package/dist/client/LowJSServer.d.ts +3 -0
- package/dist/client/LowJSServer.js +80 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +2 -0
- package/dist/client/utils/sse.d.ts +8 -0
- package/dist/client/utils/sse.js +151 -0
- package/dist/client/utils/stream.d.ts +15 -0
- package/dist/client/utils/stream.js +104 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/react/ChatContext.d.ts +31 -20
- package/dist/react/ChatContext.js +10 -4
- package/dist/tool/ToolUI.js +3 -2
- package/dist/tool/createTool.js +3 -6
- package/dist/tool/utils.js +3 -4
- package/dist/ui-store/createChatStore.d.ts +33 -66
- package/dist/ui-store/createChatStore.js +261 -247
- package/dist/vue/ChatContext.d.ts +41 -21
- package/dist/vue/ChatContext.js +8 -2
- package/package.json +3 -1
- package/src/History.ts +294 -0
- package/src/LangGraphClient.ts +98 -48
- package/src/client/LanggraphServer.ts +1 -2
- package/src/client/LowJSServer.ts +80 -0
- package/src/client/index.ts +2 -0
- package/src/client/utils/sse.ts +176 -0
- package/src/client/utils/stream.ts +114 -0
- package/src/index.ts +2 -0
- package/src/react/ChatContext.ts +25 -16
- package/src/ui-store/createChatStore.ts +310 -236
- package/src/vue/ChatContext.ts +12 -0
- package/test/TestKit.test.ts +10 -2
- package/tsconfig.json +1 -1
package/src/vue/ChatContext.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { defineComponent, inject, provide, onMounted, defineExpose, type Injecti
|
|
|
2
2
|
import { createChatStore } from "../ui-store/index.js";
|
|
3
3
|
import { useStore } from "@nanostores/vue";
|
|
4
4
|
import { PreinitializedWritableAtom, StoreValue } from "nanostores";
|
|
5
|
+
import { ILangGraphClient } from "@langgraph-js/pure-graph/dist/types.js";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @zh UnionStore 类型用于合并 store 的 data 和 mutations,使其可以直接访问。
|
|
@@ -54,7 +55,11 @@ export interface ChatProviderProps {
|
|
|
54
55
|
showHistory?: boolean;
|
|
55
56
|
showGraph?: boolean;
|
|
56
57
|
fallbackToAvailableAssistants?: boolean;
|
|
58
|
+
/** 初始化时是否自动激活最近的历史会话(默认 false,创建新会话) */
|
|
59
|
+
autoRestoreLastSession?: boolean;
|
|
57
60
|
onInitError?: (error: any, currentAgent: string) => void;
|
|
61
|
+
client?: ILangGraphClient;
|
|
62
|
+
legacyMode?: boolean;
|
|
58
63
|
}
|
|
59
64
|
|
|
60
65
|
/**
|
|
@@ -78,11 +83,14 @@ export const useChatProvider = (props: ChatProviderProps) => {
|
|
|
78
83
|
fetch: F,
|
|
79
84
|
maxRetries: 1,
|
|
80
85
|
},
|
|
86
|
+
client: props.client,
|
|
87
|
+
legacyMode: props.legacyMode,
|
|
81
88
|
},
|
|
82
89
|
{
|
|
83
90
|
showHistory: props.showHistory,
|
|
84
91
|
showGraph: props.showGraph,
|
|
85
92
|
fallbackToAvailableAssistants: props.fallbackToAvailableAssistants,
|
|
93
|
+
autoRestoreLastSession: props.autoRestoreLastSession,
|
|
86
94
|
}
|
|
87
95
|
);
|
|
88
96
|
|
|
@@ -144,6 +152,10 @@ export const ChatProvider = defineComponent({
|
|
|
144
152
|
type: Boolean as PropType<boolean>,
|
|
145
153
|
default: false,
|
|
146
154
|
},
|
|
155
|
+
autoRestoreLastSession: {
|
|
156
|
+
type: Boolean as PropType<boolean>,
|
|
157
|
+
default: false,
|
|
158
|
+
},
|
|
147
159
|
onInitError: {
|
|
148
160
|
type: Function as PropType<(error: any, currentAgent: string) => void>,
|
|
149
161
|
default: undefined,
|
package/test/TestKit.test.ts
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import { expect, test } from "vitest";
|
|
2
|
-
import { TestLangGraphChat, createChatStore } from "../src";
|
|
2
|
+
import { TestLangGraphChat, createChatStore, createLowerJSClient } from "../src";
|
|
3
3
|
|
|
4
4
|
test("test", async () => {
|
|
5
|
+
const client = await createLowerJSClient({
|
|
6
|
+
apiUrl: "http://localhost:8123",
|
|
7
|
+
defaultHeaders: {
|
|
8
|
+
Authorization: "Bearer 123",
|
|
9
|
+
},
|
|
10
|
+
});
|
|
5
11
|
const testChat = new TestLangGraphChat(
|
|
6
12
|
createChatStore(
|
|
7
|
-
"
|
|
13
|
+
"graph",
|
|
8
14
|
{
|
|
9
15
|
defaultHeaders: {
|
|
10
16
|
Authorization: "Bearer 123",
|
|
11
17
|
},
|
|
18
|
+
client,
|
|
19
|
+
legacyMode: true,
|
|
12
20
|
},
|
|
13
21
|
{}
|
|
14
22
|
),
|
package/tsconfig.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
12
|
|
|
13
13
|
/* Language and Environment */
|
|
14
|
-
"target": "
|
|
14
|
+
"target": "ES2022" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
|
15
15
|
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
16
16
|
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
17
17
|
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|