@olane/o-intelligence 0.6.2 → 0.6.3

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.
@@ -0,0 +1,5 @@
1
+ export declare enum HostModelProvider {
2
+ OLANE = "olane",
3
+ LOCAL = "local"
4
+ }
5
+ //# sourceMappingURL=host-model-provider.enum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-model-provider.enum.d.ts","sourceRoot":"","sources":["../../../src/enums/host-model-provider.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,iBAAiB;IAC3B,KAAK,UAAU;IACf,KAAK,UAAU;CAChB"}
@@ -0,0 +1,5 @@
1
+ export var HostModelProvider;
2
+ (function (HostModelProvider) {
3
+ HostModelProvider["OLANE"] = "olane";
4
+ HostModelProvider["LOCAL"] = "local";
5
+ })(HostModelProvider || (HostModelProvider = {}));
@@ -1,5 +1,8 @@
1
1
  export declare enum IntelligenceStorageKeys {
2
2
  MODEL_PROVIDER_PREFERENCE = "model-provider-preference",
3
- API_KEY_SUFFIX = "api-key"
3
+ API_KEY_SUFFIX = "api-key",
4
+ HOSTING_PROVIDER_PREFERENCE = "hosting-provider-preference",
5
+ ACCESS_TOKEN = "access-token",
6
+ OLANE_ADDRESS = "olane-address"
4
7
  }
5
8
  //# sourceMappingURL=intelligence-storage-keys.enum.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"intelligence-storage-keys.enum.d.ts","sourceRoot":"","sources":["../../../src/enums/intelligence-storage-keys.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,uBAAuB;IACjC,yBAAyB,8BAA8B;IACvD,cAAc,YAAY;CAC3B"}
1
+ {"version":3,"file":"intelligence-storage-keys.enum.d.ts","sourceRoot":"","sources":["../../../src/enums/intelligence-storage-keys.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,uBAAuB;IACjC,yBAAyB,8BAA8B;IACvD,cAAc,YAAY;IAC1B,2BAA2B,gCAAgC;IAC3D,YAAY,iBAAiB;IAC7B,aAAa,kBAAkB;CAChC"}
@@ -2,4 +2,7 @@ export var IntelligenceStorageKeys;
2
2
  (function (IntelligenceStorageKeys) {
3
3
  IntelligenceStorageKeys["MODEL_PROVIDER_PREFERENCE"] = "model-provider-preference";
4
4
  IntelligenceStorageKeys["API_KEY_SUFFIX"] = "api-key";
5
+ IntelligenceStorageKeys["HOSTING_PROVIDER_PREFERENCE"] = "hosting-provider-preference";
6
+ IntelligenceStorageKeys["ACCESS_TOKEN"] = "access-token";
7
+ IntelligenceStorageKeys["OLANE_ADDRESS"] = "olane-address";
5
8
  })(IntelligenceStorageKeys || (IntelligenceStorageKeys = {}));
@@ -3,6 +3,7 @@ export declare enum LLMProviders {
3
3
  OPENAI = "openai",
4
4
  OLLAMA = "ollama",
5
5
  PERPLEXITY = "perplexity",
6
- GROK = "grok"
6
+ GROK = "grok",
7
+ OLANE = "olane"
7
8
  }
8
9
  //# sourceMappingURL=llm-providers.enum.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"llm-providers.enum.d.ts","sourceRoot":"","sources":["../../../src/enums/llm-providers.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY;IACtB,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,UAAU,eAAe;IACzB,IAAI,SAAS;CACd"}
1
+ {"version":3,"file":"llm-providers.enum.d.ts","sourceRoot":"","sources":["../../../src/enums/llm-providers.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY;IACtB,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,UAAU,eAAe;IACzB,IAAI,SAAS;IACb,KAAK,UAAU;CAChB"}
@@ -5,4 +5,5 @@ export var LLMProviders;
5
5
  LLMProviders["OLLAMA"] = "ollama";
6
6
  LLMProviders["PERPLEXITY"] = "perplexity";
7
7
  LLMProviders["GROK"] = "grok";
8
+ LLMProviders["OLANE"] = "olane";
8
9
  })(LLMProviders || (LLMProviders = {}));
@@ -3,19 +3,28 @@ import { oAddress } from '@olane/o-core';
3
3
  import { oRequest } from '@olane/o-core';
4
4
  import { ToolResult } from '@olane/o-tool';
5
5
  import { LLMProviders } from './enums/llm-providers.enum.js';
6
+ import { ConfigureRequest } from './interfaces/configure.request.js';
7
+ import { HostModelProvider } from './enums/host-model-provider.enum.js';
6
8
  export declare class IntelligenceTool extends oVirtualTool {
7
9
  private roundRobinIndex;
8
10
  constructor(config: oToolConfig);
11
+ getSecureValue(key: string): Promise<string | null>;
9
12
  getModelProvider(): Promise<{
10
13
  provider: LLMProviders;
11
14
  }>;
12
15
  getProviderApiKey(provider: LLMProviders): Promise<{
13
16
  apiKey: string;
14
17
  }>;
18
+ getHostingProvider(): Promise<{
19
+ provider: HostModelProvider;
20
+ options: any;
21
+ }>;
15
22
  chooseIntelligence(request: oRequest): Promise<{
16
23
  choice: oAddress;
17
24
  apiKey: string;
25
+ options: any;
18
26
  }>;
27
+ _tool_configure(request: ConfigureRequest): Promise<ToolResult>;
19
28
  _tool_prompt(request: oRequest): Promise<ToolResult>;
20
29
  }
21
30
  //# sourceMappingURL=intelligence.tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"intelligence.tool.d.ts","sourceRoot":"","sources":["../../src/intelligence.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAa,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAQ3C,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,qBAAa,gBAAiB,SAAQ,YAAY;IAChD,OAAO,CAAC,eAAe,CAAK;gBAChB,MAAM,EAAE,WAAW;IA0DzB,gBAAgB,IAAI,OAAO,CAAC;QAAE,QAAQ,EAAE,YAAY,CAAA;KAAE,CAA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+BI,kBAAkB,CACtB,OAAO,EAAE,QAAQ,GAChB,OAAO,CAAC;QAAE,MAAM,EAAE,QAAQ,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,GAAG,CAAA;KAAE,CAAC;IAwBxD,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;IA6C/D,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;CAkB3D"}
@@ -8,6 +8,8 @@ import { GrokIntelligenceTool } from './grok-intelligence.tool.js';
8
8
  import { INTELLIGENCE_PARAMS } from './methods/intelligence.methods.js';
9
9
  import { IntelligenceStorageKeys } from './enums/intelligence-storage-keys.enum.js';
10
10
  import { LLMProviders } from './enums/llm-providers.enum.js';
11
+ import { HostModelProvider } from './enums/host-model-provider.enum.js';
12
+ import { multiaddr } from '@olane/o-config';
11
13
  export class IntelligenceTool extends oVirtualTool {
12
14
  constructor(config) {
13
15
  super({
@@ -56,6 +58,25 @@ export class IntelligenceTool extends oVirtualTool {
56
58
  leader: null,
57
59
  }));
58
60
  }
61
+ async getSecureValue(key) {
62
+ try {
63
+ const response = await this.use(new oAddress('o://secure'), {
64
+ method: 'get',
65
+ params: {
66
+ key: key,
67
+ },
68
+ });
69
+ const payload = response.result.data;
70
+ if (payload && payload.value) {
71
+ return payload.value;
72
+ }
73
+ return null;
74
+ }
75
+ catch (error) {
76
+ this.logger.error('Error getting secure value: ', error);
77
+ return null;
78
+ }
79
+ }
59
80
  async getModelProvider() {
60
81
  // check ENV vars for override
61
82
  if (process.env.MODEL_PROVIDER_CHOICE) {
@@ -68,39 +89,30 @@ export class IntelligenceTool extends oVirtualTool {
68
89
  }
69
90
  let model = LLMProviders.ANTHROPIC;
70
91
  // check secure storage for preference
92
+ const modelProviderStored = await this.getSecureValue(IntelligenceStorageKeys.MODEL_PROVIDER_PREFERENCE);
93
+ if (modelProviderStored) {
94
+ model = modelProviderStored;
95
+ return {
96
+ provider: model,
97
+ };
98
+ }
99
+ // no preference found, ask the human
100
+ this.logger.info('Asking human for model selection...');
101
+ const modelResponse = await this.use(new oAddress('o://human'), {
102
+ method: 'question',
103
+ params: {
104
+ question: 'Which AI model do you want to use? (anthropic, openai, ollama, perplexity, grok)',
105
+ },
106
+ });
107
+ // process the human response
108
+ const { answer: modelHuman } = modelResponse.result.data;
109
+ model = modelHuman.toLowerCase();
71
110
  await this.use(new oAddress('o://secure'), {
72
- method: 'get',
111
+ method: 'put',
73
112
  params: {
74
113
  key: IntelligenceStorageKeys.MODEL_PROVIDER_PREFERENCE,
114
+ value: model,
75
115
  },
76
- })
77
- .then((config) => {
78
- const payload = config.result.data;
79
- if (payload && payload.value) {
80
- const modelProvider = payload.value;
81
- model = modelProvider;
82
- }
83
- })
84
- .catch(async (err) => {
85
- this.logger.error('Error getting model provider preference: ', err);
86
- // we need to ask the human for the model provider
87
- this.logger.info('Asking human for model selection...');
88
- const modelResponse = await this.use(new oAddress('o://human'), {
89
- method: 'question',
90
- params: {
91
- question: 'Which AI model do you want to use? (anthropic, openai, ollama, perplexity, grok)',
92
- },
93
- });
94
- // process the human response
95
- const { answer: modelHuman } = modelResponse.result.data;
96
- model = modelHuman.toLowerCase();
97
- await this.use(new oAddress('o://secure'), {
98
- method: 'put',
99
- params: {
100
- key: IntelligenceStorageKeys.MODEL_PROVIDER_PREFERENCE,
101
- value: model,
102
- },
103
- });
104
116
  });
105
117
  return {
106
118
  provider: model,
@@ -143,49 +155,120 @@ export class IntelligenceTool extends oVirtualTool {
143
155
  }
144
156
  let apiKey = '';
145
157
  // check secure storage 2nd
158
+ const apiKeyStored = await this.getSecureValue(`${provider}-${IntelligenceStorageKeys.API_KEY_SUFFIX}`);
159
+ if (apiKeyStored) {
160
+ return {
161
+ apiKey: apiKeyStored,
162
+ };
163
+ }
164
+ // no preference found, ask the human
165
+ this.logger.info('Asking human for API key...');
166
+ const keyResponse = await this.use(new oAddress('o://human'), {
167
+ method: 'question',
168
+ params: {
169
+ question: `What is the API key for the ${provider} model?`,
170
+ },
171
+ });
172
+ // process the human response
173
+ const { answer: key } = keyResponse.result.data;
174
+ apiKey = key;
146
175
  await this.use(new oAddress('o://secure'), {
147
- method: 'get',
176
+ method: 'put',
148
177
  params: {
149
178
  key: `${provider}-${IntelligenceStorageKeys.API_KEY_SUFFIX}`,
179
+ value: key,
150
180
  },
151
- })
152
- .then((config) => {
153
- const payload = config.result.data;
154
- if (payload && payload.value) {
155
- const apiKeyStored = payload.value;
156
- apiKey = apiKeyStored;
157
- }
158
- })
159
- .catch(async (err) => {
160
- // we need to ask the human for the api key
161
- const keyResponse = await this.use(new oAddress('o://human'), {
162
- method: 'question',
163
- params: {
164
- question: `What is the API key for the ${provider} model?`,
165
- },
166
- });
167
- // process the human response
168
- const { answer: key } = keyResponse.result.data;
169
- apiKey = key;
170
- await this.use(new oAddress('o://secure'), {
171
- method: 'put',
172
- params: {
173
- key: `${provider}-${IntelligenceStorageKeys.API_KEY_SUFFIX}`,
174
- value: key,
175
- },
176
- });
177
181
  });
178
182
  return {
179
183
  apiKey: apiKey,
180
184
  };
181
185
  }
186
+ async getHostingProvider() {
187
+ let provider = HostModelProvider.LOCAL;
188
+ const hostingProviderStored = await this.getSecureValue(IntelligenceStorageKeys.HOSTING_PROVIDER_PREFERENCE);
189
+ if (hostingProviderStored) {
190
+ provider = hostingProviderStored;
191
+ }
192
+ let token = null;
193
+ const accessTokenStored = await this.getSecureValue(IntelligenceStorageKeys.ACCESS_TOKEN);
194
+ if (accessTokenStored) {
195
+ token = accessTokenStored;
196
+ }
197
+ const addressStored = await this.getSecureValue(IntelligenceStorageKeys.OLANE_ADDRESS);
198
+ let address = 'o://leader/auth/intelligence';
199
+ if (addressStored) {
200
+ address = addressStored;
201
+ }
202
+ return {
203
+ provider: provider,
204
+ options: {
205
+ token: token,
206
+ address: address,
207
+ },
208
+ };
209
+ }
182
210
  async chooseIntelligence(request) {
183
211
  // check to see if anthropic key is in vault
212
+ const { provider: hostingProvider, options } = await this.getHostingProvider();
213
+ if (hostingProvider === HostModelProvider.OLANE) {
214
+ return {
215
+ choice: new oAddress(options.address, [
216
+ multiaddr('/dns4/leader.olane.com/tcp/4000/tls/ws'),
217
+ ]),
218
+ apiKey: '',
219
+ options: {
220
+ token: options.token,
221
+ },
222
+ };
223
+ }
184
224
  const { provider } = await this.getModelProvider();
185
225
  const { apiKey } = await this.getProviderApiKey(provider);
186
226
  return {
187
227
  choice: new oAddress(`o://${provider}`),
188
228
  apiKey,
229
+ options: {},
230
+ };
231
+ }
232
+ async _tool_configure(request) {
233
+ const { modelProvider, hostingProvider, accessToken, address } = request.params;
234
+ if (hostingProvider) {
235
+ await this.use(new oAddress('o://secure'), {
236
+ method: 'put',
237
+ params: {
238
+ key: `${IntelligenceStorageKeys.HOSTING_PROVIDER_PREFERENCE}`,
239
+ value: hostingProvider,
240
+ },
241
+ });
242
+ }
243
+ if (accessToken) {
244
+ await this.use(new oAddress('o://secure'), {
245
+ method: 'put',
246
+ params: {
247
+ key: `${IntelligenceStorageKeys.ACCESS_TOKEN}`,
248
+ value: accessToken,
249
+ },
250
+ });
251
+ }
252
+ if (address) {
253
+ await this.use(new oAddress('o://secure'), {
254
+ method: 'put',
255
+ params: {
256
+ key: `${IntelligenceStorageKeys.OLANE_ADDRESS}`,
257
+ value: address,
258
+ },
259
+ });
260
+ }
261
+ if (modelProvider) {
262
+ await this.use(new oAddress('o://secure'), {
263
+ method: 'put',
264
+ params: {
265
+ key: `${IntelligenceStorageKeys.MODEL_PROVIDER_PREFERENCE}`,
266
+ value: modelProvider,
267
+ },
268
+ });
269
+ }
270
+ return {
271
+ success: true,
189
272
  };
190
273
  }
191
274
  // we cannot wrap this tool use in a plan because it is a core dependency in all planning
@@ -0,0 +1,13 @@
1
+ import { oRequest } from '@olane/o-core';
2
+ import { RequestParams } from '@olane/o-protocol';
3
+ import { LLMProviders } from '../enums/llm-providers.enum';
4
+ import { HostModelProvider } from '../enums/host-model-provider.enum';
5
+ export interface ConfigureRequest extends oRequest {
6
+ params: RequestParams & {
7
+ modelProvider: LLMProviders;
8
+ hostingProvider: HostModelProvider;
9
+ accessToken: string;
10
+ address: string;
11
+ };
12
+ }
13
+ //# sourceMappingURL=configure.request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configure.request.d.ts","sourceRoot":"","sources":["../../../src/interfaces/configure.request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,MAAM,WAAW,gBAAiB,SAAQ,QAAQ;IAChD,MAAM,EAAE,aAAa,GAAG;QACtB,aAAa,EAAE,YAAY,CAAC;QAC5B,eAAe,EAAE,iBAAiB,CAAC;QACnC,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH"}
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"intelligence.methods.d.ts","sourceRoot":"","sources":["../../../src/methods/intelligence.methods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,eAAO,MAAM,mBAAmB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAmIzD,CAAC"}
1
+ {"version":3,"file":"intelligence.methods.d.ts","sourceRoot":"","sources":["../../../src/methods/intelligence.methods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,eAAO,MAAM,mBAAmB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAuJzD,CAAC"}
@@ -1,4 +1,23 @@
1
1
  export const INTELLIGENCE_PARAMS = {
2
+ configure: {
3
+ name: 'configure',
4
+ description: 'Configure',
5
+ dependencies: [],
6
+ parameters: [
7
+ {
8
+ name: 'modelProvider',
9
+ type: 'string',
10
+ value: 'string',
11
+ description: 'The model provider to use (anthropic, openai, ollama, perplexity, grok, olane)',
12
+ },
13
+ {
14
+ name: 'hostingProvider',
15
+ type: 'string',
16
+ value: 'string',
17
+ description: 'The hosting provider to use (olane, local)',
18
+ },
19
+ ],
20
+ },
2
21
  completion: {
3
22
  name: 'completion',
4
23
  description: 'Completion',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olane/o-intelligence",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "type": "module",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -54,10 +54,10 @@
54
54
  "typescript": "5.4.5"
55
55
  },
56
56
  "peerDependencies": {
57
- "@olane/o-config": "^0.6.2",
58
- "@olane/o-core": "^0.6.2",
59
- "@olane/o-protocol": "^0.6.2",
60
- "@olane/o-tool": "^0.6.2"
57
+ "@olane/o-config": "^0.6.3",
58
+ "@olane/o-core": "^0.6.3",
59
+ "@olane/o-protocol": "^0.6.3",
60
+ "@olane/o-tool": "^0.6.3"
61
61
  },
62
62
  "dependencies": {
63
63
  "debug": "^4.4.1",