@olane/o-intelligence 0.6.1 → 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,EAAE,MAAM,eAAe,CAAC;AACzC,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) {
@@ -66,22 +87,17 @@ export class IntelligenceTool extends oVirtualTool {
66
87
  }
67
88
  throw new Error('Invalid model provider choice, please set the MODEL_PROVIDER_CHOICE environment variable to a valid model provider');
68
89
  }
90
+ let model = LLMProviders.ANTHROPIC;
69
91
  // check secure storage for preference
70
- const config = await this.use(new oAddress('o://secure-storage'), {
71
- method: 'get',
72
- params: {
73
- key: IntelligenceStorageKeys.MODEL_PROVIDER_PREFERENCE,
74
- },
75
- });
76
- const payload = config.result.data;
77
- if (payload && payload.value) {
78
- const modelProvider = payload.value;
92
+ const modelProviderStored = await this.getSecureValue(IntelligenceStorageKeys.MODEL_PROVIDER_PREFERENCE);
93
+ if (modelProviderStored) {
94
+ model = modelProviderStored;
79
95
  return {
80
- provider: modelProvider,
96
+ provider: model,
81
97
  };
82
98
  }
83
- // we need to ask the human for the model provider
84
- this.logger.info('Asking human for model selection');
99
+ // no preference found, ask the human
100
+ this.logger.info('Asking human for model selection...');
85
101
  const modelResponse = await this.use(new oAddress('o://human'), {
86
102
  method: 'question',
87
103
  params: {
@@ -89,8 +105,9 @@ export class IntelligenceTool extends oVirtualTool {
89
105
  },
90
106
  });
91
107
  // process the human response
92
- const { answer: model } = modelResponse.result.data;
93
- await this.use(new oAddress('o://secure-storage'), {
108
+ const { answer: modelHuman } = modelResponse.result.data;
109
+ model = modelHuman.toLowerCase();
110
+ await this.use(new oAddress('o://secure'), {
94
111
  method: 'put',
95
112
  params: {
96
113
  key: IntelligenceStorageKeys.MODEL_PROVIDER_PREFERENCE,
@@ -136,21 +153,16 @@ export class IntelligenceTool extends oVirtualTool {
136
153
  apiKey: modelEnvConfig.key,
137
154
  };
138
155
  }
156
+ let apiKey = '';
139
157
  // check secure storage 2nd
140
- const config = await this.use(new oAddress('o://secure-storage'), {
141
- method: 'get',
142
- params: {
143
- key: `${provider}-${IntelligenceStorageKeys.API_KEY_SUFFIX}`,
144
- },
145
- });
146
- const payload = config.result.data;
147
- if (payload && payload.value) {
148
- const apiKey = payload.value;
158
+ const apiKeyStored = await this.getSecureValue(`${provider}-${IntelligenceStorageKeys.API_KEY_SUFFIX}`);
159
+ if (apiKeyStored) {
149
160
  return {
150
- apiKey,
161
+ apiKey: apiKeyStored,
151
162
  };
152
163
  }
153
- // we need to ask the human for the api key
164
+ // no preference found, ask the human
165
+ this.logger.info('Asking human for API key...');
154
166
  const keyResponse = await this.use(new oAddress('o://human'), {
155
167
  method: 'question',
156
168
  params: {
@@ -159,7 +171,8 @@ export class IntelligenceTool extends oVirtualTool {
159
171
  });
160
172
  // process the human response
161
173
  const { answer: key } = keyResponse.result.data;
162
- await this.use(new oAddress('o://secure-storage'), {
174
+ apiKey = key;
175
+ await this.use(new oAddress('o://secure'), {
163
176
  method: 'put',
164
177
  params: {
165
178
  key: `${provider}-${IntelligenceStorageKeys.API_KEY_SUFFIX}`,
@@ -167,16 +180,95 @@ export class IntelligenceTool extends oVirtualTool {
167
180
  },
168
181
  });
169
182
  return {
170
- apiKey: key,
183
+ apiKey: apiKey,
184
+ };
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
+ },
171
208
  };
172
209
  }
173
210
  async chooseIntelligence(request) {
174
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
+ }
175
224
  const { provider } = await this.getModelProvider();
176
225
  const { apiKey } = await this.getProviderApiKey(provider);
177
226
  return {
178
227
  choice: new oAddress(`o://${provider}`),
179
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,
180
272
  };
181
273
  }
182
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.1",
3
+ "version": "0.6.3",
4
4
  "type": "module",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -37,10 +37,6 @@
37
37
  "devDependencies": {
38
38
  "@eslint/eslintrc": "^3.3.1",
39
39
  "@eslint/js": "^9.29.0",
40
- "@olane/o-config": "0.6.1",
41
- "@olane/o-core": "0.6.1",
42
- "@olane/o-protocol": "0.6.1",
43
- "@olane/o-tool": "0.6.1",
44
40
  "@tsconfig/node20": "^20.1.6",
45
41
  "@types/jest": "^30.0.0",
46
42
  "@typescript-eslint/eslint-plugin": "^8.34.1",
@@ -58,10 +54,10 @@
58
54
  "typescript": "5.4.5"
59
55
  },
60
56
  "peerDependencies": {
61
- "@olane/o-config": "^0.6.1",
62
- "@olane/o-core": "^0.6.1",
63
- "@olane/o-protocol": "^0.6.1",
64
- "@olane/o-tool": "^0.6.1"
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"
65
61
  },
66
62
  "dependencies": {
67
63
  "debug": "^4.4.1",