create-adk-agent 0.0.5 โ 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 +29 -210
- package/dist/generators/init/files/src/agents/basic/agent.ts.template +9 -19
- package/dist/generators/init/files/src/agents/multi-tool/agent.ts.template +15 -62
- package/package.json +1 -1
- 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/templates/basic/README.md +19 -125
- package/templates/basic/package.json +3 -1
- package/templates/basic/src/index.ts +16 -17
- package/templates/multi-tool/src/index.ts +60 -0
package/README.md
CHANGED
|
@@ -1,250 +1,69 @@
|
|
|
1
1
|
# create-adk-agent
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> Scaffold production-ready [Google ADK](https://google.github.io/adk-docs/) TypeScript projects in seconds
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
**What is ADK?** The [Agent Development Kit](https://google.github.io/adk-docs/) is Google's framework for building AI agents. This tool makes it easy to get started.
|
|
8
|
-
|
|
9
|
-
## ๐ Quick Start
|
|
5
|
+
## Quick Start
|
|
10
6
|
|
|
11
7
|
```bash
|
|
12
8
|
npx create-adk-agent my-agent
|
|
13
9
|
```
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
npx create-adk-agent my-agent --template=basic --modelProvider=gemini --model=gemini-2.0-flash
|
|
19
|
-
```
|
|
11
|
+
Creates a TypeScript project pre-configured for building AI agents with Google's Agent Development Kit.
|
|
20
12
|
|
|
21
|
-
|
|
13
|
+
## What You Get
|
|
22
14
|
|
|
23
|
-
- โ
|
|
15
|
+
- โ
Working agent examples from [ADK docs](https://google.github.io/adk-docs/get-started/typescript/)
|
|
16
|
+
- โ
TypeScript configured (ES2022, NodeNext, ESM)
|
|
17
|
+
- โ
Hot reload with tsx (instant execution)
|
|
18
|
+
- โ
Multi-model support (Gemini, OpenAI, Anthropic)
|
|
24
19
|
- โ
Environment setup with API key validation
|
|
25
|
-
- โ
|
|
26
|
-
- โ
Hot reload development with tsx
|
|
27
|
-
- โ
Testing setup with Jest
|
|
28
|
-
- โ
All the tooling (ESLint, Prettier, etc.)
|
|
29
|
-
|
|
30
|
-
## ๐ก Why Use This?
|
|
31
|
-
|
|
32
|
-
Instead of manually setting up TypeScript, configuring ESM, managing API keys, and copying examples from docs, `create-adk-agent` does it all for you in one command.
|
|
33
|
-
|
|
34
|
-
**Perfect for:**
|
|
35
|
-
|
|
36
|
-
- ๐ Learning ADK quickly with working examples
|
|
37
|
-
- ๐ Starting new ADK projects without boilerplate hassle
|
|
38
|
-
- ๐ฆ Getting ADK best practices out of the box
|
|
39
|
-
- ๐ Experimenting with different agent patterns
|
|
40
|
-
|
|
41
|
-
## โจ What You Get
|
|
42
|
-
|
|
43
|
-
## โจ What You Get
|
|
44
|
-
|
|
45
|
-
- ๐ค **5 Agent Templates** - Pre-built examples from [official ADK docs](https://google.github.io/adk-docs/) (basic, multi-tool, team, streaming, workflow)
|
|
46
|
-
- ๐ **Multi-Model Ready** - Pre-configured for Gemini, OpenAI, and Anthropic
|
|
47
|
-
- โก **Hot Reload** - Instant TypeScript execution with tsx (no build step needed)
|
|
48
|
-
- ๐ **Security Built-in** - Proper `.env` handling with validation and git-ignore
|
|
49
|
-
- ๐งช **Testing Included** - Jest configured and ready to go
|
|
50
|
-
- ๐ฆ **Best Practices** - TypeScript, ESLint, Prettier, Zod validation
|
|
51
|
-
|
|
52
|
-
## ๐ Agent Templates
|
|
53
|
-
|
|
54
|
-
All templates are based on [official ADK documentation examples](https://google.github.io/adk-docs/):
|
|
55
|
-
|
|
56
|
-
### Basic Agent
|
|
57
|
-
|
|
58
|
-
Simple agent with time tool - perfect for learning ADK basics.
|
|
59
|
-
|
|
60
|
-
### Multi-Tool Agent (Default)
|
|
20
|
+
- โ
Testing with Jest, linting with ESLint
|
|
61
21
|
|
|
62
|
-
|
|
22
|
+
## Usage
|
|
63
23
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
Multi-agent system with coordination, delegation, and sub-agents (greeting + farewell).
|
|
67
|
-
|
|
68
|
-
### Streaming Agent
|
|
69
|
-
|
|
70
|
-
Demonstrates real-time streaming responses using ADK Live API.
|
|
71
|
-
|
|
72
|
-
### Workflow Agent
|
|
73
|
-
|
|
74
|
-
Sequential workflow patterns with validation, transformation, and saving steps.
|
|
75
|
-
|
|
76
|
-
## ๐ฏ Usage
|
|
77
|
-
|
|
78
|
-
### Simple (Interactive)
|
|
79
|
-
|
|
80
|
-
Just run the command and answer a few questions:
|
|
24
|
+
**Interactive:**
|
|
81
25
|
|
|
82
26
|
```bash
|
|
83
27
|
npx create-adk-agent my-agent
|
|
84
28
|
```
|
|
85
29
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
- Which agent templates to include
|
|
89
|
-
- Your preferred model provider (Gemini, OpenAI, or Anthropic)
|
|
90
|
-
- Whether to install dependencies now
|
|
91
|
-
- Whether to initialize git
|
|
92
|
-
|
|
93
|
-
### Advanced (Non-Interactive)
|
|
94
|
-
|
|
95
|
-
Skip prompts by providing options:
|
|
30
|
+
**Non-interactive:**
|
|
96
31
|
|
|
97
32
|
```bash
|
|
98
33
|
npx create-adk-agent my-agent \
|
|
99
|
-
--
|
|
34
|
+
--template=basic \
|
|
100
35
|
--modelProvider=gemini \
|
|
101
|
-
--model=gemini-
|
|
102
|
-
--description="My custom agent" \
|
|
103
|
-
--installDependencies \
|
|
104
|
-
--no-interactive
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### Options
|
|
108
|
-
|
|
109
|
-
| Option | Type | Description | Default |
|
|
110
|
-
| ----------------------- | --------------------------------- | -------------------------- | ---------------------- |
|
|
111
|
-
| `name` | string | Project name (required) | - |
|
|
112
|
-
| `--templates` | string[] | Agent templates to include | `['multi-tool']` |
|
|
113
|
-
| `--modelProvider` | gemini\|openai\|anthropic\|custom | LLM provider | `gemini` |
|
|
114
|
-
| `--model` | string | Specific model to use | Provider's first model |
|
|
115
|
-
| `--description` | string | Project description | `My ADK Agent` |
|
|
116
|
-
| `--directory` | string | Target directory | Same as name |
|
|
117
|
-
| `--installDependencies` | boolean | Run npm install | Prompt |
|
|
118
|
-
| `--initGit` | boolean | Initialize git repo | Prompt |
|
|
119
|
-
| `--no-interactive` | boolean | Skip prompts | `false` |
|
|
120
|
-
|
|
121
|
-
## ๐ค Supported Models
|
|
122
|
-
|
|
123
|
-
### Google Gemini (Direct)
|
|
124
|
-
|
|
125
|
-
- gemini-3.0-flash
|
|
126
|
-
- gemini-3.0-pro
|
|
127
|
-
- gemini-2.5-flash
|
|
128
|
-
- gemini-2.5-pro
|
|
129
|
-
|
|
130
|
-
### OpenAI (via LiteLLM)
|
|
131
|
-
|
|
132
|
-
- gpt-5
|
|
133
|
-
- gpt-5-mini
|
|
134
|
-
- gpt-4o
|
|
135
|
-
- gpt-4o-mini
|
|
136
|
-
|
|
137
|
-
### Anthropic (via LiteLLM)
|
|
138
|
-
|
|
139
|
-
- claude-4.5-sonnet
|
|
140
|
-
- claude-4-sonnet
|
|
141
|
-
- claude-4-opus
|
|
142
|
-
- claude-3-5-sonnet
|
|
143
|
-
|
|
144
|
-
**Note:** You can change to any model after project generation. The list above is for initial setup convenience.
|
|
145
|
-
|
|
146
|
-
## ๐ฌ Getting Started Workflow
|
|
147
|
-
|
|
148
|
-
```bash
|
|
149
|
-
# 1. Create your project (takes ~10 seconds)
|
|
150
|
-
npx create-adk-agent my-agent
|
|
151
|
-
|
|
152
|
-
# 2. Navigate to project
|
|
153
|
-
cd my-agent
|
|
154
|
-
|
|
155
|
-
# 3. Add your API key
|
|
156
|
-
cp .env.example .env
|
|
157
|
-
# Edit .env and add your API key (get it from links in the file)
|
|
158
|
-
|
|
159
|
-
# 4. Start coding! (hot reload enabled)
|
|
160
|
-
npm run dev
|
|
161
|
-
|
|
162
|
-
# 5. Or use ADK DevTools
|
|
163
|
-
npm run adk:web # Beautiful web UI
|
|
164
|
-
npm run adk:run # CLI runner
|
|
36
|
+
--model=gemini-2.5-flash
|
|
165
37
|
```
|
|
166
38
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
## ๐ Learn More About ADK
|
|
170
|
-
|
|
171
|
-
```
|
|
172
|
-
my-agent/
|
|
173
|
-
โโโ src/
|
|
174
|
-
โ โโโ agents/
|
|
175
|
-
โ โ โโโ basic/ # Basic agent (if selected)
|
|
176
|
-
โ โ โโโ multi-tool/ # Multi-tool agent (if selected)
|
|
177
|
-
โ โ โโโ team/ # Team agents (if selected)
|
|
178
|
-
โ โ โโโ streaming/ # Streaming agent (if selected)
|
|
179
|
-
โ โ โโโ workflow/ # Workflow agent (if selected)
|
|
180
|
-
โ โโโ index.ts # Entry point with env validation
|
|
181
|
-
โโโ tests/
|
|
182
|
-
โ โโโ agents.test.ts # Jest tests
|
|
183
|
-
โโโ .env.example # Environment template (commit this)
|
|
184
|
-
โโโ .env # Your API keys (DO NOT COMMIT)
|
|
185
|
-
โโโ .gitignore # Includes .env patterns
|
|
186
|
-
โโโ package.json # With tsx, ADK, and dev tools
|
|
187
|
-
โโโ tsconfig.json # Configured for ESM + NodeNext
|
|
188
|
-
โโโ README.md # Project-specific documentation
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
## ๐ Security
|
|
192
|
-
|
|
193
|
-
**โ ๏ธ Generated projects include:**
|
|
194
|
-
|
|
195
|
-
- `.env` in `.gitignore` by default
|
|
196
|
-
- API key validation on startup
|
|
197
|
-
- Clear warnings about committing secrets
|
|
198
|
-
- `.env.example` template for sharing
|
|
199
|
-
|
|
200
|
-
## ๐ ๏ธ Development Workflow
|
|
201
|
-
|
|
202
|
-
After generating your project:
|
|
39
|
+
## After Generation
|
|
203
40
|
|
|
204
41
|
```bash
|
|
205
42
|
cd my-agent
|
|
206
43
|
|
|
207
|
-
#
|
|
44
|
+
# Add your API key
|
|
208
45
|
cp .env.example .env
|
|
209
|
-
# Edit .env
|
|
46
|
+
# Edit .env with your API key
|
|
210
47
|
|
|
211
|
-
#
|
|
212
|
-
npm install
|
|
213
|
-
|
|
214
|
-
# 3. Start development with hot reload
|
|
48
|
+
# Start development
|
|
215
49
|
npm run dev
|
|
216
50
|
|
|
217
|
-
#
|
|
218
|
-
npm
|
|
219
|
-
|
|
220
|
-
# 5. Use ADK DevTools
|
|
221
|
-
npm run adk:web # Web UI
|
|
51
|
+
# Use ADK DevTools
|
|
52
|
+
npm run adk:web # Interactive web UI
|
|
222
53
|
npm run adk:run # CLI runner
|
|
223
54
|
```
|
|
224
55
|
|
|
225
|
-
##
|
|
226
|
-
|
|
227
|
-
- [ADK Documentation](https://google.github.io/adk-docs/)
|
|
228
|
-
- [TypeScript Quick Start](https://google.github.io/adk-docs/get-started/typescript/)
|
|
229
|
-
- [Agent Tutorial](https://google.github.io/adk-docs/tutorial/agent/)
|
|
230
|
-
|
|
231
|
-
## ๐ค Contributing
|
|
56
|
+
## Templates
|
|
232
57
|
|
|
233
|
-
|
|
58
|
+
- **basic** - Single agent with one tool ([docs example](https://google.github.io/adk-docs/get-started/typescript/#define-the-agent-code))
|
|
59
|
+
- **multi-tool** - Agent with multiple tools (default)
|
|
234
60
|
|
|
235
|
-
|
|
61
|
+
## Learn More
|
|
236
62
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
# Test locally
|
|
242
|
-
nx g @adk-ts-new/create-adk-agent:init test-project
|
|
243
|
-
|
|
244
|
-
# Run tests
|
|
245
|
-
nx test create-adk-agent
|
|
246
|
-
```
|
|
63
|
+
- **[ADK Documentation](https://google.github.io/adk-docs/)** - Official ADK guide
|
|
64
|
+
- **[TypeScript Quickstart](https://google.github.io/adk-docs/get-started/typescript/)** - Getting started
|
|
65
|
+
- **[Building Agents](https://google.github.io/adk-docs/tutorials/)** - Agent tutorials
|
|
247
66
|
|
|
248
|
-
##
|
|
67
|
+
## License
|
|
249
68
|
|
|
250
|
-
MIT
|
|
69
|
+
MIT
|
|
@@ -1,34 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FunctionTool, LlmAgent } from '@google/adk';<% if (modelProvider === 'openai' || modelProvider === 'anthropic') { %>
|
|
2
2
|
import { LiteLlm } from '@google/adk';<% } %>
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/* Mock tool implementation */
|
|
6
6
|
const getCurrentTime = new FunctionTool({
|
|
7
7
|
name: 'get_current_time',
|
|
8
|
-
description: 'Returns the current time in
|
|
8
|
+
description: 'Returns the current time in a specified city.',
|
|
9
9
|
parameters: z.object({
|
|
10
|
-
|
|
11
|
-
.string()
|
|
12
|
-
.optional()
|
|
13
|
-
.describe('The timezone to use (e.g., "America/New_York", "Europe/London")'),
|
|
10
|
+
city: z.string().describe('The name of the city for which to retrieve the current time.'),
|
|
14
11
|
}),
|
|
15
|
-
execute: ({
|
|
16
|
-
|
|
17
|
-
const timeString = now.toLocaleString('en-US', { timeZone: timezone });
|
|
18
|
-
return {
|
|
19
|
-
status: 'success',
|
|
20
|
-
report: `The current time in ${timezone} is ${timeString}`,
|
|
21
|
-
};
|
|
12
|
+
execute: ({ city }) => {
|
|
13
|
+
return { status: 'success', report: `The current time in ${city} is 10:30 AM` };
|
|
22
14
|
},
|
|
23
15
|
});
|
|
24
16
|
|
|
25
|
-
// Create the agent
|
|
26
17
|
export const rootAgent = new LlmAgent({
|
|
27
18
|
name: 'hello_time_agent',
|
|
28
19
|
<% if (modelProvider === 'gemini') { %>model: '<%= model %>',<% } else if (modelProvider === 'openai' || modelProvider === 'anthropic') { %>model: new LiteLlm({ model: '<%= model %>' }),<% } else { %>model: '<%= model %>',<% } %>
|
|
29
|
-
description: '
|
|
30
|
-
instruction: `You are a
|
|
31
|
-
|
|
32
|
-
If no timezone is specified, use UTC as the default.`,
|
|
20
|
+
description: 'Tells the current time in a specified city.',
|
|
21
|
+
instruction: `You are a helpful assistant that tells the current time in a city.
|
|
22
|
+
Use the 'getCurrentTime' tool for this purpose.`,
|
|
33
23
|
tools: [getCurrentTime],
|
|
34
24
|
});
|
|
@@ -1,83 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FunctionTool, LlmAgent } from '@google/adk';<% if (modelProvider === 'openai' || modelProvider === 'anthropic') { %>
|
|
2
2
|
import { LiteLlm } from '@google/adk';<% } %>
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/* Mock tool implementations */
|
|
6
6
|
const getCurrentTime = new FunctionTool({
|
|
7
7
|
name: 'get_current_time',
|
|
8
|
-
description: 'Returns the current time in
|
|
8
|
+
description: 'Returns the current time in a specified city.',
|
|
9
9
|
parameters: z.object({
|
|
10
|
-
|
|
11
|
-
.string()
|
|
12
|
-
.optional()
|
|
13
|
-
.describe('The timezone to use (e.g., "America/New_York", "Europe/London")'),
|
|
10
|
+
city: z.string().describe('The name of the city for which to retrieve the current time.'),
|
|
14
11
|
}),
|
|
15
|
-
execute: ({
|
|
16
|
-
|
|
17
|
-
const timeString = now.toLocaleString('en-US', { timeZone: timezone });
|
|
18
|
-
return {
|
|
19
|
-
status: 'success',
|
|
20
|
-
report: `The current time in ${timezone} is ${timeString}`,
|
|
21
|
-
};
|
|
12
|
+
execute: ({ city }) => {
|
|
13
|
+
return { status: 'success', report: `The current time in ${city} is 10:30 AM` };
|
|
22
14
|
},
|
|
23
15
|
});
|
|
24
16
|
|
|
25
|
-
// Tool to get weather (mock data for demo)
|
|
26
17
|
const getWeather = new FunctionTool({
|
|
27
18
|
name: 'get_weather',
|
|
28
|
-
description: 'Returns the current weather for a
|
|
19
|
+
description: 'Returns the current weather for a specified city.',
|
|
29
20
|
parameters: z.object({
|
|
30
|
-
|
|
21
|
+
city: z.string().describe('The name of the city for which to retrieve the weather.'),
|
|
31
22
|
}),
|
|
32
|
-
execute: ({
|
|
33
|
-
|
|
34
|
-
const conditions = ['sunny', 'cloudy', 'rainy', 'partly cloudy'];
|
|
35
|
-
const condition = conditions[Math.floor(Math.random() * conditions.length)];
|
|
36
|
-
const temp = Math.floor(Math.random() * 30) + 50; // 50-80ยฐF
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
status: 'success',
|
|
40
|
-
report: `The weather in ${location} is ${condition} with a temperature of ${temp}ยฐF`,
|
|
41
|
-
};
|
|
23
|
+
execute: ({ city }) => {
|
|
24
|
+
return { status: 'success', report: `The weather in ${city} is sunny and 72ยฐF` };
|
|
42
25
|
},
|
|
43
26
|
});
|
|
44
27
|
|
|
45
|
-
// Tool for calculations
|
|
46
|
-
const calculate = new FunctionTool({
|
|
47
|
-
name: 'calculate',
|
|
48
|
-
description: 'Performs basic mathematical calculations.',
|
|
49
|
-
parameters: z.object({
|
|
50
|
-
expression: z
|
|
51
|
-
.string()
|
|
52
|
-
.describe('The mathematical expression to evaluate (e.g., "2 + 2", "10 * 5")'),
|
|
53
|
-
}),
|
|
54
|
-
execute: ({ expression }) => {
|
|
55
|
-
try {
|
|
56
|
-
// Simple eval for demo - in production, use a safe math parser
|
|
57
|
-
const result = eval(expression);
|
|
58
|
-
return {
|
|
59
|
-
status: 'success',
|
|
60
|
-
report: `${expression} = ${result}`,
|
|
61
|
-
};
|
|
62
|
-
} catch (error) {
|
|
63
|
-
return {
|
|
64
|
-
status: 'error',
|
|
65
|
-
report: `Error evaluating expression: ${error}`,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
// Create the agent with multiple tools
|
|
72
28
|
export const rootAgent = new LlmAgent({
|
|
73
29
|
name: 'multi_tool_agent',
|
|
74
30
|
<% if (modelProvider === 'gemini') { %>model: '<%= model %>',<% } else if (modelProvider === 'openai' || modelProvider === 'anthropic') { %>model: new LiteLlm({ model: '<%= model %>' }),<% } else { %>model: '<%= model %>',<% } %>
|
|
75
|
-
description: '
|
|
76
|
-
instruction: `You are a helpful assistant
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
Use the appropriate tool based on the user's request. Be friendly and helpful.`,
|
|
82
|
-
tools: [getCurrentTime, getWeather, calculate],
|
|
31
|
+
description: 'Provides current time and weather information for cities.',
|
|
32
|
+
instruction: `You are a helpful assistant that provides time and weather information.
|
|
33
|
+
Use the 'getCurrentTime' tool to get the time in a city.
|
|
34
|
+
Use the 'getWeather' tool to get weather information for a city.`,
|
|
35
|
+
tools: [getCurrentTime, getWeather],
|
|
83
36
|
});
|
package/package.json
CHANGED
|
@@ -1,34 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FunctionTool, LlmAgent } from '@google/adk';<% if (modelProvider === 'openai' || modelProvider === 'anthropic') { %>
|
|
2
2
|
import { LiteLlm } from '@google/adk';<% } %>
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/* Mock tool implementation */
|
|
6
6
|
const getCurrentTime = new FunctionTool({
|
|
7
7
|
name: 'get_current_time',
|
|
8
|
-
description: 'Returns the current time in
|
|
8
|
+
description: 'Returns the current time in a specified city.',
|
|
9
9
|
parameters: z.object({
|
|
10
|
-
|
|
11
|
-
.string()
|
|
12
|
-
.optional()
|
|
13
|
-
.describe('The timezone to use (e.g., "America/New_York", "Europe/London")'),
|
|
10
|
+
city: z.string().describe('The name of the city for which to retrieve the current time.'),
|
|
14
11
|
}),
|
|
15
|
-
execute: ({
|
|
16
|
-
|
|
17
|
-
const timeString = now.toLocaleString('en-US', { timeZone: timezone });
|
|
18
|
-
return {
|
|
19
|
-
status: 'success',
|
|
20
|
-
report: `The current time in ${timezone} is ${timeString}`,
|
|
21
|
-
};
|
|
12
|
+
execute: ({ city }) => {
|
|
13
|
+
return { status: 'success', report: `The current time in ${city} is 10:30 AM` };
|
|
22
14
|
},
|
|
23
15
|
});
|
|
24
16
|
|
|
25
|
-
// Create the agent
|
|
26
17
|
export const rootAgent = new LlmAgent({
|
|
27
18
|
name: 'hello_time_agent',
|
|
28
19
|
<% if (modelProvider === 'gemini') { %>model: '<%= model %>',<% } else if (modelProvider === 'openai' || modelProvider === 'anthropic') { %>model: new LiteLlm({ model: '<%= model %>' }),<% } else { %>model: '<%= model %>',<% } %>
|
|
29
|
-
description: '
|
|
30
|
-
instruction: `You are a
|
|
31
|
-
|
|
32
|
-
If no timezone is specified, use UTC as the default.`,
|
|
20
|
+
description: 'Tells the current time in a specified city.',
|
|
21
|
+
instruction: `You are a helpful assistant that tells the current time in a city.
|
|
22
|
+
Use the 'getCurrentTime' tool for this purpose.`,
|
|
33
23
|
tools: [getCurrentTime],
|
|
34
24
|
});
|
|
@@ -1,83 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FunctionTool, LlmAgent } from '@google/adk';<% if (modelProvider === 'openai' || modelProvider === 'anthropic') { %>
|
|
2
2
|
import { LiteLlm } from '@google/adk';<% } %>
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/* Mock tool implementations */
|
|
6
6
|
const getCurrentTime = new FunctionTool({
|
|
7
7
|
name: 'get_current_time',
|
|
8
|
-
description: 'Returns the current time in
|
|
8
|
+
description: 'Returns the current time in a specified city.',
|
|
9
9
|
parameters: z.object({
|
|
10
|
-
|
|
11
|
-
.string()
|
|
12
|
-
.optional()
|
|
13
|
-
.describe('The timezone to use (e.g., "America/New_York", "Europe/London")'),
|
|
10
|
+
city: z.string().describe('The name of the city for which to retrieve the current time.'),
|
|
14
11
|
}),
|
|
15
|
-
execute: ({
|
|
16
|
-
|
|
17
|
-
const timeString = now.toLocaleString('en-US', { timeZone: timezone });
|
|
18
|
-
return {
|
|
19
|
-
status: 'success',
|
|
20
|
-
report: `The current time in ${timezone} is ${timeString}`,
|
|
21
|
-
};
|
|
12
|
+
execute: ({ city }) => {
|
|
13
|
+
return { status: 'success', report: `The current time in ${city} is 10:30 AM` };
|
|
22
14
|
},
|
|
23
15
|
});
|
|
24
16
|
|
|
25
|
-
// Tool to get weather (mock data for demo)
|
|
26
17
|
const getWeather = new FunctionTool({
|
|
27
18
|
name: 'get_weather',
|
|
28
|
-
description: 'Returns the current weather for a
|
|
19
|
+
description: 'Returns the current weather for a specified city.',
|
|
29
20
|
parameters: z.object({
|
|
30
|
-
|
|
21
|
+
city: z.string().describe('The name of the city for which to retrieve the weather.'),
|
|
31
22
|
}),
|
|
32
|
-
execute: ({
|
|
33
|
-
|
|
34
|
-
const conditions = ['sunny', 'cloudy', 'rainy', 'partly cloudy'];
|
|
35
|
-
const condition = conditions[Math.floor(Math.random() * conditions.length)];
|
|
36
|
-
const temp = Math.floor(Math.random() * 30) + 50; // 50-80ยฐF
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
status: 'success',
|
|
40
|
-
report: `The weather in ${location} is ${condition} with a temperature of ${temp}ยฐF`,
|
|
41
|
-
};
|
|
23
|
+
execute: ({ city }) => {
|
|
24
|
+
return { status: 'success', report: `The weather in ${city} is sunny and 72ยฐF` };
|
|
42
25
|
},
|
|
43
26
|
});
|
|
44
27
|
|
|
45
|
-
// Tool for calculations
|
|
46
|
-
const calculate = new FunctionTool({
|
|
47
|
-
name: 'calculate',
|
|
48
|
-
description: 'Performs basic mathematical calculations.',
|
|
49
|
-
parameters: z.object({
|
|
50
|
-
expression: z
|
|
51
|
-
.string()
|
|
52
|
-
.describe('The mathematical expression to evaluate (e.g., "2 + 2", "10 * 5")'),
|
|
53
|
-
}),
|
|
54
|
-
execute: ({ expression }) => {
|
|
55
|
-
try {
|
|
56
|
-
// Simple eval for demo - in production, use a safe math parser
|
|
57
|
-
const result = eval(expression);
|
|
58
|
-
return {
|
|
59
|
-
status: 'success',
|
|
60
|
-
report: `${expression} = ${result}`,
|
|
61
|
-
};
|
|
62
|
-
} catch (error) {
|
|
63
|
-
return {
|
|
64
|
-
status: 'error',
|
|
65
|
-
report: `Error evaluating expression: ${error}`,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
// Create the agent with multiple tools
|
|
72
28
|
export const rootAgent = new LlmAgent({
|
|
73
29
|
name: 'multi_tool_agent',
|
|
74
30
|
<% if (modelProvider === 'gemini') { %>model: '<%= model %>',<% } else if (modelProvider === 'openai' || modelProvider === 'anthropic') { %>model: new LiteLlm({ model: '<%= model %>' }),<% } else { %>model: '<%= model %>',<% } %>
|
|
75
|
-
description: '
|
|
76
|
-
instruction: `You are a helpful assistant
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
Use the appropriate tool based on the user's request. Be friendly and helpful.`,
|
|
82
|
-
tools: [getCurrentTime, getWeather, calculate],
|
|
31
|
+
description: 'Provides current time and weather information for cities.',
|
|
32
|
+
instruction: `You are a helpful assistant that provides time and weather information.
|
|
33
|
+
Use the 'getCurrentTime' tool to get the time in a city.
|
|
34
|
+
Use the 'getWeather' tool to get weather information for a city.`,
|
|
35
|
+
tools: [getCurrentTime, getWeather],
|
|
83
36
|
});
|
|
@@ -1,22 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# **PROJECT_NAME**
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**DESCRIPTION**
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
- โ
TypeScript support with ES2022 target
|
|
8
|
-
- โ
Hot reload development with tsx
|
|
9
|
-
- โ
Multiple LLM provider support (Gemini, OpenAI, Anthropic)
|
|
10
|
-
- โ
Environment-based configuration
|
|
11
|
-
- โ
Jest testing setup
|
|
12
|
-
- โ
ESLint and Prettier configured
|
|
13
|
-
|
|
14
|
-
## Prerequisites
|
|
15
|
-
|
|
16
|
-
- Node.js 20+ (for ADK compatibility)
|
|
17
|
-
- An API key from your chosen LLM provider
|
|
18
|
-
|
|
19
|
-
## Getting Started
|
|
5
|
+
## Quick Start
|
|
20
6
|
|
|
21
7
|
### 1. Install Dependencies
|
|
22
8
|
|
|
@@ -24,132 +10,40 @@ __DESCRIPTION__
|
|
|
24
10
|
npm install
|
|
25
11
|
```
|
|
26
12
|
|
|
27
|
-
### 2.
|
|
28
|
-
|
|
29
|
-
Copy `.env.example` to `.env` and add your API key:
|
|
13
|
+
### 2. Add Your API Key
|
|
30
14
|
|
|
31
15
|
```bash
|
|
32
16
|
cp .env.example .env
|
|
17
|
+
# Edit .env and add your API key
|
|
33
18
|
```
|
|
34
19
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
```env
|
|
38
|
-
# For Google Gemini (default)
|
|
39
|
-
GEMINI_API_KEY=your_api_key_here
|
|
40
|
-
|
|
41
|
-
# OR for OpenAI
|
|
42
|
-
OPENAI_API_KEY=your_openai_key_here
|
|
43
|
-
|
|
44
|
-
# OR for Anthropic
|
|
45
|
-
ANTHROPIC_API_KEY=your_anthropic_key_here
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### 3. Run in Development Mode
|
|
20
|
+
### 3. Start Development
|
|
49
21
|
|
|
50
22
|
```bash
|
|
51
|
-
npm run dev
|
|
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
|
|
52
26
|
```
|
|
53
27
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
### 4. Run in Production Mode
|
|
28
|
+
## Available Scripts
|
|
57
29
|
|
|
58
|
-
|
|
59
|
-
npm run
|
|
60
|
-
npm run
|
|
61
|
-
|
|
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
|
|
62
35
|
|
|
63
36
|
## Project Structure
|
|
64
37
|
|
|
65
38
|
```
|
|
66
39
|
src/
|
|
67
|
-
โโโ index.ts #
|
|
68
|
-
โโโ tools/ # Custom tools for the agent
|
|
40
|
+
โโโ index.ts # Agent configuration
|
|
69
41
|
tests/
|
|
70
42
|
โโโ agents.test.ts # Agent tests
|
|
71
43
|
```
|
|
72
44
|
|
|
73
|
-
## Available Scripts
|
|
74
|
-
|
|
75
|
-
- `npm run dev` - Start with hot reload (development)
|
|
76
|
-
- `npm start` - Run once (no reload)
|
|
77
|
-
- `npm run build` - Build TypeScript to JavaScript
|
|
78
|
-
- `npm run prod` - Run built JavaScript
|
|
79
|
-
- `npm test` - Run tests
|
|
80
|
-
- `npm run lint` - Lint code
|
|
81
|
-
- `npm run format` - Format code with Prettier
|
|
82
|
-
|
|
83
|
-
## Using Different LLM Providers
|
|
84
|
-
|
|
85
|
-
### Google Gemini (Default)
|
|
86
|
-
|
|
87
|
-
```typescript
|
|
88
|
-
import { LlmAgent } from '@google/adk';
|
|
89
|
-
|
|
90
|
-
const agent = new LlmAgent({
|
|
91
|
-
model: 'gemini-2.0-flash',
|
|
92
|
-
// ...
|
|
93
|
-
});
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### OpenAI via LiteLLM
|
|
97
|
-
|
|
98
|
-
```typescript
|
|
99
|
-
import { LlmAgent, LiteLlm } from '@google/adk';
|
|
100
|
-
|
|
101
|
-
const agent = new LlmAgent({
|
|
102
|
-
model: new LiteLlm({ model: 'openai/gpt-4o' }),
|
|
103
|
-
// ...
|
|
104
|
-
});
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### Anthropic via LiteLLM
|
|
108
|
-
|
|
109
|
-
```typescript
|
|
110
|
-
import { LlmAgent, LiteLlm } from '@google/adk';
|
|
111
|
-
|
|
112
|
-
const agent = new LlmAgent({
|
|
113
|
-
model: new LiteLlm({ model: 'anthropic/claude-3-5-sonnet' }),
|
|
114
|
-
// ...
|
|
115
|
-
});
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
## Security Notes
|
|
119
|
-
|
|
120
|
-
โ ๏ธ **Never commit your `.env` file or API keys to version control!**
|
|
121
|
-
|
|
122
|
-
The `.gitignore` is configured to exclude:
|
|
123
|
-
- `.env` and `.env.local`
|
|
124
|
-
- API keys and sensitive data
|
|
125
|
-
|
|
126
|
-
## Troubleshooting
|
|
127
|
-
|
|
128
|
-
### Missing API Key Error
|
|
129
|
-
|
|
130
|
-
If you see an error about missing API keys:
|
|
131
|
-
|
|
132
|
-
1. Ensure `.env` file exists in project root
|
|
133
|
-
2. Verify the correct API key variable is set
|
|
134
|
-
3. Check that the API key is valid
|
|
135
|
-
|
|
136
|
-
### TypeScript Import Errors
|
|
137
|
-
|
|
138
|
-
ADK requires `verbatimModuleSyntax: false` in `tsconfig.json`. This is already configured.
|
|
139
|
-
|
|
140
|
-
### Module Resolution Issues
|
|
141
|
-
|
|
142
|
-
Make sure to use `.js` extensions in imports:
|
|
143
|
-
|
|
144
|
-
```typescript
|
|
145
|
-
import { myFunction } from './myModule.js';
|
|
146
|
-
```
|
|
147
|
-
|
|
148
45
|
## Learn More
|
|
149
46
|
|
|
150
|
-
- [ADK Documentation](https://google.github.io/adk-docs/)
|
|
151
|
-
- [
|
|
152
|
-
|
|
153
|
-
## License
|
|
154
|
-
|
|
155
|
-
MIT
|
|
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
|
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
"test": "jest",
|
|
13
13
|
"test:watch": "jest --watch",
|
|
14
14
|
"lint": "eslint src/**/*.ts",
|
|
15
|
-
"format": "prettier --write src/**/*.ts"
|
|
15
|
+
"format": "prettier --write src/**/*.ts",
|
|
16
|
+
"adk:web": "adk web",
|
|
17
|
+
"adk:run": "adk run src/index.ts"
|
|
16
18
|
},
|
|
17
19
|
"keywords": [
|
|
18
20
|
"adk",
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { FunctionTool, LlmAgent } from '@google/adk';
|
|
1
2
|
import 'dotenv/config';
|
|
2
|
-
import { LlmAgent, FunctionTool } from '@google/adk';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
// Validate environment variables
|
|
6
|
-
if (
|
|
6
|
+
if (
|
|
7
|
+
!process.env.GEMINI_API_KEY &&
|
|
8
|
+
!process.env.OPENAI_API_KEY &&
|
|
9
|
+
!process.env.ANTHROPIC_API_KEY
|
|
10
|
+
) {
|
|
7
11
|
console.error('โ Error: No API key found!');
|
|
8
12
|
console.error('Please set one of the following in your .env file:');
|
|
9
13
|
console.error(' - GEMINI_API_KEY (for Google Gemini)');
|
|
@@ -12,34 +16,29 @@ if (!process.env.GEMINI_API_KEY && !process.env.OPENAI_API_KEY && !process.env.A
|
|
|
12
16
|
process.exit(1);
|
|
13
17
|
}
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
/* Mock tool implementation */
|
|
16
20
|
const getCurrentTime = new FunctionTool({
|
|
17
21
|
name: 'get_current_time',
|
|
18
|
-
description: 'Returns the current time in
|
|
22
|
+
description: 'Returns the current time in a specified city.',
|
|
19
23
|
parameters: z.object({
|
|
20
|
-
|
|
24
|
+
city: z
|
|
21
25
|
.string()
|
|
22
|
-
.
|
|
23
|
-
.describe('The timezone to use (e.g., "America/New_York", "Europe/London")'),
|
|
26
|
+
.describe('The name of the city for which to retrieve the current time.'),
|
|
24
27
|
}),
|
|
25
|
-
execute: ({
|
|
26
|
-
const now = new Date();
|
|
27
|
-
const timeString = now.toLocaleString('en-US', { timeZone: timezone });
|
|
28
|
+
execute: ({ city }) => {
|
|
28
29
|
return {
|
|
29
30
|
status: 'success',
|
|
30
|
-
report: `The current time in ${
|
|
31
|
+
report: `The current time in ${city} is 10:30 AM`,
|
|
31
32
|
};
|
|
32
33
|
},
|
|
33
34
|
});
|
|
34
35
|
|
|
35
|
-
// Create the agent
|
|
36
36
|
export const rootAgent = new LlmAgent({
|
|
37
37
|
name: 'hello_time_agent',
|
|
38
38
|
model: __MODEL_CONFIG__,
|
|
39
|
-
description: '
|
|
40
|
-
instruction: `You are a
|
|
41
|
-
|
|
42
|
-
If no timezone is specified, use UTC as the default.`,
|
|
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.`,
|
|
43
42
|
tools: [getCurrentTime],
|
|
44
43
|
});
|
|
45
44
|
|
|
@@ -47,7 +46,7 @@ If no timezone is specified, use UTC as the default.`,
|
|
|
47
46
|
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
48
47
|
console.log('๐ค Hello Time Agent is ready!');
|
|
49
48
|
console.log('Ask me about the time in any timezone.\n');
|
|
50
|
-
|
|
49
|
+
|
|
51
50
|
rootAgent
|
|
52
51
|
.query('What time is it in Tokyo?')
|
|
53
52
|
.then((response) => {
|
|
@@ -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
|
+
});
|