@agentionai/agents 1.0.0 → 1.0.2

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 CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  A comprehensive TypeScript toolkit for building LLM-powered agents with RAG, and multi-agent workflows. No hidden state machines, no forced abstractions—just typed agents, composable graphs, and complete control in a complete toolkit.
8
8
 
9
- **[Documentation](https://docs.agention.ai/)** • **[Examples](https://docs.agention.ai/guide/examples)** • **[GitHub](https://github.com/laurentzuijdwijk/agention-lib)**
9
+ **[Documentation](https://docs.agention.ai/)** • **[Examples](https://docs.agention.ai/guide/examples)** • **[GitHub](https://github.com/laurentzuijdwijk/agention-lib)** • **[npm](https://www.npmjs.com/package/@agentionai/agents)**
10
10
 
11
11
  ## Quick Start
12
12
 
@@ -42,10 +42,11 @@ export ANTHROPIC_API_KEY=your-key-here
42
42
  import { ClaudeAgent } from '@agentionai/agents/claude';
43
43
 
44
44
  const agent = new ClaudeAgent({
45
- apiKey: process.env.ANTHROPIC_API_KEY, // Or pass directly (not recommended for production)
46
- model: 'claude-sonnet-4-5',
45
+ apiKey: process.env.ANTHROPIC_API_KEY,
46
+ id: 'assistant',
47
47
  name: 'Assistant',
48
48
  description: 'You are a helpful assistant.',
49
+ model: 'claude-sonnet-4-5',
49
50
  });
50
51
 
51
52
  const response = await agent.execute('What can you help me with?');
@@ -75,6 +76,7 @@ import { ClaudeAgent, OpenAiAgent } from '@agentionai/agents';
75
76
  ## Features
76
77
 
77
78
  - **Multi-Provider, No Lock-in** - Claude, OpenAI, Gemini, Mistral, plus local models via Ollama and llama.cpp—same interface. Switch models with one line.
79
+ - **Composable Context Management** - Tool result masking (lossless, free) + rolling summarization (auto-firing) + sub-agent delegation (token isolation by architecture).
78
80
  - **Streaming** - `executeStream()` on Claude, OpenAI, and all OpenAI-compatible agents. Yields `{ type: "text" | "reasoning" }` chunks; tool calls handled transparently.
79
81
  - **Built-In Tools** - Use provider-defined server-side tools (e.g. Anthropic's web search, bash, text editor) alongside your own.
80
82
  - **Composable, Not Magical** - Agents are objects. Pipelines are arrays. No hidden state, no surprises.
@@ -111,15 +113,50 @@ const weatherTool = new Tool({
111
113
 
112
114
  const agent = new GeminiAgent({
113
115
  apiKey: process.env.GEMINI_API_KEY,
114
- model: 'gemini-flash-lite-latest',
116
+ id: 'weather-agent',
115
117
  name: 'Weather Agent',
116
118
  description: 'You are a weather assistant.',
119
+ model: 'gemini-flash-lite-latest',
117
120
  tools: [weatherTool],
118
121
  });
119
122
 
120
123
  const response = await agent.execute("What's the weather in Paris?");
121
124
  ```
122
125
 
126
+ ### Context Management
127
+
128
+ Every agent conversation grows — tool results pile up, turns accumulate, tokens compound. Agention's history plugins keep the context window lean automatically, without manual bookkeeping.
129
+
130
+ ```typescript
131
+ import { toolResultMaskingPlugin, compressionPlugin } from '@agentionai/agents/history/plugins';
132
+ import { History } from '@agentionai/agents/history';
133
+
134
+ // Mask old tool results at read time — sync, free, lossless
135
+ const maskingPlugin = toolResultMaskingPlugin({ keepRecentResults: 2 });
136
+
137
+ // Compress old turns into a rolling summary — auto-fires past a token budget
138
+ const history = new History([], { maxTokens: 50000 })
139
+ .use(maskingPlugin)
140
+ .use(compressionPlugin(summaryAgent, { autoReduceWhen: { maxTokens: 8000 } }));
141
+
142
+ const agent = new ClaudeAgent({
143
+ apiKey: process.env.ANTHROPIC_API_KEY,
144
+ id: 'researcher',
145
+ name: 'Researcher',
146
+ description: 'Research topics thoroughly.',
147
+ model: 'claude-sonnet-4-6',
148
+ tools: [searchTool, maskingPlugin.retrieveTool],
149
+ }, history);
150
+ ```
151
+
152
+ | Strategy | Cost | Data loss | Trigger |
153
+ |---|---|---|---|
154
+ | `toolResultMaskingPlugin` | Zero — sync, no LLM calls | None — full content always retrievable | Every `getEntries()` call |
155
+ | `compressionPlugin` | LLM tokens (use a cheap model) | Yes — detail traded for brevity | `autoReduceWhen` threshold or manual `history.reduce()` |
156
+ | `Tool.fromAgent()` | None — structural choice | None in main context (sub-agent history is independent) | Automatic — just wrap an agent as a tool |
157
+
158
+ [Context Management guide →](https://docs.agention.ai/guide/context-management) · [History API →](https://docs.agention.ai/guide/history)
159
+
123
160
  ### Local Models (Ollama / llama.cpp / OpenAI-compatible servers)
124
161
 
125
162
  Run models on your own machine — no API key required. Same agent interface as every other provider:
@@ -172,8 +209,7 @@ class VLLMAgent extends OpenAICompatibleAgent {
172
209
  Use a provider's own server-side tools (executed by the provider, not locally) alongside your custom tools:
173
210
 
174
211
  ```typescript
175
- import { ClaudeAgent } from '@agentionai/agents/claude';
176
- import { webSearchTool } from '@agentionai/agents/claude';
212
+ import { ClaudeAgent, webSearchTool } from '@agentionai/agents/claude';
177
213
 
178
214
  const agent = new ClaudeAgent({
179
215
  apiKey: process.env.ANTHROPIC_API_KEY,
@@ -280,9 +316,10 @@ import * as fs from 'fs';
280
316
 
281
317
  const agent = new ClaudeAgent({
282
318
  apiKey: process.env.ANTHROPIC_API_KEY,
283
- model: 'claude-opus-4-6',
319
+ id: 'vision-agent',
284
320
  name: 'VisionAgent',
285
321
  description: 'You analyze images.',
322
+ model: 'claude-opus-4-6',
286
323
  });
287
324
 
288
325
  // Remote image by URL
@@ -318,16 +355,16 @@ JSON Schema + handler pattern. Unique capability: wrap any agent as a tool for d
318
355
 
319
356
  [Learn more →](https://docs.agention.ai/guide/tools)
320
357
 
358
+ ### Context Management
359
+ Tool result masking (lossless, free) + rolling summarization (auto-firing) + sub-agent delegation (token isolation by architecture). Composable plugins keep the context window lean automatically.
360
+
361
+ [Learn more →](https://docs.agention.ai/guide/context-management) · [History API →](https://docs.agention.ai/guide/history)
362
+
321
363
  ### Multimodal / Vision
322
364
  Unified `MessageContent[]` interface for images across all providers. URL and base64 images, mix text and images freely in a single call.
323
365
 
324
366
  [Learn more →](https://docs.agention.ai/guide/multimodal)
325
367
 
326
- ### History
327
- Provider-agnostic, persistent (Redis, file, custom), shareable across agents of different providers.
328
-
329
- [Learn more →](https://docs.agention.ai/guide/history)
330
-
331
368
  ### Graph Pipelines
332
369
  Compose sequential, parallel, voting, routing, and nested graphs. Mix models and providers freely.
333
370
 
@@ -346,10 +383,11 @@ Per-call and per-node token counts, duration metrics, full execution visibility.
346
383
  ## Documentation
347
384
 
348
385
  - **[Getting Started](https://docs.agention.ai/guide/getting-started)** - Installation and first agent
349
- - **[Quick Start](https://docs.agention.ai/guide/quickstart)** - Build a weather assistant in 5 minutes
386
+ - **[Context Management](https://docs.agention.ai/guide/context-management)** - Token budgets, masking, and compression
350
387
  - **[Agents](https://docs.agention.ai/guide/agents)** - Agent configuration and providers
351
388
  - **[Tools](https://docs.agention.ai/guide/tools)** - Adding capabilities and agent delegation
352
389
  - **[Multimodal / Vision](https://docs.agention.ai/guide/multimodal)** - Sending images across all providers
390
+ - **[History](https://docs.agention.ai/guide/history)** - Conversation persistence and plugins
353
391
  - **[Graph Pipelines](https://docs.agention.ai/guide/graph-pipelines)** - Multi-agent workflows
354
392
  - **[Vector Stores](https://docs.agention.ai/guide/vector-stores)** - RAG and semantic search
355
393
  - **[Examples](https://docs.agention.ai/guide/examples)** - Real-world implementations
@@ -380,6 +418,10 @@ Check out the [examples](https://github.com/laurentzuijdwijk/agention-lib/tree/m
380
418
  - RAG applications with vector search
381
419
  - Document ingestion and chunking
382
420
 
421
+ ## Built with Agention
422
+
423
+ - **[Marshall](https://marshall.agention.ai/)** — a coding agent for open weights. Runs a planner/coder/reviewer loop entirely on local hardware via llama.cpp or Ollama, no API key, account, or cloud required — with approval-gated file writes and shell commands, and support for mixing local and paid models across roles.
424
+
383
425
  ## Contributing
384
426
 
385
427
  Contributions are welcome! Please open an issue or submit a pull request.
@@ -7,7 +7,7 @@ import { History, MessageContent } from "../../history/History";
7
7
  /**
8
8
  * A single chunk yielded by `executeStream()`.
9
9
  * - `"text"` — visible output token
10
- * - `"reasoning"` — internal reasoning token (DeepSeek-style `reasoning_content`)
10
+ * - `"reasoning"` — internal reasoning token (`reasoning` on OpenRouter, `reasoning_content` on DeepSeek/llama.cpp)
11
11
  */
12
12
  export type StreamChunk = {
13
13
  type: "text" | "reasoning";
@@ -340,8 +340,12 @@ class OpenAICompatibleAgent extends BaseAgent_1.BaseAgent {
340
340
  this.emit(AgentEvent_1.AgentEvent.CHUNK, delta.content);
341
341
  yield { type: "text", content: delta.content };
342
342
  }
343
- // DeepSeek-style reasoning tokens (not in OpenAI SDK types — cast required)
344
- const reasoningDelta = delta.reasoning_content;
343
+ // Reasoning tokens (not in OpenAI SDK types — cast required). Servers
344
+ // disagree on the field name: OpenRouter sends `delta.reasoning`, while
345
+ // DeepSeek/llama.cpp send `delta.reasoning_content`. Prefer `reasoning`;
346
+ // never concatenate — that would duplicate the text if both were sent.
347
+ const deltaExtras = delta;
348
+ const reasoningDelta = (deltaExtras.reasoning ?? deltaExtras.reasoning_content);
345
349
  if (reasoningDelta) {
346
350
  this.emit(AgentEvent_1.AgentEvent.REASONING_CHUNK, reasoningDelta);
347
351
  yield { type: "reasoning", content: reasoningDelta };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agentionai/agents",
3
3
  "author": "Laurent Zuijdwijk",
4
- "version": "1.0.0",
4
+ "version": "1.0.2",
5
5
  "description": "Agent Library",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",