@aizonaai/adk 0.1.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 +21 -0
- package/README.md +283 -0
- package/dist/bin/adk-cli.js +179 -0
- package/dist/index.cjs +8084 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +3198 -0
- package/dist/index.d.ts +3198 -0
- package/dist/index.js +7932 -0
- package/dist/index.js.map +1 -0
- package/examples/email-assistant/README.md +39 -0
- package/examples/email-assistant/index.ts +71 -0
- package/examples/hello-world/README.md +25 -0
- package/examples/hello-world/index.ts +31 -0
- package/examples/web-scraper/README.md +36 -0
- package/examples/web-scraper/index.ts +54 -0
- package/package.json +65 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Email Assistant
|
|
2
|
+
|
|
3
|
+
An agent that drafts emails using a structured tool with Zod validation.
|
|
4
|
+
|
|
5
|
+
## Run
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
ANTHROPIC_API_KEY=<your-key> npx tsx index.ts \
|
|
9
|
+
"Draft a follow-up to sarah@example.com about last week's Q3 review"
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## What it does
|
|
13
|
+
|
|
14
|
+
- Defines a `draft_email` tool with a rich Zod schema (email, enum, defaults)
|
|
15
|
+
- The agent parses the user's natural language request and calls the tool
|
|
16
|
+
- In a real app, the tool would call SendGrid / Gmail API / Nodemailer
|
|
17
|
+
|
|
18
|
+
## Key APIs
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
defineTool({
|
|
22
|
+
name: "draft_email",
|
|
23
|
+
inputSchema: z.object({
|
|
24
|
+
to: z.string().email(),
|
|
25
|
+
subject: z.string(),
|
|
26
|
+
body: z.string(),
|
|
27
|
+
tone: z.enum(["professional", "friendly", "formal"]).default("professional"),
|
|
28
|
+
}),
|
|
29
|
+
execute: async ({ to, subject, body, tone }) => { /* send or save */ },
|
|
30
|
+
})
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Extend it
|
|
34
|
+
|
|
35
|
+
- Add a `send_email` tool that actually delivers via your email provider
|
|
36
|
+
- Wire up Gmail API with OAuth using the ADK `ProxyRouter`
|
|
37
|
+
- Add a guardrail to require explicit confirmation before sending
|
|
38
|
+
|
|
39
|
+
See the [ADK README](../../README.md) for the full API reference.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Email Assistant — agent with a structured draft tool
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates:
|
|
5
|
+
* - defineTool() with rich Zod schema (enum, default, email validation)
|
|
6
|
+
* - Side-effectful tool (in a real app, this would call your email API)
|
|
7
|
+
* - Agent instructions that guide multi-step behaviour
|
|
8
|
+
*
|
|
9
|
+
* Run:
|
|
10
|
+
* ANTHROPIC_API_KEY=<key> npx tsx index.ts \
|
|
11
|
+
* "Draft a follow-up to sarah@example.com about last week's Q3 review"
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
import { AnthropicProvider, Runner, defineAgent, defineTool } from "@aizonaai/adk";
|
|
16
|
+
|
|
17
|
+
const draftEmailTool = defineTool({
|
|
18
|
+
name: "draft_email",
|
|
19
|
+
description: "Create an email draft with the specified recipient, subject, and body",
|
|
20
|
+
inputSchema: z.object({
|
|
21
|
+
to: z.string().email().describe("Recipient email address"),
|
|
22
|
+
subject: z.string().describe("Email subject line (concise, under 60 chars)"),
|
|
23
|
+
body: z.string().describe("Full email body text"),
|
|
24
|
+
tone: z
|
|
25
|
+
.enum(["professional", "friendly", "formal"])
|
|
26
|
+
.default("professional")
|
|
27
|
+
.describe("Writing tone"),
|
|
28
|
+
}),
|
|
29
|
+
execute: async ({ to, subject, body, tone }) => {
|
|
30
|
+
// In a real app: call SendGrid, Nodemailer, Gmail API, etc.
|
|
31
|
+
console.log("\n─── EMAIL DRAFT ───────────────────────────────");
|
|
32
|
+
console.log(`To: ${to}`);
|
|
33
|
+
console.log(`Subject: ${subject}`);
|
|
34
|
+
console.log(`Tone: ${tone}`);
|
|
35
|
+
console.log();
|
|
36
|
+
console.log(body);
|
|
37
|
+
console.log("───────────────────────────────────────────────\n");
|
|
38
|
+
return {
|
|
39
|
+
success: true,
|
|
40
|
+
draftId: `draft_${Date.now()}`,
|
|
41
|
+
message: `Draft saved for ${to}`,
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const agent = defineAgent({
|
|
47
|
+
name: "email-assistant",
|
|
48
|
+
instructions: `You are an expert email writing assistant.
|
|
49
|
+
|
|
50
|
+
When asked to write or draft an email:
|
|
51
|
+
1. Identify the recipient, subject, and purpose from the user's request
|
|
52
|
+
2. Choose an appropriate tone (professional by default)
|
|
53
|
+
3. Call draft_email to create the draft
|
|
54
|
+
4. Confirm what you drafted and offer to adjust tone or content
|
|
55
|
+
|
|
56
|
+
Write clear, concise emails. Avoid filler phrases like "I hope this email finds you well."`,
|
|
57
|
+
model: "claude-haiku-4-5-20251001",
|
|
58
|
+
tools: [draftEmailTool],
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const runner = new Runner({
|
|
62
|
+
provider: new AnthropicProvider({ apiKey: process.env.ANTHROPIC_API_KEY! }),
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const result = await runner.run(agent, {
|
|
66
|
+
input:
|
|
67
|
+
process.argv[2] ??
|
|
68
|
+
"Draft a professional follow-up email to sarah@acmecorp.com about the Q3 budget review meeting we had last week.",
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
console.log(result.output);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Hello World
|
|
2
|
+
|
|
3
|
+
The simplest possible ADK agent — one file, no tools, no config.
|
|
4
|
+
|
|
5
|
+
## Run
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
ANTHROPIC_API_KEY=<your-key> npx tsx index.ts "Hello!"
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## What it does
|
|
12
|
+
|
|
13
|
+
- Creates an agent with a name, instructions, and a model
|
|
14
|
+
- Runs it with the `Runner` and prints the response
|
|
15
|
+
- Shows token usage and cost per run
|
|
16
|
+
|
|
17
|
+
## Key APIs
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
defineAgent({ name, instructions, model })
|
|
21
|
+
new Runner({ provider })
|
|
22
|
+
runner.run(agent, { input: "..." }) → RunResult
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
See the [ADK README](../../README.md) for the full API reference.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hello World — minimal ADK agent
|
|
3
|
+
*
|
|
4
|
+
* The simplest possible agent: a name, instructions, and a model.
|
|
5
|
+
* No tools, no sessions, no multi-agent routing — just a direct chat.
|
|
6
|
+
*
|
|
7
|
+
* Run:
|
|
8
|
+
* ANTHROPIC_API_KEY=<key> npx tsx index.ts "Hello!"
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { AnthropicProvider, Runner, defineAgent } from "@aizonaai/adk";
|
|
12
|
+
|
|
13
|
+
const agent = defineAgent({
|
|
14
|
+
name: "hello-world",
|
|
15
|
+
instructions:
|
|
16
|
+
"You are a friendly assistant. Greet users warmly and answer their questions concisely.",
|
|
17
|
+
model: "claude-haiku-4-5-20251001",
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const runner = new Runner({
|
|
21
|
+
provider: new AnthropicProvider({ apiKey: process.env.ANTHROPIC_API_KEY! }),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const result = await runner.run(agent, {
|
|
25
|
+
input: process.argv[2] ?? "Hello! What can you do?",
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
console.log(result.output);
|
|
29
|
+
console.log(
|
|
30
|
+
`\n[${result.usage.totalCostUsd.toFixed(6)} USD | ${result.usage.inputTokens + result.usage.outputTokens} tokens]`,
|
|
31
|
+
);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Web Scraper
|
|
2
|
+
|
|
3
|
+
An agent that fetches and summarizes web content using a custom tool.
|
|
4
|
+
|
|
5
|
+
## Run
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
ANTHROPIC_API_KEY=<your-key> npx tsx index.ts "Summarize https://example.com"
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## What it does
|
|
12
|
+
|
|
13
|
+
- Defines a `fetch_url` tool with Zod input schema validation
|
|
14
|
+
- The agent decides when to call the tool based on the user's request
|
|
15
|
+
- Strips HTML and truncates to fit within the context window
|
|
16
|
+
|
|
17
|
+
## Key APIs
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
defineTool({
|
|
21
|
+
name: "fetch_url",
|
|
22
|
+
description: "...",
|
|
23
|
+
inputSchema: z.object({ url: z.string().url() }),
|
|
24
|
+
execute: async ({ url }) => { /* ... */ return string },
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
defineAgent({ name, instructions, tools: [fetchUrlTool] })
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Extend it
|
|
31
|
+
|
|
32
|
+
- Add authentication headers for paywalled sites
|
|
33
|
+
- Parse structured data (JSON-LD, Open Graph) instead of stripping HTML
|
|
34
|
+
- Chain with another agent to generate a report from multiple URLs
|
|
35
|
+
|
|
36
|
+
See the [ADK README](../../README.md) for the full API reference.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web Scraper — agent with a custom fetch tool
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates:
|
|
5
|
+
* - defineTool() with Zod input schema
|
|
6
|
+
* - Tool execution with error handling
|
|
7
|
+
* - Agent with tool access
|
|
8
|
+
*
|
|
9
|
+
* Run:
|
|
10
|
+
* ANTHROPIC_API_KEY=<key> npx tsx index.ts "Summarize https://example.com"
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
import { AnthropicProvider, Runner, defineAgent, defineTool } from "@aizonaai/adk";
|
|
15
|
+
|
|
16
|
+
const fetchUrlTool = defineTool({
|
|
17
|
+
name: "fetch_url",
|
|
18
|
+
description: "Fetch the text content of a URL and return it as plain text",
|
|
19
|
+
inputSchema: z.object({
|
|
20
|
+
url: z.string().url().describe("The full URL to fetch"),
|
|
21
|
+
}),
|
|
22
|
+
execute: async ({ url }) => {
|
|
23
|
+
const res = await fetch(url, {
|
|
24
|
+
headers: { "User-Agent": "Mozilla/5.0 (compatible; ADK-Example/1.0)" },
|
|
25
|
+
signal: AbortSignal.timeout(10_000),
|
|
26
|
+
});
|
|
27
|
+
if (!res.ok) throw new Error(`HTTP ${res.status} ${res.statusText}`);
|
|
28
|
+
const html = await res.text();
|
|
29
|
+
// Strip tags and collapse whitespace — good enough for demo purposes
|
|
30
|
+
const text = html.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
|
|
31
|
+
return text.slice(0, 8_000);
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const agent = defineAgent({
|
|
36
|
+
name: "web-scraper",
|
|
37
|
+
instructions: `You are a web research assistant.
|
|
38
|
+
Use the fetch_url tool to retrieve content from URLs the user provides.
|
|
39
|
+
After fetching, extract and summarize the key information they asked for.
|
|
40
|
+
If a fetch fails, report the error and suggest alternatives.`,
|
|
41
|
+
model: "claude-haiku-4-5-20251001",
|
|
42
|
+
tools: [fetchUrlTool],
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const runner = new Runner({
|
|
46
|
+
provider: new AnthropicProvider({ apiKey: process.env.ANTHROPIC_API_KEY! }),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const result = await runner.run(agent, {
|
|
50
|
+
input:
|
|
51
|
+
process.argv[2] ?? "Fetch https://example.com and summarize what the page is about.",
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
console.log(result.output);
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aizonaai/adk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "AIZona Agent Development Kit \u2014 Build, deploy, and orchestrate AI agents",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"bin": {
|
|
17
|
+
"adk": "./dist/bin/adk-cli.js"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"examples",
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsup",
|
|
27
|
+
"build:tsc": "tsc",
|
|
28
|
+
"typecheck": "tsc --noEmit",
|
|
29
|
+
"test": "vitest run",
|
|
30
|
+
"test:watch": "vitest",
|
|
31
|
+
"prepublishOnly": "pnpm build"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"zod": "^3.24.1"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/node": "^20.0.0",
|
|
38
|
+
"tsup": "^8.5.1",
|
|
39
|
+
"typescript": "^5.7.3",
|
|
40
|
+
"vitest": "^4.0.18"
|
|
41
|
+
},
|
|
42
|
+
"keywords": [
|
|
43
|
+
"ai",
|
|
44
|
+
"agents",
|
|
45
|
+
"adk",
|
|
46
|
+
"aizona",
|
|
47
|
+
"agent-development-kit"
|
|
48
|
+
],
|
|
49
|
+
"license": "MIT",
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=18"
|
|
52
|
+
},
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"access": "public"
|
|
55
|
+
},
|
|
56
|
+
"repository": {
|
|
57
|
+
"type": "git",
|
|
58
|
+
"url": "https://github.com/ai-zona/adk",
|
|
59
|
+
"directory": "packages/adk"
|
|
60
|
+
},
|
|
61
|
+
"homepage": "https://github.com/ai-zona/AIZona#readme",
|
|
62
|
+
"bugs": {
|
|
63
|
+
"url": "https://github.com/ai-zona/AIZona/issues"
|
|
64
|
+
}
|
|
65
|
+
}
|