@dawn-ai/langchain 0.1.8 → 0.2.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.
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Detect whether a tool's return value uses the Dawn wrapper shape
3
+ * `{result, state?}` and split it into the agent-facing `content` and the
4
+ * optional `stateUpdates` for the route's state channels.
5
+ *
6
+ * The wrapper shape is recognized strictly: the value must be a non-null
7
+ * plain object whose own enumerable keys are exactly `result`, or exactly
8
+ * `result` and `state`. Any other shape (including objects with extra keys,
9
+ * missing `result`, or arrays) falls through to plain-return handling.
10
+ *
11
+ * Edge case: if a tool returns `{result: undefined}`, the wrapper IS detected
12
+ * structurally but the resulting `content` would be the string "undefined"
13
+ * (JSON.stringify(undefined) === undefined). We treat this as plain — capability
14
+ * authors should never return undefined as the agent-facing result.
15
+ */
16
+ export function unwrapToolResult(value) {
17
+ if (!isWrapperShape(value)) {
18
+ return { content: JSON.stringify(value), stateUpdates: undefined };
19
+ }
20
+ const { result, state } = value;
21
+ // Defensive: if result is undefined, fall back to plain (the wrapper shape
22
+ // was structurally present but the content would be meaningless).
23
+ if (result === undefined) {
24
+ return { content: JSON.stringify(value), stateUpdates: undefined };
25
+ }
26
+ const content = typeof result === "string" ? result : JSON.stringify(result);
27
+ const stateUpdates = state !== undefined && state !== null && typeof state === "object"
28
+ ? state
29
+ : undefined;
30
+ return { content, stateUpdates };
31
+ }
32
+ function isWrapperShape(value) {
33
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
34
+ return false;
35
+ }
36
+ const keys = Object.keys(value);
37
+ if (keys.length === 1)
38
+ return keys[0] === "result";
39
+ if (keys.length === 2)
40
+ return keys.includes("result") && keys.includes("state");
41
+ return false;
42
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dawn-ai/langchain",
3
- "version": "0.1.8",
3
+ "version": "0.2.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -30,20 +30,63 @@
30
30
  "access": "public"
31
31
  },
32
32
  "dependencies": {
33
- "@langchain/langgraph": "^0.2.71",
34
- "@langchain/openai": "^0.3.17",
35
- "@dawn-ai/sdk": "0.1.8"
33
+ "@langchain/langgraph": "^1.3.0",
34
+ "@langchain/openai": "^1.4.5",
35
+ "@dawn-ai/core": "0.2.0",
36
+ "@dawn-ai/sdk": "0.2.0"
36
37
  },
37
38
  "peerDependencies": {
38
- "@langchain/core": ">=0.3.0"
39
+ "@langchain/core": "^1.1.47",
40
+ "@langchain/langgraph-checkpoint": "^1.0.2",
41
+ "@langchain/anthropic": "^1.4.0",
42
+ "@langchain/google-genai": "^2.1.31",
43
+ "@langchain/mistralai": "^1.0.8",
44
+ "@langchain/groq": "^1.2.1",
45
+ "@langchain/ollama": "^1.2.7",
46
+ "@langchain/xai": "^1.3.18",
47
+ "@langchain/openrouter": "^0.2.5"
48
+ },
49
+ "peerDependenciesMeta": {
50
+ "@langchain/langgraph-checkpoint": {
51
+ "optional": false
52
+ },
53
+ "@langchain/anthropic": {
54
+ "optional": true
55
+ },
56
+ "@langchain/google-genai": {
57
+ "optional": true
58
+ },
59
+ "@langchain/mistralai": {
60
+ "optional": true
61
+ },
62
+ "@langchain/groq": {
63
+ "optional": true
64
+ },
65
+ "@langchain/ollama": {
66
+ "optional": true
67
+ },
68
+ "@langchain/xai": {
69
+ "optional": true
70
+ },
71
+ "@langchain/openrouter": {
72
+ "optional": true
73
+ }
39
74
  },
40
75
  "devDependencies": {
41
- "@langchain/core": "0.3.80",
42
- "@langchain/langgraph": "0.2.71",
43
- "@langchain/openai": "0.3.17",
76
+ "@langchain/anthropic": "^1.4.0",
77
+ "@langchain/langgraph-checkpoint": "^1.0.2",
78
+ "@langchain/core": "1.1.47",
79
+ "@langchain/google-genai": "^2.1.31",
80
+ "@langchain/groq": "^1.2.1",
81
+ "@langchain/langgraph": "1.3.0",
82
+ "@langchain/mistralai": "^1.0.8",
83
+ "@langchain/ollama": "^1.2.7",
84
+ "@langchain/openai": "1.4.5",
85
+ "@langchain/openrouter": "^0.2.5",
86
+ "@langchain/xai": "^1.3.18",
44
87
  "@types/node": "25.6.0",
45
- "zod": "3.24.4",
46
- "@dawn-ai/config-typescript": "0.1.8"
88
+ "zod": "4.4.3",
89
+ "@dawn-ai/config-typescript": "0.2.0"
47
90
  },
48
91
  "scripts": {
49
92
  "build": "tsc -b tsconfig.json",