@olane/o-core 0.4.4 → 0.6.1

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 (76) hide show
  1. package/dist/src/core/core.node.d.ts +1 -1
  2. package/dist/src/core/core.node.d.ts.map +1 -1
  3. package/dist/src/core/core.node.js +7 -3
  4. package/dist/src/core/lib/o-address-resolution.d.ts.map +1 -1
  5. package/dist/src/core/lib/o-address-resolution.js +3 -4
  6. package/dist/src/core/lib/o-request.d.ts +2 -0
  7. package/dist/src/core/lib/o-request.d.ts.map +1 -1
  8. package/dist/src/core/lib/o-request.js +9 -0
  9. package/dist/src/core/lib/resolvers/anything.resolver.d.ts.map +1 -1
  10. package/dist/src/core/lib/resolvers/anything.resolver.js +2 -1
  11. package/dist/src/core/utils/network.utils.d.ts.map +1 -1
  12. package/dist/src/core/utils/network.utils.js +0 -1
  13. package/dist/src/error/tool.error.d.ts +2 -0
  14. package/dist/src/error/tool.error.d.ts.map +1 -1
  15. package/dist/src/error/tool.error.js +10 -0
  16. package/dist/src/index.d.ts +1 -0
  17. package/dist/src/index.d.ts.map +1 -1
  18. package/dist/src/index.js +1 -0
  19. package/dist/src/node/node.d.ts +4 -4
  20. package/dist/src/node/node.d.ts.map +1 -1
  21. package/dist/src/node/node.js +29 -32
  22. package/dist/src/plan/agent.plan.d.ts +2 -1
  23. package/dist/src/plan/agent.plan.d.ts.map +1 -1
  24. package/dist/src/plan/agent.plan.js +55 -33
  25. package/dist/src/plan/interfaces/configure.result.d.ts +6 -0
  26. package/dist/src/plan/interfaces/configure.result.d.ts.map +1 -0
  27. package/dist/src/plan/interfaces/configure.result.js +1 -0
  28. package/dist/src/plan/interfaces/handshake.result.d.ts +14 -0
  29. package/dist/src/plan/interfaces/handshake.result.d.ts.map +1 -0
  30. package/dist/src/plan/interfaces/handshake.result.js +1 -0
  31. package/dist/src/plan/interfaces/plan-config.interface.d.ts +3 -1
  32. package/dist/src/plan/interfaces/plan-config.interface.d.ts.map +1 -1
  33. package/dist/src/plan/interfaces/plan-type.enum.d.ts +2 -1
  34. package/dist/src/plan/interfaces/plan-type.enum.d.ts.map +1 -1
  35. package/dist/src/plan/interfaces/plan-type.enum.js +1 -0
  36. package/dist/src/plan/interfaces/plan.result.d.ts +4 -4
  37. package/dist/src/plan/interfaces/plan.result.d.ts.map +1 -1
  38. package/dist/src/plan/o-plan.d.ts +3 -1
  39. package/dist/src/plan/o-plan.d.ts.map +1 -1
  40. package/dist/src/plan/o-plan.js +52 -45
  41. package/dist/src/plan/prompts/agent.prompt.d.ts +1 -1
  42. package/dist/src/plan/prompts/agent.prompt.d.ts.map +1 -1
  43. package/dist/src/plan/prompts/agent.prompt.js +31 -14
  44. package/dist/src/plan/prompts/configure.prompt.d.ts +1 -1
  45. package/dist/src/plan/prompts/configure.prompt.d.ts.map +1 -1
  46. package/dist/src/plan/prompts/configure.prompt.js +34 -49
  47. package/dist/src/plan/prompts/custom.prompt.d.ts +1 -1
  48. package/dist/src/plan/prompts/custom.prompt.d.ts.map +1 -1
  49. package/dist/src/plan/prompts/custom.prompt.js +31 -6
  50. package/dist/src/plan/search/search.plan.d.ts.map +1 -1
  51. package/dist/src/plan/search/search.plan.js +15 -8
  52. package/dist/src/plan/use/use.plan.d.ts +3 -0
  53. package/dist/src/plan/use/use.plan.d.ts.map +1 -1
  54. package/dist/src/plan/use/use.plan.js +116 -38
  55. package/dist/src/utils/index.d.ts +3 -0
  56. package/dist/src/utils/index.d.ts.map +1 -0
  57. package/dist/src/utils/index.js +2 -0
  58. package/dist/src/utils/object.utils.d.ts +5 -0
  59. package/dist/src/utils/object.utils.d.ts.map +1 -0
  60. package/dist/src/utils/object.utils.js +23 -0
  61. package/dist/src/utils/regex.utils.d.ts +4 -0
  62. package/dist/src/utils/regex.utils.d.ts.map +1 -0
  63. package/dist/src/utils/regex.utils.js +13 -0
  64. package/package.json +6 -3
  65. package/dist/src/plan/configure/configure.plan.d.ts +0 -11
  66. package/dist/src/plan/configure/configure.plan.d.ts.map +0 -1
  67. package/dist/src/plan/configure/configure.plan.js +0 -15
  68. package/dist/src/plan/error/error.plan.d.ts +0 -11
  69. package/dist/src/plan/error/error.plan.d.ts.map +0 -1
  70. package/dist/src/plan/error/error.plan.js +0 -20
  71. package/dist/src/plan/prompts/error.prompt.d.ts +0 -2
  72. package/dist/src/plan/prompts/error.prompt.d.ts.map +0 -1
  73. package/dist/src/plan/prompts/error.prompt.js +0 -39
  74. package/dist/src/plan/prompts/search.prompt.d.ts +0 -2
  75. package/dist/src/plan/prompts/search.prompt.d.ts.map +0 -1
  76. package/dist/src/plan/prompts/search.prompt.js +0 -43
@@ -52,7 +52,7 @@ export declare abstract class oCoreNode {
52
52
  * @param config
53
53
  * @returns
54
54
  */
55
- use(addressWithLeaderTransports: oAddress, data: {
55
+ use(addressWithLeaderTransports: oAddress, data?: {
56
56
  method?: string;
57
57
  params?: {
58
58
  [key: string]: any;
@@ -1 +1 @@
1
- {"version":3,"file":"core.node.d.ts","sourceRoot":"","sources":["../../../src/core/core.node.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EACN,YAAY,EACZ,SAAS,EAET,MAAM,EACP,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE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;IAsCvC,8BAA8B,CAClC,YAAY,EAAE,QAAQ,GACrB,OAAO,CAAC,QAAQ,CAAC;IAgCd,gBAAgB,CAAC,2BAA2B,EAAE,QAAQ,GAAG,OAAO,CAAC;QACrE,cAAc,EAAE,QAAQ,CAAC;QACzB,aAAa,EAAE,QAAQ,CAAC;KACzB,CAAC;IAiCF,iBAAiB,CAAC,2BAA2B,EAAE,QAAQ,GAAG,OAAO;IAuBjE;;;;;;OAMG;IACG,GAAG,CACP,2BAA2B,EAAE,QAAQ,EACrC,IAAI,CAAC,EAAE;QACL,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;SAAE,CAAC;KACjC,GACA,OAAO,CAAC,SAAS,CAAC;IA4Bf,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAsB3B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAgCzB,OAAO,CACX,cAAc,EAAE,QAAQ,EACxB,aAAa,EAAE,QAAQ,GACtB,OAAO,CAAC,WAAW,CAAC;IA2BV,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAQtC;;;OAGG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAuBnC;;OAEG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAanC"}
@@ -5,6 +5,7 @@ import { Logger } from './utils/logger.js';
5
5
  import { NodeType } from './interfaces/node-type.enum.js';
6
6
  import { oAddressResolution } from './lib/o-address-resolution.js';
7
7
  import { oDependency } from './o-dependency.js';
8
+ import { oToolError } from '../error/tool.error.js';
8
9
  export class oCoreNode {
9
10
  constructor(config) {
10
11
  this.config = config;
@@ -165,14 +166,17 @@ export class oCoreNode {
165
166
  throw new Error('Invalid address');
166
167
  }
167
168
  const { nextHopAddress, targetAddress } = await this.translateAddress(addressWithLeaderTransports);
168
- this.logger.debug('Using address, target: ', targetAddress.toString(), 'nextHop: ', nextHopAddress.toString(), 'with transports: ', nextHopAddress.libp2pTransports);
169
169
  const connection = await this.connect(nextHopAddress, targetAddress);
170
- this.logger.debug('Connected to: ', targetAddress.toString(), ' sending data: ', data);
171
170
  // communicate the payload to the target node
172
171
  const response = await connection.send({
173
172
  address: targetAddress?.toString() || '',
174
- payload: data,
173
+ payload: data || {},
175
174
  });
175
+ // if there is an error, throw it to continue to bubble up
176
+ if (response.result.error) {
177
+ console.log('response.result.error', JSON.stringify(response.result.error, null, 2));
178
+ throw oToolError.fromJSON(response.result.error);
179
+ }
176
180
  return response;
177
181
  }
178
182
  async unregister() {
@@ -1 +1 @@
1
- {"version":3,"file":"o-address-resolution.d.ts","sourceRoot":"","sources":["../../../../src/core/lib/o-address-resolution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA0B;IAEpD,WAAW,CAAC,QAAQ,EAAE,gBAAgB;IAItC,iBAAiB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO;IAQvC,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;CAWpD"}
1
+ {"version":3,"file":"o-address-resolution.d.ts","sourceRoot":"","sources":["../../../../src/core/lib/o-address-resolution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA0B;IAEpD,WAAW,CAAC,QAAQ,EAAE,gBAAgB;IAItC,iBAAiB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO;IAWvC,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;CAOpD"}
@@ -7,6 +7,9 @@ export class oAddressResolution {
7
7
  this.resolvers.push(resolver);
8
8
  }
9
9
  supportsTransport(address) {
10
+ if (address.libp2pTransports.length > 0) {
11
+ return false;
12
+ }
10
13
  return this.resolvers.some((r) => address.customTransports.some((t) => {
11
14
  return r.transports.includes(t);
12
15
  }));
@@ -16,10 +19,6 @@ export class oAddressResolution {
16
19
  for (const resolver of this.resolvers) {
17
20
  resolvedAddress = await resolver.resolve(resolvedAddress);
18
21
  }
19
- // // ensure we have the transports from the original address
20
- // if (address.transports.length > 0) {
21
- // resolvedAddress.setTransports(address.transports as Multiaddr[]);
22
- // }
23
22
  return resolvedAddress;
24
23
  }
25
24
  }
@@ -10,6 +10,8 @@ export declare class oRequest implements JSONRPCRequest {
10
10
  get connectionId(): string;
11
11
  toJSON(): JSONRPCRequest;
12
12
  toString(): string;
13
+ static hasOlaneAddress(value: string): boolean;
14
+ static extractAddresses(value: string): string[];
13
15
  static fromJSON(json: Request & {
14
16
  id: RequestId;
15
17
  }): oRequest;
@@ -1 +1 @@
1
- {"version":3,"file":"o-request.d.ts","sourceRoot":"","sources":["../../../../src/core/lib/o-request.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,cAAc,EACd,OAAO,EACP,SAAS,EACT,aAAa,EACd,MAAM,mBAAmB,CAAC;AAE3B,qBAAa,QAAS,YAAW,cAAc;IAC7C,OAAO,EAAE,OAAO,eAAe,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,aAAa,CAAC;IACtB,EAAE,EAAE,SAAS,CAAC;gBAEF,MAAM,EAAE,OAAO,GAAG;QAAE,EAAE,EAAE,SAAS,CAAA;KAAE;IAO/C,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,MAAM,IAAI,cAAc;IASxB,QAAQ;IAIR,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG;QAAE,EAAE,EAAE,SAAS,CAAA;KAAE,GAAG,QAAQ;CAG7D"}
1
+ {"version":3,"file":"o-request.d.ts","sourceRoot":"","sources":["../../../../src/core/lib/o-request.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,cAAc,EACd,OAAO,EACP,SAAS,EACT,aAAa,EACd,MAAM,mBAAmB,CAAC;AAE3B,qBAAa,QAAS,YAAW,cAAc;IAC7C,OAAO,EAAE,OAAO,eAAe,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,aAAa,CAAC;IACtB,EAAE,EAAE,SAAS,CAAC;gBAEF,MAAM,EAAE,OAAO,GAAG;QAAE,EAAE,EAAE,SAAS,CAAA;KAAE;IAO/C,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,MAAM,IAAI,cAAc;IASxB,QAAQ;IAIR,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAQ9C,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAKhD,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG;QAAE,EAAE,EAAE,SAAS,CAAA;KAAE,GAAG,QAAQ;CAG7D"}
@@ -20,6 +20,15 @@ export class oRequest {
20
20
  toString() {
21
21
  return JSON.stringify(this.toJSON());
22
22
  }
23
+ static hasOlaneAddress(value) {
24
+ return (!!value &&
25
+ typeof value === 'string' &&
26
+ !!value?.match(/o:\/\/.*(placeholder)+(?:\/[\w.-]+)+/g));
27
+ }
28
+ static extractAddresses(value) {
29
+ const matches = value.matchAll(/o:\/\/.*(placeholder)+(?:\/[\w.-]+)+/g);
30
+ return Array.from(matches, (match) => match[0]);
31
+ }
23
32
  static fromJSON(json) {
24
33
  return new oRequest(json);
25
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"anything.resolver.d.ts","sourceRoot":"","sources":["../../../../../src/core/lib/resolvers/anything.resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,8BAAsB,iBAAkB,SAAQ,gBAAgB;IAC9D,IAAI,UAAU,IAAI,MAAM,EAAE,CAEzB;IAEK,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC;CAUjE"}
1
+ {"version":3,"file":"anything.resolver.d.ts","sourceRoot":"","sources":["../../../../../src/core/lib/resolvers/anything.resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,8BAAsB,iBAAkB,SAAQ,gBAAgB;IAC9D,IAAI,UAAU,IAAI,MAAM,EAAE,CAEzB;IAEK,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC;CAYjE"}
@@ -8,7 +8,8 @@ export class oAnythingResolver extends oAddressResolver {
8
8
  const nextHopAddress = this.determineNextHopAddress(address);
9
9
  // at this point, the next-hop resolver did not work so we can trust that the
10
10
  // next hop should be contained within the current node as an abstraction
11
- this.logger.debug('Resolving anything address: ', address);
11
+ this.logger.debug('Resolving anything address: ', address, this.transports);
12
+ // this ADDS the transport from the custom resolver to the address
12
13
  return new oAddress(nextHopAddress.toString(), (address.transports || []).concat(this.transports));
13
14
  }
14
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"network.utils.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/network.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,qBAAa,YAAY;WACH,QAAQ,CAC1B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,QAAQ,GAChB,OAAO,CAAC;QACT,UAAU,EAAE,SAAS,EAAE,CAAC;QACxB,aAAa,EAAE,MAAM,CAAC;QACtB,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;CA0CH"}
1
+ {"version":3,"file":"network.utils.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/network.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,qBAAa,YAAY;WACH,QAAQ,CAC1B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,QAAQ,GAChB,OAAO,CAAC;QACT,UAAU,EAAE,SAAS,EAAE,CAAC;QACxB,aAAa,EAAE,MAAM,CAAC;QACtB,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;CAyCH"}
@@ -28,7 +28,6 @@ export class NetworkUtils {
28
28
  };
29
29
  }
30
30
  catch (timeoutError) {
31
- console.log('Timeout error: ', timeoutError);
32
31
  if (timeoutError.message === 'Content routing provide timeout') {
33
32
  return { transports: [], staticAddress: '', absoluteAddress: '' };
34
33
  }
@@ -13,5 +13,7 @@ export declare class oToolError extends Error implements oToolErrorInterface {
13
13
  message: string;
14
14
  details: any;
15
15
  };
16
+ static fromJSON(json: any): oToolError;
17
+ toString(): string;
16
18
  }
17
19
  //# sourceMappingURL=tool.error.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool.error.d.ts","sourceRoot":"","sources":["../../../src/error/tool.error.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,GAAG,CAAC;CACf;AAED,qBAAa,UAAW,SAAQ,KAAM,YAAW,mBAAmB;IAClE,IAAI,EAAE,MAAM,CAAK;IACjB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,OAAO,EAAE,MAAM,CAAM;gBAET,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;IAOxD,MAAM;;;;;CAOP"}
1
+ {"version":3,"file":"tool.error.d.ts","sourceRoot":"","sources":["../../../src/error/tool.error.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,GAAG,CAAC;CACf;AAED,qBAAa,UAAW,SAAQ,KAAM,YAAW,mBAAmB;IAClE,IAAI,EAAE,MAAM,CAAK;IACjB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,OAAO,EAAE,MAAM,CAAM;gBAET,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;IAOxD,MAAM;;;;;IAQN,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG;IAOzB,QAAQ;CAGT"}
@@ -1,3 +1,4 @@
1
+ import { oToolErrorCodes } from './enums/codes.error.js';
1
2
  export class oToolError extends Error {
2
3
  constructor(code, message, details) {
3
4
  super(message);
@@ -14,4 +15,13 @@ export class oToolError extends Error {
14
15
  details: this.details,
15
16
  };
16
17
  }
18
+ static fromJSON(json) {
19
+ if (json?.code && json?.message) {
20
+ return new oToolError(json.code, json.message, json.details);
21
+ }
22
+ return new oToolError(oToolErrorCodes.TOOL_ERROR, json, json?.details);
23
+ }
24
+ toString() {
25
+ return `OLANE ERROR CODE: ${this.code}\nMESSAGE: ${this.message}\n-----\nDETAILS: ${this.details}`;
26
+ }
17
27
  }
@@ -3,4 +3,5 @@ export * from './node/index.js';
3
3
  export * from './error/index.js';
4
4
  export * from './plan/index.js';
5
5
  export * from './node-virtual/index.js';
6
+ export * from './utils/index.js';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC"}
package/dist/src/index.js CHANGED
@@ -3,3 +3,4 @@ export * from './node/index.js';
3
3
  export * from './error/index.js';
4
4
  export * from './plan/index.js';
5
5
  export * from './node-virtual/index.js';
6
+ export * from './utils/index.js';
@@ -1,18 +1,18 @@
1
1
  import { Libp2pConfig, Stream } from '@olane/o-config';
2
2
  import { oAddress, oCoreNode, oRequest, oResponse } from '../core/index.js';
3
3
  import { NetworkActivity } from './lib/network-activity.lib.js';
4
- import { oPlanResult } from '../plan/interfaces/plan.result.js';
5
4
  import { CID } from 'multiformats';
5
+ import { oHandshakeResult } from '../plan/interfaces/handshake.result.js';
6
6
  export declare abstract class oNode extends oCoreNode {
7
7
  networkActivity: NetworkActivity;
8
8
  childNodes: oNode[];
9
9
  childAddresses: oAddress[];
10
10
  validate(): void;
11
- _tool_handshake(handshake: oRequest): Promise<oPlanResult>;
11
+ _tool_handshake(handshake: oRequest): Promise<oHandshakeResult>;
12
12
  abstract configureTransports(): any[];
13
- myTools(): string[];
13
+ myTools(obj?: any): string[];
14
14
  applyBridgeTransports(address: oAddress, request: oRequest): Promise<oResponse>;
15
- matchAgainstMethods(address: oAddress): boolean;
15
+ matchAgainstMethods(address: oAddress): Promise<boolean>;
16
16
  extractMethod(address: oAddress): string;
17
17
  _tool_route(request: oRequest & {
18
18
  stream: Stream;
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/node/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,YAAY,EAKZ,MAAM,EACP,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAIL,QAAQ,EAER,SAAS,EACT,QAAQ,EACR,SAAS,EACV,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAKhE,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAGhE,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAKnC,8BAAsB,KAAM,SAAQ,SAAS;IACpC,eAAe,EAAG,eAAe,CAAC;IAClC,UAAU,EAAE,KAAK,EAAE,CAAM;IACzB,cAAc,EAAE,QAAQ,EAAE,CAAM;IAEvC,QAAQ,IAAI,IAAI;IASV,eAAe,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC;IAyBhE,QAAQ,CAAC,mBAAmB,IAAI,GAAG,EAAE;IAErC,OAAO,IAAI,MAAM,EAAE;IAMb,qBAAqB,CACzB,OAAO,EAAE,QAAQ,EACjB,OAAO,EAAE,QAAQ,GAChB,OAAO,CAAC,SAAS,CAAC;IAOrB,mBAAmB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO;IAQ/C,aAAa,CAAC,OAAO,EAAE,QAAQ,GAAG,MAAM;IAIlC,WAAW,CAAC,OAAO,EAAE,QAAQ,GAAG;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,CAAC;IAyEvE;;;;OAIG;IACG,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IA2B7C,oBAAoB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAA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';
7
7
  import { oAgentPlan } from '../plan/agent.plan.js';
8
8
  import { oPlanContext } from '../plan/plan.context.js';
9
- import { oConfigurePlan } from '../plan/configure/configure.plan.js';
10
9
  import { v4 as uuidv4 } from 'uuid';
11
10
  // Enable default Node.js metrics
12
11
  // collectDefaultMetrics({ register: sharedRegistry });
@@ -26,33 +25,28 @@ export class oNode extends oCoreNode {
26
25
  }
27
26
  async _tool_handshake(handshake) {
28
27
  this.logger.debug('Performing handshake with intent: ', handshake.params.intent);
29
- const pc = new oConfigurePlan({
30
- intent: `This is a handshake request. You have already found the tool to resolve the user's intent: ${this.address.toString()}. Configure the handshake for the request to use the tool with user intent: ${handshake.params.intent}`,
31
- currentNode: this,
32
- caller: this.address,
33
- context: new oPlanContext([
34
- `[Method Metadata Begin]\n${JSON.stringify(this.methods)}\n[Method Metadata End]`,
35
- `[Method Options Begin]\n${this.myTools().join(', ')}\n[Method Options End]`,
36
- ]),
37
- });
38
- const result = await pc.execute();
39
- this.logger.debug('Handshake result: ', result);
40
- if (result.error) {
41
- return result;
42
- }
43
- this.logger.debug('Handshake json: ', result.handshake);
44
- return result;
28
+ const mytools = await this.myTools();
29
+ return {
30
+ tools: mytools.filter((t) => t !== 'handshake' && t !== 'intent'),
31
+ methods: this.methods,
32
+ successes: [],
33
+ failures: [],
34
+ task: undefined,
35
+ type: 'handshake',
36
+ };
45
37
  }
46
- myTools() {
47
- return Object.getOwnPropertyNames(oNode.prototype)
38
+ myTools(obj) {
39
+ return Object.getOwnPropertyNames(obj || this.constructor.prototype)
48
40
  .filter((key) => key.startsWith('_tool_'))
41
+ .filter((key) => !!key)
49
42
  .map((key) => key.replace('_tool_', ''));
50
43
  }
51
44
  async applyBridgeTransports(address, request) {
52
45
  throw new oToolError(oToolErrorCodes.TOOL_TRANSPORT_NOT_SUPPORTED, 'Bridge transports not implemented');
53
46
  }
54
- matchAgainstMethods(address) {
55
- const methods = this.myTools();
47
+ async matchAgainstMethods(address) {
48
+ const methods = await this.myTools();
49
+ this.logger.debug('Matching against methods: ', methods);
56
50
  const method = address
57
51
  .toString()
58
52
  .replace(this.address.toString() + '/', '');
@@ -64,11 +58,11 @@ export class oNode extends oCoreNode {
64
58
  async _tool_route(request) {
65
59
  const { payload } = request.params;
66
60
  const { address } = request.params;
67
- this.logger.debug('Routing request to: ', address, ' with payload: ', payload);
61
+ this.logger.debug('Routing request to: ', address);
68
62
  const destinationAddress = new oAddress(address);
69
63
  // determine the next hop address from the encapsulated address
70
64
  const nextHopAddress = await this.addressResolution.resolve(destinationAddress);
71
- this.logger.debug('Next hop address: ', nextHopAddress.toString());
65
+ this.logger.debug('Next hop address: ', nextHopAddress.toString(), nextHopAddress.customTransports);
72
66
  // prepare the request for the destination receiver
73
67
  let forwardRequest = new oRequest({
74
68
  params: payload.params,
@@ -77,6 +71,7 @@ export class oNode extends oCoreNode {
77
71
  });
78
72
  // if the next hop is not a libp2p address, we need to communicate to it another way
79
73
  if (this.addressResolution.supportsTransport(nextHopAddress)) {
74
+ this.logger.debug('Bridge transports supported, applying custom transports...');
80
75
  return this.applyBridgeTransports(nextHopAddress, forwardRequest);
81
76
  }
82
77
  // assume the next hop is a libp2p address, so we need to set the transports and dial it
@@ -84,20 +79,21 @@ export class oNode extends oCoreNode {
84
79
  const isAtDestination = nextHopAddress.value === destinationAddress.value;
85
80
  // if we are at the destination, let's look for the closest tool that can service the request
86
81
  const transports = nextHopAddress.transports.filter((t) => typeof t !== 'string');
87
- const isMethodMatch = this.matchAgainstMethods(destinationAddress);
82
+ const isMethodMatch = await this.matchAgainstMethods(destinationAddress);
88
83
  // handle address -> method resolution
89
84
  if (isMethodMatch) {
90
85
  this.logger.debug('Method match found, forwarding to self...');
91
86
  const extractedMethod = this.extractMethod(destinationAddress);
92
- const response = await this.use(this.address, {
93
- method: payload.method || extractedMethod,
94
- params: payload.params,
95
- });
96
- if (response.result.error) {
97
- const error = response.result.error;
98
- throw new oToolError(error.code, error.message);
87
+ try {
88
+ const response = await this.use(this.address, {
89
+ method: payload.method || extractedMethod,
90
+ params: payload.params,
91
+ });
92
+ return response.result.data;
93
+ }
94
+ catch (error) {
95
+ return error;
99
96
  }
100
- return response.result.data;
101
97
  }
102
98
  const targetStream = await this.p2pNode.dialProtocol(transports, nextHopAddress.protocol);
103
99
  // if not at destination, we need to forward the request to the target
@@ -134,6 +130,7 @@ export class oNode extends oCoreNode {
134
130
  const response = await pc.execute();
135
131
  return {
136
132
  ...response,
133
+ cycles: pc.sequence.length,
137
134
  sequence: pc.sequence.map((s) => {
138
135
  return {
139
136
  reasoning: s.result?.reasoning,
@@ -2,6 +2,7 @@ import { oPlanResult } from './interfaces/plan.result.js';
2
2
  import { oPlanConfig } from './interfaces/plan-config.interface.js';
3
3
  import { oPlan } from './o-plan.js';
4
4
  import { oQueryConfig } from './interfaces/query.config.js';
5
+ import { oTaskConfig } from './interfaces/task.config.js';
5
6
  /**
6
7
  * oAgentPlan is responsible for managing the execution of plans.
7
8
  * General execution flow:
@@ -14,9 +15,9 @@ export declare class oAgentPlan extends oPlan {
14
15
  private MAX_ITERATIONS;
15
16
  private contextIdHash;
16
17
  constructor(config: oPlanConfig);
18
+ doTask(task: oTaskConfig, config: oPlanConfig): Promise<oPlanResult>;
17
19
  handleTasks(results: oPlanResult, config: oPlanConfig): Promise<oPlanResult[]>;
18
20
  handleSearch(queries: oQueryConfig[], config: oPlanConfig): Promise<any[]>;
19
- handleError(error: any, config: oPlanConfig): Promise<oPlanResult>;
20
21
  /**
21
22
  * The analysis of the intent results in a list of steps and queries to complete the intent.
22
23
  */
@@ -1 +1 @@
1
- {"version":3,"file":"agent.plan.d.ts","sourceRoot":"","sources":["../../../src/plan/agent.plan.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGpC,OAAO,EAAE,YAAY,EAAE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WAAW,EACpB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,WAAW,EAAE,CAAC;IAmBnB,YAAY,CAChB,OAAO,EAAE,YAAY,EAAE,EACvB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,GAAG,EAAE,CAAC;IAmCjB;;OAEG;IACG,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAmB7D,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC;IA6F5B,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC;CAGlC"}
@@ -2,7 +2,6 @@ import { oAddress } from '../core/index.js';
2
2
  import { oPlan } from './o-plan.js';
3
3
  import { oUsePlan } from './use/use.plan.js';
4
4
  import { oSearchPlan } from './search/search.plan.js';
5
- import { oErrorPlan } from './error/error.plan.js';
6
5
  /**
7
6
  * oAgentPlan is responsible for managing the execution of plans.
8
7
  * General execution flow:
@@ -17,6 +16,28 @@ export class oAgentPlan extends oPlan {
17
16
  this.MAX_ITERATIONS = 20;
18
17
  this.contextIdHash = {};
19
18
  }
19
+ async doTask(task, config) {
20
+ this.logger.debug('Doing task...', task);
21
+ const taskPlan = new oUsePlan({
22
+ ...config,
23
+ intent: this.config.intent,
24
+ context: this.config.context,
25
+ receiver: new oAddress(task.address),
26
+ sequence: this.sequence,
27
+ });
28
+ const taskResult = await taskPlan.execute();
29
+ this.addSequencePlan(taskPlan);
30
+ this.logger.debug('Pushed task plan to sequence: ', taskResult.result);
31
+ if (taskResult.error) {
32
+ this.logger.debug('Task error: ', taskResult.error);
33
+ // const errorResult = await this.handleError(taskResult.error, config);
34
+ // if (errorResult.type === 'result') {
35
+ // return errorResult;
36
+ // }
37
+ // return this.doTask(task, config);
38
+ }
39
+ return taskResult;
40
+ }
20
41
  async handleTasks(results, config) {
21
42
  this.logger.debug('Handling task...', results);
22
43
  const tasks = results.tasks;
@@ -29,17 +50,8 @@ export class oAgentPlan extends oPlan {
29
50
  throw new Error('Invalid address passed to handleTask');
30
51
  }
31
52
  // perform task if necessary
32
- const taskPlan = new oUsePlan({
33
- ...config,
34
- intent: this.config.intent,
35
- context: this.config.context,
36
- receiver: new oAddress(task.address),
37
- });
38
- const taskResult = await taskPlan.execute();
39
- this.sequence.push(taskPlan);
40
- this.logger.debug('Pushed task plan to sequence: ', taskPlan.result);
41
- taskResults.push(taskResult);
42
- await this.handleError(taskResult.error, config);
53
+ const result = await this.doTask(task, config);
54
+ taskResults.push(result);
43
55
  }
44
56
  return taskResults;
45
57
  }
@@ -57,35 +69,39 @@ export class oAgentPlan extends oPlan {
57
69
  external: query?.provider === 'external',
58
70
  });
59
71
  const result = await searchPlan.execute();
60
- this.sequence.push(searchPlan);
72
+ this.addSequencePlan(searchPlan);
61
73
  this.logger.debug('Search result: ', result.result);
62
74
  results.push(result.result);
63
75
  }
64
76
  return results.flat();
65
77
  }
66
- async handleError(error, config) {
67
- this.logger.debug('Handling error...', error);
68
- const errorPlan = new oErrorPlan({
69
- ...config,
70
- error: error,
71
- });
72
- this.sequence.push(errorPlan);
73
- const result = await errorPlan.execute();
74
- return result;
75
- }
78
+ // async handleError(error: any, config: oPlanConfig): Promise<oPlanResult> {
79
+ // this.logger.debug('Handling error...', error);
80
+ // const errorPlan = new oAgentPlan({
81
+ // ...config,
82
+ // intent: `If this error is already indicating that the user intent is solved, return a result otherwise solve it. The error is: ${error}`,
83
+ // context: this.config.context,
84
+ // sequence: this.sequence,
85
+ // parentId: this.id,
86
+ // });
87
+ // const result = await errorPlan.execute();
88
+ // this.addSequencePlan(errorPlan);
89
+ // return result;
90
+ // }
76
91
  /**
77
92
  * The analysis of the intent results in a list of steps and queries to complete the intent.
78
93
  */
79
94
  async handleMultipleStep(output) {
80
- this.logger.debug('Handling analysis...', output);
81
95
  const results = [];
82
96
  for (const intent of output?.intents || []) {
83
97
  const subPlan = new oAgentPlan({
84
98
  ...this.config,
85
- intent: intent.intent,
99
+ intent: intent,
100
+ sequence: this.sequence,
101
+ parentId: this.id,
86
102
  });
87
103
  const response = await subPlan.execute();
88
- this.logger.debug('Handled multiple step intent: ', intent.intent, response);
104
+ this.addSequencePlan(subPlan);
89
105
  results.push(JSON.stringify(response));
90
106
  }
91
107
  return {
@@ -102,10 +118,9 @@ export class oAgentPlan extends oPlan {
102
118
  this.logger.debug('Plan context size: ', this.config.context?.toString()?.length);
103
119
  // setup the plan config
104
120
  const planConfig = {
105
- intent: this.config.intent,
121
+ ...this.config,
106
122
  currentNode: this.node,
107
123
  caller: this.node?.address,
108
- context: this.config.context,
109
124
  sequence: this.sequence,
110
125
  };
111
126
  // search or resolve the intent with tool usage
@@ -115,13 +130,14 @@ export class oAgentPlan extends oPlan {
115
130
  const planResult = response;
116
131
  const { error, result, type } = planResult;
117
132
  // update the sequence to reflect state change
118
- this.sequence.push(plan);
133
+ this.addSequencePlan(plan);
119
134
  // handle the various result types
120
135
  const resultType = type;
121
136
  // if there is an answer, return it
122
137
  if (resultType === 'result' ||
123
138
  resultType === 'error' ||
124
- resultType === 'handshake') {
139
+ resultType === 'handshake' ||
140
+ resultType === 'configure') {
125
141
  return planResult;
126
142
  }
127
143
  // if there are intents, handle them
@@ -140,9 +156,15 @@ export class oAgentPlan extends oPlan {
140
156
  }
141
157
  // update the context with the search results
142
158
  for (const searchResult of filteredSearchResults) {
143
- // add the context data
144
- this.contextIdHash[searchResult.metadata.id] = true;
145
- searchResultContext += `Tool Address: ${searchResult.metadata.address}\nTool Data: ${searchResult.pageContent}\n\n`;
159
+ // internal search results
160
+ if (searchResult?.metadata) {
161
+ // add the context data
162
+ this.contextIdHash[searchResult?.metadata?.id || '0'] = true;
163
+ searchResultContext += `Tool Address: ${searchResult?.metadata?.address || 'unknown'}\nTool Data: ${searchResult?.pageContent || 'unknown'}\n\n`;
164
+ }
165
+ else {
166
+ searchResultContext += `External Search Result: ${searchResult?.message || 'unknown'}\n\n`;
167
+ }
146
168
  }
147
169
  searchResultContext += `[Search Results End]`;
148
170
  if (filteredSearchResults.length > 0) {
@@ -0,0 +1,6 @@
1
+ import { oTaskConfig } from './task.config';
2
+ export interface oConfigureResult {
3
+ task: oTaskConfig;
4
+ type: 'configure';
5
+ }
6
+ //# sourceMappingURL=configure.result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configure.result.d.ts","sourceRoot":"","sources":["../../../../src/plan/interfaces/configure.result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,WAAW,CAAC;CACnB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ import { oMethod } from '@olane/o-protocol';
2
+ import { oPlanResult } from './plan.result';
3
+ import { oTaskConfig } from './task.config';
4
+ export interface oHandshakeResult {
5
+ tools: string[];
6
+ methods: {
7
+ [key: string]: oMethod;
8
+ };
9
+ successes: oPlanResult[];
10
+ failures: oPlanResult[];
11
+ task?: oTaskConfig;
12
+ type: 'handshake';
13
+ }
14
+ //# sourceMappingURL=handshake.result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handshake.result.d.ts","sourceRoot":"","sources":["../../../../src/plan/interfaces/handshake.result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IACpC,SAAS,EAAE,WAAW,EAAE,CAAC;IACzB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,IAAI,EAAE,WAAW,CAAC;CACnB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -7,6 +7,8 @@ export interface oPlanConfig {
7
7
  currentNode: oCoreNode;
8
8
  caller: oAddress;
9
9
  receiver?: oAddress;
10
- promptFunction?: (intent: string, context: string, agentHistory: string) => string;
10
+ promptFunction?: (intent: string, context: string, agentHistory: string, extraInstructions: string) => string;
11
+ extraInstructions?: string;
12
+ parentId?: string;
11
13
  }
12
14
  //# sourceMappingURL=plan-config.interface.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plan-config.interface.d.ts","sourceRoot":"","sources":["../../../../src/plan/interfaces/plan-config.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,WAAW,WAAW;IAE1B,MAAM,EAAE,MAAM,CAAC;IAEf,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC;IAGjB,WAAW,EAAE,SAAS,CAAC;IACvB,MAAM,EAAE,QAAQ,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,cAAc,CAAC,EAAE,CACf,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,KACjB,MAAM,CAAC;CACb"}
1
+ {"version":3,"file":"plan-config.interface.d.ts","sourceRoot":"","sources":["../../../../src/plan/interfaces/plan-config.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,WAAW,WAAW;IAE1B,MAAM,EAAE,MAAM,CAAC;IAEf,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC;IAGjB,WAAW,EAAE,SAAS,CAAC;IACvB,MAAM,EAAE,QAAQ,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,cAAc,CAAC,EAAE,CACf,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,iBAAiB,EAAE,MAAM,KACtB,MAAM,CAAC;IACZ,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
@@ -2,6 +2,7 @@ export declare enum oPlanType {
2
2
  ANALYSIS = "analysis",
3
3
  SEARCH = "search",
4
4
  CONFIGURE = "configure",
5
- USE = "use"
5
+ USE = "use",
6
+ ERROR = "error"
6
7
  }
7
8
  //# sourceMappingURL=plan-type.enum.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plan-type.enum.d.ts","sourceRoot":"","sources":["../../../../src/plan/interfaces/plan-type.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,SAAS;IACnB,QAAQ,aAAa;IACrB,MAAM,WAAW;IACjB,SAAS,cAAc;IACvB,GAAG,QAAQ;CACZ"}
1
+ {"version":3,"file":"plan-type.enum.d.ts","sourceRoot":"","sources":["../../../../src/plan/interfaces/plan-type.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,SAAS;IACnB,QAAQ,aAAa;IACrB,MAAM,WAAW;IACjB,SAAS,cAAc;IACvB,GAAG,QAAQ;IACX,KAAK,UAAU;CAChB"}
@@ -4,4 +4,5 @@ export var oPlanType;
4
4
  oPlanType["SEARCH"] = "search";
5
5
  oPlanType["CONFIGURE"] = "configure";
6
6
  oPlanType["USE"] = "use";
7
+ oPlanType["ERROR"] = "error";
7
8
  })(oPlanType || (oPlanType = {}));