@agents-eco/framework 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 agents.eco
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,387 @@
1
+ <p align="center">
2
+ <img src="icon.png" alt="agents.eco framework" width="128" />
3
+ </p>
4
+
5
+ # @agents-eco/framework
6
+
7
+ **Open agentic framework** — skills-as-markdown, pluggable LLM providers, file-based memory.
8
+
9
+ Built for [agents.eco](https://agents.eco). MIT licensed. Works with any OpenAI-compatible API.
10
+
11
+ ```
12
+ npm install @agents-eco/framework
13
+ ```
14
+
15
+ ## Why
16
+
17
+ Most agent frameworks are either too complex (LangChain) or too locked-in (proprietary APIs). This framework takes inspiration from [OpenClaw](https://github.com/openclaw/openclaw)'s architecture:
18
+
19
+ - **Skills as Markdown** — extend your agent with `.md` files, not code. Hot-reloadable, human-readable, agent-authorable.
20
+ - **Pluggable providers** — OpenAI, Venice, Groq, Ollama, agents.eco, or any OpenAI-compatible API.
21
+ - **File-based memory** — JSONL + Markdown files you can inspect, edit, and version control.
22
+ - **Tool calling** — register handlers, define tools in skill files, let the agent use them.
23
+ - **Zero lock-in** — MIT license, no vendor dependencies, works offline with Ollama.
24
+
25
+ ## Quick Start
26
+
27
+ ### Programmatic
28
+
29
+ ```typescript
30
+ import { Agent } from "@agents-eco/framework";
31
+
32
+ const agent = new Agent({
33
+ name: "my-agent",
34
+ systemPrompt: "You are a helpful assistant.",
35
+ provider: {
36
+ name: "venice",
37
+ apiKey: process.env.VENICE_API_KEY!,
38
+ baseUrl: "https://api.venice.ai/api/v1",
39
+ defaultModel: "qwen3-4b",
40
+ },
41
+ });
42
+
43
+ const result = await agent.chat("What is agents.eco?");
44
+ console.log(result.response);
45
+ ```
46
+
47
+ ### CLI
48
+
49
+ ```bash
50
+ # Initialize a new agent project
51
+ npx @agents-eco/framework init
52
+
53
+ # Start interactive chat
54
+ npx @agents-eco/framework chat
55
+
56
+ # One-shot prompt
57
+ npx @agents-eco/framework run "Explain quantum computing in 3 sentences"
58
+ ```
59
+
60
+ ## Providers
61
+
62
+ Works with any OpenAI-compatible API out of the box:
63
+
64
+ ```typescript
65
+ import {
66
+ veniceProvider,
67
+ openaiProvider,
68
+ groqProvider,
69
+ ollamaProvider,
70
+ agentsEcoProvider,
71
+ OpenAIProvider,
72
+ } from "@agents-eco/framework";
73
+
74
+ // Pre-configured providers
75
+ const venice = veniceProvider("your-api-key");
76
+ const openai = openaiProvider("sk-...");
77
+ const groq = groqProvider("gsk_...");
78
+ const ollama = ollamaProvider("llama3.2"); // local, no API key needed
79
+ const eco = agentsEcoProvider("ak_...");
80
+
81
+ // Custom provider
82
+ const custom = new OpenAIProvider({
83
+ name: "my-provider",
84
+ apiKey: "...",
85
+ baseUrl: "https://my-api.com/v1",
86
+ defaultModel: "my-model",
87
+ });
88
+ ```
89
+
90
+ Use with an agent:
91
+
92
+ ```typescript
93
+ const agent = new Agent({
94
+ name: "my-agent",
95
+ systemPrompt: "You are helpful.",
96
+ provider: { name: "ollama", baseUrl: "http://localhost:11434/v1", defaultModel: "llama3.2" },
97
+ });
98
+
99
+ // Or swap providers at runtime
100
+ agent.useProvider(veniceProvider("your-key"));
101
+ ```
102
+
103
+ ## Skills (Markdown-Driven)
104
+
105
+ Skills are `.md` files with YAML frontmatter. Drop them in a `skills/` directory and the agent loads them automatically.
106
+
107
+ ### Example Skill
108
+
109
+ Create `skills/weather.md`:
110
+
111
+ ```markdown
112
+ ---
113
+ name: weather
114
+ description: Get current weather for a location
115
+ tools:
116
+ - name: get_weather
117
+ description: Fetch current weather data
118
+ parameters:
119
+ type: object
120
+ properties:
121
+ location:
122
+ type: string
123
+ description: City name or coordinates
124
+ required:
125
+ - location
126
+ ---
127
+
128
+ # Weather Skill
129
+
130
+ When the user asks about weather, use the `get_weather` tool.
131
+ Present the results in a friendly, conversational format.
132
+ Include temperature, conditions, and any relevant alerts.
133
+ ```
134
+
135
+ ### Register the tool handler:
136
+
137
+ ```typescript
138
+ const agent = new Agent({
139
+ name: "weather-bot",
140
+ systemPrompt: "You help people check the weather.",
141
+ provider: { ... },
142
+ skillsDir: "./skills",
143
+ toolHandlers: {
144
+ get_weather: async ({ location }) => {
145
+ const res = await fetch(`https://wttr.in/${location}?format=j1`);
146
+ const data = await res.json();
147
+ return JSON.stringify(data.current_condition[0]);
148
+ },
149
+ },
150
+ });
151
+ ```
152
+
153
+ ### Skill Discovery
154
+
155
+ Skills are loaded from:
156
+ 1. **`skillsDir`** — auto-discovers all `.md` files with YAML frontmatter
157
+ 2. **`skills` array** — explicit file paths or `Skill` objects
158
+ 3. **Subdirectories** — looks for `SKILL.md` inside each subdirectory
159
+
160
+ ```
161
+ skills/
162
+ ├── greeting.md # Simple skill (single file)
163
+ ├── weather.md # Another simple skill
164
+ ├── web-search/
165
+ │ └── SKILL.md # Skill in a directory (can include extra files)
166
+ └── code-exec/
167
+ └── SKILL.md
168
+ ```
169
+
170
+ ## Memory
171
+
172
+ File-based memory that's human-readable and inspectable:
173
+
174
+ ```typescript
175
+ const agent = new Agent({
176
+ name: "my-agent",
177
+ systemPrompt: "You remember previous conversations.",
178
+ provider: { ... },
179
+ memoryDir: "./.agent/memory", // default
180
+ });
181
+
182
+ // Memory is automatic — conversations are stored after each chat
183
+ await agent.chat("My name is Alice");
184
+ await agent.chat("What's my name?"); // "Your name is Alice"
185
+ ```
186
+
187
+ Memory files:
188
+ - **`memory.jsonl`** — append-only log (one JSON per line)
189
+ - **`context.md`** — auto-generated markdown summary
190
+
191
+ ### Custom Memory Store
192
+
193
+ ```typescript
194
+ import { MemoryStore, MemoryEntry } from "@agents-eco/framework";
195
+
196
+ class MyVectorMemory implements MemoryStore {
197
+ async add(entry) { /* store in your vector DB */ }
198
+ async search(query, limit) { /* semantic search */ }
199
+ async list(limit) { /* return recent entries */ }
200
+ async clear() { /* wipe */ }
201
+ }
202
+
203
+ const agent = new Agent({
204
+ ...config,
205
+ memory: new MyVectorMemory(),
206
+ });
207
+ ```
208
+
209
+ ### Disable Memory
210
+
211
+ ```typescript
212
+ const agent = new Agent({ ...config, memory: false });
213
+ ```
214
+
215
+ ## Tool Calling
216
+
217
+ Register tool handlers that the agent can invoke:
218
+
219
+ ```typescript
220
+ const agent = new Agent({
221
+ name: "tool-agent",
222
+ systemPrompt: "You can use tools to help users.",
223
+ provider: { ... },
224
+ toolHandlers: {
225
+ calculate: async ({ expression }) => {
226
+ return String(eval(expression));
227
+ },
228
+ fetch_url: async ({ url }) => {
229
+ const res = await fetch(url);
230
+ return await res.text();
231
+ },
232
+ },
233
+ });
234
+
235
+ // Or add tools after creation
236
+ agent.tool("greet", async ({ name }) => `Hello, ${name}!`);
237
+ ```
238
+
239
+ ## Hooks
240
+
241
+ Intercept and modify behavior at every stage:
242
+
243
+ ```typescript
244
+ const agent = new Agent({
245
+ ...config,
246
+ hooks: {
247
+ beforeRequest: async (messages, tools) => {
248
+ console.log(`Sending ${messages.length} messages`);
249
+ return messages; // can modify
250
+ },
251
+ afterResponse: async (response) => {
252
+ console.log(`Got response: ${response.content.slice(0, 50)}...`);
253
+ return response; // can modify
254
+ },
255
+ beforeToolCall: async (name, args) => {
256
+ console.log(`Calling tool: ${name}`, args);
257
+ return args; // can modify
258
+ },
259
+ afterToolCall: async (name, result) => {
260
+ console.log(`Tool result: ${result.content.slice(0, 50)}...`);
261
+ return result; // can modify
262
+ },
263
+ onError: (error) => {
264
+ console.error("Agent error:", error);
265
+ },
266
+ },
267
+ });
268
+ ```
269
+
270
+ ## Configuration (agent.yaml)
271
+
272
+ The CLI uses `agent.yaml` for configuration:
273
+
274
+ ```yaml
275
+ name: my-agent
276
+ systemPrompt: |
277
+ You are a helpful AI assistant.
278
+
279
+ provider:
280
+ name: venice
281
+ apiKey: ${VENICE_API_KEY}
282
+ baseUrl: https://api.venice.ai/api/v1
283
+ defaultModel: qwen3-4b
284
+
285
+ skillsDir: ./skills
286
+ memoryDir: ./.agent/memory
287
+ temperature: 0.7
288
+ maxTokens: 4096
289
+ ```
290
+
291
+ Environment variables are resolved with `${VAR_NAME}` syntax.
292
+
293
+ ## Integration with agents.eco SDK
294
+
295
+ Use alongside the [agents-eco-sdk](https://www.npmjs.com/package/agents-eco-sdk) for billing, wallet management, and the full agents.eco platform:
296
+
297
+ ```typescript
298
+ import { Agent, agentsEcoProvider } from "@agents-eco/framework";
299
+ import { AgentsEco } from "agents-eco-sdk";
300
+
301
+ // Use agents.eco as the LLM provider (pay-per-token with USDC)
302
+ const agent = new Agent({
303
+ name: "eco-agent",
304
+ systemPrompt: "You are powered by agents.eco.",
305
+ provider: {
306
+ name: "agents.eco",
307
+ apiKey: process.env.AGENTS_ECO_API_KEY!,
308
+ baseUrl: "https://agents-eco-dfc6baa9f955.herokuapp.com/v1",
309
+ defaultModel: "qwen3-4b",
310
+ },
311
+ skillsDir: "./skills",
312
+ });
313
+
314
+ const result = await agent.chat("Hello!");
315
+ console.log(result.response);
316
+ console.log(`Tokens used: ${result.usage.totalTokens}`);
317
+ ```
318
+
319
+ ## Architecture
320
+
321
+ ```
322
+ ┌─────────────────────────────────────────────┐
323
+ │ Agent │
324
+ │ │
325
+ │ ┌──────────┐ ┌──────────┐ ┌───────────┐ │
326
+ │ │ Skills │ │ Memory │ │ Hooks │ │
327
+ │ │ (SKILL.md)│ │ (JSONL) │ │ │ │
328
+ │ └─────┬─────┘ └─────┬────┘ └─────┬─────┘ │
329
+ │ │ │ │ │
330
+ │ ┌─────▼──────────────▼──────────────▼─────┐ │
331
+ │ │ Message Builder │ │
332
+ │ │ system prompt + skills + memory + user │ │
333
+ │ └─────────────────┬───────────────────────┘ │
334
+ │ │ │
335
+ │ ┌─────────────────▼───────────────────────┐ │
336
+ │ │ Provider (OpenAI-compat) │ │
337
+ │ │ Venice │ OpenAI │ Groq │ Ollama │ ... │ │
338
+ │ └─────────────────┬───────────────────────┘ │
339
+ │ │ │
340
+ │ ┌─────────────────▼───────────────────────┐ │
341
+ │ │ Tool Call Loop │ │
342
+ │ │ LLM → tool calls → execute → repeat │ │
343
+ │ └─────────────────────────────────────────┘ │
344
+ └─────────────────────────────────────────────┘
345
+ ```
346
+
347
+ ## Built-in Skills
348
+
349
+ The package includes starter skills in the `skills/` directory:
350
+
351
+ | Skill | Description |
352
+ |-------|-------------|
353
+ | `web-search` | Search the web for current information |
354
+ | `code-exec` | Execute JavaScript code snippets |
355
+ | `file-ops` | Read, write, and list files |
356
+
357
+ Copy them to your project's `skills/` directory and register the corresponding tool handlers.
358
+
359
+ ## API Reference
360
+
361
+ ### `Agent`
362
+
363
+ | Method | Description |
364
+ |--------|-------------|
365
+ | `chat(message)` | Send a message, get a response (with history + memory) |
366
+ | `run(prompt, systemPrompt?)` | One-shot completion (no history/memory) |
367
+ | `useProvider(provider)` | Swap the LLM provider |
368
+ | `tool(name, handler)` | Register a tool handler |
369
+ | `addSkill(skill)` | Add a skill at runtime |
370
+ | `loadSkillFile(path)` | Load a skill from a file |
371
+ | `getHistory()` | Get conversation history |
372
+ | `clearHistory()` | Clear conversation history |
373
+ | `getMemory()` | Get the memory store |
374
+
375
+ ### `RunResult`
376
+
377
+ | Field | Type | Description |
378
+ |-------|------|-------------|
379
+ | `response` | `string` | The agent's response |
380
+ | `messages` | `ChatMessage[]` | Full message chain |
381
+ | `toolCalls` | `Array<{name, args, result}>` | Tool calls made |
382
+ | `usage` | `{promptTokens, completionTokens, totalTokens, llmCalls}` | Token usage |
383
+ | `duration` | `number` | Time in milliseconds |
384
+
385
+ ## License
386
+
387
+ MIT — [agents.eco](https://agents.eco)
@@ -0,0 +1,58 @@
1
+ import type { AgentConfig, ChatMessage, Provider, RunResult, Skill, ToolHandler, MemoryStore } from "./types.js";
2
+ /**
3
+ * The core agent runtime.
4
+ *
5
+ * Usage:
6
+ * ```ts
7
+ * import { Agent } from "@agents-eco/framework";
8
+ *
9
+ * const agent = new Agent({
10
+ * name: "my-agent",
11
+ * systemPrompt: "You are a helpful assistant.",
12
+ * provider: { name: "venice", apiKey: "...", baseUrl: "https://api.venice.ai/api/v1", defaultModel: "qwen3-4b" },
13
+ * skillsDir: "./skills",
14
+ * });
15
+ *
16
+ * const result = await agent.chat("Hello!");
17
+ * console.log(result.response);
18
+ * ```
19
+ */
20
+ export declare class Agent {
21
+ readonly name: string;
22
+ private provider;
23
+ private model;
24
+ private systemPrompt;
25
+ private skills;
26
+ private toolHandlers;
27
+ private memory;
28
+ private history;
29
+ private config;
30
+ private maxReasoningSteps;
31
+ constructor(config: AgentConfig);
32
+ /** Use a custom provider instance */
33
+ useProvider(provider: Provider): this;
34
+ /** Register a tool handler */
35
+ tool(name: string, handler: ToolHandler): this;
36
+ /** Add a skill at runtime */
37
+ addSkill(skill: Skill): this;
38
+ /** Load a skill from a file path */
39
+ loadSkillFile(path: string): this;
40
+ /** Get conversation history */
41
+ getHistory(): ChatMessage[];
42
+ /** Clear conversation history */
43
+ clearHistory(): void;
44
+ /** Get the memory store */
45
+ getMemory(): MemoryStore | null;
46
+ /**
47
+ * Send a message to the agent and get a response.
48
+ * Handles tool calling loops, memory retrieval, and skill injection.
49
+ */
50
+ chat(message: string): Promise<RunResult>;
51
+ /**
52
+ * Run a one-shot completion (no history, no memory).
53
+ */
54
+ run(prompt: string, systemPrompt?: string): Promise<string>;
55
+ private loadSkills;
56
+ private getAllTools;
57
+ }
58
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EAGX,QAAQ,EACR,SAAS,EACT,KAAK,EAEL,WAAW,EAEX,WAAW,EACZ,MAAM,YAAY,CAAC;AAOpB;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,KAAK;IAChB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,YAAY,CAAuC;IAC3D,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,iBAAiB,CAAS;gBAEtB,MAAM,EAAE,WAAW;IA8B/B,qCAAqC;IACrC,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAKrC,8BAA8B;IAC9B,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI;IAK9C,6BAA6B;IAC7B,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAK5B,oCAAoC;IACpC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKjC,+BAA+B;IAC/B,UAAU,IAAI,WAAW,EAAE;IAI3B,iCAAiC;IACjC,YAAY,IAAI,IAAI;IAIpB,2BAA2B;IAC3B,SAAS,IAAI,WAAW,GAAG,IAAI;IAI/B;;;OAGG;IACG,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAqK/C;;OAEG;IACG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAkBjE,OAAO,CAAC,UAAU;IAuBlB,OAAO,CAAC,WAAW;CAwBpB"}