@olane/o-core 0.6.8 → 0.6.9
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/o-address-resolution.d.ts.map +1 -1
- package/dist/src/core/lib/o-address-resolution.js +0 -3
- package/dist/src/node/node.d.ts.map +1 -1
- package/dist/src/node/node.js +8 -2
- package/dist/src/plan/configure/configure.plan.d.ts +11 -0
- package/dist/src/plan/configure/configure.plan.d.ts.map +1 -0
- package/dist/src/plan/configure/configure.plan.js +15 -0
- package/dist/src/plan/error/error.plan.d.ts +8 -0
- package/dist/src/plan/error/error.plan.d.ts.map +1 -0
- package/dist/src/plan/error/error.plan.js +11 -0
- package/dist/src/plan/prompts/error.prompt.d.ts +1 -0
- package/dist/src/plan/prompts/error.prompt.d.ts.map +1 -0
- package/dist/src/plan/prompts/error.prompt.js +87 -0
- package/dist/src/plan/prompts/search.prompt.d.ts +2 -0
- package/dist/src/plan/prompts/search.prompt.d.ts.map +1 -0
- package/dist/src/plan/prompts/search.prompt.js +43 -0
- package/package.json +9 -3
|
@@ -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;IAQvC,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;CAOpD"}
|
|
@@ -7,9 +7,6 @@ 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
|
-
}
|
|
13
10
|
return this.resolvers.some((r) => address.customTransports.some((t) => {
|
|
14
11
|
return r.transports.includes(t);
|
|
15
12
|
}));
|
|
@@ -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,mBAA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AmB,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;IAiFtD;;;;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
|
@@ -62,7 +62,7 @@ export class oNode extends oCoreNode {
|
|
|
62
62
|
const destinationAddress = new oAddress(address);
|
|
63
63
|
// determine the next hop address from the encapsulated address
|
|
64
64
|
const nextHopAddress = await this.addressResolution.resolve(destinationAddress);
|
|
65
|
-
this.logger.debug('Next hop address: ', nextHopAddress.toString(), nextHopAddress.
|
|
65
|
+
this.logger.debug('Next hop address: ', nextHopAddress.toString(), nextHopAddress.transports);
|
|
66
66
|
// prepare the request for the destination receiver
|
|
67
67
|
let forwardRequest = new oRequest({
|
|
68
68
|
params: payload.params,
|
|
@@ -72,7 +72,13 @@ 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
|
-
|
|
75
|
+
try {
|
|
76
|
+
// attempt to resolve with bridge transports
|
|
77
|
+
return this.applyBridgeTransports(nextHopAddress, forwardRequest);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
this.logger.error('Failed to apply bridge transports: ', error.message);
|
|
81
|
+
}
|
|
76
82
|
}
|
|
77
83
|
// assume the next hop is a libp2p address, so we need to set the transports and dial it
|
|
78
84
|
nextHopAddress.setTransports(this.getTransports(nextHopAddress));
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=error.prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.prompt.d.ts","sourceRoot":"","sources":["../../../../src/plan/prompts/error.prompt.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
// );
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olane/o-core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -21,10 +21,16 @@
|
|
|
21
21
|
"test:browser": "aegir test -t browser",
|
|
22
22
|
"deep:clean": "rm -rf node_modules && rm package-lock.json",
|
|
23
23
|
"dev": "DEBUG=o-protocol:* npx tsx src/tests/index.ts",
|
|
24
|
+
"update:peers": "npm install @olane/o-config@latest @olane/o-protocol@latest --save-peer",
|
|
24
25
|
"build": "tsc",
|
|
25
26
|
"start:prod": "node dist/index.js",
|
|
26
27
|
"prepublishOnly": "npm run build",
|
|
27
|
-
"lint": "aegir lint"
|
|
28
|
+
"lint": "aegir lint",
|
|
29
|
+
"release": "cd scripts && npm run release",
|
|
30
|
+
"release:dry-run": "cd scripts && npm run release:dry-run",
|
|
31
|
+
"release:parallel": "cd scripts && npm run release:parallel",
|
|
32
|
+
"release:minor": "cd scripts && npm run release:minor",
|
|
33
|
+
"release:major": "cd scripts && npm run release:major"
|
|
28
34
|
},
|
|
29
35
|
"repository": {
|
|
30
36
|
"type": "git",
|
|
@@ -55,7 +61,7 @@
|
|
|
55
61
|
"typescript": "^5.8.3"
|
|
56
62
|
},
|
|
57
63
|
"peerDependencies": {
|
|
58
|
-
"@olane/o-config": "^0.6.
|
|
64
|
+
"@olane/o-config": "^0.6.8",
|
|
59
65
|
"@olane/o-protocol": "^0.6.8"
|
|
60
66
|
},
|
|
61
67
|
"dependencies": {
|