@olane/o-core 0.5.1 → 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 -1
  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 +3 -3
  20. package/dist/src/node/node.d.ts.map +1 -1
  21. package/dist/src/node/node.js +27 -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 +51 -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 +26 -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 +5 -5
  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
@@ -7,6 +7,8 @@ export declare class oPlan {
7
7
  protected logger: Logger;
8
8
  sequence: oPlan[];
9
9
  cid: CID | undefined;
10
+ id: string;
11
+ parentId: string | undefined;
10
12
  result: oPlanResult | undefined;
11
13
  constructor(config: oPlanConfig);
12
14
  get caller(): oAddress;
@@ -19,12 +21,12 @@ export declare class oPlan {
19
21
  sequence: string[];
20
22
  result: oPlanResult | undefined;
21
23
  };
24
+ addSequencePlan(plan: oPlan): void;
22
25
  toCID(): Promise<CID>;
23
26
  storePlan(): Promise<void>;
24
27
  get agentHistory(): string;
25
28
  searchPlans(): Promise<any>;
26
29
  preflight(): Promise<void>;
27
- extractResultFromAI(message: string): oPlanResult;
28
30
  run(): Promise<oPlanResult>;
29
31
  execute(): Promise<oPlanResult>;
30
32
  handleNetworkChanges(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"o-plan.d.ts","sourceRoot":"","sources":["../../../src/plan/o-plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAInC,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAI1D,qBAAa,KAAK;IAOJ,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,WAAW;IANlD,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,KAAK,EAAE,CAAM;IACvB,GAAG,EAAE,GAAG,GAAG,SAAS,CAAC;IAErB,MAAM,EAAE,WAAW,GAAG,SAAS,CAAC;gBAER,MAAM,EAAE,WAAW;IAKlD,IAAI,MAAM,aAET;IAED,IAAI,QAAQ,yBAEX;IAED,IAAI,IAAI,6CAEP;IAED,UAAU,IAAI,GAAG;IAQjB,IAAI;IAIJ,MAAM;;;;;IAQA,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC;IAUrB,SAAS;IAef,IAAI,YAAY,WAef;IAEK,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC;IAmB3B,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAKhC,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW;IAoB3C,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC;IAqC3B,OAAO,IAAI,OAAO,CAAC,WAAW,CAAC;IAQ/B,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAUrC,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB7B,UAAU,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;CAc9D"}
1
+ {"version":3,"file":"o-plan.d.ts","sourceRoot":"","sources":["../../../src/plan/o-plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAInC,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAK1D,qBAAa,KAAK;IASJ,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,WAAW;IARlD,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,KAAK,EAAE,CAAM;IACvB,GAAG,EAAE,GAAG,GAAG,SAAS,CAAC;IACrB,EAAE,EAAE,MAAM,CAAY;IACtB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAE7B,MAAM,EAAE,WAAW,GAAG,SAAS,CAAC;gBAER,MAAM,EAAE,WAAW;IAMlD,IAAI,MAAM,aAET;IAED,IAAI,QAAQ,yBAEX;IAED,IAAI,IAAI,6CAEP;IAED,UAAU,IAAI,GAAG;IAQjB,IAAI;IAIJ,MAAM;;;;;IAQN,eAAe,CAAC,IAAI,EAAE,KAAK;IAarB,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC;IAUrB,SAAS;IAef,IAAI,YAAY,WA0Bf;IAEK,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC;IAmB3B,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAK1B,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC;IAsC3B,OAAO,IAAI,OAAO,CAAC,WAAW,CAAC;IAQ/B,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAUrC,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB7B,UAAU,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;CAc9D"}
@@ -3,14 +3,16 @@ import { CID } from 'multiformats';
3
3
  import * as json from 'multiformats/codecs/json';
4
4
  import { sha256 } from 'multiformats/hashes/sha2';
5
5
  import { AGENT_PROMPT } from './prompts/agent.prompt.js';
6
- import { oToolError } from '../error/tool.error.js';
7
6
  import { v4 as uuidv4 } from 'uuid';
7
+ import { RegexUtils } from '../utils/index.js';
8
8
  export class oPlan {
9
9
  constructor(config) {
10
10
  this.config = config;
11
11
  this.sequence = [];
12
+ this.id = uuidv4();
12
13
  this.logger = new Logger('oPlan:' + `[${this.config.intent}]`);
13
- this.sequence = this.config.sequence || [];
14
+ this.sequence = Object.assign([], this.config.sequence || []);
15
+ this.parentId = this.config.parentId;
14
16
  }
15
17
  get caller() {
16
18
  return this.config.caller;
@@ -38,6 +40,18 @@ export class oPlan {
38
40
  result: this.result,
39
41
  };
40
42
  }
43
+ addSequencePlan(plan) {
44
+ this.sequence.push(plan);
45
+ // console.log(
46
+ // `${this.parentId ? '--[Child ' : '['}Cycle ${this.sequence.length} - ${this.id}]\n ${JSON.stringify(
47
+ // {
48
+ // ...plan.result,
49
+ // },
50
+ // null,
51
+ // 2,
52
+ // )}\n${this.parentId ? '--[Child ' : '['}Cycle ${this.sequence.length} - ${this.id}]`,
53
+ // );
54
+ }
41
55
  async toCID() {
42
56
  if (this.cid) {
43
57
  return this.cid;
@@ -61,10 +75,21 @@ export class oPlan {
61
75
  });
62
76
  }
63
77
  get agentHistory() {
78
+ const added = {};
64
79
  return (this.sequence
65
- ?.map((s, index) => `[Cycle ${index + 1} Begin]\n${JSON.stringify({
80
+ ?.filter((s) => {
81
+ if (added[s.id]) {
82
+ return false;
83
+ }
84
+ added[s.id] = true;
85
+ return true;
86
+ })
87
+ ?.map((s, index) => `[Cycle ${index + 1} Begin ${s.id}]\n
88
+ Cycle Intent: ${s.config.intent}\n
89
+ Cycle Result:\n
90
+ ${JSON.stringify({
66
91
  ...s.result,
67
- }, null, 2)} \n[Cycle ${index + 1} End]`)
92
+ }, null, 2)} \n[Cycle ${index + 1} End ${s.id}]`)
68
93
  .join('\n') || '');
69
94
  }
70
95
  async searchPlans() {
@@ -87,48 +112,29 @@ export class oPlan {
87
112
  this.logger.debug('Preflight...');
88
113
  this.cid = await this.toCID();
89
114
  }
90
- extractResultFromAI(message) {
91
- this.logger.debug('Extracting result from AI: ', message);
92
- // handle 4 levels of nested JSON
93
- const matches = message.match(/\{(?:[^{}]*|\{(?:[^{}]*|\{(?:[^{}]*|\{(?:[^{}]*|\{[^{}]*\})*\})*\})*\})*\}/);
94
- if (!matches || matches.length === 0) {
95
- // AI failed to return a valid JSON object
96
- throw new Error('AI failed to return a valid JSON object');
97
- }
98
- const json = matches[0];
99
- this.logger.debug('[AGENT PLAN] Analysis result: ', json);
100
- // process the result and react
101
- const planResult = JSON.parse(json);
102
- return planResult;
103
- }
104
115
  async run() {
105
116
  this.logger.debug('Running plan...');
106
117
  const ctxt = this.config.context?.toString() || '';
107
- this.logger.debug('Agent history: ', this.agentHistory);
108
118
  let prompt = null;
109
119
  if (this.config.promptFunction) {
110
120
  this.logger.debug('Using prompt function: ', this.config.promptFunction);
111
- prompt = this.config.promptFunction(this.config.intent, ctxt, this.agentHistory);
121
+ prompt = this.config.promptFunction(this.config.intent, ctxt, this.agentHistory, this.config.extraInstructions || '');
112
122
  }
113
123
  else {
114
- prompt = AGENT_PROMPT(this.config.intent, ctxt, this.agentHistory);
124
+ prompt = AGENT_PROMPT(this.config.intent, ctxt, this.agentHistory, this.config.extraInstructions || '');
115
125
  }
116
- this.logger.debug('Prompt: ', prompt);
126
+ // this.logger.debug('Prompt: ', prompt);
117
127
  const response = await this.node.use(new oAddress('o://intelligence'), {
118
128
  method: 'prompt',
119
129
  params: {
120
130
  prompt: prompt,
131
+ response_format: 'json_object',
121
132
  },
122
133
  });
123
- if (response.result.error) {
124
- this.logger.error('Error in plan: ', response.result.error);
125
- const error = response.result.error;
126
- throw new oToolError(error.code, error.message);
127
- }
128
134
  const data = response.result.data;
129
135
  this.logger.debug('Plan response: ', data);
130
136
  const message = data.message;
131
- const planResult = this.extractResultFromAI(message);
137
+ const planResult = RegexUtils.extractResultFromAI(message);
132
138
  return planResult;
133
139
  }
134
140
  async execute() {
@@ -147,23 +153,23 @@ export class oPlan {
147
153
  });
148
154
  }
149
155
  async addReasoning() {
150
- if (this.result?.reasoning) {
151
- this.logger.debug('Adding knowledge: ', this.result?.reasoning);
152
- await this.node.use(new oAddress('o://vector-store'), {
153
- method: 'add_documents',
154
- params: {
155
- documents: [
156
- {
157
- pageContent: this.result?.reasoning,
158
- metadata: {
159
- address: this.caller?.toString(),
160
- id: uuidv4(),
161
- },
162
- },
163
- ],
164
- },
165
- });
166
- }
156
+ // if (this.result?.reasoning) {
157
+ // this.logger.debug('Adding knowledge: ', this.result?.reasoning);
158
+ // await this.node.use(new oAddress('o://vector-store'), {
159
+ // method: 'add_documents',
160
+ // params: {
161
+ // documents: [
162
+ // {
163
+ // pageContent: this.result?.reasoning,
164
+ // metadata: {
165
+ // address: this.caller?.toString(),
166
+ // id: uuidv4(),
167
+ // },
168
+ // },
169
+ // ],
170
+ // },
171
+ // });
172
+ // }
167
173
  }
168
174
  async postflight(response) {
169
175
  this.logger.debug('Postflight...');
@@ -1,2 +1,2 @@
1
- export declare const AGENT_PROMPT: (intent: string, context: string, agentHistory: string) => string;
1
+ export declare const AGENT_PROMPT: (intent: string, context: string, agentHistory: string, extraInstructions: string) => string;
2
2
  //# sourceMappingURL=agent.prompt.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent.prompt.d.ts","sourceRoot":"","sources":["../../../../src/plan/prompts/agent.prompt.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,GACvB,QAAQ,MAAM,EACd,SAAS,MAAM,EACf,cAAc,MAAM,WAoGnB,CAAC"}
1
+ {"version":3,"file":"agent.prompt.d.ts","sourceRoot":"","sources":["../../../../src/plan/prompts/agent.prompt.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,GACvB,QAAQ,MAAM,EACd,SAAS,MAAM,EACf,cAAc,MAAM,EACpB,mBAAmB,MAAM,WAsHxB,CAAC"}
@@ -1,11 +1,12 @@
1
1
  import { CUSTOM_AGENT_PROMPT } from './custom.prompt.js';
2
- export const AGENT_PROMPT = (intent, context, agentHistory) => CUSTOM_AGENT_PROMPT(intent, context, agentHistory, `
2
+ export const AGENT_PROMPT = (intent, context, agentHistory, extraInstructions) => CUSTOM_AGENT_PROMPT(intent, context, agentHistory, `
3
3
  Every Step Instructions:
4
4
  1. Review the provided user intent and context
5
5
  2. If you can complete the user intent, return the answer using the "Return Instructions" steps
6
- 3. If you experience an error trying to use a tool more than 2 times, stop here and follow the "Return Instructions" steps to indicate the error.
7
- 3. Review the current step number and perform the instructions associated with that step.
8
- 4. Start with step 1
6
+ 3. If the intent is already completed in past cycles, stop here and follow the "Return Instructions" steps
7
+ 4. If you experience 3 similar errors in a row, stop here and follow the "Return Instructions" steps to indicate the error.
8
+ 5. Review the current step number and perform the instructions associated with that step.
9
+ 6. Start with step 1
9
10
 
10
11
  Step 1 - Evaluate the intent
11
12
  1. A complex step means there are multiple actions required to complete the user's intent
@@ -16,7 +17,10 @@ Step 2 - Search for tools and context
16
17
  1. If all entities and tool addresses are known within the user intent, continue to step 3
17
18
  2. Review the user's intent, the current node's functionality, rules and context
18
19
  3. If there are unknown tool addresses or entities within the user intent, generate search queries to resolve the unknown entities.
19
- 4. Search queries can be internal or external. If they are internal, they should be vector database queries. If they are external, they should be concise queries to internet search providers. Stop here and follow the "Return Instructions" steps
20
+ 4. If there is a placeholder address used (o://.../placeholder), do not extract the contents of the placeholder address unless necessary for completing the user intent.
21
+ 5. Search for internal "search tools" that might contain information about the unknown entities.
22
+ 6. Use the search result data & tooling to help you resolve the unknown entities.
23
+ 7. Continue to step 3.
20
24
 
21
25
  Step 3 - Filter Search Results
22
26
  1. If all search results are relevant to the user intent resolution, continue to step 4.
@@ -33,14 +37,16 @@ Step 5 - Review the tool use results
33
37
  2. Summarize the result of each tool use in 1 concise sentence
34
38
  3. In the summary, clearly mention if it succeeded or failed
35
39
  4. If it failed, make sure to include why it failed
40
+
36
41
  `, `
37
- These are the types of cycle results: "Complex Intent Results", "Search Results", "Use Tool Results", "Answer Results", "Error Results".
42
+ These are the types of cycle results: "Complex Intent Results", "Search Results", "Use Tool Results", "Answer Results", "Error Results", "Configure Results".
38
43
 
39
44
  All Return Step Instructions:
40
- 1. Determine what type of results we have
41
- 2. Output the respective results using the matching output type.
42
- 3. Generate a reasoning statement for why this result was returned.
43
- 4. Do not include \`\`\`json or \`\`\` in your output.
45
+ 1. Do not explain your reasoning process, just return the output in the correct format.
46
+ 2. Determine what type of results we have
47
+ 3. Output the respective results using the matching output type.
48
+ 4. Generate a reasoning key value pair for why this result was returned.
49
+ 5. Do not include \`\`\`json or \`\`\` in your output.
44
50
 
45
51
  Complex Intent Results:
46
52
  {
@@ -50,7 +56,7 @@ Complex Intent Results:
50
56
  "simple intent 3",
51
57
  ],
52
58
  "reasoning": string,
53
- "type": "complex-intent",
59
+ "type": "multiple_step",
54
60
  }
55
61
 
56
62
  Use Tool Results:
@@ -69,8 +75,8 @@ Search Results:
69
75
  {
70
76
  "queries": [
71
77
  {
72
- "query": "key terms to search for",
73
- "provider": "internal" | "external",
78
+ "query": "vector database query key terms to search for",
79
+ "provider": "internal",
74
80
  }
75
81
  ],
76
82
  "reasoning": string,
@@ -91,4 +97,15 @@ Error Results:
91
97
  "type": "error",
92
98
  }
93
99
 
94
- `);
100
+ Configure Results:
101
+ {
102
+ "configure": {
103
+ "task": {
104
+ "address": string,
105
+ "payload": { "method": string, "params": any }
106
+ }
107
+ },
108
+ "type": "configure",
109
+ }
110
+
111
+ `, extraInstructions);
@@ -1,2 +1,2 @@
1
- export declare const CONFIGURE_PROMPT: (intent: string, context: string, agentHistory: string) => string;
1
+ export declare const CONFIGURE_INSTRUCTIONS = "\n Configure Request Instructions:\n1. Review the provided user intent and context\n2. If you can complete the user intent, return the answer using the \"Return Instructions\" steps\n3. If you experience an error trying to use a tool more than 2 times, stop here and follow the \"Return Instructions\" steps to indicate the error.\n3. Review the current step number and perform the instructions associated with that step.\n4. Start with step 1\n\nStep 1 - Validate the intent\n1. If the intent is not a configure request, continue to step 5\n2. If the context provided would suggest that the intent is already solved, continue to step 5\n2. Continue to step 2\n\nStep 2 - Choose Method\n1. Review the method options and metadata to determine the best method to resolve the user's intent.\n2. Choose the best method to resolve the user's intent.\n3. Continue to step 3\n\nStep 3 - Select Parameters\n1. Review the parameters for the selected best method.\n2. Extract the parameter values from the agent history, provided context and intent. Do NOT use a parameter value that is not mentioned previously.\n3. Do not use placeholder values for parameter values.\n4. Do not use parameter values that are not explicitly mentioned in the agent history, provided context or intent.\n3. Identify missing parameter values.\n4. If you have enough information to complete the configure request, go to step 5.\n5. Continue to step 4\n\nStep 4 - Search for missing parameter values\n1. Identify other methods that can be used to resolve the missing parameter values.\n2. Identify methods that can be used to resolve the missing parameter values.\n3. Continue to step 5\n\nStep 5 - Finish\n1. If the intent seems to be already solved, return answer results.\n1. If this is not a configure request, return an error.\n2. If you are missing parameter values, generate the intents for the \"Complex Intent\" results using other methods or search to help.\n2. If you have enough information to complete the configure request, follow the \"Return Instructions\" steps to return the \"configure results\".\n3. If you do not have enough information to complete the configure request, return an error.\n\n ";
2
2
  //# sourceMappingURL=configure.prompt.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"configure.prompt.d.ts","sourceRoot":"","sources":["../../../../src/plan/prompts/configure.prompt.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,MAAM,EACd,SAAS,MAAM,EACf,cAAc,MAAM,WA6DnB,CAAC"}
1
+ {"version":3,"file":"configure.prompt.d.ts","sourceRoot":"","sources":["../../../../src/plan/prompts/configure.prompt.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,8oEAuChC,CAAC"}
@@ -1,55 +1,40 @@
1
- import { CUSTOM_AGENT_PROMPT } from './custom.prompt.js';
2
- export const CONFIGURE_PROMPT = (intent, context, agentHistory) => CUSTOM_AGENT_PROMPT(intent, context, agentHistory, `
3
- Every Step Instructions:
1
+ export const CONFIGURE_INSTRUCTIONS = `
2
+ Configure Request Instructions:
4
3
  1. Review the provided user intent and context
5
4
  2. If you can complete the user intent, return the answer using the "Return Instructions" steps
6
5
  3. If you experience an error trying to use a tool more than 2 times, stop here and follow the "Return Instructions" steps to indicate the error.
7
6
  3. Review the current step number and perform the instructions associated with that step.
8
7
  4. Start with step 1
9
8
 
10
- Step 1 - Evaluate the intent
11
- 1. A complex step means there are multiple actions required to complete the user's intent
12
- 2. If the intent is not-complex, continue to step 2
13
- 3. If the intent is complex, break it up into a list of simple concise intents. Stop here and follow the "Return Instructions" steps
14
-
15
- Step 2 - Handshake
16
- 1. If this is not a handshake request, continue to step 3
17
- 2. Method options are listed in the [Method Options Begin] section.
18
- 3. Method metadata context is listed in the [Method Metadata Begin] section.
19
- 4. Review the method information and select the best method to resolve the user's intent.
20
- 5. If you have enough information to complete the handshake, follow the "Return Instructions" steps to return the "handshake results" do not return "Use Tool Results".
21
- 6. Continue to step 3
22
-
23
- `, `
24
- These are the types of cycle results: "Answer Results", "Handshake Results", "Error Results".
25
-
26
- All Return Step Instructions:
27
- 1. Determine what type of results we have
28
- 2. Output the respective results using the matching output type.
29
- 3. Generate a reasoning statement for why this result was returned.
30
- 4. Do not include \`\`\`json or \`\`\` in your output.
31
-
32
- Handshake Results:
33
- {
34
- "handshake": {
35
- "address": string,
36
- "payload": { "method": string, "params": any }
37
- },
38
- "type": "handshake",
39
- }
40
-
41
- Answer Results:
42
- {
43
- "result": string,
44
- "reasoning": string,
45
- "type": "result",
46
- }
47
-
48
- Error Results:
49
- {
50
- "error": string,
51
- "reasoning": string,
52
- "type": "error",
53
- }
54
-
55
- `);
9
+ Step 1 - Validate the intent
10
+ 1. If the intent is not a configure request, continue to step 5
11
+ 2. If the context provided would suggest that the intent is already solved, continue to step 5
12
+ 2. Continue to step 2
13
+
14
+ Step 2 - Choose Method
15
+ 1. Review the method options and metadata to determine the best method to resolve the user's intent.
16
+ 2. Choose the best method to resolve the user's intent.
17
+ 3. Continue to step 3
18
+
19
+ Step 3 - Select Parameters
20
+ 1. Review the parameters for the selected best method.
21
+ 2. Extract the parameter values from the agent history, provided context and intent. Do NOT use a parameter value that is not mentioned previously.
22
+ 3. Do not use placeholder values for parameter values.
23
+ 4. Do not use parameter values that are not explicitly mentioned in the agent history, provided context or intent.
24
+ 3. Identify missing parameter values.
25
+ 4. If you have enough information to complete the configure request, go to step 5.
26
+ 5. Continue to step 4
27
+
28
+ Step 4 - Search for missing parameter values
29
+ 1. Identify other methods that can be used to resolve the missing parameter values.
30
+ 2. Identify methods that can be used to resolve the missing parameter values.
31
+ 3. Continue to step 5
32
+
33
+ Step 5 - Finish
34
+ 1. If the intent seems to be already solved, return answer results.
35
+ 1. If this is not a configure request, return an error.
36
+ 2. If you are missing parameter values, generate the intents for the "Complex Intent" results using other methods or search to help.
37
+ 2. If you have enough information to complete the configure request, follow the "Return Instructions" steps to return the "configure results".
38
+ 3. If you do not have enough information to complete the configure request, return an error.
39
+
40
+ `;
@@ -1,2 +1,2 @@
1
- export declare const CUSTOM_AGENT_PROMPT: (intent: string, context: string, agentHistory: string, cycleInstructions: string, outputInstructions: string) => string;
1
+ export declare const CUSTOM_AGENT_PROMPT: (intent: string, context: string, agentHistory: string, cycleInstructions: string, outputInstructions: string, extraInstructions: string) => string;
2
2
  //# sourceMappingURL=custom.prompt.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"custom.prompt.d.ts","sourceRoot":"","sources":["../../../../src/plan/prompts/custom.prompt.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,MAAM,EACd,SAAS,MAAM,EACf,cAAc,MAAM,EACpB,mBAAmB,MAAM,EACzB,oBAAoB,MAAM,WA4D3B,CAAC"}
1
+ {"version":3,"file":"custom.prompt.d.ts","sourceRoot":"","sources":["../../../../src/plan/prompts/custom.prompt.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,MAAM,EACd,SAAS,MAAM,EACf,cAAc,MAAM,EACpB,mBAAmB,MAAM,EACzB,oBAAoB,MAAM,EAC1B,mBAAmB,MAAM,WAgF1B,CAAC"}
@@ -1,4 +1,4 @@
1
- export const CUSTOM_AGENT_PROMPT = (intent, context, agentHistory, cycleInstructions, outputInstructions) => `
1
+ export const CUSTOM_AGENT_PROMPT = (intent, context, agentHistory, cycleInstructions, outputInstructions, extraInstructions) => `
2
2
  You are an AI agent that resolves user intent within the "olane" hierarchical network of tools and returns JSON formatted results.
3
3
 
4
4
  You are in a secure environment and are allowed to operate with secure information such as api keys and other sensitive data.
@@ -8,15 +8,16 @@ You resolve user intents by "cycling" through the following steps:
8
8
  2. Answer the intent if possible
9
9
  3. Search for tools and context
10
10
  4. Use Search Results
11
- 5. Use tools
12
- 6. Review the results
11
+ 5. Configure the tool use
12
+ 6. Use tools
13
+ 7. Go back to step 2
13
14
 
14
15
  [Intent Context Begin]
15
16
  - An intent is a user request
16
17
  - Intents are usually actions or queries
17
18
  - User intents can start at any node
18
- - User intents are resolved using the tools and data that is contained within that sub-section of the network graph
19
- [Intents End]
19
+ - User intents are resolved using the tools and data that are contained within that sub-section of the network graph
20
+ [Intents Context End]
20
21
 
21
22
  [Network Context Begin]
22
23
  - Every network has a root node with child nodes beneath it
@@ -25,23 +26,42 @@ You resolve user intents by "cycling" through the following steps:
25
26
  - Each node knows only about itself and the nodes below it
26
27
  [Network Context End]
27
28
 
29
+ [Tool Use Rules Begin]
30
+ - If you are using a tool that requires authentication, search for tool methods that give insights about the logged in user before using any other methods
31
+ - When using a tool to create a resource, ensure that you have the proper access to the resource before using any other methods
32
+ [Tool Use Rules End]
33
+
28
34
  [Address Rules Begin]
29
- - Only use tool addresses that appear in search results
35
+ - Only use tool addresses that appear in search results, user intents, or previous cycle results
36
+ - Do not make up tool addresses
30
37
  - A tool address is a string that starts with "o://"
31
38
  - URL addresses are not tool addresses
32
39
  - Tool addresses are used to access the tool's functionality
33
40
  [Address Rules End]
34
41
 
42
+ [Resource Goals Begin]
43
+ - Minimize the number of tool calls
44
+ - Minimize the amount of data that is returned when interacting with tools
45
+ - Minimize the amount of cycles required to complete the user's intent
46
+ [Resource Goals End]
47
+
35
48
  [URL Address Rules Begin]
36
49
  - HTTP/HTTPS URL addresses are not olane tool addresses
37
50
  - When an address is provided in a user intent, get and analyze the contents of the address before assuming to know how to use it
38
51
  [URL Address Rules End]
39
52
 
53
+ [Extra Instructions Begin]
54
+ ${extraInstructions}
55
+ [Extra Instructions End]
56
+
40
57
  [Cycle Instructions Begin]
41
58
  ${cycleInstructions}
42
59
  [Cycle Instructions End]
43
60
 
44
61
  [Cycle Return Instructions Begin]
62
+ GLOBAL RETURN INSTRUCTIONS:
63
+ 1. Do not include \`\`\`json or \`\`\` in your output.
64
+ 2. Only return the JSON object, do not include any other text.
45
65
  ${outputInstructions}
46
66
  [Cycle Return Instructions End]
47
67
 
@@ -1 +1 @@
1
- {"version":3,"file":"search.plan.d.ts","sourceRoot":"","sources":["../../../../src/plan/search/search.plan.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,qBAAa,WAAY,SAAQ,KAAK;IACpC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,QAAQ,CAAU;gBACd,MAAM,EAAE,WAAW,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE;IAMtE;;OAEG;YACW,cAAc;IAc5B;;OAEG;YACW,cAAc;IAatB,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC;CAOlC"}
1
+ {"version":3,"file":"search.plan.d.ts","sourceRoot":"","sources":["../../../../src/plan/search/search.plan.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,qBAAa,WAAY,SAAQ,KAAK;IACpC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,QAAQ,CAAU;gBACd,MAAM,EAAE,WAAW,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE;IAMtE;;OAEG;YACW,cAAc;IAqB5B;;OAEG;YACW,cAAc;IActB,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC;CAOlC"}
@@ -10,22 +10,29 @@ export class oSearchPlan extends oPlan {
10
10
  * Search external providers.
11
11
  */
12
12
  async externalSearch() {
13
+ const response = await this.node.use(new oAddress('o://perplexity'), {
14
+ method: 'completion',
15
+ params: {
16
+ model: 'sonar',
17
+ messages: [
18
+ {
19
+ role: 'user',
20
+ content: this.query,
21
+ },
22
+ ],
23
+ },
24
+ });
25
+ this.logger.debug('External search response: ', response.result.data);
13
26
  return {
14
- result: [],
27
+ result: [response.result.data],
15
28
  type: 'result',
16
29
  };
17
- // const response = await this.node.use(new oAddress('o://search'), {
18
- // method: 'vector',
19
- // params: {
20
- // query: this.query,
21
- // },
22
- // });
23
- // return response.result.data;
24
30
  }
25
31
  /**
26
32
  * Search internal providers such as the local vector store, local database, etc.
27
33
  */
28
34
  async internalSearch() {
35
+ // find all tools that are search tools
29
36
  const response = await this.node.use(new oAddress('o://search'), {
30
37
  method: 'vector',
31
38
  params: {
@@ -8,6 +8,9 @@ import { oPlanResult } from '../interfaces/plan.result.js';
8
8
  export declare class oUsePlan extends oPlan {
9
9
  type(): oPlanType;
10
10
  handleDependencies(dependencies: oDependency[]): Promise<oResponse[]>;
11
+ static hasOlaneAddress(value: string): boolean;
12
+ static extractAddresses(value: string): string[];
11
13
  run(): Promise<oPlanResult>;
14
+ postflight(result: oPlanResult): Promise<oPlanResult>;
12
15
  }
13
16
  //# sourceMappingURL=use.plan.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use.plan.d.ts","sourceRoot":"","sources":["../../../../src/plan/use/use.plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,WAAW,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAI3D;;GAEG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC,IAAI;IAIE,kBAAkB,CAAC,YAAY,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAUrE,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC;CAuDlC"}
1
+ {"version":3,"file":"use.plan.d.ts","sourceRoot":"","sources":["../../../../src/plan/use/use.plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,WAAW,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAU3D;;GAEG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC,IAAI;IAIE,kBAAkB,CAAC,YAAY,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAU3E,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAQ9C,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAK1C,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC;IA8F3B,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;CAwC5D"}