@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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AI Zona Inc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,283 @@
1
+ # @aizona/adk
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@aizona/adk.svg)](https://www.npmjs.com/package/@aizona/adk)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@aizona/adk.svg)](https://www.npmjs.com/package/@aizona/adk)
5
+ [![license](https://img.shields.io/npm/l/@aizona/adk.svg)](LICENSE)
6
+ [![node](https://img.shields.io/node/v/@aizona/adk.svg)](https://nodejs.org)
7
+
8
+ **Agent Development Kit** — Build, deploy, and orchestrate AI agents. Zero platform dependencies (only `zod`). ESM + CJS dual publish, full TypeScript.
9
+
10
+ ## Features
11
+
12
+ - **Multi-agent orchestration** — Handoffs (Swarm pattern), parallel runners, team coordination
13
+ - **6 built-in LLM providers** — Anthropic, OpenAI, Google, xAI, Ollama, LMStudio with routing strategies
14
+ - **Guardrails engine** — Content filters, budget limits, PII redaction, consent gating
15
+ - **Skills system** — Define and compose reusable agent behaviors (publishing, research, outreach)
16
+ - **Eval harness** — Structured evaluation framework with scoring and reporting
17
+ - **Streaming** — SSE + WebSocket relay, typed event bus (16 event types)
18
+ - **Memory** — Vector-based semantic memory with pgvector backend and auto-decay
19
+ - **MCP integration** — Connect to Model Context Protocol servers
20
+ - **Realtime / Voice** — Voice conversation support via Anthropic Realtime API
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ npm install @aizona/adk
26
+ # or
27
+ pnpm add @aizona/adk
28
+ # or
29
+ yarn add @aizona/adk
30
+ ```
31
+
32
+ ## CLI
33
+
34
+ ```bash
35
+ npx adk --help
36
+ npx adk init my-agent # scaffold a new project
37
+ npx adk test agent.ts # run guidance
38
+ npx adk deploy agent.ts # deploy to AIZona platform
39
+ ```
40
+
41
+ ## Examples
42
+
43
+ | Example | Description |
44
+ |---------|-------------|
45
+ | [hello-world](./examples/hello-world/) | Minimal agent — no tools |
46
+ | [web-scraper](./examples/web-scraper/) | Agent with a `fetch_url` tool |
47
+ | [email-assistant](./examples/email-assistant/) | Agent with a structured draft tool |
48
+
49
+ ## Quick Start
50
+
51
+ ```typescript
52
+ import { defineAgent, defineTool, Runner, createProvider } from "@aizona/adk";
53
+
54
+ const calculator = defineTool({
55
+ name: "add",
56
+ description: "Add two numbers",
57
+ inputSchema: { type: "object", properties: { a: { type: "number" }, b: { type: "number" } } },
58
+ execute: async (input) => ({ result: input.a + input.b }),
59
+ });
60
+
61
+ const agent = defineAgent({
62
+ name: "math-agent",
63
+ instructions: "You are a helpful math assistant.",
64
+ tools: [calculator],
65
+ });
66
+
67
+ const provider = createProvider({ providerId: "anthropic", apiKey: process.env.ANTHROPIC_API_KEY });
68
+ const runner = new Runner({ provider });
69
+ const result = await runner.run(agent, { input: "What is 2 + 3?" });
70
+ console.log(result.output); // "The answer is 5."
71
+ ```
72
+
73
+ ## Core APIs
74
+
75
+ ### `defineAgent(config)`
76
+
77
+ Creates an agent with instructions, tools, guardrails, and handoffs.
78
+
79
+ ```typescript
80
+ const agent = defineAgent({
81
+ name: "my-agent",
82
+ instructions: "You are a helpful assistant.", // string or (ctx) => string
83
+ description: "Short description for discovery",
84
+ tools: [myTool],
85
+ guardrails: [contentFilter()],
86
+ handoffs: [{ agent: otherAgent, description: "Hand off for specialized tasks" }],
87
+ outputSchema: z.object({ answer: z.string() }), // structured output
88
+ consentLevel: "auto", // auto | notify | explicit | multi_party
89
+ maxTurns: 25,
90
+ });
91
+ ```
92
+
93
+ ### `defineTool(config)`
94
+
95
+ Creates a tool with input validation and execution hooks.
96
+
97
+ ```typescript
98
+ const tool = defineTool({
99
+ name: "search",
100
+ description: "Search the web",
101
+ inputSchema: z.object({ query: z.string() }),
102
+ execute: async (input, ctx) => {
103
+ return { results: await search(input.query) };
104
+ },
105
+ hooks: {
106
+ preExecute: async (input) => input, // modify or block
107
+ postExecute: async (output) => output, // transform result
108
+ },
109
+ });
110
+ ```
111
+
112
+ ### `Runner`
113
+
114
+ Main execution engine. Runs agents through a turn loop: build messages → LLM call → tool execution → guardrails → handoff → repeat.
115
+
116
+ ```typescript
117
+ const runner = new Runner({ provider, eventBus, defaultMaxTurns: 25 });
118
+
119
+ // Synchronous run
120
+ const result = await runner.run(agent, {
121
+ input: "Hello",
122
+ messages: [], // prior conversation
123
+ sessionId: "session-123",
124
+ maxTurns: 10,
125
+ signal: abortController.signal,
126
+ });
127
+
128
+ // Streaming run — yields events as they happen
129
+ for await (const event of runner.stream(agent, { input: "Hello" })) {
130
+ switch (event.type) {
131
+ case "turn_started": break;
132
+ case "text_delta": process.stdout.write(event.content); break;
133
+ case "tool_result": break;
134
+ case "handoff": break;
135
+ case "run_complete": console.log(event.result); break;
136
+ }
137
+ }
138
+ ```
139
+
140
+ ### Guardrails
141
+
142
+ Input, output, and tool-level guardrails with tripwire support.
143
+
144
+ ```typescript
145
+ import { contentFilter, budgetLimit, consentGate } from "@aizona/adk";
146
+
147
+ const agent = defineAgent({
148
+ name: "safe-agent",
149
+ instructions: "...",
150
+ guardrails: [
151
+ contentFilter({ blockedTerms: ["harmful"] }),
152
+ budgetLimit({ maxCostUsd: 1.0 }),
153
+ consentGate({ level: "explicit" }),
154
+ ],
155
+ });
156
+ ```
157
+
158
+ ### Multi-Agent
159
+
160
+ Handoffs (Swarm pattern), parallel execution, and team orchestration.
161
+
162
+ ```typescript
163
+ import { ParallelRunner, Team, agentAsTool } from "@aizona/adk";
164
+
165
+ // Route to specialists via handoffs
166
+ const router = defineAgent({
167
+ name: "router",
168
+ instructions: "Route to specialists",
169
+ handoffs: [
170
+ { agent: codeAgent, description: "For code questions" },
171
+ { agent: mathAgent, description: "For math questions" },
172
+ ],
173
+ });
174
+
175
+ // Parallel execution
176
+ const parallel = new ParallelRunner();
177
+ const results = await parallel.run([agent1, agent2], { input: "Analyze this" });
178
+
179
+ // Agent as tool
180
+ const researchTool = agentAsTool(researchAgent, "Research a topic deeply");
181
+ ```
182
+
183
+ ### LLM Providers
184
+
185
+ 6 built-in providers with routing strategies.
186
+
187
+ ```typescript
188
+ import { createProvider, ADKRouter } from "@aizona/adk";
189
+
190
+ const anthropic = createProvider({ providerId: "anthropic", apiKey: "sk-ant-..." });
191
+ const openai = createProvider({ providerId: "openai", apiKey: "sk-..." });
192
+
193
+ const router = new ADKRouter({
194
+ providers: [anthropic, openai],
195
+ strategy: "balanced", // cost-optimized | latency-optimized | quality-optimized | balanced | fallback-chain
196
+ });
197
+ ```
198
+
199
+ ### Skills
200
+
201
+ Define and compose reusable agent behaviors.
202
+
203
+ ```typescript
204
+ import { defineSkill } from "@aizona/adk";
205
+
206
+ const summarizeSkill = defineSkill({
207
+ name: "summarize",
208
+ description: "Summarize a document",
209
+ execute: async (input, ctx) => {
210
+ const result = await ctx.runner.run(summarizerAgent, { input: input.text });
211
+ return { summary: result.output };
212
+ },
213
+ });
214
+ ```
215
+
216
+ ### Memory
217
+
218
+ Vector-based semantic memory with auto-decay.
219
+
220
+ ```typescript
221
+ import { MemoryManager, EmbeddingService, PgVectorMemoryBackend } from "@aizona/adk";
222
+
223
+ const memory = new MemoryManager({
224
+ backend: new PgVectorMemoryBackend(dbClient),
225
+ embeddings: new EmbeddingService({ provider: anthropic }),
226
+ });
227
+
228
+ await memory.storeMemory({ content: "User prefers TypeScript", type: "fact" });
229
+ const results = await memory.searchMemories("programming language preference");
230
+ ```
231
+
232
+ ### Eval Harness
233
+
234
+ Structured evaluation framework.
235
+
236
+ ```typescript
237
+ import { EvalHarness } from "@aizona/adk";
238
+
239
+ const harness = new EvalHarness({ runner, provider });
240
+ const report = await harness.evaluate(agent, testCases);
241
+ console.log(report.passRate, report.avgScore);
242
+ ```
243
+
244
+ ### Event Bus
245
+
246
+ Typed event system for real-time observability (16 event types).
247
+
248
+ ```typescript
249
+ import { ADKEventBus } from "@aizona/adk";
250
+
251
+ const bus = new ADKEventBus();
252
+ bus.on("run.started", (data) => console.log("Run started:", data.runId));
253
+ bus.on("tool.invoked", (data) => console.log("Tool:", data.toolName));
254
+ ```
255
+
256
+ ### MCP Integration
257
+
258
+ Connect to Model Context Protocol servers.
259
+
260
+ ```typescript
261
+ import { mcpServerTools } from "@aizona/adk";
262
+
263
+ const tools = await mcpServerTools({ serverUrl: "http://localhost:3000" });
264
+ const agent = defineAgent({ name: "mcp-agent", tools });
265
+ ```
266
+
267
+ ## Architecture
268
+
269
+ - **Turn Loop** — messages → LLM call → tool execution → guardrails → handoff check → repeat
270
+ - **Standalone** — Zero platform dependencies; works with any supported LLM provider
271
+ - **Type-Safe** — Full TypeScript with Zod validation on all boundaries
272
+ - **Composable** — Tools, guardrails, handoffs, and skills mix-and-match freely
273
+ - **Observable** — Structured event bus, distributed tracing, and streaming out of the box
274
+
275
+ ## Documentation
276
+
277
+ Full documentation and guides: [github.com/ai-zona/AIZona](https://github.com/ai-zona/AIZona)
278
+
279
+ Bug reports and feature requests: [github.com/ai-zona/AIZona/issues](https://github.com/ai-zona/AIZona/issues)
280
+
281
+ ## License
282
+
283
+ MIT — see [LICENSE](LICENSE) for details.
@@ -0,0 +1,179 @@
1
+ #!/usr/bin/env node
2
+
3
+ // bin/adk-cli.ts
4
+ var VERSION = "0.1.0";
5
+ var args = process.argv.slice(2);
6
+ var command = args[0];
7
+ function printHelp() {
8
+ process.stdout.write(`
9
+ adk \u2014 AIZona Agent Development Kit v${VERSION}
10
+
11
+ Usage:
12
+ adk <command> [options]
13
+
14
+ Commands:
15
+ init [name] Scaffold a new ADK project (default: my-agent)
16
+ test <file> Show guidance for running an agent test file
17
+ deploy <file> Deploy an agent to AIZona platform
18
+
19
+ Options:
20
+ --help, -h Show this help message
21
+ --version, -v Print version
22
+
23
+ Examples:
24
+ adk init my-agent
25
+ adk test ./src/agent.ts
26
+ adk deploy ./src/agent.ts
27
+
28
+ Docs: https://github.com/ai-zona/AIZona/tree/main/packages/adk
29
+ `);
30
+ }
31
+ async function cmdInit(name = "my-agent") {
32
+ const { mkdir, writeFile } = await import("fs/promises");
33
+ const { join, resolve } = await import("path");
34
+ const root = resolve(process.cwd(), name);
35
+ await mkdir(join(root, "src"), { recursive: true });
36
+ await writeFile(
37
+ join(root, "src", "agent.ts"),
38
+ `import { defineAgent, Runner, AnthropicProvider } from "@aizonaai/adk";
39
+
40
+ const agent = defineAgent({
41
+ name: "${name}",
42
+ instructions: "You are a helpful assistant.",
43
+ model: "claude-haiku-4-5-20251001",
44
+ });
45
+
46
+ const runner = new Runner({
47
+ provider: new AnthropicProvider({ apiKey: process.env.ANTHROPIC_API_KEY! }),
48
+ });
49
+
50
+ const result = await runner.run(agent, {
51
+ input: process.argv[2] ?? "Hello! What can you do?",
52
+ });
53
+
54
+ console.log(result.output);
55
+ `
56
+ );
57
+ await writeFile(
58
+ join(root, "package.json"),
59
+ JSON.stringify(
60
+ {
61
+ name,
62
+ version: "0.1.0",
63
+ type: "module",
64
+ scripts: {
65
+ start: "tsx src/agent.ts",
66
+ typecheck: "tsc --noEmit"
67
+ },
68
+ dependencies: {
69
+ "@aizonaai/adk": "latest",
70
+ zod: "^3.24.1"
71
+ },
72
+ devDependencies: {
73
+ tsx: "^4.0.0",
74
+ typescript: "^5.7.3",
75
+ "@types/node": "^20.0.0"
76
+ }
77
+ },
78
+ null,
79
+ 2
80
+ )
81
+ );
82
+ await writeFile(
83
+ join(root, "tsconfig.json"),
84
+ JSON.stringify(
85
+ {
86
+ compilerOptions: {
87
+ target: "ES2022",
88
+ module: "NodeNext",
89
+ moduleResolution: "NodeNext",
90
+ strict: true,
91
+ outDir: "./dist",
92
+ rootDir: "./src"
93
+ },
94
+ include: ["src"]
95
+ },
96
+ null,
97
+ 2
98
+ )
99
+ );
100
+ await writeFile(join(root, ".env.example"), "ANTHROPIC_API_KEY=your_key_here\n");
101
+ await writeFile(join(root, ".gitignore"), "node_modules/\ndist/\n.env\n");
102
+ await writeFile(
103
+ join(root, "README.md"),
104
+ `# ${name}
105
+
106
+ An AI agent built with the [AIZona ADK](https://github.com/ai-zona/AIZona).
107
+
108
+ ## Setup
109
+
110
+ \`\`\`bash
111
+ pnpm install
112
+ cp .env.example .env # fill in your ANTHROPIC_API_KEY
113
+ pnpm start "Hello!"
114
+ \`\`\`
115
+ `
116
+ );
117
+ console.log(`Created ADK project at ./${name}/`);
118
+ console.log(` src/agent.ts \u2014 your agent`);
119
+ console.log(` package.json \u2014 dependencies`);
120
+ console.log();
121
+ console.log("Next steps:");
122
+ console.log(` cd ${name}`);
123
+ console.log(" pnpm install");
124
+ console.log(" cp .env.example .env # add ANTHROPIC_API_KEY");
125
+ console.log(` pnpm start "Hello!"`);
126
+ }
127
+ async function cmdTest(file) {
128
+ if (!file) {
129
+ process.stderr.write("Error: file argument required\n Usage: adk test <file>\n");
130
+ process.exit(1);
131
+ }
132
+ console.log("Run your agent file directly:");
133
+ console.log(` npx tsx ${file}`);
134
+ console.log();
135
+ console.log("Run automated tests with vitest:");
136
+ console.log(" npx vitest run");
137
+ console.log();
138
+ console.log("Run the eval harness:");
139
+ console.log(" import { defineEvalSuite, runEval } from '@aizonaai/adk'");
140
+ }
141
+ async function cmdDeploy(file) {
142
+ if (!file) {
143
+ process.stderr.write("Error: file argument required\n Usage: adk deploy <file>\n");
144
+ process.exit(1);
145
+ }
146
+ console.log("Platform deploy is coming soon.");
147
+ console.log("See https://github.com/ai-zona/AIZona for current deployment options.");
148
+ }
149
+ async function main() {
150
+ if (!command || command === "--help" || command === "-h") {
151
+ printHelp();
152
+ return;
153
+ }
154
+ if (command === "--version" || command === "-v" || command === "version") {
155
+ console.log(`adk v${VERSION}`);
156
+ return;
157
+ }
158
+ switch (command) {
159
+ case "init":
160
+ await cmdInit(args[1]);
161
+ break;
162
+ case "test":
163
+ await cmdTest(args[1]);
164
+ break;
165
+ case "deploy":
166
+ await cmdDeploy(args[1]);
167
+ break;
168
+ default:
169
+ process.stderr.write(`Unknown command: ${command}
170
+ Run "adk --help" for usage.
171
+ `);
172
+ process.exit(1);
173
+ }
174
+ }
175
+ main().catch((err) => {
176
+ process.stderr.write(`${err instanceof Error ? err.message : String(err)}
177
+ `);
178
+ process.exit(1);
179
+ });