@framers/agentos 0.1.21 → 0.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,15 +20,110 @@
20
20
 
21
21
  ---
22
22
 
23
+ ## Table of Contents
24
+
25
+ - [Overview](#overview)
26
+ - [Quick Start](#quick-start)
27
+ - [System Architecture](#system-architecture)
28
+ - [Architecture Diagram](#architecture-diagram)
29
+ - [Request Lifecycle](#request-lifecycle)
30
+ - [Layer Breakdown](#layer-breakdown)
31
+ - [Core Modules](#core-modules)
32
+ - [API Layer](#api-layer)
33
+ - [Cognitive Substrate (GMI)](#cognitive-substrate-gmi)
34
+ - [LLM Provider Management](#llm-provider-management)
35
+ - [Tool System](#tool-system)
36
+ - [Extension System](#extension-system)
37
+ - [Planning Engine](#planning-engine)
38
+ - [Conversation Management](#conversation-management)
39
+ - [RAG (Retrieval Augmented Generation)](#rag-retrieval-augmented-generation)
40
+ - [Safety and Guardrails](#safety-and-guardrails)
41
+ - [Human-in-the-Loop (HITL)](#human-in-the-loop-hitl)
42
+ - [Channels System](#channels-system)
43
+ - [Voice and Telephony](#voice-and-telephony)
44
+ - [Workflows](#workflows)
45
+ - [Multi-Agent Coordination](#multi-agent-coordination)
46
+ - [Observability](#observability)
47
+ - [Skills](#skills)
48
+ - [Structured Output](#structured-output)
49
+ - [Configuration](#configuration)
50
+ - [Development (Quick Start)](#development-quick-start)
51
+ - [Production](#production)
52
+ - [Multiple Providers](#multiple-providers)
53
+ - [Environment Variables](#environment-variables)
54
+ - [API Reference](#api-reference)
55
+ - [AgentOS Class](#agentos-class)
56
+ - [IAgentOS Interface](#iagentos-interface)
57
+ - [AgentOSInput](#agentosinput)
58
+ - [AgentOSResponse Streaming](#agentosresponse-streaming)
59
+ - [ITool Interface](#itool-interface)
60
+ - [ExtensionDescriptor](#extensiondescriptor)
61
+ - [IGuardrailService](#iguardrailservice)
62
+ - [IHumanInteractionManager](#ihumaninteractionmanager)
63
+ - [Usage Examples](#usage-examples)
64
+ - [Streaming Chat](#streaming-chat)
65
+ - [Adding Tools](#adding-tools)
66
+ - [Multi-Agent Collaboration](#multi-agent-collaboration)
67
+ - [Human-in-the-Loop Approvals](#human-in-the-loop-approvals)
68
+ - [Structured Data Extraction](#structured-data-extraction)
69
+ - [RAG Memory](#rag-memory)
70
+ - [Custom Guardrails](#custom-guardrails)
71
+ - [Channel Adapters](#channel-adapters)
72
+ - [Voice Calls](#voice-calls)
73
+ - [Package Exports](#package-exports)
74
+ - [Internal Documentation](#internal-documentation)
75
+ - [Contributing](#contributing)
76
+ - [License](#license)
77
+
78
+ ---
79
+
80
+ ## Overview
81
+
82
+ `@framers/agentos` is a TypeScript-first AI agent orchestration library that provides a complete runtime for building, deploying, and managing adaptive AI agents. It handles the full lifecycle from prompt construction through tool execution, safety evaluation, and streaming response delivery.
83
+
84
+ **Key facts:**
85
+
86
+ | Property | Value |
87
+ |----------|-------|
88
+ | Package | `@framers/agentos` |
89
+ | Version | `0.1.21` |
90
+ | Language | TypeScript 5.4+ / Node.js 18+ |
91
+ | Source files | 260+ TypeScript files across 25 top-level directories |
92
+ | Export paths | 112 package.json export entries |
93
+ | License | Apache 2.0 |
94
+
95
+ **Runtime dependencies:**
96
+
97
+ | Dependency | Purpose |
98
+ |------------|---------|
99
+ | `@opentelemetry/api` | Distributed tracing and metrics |
100
+ | `ajv` + `ajv-formats` | JSON Schema validation for tool I/O |
101
+ | `axios` | HTTP client for LLM provider APIs |
102
+ | `lru-cache` | High-performance caching (dedup, embeddings, cost tracking) |
103
+ | `natural` | NLP utilities (tokenization, stemming, sentiment) |
104
+ | `pino` | Structured JSON logging |
105
+ | `uuid` | Unique identifier generation |
106
+ | `yaml` | YAML config parsing (agent configs, skill definitions) |
107
+
108
+ **Optional peer dependencies:**
109
+
110
+ | Peer Dependency | Purpose |
111
+ |-----------------|---------|
112
+ | `@framers/sql-storage-adapter` | SQL-backed vector store and persistence |
113
+ | `graphology` + `graphology-communities-louvain` | GraphRAG community detection |
114
+ | `hnswlib-node` | HNSW-based approximate nearest neighbor search |
115
+
116
+ ---
117
+
23
118
  ## Quick Start
24
119
 
25
120
  ```bash
26
121
  npm install @framers/agentos
27
122
  ```
28
123
 
29
- **Requirements:** Node.js 18+ · TypeScript 5.0+
124
+ **Requirements:** Node.js 18+ and TypeScript 5.0+
30
125
 
31
- ### Streaming Chat
126
+ ### Minimal Example
32
127
 
33
128
  ```typescript
34
129
  import { AgentOS, AgentOSResponseChunkType } from '@framers/agentos';
@@ -48,132 +143,814 @@ for await (const chunk of agent.processRequest({
48
143
  }
49
144
  ```
50
145
 
51
- ### Adding Tools
146
+ ---
52
147
 
53
- Tools are registered via extension packs and called automatically by the model:
148
+ ## System Architecture
149
+
150
+ ### Architecture Diagram
151
+
152
+ ```
153
+ +===================================================================+
154
+ | AgentOS Runtime |
155
+ +===================================================================+
156
+ | |
157
+ | +---------------------+ +----------------------+ |
158
+ | | AgentOS (API) |---->| AgentOSOrchestrator | |
159
+ | | (Service Facade) | | (Delegation Hub) | |
160
+ | +---------------------+ +----------+-----------+ |
161
+ | | | |
162
+ | v v |
163
+ | +------------------+ +-------------------+ |
164
+ | | StreamingManager | | PromptEngine | |
165
+ | | (Async Gen Mgmt) | | (Dynamic Prompts) | |
166
+ | +------------------+ +-------------------+ |
167
+ | | | |
168
+ | +----------+-------------------+ |
169
+ | | |
170
+ | v |
171
+ | +=========================================================+ |
172
+ | | GMI Manager | |
173
+ | | (Generalized Modular Intelligence Lifecycle) | |
174
+ | | | |
175
+ | | +-----------+ +-----------+ +-----------+ +-------+ | |
176
+ | | | Working | | Context | | Persona | |Learning| | |
177
+ | | | Memory | | Manager | | Overlay | | Module | | |
178
+ | | +-----------+ +-----------+ +-----------+ +-------+ | |
179
+ | | | |
180
+ | | +-----------+ +-----------+ +-----------+ | |
181
+ | | | Episodic | | Semantic | |Procedural | | |
182
+ | | | Memory | | Memory | | Memory | | |
183
+ | | +-----------+ +-----------+ +-----------+ | |
184
+ | +=========================================================+ |
185
+ | | | | |
186
+ | v v v |
187
+ | +--------------+ +----------+ +--------------+ +-----------+ |
188
+ | | Tool | | RAG | | Planning | | Workflow | |
189
+ | | Orchestrator | | Memory | | Engine | | Engine | |
190
+ | +--------------+ +----------+ +--------------+ +-----------+ |
191
+ | | | | | |
192
+ | | | v v |
193
+ | | | +-----------+ +-----------+ |
194
+ | | | | Embedding | | ReAct | |
195
+ | | | | Manager | | Reasoner | |
196
+ | | | +-----------+ +-----------+ |
197
+ | | | | |
198
+ | v v v |
199
+ | +=========================================================+ |
200
+ | | LLM Provider Manager | |
201
+ | | | |
202
+ | | +--------+ +----------+ +-------+ +--------+ +------+ | |
203
+ | | | OpenAI | |Anthropic | | Azure | | Ollama | |OpenR.| | |
204
+ | | +--------+ +----------+ +-------+ +--------+ +------+ | |
205
+ | +=========================================================+ |
206
+ | |
207
+ | +---------+ +----------+ +----------+ +-----------+ |
208
+ | |Guardrail| | Circuit | | Cost | | Stuck | |
209
+ | | Service | | Breaker | | Guard | | Detector | |
210
+ | +---------+ +----------+ +----------+ +-----------+ |
211
+ | |
212
+ | +-------------------+ +-------------------+ +----------------+ |
213
+ | | Extension Manager | | Channel Router | | Call Manager | |
214
+ | | (12+ kinds) | | (20 platforms) | | (Voice/Tel.) | |
215
+ | +-------------------+ +-------------------+ +----------------+ |
216
+ | |
217
+ | +-------------------+ +-------------------+ +----------------+ |
218
+ | | Observability | | HITL Manager | | Skill Registry | |
219
+ | | (OpenTelemetry) | | (Approval/Escal.) | | (SKILL.md) | |
220
+ | +-------------------+ +-------------------+ +----------------+ |
221
+ | |
222
+ +====================================================================+
223
+ ```
224
+
225
+ ### Request Lifecycle
226
+
227
+ A single `processRequest()` call flows through these stages:
228
+
229
+ ```
230
+ User Input (AgentOSInput)
231
+ |
232
+ v
233
+ [1] Input Guardrails ---- evaluateInput() ----> BLOCK / SANITIZE / ALLOW
234
+ |
235
+ v
236
+ [2] Context Assembly ----- ConversationManager + RAG retrieval
237
+ |
238
+ v
239
+ [3] Prompt Construction -- PromptEngine builds system + contextual elements
240
+ |
241
+ v
242
+ [4] GMI Processing ------- Working memory, persona overlay, adaptation
243
+ |
244
+ v
245
+ [5] LLM Call ------------- AIModelProviderManager dispatches to provider
246
+ | (with circuit breaker + cost guard)
247
+ v
248
+ [6] Tool Execution? ------ ToolOrchestrator validates, executes, loops back to [5]
249
+ | (with ToolExecutionGuard + permission checks)
250
+ v
251
+ [7] Output Guardrails ---- evaluateOutput() ----> BLOCK / SANITIZE / ALLOW
252
+ |
253
+ v
254
+ [8] Streaming Response --- AsyncGenerator<AgentOSResponse> yields chunks
255
+ |
256
+ v
257
+ [9] Post-Processing ------ Memory persistence, cost aggregation, telemetry
258
+ ```
259
+
260
+ ### Layer Breakdown
261
+
262
+ AgentOS is organized into six architectural layers:
263
+
264
+ | Layer | Directory | Purpose |
265
+ |-------|-----------|---------|
266
+ | **API** | `src/api/` | Public-facing facade, input/output types, orchestrator |
267
+ | **Cognitive** | `src/cognitive_substrate/` | GMI instances, persona overlays, multi-layer memory |
268
+ | **Core** | `src/core/` | 28 subdirectories: LLM, tools, safety, guardrails, planning, workflows, HITL, observability, etc. |
269
+ | **Integration** | `src/channels/`, `src/voice/`, `src/extensions/` | External platform adapters, telephony, plugin system |
270
+ | **Intelligence** | `src/rag/`, `src/skills/` | RAG pipeline, GraphRAG, skill loading |
271
+ | **Infrastructure** | `src/config/`, `src/logging/`, `src/utils/`, `src/types/` | Configuration, structured logging, shared utilities |
272
+
273
+ ---
274
+
275
+ ## Core Modules
276
+
277
+ ### API Layer
278
+
279
+ **Location:** `src/api/`
280
+
281
+ The API layer is the primary entry point for all interactions with AgentOS.
282
+
283
+ | File | Role |
284
+ |------|------|
285
+ | `AgentOS.ts` | Main service facade (1000+ lines). Implements `IAgentOS`. Initializes all subsystems and delegates to the orchestrator. |
286
+ | `AgentOSOrchestrator.ts` | Delegation hub. Coordinates GMI processing, tool execution, guardrail evaluation, and streaming assembly. Streaming-first design using async generators. |
287
+ | `interfaces/IAgentOS.ts` | Core contract defining `initialize()`, `processRequest()`, `handleToolResult()`, workflow management, persona listing, and conversation history retrieval. |
288
+ | `types/AgentOSInput.ts` | Unified input structure: text, vision, audio, persona selection, user API keys, feedback, workflow/agency invocations, and processing options. |
289
+ | `types/AgentOSResponse.ts` | Streaming output: 11 chunk types covering text deltas, tool calls, progress, errors, workflows, agency updates, and provenance events. |
290
+
291
+ **Response chunk types:**
54
292
 
55
293
  ```typescript
56
- import {
57
- AgentOS,
58
- AgentOSResponseChunkType,
59
- EXTENSION_KIND_TOOL,
60
- type ExtensionManifest,
61
- type ExtensionPack,
62
- type ITool,
63
- } from '@framers/agentos';
64
- import { createTestAgentOSConfig } from '@framers/agentos/config/AgentOSConfig';
294
+ enum AgentOSResponseChunkType {
295
+ TEXT_DELTA // Incremental text tokens
296
+ SYSTEM_PROGRESS // Internal processing updates
297
+ TOOL_CALL_REQUEST // Agent requests tool execution
298
+ TOOL_RESULT_EMISSION // Tool execution result
299
+ UI_COMMAND // Client-side UI directives
300
+ FINAL_RESPONSE // Aggregated final response
301
+ ERROR // Error information
302
+ METADATA_UPDATE // Session/context metadata changes
303
+ WORKFLOW_UPDATE // Workflow progress notifications
304
+ AGENCY_UPDATE // Multi-agent coordination events
305
+ PROVENANCE_EVENT // Immutability/audit trail events
306
+ }
307
+ ```
65
308
 
66
- const weatherTool: ITool = {
67
- id: 'get-weather',
68
- name: 'get_weather',
69
- displayName: 'Get Weather',
70
- description: 'Returns current weather for a city.',
71
- category: 'utility',
72
- hasSideEffects: false,
73
- inputSchema: {
74
- type: 'object',
75
- properties: { city: { type: 'string', description: 'City name' } },
76
- required: ['city'],
77
- },
78
- execute: async (args) => ({
79
- success: true,
80
- output: { text: `Weather in ${args.city}: 22°C, partly cloudy` },
81
- }),
82
- };
309
+ ---
83
310
 
84
- const manifest: ExtensionManifest = {
85
- packs: [{
86
- factory: async () => ({
87
- name: 'my-tools',
88
- descriptors: [{ id: weatherTool.id, kind: EXTENSION_KIND_TOOL, payload: weatherTool }],
89
- } satisfies ExtensionPack),
90
- }],
91
- };
311
+ ### Cognitive Substrate (GMI)
92
312
 
93
- const agent = new AgentOS();
94
- const config = await createTestAgentOSConfig();
95
- await agent.initialize({ ...config, extensionManifest: manifest });
313
+ **Location:** `src/cognitive_substrate/`
314
+
315
+ The Generalized Modular Intelligence (GMI) is the core agent instance -- the "brain" of each agent. A single AgentOS runtime can manage multiple GMI instances via `GMIManager`.
316
+
317
+ ```
318
+ +================================================================+
319
+ | GMI Instance |
320
+ | |
321
+ | +-------------------+ +----------------------------+ |
322
+ | | PersonaOverlay | | Context Manager | |
323
+ | | Manager | | (Dynamic prompt elements, | |
324
+ | | (Personality | | user context, session) | |
325
+ | | switching) | +----------------------------+ |
326
+ | +-------------------+ |
327
+ | |
328
+ | +-------------------+ +----------------------------+ |
329
+ | | Working Memory | | Adaptation Manager | |
330
+ | | (Current session | | (Learning rate, style | |
331
+ | | state, tool ctx) | | drift, tone adaptation) | |
332
+ | +-------------------+ +----------------------------+ |
333
+ | |
334
+ | +-----------------------------------------------------------+ |
335
+ | | Multi-Layer Memory | |
336
+ | | +----------+ +----------+ +-----------+ +-----------+ | |
337
+ | | | Episodic | | Semantic | | Procedural| | Long-Term | | |
338
+ | | | (Events) | | (Facts) | | (Skills) | | (Archive) | | |
339
+ | | +----------+ +----------+ +-----------+ +-----------+ | |
340
+ | +-----------------------------------------------------------+ |
341
+ +================================================================+
342
+ ```
96
343
 
344
+ **Key components:**
345
+
346
+ - **GMI.ts** -- Core agent instance (2000+ lines). Manages the complete cognitive loop: context assembly, prompt construction, LLM invocation, tool handling, and response generation.
347
+ - **GMIManager.ts** -- Lifecycle manager for multiple GMI instances. Handles creation, pooling, configuration, and teardown.
348
+ - **IGMI.ts** -- Interface contract for GMI implementations.
349
+ - **PersonaOverlayManager** -- Enables dynamic personality switching at runtime. Ships with 5+ built-in personas:
350
+ - `Researcher` -- Analytical, citation-heavy responses
351
+ - `Generalist` -- Balanced, conversational
352
+ - `Atlas` -- Navigation and spatial reasoning
353
+ - `Default Assistant` -- General-purpose helpful assistant
354
+ - **Memory subsystem** (`memory/`) -- Four-layer memory architecture:
355
+ - **Working memory** -- Current session state, active tool context, conversation buffer
356
+ - **Episodic memory** -- Timestamped events and interactions
357
+ - **Semantic memory** -- Extracted facts, entity relationships, domain knowledge
358
+ - **Procedural memory** -- Learned skills, patterns, and execution strategies
359
+
360
+ ---
361
+
362
+ ### LLM Provider Management
363
+
364
+ **Location:** `src/core/llm/`
365
+
366
+ The LLM layer abstracts multiple AI model providers behind a unified interface.
367
+
368
+ ```
369
+ +-----------------------------------------------------------+
370
+ | AIModelProviderManager |
371
+ | (Provider registry, routing, fallback, model switching) |
372
+ +-----------------------------------------------------------+
373
+ | | | |
374
+ v v v v
375
+ +----------+ +----------+ +----------+ +----------+
376
+ | OpenAI | | Ollama | | OpenRouter| | (Custom) |
377
+ | Provider | | Provider | | Provider | | Provider |
378
+ +----------+ +----------+ +----------+ +----------+
379
+ | | |
380
+ v v v
381
+ gpt-4o llama3.2 claude-3.5
382
+ gpt-4o-mini mistral gemini-pro
383
+ o1-preview codellama command-r+
384
+ ```
385
+
386
+ **Provider implementations:**
387
+
388
+ | Provider | File | Models |
389
+ |----------|------|--------|
390
+ | OpenAI | `providers/implementations/OpenAIProvider.ts` | GPT-4o, GPT-4o-mini, o1, o3, etc. |
391
+ | Ollama | `providers/implementations/OllamaProvider.ts` | Any locally-hosted model (Llama, Mistral, etc.) |
392
+ | OpenRouter | `providers/implementations/OpenRouterProvider.ts` | 100+ models from any provider via unified API |
393
+
394
+ **Additional components:**
395
+
396
+ - **PromptEngine** (`PromptEngine.ts`) -- Constructs prompts from system instructions, contextual elements, persona definitions, and dynamic user context. Supports template interpolation and conditional element inclusion.
397
+ - **IProvider** (`providers/IProvider.ts`) -- Interface contract for adding custom LLM providers.
398
+ - **Streaming adapters** -- All providers support token-level streaming via async generators with backpressure control.
399
+
400
+ **Per-request model override:**
401
+
402
+ ```typescript
97
403
  for await (const chunk of agent.processRequest({
98
404
  userId: 'user-1',
99
405
  sessionId: 'session-1',
100
- textInput: 'What is the weather in Tokyo?',
101
- })) {
102
- switch (chunk.type) {
103
- case AgentOSResponseChunkType.TEXT_DELTA:
104
- process.stdout.write(chunk.textDelta);
105
- break;
106
- case AgentOSResponseChunkType.TOOL_CALL_REQUEST:
107
- console.log('Tool calls:', chunk.toolCalls);
108
- break;
109
- case AgentOSResponseChunkType.TOOL_RESULT_EMISSION:
110
- console.log('Tool result:', chunk.toolResult);
111
- break;
112
- }
406
+ textInput: 'Summarize this document',
407
+ options: {
408
+ preferredProviderId: 'anthropic',
409
+ preferredModelId: 'claude-sonnet-4-5-20250929',
410
+ },
411
+ })) { /* ... */ }
412
+ ```
413
+
414
+ ---
415
+
416
+ ### Tool System
417
+
418
+ **Location:** `src/core/tools/`
419
+
420
+ Tools are the primary mechanism for agents to interact with the outside world. Every tool implements the `ITool` interface.
421
+
422
+ ```
423
+ +-----------------------------------------------------------+
424
+ | ToolOrchestrator |
425
+ | (Discovery, selection, validation, execution pipeline) |
426
+ +-----------------------------------------------------------+
427
+ | | |
428
+ v v v
429
+ +---------------+ +---------------+ +-------------------+
430
+ | ToolExecutor | | ToolPermission| | ToolExecution |
431
+ | (Validation, | | Manager | | Guard |
432
+ | invocation, | | (RBAC, per- | | (Timeout 30s, |
433
+ | result wrap) | | user access) | | circuit breaker) |
434
+ +---------------+ +---------------+ +-------------------+
435
+ ```
436
+
437
+ **ITool interface (abbreviated):**
438
+
439
+ ```typescript
440
+ interface ITool<TInput = any, TOutput = any> {
441
+ readonly id: string; // Globally unique identifier
442
+ readonly name: string; // LLM-facing function name
443
+ readonly displayName: string; // Human-readable title
444
+ readonly description: string; // Natural language description for LLM
445
+ readonly inputSchema: JSONSchemaObject; // JSON Schema for input validation
446
+ readonly outputSchema?: JSONSchemaObject; // JSON Schema for output validation
447
+ readonly category?: string; // Grouping (e.g., "data_analysis")
448
+ readonly hasSideEffects: boolean; // Whether the tool modifies external state
449
+ readonly requiredCapabilities?: string[]; // Persona capabilities needed
450
+
451
+ execute(
452
+ args: TInput,
453
+ context?: ToolExecutionContext
454
+ ): Promise<ToolExecutionResult<TOutput>>;
455
+ }
456
+ ```
457
+
458
+ **ToolExecutionResult:**
459
+
460
+ ```typescript
461
+ interface ToolExecutionResult<TOutput = any> {
462
+ success: boolean;
463
+ output?: TOutput;
464
+ error?: string;
465
+ contentType?: string; // MIME type (default: "application/json")
466
+ details?: Record<string, any>;
113
467
  }
114
468
  ```
115
469
 
470
+ **ToolExecutionContext** provides the tool with calling agent identity (`gmiId`, `personaId`), user context, correlation ID for tracing, and optional session data.
471
+
116
472
  ---
117
473
 
118
- ## Features
474
+ ### Extension System
475
+
476
+ **Location:** `src/extensions/`
477
+
478
+ The extension system is AgentOS's plugin architecture. Extensions are packaged as **packs** containing one or more **descriptors**, loaded via a **manifest**.
479
+
480
+ ```
481
+ ExtensionManifest
482
+ |
483
+ +-- ExtensionPackManifestEntry[]
484
+ |
485
+ +-- ExtensionPack (resolved via factory/module/package)
486
+ |
487
+ +-- ExtensionDescriptor[] (id + kind + payload)
488
+ |
489
+ +-- Registered in ExtensionRegistry
490
+ |
491
+ +-- Consumed by runtime (ToolOrchestrator,
492
+ GuardrailService, WorkflowEngine, etc.)
493
+ ```
494
+
495
+ **12 extension kinds:**
496
+
497
+ | Kind Constant | Value | Payload Type |
498
+ |---------------|-------|--------------|
499
+ | `EXTENSION_KIND_TOOL` | `"tool"` | `ITool` |
500
+ | `EXTENSION_KIND_GUARDRAIL` | `"guardrail"` | `IGuardrailService` |
501
+ | `EXTENSION_KIND_RESPONSE_PROCESSOR` | `"response-processor"` | Response transform function |
502
+ | `EXTENSION_KIND_WORKFLOW` | `"workflow"` | `WorkflowDescriptorPayload` |
503
+ | `EXTENSION_KIND_WORKFLOW_EXECUTOR` | `"workflow-executor"` | Workflow step executor |
504
+ | `EXTENSION_KIND_PERSONA` | `"persona"` | `IPersonaDefinition` |
505
+ | `EXTENSION_KIND_PLANNING_STRATEGY` | `"planning-strategy"` | Planning algorithm |
506
+ | `EXTENSION_KIND_HITL_HANDLER` | `"hitl-handler"` | Human interaction handler |
507
+ | `EXTENSION_KIND_COMM_CHANNEL` | `"communication-channel"` | Agent-to-agent channel |
508
+ | `EXTENSION_KIND_MEMORY_PROVIDER` | `"memory-provider"` | Memory backend |
509
+ | `EXTENSION_KIND_MESSAGING_CHANNEL` | `"messaging-channel"` | External platform adapter |
510
+ | `EXTENSION_KIND_PROVENANCE` | `"provenance"` | Audit/immutability handler |
511
+
512
+ **ExtensionDescriptor:**
513
+
514
+ ```typescript
515
+ interface ExtensionDescriptor<TPayload = unknown> {
516
+ id: string; // Unique within its kind
517
+ kind: ExtensionKind; // One of the 12 kinds above
518
+ priority?: number; // Higher loads later (overrides earlier)
519
+ enableByDefault?: boolean; // Auto-enable on discovery
520
+ metadata?: Record<string, unknown>; // Arbitrary metadata
521
+ payload: TPayload; // The actual implementation
522
+ source?: ExtensionSourceMetadata; // Provenance (package name, version)
523
+ requiredSecrets?: ExtensionSecretRequirement[]; // API keys needed
524
+ onActivate?: (ctx: ExtensionLifecycleContext) => Promise<void> | void;
525
+ onDeactivate?: (ctx: ExtensionLifecycleContext) => Promise<void> | void;
526
+ }
527
+ ```
528
+
529
+ **ExtensionManifest:**
530
+
531
+ ```typescript
532
+ interface ExtensionManifest {
533
+ packs: ExtensionPackManifestEntry[]; // Pack references
534
+ overrides?: ExtensionOverrides; // Per-descriptor enable/disable/priority
535
+ }
536
+
537
+ // Packs can be resolved three ways:
538
+ type ExtensionPackResolver =
539
+ | { package: string; version?: string } // npm package
540
+ | { module: string } // Local module path
541
+ | { factory: () => Promise<ExtensionPack> | ExtensionPack }; // Inline factory
542
+ ```
543
+
544
+ **Loading pipeline:**
545
+
546
+ 1. `ExtensionLoader` resolves pack entries from the manifest
547
+ 2. `ExtensionRegistry` registers descriptors by kind, applying priority stacking
548
+ 3. `ExtensionManager` provides runtime access: `getTools()`, `getGuardrails()`, `getWorkflows()`, etc.
549
+ 4. `MultiRegistryLoader` supports loading from multiple remote registries
550
+
551
+ ---
552
+
553
+ ### Planning Engine
554
+
555
+ **Location:** `src/core/planning/`
556
+
557
+ The planning engine enables multi-step task decomposition and execution using ReAct (Reasoning + Acting) patterns.
558
+
559
+ ```
560
+ +-----------------------------------------------------------+
561
+ | PlanningEngine |
562
+ | (Task decomposition, step sequencing, execution loop) |
563
+ +-----------------------------------------------------------+
564
+ |
565
+ v
566
+ +-----------------------------------------------------------+
567
+ | IPlanningEngine Interface |
568
+ | |
569
+ | createPlan(goal, context) -> Plan |
570
+ | executePlan(plan) -> AsyncGenerator<PlanStepResult> |
571
+ | revisePlan(plan, feedback) -> Plan |
572
+ +-----------------------------------------------------------+
573
+ ```
574
+
575
+ Plans are composed of typed steps that the agent executes sequentially, with the ability to revise the plan based on intermediate results. The planning engine integrates with:
576
+
577
+ - **Tool system** for action execution
578
+ - **Guardrails** for step-level safety checks
579
+ - **HITL** for human approval of high-risk steps
580
+ - **Memory** for persisting plan state across sessions
581
+
582
+ See [`docs/PLANNING_ENGINE.md`](docs/PLANNING_ENGINE.md) for the full planning system specification.
583
+
584
+ ---
585
+
586
+ ### Conversation Management
587
+
588
+ **Location:** `src/core/conversation/`
589
+
590
+ Manages session state, message history, and long-term memory persistence.
591
+
592
+ - **ConversationManager** -- Creates and retrieves conversation contexts, manages rolling message windows, and coordinates memory persistence.
593
+ - **ConversationContext** -- Immutable snapshot of a conversation: messages, metadata, active persona, user context.
594
+ - **IRollingSummaryMemorySink** -- Interface for persisting conversation summaries that compress long conversations into retrievable memory.
595
+ - **ILongTermMemoryRetriever** -- Interface for retrieving relevant past conversations during context assembly.
596
+
597
+ ---
598
+
599
+ ### RAG (Retrieval Augmented Generation)
600
+
601
+ **Location:** `src/rag/`
602
+
603
+ A complete RAG pipeline with pluggable vector stores, embedding management, and document ingestion.
604
+
605
+ ```
606
+ +-----------------------------------------------------------+
607
+ | RetrievalAugmentor |
608
+ | (Orchestrates ingestion, retrieval, document management) |
609
+ +-----------------------------------------------------------+
610
+ | |
611
+ v v
612
+ +-------------------+ +---------------------+
613
+ | EmbeddingManager | | VectorStoreManager |
614
+ | (Model selection,| | (Multi-provider |
615
+ | caching, batch) | | vector storage) |
616
+ +-------------------+ +---------------------+
617
+ | |
618
+ v v
619
+ +-------------------+ +---------------------+
620
+ | LLM Provider | | IVectorStore impls |
621
+ | (embedding models)| +---------------------+
622
+ +-------------------+ | | | |
623
+ +----------+ | | +-----------+
624
+ v v v v
625
+ +-----------+ +--------+ +--------+ +---------+
626
+ | InMemory | | SQL | | HNSW | | Qdrant |
627
+ | (dev) | | (prod) | | (local)| | (cloud) |
628
+ +-----------+ +--------+ +--------+ +---------+
629
+ ```
630
+
631
+ **Vector store implementations:**
632
+
633
+ | Store | Import | Use Case |
634
+ |-------|--------|----------|
635
+ | `InMemoryVectorStore` | `@framers/agentos/rag` | Development and testing |
636
+ | `SqlVectorStore` | `@framers/agentos/rag` | Production (SQLite/Postgres via `@framers/sql-storage-adapter`) |
637
+ | `HnswlibVectorStore` | `@framers/agentos/rag` | High-performance local ANN search |
638
+ | `QdrantVectorStore` | `@framers/agentos/rag` | Cloud-hosted vector database |
639
+
640
+ **GraphRAG:**
641
+
642
+ The `GraphRAGEngine` (at `src/rag/graphrag/`) extends traditional RAG with knowledge graph capabilities:
643
+
644
+ - Entity and relationship extraction from documents
645
+ - Community detection via Louvain algorithm (requires `graphology` peer dependency)
646
+ - Local search (entity-centric) and global search (community-summarized)
647
+ - Hybrid retrieval combining vector similarity with graph traversal
648
+
649
+ ```typescript
650
+ import { GraphRAGEngine } from '@framers/agentos/rag/graphrag';
651
+ import type { GraphRAGConfig, GraphEntity, GraphRelationship } from '@framers/agentos/rag/graphrag';
652
+ ```
653
+
654
+ See [`docs/RAG_MEMORY_CONFIGURATION.md`](docs/RAG_MEMORY_CONFIGURATION.md) and [`docs/MULTIMODAL_RAG.md`](docs/MULTIMODAL_RAG.md) for detailed configuration guides.
655
+
656
+ ---
657
+
658
+ ### Safety and Guardrails
659
+
660
+ **Location:** `src/core/safety/` and `src/core/guardrails/`
661
+
662
+ AgentOS provides defense-in-depth safety through two complementary systems.
663
+
664
+ #### Safety Primitives (`core/safety/`)
665
+
666
+ Five runtime safety components:
667
+
668
+ | Component | Export | Purpose |
669
+ |-----------|--------|---------|
670
+ | **CircuitBreaker** | `CircuitBreaker` | Three-state (closed/open/half-open) wrapper for LLM calls. Configurable failure threshold, reset timeout, and half-open probe count. Throws `CircuitOpenError` when tripped. |
671
+ | **ActionDeduplicator** | `ActionDeduplicator` | Hash-based recent action tracking with LRU eviction. Prevents redundant tool calls and repeated operations within a configurable time window. |
672
+ | **StuckDetector** | `StuckDetector` | Detects three patterns: repeated outputs, repeated errors, and oscillation (A-B-A-B cycles). Returns `StuckDetection` with reason and confidence. |
673
+ | **CostGuard** | `CostGuard` | Per-agent session and daily spending caps. Defaults: $1/session, $5/day. Throws `CostCapExceededError` when limits are hit. Tracks token usage across all LLM calls. |
674
+ | **ToolExecutionGuard** | `ToolExecutionGuard` | Per-tool timeout (30s default) with independent circuit breakers per tool ID. Reports `ToolHealthReport` for monitoring. Throws `ToolTimeoutError`. |
675
+
676
+ ```typescript
677
+ import {
678
+ CircuitBreaker,
679
+ CostGuard,
680
+ StuckDetector,
681
+ ActionDeduplicator,
682
+ ToolExecutionGuard,
683
+ } from '@framers/agentos/core/safety';
684
+ ```
685
+
686
+ See [`docs/SAFETY_PRIMITIVES.md`](docs/SAFETY_PRIMITIVES.md) for the full safety API reference.
687
+
688
+ #### Guardrails (`core/guardrails/`)
689
+
690
+ Content-level input/output filtering:
691
+
692
+ ```typescript
693
+ enum GuardrailAction {
694
+ ALLOW = 'allow', // Pass through unchanged
695
+ FLAG = 'flag', // Pass through but log for review
696
+ SANITIZE = 'sanitize', // Replace with modified content (e.g., PII redaction)
697
+ BLOCK = 'block', // Reject entirely, terminate stream
698
+ }
699
+
700
+ interface IGuardrailService {
701
+ evaluateInput?(input: AgentOSInput, context: GuardrailContext): Promise<GuardrailEvaluationResult>;
702
+ evaluateOutput?(output: string, context: GuardrailContext): Promise<GuardrailEvaluationResult>;
703
+ }
704
+ ```
705
+
706
+ Guardrails run at two points in the request lifecycle:
707
+ 1. **Pre-processing** -- `evaluateInput()` inspects user input before it reaches the LLM
708
+ 2. **Post-processing** -- `evaluateOutput()` inspects the LLM response before streaming to the client
709
+
710
+ Multiple guardrails can be composed via the extension system, and each receives full context (user ID, session ID, persona ID, custom metadata) for context-aware policy decisions.
711
+
712
+ See [`docs/GUARDRAILS_USAGE.md`](docs/GUARDRAILS_USAGE.md) for implementation patterns.
713
+
714
+ ---
715
+
716
+ ### Human-in-the-Loop (HITL)
717
+
718
+ **Location:** `src/core/hitl/`
719
+
720
+ The HITL system enables agents to request human approval, clarification, and collaboration at key decision points.
721
+
722
+ **Core interface: `IHumanInteractionManager`**
723
+
724
+ Three interaction modes:
725
+
726
+ | Mode | Method | Use Case |
727
+ |------|--------|----------|
728
+ | **Approval** | `requestApproval()` | Gate high-risk actions (database mutations, financial operations, external communications) |
729
+ | **Clarification** | `requestClarification()` | Ask the user for missing information before proceeding |
730
+ | **Escalation** | `escalateToHuman()` | Hand off to a human operator when the agent cannot proceed |
731
+
732
+ **PendingAction structure:**
733
+
734
+ ```typescript
735
+ interface PendingAction {
736
+ actionId: string;
737
+ description: string;
738
+ severity: 'low' | 'medium' | 'high' | 'critical';
739
+ category?: 'data_modification' | 'external_api' | 'financial' |
740
+ 'communication' | 'system' | 'other';
741
+ agentId: string;
742
+ context: Record<string, unknown>;
743
+ potentialConsequences?: string[];
744
+ reversible: boolean;
745
+ estimatedCost?: { amount: number; currency: string };
746
+ timeoutMs?: number;
747
+ alternatives?: AlternativeAction[];
748
+ }
749
+ ```
750
+
751
+ HITL integrates with the planning engine so individual plan steps can require approval, and with the extension system via `EXTENSION_KIND_HITL_HANDLER` for custom approval UIs.
752
+
753
+ See [`docs/HUMAN_IN_THE_LOOP.md`](docs/HUMAN_IN_THE_LOOP.md) for the full HITL specification.
754
+
755
+ ---
756
+
757
+ ### Channels System
758
+
759
+ **Location:** `src/channels/`
760
+
761
+ Unified adapters for 20 external messaging platforms.
762
+
763
+ **20 supported platforms:**
764
+
765
+ | Priority | Platforms |
766
+ |----------|-----------|
767
+ | **P0** (Core) | Telegram, WhatsApp, Discord, Slack, Webchat |
768
+ | **P1** | Signal, iMessage, Google Chat, Microsoft Teams |
769
+ | **P2** | Matrix, Zalo, Email, SMS |
770
+ | **P3** | Nostr, Twitch, Line, Feishu, Mattermost, Nextcloud Talk, Tlon |
771
+
772
+ **21 capability flags:**
773
+
774
+ Each adapter declares its capabilities, allowing consumers to check before attempting unsupported actions:
775
+
776
+ ```
777
+ text, rich_text, images, video, audio, voice_notes, documents,
778
+ stickers, reactions, threads, typing_indicator, read_receipts,
779
+ group_chat, channels, buttons, inline_keyboard, embeds,
780
+ mentions, editing, deletion
781
+ ```
782
+
783
+ **IChannelAdapter** -- Unified interface for bidirectional messaging:
784
+
785
+ - `connect()` / `disconnect()` -- Lifecycle management
786
+ - `sendMessage()` -- Outbound messages with platform-specific formatting
787
+ - `onMessage()` -- Inbound message handler registration
788
+ - `getConnectionInfo()` -- Connection health monitoring
789
+ - `capabilities` -- Declared capability set
790
+
791
+ **ChannelRouter** -- Routes inbound messages to the appropriate agent and outbound responses to the correct platform adapter. Supports multi-platform agents (one agent, many channels).
792
+
793
+ **Connection status:** `disconnected` -> `connecting` -> `connected` -> `reconnecting` -> `error`
794
+
795
+ Channel adapters are registered as extensions via `EXTENSION_KIND_MESSAGING_CHANNEL`.
796
+
797
+ See [`docs/PLATFORM_SUPPORT.md`](docs/PLATFORM_SUPPORT.md) for platform-specific configuration.
798
+
799
+ ---
800
+
801
+ ### Voice and Telephony
802
+
803
+ **Location:** `src/voice/`
804
+
805
+ Enable agents to make and receive phone calls via telephony providers.
806
+
807
+ **Call state machine:**
808
+
809
+ ```
810
+ initiated --> ringing --> answered --> active --> speaking <--> listening
811
+ | | | | | |
812
+ +------------+-----------+----------+------------+------------+
813
+ | (any non-terminal state) |
814
+ v
815
+ [Terminal States]
816
+ completed | hangup-user | hangup-bot | timeout | error |
817
+ failed | no-answer | busy | voicemail
818
+ ```
819
+
820
+ **Providers:**
821
+
822
+ | Provider | Support |
823
+ |----------|---------|
824
+ | Twilio | Full voice + SMS |
825
+ | Telnyx | Full voice |
826
+ | Plivo | Full voice |
827
+ | Mock | Testing/development |
828
+
829
+ **Key components:**
830
+
831
+ - **CallManager** -- Manages call lifecycle, state transitions, and event dispatch
832
+ - **IVoiceCallProvider** -- Interface for telephony provider adapters
833
+ - **telephony-audio.ts** -- Audio stream handling and format conversion
834
+
835
+ Voice providers are registered via `EXTENSION_KIND_TOOL` with the `voice-call-provider` category.
836
+
837
+ ---
838
+
839
+ ### Workflows
840
+
841
+ **Location:** `src/core/workflows/`
119
842
 
120
- ### LLM Providers
121
- - **Multi-provider** — OpenAI, Anthropic, Azure, Google, Ollama, OpenRouter, and more
122
- - **Model switching** — Change providers/models per request via `ProcessingOptions`
123
- - **Streaming-first** — Token-level async generator responses with backpressure
843
+ Declarative multi-step workflows with persistence and monitoring.
124
844
 
125
- ### Tools & Extensions
126
- - **Extension packs** Register tools, guardrails, workflows, personas, and channel adapters
127
- - **12 extension kinds** `tool`, `guardrail`, `workflow`, `persona`, `messaging-channel`, `planning-strategy`, `hitl-handler`, `memory-provider`, and more
128
- - **Permission management** — Fine-grained tool access control per user/role
129
- - **Dynamic registration** — Add/remove tools at runtime
845
+ - **WorkflowEngine** -- Instantiates and executes workflow definitions
846
+ - **IWorkflowStore** -- Persistence interface for workflow state (supports SQL and in-memory backends)
847
+ - **WorkflowTypes** -- Type definitions for workflow definitions, instances, tasks, and progress updates
130
848
 
131
- ### Agent Intelligence
132
- - **Persistent agents (GMIs)** — Working memory, persona adaptation, learning across sessions
133
- - **Contextual prompting** — Dynamic prompt elements selected by user context and task
134
- - **Mood adaptation** — Tone shifts based on conversation sentiment
849
+ Workflows integrate with the IAgentOS interface:
135
850
 
136
- ### Planning & Human-in-the-Loop
137
- - **Task planning** Multi-step plan generation with ReAct reasoning
138
- - **Approval workflows** — Gate high-risk actions with human review
139
- - **Clarification requests** — Agents ask for missing information
140
- - **Escalation** Automatic handoff to human operators
851
+ ```typescript
852
+ // List available workflow definitions
853
+ const definitions = agent.listWorkflowDefinitions();
854
+
855
+ // Start a workflow instance
856
+ const instance = await agent.startWorkflow('data-pipeline-v1', input, {
857
+ context: { source: 'scheduled' },
858
+ roleAssignments: { analyst: 'gmi-123', reviewer: 'gmi-456' },
859
+ });
860
+
861
+ // Monitor progress
862
+ const status = await agent.getWorkflow(instance.workflowId);
863
+ ```
864
+
865
+ ---
141
866
 
142
867
  ### Multi-Agent Coordination
143
- - **Agency registry** — Register and manage agent teams
144
- - **Communication bus** — Inter-agent message passing and handoffs
145
- - **Shared memory** — Agency-level memory with vector search
146
-
147
- ### Memory & RAG
148
- - **Vector retrieval** Embedding-based semantic search (SQL-backed)
149
- - **Conversation persistence** Rolling summaries and long-term memory
150
- - **Multiple data sources** Configure separate vector stores per domain
151
-
152
- ### Safety & Guardrails
153
- - **Input/output guardrails** — Block, modify, or escalate based on content
154
- - **Circuit breaker** — Three-state (closed/open/half-open) wrapper for LLM calls with configurable thresholds
155
- - **Cost guard** — Per-agent session and daily spending caps ($1/session, $5/day defaults)
156
- - **Stuck detection** — Detects repeated outputs, repeated errors, and oscillation patterns
157
- - **Action deduplication** — Hash-based recent action tracking with LRU eviction
158
- - **Tool execution guard** — Per-tool timeout (30s default) with circuit breakers
159
- - **Cross-agent guardrails** Monitor agent-to-agent interactions
160
-
161
- See [`docs/SAFETY_PRIMITIVES.md`](docs/SAFETY_PRIMITIVES.md) for full API reference.
868
+
869
+ **Location:** `src/core/agency/`
870
+
871
+ Enables teams of agents to collaborate on shared goals.
872
+
873
+ - **AgencyRegistry** -- Register and manage agent teams with role assignments
874
+ - **AgentCommunicationBus** -- Inter-agent message passing with typed events and handoffs
875
+ - **AgencyMemoryManager** -- Shared memory space with vector search for agency-wide knowledge
876
+
877
+ ```
878
+ +-----------------------------------------------------------+
879
+ | AgencyRegistry |
880
+ +-----------------------------------------------------------+
881
+ | | | |
882
+ v v v v
883
+ +--------+ +--------+ +--------+ +--------+
884
+ | Agent | | Agent | | Agent | | Agent |
885
+ | (GMI) | | (GMI) | | (GMI) | | (GMI) |
886
+ | Resrch | | Writer | | Review | | Deploy |
887
+ +--------+ +--------+ +--------+ +--------+
888
+ | | | |
889
+ +-------+-------+-------+-------+-------+-------+
890
+ | |
891
+ v v
892
+ +------------------+ +--------------------+
893
+ | Communication | | Agency Memory |
894
+ | Bus (events, | | Manager (shared |
895
+ | handoffs, sync) | | vector memory) |
896
+ +------------------+ +--------------------+
897
+ ```
898
+
899
+ See [`docs/AGENT_COMMUNICATION.md`](docs/AGENT_COMMUNICATION.md) for the full multi-agent specification.
900
+
901
+ ---
902
+
903
+ ### Observability
904
+
905
+ **Location:** `src/core/observability/`
906
+
907
+ OpenTelemetry-native observability for tracing, metrics, and cost tracking.
908
+
909
+ - **ITracer** / **Tracer** -- Span creation and propagation for distributed tracing
910
+ - **otel.ts** -- `configureAgentOSObservability()` sets up the OpenTelemetry SDK with custom exporters
911
+ - **Metrics** -- Token usage, latency percentiles, tool execution counts, error rates
912
+ - **Cost tracking** -- Per-request and aggregate cost computation across providers
913
+
914
+ ```typescript
915
+ import { configureAgentOSObservability } from '@framers/agentos';
916
+
917
+ configureAgentOSObservability({
918
+ serviceName: 'my-agent',
919
+ traceExporter: myOTLPExporter,
920
+ metricExporter: myMetricsExporter,
921
+ });
922
+ ```
923
+
924
+ See [`docs/OBSERVABILITY.md`](docs/OBSERVABILITY.md) and [`docs/COST_OPTIMIZATION.md`](docs/COST_OPTIMIZATION.md) for setup guides.
925
+
926
+ ---
927
+
928
+ ### Skills
929
+
930
+ **Location:** `src/skills/`
931
+
932
+ Skills are portable, self-describing agent capabilities defined in `SKILL.md` files.
933
+
934
+ - **SkillRegistry** -- Discovers and registers available skills
935
+ - **SkillLoader** -- Parses SKILL.md format (YAML frontmatter + markdown body)
936
+ - **SKILL.md format** -- Declarative skill definition with name, description, required tools, and behavioral instructions
937
+
938
+ See [`docs/SKILLS.md`](docs/SKILLS.md) for the skill authoring guide.
939
+
940
+ ---
162
941
 
163
942
  ### Structured Output
164
- - **JSON schema validation** — Extract typed data from unstructured text
165
- - **Parallel function calls** — Multiple tool invocations in one turn
166
- - **Entity extraction** — Named entity recognition with schema constraints
167
943
 
168
- ### Messaging Channels
169
- - **13+ platforms** — Telegram, WhatsApp, Discord, Slack, Signal, Teams, Matrix, and more
170
- - **Bidirectional adapters** Unified `IChannelAdapter` interface for all platforms
171
- - **Channel routing** — Inbound/outbound message routing with `ChannelRouter`
944
+ **Location:** `src/core/structured/`
945
+
946
+ Extract typed, validated data from unstructured text using JSON Schema.
172
947
 
173
- ### Operations
174
- - **OpenTelemetry** Opt-in tracing, metrics, and structured logging
175
- - **Provenance** Optional immutability policies, signed event ledger, external anchoring
176
- - **Cost tracking** Token usage monitoring and optimization
948
+ - **StructuredOutputManager** -- Coordinates schema-constrained generation with validation
949
+ - **JSON Schema validation** -- Input/output validation via ajv with format support
950
+ - **Parallel function calls** -- Multiple tool invocations in a single LLM turn
951
+ - **Entity extraction** -- Named entity recognition with schema constraints
952
+
953
+ See [`docs/STRUCTURED_OUTPUT.md`](docs/STRUCTURED_OUTPUT.md) for usage patterns.
177
954
 
178
955
  ---
179
956
 
@@ -195,17 +972,6 @@ await agent.initialize(await createTestAgentOSConfig());
195
972
 
196
973
  `createAgentOSConfig()` reads from environment variables:
197
974
 
198
- ```bash
199
- # Required
200
- DATABASE_URL=file:./data/agentos.db
201
-
202
- # LLM Providers (at least one)
203
- OPENAI_API_KEY=sk-...
204
- ANTHROPIC_API_KEY=sk-ant-...
205
- OPENROUTER_API_KEY=sk-or-...
206
- OLLAMA_BASE_URL=http://localhost:11434
207
- ```
208
-
209
975
  ```typescript
210
976
  import { AgentOS } from '@framers/agentos';
211
977
  import { createAgentOSConfig } from '@framers/agentos/config/AgentOSConfig';
@@ -226,9 +992,12 @@ await agent.initialize({
226
992
  ...config,
227
993
  modelProviderManagerConfig: {
228
994
  providers: [
229
- { providerId: 'openai', enabled: true, isDefault: true, config: { apiKey: process.env.OPENAI_API_KEY } },
230
- { providerId: 'anthropic', enabled: true, config: { apiKey: process.env.ANTHROPIC_API_KEY } },
231
- { providerId: 'ollama', enabled: true, config: { baseUrl: 'http://localhost:11434' } },
995
+ { providerId: 'openai', enabled: true, isDefault: true,
996
+ config: { apiKey: process.env.OPENAI_API_KEY } },
997
+ { providerId: 'anthropic', enabled: true,
998
+ config: { apiKey: process.env.ANTHROPIC_API_KEY } },
999
+ { providerId: 'ollama', enabled: true,
1000
+ config: { baseUrl: 'http://localhost:11434' } },
232
1001
  ],
233
1002
  },
234
1003
  gmiManagerConfig: {
@@ -246,13 +1015,277 @@ for await (const chunk of agent.processRequest({
246
1015
  userId: 'user-1',
247
1016
  sessionId: 'session-1',
248
1017
  textInput: 'Hello',
249
- options: { preferredProviderId: 'anthropic', preferredModelId: 'claude-sonnet-4-5-20250929' },
1018
+ options: {
1019
+ preferredProviderId: 'anthropic',
1020
+ preferredModelId: 'claude-sonnet-4-5-20250929',
1021
+ },
250
1022
  })) { /* ... */ }
251
1023
  ```
252
1024
 
1025
+ ### Environment Variables
1026
+
1027
+ ```bash
1028
+ # Required: at least one LLM provider
1029
+ OPENAI_API_KEY=sk-...
1030
+ ANTHROPIC_API_KEY=sk-ant-...
1031
+ OPENROUTER_API_KEY=sk-or-...
1032
+ OLLAMA_BASE_URL=http://localhost:11434
1033
+
1034
+ # Database
1035
+ DATABASE_URL=file:./data/agentos.db
1036
+
1037
+ # Observability (optional)
1038
+ OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
1039
+ OTEL_SERVICE_NAME=my-agent
1040
+
1041
+ # Voice/Telephony (optional)
1042
+ TWILIO_ACCOUNT_SID=AC...
1043
+ TWILIO_AUTH_TOKEN=...
1044
+ TELNYX_API_KEY=KEY...
1045
+ ```
1046
+
1047
+ ---
1048
+
1049
+ ## API Reference
1050
+
1051
+ ### AgentOS Class
1052
+
1053
+ The main service facade. Implements `IAgentOS`.
1054
+
1055
+ ```typescript
1056
+ class AgentOS implements IAgentOS {
1057
+ // Lifecycle
1058
+ initialize(config: AgentOSConfig): Promise<void>;
1059
+ shutdown(): Promise<void>;
1060
+
1061
+ // Core interaction (streaming-first)
1062
+ processRequest(input: AgentOSInput): AsyncGenerator<AgentOSResponse>;
1063
+ handleToolResult(streamId, toolCallId, toolName, toolOutput, isSuccess, errorMessage?):
1064
+ AsyncGenerator<AgentOSResponse>;
1065
+
1066
+ // Personas
1067
+ listPersonas(): IPersonaDefinition[];
1068
+ setActivePersona(personaId: string): Promise<void>;
1069
+
1070
+ // Conversation
1071
+ getConversationHistory(sessionId: string): Promise<ConversationContext>;
1072
+
1073
+ // Workflows
1074
+ listWorkflowDefinitions(): WorkflowDefinition[];
1075
+ startWorkflow(definitionId, input, options?): Promise<WorkflowInstance>;
1076
+ getWorkflow(workflowId): Promise<WorkflowInstance | null>;
1077
+ updateWorkflowTask(workflowId, taskId, update): Promise<void>;
1078
+ queryWorkflows(options?): Promise<WorkflowInstance[]>;
1079
+
1080
+ // Feedback
1081
+ submitFeedback(feedback: UserFeedbackPayload): Promise<void>;
1082
+
1083
+ // Exposed managers (for advanced usage)
1084
+ readonly llmProviderManager: AIModelProviderManager;
1085
+ readonly extensionManager: ExtensionManager;
1086
+ readonly conversationManager: ConversationManager;
1087
+ }
1088
+ ```
1089
+
1090
+ ### IAgentOS Interface
1091
+
1092
+ The core contract. See `src/api/interfaces/IAgentOS.ts` for the full interface definition.
1093
+
1094
+ ### AgentOSInput
1095
+
1096
+ ```typescript
1097
+ interface AgentOSInput {
1098
+ userId: string;
1099
+ organizationId?: string; // Multi-tenant routing
1100
+ sessionId: string;
1101
+ textInput: string | null;
1102
+ visionInput?: VisionInputData; // Image/video input
1103
+ audioInput?: AudioInputData; // Audio input
1104
+ preferredPersonaId?: string; // Request specific persona
1105
+ userApiKeys?: Record<string, string>; // User-provided API keys
1106
+ feedback?: UserFeedbackPayload; // Inline feedback
1107
+ workflowInvocation?: WorkflowInvocationRequest;
1108
+ agencyInvocation?: AgencyInvocationRequest;
1109
+ memoryControl?: AgentOSMemoryControl;
1110
+ options?: ProcessingOptions; // Model override, temperature, etc.
1111
+ }
1112
+ ```
1113
+
1114
+ ### AgentOSResponse Streaming
1115
+
1116
+ All core methods return `AsyncGenerator<AgentOSResponse>`. Each yielded chunk has a `type` discriminant:
1117
+
1118
+ ```typescript
1119
+ // Handle all chunk types:
1120
+ for await (const chunk of agent.processRequest(input)) {
1121
+ switch (chunk.type) {
1122
+ case AgentOSResponseChunkType.TEXT_DELTA:
1123
+ process.stdout.write(chunk.textDelta);
1124
+ break;
1125
+ case AgentOSResponseChunkType.TOOL_CALL_REQUEST:
1126
+ console.log('Tools requested:', chunk.toolCalls);
1127
+ break;
1128
+ case AgentOSResponseChunkType.TOOL_RESULT_EMISSION:
1129
+ console.log('Tool result:', chunk.toolName, chunk.toolResult);
1130
+ break;
1131
+ case AgentOSResponseChunkType.SYSTEM_PROGRESS:
1132
+ console.log('Progress:', chunk.message, chunk.progressPercentage);
1133
+ break;
1134
+ case AgentOSResponseChunkType.WORKFLOW_UPDATE:
1135
+ console.log('Workflow:', chunk.workflowProgress);
1136
+ break;
1137
+ case AgentOSResponseChunkType.AGENCY_UPDATE:
1138
+ console.log('Agency event:', chunk.agencyEvent);
1139
+ break;
1140
+ case AgentOSResponseChunkType.ERROR:
1141
+ console.error('Error:', chunk.error);
1142
+ break;
1143
+ case AgentOSResponseChunkType.FINAL_RESPONSE:
1144
+ console.log('Complete:', chunk.finalText);
1145
+ break;
1146
+ }
1147
+ }
1148
+ ```
1149
+
1150
+ ### ITool Interface
1151
+
1152
+ See the [Tool System](#tool-system) section above for the full interface. Tools are registered via extension packs:
1153
+
1154
+ ```typescript
1155
+ const descriptor: ExtensionDescriptor<ITool> = {
1156
+ id: 'my-tool',
1157
+ kind: EXTENSION_KIND_TOOL,
1158
+ payload: myToolImplementation,
1159
+ };
1160
+ ```
1161
+
1162
+ ### ExtensionDescriptor
1163
+
1164
+ See the [Extension System](#extension-system) section above for the full type definition and all 12 extension kinds.
1165
+
1166
+ ### IGuardrailService
1167
+
1168
+ ```typescript
1169
+ interface IGuardrailService {
1170
+ evaluateInput?(
1171
+ input: AgentOSInput,
1172
+ context: GuardrailContext,
1173
+ ): Promise<GuardrailEvaluationResult>;
1174
+
1175
+ evaluateOutput?(
1176
+ output: string,
1177
+ context: GuardrailContext,
1178
+ ): Promise<GuardrailEvaluationResult>;
1179
+ }
1180
+
1181
+ interface GuardrailEvaluationResult {
1182
+ action: GuardrailAction; // ALLOW | FLAG | SANITIZE | BLOCK
1183
+ reason?: string; // Human-readable explanation
1184
+ reasonCode?: string; // Machine-readable code
1185
+ modifiedText?: string; // Required when action is SANITIZE
1186
+ metadata?: Record<string, any>; // Additional context for logging
1187
+ }
1188
+ ```
1189
+
1190
+ ### IHumanInteractionManager
1191
+
1192
+ ```typescript
1193
+ interface IHumanInteractionManager {
1194
+ requestApproval(action: PendingAction): Promise<ApprovalDecision>;
1195
+ requestClarification(request: ClarificationRequest): Promise<ClarificationResponse>;
1196
+ escalateToHuman(context: EscalationContext): Promise<EscalationResult>;
1197
+ getPendingActions(): Promise<PendingAction[]>;
1198
+ }
1199
+ ```
1200
+
253
1201
  ---
254
1202
 
255
- ## Examples
1203
+ ## Usage Examples
1204
+
1205
+ ### Streaming Chat
1206
+
1207
+ ```typescript
1208
+ import { AgentOS, AgentOSResponseChunkType } from '@framers/agentos';
1209
+ import { createTestAgentOSConfig } from '@framers/agentos/config/AgentOSConfig';
1210
+
1211
+ const agent = new AgentOS();
1212
+ await agent.initialize(await createTestAgentOSConfig());
1213
+
1214
+ for await (const chunk of agent.processRequest({
1215
+ userId: 'user-1',
1216
+ sessionId: 'session-1',
1217
+ textInput: 'Explain how TCP handshakes work',
1218
+ })) {
1219
+ if (chunk.type === AgentOSResponseChunkType.TEXT_DELTA) {
1220
+ process.stdout.write(chunk.textDelta);
1221
+ }
1222
+ }
1223
+ ```
1224
+
1225
+ ### Adding Tools
1226
+
1227
+ Tools are registered via extension packs and called automatically by the model:
1228
+
1229
+ ```typescript
1230
+ import {
1231
+ AgentOS,
1232
+ AgentOSResponseChunkType,
1233
+ EXTENSION_KIND_TOOL,
1234
+ type ExtensionManifest,
1235
+ type ExtensionPack,
1236
+ type ITool,
1237
+ } from '@framers/agentos';
1238
+ import { createTestAgentOSConfig } from '@framers/agentos/config/AgentOSConfig';
1239
+
1240
+ const weatherTool: ITool = {
1241
+ id: 'get-weather',
1242
+ name: 'get_weather',
1243
+ displayName: 'Get Weather',
1244
+ description: 'Returns current weather for a city.',
1245
+ category: 'utility',
1246
+ hasSideEffects: false,
1247
+ inputSchema: {
1248
+ type: 'object',
1249
+ properties: { city: { type: 'string', description: 'City name' } },
1250
+ required: ['city'],
1251
+ },
1252
+ execute: async (args) => ({
1253
+ success: true,
1254
+ output: { text: `Weather in ${args.city}: 22 C, partly cloudy` },
1255
+ }),
1256
+ };
1257
+
1258
+ const manifest: ExtensionManifest = {
1259
+ packs: [{
1260
+ factory: async () => ({
1261
+ name: 'my-tools',
1262
+ descriptors: [{ id: weatherTool.id, kind: EXTENSION_KIND_TOOL, payload: weatherTool }],
1263
+ } satisfies ExtensionPack),
1264
+ }],
1265
+ };
1266
+
1267
+ const agent = new AgentOS();
1268
+ const config = await createTestAgentOSConfig();
1269
+ await agent.initialize({ ...config, extensionManifest: manifest });
1270
+
1271
+ for await (const chunk of agent.processRequest({
1272
+ userId: 'user-1',
1273
+ sessionId: 'session-1',
1274
+ textInput: 'What is the weather in Tokyo?',
1275
+ })) {
1276
+ switch (chunk.type) {
1277
+ case AgentOSResponseChunkType.TEXT_DELTA:
1278
+ process.stdout.write(chunk.textDelta);
1279
+ break;
1280
+ case AgentOSResponseChunkType.TOOL_CALL_REQUEST:
1281
+ console.log('Tool calls:', chunk.toolCalls);
1282
+ break;
1283
+ case AgentOSResponseChunkType.TOOL_RESULT_EMISSION:
1284
+ console.log('Tool result:', chunk.toolResult);
1285
+ break;
1286
+ }
1287
+ }
1288
+ ```
256
1289
 
257
1290
  ### Multi-Agent Collaboration
258
1291
 
@@ -297,15 +1330,17 @@ import { HumanInteractionManager } from '@framers/agentos';
297
1330
  const hitl = new HumanInteractionManager({ defaultTimeoutMs: 300_000 });
298
1331
 
299
1332
  const decision = await hitl.requestApproval({
300
- action: {
301
- type: 'database_mutation',
302
- description: 'Archive 50K inactive accounts older than 2 years',
303
- severity: 'high',
304
- metadata: { affectedRows: 50_000, table: 'users' },
305
- },
1333
+ actionId: 'archive-inactive',
1334
+ description: 'Archive 50K inactive accounts older than 2 years',
1335
+ severity: 'high',
1336
+ category: 'data_modification',
1337
+ agentId: 'data-cleanup-agent',
1338
+ context: { affectedRows: 50_000, table: 'users' },
1339
+ reversible: true,
1340
+ potentialConsequences: ['Users will lose access to archived data'],
306
1341
  alternatives: [
307
- { action: 'soft_delete', description: 'Mark as inactive instead' },
308
- { action: 'export_first', description: 'Export to CSV before archiving' },
1342
+ { alternativeId: 'soft_delete', description: 'Mark as inactive instead' },
1343
+ { alternativeId: 'export_first', description: 'Export to CSV before archiving' },
309
1344
  ],
310
1345
  });
311
1346
 
@@ -343,7 +1378,7 @@ const contact = await structured.generate({
343
1378
  },
344
1379
  schemaName: 'ContactInfo',
345
1380
  });
346
- // { name: 'Sarah Chen', email: 'sarah@startup.io', date: 'Jan 15', topic: 'Series A' }
1381
+ // Result: { name: 'Sarah Chen', email: 'sarah@startup.io', date: 'Jan 15', topic: 'Series A' }
347
1382
  ```
348
1383
 
349
1384
  ### RAG Memory
@@ -360,12 +1395,15 @@ await agent.initialize({
360
1395
  ragConfig: {
361
1396
  embeddingManagerConfig: {
362
1397
  embeddingModels: [
363
- { modelId: 'text-embedding-3-small', providerId: 'openai', dimension: 1536, isDefault: true },
1398
+ { modelId: 'text-embedding-3-small', providerId: 'openai',
1399
+ dimension: 1536, isDefault: true },
364
1400
  ],
365
1401
  },
366
1402
  vectorStoreManagerConfig: {
367
1403
  managerId: 'rag-vsm',
368
- providers: [{ id: 'sql-store', type: 'sql', storage: { filePath: './data/vectors.db' } }],
1404
+ providers: [
1405
+ { id: 'sql-store', type: 'sql', storage: { filePath: './data/vectors.db' } },
1406
+ ],
369
1407
  defaultProviderId: 'sql-store',
370
1408
  defaultEmbeddingDimension: 1536,
371
1409
  },
@@ -386,7 +1424,7 @@ await agent.initialize({
386
1424
  // Agent now retrieves relevant context from vector memory before responding
387
1425
  ```
388
1426
 
389
- ### Guardrails
1427
+ ### Custom Guardrails
390
1428
 
391
1429
  ```typescript
392
1430
  import {
@@ -397,15 +1435,27 @@ import {
397
1435
  } from '@framers/agentos';
398
1436
  import { createTestAgentOSConfig } from '@framers/agentos/config/AgentOSConfig';
399
1437
 
400
- // Guardrails intercept responses before delivery
401
- const costGuard: IGuardrailService = {
402
- async evaluateOutput(context: GuardrailContext) {
403
- const tokens = context.usage?.totalTokens ?? 0;
404
- if (tokens > 10_000) {
1438
+ const piiGuardrail: IGuardrailService = {
1439
+ async evaluateInput(input, context) {
1440
+ // Check for SSN patterns in user input
1441
+ const ssnPattern = /\b\d{3}-\d{2}-\d{4}\b/g;
1442
+ if (input.textInput && ssnPattern.test(input.textInput)) {
1443
+ return {
1444
+ action: GuardrailAction.SANITIZE,
1445
+ modifiedText: input.textInput.replace(ssnPattern, '[SSN REDACTED]'),
1446
+ reason: 'PII detected in user input',
1447
+ reasonCode: 'PII_SSN',
1448
+ };
1449
+ }
1450
+ return { action: GuardrailAction.ALLOW };
1451
+ },
1452
+
1453
+ async evaluateOutput(output, context) {
1454
+ if (output.toLowerCase().includes('password')) {
405
1455
  return {
406
- action: GuardrailAction.MODIFY,
407
- modifiedContent: 'Response exceeded token budget. Please ask a more specific question.',
408
- reason: `Token count ${tokens} exceeds limit`,
1456
+ action: GuardrailAction.BLOCK,
1457
+ reason: 'Output contains potentially sensitive credential information',
1458
+ reasonCode: 'CREDENTIAL_LEAK',
409
1459
  };
410
1460
  }
411
1461
  return { action: GuardrailAction.ALLOW };
@@ -414,61 +1464,167 @@ const costGuard: IGuardrailService = {
414
1464
 
415
1465
  const agent = new AgentOS();
416
1466
  const config = await createTestAgentOSConfig();
417
- await agent.initialize({ ...config, guardrailService: costGuard });
1467
+ await agent.initialize({ ...config, guardrailService: piiGuardrail });
1468
+ ```
1469
+
1470
+ ### Channel Adapters
1471
+
1472
+ ```typescript
1473
+ import {
1474
+ EXTENSION_KIND_MESSAGING_CHANNEL,
1475
+ type ExtensionManifest,
1476
+ type IChannelAdapter,
1477
+ type ChannelPlatform,
1478
+ } from '@framers/agentos';
1479
+
1480
+ // Implement a custom channel adapter
1481
+ const myAdapter: IChannelAdapter = {
1482
+ platform: 'webchat' as ChannelPlatform,
1483
+ capabilities: new Set(['text', 'rich_text', 'images', 'typing_indicator']),
1484
+
1485
+ async connect() { /* establish connection */ },
1486
+ async disconnect() { /* clean up */ },
1487
+ async sendMessage(channelId, message) { /* send outbound */ },
1488
+ onMessage(handler) { /* register inbound handler */ },
1489
+ getConnectionInfo() {
1490
+ return { status: 'connected', connectedSince: new Date().toISOString() };
1491
+ },
1492
+ };
1493
+
1494
+ // Register via extension manifest
1495
+ const manifest: ExtensionManifest = {
1496
+ packs: [{
1497
+ factory: async () => ({
1498
+ name: 'my-channels',
1499
+ descriptors: [{
1500
+ id: 'webchat-adapter',
1501
+ kind: EXTENSION_KIND_MESSAGING_CHANNEL,
1502
+ payload: myAdapter,
1503
+ }],
1504
+ }),
1505
+ }],
1506
+ };
1507
+ ```
1508
+
1509
+ ### Voice Calls
1510
+
1511
+ ```typescript
1512
+ import { CallManager, type IVoiceCallProvider } from '@framers/agentos';
1513
+
1514
+ const callManager = new CallManager();
1515
+
1516
+ // Initiate an outbound call
1517
+ const call = await callManager.initiateCall({
1518
+ provider: 'twilio',
1519
+ to: '+1234567890',
1520
+ from: '+0987654321',
1521
+ agentId: 'support-agent',
1522
+ });
1523
+
1524
+ // Monitor call state transitions
1525
+ call.on('stateChange', (newState) => {
1526
+ console.log(`Call ${call.id}: ${newState}`);
1527
+ // initiated -> ringing -> answered -> active -> speaking <-> listening -> completed
1528
+ });
1529
+
1530
+ // Handle call completion
1531
+ call.on('completed', (summary) => {
1532
+ console.log('Duration:', summary.durationMs);
1533
+ console.log('Transcript:', summary.transcript);
1534
+ });
418
1535
  ```
419
1536
 
420
1537
  ---
421
1538
 
422
- ## Architecture
423
-
424
- ```
425
- ┌─────────────────────────────────────────────────────────────────┐
426
- │ AgentOS Runtime │
427
- ├─────────────────────────────────────────────────────────────────┤
428
- │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
429
- │ │ Request │ │ Prompt │ │ Streaming │ │
430
- │ │ Router │→ │ Engine │→ │ Manager │ │
431
- │ └─────────────┘ └─────────────┘ └─────────────┘ │
432
- │ ↓ ↓ ↓ │
433
- │ ┌─────────────────────────────────────────────────────────┐ │
434
- │ │ GMI Manager │ │
435
- │ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │
436
- │ │ │ Working │ │ Context │ │ Persona │ │Learning │ │ │
437
- │ │ │ Memory │ │ Manager │ │ Overlay │ │ Module │ │ │
438
- │ │ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │ │
439
- │ └─────────────────────────────────────────────────────────┘ │
440
- │ ↓ ↓ ↓ │
441
- │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
442
- │ │ Tool │ │ RAG │ │ Planning │ │
443
- │ │Orchestrator │ │ Memory │ │ Engine │ │
444
- │ └─────────────┘ └─────────────┘ └─────────────┘ │
445
- │ ↓ ↓ ↓ │
446
- │ ┌─────────────────────────────────────────────────────────┐ │
447
- │ │ LLM Provider Manager │ │
448
- │ │ OpenAI │ Anthropic │ Azure │ Ollama │ ... │ │
449
- │ └─────────────────────────────────────────────────────────┘ │
450
- └─────────────────────────────────────────────────────────────────┘
1539
+ ## Package Exports
1540
+
1541
+ AgentOS provides 112 export paths for fine-grained imports. Key entry points:
1542
+
1543
+ ```typescript
1544
+ // Main entry -- all public types and classes
1545
+ import { AgentOS, AgentOSResponseChunkType, /* ... */ } from '@framers/agentos';
1546
+
1547
+ // Configuration
1548
+ import { createAgentOSConfig, createTestAgentOSConfig } from '@framers/agentos/config/AgentOSConfig';
1549
+
1550
+ // Safety primitives
1551
+ import { CircuitBreaker, CostGuard, StuckDetector } from '@framers/agentos/core/safety';
1552
+
1553
+ // Guardrails
1554
+ import { GuardrailAction } from '@framers/agentos/core/guardrails';
1555
+
1556
+ // Tools
1557
+ import type { ITool, ToolExecutionResult } from '@framers/agentos/core/tools';
1558
+
1559
+ // HITL
1560
+ import type { IHumanInteractionManager } from '@framers/agentos/core/hitl';
1561
+
1562
+ // RAG
1563
+ import { VectorStoreManager, EmbeddingManager, RetrievalAugmentor } from '@framers/agentos/rag';
1564
+ import { GraphRAGEngine } from '@framers/agentos/rag/graphrag';
1565
+
1566
+ // Skills
1567
+ import { SkillRegistry, SkillLoader } from '@framers/agentos/skills';
1568
+
1569
+ // Deep imports (wildcard exports)
1570
+ import { SomeType } from '@framers/agentos/core/safety/CircuitBreaker';
1571
+ import { SomeConfig } from '@framers/agentos/config/ToolOrchestratorConfig';
451
1572
  ```
452
1573
 
1574
+ Wildcard exports support paths up to 4 levels deep:
1575
+ - `./*` -- `dist/*.js`
1576
+ - `./*/*` -- `dist/*/*.js`
1577
+ - `./*/*/*` -- `dist/*/*/*.js`
1578
+ - `./*/*/*/*` -- `dist/*/*/*/*.js`
1579
+
453
1580
  ---
454
1581
 
455
- ## Documentation
1582
+ ## Internal Documentation
1583
+
1584
+ The `docs/` directory contains 25 detailed specification documents:
1585
+
1586
+ | Document | Description |
1587
+ |----------|-------------|
1588
+ | [`ARCHITECTURE.md`](docs/ARCHITECTURE.md) | Complete system architecture with data flow diagrams |
1589
+ | [`SAFETY_PRIMITIVES.md`](docs/SAFETY_PRIMITIVES.md) | Circuit breaker, cost guard, stuck detection, dedup API reference |
1590
+ | [`PLANNING_ENGINE.md`](docs/PLANNING_ENGINE.md) | ReAct reasoning, multi-step task planning specification |
1591
+ | [`HUMAN_IN_THE_LOOP.md`](docs/HUMAN_IN_THE_LOOP.md) | Approval workflows, clarification, escalation patterns |
1592
+ | [`GUARDRAILS_USAGE.md`](docs/GUARDRAILS_USAGE.md) | Input/output guardrail implementation patterns |
1593
+ | [`RAG_MEMORY_CONFIGURATION.md`](docs/RAG_MEMORY_CONFIGURATION.md) | Vector store setup, embedding models, data source config |
1594
+ | [`MULTIMODAL_RAG.md`](docs/MULTIMODAL_RAG.md) | Image, audio, and document RAG pipelines |
1595
+ | [`STRUCTURED_OUTPUT.md`](docs/STRUCTURED_OUTPUT.md) | JSON schema validation, entity extraction, function calling |
1596
+ | [`AGENT_COMMUNICATION.md`](docs/AGENT_COMMUNICATION.md) | Inter-agent messaging, handoffs, shared memory |
1597
+ | [`TOOL_CALLING_AND_LOADING.md`](docs/TOOL_CALLING_AND_LOADING.md) | Tool registration, discovery, execution pipeline |
1598
+ | [`OBSERVABILITY.md`](docs/OBSERVABILITY.md) | OpenTelemetry setup, custom spans, metrics export |
1599
+ | [`COST_OPTIMIZATION.md`](docs/COST_OPTIMIZATION.md) | Token usage monitoring, caching strategies, model routing |
1600
+ | [`SKILLS.md`](docs/SKILLS.md) | SKILL.md format specification, skill authoring guide |
1601
+ | [`PLATFORM_SUPPORT.md`](docs/PLATFORM_SUPPORT.md) | Channel platform capabilities and adapter configuration |
1602
+ | [`ECOSYSTEM.md`](docs/ECOSYSTEM.md) | Extension ecosystem, official packs, community extensions |
1603
+ | [`PROVENANCE_IMMUTABILITY.md`](docs/PROVENANCE_IMMUTABILITY.md) | Sealed agents, signed event ledger, external anchoring |
1604
+ | [`IMMUTABLE_AGENTS.md`](docs/IMMUTABLE_AGENTS.md) | Agent sealing, toolset manifests, revision tracking |
1605
+ | [`RFC_EXTENSION_STANDARDS.md`](docs/RFC_EXTENSION_STANDARDS.md) | Extension pack authoring standards and conventions |
1606
+ | [`EVALUATION_FRAMEWORK.md`](docs/EVALUATION_FRAMEWORK.md) | Agent evaluation, benchmarking, quality metrics |
1607
+ | [`RECURSIVE_SELF_BUILDING_AGENTS.md`](docs/RECURSIVE_SELF_BUILDING_AGENTS.md) | Self-modifying agent patterns |
1608
+ | [`LOGGING.md`](docs/LOGGING.md) | Structured logging configuration with pino |
1609
+ | [`CLIENT_SIDE_STORAGE.md`](docs/CLIENT_SIDE_STORAGE.md) | Browser-compatible storage adapters |
1610
+ | [`SQL_STORAGE_QUICKSTART.md`](docs/SQL_STORAGE_QUICKSTART.md) | SQLite/Postgres setup with `@framers/sql-storage-adapter` |
1611
+ | [`RELEASING.md`](docs/RELEASING.md) | Release process and semantic versioning |
1612
+
1613
+ ---
456
1614
 
457
- Full documentation at **[docs.agentos.sh](https://docs.agentos.sh)**
1615
+ ## Key Design Patterns
458
1616
 
459
- | Topic | Description |
460
- |-------|-------------|
461
- | [System Architecture](https://docs.agentos.sh/docs/architecture/system-architecture) | Core design and component internals |
462
- | [Planning Engine](https://docs.agentos.sh/docs/features/planning-engine) | Multi-step task planning and execution |
463
- | [Human-in-the-Loop](https://docs.agentos.sh/docs/features/human-in-the-loop) | Approval workflows and oversight |
464
- | [Guardrails](https://docs.agentos.sh/docs/features/guardrails) | Safety constraints and content filtering |
465
- | [RAG Memory](https://docs.agentos.sh/docs/features/rag-memory) | Vector storage and retrieval configuration |
466
- | [Extensions](https://docs.agentos.sh/docs/extensions/overview) | Extension system, official extensions catalog |
467
- | [Structured Output](https://docs.agentos.sh/docs/features/structured-output) | JSON schema validation and entity extraction |
468
- | [Agent Communication](https://docs.agentos.sh/docs/features/agent-communication) | Inter-agent messaging and handoffs |
469
- | [Observability](https://docs.agentos.sh/docs/architecture/observability) | OpenTelemetry traces, metrics, and logging |
470
- | [Cost Optimization](https://docs.agentos.sh/docs/features/cost-optimization) | Token usage monitoring and caching |
471
- | [API Reference](https://docs.agentos.sh/docs/api/) | Auto-generated TypeDoc API docs |
1617
+ 1. **Interface-driven design** -- All major components define interface contracts (`IAgentOS`, `ITool`, `IGuardrailService`, `IChannelAdapter`, `IVoiceCallProvider`, `IVectorStore`, etc.). Implementations are swappable.
1618
+
1619
+ 2. **Streaming-first** -- Core interaction methods return `AsyncGenerator<AgentOSResponse>` for token-level streaming with natural backpressure. Consumers process chunks as they arrive.
1620
+
1621
+ 3. **Extension system** -- Pluggable components via `ExtensionDescriptor` with 12 kinds, priority stacking, lifecycle hooks, and secret management. Extensions can be loaded from npm packages, local modules, or inline factories.
1622
+
1623
+ 4. **Multi-provider** -- LLM providers, vector stores, voice providers, and channel adapters all support multiple backend implementations with runtime switching.
1624
+
1625
+ 5. **Safety layering** -- Defense-in-depth: input guardrails, output guardrails, circuit breakers, cost guards, tool execution guards, stuck detection, action deduplication, and HITL approval gates.
1626
+
1627
+ 6. **Observability** -- OpenTelemetry integration throughout the stack with distributed tracing, custom metrics, cost tracking, and structured logging via pino.
472
1628
 
473
1629
  ---
474
1630
 
@@ -482,6 +1638,17 @@ pnpm run build
482
1638
  pnpm run test
483
1639
  ```
484
1640
 
1641
+ **Available scripts:**
1642
+
1643
+ | Script | Purpose |
1644
+ |--------|---------|
1645
+ | `pnpm run build` | Clean, compile TypeScript, resolve aliases, fix ESM imports |
1646
+ | `pnpm run typecheck` | Type-check without emitting |
1647
+ | `pnpm run lint` | Strip non-breaking spaces + ESLint |
1648
+ | `pnpm run test` | Run vitest test suite |
1649
+ | `pnpm run dev:test` | Run vitest in watch mode |
1650
+ | `pnpm run docs` | Generate TypeDoc API documentation |
1651
+
485
1652
  We use [Conventional Commits](https://www.conventionalcommits.org/): `feat:` (minor), `fix:` (patch), `BREAKING CHANGE:` (major).
486
1653
 
487
1654
  See the [Contributing Guide](https://github.com/framersai/agentos/blob/master/CONTRIBUTING.md) for details.
@@ -490,7 +1657,7 @@ See the [Contributing Guide](https://github.com/framersai/agentos/blob/master/CO
490
1657
 
491
1658
  ## License
492
1659
 
493
- [Apache 2.0](./LICENSE) [Frame.dev](https://frame.dev)
1660
+ [Apache 2.0](./LICENSE) -- [Frame.dev](https://frame.dev)
494
1661
 
495
1662
  <div align="center">
496
1663