@framers/agentos 0.1.134 → 0.1.136
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 +308 -60
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
[](https://www.npmjs.com/package/@framers/agentos)
|
|
12
12
|
[](https://github.com/framersai/agentos/actions/workflows/ci.yml)
|
|
13
|
+
[](https://github.com/framersai/agentos/actions/workflows/ci.yml)
|
|
13
14
|
[](https://codecov.io/gh/framersai/agentos)
|
|
14
15
|
[](https://www.typescriptlang.org/)
|
|
15
16
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
@@ -40,6 +41,7 @@
|
|
|
40
41
|
- [Planning Engine](#planning-engine)
|
|
41
42
|
- [Conversation Management](#conversation-management)
|
|
42
43
|
- [RAG (Retrieval Augmented Generation)](#rag-retrieval-augmented-generation)
|
|
44
|
+
- [Bundled Platform Knowledge](#bundled-platform-knowledge)
|
|
43
45
|
- [Safety and Guardrails](#safety-and-guardrails)
|
|
44
46
|
- [Human-in-the-Loop (HITL)](#human-in-the-loop-hitl)
|
|
45
47
|
- [Channels System](#channels-system)
|
|
@@ -83,7 +85,7 @@
|
|
|
83
85
|
|
|
84
86
|
## Overview
|
|
85
87
|
|
|
86
|
-
`@framers/agentos` is an open-source TypeScript AI agent runtime for building, deploying, and managing production AI agents. It provides multimodal RAG with cognitive memory (Ebbinghaus decay), multi-agent orchestration, 37 channel adapters, 5-tier guardrails with prompt injection defense, 21 LLM providers, and
|
|
88
|
+
`@framers/agentos` is an open-source TypeScript AI agent runtime for building, deploying, and managing production AI agents. It provides multimodal RAG with cognitive memory (Ebbinghaus decay, 8 neuroscience-backed mechanisms including reconsolidation, retrieval-induced forgetting, involuntary recall, metacognitive FOK, temporal gist extraction, schema encoding, source confidence decay, and emotion regulation — all HEXACO personality-modulated), multi-agent orchestration, 37 channel adapters, 5-tier guardrails with prompt injection defense, 21 LLM providers, and 72 curated skills. Self-hostable and production-ready, it handles the full lifecycle from prompt construction through tool execution, safety evaluation, and streaming response delivery.
|
|
87
89
|
|
|
88
90
|
**Key facts:**
|
|
89
91
|
|
|
@@ -106,14 +108,19 @@
|
|
|
106
108
|
| `uuid` | Unique identifier generation |
|
|
107
109
|
| `yaml` | YAML config parsing (agent configs, skill definitions) |
|
|
108
110
|
|
|
111
|
+
**Required peer dependency:**
|
|
112
|
+
|
|
113
|
+
| Dependency | Purpose |
|
|
114
|
+
|------------|---------|
|
|
115
|
+
| `@framers/sql-storage-adapter` | Cross-platform SQL persistence (SQLite, sql.js, IndexedDB, Postgres) — required for memory, knowledge graph, and trace storage |
|
|
116
|
+
|
|
109
117
|
**Optional peer dependencies:**
|
|
110
118
|
|
|
111
119
|
| Peer Dependency | Purpose |
|
|
112
120
|
|-----------------|---------|
|
|
113
|
-
|
|
|
114
|
-
| `
|
|
115
|
-
| `
|
|
116
|
-
| `neo4j-driver` | Neo4j-backed vector + GraphRAG persistence |
|
|
121
|
+
| `graphology` + `graphology-communities-louvain` | GraphRAG community detection and memory graph clustering |
|
|
122
|
+
| `hnswlib-node` | HNSW-based approximate nearest neighbor search (falls back to brute-force without) |
|
|
123
|
+
| `neo4j-driver` | Neo4j-backed knowledge graph and GraphRAG (falls back to SQLite without) |
|
|
117
124
|
|
|
118
125
|
---
|
|
119
126
|
|
|
@@ -125,7 +132,7 @@
|
|
|
125
132
|
| **@framers/agentos-extensions** | Official extension registry (45+ extensions) | [](https://www.npmjs.com/package/@framers/agentos-extensions) · [GitHub](https://github.com/framersai/agentos-extensions) |
|
|
126
133
|
| **@framers/agentos-extensions-registry** | Curated manifest builder | [](https://www.npmjs.com/package/@framers/agentos-extensions-registry) · [GitHub](https://github.com/framersai/agentos-extensions-registry) |
|
|
127
134
|
| **@framers/agentos-skills-registry** | Skills catalog SDK (query helpers + snapshot factories) | [](https://www.npmjs.com/package/@framers/agentos-skills-registry) · [GitHub](https://github.com/framersai/agentos-skills-registry) |
|
|
128
|
-
| **@framers/agentos-skills** | Skills content (
|
|
135
|
+
| **@framers/agentos-skills** | Skills content (72 SKILL.md files + registry.json) | [](https://www.npmjs.com/package/@framers/agentos-skills) · [GitHub](https://github.com/framersai/agentos-skills) |
|
|
129
136
|
| **docs.agentos.sh** | Documentation site (Docusaurus) | [GitHub](https://github.com/framersai/agentos-live-docs) · [docs.agentos.sh](https://docs.agentos.sh) |
|
|
130
137
|
|
|
131
138
|
### Guardrail Extensions
|
|
@@ -176,8 +183,9 @@ const result = await team.generate('Summarise recent advances in fusion energy.'
|
|
|
176
183
|
console.log(result.text);
|
|
177
184
|
```
|
|
178
185
|
|
|
179
|
-
Set
|
|
180
|
-
|
|
186
|
+
Set any provider's API key (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY`,
|
|
187
|
+
`GROQ_API_KEY`, `OLLAMA_BASE_URL`, etc.) and the agency auto-detects the provider.
|
|
188
|
+
All five strategies are available out of the box:
|
|
181
189
|
|
|
182
190
|
| Strategy | What it does |
|
|
183
191
|
|---|---|
|
|
@@ -214,23 +222,157 @@ Use the streamlined helpers when you want AI SDK-style text generation, structur
|
|
|
214
222
|
output extraction, embedding generation, image generation, or a single stateful
|
|
215
223
|
session without a multi-agent team.
|
|
216
224
|
|
|
225
|
+
#### Provider-First Pattern (Recommended)
|
|
226
|
+
|
|
227
|
+
The recommended way to call any helper is **provider-first**: specify the provider
|
|
228
|
+
name and let AgentOS pick the best default model automatically. No model string
|
|
229
|
+
needed -- just set the matching environment variable and go.
|
|
230
|
+
|
|
217
231
|
```typescript
|
|
218
|
-
import {
|
|
219
|
-
agent, embedText, generateImage, generateObject, generateText, streamText, streamObject,
|
|
220
|
-
} from '@framers/agentos';
|
|
221
|
-
import { z } from 'zod';
|
|
232
|
+
import { generateText, streamText, agent } from '@framers/agentos';
|
|
222
233
|
|
|
223
|
-
// Provider-first
|
|
224
|
-
|
|
225
|
-
const quick = await generateText({
|
|
234
|
+
// Provider-first -- AgentOS picks the best default model
|
|
235
|
+
const result = await generateText({
|
|
226
236
|
provider: 'openai',
|
|
227
|
-
prompt: 'Explain
|
|
237
|
+
prompt: 'Explain TCP handshakes in 3 bullets.',
|
|
228
238
|
});
|
|
229
239
|
|
|
230
|
-
|
|
240
|
+
// Works with any provider -- just change the name
|
|
241
|
+
const result2 = await generateText({
|
|
242
|
+
provider: 'anthropic',
|
|
243
|
+
prompt: 'Explain TCP handshakes in 3 bullets.',
|
|
244
|
+
});
|
|
231
245
|
|
|
232
|
-
|
|
246
|
+
// Local models via Ollama -- zero API keys
|
|
247
|
+
const result3 = await generateText({
|
|
248
|
+
provider: 'ollama',
|
|
249
|
+
prompt: 'Explain TCP handshakes in 3 bullets.',
|
|
250
|
+
});
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
The same pattern works across **every helper function**: `generateText`, `streamText`,
|
|
254
|
+
`generateObject`, `streamObject`, `embedText`, `generateImage`, and `agent`.
|
|
255
|
+
|
|
256
|
+
#### Default Models Per Provider
|
|
257
|
+
|
|
258
|
+
When you use the provider-first pattern, AgentOS resolves the default model
|
|
259
|
+
from a built-in registry. Set the matching env var and you are ready to go:
|
|
260
|
+
|
|
261
|
+
| Provider | Default Model | Env Var |
|
|
262
|
+
|---|---|---|
|
|
263
|
+
| `openai` | `gpt-4o` | `OPENAI_API_KEY` |
|
|
264
|
+
| `anthropic` | `claude-sonnet-4-20250514` | `ANTHROPIC_API_KEY` |
|
|
265
|
+
| `gemini` | `gemini-2.5-flash` | `GEMINI_API_KEY` |
|
|
266
|
+
| `ollama` | `llama3.2` | `OLLAMA_BASE_URL` |
|
|
267
|
+
| `groq` | `llama-3.3-70b-versatile` | `GROQ_API_KEY` |
|
|
268
|
+
| `openrouter` | `openai/gpt-4o` | `OPENROUTER_API_KEY` |
|
|
269
|
+
| `together` | `Meta-Llama-3.1-70B-Instruct-Turbo` | `TOGETHER_API_KEY` |
|
|
270
|
+
| `mistral` | `mistral-large-latest` | `MISTRAL_API_KEY` |
|
|
271
|
+
| `xai` | `grok-2` | `XAI_API_KEY` |
|
|
272
|
+
|
|
273
|
+
See `src/api/runtime/provider-defaults.ts` for the full registry including image
|
|
274
|
+
and embedding defaults.
|
|
275
|
+
|
|
276
|
+
#### Multi-Provider Showcase
|
|
277
|
+
|
|
278
|
+
The **same prompt** works across every supported provider -- swap one string:
|
|
279
|
+
|
|
280
|
+
```typescript
|
|
281
|
+
import { generateText } from '@framers/agentos';
|
|
282
|
+
|
|
283
|
+
// OpenAI
|
|
284
|
+
await generateText({ provider: 'openai', prompt: 'What is QUIC?' });
|
|
285
|
+
|
|
286
|
+
// Anthropic
|
|
287
|
+
await generateText({ provider: 'anthropic', prompt: 'What is QUIC?' });
|
|
288
|
+
|
|
289
|
+
// Google Gemini
|
|
290
|
+
await generateText({ provider: 'gemini', prompt: 'What is QUIC?' });
|
|
291
|
+
|
|
292
|
+
// Groq (fast inference)
|
|
293
|
+
await generateText({ provider: 'groq', prompt: 'What is QUIC?' });
|
|
294
|
+
|
|
295
|
+
// Local via Ollama (no API key needed)
|
|
296
|
+
await generateText({ provider: 'ollama', prompt: 'What is QUIC?' });
|
|
297
|
+
|
|
298
|
+
// OpenRouter (200+ models, auto-routing)
|
|
299
|
+
await generateText({ provider: 'openrouter', prompt: 'What is QUIC?' });
|
|
300
|
+
|
|
301
|
+
// Mistral
|
|
302
|
+
await generateText({ provider: 'mistral', prompt: 'What is QUIC?' });
|
|
303
|
+
|
|
304
|
+
// xAI (Grok)
|
|
305
|
+
await generateText({ provider: 'xai', prompt: 'What is QUIC?' });
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
#### Provider + Model Override
|
|
309
|
+
|
|
310
|
+
When you need a specific model instead of the default, pass both:
|
|
311
|
+
|
|
312
|
+
```typescript
|
|
313
|
+
// Cheaper model for high-volume workloads
|
|
314
|
+
await generateText({
|
|
233
315
|
provider: 'openai',
|
|
316
|
+
model: 'gpt-4o-mini',
|
|
317
|
+
prompt: 'Classify this support ticket.',
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
// Specific Anthropic model
|
|
321
|
+
await generateText({
|
|
322
|
+
provider: 'anthropic',
|
|
323
|
+
model: 'claude-haiku-4-5-20251001',
|
|
324
|
+
prompt: 'Summarise this paragraph.',
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
// Specific Ollama model
|
|
328
|
+
await generateText({
|
|
329
|
+
provider: 'ollama',
|
|
330
|
+
model: 'codellama',
|
|
331
|
+
prompt: 'Write a Python fizzbuzz.',
|
|
332
|
+
});
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
#### Global Defaults via Environment Variables
|
|
336
|
+
|
|
337
|
+
AgentOS auto-detects your active provider by scanning environment variables in
|
|
338
|
+
priority order. Set one key and every call uses that provider automatically --
|
|
339
|
+
no `provider` field needed:
|
|
340
|
+
|
|
341
|
+
```bash
|
|
342
|
+
# Set one of these -- AgentOS picks the first it finds:
|
|
343
|
+
# Priority: OPENROUTER > OPENAI > ANTHROPIC > GEMINI > GROQ > TOGETHER > MISTRAL > XAI > OLLAMA
|
|
344
|
+
export ANTHROPIC_API_KEY=sk-ant-...
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
```typescript
|
|
348
|
+
import { generateText } from '@framers/agentos';
|
|
349
|
+
|
|
350
|
+
// No provider or model needed -- auto-detected from env vars
|
|
351
|
+
const result = await generateText({ prompt: 'Hello world' });
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
#### Legacy Format
|
|
355
|
+
|
|
356
|
+
The `provider:model` string format still works but provider-first is preferred:
|
|
357
|
+
|
|
358
|
+
```typescript
|
|
359
|
+
// Legacy format -- still fully supported but not recommended for new code
|
|
360
|
+
await generateText({ model: 'openai:gpt-4o', prompt: '...' });
|
|
361
|
+
await generateText({ model: 'anthropic:claude-sonnet-4-20250514', prompt: '...' });
|
|
362
|
+
await generateText({ model: 'ollama:llama3.2', prompt: '...' });
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
#### Streaming, Structured Output, Images, and Embeddings
|
|
366
|
+
|
|
367
|
+
```typescript
|
|
368
|
+
import {
|
|
369
|
+
agent, embedText, generateImage, generateObject, streamText, streamObject,
|
|
370
|
+
} from '@framers/agentos';
|
|
371
|
+
import { z } from 'zod';
|
|
372
|
+
|
|
373
|
+
// Streaming with Anthropic
|
|
374
|
+
const live = streamText({
|
|
375
|
+
provider: 'anthropic',
|
|
234
376
|
prompt: 'Stream a short explanation of SYN, SYN-ACK, ACK.',
|
|
235
377
|
});
|
|
236
378
|
|
|
@@ -238,6 +380,7 @@ for await (const delta of live.textStream) {
|
|
|
238
380
|
process.stdout.write(delta);
|
|
239
381
|
}
|
|
240
382
|
|
|
383
|
+
// Image generation with OpenAI
|
|
241
384
|
const image = await generateImage({
|
|
242
385
|
provider: 'openai',
|
|
243
386
|
prompt: 'A cinematic neon city skyline reflected in rain at night.',
|
|
@@ -245,18 +388,18 @@ const image = await generateImage({
|
|
|
245
388
|
|
|
246
389
|
console.log(image.images[0]?.mimeType);
|
|
247
390
|
|
|
248
|
-
// Structured output
|
|
391
|
+
// Structured output with Gemini -- Zod-validated JSON extraction
|
|
249
392
|
const { object } = await generateObject({
|
|
250
|
-
|
|
393
|
+
provider: 'gemini',
|
|
251
394
|
schema: z.object({ name: z.string(), age: z.number() }),
|
|
252
395
|
prompt: 'Extract: "John is 30 years old"',
|
|
253
396
|
});
|
|
254
397
|
|
|
255
398
|
console.log(object.name, object.age); // "John" 30
|
|
256
399
|
|
|
257
|
-
// Streaming structured output
|
|
400
|
+
// Streaming structured output with Groq
|
|
258
401
|
const structured = streamObject({
|
|
259
|
-
|
|
402
|
+
provider: 'groq',
|
|
260
403
|
schema: z.object({ title: z.string(), tags: z.array(z.string()) }),
|
|
261
404
|
prompt: 'Generate metadata for an article about TCP.',
|
|
262
405
|
});
|
|
@@ -266,17 +409,18 @@ for await (const partial of structured.partialObjectStream) {
|
|
|
266
409
|
}
|
|
267
410
|
console.log('final:', await structured.object);
|
|
268
411
|
|
|
269
|
-
// Embeddings
|
|
412
|
+
// Embeddings -- single or batch (OpenAI)
|
|
270
413
|
const { embeddings } = await embedText({
|
|
271
|
-
|
|
414
|
+
provider: 'openai',
|
|
272
415
|
input: ['Hello world', 'Goodbye world'],
|
|
273
416
|
dimensions: 256,
|
|
274
417
|
});
|
|
275
418
|
|
|
276
419
|
console.log(embeddings.length, embeddings[0].length); // 2, 256
|
|
277
420
|
|
|
421
|
+
// Stateful agent session with Anthropic
|
|
278
422
|
const assistant = agent({
|
|
279
|
-
provider: '
|
|
423
|
+
provider: 'anthropic',
|
|
280
424
|
instructions: 'You are a concise networking tutor.',
|
|
281
425
|
maxSteps: 3,
|
|
282
426
|
});
|
|
@@ -285,9 +429,6 @@ const session = assistant.session('tcp-demo');
|
|
|
285
429
|
const reply = await session.send('Now compare TCP and UDP.');
|
|
286
430
|
console.log(reply.text);
|
|
287
431
|
console.log(await session.usage());
|
|
288
|
-
|
|
289
|
-
// Legacy format — still supported:
|
|
290
|
-
// const result = await generateText({ model: 'openai:gpt-4o', prompt: '...' });
|
|
291
432
|
```
|
|
292
433
|
|
|
293
434
|
If you want durable helper-level usage accounting outside the full runtime, enable
|
|
@@ -297,7 +438,7 @@ the opt-in usage ledger:
|
|
|
297
438
|
import { generateText, getRecordedAgentOSUsage } from '@framers/agentos';
|
|
298
439
|
|
|
299
440
|
await generateText({
|
|
300
|
-
provider: '
|
|
441
|
+
provider: 'anthropic',
|
|
301
442
|
prompt: 'Explain HTTP keep-alive.',
|
|
302
443
|
usageLedger: { enabled: true, sessionId: 'readme-demo' },
|
|
303
444
|
});
|
|
@@ -386,7 +527,7 @@ graph TB
|
|
|
386
527
|
Plan --> ReAct["ReAct<br/>Reasoner"]
|
|
387
528
|
|
|
388
529
|
subgraph LLM["LLM Provider Manager"]
|
|
389
|
-
OAI["OpenAI"] ~~~ Anth["Anthropic"] ~~~
|
|
530
|
+
OAI["OpenAI"] ~~~ Anth["Anthropic"] ~~~ Gem["Gemini"] ~~~ Oll["Ollama"] ~~~ OR["OpenRouter"]
|
|
390
531
|
end
|
|
391
532
|
|
|
392
533
|
Tools --> LLM
|
|
@@ -524,12 +665,36 @@ graph TB
|
|
|
524
665
|
- `Generalist` -- Balanced, conversational
|
|
525
666
|
- `Atlas` -- Navigation and spatial reasoning
|
|
526
667
|
- `Default Assistant` -- General-purpose helpful assistant
|
|
527
|
-
- **Memory subsystem** (`memory/`) --
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
668
|
+
- **Memory subsystem** (`memory/`) -- 5 memory types, 4-tier hierarchy, 8 cognitive mechanisms:
|
|
669
|
+
|
|
670
|
+
**Memory types** (Tulving's long-term memory taxonomy):
|
|
671
|
+
| Type | Cognitive Model | Usage |
|
|
672
|
+
|------|----------------|-------|
|
|
673
|
+
| `episodic` | Autobiographical events | Conversation events, interactions |
|
|
674
|
+
| `semantic` | General knowledge/facts | Learned facts, preferences, schemas |
|
|
675
|
+
| `procedural` | Skills and how-to | Workflows, tool usage patterns |
|
|
676
|
+
| `prospective` | Future intentions | Goals, reminders, planned actions |
|
|
677
|
+
| `working` | Baddeley's model | Current session state, active context (7 +/- 2 slots) |
|
|
678
|
+
|
|
679
|
+
**4-tier directory hierarchy:**
|
|
680
|
+
- `core/` -- Types, config, encoding (Yerkes-Dodson, flashbulb, HEXACO-weighted), decay (Ebbinghaus curves + spaced repetition), working memory, prompt assembly
|
|
681
|
+
- `retrieval/` -- MemoryStore (6-signal composite scoring), memory graph (spreading activation), prospective memory, retrieval feedback
|
|
682
|
+
- `pipeline/` -- Consolidation (merge, prune, promote, schema extraction), observation (buffer, compress, reflect), lifecycle management, infinite context window
|
|
683
|
+
- `io/` -- Document ingestion (PDF, DOCX, HTML, Markdown, URL), import/export (JSON, Obsidian, SQLite, ChatGPT, CSV), facade API, memory tools, extensions
|
|
684
|
+
|
|
685
|
+
**Cognitive mechanisms** (`memory/mechanisms/`) -- 8 optional, all HEXACO personality-modulated:
|
|
686
|
+
| Mechanism | Citation | Effect |
|
|
687
|
+
|-----------|----------|--------|
|
|
688
|
+
| Reconsolidation | [Nader et al., 2000](https://doi.org/10.1038/35021052) | Retrieved memories drift toward current mood |
|
|
689
|
+
| Retrieval-Induced Forgetting | [Anderson et al., 1994](https://doi.org/10.1037/0278-7393.20.5.1063) | Retrieving one memory suppresses similar competitors |
|
|
690
|
+
| Involuntary Recall | [Berntsen, 2009](https://doi.org/10.1017/CBO9780511575921) | Random surfacing of old high-vividness memories |
|
|
691
|
+
| Metacognitive FOK | [Nelson & Narens, 1990](https://doi.org/10.1016/S0079-7421(08)60053-5) | Feeling-of-knowing scoring for tip-of-tongue states |
|
|
692
|
+
| Temporal Gist | [Reyna & Brainerd, 1995](https://doi.org/10.1016/1041-6080(95)90003-9) | Old traces compressed to core assertions |
|
|
693
|
+
| Schema Encoding | [Bartlett, 1932](https://doi.org/10.1017/CBO9780511759185) | Novel input boosted, schema-matching encoded efficiently |
|
|
694
|
+
| Source Confidence Decay | [Johnson et al., 1993](https://doi.org/10.1037/0033-2909.114.1.3) | Agent inferences decay faster than observations |
|
|
695
|
+
| Emotion Regulation | [Gross, 1998](https://doi.org/10.1037/1089-2680.2.3.271) | Reappraisal + suppression during consolidation |
|
|
696
|
+
|
|
697
|
+
See `docs/memory/COGNITIVE_MECHANISMS.md` for API reference and 30+ APA citations.
|
|
533
698
|
|
|
534
699
|
---
|
|
535
700
|
|
|
@@ -543,21 +708,30 @@ The LLM layer abstracts multiple AI model providers behind a unified interface.
|
|
|
543
708
|
graph TD
|
|
544
709
|
PM["AIModelProviderManager<br/><i>Provider registry · Routing · Fallback · Model switching</i>"]
|
|
545
710
|
PM --> OAI["OpenAI Provider<br/><code>gpt-4o · gpt-4o-mini · o1</code>"]
|
|
711
|
+
PM --> Anth["Anthropic Provider<br/><code>claude-sonnet-4 · claude-haiku</code>"]
|
|
712
|
+
PM --> Gem["Gemini Provider<br/><code>gemini-2.5-flash · gemini-2.0</code>"]
|
|
546
713
|
PM --> Oll["Ollama Provider<br/><code>llama3.2 · mistral · codellama</code>"]
|
|
547
|
-
PM -->
|
|
714
|
+
PM --> GQ["Groq Provider<br/><code>llama-3.3-70b · gemma2-9b</code>"]
|
|
715
|
+
PM --> OR["OpenRouter Provider<br/><code>200+ models · auto-routing</code>"]
|
|
548
716
|
PM --> Custom["Custom Provider<br/><i>IProvider interface</i>"]
|
|
549
717
|
style PM fill:#1c1c28,stroke:#8b5cf6,color:#f2f2fa
|
|
550
718
|
```
|
|
551
719
|
|
|
552
720
|
**Provider implementations:**
|
|
553
721
|
|
|
554
|
-
| Provider | File | Models |
|
|
555
|
-
|
|
556
|
-
| OpenAI | `providers/implementations/OpenAIProvider.ts` | GPT-4o, GPT-4o-mini, o1, o3
|
|
557
|
-
|
|
|
558
|
-
|
|
|
722
|
+
| Provider | File | Models | Env Var |
|
|
723
|
+
|----------|------|--------|---------|
|
|
724
|
+
| OpenAI | `providers/implementations/OpenAIProvider.ts` | GPT-4o, GPT-4o-mini, o1, o3 | `OPENAI_API_KEY` |
|
|
725
|
+
| Anthropic | `providers/implementations/AnthropicProvider.ts` | Claude Sonnet 4, Claude Haiku | `ANTHROPIC_API_KEY` |
|
|
726
|
+
| Gemini | `providers/implementations/GeminiProvider.ts` | Gemini 2.5 Flash, Gemini 2.0 | `GEMINI_API_KEY` |
|
|
727
|
+
| Groq | `providers/implementations/GroqProvider.ts` | Llama 3.3 70B, Gemma2 9B (fast inference) | `GROQ_API_KEY` |
|
|
728
|
+
| Mistral | `providers/implementations/MistralProvider.ts` | Mistral Large, Mistral Small | `MISTRAL_API_KEY` |
|
|
729
|
+
| Together | via OpenAI-compat | Meta-Llama 3.1 70B/8B | `TOGETHER_API_KEY` |
|
|
730
|
+
| xAI | via OpenAI-compat | Grok-2, Grok-2 Mini | `XAI_API_KEY` |
|
|
731
|
+
| Ollama | `providers/implementations/OllamaProvider.ts` | Any locally-hosted model | `OLLAMA_BASE_URL` |
|
|
732
|
+
| OpenRouter | `providers/implementations/OpenRouterProvider.ts` | 200+ models from any provider | `OPENROUTER_API_KEY` |
|
|
559
733
|
|
|
560
|
-
> **
|
|
734
|
+
> **Auto-detection:** When no `provider` is specified, AgentOS scans env vars in priority order (OpenRouter > OpenAI > Anthropic > Gemini > Groq > Together > Mistral > xAI > Ollama) and uses the first configured provider. Set one env var and every helper call works automatically.
|
|
561
735
|
|
|
562
736
|
**Additional components:**
|
|
563
737
|
|
|
@@ -565,7 +739,17 @@ graph TD
|
|
|
565
739
|
- **IProvider** (`providers/IProvider.ts`) -- Interface contract for adding custom LLM providers.
|
|
566
740
|
- **Streaming adapters** -- All providers support token-level streaming via async generators with backpressure control.
|
|
567
741
|
|
|
568
|
-
**Per-request model override:**
|
|
742
|
+
**Per-request model override (high-level helpers):**
|
|
743
|
+
|
|
744
|
+
```typescript
|
|
745
|
+
// Provider-first: AgentOS picks the default model
|
|
746
|
+
await generateText({ provider: 'gemini', prompt: 'Summarize this document' });
|
|
747
|
+
|
|
748
|
+
// Override a specific model
|
|
749
|
+
await generateText({ provider: 'anthropic', model: 'claude-haiku-4-5-20251001', prompt: '...' });
|
|
750
|
+
```
|
|
751
|
+
|
|
752
|
+
**Per-request model override (full runtime):**
|
|
569
753
|
|
|
570
754
|
```typescript
|
|
571
755
|
for await (const chunk of agent.processRequest({
|
|
@@ -573,8 +757,8 @@ for await (const chunk of agent.processRequest({
|
|
|
573
757
|
sessionId: 'session-1',
|
|
574
758
|
textInput: 'Summarize this document',
|
|
575
759
|
options: {
|
|
576
|
-
preferredProviderId: '
|
|
577
|
-
preferredModelId: '
|
|
760
|
+
preferredProviderId: 'gemini',
|
|
761
|
+
preferredModelId: 'gemini-2.5-flash',
|
|
578
762
|
},
|
|
579
763
|
})) { /* ... */ }
|
|
580
764
|
```
|
|
@@ -858,6 +1042,41 @@ See [`docs/memory/MEMORY_SCALING.md`](./docs/memory/MEMORY_SCALING.md), [`docs/m
|
|
|
858
1042
|
|
|
859
1043
|
---
|
|
860
1044
|
|
|
1045
|
+
### Bundled Platform Knowledge
|
|
1046
|
+
|
|
1047
|
+
**Location:** `knowledge/platform-corpus.json`
|
|
1048
|
+
|
|
1049
|
+
AgentOS ships with **243 pre-built knowledge entries** covering the entire platform surface area. When the QueryRouter initializes, these entries are automatically loaded alongside your project-specific documentation corpus, giving every agent instant knowledge about AgentOS capabilities with zero configuration.
|
|
1050
|
+
|
|
1051
|
+
**Coverage breakdown:**
|
|
1052
|
+
|
|
1053
|
+
| Category | Count | What it covers |
|
|
1054
|
+
|----------|-------|---------------|
|
|
1055
|
+
| Tools | 105 | Every tool and channel adapter (Discord, Telegram, LinkedIn, Bluesky, etc.) |
|
|
1056
|
+
| Skills | 79 | All curated skills from the skills registry |
|
|
1057
|
+
| FAQ | 30 | Common questions (voice setup, supported models, streaming, OCR, etc.) |
|
|
1058
|
+
| API | 14 | Core API functions (generateText, streamText, agent, agency, etc.) |
|
|
1059
|
+
| Troubleshooting | 15 | Common errors and their fixes (missing API keys, model not found, etc.) |
|
|
1060
|
+
|
|
1061
|
+
**How it works:**
|
|
1062
|
+
|
|
1063
|
+
- During `router.init()`, the QueryRouter loads `knowledge/platform-corpus.json` from the package directory
|
|
1064
|
+
- Platform entries are merged into the same corpus as user docs, making them searchable via both vector and keyword retrieval
|
|
1065
|
+
- The keyword fallback index covers platform entries, so they work even without an embedding API key
|
|
1066
|
+
|
|
1067
|
+
**Disabling platform knowledge:**
|
|
1068
|
+
|
|
1069
|
+
```typescript
|
|
1070
|
+
const router = new QueryRouter({
|
|
1071
|
+
knowledgeCorpus: ['./docs'],
|
|
1072
|
+
includePlatformKnowledge: false, // Skip bundled platform entries
|
|
1073
|
+
});
|
|
1074
|
+
```
|
|
1075
|
+
|
|
1076
|
+
When disabled, the router only loads your `knowledgeCorpus` directories. This is useful when you want a purely project-specific knowledge base or are building a non-AgentOS product.
|
|
1077
|
+
|
|
1078
|
+
---
|
|
1079
|
+
|
|
861
1080
|
### Safety and Guardrails
|
|
862
1081
|
|
|
863
1082
|
**Location:** `src/safety/runtime/` and `src/safety/guardrails/`
|
|
@@ -1243,7 +1462,30 @@ await agent.initialize(await createAgentOSConfig());
|
|
|
1243
1462
|
|
|
1244
1463
|
### Multiple Providers
|
|
1245
1464
|
|
|
1246
|
-
|
|
1465
|
+
**High-level helpers** (recommended): Just set env vars. No config object needed.
|
|
1466
|
+
|
|
1467
|
+
```bash
|
|
1468
|
+
# Set as many provider keys as you like -- AgentOS uses them on demand
|
|
1469
|
+
export ANTHROPIC_API_KEY=sk-ant-...
|
|
1470
|
+
export OPENAI_API_KEY=sk-...
|
|
1471
|
+
export GEMINI_API_KEY=AIza...
|
|
1472
|
+
export OLLAMA_BASE_URL=http://localhost:11434
|
|
1473
|
+
```
|
|
1474
|
+
|
|
1475
|
+
```typescript
|
|
1476
|
+
import { generateText } from '@framers/agentos';
|
|
1477
|
+
|
|
1478
|
+
// Each call picks the right credentials from env vars automatically
|
|
1479
|
+
await generateText({ provider: 'anthropic', prompt: 'Hello from Claude' });
|
|
1480
|
+
await generateText({ provider: 'openai', prompt: 'Hello from GPT' });
|
|
1481
|
+
await generateText({ provider: 'gemini', prompt: 'Hello from Gemini' });
|
|
1482
|
+
await generateText({ provider: 'ollama', prompt: 'Hello from Llama' });
|
|
1483
|
+
|
|
1484
|
+
// Or omit provider entirely -- auto-detects the first configured one
|
|
1485
|
+
await generateText({ prompt: 'Hello from whichever provider is available' });
|
|
1486
|
+
```
|
|
1487
|
+
|
|
1488
|
+
**Full runtime** — configure multiple providers with explicit fallback:
|
|
1247
1489
|
|
|
1248
1490
|
```typescript
|
|
1249
1491
|
const agent = new AgentOS();
|
|
@@ -1253,10 +1495,12 @@ await agent.initialize({
|
|
|
1253
1495
|
...config,
|
|
1254
1496
|
modelProviderManagerConfig: {
|
|
1255
1497
|
providers: [
|
|
1256
|
-
{ providerId: '
|
|
1257
|
-
config: { apiKey: process.env.OPENAI_API_KEY } },
|
|
1258
|
-
{ providerId: 'anthropic', enabled: true,
|
|
1498
|
+
{ providerId: 'anthropic', enabled: true, isDefault: true,
|
|
1259
1499
|
config: { apiKey: process.env.ANTHROPIC_API_KEY } },
|
|
1500
|
+
{ providerId: 'openai', enabled: true,
|
|
1501
|
+
config: { apiKey: process.env.OPENAI_API_KEY } },
|
|
1502
|
+
{ providerId: 'gemini', enabled: true,
|
|
1503
|
+
config: { apiKey: process.env.GEMINI_API_KEY } },
|
|
1260
1504
|
{ providerId: 'ollama', enabled: true,
|
|
1261
1505
|
config: { baseUrl: process.env.OLLAMA_BASE_URL || 'http://localhost:11434' } },
|
|
1262
1506
|
],
|
|
@@ -1265,8 +1509,8 @@ await agent.initialize({
|
|
|
1265
1509
|
...config.gmiManagerConfig,
|
|
1266
1510
|
defaultGMIBaseConfigDefaults: {
|
|
1267
1511
|
...(config.gmiManagerConfig.defaultGMIBaseConfigDefaults ?? {}),
|
|
1268
|
-
defaultLlmProviderId: '
|
|
1269
|
-
defaultLlmModelId: '
|
|
1512
|
+
defaultLlmProviderId: 'anthropic',
|
|
1513
|
+
defaultLlmModelId: 'claude-sonnet-4-20250514',
|
|
1270
1514
|
},
|
|
1271
1515
|
},
|
|
1272
1516
|
});
|
|
@@ -1277,8 +1521,8 @@ for await (const chunk of agent.processRequest({
|
|
|
1277
1521
|
sessionId: 'session-1',
|
|
1278
1522
|
textInput: 'Hello',
|
|
1279
1523
|
options: {
|
|
1280
|
-
preferredProviderId: '
|
|
1281
|
-
preferredModelId: '
|
|
1524
|
+
preferredProviderId: 'gemini',
|
|
1525
|
+
preferredModelId: 'gemini-2.5-flash',
|
|
1282
1526
|
},
|
|
1283
1527
|
})) { /* ... */ }
|
|
1284
1528
|
```
|
|
@@ -1286,12 +1530,16 @@ for await (const chunk of agent.processRequest({
|
|
|
1286
1530
|
### Environment Variables
|
|
1287
1531
|
|
|
1288
1532
|
```bash
|
|
1289
|
-
#
|
|
1290
|
-
OPENAI_API_KEY=sk-...
|
|
1291
|
-
ANTHROPIC_API_KEY=sk-ant-...
|
|
1292
|
-
GEMINI_API_KEY=AIza...
|
|
1293
|
-
OPENROUTER_API_KEY=sk-or-...
|
|
1294
|
-
|
|
1533
|
+
# LLM providers (set at least one)
|
|
1534
|
+
OPENAI_API_KEY=sk-... # OpenAI (GPT-4o, GPT-4o-mini, o1, o3)
|
|
1535
|
+
ANTHROPIC_API_KEY=sk-ant-... # Anthropic (Claude Sonnet 4, Claude Haiku)
|
|
1536
|
+
GEMINI_API_KEY=AIza... # Google Gemini (2.5 Flash, 2.0)
|
|
1537
|
+
OPENROUTER_API_KEY=sk-or-... # OpenRouter (200+ models, auto-routing)
|
|
1538
|
+
GROQ_API_KEY=gsk_... # Groq (fast inference: Llama 3.3 70B)
|
|
1539
|
+
TOGETHER_API_KEY=... # Together AI (Llama, Mixtral)
|
|
1540
|
+
MISTRAL_API_KEY=... # Mistral (Mistral Large, Small)
|
|
1541
|
+
XAI_API_KEY=xai-... # xAI (Grok-2)
|
|
1542
|
+
OLLAMA_BASE_URL=http://localhost:11434 # Ollama (local models, no API key needed)
|
|
1295
1543
|
|
|
1296
1544
|
# Database
|
|
1297
1545
|
DATABASE_URL=file:./data/agentos.db
|