@avee1234/agent-kit 0.1.0 → 0.3.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/README.md +77 -9
- package/dist/cli.cjs +100 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +77 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +391 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +72 -10
- package/dist/index.d.ts +72 -10
- package/dist/index.js +389 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
# agent-kit
|
|
2
2
|
|
|
3
|
+
[](https://github.com/abhid1234/agent-kit/actions/workflows/ci.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/@avee1234/agent-kit)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
3
7
|
TypeScript-first library for building stateful, persistent AI agents.
|
|
4
8
|
|
|
9
|
+
<p align="center">
|
|
10
|
+
<img src="assets/demo.svg" alt="agent-kit demo — memory persists across sessions" width="750" />
|
|
11
|
+
</p>
|
|
12
|
+
|
|
5
13
|
## Why agent-kit?
|
|
6
14
|
|
|
7
15
|
- **Persistent memory across sessions** — SQLite store keeps conversation history and auto-summarizes old exchanges. Restart your process; the agent still remembers.
|
|
@@ -12,13 +20,13 @@ TypeScript-first library for building stateful, persistent AI agents.
|
|
|
12
20
|
## Installation
|
|
13
21
|
|
|
14
22
|
```bash
|
|
15
|
-
npm install agent-kit
|
|
23
|
+
npm install @avee1234/agent-kit
|
|
16
24
|
```
|
|
17
25
|
|
|
18
26
|
## Quick Start
|
|
19
27
|
|
|
20
28
|
```typescript
|
|
21
|
-
import { Agent, Tool, Memory } from 'agent-kit';
|
|
29
|
+
import { Agent, Tool, Memory } from '@avee1234/agent-kit';
|
|
22
30
|
|
|
23
31
|
const echo = Tool.create({
|
|
24
32
|
name: 'echo',
|
|
@@ -67,7 +75,7 @@ Kill the process and restart — memory persists in `research.db`.
|
|
|
67
75
|
The main class. Runs a tool-calling loop, manages memory context, and emits observability events.
|
|
68
76
|
|
|
69
77
|
```typescript
|
|
70
|
-
import { Agent } from 'agent-kit';
|
|
78
|
+
import { Agent } from '@avee1234/agent-kit';
|
|
71
79
|
|
|
72
80
|
const agent = new Agent({
|
|
73
81
|
name: 'assistant',
|
|
@@ -99,7 +107,7 @@ const agent = new Agent({
|
|
|
99
107
|
Wraps a function so the agent can call it.
|
|
100
108
|
|
|
101
109
|
```typescript
|
|
102
|
-
import { Tool } from 'agent-kit';
|
|
110
|
+
import { Tool } from '@avee1234/agent-kit';
|
|
103
111
|
|
|
104
112
|
const getWeather = Tool.create({
|
|
105
113
|
name: 'get_weather',
|
|
@@ -130,7 +138,7 @@ const getWeather = Tool.create({
|
|
|
130
138
|
Manages conversation persistence and context retrieval.
|
|
131
139
|
|
|
132
140
|
```typescript
|
|
133
|
-
import { Memory } from 'agent-kit';
|
|
141
|
+
import { Memory } from '@avee1234/agent-kit';
|
|
134
142
|
|
|
135
143
|
// In-memory (default, testing)
|
|
136
144
|
new Memory()
|
|
@@ -153,6 +161,66 @@ new Memory({ store: myCustomStore })
|
|
|
153
161
|
|
|
154
162
|
Auto-summarization: when `summarizeAfter` messages accumulate, the agent summarizes them and stores the summary. Older context is retrieved via `searchSummaries`.
|
|
155
163
|
|
|
164
|
+
### Team (Multi-Agent Coordination)
|
|
165
|
+
|
|
166
|
+
Coordinate multiple agents on a single task using four strategies.
|
|
167
|
+
|
|
168
|
+
**Sequential** — agents run in order, each getting the previous agent's output:
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
import { Agent, Team } from '@avee1234/agent-kit';
|
|
172
|
+
|
|
173
|
+
const team = new Team({
|
|
174
|
+
agents: [researcher, writer],
|
|
175
|
+
strategy: 'sequential',
|
|
176
|
+
});
|
|
177
|
+
const result = await team.run('Research AI frameworks and write a summary');
|
|
178
|
+
// writer receives researcher's output as context
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**Parallel** — all agents run concurrently, results merged:
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
const team = new Team({
|
|
185
|
+
agents: [researcher, writer, critic],
|
|
186
|
+
strategy: 'parallel',
|
|
187
|
+
});
|
|
188
|
+
const result = await team.run('Analyze this codebase');
|
|
189
|
+
// result.responses has each agent's individual output
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**Debate** — agents take turns critiquing and refining:
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
const team = new Team({
|
|
196
|
+
agents: [proposer, critic],
|
|
197
|
+
strategy: 'debate',
|
|
198
|
+
maxRounds: 3,
|
|
199
|
+
});
|
|
200
|
+
const result = await team.run('What is the best database for embeddings?');
|
|
201
|
+
// 3 rounds of back-and-forth, then final answer
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Hierarchical** — a manager delegates tasks to specialists:
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
const team = new Team({
|
|
208
|
+
agents: [researcher, writer, critic],
|
|
209
|
+
strategy: 'hierarchical',
|
|
210
|
+
manager: new Agent({ name: 'manager', system: 'You coordinate a team of specialists.' }),
|
|
211
|
+
});
|
|
212
|
+
const result = await team.run('Write a blog post about transformer alternatives');
|
|
213
|
+
// manager decides who does what and when
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
| Option | Type | Default | Description |
|
|
217
|
+
|--------|------|---------|-------------|
|
|
218
|
+
| `agents` | `Agent[]` | — | The agents to coordinate |
|
|
219
|
+
| `strategy` | `string` | — | `'sequential'`, `'parallel'`, `'debate'`, or `'hierarchical'` |
|
|
220
|
+
| `manager` | `Agent` | — | Required for hierarchical strategy |
|
|
221
|
+
| `maxRounds` | `number` | `3` | Number of debate rounds |
|
|
222
|
+
| `maxDelegations` | `number` | `10` | Max delegations for hierarchical |
|
|
223
|
+
|
|
156
224
|
## Model Configuration
|
|
157
225
|
|
|
158
226
|
### Mock (zero config, built-in)
|
|
@@ -160,7 +228,7 @@ Auto-summarization: when `summarizeAfter` messages accumulate, the agent summari
|
|
|
160
228
|
If you omit `model`, the agent uses `MockAdapter` — it echoes inputs and simulates tool calls. Useful for testing.
|
|
161
229
|
|
|
162
230
|
```typescript
|
|
163
|
-
import { MockAdapter } from 'agent-kit';
|
|
231
|
+
import { MockAdapter } from '@avee1234/agent-kit';
|
|
164
232
|
|
|
165
233
|
const agent = new Agent({ name: 'test', model: new MockAdapter() });
|
|
166
234
|
```
|
|
@@ -180,7 +248,7 @@ const agent = new Agent({
|
|
|
180
248
|
Works with Together AI, OpenRouter, Anyscale, LM Studio, and any other OpenAI-compatible API.
|
|
181
249
|
|
|
182
250
|
```typescript
|
|
183
|
-
import { OpenAICompatibleAdapter } from 'agent-kit';
|
|
251
|
+
import { OpenAICompatibleAdapter } from '@avee1234/agent-kit';
|
|
184
252
|
|
|
185
253
|
const agent = new Agent({
|
|
186
254
|
name: 'agent',
|
|
@@ -238,8 +306,8 @@ All events include `type`, `timestamp`, and `agentId` fields from `AgentEvent`.
|
|
|
238
306
|
Implement the `MemoryStore` interface to plug in any storage backend (PostgreSQL, Redis, DynamoDB, etc.).
|
|
239
307
|
|
|
240
308
|
```typescript
|
|
241
|
-
import type { MemoryStore } from 'agent-kit';
|
|
242
|
-
import type { Message, Summary } from 'agent-kit';
|
|
309
|
+
import type { MemoryStore } from '@avee1234/agent-kit';
|
|
310
|
+
import type { Message, Summary } from '@avee1234/agent-kit';
|
|
243
311
|
|
|
244
312
|
class MyStore implements MemoryStore {
|
|
245
313
|
async saveMessages(agentId: string, messages: Message[]): Promise<void> {
|
package/dist/cli.cjs
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
|
|
26
|
+
// src/cli.ts
|
|
27
|
+
var import_fs = __toESM(require("fs"), 1);
|
|
28
|
+
var import_path = __toESM(require("path"), 1);
|
|
29
|
+
var args = process.argv.slice(2);
|
|
30
|
+
var command = args[0];
|
|
31
|
+
var projectName = args[1] ?? "my-agent";
|
|
32
|
+
if (command !== "init") {
|
|
33
|
+
console.error(`Unknown command: ${command}`);
|
|
34
|
+
console.error("Usage: agent-kit init [project-name]");
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
var targetDir = import_path.default.resolve(process.cwd(), projectName);
|
|
38
|
+
if (import_fs.default.existsSync(targetDir)) {
|
|
39
|
+
console.error(`Directory already exists: ${targetDir}`);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
import_fs.default.mkdirSync(targetDir, { recursive: true });
|
|
43
|
+
var packageJson = {
|
|
44
|
+
name: projectName,
|
|
45
|
+
version: "1.0.0",
|
|
46
|
+
private: true,
|
|
47
|
+
type: "module",
|
|
48
|
+
scripts: {
|
|
49
|
+
start: "npx tsx agent.ts"
|
|
50
|
+
},
|
|
51
|
+
dependencies: {
|
|
52
|
+
"@avee1234/agent-kit": "^0.2.0"
|
|
53
|
+
},
|
|
54
|
+
devDependencies: {
|
|
55
|
+
tsx: "^4.0.0"
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var agentTs = `import { Agent, Tool, Memory } from '@avee1234/agent-kit';
|
|
59
|
+
|
|
60
|
+
const greet = Tool.create({
|
|
61
|
+
name: 'greet',
|
|
62
|
+
description: 'Greet someone by name',
|
|
63
|
+
parameters: {
|
|
64
|
+
name: { type: 'string', description: 'Name to greet' },
|
|
65
|
+
},
|
|
66
|
+
execute: async ({ name }) => \`Hello, \${name}!\`,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const agent = new Agent({
|
|
70
|
+
name: 'my-agent',
|
|
71
|
+
memory: new Memory({ store: 'sqlite', path: './memory.db' }),
|
|
72
|
+
tools: [greet],
|
|
73
|
+
system: 'You are a helpful assistant.',
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const response = await agent.chat(process.argv[2] ?? 'Hello!');
|
|
77
|
+
console.log(response.content);
|
|
78
|
+
`;
|
|
79
|
+
var readmeMd = `# ${projectName}
|
|
80
|
+
|
|
81
|
+
Built with [agent-kit](https://github.com/abhid1234/agent-kit).
|
|
82
|
+
|
|
83
|
+
## Quick Start
|
|
84
|
+
|
|
85
|
+
\`\`\`bash
|
|
86
|
+
npm install
|
|
87
|
+
npm start "Hello, what can you do?"
|
|
88
|
+
\`\`\`
|
|
89
|
+
`;
|
|
90
|
+
import_fs.default.writeFileSync(import_path.default.join(targetDir, "package.json"), JSON.stringify(packageJson, null, 2) + "\n");
|
|
91
|
+
import_fs.default.writeFileSync(import_path.default.join(targetDir, "agent.ts"), agentTs);
|
|
92
|
+
import_fs.default.writeFileSync(import_path.default.join(targetDir, "README.md"), readmeMd);
|
|
93
|
+
console.log(`
|
|
94
|
+
Scaffolded project: ${projectName}
|
|
95
|
+
`);
|
|
96
|
+
console.log("Next steps:\n");
|
|
97
|
+
console.log(` cd ${projectName}`);
|
|
98
|
+
console.log(" npm install");
|
|
99
|
+
console.log(' npm start "Hello, what can you do?"\n');
|
|
100
|
+
//# sourceMappingURL=cli.cjs.map
|
package/dist/cli.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport fs from 'fs';\nimport path from 'path';\n\nconst args = process.argv.slice(2);\nconst command = args[0];\nconst projectName = args[1] ?? 'my-agent';\n\nif (command !== 'init') {\n console.error(`Unknown command: ${command}`);\n console.error('Usage: agent-kit init [project-name]');\n process.exit(1);\n}\n\nconst targetDir = path.resolve(process.cwd(), projectName);\n\nif (fs.existsSync(targetDir)) {\n console.error(`Directory already exists: ${targetDir}`);\n process.exit(1);\n}\n\nfs.mkdirSync(targetDir, { recursive: true });\n\nconst packageJson = {\n name: projectName,\n version: '1.0.0',\n private: true,\n type: 'module',\n scripts: {\n start: 'npx tsx agent.ts',\n },\n dependencies: {\n '@avee1234/agent-kit': '^0.2.0',\n },\n devDependencies: {\n tsx: '^4.0.0',\n },\n};\n\nconst agentTs = `import { Agent, Tool, Memory } from '@avee1234/agent-kit';\n\nconst greet = Tool.create({\n name: 'greet',\n description: 'Greet someone by name',\n parameters: {\n name: { type: 'string', description: 'Name to greet' },\n },\n execute: async ({ name }) => \\`Hello, \\${name}!\\`,\n});\n\nconst agent = new Agent({\n name: 'my-agent',\n memory: new Memory({ store: 'sqlite', path: './memory.db' }),\n tools: [greet],\n system: 'You are a helpful assistant.',\n});\n\nconst response = await agent.chat(process.argv[2] ?? 'Hello!');\nconsole.log(response.content);\n`;\n\nconst readmeMd = `# ${projectName}\n\nBuilt with [agent-kit](https://github.com/abhid1234/agent-kit).\n\n## Quick Start\n\n\\`\\`\\`bash\nnpm install\nnpm start \"Hello, what can you do?\"\n\\`\\`\\`\n`;\n\nfs.writeFileSync(path.join(targetDir, 'package.json'), JSON.stringify(packageJson, null, 2) + '\\n');\nfs.writeFileSync(path.join(targetDir, 'agent.ts'), agentTs);\nfs.writeFileSync(path.join(targetDir, 'README.md'), readmeMd);\n\nconsole.log(`\\nScaffolded project: ${projectName}\\n`);\nconsole.log('Next steps:\\n');\nconsole.log(` cd ${projectName}`);\nconsole.log(' npm install');\nconsole.log(' npm start \"Hello, what can you do?\"\\n');\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,gBAAe;AACf,kBAAiB;AAEjB,IAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,IAAM,UAAU,KAAK,CAAC;AACtB,IAAM,cAAc,KAAK,CAAC,KAAK;AAE/B,IAAI,YAAY,QAAQ;AACtB,UAAQ,MAAM,oBAAoB,OAAO,EAAE;AAC3C,UAAQ,MAAM,sCAAsC;AACpD,UAAQ,KAAK,CAAC;AAChB;AAEA,IAAM,YAAY,YAAAA,QAAK,QAAQ,QAAQ,IAAI,GAAG,WAAW;AAEzD,IAAI,UAAAC,QAAG,WAAW,SAAS,GAAG;AAC5B,UAAQ,MAAM,6BAA6B,SAAS,EAAE;AACtD,UAAQ,KAAK,CAAC;AAChB;AAEA,UAAAA,QAAG,UAAU,WAAW,EAAE,WAAW,KAAK,CAAC;AAE3C,IAAM,cAAc;AAAA,EAClB,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,IACP,OAAO;AAAA,EACT;AAAA,EACA,cAAc;AAAA,IACZ,uBAAuB;AAAA,EACzB;AAAA,EACA,iBAAiB;AAAA,IACf,KAAK;AAAA,EACP;AACF;AAEA,IAAM,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsBhB,IAAM,WAAW,KAAK,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYjC,UAAAA,QAAG,cAAc,YAAAD,QAAK,KAAK,WAAW,cAAc,GAAG,KAAK,UAAU,aAAa,MAAM,CAAC,IAAI,IAAI;AAClG,UAAAC,QAAG,cAAc,YAAAD,QAAK,KAAK,WAAW,UAAU,GAAG,OAAO;AAC1D,UAAAC,QAAG,cAAc,YAAAD,QAAK,KAAK,WAAW,WAAW,GAAG,QAAQ;AAE5D,QAAQ,IAAI;AAAA,sBAAyB,WAAW;AAAA,CAAI;AACpD,QAAQ,IAAI,eAAe;AAC3B,QAAQ,IAAI,QAAQ,WAAW,EAAE;AACjC,QAAQ,IAAI,eAAe;AAC3B,QAAQ,IAAI,yCAAyC;","names":["path","fs"]}
|
package/dist/cli.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/cli.ts
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import path from "path";
|
|
6
|
+
var args = process.argv.slice(2);
|
|
7
|
+
var command = args[0];
|
|
8
|
+
var projectName = args[1] ?? "my-agent";
|
|
9
|
+
if (command !== "init") {
|
|
10
|
+
console.error(`Unknown command: ${command}`);
|
|
11
|
+
console.error("Usage: agent-kit init [project-name]");
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
var targetDir = path.resolve(process.cwd(), projectName);
|
|
15
|
+
if (fs.existsSync(targetDir)) {
|
|
16
|
+
console.error(`Directory already exists: ${targetDir}`);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
20
|
+
var packageJson = {
|
|
21
|
+
name: projectName,
|
|
22
|
+
version: "1.0.0",
|
|
23
|
+
private: true,
|
|
24
|
+
type: "module",
|
|
25
|
+
scripts: {
|
|
26
|
+
start: "npx tsx agent.ts"
|
|
27
|
+
},
|
|
28
|
+
dependencies: {
|
|
29
|
+
"@avee1234/agent-kit": "^0.2.0"
|
|
30
|
+
},
|
|
31
|
+
devDependencies: {
|
|
32
|
+
tsx: "^4.0.0"
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var agentTs = `import { Agent, Tool, Memory } from '@avee1234/agent-kit';
|
|
36
|
+
|
|
37
|
+
const greet = Tool.create({
|
|
38
|
+
name: 'greet',
|
|
39
|
+
description: 'Greet someone by name',
|
|
40
|
+
parameters: {
|
|
41
|
+
name: { type: 'string', description: 'Name to greet' },
|
|
42
|
+
},
|
|
43
|
+
execute: async ({ name }) => \`Hello, \${name}!\`,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const agent = new Agent({
|
|
47
|
+
name: 'my-agent',
|
|
48
|
+
memory: new Memory({ store: 'sqlite', path: './memory.db' }),
|
|
49
|
+
tools: [greet],
|
|
50
|
+
system: 'You are a helpful assistant.',
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const response = await agent.chat(process.argv[2] ?? 'Hello!');
|
|
54
|
+
console.log(response.content);
|
|
55
|
+
`;
|
|
56
|
+
var readmeMd = `# ${projectName}
|
|
57
|
+
|
|
58
|
+
Built with [agent-kit](https://github.com/abhid1234/agent-kit).
|
|
59
|
+
|
|
60
|
+
## Quick Start
|
|
61
|
+
|
|
62
|
+
\`\`\`bash
|
|
63
|
+
npm install
|
|
64
|
+
npm start "Hello, what can you do?"
|
|
65
|
+
\`\`\`
|
|
66
|
+
`;
|
|
67
|
+
fs.writeFileSync(path.join(targetDir, "package.json"), JSON.stringify(packageJson, null, 2) + "\n");
|
|
68
|
+
fs.writeFileSync(path.join(targetDir, "agent.ts"), agentTs);
|
|
69
|
+
fs.writeFileSync(path.join(targetDir, "README.md"), readmeMd);
|
|
70
|
+
console.log(`
|
|
71
|
+
Scaffolded project: ${projectName}
|
|
72
|
+
`);
|
|
73
|
+
console.log("Next steps:\n");
|
|
74
|
+
console.log(` cd ${projectName}`);
|
|
75
|
+
console.log(" npm install");
|
|
76
|
+
console.log(' npm start "Hello, what can you do?"\n');
|
|
77
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport fs from 'fs';\nimport path from 'path';\n\nconst args = process.argv.slice(2);\nconst command = args[0];\nconst projectName = args[1] ?? 'my-agent';\n\nif (command !== 'init') {\n console.error(`Unknown command: ${command}`);\n console.error('Usage: agent-kit init [project-name]');\n process.exit(1);\n}\n\nconst targetDir = path.resolve(process.cwd(), projectName);\n\nif (fs.existsSync(targetDir)) {\n console.error(`Directory already exists: ${targetDir}`);\n process.exit(1);\n}\n\nfs.mkdirSync(targetDir, { recursive: true });\n\nconst packageJson = {\n name: projectName,\n version: '1.0.0',\n private: true,\n type: 'module',\n scripts: {\n start: 'npx tsx agent.ts',\n },\n dependencies: {\n '@avee1234/agent-kit': '^0.2.0',\n },\n devDependencies: {\n tsx: '^4.0.0',\n },\n};\n\nconst agentTs = `import { Agent, Tool, Memory } from '@avee1234/agent-kit';\n\nconst greet = Tool.create({\n name: 'greet',\n description: 'Greet someone by name',\n parameters: {\n name: { type: 'string', description: 'Name to greet' },\n },\n execute: async ({ name }) => \\`Hello, \\${name}!\\`,\n});\n\nconst agent = new Agent({\n name: 'my-agent',\n memory: new Memory({ store: 'sqlite', path: './memory.db' }),\n tools: [greet],\n system: 'You are a helpful assistant.',\n});\n\nconst response = await agent.chat(process.argv[2] ?? 'Hello!');\nconsole.log(response.content);\n`;\n\nconst readmeMd = `# ${projectName}\n\nBuilt with [agent-kit](https://github.com/abhid1234/agent-kit).\n\n## Quick Start\n\n\\`\\`\\`bash\nnpm install\nnpm start \"Hello, what can you do?\"\n\\`\\`\\`\n`;\n\nfs.writeFileSync(path.join(targetDir, 'package.json'), JSON.stringify(packageJson, null, 2) + '\\n');\nfs.writeFileSync(path.join(targetDir, 'agent.ts'), agentTs);\nfs.writeFileSync(path.join(targetDir, 'README.md'), readmeMd);\n\nconsole.log(`\\nScaffolded project: ${projectName}\\n`);\nconsole.log('Next steps:\\n');\nconsole.log(` cd ${projectName}`);\nconsole.log(' npm install');\nconsole.log(' npm start \"Hello, what can you do?\"\\n');\n"],"mappings":";;;AAEA,OAAO,QAAQ;AACf,OAAO,UAAU;AAEjB,IAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,IAAM,UAAU,KAAK,CAAC;AACtB,IAAM,cAAc,KAAK,CAAC,KAAK;AAE/B,IAAI,YAAY,QAAQ;AACtB,UAAQ,MAAM,oBAAoB,OAAO,EAAE;AAC3C,UAAQ,MAAM,sCAAsC;AACpD,UAAQ,KAAK,CAAC;AAChB;AAEA,IAAM,YAAY,KAAK,QAAQ,QAAQ,IAAI,GAAG,WAAW;AAEzD,IAAI,GAAG,WAAW,SAAS,GAAG;AAC5B,UAAQ,MAAM,6BAA6B,SAAS,EAAE;AACtD,UAAQ,KAAK,CAAC;AAChB;AAEA,GAAG,UAAU,WAAW,EAAE,WAAW,KAAK,CAAC;AAE3C,IAAM,cAAc;AAAA,EAClB,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,IACP,OAAO;AAAA,EACT;AAAA,EACA,cAAc;AAAA,IACZ,uBAAuB;AAAA,EACzB;AAAA,EACA,iBAAiB;AAAA,IACf,KAAK;AAAA,EACP;AACF;AAEA,IAAM,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsBhB,IAAM,WAAW,KAAK,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYjC,GAAG,cAAc,KAAK,KAAK,WAAW,cAAc,GAAG,KAAK,UAAU,aAAa,MAAM,CAAC,IAAI,IAAI;AAClG,GAAG,cAAc,KAAK,KAAK,WAAW,UAAU,GAAG,OAAO;AAC1D,GAAG,cAAc,KAAK,KAAK,WAAW,WAAW,GAAG,QAAQ;AAE5D,QAAQ,IAAI;AAAA,sBAAyB,WAAW;AAAA,CAAI;AACpD,QAAQ,IAAI,eAAe;AAC3B,QAAQ,IAAI,QAAQ,WAAW,EAAE;AACjC,QAAQ,IAAI,eAAe;AAC3B,QAAQ,IAAI,yCAAyC;","names":[]}
|