@langgraph-js/pure-graph 1.3.0 → 1.4.1

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.
Files changed (78) hide show
  1. package/README.md +180 -16
  2. package/dist/adapter/nextjs/router.js +6 -6
  3. package/dist/global.d.ts +3 -2
  4. package/dist/global.js +3 -0
  5. package/dist/storage/index.d.ts +4 -3
  6. package/dist/storage/index.js +21 -3
  7. package/dist/storage/memory/threads.d.ts +1 -0
  8. package/dist/storage/memory/threads.js +3 -0
  9. package/dist/storage/pg/checkpoint.d.ts +2 -0
  10. package/dist/storage/pg/checkpoint.js +9 -0
  11. package/dist/storage/pg/threads.d.ts +43 -0
  12. package/dist/storage/pg/threads.js +303 -0
  13. package/dist/storage/sqlite/DB.js +1 -1
  14. package/dist/storage/sqlite/threads.d.ts +1 -1
  15. package/dist/storage/sqlite/threads.js +1 -2
  16. package/dist/threads/index.d.ts +1 -0
  17. package/dist/tsconfig.tsbuildinfo +1 -0
  18. package/package.json +38 -5
  19. package/.prettierrc +0 -11
  20. package/bun.lock +0 -209
  21. package/dist/adapter/hono/zod.d.ts +0 -203
  22. package/dist/adapter/hono/zod.js +0 -43
  23. package/dist/adapter/nextjs/zod.d.ts +0 -203
  24. package/dist/adapter/nextjs/zod.js +0 -60
  25. package/examples/nextjs/README.md +0 -36
  26. package/examples/nextjs/app/api/langgraph/[...path]/route.ts +0 -10
  27. package/examples/nextjs/app/favicon.ico +0 -0
  28. package/examples/nextjs/app/globals.css +0 -26
  29. package/examples/nextjs/app/layout.tsx +0 -34
  30. package/examples/nextjs/app/page.tsx +0 -211
  31. package/examples/nextjs/next.config.ts +0 -26
  32. package/examples/nextjs/package.json +0 -24
  33. package/examples/nextjs/postcss.config.mjs +0 -5
  34. package/examples/nextjs/tsconfig.json +0 -27
  35. package/packages/agent-graph/demo.json +0 -35
  36. package/packages/agent-graph/package.json +0 -18
  37. package/packages/agent-graph/src/index.ts +0 -47
  38. package/packages/agent-graph/src/tools/tavily.ts +0 -9
  39. package/packages/agent-graph/src/tools.ts +0 -38
  40. package/packages/agent-graph/src/types.ts +0 -42
  41. package/pnpm-workspace.yaml +0 -4
  42. package/src/adapter/hono/assistants.ts +0 -24
  43. package/src/adapter/hono/endpoint.ts +0 -3
  44. package/src/adapter/hono/index.ts +0 -14
  45. package/src/adapter/hono/runs.ts +0 -92
  46. package/src/adapter/hono/threads.ts +0 -37
  47. package/src/adapter/nextjs/endpoint.ts +0 -2
  48. package/src/adapter/nextjs/index.ts +0 -2
  49. package/src/adapter/nextjs/router.ts +0 -206
  50. package/src/adapter/nextjs/zod.ts +0 -66
  51. package/src/adapter/zod.ts +0 -144
  52. package/src/createEndpoint.ts +0 -116
  53. package/src/e.d.ts +0 -3
  54. package/src/global.ts +0 -11
  55. package/src/graph/stream.ts +0 -263
  56. package/src/graph/stringify.ts +0 -219
  57. package/src/index.ts +0 -6
  58. package/src/queue/JsonPlusSerializer.ts +0 -143
  59. package/src/queue/event_message.ts +0 -30
  60. package/src/queue/stream_queue.ts +0 -237
  61. package/src/storage/index.ts +0 -52
  62. package/src/storage/memory/checkpoint.ts +0 -2
  63. package/src/storage/memory/queue.ts +0 -91
  64. package/src/storage/memory/threads.ts +0 -183
  65. package/src/storage/redis/queue.ts +0 -148
  66. package/src/storage/sqlite/DB.ts +0 -16
  67. package/src/storage/sqlite/checkpoint.ts +0 -502
  68. package/src/storage/sqlite/threads.ts +0 -405
  69. package/src/storage/sqlite/type.ts +0 -12
  70. package/src/threads/index.ts +0 -37
  71. package/src/types.ts +0 -118
  72. package/src/utils/createEntrypointGraph.ts +0 -20
  73. package/src/utils/getGraph.ts +0 -44
  74. package/src/utils/getLangGraphCommand.ts +0 -21
  75. package/test/graph/entrypoint.ts +0 -21
  76. package/test/graph/index.ts +0 -60
  77. package/test/hono.ts +0 -15
  78. package/tsconfig.json +0 -20
@@ -1,60 +0,0 @@
1
- import { interrupt, StateGraph } from '@langchain/langgraph';
2
- import { HumanInterrupt } from '@langchain/langgraph/prebuilt';
3
- import { createReactAgentAnnotation } from '@langchain/langgraph/prebuilt';
4
- import { createState } from '@langgraph-js/pro';
5
- const state = createState(createReactAgentAnnotation()).build({});
6
- export const graph = new StateGraph(state)
7
- .addNode('agent', async (state) => {
8
- return {
9
- messages: [
10
- ...state.messages,
11
- {
12
- role: 'ai',
13
- content: 'Processing...',
14
- },
15
- ],
16
- };
17
- })
18
- .addNode('interrupt', async (state) => {
19
- // interrupt
20
- const response = interrupt([
21
- {
22
- action_request: {
23
- action: 'test',
24
- args: {
25
- a: 1,
26
- },
27
- },
28
- config: {
29
- allow_ignore: true,
30
- allow_respond: true,
31
- allow_edit: true,
32
- allow_accept: true,
33
- },
34
- description: 'Please review the tool call',
35
- } as HumanInterrupt,
36
- ])[0];
37
- return {
38
- messages: [
39
- ...state.messages,
40
- {
41
- role: 'ai',
42
- content: response,
43
- },
44
- ],
45
- };
46
- })
47
- .addEdge('__start__', 'agent')
48
- .addConditionalEdges(
49
- 'agent',
50
- (state) => {
51
- // 条件:如果消息数量大于1,则走interrupt路径
52
- return state.messages.length > 1 ? 'interrupt' : '__end__';
53
- },
54
- {
55
- interrupt: 'interrupt',
56
- __end__: '__end__',
57
- },
58
- )
59
- .addEdge('interrupt', '__end__')
60
- .compile();
package/test/hono.ts DELETED
@@ -1,15 +0,0 @@
1
- import { registerGraph } from '../src/createEndpoint';
2
- import { graph } from './graph/index';
3
- import { graph as entrypointGraph } from './graph/entrypoint';
4
- // import { graph as agentGraph } from '../packages/agent-graph/src/index';
5
- import { Hono } from 'hono';
6
- import LangGraphApp from '../src/adapter/hono/index';
7
-
8
- registerGraph('test', graph);
9
- // registerGraph('agent-graph', agentGraph);
10
- registerGraph('test-entrypoint', entrypointGraph);
11
-
12
- const app = new Hono();
13
- app.route('/', LangGraphApp);
14
-
15
- export default app;
package/tsconfig.json DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "lib": [],
4
- "allowJs": true,
5
- "skipLibCheck": true,
6
- "strict": true,
7
- "esModuleInterop": true,
8
- "target": "esnext",
9
- "module": "esnext",
10
- "moduleResolution": "bundler",
11
- "resolveJsonModule": true,
12
- "isolatedModules": true,
13
- "jsx": "preserve",
14
- "incremental": true,
15
- "outDir": "./dist",
16
- "declaration": true
17
- },
18
- "include": ["src/**/*.ts"],
19
- "exclude": ["node_modules"]
20
- }