@langgraph-js/pure-graph 1.2.0 → 1.4.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.
Files changed (79) hide show
  1. package/README.md +22 -14
  2. package/dist/adapter/hono/runs.js +18 -1
  3. package/dist/adapter/nextjs/router.js +18 -7
  4. package/dist/adapter/zod.d.ts +15 -8
  5. package/dist/adapter/zod.js +8 -0
  6. package/dist/global.d.ts +3 -2
  7. package/dist/storage/index.d.ts +4 -3
  8. package/dist/storage/index.js +13 -1
  9. package/dist/storage/memory/threads.d.ts +3 -2
  10. package/dist/storage/memory/threads.js +29 -2
  11. package/dist/storage/pg/checkpoint.d.ts +2 -0
  12. package/dist/storage/pg/checkpoint.js +9 -0
  13. package/dist/storage/pg/threads.d.ts +43 -0
  14. package/dist/storage/pg/threads.js +304 -0
  15. package/dist/storage/sqlite/threads.d.ts +3 -2
  16. package/dist/storage/sqlite/threads.js +37 -3
  17. package/dist/threads/index.d.ts +3 -2
  18. package/dist/threads/index.js +1 -26
  19. package/dist/tsconfig.tsbuildinfo +1 -0
  20. package/dist/types.d.ts +2 -1
  21. package/package.json +38 -5
  22. package/.prettierrc +0 -11
  23. package/bun.lock +0 -209
  24. package/dist/adapter/nextjs/zod.d.ts +0 -203
  25. package/dist/adapter/nextjs/zod.js +0 -60
  26. package/examples/nextjs/README.md +0 -36
  27. package/examples/nextjs/app/api/langgraph/[...path]/route.ts +0 -10
  28. package/examples/nextjs/app/favicon.ico +0 -0
  29. package/examples/nextjs/app/globals.css +0 -26
  30. package/examples/nextjs/app/layout.tsx +0 -34
  31. package/examples/nextjs/app/page.tsx +0 -211
  32. package/examples/nextjs/next.config.ts +0 -26
  33. package/examples/nextjs/package.json +0 -24
  34. package/examples/nextjs/postcss.config.mjs +0 -5
  35. package/examples/nextjs/tsconfig.json +0 -27
  36. package/packages/agent-graph/demo.json +0 -35
  37. package/packages/agent-graph/package.json +0 -18
  38. package/packages/agent-graph/src/index.ts +0 -47
  39. package/packages/agent-graph/src/tools/tavily.ts +0 -9
  40. package/packages/agent-graph/src/tools.ts +0 -38
  41. package/packages/agent-graph/src/types.ts +0 -42
  42. package/pnpm-workspace.yaml +0 -4
  43. package/src/adapter/hono/assistants.ts +0 -24
  44. package/src/adapter/hono/endpoint.ts +0 -3
  45. package/src/adapter/hono/index.ts +0 -14
  46. package/src/adapter/hono/runs.ts +0 -65
  47. package/src/adapter/hono/threads.ts +0 -37
  48. package/src/adapter/nextjs/endpoint.ts +0 -2
  49. package/src/adapter/nextjs/index.ts +0 -2
  50. package/src/adapter/nextjs/router.ts +0 -193
  51. package/src/adapter/nextjs/zod.ts +0 -66
  52. package/src/adapter/zod.ts +0 -135
  53. package/src/createEndpoint.ts +0 -116
  54. package/src/e.d.ts +0 -3
  55. package/src/global.ts +0 -11
  56. package/src/graph/stream.ts +0 -263
  57. package/src/graph/stringify.ts +0 -219
  58. package/src/index.ts +0 -6
  59. package/src/queue/JsonPlusSerializer.ts +0 -143
  60. package/src/queue/event_message.ts +0 -30
  61. package/src/queue/stream_queue.ts +0 -237
  62. package/src/storage/index.ts +0 -52
  63. package/src/storage/memory/checkpoint.ts +0 -2
  64. package/src/storage/memory/queue.ts +0 -91
  65. package/src/storage/memory/threads.ts +0 -154
  66. package/src/storage/redis/queue.ts +0 -148
  67. package/src/storage/sqlite/DB.ts +0 -16
  68. package/src/storage/sqlite/checkpoint.ts +0 -503
  69. package/src/storage/sqlite/threads.ts +0 -366
  70. package/src/storage/sqlite/type.ts +0 -12
  71. package/src/threads/index.ts +0 -51
  72. package/src/types.ts +0 -116
  73. package/src/utils/createEntrypointGraph.ts +0 -20
  74. package/src/utils/getGraph.ts +0 -44
  75. package/src/utils/getLangGraphCommand.ts +0 -21
  76. package/test/graph/entrypoint.ts +0 -21
  77. package/test/graph/index.ts +0 -60
  78. package/test/hono.ts +0 -15
  79. 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
- }