@olane/o-tools-common 0.3.1 → 0.3.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/dist/common/common.node.d.ts +6 -0
- package/dist/common/common.node.d.ts.map +1 -0
- package/dist/common/common.node.js +6 -0
- package/dist/common/index.d.ts +2 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/index.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/leader/index.d.ts +2 -0
- package/dist/leader/index.d.ts.map +1 -0
- package/dist/leader/index.js +1 -0
- package/dist/leader/leader.node.d.ts +11 -0
- package/dist/leader/leader.node.d.ts.map +1 -0
- package/dist/leader/leader.node.js +60 -0
- package/dist/leader/methods/start.method.d.ts +3 -0
- package/dist/leader/methods/start.method.d.ts.map +1 -0
- package/dist/leader/methods/start.method.js +21 -0
- package/package.json +9 -9
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.node.d.ts","sourceRoot":"","sources":["../../src/common/common.node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,qBAAa,WAAY,SAAQ,YAAY;gBAC/B,MAAM,EAAE,UAAU;CAG/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './common.node.js';
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/leader/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './leader.node.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { oRequest } from '@olane/o-core';
|
|
2
|
+
import { oToolConfig } from '@olane/o-tool';
|
|
3
|
+
import { oCommonNode } from '../common/index.js';
|
|
4
|
+
export declare class oLeaderNode extends oCommonNode {
|
|
5
|
+
constructor(config: oToolConfig);
|
|
6
|
+
validateJoinRequest(request: oRequest): Promise<any>;
|
|
7
|
+
_tool_join_network(request: oRequest): Promise<any>;
|
|
8
|
+
_tool_save_plan(request: oRequest): Promise<any>;
|
|
9
|
+
_tool_index_network(request: oRequest): Promise<any>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=leader.node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leader.node.d.ts","sourceRoot":"","sources":["../../src/leader/leader.node.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,QAAQ,EAET,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGjD,qBAAa,WAAY,SAAQ,WAAW;gBAC9B,MAAM,EAAE,WAAW;IAWzB,mBAAmB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAIpD,kBAAkB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAuBnD,eAAe,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAUhD,mBAAmB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;CAwB3D"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { LEADER_ADRESS, NodeType, oAddress, } from '@olane/o-core';
|
|
2
|
+
import { oCommonNode } from '../common/index.js';
|
|
3
|
+
import { START_METHOD } from './methods/start.method.js';
|
|
4
|
+
export class oLeaderNode extends oCommonNode {
|
|
5
|
+
constructor(config) {
|
|
6
|
+
super({
|
|
7
|
+
...config,
|
|
8
|
+
address: new oAddress(LEADER_ADRESS),
|
|
9
|
+
type: NodeType.LEADER,
|
|
10
|
+
methods: {
|
|
11
|
+
start: START_METHOD,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
async validateJoinRequest(request) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
async _tool_join_network(request) {
|
|
19
|
+
const { caller, parent, transports } = request.params;
|
|
20
|
+
this.logger.debug('Joining network: ' + caller);
|
|
21
|
+
if (!caller || !parent || !transports) {
|
|
22
|
+
throw new Error('Invalid parameters provided, cannot join network');
|
|
23
|
+
}
|
|
24
|
+
await this.validateJoinRequest(request);
|
|
25
|
+
await this.use(new oAddress(parent), {
|
|
26
|
+
method: 'add_child',
|
|
27
|
+
params: {
|
|
28
|
+
address: caller,
|
|
29
|
+
transports: transports,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
message: 'Network joined!',
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
async _tool_save_plan(request) {
|
|
37
|
+
const { plan } = request.params;
|
|
38
|
+
this.logger.debug('Adding plan to network: ' + plan);
|
|
39
|
+
if (!this.config.networkName) {
|
|
40
|
+
this.logger.warn('No network name provided, cannot update config');
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async _tool_index_network(request) {
|
|
45
|
+
// paginate through all the registered nodes and index them
|
|
46
|
+
const nodes = await this.use(new oAddress('o://leader/register'), {
|
|
47
|
+
method: 'find_all',
|
|
48
|
+
params: {},
|
|
49
|
+
});
|
|
50
|
+
const nodesArray = nodes.result.data;
|
|
51
|
+
for (let i = 0; i < nodesArray.length; i++) {
|
|
52
|
+
// first let's get the node's tools
|
|
53
|
+
const node = nodesArray[i];
|
|
54
|
+
const { result } = await this.use(new oAddress(node.address), {
|
|
55
|
+
method: 'index_network',
|
|
56
|
+
params: {},
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.method.d.ts","sourceRoot":"","sources":["../../../src/leader/methods/start.method.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,eAAO,MAAM,YAAY,EAAE,OAoB1B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const START_METHOD = {
|
|
2
|
+
name: 'start',
|
|
3
|
+
description: 'Start a task',
|
|
4
|
+
dependencies: [],
|
|
5
|
+
parameters: [
|
|
6
|
+
{
|
|
7
|
+
name: 'intent',
|
|
8
|
+
type: 'string',
|
|
9
|
+
value: 'string',
|
|
10
|
+
description: 'The intent of the task',
|
|
11
|
+
required: true,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'userInput',
|
|
15
|
+
type: 'string',
|
|
16
|
+
value: 'string',
|
|
17
|
+
description: 'The user input to the task',
|
|
18
|
+
required: false,
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olane/o-tools-common",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@eslint/eslintrc": "^3.3.1",
|
|
36
36
|
"@eslint/js": "^9.29.0",
|
|
37
|
-
"@olane/o-config": "^0.3.
|
|
38
|
-
"@olane/o-core": "^0.3.
|
|
39
|
-
"@olane/o-protocol": "^0.3.
|
|
40
|
-
"@olane/o-tool": "^0.3.
|
|
37
|
+
"@olane/o-config": "^0.3.2",
|
|
38
|
+
"@olane/o-core": "^0.3.2",
|
|
39
|
+
"@olane/o-protocol": "^0.3.2",
|
|
40
|
+
"@olane/o-tool": "^0.3.2",
|
|
41
41
|
"@tsconfig/node20": "^20.1.6",
|
|
42
42
|
"@types/jest": "^30.0.0",
|
|
43
43
|
"@typescript-eslint/eslint-plugin": "^8.34.1",
|
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
"typescript": "5.4.5"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@olane/o-config": "^0.3.
|
|
59
|
-
"@olane/o-core": "^0.3.
|
|
60
|
-
"@olane/o-protocol": "^0.3.
|
|
61
|
-
"@olane/o-tool": "^0.3.
|
|
58
|
+
"@olane/o-config": "^0.3.2",
|
|
59
|
+
"@olane/o-core": "^0.3.2",
|
|
60
|
+
"@olane/o-protocol": "^0.3.2",
|
|
61
|
+
"@olane/o-tool": "^0.3.2"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"debug": "^4.4.1",
|