@olane/o-core 0.6.10 → 0.6.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/core/lib/resolvers/next-hop.resolver.d.ts.map +1 -1
- package/dist/src/core/lib/resolvers/next-hop.resolver.js +1 -0
- package/dist/src/core/utils/network.utils.d.ts +6 -0
- package/dist/src/core/utils/network.utils.d.ts.map +1 -1
- package/dist/src/core/utils/network.utils.js +28 -33
- package/dist/src/node/node.d.ts +1 -0
- package/dist/src/node/node.d.ts.map +1 -1
- package/dist/src/node/node.js +25 -22
- package/package.json +3 -6
- 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 -8
- package/dist/src/plan/error/error.plan.d.ts.map +0 -1
- package/dist/src/plan/error/error.plan.js +0 -11
- package/dist/src/plan/prompts/error.prompt.d.ts +0 -1
- package/dist/src/plan/prompts/error.prompt.d.ts.map +0 -1
- package/dist/src/plan/prompts/error.prompt.js +0 -87
- 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":"next-hop.resolver.d.ts","sourceRoot":"","sources":["../../../../../src/core/lib/resolvers/next-hop.resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAG5D,qBAAa,eAAgB,SAAQ,gBAAgB;IAE7C,0BAA0B,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAYnE,sBAAsB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IA+B/D,WAAW,CAAC,aAAa,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"next-hop.resolver.d.ts","sourceRoot":"","sources":["../../../../../src/core/lib/resolvers/next-hop.resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAG5D,qBAAa,eAAgB,SAAQ,gBAAgB;IAE7C,0BAA0B,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAYnE,sBAAsB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IA+B/D,WAAW,CAAC,aAAa,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAsBvD,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;CAIpD"}
|
|
@@ -41,6 +41,7 @@ export class NextHopResolver extends oAddressResolver {
|
|
|
41
41
|
async findNextHop(targetAddress) {
|
|
42
42
|
// check to see if we are at the destination
|
|
43
43
|
if (targetAddress.protocol === this.address.protocol) {
|
|
44
|
+
this.logger.debug('At destination, finding provider transports...');
|
|
44
45
|
const transports = await this.findProviderTransports(targetAddress);
|
|
45
46
|
return new oAddress(targetAddress.value, transports.map((t) => multiaddr(t)));
|
|
46
47
|
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { Libp2p, Multiaddr } from '@olane/o-config';
|
|
2
2
|
import { oAddress } from '../o-address.js';
|
|
3
|
+
import { CID } from 'multiformats';
|
|
3
4
|
export declare class NetworkUtils {
|
|
5
|
+
static findProviders(p2pNode: Libp2p, cid: CID): Promise<{
|
|
6
|
+
transports: Multiaddr[];
|
|
7
|
+
staticAddress: string;
|
|
8
|
+
absoluteAddress: string;
|
|
9
|
+
}>;
|
|
4
10
|
static findNode(p2pNode: Libp2p, address: oAddress): Promise<{
|
|
5
11
|
transports: Multiaddr[];
|
|
6
12
|
staticAddress: string;
|
|
@@ -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;
|
|
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,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,qBAAa,YAAY;WACH,aAAa,CAC/B,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,GAAG,GACP,OAAO,CAAC;QACT,UAAU,EAAE,SAAS,EAAE,CAAC;QACxB,aAAa,EAAE,MAAM,CAAC;QACtB,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;WA4BkB,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;CAgBH"}
|
|
@@ -1,40 +1,35 @@
|
|
|
1
1
|
import { Logger } from '../index.js';
|
|
2
2
|
export class NetworkUtils {
|
|
3
|
-
static async
|
|
4
|
-
const logger = new Logger(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
providers
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
name: 'DIAL_PEER',
|
|
18
|
-
type: 7
|
|
19
|
-
}
|
|
20
|
-
*/
|
|
21
|
-
if (!value) {
|
|
22
|
-
return { transports: [], staticAddress: '', absoluteAddress: '' };
|
|
3
|
+
static async findProviders(p2pNode, cid) {
|
|
4
|
+
const logger = new Logger('NetworkUtils');
|
|
5
|
+
let peer = null;
|
|
6
|
+
let multiaddrs = [];
|
|
7
|
+
for await (const event of p2pNode.services.dht.findProviders(cid)) {
|
|
8
|
+
// Look for events that contain actual provider information
|
|
9
|
+
if (event.name === 'PEER_RESPONSE') {
|
|
10
|
+
if (event.providers?.length === 0) {
|
|
11
|
+
logger.debug('No providers found');
|
|
12
|
+
break;
|
|
13
|
+
}
|
|
14
|
+
peer = event.providers[0].id;
|
|
15
|
+
multiaddrs = event.providers[0].multiaddrs;
|
|
16
|
+
break;
|
|
23
17
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
logger.debug('Found node:', result);
|
|
27
|
-
return {
|
|
28
|
-
transports: result.multiaddrs,
|
|
29
|
-
staticAddress: '',
|
|
30
|
-
absoluteAddress: '',
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
catch (timeoutError) {
|
|
34
|
-
if (timeoutError.message === 'Content routing provide timeout') {
|
|
35
|
-
return { transports: [], staticAddress: '', absoluteAddress: '' };
|
|
18
|
+
if (event.name === 'PATH_ENDED' || event.name === 'QUERY_ERROR') {
|
|
19
|
+
break;
|
|
36
20
|
}
|
|
37
|
-
throw timeoutError;
|
|
38
21
|
}
|
|
22
|
+
return {
|
|
23
|
+
transports: multiaddrs,
|
|
24
|
+
staticAddress: '',
|
|
25
|
+
absoluteAddress: '',
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
static async findNode(p2pNode, address) {
|
|
29
|
+
const cid = await address.toCID();
|
|
30
|
+
return await Promise.race([
|
|
31
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error('Content routing provide timeout')), 5000)),
|
|
32
|
+
this.findProviders(p2pNode, cid),
|
|
33
|
+
]);
|
|
39
34
|
}
|
|
40
35
|
}
|
package/dist/src/node/node.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export declare abstract class oNode extends oCoreNode {
|
|
|
35
35
|
*/
|
|
36
36
|
configure(): Promise<Libp2pConfig>;
|
|
37
37
|
initialize(): Promise<void>;
|
|
38
|
+
dhtProvide(value: CID): Promise<void>;
|
|
38
39
|
advertiseValueToNetwork(value: CID): Promise<void>;
|
|
39
40
|
get isServer(): boolean;
|
|
40
41
|
advertiseToNetwork(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/node/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,YAAY,EAMb,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;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAK7D,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,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/node/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,YAAY,EAMb,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;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAK7D,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,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC;IA8EtD;;;;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,UAAU,CAAC,KAAK,EAAE,GAAG;IAiBrB,uBAAuB,CAAC,KAAK,EAAE,GAAG;IAiBxC,IAAI,QAAQ,IAAI,OAAO,CAItB;IAEK,kBAAkB;IA6BxB,sBAAsB;IAIhB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAOhC"}
|
package/dist/src/node/node.js
CHANGED
|
@@ -72,13 +72,9 @@ export class oNode extends oCoreNode {
|
|
|
72
72
|
// if the next hop is not a libp2p address, we need to communicate to it another way
|
|
73
73
|
if (this.addressResolution.supportsTransport(nextHopAddress)) {
|
|
74
74
|
this.logger.debug('Bridge transports supported, applying custom transports...');
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
this.logger.error('Failed to apply bridge transports: ', error.message);
|
|
81
|
-
}
|
|
75
|
+
this.logger.debug('Next hop address: BRENDON!');
|
|
76
|
+
// attempt to resolve with bridge transports
|
|
77
|
+
return this.applyBridgeTransports(nextHopAddress, forwardRequest);
|
|
82
78
|
}
|
|
83
79
|
// assume the next hop is a libp2p address, so we need to set the transports and dial it
|
|
84
80
|
nextHopAddress.setTransports(this.getTransports(nextHopAddress));
|
|
@@ -294,13 +290,26 @@ export class oNode extends oCoreNode {
|
|
|
294
290
|
// listen for network events
|
|
295
291
|
// this.listenForNetworkEvents();
|
|
296
292
|
}
|
|
293
|
+
async dhtProvide(value) {
|
|
294
|
+
if (!this.config.parent && !this.config.leader) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
for await (const event of this.p2pNode.services.dht.provide(value)) {
|
|
298
|
+
if (event.name === 'PATH_ENDED' ||
|
|
299
|
+
event.name === 'QUERY_ERROR' ||
|
|
300
|
+
event.name === 'PEER_RESPONSE') {
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
297
305
|
async advertiseValueToNetwork(value) {
|
|
298
306
|
if (!this.isServer) {
|
|
299
307
|
return;
|
|
300
308
|
}
|
|
301
|
-
|
|
309
|
+
this.logger.debug('Advertising value to network: ', value.toString());
|
|
302
310
|
const timeoutPromise = new Promise((_, reject) => setTimeout(() => reject(new Error('Advertise Content routing provide timeout')), 5000));
|
|
303
|
-
await Promise.race([
|
|
311
|
+
await Promise.race([this.dhtProvide(value), timeoutPromise]);
|
|
312
|
+
this.logger.debug('Advertise complete!');
|
|
304
313
|
}
|
|
305
314
|
// if the node has any transports that are not memory, it is a server
|
|
306
315
|
get isServer() {
|
|
@@ -313,22 +322,16 @@ export class oNode extends oCoreNode {
|
|
|
313
322
|
this.logger.debug('Advertising to network our static and absolute addresses...');
|
|
314
323
|
// advertise the absolute address to the network with timeout
|
|
315
324
|
const absoluteAddressCid = await this.address.toCID();
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
await this.advertiseValueToNetwork(absoluteAddressCid);
|
|
319
|
-
}
|
|
320
|
-
catch (error) {
|
|
325
|
+
// Add timeout to prevent hanging
|
|
326
|
+
this.advertiseValueToNetwork(absoluteAddressCid).catch((error) => {
|
|
321
327
|
this.logger.warn('Failed to advertise absolute address (this is normal for isolated nodes):', error.message);
|
|
322
|
-
}
|
|
328
|
+
});
|
|
323
329
|
// advertise the static address to the network with timeout
|
|
324
330
|
const staticAddressCid = await this.staticAddress.toCID();
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
}
|
|
329
|
-
catch (error) {
|
|
330
|
-
this.logger.warn('Failed to advertise static address (this is normal for isolated nodes):', error.message);
|
|
331
|
-
}
|
|
331
|
+
// Add timeout to prevent hanging
|
|
332
|
+
this.advertiseValueToNetwork(staticAddressCid).catch((error) => {
|
|
333
|
+
this.logger.warn('Failed to advertise absolute address (this is normal for isolated nodes):', error.message);
|
|
334
|
+
});
|
|
332
335
|
}
|
|
333
336
|
listenForNetworkEvents() {
|
|
334
337
|
this.networkActivity = new NetworkActivity(this.logger, this.p2pNode);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olane/o-core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -39,9 +39,6 @@
|
|
|
39
39
|
"author": "Olane Inc.",
|
|
40
40
|
"license": "ISC",
|
|
41
41
|
"description": "Olane addressable p2p node used to host tools, data or anything else your heart can dream of.",
|
|
42
|
-
"workspaces": [
|
|
43
|
-
"packages/*"
|
|
44
|
-
],
|
|
45
42
|
"devDependencies": {
|
|
46
43
|
"@eslint/eslintrc": "^3.3.1",
|
|
47
44
|
"@eslint/js": "^9.29.0",
|
|
@@ -64,8 +61,8 @@
|
|
|
64
61
|
"typescript": "^5.8.3"
|
|
65
62
|
},
|
|
66
63
|
"peerDependencies": {
|
|
67
|
-
"@olane/o-config": "^0.6.
|
|
68
|
-
"@olane/o-protocol": "^0.6.
|
|
64
|
+
"@olane/o-config": "^0.6.11",
|
|
65
|
+
"@olane/o-protocol": "^0.6.11"
|
|
69
66
|
},
|
|
70
67
|
"dependencies": {
|
|
71
68
|
"chalk": "^5.4.1",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { oPlan } from '../o-plan.js';
|
|
2
|
-
import { oPlanType } from '../interfaces/plan-type.enum.js';
|
|
3
|
-
import { oPlanConfig } from '../interfaces/plan-config.interface.js';
|
|
4
|
-
/**
|
|
5
|
-
* We know what tool we want to use, let's configure it.
|
|
6
|
-
*/
|
|
7
|
-
export declare class oConfigurePlan extends oPlan {
|
|
8
|
-
constructor(config: oPlanConfig);
|
|
9
|
-
type(): oPlanType;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=configure.plan.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configure.plan.d.ts","sourceRoot":"","sources":["../../../../src/plan/configure/configure.plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAGrE;;GAEG;AACH,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,MAAM,EAAE,WAAW;IAK/B,IAAI;CAGL"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { oPlan } from '../o-plan.js';
|
|
2
|
-
import { oPlanType } from '../interfaces/plan-type.enum.js';
|
|
3
|
-
import { CONFIGURE_PROMPT } from '../prompts/configure.prompt.js';
|
|
4
|
-
/**
|
|
5
|
-
* We know what tool we want to use, let's configure it.
|
|
6
|
-
*/
|
|
7
|
-
export class oConfigurePlan extends oPlan {
|
|
8
|
-
constructor(config) {
|
|
9
|
-
super(config);
|
|
10
|
-
this.config.promptFunction = CONFIGURE_PROMPT;
|
|
11
|
-
}
|
|
12
|
-
type() {
|
|
13
|
-
return oPlanType.CONFIGURE;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { oPlanConfig } from '../interfaces/plan-config.interface.js';
|
|
2
|
-
import { oPlanType } from '../interfaces/plan-type.enum.js';
|
|
3
|
-
import { oPlan } from '../o-plan.js';
|
|
4
|
-
export declare class oErrorPlan extends oPlan {
|
|
5
|
-
constructor(config: oPlanConfig);
|
|
6
|
-
type(): oPlanType;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=error.plan.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error.plan.d.ts","sourceRoot":"","sources":["../../../../src/plan/error/error.plan.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAE5D,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,qBAAa,UAAW,SAAQ,KAAK;gBACvB,MAAM,EAAE,WAAW;IAK/B,IAAI;CAGL"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { oPlanType } from '../interfaces/plan-type.enum.js';
|
|
2
|
-
import { oPlan } from '../o-plan.js';
|
|
3
|
-
export class oErrorPlan extends oPlan {
|
|
4
|
-
constructor(config) {
|
|
5
|
-
super(config);
|
|
6
|
-
// this.config.promptFunction = CONFIGURE_PROMPT;
|
|
7
|
-
}
|
|
8
|
-
type() {
|
|
9
|
-
return oPlanType.ERROR;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=error.prompt.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error.prompt.d.ts","sourceRoot":"","sources":["../../../../src/plan/prompts/error.prompt.ts"],"names":[],"mappings":""}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import { CUSTOM_AGENT_PROMPT } from './custom.prompt';
|
|
3
|
-
// export const ERROR_PROMPT = (
|
|
4
|
-
// intent: string,
|
|
5
|
-
// context: string,
|
|
6
|
-
// agentHistory: string,
|
|
7
|
-
// ) =>
|
|
8
|
-
// CUSTOM_AGENT_PROMPT(
|
|
9
|
-
// intent,
|
|
10
|
-
// context,
|
|
11
|
-
// agentHistory,
|
|
12
|
-
// `
|
|
13
|
-
// Error: ${JSON.stringify(error, null, 2)}
|
|
14
|
-
// Rules:
|
|
15
|
-
// 1. Do not explain the reasoning process, just return the output.
|
|
16
|
-
// 2. Do not include \`\`\`json or \`\`\` in your output.
|
|
17
|
-
// Steps:
|
|
18
|
-
// 1. Review the error and determine the cause.
|
|
19
|
-
// 2. Check the agentic state history to see if there was a better choice that could have been made to prevent this error.
|
|
20
|
-
// 3. Review the method options to see if there was a better method that could have been used to prevent this error.
|
|
21
|
-
// 4. Review the method metadata to see if the error is due to a missing method or parameter.
|
|
22
|
-
// 5. If you can fix the error, provide a solution.
|
|
23
|
-
// 6. If you cannot fix the error, create a human readable explanation on how to solve the error.
|
|
24
|
-
// 5. The explanation should summarize the intent and explain why it failed concisely.
|
|
25
|
-
// Error Output Format:
|
|
26
|
-
// {
|
|
27
|
-
// "error": {
|
|
28
|
-
// "message": string,
|
|
29
|
-
// "solution": string,
|
|
30
|
-
// "explanation": string,
|
|
31
|
-
// },
|
|
32
|
-
// "type": "error",
|
|
33
|
-
// }
|
|
34
|
-
// [Agentic State]
|
|
35
|
-
// ${agentHistory}
|
|
36
|
-
// `,
|
|
37
|
-
// `These are the types of cycle results: "Complex Intent Results", "Search Results", "Use Tool Results", "Answer Results", "Error Results".
|
|
38
|
-
// All Return Step Instructions:
|
|
39
|
-
// 1. Determine what type of results we have
|
|
40
|
-
// 2. Output the respective results using the matching output type.
|
|
41
|
-
// 3. Generate a reasoning statement for why this result was returned.
|
|
42
|
-
// 4. Do not include \`\`\`json or \`\`\` in your output.
|
|
43
|
-
// Complex Intent Results:
|
|
44
|
-
// {
|
|
45
|
-
// "intents": [
|
|
46
|
-
// "simple intent 1",
|
|
47
|
-
// "simple intent 2",
|
|
48
|
-
// "simple intent 3",
|
|
49
|
-
// ],
|
|
50
|
-
// "reasoning": string,
|
|
51
|
-
// "type": "multiple_step",
|
|
52
|
-
// }
|
|
53
|
-
// Use Tool Results:
|
|
54
|
-
// {
|
|
55
|
-
// "tasks": [
|
|
56
|
-
// {
|
|
57
|
-
// "address": "string",
|
|
58
|
-
// "intent": "string",
|
|
59
|
-
// },
|
|
60
|
-
// ],
|
|
61
|
-
// "reasoning": string,
|
|
62
|
-
// "type": "task",
|
|
63
|
-
// }
|
|
64
|
-
// Search Results:
|
|
65
|
-
// {
|
|
66
|
-
// "queries": [
|
|
67
|
-
// {
|
|
68
|
-
// "query": "key terms to search for",
|
|
69
|
-
// "provider": "internal" | "external",
|
|
70
|
-
// }
|
|
71
|
-
// ],
|
|
72
|
-
// "reasoning": string,
|
|
73
|
-
// "type": "search",
|
|
74
|
-
// }
|
|
75
|
-
// Answer Results:
|
|
76
|
-
// {
|
|
77
|
-
// "result": string,
|
|
78
|
-
// "reasoning": string,
|
|
79
|
-
// "type": "result",
|
|
80
|
-
// }
|
|
81
|
-
// Error Results:
|
|
82
|
-
// {
|
|
83
|
-
// "error": string,
|
|
84
|
-
// "reasoning": string,
|
|
85
|
-
// "type": "error",
|
|
86
|
-
// }`,
|
|
87
|
-
// );
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"search.prompt.d.ts","sourceRoot":"","sources":["../../../../src/plan/prompts/search.prompt.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,GAAI,QAAQ,MAAM,EAAE,SAAS,MAAM,WA0C5D,CAAC"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
export const SEARCH_PROMPT = (intent, context) => `
|
|
2
|
-
You are a helpful assistant that searches for unknown entities in the user's input or returns a tool address that helps complete the user's task.
|
|
3
|
-
|
|
4
|
-
All entities are hosted within a network of p2p nodes and are tools, data, or other items.
|
|
5
|
-
The p2p nodes and their contained data are accessible via the network address resolution system.
|
|
6
|
-
|
|
7
|
-
All entity data is stored within a vector database that can be queried for more information.
|
|
8
|
-
|
|
9
|
-
User Input: ${intent}
|
|
10
|
-
|
|
11
|
-
Rules:
|
|
12
|
-
1. Do not explain the reasoning process, just return the output.
|
|
13
|
-
2. Your output should be a search query or the tool address to use to answer the user's input.
|
|
14
|
-
3. Do not include \`\`\`json or \`\`\` in your output.
|
|
15
|
-
|
|
16
|
-
Steps:
|
|
17
|
-
1. If you know a tool that can help with the user's input, return it in the format of a task output.
|
|
18
|
-
2. Create a list of unknown entities mentioned in the user's input.
|
|
19
|
-
3. Generate a vector db query for each unknown entity.
|
|
20
|
-
4. Do not return a tool address unless you have seen it in the context.
|
|
21
|
-
|
|
22
|
-
Task Output Format:
|
|
23
|
-
{
|
|
24
|
-
"task": {
|
|
25
|
-
"address": string,
|
|
26
|
-
},
|
|
27
|
-
"type": "task",
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
Search Output Format:
|
|
31
|
-
{
|
|
32
|
-
"queries": [
|
|
33
|
-
{
|
|
34
|
-
"query": string,
|
|
35
|
-
"explanation": string,
|
|
36
|
-
}
|
|
37
|
-
],
|
|
38
|
-
"type": "search",
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
Additional Context: ${context}
|
|
42
|
-
|
|
43
|
-
`;
|