@olane/o-lane 0.7.1
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 +1495 -0
- package/dist/src/capabilities/enums/o-capability.type-enum.d.ts +11 -0
- package/dist/src/capabilities/enums/o-capability.type-enum.d.ts.map +1 -0
- package/dist/src/capabilities/enums/o-capability.type-enum.js +11 -0
- package/dist/src/capabilities/index.d.ts +6 -0
- package/dist/src/capabilities/index.d.ts.map +1 -0
- package/dist/src/capabilities/index.js +5 -0
- package/dist/src/capabilities/interfaces/o-capability.config.d.ts +11 -0
- package/dist/src/capabilities/interfaces/o-capability.config.d.ts.map +1 -0
- package/dist/src/capabilities/interfaces/o-capability.config.js +1 -0
- package/dist/src/capabilities/interfaces/o-capability.intelligence-result.d.ts +5 -0
- package/dist/src/capabilities/interfaces/o-capability.intelligence-result.d.ts.map +1 -0
- package/dist/src/capabilities/interfaces/o-capability.intelligence-result.js +3 -0
- package/dist/src/capabilities/interfaces/o-capability.result-interface.d.ts +9 -0
- package/dist/src/capabilities/interfaces/o-capability.result-interface.d.ts.map +1 -0
- package/dist/src/capabilities/interfaces/o-capability.result-interface.js +1 -0
- package/dist/src/capabilities/o-capability.d.ts +16 -0
- package/dist/src/capabilities/o-capability.d.ts.map +1 -0
- package/dist/src/capabilities/o-capability.intelligence.d.ts +6 -0
- package/dist/src/capabilities/o-capability.intelligence.d.ts.map +1 -0
- package/dist/src/capabilities/o-capability.intelligence.js +40 -0
- package/dist/src/capabilities/o-capability.js +20 -0
- package/dist/src/capabilities/o-capability.result.d.ts +27 -0
- package/dist/src/capabilities/o-capability.result.d.ts.map +1 -0
- package/dist/src/capabilities/o-capability.result.js +27 -0
- package/dist/src/capabilities-all/o-capability.all.d.ts +5 -0
- package/dist/src/capabilities-all/o-capability.all.d.ts.map +1 -0
- package/dist/src/capabilities-all/o-capability.all.js +12 -0
- package/dist/src/capabilities-configure/interfaces/o-capability.configure-config.d.ts +8 -0
- package/dist/src/capabilities-configure/interfaces/o-capability.configure-config.d.ts.map +1 -0
- package/dist/src/capabilities-configure/interfaces/o-capability.configure-config.js +1 -0
- package/dist/src/capabilities-configure/o-capability.configure-result.d.ts +6 -0
- package/dist/src/capabilities-configure/o-capability.configure-result.d.ts.map +1 -0
- package/dist/src/capabilities-configure/o-capability.configure-result.js +3 -0
- package/dist/src/capabilities-configure/o-capability.configure.d.ts +16 -0
- package/dist/src/capabilities-configure/o-capability.configure.d.ts.map +1 -0
- package/dist/src/capabilities-configure/o-capability.configure.js +43 -0
- package/dist/src/capabilities-evaluate/o-capability.evaluate.d.ts +9 -0
- package/dist/src/capabilities-evaluate/o-capability.evaluate.d.ts.map +1 -0
- package/dist/src/capabilities-evaluate/o-capability.evaluate.js +15 -0
- package/dist/src/capabilities-multiple-step/interfaces/o-capability.multiple-step-config.d.ts +12 -0
- package/dist/src/capabilities-multiple-step/interfaces/o-capability.multiple-step-config.d.ts.map +1 -0
- package/dist/src/capabilities-multiple-step/interfaces/o-capability.multiple-step-config.js +1 -0
- package/dist/src/capabilities-multiple-step/o-capability.multiple-step.d.ts +14 -0
- package/dist/src/capabilities-multiple-step/o-capability.multiple-step.d.ts.map +1 -0
- package/dist/src/capabilities-multiple-step/o-capability.multiple-step.js +36 -0
- package/dist/src/capabilities-search/interfaces/o-capability.search-config.d.ts +12 -0
- package/dist/src/capabilities-search/interfaces/o-capability.search-config.d.ts.map +1 -0
- package/dist/src/capabilities-search/interfaces/o-capability.search-config.js +1 -0
- package/dist/src/capabilities-search/o-capability.search-result.d.ts +7 -0
- package/dist/src/capabilities-search/o-capability.search-result.d.ts.map +1 -0
- package/dist/src/capabilities-search/o-capability.search-result.js +8 -0
- package/dist/src/capabilities-search/o-capability.search.d.ts +27 -0
- package/dist/src/capabilities-search/o-capability.search.d.ts.map +1 -0
- package/dist/src/capabilities-search/o-capability.search.js +108 -0
- package/dist/src/capabilities-task/interfaces/o-capability.task-config.d.ts +15 -0
- package/dist/src/capabilities-task/interfaces/o-capability.task-config.d.ts.map +1 -0
- package/dist/src/capabilities-task/interfaces/o-capability.task-config.js +1 -0
- package/dist/src/capabilities-task/o-capability.task-result.d.ts +5 -0
- package/dist/src/capabilities-task/o-capability.task-result.d.ts.map +1 -0
- package/dist/src/capabilities-task/o-capability.task-result.js +3 -0
- package/dist/src/capabilities-task/o-capability.task.d.ts +20 -0
- package/dist/src/capabilities-task/o-capability.task.d.ts.map +1 -0
- package/dist/src/capabilities-task/o-capability.task.js +81 -0
- package/dist/src/enum/o-lane.status-enum.d.ts +10 -0
- package/dist/src/enum/o-lane.status-enum.d.ts.map +1 -0
- package/dist/src/enum/o-lane.status-enum.js +10 -0
- package/dist/src/index.d.ts +17 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +16 -0
- package/dist/src/intent/index.d.ts +2 -0
- package/dist/src/intent/index.d.ts.map +1 -0
- package/dist/src/intent/index.js +1 -0
- package/dist/src/intent/interfaces/o-intent.config.d.ts +4 -0
- package/dist/src/intent/interfaces/o-intent.config.d.ts.map +1 -0
- package/dist/src/intent/interfaces/o-intent.config.js +1 -0
- package/dist/src/intent/o-intent.d.ts +10 -0
- package/dist/src/intent/o-intent.d.ts.map +1 -0
- package/dist/src/intent/o-intent.js +18 -0
- package/dist/src/intent-encoder/index.d.ts +2 -0
- package/dist/src/intent-encoder/index.d.ts.map +1 -0
- package/dist/src/intent-encoder/index.js +1 -0
- package/dist/src/intent-encoder/o-intent.encoder.d.ts +4 -0
- package/dist/src/intent-encoder/o-intent.encoder.d.ts.map +1 -0
- package/dist/src/intent-encoder/o-intent.encoder.js +3 -0
- package/dist/src/interfaces/configure.result.d.ts +7 -0
- package/dist/src/interfaces/configure.result.d.ts.map +1 -0
- package/dist/src/interfaces/configure.result.js +1 -0
- package/dist/src/interfaces/handshake.result.d.ts +13 -0
- package/dist/src/interfaces/handshake.result.d.ts.map +1 -0
- package/dist/src/interfaces/handshake.result.js +8 -0
- package/dist/src/interfaces/index.d.ts +8 -0
- package/dist/src/interfaces/index.d.ts.map +1 -0
- package/dist/src/interfaces/index.js +7 -0
- package/dist/src/interfaces/o-lane-query.config.d.ts +6 -0
- package/dist/src/interfaces/o-lane-query.config.d.ts.map +1 -0
- package/dist/src/interfaces/o-lane-query.config.js +1 -0
- package/dist/src/interfaces/o-lane-task.config.d.ts +10 -0
- package/dist/src/interfaces/o-lane-task.config.d.ts.map +1 -0
- package/dist/src/interfaces/o-lane-task.config.js +1 -0
- package/dist/src/interfaces/o-lane-type.enum.d.ts +8 -0
- package/dist/src/interfaces/o-lane-type.enum.d.ts.map +1 -0
- package/dist/src/interfaces/o-lane-type.enum.js +8 -0
- package/dist/src/interfaces/o-lane.config.d.ts +18 -0
- package/dist/src/interfaces/o-lane.config.d.ts.map +1 -0
- package/dist/src/interfaces/o-lane.config.js +1 -0
- package/dist/src/interfaces/o-lane.result.d.ts +6 -0
- package/dist/src/interfaces/o-lane.result.d.ts.map +1 -0
- package/dist/src/interfaces/o-lane.result.js +1 -0
- package/dist/src/manager/interfaces/o-lane.manager-config.d.ts +4 -0
- package/dist/src/manager/interfaces/o-lane.manager-config.d.ts.map +1 -0
- package/dist/src/manager/interfaces/o-lane.manager-config.js +1 -0
- package/dist/src/manager/o-lane.manager.d.ts +18 -0
- package/dist/src/manager/o-lane.manager.d.ts.map +1 -0
- package/dist/src/manager/o-lane.manager.js +50 -0
- package/dist/src/o-lane.context.d.ts +10 -0
- package/dist/src/o-lane.context.d.ts.map +1 -0
- package/dist/src/o-lane.context.js +28 -0
- package/dist/src/o-lane.d.ts +40 -0
- package/dist/src/o-lane.d.ts.map +1 -0
- package/dist/src/o-lane.js +202 -0
- package/dist/src/o-lane.tool.d.ts +16 -0
- package/dist/src/o-lane.tool.d.ts.map +1 -0
- package/dist/src/o-lane.tool.js +64 -0
- package/dist/src/prompts/agent.prompt.d.ts +2 -0
- package/dist/src/prompts/agent.prompt.d.ts.map +1 -0
- package/dist/src/prompts/agent.prompt.js +118 -0
- package/dist/src/prompts/configure.prompt.d.ts +2 -0
- package/dist/src/prompts/configure.prompt.d.ts.map +1 -0
- package/dist/src/prompts/configure.prompt.js +40 -0
- package/dist/src/prompts/custom.prompt.d.ts +2 -0
- package/dist/src/prompts/custom.prompt.d.ts.map +1 -0
- package/dist/src/prompts/custom.prompt.js +73 -0
- package/dist/src/storage/o-lane.storage.d.ts +5 -0
- package/dist/src/storage/o-lane.storage.d.ts.map +1 -0
- package/dist/src/storage/o-lane.storage.js +11 -0
- package/dist/src/utils/encoder.utils.d.ts +6 -0
- package/dist/src/utils/encoder.utils.d.ts.map +1 -0
- package/dist/src/utils/encoder.utils.js +8 -0
- package/dist/test/ai.spec.d.ts +2 -0
- package/dist/test/ai.spec.d.ts.map +1 -0
- package/dist/test/ai.spec.js +19 -0
- package/package.json +68 -0
package/README.md
ADDED
|
@@ -0,0 +1,1495 @@
|
|
|
1
|
+
# @olane/o-lane
|
|
2
|
+
|
|
3
|
+
> Agentic process management for Olane OS - transform intents into intelligent, self-organizing workflows
|
|
4
|
+
|
|
5
|
+
The execution layer that manages AI agent processes through capability-based loops, turning natural language intents into coordinated multi-step actions without explicit orchestration.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@olane/o-lane)
|
|
8
|
+
[](https://opensource.org/licenses/ISC)
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- 🔄 **Intent-Driven Execution** - Transform natural language goals into agent workflows
|
|
13
|
+
- 🧠 **Capability-Based Loop** - Evaluate-plan-execute cycle for emergent behavior
|
|
14
|
+
- 📊 **Execution Tracking** - Complete sequence history with cycle-by-cycle audit trails
|
|
15
|
+
- 🌊 **Streaming Support** - Real-time progress updates to calling agents
|
|
16
|
+
- 💾 **Persistent State** - Content-addressed storage of lane execution history
|
|
17
|
+
- 🎯 **Pre-built Capabilities** - Evaluate, Task, Search, Configure, Error handling included
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @olane/o-lane
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
### Creating a Lane-Enabled Tool
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { oLaneTool } from '@olane/o-lane';
|
|
31
|
+
import { oAddress } from '@olane/o-core';
|
|
32
|
+
|
|
33
|
+
class MyAgentTool extends oLaneTool {
|
|
34
|
+
constructor() {
|
|
35
|
+
super({
|
|
36
|
+
address: new oAddress('o://my-agent'),
|
|
37
|
+
description: 'My intelligent agent tool'
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Add custom tool methods
|
|
42
|
+
async _tool_analyze(request: oRequest): Promise<any> {
|
|
43
|
+
return { analysis: 'Data analyzed successfully' };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Start your agent
|
|
48
|
+
const agent = new MyAgentTool();
|
|
49
|
+
await agent.start();
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Executing an Intent
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
// Agent receives an intent and autonomously determines how to execute it
|
|
56
|
+
const response = await agent.use({
|
|
57
|
+
method: 'intent',
|
|
58
|
+
params: {
|
|
59
|
+
intent: 'Analyze the sales data and create a summary report',
|
|
60
|
+
context: 'Previous conversation context here...',
|
|
61
|
+
streamTo: 'o://user/session'
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
console.log(response.result);
|
|
66
|
+
// {
|
|
67
|
+
// result: "Analysis complete. Created summary report with key insights...",
|
|
68
|
+
// cycles: 5,
|
|
69
|
+
// sequence: [
|
|
70
|
+
// { type: 'EVALUATE', reasoning: '...' },
|
|
71
|
+
// { type: 'TASK', result: '...' },
|
|
72
|
+
// { type: 'SEARCH', result: '...' },
|
|
73
|
+
// { type: 'TASK', result: '...' },
|
|
74
|
+
// { type: 'STOP', result: '...' }
|
|
75
|
+
// ]
|
|
76
|
+
// }
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Expected Output
|
|
80
|
+
|
|
81
|
+
After executing an intent, you'll receive:
|
|
82
|
+
- ✅ **Final result** - The outcome of the intent execution
|
|
83
|
+
- ✅ **Cycle count** - Number of capability cycles executed
|
|
84
|
+
- ✅ **Execution sequence** - Step-by-step breakdown of what the agent did
|
|
85
|
+
- ✅ **Reasoning traces** - Why the agent made each decision
|
|
86
|
+
|
|
87
|
+
### Next Steps
|
|
88
|
+
|
|
89
|
+
- [Understand what lanes are](#what-is-o-lane)
|
|
90
|
+
- [Learn about capabilities](#built-in-capabilities)
|
|
91
|
+
- [Create custom capabilities](#custom-capabilities)
|
|
92
|
+
- [Implement streaming](#streaming-integration)
|
|
93
|
+
|
|
94
|
+
## What is o-lane?
|
|
95
|
+
|
|
96
|
+
### The Agent Process Manager
|
|
97
|
+
|
|
98
|
+
Think of `o-lane` as the **process manager for tool nodes (applications)** in Olane OS. It enables your tool nodes to accept natural language intents from AI agents (LLMs) and autonomously resolve them through emergent workflows.
|
|
99
|
+
|
|
100
|
+
**Key Concept**:
|
|
101
|
+
- **AI Agents (Users)**: GPT-4, Claude, etc. - the intelligent users who send intents
|
|
102
|
+
- **Tool Nodes (Applications)**: What you build with o-lane - specialized capabilities that process intents
|
|
103
|
+
- **o-lane**: The runtime that enables tool nodes to execute intent-driven workflows
|
|
104
|
+
|
|
105
|
+
**Key Innovation: Emergent vs Explicit Orchestration**
|
|
106
|
+
|
|
107
|
+
| Traditional Frameworks (LangGraph, etc.) | o-lane |
|
|
108
|
+
|----------------------------------------|--------|
|
|
109
|
+
| Pre-define workflow graphs | Agents discover workflows |
|
|
110
|
+
| Explicit state machines | Emergent behavior patterns |
|
|
111
|
+
| Manual step orchestration | Capability-based autonomy |
|
|
112
|
+
| Fixed execution paths | Dynamic path discovery |
|
|
113
|
+
|
|
114
|
+
### How It Works
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
User Intent → Lane Creation → Capability Loop → Result Storage
|
|
118
|
+
↓
|
|
119
|
+
[Evaluate → Plan → Execute] × N cycles
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
1. **User provides natural language intent** - "Analyze sales data"
|
|
123
|
+
2. **Lane created** - Agentic process begins
|
|
124
|
+
3. **Capability loop** - Agent evaluates, plans, executes repeatedly
|
|
125
|
+
4. **Emergent workflow** - Agent discovers optimal path through capabilities
|
|
126
|
+
5. **Result stored** - Complete execution history saved with content addressing
|
|
127
|
+
|
|
128
|
+
### This is NOT Orchestration
|
|
129
|
+
|
|
130
|
+
o-lane doesn't tell agents what to do. Instead:
|
|
131
|
+
- Agents **evaluate** their current state and intent
|
|
132
|
+
- Agents **decide** which capability to use next
|
|
133
|
+
- Agents **learn** from execution history
|
|
134
|
+
- Workflows **emerge** from agent intelligence
|
|
135
|
+
|
|
136
|
+
## Core Concepts
|
|
137
|
+
|
|
138
|
+
### Lanes as Agentic Processes
|
|
139
|
+
|
|
140
|
+
A **lane** is a self-contained execution context for resolving an intent. Like an OS process, it has:
|
|
141
|
+
|
|
142
|
+
- **Unique ID** - Content-addressable identifier (CID)
|
|
143
|
+
- **Lifecycle states** - PENDING → RUNNING → COMPLETED
|
|
144
|
+
- **Execution history** - Complete audit trail of decisions
|
|
145
|
+
- **Resource isolation** - Independent execution context
|
|
146
|
+
- **Parent-child relationships** - Lanes can spawn sub-lanes
|
|
147
|
+
|
|
148
|
+
#### Lane Lifecycle
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
// 1. Lane creation
|
|
152
|
+
const lane = await manager.createLane({
|
|
153
|
+
intent: new oIntent({ intent: 'Process customer order' }),
|
|
154
|
+
currentNode: agentTool,
|
|
155
|
+
caller: callerAddress,
|
|
156
|
+
context: contextData
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// 2. Lane execution (automatic lifecycle)
|
|
160
|
+
const result = await lane.execute();
|
|
161
|
+
// → PREFLIGHT: Preparation and validation
|
|
162
|
+
// → RUNNING: Capability loop execution
|
|
163
|
+
// → POSTFLIGHT: Cleanup and storage
|
|
164
|
+
// → COMPLETED: Final state
|
|
165
|
+
|
|
166
|
+
// 3. Lane result
|
|
167
|
+
console.log(lane.status); // COMPLETED
|
|
168
|
+
console.log(lane.sequence); // Full execution history
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
#### Lane States
|
|
172
|
+
|
|
173
|
+
| State | Description |
|
|
174
|
+
|-------|-------------|
|
|
175
|
+
| `PENDING` | Lane created, awaiting execution |
|
|
176
|
+
| `PREFLIGHT` | Pre-execution validation and setup |
|
|
177
|
+
| `RUNNING` | Active capability loop processing |
|
|
178
|
+
| `POSTFLIGHT` | Storing results and cleanup |
|
|
179
|
+
| `COMPLETED` | Successfully finished |
|
|
180
|
+
| `FAILED` | Encountered unrecoverable error |
|
|
181
|
+
| `CANCELLED` | Manually terminated |
|
|
182
|
+
|
|
183
|
+
### Intents
|
|
184
|
+
|
|
185
|
+
Intents are **natural language expressions of what the agent should accomplish**.
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
import { oIntent } from '@olane/o-lane';
|
|
189
|
+
|
|
190
|
+
// Simple intent
|
|
191
|
+
const intent1 = new oIntent({
|
|
192
|
+
intent: 'Find relevant documentation for API authentication'
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
// Complex intent
|
|
196
|
+
const intent2 = new oIntent({
|
|
197
|
+
intent: 'Analyze Q4 sales trends, identify top performers, and generate executive summary'
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
console.log(intent1.value); // Access the intent string
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**Best Practice:** Keep intents specific and outcome-focused rather than prescriptive:
|
|
204
|
+
- ✅ "Create a summary of customer feedback from the last month"
|
|
205
|
+
- ❌ "Query the database, filter by date, run sentiment analysis, format results"
|
|
206
|
+
|
|
207
|
+
### Capabilities
|
|
208
|
+
|
|
209
|
+
Capabilities are **atomic execution primitives** that agents can use to accomplish tasks. Each capability:
|
|
210
|
+
|
|
211
|
+
- Performs one specific type of action
|
|
212
|
+
- Returns a `oCapabilityResult` indicating next capability
|
|
213
|
+
- Can succeed, fail, or trigger other capabilities
|
|
214
|
+
- Is discoverable and composable
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
import { oCapability, oCapabilityResult, oCapabilityType } from '@olane/o-lane';
|
|
218
|
+
|
|
219
|
+
// Capabilities are executed in sequence based on agent decisions
|
|
220
|
+
class CustomCapability extends oCapability {
|
|
221
|
+
get type() {
|
|
222
|
+
return oCapabilityType.CUSTOM;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
async run(): Promise<oCapabilityResult> {
|
|
226
|
+
// Your capability logic here
|
|
227
|
+
const result = await this.doWork();
|
|
228
|
+
|
|
229
|
+
return new oCapabilityResult({
|
|
230
|
+
type: oCapabilityType.EVALUATE, // Tell agent what to do next
|
|
231
|
+
result: result,
|
|
232
|
+
config: { intent: this.intent }
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### The Capability Loop
|
|
239
|
+
|
|
240
|
+
The heart of o-lane's emergent orchestration:
|
|
241
|
+
|
|
242
|
+
```
|
|
243
|
+
1. EVALUATE → Agent analyzes intent and current state
|
|
244
|
+
↓
|
|
245
|
+
2. DECIDE → Agent determines next capability to use
|
|
246
|
+
↓
|
|
247
|
+
3. EXECUTE → Capability performs its action
|
|
248
|
+
↓
|
|
249
|
+
4. RECORD → Result added to sequence
|
|
250
|
+
↓
|
|
251
|
+
5. CHECK → Complete? If yes, STOP. If no, return to EVALUATE
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
**Key Properties:**
|
|
255
|
+
|
|
256
|
+
- **Maximum Cycles**: Configurable limit (default: 20) prevents infinite loops
|
|
257
|
+
- **State Accumulation**: Each cycle builds on previous results
|
|
258
|
+
- **Emergent Patterns**: Optimal workflows discovered through execution
|
|
259
|
+
- **Fault Tolerance**: Errors trigger ERROR capability for recovery
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
// The loop runs automatically in lane.execute()
|
|
263
|
+
async loop(): Promise<oCapabilityResult> {
|
|
264
|
+
let iterations = 0;
|
|
265
|
+
let currentStep = /* Initial EVALUATE capability */;
|
|
266
|
+
|
|
267
|
+
while (iterations++ < this.MAX_CYCLES && this.status === RUNNING) {
|
|
268
|
+
const result = await this.doCapability(currentStep);
|
|
269
|
+
this.addSequence(result); // Track history
|
|
270
|
+
|
|
271
|
+
if (result.type === oCapabilityType.STOP) {
|
|
272
|
+
return result; // Intent resolved
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
currentStep = result; // Continue with next capability
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Execution Sequences
|
|
281
|
+
|
|
282
|
+
Every capability execution is recorded in the lane's sequence, creating a complete audit trail:
|
|
283
|
+
|
|
284
|
+
```typescript
|
|
285
|
+
// Access execution history
|
|
286
|
+
console.log(lane.sequence);
|
|
287
|
+
// [
|
|
288
|
+
// {
|
|
289
|
+
// id: 'cap-1',
|
|
290
|
+
// type: 'EVALUATE',
|
|
291
|
+
// config: { intent: '...', context: '...' },
|
|
292
|
+
// result: { reasoning: 'Need to search for information', next: 'SEARCH' }
|
|
293
|
+
// },
|
|
294
|
+
// {
|
|
295
|
+
// id: 'cap-2',
|
|
296
|
+
// type: 'SEARCH',
|
|
297
|
+
// config: { query: 'customer data' },
|
|
298
|
+
// result: { data: [...], next: 'TASK' }
|
|
299
|
+
// },
|
|
300
|
+
// // ... more cycles
|
|
301
|
+
// ]
|
|
302
|
+
|
|
303
|
+
// Formatted agent history
|
|
304
|
+
console.log(lane.agentHistory);
|
|
305
|
+
// [Cycle 1 Begin]
|
|
306
|
+
// Cycle Intent: Find customer data
|
|
307
|
+
// Cycle Result: { reasoning: "...", result: "..." }
|
|
308
|
+
// [Cycle 1 End]
|
|
309
|
+
// [Cycle 2 Begin]
|
|
310
|
+
// ...
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## Built-in Capabilities
|
|
314
|
+
|
|
315
|
+
o-lane includes six core capabilities that handle most agentic workflows:
|
|
316
|
+
|
|
317
|
+
### 1. Evaluate (`EVALUATE`)
|
|
318
|
+
|
|
319
|
+
**Purpose**: Analyze the intent and determine the next capability to use.
|
|
320
|
+
|
|
321
|
+
**When Used**:
|
|
322
|
+
- Start of every lane
|
|
323
|
+
- After completing any other capability
|
|
324
|
+
- When agent needs to reassess approach
|
|
325
|
+
|
|
326
|
+
```typescript
|
|
327
|
+
import { oCapabilityEvaluate } from '@olane/o-lane';
|
|
328
|
+
|
|
329
|
+
// Automatically uses AI to evaluate intent and choose next step
|
|
330
|
+
// Returns: { type: 'TASK' | 'SEARCH' | 'CONFIGURE' | 'STOP', reasoning: '...' }
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### 2. Task (`TASK`)
|
|
334
|
+
|
|
335
|
+
**Purpose**: Execute a specific tool method with parameters.
|
|
336
|
+
|
|
337
|
+
**When Used**: Agent needs to call a tool (API, database, computation, etc.)
|
|
338
|
+
|
|
339
|
+
```typescript
|
|
340
|
+
// Agent decides to execute a task
|
|
341
|
+
// Result: { type: 'TASK', config: { task: { address: 'o://tool', payload: {...} } } }
|
|
342
|
+
|
|
343
|
+
// Capability executes:
|
|
344
|
+
const response = await this.node.use(new oAddress('o://analytics'), {
|
|
345
|
+
method: 'analyze_sales',
|
|
346
|
+
params: { period: 'Q4' }
|
|
347
|
+
});
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### 3. Search (`SEARCH`)
|
|
351
|
+
|
|
352
|
+
**Purpose**: Query vector stores, registries, or knowledge bases for information.
|
|
353
|
+
|
|
354
|
+
**When Used**: Agent needs to find relevant context, tools, or data
|
|
355
|
+
|
|
356
|
+
```typescript
|
|
357
|
+
// Searches network for capabilities or information
|
|
358
|
+
// Can query vector stores, registries, or other search services
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### 4. Configure (`CONFIGURE`)
|
|
362
|
+
|
|
363
|
+
**Purpose**: Set up tool parameters, establish connections, or prepare environment.
|
|
364
|
+
|
|
365
|
+
**When Used**: Before executing complex operations requiring setup
|
|
366
|
+
|
|
367
|
+
```typescript
|
|
368
|
+
// Configures tools or establishes required state
|
|
369
|
+
// Returns configuration result and proceeds to next capability
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### 5. Error (`ERROR`)
|
|
373
|
+
|
|
374
|
+
**Purpose**: Handle errors gracefully and attempt recovery.
|
|
375
|
+
|
|
376
|
+
**When Used**: Any capability encounters an error
|
|
377
|
+
|
|
378
|
+
```typescript
|
|
379
|
+
// Automatically triggered on errors
|
|
380
|
+
// Analyzes error, determines recovery strategy
|
|
381
|
+
// Can retry, use alternative approach, or escalate
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
### 6. Multiple Step (`MULTIPLE_STEP`)
|
|
385
|
+
|
|
386
|
+
**Purpose**: Coordinate complex multi-step operations.
|
|
387
|
+
|
|
388
|
+
**When Used**: Intent requires coordinating several dependent actions
|
|
389
|
+
|
|
390
|
+
```typescript
|
|
391
|
+
// Manages sequences of related tasks
|
|
392
|
+
// Tracks progress across multiple steps
|
|
393
|
+
// Handles dependencies between steps
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### Capability Flow Example
|
|
397
|
+
|
|
398
|
+
```
|
|
399
|
+
Intent: "Analyze Q4 sales and create report"
|
|
400
|
+
↓
|
|
401
|
+
Cycle 1: EVALUATE → "Need to search for sales data tool"
|
|
402
|
+
↓
|
|
403
|
+
Cycle 2: SEARCH → Found 'o://analytics/sales'
|
|
404
|
+
↓
|
|
405
|
+
Cycle 3: EVALUATE → "Ready to fetch data"
|
|
406
|
+
↓
|
|
407
|
+
Cycle 4: TASK → Execute o://analytics/sales/fetch_q4_data
|
|
408
|
+
↓
|
|
409
|
+
Cycle 5: EVALUATE → "Have data, need to analyze"
|
|
410
|
+
↓
|
|
411
|
+
Cycle 6: TASK → Execute o://analytics/analyze
|
|
412
|
+
↓
|
|
413
|
+
Cycle 7: EVALUATE → "Analysis complete, create report"
|
|
414
|
+
↓
|
|
415
|
+
Cycle 8: TASK → Execute o://reports/create
|
|
416
|
+
↓
|
|
417
|
+
Cycle 9: EVALUATE → "Report created, done"
|
|
418
|
+
↓
|
|
419
|
+
Cycle 10: STOP → Return final result
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
## API Reference
|
|
423
|
+
|
|
424
|
+
### `oLane` Class
|
|
425
|
+
|
|
426
|
+
Core lane execution class that manages the capability loop.
|
|
427
|
+
|
|
428
|
+
#### Constructor
|
|
429
|
+
|
|
430
|
+
```typescript
|
|
431
|
+
new oLane(config: oLaneConfig)
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
**Config Properties:**
|
|
435
|
+
- `intent: oIntent` - The intent to resolve (required)
|
|
436
|
+
- `caller: oAddress` - Address of the calling agent (required)
|
|
437
|
+
- `currentNode: oLaneTool` - The agent tool executing the lane (required)
|
|
438
|
+
- `context?: oLaneContext` - Historical or domain context
|
|
439
|
+
- `streamTo?: oAddress` - Address to stream progress updates
|
|
440
|
+
- `capabilities?: oCapability[]` - Custom capability set
|
|
441
|
+
- `maxCycles?: number` - Override default max cycles (20)
|
|
442
|
+
- `parentLaneId?: string` - Parent lane for sub-lanes
|
|
443
|
+
|
|
444
|
+
#### Properties
|
|
445
|
+
|
|
446
|
+
- `intent: oIntent` - The intent being resolved
|
|
447
|
+
- `sequence: oCapabilityResult[]` - Execution history
|
|
448
|
+
- `status: oLaneStatus` - Current lifecycle state
|
|
449
|
+
- `result: oCapabilityResult` - Final execution result
|
|
450
|
+
- `id: string` - Unique lane identifier
|
|
451
|
+
- `cid?: CID` - Content identifier for storage
|
|
452
|
+
- `agentHistory: string` - Formatted execution history
|
|
453
|
+
|
|
454
|
+
#### Methods
|
|
455
|
+
|
|
456
|
+
**`async execute(): Promise<oCapabilityResult>`**
|
|
457
|
+
|
|
458
|
+
Execute the complete lane lifecycle.
|
|
459
|
+
|
|
460
|
+
```typescript
|
|
461
|
+
const result = await lane.execute();
|
|
462
|
+
// Returns final capability result with outcome
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
**`async loop(): Promise<oCapabilityResult>`**
|
|
466
|
+
|
|
467
|
+
Internal capability loop execution (called by execute).
|
|
468
|
+
|
|
469
|
+
**`addSequence(result: oCapabilityResult): void`**
|
|
470
|
+
|
|
471
|
+
Add a capability result to the execution sequence.
|
|
472
|
+
|
|
473
|
+
```typescript
|
|
474
|
+
lane.addSequence(new oCapabilityResult({ type: 'TASK', result: data }));
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
**`async store(): Promise<void>`**
|
|
478
|
+
|
|
479
|
+
Store lane execution history to persistent storage.
|
|
480
|
+
|
|
481
|
+
```typescript
|
|
482
|
+
await lane.store();
|
|
483
|
+
// Lane stored at o://lane/<cid>
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
**`async toCID(): Promise<CID>`**
|
|
487
|
+
|
|
488
|
+
Generate content-addressed identifier for this lane.
|
|
489
|
+
|
|
490
|
+
```typescript
|
|
491
|
+
const cid = await lane.toCID();
|
|
492
|
+
console.log(cid.toString()); // "bafyreib..."
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
**`cancel(): void`**
|
|
496
|
+
|
|
497
|
+
Cancel lane execution.
|
|
498
|
+
|
|
499
|
+
```typescript
|
|
500
|
+
lane.cancel();
|
|
501
|
+
console.log(lane.status); // CANCELLED
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
---
|
|
505
|
+
|
|
506
|
+
### `oLaneTool` Class
|
|
507
|
+
|
|
508
|
+
Extends `oNodeTool` with lane execution capabilities.
|
|
509
|
+
|
|
510
|
+
#### Built-in Methods
|
|
511
|
+
|
|
512
|
+
**`async _tool_handshake(request: oRequest): Promise<oHandshakeResult>`**
|
|
513
|
+
|
|
514
|
+
Perform capability negotiation with other agents.
|
|
515
|
+
|
|
516
|
+
```typescript
|
|
517
|
+
const result = await agent.use({
|
|
518
|
+
method: 'handshake',
|
|
519
|
+
params: { intent: 'Discover capabilities' }
|
|
520
|
+
});
|
|
521
|
+
// Returns: { tools: [...], methods: {...} }
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
**`async _tool_intent(request: oRequest): Promise<any>`**
|
|
525
|
+
|
|
526
|
+
Main entry point for intent resolution.
|
|
527
|
+
|
|
528
|
+
```typescript
|
|
529
|
+
const result = await agent.use({
|
|
530
|
+
method: 'intent',
|
|
531
|
+
params: {
|
|
532
|
+
intent: 'Your natural language goal here',
|
|
533
|
+
context: 'Optional conversation history',
|
|
534
|
+
streamTo: 'o://optional/stream/address'
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
#### Usage Example
|
|
540
|
+
|
|
541
|
+
```typescript
|
|
542
|
+
class CustomAgent extends oLaneTool {
|
|
543
|
+
constructor() {
|
|
544
|
+
super({
|
|
545
|
+
address: new oAddress('o://custom-agent'),
|
|
546
|
+
description: 'My specialized agent'
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
// Add domain-specific tool methods
|
|
551
|
+
async _tool_domain_action(request: oRequest): Promise<any> {
|
|
552
|
+
// Your custom logic
|
|
553
|
+
return { success: true };
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
---
|
|
559
|
+
|
|
560
|
+
### `oIntent` Class
|
|
561
|
+
|
|
562
|
+
Wrapper for natural language intents.
|
|
563
|
+
|
|
564
|
+
```typescript
|
|
565
|
+
import { oIntent } from '@olane/o-lane';
|
|
566
|
+
|
|
567
|
+
const intent = new oIntent({ intent: 'Process customer order #12345' });
|
|
568
|
+
console.log(intent.value); // "Process customer order #12345"
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
---
|
|
572
|
+
|
|
573
|
+
### `oCapability` Abstract Class
|
|
574
|
+
|
|
575
|
+
Base class for creating custom capabilities.
|
|
576
|
+
|
|
577
|
+
```typescript
|
|
578
|
+
import { oCapability, oCapabilityResult, oCapabilityType } from '@olane/o-lane';
|
|
579
|
+
|
|
580
|
+
class MyCapability extends oCapability {
|
|
581
|
+
// Define capability type
|
|
582
|
+
get type(): oCapabilityType {
|
|
583
|
+
return oCapabilityType.CUSTOM;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
static get type() {
|
|
587
|
+
return oCapabilityType.CUSTOM;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// Implement execution logic
|
|
591
|
+
async run(): Promise<oCapabilityResult> {
|
|
592
|
+
// Access intent: this.intent
|
|
593
|
+
// Access node: this.node
|
|
594
|
+
// Access config: this.config
|
|
595
|
+
|
|
596
|
+
const result = await this.performWork();
|
|
597
|
+
|
|
598
|
+
return new oCapabilityResult({
|
|
599
|
+
type: oCapabilityType.EVALUATE, // Next capability
|
|
600
|
+
result: result,
|
|
601
|
+
config: { intent: this.intent }
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
---
|
|
608
|
+
|
|
609
|
+
### `oLaneManager` Class
|
|
610
|
+
|
|
611
|
+
Manages lane lifecycle and tracking.
|
|
612
|
+
|
|
613
|
+
```typescript
|
|
614
|
+
import { oLaneManager } from '@olane/o-lane';
|
|
615
|
+
|
|
616
|
+
const manager = new oLaneManager();
|
|
617
|
+
|
|
618
|
+
// Create a new lane
|
|
619
|
+
const lane = await manager.createLane({
|
|
620
|
+
intent: new oIntent({ intent: 'Your goal' }),
|
|
621
|
+
currentNode: agentTool,
|
|
622
|
+
caller: callerAddress
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
// Lane is automatically tracked
|
|
626
|
+
```
|
|
627
|
+
|
|
628
|
+
---
|
|
629
|
+
|
|
630
|
+
### `oCapabilityResult` Class
|
|
631
|
+
|
|
632
|
+
Result object returned by capabilities.
|
|
633
|
+
|
|
634
|
+
```typescript
|
|
635
|
+
import { oCapabilityResult, oCapabilityType } from '@olane/o-lane';
|
|
636
|
+
|
|
637
|
+
const result = new oCapabilityResult({
|
|
638
|
+
type: oCapabilityType.TASK,
|
|
639
|
+
result: { data: 'success' },
|
|
640
|
+
config: { /* next capability config */ },
|
|
641
|
+
error: undefined
|
|
642
|
+
});
|
|
643
|
+
```
|
|
644
|
+
|
|
645
|
+
**Properties:**
|
|
646
|
+
- `type: oCapabilityType` - Next capability to execute
|
|
647
|
+
- `result: any` - Execution result data
|
|
648
|
+
- `config?: any` - Configuration for next capability
|
|
649
|
+
- `error?: string` - Error message if failed
|
|
650
|
+
|
|
651
|
+
---
|
|
652
|
+
|
|
653
|
+
### Enums
|
|
654
|
+
|
|
655
|
+
#### `oLaneStatus`
|
|
656
|
+
|
|
657
|
+
```typescript
|
|
658
|
+
enum oLaneStatus {
|
|
659
|
+
PENDING = 'pending',
|
|
660
|
+
PREFLIGHT = 'preflight',
|
|
661
|
+
RUNNING = 'running',
|
|
662
|
+
POSTFLIGHT = 'postflight',
|
|
663
|
+
COMPLETED = 'completed',
|
|
664
|
+
FAILED = 'failed',
|
|
665
|
+
CANCELLED = 'cancelled'
|
|
666
|
+
}
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
#### `oCapabilityType`
|
|
670
|
+
|
|
671
|
+
```typescript
|
|
672
|
+
enum oCapabilityType {
|
|
673
|
+
EVALUATE = 'evaluate',
|
|
674
|
+
TASK = 'task',
|
|
675
|
+
SEARCH = 'search',
|
|
676
|
+
CONFIGURE = 'configure',
|
|
677
|
+
ERROR = 'error',
|
|
678
|
+
MULTIPLE_STEP = 'multiple_step',
|
|
679
|
+
STOP = 'stop',
|
|
680
|
+
RESULT = 'result',
|
|
681
|
+
UNKNOWN = 'unknown'
|
|
682
|
+
}
|
|
683
|
+
```
|
|
684
|
+
|
|
685
|
+
## Examples
|
|
686
|
+
|
|
687
|
+
### Basic Intent Resolution
|
|
688
|
+
|
|
689
|
+
```typescript
|
|
690
|
+
import { oLaneTool, oIntent } from '@olane/o-lane';
|
|
691
|
+
import { oAddress } from '@olane/o-core';
|
|
692
|
+
|
|
693
|
+
// Create agent
|
|
694
|
+
const agent = new oLaneTool({
|
|
695
|
+
address: new oAddress('o://assistant'),
|
|
696
|
+
description: 'General purpose assistant'
|
|
697
|
+
});
|
|
698
|
+
|
|
699
|
+
await agent.start();
|
|
700
|
+
|
|
701
|
+
// Resolve an intent
|
|
702
|
+
const response = await agent.use({
|
|
703
|
+
method: 'intent',
|
|
704
|
+
params: {
|
|
705
|
+
intent: 'Find the latest sales report and summarize key metrics'
|
|
706
|
+
}
|
|
707
|
+
});
|
|
708
|
+
|
|
709
|
+
console.log('Result:', response.result);
|
|
710
|
+
console.log('Cycles used:', response.cycles);
|
|
711
|
+
console.log('Execution path:', response.sequence.map(s => s.type));
|
|
712
|
+
// ['EVALUATE', 'SEARCH', 'TASK', 'EVALUATE', 'TASK', 'STOP']
|
|
713
|
+
```
|
|
714
|
+
|
|
715
|
+
### Custom Capability
|
|
716
|
+
|
|
717
|
+
```typescript
|
|
718
|
+
import { oCapability, oCapabilityResult, oCapabilityType } from '@olane/o-lane';
|
|
719
|
+
|
|
720
|
+
// Create domain-specific capability
|
|
721
|
+
class EmailCapability extends oCapability {
|
|
722
|
+
get type() {
|
|
723
|
+
return oCapabilityType.CUSTOM;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
async run(): Promise<oCapabilityResult> {
|
|
727
|
+
this.logger.info('Sending email...');
|
|
728
|
+
|
|
729
|
+
try {
|
|
730
|
+
// Send email using your email service
|
|
731
|
+
await this.sendEmail({
|
|
732
|
+
to: this.config.recipient,
|
|
733
|
+
subject: this.config.subject,
|
|
734
|
+
body: this.config.body
|
|
735
|
+
});
|
|
736
|
+
|
|
737
|
+
return new oCapabilityResult({
|
|
738
|
+
type: oCapabilityType.EVALUATE, // Back to evaluation
|
|
739
|
+
result: 'Email sent successfully',
|
|
740
|
+
config: { intent: this.intent }
|
|
741
|
+
});
|
|
742
|
+
} catch (error) {
|
|
743
|
+
return new oCapabilityResult({
|
|
744
|
+
type: oCapabilityType.ERROR,
|
|
745
|
+
error: error.message,
|
|
746
|
+
config: { intent: this.intent, originalError: error }
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
async sendEmail(params: any) {
|
|
752
|
+
// Your email sending logic
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
// Use custom capability
|
|
757
|
+
const lane = await manager.createLane({
|
|
758
|
+
intent: new oIntent({ intent: 'Send status update to team' }),
|
|
759
|
+
currentNode: agentTool,
|
|
760
|
+
caller: callerAddress,
|
|
761
|
+
capabilities: [
|
|
762
|
+
new oCapabilityEvaluate(),
|
|
763
|
+
new EmailCapability(),
|
|
764
|
+
new oCapabilityError()
|
|
765
|
+
]
|
|
766
|
+
});
|
|
767
|
+
|
|
768
|
+
const result = await lane.execute();
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
### Streaming Results
|
|
772
|
+
|
|
773
|
+
```typescript
|
|
774
|
+
// Create streaming endpoint
|
|
775
|
+
class StreamReceiver extends oLaneTool {
|
|
776
|
+
async _tool_receive_stream(request: oRequest): Promise<any> {
|
|
777
|
+
const { data } = request.params;
|
|
778
|
+
console.log('Stream update:', data);
|
|
779
|
+
// Send to UI, websocket, etc.
|
|
780
|
+
return { received: true };
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
const receiver = new StreamReceiver({
|
|
785
|
+
address: new oAddress('o://stream-receiver')
|
|
786
|
+
});
|
|
787
|
+
await receiver.start();
|
|
788
|
+
|
|
789
|
+
// Execute intent with streaming
|
|
790
|
+
const response = await agent.use({
|
|
791
|
+
method: 'intent',
|
|
792
|
+
params: {
|
|
793
|
+
intent: 'Process large dataset',
|
|
794
|
+
streamTo: 'o://stream-receiver' // Receive real-time updates
|
|
795
|
+
}
|
|
796
|
+
});
|
|
797
|
+
|
|
798
|
+
// Receiver gets updates as each capability completes:
|
|
799
|
+
// Stream update: { reasoning: "Starting data fetch..." }
|
|
800
|
+
// Stream update: { result: "Fetched 1000 records" }
|
|
801
|
+
// Stream update: { result: "Processing batch 1/10..." }
|
|
802
|
+
// ...
|
|
803
|
+
```
|
|
804
|
+
|
|
805
|
+
### Lane with Context
|
|
806
|
+
|
|
807
|
+
```typescript
|
|
808
|
+
import { oLaneContext } from '@olane/o-lane';
|
|
809
|
+
|
|
810
|
+
// Provide conversation history or domain context
|
|
811
|
+
const context = new oLaneContext([
|
|
812
|
+
'[Previous Conversation]',
|
|
813
|
+
'User: What were our sales last quarter?',
|
|
814
|
+
'Agent: Q3 sales were $1.2M, up 15% from Q2.',
|
|
815
|
+
'User: Now show me Q4 projections.',
|
|
816
|
+
'[End Previous Conversation]'
|
|
817
|
+
]);
|
|
818
|
+
|
|
819
|
+
const response = await agent.use({
|
|
820
|
+
method: 'intent',
|
|
821
|
+
params: {
|
|
822
|
+
intent: 'Calculate Q4 projections',
|
|
823
|
+
context: context.toString()
|
|
824
|
+
}
|
|
825
|
+
});
|
|
826
|
+
|
|
827
|
+
// Agent uses context to understand the full conversation
|
|
828
|
+
```
|
|
829
|
+
|
|
830
|
+
### Multi-Cycle Execution with Analysis
|
|
831
|
+
|
|
832
|
+
```typescript
|
|
833
|
+
// Complex intent requiring multiple capabilities
|
|
834
|
+
const response = await agent.use({
|
|
835
|
+
method: 'intent',
|
|
836
|
+
params: {
|
|
837
|
+
intent: 'Analyze customer feedback from last month, identify common themes, and create action items'
|
|
838
|
+
}
|
|
839
|
+
});
|
|
840
|
+
|
|
841
|
+
// Analyze the execution path
|
|
842
|
+
console.log('Execution Analysis:');
|
|
843
|
+
response.sequence.forEach((step, index) => {
|
|
844
|
+
console.log(`\nCycle ${index + 1}:`);
|
|
845
|
+
console.log(` Type: ${step.type}`);
|
|
846
|
+
console.log(` Reasoning: ${step.reasoning}`);
|
|
847
|
+
if (step.result) {
|
|
848
|
+
console.log(` Result: ${JSON.stringify(step.result).slice(0, 100)}...`);
|
|
849
|
+
}
|
|
850
|
+
});
|
|
851
|
+
|
|
852
|
+
// Output might show:
|
|
853
|
+
// Cycle 1: EVALUATE - "Need to search for feedback collection tool"
|
|
854
|
+
// Cycle 2: SEARCH - Found o://feedback/collector
|
|
855
|
+
// Cycle 3: TASK - Fetched 145 feedback items
|
|
856
|
+
// Cycle 4: EVALUATE - "Have data, need sentiment analysis"
|
|
857
|
+
// Cycle 5: TASK - Analyzed sentiment across feedback
|
|
858
|
+
// Cycle 6: EVALUATE - "Need to identify themes"
|
|
859
|
+
// Cycle 7: TASK - Extracted 5 common themes
|
|
860
|
+
// Cycle 8: EVALUATE - "Ready to create action items"
|
|
861
|
+
// Cycle 9: TASK - Generated 8 action items
|
|
862
|
+
// Cycle 10: STOP - Completed successfully
|
|
863
|
+
```
|
|
864
|
+
|
|
865
|
+
## Advanced Usage
|
|
866
|
+
|
|
867
|
+
### Custom Capabilities
|
|
868
|
+
|
|
869
|
+
Create domain-specific capabilities for specialized workflows:
|
|
870
|
+
|
|
871
|
+
```typescript
|
|
872
|
+
import { oCapability, oCapabilityResult, oCapabilityType } from '@olane/o-lane';
|
|
873
|
+
|
|
874
|
+
class DatabaseQueryCapability extends oCapability {
|
|
875
|
+
get type() {
|
|
876
|
+
return oCapabilityType.CUSTOM;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
async run(): Promise<oCapabilityResult> {
|
|
880
|
+
const { query, params } = this.config;
|
|
881
|
+
|
|
882
|
+
try {
|
|
883
|
+
// Execute database query
|
|
884
|
+
const results = await this.executeQuery(query, params);
|
|
885
|
+
|
|
886
|
+
// Store results in lane storage for later use
|
|
887
|
+
await this.node.use(new oAddress('o://lane'), {
|
|
888
|
+
method: 'put',
|
|
889
|
+
params: {
|
|
890
|
+
key: `query-result-${Date.now()}`,
|
|
891
|
+
value: JSON.stringify(results)
|
|
892
|
+
}
|
|
893
|
+
});
|
|
894
|
+
|
|
895
|
+
return new oCapabilityResult({
|
|
896
|
+
type: oCapabilityType.EVALUATE,
|
|
897
|
+
result: {
|
|
898
|
+
rowCount: results.length,
|
|
899
|
+
data: results,
|
|
900
|
+
reasoning: `Query returned ${results.length} rows`
|
|
901
|
+
}
|
|
902
|
+
});
|
|
903
|
+
} catch (error) {
|
|
904
|
+
return new oCapabilityResult({
|
|
905
|
+
type: oCapabilityType.ERROR,
|
|
906
|
+
error: error.message
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
async executeQuery(query: string, params: any) {
|
|
912
|
+
// Your database logic
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
```
|
|
916
|
+
|
|
917
|
+
**When to Create Custom Capabilities:**
|
|
918
|
+
- Domain-specific operations (database queries, API calls, etc.)
|
|
919
|
+
- Complex multi-step processes that should be atomic
|
|
920
|
+
- Integration with external systems
|
|
921
|
+
- Performance-critical operations requiring optimization
|
|
922
|
+
|
|
923
|
+
### Lane Context
|
|
924
|
+
|
|
925
|
+
Provide rich context to help agents make better decisions:
|
|
926
|
+
|
|
927
|
+
```typescript
|
|
928
|
+
import { oLaneContext } from '@olane/o-lane';
|
|
929
|
+
|
|
930
|
+
// Conversation context
|
|
931
|
+
const conversationContext = new oLaneContext([
|
|
932
|
+
'[Chat History]',
|
|
933
|
+
'User: Show me last quarter sales',
|
|
934
|
+
'Agent: Q3 sales: $1.2M (↑15%)',
|
|
935
|
+
'[End History]'
|
|
936
|
+
]);
|
|
937
|
+
|
|
938
|
+
// Domain knowledge context
|
|
939
|
+
const domainContext = new oLaneContext([
|
|
940
|
+
'[Business Rules]',
|
|
941
|
+
'- Sales reports require manager approval',
|
|
942
|
+
'- Sensitive data must be redacted',
|
|
943
|
+
'- All currency in USD',
|
|
944
|
+
'[End Rules]'
|
|
945
|
+
]);
|
|
946
|
+
|
|
947
|
+
// Combine contexts
|
|
948
|
+
const combinedContext = new oLaneContext([
|
|
949
|
+
...conversationContext.contexts,
|
|
950
|
+
...domainContext.contexts
|
|
951
|
+
]);
|
|
952
|
+
|
|
953
|
+
const response = await agent.use({
|
|
954
|
+
method: 'intent',
|
|
955
|
+
params: {
|
|
956
|
+
intent: 'Generate Q4 sales report',
|
|
957
|
+
context: combinedContext.toString()
|
|
958
|
+
}
|
|
959
|
+
});
|
|
960
|
+
```
|
|
961
|
+
|
|
962
|
+
### Controlling Max Cycles
|
|
963
|
+
|
|
964
|
+
Adjust maximum cycles based on task complexity:
|
|
965
|
+
|
|
966
|
+
```typescript
|
|
967
|
+
// Environment variable (applies to all lanes)
|
|
968
|
+
process.env.MAX_CYCLES = '30';
|
|
969
|
+
|
|
970
|
+
// Per-lane configuration
|
|
971
|
+
const lane = await manager.createLane({
|
|
972
|
+
intent: new oIntent({ intent: 'Complex multi-step analysis' }),
|
|
973
|
+
currentNode: agent,
|
|
974
|
+
caller: callerAddress,
|
|
975
|
+
maxCycles: 50 // Override default
|
|
976
|
+
});
|
|
977
|
+
|
|
978
|
+
// Quick tasks
|
|
979
|
+
const quickLane = await manager.createLane({
|
|
980
|
+
intent: new oIntent({ intent: 'Simple lookup' }),
|
|
981
|
+
currentNode: agent,
|
|
982
|
+
caller: callerAddress,
|
|
983
|
+
maxCycles: 5 // Fail fast if not simple
|
|
984
|
+
});
|
|
985
|
+
```
|
|
986
|
+
|
|
987
|
+
**Guidelines:**
|
|
988
|
+
- Simple lookups/queries: 5-10 cycles
|
|
989
|
+
- Standard tasks: 15-20 cycles (default)
|
|
990
|
+
- Complex analysis: 30-50 cycles
|
|
991
|
+
- Long-running workflows: 50-100 cycles
|
|
992
|
+
|
|
993
|
+
### Streaming Integration
|
|
994
|
+
|
|
995
|
+
Implement real-time progress reporting:
|
|
996
|
+
|
|
997
|
+
```typescript
|
|
998
|
+
class ProgressTracker extends oLaneTool {
|
|
999
|
+
private updates: any[] = [];
|
|
1000
|
+
|
|
1001
|
+
async _tool_receive_stream(request: oRequest): Promise<any> {
|
|
1002
|
+
const { data } = request.params;
|
|
1003
|
+
this.updates.push({
|
|
1004
|
+
timestamp: Date.now(),
|
|
1005
|
+
data: data
|
|
1006
|
+
});
|
|
1007
|
+
|
|
1008
|
+
// Send to UI via WebSocket, SSE, etc.
|
|
1009
|
+
await this.broadcastToUI(data);
|
|
1010
|
+
|
|
1011
|
+
return { received: true, totalUpdates: this.updates.length };
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
async broadcastToUI(data: any) {
|
|
1015
|
+
// Your UI streaming logic (WebSocket, Server-Sent Events, etc.)
|
|
1016
|
+
this.websocket?.send(JSON.stringify({
|
|
1017
|
+
type: 'lane_update',
|
|
1018
|
+
data: data
|
|
1019
|
+
}));
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
// Use with streaming
|
|
1024
|
+
const tracker = new ProgressTracker({
|
|
1025
|
+
address: new oAddress('o://progress-tracker')
|
|
1026
|
+
});
|
|
1027
|
+
await tracker.start();
|
|
1028
|
+
|
|
1029
|
+
// Long-running task with progress updates
|
|
1030
|
+
const response = await agent.use({
|
|
1031
|
+
method: 'intent',
|
|
1032
|
+
params: {
|
|
1033
|
+
intent: 'Process 10,000 customer records',
|
|
1034
|
+
streamTo: 'o://progress-tracker'
|
|
1035
|
+
}
|
|
1036
|
+
});
|
|
1037
|
+
```
|
|
1038
|
+
|
|
1039
|
+
### Lane Storage & Retrieval
|
|
1040
|
+
|
|
1041
|
+
Access historical lane executions:
|
|
1042
|
+
|
|
1043
|
+
```typescript
|
|
1044
|
+
import { oAddress } from '@olane/o-core';
|
|
1045
|
+
|
|
1046
|
+
// Execute and store lane
|
|
1047
|
+
const response = await agent.use({
|
|
1048
|
+
method: 'intent',
|
|
1049
|
+
params: { intent: 'Analyze sales data' }
|
|
1050
|
+
});
|
|
1051
|
+
|
|
1052
|
+
// Get the lane's CID from execution
|
|
1053
|
+
const lane = await manager.createLane({...});
|
|
1054
|
+
const cid = await lane.toCID();
|
|
1055
|
+
|
|
1056
|
+
// Later: retrieve lane history
|
|
1057
|
+
const storedLane = await agent.use(new oAddress('o://lane'), {
|
|
1058
|
+
method: 'get',
|
|
1059
|
+
params: { key: cid.toString() }
|
|
1060
|
+
});
|
|
1061
|
+
|
|
1062
|
+
console.log('Historical execution:', storedLane.result);
|
|
1063
|
+
// {
|
|
1064
|
+
// config: { intent: '...', caller: '...' },
|
|
1065
|
+
// sequence: [...],
|
|
1066
|
+
// result: {...}
|
|
1067
|
+
// }
|
|
1068
|
+
|
|
1069
|
+
// Analyze patterns across multiple lanes
|
|
1070
|
+
const allLanes = await agent.use(new oAddress('o://lane'), {
|
|
1071
|
+
method: 'list',
|
|
1072
|
+
params: { prefix: 'bafy' } // All CIDs
|
|
1073
|
+
});
|
|
1074
|
+
|
|
1075
|
+
// Find common execution patterns
|
|
1076
|
+
const patterns = analyzeLanePatterns(allLanes);
|
|
1077
|
+
console.log('Most common capability sequences:', patterns);
|
|
1078
|
+
```
|
|
1079
|
+
|
|
1080
|
+
## Testing
|
|
1081
|
+
|
|
1082
|
+
### Testing Lane Execution
|
|
1083
|
+
|
|
1084
|
+
```typescript
|
|
1085
|
+
import { describe, it, expect, beforeEach, afterEach } from '@jest/globals';
|
|
1086
|
+
import { oLaneTool, oIntent, oLaneManager } from '@olane/o-lane';
|
|
1087
|
+
import { oAddress } from '@olane/o-core';
|
|
1088
|
+
|
|
1089
|
+
describe('Lane Execution', () => {
|
|
1090
|
+
let agent: oLaneTool;
|
|
1091
|
+
let manager: oLaneManager;
|
|
1092
|
+
|
|
1093
|
+
beforeEach(async () => {
|
|
1094
|
+
agent = new oLaneTool({
|
|
1095
|
+
address: new oAddress('o://test-agent'),
|
|
1096
|
+
description: 'Test agent'
|
|
1097
|
+
});
|
|
1098
|
+
await agent.start();
|
|
1099
|
+
manager = new oLaneManager();
|
|
1100
|
+
});
|
|
1101
|
+
|
|
1102
|
+
afterEach(async () => {
|
|
1103
|
+
await agent.stop();
|
|
1104
|
+
});
|
|
1105
|
+
|
|
1106
|
+
it('should execute simple intent', async () => {
|
|
1107
|
+
const lane = await manager.createLane({
|
|
1108
|
+
intent: new oIntent({ intent: 'Test task' }),
|
|
1109
|
+
currentNode: agent,
|
|
1110
|
+
caller: new oAddress('o://tester')
|
|
1111
|
+
});
|
|
1112
|
+
|
|
1113
|
+
const result = await lane.execute();
|
|
1114
|
+
|
|
1115
|
+
expect(result).toBeDefined();
|
|
1116
|
+
expect(lane.status).toBe('completed');
|
|
1117
|
+
expect(lane.sequence.length).toBeGreaterThan(0);
|
|
1118
|
+
});
|
|
1119
|
+
|
|
1120
|
+
it('should respect max cycles', async () => {
|
|
1121
|
+
const lane = await manager.createLane({
|
|
1122
|
+
intent: new oIntent({ intent: 'Complex task' }),
|
|
1123
|
+
currentNode: agent,
|
|
1124
|
+
caller: new oAddress('o://tester'),
|
|
1125
|
+
maxCycles: 3
|
|
1126
|
+
});
|
|
1127
|
+
|
|
1128
|
+
await expect(lane.execute()).rejects.toThrow('reached max iterations');
|
|
1129
|
+
});
|
|
1130
|
+
|
|
1131
|
+
it('should stream updates', async () => {
|
|
1132
|
+
const updates: any[] = [];
|
|
1133
|
+
|
|
1134
|
+
// Mock stream receiver
|
|
1135
|
+
class MockReceiver extends oLaneTool {
|
|
1136
|
+
async _tool_receive_stream(request: any) {
|
|
1137
|
+
updates.push(request.params.data);
|
|
1138
|
+
return { received: true };
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
const receiver = new MockReceiver({
|
|
1143
|
+
address: new oAddress('o://mock-receiver')
|
|
1144
|
+
});
|
|
1145
|
+
await receiver.start();
|
|
1146
|
+
|
|
1147
|
+
const lane = await manager.createLane({
|
|
1148
|
+
intent: new oIntent({ intent: 'Streaming task' }),
|
|
1149
|
+
currentNode: agent,
|
|
1150
|
+
caller: new oAddress('o://tester'),
|
|
1151
|
+
streamTo: new oAddress('o://mock-receiver')
|
|
1152
|
+
});
|
|
1153
|
+
|
|
1154
|
+
await lane.execute();
|
|
1155
|
+
|
|
1156
|
+
expect(updates.length).toBeGreaterThan(0);
|
|
1157
|
+
|
|
1158
|
+
await receiver.stop();
|
|
1159
|
+
});
|
|
1160
|
+
});
|
|
1161
|
+
```
|
|
1162
|
+
|
|
1163
|
+
### Mocking Capabilities
|
|
1164
|
+
|
|
1165
|
+
```typescript
|
|
1166
|
+
import { oCapability, oCapabilityResult, oCapabilityType } from '@olane/o-lane';
|
|
1167
|
+
|
|
1168
|
+
// Create mock capability for testing
|
|
1169
|
+
class MockTaskCapability extends oCapability {
|
|
1170
|
+
get type() {
|
|
1171
|
+
return oCapabilityType.TASK;
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
async run(): Promise<oCapabilityResult> {
|
|
1175
|
+
// Return predetermined result for testing
|
|
1176
|
+
return new oCapabilityResult({
|
|
1177
|
+
type: oCapabilityType.STOP,
|
|
1178
|
+
result: { mocked: true, data: 'test data' }
|
|
1179
|
+
});
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
// Test with mock capabilities
|
|
1184
|
+
it('should use mock capabilities', async () => {
|
|
1185
|
+
const mockCapabilities = [
|
|
1186
|
+
new oCapabilityEvaluate(),
|
|
1187
|
+
new MockTaskCapability()
|
|
1188
|
+
];
|
|
1189
|
+
|
|
1190
|
+
const lane = await manager.createLane({
|
|
1191
|
+
intent: new oIntent({ intent: 'Test with mocks' }),
|
|
1192
|
+
currentNode: agent,
|
|
1193
|
+
caller: new oAddress('o://tester'),
|
|
1194
|
+
capabilities: mockCapabilities
|
|
1195
|
+
});
|
|
1196
|
+
|
|
1197
|
+
const result = await lane.execute();
|
|
1198
|
+
expect(result.result.mocked).toBe(true);
|
|
1199
|
+
});
|
|
1200
|
+
```
|
|
1201
|
+
|
|
1202
|
+
## Best Practices
|
|
1203
|
+
|
|
1204
|
+
### Intent Design
|
|
1205
|
+
|
|
1206
|
+
✅ **DO:**
|
|
1207
|
+
- Use clear, outcome-focused language
|
|
1208
|
+
- Specify concrete goals rather than steps
|
|
1209
|
+
- Provide sufficient context in the intent
|
|
1210
|
+
- Keep intents scoped to achievable tasks
|
|
1211
|
+
|
|
1212
|
+
```typescript
|
|
1213
|
+
// Good intents
|
|
1214
|
+
"Analyze customer satisfaction scores from Q4 and identify improvement areas"
|
|
1215
|
+
"Find all pending orders and send reminder emails to customers"
|
|
1216
|
+
"Generate a summary report of this week's support tickets"
|
|
1217
|
+
```
|
|
1218
|
+
|
|
1219
|
+
❌ **DON'T:**
|
|
1220
|
+
- Use vague or ambiguous language
|
|
1221
|
+
- Prescribe specific implementation steps
|
|
1222
|
+
- Combine unrelated tasks
|
|
1223
|
+
- Assume agent has unstated context
|
|
1224
|
+
|
|
1225
|
+
```typescript
|
|
1226
|
+
// Poor intents
|
|
1227
|
+
"Do some analysis" // Too vague
|
|
1228
|
+
"Query database, filter results, format as JSON, send to API" // Too prescriptive
|
|
1229
|
+
"Analyze sales and fix the server bug and update documentation" // Unrelated tasks
|
|
1230
|
+
```
|
|
1231
|
+
|
|
1232
|
+
### Capability Design
|
|
1233
|
+
|
|
1234
|
+
✅ **DO:**
|
|
1235
|
+
- Keep capabilities atomic and focused
|
|
1236
|
+
- Return clear next-capability signals
|
|
1237
|
+
- Handle errors gracefully
|
|
1238
|
+
- Log reasoning and decisions
|
|
1239
|
+
|
|
1240
|
+
❌ **DON'T:**
|
|
1241
|
+
- Create monolithic capabilities
|
|
1242
|
+
- Assume state from previous cycles
|
|
1243
|
+
- Silently fail
|
|
1244
|
+
- Lose execution context
|
|
1245
|
+
|
|
1246
|
+
### Context Management
|
|
1247
|
+
|
|
1248
|
+
✅ **DO:**
|
|
1249
|
+
- Provide relevant conversation history
|
|
1250
|
+
- Include domain-specific rules and constraints
|
|
1251
|
+
- Keep context concise but complete
|
|
1252
|
+
- Update context as conversations evolve
|
|
1253
|
+
|
|
1254
|
+
❌ **DON'T:**
|
|
1255
|
+
- Dump entire chat history
|
|
1256
|
+
- Include irrelevant information
|
|
1257
|
+
- Assume context is remembered between lanes
|
|
1258
|
+
- Mix different types of context
|
|
1259
|
+
|
|
1260
|
+
### Cycle Management
|
|
1261
|
+
|
|
1262
|
+
✅ **DO:**
|
|
1263
|
+
- Set appropriate max cycles for task complexity
|
|
1264
|
+
- Monitor cycle usage patterns
|
|
1265
|
+
- Optimize frequently-used capability paths
|
|
1266
|
+
- Use streaming for long-running tasks
|
|
1267
|
+
|
|
1268
|
+
❌ **DON'T:**
|
|
1269
|
+
- Use same max cycles for all tasks
|
|
1270
|
+
- Ignore high cycle counts
|
|
1271
|
+
- Let lanes run indefinitely
|
|
1272
|
+
- Block waiting for lane completion
|
|
1273
|
+
|
|
1274
|
+
### Monitoring & Debugging
|
|
1275
|
+
|
|
1276
|
+
✅ **DO:**
|
|
1277
|
+
- Store and analyze lane execution histories
|
|
1278
|
+
- Track capability success/failure rates
|
|
1279
|
+
- Monitor average cycles per intent type
|
|
1280
|
+
- Log reasoning at each capability
|
|
1281
|
+
|
|
1282
|
+
❌ **DON'T:**
|
|
1283
|
+
- Ignore lane storage
|
|
1284
|
+
- Treat all failures the same
|
|
1285
|
+
- Skip execution analysis
|
|
1286
|
+
- Remove debugging information too early
|
|
1287
|
+
|
|
1288
|
+
## Use Cases
|
|
1289
|
+
|
|
1290
|
+
### Complex Multi-Step Workflows
|
|
1291
|
+
|
|
1292
|
+
```typescript
|
|
1293
|
+
// Intent: "Onboard new customer: create account, send welcome email, assign CSM"
|
|
1294
|
+
// Lane automatically:
|
|
1295
|
+
// 1. Evaluates steps needed
|
|
1296
|
+
// 2. Searches for account creation tool
|
|
1297
|
+
// 3. Creates account
|
|
1298
|
+
// 4. Searches for email service
|
|
1299
|
+
// 5. Sends welcome email
|
|
1300
|
+
// 6. Searches for CSM assignment tool
|
|
1301
|
+
// 7. Assigns customer success manager
|
|
1302
|
+
// 8. Returns confirmation
|
|
1303
|
+
```
|
|
1304
|
+
|
|
1305
|
+
### Long-Running Agent Tasks
|
|
1306
|
+
|
|
1307
|
+
```typescript
|
|
1308
|
+
// Intent: "Monitor API health every 5 minutes and alert on failures"
|
|
1309
|
+
// Lane manages:
|
|
1310
|
+
// - Periodic execution via scheduling capability
|
|
1311
|
+
// - State persistence across executions
|
|
1312
|
+
// - Error detection and alerting
|
|
1313
|
+
// - Automatic recovery attempts
|
|
1314
|
+
```
|
|
1315
|
+
|
|
1316
|
+
### Intent-Based Automation
|
|
1317
|
+
|
|
1318
|
+
```typescript
|
|
1319
|
+
// Intent: "When new sales lead arrives, score it and route to appropriate team"
|
|
1320
|
+
// Lane orchestrates:
|
|
1321
|
+
// - Lead data extraction
|
|
1322
|
+
// - Scoring algorithm execution
|
|
1323
|
+
// - Team assignment logic
|
|
1324
|
+
// - Notification delivery
|
|
1325
|
+
// - CRM updates
|
|
1326
|
+
```
|
|
1327
|
+
|
|
1328
|
+
### Agent Coordination Patterns
|
|
1329
|
+
|
|
1330
|
+
```typescript
|
|
1331
|
+
// Intent: "Coordinate 3 specialist agents to analyze customer data"
|
|
1332
|
+
// Lane enables:
|
|
1333
|
+
// - Discovery of specialist agents
|
|
1334
|
+
// - Parallel task distribution
|
|
1335
|
+
// - Result aggregation
|
|
1336
|
+
// - Consensus building
|
|
1337
|
+
// - Final report generation
|
|
1338
|
+
```
|
|
1339
|
+
|
|
1340
|
+
### Emergent Workflow Discovery
|
|
1341
|
+
|
|
1342
|
+
```typescript
|
|
1343
|
+
// Multiple users with similar intents
|
|
1344
|
+
// Lane learns optimal paths:
|
|
1345
|
+
// "Generate sales report" -> most efficient capability sequence emerges
|
|
1346
|
+
// Future executions follow discovered optimal path
|
|
1347
|
+
// Workflow improves over time through accumulated learning
|
|
1348
|
+
```
|
|
1349
|
+
|
|
1350
|
+
## Troubleshooting
|
|
1351
|
+
|
|
1352
|
+
### Lane Reaches Max Cycles
|
|
1353
|
+
|
|
1354
|
+
**Symptom:** Lane throws "reached max iterations" error
|
|
1355
|
+
|
|
1356
|
+
**Causes:**
|
|
1357
|
+
- Intent too complex for cycle limit
|
|
1358
|
+
- Agent stuck in evaluation loop
|
|
1359
|
+
- Missing required capabilities
|
|
1360
|
+
- Poor capability return signals
|
|
1361
|
+
|
|
1362
|
+
**Solutions:**
|
|
1363
|
+
```typescript
|
|
1364
|
+
// 1. Increase max cycles for complex tasks
|
|
1365
|
+
maxCycles: 50
|
|
1366
|
+
|
|
1367
|
+
// 2. Break intent into smaller sub-intents
|
|
1368
|
+
"Analyze all customer data" → "Analyze customer data for Q4"
|
|
1369
|
+
|
|
1370
|
+
// 3. Add missing capabilities
|
|
1371
|
+
capabilities: [...ALL_CAPABILITIES, new CustomCapability()]
|
|
1372
|
+
|
|
1373
|
+
// 4. Review agent history to find loops
|
|
1374
|
+
console.log(lane.agentHistory);
|
|
1375
|
+
// Look for repeated capability patterns
|
|
1376
|
+
```
|
|
1377
|
+
|
|
1378
|
+
### Capability Not Found Errors
|
|
1379
|
+
|
|
1380
|
+
**Symptom:** "Unknown capability" error during execution
|
|
1381
|
+
|
|
1382
|
+
**Causes:**
|
|
1383
|
+
- Custom capability not registered
|
|
1384
|
+
- Agent choosing unavailable capability type
|
|
1385
|
+
- Capability type mismatch
|
|
1386
|
+
|
|
1387
|
+
**Solutions:**
|
|
1388
|
+
```typescript
|
|
1389
|
+
// 1. Register custom capabilities
|
|
1390
|
+
const lane = await manager.createLane({
|
|
1391
|
+
capabilities: [
|
|
1392
|
+
...ALL_CAPABILITIES,
|
|
1393
|
+
new MyCustomCapability()
|
|
1394
|
+
]
|
|
1395
|
+
});
|
|
1396
|
+
|
|
1397
|
+
// 2. Check capability type enum values match
|
|
1398
|
+
get type() {
|
|
1399
|
+
return oCapabilityType.CUSTOM; // Must match exactly
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
// 3. Provide all standard capabilities
|
|
1403
|
+
import { ALL_CAPABILITIES } from '@olane/o-lane';
|
|
1404
|
+
```
|
|
1405
|
+
|
|
1406
|
+
### Intent Not Resolving
|
|
1407
|
+
|
|
1408
|
+
**Symptom:** Lane completes but doesn't achieve desired outcome
|
|
1409
|
+
|
|
1410
|
+
**Causes:**
|
|
1411
|
+
- Intent too vague
|
|
1412
|
+
- Missing context
|
|
1413
|
+
- Insufficient capabilities available
|
|
1414
|
+
- Poor tool descriptions
|
|
1415
|
+
|
|
1416
|
+
**Solutions:**
|
|
1417
|
+
```typescript
|
|
1418
|
+
// 1. Make intent more specific
|
|
1419
|
+
"Do analysis" → "Calculate average sales per region for Q4 2024"
|
|
1420
|
+
|
|
1421
|
+
// 2. Provide context
|
|
1422
|
+
context: new oLaneContext([
|
|
1423
|
+
'Available data: sales_q4.csv',
|
|
1424
|
+
'Required format: JSON with region, avg_sales fields'
|
|
1425
|
+
])
|
|
1426
|
+
|
|
1427
|
+
// 3. Add specialized capabilities
|
|
1428
|
+
capabilities: [...ALL_CAPABILITIES, new DataAnalysisCapability()]
|
|
1429
|
+
|
|
1430
|
+
// 4. Improve tool descriptions in agent config
|
|
1431
|
+
description: 'Calculates regional sales averages from CSV data'
|
|
1432
|
+
```
|
|
1433
|
+
|
|
1434
|
+
### Storage Failures
|
|
1435
|
+
|
|
1436
|
+
**Symptom:** Lane executes but fails to store results
|
|
1437
|
+
|
|
1438
|
+
**Causes:**
|
|
1439
|
+
- Storage service unavailable
|
|
1440
|
+
- Invalid CID generation
|
|
1441
|
+
- Permission issues
|
|
1442
|
+
- Storage quota exceeded
|
|
1443
|
+
|
|
1444
|
+
**Solutions:**
|
|
1445
|
+
```typescript
|
|
1446
|
+
// 1. Verify storage service is running
|
|
1447
|
+
await agent.use(new oAddress('o://lane'), { method: 'ping' });
|
|
1448
|
+
|
|
1449
|
+
// 2. Check CID generation
|
|
1450
|
+
const cid = await lane.toCID();
|
|
1451
|
+
console.log('CID:', cid.toString());
|
|
1452
|
+
|
|
1453
|
+
// 3. Add error handling
|
|
1454
|
+
try {
|
|
1455
|
+
await lane.store();
|
|
1456
|
+
} catch (error) {
|
|
1457
|
+
console.error('Storage failed:', error);
|
|
1458
|
+
// Implement fallback storage
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
// 4. Monitor storage usage
|
|
1462
|
+
const usage = await agent.use(new oAddress('o://lane'), {
|
|
1463
|
+
method: 'usage'
|
|
1464
|
+
});
|
|
1465
|
+
```
|
|
1466
|
+
|
|
1467
|
+
## Related Packages
|
|
1468
|
+
|
|
1469
|
+
- **[@olane/o-core](../o-core)** - Core OS functionality and base classes
|
|
1470
|
+
- **[@olane/o-node](../o-node)** - Network-connected tools with P2P capabilities
|
|
1471
|
+
- **[@olane/o-tool](../o-tool)** - Tool augmentation system for agent specialization
|
|
1472
|
+
- **[@olane/o-leader](../o-leader)** - Network coordination and agent discovery
|
|
1473
|
+
- **[@olane/o-protocol](../o-protocol)** - Protocol definitions and types
|
|
1474
|
+
- **[@olane/o-config](../o-config)** - Configuration management utilities
|
|
1475
|
+
|
|
1476
|
+
## Contributing
|
|
1477
|
+
|
|
1478
|
+
We welcome contributions! Please see our [Contributing Guide](../../CONTRIBUTING.md) for details on our code of conduct and development process.
|
|
1479
|
+
|
|
1480
|
+
## License
|
|
1481
|
+
|
|
1482
|
+
ISC © oLane Inc.
|
|
1483
|
+
|
|
1484
|
+
## Resources
|
|
1485
|
+
|
|
1486
|
+
- [Full Documentation](https://olane.com/docs)
|
|
1487
|
+
- [Olane OS Overview](../../README.md)
|
|
1488
|
+
- [Examples](../../examples)
|
|
1489
|
+
- [GitHub Repository](https://github.com/olane-labs/olane)
|
|
1490
|
+
- [Report Issues](https://github.com/olane-labs/olane/issues)
|
|
1491
|
+
- [Community Forum](https://olane.com/community)
|
|
1492
|
+
|
|
1493
|
+
---
|
|
1494
|
+
|
|
1495
|
+
**Part of the Olane OS ecosystem** - An agentic operating system for building intelligent, collaborative AI agent networks.
|