@framers/agentos 0.1.200 → 0.1.202

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.
Files changed (48) hide show
  1. package/README.md +162 -907
  2. package/dist/memory/CognitiveMemoryManager.d.ts +22 -0
  3. package/dist/memory/CognitiveMemoryManager.d.ts.map +1 -1
  4. package/dist/memory/CognitiveMemoryManager.js +26 -0
  5. package/dist/memory/CognitiveMemoryManager.js.map +1 -1
  6. package/dist/memory/archive/IMemoryArchive.d.ts +179 -0
  7. package/dist/memory/archive/IMemoryArchive.d.ts.map +1 -0
  8. package/dist/memory/archive/IMemoryArchive.js +18 -0
  9. package/dist/memory/archive/IMemoryArchive.js.map +1 -0
  10. package/dist/memory/archive/SqlStorageMemoryArchive.d.ts +130 -0
  11. package/dist/memory/archive/SqlStorageMemoryArchive.d.ts.map +1 -0
  12. package/dist/memory/archive/SqlStorageMemoryArchive.js +243 -0
  13. package/dist/memory/archive/SqlStorageMemoryArchive.js.map +1 -0
  14. package/dist/memory/archive/index.d.ts +8 -0
  15. package/dist/memory/archive/index.d.ts.map +1 -0
  16. package/dist/memory/archive/index.js +7 -0
  17. package/dist/memory/archive/index.js.map +1 -0
  18. package/dist/memory/core/config.d.ts +11 -0
  19. package/dist/memory/core/config.d.ts.map +1 -1
  20. package/dist/memory/core/config.js.map +1 -1
  21. package/dist/memory/io/extension/MemoryToolsExtension.d.ts +6 -0
  22. package/dist/memory/io/extension/MemoryToolsExtension.d.ts.map +1 -1
  23. package/dist/memory/io/extension/MemoryToolsExtension.js.map +1 -1
  24. package/dist/memory/io/tools/RehydrateMemoryTool.d.ts +81 -0
  25. package/dist/memory/io/tools/RehydrateMemoryTool.d.ts.map +1 -0
  26. package/dist/memory/io/tools/RehydrateMemoryTool.js +94 -0
  27. package/dist/memory/io/tools/RehydrateMemoryTool.js.map +1 -0
  28. package/dist/memory/io/tools/index.d.ts +3 -0
  29. package/dist/memory/io/tools/index.d.ts.map +1 -1
  30. package/dist/memory/io/tools/index.js +2 -0
  31. package/dist/memory/io/tools/index.js.map +1 -1
  32. package/dist/memory/mechanisms/consolidation/TemporalGist.d.ts.map +1 -1
  33. package/dist/memory/mechanisms/consolidation/TemporalGist.js +21 -0
  34. package/dist/memory/mechanisms/consolidation/TemporalGist.js.map +1 -1
  35. package/dist/memory/mechanisms/types.d.ts +4 -0
  36. package/dist/memory/mechanisms/types.d.ts.map +1 -1
  37. package/dist/memory/pipeline/consolidation/ConsolidationPipeline.d.ts +6 -0
  38. package/dist/memory/pipeline/consolidation/ConsolidationPipeline.d.ts.map +1 -1
  39. package/dist/memory/pipeline/consolidation/ConsolidationPipeline.js +16 -0
  40. package/dist/memory/pipeline/consolidation/ConsolidationPipeline.js.map +1 -1
  41. package/dist/memory/pipeline/lifecycle/MemoryLifecycleManager.d.ts +11 -0
  42. package/dist/memory/pipeline/lifecycle/MemoryLifecycleManager.d.ts.map +1 -1
  43. package/dist/memory/pipeline/lifecycle/MemoryLifecycleManager.js +43 -5
  44. package/dist/memory/pipeline/lifecycle/MemoryLifecycleManager.js.map +1 -1
  45. package/dist/memory/retrieval/store/SqliteBrain.d.ts.map +1 -1
  46. package/dist/memory/retrieval/store/SqliteBrain.js +7 -0
  47. package/dist/memory/retrieval/store/SqliteBrain.js.map +1 -1
  48. package/package.json +1 -1
package/README.md CHANGED
@@ -1,50 +1,40 @@
1
1
  <div align="center">
2
2
 
3
3
  <a href="https://agentos.sh">
4
- <img src="https://raw.githubusercontent.com/framersai/agentos/master/assets/agentos-primary-no-tagline-transparent-2x.png" alt="AgentOS" height="100" />
4
+ <img src="https://raw.githubusercontent.com/framersai/agentos/master/assets/agentos-primary-no-tagline-transparent-2x.png" alt="AgentOS — TypeScript AI Agent Framework" height="100" />
5
5
  </a>
6
6
 
7
7
  <br />
8
8
 
9
- **Build autonomous AI agents with adaptive intelligence, cognitive memory, and emergent behaviors. Open-source TypeScript runtime.**
9
+ **Open-source TypeScript runtime for autonomous AI agents with cognitive memory, HEXACO personality, and emergent tool forging.**
10
10
 
11
- [![npm version](https://img.shields.io/npm/v/@framers/agentos?style=flat-square&logo=npm&color=cb3837)](https://www.npmjs.com/package/@framers/agentos)
11
+ [![npm](https://img.shields.io/npm/v/@framers/agentos?style=flat-square&logo=npm&color=cb3837)](https://www.npmjs.com/package/@framers/agentos)
12
12
  [![CI](https://img.shields.io/github/actions/workflow/status/framersai/agentos/ci.yml?branch=master&style=flat-square&logo=github&label=CI)](https://github.com/framersai/agentos/actions/workflows/ci.yml)
13
13
  [![tests](https://img.shields.io/badge/tests-3%2C866%2B_passed-2ea043?style=flat-square&logo=vitest&logoColor=white)](https://github.com/framersai/agentos/actions/workflows/ci.yml)
14
14
  [![codecov](https://codecov.io/gh/framersai/agentos/graph/badge.svg)](https://codecov.io/gh/framersai/agentos)
15
15
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.4+-3178c6?style=flat-square&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
16
16
  [![License](https://img.shields.io/badge/License-Apache_2.0-blue?style=flat-square)](https://opensource.org/licenses/Apache-2.0)
17
+ [![Discord](https://img.shields.io/badge/Discord-Join%20Us-5865F2?style=flat-square&logo=discord)](https://discord.gg/VXXC4SJMKh)
17
18
 
18
- [Website](https://agentos.sh) · [Documentation](https://docs.agentos.sh) · [npm](https://www.npmjs.com/package/@framers/agentos) · [GitHub](https://github.com/framersai/agentos)
19
+ [Website](https://agentos.sh) · [Docs](https://docs.agentos.sh) · [npm](https://www.npmjs.com/package/@framers/agentos) · [GitHub](https://github.com/framersai/agentos) · [Discord](https://discord.gg/VXXC4SJMKh) · [Blog](https://docs.agentos.sh/blog)
19
20
 
20
21
  </div>
21
22
 
22
23
  ---
23
24
 
24
- ## Overview
25
+ ## What is AgentOS?
25
26
 
26
- AgentOS is an open-source TypeScript runtime for building autonomous AI agents. Agents have personality traits that shape how they think, cognitive memory that determines what they remember, and emergent capabilities that let them forge new tools at runtime. The result is agents that adapt and improve without retraining.
27
+ AgentOS is a TypeScript runtime for building AI agents that remember, adapt, and create new tools at runtime. Each agent is a **Generalized Mind Instance** (GMI) with its own personality, memory lifecycle, and behavioral adaptation loop.
27
28
 
28
- Unlike frameworks that focus purely on LLM orchestration, AgentOS treats each agent as a **Generalized Mind Instance** (GMI) — a cognitive entity with its own identity, personality, memory lifecycle, and behavioral adaptation loop. This makes it particularly suited for long-running agents, multi-agent teams, and applications where agent consistency matters.
29
-
30
- **What makes it different:**
29
+ ### Why AgentOS over alternatives?
31
30
 
32
31
  | vs. | AgentOS differentiator |
33
32
  |-----|------------------------|
34
- | LangChain / LlamaIndex | Cognitive memory with 8 neuroscience-backed mechanisms, HEXACO personality modulation, runtime tool forging |
35
- | Vercel AI SDK | Multi-agent teams with 6 strategies, full RAG pipeline with 7 vector backends, guardrail packs, voice/telephony |
36
- | AutoGen / CrewAI | Unified orchestration layer (workflow DAGs, agent graphs, goal-driven missions), personality-driven edge routing |
37
-
38
- **Ecosystem packages:**
33
+ | **LangChain / LangGraph** | Cognitive memory (8 neuroscience-backed mechanisms), HEXACO personality, runtime tool forging |
34
+ | **Vercel AI SDK** | Multi-agent teams (6 strategies), full RAG pipeline (7 vector backends), guardrails, voice/telephony |
35
+ | **CrewAI / Mastra** | Unified orchestration (workflow DAGs + agent graphs + goal-driven missions), personality-driven routing |
39
36
 
40
- | Package | Description |
41
- |---------|-------------|
42
- | [`@framers/agentos`](https://www.npmjs.com/package/@framers/agentos) | Core runtime -- agents, providers, memory, RAG, orchestration, guardrails |
43
- | [`@framers/agentos-extensions`](https://www.npmjs.com/package/@framers/agentos-extensions) | Official extension source/catalog (100+ extensions and templates) |
44
- | [`@framers/agentos-extensions-registry`](https://www.npmjs.com/package/@framers/agentos-extensions-registry) | Curated manifest builder for extension catalogs |
45
- | [`@framers/agentos-skills`](https://www.npmjs.com/package/@framers/agentos-skills) | 88 curated SKILL.md skill definitions |
46
- | [`@framers/agentos-skills-registry`](https://www.npmjs.com/package/@framers/agentos-skills-registry) | Skills catalog SDK (query helpers + snapshot factories) |
47
- | [`@framers/sql-storage-adapter`](https://www.npmjs.com/package/@framers/sql-storage-adapter) | Cross-platform SQL persistence (SQLite, sql.js, Postgres, IndexedDB) |
37
+ > **Full comparison:** [AgentOS vs LangGraph vs CrewAI vs Mastra](https://docs.agentos.sh/blog/2026/02/20/agentos-vs-langgraph-vs-crewai)
48
38
 
49
39
  ---
50
40
 
@@ -54,70 +44,58 @@ Unlike frameworks that focus purely on LLM orchestration, AgentOS treats each ag
54
44
  npm install @framers/agentos
55
45
  ```
56
46
 
57
- Set any provider's API key:
47
+ ### Configure API Keys
58
48
 
59
49
  ```bash
60
- export OPENAI_API_KEY=sk-... # or ANTHROPIC_API_KEY, GEMINI_API_KEY, GROQ_API_KEY, etc.
50
+ # Environment variables (recommended for production)
51
+ export OPENAI_API_KEY=sk-...
52
+ export ANTHROPIC_API_KEY=sk-ant-...
53
+ export GEMINI_API_KEY=AIza...
54
+
55
+ # Key rotation — comma-separated keys auto-rotate with quota detection
56
+ export OPENAI_API_KEY=sk-key1,sk-key2,sk-key3
57
+ ```
58
+
59
+ ```typescript
60
+ // Or pass apiKey inline (multi-tenant apps, tests, dynamic config)
61
+ await generateText({ provider: 'openai', apiKey: 'sk-...', prompt: '...' });
61
62
  ```
62
63
 
64
+ All high-level functions accept `apiKey` and `baseUrl` parameters.
65
+
63
66
  ---
64
67
 
65
68
  ## Quick Start
66
69
 
67
- ### 1. Generate Text
68
-
69
- AgentOS auto-detects which provider to use from your environment variables and maps each provider to a sensible default model (see [Default Models Per Provider](#default-models-per-provider) below):
70
+ ### Generate Text
70
71
 
71
72
  ```typescript
72
73
  import { generateText } from '@framers/agentos';
73
74
 
74
- // Zero config -- auto-detects provider from env vars, uses its default model
75
- // Priority: OPENAI_API_KEY ANTHROPIC_API_KEY OPENROUTER_API_KEY → GEMINI → ...
76
- const result = await generateText({
77
- prompt: 'Explain how TCP handshakes work in 3 bullets.',
75
+ // Auto-detect provider from env vars
76
+ const { text } = await generateText({
77
+ prompt: 'Explain TCP handshakes in 3 bullets.',
78
78
  });
79
- console.log(result.text);
80
79
 
81
- // Pin a provider -- uses that provider's default model (e.g. anthropic → claude-sonnet-4)
82
- const pinned = await generateText({
80
+ // Pin a provider
81
+ const { text: claude } = await generateText({
83
82
  provider: 'anthropic',
84
83
  prompt: 'Compare TCP and UDP.',
85
84
  });
86
-
87
- // Full control -- explicit provider + model override
88
- const custom = await generateText({
89
- provider: 'openai',
90
- model: 'gpt-4o-mini', // override the default (gpt-4o)
91
- prompt: 'What is the capital of France?',
92
- });
93
85
  ```
94
86
 
95
- 16 providers supported. Auto-fallback on 402/429/5xx — if the primary provider fails, the next available provider is tried automatically.
87
+ 16 providers. Auto-fallback on 402/429/5xx.
96
88
 
97
- ### 2. Streaming
89
+ ### Streaming
98
90
 
99
91
  ```typescript
100
92
  import { streamText } from '@framers/agentos';
101
93
 
102
- const stream = streamText({
103
- provider: 'openai',
104
- prompt: 'Write a haiku about distributed systems.',
105
- });
106
-
107
- // Iterate token-by-token
108
- for await (const chunk of stream.textStream) {
109
- process.stdout.write(chunk);
110
- }
111
-
112
- // Or await the full result
113
- const fullText = await stream.text;
114
- const usage = await stream.usage;
115
- console.log(`\n\nTokens used: ${usage.totalTokens}`);
94
+ const stream = streamText({ provider: 'openai', prompt: 'Write a haiku.' });
95
+ for await (const chunk of stream.textStream) process.stdout.write(chunk);
116
96
  ```
117
97
 
118
- ### 3. Structured Output
119
-
120
- Extract typed data from unstructured text with Zod validation:
98
+ ### Structured Output
121
99
 
122
100
  ```typescript
123
101
  import { generateObject } from '@framers/agentos';
@@ -126,943 +104,220 @@ import { z } from 'zod';
126
104
  const { object } = await generateObject({
127
105
  provider: 'gemini',
128
106
  schema: z.object({
129
- name: z.string(),
130
107
  sentiment: z.enum(['positive', 'negative', 'neutral']),
131
108
  topics: z.array(z.string()),
132
109
  }),
133
- prompt: 'Analyze: "The new iPhone camera is incredible but the battery life is disappointing."',
110
+ prompt: 'Analyze: "Great camera but disappointing battery."',
134
111
  });
135
-
136
- console.log(object);
137
- // { name: "iPhone Review", sentiment: "neutral", topics: ["camera", "battery"] }
138
112
  ```
139
113
 
140
- Failed parses are automatically retried with error feedback so the model can self-correct.
141
-
142
- ### 4. Create an Agent
143
-
144
- The simplest possible agent — 3 lines:
114
+ ### Create an Agent
145
115
 
146
116
  ```typescript
147
117
  import { agent } from '@framers/agentos';
148
118
 
149
119
  const bot = agent({ provider: 'anthropic', instructions: 'You are a helpful assistant.' });
150
120
  const reply = await bot.session('demo').send('What is 2+2?');
151
- console.log(reply.text); // "4"
121
+ console.log(reply.text);
152
122
  ```
153
123
 
154
- #### Agent with Personality & Memory
155
-
156
- The key differentiator. Agents have HEXACO personality traits that shape their communication style, and cognitive memory that determines what they retain:
124
+ ### Agent with Personality & Memory
157
125
 
158
126
  ```typescript
159
- import { agent } from '@framers/agentos';
160
-
161
127
  const tutor = agent({
162
128
  provider: 'anthropic',
163
- instructions: 'You are a patient computer science tutor.',
129
+ instructions: 'You are a patient CS tutor.',
164
130
  personality: {
165
- openness: 0.9, // creative, exploratory answers
166
- conscientiousness: 0.95, // thorough, well-structured
167
- agreeableness: 0.85, // warm, encouraging tone
168
- },
169
- memory: {
170
- enabled: true,
171
- cognitive: true, // Ebbinghaus decay, reconsolidation, involuntary recall
131
+ openness: 0.9,
132
+ conscientiousness: 0.95,
133
+ agreeableness: 0.85,
172
134
  },
173
- tools: [{
174
- name: 'run_code',
175
- description: 'Execute a code snippet and return output.',
176
- parameters: { type: 'object', properties: { code: { type: 'string' } }, required: ['code'] },
177
- execute: async ({ code }) => ({ success: true, output: `Ran: ${code}` }),
178
- }],
135
+ memory: { enabled: true, cognitive: true },
179
136
  });
180
137
 
181
- // Sessions maintain conversation history
182
138
  const session = tutor.session('student-1');
183
- const reply = await session.send('Explain recursion with an analogy.');
184
- console.log(reply.text);
185
-
186
- // Memory persists -- the agent remembers prior context
187
- const followUp = await session.send('Can you expand on that?');
188
- console.log(followUp.text);
189
-
190
- // Export agent config for portability
191
- const config = tutor.exportJSON();
139
+ await session.send('Explain recursion with an analogy.');
140
+ await session.send('Can you expand on that?'); // remembers context
192
141
  ```
193
142
 
194
- The lightweight API also supports per-call model routing and lifecycle middleware without booting the full `AgentOS` runtime:
195
-
196
- ```typescript
197
- import type { IModelRouter } from '@framers/agentos';
198
-
199
- const router: IModelRouter = {
200
- routerId: 'fast-vs-quality',
201
- async initialize() {},
202
- async selectModel(params) {
203
- if (params.optimizationPreference === 'speed') {
204
- return null; // fall back to the caller's provider/model
205
- }
206
- return null;
207
- },
208
- };
209
-
210
- const reviewer = agent({
211
- instructions: 'Review drafts for policy and tone.',
212
- router,
213
- skills: [{
214
- skill: {
215
- name: 'policy-review',
216
- description: 'Review output before it is shown to users.',
217
- content: 'Flag unsafe content and keep the tone concise.',
218
- },
219
- frontmatter: {} as any,
220
- }],
221
- onBeforeGeneration: async (ctx) => ({
222
- ...ctx,
223
- messages: [{ role: 'system', content: 'User is on the free plan.' }, ...ctx.messages],
224
- }),
225
- onAfterGeneration: async (result) => ({
226
- ...result,
227
- text: result.text.trim(),
228
- }),
229
- });
230
- ```
231
-
232
- ### 5. Multimodal (Image, Video, Audio, OCR, Embeddings)
233
-
234
- ```typescript
235
- import {
236
- generateImage,
237
- performOCR,
238
- embedText,
239
- generateVideo,
240
- generateMusic,
241
- } from '@framers/agentos';
242
-
243
- // Generate an image (supports OpenAI, Stability, Replicate, BFL, Fal)
244
- const image = await generateImage({
245
- provider: 'openai',
246
- prompt: 'A cyberpunk cityscape at sunset, neon signs reflecting in rain puddles',
247
- size: '1024x1024',
248
- });
249
- console.log(image.images[0].url);
250
-
251
- // OCR: extract text from images (progressive tiers: local -> cloud LLM)
252
- const ocr = await performOCR({
253
- image: '/tmp/receipt.png',
254
- strategy: 'progressive', // tries fast local OCR first, falls back to cloud
255
- });
256
- console.log(ocr.text);
257
-
258
- // Embeddings (OpenAI, Ollama, or any compatible provider)
259
- const embedding = await embedText({
260
- provider: 'openai',
261
- input: ['Hello world', 'Goodbye world'],
262
- dimensions: 256,
263
- });
264
- console.log(embedding.embeddings[0].length); // 256
265
-
266
- // Video generation
267
- const video = await generateVideo({
268
- prompt: 'A timelapse of a flower blooming',
269
- });
270
-
271
- // Music generation
272
- const music = await generateMusic({
273
- prompt: 'Lo-fi hip hop beat for studying',
274
- });
275
- ```
276
-
277
- ### 6. Multi-Agent Teams
278
-
279
- Coordinate specialized agents with built-in strategies:
143
+ ### Multi-Agent Teams
280
144
 
281
145
  ```typescript
282
146
  import { agency } from '@framers/agentos';
283
147
 
284
148
  const team = agency({
149
+ strategy: 'graph',
285
150
  agents: {
286
- researcher: {
287
- instructions: 'Find relevant facts and data.',
288
- provider: 'anthropic',
289
- },
290
- writer: {
291
- instructions: 'Write a clear, engaging summary.',
292
- provider: 'openai',
293
- },
294
- reviewer: {
295
- instructions: 'Check for accuracy and suggest improvements.',
296
- provider: 'gemini',
297
- dependsOn: ['writer'], // runs after writer completes
298
- },
151
+ researcher: { provider: 'anthropic', instructions: 'Find relevant facts.' },
152
+ writer: { provider: 'openai', instructions: 'Write a clear summary.', dependsOn: ['researcher'] },
153
+ reviewer: { provider: 'gemini', instructions: 'Check accuracy.', dependsOn: ['writer'] },
299
154
  },
300
- strategy: 'graph', // dependency-based DAG execution
301
- memory: { shared: true }, // agents share context
302
155
  });
303
156
 
304
157
  const result = await team.generate('Compare TCP vs UDP for game networking.');
305
- console.log(result.text);
306
-
307
- // Streaming works too
308
- const stream = team.stream('Explain QUIC protocol benefits.');
309
- for await (const chunk of stream.textStream) {
310
- process.stdout.write(chunk);
311
- }
312
- ```
313
-
314
- 6 strategies — each controls how agents coordinate:
315
-
316
- ```typescript
317
- // Sequential: A → B → C, each gets the previous output
318
- agency({ agents, strategy: 'sequential' });
319
-
320
- // Parallel: all agents run at once, synthesis agent merges results
321
- agency({ agents, strategy: 'parallel' });
322
-
323
- // Debate: agents argue across rounds, a judge picks the best
324
- agency({ agents, strategy: 'debate', maxRounds: 3 });
325
-
326
- // Review loop: drafter writes, reviewer critiques, iterate until approved
327
- agency({ agents, strategy: 'review-loop' });
328
-
329
- // Hierarchical: orchestrator dispatches sub-tasks to specialists
330
- agency({ agents, strategy: 'hierarchical' });
331
-
332
- // Graph (DAG): explicit dependency order via dependsOn
333
- agency({ agents, strategy: 'graph' }); // auto-detected when dependsOn is used
334
- ```
335
-
336
- ### 7. Orchestration (Workflows, Graphs, Missions)
337
-
338
- Three authoring APIs that compile to one graph runtime. Choose based on how much control you need:
339
-
340
- ```typescript
341
- import {
342
- workflow,
343
- AgentGraph,
344
- mission,
345
- gmiNode,
346
- toolNode,
347
- START,
348
- END,
349
- } from '@framers/agentos/orchestration';
350
- import { z } from 'zod';
351
-
352
- // 1. workflow() -- deterministic DAG with typed I/O
353
- const pipeline = workflow('content-pipeline')
354
- .input(z.object({ topic: z.string() }))
355
- .returns(z.object({ summary: z.string() }))
356
- .step('research', { tool: 'web_search' })
357
- .then('draft', { gmi: { instructions: 'Write a blog post from the research.' } })
358
- .then('review', { gmi: { instructions: 'Review for accuracy and tone.' } })
359
- .compile();
360
-
361
- const result = await pipeline.invoke({ topic: 'WebAssembly in 2026' });
362
-
363
- // 2. AgentGraph -- explicit nodes, edges, cycles, subgraphs
364
- const graph = new AgentGraph({
365
- input: z.object({ topic: z.string() }),
366
- scratch: z.object({ draft: z.string().optional() }),
367
- artifacts: z.object({ summary: z.string().optional() }),
368
- })
369
- .addNode('draft', gmiNode({ instructions: 'Draft a summary', executionMode: 'single_turn' }))
370
- .addNode('publish', toolNode('publish_report'))
371
- .addEdge(START, 'draft')
372
- .addEdge('draft', 'publish')
373
- .addEdge('publish', END)
374
- .compile();
375
-
376
- await graph.invoke({ topic: 'quantum computing' });
377
-
378
- // 3. mission() -- goal-driven, planner decides the steps
379
- const researcher = mission('deep-research')
380
- .input(z.object({ topic: z.string() }))
381
- .goal('Research {topic} and produce a cited summary')
382
- .returns(z.object({ summary: z.string() }))
383
- .planner({ strategy: 'plan_and_execute', maxSteps: 8 })
384
- .compile();
385
-
386
- // Preview the plan without executing
387
- const preview = await researcher.explain({ topic: 'AI safety' });
388
- console.log(preview.steps.map(s => s.id));
389
- ```
390
-
391
- All three support persistent checkpointing for fault recovery and time-travel debugging.
392
-
393
- See [`docs/orchestration/WORKFLOW_DSL.md`](./docs/orchestration/WORKFLOW_DSL.md), [`docs/architecture/AGENT_GRAPH.md`](./docs/architecture/AGENT_GRAPH.md), [`docs/orchestration/MISSION_API.md`](./docs/orchestration/MISSION_API.md).
394
-
395
- ### 8. Voice Pipeline
396
-
397
- ```typescript
398
- import { agent } from '@framers/agentos';
399
-
400
- const receptionist = agent({
401
- provider: 'openai',
402
- instructions: 'You are a friendly receptionist for a dental clinic.',
403
- voice: {
404
- tts: { provider: 'elevenlabs', voice: 'Rachel' },
405
- stt: { provider: 'deepgram' },
406
- },
407
- });
408
158
  ```
409
159
 
410
- Telephony providers: Twilio, Telnyx, Plivo. Speech: ElevenLabs, Deepgram, OpenAI Whisper, and more.
411
-
412
- ### 9. Guardrails
160
+ 6 strategies: `sequential` · `parallel` · `debate` · `review-loop` · `hierarchical` · `graph`
413
161
 
414
- 5-tier security with 6 guardrail packs:
162
+ ### Multimodal
415
163
 
416
164
  ```typescript
417
- import { agent } from '@framers/agentos';
165
+ import { generateImage, generateVideo, generateMusic, performOCR, embedText } from '@framers/agentos';
418
166
 
419
- const secureBot = agent({
420
- provider: 'anthropic',
421
- instructions: 'You are a customer support agent.',
422
- security: { tier: 'strict' },
423
- guardrails: {
424
- input: ['pii-redaction', 'ml-classifiers'], // block PII + detect injection
425
- output: ['grounding-guard', 'code-safety'], // prevent hallucination + unsafe code
426
- },
427
- });
167
+ const image = await generateImage({ provider: 'openai', prompt: 'Neon cityscape at sunset' });
168
+ const video = await generateVideo({ prompt: 'Drone over misty forest' });
169
+ const music = await generateMusic({ prompt: 'Lo-fi hip hop beat' });
170
+ const ocr = await performOCR({ image: './receipt.png', strategy: 'progressive' });
171
+ const embed = await embedText({ provider: 'openai', input: ['hello', 'world'] });
428
172
  ```
429
173
 
430
- 5 security tiers: `dangerous` > `permissive` > `balanced` > `strict` > `paranoid`.
431
-
432
- 6 guardrail packs:
433
- - **PII Redaction** -- four-tier detection (regex + NLP + NER + LLM)
434
- - **ML Classifiers** -- toxicity, injection, jailbreak via ONNX BERT
435
- - **Topicality** -- embedding-based topic enforcement + drift detection
436
- - **Code Safety** -- OWASP Top 10 code scanning (25 regex rules)
437
- - **Grounding Guard** -- RAG-source claim verification and hallucination detection
438
- - **Content Policy Rewriter** -- 8 categories, LLM rewrite/block, 4 presets
439
-
440
- ### 10. Citation Verification
174
+ ### Orchestration
441
175
 
442
- Verify claims in agent responses against sources using cosine similarity:
176
+ Three authoring APIs, one graph runtime:
443
177
 
444
178
  ```typescript
445
- import { CitationVerifier } from '@framers/agentos';
179
+ import { workflow, AgentGraph, mission } from '@framers/agentos/orchestration';
446
180
 
447
- const verifier = new CitationVerifier({
448
- embedFn: async (texts) => embeddingManager.embedBatch(texts),
449
- });
450
-
451
- const result = await verifier.verify(
452
- "Tokyo has a population of 14 million. It is the capital of Japan.",
453
- [
454
- { content: "Tokyo proper has a population of approximately 14 million.", url: "https://example.com" },
455
- { content: "Tokyo is the capital and largest city of Japan.", url: "https://example.com/japan" },
456
- ]
457
- );
458
-
459
- console.log(result.summary);
460
- // "2/2 claims verified (100%)"
461
- console.log(result.claims[0]);
462
- // { text: "Tokyo has a population of 14 million.", verdict: "supported", confidence: 0.87 }
463
- ```
181
+ // 1. workflow() deterministic DAG
182
+ const pipe = workflow('content').step('research', { tool: 'web_search' }).then('draft', { gmi: { instructions: '...' } }).compile();
464
183
 
465
- On-demand tool for agents:
184
+ // 2. AgentGraph — cycles, subgraphs
185
+ const graph = new AgentGraph('review').addNode('draft', gmiNode({...})).addNode('review', judgeNode({...})).addEdge('draft','review').compile();
466
186
 
467
- ```typescript
468
- // Agent can call verify_citations to check its own output
469
- verify_citations({
470
- text: "The speed of light is 300,000 km/s.",
471
- webFallback: true, // search web if sources don't match
472
- })
187
+ // 3. mission() — goal-driven, planner decides steps
188
+ const m = mission('research').goal('Research {topic}').planner({ strategy: 'adaptive' }).compile();
473
189
  ```
474
190
 
475
- Automatic during deep research — set `verifyCitations: true` in config:
191
+ ---
476
192
 
477
- ```json
478
- { "queryRouter": { "verifyCitations": true } }
479
- ```
193
+ ## Key Features
194
+
195
+ | Category | Highlights |
196
+ |----------|-----------|
197
+ | **LLM Providers** | 16 providers: OpenAI, Anthropic, Gemini, Groq, Ollama, OpenRouter, Together, Mistral, xAI, Claude CLI, Gemini CLI, + 5 image/video |
198
+ | **Cognitive Memory** | 8 neuroscience-backed mechanisms (reconsolidation, RIF, involuntary recall, FOK, gist extraction, schema encoding, source decay, emotion regulation) |
199
+ | **HEXACO Personality** | 6 traits modulate memory, retrieval bias, response style — agents have consistent identity |
200
+ | **RAG Pipeline** | 7 vector backends (InMemory, SQL, HNSW, Qdrant, Neo4j, pgvector, Pinecone) · 4 retrieval strategies · GraphRAG |
201
+ | **Multi-Agent Teams** | 6 coordination strategies · shared memory · inter-agent messaging · HITL approval gates |
202
+ | **Orchestration** | `workflow()` DAGs · `AgentGraph` cycles/subgraphs · `mission()` goal-driven planning · persistent checkpointing |
203
+ | **Guardrails** | 5 security tiers · 6 packs (PII redaction, ML classifiers, topicality, code safety, grounding, content policy) |
204
+ | **Emergent Capabilities** | Runtime tool forging · dynamic skill management · tiered promotion (session → agent → shared) |
205
+ | **Voice & Telephony** | ElevenLabs, Deepgram, OpenAI Whisper · Twilio, Telnyx, Plivo |
206
+ | **Channels** | 37 platform adapters (Telegram, Discord, Slack, WhatsApp, webchat, and more) |
207
+ | **Structured Output** | Zod-validated JSON extraction with retry · provider-native structured output |
208
+ | **Observability** | OpenTelemetry traces/metrics · usage ledger · cost guard · circuit breaker |
480
209
 
481
- ### Default Models Per Provider
210
+ ---
482
211
 
483
- When you specify `provider` without `model`, these defaults are used:
212
+ ## Default Models Per Provider
484
213
 
485
- | Provider | Default Text Model | Default Image Model | Env Var |
214
+ | Provider | Text Model | Image Model | Env Var |
486
215
  |---|---|---|---|
487
216
  | `openai` | gpt-4o | gpt-image-1 | `OPENAI_API_KEY` |
488
- | `anthropic` | claude-sonnet-4 | -- | `ANTHROPIC_API_KEY` |
489
- | `gemini` | gemini-2.5-flash | -- | `GEMINI_API_KEY` |
217
+ | `anthropic` | claude-sonnet-4 | | `ANTHROPIC_API_KEY` |
218
+ | `gemini` | gemini-2.5-flash | | `GEMINI_API_KEY` |
219
+ | `groq` | llama-3.3-70b | — | `GROQ_API_KEY` |
490
220
  | `ollama` | llama3.2 | stable-diffusion | `OLLAMA_BASE_URL` |
491
- | `groq` | llama-3.3-70b-versatile | -- | `GROQ_API_KEY` |
492
- | `openrouter` | openai/gpt-4o | -- | `OPENROUTER_API_KEY` |
493
- | `together` | Meta-Llama-3.1-70B | -- | `TOGETHER_API_KEY` |
494
- | `mistral` | mistral-large-latest | -- | `MISTRAL_API_KEY` |
495
- | `xai` | grok-2 | -- | `XAI_API_KEY` |
496
- | `stability` | -- | stable-diffusion-xl | `STABILITY_API_KEY` |
497
- | `replicate` | -- | flux-1.1-pro | `REPLICATE_API_TOKEN` |
498
- | `bfl` | -- | flux-pro-1.1 | `BFL_API_KEY` |
499
- | `fal` | -- | fal-ai/flux/dev | `FAL_API_KEY` |
500
- | `claude-code-cli` | claude-sonnet-4 | -- | `claude` binary on PATH |
501
- | `gemini-cli` | gemini-2.5-flash | -- | `gemini` binary on PATH |
502
- | `stable-diffusion-local` | -- | v1-5-pruned-emaonly | `STABLE_DIFFUSION_LOCAL_BASE_URL` |
503
-
504
- Auto-detection priority: OpenAI > Anthropic > OpenRouter > Gemini > Groq > Together > Mistral > xAI > claude-code-cli > gemini-cli > Ollama > image-only providers.
505
-
506
- ---
507
-
508
- ## Core Concepts
509
-
510
- ### GMI (Generalized Modular Intelligence)
511
-
512
- Each agent is backed by a GMI instance -- the "brain" that manages working memory, persona overlays, context assembly, and the cognitive loop. A single runtime can manage multiple GMI instances via `GMIManager`.
513
-
514
- GMI components: working memory (7 +/- 2 slots, Baddeley's model), context manager, persona overlay switching, adaptation manager (learning rate, style drift), and multi-layer memory (episodic, semantic, procedural, prospective).
515
-
516
- See [`docs/architecture/ARCHITECTURE.md`](./docs/architecture/ARCHITECTURE.md) for detailed diagrams and data flow.
517
-
518
- ### HEXACO Personality
519
-
520
- Six personality dimensions modulate agent behavior at every level -- from memory retrieval to response style:
521
-
522
- | Trait | High Value Effect | Low Value Effect |
523
- |-------|-------------------|------------------|
524
- | **Honesty-Humility** | Source skepticism, transparent reasoning | Confident assertions |
525
- | **Emotionality** | Memory reconsolidation drift toward mood | Stable recall |
526
- | **Extraversion** | Stronger feeling-of-knowing, verbose output | Reserved, concise output |
527
- | **Agreeableness** | Emotion regulation during consolidation | Unfiltered expression |
528
- | **Conscientiousness** | Retrieval-induced forgetting of irrelevant data | Broader recall |
529
- | **Openness** | Involuntary recall, novelty-boosted encoding | Schema-conforming recall |
530
-
531
- Personality traits are set at agent creation and can be adapted within bounded limits at runtime via `adapt_personality`.
532
-
533
- ### Cognitive Memory
534
-
535
- 8 neuroscience-backed mechanisms, all HEXACO personality-modulated:
536
-
537
- | Mechanism | Effect | Citation |
538
- |-----------|--------|----------|
539
- | Reconsolidation | Retrieved memories drift toward current mood | [Nader, Schiller & LeDoux (2000)](https://doi.org/10.1038/35021052). *Nature*, 406, 722-726 |
540
- | Retrieval-Induced Forgetting | Retrieving one memory suppresses similar competitors | [Anderson, Bjork & Bjork (1994)](https://doi.org/10.1037/0278-7393.20.5.1063). *JEP: Learning*, 20, 1063-1087 |
541
- | Involuntary Recall | Random surfacing of old high-vividness memories | [Berntsen (1996)](https://doi.org/10.1002/(SICI)1099-0720(199610)10:5%3C435::AID-ACP395%3E3.0.CO;2-8). *Applied Cognitive Psychology*, 10, 435-454 |
542
- | Metacognitive FOK | Feeling-of-knowing scoring for tip-of-tongue states | [Hart (1965)](https://doi.org/10.1037/h0022263). *JEPG*, 56, 208-216 |
543
- | Temporal Gist Extraction | Old traces compressed to core assertions | [Reyna & Brainerd (1995)](https://doi.org/10.1006/drev.1995.1002). *Developmental Review*, 15, 3-47 |
544
- | Schema Encoding | Novel input boosted, schema-matching encoded efficiently | [Bartlett (1932)](https://doi.org/10.1017/CBO9780511759185). *Remembering*. Cambridge University Press |
545
- | Source Confidence Decay | Agent inferences decay faster than observations | [Johnson, Hashtroudi & Lindsay (1993)](https://doi.org/10.1037/0033-2909.114.1.3). *Psych. Bulletin*, 114, 3-28 |
546
- | Emotion Regulation | Reappraisal + suppression during consolidation | [Gross (1998)](https://doi.org/10.1037/1089-2680.2.3.271). *Review of General Psychology*, 2, 271-299 |
547
-
548
- **HEXACO Personality Modulation** -- each mechanism's intensity is governed by one or more HEXACO traits:
549
-
550
- | HEXACO Trait | Mechanisms Modulated | Effect |
551
- |--------------|---------------------|--------|
552
- | Emotionality | Reconsolidation | Higher emotionality increases mood-congruent drift rate |
553
- | Conscientiousness | Retrieval-Induced Forgetting | Higher conscientiousness strengthens suppression of irrelevant competitors |
554
- | Openness | Involuntary Recall, Schema Encoding | Higher openness increases involuntary recall probability and novelty boost |
555
- | Extraversion | Metacognitive FOK | Higher extraversion strengthens feeling-of-knowing confidence signals |
556
- | Honesty-Humility | Source Confidence Decay | Higher honesty increases skepticism of agent-inferred sources |
557
- | Agreeableness | Emotion Regulation | Higher agreeableness strengthens reappraisal during consolidation |
558
-
559
- **Using cognitive mechanisms with `agent()`:**
560
-
561
- ```typescript
562
- import { agent } from '@framers/agentos';
563
-
564
- const researcher = agent({
565
- provider: 'anthropic',
566
- instructions: 'You are a thorough research analyst.',
567
- personality: {
568
- openness: 0.9, // High openness -> more involuntary recall, stronger novelty bias
569
- conscientiousness: 0.85, // High conscientiousness -> stronger RIF suppression
570
- emotionality: 0.6, // Moderate -> moderate reconsolidation drift
571
- },
572
- memory: { enabled: true },
573
- cognitiveMechanisms: {
574
- // All 8 mechanisms enabled with defaults -- just pass {}
575
- // Or tune individual mechanisms:
576
- reconsolidation: { driftRate: 0.08 },
577
- involuntaryRecall: { probability: 0.12 },
578
- temporalGist: { ageThresholdDays: 30 },
579
- },
580
- });
581
- ```
582
-
583
- Pass `{}` for all defaults, or omit entirely to disable (zero overhead).
584
-
585
- Memory is organized in a 4-tier hierarchy: `core/` (encoding, decay, working memory), `retrieval/` (composite scoring, graph, prospective), `pipeline/` (consolidation, observation, lifecycle), `io/` (ingestion, import/export).
586
-
587
- **Automatic Memory Type Decomposition** -- the Observer→Reflector pipeline automatically classifies raw conversation into 5 memory types:
588
-
589
- | Type | What it stores | Example |
590
- |------|---------------|---------|
591
- | **Episodic** | Autobiographical events | "User and I discussed deployment on March 5th" |
592
- | **Semantic** | Durable facts | "User is a software engineer" |
593
- | **Procedural** | Patterns and preferences | "User prefers concise answers" |
594
- | **Prospective** | Future intentions | "User said they'd check back Friday" |
595
- | **Relational** | Trust signals and bonds | "User shared vulnerability about work stress" |
596
-
597
- The Reflector uses chain-of-thought reasoning and HEXACO personality bias to classify each trace. Commitment notes are auto-registered as prospective reminders.
598
-
599
- **KnowledgeGraph** is enabled by default -- spreading activation (Collins & Quillian model), Hebbian co-activation learning, conflict detection, and graph-boosted retrieval scoring. Set `graph: { disabled: true }` to opt out.
600
-
601
- **HyDE Memory Retrieval** -- a memory-specific Hypothetical Document Embedding retriever auto-attaches when an LLM invoker is available. Generates hypothetical stored traces for vague queries like "that thing about cats", improving recall. Opt-in per query via `retrieve({ hyde: true })`.
602
-
603
- **Prompt Assembly Guidance** -- the `MemoryPromptAssembler` injects a personality-aware preamble that teaches the LLM how to use each memory type differently (semantic as background truth, episodic woven naturally, prospective as action items, relational as tone modulators).
604
-
605
- **SqliteBrain Persistence** -- the cognitive memory path writes through to SqliteBrain's SQL tables via `@framers/sql-storage-adapter`. Traces survive process restarts. In-memory vector index is the hot read path; SQL is the durable backing store.
606
-
607
- **Full API Surface** via `AgentMemory`:
608
-
609
- ```typescript
610
- const memory = AgentMemory.wrap(cognitiveManager);
611
-
612
- // Visualization
613
- const graph = await memory.getGraph(); // nodes, edges, clusters
614
- const dist = await memory.getStrengthDistribution(); // per-type stats
615
- const conflicts = await memory.getConflicts(); // contradicting traces
616
-
617
- // Inspection
618
- const relational = await memory.getRelationalMemories();
619
- const working = await memory.getWorkingMemory(); // in-focus slots
620
- const stats = await memory.getObservationStats(); // pipeline health
621
-
622
- // Portability
623
- const snapshot = await memory.exportSnapshot(); // full state export
624
- await memory.importSnapshot(snapshot); // restore from export
625
- ```
626
-
627
- See [`docs/memory/COGNITIVE_MECHANISMS.md`](./docs/memory/COGNITIVE_MECHANISMS.md) for API reference and 30+ APA citations.
628
-
629
- ### Multimodal RAG
630
-
631
- Complete retrieval-augmented generation pipeline:
632
-
633
- - **7 vector backends:** InMemory, SQL (SQLite/Postgres), HNSW, Qdrant, Neo4j, Postgres+pgvector, Pinecone
634
- - **4 retrieval strategies:** keyword, vector, hybrid (RRF), HyDE (Hypothetical Document Embedding)
635
- - **GraphRAG:** entity/relationship extraction, Louvain community detection, local + global search
636
- - **4-tier scaling path:** SQLite (dev) > HNSW sidecar (auto at 1K vectors) > Postgres+pgvector > Qdrant/Pinecone
637
- - **Document ingestion:** PDF, DOCX, HTML, Markdown, URL
638
- - **One-command migration** between any two backends via `MigrationEngine`
639
-
640
- See [`docs/memory/RAG_MEMORY_CONFIGURATION.md`](./docs/memory/RAG_MEMORY_CONFIGURATION.md) and [`docs/memory/MULTIMODAL_RAG.md`](./docs/memory/MULTIMODAL_RAG.md).
641
-
642
- ### LLM Output Validation
643
-
644
- Structured LLM outputs are validated with Zod schemas, retried with error feedback on failure, and use provider-native structured output when available.
645
-
646
- ```typescript
647
- import { createValidatedInvoker } from '@framers/agentos/core/validation';
648
- import { z } from 'zod';
649
-
650
- const PersonalitySchema = z.object({
651
- honesty: z.number().min(0).max(100),
652
- emotionality: z.number().min(0).max(100),
653
- extraversion: z.number().min(0).max(100),
654
- });
655
-
656
- // Wrap any LLM invoker with Zod validation + retry
657
- const validated = createValidatedInvoker(llmInvoker, PersonalitySchema, {
658
- maxRetries: 2, // retry with error feedback on failure
659
- injectSchemaOnRetry: true, // include schema description in retry prompt
660
- });
661
-
662
- const personality = await validated(systemPrompt, userPrompt);
663
- // personality is typed as { honesty: number; emotionality: number; extraversion: number }
664
- ```
665
-
666
- **Centralized JSON extraction** handles all messy LLM output formats:
667
-
668
- ```typescript
669
- import { extractJson } from '@framers/agentos/core/validation';
670
-
671
- extractJson('```json\n{"key": "value"}\n```'); // '{"key": "value"}'
672
- extractJson('<thinking>hmm</thinking>\n{"a": 1}'); // '{"a": 1}'
673
- extractJson('Result: {"a": 1} done'); // '{"a": 1}'
674
- extractJson('{"a":1}\n{"b":2}'); // '[{"a":1},{"b":2}]' (JSONL)
675
- ```
676
-
677
- **Agent-level validation** via `responseSchema`:
678
-
679
- ```typescript
680
- const extractor = agent({
681
- instructions: 'Extract entities as JSON',
682
- responseSchema: z.object({ entities: z.array(z.string()) }),
683
- });
684
-
685
- const result = await extractor.generate('Find entities in: ...');
686
- // result.parsed?.entities is string[] — typed and validated
687
- ```
688
-
689
- **Schema primitives** for composing domain-specific schemas:
690
-
691
- ```typescript
692
- import { MemoryTypeEnum, ConfidenceScore, EntityArray } from '@framers/agentos/core/validation';
693
-
694
- const MySchema = z.object({
695
- type: MemoryTypeEnum, // 'episodic' | 'semantic' | 'procedural' | 'prospective' | 'relational'
696
- confidence: ConfidenceScore, // number 0-1
697
- entities: EntityArray, // string[], defaults to []
698
- });
699
- ```
700
-
701
- When validation fails after all retries, `LlmOutputValidationError` is thrown with the raw output, Zod errors, retry count, and full retry history for debugging.
702
-
703
- ### Adaptive Intelligence & Metacognition
704
-
705
- Agents don't just respond — they monitor their own performance and adapt their behavior in real-time.
706
-
707
- **MetapromptExecutor** rewrites the agent's own system prompt mid-conversation based on detected patterns:
708
-
709
- | Trigger | What happens | Example |
710
- |---------|-------------|---------|
711
- | **Frustration recovery** | Detects user frustration via SentimentTracker → simplifies language, offers alternatives | User asks same question 3x → agent acknowledges confusion and tries a different approach |
712
- | **Confusion clarification** | Detects ambiguous query → asks targeted follow-up | Vague request → agent probes for specifics before acting |
713
- | **Satisfaction reinforcement** | Detects positive feedback → reinforces successful patterns | User says "perfect" → agent remembers what worked |
714
- | **Engagement boost** | Detects disengagement → adjusts tone, offers proactive suggestions | Short replies → agent becomes more concise and action-oriented |
715
- | **Error recovery** | Detects tool failures → adjusts strategy | API call fails → agent switches to alternative approach |
716
- | **Trait adjustment** | Bounded HEXACO mutation → personality evolves within limits | Agent becomes slightly more conscientious after repeated accuracy requests |
717
-
718
- Three trigger modes: `turn_interval` (periodic self-reflection), `event_based` (driven by sentiment events), and `manual` (flags in working memory).
719
-
720
- **PromptProfileRouter** selects prompt strategies based on task classification — a code question gets a different prompt structure than a creative writing request.
721
-
722
- **Self-improvement** (opt-in, bounded):
723
-
724
- ```typescript
725
- const adaptive = agent({
726
- provider: 'anthropic',
727
- instructions: 'You are a research analyst.',
728
- selfImprovement: {
729
- enabled: true,
730
- personality: {
731
- maxDeltaPerSession: 0.15, // HEXACO traits can shift ±0.15 per session
732
- decayToBaseline: true, // Drift back toward baseline during consolidation
733
- },
734
- skills: { enabled: true }, // Can enable/disable skills based on task
735
- selfEvaluation: {
736
- enabled: true, // LLM-based self-scoring after each turn
737
- adjustParameters: true, // Auto-tune temperature/top-p based on scores
738
- },
739
- },
740
- });
741
- ```
742
-
743
- See [`docs/architecture/ARCHITECTURE.md`](./docs/architecture/ARCHITECTURE.md) for the full metacognition pipeline.
744
-
745
- ### Emergent Capabilities
746
-
747
- Agents with `emergent: true` create new tools at runtime:
748
-
749
- - **Runtime tool forging** via `forge_tool` — sandboxed JavaScript execution + LLM-as-judge safety evaluation
750
- - **Dynamic skill management** via `manage_skills` — enable/disable skills based on task
751
- - **Tiered promotion:** session (in-memory) → agent (persisted after 5+ uses with >0.8 confidence) → shared (HITL-approved)
752
- - **Self-improving personality** — bounded HEXACO trait adaptation with Ebbinghaus decay
753
-
754
- ```typescript
755
- const creative = agent({
756
- provider: 'openai',
757
- instructions: 'You solve problems creatively.',
758
- emergent: {
759
- enabled: true,
760
- toolForging: true, // Can create new tools at runtime
761
- maxForgedTools: 10, // Limit per session
762
- promotionThreshold: 0.8, // Confidence required for permanent promotion
763
- },
764
- });
765
-
766
- const session = creative.session('project');
767
- await session.send('Parse this CSV and create a chart');
768
- // Agent may forge a "csv_parser" tool if none exists,
769
- // run it in a sandbox, and promote it if it works well.
770
-
771
- console.log(session.forgedTools());
772
- // [{ name: "csv_parser", forgedAt: "...", uses: 3, confidence: 0.92 }]
773
- ```
774
-
775
- See [`docs/architecture/EMERGENT_CAPABILITIES.md`](./docs/architecture/EMERGENT_CAPABILITIES.md).
776
-
777
- ### Capability Discovery
778
-
779
- 3-tier semantic search that replaces static tool/skill dumps (~90% token reduction):
780
-
781
- - **Tier 0:** Category summaries (~150 tokens, always included)
782
- - **Tier 1:** Top-5 semantic matches (~200 tokens)
783
- - **Tier 2:** Full schemas on demand (~1500 tokens)
784
-
785
- The `discover_capabilities` meta-tool lets agents self-discover available tools, skills, and extensions at runtime.
786
-
787
- ---
788
-
789
- ## Architecture
790
-
791
- ```
792
- +------------------------------------------------------------------+
793
- | AgentOS Runtime |
794
- | |
795
- | +-----------+ +--------------+ +-----------+ |
796
- | | API Layer |-->| Orchestrator |-->| Streaming | |
797
- | +-----------+ +--------------+ +-----------+ |
798
- | | | |
799
- | +-----v----------------v-----+ |
800
- | | GMI (Generalized | +------------------+ |
801
- | | Modular Intelligence) |---->| Tool Orchestrator | |
802
- | | | +------------------+ |
803
- | | Working Memory Persona | +------------------+ |
804
- | | Context Mgr Adaptation |---->| RAG Pipeline | |
805
- | | Episodic Semantic Proc. | +------------------+ |
806
- | +-----------------------------+ +------------------+ |
807
- | | ---->| Planning Engine | |
808
- | +-----v-----+ +------------------+ |
809
- | | LLM Providers (16) | |
810
- | | OpenAI Anthropic Gemini | +----------+ +----------+ |
811
- | | Ollama Groq OpenRouter | | Guardrails| | Channels | |
812
- | | Together Mistral xAI ... | | (6 packs) | | (37) | |
813
- | +----------------------------+ +----------+ +----------+ |
814
- +------------------------------------------------------------------+
815
- ```
816
-
817
- For the full architecture with data flow diagrams, request lifecycle, and layer breakdown, see [`docs/architecture/ARCHITECTURE.md`](./docs/architecture/ARCHITECTURE.md).
221
+ | `openrouter` | openai/gpt-4o | | `OPENROUTER_API_KEY` |
222
+ | `together` | Llama-3.1-70B | | `TOGETHER_API_KEY` |
223
+ | `mistral` | mistral-large | | `MISTRAL_API_KEY` |
224
+ | `xai` | grok-2 | | `XAI_API_KEY` |
225
+ | `stability` | | stable-diffusion-xl | `STABILITY_API_KEY` |
226
+ | `replicate` | | flux-1.1-pro | `REPLICATE_API_TOKEN` |
227
+ | `bfl` | | flux-pro-1.1 | `BFL_API_KEY` |
228
+ | `fal` | | fal-ai/flux/dev | `FAL_API_KEY` |
229
+ | `claude-code-cli` | claude-sonnet-4 | | `claude` on PATH |
230
+ | `gemini-cli` | gemini-2.5-flash | | `gemini` on PATH |
231
+
232
+ Auto-detection: OpenAI Anthropic OpenRouter Gemini → Groq → Together → Mistral → xAI → CLI → Ollama
818
233
 
819
234
  ---
820
235
 
821
- ## Configuration
822
-
823
- ### Environment Variables
824
-
825
- ```bash
826
- # LLM providers (set at least one)
827
- OPENAI_API_KEY=sk-... # OpenAI (GPT-4o, GPT-4o-mini, o1, o3)
828
- ANTHROPIC_API_KEY=sk-ant-... # Anthropic (Claude Sonnet 4, Claude Haiku)
829
- GEMINI_API_KEY=AIza... # Google Gemini (2.5 Flash, 2.0)
830
- OPENROUTER_API_KEY=sk-or-... # OpenRouter (200+ models, auto-routing)
831
- GROQ_API_KEY=gsk_... # Groq (fast inference: Llama 3.3 70B)
832
- TOGETHER_API_KEY=... # Together AI (Llama, Mixtral)
833
- MISTRAL_API_KEY=... # Mistral (Mistral Large, Small)
834
- XAI_API_KEY=xai-... # xAI (Grok-2)
835
- OLLAMA_BASE_URL=http://localhost:11434 # Ollama (local models, no API key needed)
836
-
837
- # Database (optional, defaults to in-memory)
838
- DATABASE_URL=file:./data/agentos.db
839
-
840
- # Observability (optional)
841
- OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
842
- OTEL_SERVICE_NAME=my-agent
843
-
844
- # Voice/Telephony (optional)
845
- TWILIO_ACCOUNT_SID=AC...
846
- TWILIO_AUTH_TOKEN=...
847
- ```
848
-
849
- ### Multiple Providers
850
-
851
- High-level helpers auto-detect from env vars -- no configuration object needed:
852
-
853
- ```typescript
854
- import { generateText } from '@framers/agentos';
855
-
856
- // Each call picks the right credentials automatically
857
- await generateText({ provider: 'anthropic', prompt: 'Hello from Claude' });
858
- await generateText({ provider: 'openai', prompt: 'Hello from GPT' });
859
- await generateText({ provider: 'gemini', prompt: 'Hello from Gemini' });
860
- await generateText({ provider: 'ollama', prompt: 'Hello from Llama' });
861
-
862
- // Omit provider -- auto-detects the first configured one
863
- await generateText({ prompt: 'Hello from whichever provider is available' });
864
- ```
865
-
866
- For the full runtime with explicit provider configuration, see [`docs/getting-started/HIGH_LEVEL_API.md`](./docs/getting-started/HIGH_LEVEL_API.md).
867
-
868
- ### Fallback Providers
869
-
870
- ```typescript
871
- import { agent } from '@framers/agentos';
872
-
873
- const resilient = agent({
874
- provider: 'anthropic',
875
- instructions: 'You are a helpful assistant.',
876
- fallbackProviders: [
877
- { provider: 'openai' },
878
- { provider: 'groq' },
879
- ],
880
- onFallback: (error, provider) => {
881
- console.warn(`Falling back to ${provider}: ${error.message}`);
882
- },
883
- });
884
- ```
885
-
886
- ---
887
-
888
- ## API Quick Reference
236
+ ## API Reference
889
237
 
890
238
  ### High-Level Functions
891
239
 
892
240
  | Function | Description |
893
241
  |----------|-------------|
894
- | `generateText(opts)` | Single-call text generation with multi-step tool calling |
895
- | `streamText(opts)` | Streaming text generation with async iterables |
896
- | `generateObject(opts)` | Zod-validated structured output extraction |
897
- | `streamObject(opts)` | Streaming structured output |
898
- | `embedText(opts)` | Text embedding generation (single or batch) |
899
- | `generateImage(opts)` | Image generation with character consistency (7 providers) |
900
- | `editImage(opts)` | Image editing/inpainting |
901
- | `upscaleImage(opts)` | Image upscaling |
902
- | `variateImage(opts)` | Image variations |
903
- | `transferStyle(opts)` | Style transfer via Flux Redux / img2img |
904
- | `generateVideo(opts)` | Video generation |
905
- | `analyzeVideo(opts)` | Video analysis and understanding |
906
- | `detectScenes(opts)` | Scene detection in video |
907
- | `generateMusic(opts)` | Music generation |
908
- | `generateSFX(opts)` | Sound effect generation |
909
- | `performOCR(opts)` | Text extraction from images (progressive tiers) |
910
- | `agent(opts)` | Stateful agent with personality, memory, and sessions |
911
- | `agency(opts)` | Multi-agent team with strategy-based coordination |
912
- | `hitl(opts)` | Human-in-the-loop approval handler |
913
-
914
- ### Orchestration Builders
915
-
916
- | Builder | Import Path | Description |
917
- |---------|-------------|-------------|
918
- | `workflow(name)` | `@framers/agentos/orchestration` | Deterministic DAG with typed steps |
919
- | `AgentGraph` | `@framers/agentos/orchestration` | Explicit graph with cycles, subgraphs |
920
- | `mission(name)` | `@framers/agentos/orchestration` | Goal-driven, planner decides steps |
921
-
922
- ### Core Types
923
-
924
- ```typescript
925
- import type {
926
- AgentOSInput, // Full runtime input structure
927
- AgentOSResponse, // Streaming response chunk
928
- ITool, // Tool interface (id, name, inputSchema, execute)
929
- ToolExecutionResult, // Tool result (success, output, error)
930
- AgentOptions, // agent() configuration
931
- AgencyOptions, // agency() configuration
932
- GenerateTextOptions, // generateText() / streamText() options
933
- GenerateImageOptions, // generateImage() options
934
- TransferStyleOptions, // transferStyle() options
935
- GenerateObjectOptions, // generateObject() options
936
- EmbedTextOptions, // embedText() options
937
- ExtensionDescriptor, // Extension pack descriptor
938
- IGuardrailService, // Guardrail interface
939
- IChannelAdapter, // Channel adapter interface
940
- } from '@framers/agentos';
941
- ```
942
-
943
- ### Full Runtime
944
-
945
- The `AgentOS` class provides the full-featured runtime with GMI management, extension loading, and streaming:
242
+ | `generateText()` | Text generation with multi-step tool calling |
243
+ | `streamText()` | Streaming text with async iterables |
244
+ | `generateObject()` | Zod-validated structured output |
245
+ | `streamObject()` | Streaming structured output |
246
+ | `generateImage()` | Image generation (7 providers, character consistency) |
247
+ | `generateVideo()` | Video generation |
248
+ | `generateMusic()` / `generateSFX()` | Audio generation |
249
+ | `performOCR()` | Text extraction from images |
250
+ | `embedText()` | Embedding generation |
251
+ | `agent()` | Stateful agent with personality, memory, sessions |
252
+ | `agency()` | Multi-agent teams with strategy coordination |
253
+
254
+ ### Orchestration
255
+
256
+ | Builder | Description |
257
+ |---------|-------------|
258
+ | `workflow(name)` | Deterministic DAG with typed steps |
259
+ | `AgentGraph` | Explicit graph with cycles, subgraphs |
260
+ | `mission(name)` | Goal-driven, planner decides steps |
946
261
 
947
- ```typescript
948
- import { AgentOS, AgentOSResponseChunkType } from '@framers/agentos';
949
- import { createTestAgentOSConfig } from '@framers/agentos/config/AgentOSConfig';
950
-
951
- const agent = new AgentOS();
952
- await agent.initialize(await createTestAgentOSConfig());
953
-
954
- for await (const chunk of agent.processRequest({
955
- userId: 'user-1',
956
- sessionId: 'session-1',
957
- textInput: 'Explain how TCP handshakes work',
958
- })) {
959
- if (chunk.type === AgentOSResponseChunkType.TEXT_DELTA) {
960
- process.stdout.write(chunk.textDelta);
961
- }
962
- }
963
- ```
262
+ Full API reference: [docs.agentos.sh/api](https://docs.agentos.sh/api)
964
263
 
965
264
  ---
966
265
 
967
- ## Package Exports
968
-
969
- AgentOS provides 112 export paths for fine-grained imports:
266
+ ## Ecosystem
970
267
 
971
- ```typescript
972
- // Main entry -- all public types and classes
973
- import { AgentOS, generateText, streamText, agent, agency } from '@framers/agentos';
974
-
975
- // Configuration
976
- import { createAgentOSConfig, createTestAgentOSConfig } from '@framers/agentos/config/AgentOSConfig';
977
-
978
- // Orchestration (workflow, graph, mission builders)
979
- import { workflow, AgentGraph, mission, START, END } from '@framers/agentos/orchestration';
980
-
981
- // Safety primitives
982
- import { CircuitBreaker, CostGuard, StuckDetector } from '@framers/agentos/safety/runtime';
983
-
984
- // Guardrails
985
- import { GuardrailAction, ParallelGuardrailDispatcher } from '@framers/agentos/safety/guardrails';
986
-
987
- // RAG and GraphRAG
988
- import { VectorStoreManager, EmbeddingManager, RetrievalAugmentor } from '@framers/agentos/rag';
989
- import { GraphRAGEngine } from '@framers/agentos/rag/graphrag';
990
-
991
- // Skills
992
- import { SkillRegistry, SkillLoader } from '@framers/agentos/skills';
993
-
994
- // Tools
995
- import type { ITool, ToolExecutionResult } from '@framers/agentos/core/tools';
996
-
997
- // HITL
998
- import type { IHumanInteractionManager } from '@framers/agentos/orchestration/hitl';
999
-
1000
- // Deep imports via wildcard (up to 4 levels)
1001
- import { SomeType } from '@framers/agentos/safety/runtime/CircuitBreaker';
1002
- ```
268
+ | Package | Description |
269
+ |---------|-------------|
270
+ | [`@framers/agentos`](https://www.npmjs.com/package/@framers/agentos) | Core runtime — agents, providers, memory, RAG, orchestration, guardrails |
271
+ | [`@framers/agentos-extensions`](https://www.npmjs.com/package/@framers/agentos-extensions) | 100+ extensions and templates |
272
+ | [`@framers/agentos-extensions-registry`](https://www.npmjs.com/package/@framers/agentos-extensions-registry) | Curated manifest builder |
273
+ | [`@framers/agentos-skills`](https://www.npmjs.com/package/@framers/agentos-skills) | 88 curated SKILL.md definitions |
274
+ | [`@framers/agentos-skills-registry`](https://www.npmjs.com/package/@framers/agentos-skills-registry) | Skills catalog SDK |
275
+ | [`@framers/sql-storage-adapter`](https://www.npmjs.com/package/@framers/sql-storage-adapter) | SQL persistence (SQLite, Postgres, IndexedDB) |
1003
276
 
1004
277
  ---
1005
278
 
1006
279
  ## Documentation
1007
280
 
1008
- | Guide | What it covers |
1009
- |-------|---------------|
1010
- | [`ARCHITECTURE.md`](./docs/architecture/ARCHITECTURE.md) | Full system architecture, data flow diagrams, layer breakdown |
1011
- | [`HIGH_LEVEL_API.md`](./docs/getting-started/HIGH_LEVEL_API.md) | `generateText`, `streamText`, `generateObject`, `agent` reference |
1012
- | [`AGENCY_API.md`](./docs/orchestration/AGENCY_API.md) | `agency()` -- all strategies, HITL, guardrails, RAG, nested agencies |
1013
- | [`UNIFIED_ORCHESTRATION.md`](./docs/orchestration/UNIFIED_ORCHESTRATION.md) | Orchestration layer overview (workflow, graph, mission) |
1014
- | [`WORKFLOW_DSL.md`](./docs/orchestration/WORKFLOW_DSL.md) | `workflow()` DSL reference |
1015
- | [`AGENT_GRAPH.md`](./docs/architecture/AGENT_GRAPH.md) | `AgentGraph` builder reference |
1016
- | [`MISSION_API.md`](./docs/orchestration/MISSION_API.md) | `mission()` goal-driven orchestration |
1017
- | [`CHECKPOINTING.md`](./docs/orchestration/CHECKPOINTING.md) | Persistent checkpointing and fault recovery |
1018
- | [`COGNITIVE_MECHANISMS.md`](./docs/memory/COGNITIVE_MECHANISMS.md) | 8 cognitive memory mechanisms, 30+ APA citations |
1019
- | [`RAG_MEMORY_CONFIGURATION.md`](./docs/memory/RAG_MEMORY_CONFIGURATION.md) | Vector store setup, embedding models, data sources |
1020
- | [`MULTIMODAL_RAG.md`](./docs/memory/MULTIMODAL_RAG.md) | Image, audio, and document RAG pipelines |
1021
- | [`MEMORY_SCALING.md`](./docs/memory/MEMORY_SCALING.md) | 4-tier vector storage scaling path |
1022
- | [`GUARDRAILS_USAGE.md`](./docs/safety/GUARDRAILS_USAGE.md) | Guardrail implementation patterns |
1023
- | [`SAFETY_PRIMITIVES.md`](./docs/safety/SAFETY_PRIMITIVES.md) | Circuit breaker, cost guard, stuck detection |
1024
- | [`HUMAN_IN_THE_LOOP.md`](./docs/safety/HUMAN_IN_THE_LOOP.md) | Approval workflows, clarification, escalation |
1025
- | [`PLANNING_ENGINE.md`](./docs/orchestration/PLANNING_ENGINE.md) | ReAct reasoning, task planning |
1026
- | [`STRUCTURED_OUTPUT.md`](./docs/orchestration/STRUCTURED_OUTPUT.md) | JSON schema validation, entity extraction |
1027
- | [`AGENT_COMMUNICATION.md`](./docs/architecture/AGENT_COMMUNICATION.md) | Inter-agent messaging and handoffs |
1028
- | [`PLATFORM_SUPPORT.md`](./docs/architecture/PLATFORM_SUPPORT.md) | 37 channel platform capabilities |
1029
- | [`OBSERVABILITY.md`](./docs/observability/OBSERVABILITY.md) | OpenTelemetry setup, tracing, metrics |
1030
- | [`COST_OPTIMIZATION.md`](./docs/safety/COST_OPTIMIZATION.md) | Token usage, caching, model routing |
1031
- | [`SKILLS.md`](./docs/extensions/SKILLS.md) | SKILL.md format, skill authoring guide |
1032
- | [`EMERGENT_CAPABILITIES.md`](./docs/architecture/EMERGENT_CAPABILITIES.md) | Runtime tool forging, tiered promotion |
1033
- | [`SQL_STORAGE_QUICKSTART.md`](./docs/getting-started/SQL_STORAGE_QUICKSTART.md) | SQLite/Postgres setup |
1034
- | [`ECOSYSTEM.md`](./docs/architecture/ECOSYSTEM.md) | Extension ecosystem and official packs |
281
+ | Guide | Topic |
282
+ |-------|-------|
283
+ | [Architecture](./docs/architecture/ARCHITECTURE.md) | System design, data flow, layer breakdown |
284
+ | [High-Level API](./docs/getting-started/HIGH_LEVEL_API.md) | `generateText`, `agent`, `agency` reference |
285
+ | [Orchestration](./docs/orchestration/UNIFIED_ORCHESTRATION.md) | Workflows, graphs, missions |
286
+ | [Cognitive Memory](./docs/memory/COGNITIVE_MECHANISMS.md) | 8 mechanisms, 30+ APA citations |
287
+ | [RAG Configuration](./docs/memory/RAG_MEMORY_CONFIGURATION.md) | Vector stores, embeddings, data sources |
288
+ | [Guardrails](./docs/safety/GUARDRAILS_USAGE.md) | 5 tiers, 6 packs |
289
+ | [Human-in-the-Loop](./docs/safety/HUMAN_IN_THE_LOOP.md) | Approval workflows, escalation |
290
+ | [Emergent Capabilities](./docs/architecture/EMERGENT_CAPABILITIES.md) | Runtime tool forging |
291
+ | [Channels & Platforms](./docs/architecture/PLATFORM_SUPPORT.md) | 37 platform adapters |
292
+ | [Voice Pipeline](./docs/features/VOICE_PIPELINE.md) | TTS, STT, telephony |
293
+
294
+ Full documentation: [docs.agentos.sh](https://docs.agentos.sh)
1035
295
 
1036
296
  ---
1037
297
 
1038
298
  ## Contributing
1039
299
 
1040
300
  ```bash
1041
- git clone https://github.com/framersai/agentos.git
1042
- cd agentos
1043
- pnpm install
1044
- pnpm run build
1045
- pnpm run test
301
+ git clone https://github.com/framersai/agentos.git && cd agentos
302
+ pnpm install && pnpm build && pnpm test
1046
303
  ```
1047
304
 
1048
- | Script | Purpose |
1049
- |--------|---------|
1050
- | `pnpm run build` | Clean, compile TypeScript, resolve aliases, fix ESM imports |
1051
- | `pnpm run typecheck` | Type-check without emitting |
1052
- | `pnpm run lint` | Strip non-breaking spaces + ESLint |
1053
- | `pnpm run test` | Run vitest test suite |
1054
- | `pnpm run dev:test` | Run vitest in watch mode |
1055
- | `pnpm run docs` | Generate TypeDoc API documentation |
305
+ We use [Conventional Commits](https://www.conventionalcommits.org/). See the [Contributing Guide](https://github.com/framersai/agentos/blob/master/CONTRIBUTING.md).
306
+
307
+ ---
1056
308
 
1057
- We use [Conventional Commits](https://www.conventionalcommits.org/): `feat:` (minor), `fix:` (patch), `BREAKING CHANGE:` (major).
309
+ ## Community
1058
310
 
1059
- See the [Contributing Guide](https://github.com/framersai/agentos/blob/master/CONTRIBUTING.md) for details.
311
+ - **Discord:** [discord.gg/VXXC4SJMKh](https://discord.gg/VXXC4SJMKh)
312
+ - **GitHub Issues:** [github.com/framersai/agentos/issues](https://github.com/framersai/agentos/issues)
313
+ - **Blog:** [docs.agentos.sh/blog](https://docs.agentos.sh/blog)
314
+ - **Wilds.ai:** [wilds.ai](https://wilds.ai) — AI game worlds powered by AgentOS
1060
315
 
1061
316
  ---
1062
317
 
1063
318
  ## License
1064
319
 
1065
- [Apache 2.0](./LICENSE) -- [Frame.dev](https://frame.dev)
320
+ [Apache 2.0](./LICENSE)
1066
321
 
1067
322
  <div align="center">
1068
323
 
@@ -1074,6 +329,6 @@ See the [Contributing Guide](https://github.com/framersai/agentos/blob/master/CO
1074
329
  <img src="https://raw.githubusercontent.com/framersai/agentos/master/assets/frame-logo-green-no-tagline.svg" alt="Frame.dev" height="40" />
1075
330
  </a>
1076
331
 
1077
- **Built by [Frame.dev](https://frame.dev)**
332
+ **Built by [Manic Agency LLC](https://manic.agency) · [Frame.dev](https://frame.dev) · [Wilds.ai](https://wilds.ai)**
1078
333
 
1079
334
  </div>