@olane/o-leader 0.8.3 → 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +115 -150
  2. package/package.json +9 -9
package/README.md CHANGED
@@ -20,20 +20,12 @@ Use `o-leader` when:
20
20
 
21
21
  ### Core capabilities {#core-capabilities}
22
22
 
23
- <CardGroup cols={2}>
24
- <Card title="Network Coordination" icon="network-wired" color="#0D9373">
25
- Entry point for agents joining the network
26
- </Card>
27
- <Card title="Agent Discovery" icon="magnifying-glass" color="#0D9373">
28
- Built-in registry for finding agents by capability
29
- </Card>
30
- <Card title="Network Intelligence" icon="brain" color="#0D9373">
31
- Automatic indexing and mapping of agent capabilities
32
- </Card>
33
- <Card title="Fault Tolerance" icon="shield" color="#0D9373">
34
- Automatic failover and recovery coordination
35
- </Card>
36
- </CardGroup>
23
+ | Capability | Description |
24
+ |------------|-------------|
25
+ | **Network Coordination** | Entry point for agents joining the network |
26
+ | **Agent Discovery** | Built-in registry for finding agents by capability |
27
+ | **Network Intelligence** | Automatic indexing and mapping of agent capabilities |
28
+ | **Fault Tolerance** | Automatic failover and recovery coordination |
37
29
 
38
30
  ---
39
31
 
@@ -48,7 +40,7 @@ Use `o-leader` when:
48
40
  ### Installation {#installation}
49
41
 
50
42
  ```bash
51
- npm install @olane/o-leader
43
+ pnpm install @olane/o-leader
52
44
  ```
53
45
 
54
46
  ### Basic Leader Node Setup {#basic-setup}
@@ -77,17 +69,9 @@ console.log('Registry service available at o://registry');
77
69
 
78
70
  ### Next Steps {#next-steps}
79
71
 
80
- <CardGroup cols={3}>
81
- <Card title="Join Agents" icon="users" href="#joining-agents-to-network">
82
- Connect agents to your network
83
- </Card>
84
- <Card title="Discover Agents" icon="magnifying-glass" href="#using-the-registry">
85
- Search for agents by capability
86
- </Card>
87
- <Card title="Custom Validation" icon="shield-check" href="#join-request-validation">
88
- Implement access control
89
- </Card>
90
- </CardGroup>
72
+ - **[Join Agents](#joining-agents-to-network)** - Connect agents to your network
73
+ - **[Discover Agents](#using-the-registry)** - Search for agents by capability
74
+ - **[Custom Validation](#join-request-validation)** - Implement access control
91
75
 
92
76
  ---
93
77
 
@@ -137,8 +121,10 @@ const agents = await leader.use(new oAddress('o://registry'), {
137
121
  }
138
122
  });
139
123
 
140
- console.log(`Found ${agents.result.length} agents with payment capabilities`);
141
- // Use the discovered agents in your workflow
124
+ if (agents.result.success) {
125
+ console.log(`Found ${agents.result.data.length} agents with payment capabilities`);
126
+ // Use the discovered agents in your workflow
127
+ }
142
128
  ```
143
129
 
144
130
  ### Network Joining Flow {#joining-flow}
@@ -313,7 +299,7 @@ const analysts = await leader.use(new oAddress('o://registry'), {
313
299
  protocols: ['financial-analysis']
314
300
  }
315
301
  });
316
- console.log(`Found ${analysts.result.length} financial analysts`);
302
+ console.log(`Found ${analysts.result.data.length} financial analysts`);
317
303
 
318
304
  // Find agent by address
319
305
  const agent = await leader.use(new oAddress('o://registry'), {
@@ -322,7 +308,7 @@ const agent = await leader.use(new oAddress('o://registry'), {
322
308
  address: 'o://company/finance/analyst'
323
309
  }
324
310
  });
325
- console.log('Found agent:', agent.result[0]);
311
+ console.log('Found agent:', agent.result.data[0]);
326
312
 
327
313
  // Find by static address (for stable references)
328
314
  const stable = await leader.use(new oAddress('o://registry'), {
@@ -343,8 +329,8 @@ const allAgents = await leader.use(new oAddress('o://registry'), {
343
329
  params: {}
344
330
  });
345
331
 
346
- console.log(`Network has ${allAgents.result.length} active agents`);
347
- allAgents.result.forEach(agent => {
332
+ console.log(`Network has ${allAgents.result.data.length} active agents`);
333
+ allAgents.result.data.forEach(agent => {
348
334
  console.log(`- ${agent.address} (${agent.protocols.join(', ')})`);
349
335
  });
350
336
  ```
@@ -366,9 +352,7 @@ console.log('Network indexing complete');
366
352
  // This crawls all registered agents and indexes their capabilities
367
353
  ```
368
354
 
369
- <Note>
370
- **Tip**: Run indexing on a schedule (e.g., every 5-10 minutes) or trigger it after significant network changes.
371
- </Note>
355
+ > **Tip**: Run indexing on a schedule (e.g., every 5-10 minutes) or trigger it after significant network changes.
372
356
 
373
357
  #### Custom Indexing Logic {#custom-indexing}
374
358
 
@@ -442,8 +426,9 @@ class PostgresRegistryTool extends RegistryTool {
442
426
  transports = EXCLUDED.transports,
443
427
  updated_at = NOW()
444
428
  `, [params.peerId, params.address, params.protocols, params.transports]);
445
-
446
- return { success: true };
429
+
430
+ // Return raw data - base class wraps it in { success, data, error }
431
+ return { peerId: params.peerId, address: params.address };
447
432
  }
448
433
 
449
434
  async _tool_search(request: oRequest): Promise<any> {
@@ -476,9 +461,7 @@ await leader.start();
476
461
  console.log('Leader using persistent registry');
477
462
  ```
478
463
 
479
- <Check>
480
- **Production Recommendation**: Always use a persistent registry (PostgreSQL, Redis, MongoDB) for production networks.
481
- </Check>
464
+ > **Production Recommendation**: Always use a persistent registry (PostgreSQL, Redis, MongoDB) for production networks.
482
465
 
483
466
  ---
484
467
 
@@ -518,9 +501,7 @@ const euLeader = new oLeaderNode({
518
501
  // but can query primary leader for global discovery
519
502
  ```
520
503
 
521
- <Note>
522
- **Pattern**: Regional leaders handle local coordination while primary leader maintains global visibility.
523
- </Note>
504
+ > **Pattern**: Regional leaders handle local coordination while primary leader maintains global visibility.
524
505
 
525
506
  ---
526
507
 
@@ -609,15 +590,16 @@ class MonitoredLeader extends oLeaderNode {
609
590
  { method: 'find_all', params: {} }
610
591
  );
611
592
 
593
+ const agents = allAgents.result.data;
612
594
  const health = {
613
- totalAgents: allAgents.result.length,
595
+ totalAgents: agents.length,
614
596
  activeAgents: 0,
615
597
  unhealthyAgents: [],
616
598
  timestamp: Date.now()
617
599
  };
618
-
600
+
619
601
  // Check each agent
620
- for (const agent of allAgents.result) {
602
+ for (const agent of agents) {
621
603
  const isHealthy = await this.checkAgentHealth(agent);
622
604
  if (isHealthy) {
623
605
  health.activeAgents++;
@@ -739,9 +721,7 @@ Use **static addresses** for production agents that need stable references:
739
721
  }
740
722
  ```
741
723
 
742
- <Check>
743
- **Why?** Static addresses allow reliable references even when agent instances change.
744
- </Check>
724
+ > **Why?** Static addresses allow reliable references even when agent instances change.
745
725
 
746
726
  ---
747
727
 
@@ -790,26 +770,12 @@ const metrics = {
790
770
 
791
771
  Follow these security guidelines for production networks:
792
772
 
793
- <Steps>
794
- <Step title="Validate Join Requests">
795
- Always implement custom `validateJoinRequest()` logic with business rules
796
- </Step>
797
- <Step title="Use Authentication">
798
- Require authentication tokens for all join requests
799
- </Step>
800
- <Step title="Rate Limiting">
801
- Implement rate limiting on join requests to prevent abuse
802
- </Step>
803
- <Step title="Permission-Based Access">
804
- Filter registry results based on caller permissions
805
- </Step>
806
- <Step title="Monitor Patterns">
807
- Watch for unusual patterns (rapid joins, suspicious addresses)
808
- </Step>
809
- <Step title="Encrypted Transports">
810
- Prefer WebRTC over WebSocket for sensitive data
811
- </Step>
812
- </Steps>
773
+ 1. **Validate Join Requests** - Always implement custom `validateJoinRequest()` logic with business rules
774
+ 2. **Use Authentication** - Require authentication tokens for all join requests
775
+ 3. **Rate Limiting** - Implement rate limiting on join requests to prevent abuse
776
+ 4. **Permission-Based Access** - Filter registry results based on caller permissions
777
+ 5. **Monitor Patterns** - Watch for unusual patterns (rapid joins, suspicious addresses)
778
+ 6. **Encrypted Transports** - Prefer WebRTC over WebSocket for sensitive data
813
779
 
814
780
  ---
815
781
 
@@ -872,7 +838,11 @@ const allAgents = await leader.use(
872
838
  new oAddress('o://registry'),
873
839
  { method: 'find_all', params: {} }
874
840
  );
875
- console.log('Registry state:', JSON.stringify(allAgents, null, 2));
841
+ if (allAgents.result.success) {
842
+ console.log('Registry state:', JSON.stringify(allAgents.result.data, null, 2));
843
+ } else {
844
+ console.error('Failed to fetch registry:', allAgents.result.error);
845
+ }
876
846
  ```
877
847
 
878
848
  #### Monitor Join Requests
@@ -900,6 +870,38 @@ class DebugLeader extends oLeaderNode {
900
870
 
901
871
  ## API Reference {#api-reference}
902
872
 
873
+ ### Response Structure {#response-structure}
874
+
875
+ All `use()` calls return responses following the standard Olane response wrapping pattern:
876
+
877
+ ```typescript
878
+ const response = await leader.use(new oAddress('o://registry'), {
879
+ method: 'find_all',
880
+ params: {}
881
+ });
882
+
883
+ // Response structure:
884
+ // {
885
+ // jsonrpc: "2.0",
886
+ // id: "request-id",
887
+ // result: {
888
+ // success: boolean, // Whether the operation succeeded
889
+ // data: any, // The returned data (on success)
890
+ // error?: string // Error details (on failure)
891
+ // }
892
+ // }
893
+
894
+ // Always check success before accessing data
895
+ if (response.result.success) {
896
+ const agents = response.result.data;
897
+ console.log(`Found ${agents.length} agents`);
898
+ } else {
899
+ console.error('Error:', response.result.error);
900
+ }
901
+ ```
902
+
903
+ > **Important**: Access data via `response.result.data`, not `response.result` directly.
904
+
903
905
  ### oLeaderNode {#oleadernode}
904
906
 
905
907
  The main class for creating a leader node.
@@ -1034,9 +1036,7 @@ const registry = new RegistryMemoryTool(config);
1034
1036
  - Protocol indexing for **efficient searches**
1035
1037
  - **Not persistent** across restarts (use for development only)
1036
1038
 
1037
- <Warning>
1038
- **Production Warning**: Use a persistent registry (PostgreSQL, Redis) for production networks.
1039
- </Warning>
1039
+ > **Warning**: Use a persistent registry (PostgreSQL, Redis) for production networks.
1040
1040
 
1041
1041
  ---
1042
1042
 
@@ -1092,7 +1092,7 @@ async function main() {
1092
1092
  params: {}
1093
1093
  });
1094
1094
 
1095
- console.log(`Network has ${agents.result.length} agents`);
1095
+ console.log(`Network has ${agents.result.data.length} agents`);
1096
1096
  }
1097
1097
  ```
1098
1098
 
@@ -1152,9 +1152,9 @@ async function findAnalysisAgents(leader: oLeaderNode) {
1152
1152
  }
1153
1153
  });
1154
1154
 
1155
- const agents = result.result;
1155
+ const agents = result.result.data;
1156
1156
  console.log(`Found ${agents.length} agents with analysis capabilities`);
1157
-
1157
+
1158
1158
  // Connect to first available agent
1159
1159
  if (agents.length > 0) {
1160
1160
  const targetAgent = new oAddress(agents[0].address);
@@ -1180,11 +1180,12 @@ class HealthMonitorLeader extends oLeaderNode {
1180
1180
  { method: 'find_all', params: {} }
1181
1181
  );
1182
1182
 
1183
+ const agents = allAgents.result.data;
1183
1184
  const dashboard = {
1184
- totalAgents: allAgents.result.length,
1185
- byCapability: this.groupByCapability(allAgents.result),
1186
- byDomain: this.groupByDomain(allAgents.result),
1187
- health: await this.checkAllAgentsHealth(allAgents.result)
1185
+ totalAgents: agents.length,
1186
+ byCapability: this.groupByCapability(agents),
1187
+ byDomain: this.groupByDomain(agents),
1188
+ health: await this.checkAllAgentsHealth(agents)
1188
1189
  };
1189
1190
 
1190
1191
  return dashboard;
@@ -1300,66 +1301,48 @@ const agents = await leader.use(new oAddress('o://registry'), {
1300
1301
 
1301
1302
  ### General Questions {#faq-general}
1302
1303
 
1303
- <AccordionGroup>
1304
- <Accordion title="Do I need a leader node for every Olane OS network?">
1305
- Yes, every network needs at least one leader node. It serves as the **entry point** and **coordination hub** for the network.
1306
- </Accordion>
1304
+ **Do I need a leader node for every Olane OS network?**
1305
+ Yes, every network needs at least one leader node. It serves as the **entry point** and **coordination hub** for the network.
1307
1306
 
1308
- <Accordion title="Can I have multiple leader nodes?">
1309
- Yes, for large or distributed networks, you can implement a **federation pattern** with regional leaders. See [Multi-Leader Networks](#multi-leader-networks).
1310
- </Accordion>
1307
+ **Can I have multiple leader nodes?**
1308
+ Yes, for large or distributed networks, you can implement a **federation pattern** with regional leaders. See [Multi-Leader Networks](#multi-leader-networks).
1311
1309
 
1312
- <Accordion title="Is the registry required?">
1313
- The registry is **built into** the leader node and is essential for agent discovery. You cannot run a leader without a registry.
1314
- </Accordion>
1310
+ **Is the registry required?**
1311
+ The registry is **built into** the leader node and is essential for agent discovery. You cannot run a leader without a registry.
1315
1312
 
1316
- <Accordion title="What happens if the leader node goes down?">
1317
- Existing agent connections remain active, but **new agents cannot join**. Implement leader failover for high availability.
1318
- </Accordion>
1319
- </AccordionGroup>
1313
+ **What happens if the leader node goes down?**
1314
+ Existing agent connections remain active, but **new agents cannot join**. Implement leader failover for high availability.
1320
1315
 
1321
1316
  ### Technical Questions {#faq-technical}
1322
1317
 
1323
- <AccordionGroup>
1324
- <Accordion title="How does registry search performance scale?">
1325
- In-memory registry is **O(n)** for searches. For large networks (1000+ agents), implement **indexed** or **database-backed** registries.
1326
- </Accordion>
1318
+ **How does registry search performance scale?**
1319
+ In-memory registry is **O(n)** for searches. For large networks (1000+ agents), implement **indexed** or **database-backed** registries.
1327
1320
 
1328
- <Accordion title="Can I customize the registry implementation?">
1329
- Yes, extend `RegistryTool` to implement custom storage backends (PostgreSQL, Redis, MongoDB, etc.). See [Custom Registry Implementations](#custom-registry).
1330
- </Accordion>
1321
+ **Can I customize the registry implementation?**
1322
+ Yes, extend `RegistryTool` to implement custom storage backends (PostgreSQL, Redis, MongoDB, etc.). See [Custom Registry Implementations](#custom-registry).
1331
1323
 
1332
- <Accordion title="What transports does the leader support?">
1333
- The leader supports all **libp2p transports**: WebRTC, WebSocket, TCP, QUIC, etc.
1334
- </Accordion>
1324
+ **What transports does the leader support?**
1325
+ The leader supports all **libp2p transports**: WebRTC, WebSocket, TCP, QUIC, etc.
1335
1326
 
1336
- <Accordion title="How do I handle registry cleanup?">
1337
- Implement **TTL logic** in your registry and **periodic cleanup** of disconnected agents. See [Registry Maintenance](#registry-maintenance).
1338
- </Accordion>
1339
- </AccordionGroup>
1327
+ **How do I handle registry cleanup?**
1328
+ Implement **TTL logic** in your registry and **periodic cleanup** of disconnected agents. See [Registry Maintenance](#registry-maintenance).
1340
1329
 
1341
1330
  ### Operational Questions {#faq-operational}
1342
1331
 
1343
- <AccordionGroup>
1344
- <Accordion title="How often should I run network indexing?">
1345
- Depends on network dynamics:
1346
- - **Stable networks**: Every 5-10 minutes
1347
- - **Dynamic networks**: Event-driven indexing
1348
- - **Large networks**: Incremental indexing
1349
- </Accordion>
1332
+ **How often should I run network indexing?**
1333
+ Depends on network dynamics:
1334
+ - **Stable networks**: Every 5-10 minutes
1335
+ - **Dynamic networks**: Event-driven indexing
1336
+ - **Large networks**: Incremental indexing
1350
1337
 
1351
- <Accordion title="What's the recommended registry backend for production?">
1352
- For production, use a **persistent registry** (PostgreSQL, Redis, MongoDB) instead of in-memory. See [Persistent Registry Example](#persistent-registry-example).
1353
- </Accordion>
1338
+ **What's the recommended registry backend for production?**
1339
+ For production, use a **persistent registry** (PostgreSQL, Redis, MongoDB) instead of in-memory. See [Persistent Registry Example](#persistent-registry-example).
1354
1340
 
1355
- <Accordion title="How do I monitor leader health?">
1356
- Implement **health check endpoints** and monitoring using your observability tools. See [Network Health Monitoring](#network-health).
1357
- </Accordion>
1341
+ **How do I monitor leader health?**
1342
+ Implement **health check endpoints** and monitoring using your observability tools. See [Network Health Monitoring](#network-health).
1358
1343
 
1359
- <Accordion title="Can agents join from different networks?">
1360
- Yes, as long as they can **reach the leader node** and **pass validation**.
1361
- </Accordion>
1362
- </AccordionGroup>
1344
+ **Can agents join from different networks?**
1345
+ Yes, as long as they can **reach the leader node** and **pass validation**.
1363
1346
 
1364
1347
  ---
1365
1348
 
@@ -1367,20 +1350,10 @@ const agents = await leader.use(new oAddress('o://registry'), {
1367
1350
 
1368
1351
  ### Documentation {#documentation-links}
1369
1352
 
1370
- <CardGroup cols={2}>
1371
- <Card title="Olane OS Overview" icon="home" href="/README.md">
1372
- Learn about Olane OS architecture
1373
- </Card>
1374
- <Card title="o-core" icon="gear" href="/packages/o-core/README.md">
1375
- Core protocol and addressing
1376
- </Card>
1377
- <Card title="o-node" icon="server" href="/packages/o-node/README.md">
1378
- Build agent nodes
1379
- </Card>
1380
- <Card title="o-lane" icon="brain" href="/packages/o-lane/README.md">
1381
- Add intelligence to nodes
1382
- </Card>
1383
- </CardGroup>
1353
+ - **[Olane OS Overview](/README.md)** - Learn about Olane OS architecture
1354
+ - **[o-core](/packages/o-core/README.md)** - Core protocol and addressing
1355
+ - **[o-node](/packages/o-node/README.md)** - Build agent nodes
1356
+ - **[o-lane](/packages/o-lane/README.md)** - Add intelligence to nodes
1384
1357
 
1385
1358
  ### Examples {#example-projects}
1386
1359
 
@@ -1391,17 +1364,9 @@ const agents = await leader.use(new oAddress('o://registry'), {
1391
1364
 
1392
1365
  ### Community {#community}
1393
1366
 
1394
- <CardGroup cols={3}>
1395
- <Card title="GitHub Issues" icon="github" href="https://github.com/olane-labs/olane/issues">
1396
- Report bugs or request features
1397
- </Card>
1398
- <Card title="Discussions" icon="comments" href="https://github.com/olane-labs/olane/discussions">
1399
- Ask questions and share ideas
1400
- </Card>
1401
- <Card title="Discord" icon="discord" href="https://discord.gg/olane">
1402
- Join our community
1403
- </Card>
1404
- </CardGroup>
1367
+ - **[GitHub Issues](https://github.com/olane-labs/olane/issues)** - Report bugs or request features
1368
+ - **[Discussions](https://github.com/olane-labs/olane/discussions)** - Ask questions and share ideas
1369
+ - **[Discord](https://discord.gg/olane)** - Join our community
1405
1370
 
1406
1371
  ### Commercial Support {#commercial-support}
1407
1372
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olane/o-leader",
3
- "version": "0.8.3",
3
+ "version": "0.8.4",
4
4
  "type": "module",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -53,15 +53,15 @@
53
53
  "typescript": "5.4.5"
54
54
  },
55
55
  "dependencies": {
56
- "@olane/o-config": "0.8.3",
57
- "@olane/o-core": "0.8.3",
58
- "@olane/o-gateway-olane": "0.8.3",
59
- "@olane/o-lane": "0.8.3",
60
- "@olane/o-node": "0.8.3",
61
- "@olane/o-protocol": "0.8.3",
62
- "@olane/o-tool": "0.8.3",
56
+ "@olane/o-config": "0.8.4",
57
+ "@olane/o-core": "0.8.4",
58
+ "@olane/o-gateway-olane": "0.8.4",
59
+ "@olane/o-lane": "0.8.4",
60
+ "@olane/o-node": "0.8.4",
61
+ "@olane/o-protocol": "0.8.4",
62
+ "@olane/o-tool": "0.8.4",
63
63
  "debug": "^4.4.1",
64
64
  "dotenv": "^16.5.0"
65
65
  },
66
- "gitHead": "189c0cf7b6dd9d5d961f5424af21d37978092d9e"
66
+ "gitHead": "b53623b1ad4365133911722f80d5597a72b65bf2"
67
67
  }