create-adk-agent 0.0.2 → 0.0.9
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/README.md +30 -202
- package/bin/create-adk-agent.js +361 -35
- package/dist/generators/init/files/.env.example.template +16 -0
- package/dist/generators/init/files/.eslintrc.json.template +20 -0
- package/dist/generators/init/files/.gitignore.template +27 -0
- package/dist/generators/init/files/.prettierrc.template +7 -0
- package/dist/generators/init/files/README.md.template +243 -0
- package/dist/generators/init/files/jest.config.ts.template +7 -0
- package/dist/generators/init/files/package.json.template +41 -0
- package/dist/generators/init/files/src/agents/basic/agent.ts.template +24 -0
- package/dist/generators/init/files/src/agents/multi-tool/agent.ts.template +36 -0
- package/dist/generators/init/files/src/agents/streaming/agent.ts.template +36 -0
- package/dist/generators/init/files/src/agents/team/farewell-agent.ts.template +43 -0
- package/dist/generators/init/files/src/agents/team/greeting-agent.ts.template +43 -0
- package/dist/generators/init/files/src/agents/team/root-agent.ts.template +18 -0
- package/dist/generators/init/files/src/agents/workflow/agent.ts.template +69 -0
- package/dist/generators/init/files/src/index.ts.template +61 -0
- package/dist/generators/init/files/tests/agents.test.ts.template +80 -0
- package/dist/generators/init/files/tsconfig.json.template +20 -0
- package/dist/generators/init/files/vite.config.ts.template +36 -0
- package/dist/generators/init/generator.js +3 -0
- package/dist/generators/init/generator.js.map +1 -1
- package/dist/generators/init/schema.json +124 -0
- package/package.json +20 -4
- package/src/generators/init/files/README.md.template +3 -2
- package/src/generators/init/files/package.json.template +8 -6
- package/src/generators/init/files/src/agents/basic/agent.ts.template +9 -19
- package/src/generators/init/files/src/agents/multi-tool/agent.ts.template +15 -62
- package/src/generators/init/files/vite.config.ts.template +36 -0
- package/templates/basic/.env.example +16 -0
- package/templates/basic/.eslintrc.json +13 -0
- package/templates/basic/.prettierrc +5 -0
- package/templates/basic/README.md +49 -0
- package/templates/basic/_gitignore +8 -0
- package/templates/basic/jest.config.ts +8 -0
- package/templates/basic/package.json +43 -0
- package/templates/basic/src/index.ts +59 -0
- package/templates/basic/tests/agents.test.ts +19 -0
- package/templates/basic/tsconfig.json +21 -0
- package/templates/multi-tool/src/index.ts +60 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Google Gemini API Key
|
|
2
|
+
# Get your key from: https://aistudio.google.com/apikey
|
|
3
|
+
GEMINI_API_KEY=your_google_api_key_here
|
|
4
|
+
|
|
5
|
+
# OR use Vertex AI (for Google Cloud)
|
|
6
|
+
# GOOGLE_GENAI_USE_VERTEXAI=true
|
|
7
|
+
# GOOGLE_CLOUD_PROJECT=your-project-id
|
|
8
|
+
# GOOGLE_CLOUD_LOCATION=us-central1
|
|
9
|
+
|
|
10
|
+
# OpenAI API Key (if using OpenAI models)
|
|
11
|
+
# Get your key from: https://platform.openai.com/api-keys
|
|
12
|
+
# OPENAI_API_KEY=your_openai_api_key_here
|
|
13
|
+
|
|
14
|
+
# Anthropic API Key (if using Claude models)
|
|
15
|
+
# Get your key from: https://console.anthropic.com/settings/keys
|
|
16
|
+
# ANTHROPIC_API_KEY=your_anthropic_api_key_here
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"parser": "@typescript-eslint/parser",
|
|
3
|
+
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
|
|
4
|
+
"parserOptions": {
|
|
5
|
+
"ecmaVersion": 2022,
|
|
6
|
+
"sourceType": "module"
|
|
7
|
+
},
|
|
8
|
+
"env": {
|
|
9
|
+
"node": true,
|
|
10
|
+
"es2022": true
|
|
11
|
+
},
|
|
12
|
+
"rules": {}
|
|
13
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# **PROJECT_NAME**
|
|
2
|
+
|
|
3
|
+
**DESCRIPTION**
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
### 1. Install Dependencies
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### 2. Add Your API Key
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
cp .env.example .env
|
|
17
|
+
# Edit .env and add your API key
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### 3. Start Development
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm run dev # Hot reload development
|
|
24
|
+
npm run adk:web # Interactive web UI at http://localhost:8000
|
|
25
|
+
npm run adk:run # CLI runner
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Available Scripts
|
|
29
|
+
|
|
30
|
+
- `npm run dev` - Hot reload development
|
|
31
|
+
- `npm run adk:web` - ADK web UI for testing
|
|
32
|
+
- `npm run adk:run` - ADK CLI runner
|
|
33
|
+
- `npm test` - Run tests
|
|
34
|
+
- `npm run build` - Build for production
|
|
35
|
+
|
|
36
|
+
## Project Structure
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
src/
|
|
40
|
+
├── index.ts # Agent configuration
|
|
41
|
+
tests/
|
|
42
|
+
└── agents.test.ts # Agent tests
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Learn More
|
|
46
|
+
|
|
47
|
+
- **[ADK Documentation](https://google.github.io/adk-docs/)** - Complete ADK guide
|
|
48
|
+
- **[TypeScript Quickstart](https://google.github.io/adk-docs/get-started/typescript/)** - Getting started tutorial
|
|
49
|
+
- **[Building Agents](https://google.github.io/adk-docs/tutorials/)** - Agent tutorials and patterns
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "__PROJECT_NAME__",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "__DESCRIPTION__",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"dev": "tsx watch src/index.ts",
|
|
9
|
+
"start": "tsx src/index.ts",
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"prod": "node dist/index.js",
|
|
12
|
+
"test": "jest",
|
|
13
|
+
"test:watch": "jest --watch",
|
|
14
|
+
"lint": "eslint src/**/*.ts",
|
|
15
|
+
"format": "prettier --write src/**/*.ts",
|
|
16
|
+
"adk:web": "adk web",
|
|
17
|
+
"adk:run": "adk run src/index.ts"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"adk",
|
|
21
|
+
"agent",
|
|
22
|
+
"ai",
|
|
23
|
+
"llm"
|
|
24
|
+
],
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@google/adk": "^0.2.0",
|
|
28
|
+
"@google/adk-devtools": "^0.2.0",
|
|
29
|
+
"dotenv": "^16.4.0",
|
|
30
|
+
"zod": "^3.23.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^20.10.0",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "^7.0.0",
|
|
35
|
+
"@typescript-eslint/parser": "^7.0.0",
|
|
36
|
+
"eslint": "^8.56.0",
|
|
37
|
+
"jest": "^29.7.0",
|
|
38
|
+
"prettier": "^3.2.0",
|
|
39
|
+
"ts-jest": "^29.1.0",
|
|
40
|
+
"tsx": "^4.7.0",
|
|
41
|
+
"typescript": "^5.9.3"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { FunctionTool, LlmAgent } from '@google/adk';
|
|
2
|
+
import 'dotenv/config';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
// Validate environment variables
|
|
6
|
+
if (
|
|
7
|
+
!process.env.GEMINI_API_KEY &&
|
|
8
|
+
!process.env.OPENAI_API_KEY &&
|
|
9
|
+
!process.env.ANTHROPIC_API_KEY
|
|
10
|
+
) {
|
|
11
|
+
console.error('❌ Error: No API key found!');
|
|
12
|
+
console.error('Please set one of the following in your .env file:');
|
|
13
|
+
console.error(' - GEMINI_API_KEY (for Google Gemini)');
|
|
14
|
+
console.error(' - OPENAI_API_KEY (for OpenAI)');
|
|
15
|
+
console.error(' - ANTHROPIC_API_KEY (for Anthropic/Claude)');
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/* Mock tool implementation */
|
|
20
|
+
const getCurrentTime = new FunctionTool({
|
|
21
|
+
name: 'get_current_time',
|
|
22
|
+
description: 'Returns the current time in a specified city.',
|
|
23
|
+
parameters: z.object({
|
|
24
|
+
city: z
|
|
25
|
+
.string()
|
|
26
|
+
.describe('The name of the city for which to retrieve the current time.'),
|
|
27
|
+
}),
|
|
28
|
+
execute: ({ city }) => {
|
|
29
|
+
return {
|
|
30
|
+
status: 'success',
|
|
31
|
+
report: `The current time in ${city} is 10:30 AM`,
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const rootAgent = new LlmAgent({
|
|
37
|
+
name: 'hello_time_agent',
|
|
38
|
+
model: __MODEL_CONFIG__,
|
|
39
|
+
description: 'Tells the current time in a specified city.',
|
|
40
|
+
instruction: `You are a helpful assistant that tells the current time in a city.
|
|
41
|
+
Use the 'getCurrentTime' tool for this purpose.`,
|
|
42
|
+
tools: [getCurrentTime],
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// Run the agent (for direct execution)
|
|
46
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
47
|
+
console.log('🤖 Hello Time Agent is ready!');
|
|
48
|
+
console.log('Ask me about the time in any timezone.\n');
|
|
49
|
+
|
|
50
|
+
rootAgent
|
|
51
|
+
.query('What time is it in Tokyo?')
|
|
52
|
+
.then((response) => {
|
|
53
|
+
console.log('Agent response:', response);
|
|
54
|
+
})
|
|
55
|
+
.catch((error) => {
|
|
56
|
+
console.error('Error:', error);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { describe, it, expect } from '@jest/globals';
|
|
2
|
+
import { rootAgent } from '../src/index.js';
|
|
3
|
+
|
|
4
|
+
describe('Time Agent', () => {
|
|
5
|
+
it('should have correct name', () => {
|
|
6
|
+
expect(rootAgent.name).toBe('hello_time_agent');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('should have get_current_time tool', () => {
|
|
10
|
+
expect(rootAgent.tools).toHaveLength(1);
|
|
11
|
+
expect(rootAgent.tools[0].name).toBe('get_current_time');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('should return time when queried', async () => {
|
|
15
|
+
const response = await rootAgent.query('What time is it?');
|
|
16
|
+
expect(response).toBeDefined();
|
|
17
|
+
expect(typeof response).toBe('string');
|
|
18
|
+
}, 30000);
|
|
19
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"lib": ["ES2022"],
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"rootDir": "./src",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"resolveJsonModule": true,
|
|
14
|
+
"declaration": true,
|
|
15
|
+
"declarationMap": true,
|
|
16
|
+
"sourceMap": true,
|
|
17
|
+
"verbatimModuleSyntax": false
|
|
18
|
+
},
|
|
19
|
+
"include": ["src/**/*"],
|
|
20
|
+
"exclude": ["node_modules", "dist", "tests"]
|
|
21
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { FunctionTool, LlmAgent } from '@google/adk';
|
|
2
|
+
import 'dotenv/config';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
// Validate environment variables
|
|
6
|
+
if (
|
|
7
|
+
!process.env.GEMINI_API_KEY &&
|
|
8
|
+
!process.env.OPENAI_API_KEY &&
|
|
9
|
+
!process.env.ANTHROPIC_API_KEY
|
|
10
|
+
) {
|
|
11
|
+
console.error('❌ Error: No API key found!');
|
|
12
|
+
console.error('Please set one of the following in your .env file:');
|
|
13
|
+
console.error(' - GEMINI_API_KEY (for Google Gemini)');
|
|
14
|
+
console.error(' - OPENAI_API_KEY (for OpenAI)');
|
|
15
|
+
console.error(' - ANTHROPIC_API_KEY (for Anthropic/Claude)');
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/* Mock tool implementations */
|
|
20
|
+
const getCurrentTime = new FunctionTool({
|
|
21
|
+
name: 'get_current_time',
|
|
22
|
+
description: 'Returns the current time in a specified city.',
|
|
23
|
+
parameters: z.object({
|
|
24
|
+
city: z
|
|
25
|
+
.string()
|
|
26
|
+
.describe('The name of the city for which to retrieve the current time.'),
|
|
27
|
+
}),
|
|
28
|
+
execute: ({ city }) => {
|
|
29
|
+
return {
|
|
30
|
+
status: 'success',
|
|
31
|
+
report: `The current time in ${city} is 10:30 AM`,
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const getWeather = new FunctionTool({
|
|
37
|
+
name: 'get_weather',
|
|
38
|
+
description: 'Returns the current weather for a specified city.',
|
|
39
|
+
parameters: z.object({
|
|
40
|
+
city: z
|
|
41
|
+
.string()
|
|
42
|
+
.describe('The name of the city for which to retrieve the weather.'),
|
|
43
|
+
}),
|
|
44
|
+
execute: ({ city }) => {
|
|
45
|
+
return {
|
|
46
|
+
status: 'success',
|
|
47
|
+
report: `The weather in ${city} is sunny and 72°F`,
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export const rootAgent = new LlmAgent({
|
|
53
|
+
name: 'multi_tool_agent',
|
|
54
|
+
model: __MODEL_CONFIG__,
|
|
55
|
+
description: 'Provides current time and weather information for cities.',
|
|
56
|
+
instruction: `You are a helpful assistant that provides time and weather information.
|
|
57
|
+
Use the 'getCurrentTime' tool to get the time in a city.
|
|
58
|
+
Use the 'getWeather' tool to get weather information for a city.`,
|
|
59
|
+
tools: [getCurrentTime, getWeather],
|
|
60
|
+
});
|