@olane/o-node 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.
Files changed (231) hide show
  1. package/dist/o-core/src/connection/index.d.ts +8 -0
  2. package/dist/o-core/src/connection/index.d.ts.map +1 -0
  3. package/dist/o-core/src/connection/index.js +7 -0
  4. package/dist/o-core/src/connection/interfaces/connection-manager.config.d.ts +15 -0
  5. package/dist/o-core/src/connection/interfaces/connection-manager.config.d.ts.map +1 -0
  6. package/dist/o-core/src/connection/interfaces/connection-manager.config.js +1 -0
  7. package/dist/o-core/src/connection/interfaces/connection-send-params.interface.d.ts +9 -0
  8. package/dist/o-core/src/connection/interfaces/connection-send-params.interface.d.ts.map +1 -0
  9. package/dist/o-core/src/connection/interfaces/connection-send-params.interface.js +1 -0
  10. package/dist/o-core/src/connection/interfaces/connection.config.d.ts +20 -0
  11. package/dist/o-core/src/connection/interfaces/connection.config.d.ts.map +1 -0
  12. package/dist/o-core/src/connection/interfaces/connection.config.js +1 -0
  13. package/dist/o-core/src/connection/interfaces/index.d.ts +5 -0
  14. package/dist/o-core/src/connection/interfaces/index.d.ts.map +1 -0
  15. package/dist/o-core/src/connection/interfaces/index.js +4 -0
  16. package/dist/o-core/src/connection/interfaces/request-state.enum.d.ts +7 -0
  17. package/dist/o-core/src/connection/interfaces/request-state.enum.d.ts.map +1 -0
  18. package/dist/o-core/src/connection/interfaces/request-state.enum.js +7 -0
  19. package/dist/o-core/src/connection/o-connection-manager.d.ts +19 -0
  20. package/dist/o-core/src/connection/o-connection-manager.d.ts.map +1 -0
  21. package/dist/o-core/src/connection/o-connection-manager.js +27 -0
  22. package/dist/o-core/src/connection/o-connection.d.ts +26 -0
  23. package/dist/o-core/src/connection/o-connection.d.ts.map +1 -0
  24. package/dist/o-core/src/connection/o-connection.js +54 -0
  25. package/dist/o-core/src/connection/o-request.d.ts +23 -0
  26. package/dist/o-core/src/connection/o-request.d.ts.map +1 -0
  27. package/dist/o-core/src/connection/o-request.js +42 -0
  28. package/dist/o-core/src/connection/o-response.d.ts +1 -0
  29. package/dist/o-core/src/connection/o-response.d.ts.map +1 -1
  30. package/dist/o-core/src/connection/o-response.js +7 -0
  31. package/dist/o-core/src/core/defaults/config.d.ts +4 -0
  32. package/dist/o-core/src/core/defaults/config.d.ts.map +1 -0
  33. package/dist/o-core/src/core/defaults/config.js +5 -0
  34. package/dist/o-core/src/core/defaults/index.d.ts +2 -0
  35. package/dist/o-core/src/core/defaults/index.d.ts.map +1 -0
  36. package/dist/o-core/src/core/defaults/index.js +1 -0
  37. package/dist/o-core/src/core/graceful-shutdown.d.ts +25 -0
  38. package/dist/o-core/src/core/graceful-shutdown.d.ts.map +1 -0
  39. package/dist/o-core/src/core/graceful-shutdown.js +84 -0
  40. package/dist/o-core/src/core/index.d.ts +9 -0
  41. package/dist/o-core/src/core/index.d.ts.map +1 -0
  42. package/dist/o-core/src/core/index.js +8 -0
  43. package/dist/o-core/src/core/interfaces/index.d.ts +7 -0
  44. package/dist/o-core/src/core/interfaces/index.d.ts.map +1 -0
  45. package/dist/o-core/src/core/interfaces/index.js +6 -0
  46. package/dist/o-core/src/core/interfaces/node-type.enum.d.ts +10 -0
  47. package/dist/o-core/src/core/interfaces/node-type.enum.d.ts.map +1 -0
  48. package/dist/o-core/src/core/interfaces/node-type.enum.js +10 -0
  49. package/dist/o-core/src/core/interfaces/o-core.config.d.ts +23 -0
  50. package/dist/o-core/src/core/interfaces/o-core.config.d.ts.map +1 -0
  51. package/dist/o-core/src/core/interfaces/o-core.config.js +1 -0
  52. package/dist/o-core/src/core/interfaces/o-core.interface.d.ts +18 -0
  53. package/dist/o-core/src/core/interfaces/o-core.interface.d.ts.map +1 -0
  54. package/dist/o-core/src/core/interfaces/o-core.interface.js +1 -0
  55. package/dist/o-core/src/core/interfaces/state.enum.d.ts +8 -0
  56. package/dist/o-core/src/core/interfaces/state.enum.d.ts.map +1 -0
  57. package/dist/o-core/src/core/interfaces/state.enum.js +8 -0
  58. package/dist/o-core/src/core/interfaces/use-options.interface.d.ts +11 -0
  59. package/dist/o-core/src/core/interfaces/use-options.interface.d.ts.map +1 -0
  60. package/dist/o-core/src/core/interfaces/use-options.interface.js +1 -0
  61. package/dist/o-core/src/core/interfaces/use-stream-options.interface.d.ts +4 -0
  62. package/dist/o-core/src/core/interfaces/use-stream-options.interface.d.ts.map +1 -0
  63. package/dist/o-core/src/core/interfaces/use-stream-options.interface.js +1 -0
  64. package/dist/o-core/src/core/lib/events/connection-events.d.ts +31 -0
  65. package/dist/o-core/src/core/lib/events/connection-events.d.ts.map +1 -0
  66. package/dist/o-core/src/core/lib/events/connection-events.js +46 -0
  67. package/dist/o-core/src/core/lib/events/hierarchy-events.d.ts +69 -0
  68. package/dist/o-core/src/core/lib/events/hierarchy-events.d.ts.map +1 -0
  69. package/dist/o-core/src/core/lib/events/hierarchy-events.js +100 -0
  70. package/dist/o-core/src/core/lib/events/index.d.ts +6 -0
  71. package/dist/o-core/src/core/lib/events/index.d.ts.map +1 -0
  72. package/dist/o-core/src/core/lib/events/index.js +5 -0
  73. package/dist/o-core/src/core/lib/events/node-events.d.ts +40 -0
  74. package/dist/o-core/src/core/lib/events/node-events.d.ts.map +1 -0
  75. package/dist/o-core/src/core/lib/events/node-events.js +58 -0
  76. package/dist/o-core/src/core/lib/events/o-notification-event.d.ts +26 -0
  77. package/dist/o-core/src/core/lib/events/o-notification-event.d.ts.map +1 -0
  78. package/dist/o-core/src/core/lib/events/o-notification-event.js +30 -0
  79. package/dist/o-core/src/core/lib/index.d.ts +8 -0
  80. package/dist/o-core/src/core/lib/index.d.ts.map +1 -0
  81. package/dist/o-core/src/core/lib/index.js +7 -0
  82. package/dist/o-core/src/core/lib/interfaces/notification-types.d.ts +49 -0
  83. package/dist/o-core/src/core/lib/interfaces/notification-types.d.ts.map +1 -0
  84. package/dist/o-core/src/core/lib/interfaces/notification-types.js +1 -0
  85. package/dist/o-core/src/core/lib/o-hierarchy.manager.d.ts +24 -0
  86. package/dist/o-core/src/core/lib/o-hierarchy.manager.d.ts.map +1 -0
  87. package/dist/o-core/src/core/lib/o-hierarchy.manager.js +58 -0
  88. package/dist/o-core/src/core/lib/o-metrics.d.ts +5 -0
  89. package/dist/o-core/src/core/lib/o-metrics.d.ts.map +1 -0
  90. package/dist/o-core/src/core/lib/o-metrics.js +6 -0
  91. package/dist/o-core/src/core/lib/o-notification.manager.d.ts +58 -0
  92. package/dist/o-core/src/core/lib/o-notification.manager.d.ts.map +1 -0
  93. package/dist/o-core/src/core/lib/o-notification.manager.js +159 -0
  94. package/dist/o-core/src/core/lib/o-request.manager.d.ts +10 -0
  95. package/dist/o-core/src/core/lib/o-request.manager.d.ts.map +1 -0
  96. package/dist/o-core/src/core/lib/o-request.manager.js +18 -0
  97. package/dist/o-core/src/core/lib/utils/event-filters.d.ts +38 -0
  98. package/dist/o-core/src/core/lib/utils/event-filters.d.ts.map +1 -0
  99. package/dist/o-core/src/core/lib/utils/event-filters.js +159 -0
  100. package/dist/o-core/src/core/o-core.d.ts +240 -0
  101. package/dist/o-core/src/core/o-core.d.ts.map +1 -0
  102. package/dist/o-core/src/core/o-core.js +463 -0
  103. package/dist/o-core/src/core/o-dependency.d.ts +9 -0
  104. package/dist/o-core/src/core/o-dependency.d.ts.map +1 -0
  105. package/dist/o-core/src/core/o-dependency.js +15 -0
  106. package/dist/o-core/src/core/o-object.d.ts +7 -0
  107. package/dist/o-core/src/core/o-object.d.ts.map +1 -0
  108. package/dist/o-core/src/core/o-object.js +10 -0
  109. package/dist/o-core/src/core/o-parameter.d.ts +12 -0
  110. package/dist/o-core/src/core/o-parameter.d.ts.map +1 -0
  111. package/dist/o-core/src/core/o-parameter.js +21 -0
  112. package/dist/o-core/src/error/index.d.ts +3 -0
  113. package/dist/o-core/src/error/index.d.ts.map +1 -0
  114. package/dist/o-core/src/error/index.js +2 -0
  115. package/dist/o-core/src/index.d.ts +8 -0
  116. package/dist/o-core/src/index.d.ts.map +1 -0
  117. package/dist/o-core/src/index.js +7 -0
  118. package/dist/o-core/src/response/index.d.ts +2 -0
  119. package/dist/o-core/src/response/index.d.ts.map +1 -0
  120. package/dist/o-core/src/response/index.js +1 -0
  121. package/dist/o-core/src/response/response-builder.d.ts +140 -0
  122. package/dist/o-core/src/response/response-builder.d.ts.map +1 -0
  123. package/dist/o-core/src/response/response-builder.js +190 -0
  124. package/dist/o-core/src/router/enums/restricted-addresses.enum.d.ts +8 -0
  125. package/dist/o-core/src/router/enums/restricted-addresses.enum.d.ts.map +1 -0
  126. package/dist/o-core/src/router/enums/restricted-addresses.enum.js +13 -0
  127. package/dist/o-core/src/router/index.d.ts +11 -0
  128. package/dist/o-core/src/router/index.d.ts.map +1 -0
  129. package/dist/o-core/src/router/index.js +10 -0
  130. package/dist/o-core/src/router/interfaces/resolve.request.d.ts +10 -0
  131. package/dist/o-core/src/router/interfaces/resolve.request.d.ts.map +1 -0
  132. package/dist/o-core/src/router/interfaces/resolve.request.js +1 -0
  133. package/dist/o-core/src/router/interfaces/route.response.d.ts +8 -0
  134. package/dist/o-core/src/router/interfaces/route.response.d.ts.map +1 -0
  135. package/dist/o-core/src/router/interfaces/route.response.js +1 -0
  136. package/dist/o-core/src/router/o-address-resolver.d.ts +14 -0
  137. package/dist/o-core/src/router/o-address-resolver.d.ts.map +1 -0
  138. package/dist/o-core/src/router/o-address-resolver.js +19 -0
  139. package/dist/o-core/src/router/o-address.d.ts +33 -0
  140. package/dist/o-core/src/router/o-address.d.ts.map +1 -0
  141. package/dist/o-core/src/router/o-address.js +114 -0
  142. package/dist/o-core/src/router/o-request-preparation.d.ts +37 -0
  143. package/dist/o-core/src/router/o-request-preparation.d.ts.map +1 -0
  144. package/dist/o-core/src/router/o-request-preparation.js +75 -0
  145. package/dist/o-core/src/router/o-request.router.d.ts +18 -0
  146. package/dist/o-core/src/router/o-request.router.d.ts.map +1 -0
  147. package/dist/o-core/src/router/o-request.router.js +12 -0
  148. package/dist/o-core/src/router/o-resolver-chain.d.ts +32 -0
  149. package/dist/o-core/src/router/o-resolver-chain.d.ts.map +1 -0
  150. package/dist/o-core/src/router/o-resolver-chain.js +62 -0
  151. package/dist/o-core/src/router/o-router.d.ts +19 -0
  152. package/dist/o-core/src/router/o-router.d.ts.map +1 -0
  153. package/dist/o-core/src/router/o-router.js +14 -0
  154. package/dist/o-core/src/router/o-routing-policy.d.ts +36 -0
  155. package/dist/o-core/src/router/o-routing-policy.d.ts.map +1 -0
  156. package/dist/o-core/src/router/o-routing-policy.js +19 -0
  157. package/dist/o-core/src/transports/custom.transport.d.ts +6 -0
  158. package/dist/o-core/src/transports/custom.transport.d.ts.map +1 -0
  159. package/dist/o-core/src/transports/custom.transport.js +10 -0
  160. package/dist/o-core/src/transports/index.d.ts +4 -0
  161. package/dist/o-core/src/transports/index.d.ts.map +1 -0
  162. package/dist/o-core/src/transports/index.js +3 -0
  163. package/dist/o-core/src/transports/interfaces/transport-type.enum.d.ts +5 -0
  164. package/dist/o-core/src/transports/interfaces/transport-type.enum.d.ts.map +1 -0
  165. package/dist/o-core/src/transports/interfaces/transport-type.enum.js +5 -0
  166. package/dist/o-core/src/transports/o-transport.d.ts +10 -0
  167. package/dist/o-core/src/transports/o-transport.d.ts.map +1 -0
  168. package/dist/o-core/src/transports/o-transport.js +16 -0
  169. package/dist/o-core/src/utils/core.utils.d.ts +34 -0
  170. package/dist/o-core/src/utils/core.utils.d.ts.map +1 -0
  171. package/dist/o-core/src/utils/core.utils.js +123 -0
  172. package/dist/o-core/src/utils/index.d.ts +6 -0
  173. package/dist/o-core/src/utils/index.d.ts.map +1 -0
  174. package/dist/o-core/src/utils/index.js +5 -0
  175. package/dist/o-core/src/utils/logger.d.ts +14 -0
  176. package/dist/o-core/src/utils/logger.d.ts.map +1 -0
  177. package/dist/o-core/src/utils/logger.js +31 -0
  178. package/dist/o-core/src/utils/object.utils.d.ts +5 -0
  179. package/dist/o-core/src/utils/object.utils.d.ts.map +1 -0
  180. package/dist/o-core/src/utils/object.utils.js +23 -0
  181. package/dist/o-core/src/utils/regex.utils.d.ts +4 -0
  182. package/dist/o-core/src/utils/regex.utils.d.ts.map +1 -0
  183. package/dist/o-core/src/utils/regex.utils.js +13 -0
  184. package/dist/o-core/src/utils/remote.utils.d.ts +4 -0
  185. package/dist/o-core/src/utils/remote.utils.d.ts.map +1 -0
  186. package/dist/o-core/src/utils/remote.utils.js +5 -0
  187. package/dist/o-node/src/connection/o-node-connection.d.ts +2 -2
  188. package/dist/o-node/src/connection/o-node-connection.d.ts.map +1 -1
  189. package/dist/o-node/src/connection/o-node-connection.js +36 -23
  190. package/dist/o-node/src/connection/o-node-connection.manager.d.ts.map +1 -1
  191. package/dist/o-node/src/connection/o-node-connection.manager.js +13 -41
  192. package/dist/o-node/src/index.d.ts +1 -0
  193. package/dist/o-node/src/index.d.ts.map +1 -1
  194. package/dist/o-node/src/index.js +1 -0
  195. package/dist/o-node/src/interfaces/o-node.config.d.ts +0 -17
  196. package/dist/o-node/src/interfaces/o-node.config.d.ts.map +1 -1
  197. package/dist/o-node/src/managers/o-connection-heartbeat.manager.d.ts +1 -0
  198. package/dist/o-node/src/managers/o-connection-heartbeat.manager.d.ts.map +1 -1
  199. package/dist/o-node/src/managers/o-connection-heartbeat.manager.js +17 -3
  200. package/dist/o-node/src/o-node.d.ts +11 -12
  201. package/dist/o-node/src/o-node.d.ts.map +1 -1
  202. package/dist/o-node/src/o-node.js +104 -25
  203. package/dist/o-node/src/o-node.notification-manager.js +4 -1
  204. package/dist/o-node/src/o-node.tool.d.ts.map +1 -1
  205. package/dist/o-node/src/o-node.tool.js +16 -23
  206. package/dist/o-node/src/router/o-node.router.d.ts +1 -0
  207. package/dist/o-node/src/router/o-node.router.d.ts.map +1 -1
  208. package/dist/o-node/src/router/o-node.router.js +53 -7
  209. package/dist/o-node/src/router/resolvers/o-node.resolver.d.ts.map +1 -1
  210. package/dist/o-node/src/router/resolvers/o-node.resolver.js +5 -1
  211. package/dist/o-node/src/ui/index.d.ts +3 -0
  212. package/dist/o-node/src/ui/index.d.ts.map +1 -0
  213. package/dist/o-node/src/ui/index.js +2 -0
  214. package/dist/o-node/src/ui/types.d.ts +110 -0
  215. package/dist/o-node/src/ui/types.d.ts.map +1 -0
  216. package/dist/o-node/src/ui/types.js +17 -0
  217. package/dist/o-node/src/ui/ui-graph.manager.d.ts +70 -0
  218. package/dist/o-node/src/ui/ui-graph.manager.d.ts.map +1 -0
  219. package/dist/o-node/src/ui/ui-graph.manager.js +274 -0
  220. package/dist/o-node/src/utils/index.d.ts +0 -2
  221. package/dist/o-node/src/utils/index.d.ts.map +1 -1
  222. package/dist/o-node/src/utils/index.js +0 -2
  223. package/dist/o-node/src/utils/stream.utils.d.ts.map +1 -1
  224. package/dist/o-node/src/utils/stream.utils.js +25 -21
  225. package/dist/o-node/test/helpers/test-node.tool.d.ts +15 -0
  226. package/dist/o-node/test/helpers/test-node.tool.d.ts.map +1 -0
  227. package/dist/o-node/test/helpers/test-node.tool.js +27 -0
  228. package/dist/src/connection/o-node-connection.manager.d.ts +14 -4
  229. package/dist/src/connection/o-node-connection.manager.d.ts.map +1 -1
  230. package/dist/src/connection/o-node-connection.manager.js +61 -29
  231. package/package.json +6 -6
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object.utils.d.ts","sourceRoot":"","sources":["../../../../../o-core/src/utils/object.utils.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAW;IACtB,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO;WAIrB,YAAY,CACvB,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,GAClD,OAAO,CAAC,GAAG,CAAC;CAkBhB"}
@@ -0,0 +1,23 @@
1
+ export class ObjectUtils {
2
+ static isObject(obj) {
3
+ return obj !== null && typeof obj === 'object';
4
+ }
5
+ static async allKeyValues(obj, callback) {
6
+ if (!ObjectUtils.isObject(obj)) {
7
+ return obj;
8
+ }
9
+ for (const key in obj) {
10
+ let value = obj[key];
11
+ // iterate over the object if not a primitive
12
+ if (ObjectUtils.isObject(value)) {
13
+ value = await ObjectUtils.allKeyValues(value, callback);
14
+ }
15
+ else {
16
+ value = await callback(key, value);
17
+ }
18
+ // update the object
19
+ obj[key] = value;
20
+ }
21
+ return obj;
22
+ }
23
+ }
@@ -0,0 +1,4 @@
1
+ export declare class RegexUtils {
2
+ static extractResultFromAI(message: string): any;
3
+ }
4
+ //# sourceMappingURL=regex.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"regex.utils.d.ts","sourceRoot":"","sources":["../../../../../o-core/src/utils/regex.utils.ts"],"names":[],"mappings":"AAAA,qBAAa,UAAU;IACrB,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG;CAajD"}
@@ -0,0 +1,13 @@
1
+ export class RegexUtils {
2
+ static extractResultFromAI(message) {
3
+ // handle 4 levels of nested JSON
4
+ const match = message.match(/\{.+\}/s);
5
+ const json = match ? match[0] : null;
6
+ if (!json) {
7
+ throw new Error('AI failed to return a valid JSON object');
8
+ }
9
+ // process the result and react
10
+ const planResult = JSON.parse(json);
11
+ return planResult;
12
+ }
13
+ }
@@ -0,0 +1,4 @@
1
+ export declare class RemoteUtils {
2
+ static getRemoteAddress(): string;
3
+ }
4
+ //# sourceMappingURL=remote.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote.utils.d.ts","sourceRoot":"","sources":["../../../../../o-core/src/utils/remote.utils.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAW;IACtB,MAAM,CAAC,gBAAgB,IAAI,MAAM;CAKlC"}
@@ -0,0 +1,5 @@
1
+ export class RemoteUtils {
2
+ static getRemoteAddress() {
3
+ return (process.env.OLANE_ADDRESS || '/dns4/leader.olane.com/tcp/4000/tls/ws');
4
+ }
5
+ }
@@ -1,13 +1,13 @@
1
- import { Connection, Stream } from '@olane/o-config';
1
+ import { Connection } from '@olane/o-config';
2
2
  import { oConnection, oRequest, oResponse } from '@olane/o-core';
3
3
  import { oNodeConnectionConfig } from './interfaces/o-node-connection.config.js';
4
4
  export declare class oNodeConnection extends oConnection {
5
5
  protected readonly config: oNodeConnectionConfig;
6
6
  p2pConnection: Connection;
7
7
  constructor(config: oNodeConnectionConfig);
8
- read(source: Stream): Promise<any>;
9
8
  validate(): void;
10
9
  transmit(request: oRequest): Promise<oResponse>;
10
+ abort(error: Error): Promise<void>;
11
11
  close(): Promise<void>;
12
12
  }
13
13
  //# sourceMappingURL=o-node-connection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"o-node-connection.d.ts","sourceRoot":"","sources":["../../../../src/connection/o-node-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAIV,MAAM,EAEP,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,WAAW,EAGX,QAAQ,EACR,SAAS,EACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAEjF,qBAAa,eAAgB,SAAQ,WAAW;IAGlC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,qBAAqB;IAFrD,aAAa,EAAE,UAAU,CAAC;gBAEF,MAAM,EAAE,qBAAqB;IAKtD,IAAI,CAAC,MAAM,EAAE,MAAM;IAWzB,QAAQ;IAOF,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;IA0E/C,KAAK;CAKZ"}
1
+ {"version":3,"file":"o-node-connection.d.ts","sourceRoot":"","sources":["../../../../src/connection/o-node-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAEL,WAAW,EAGX,QAAQ,EACR,SAAS,EACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAEjF,qBAAa,eAAgB,SAAQ,WAAW;IAGlC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,qBAAqB;IAFrD,aAAa,EAAE,UAAU,CAAC;gBAEF,MAAM,EAAE,qBAAqB;IAK5D,QAAQ;IAOF,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;IAsF/C,KAAK,CAAC,KAAK,EAAE,KAAK;IAMlB,KAAK;CAKZ"}
@@ -1,4 +1,3 @@
1
- import { Uint8ArrayList, byteStream, } from '@olane/o-config';
2
1
  import { CoreUtils, oConnection, oError, oErrorCodes, oResponse, } from '@olane/o-core';
3
2
  export class oNodeConnection extends oConnection {
4
3
  constructor(config) {
@@ -6,15 +5,6 @@ export class oNodeConnection extends oConnection {
6
5
  this.config = config;
7
6
  this.p2pConnection = config.p2pConnection;
8
7
  }
9
- async read(source) {
10
- const bytes = byteStream(source);
11
- const output = await bytes.read({
12
- signal: AbortSignal.timeout(this.config.readTimeoutMs ?? 120000), // Default: 2 min timeout
13
- });
14
- const outputObj = output instanceof Uint8ArrayList ? output.subarray() : output;
15
- const jsonStr = new TextDecoder().decode(outputObj);
16
- return JSON.parse(jsonStr);
17
- }
18
8
  validate() {
19
9
  if (this.config.p2pConnection.status !== 'open') {
20
10
  throw new Error('Connection is not valid');
@@ -24,10 +14,12 @@ export class oNodeConnection extends oConnection {
24
14
  async transmit(request) {
25
15
  try {
26
16
  const stream = await this.p2pConnection.newStream(this.nextHopAddress.protocol, {
27
- maxOutboundStreams: Infinity,
17
+ signal: this.abortSignal,
18
+ maxOutboundStreams: process.env.MAX_OUTBOUND_STREAMS
19
+ ? parseInt(process.env.MAX_OUTBOUND_STREAMS)
20
+ : 1000,
28
21
  runOnLimitedConnection: true, // TODO: should this be configurable?
29
22
  });
30
- const isStreamRequest = request.params._isStream;
31
23
  if (!stream || (stream.status !== 'open' && stream.status !== 'reset')) {
32
24
  throw new oError(oErrorCodes.FAILED_TO_DIAL_TARGET, 'Failed to dial target');
33
25
  }
@@ -37,16 +29,37 @@ export class oNodeConnection extends oConnection {
37
29
  // Send the data with backpressure handling (libp2p v3 best practice)
38
30
  const data = new TextEncoder().encode(request.toString());
39
31
  const sent = stream.send(data);
40
- if (isStreamRequest) {
32
+ let lastResponse;
33
+ await new Promise((resolve, reject) => {
34
+ const abortHandler = async () => {
35
+ try {
36
+ await stream.abort(new Error('Request aborted'));
37
+ }
38
+ catch (e) {
39
+ // Stream may already be closed
40
+ }
41
+ reject(new Error('Request aborted'));
42
+ };
43
+ // Listen for abort signal
44
+ if (this.abortSignal) {
45
+ this.abortSignal.addEventListener('abort', abortHandler);
46
+ }
41
47
  stream.addEventListener('message', async (event) => {
42
48
  const response = await CoreUtils.processStreamResponse(event);
43
49
  this.emitter.emit('chunk', response);
44
50
  // marked as the last chunk let's close
45
- if (response.result._last) {
51
+ if (response.result._last || !response.result._isStreaming) {
52
+ // this.logger.debug('Last chunk received...');
53
+ lastResponse = response;
54
+ // Clean up abort listener before closing
55
+ if (this.abortSignal) {
56
+ this.abortSignal.removeEventListener('abort', abortHandler);
57
+ }
46
58
  await stream.close();
59
+ resolve(true);
47
60
  }
48
61
  });
49
- }
62
+ });
50
63
  // If send() returns false, wait for the stream to drain before continuing
51
64
  if (!sent) {
52
65
  this.logger.debug('Stream buffer full, waiting for drain...');
@@ -54,15 +67,10 @@ export class oNodeConnection extends oConnection {
54
67
  signal: AbortSignal.timeout(this.config.drainTimeoutMs ?? 30000),
55
68
  }); // Default: 30 second timeout
56
69
  }
57
- if (isStreamRequest) {
58
- return Promise.resolve(CoreUtils.buildResponse(request, 'request is streaming, this response is not used', null));
70
+ if (stream.status === 'open') {
71
+ await stream.abort(new Error('Connection closed'));
59
72
  }
60
- const res = await this.read(stream);
61
- await stream.close();
62
- // process the response
63
- const response = new oResponse({
64
- ...res.result,
65
- });
73
+ const response = oResponse.fromJSON(lastResponse);
66
74
  return response;
67
75
  }
68
76
  catch (error) {
@@ -72,6 +80,11 @@ export class oNodeConnection extends oConnection {
72
80
  throw error;
73
81
  }
74
82
  }
83
+ async abort(error) {
84
+ this.logger.debug('Aborting connection');
85
+ await this.p2pConnection.abort(error);
86
+ this.logger.debug('Connection aborted');
87
+ }
75
88
  async close() {
76
89
  this.logger.debug('Closing connection');
77
90
  await this.p2pConnection.close();
@@ -1 +1 @@
1
- {"version":3,"file":"o-node-connection.manager.d.ts","sourceRoot":"","sources":["../../../../src/connection/o-node-connection.manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,4BAA4B,EAAE,MAAM,kDAAkD,CAAC;AAEhG,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,sBAAuB,SAAQ,kBAAkB;IAC5D,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,oBAAoB,CAAC,CAAS;IACtC,OAAO,CAAC,qBAAqB,CAAC,CAAS;gBAE3B,MAAM,EAAE,4BAA4B;IAOhD;;;;OAIG;IACG,OAAO,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC;IA8FlE,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO;IAIpC,mBAAmB,CAAC,OAAO,EAAE,QAAQ,GAAG,WAAW,GAAG,IAAI;CAe3D"}
1
+ {"version":3,"file":"o-node-connection.manager.d.ts","sourceRoot":"","sources":["../../../../src/connection/o-node-connection.manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,4BAA4B,EAAE,MAAM,kDAAkD,CAAC;AAEhG,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,sBAAuB,SAAQ,kBAAkB;IAC5D,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,oBAAoB,CAAC,CAAS;IACtC,OAAO,CAAC,qBAAqB,CAAC,CAAS;gBAE3B,MAAM,EAAE,4BAA4B;IAOhD;;;;OAIG;IACG,OAAO,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC;IAmDlE,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO;IAIpC,mBAAmB,CAAC,OAAO,EAAE,QAAQ,GAAG,WAAW,GAAG,IAAI;CAe3D"}
@@ -29,47 +29,19 @@ export class oNodeConnectionManager extends oConnectionManager {
29
29
  }
30
30
  }
31
31
  // Retry configuration for handling transient connection failures
32
- const MAX_RETRIES = 3;
33
- const BASE_DELAY_MS = 1000; // Start with 1 second
34
- const MAX_DELAY_MS = 10000; // Cap at 10 seconds
35
- // first time setup connection with retry logic
36
- let lastError;
37
- for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
38
- try {
39
- if (attempt > 0) {
40
- // Calculate exponential backoff delay: 1s, 2s, 4s, 8s (capped at MAX_DELAY_MS)
41
- const delay = Math.min(BASE_DELAY_MS * Math.pow(2, attempt - 1), MAX_DELAY_MS);
42
- this.logger.debug(`Retry attempt ${attempt}/${MAX_RETRIES} for ${nextHopAddress.toString()} after ${delay}ms delay`);
43
- await new Promise((resolve) => setTimeout(resolve, delay));
44
- }
45
- const p2pConnection = await this.p2pNode.dial(nextHopAddress.libp2pTransports.map((ma) => ma.toMultiaddr()));
46
- const connection = new oNodeConnection({
47
- nextHopAddress: nextHopAddress,
48
- address: address,
49
- p2pConnection: p2pConnection,
50
- callerAddress: callerAddress,
51
- readTimeoutMs: readTimeoutMs ?? this.defaultReadTimeoutMs,
52
- drainTimeoutMs: drainTimeoutMs ?? this.defaultDrainTimeoutMs,
53
- isStream: config.isStream || false,
54
- });
55
- if (attempt > 0) {
56
- this.logger.info(`Successfully connected to ${nextHopAddress.toString()} on retry attempt ${attempt}`);
57
- }
58
- // this.cache.set(nextHopAddress.toString(), connection);
59
- return connection;
60
- }
61
- catch (error) {
62
- lastError = error;
63
- this.logger.warn(`[${callerAddress?.toString() || 'unknown'}] Connection attempt ${attempt + 1}/${MAX_RETRIES + 1} failed for ${nextHopAddress.toString()}: ${error instanceof Error ? error.message : String(error)}`);
64
- // Don't retry on the last attempt
65
- if (attempt === MAX_RETRIES) {
66
- break;
67
- }
68
- }
69
- }
70
- // All retries exhausted
71
- this.logger.error(`[${callerAddress?.toString() || 'unknown'}] Failed to connect after ${MAX_RETRIES + 1} attempts to address! Next hop: ${nextHopAddress} With Address: ${address.toString()}`, lastError);
72
- throw lastError;
32
+ const p2pConnection = await this.p2pNode.dial(nextHopAddress.libp2pTransports.map((ma) => ma.toMultiaddr()));
33
+ const connection = new oNodeConnection({
34
+ nextHopAddress: nextHopAddress,
35
+ address: address,
36
+ p2pConnection: p2pConnection,
37
+ callerAddress: callerAddress,
38
+ readTimeoutMs: readTimeoutMs ?? this.defaultReadTimeoutMs,
39
+ drainTimeoutMs: drainTimeoutMs ?? this.defaultDrainTimeoutMs,
40
+ isStream: config.isStream ?? false,
41
+ abortSignal: config.abortSignal,
42
+ });
43
+ // this.cache.set(nextHopAddress.toString(), connection);
44
+ return connection;
73
45
  }
74
46
  isCached(address) {
75
47
  return this.cache.has(address.toString());
@@ -8,4 +8,5 @@ export * from './nodes/index.js';
8
8
  export * from './interfaces/o-node.tool-config.js';
9
9
  export * from './router/index.js';
10
10
  export * from './connection/o-stream.request.js';
11
+ export * from './ui/index.js';
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oCAAoC,CAAC;AACnD,cAAc,mBAAmB,CAAC;AAClC,cAAc,kCAAkC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oCAAoC,CAAC;AACnD,cAAc,mBAAmB,CAAC;AAClC,cAAc,kCAAkC,CAAC;AACjD,cAAc,eAAe,CAAC"}
@@ -8,3 +8,4 @@ export * from './nodes/index.js';
8
8
  export * from './interfaces/o-node.tool-config.js';
9
9
  export * from './router/index.js';
10
10
  export * from './connection/o-stream.request.js';
11
+ export * from './ui/index.js';
@@ -29,23 +29,6 @@ export interface oNodeConfig extends oCoreConfig {
29
29
  parentDiscoveryIntervalMs?: number;
30
30
  parentDiscoveryMaxDelayMs?: number;
31
31
  };
32
- /**
33
- * Leader request retry configuration
34
- * Handles temporary leader unavailability (healing, maintenance)
35
- */
36
- leaderRetry?: {
37
- enabled?: boolean;
38
- maxAttempts?: number;
39
- baseDelayMs?: number;
40
- maxDelayMs?: number;
41
- timeoutMs?: number;
42
- circuitBreaker?: {
43
- enabled?: boolean;
44
- failureThreshold?: number;
45
- openTimeoutMs?: number;
46
- halfOpenMaxAttempts?: number;
47
- };
48
- };
49
32
  /**
50
33
  * Connection timeout configuration
51
34
  * Controls timeouts for stream read and drain operations in connections
@@ -1 +1 @@
1
- {"version":3,"file":"o-node.config.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/o-node.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eA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@ -37,6 +37,7 @@ export declare class oConnectionHeartbeatManager extends oObject {
37
37
  private config;
38
38
  private heartbeatInterval?;
39
39
  private healthMap;
40
+ private isRunning;
40
41
  constructor(node: IHeartbeatableNode, config: HeartbeatConfig);
41
42
  start(): Promise<void>;
42
43
  stop(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"o-connection-heartbeat.manager.d.ts","sourceRoot":"","sources":["../../../../src/managers/o-connection-heartbeat.manager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAOR,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAE3E,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,MAAM,CAAC;IAC3B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,SAAS,GAAG,UAAU,GAAG,MAAM,CAAC;CACzC;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,2BAA4B,SAAQ,OAAO;IAKpD,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,MAAM;IALhB,OAAO,CAAC,iBAAiB,CAAC,CAAiB;IAC3C,OAAO,CAAC,SAAS,CAAuC;gBAG9C,IAAI,EAAE,kBAAkB,EACxB,MAAM,EAAE,eAAe;IAK3B,KAAK;IAqBL,IAAI;YAQI,qBAAqB;IAyCnC,OAAO,CAAC,MAAM;YASA,UAAU;IAuFxB,OAAO,CAAC,oBAAoB;IAyD5B,OAAO,CAAC,2BAA2B;IAmBnC,OAAO,CAAC,4BAA4B;IAiBpC;;OAEG;IACH,eAAe,IAAI,gBAAgB,EAAE;IAIrC;;OAEG;IACH,mBAAmB,CAAC,OAAO,EAAE,YAAY,GAAG,gBAAgB,GAAG,SAAS;IAIxE;;OAEG;IACH,SAAS,IAAI,eAAe;CAG7B"}
1
+ {"version":3,"file":"o-connection-heartbeat.manager.d.ts","sourceRoot":"","sources":["../../../../src/managers/o-connection-heartbeat.manager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAOR,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAE3E,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,MAAM,CAAC;IAC3B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,SAAS,GAAG,UAAU,GAAG,MAAM,CAAC;CACzC;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,2BAA4B,SAAQ,OAAO;IAMpD,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,MAAM;IANhB,OAAO,CAAC,iBAAiB,CAAC,CAAiB;IAC3C,OAAO,CAAC,SAAS,CAAuC;IACxD,OAAO,CAAC,SAAS,CAAS;gBAGhB,IAAI,EAAE,kBAAkB,EACxB,MAAM,EAAE,eAAe;IAK3B,KAAK;IAqBL,IAAI;YAQI,qBAAqB;IAgDnC,OAAO,CAAC,MAAM;YAcA,UAAU;IAuFxB,OAAO,CAAC,oBAAoB;IAyD5B,OAAO,CAAC,2BAA2B;IAmBnC,OAAO,CAAC,4BAA4B;IAiBpC;;OAEG;IACH,eAAe,IAAI,gBAAgB,EAAE;IAIrC;;OAEG;IACH,mBAAmB,CAAC,OAAO,EAAE,YAAY,GAAG,gBAAgB,GAAG,SAAS;IAIxE;;OAEG;IACH,SAAS,IAAI,eAAe;CAG7B"}
@@ -1,4 +1,4 @@
1
- import { oObject, ChildLeftEvent, ParentDisconnectedEvent, LeaderDisconnectedEvent, ConnectionDegradedEvent, ConnectionRecoveredEvent, } from '@olane/o-core';
1
+ import { oObject, ChildLeftEvent, ParentDisconnectedEvent, LeaderDisconnectedEvent, ConnectionDegradedEvent, ConnectionRecoveredEvent, oAddress, } from '@olane/o-core';
2
2
  /**
3
3
  * Connection Heartbeat Manager
4
4
  *
@@ -19,6 +19,7 @@ export class oConnectionHeartbeatManager extends oObject {
19
19
  this.node = node;
20
20
  this.config = config;
21
21
  this.healthMap = new Map();
22
+ this.isRunning = false;
22
23
  }
23
24
  async start() {
24
25
  if (!this.config.enabled) {
@@ -40,6 +41,10 @@ export class oConnectionHeartbeatManager extends oObject {
40
41
  this.healthMap.clear();
41
42
  }
42
43
  async performHeartbeatCycle() {
44
+ if (!this.isRunning) {
45
+ return;
46
+ }
47
+ this.isRunning = true;
43
48
  const targets = [];
44
49
  // Check if this is a leader node (no leader in hierarchy = we are leader)
45
50
  const isLeaderNode = this.node.getLeaders().length === 0;
@@ -55,7 +60,8 @@ export class oConnectionHeartbeatManager extends oObject {
55
60
  // Use this.node.parent getter to get the current parent address with transports
56
61
  // rather than getParents() which may have a stale reference
57
62
  const parent = this.node.parent;
58
- if (parent) {
63
+ // make sure that we don't double ping the leader
64
+ if (parent && parent?.toString() !== oAddress.leader().toString()) {
59
65
  targets.push({ address: parent, role: 'parent' });
60
66
  }
61
67
  }
@@ -68,12 +74,20 @@ export class oConnectionHeartbeatManager extends oObject {
68
74
  }
69
75
  // Ping all targets in parallel
70
76
  await Promise.allSettled(targets.map((target) => this.pingTarget(target.address, target.role)));
77
+ this.isRunning = false;
71
78
  }
72
79
  doPing(address) {
73
80
  if (address.toString() === this.node.address.toString()) {
74
81
  return Promise.resolve();
75
82
  }
76
- return this.node.p2pNode.services.ping.ping(address.libp2pTransports[0].toMultiaddr());
83
+ const transport = address.libp2pTransports[0].toMultiaddr();
84
+ if (transport.toString().indexOf('p2p-circuit') > -1) {
85
+ return this.node.use(address, {
86
+ method: 'ping',
87
+ params: {},
88
+ });
89
+ }
90
+ return this.node.p2pNode.services.ping.ping(transport);
77
91
  }
78
92
  async pingTarget(address, role) {
79
93
  if (!address.libp2pTransports.length) {
@@ -3,14 +3,13 @@ import { PeerId } from '@olane/o-config';
3
3
  import { oNodeHierarchyManager } from './o-node.hierarchy-manager.js';
4
4
  import { oNodeConfig } from './interfaces/o-node.config.js';
5
5
  import { oNodeTransport } from './router/o-node.transport.js';
6
- import { oAddress, oRequest, oNotificationManager } from '@olane/o-core';
6
+ import { oRequest, oNotificationManager } from '@olane/o-core';
7
7
  import { oNodeAddress } from './router/o-node.address.js';
8
8
  import { oNodeConnection } from './connection/o-node-connection.js';
9
9
  import { oNodeConnectionManager } from './connection/o-node-connection.manager.js';
10
10
  import { oToolBase } from '@olane/o-tool';
11
11
  import { oConnectionHeartbeatManager } from './managers/o-connection-heartbeat.manager.js';
12
12
  import { oReconnectionManager } from './managers/o-reconnection.manager.js';
13
- import { LeaderRequestWrapper } from './utils/leader-request-wrapper.js';
14
13
  import { oNodeConnectionConfig } from './connection/index.js';
15
14
  export declare class oNode extends oToolBase {
16
15
  peerId: PeerId;
@@ -21,7 +20,6 @@ export declare class oNode extends oToolBase {
21
20
  hierarchyManager: oNodeHierarchyManager;
22
21
  connectionHeartbeatManager?: oConnectionHeartbeatManager;
23
22
  reconnectionManager?: oReconnectionManager;
24
- leaderRequestWrapper: LeaderRequestWrapper;
25
23
  protected didRegister: boolean;
26
24
  constructor(config: oNodeConfig);
27
25
  get leader(): oNodeAddress | null;
@@ -55,19 +53,20 @@ export declare class oNode extends oToolBase {
55
53
  /**
56
54
  * Override use() to wrap leader/registry requests with retry logic
57
55
  */
58
- use(address: oAddress, data?: {
59
- method?: string;
60
- params?: {
61
- [key: string]: any;
62
- };
63
- id?: string;
64
- }, options?: {
65
- noRouting?: boolean;
66
- }): Promise<any>;
67
56
  teardown(): Promise<void>;
68
57
  getLeaders(): oNodeAddress[];
69
58
  getParents(): oNodeAddress[];
70
59
  getChildren(): oNodeAddress[];
71
60
  removeChild(childAddress: oNodeAddress): void;
61
+ /**
62
+ * Get the total number of active streams across all connections
63
+ * @returns Total count of active streams
64
+ */
65
+ getStreamCount(): number;
66
+ /**
67
+ * Get libp2p metrics for this node
68
+ * Tool method that can be called remotely by monitoring systems
69
+ */
70
+ _tool_get_libp2p_metrics(request: oRequest): Promise<any>;
72
71
  }
73
72
  //# sourceMappingURL=o-node.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"o-node.d.ts","sourceRoot":"","sources":["../../../src/o-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,MAAM,EACN,YAAY,EACb,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAIL,QAAQ,EACR,QAAQ,EAER,oBAAoB,EAErB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAA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CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;CAwEhE"}
@@ -12,7 +12,6 @@ import { oLeaderResolverFallback } from './router/index.js';
12
12
  import { oNodeNotificationManager } from './o-node.notification-manager.js';
13
13
  import { oConnectionHeartbeatManager } from './managers/o-connection-heartbeat.manager.js';
14
14
  import { oReconnectionManager } from './managers/o-reconnection.manager.js';
15
- import { LeaderRequestWrapper } from './utils/leader-request-wrapper.js';
16
15
  export class oNode extends oToolBase {
17
16
  constructor(config) {
18
17
  super(config);
@@ -103,7 +102,9 @@ export class oNode extends oToolBase {
103
102
  peerId: this.peerId.toString(),
104
103
  },
105
104
  };
106
- await this.use(address, params);
105
+ this.use(address, params).catch((error) => {
106
+ this.logger.error('Failed to unregister from network:', error);
107
+ });
107
108
  }
108
109
  async registerParent() {
109
110
  if (this.type === NodeType.LEADER) {
@@ -123,7 +124,7 @@ export class oNode extends oToolBase {
123
124
  // if no parent transports, register with the parent to get them
124
125
  // TODO: should we remove the transports check to make this more consistent?
125
126
  if (this.config.parent) {
126
- this.logger.debug('Registering node with parent...', this.config.parent);
127
+ this.logger.debug('Registering node with parent...', this.config.parent?.toString());
127
128
  await this.use(this.config.parent, {
128
129
  method: 'child_register',
129
130
  params: {
@@ -243,6 +244,10 @@ export class oNode extends oToolBase {
243
244
  if (this.hierarchyManager.children.some((c) => c.libp2pTransports.some((t) => t.toPeerId() === peerId.toString()))) {
244
245
  return false;
245
246
  }
247
+ // check for standalone node
248
+ if (!this.config.parent && !this.config.leader) {
249
+ return false;
250
+ }
246
251
  return true;
247
252
  },
248
253
  // who can call us?
@@ -346,28 +351,11 @@ export class oNode extends oToolBase {
346
351
  await this.initializeRouter();
347
352
  // need to wait until our libpp2 node is initialized before calling super.initialize
348
353
  await super.initialize();
349
- this.logger.debug('Node initializedddd!', this.transports.map((t) => t.toString()));
354
+ this.logger.debug('Node initialized!', this.transports.map((t) => t.toString()));
350
355
  this.address.setTransports(this.transports);
351
356
  this.peerId = this.p2pNode.peerId;
352
357
  // initialize connection manager
353
358
  await this.initConnectionManager();
354
- // Initialize leader request wrapper with circuit breaker
355
- this.leaderRequestWrapper = new LeaderRequestWrapper({
356
- enabled: this.config.leaderRetry?.enabled ?? true,
357
- maxAttempts: this.config.leaderRetry?.maxAttempts ?? 20,
358
- baseDelayMs: this.config.leaderRetry?.baseDelayMs ?? 2000,
359
- maxDelayMs: this.config.leaderRetry?.maxDelayMs ?? 30000,
360
- timeoutMs: this.config.leaderRetry?.timeoutMs ?? 120000,
361
- circuitBreaker: {
362
- enabled: this.config.leaderRetry?.circuitBreaker?.enabled ?? true,
363
- failureThreshold: this.config.leaderRetry?.circuitBreaker?.failureThreshold ?? 3,
364
- openTimeoutMs: this.config.leaderRetry?.circuitBreaker?.openTimeoutMs ?? 30000,
365
- halfOpenMaxAttempts: this.config.leaderRetry?.circuitBreaker?.halfOpenMaxAttempts ?? 1,
366
- },
367
- });
368
- this.logger.info(`Leader retry config: enabled=${this.leaderRequestWrapper.getConfig().enabled}, ` +
369
- `maxAttempts=${this.leaderRequestWrapper.getConfig().maxAttempts}, ` +
370
- `circuitBreaker.enabled=${this.leaderRequestWrapper.getConfig().circuitBreaker?.enabled}`);
371
359
  // initialize address resolution
372
360
  this.router.addResolver(new oMethodResolver(this.address));
373
361
  this.router.addResolver(new oNodeResolver(this.address));
@@ -383,10 +371,20 @@ export class oNode extends oToolBase {
383
371
  /**
384
372
  * Override use() to wrap leader/registry requests with retry logic
385
373
  */
386
- async use(address, data, options) {
387
- // Wrap leader/registry requests with retry logic
388
- return this.leaderRequestWrapper.execute(() => super.use(address, data, { noRouting: options?.noRouting ?? false }), address, data?.method);
389
- }
374
+ // async use(
375
+ // address: oAddress,
376
+ // data?: {
377
+ // method?: string;
378
+ // params?: { [key: string]: any };
379
+ // id?: string;
380
+ // },
381
+ // options?: UseOptions,
382
+ // ): Promise<any> {
383
+ // // Wrap leader/registry requests with retry logic
384
+ // return super.use(address, data, options),
385
+ // address,
386
+ // data?.method,
387
+ // }
390
388
  async teardown() {
391
389
  // Stop heartbeat before parent teardown
392
390
  if (this.connectionHeartbeatManager) {
@@ -411,4 +409,85 @@ export class oNode extends oToolBase {
411
409
  removeChild(childAddress) {
412
410
  this.hierarchyManager.removeChild(childAddress);
413
411
  }
412
+ /**
413
+ * Get the total number of active streams across all connections
414
+ * @returns Total count of active streams
415
+ */
416
+ getStreamCount() {
417
+ if (!this.p2pNode) {
418
+ return 0;
419
+ }
420
+ const connections = this.p2pNode.getConnections();
421
+ return connections.reduce((count, conn) => {
422
+ return count + (conn.streams?.length || 0);
423
+ }, 0);
424
+ }
425
+ /**
426
+ * Get libp2p metrics for this node
427
+ * Tool method that can be called remotely by monitoring systems
428
+ */
429
+ async _tool_get_libp2p_metrics(request) {
430
+ if (!this.p2pNode) {
431
+ return {
432
+ error: 'libp2p node not available',
433
+ available: false,
434
+ };
435
+ }
436
+ try {
437
+ // Get basic connection stats
438
+ const connections = this.p2pNode.getConnections();
439
+ const peers = await this.p2pNode.peerStore.all();
440
+ const inbound = connections.filter((c) => c.direction === 'inbound').length;
441
+ const outbound = connections.filter((c) => c.direction === 'outbound').length;
442
+ // Get DHT info if available
443
+ const services = this.p2pNode.services;
444
+ const dht = services?.dht;
445
+ const routingTable = dht?.routingTable;
446
+ const kBuckets = routingTable?.kb || null;
447
+ let routingTableSize = 0;
448
+ if (kBuckets) {
449
+ // Handle both array and object-like structures
450
+ if (Array.isArray(kBuckets)) {
451
+ for (const bucket of kBuckets) {
452
+ routingTableSize += bucket.peers?.length || 0;
453
+ }
454
+ }
455
+ else if (typeof kBuckets === 'object') {
456
+ // If it's an object, iterate over its values
457
+ for (const bucket of Object.values(kBuckets)) {
458
+ routingTableSize += bucket?.peers?.length || 0;
459
+ }
460
+ }
461
+ }
462
+ // Calculate total stream count across all connections
463
+ const streamCount = connections.reduce((count, conn) => {
464
+ return count + (conn.streams?.length || 0);
465
+ }, 0);
466
+ return {
467
+ available: true,
468
+ timestamp: Date.now(),
469
+ nodeAddress: this.address.toString(),
470
+ peerCount: peers.length,
471
+ connectionCount: connections.length,
472
+ inboundConnections: inbound,
473
+ outboundConnections: outbound,
474
+ streamCount,
475
+ dhtEnabled: !!dht,
476
+ dhtMode: dht?.clientMode ? 'client' : 'server',
477
+ dhtRoutingTableSize: routingTableSize,
478
+ protocols: Array.from(this.p2pNode.getProtocols()),
479
+ selfPeerId: this.p2pNode.peerId.toString(),
480
+ multiaddrs: this.p2pNode
481
+ .getMultiaddrs()
482
+ .map((ma) => ma.toString()),
483
+ };
484
+ }
485
+ catch (error) {
486
+ return {
487
+ error: `Failed to collect libp2p metrics: ${error.message}`,
488
+ available: false,
489
+ nodeAddress: this.address.toString(),
490
+ };
491
+ }
492
+ }
414
493
  }