Skip to content

Commit 04d27dc

Browse files
committed
Add the LangChain DeepAgents.js
1 parent 4f305be commit 04d27dc

29 files changed

Lines changed: 2188 additions & 757 deletions

File tree

.github/dependabot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ updates:
2626
- '/common/backend/'
2727
- '/agents/agent-ai-sdk/'
2828
- '/agents/agent-claude-agent-sdk/'
29+
- '/agents/agent-deepagents/'
2930
- '/agents/agent-langchain/'
3031
- '/agents/agent-langchain-nextjs/'
3132
- '/agents/agent-strands/'

agents/agent-ai-sdk/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@
2929
"jiti": "^2.6.1",
3030
"tsx": "^4.21.0",
3131
"typescript": "^5.9.3",
32-
"typescript-eslint": "^8.58.1",
32+
"typescript-eslint": "^8.58.2",
3333
"vite": "^8.0.8",
3434
"vitest": "^4.1.4"
3535
},
3636
"dependencies": {
37-
"@ai-sdk/amazon-bedrock": "^4.0.92",
37+
"@ai-sdk/amazon-bedrock": "^4.0.93",
3838
"@ai-sdk/azure": "^3.0.53",
3939
"@llm-ts-example/common-backend-core": "workspace:*",
4040
"@llm-ts-example/common-core": "workspace:*",
4141
"@smithy/eventstream-codec": "^4.2.14",
42-
"ai": "^6.0.156",
43-
"aws-cdk-lib": "^2.248.0",
42+
"ai": "^6.0.159",
43+
"aws-cdk-lib": "^2.249.0",
4444
"constructs": "^10.6.0",
45-
"dotenv": "^17.4.1",
45+
"dotenv": "^17.4.2",
4646
"zod": "^4.3.6"
4747
}
4848
}

agents/agent-claude-agent-sdk/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"@stylistic/eslint-plugin": "^5.10.0",
2020
"@types/node": "^24.12.2",
2121
"@vitest/eslint-plugin": "^1.6.15",
22-
"dotenv": "^17.4.1",
22+
"dotenv": "^17.4.2",
2323
"esbuild": "^0.27.7",
2424
"eslint": "^10.2.0",
2525
"eslint-import-resolver-typescript": "^4.4.4",
@@ -28,7 +28,7 @@
2828
"jiti": "^2.6.1",
2929
"tsx": "^4.21.0",
3030
"typescript": "^5.9.3",
31-
"typescript-eslint": "^8.58.1",
31+
"typescript-eslint": "^8.58.2",
3232
"vite": "^8.0.8",
3333
"vitest": "^4.1.4"
3434
},

agents/agent-deepagents/.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
*.js
2+
!jest.config.js
3+
*.d.ts
4+
node_modules
5+
6+
# CDK asset staging directory
7+
.cdk.staging
8+
cdk.out
9+
10+
!eslint.config.js
11+
12+
!types/*.d.ts
13+
!lambda/awslambda.d.ts
14+
!*.config.js
15+
.env*
16+
vite.config.js
17+
eslint.config.js
18+
tsconfig.tsbuildinfo
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { defineConfig } from 'eslint/config';
2+
import eslint from '@eslint/js';
3+
import stylistic from '@stylistic/eslint-plugin';
4+
import { configs, parser } from 'typescript-eslint';
5+
import eslintImport from 'eslint-plugin-import-x';
6+
7+
import { includeIgnoreFile } from '@eslint/compat';
8+
import path from 'node:path';
9+
import { fileURLToPath } from 'node:url';
10+
11+
const __filename = fileURLToPath(import.meta.url);
12+
const __dirname = path.dirname(__filename);
13+
const gitignorePath = path.resolve(__dirname, '.gitignore');
14+
15+
export default defineConfig(
16+
includeIgnoreFile(gitignorePath),
17+
{
18+
ignores: [
19+
'**/*.d.ts',
20+
'**/*.js',
21+
'node_modules/**/*',
22+
'out',
23+
'dist',
24+
'cdk.out',
25+
'.output',
26+
],
27+
},
28+
eslint.configs.recommended,
29+
...configs.strict,
30+
...configs.stylistic,
31+
{
32+
files: ['{bin,lib,lambda}/**/*.{ts,tsx}', '*.js'],
33+
plugins: {
34+
'@stylistic': stylistic,
35+
},
36+
languageOptions: {
37+
ecmaVersion: 'latest',
38+
sourceType: 'module',
39+
parser,
40+
parserOptions: {
41+
tsconfigRootDir: __dirname,
42+
project: ['./tsconfig-eslint.json'],
43+
},
44+
},
45+
extends: [
46+
eslintImport.flatConfigs.recommended,
47+
eslintImport.flatConfigs.typescript,
48+
],
49+
settings: {
50+
'import-x/resolver': {
51+
// You will also need to install and configure the TypeScript resolver
52+
// See also https://github.com/import-js/eslint-import-resolver-typescript#configuration
53+
'typescript': true,
54+
'node': true,
55+
},
56+
},
57+
rules: {
58+
'@stylistic/semi': ['error', 'always'],
59+
'@stylistic/indent': ['error', 2],
60+
'@stylistic/comma-dangle': ['error', 'always-multiline'],
61+
'@stylistic/quotes': ['error', 'single'],
62+
},
63+
},
64+
);
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "agent-deepagents",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "dist/index.js",
6+
"type": "module",
7+
"scripts": {
8+
"start": "tsx src/index.ts"
9+
},
10+
"keywords": [],
11+
"author": "",
12+
"dependencies": {
13+
"@aws-sdk/credential-provider-node": "^3.972.33",
14+
"@langchain/anthropic": "^1.3.26",
15+
"@langchain/aws": "^1.3.5",
16+
"@langchain/core": "^1.1.39",
17+
"@langchain/mcp-adapters": "^1.1.3",
18+
"@opentelemetry/api": "^1.9.1",
19+
"@opentelemetry/exporter-trace-otlp-http": "^0.214.0",
20+
"@opentelemetry/exporter-trace-otlp-proto": "^0.214.0",
21+
"@opentelemetry/instrumentation": "^0.214.0",
22+
"@opentelemetry/resources": "^2.6.1",
23+
"@opentelemetry/sdk-node": "^0.214.0",
24+
"@opentelemetry/sdk-trace-base": "^2.6.1",
25+
"@opentelemetry/sdk-trace-node": "^2.6.1",
26+
"@opentelemetry/semantic-conventions": "^1.40.0",
27+
"@traceloop/node-server-sdk": "^0.25.0",
28+
"deepagents": "^1.9.0",
29+
"dotenv": "^17.4.2",
30+
"zod": "^4.3.6"
31+
},
32+
"devDependencies": {
33+
"@eslint/compat": "^2.0.5",
34+
"@eslint/js": "^10.0.1",
35+
"@stylistic/eslint-plugin": "^5.10.0",
36+
"@types/node": "^24.12.2",
37+
"eslint": "^10.2.0",
38+
"eslint-import-resolver-typescript": "^4.4.4",
39+
"eslint-plugin-import-x": "^4.16.2",
40+
"eslint-plugin-promise": "^7.2.1",
41+
"langchain": "^1.3.2",
42+
"tsx": "^4.21.0",
43+
"typescript": "^5.9.3",
44+
"typescript-eslint": "^8.58.2",
45+
"vite": "^8.0.8",
46+
"vitest": "^4.1.4"
47+
}
48+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { createDeepAgent } from "deepagents";
2+
import * as traceloop from "@traceloop/node-server-sdk";
3+
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
4+
import { tools } from "./tools.js";
5+
6+
traceloop.initialize({
7+
appName: "my-deep-agent",
8+
exporter: new OTLPTraceExporter({
9+
url: "http://127.0.0.1:5000/v1/traces",
10+
headers: {
11+
"x-mlflow-experiment-id": "0",
12+
},
13+
}),
14+
});
15+
16+
// System prompt to steer the agent to be an expert researcher
17+
const researchInstructions = `
18+
You are an assistant that helps architects design systems using Amazon Web Services (AWS). Your primary function is to answer user questions based on AWS knowledge and propose system architectures. When responding, follow these guidelines:
19+
20+
- If information is not available in aws-knowledge-mcp-server, clearly state that you don't know
21+
- Always cite your sources
22+
- When proposing architectures, provide multiple patterns whenever possible
23+
- Respond in the same language as the question
24+
- Keep responses concise yet informative
25+
- When returning Markdown, ensure it passes markdownlint-cli validation without warnings
26+
- For non-AWS information, use Context7 to resolve queries with up-to-date information
27+
- If Context7 cannot resolve the query, clearly state that you don't know
28+
`;
29+
30+
const agent = createDeepAgent({
31+
model: "bedrock:global.amazon.nova-2-lite-v1:0",
32+
tools,
33+
systemPrompt: researchInstructions,
34+
});
35+
36+
const result = await agent.invoke({
37+
messages: [{ role: "user", content: "MCPサーバーをサーバーレスで構築するには?" }],
38+
});
39+
40+
// Print the agent's response
41+
console.log(result.messages[result.messages.length - 1].content);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
import { MultiServerMCPClient } from "@langchain/mcp-adapters";
3+
4+
const client = new MultiServerMCPClient({
5+
'aws-knowledge-mcp-server': {
6+
transport: "http",
7+
url: 'https://knowledge-mcp.global.api.aws',
8+
},
9+
});
10+
11+
export const tools = await client.getTools();
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"compilerOptions": {
3+
"target": "esnext",
4+
"module": "nodenext",
5+
"lib": [
6+
"esnext",
7+
"dom"
8+
],
9+
"moduleResolution": "nodenext",
10+
"moduleDetection": "force",
11+
"resolveJsonModule": true,
12+
"allowJs": true,
13+
"esModuleInterop": true,
14+
"isolatedModules": true,
15+
"declaration": true,
16+
"strict": true,
17+
"noImplicitAny": true,
18+
"strictNullChecks": true,
19+
"noImplicitThis": true,
20+
"alwaysStrict": true,
21+
"noUnusedLocals": false,
22+
"noUnusedParameters": false,
23+
"noImplicitReturns": true,
24+
"noFallthroughCasesInSwitch": false,
25+
"inlineSourceMap": true,
26+
"inlineSources": true,
27+
"experimentalDecorators": true,
28+
"strictPropertyInitialization": false,
29+
"skipLibCheck": true,
30+
"rootDir": "./src",
31+
"outDir": "./dist",
32+
"typeRoots": [
33+
"./node_modules",
34+
"./node_modules/@types",
35+
"./lambda"
36+
],
37+
"types": [
38+
"node"
39+
]
40+
},
41+
"include": [
42+
"src/**/*"
43+
],
44+
"exclude": [
45+
"node_modules",
46+
"cdk.out",
47+
"eslint.config.*",
48+
"vitest.config.*"
49+
]
50+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/// <reference types="vitest" />
2+
/// <reference types="vite/client" />
3+
4+
import { defineConfig } from 'vitest/config';
5+
import * as dotenv from 'dotenv';
6+
import { resolve } from 'path';
7+
8+
export default defineConfig({
9+
// モノレポ用の共通設定
10+
resolve: {
11+
alias: {
12+
// パッケージ間の直接参照
13+
'@llm-ts-example/common-core': resolve(__dirname, '../../common/core/src'),
14+
'@llm-ts-example/common-backend': resolve(__dirname, '../../common/backend/src'),
15+
},
16+
},
17+
server: {
18+
fs: {
19+
// モノレポ内のファイルアクセスを許可
20+
allow: ['..'],
21+
},
22+
},
23+
build: {
24+
target: 'esnext',
25+
rollupOptions: {
26+
// ESModuleとして出力
27+
output: {
28+
format: 'es',
29+
},
30+
},
31+
},
32+
root: '.',
33+
test: {
34+
environment: 'node',
35+
globals: true,
36+
isolate: true,
37+
env: dotenv.config({ path: '.env.test' }).parsed,
38+
testTimeout: 30000,
39+
},
40+
// resolve: {
41+
// conditions: ['development'],
42+
// }
43+
});

0 commit comments

Comments
 (0)