@olane/os 0.7.12-alpha.37 → 0.7.12-alpha.39
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/dist/test/basic/playground.spec.js +74 -11
- package/package.json +13 -12
|
@@ -4,30 +4,93 @@ import dotenv from 'dotenv';
|
|
|
4
4
|
import { defaultOSInstance } from '../utils/os.default.js';
|
|
5
5
|
import { oNodeAddress, oNodeTransport } from '@olane/o-node';
|
|
6
6
|
import { tmpNode } from '../utils/tmp.node.js';
|
|
7
|
+
import { oHumanLoginTool } from '@olane/o-login';
|
|
7
8
|
dotenv.config();
|
|
8
9
|
const network = defaultOSInstance;
|
|
10
|
+
const entryNode = tmpNode;
|
|
11
|
+
let humanNode;
|
|
9
12
|
describe('playground running', async () => {
|
|
10
13
|
it('should be able to use stream from a provider service', async () => {
|
|
11
|
-
const entryNode = tmpNode;
|
|
12
14
|
await entryNode.start();
|
|
13
15
|
expect(entryNode).to.exist;
|
|
14
16
|
expect(entryNode.state).to.equal(NodeState.RUNNING);
|
|
15
17
|
console.log('Using intelligence tool');
|
|
16
|
-
const
|
|
18
|
+
const leader = new oNodeAddress('o://leader', [
|
|
17
19
|
new oNodeTransport('/ip4/127.0.0.1/tcp/4000/ws/p2p/12D3KooWPHdsHhEdyBd9DS2zHJ1vRSyqSkZ97iT7F8ByYJ7U7bw8'),
|
|
18
|
-
])
|
|
19
|
-
|
|
20
|
+
]);
|
|
21
|
+
humanNode = new oHumanLoginTool({
|
|
22
|
+
address: new oNodeAddress('o://human'),
|
|
23
|
+
leader: leader,
|
|
24
|
+
parent: leader,
|
|
25
|
+
respond: async (intent) => {
|
|
26
|
+
return 'Request approved';
|
|
27
|
+
},
|
|
28
|
+
answer: async (question) => {
|
|
29
|
+
return 'Request approved';
|
|
30
|
+
},
|
|
31
|
+
receiveStream: async (data) => {
|
|
32
|
+
console.log('Received stream:', data);
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
await humanNode.start();
|
|
36
|
+
// const response = await entryNode.useStream(
|
|
37
|
+
// leader,
|
|
38
|
+
// {
|
|
39
|
+
// method: 'intent',
|
|
40
|
+
// params: {
|
|
41
|
+
// _isStreaming: true,
|
|
42
|
+
// intent:
|
|
43
|
+
// 'Use the perplexity tool to search for the latest news on the stock market',
|
|
44
|
+
// _token: 'test',
|
|
45
|
+
// },
|
|
46
|
+
// },
|
|
47
|
+
// {
|
|
48
|
+
// abortSignal: AbortSignal.timeout(5_000),
|
|
49
|
+
// onChunk: (chunk) => {
|
|
50
|
+
// console.log(
|
|
51
|
+
// 'Received chunk:',
|
|
52
|
+
// JSON.stringify(chunk.result.data, null, 2),
|
|
53
|
+
// );
|
|
54
|
+
// },
|
|
55
|
+
// },
|
|
56
|
+
// );
|
|
57
|
+
// console.log('Response:', response.result.data);
|
|
58
|
+
// await entryNode.stop();
|
|
59
|
+
});
|
|
60
|
+
it('should fail when action is not approved', async () => {
|
|
61
|
+
const entryNode = tmpNode;
|
|
62
|
+
// await entryNode.start();
|
|
63
|
+
expect(entryNode).to.exist;
|
|
64
|
+
expect(entryNode.state).to.equal(NodeState.RUNNING);
|
|
65
|
+
console.log('Setting approval preference to deny a specific action');
|
|
66
|
+
// Set a preference to deny a specific tool/method combination
|
|
67
|
+
const setPreferenceResponse = await entryNode.use(new oNodeAddress('o://approval'), {
|
|
68
|
+
method: 'set_preference',
|
|
20
69
|
params: {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
_token: 'test',
|
|
70
|
+
toolMethod: 'o://storage/delete',
|
|
71
|
+
preference: 'deny',
|
|
24
72
|
},
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
73
|
+
});
|
|
74
|
+
console.log('Set preference response:', setPreferenceResponse.result.data);
|
|
75
|
+
expect(setPreferenceResponse.result.data).to.exist;
|
|
76
|
+
console.log('Attempting to request approval for denied action');
|
|
77
|
+
// Now request approval for the denied action
|
|
78
|
+
const approvalResponse = await entryNode.use(new oNodeAddress('o://approval'), {
|
|
79
|
+
method: 'request_approval',
|
|
80
|
+
params: {
|
|
81
|
+
toolAddress: 'o://storage',
|
|
82
|
+
method: 'delete',
|
|
83
|
+
params: { key: 'test-key' },
|
|
84
|
+
intent: 'Testing approval denial',
|
|
28
85
|
},
|
|
29
86
|
});
|
|
30
|
-
console.log('
|
|
87
|
+
console.log('Approval response:', approvalResponse.result.data);
|
|
88
|
+
// Verify the action was denied
|
|
89
|
+
expect(approvalResponse.result.data).to.exist;
|
|
90
|
+
expect(approvalResponse.result.data.approved).to.be.false;
|
|
91
|
+
expect(approvalResponse.result.data.decision).to.equal('deny');
|
|
92
|
+
console.log('✓ Action was successfully denied by approval system');
|
|
31
93
|
await entryNode.stop();
|
|
94
|
+
await humanNode.stop();
|
|
32
95
|
});
|
|
33
96
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olane/os",
|
|
3
|
-
"version": "0.7.12-alpha.
|
|
3
|
+
"version": "0.7.12-alpha.39",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -57,21 +57,22 @@
|
|
|
57
57
|
"typescript": "5.4.5"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@olane/o-config": "0.7.12-alpha.
|
|
61
|
-
"@olane/o-core": "0.7.12-alpha.
|
|
62
|
-
"@olane/o-intelligence": "0.7.12-alpha.
|
|
63
|
-
"@olane/o-lane": "0.7.12-alpha.
|
|
64
|
-
"@olane/o-leader": "0.7.12-alpha.
|
|
65
|
-
"@olane/o-
|
|
66
|
-
"@olane/o-
|
|
67
|
-
"@olane/o-
|
|
68
|
-
"@olane/o-tool
|
|
69
|
-
"@olane/o-
|
|
60
|
+
"@olane/o-config": "0.7.12-alpha.39",
|
|
61
|
+
"@olane/o-core": "0.7.12-alpha.39",
|
|
62
|
+
"@olane/o-intelligence": "0.7.12-alpha.39",
|
|
63
|
+
"@olane/o-lane": "0.7.12-alpha.39",
|
|
64
|
+
"@olane/o-leader": "0.7.12-alpha.39",
|
|
65
|
+
"@olane/o-login": "0.7.12-alpha.39",
|
|
66
|
+
"@olane/o-protocol": "0.7.12-alpha.39",
|
|
67
|
+
"@olane/o-storage": "0.7.12-alpha.39",
|
|
68
|
+
"@olane/o-tool": "0.7.12-alpha.39",
|
|
69
|
+
"@olane/o-tool-registry": "0.7.12-alpha.39",
|
|
70
|
+
"@olane/o-tools-common": "0.7.12-alpha.39",
|
|
70
71
|
"chalk": "^5.4.1",
|
|
71
72
|
"debug": "^4.4.1",
|
|
72
73
|
"dotenv": "^16.5.0",
|
|
73
74
|
"fs-extra": "^11.3.0",
|
|
74
75
|
"touch": "^3.1.1"
|
|
75
76
|
},
|
|
76
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "794416f70451282e59b498e969c6597896abec29"
|
|
77
78
|
}
|