@olane/o-tool 0.7.12-alpha.6 → 0.7.12-alpha.60

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.
@@ -1,4 +1,4 @@
1
- import { oAddress, oConnection, oCore, oRequest, oNotificationManager } from '@olane/o-core';
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(nextHopAddress: oAddress, targetAddress: oAddress): Promise<oConnection>;
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,EACL,QAAQ,EACR,WAAW,EACX,KAAK,EAGL,QAAQ,EAER,oBAAoB,EACrB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AAInE;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAClC,OAAO,CAAC,OAAO,CAAkB;IAEjC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO;IAY7C,mBAAmB,IAAI,GAAG,EAAE;IAI5B,OAAO,CACL,cAAc,EAAE,QAAQ,EACxB,aAAa,EAAE,QAAQ,GACtB,OAAO,CAAC,WAAW,CAAC;IAGvB,gBAAgB,IAAI,OAAO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gB,IAAI,OAAO,CAAC,IAAI,CAAC;IAMjC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAG3B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAIzB,SAAS,CAAC,yBAAyB,IAAI,oBAAoB;IAOrD,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IA8B3D,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IA2BjE,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAS/B,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAIvD,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAiBnE,KAAK;;;;;;;IA4FL,MAAM;;;;CAQb"}
@@ -26,7 +26,7 @@ export class oToolBase extends oCore {
26
26
  configureTransports() {
27
27
  return [];
28
28
  }
29
- connect(nextHopAddress, targetAddress) {
29
+ connect(config) {
30
30
  throw new oError(oErrorCodes.NOT_IMPLEMENTED, 'Connect not implemented');
31
31
  }
32
32
  initializeRouter() {
@@ -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.debug('Calling tool: ' + method);
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.debug('Tool already indexed, skipping...');
106
+ this.logger.verbose('Tool already indexed, skipping...');
107
107
  return {
108
108
  summary: 'Tool already indexed',
109
109
  };
@@ -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,CAgQ7E"}
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"}
@@ -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: process.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.debug('Route to self, calling tool...');
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-alpha.6",
3
+ "version": "0.7.12-alpha.60",
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-alpha.5",
58
- "@olane/o-core": "0.7.12-alpha.6",
59
- "@olane/o-protocol": "0.7.12-alpha.6",
57
+ "@olane/o-config": "0.7.12-alpha.60",
58
+ "@olane/o-core": "0.7.12-alpha.60",
59
+ "@olane/o-protocol": "0.7.12-alpha.60",
60
60
  "debug": "^4.4.1",
61
61
  "dotenv": "^16.5.0"
62
62
  },
63
- "gitHead": "fad0400ec59d38b163bd996d967cd46c6a5a9e0a"
63
+ "gitHead": "4419813eec431b7030c230069d08984f25bbaed2"
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,10 +0,0 @@
1
- import { oRequest } from '@olane/o-core';
2
- export class oRouterRequest extends oRequest {
3
- constructor(config) {
4
- super(config);
5
- this.method = config.method;
6
- this.params = config.params;
7
- this.stream = config.stream;
8
- this.id = config.id;
9
- }
10
- }
@@ -1,6 +0,0 @@
1
- import { oResponse } from '@olane/o-core';
2
- import { oRequest } from '@olane/o-protocol';
3
- export declare class ToolUtils {
4
- static buildResponse(request: oRequest, result: any, error: any): oResponse;
5
- }
6
- //# sourceMappingURL=tool.utils.d.ts.map
@@ -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
- }