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