@olane/o-core 0.5.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/core/core.node.d.ts +1 -1
- package/dist/src/core/core.node.d.ts.map +1 -1
- package/dist/src/core/core.node.js +7 -1
- package/dist/src/core/lib/o-address-resolution.d.ts.map +1 -1
- package/dist/src/core/lib/o-address-resolution.js +3 -4
- package/dist/src/core/lib/o-request.d.ts +2 -0
- package/dist/src/core/lib/o-request.d.ts.map +1 -1
- package/dist/src/core/lib/o-request.js +9 -0
- package/dist/src/core/lib/resolvers/anything.resolver.d.ts.map +1 -1
- package/dist/src/core/lib/resolvers/anything.resolver.js +2 -1
- package/dist/src/core/utils/network.utils.d.ts.map +1 -1
- package/dist/src/core/utils/network.utils.js +0 -1
- package/dist/src/error/tool.error.d.ts +2 -0
- package/dist/src/error/tool.error.d.ts.map +1 -1
- package/dist/src/error/tool.error.js +10 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/node/node.d.ts +3 -3
- package/dist/src/node/node.d.ts.map +1 -1
- package/dist/src/node/node.js +27 -32
- package/dist/src/plan/agent.plan.d.ts +2 -1
- package/dist/src/plan/agent.plan.d.ts.map +1 -1
- package/dist/src/plan/agent.plan.js +55 -33
- package/dist/src/plan/interfaces/configure.result.d.ts +6 -0
- package/dist/src/plan/interfaces/configure.result.d.ts.map +1 -0
- package/dist/src/plan/interfaces/configure.result.js +1 -0
- package/dist/src/plan/interfaces/handshake.result.d.ts +14 -0
- package/dist/src/plan/interfaces/handshake.result.d.ts.map +1 -0
- package/dist/src/plan/interfaces/handshake.result.js +1 -0
- package/dist/src/plan/interfaces/plan-config.interface.d.ts +3 -1
- package/dist/src/plan/interfaces/plan-config.interface.d.ts.map +1 -1
- package/dist/src/plan/interfaces/plan-type.enum.d.ts +2 -1
- package/dist/src/plan/interfaces/plan-type.enum.d.ts.map +1 -1
- package/dist/src/plan/interfaces/plan-type.enum.js +1 -0
- package/dist/src/plan/interfaces/plan.result.d.ts +4 -4
- package/dist/src/plan/interfaces/plan.result.d.ts.map +1 -1
- package/dist/src/plan/o-plan.d.ts +3 -1
- package/dist/src/plan/o-plan.d.ts.map +1 -1
- package/dist/src/plan/o-plan.js +51 -45
- package/dist/src/plan/prompts/agent.prompt.d.ts +1 -1
- package/dist/src/plan/prompts/agent.prompt.d.ts.map +1 -1
- package/dist/src/plan/prompts/agent.prompt.js +31 -14
- package/dist/src/plan/prompts/configure.prompt.d.ts +1 -1
- package/dist/src/plan/prompts/configure.prompt.d.ts.map +1 -1
- package/dist/src/plan/prompts/configure.prompt.js +34 -49
- package/dist/src/plan/prompts/custom.prompt.d.ts +1 -1
- package/dist/src/plan/prompts/custom.prompt.d.ts.map +1 -1
- package/dist/src/plan/prompts/custom.prompt.js +26 -6
- package/dist/src/plan/search/search.plan.d.ts.map +1 -1
- package/dist/src/plan/search/search.plan.js +15 -8
- package/dist/src/plan/use/use.plan.d.ts +3 -0
- package/dist/src/plan/use/use.plan.d.ts.map +1 -1
- package/dist/src/plan/use/use.plan.js +116 -38
- package/dist/src/utils/index.d.ts +3 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/src/utils/index.js +2 -0
- package/dist/src/utils/object.utils.d.ts +5 -0
- package/dist/src/utils/object.utils.d.ts.map +1 -0
- package/dist/src/utils/object.utils.js +23 -0
- package/dist/src/utils/regex.utils.d.ts +4 -0
- package/dist/src/utils/regex.utils.d.ts.map +1 -0
- package/dist/src/utils/regex.utils.js +13 -0
- package/package.json +3 -5
- package/dist/src/plan/configure/configure.plan.d.ts +0 -11
- package/dist/src/plan/configure/configure.plan.d.ts.map +0 -1
- package/dist/src/plan/configure/configure.plan.js +0 -15
- package/dist/src/plan/error/error.plan.d.ts +0 -11
- package/dist/src/plan/error/error.plan.d.ts.map +0 -1
- package/dist/src/plan/error/error.plan.js +0 -20
- package/dist/src/plan/prompts/error.prompt.d.ts +0 -2
- package/dist/src/plan/prompts/error.prompt.d.ts.map +0 -1
- package/dist/src/plan/prompts/error.prompt.js +0 -39
- package/dist/src/plan/prompts/search.prompt.d.ts +0 -2
- package/dist/src/plan/prompts/search.prompt.d.ts.map +0 -1
- package/dist/src/plan/prompts/search.prompt.js +0 -43
|
@@ -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,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"core.node.d.ts","sourceRoot":"","sources":["../../../src/core/core.node.ts"],"names":[],"mappings":"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"}
|
|
@@ -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;
|
|
@@ -169,8 +170,13 @@ export class oCoreNode {
|
|
|
169
170
|
// communicate the payload to the target node
|
|
170
171
|
const response = await connection.send({
|
|
171
172
|
address: targetAddress?.toString() || '',
|
|
172
|
-
payload: data,
|
|
173
|
+
payload: data || {},
|
|
173
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
|
+
}
|
|
174
180
|
return response;
|
|
175
181
|
}
|
|
176
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;
|
|
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;
|
|
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;
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.error.d.ts","sourceRoot":"","sources":["../../../src/error/tool.error.ts"],"names":[],"mappings":"
|
|
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
|
}
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.d.ts.map
CHANGED
|
@@ -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
package/dist/src/node/node.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
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<
|
|
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
15
|
matchAgainstMethods(address: oAddress): Promise<boolean>;
|
|
16
16
|
extractMethod(address: oAddress): string;
|
|
@@ -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;
|
|
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;AAMhE,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAK1E,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,gBAAgB,CAAC;IAkBrE,QAAQ,CAAC,mBAAmB,IAAI,GAAG,EAAE;IAErC,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,MAAM,EAAE;IAOtB,qBAAqB,CACzB,OAAO,EAAE,QAAQ,EACjB,OAAO,EAAE,QAAQ,GAChB,OAAO,CAAC,SAAS,CAAC;IAOf,mBAAmB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAS9D,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;IA4EvE;;;;OAIG;IACG,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IA4B7C,oBAAoB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IASrD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAOtB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IA2C9B,mBAAmB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAIpD,eAAe,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAYtD,YAAY,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI;IAK/B,eAAe,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI;IAIlC;;;OAGG;IACG,SAAS,IAAI,OAAO,CAAC,YAAY,CAAC;IA4ElC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAyB3B,uBAAuB,CAAC,KAAK,EAAE,GAAG;IAexC,IAAI,QAAQ,IAAI,OAAO,CAItB;IAEK,kBAAkB;IAgCxB,sBAAsB;IAIhB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAOhC"}
|
package/dist/src/node/node.js
CHANGED
|
@@ -6,7 +6,6 @@ import { oToolError } from '../error/tool.error.js';
|
|
|
6
6
|
import { oToolErrorCodes } from '../error/enums/codes.error.js';
|
|
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 });
|
|
@@ -27,26 +26,19 @@ export class oNode extends oCoreNode {
|
|
|
27
26
|
async _tool_handshake(handshake) {
|
|
28
27
|
this.logger.debug('Performing handshake with intent: ', handshake.params.intent);
|
|
29
28
|
const mytools = await this.myTools();
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
39
|
-
const result = await pc.execute();
|
|
40
|
-
this.logger.debug('Handshake result: ', result);
|
|
41
|
-
if (result.error) {
|
|
42
|
-
return result;
|
|
43
|
-
}
|
|
44
|
-
this.logger.debug('Handshake json: ', result.handshake);
|
|
45
|
-
return result;
|
|
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
|
+
};
|
|
46
37
|
}
|
|
47
|
-
myTools() {
|
|
48
|
-
return Object.getOwnPropertyNames(
|
|
38
|
+
myTools(obj) {
|
|
39
|
+
return Object.getOwnPropertyNames(obj || this.constructor.prototype)
|
|
49
40
|
.filter((key) => key.startsWith('_tool_'))
|
|
41
|
+
.filter((key) => !!key)
|
|
50
42
|
.map((key) => key.replace('_tool_', ''));
|
|
51
43
|
}
|
|
52
44
|
async applyBridgeTransports(address, request) {
|
|
@@ -70,13 +62,18 @@ export class oNode extends oCoreNode {
|
|
|
70
62
|
const destinationAddress = new oAddress(address);
|
|
71
63
|
// determine the next hop address from the encapsulated address
|
|
72
64
|
const nextHopAddress = await this.addressResolution.resolve(destinationAddress);
|
|
73
|
-
this.logger.debug('Next hop address: ', nextHopAddress.toString());
|
|
65
|
+
this.logger.debug('Next hop address: ', nextHopAddress.toString(), nextHopAddress.customTransports);
|
|
74
66
|
// prepare the request for the destination receiver
|
|
75
67
|
let forwardRequest = new oRequest({
|
|
76
68
|
params: payload.params,
|
|
77
69
|
id: request.id,
|
|
78
70
|
method: payload.method,
|
|
79
71
|
});
|
|
72
|
+
// if the next hop is not a libp2p address, we need to communicate to it another way
|
|
73
|
+
if (this.addressResolution.supportsTransport(nextHopAddress)) {
|
|
74
|
+
this.logger.debug('Bridge transports supported, applying custom transports...');
|
|
75
|
+
return this.applyBridgeTransports(nextHopAddress, forwardRequest);
|
|
76
|
+
}
|
|
80
77
|
// assume the next hop is a libp2p address, so we need to set the transports and dial it
|
|
81
78
|
nextHopAddress.setTransports(this.getTransports(nextHopAddress));
|
|
82
79
|
const isAtDestination = nextHopAddress.value === destinationAddress.value;
|
|
@@ -87,19 +84,16 @@ export class oNode extends oCoreNode {
|
|
|
87
84
|
if (isMethodMatch) {
|
|
88
85
|
this.logger.debug('Method match found, forwarding to self...');
|
|
89
86
|
const extractedMethod = this.extractMethod(destinationAddress);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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;
|
|
97
96
|
}
|
|
98
|
-
return response.result.data;
|
|
99
|
-
}
|
|
100
|
-
// if the next hop is not a libp2p address, we need to communicate to it another way
|
|
101
|
-
if (this.addressResolution.supportsTransport(nextHopAddress)) {
|
|
102
|
-
return this.applyBridgeTransports(nextHopAddress, forwardRequest);
|
|
103
97
|
}
|
|
104
98
|
const targetStream = await this.p2pNode.dialProtocol(transports, nextHopAddress.protocol);
|
|
105
99
|
// if not at destination, we need to forward the request to the target
|
|
@@ -136,6 +130,7 @@ export class oNode extends oCoreNode {
|
|
|
136
130
|
const response = await pc.execute();
|
|
137
131
|
return {
|
|
138
132
|
...response,
|
|
133
|
+
cycles: pc.sequence.length,
|
|
139
134
|
sequence: pc.sequence.map((s) => {
|
|
140
135
|
return {
|
|
141
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,MAAM,8BAA8B,CAAC;
|
|
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,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D;;;;;;;GAOG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC,OAAO,CAAC,cAAc,CAAM;IAC5B,OAAO,CAAC,aAAa,CAAkC;gBAE3C,MAAM,EAAE,WAAW;IAIzB,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAuBpE,WAAW,CACf,OAAO,EAAE,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
|
|
33
|
-
|
|
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.
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
|
99
|
+
intent: intent,
|
|
100
|
+
sequence: this.sequence,
|
|
101
|
+
parentId: this.id,
|
|
86
102
|
});
|
|
87
103
|
const response = await subPlan.execute();
|
|
88
|
-
this.
|
|
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
|
-
|
|
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.
|
|
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
|
-
//
|
|
144
|
-
|
|
145
|
-
|
|
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 @@
|
|
|
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,
|
|
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"}
|
|
@@ -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;
|
|
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"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { oQueryConfig } from './query.config.js';
|
|
2
2
|
import { oTaskConfig } from './task.config.js';
|
|
3
|
+
import { oConfigureResult } from './configure.result.js';
|
|
3
4
|
export interface oPlanResult {
|
|
4
|
-
intents?:
|
|
5
|
-
intent: string;
|
|
6
|
-
}[];
|
|
5
|
+
intents?: string[];
|
|
7
6
|
queries?: oQueryConfig[];
|
|
8
7
|
tasks?: oTaskConfig[];
|
|
9
8
|
handshake?: oTaskConfig;
|
|
10
9
|
result?: any;
|
|
11
10
|
reasoning?: string;
|
|
12
11
|
error?: any;
|
|
13
|
-
|
|
12
|
+
configure?: oConfigureResult;
|
|
13
|
+
type: 'result' | 'task' | 'search' | 'multiple_step' | 'error' | 'handshake' | 'configure';
|
|
14
14
|
}
|
|
15
15
|
//# sourceMappingURL=plan.result.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.result.d.ts","sourceRoot":"","sources":["../../../../src/plan/interfaces/plan.result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"plan.result.d.ts","sourceRoot":"","sources":["../../../../src/plan/interfaces/plan.result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,KAAK,CAAC,EAAE,WAAW,EAAE,CAAC;IACtB,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,IAAI,EACA,QAAQ,GACR,MAAM,GACN,QAAQ,GACR,eAAe,GACf,OAAO,GACP,WAAW,GACX,WAAW,CAAC;CACjB"}
|