@dawn-ai/langchain 0.1.7 → 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.
- package/LICENSE +1 -1
- package/README.md +17 -3
- package/dist/agent-adapter.d.ts +47 -4
- package/dist/agent-adapter.d.ts.map +1 -1
- package/dist/agent-adapter.js +359 -73
- package/dist/chat-model-factory.d.ts +11 -0
- package/dist/chat-model-factory.d.ts.map +1 -0
- package/dist/chat-model-factory.js +49 -0
- package/dist/index.d.ts +12 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/model-provider-resolver.d.ts +8 -0
- package/dist/model-provider-resolver.d.ts.map +1 -0
- package/dist/model-provider-resolver.js +40 -0
- package/dist/subagent-dispatcher.d.ts +33 -0
- package/dist/subagent-dispatcher.d.ts.map +1 -0
- package/dist/subagent-dispatcher.js +182 -0
- package/dist/subagent-tool-bridge.d.ts +27 -0
- package/dist/subagent-tool-bridge.d.ts.map +1 -0
- package/dist/subagent-tool-bridge.js +32 -0
- package/dist/tool-converter.d.ts +3 -0
- package/dist/tool-converter.d.ts.map +1 -1
- package/dist/tool-converter.js +70 -20
- package/dist/unwrap-tool-result.d.ts +35 -0
- package/dist/unwrap-tool-result.d.ts.map +1 -0
- package/dist/unwrap-tool-result.js +42 -0
- package/package.json +53 -10
|
@@ -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.
|
|
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": "^
|
|
34
|
-
"@langchain/openai": "^
|
|
35
|
-
"@dawn-ai/
|
|
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": "
|
|
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/
|
|
42
|
-
"@langchain/langgraph": "0.2
|
|
43
|
-
"@langchain/
|
|
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": "
|
|
46
|
-
"@dawn-ai/config-typescript": "0.
|
|
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",
|