@noosphere/agent-core 0.1.0-alpha.0 → 0.1.0-alpha.2
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 +143 -0
- package/package.json +4 -4
package/README.md
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# @noosphere/agent-core
|
|
2
|
+
|
|
3
|
+
Core modules for building Noosphere compute agents.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @noosphere/agent-core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
For alpha version:
|
|
12
|
+
```bash
|
|
13
|
+
npm install @noosphere/agent-core@alpha
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Components
|
|
17
|
+
|
|
18
|
+
### NoosphereAgent
|
|
19
|
+
|
|
20
|
+
Main agent class that orchestrates compute request handling.
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { NoosphereAgent } from '@noosphere/agent-core';
|
|
24
|
+
|
|
25
|
+
const agent = new NoosphereAgent({
|
|
26
|
+
rpcUrl: 'https://sepolia.hpp.io',
|
|
27
|
+
wsUrl: 'wss://sepolia.hpp.io',
|
|
28
|
+
routerAddress: '0x89c76ee71E9cC8D57BEE3d414478B630AE41fF43',
|
|
29
|
+
coordinatorAddress: '0x244D87a7CAe0D557C223C13a90Ae845e56430A50',
|
|
30
|
+
keystore,
|
|
31
|
+
containers: [
|
|
32
|
+
{
|
|
33
|
+
containerId: 'hello-world',
|
|
34
|
+
imageName: 'noosphere/hello-world:latest',
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Event handlers
|
|
40
|
+
agent.on('requestStarted', (event) => {
|
|
41
|
+
console.log('Request started:', event.requestId);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
agent.on('computeDelivered', (event) => {
|
|
45
|
+
console.log('Compute delivered:', event.requestId);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Start agent
|
|
49
|
+
await agent.start();
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### EventMonitor
|
|
53
|
+
|
|
54
|
+
WebSocket-based blockchain event monitor with automatic reconnection.
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import { EventMonitor } from '@noosphere/agent-core';
|
|
58
|
+
|
|
59
|
+
const monitor = new EventMonitor(
|
|
60
|
+
{
|
|
61
|
+
rpcUrl: 'https://sepolia.hpp.io',
|
|
62
|
+
wsUrl: 'wss://sepolia.hpp.io',
|
|
63
|
+
routerAddress: '0x89c76ee71E9cC8D57BEE3d414478B630AE41fF43',
|
|
64
|
+
coordinatorAddress: '0x244D87a7CAe0D557C223C13a90Ae845e56430A50',
|
|
65
|
+
},
|
|
66
|
+
routerAbi,
|
|
67
|
+
coordinatorAbi,
|
|
68
|
+
{ enableHeartbeat: true }
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
monitor.on('RequestStarted', (event) => {
|
|
72
|
+
console.log('New request:', event);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
await monitor.start();
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### ContainerManager
|
|
79
|
+
|
|
80
|
+
Docker container lifecycle management.
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { ContainerManager } from '@noosphere/agent-core';
|
|
84
|
+
|
|
85
|
+
const manager = new ContainerManager();
|
|
86
|
+
|
|
87
|
+
// Run container
|
|
88
|
+
const result = await manager.runContainer({
|
|
89
|
+
imageName: 'noosphere/hello-world:latest',
|
|
90
|
+
input: { message: 'Hello' },
|
|
91
|
+
timeout: 30000,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
console.log('Output:', result.output);
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### SchedulerService
|
|
98
|
+
|
|
99
|
+
Subscription scheduling and interval management.
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
import { SchedulerService } from '@noosphere/agent-core';
|
|
103
|
+
|
|
104
|
+
const scheduler = new SchedulerService(
|
|
105
|
+
coordinatorContract,
|
|
106
|
+
walletManager,
|
|
107
|
+
{ intervalCheckMs: 60000 }
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
scheduler.on('intervalPrepared', (event) => {
|
|
111
|
+
console.log('Interval prepared:', event);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
await scheduler.start(subscriptions);
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Re-exports
|
|
118
|
+
|
|
119
|
+
For convenience, this package re-exports from other Noosphere packages:
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
// From @noosphere/crypto
|
|
123
|
+
import { KeystoreManager, WalletManager } from '@noosphere/agent-core';
|
|
124
|
+
|
|
125
|
+
// From @noosphere/registry
|
|
126
|
+
import { RegistryManager } from '@noosphere/agent-core';
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Types
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
import type {
|
|
133
|
+
NoosphereAgentConfig,
|
|
134
|
+
ContainerConfig,
|
|
135
|
+
CheckpointData,
|
|
136
|
+
ComputeDeliveredEvent,
|
|
137
|
+
RequestStartedCallbackEvent,
|
|
138
|
+
} from '@noosphere/agent-core';
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## License
|
|
142
|
+
|
|
143
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noosphere/agent-core",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.2",
|
|
4
4
|
"description": "Core modules for Noosphere agent (EventMonitor, ContainerManager, NoosphereAgent)",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@noosphere/contracts": "
|
|
52
|
-
"@noosphere/crypto": "
|
|
53
|
-
"@noosphere/registry": "
|
|
51
|
+
"@noosphere/contracts": "0.1.0-alpha.2",
|
|
52
|
+
"@noosphere/crypto": "0.1.0-alpha.2",
|
|
53
|
+
"@noosphere/registry": "0.1.0-alpha.2",
|
|
54
54
|
"axios": "^1.13.2",
|
|
55
55
|
"dockerode": "^4.0.0",
|
|
56
56
|
"dotenv": "^16.3.0",
|