@olane/o-tool 0.7.12-alpha.9 → 0.7.12
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/src/o-tool.base.d.ts +2 -2
- package/dist/src/o-tool.base.d.ts.map +1 -1
- package/dist/src/o-tool.base.js +4 -4
- package/dist/src/o-tool.d.ts.map +1 -1
- package/dist/src/o-tool.js +10 -2
- package/package.json +6 -6
- package/dist/src/router/o-request.router.d.ts +0 -15
- package/dist/src/router/o-request.router.d.ts.map +0 -1
- package/dist/src/router/o-request.router.js +0 -10
- package/dist/src/utils/tool.utils.d.ts +0 -6
- package/dist/src/utils/tool.utils.d.ts.map +0 -1
- package/dist/src/utils/tool.utils.js +0 -17
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { oConnection, oCore, oRequest, oNotificationManager, oConnectionConfig } from '@olane/o-core';
|
|
2
2
|
import { Stream } from '@olane/o-config';
|
|
3
3
|
import { RunResult } from './interfaces/run-result.interface.js';
|
|
4
4
|
import { ToolResult } from './interfaces/tool-result.interface.js';
|
|
@@ -11,7 +11,7 @@ export declare class oToolBase extends oCore {
|
|
|
11
11
|
private indexed;
|
|
12
12
|
validateToolCall(oRequest: oRequest): boolean;
|
|
13
13
|
configureTransports(): any[];
|
|
14
|
-
connect(
|
|
14
|
+
connect(config: oConnectionConfig): Promise<oConnection>;
|
|
15
15
|
initializeRouter(): Promise<void>;
|
|
16
16
|
unregister(): Promise<void>;
|
|
17
17
|
register(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o-tool.base.d.ts","sourceRoot":"","sources":["../../src/o-tool.base.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"o-tool.base.d.ts","sourceRoot":"","sources":["../../src/o-tool.base.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,KAAK,EAGL,QAAQ,EAER,oBAAoB,EACpB,i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-
connect(
|
|
29
|
+
connect(config) {
|
|
30
30
|
throw new oError(oErrorCodes.NOT_IMPLEMENTED, 'Connect not implemented');
|
|
31
31
|
}
|
|
32
32
|
initializeRouter() {
|
|
@@ -67,7 +67,7 @@ export class oToolBase extends oCore {
|
|
|
67
67
|
const missingParams = MethodUtils.findMissingParams(this, request.method, request.params || {});
|
|
68
68
|
if (missingParams.length > 0) {
|
|
69
69
|
this.logger.error('Missing required parameters: ', missingParams, ' with passed params: ', request.params);
|
|
70
|
-
throw new oError(oErrorCodes.MISSING_PARAMETERS, 'Missing required parameters', {
|
|
70
|
+
throw new oError(oErrorCodes.MISSING_PARAMETERS, 'Missing required parameters: ' + missingParams.join(','), {
|
|
71
71
|
parameters: missingParams,
|
|
72
72
|
toolAddress: this.address.toString(),
|
|
73
73
|
data: request.params,
|
|
@@ -87,7 +87,7 @@ export class oToolBase extends oCore {
|
|
|
87
87
|
}
|
|
88
88
|
async callMyTool(request, stream) {
|
|
89
89
|
const method = request.method;
|
|
90
|
-
this.logger.
|
|
90
|
+
this.logger.verbose('Calling tool: ' + method);
|
|
91
91
|
// TODO: implement this
|
|
92
92
|
// this.requests[request.id] = request;
|
|
93
93
|
// @ts-ignore
|
|
@@ -103,7 +103,7 @@ export class oToolBase extends oCore {
|
|
|
103
103
|
}
|
|
104
104
|
async index() {
|
|
105
105
|
if (this.indexed) {
|
|
106
|
-
this.logger.
|
|
106
|
+
this.logger.verbose('Tool already indexed, skipping...');
|
|
107
107
|
return {
|
|
108
108
|
summary: 'Tool already indexed',
|
|
109
109
|
};
|
package/dist/src/o-tool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o-tool.d.ts","sourceRoot":"","sources":["../../src/o-tool.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAI7C;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,SAAS,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"o-tool.d.ts","sourceRoot":"","sources":["../../src/o-tool.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAI7C;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,SAAS,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAuQ7E"}
|
package/dist/src/o-tool.js
CHANGED
|
@@ -45,6 +45,8 @@ export function oTool(Base) {
|
|
|
45
45
|
await this.useChild(child, {
|
|
46
46
|
method: 'index_network',
|
|
47
47
|
params: {},
|
|
48
|
+
}).catch((error) => {
|
|
49
|
+
this.logger.error('Error indexing child: ', error);
|
|
48
50
|
});
|
|
49
51
|
}
|
|
50
52
|
this.logger.debug('Node + children indexed!');
|
|
@@ -67,7 +69,7 @@ export function oTool(Base) {
|
|
|
67
69
|
errorCount: this.metrics.errorCount,
|
|
68
70
|
activeRequests: this.requestManager.activeRequests.length,
|
|
69
71
|
state: this.state,
|
|
70
|
-
uptime:
|
|
72
|
+
uptime: 0,
|
|
71
73
|
memoryUsage: process.memoryUsage(),
|
|
72
74
|
children: this.hierarchyManager.getChildren().map((c) => c.toString()),
|
|
73
75
|
};
|
|
@@ -75,7 +77,7 @@ export function oTool(Base) {
|
|
|
75
77
|
async _tool_route(request) {
|
|
76
78
|
if (request.params.address === this.address.toString() ||
|
|
77
79
|
request.params.address === this.staticAddress.toString()) {
|
|
78
|
-
this.logger.
|
|
80
|
+
this.logger.verbose('Route to self, calling tool...');
|
|
79
81
|
const { payload } = request.params;
|
|
80
82
|
return this.callMyTool(new oRequest({
|
|
81
83
|
method: payload.method,
|
|
@@ -85,6 +87,12 @@ export function oTool(Base) {
|
|
|
85
87
|
}
|
|
86
88
|
return this.router.route(request, this);
|
|
87
89
|
}
|
|
90
|
+
async _tool_register_leader(request) {
|
|
91
|
+
await this.registerLeader();
|
|
92
|
+
return {
|
|
93
|
+
message: 'Leader registered',
|
|
94
|
+
};
|
|
95
|
+
}
|
|
88
96
|
async _tool_child_register(request) {
|
|
89
97
|
throw new oError(oErrorCodes.NOT_IMPLEMENTED, 'Child register not implemented');
|
|
90
98
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olane/o-tool",
|
|
3
|
-
"version": "0.7.12
|
|
3
|
+
"version": "0.7.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"test:node": "aegir test -t node",
|
|
21
21
|
"deep:clean": "rm -rf node_modules && rm package-lock.json",
|
|
22
22
|
"test:browser": "aegir test -t browser",
|
|
23
|
-
"build": "tsc",
|
|
23
|
+
"build": "rm -rf dist && tsc",
|
|
24
24
|
"start:prod": "node dist/index.js",
|
|
25
25
|
"prepublishOnly": "npm run build",
|
|
26
26
|
"lint": "aegir lint"
|
|
@@ -54,11 +54,11 @@
|
|
|
54
54
|
"typescript": "^5.8.3"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@olane/o-config": "0.7.12
|
|
58
|
-
"@olane/o-core": "0.7.12
|
|
59
|
-
"@olane/o-protocol": "0.7.12
|
|
57
|
+
"@olane/o-config": "0.7.12",
|
|
58
|
+
"@olane/o-core": "0.7.12",
|
|
59
|
+
"@olane/o-protocol": "0.7.12",
|
|
60
60
|
"debug": "^4.4.1",
|
|
61
61
|
"dotenv": "^16.5.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "580d8c51fe0a12695ba1d77f077029200f0c8af4"
|
|
64
64
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { oProtocolMethods, oRouterRequest as oRouterRequestInterface, RequestParams } from '@olane/o-protocol';
|
|
2
|
-
import { oRequest } from '@olane/o-core';
|
|
3
|
-
import { Stream } from '@olane/o-config';
|
|
4
|
-
export declare class oRouterRequest extends oRequest implements oRouterRequestInterface {
|
|
5
|
-
method: oProtocolMethods.ROUTE;
|
|
6
|
-
stream?: Stream | undefined;
|
|
7
|
-
params: RequestParams & {
|
|
8
|
-
address: string;
|
|
9
|
-
payload: {
|
|
10
|
-
[key: string]: unknown;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
constructor(config: oRouterRequestInterface);
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=o-request.router.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"o-request.router.d.ts","sourceRoot":"","sources":["../../../src/router/o-request.router.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,cAAc,IAAI,uBAAuB,EACzC,aAAa,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,qBAAa,cACX,SAAQ,QACR,YAAW,uBAAuB;IAElC,MAAM,EAAE,gBAAgB,CAAC,KAAK,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,EAAE,aAAa,GAAG;QACtB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE;YACP,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;SACxB,CAAC;KACH,CAAC;gBACU,MAAM,EAAE,uBAAuB;CAO5C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool.utils.d.ts","sourceRoot":"","sources":["../../../src/utils/tool.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,qBAAa,SAAS;IACpB,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,GAAG,SAAS;CAc5E"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { oResponse } from '@olane/o-core';
|
|
2
|
-
export class ToolUtils {
|
|
3
|
-
static buildResponse(request, result, error) {
|
|
4
|
-
let success = true;
|
|
5
|
-
if (error) {
|
|
6
|
-
success = false;
|
|
7
|
-
}
|
|
8
|
-
return new oResponse({
|
|
9
|
-
id: request.id,
|
|
10
|
-
data: result,
|
|
11
|
-
error: result?.error,
|
|
12
|
-
...{ success },
|
|
13
|
-
_requestMethod: request.method,
|
|
14
|
-
_connectionId: request.params?._connectionId,
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
}
|