create-adk-agent 0.0.2 → 0.0.5

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.
Files changed (37) hide show
  1. package/README.md +10 -1
  2. package/bin/create-adk-agent.js +361 -35
  3. package/dist/generators/init/files/.env.example.template +16 -0
  4. package/dist/generators/init/files/.eslintrc.json.template +20 -0
  5. package/dist/generators/init/files/.gitignore.template +27 -0
  6. package/dist/generators/init/files/.prettierrc.template +7 -0
  7. package/dist/generators/init/files/README.md.template +243 -0
  8. package/dist/generators/init/files/jest.config.ts.template +7 -0
  9. package/dist/generators/init/files/package.json.template +41 -0
  10. package/dist/generators/init/files/src/agents/basic/agent.ts.template +34 -0
  11. package/dist/generators/init/files/src/agents/multi-tool/agent.ts.template +83 -0
  12. package/dist/generators/init/files/src/agents/streaming/agent.ts.template +36 -0
  13. package/dist/generators/init/files/src/agents/team/farewell-agent.ts.template +43 -0
  14. package/dist/generators/init/files/src/agents/team/greeting-agent.ts.template +43 -0
  15. package/dist/generators/init/files/src/agents/team/root-agent.ts.template +18 -0
  16. package/dist/generators/init/files/src/agents/workflow/agent.ts.template +69 -0
  17. package/dist/generators/init/files/src/index.ts.template +61 -0
  18. package/dist/generators/init/files/tests/agents.test.ts.template +80 -0
  19. package/dist/generators/init/files/tsconfig.json.template +20 -0
  20. package/dist/generators/init/files/vite.config.ts.template +36 -0
  21. package/dist/generators/init/generator.js +3 -0
  22. package/dist/generators/init/generator.js.map +1 -1
  23. package/dist/generators/init/schema.json +124 -0
  24. package/package.json +20 -4
  25. package/src/generators/init/files/README.md.template +3 -2
  26. package/src/generators/init/files/package.json.template +8 -6
  27. package/src/generators/init/files/vite.config.ts.template +36 -0
  28. package/templates/basic/.env.example +16 -0
  29. package/templates/basic/.eslintrc.json +13 -0
  30. package/templates/basic/.prettierrc +5 -0
  31. package/templates/basic/README.md +155 -0
  32. package/templates/basic/_gitignore +8 -0
  33. package/templates/basic/jest.config.ts +8 -0
  34. package/templates/basic/package.json +41 -0
  35. package/templates/basic/src/index.ts +60 -0
  36. package/templates/basic/tests/agents.test.ts +19 -0
  37. package/templates/basic/tsconfig.json +21 -0
@@ -0,0 +1,155 @@
1
+ # __PROJECT_NAME__
2
+
3
+ __DESCRIPTION__
4
+
5
+ ## Features
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
20
+
21
+ ### 1. Install Dependencies
22
+
23
+ ```bash
24
+ npm install
25
+ ```
26
+
27
+ ### 2. Configure Environment
28
+
29
+ Copy `.env.example` to `.env` and add your API key:
30
+
31
+ ```bash
32
+ cp .env.example .env
33
+ ```
34
+
35
+ Edit `.env` and add your API key:
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
49
+
50
+ ```bash
51
+ npm run dev
52
+ ```
53
+
54
+ This starts the agent with hot reload - any code changes will automatically restart the agent.
55
+
56
+ ### 4. Run in Production Mode
57
+
58
+ ```bash
59
+ npm run build
60
+ npm run prod
61
+ ```
62
+
63
+ ## Project Structure
64
+
65
+ ```
66
+ src/
67
+ ├── index.ts # Main entry point with agent configuration
68
+ └── tools/ # Custom tools for the agent
69
+ tests/
70
+ └── agents.test.ts # Agent tests
71
+ ```
72
+
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
+ ## Learn More
149
+
150
+ - [ADK Documentation](https://google.github.io/adk-docs/)
151
+ - [ADK GitHub](https://github.com/google/adk)
152
+
153
+ ## License
154
+
155
+ MIT
@@ -0,0 +1,8 @@
1
+ node_modules
2
+ dist
3
+ .env
4
+ .env.local
5
+ *.log
6
+ .DS_Store
7
+ coverage
8
+ .adk
@@ -0,0 +1,8 @@
1
+ export default {
2
+ preset: 'ts-jest/presets/default-esm',
3
+ testEnvironment: 'node',
4
+ extensionsToTreatAsEsm: ['.ts'],
5
+ moduleNameMapper: {
6
+ '^(\\.{1,2}/.*)\\.js$': '$1',
7
+ },
8
+ };
@@ -0,0 +1,41 @@
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
+ },
17
+ "keywords": [
18
+ "adk",
19
+ "agent",
20
+ "ai",
21
+ "llm"
22
+ ],
23
+ "license": "MIT",
24
+ "dependencies": {
25
+ "@google/adk": "^0.2.0",
26
+ "@google/adk-devtools": "^0.2.0",
27
+ "dotenv": "^16.4.0",
28
+ "zod": "^3.23.0"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "^20.10.0",
32
+ "@typescript-eslint/eslint-plugin": "^7.0.0",
33
+ "@typescript-eslint/parser": "^7.0.0",
34
+ "eslint": "^8.56.0",
35
+ "jest": "^29.7.0",
36
+ "prettier": "^3.2.0",
37
+ "ts-jest": "^29.1.0",
38
+ "tsx": "^4.7.0",
39
+ "typescript": "^5.9.3"
40
+ }
41
+ }
@@ -0,0 +1,60 @@
1
+ import 'dotenv/config';
2
+ import { LlmAgent, FunctionTool } from '@google/adk';
3
+ import { z } from 'zod';
4
+
5
+ // Validate environment variables
6
+ if (!process.env.GEMINI_API_KEY && !process.env.OPENAI_API_KEY && !process.env.ANTHROPIC_API_KEY) {
7
+ console.error('❌ Error: No API key found!');
8
+ console.error('Please set one of the following in your .env file:');
9
+ console.error(' - GEMINI_API_KEY (for Google Gemini)');
10
+ console.error(' - OPENAI_API_KEY (for OpenAI)');
11
+ console.error(' - ANTHROPIC_API_KEY (for Anthropic/Claude)');
12
+ process.exit(1);
13
+ }
14
+
15
+ // Tool to get current time
16
+ const getCurrentTime = new FunctionTool({
17
+ name: 'get_current_time',
18
+ description: 'Returns the current time in the specified timezone.',
19
+ parameters: z.object({
20
+ timezone: z
21
+ .string()
22
+ .optional()
23
+ .describe('The timezone to use (e.g., "America/New_York", "Europe/London")'),
24
+ }),
25
+ execute: ({ timezone = 'UTC' }) => {
26
+ const now = new Date();
27
+ const timeString = now.toLocaleString('en-US', { timeZone: timezone });
28
+ return {
29
+ status: 'success',
30
+ report: `The current time in ${timezone} is ${timeString}`,
31
+ };
32
+ },
33
+ });
34
+
35
+ // Create the agent
36
+ export const rootAgent = new LlmAgent({
37
+ name: 'hello_time_agent',
38
+ model: __MODEL_CONFIG__,
39
+ description: 'An agent that can tell you the current time in any timezone.',
40
+ instruction: `You are a friendly time-telling assistant. When asked about the time,
41
+ use the get_current_time tool to provide the current time in the requested timezone.
42
+ If no timezone is specified, use UTC as the default.`,
43
+ tools: [getCurrentTime],
44
+ });
45
+
46
+ // Run the agent (for direct execution)
47
+ if (import.meta.url === `file://${process.argv[1]}`) {
48
+ console.log('🤖 Hello Time Agent is ready!');
49
+ console.log('Ask me about the time in any timezone.\n');
50
+
51
+ rootAgent
52
+ .query('What time is it in Tokyo?')
53
+ .then((response) => {
54
+ console.log('Agent response:', response);
55
+ })
56
+ .catch((error) => {
57
+ console.error('Error:', error);
58
+ process.exit(1);
59
+ });
60
+ }
@@ -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
+ }