art-framework 0.4.7 → 0.4.11

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
@@ -1,6 +1,4 @@
1
- 
2
-
3
- # ✨ ART: Agentic Runtime Framework (beta) <img src="https://img.shields.io/badge/Version-v0.4.7-blue" alt="Version 0.4.7">
1
+ # ✨ ART: Agentic Runtime Framework <img src="https://img.shields.io/badge/Version-v0.4.11-blue" alt="Version 0.4.11">
4
2
 
5
3
  <p align="center">
6
4
  <img src="docs/art-logo.jpeg" alt="ART Framework Logo" width="200"/>
@@ -9,60 +7,42 @@
9
7
  <img src="docs/art-banner.png" alt="ART Framework Overview" width="100%"/>
10
8
  </p>
11
9
 
12
- **ART is a powerful, modular, and browser-first TypeScript framework for building sophisticated LLM-powered agents capable of complex reasoning, planning, and tool usage.**
10
+ **ART (Agentic Reactive Triad) is a powerful, modular, and browser-first TypeScript framework for building sophisticated LLM-powered agents capable of complex reasoning, planning, and tool usage.**
13
11
 
14
- It provides the building blocks for creating robust agentic systems that can run entirely client-side, emphasizing user privacy, offline capability, and deep observability, while also supporting server-side deployments.
12
+ It provides the missing runtime for production-ready agentic systems, emphasizing **Reliability**, **Observability**, and **Resilience**.
15
13
 
16
14
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
17
15
  [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
18
16
 
19
17
  [![Sponsor on Patreon](https://img.shields.io/badge/Sponsor%20on-Patreon-F96854?logo=patreon&style=flat)](https://www.patreon.com/HashanWickramasinghe)
20
18
 
21
- ## Overview
19
+ ## The Reactive Triad
22
20
 
23
- Existing agent frameworks often rely on server-side components, limiting their use in web applications where user privacy or offline functionality is critical. ART is engineered to address this gap by providing a comprehensive, standalone toolkit designed for the browser, while remaining powerful enough for server-side execution.
21
+ ART is architected around three core nodes that ensure your agents are production-ready:
24
22
 
25
- **Core Goals:**
26
- * **Browser-First:** Enable complex agent logic to run directly in the user's browser, enhancing privacy and reducing server costs.
27
- * **Modularity:** Offer distinct, replaceable components for storage, reasoning, and tools.
28
- * **Observability:** Provide deep, real-time insights into the agent's internal thought process.
29
- * **Developer Experience:** Deliver a layered API that is simple for basic use cases yet powerful enough for advanced customization.
23
+ 1. **Reactive Agent (Orchestration):** The flagship `PESAgent` uses a **Plan-Execute-Synthesize** workflow to handle complex, multi-step tasks with dynamic refinement.
24
+ 2. **Persistent State (Memory):** Durable state management that persists across sessions, crashes, and human-in-the-loop pauses.
25
+ 3. **Standardized UI (Observability):** A reactive socket system that streams granular "thoughts," tool calls, and status updates directly to your frontend.
30
26
 
31
27
  ## Key Features
32
28
 
33
- #### Reasoning & Orchestration
34
- * **Swappable Agent Cores:** Start with the default Plan-Execute-Synthesize (`PESAgent`) pattern and seamlessly switch to or create custom reasoning patterns (e.g., ReAct, Chain of Thought).
35
- * **Streaming-First:** Native support for streaming LLM responses, enabling real-time, interactive user experiences.
36
- * **Dynamic Prompt Management:** A powerful system for constructing prompts from blueprints with dynamic context injection.
37
- * **Agent Persona Customization:** Easily define your agent's identity and default system prompt through a simple configuration object.
38
- * **Rich Observability:** A detailed, typed `Observation` system provides transparent insights into every step of an agent's operation for debugging, monitoring, and visualization.
39
-
40
- #### Connectivity & Data
41
- * **Multi-Provider Support:** A centralized `ProviderManager` allows runtime selection and configuration of multiple LLM providers (OpenAI, Anthropic, Gemini, OpenRouter, and local models via Ollama).
42
- * **Pluggable Storage:** A flexible `StorageAdapter` interface allows easy integration with any storage backend (default support for IndexedDB, InMemory, and Supabase).
43
- * **Schema-Driven Tooling:** A robust tool integration system with automatic schema validation and secure execution.
44
- * **Dynamic Tool Loading (MCP):** Support for the Model Context Protocol (MCP) enables agents to dynamically discover and use tools from compliant external servers.
45
-
46
- #### Developer Experience
47
- * **Browser-First Design:** Built to run fully in the browser, enabling privacy-preserving and offline-capable applications.
48
- * **Flexible UI Integration:** A typed, publish/subscribe socket system allows for reactive UI updates with fine-grained event filtering.
49
- * **TypeScript-Native:** Engineered from the ground up with TypeScript for a robust, type-safe development experience.
50
-
51
- ## Architecture: The 3 Nodes
52
-
53
- ART's architecture is best understood as three interconnected nodes:
54
-
55
- ```mermaid
56
- flowchart LR
57
- A["Node 1: Developer Interface\n(Your Code & Config)"] -- Configures & Invokes --> B["Node 2: ART Core Orchestration\n(The Framework's Brain)"]
58
- B -- Manages & Uses --> C["Node 3: External Dependencies & Interactions\n(LLMs, Tools, Storage)"]
59
- C -- Provides Data/Services --> B
60
- B -- Streams Results/Updates --> A
61
- ```
29
+ #### 🧠 Advanced Reasoning (PES Agent)
30
+ * **Structured Planning:** Decomposes user intent into a discrete `TodoList` with dependency mapping.
31
+ * **TAEF (Tool-Aware Execution Framework):** Strictly validates tool usage to eliminate hallucinations and ensure protocol adherence.
32
+ * **Dynamic Refinement:** Self-correcting plans that adapt in real-time based on tool outputs.
33
+ * **Synthesis Engine:** Aggregates task results into rich responses with UI metadata and citations.
34
+
35
+ #### 🛡️ Production Robustness
36
+ * **HITL V2 (Human-in-the-Loop):** Seamlessly pause execution for human approval with full state preservation and resumption.
37
+ * **Crash Recovery:** Automatic state hydration ensures agents resume exactly where they left off.
38
+ * **A2A (Agent-to-Agent) Delegation:** Coordinate complex workflows by delegating sub-tasks to specialized agents.
39
+ * **Step Output Table:** Persists all historical tool results for consistent cross-step data access.
62
40
 
63
- * **Node 1: Developer Interface (Your Code & Config):** This is your interaction point with ART. You use `createArtInstance` to configure the framework, selecting your storage, LLM providers, and tools. You then invoke the agent via the `art.process()` method.
64
- * **Node 2: ART Core Orchestration (The Framework's Brain):** This is the internal engine that manages the agent's lifecycle. It orchestrates state, reasons with LLMs, constructs prompts, executes tools, and broadcasts updates to your UI. The selected `Agent Core` (e.g., `PESAgent`) dictates the high-level reasoning strategy used here.
65
- * **Node 3: External Dependencies & Interactions (The Outside World):** This node represents the external services ART connects to. This includes LLM APIs (like OpenAI), your custom tool logic, and storage backends (like IndexedDB or a remote database).
41
+ #### 🔌 Universal Connectivity
42
+ * **Multi-Provider Support:** First-class support for Gemini (Thinking), Claude (Extended Thinking), GPT (Reasoning), DeepSeek, Groq, and local models via Ollama.
43
+ * **MCP (Model Context Protocol):** Dynamically discover and execute tools from any MCP-compliant server.
44
+ * **Pluggable Storage:** Integrated adapters for IndexedDB (Browser), Supabase (Backend), and In-Memory.
45
+ * **OAuth & Auth Strategies:** Built-in support for PKCE, Generic OAuth, and API key management.
66
46
 
67
47
  ## Installation
68
48
 
@@ -70,106 +50,57 @@ flowchart LR
70
50
  npm install art-framework
71
51
  # or
72
52
  pnpm install art-framework
73
- # or
74
- yarn add art-framework
75
53
  ```
76
54
 
77
55
  ## Quick Start
78
56
 
79
- This example demonstrates setting up a simple agent that uses OpenAI and runs in-memory. For a complete example with all configurations, see the [Comprehensive Developer Guide](./docs/README.md).
80
-
81
57
  ```typescript
82
58
  import {
83
59
  createArtInstance,
84
- ArtInstanceConfig,
85
- ThreadConfig,
86
- CalculatorTool,
60
+ PESAgent,
87
61
  OpenAIAdapter,
88
- GeminiAdapter
62
+ CalculatorTool
89
63
  } from 'art-framework';
90
64
 
91
- // --- 1. Configure the ART Instance ---
92
- // Note: No API keys or secrets are present here.
93
-
94
- const artConfig: ArtInstanceConfig = {
95
- storage: {
96
- type: 'indexedDB',
97
- dbName: 'MyCorrectChatDB'
98
- },
65
+ const art = await createArtInstance({
66
+ storage: { type: 'indexedDB', dbName: 'AgentDB' },
99
67
  providers: {
100
- availableProviders: [
101
- { name: 'openai', adapter: OpenAIAdapter },
102
- { name: 'gemini', adapter: GeminiAdapter }
103
- ]
68
+ availableProviders: [{ name: 'openai', adapter: OpenAIAdapter }]
104
69
  },
105
70
  tools: [new CalculatorTool()],
106
- persona: {
107
- name: 'ConfigExpert',
108
- prompts: {
109
- synthesis: 'You explain configurations clearly.'
110
- }
71
+ agentCore: PESAgent // Default flagship agent
72
+ });
73
+
74
+ // Configure the thread (Where API keys live)
75
+ await art.stateManager.setThreadConfig('my-thread', {
76
+ providerConfig: {
77
+ providerName: 'openai',
78
+ modelId: 'gpt-4o',
79
+ adapterOptions: { apiKey: process.env.OPENAI_API_KEY }
111
80
  },
112
- logger: { level: 'info' }
113
- };
114
-
115
-
116
- // --- 2. Main Application Logic ---
117
-
118
- async function initializeAndRun() {
119
- // Create the ART instance with the high-level configuration.
120
- const art = await createArtInstance(artConfig);
121
- console.log('ART Instance Initialized.');
122
-
123
- // --- 3. Set Up a New Conversation Thread ---
124
- const threadId = 'user-123-session-1';
125
-
126
- // Create the thread-specific configuration.
127
- // THIS is where you specify the provider, model, and API key.
128
- const threadConfig: ThreadConfig = {
129
- providerConfig: {
130
- providerName: 'openai', // Must match a name from availableProviders
131
- modelId: 'gpt-4o',
132
- adapterOptions: {
133
- apiKey: 'sk-your-real-openai-api-key', // Securely provide your API key here
134
- temperature: 0.7
135
- }
136
- },
137
- // Other thread settings
138
- enabledTools: ['CalculatorTool'],
139
- historyLimit: 20
140
- };
141
-
142
- // Save this configuration for the new thread.
143
- // This step is crucial and must be done before the first `process` call.
144
- await art.stateManager.setThreadConfig(threadId, threadConfig);
145
- console.log(`ThreadConfig set for threadId: ${threadId}`);
146
-
147
- // Now the ART instance is ready to process requests for this thread.
148
- console.log('Sending first message...');
149
- const response = await art.process({
150
- query: 'What is 2 + 2?',
151
- threadId: threadId
152
- });
153
-
154
- console.log('Final response:', response.response.content);
155
- }
156
-
157
- initializeAndRun().catch(console.error);
158
- ```
81
+ enabledTools: ['CalculatorTool']
82
+ });
159
83
 
160
- *(Note: Replace `'YOUR_OPENAI_API_KEY'` with your actual key. In a real application, load this from a secure source like environment variables or a secrets manager.)*
84
+ // Process a request
85
+ const result = await art.process({
86
+ query: 'Calculate the compound interest for $1000 at 5% over 10 years.',
87
+ threadId: 'my-thread'
88
+ });
89
+
90
+ console.log(result.response.content);
91
+ ```
161
92
 
162
93
  ## Documentation
163
94
 
164
- * **[Comprehensive Developer Guide](docs/README.md):** The primary guide covering concepts, architecture, and API usage. **(Start Here!)**
165
- * **[How-To Guides](./docs/how-to):** Practical guides for specific tasks, such as [Customizing the Agent's Persona](./docs/how-to/customizing-agent-persona.md).
166
- * **[API Reference](./docs/components):** Auto-generated API documentation.
167
- * **[Examples](./examples):** Find practical examples, including a full React chatbot implementation.
95
+ * **[Concepts Guide](docs/concepts/pes-agent.md):** Deep dive into the PES Agent and Reactive Triad.
96
+ * **[How-To Guides](./docs/how-to):** Practical tutorials for [HITL](./docs/how-to/using-hitl-pausing.md), [MCP](./docs/concepts/mcp-system.md), and [Custom UI](./docs/how-to/connecting-your-ui.md).
97
+ * **[API Reference](https://inferq.github.io/ART/components/index.html):** Full technical documentation.
98
+ * **[Website](https://inferq.github.io/ART/):** Marketing site & Live Demos.
168
99
 
169
100
  ## Contributing
170
101
 
171
- Contributions are welcome! Please refer to the [Contributing Guide](./CONTRIBUTING.md) for details on how to submit issues, feature requests, and pull requests.
102
+ Contributions are welcome! Please refer to the [Contributing Guide](./CONTRIBUTING.md).
172
103
 
173
104
  ## License
174
105
 
175
- ART Framework is released under the [MIT License](https://opensource.org/licenses/MIT).
106
+ ART Framework is released under the [MIT License](https://opensource.org/licenses/MIT).