@olane/o-intelligence 0.6.5 → 0.6.7

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.
@@ -2,6 +2,7 @@ import { oRequest } from '@olane/o-core';
2
2
  import { oToolConfig, oVirtualTool, ToolResult } from '@olane/o-tool';
3
3
  export declare class AnthropicIntelligenceTool extends oVirtualTool {
4
4
  private defaultModel;
5
+ private apiKey;
5
6
  constructor(config: oToolConfig);
6
7
  /**
7
8
  * Chat completion with Anthropic
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic-intelligence.tool.d.ts","sourceRoot":"","sources":["../../src/anthropic-intelligence.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAmGtE,qBAAa,yBAA0B,SAAQ,YAAY;IACzD,OAAO,CAAC,YAAY,CAA8B;gBAEtC,MAAM,EAAE,WAAW;IAW/B;;OAEG;IACG,gBAAgB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAqE9D;;OAEG;IACG,cAAc,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IA+E5D;;OAEG;IACG,iBAAiB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IA4C/D;;OAEG;IACG,gBAAgB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAoD9D;;OAEG;IACG,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAwC1D;;OAEG;IACH,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA+GlB;;OAEG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AOnB;;OAEG;IACH,kBAAkB;;;;;;;;;;IAalB;;OAEG;IACH,cAAc;;;;CAMf"}
@@ -12,6 +12,7 @@ export class AnthropicIntelligenceTool extends oVirtualTool {
12
12
  dependencies: [],
13
13
  });
14
14
  this.defaultModel = 'claude-sonnet-4-20250514';
15
+ this.apiKey = process.env.ANTHROPIC_API_KEY || '';
15
16
  }
16
17
  /**
17
18
  * Chat completion with Anthropic
@@ -19,7 +20,7 @@ export class AnthropicIntelligenceTool extends oVirtualTool {
19
20
  async _tool_completion(request) {
20
21
  try {
21
22
  const params = request.params;
22
- const { model = this.defaultModel, messages, system, max_tokens = 1000, apiKey, } = params;
23
+ const { model = this.defaultModel, messages, system, max_tokens = 1000, apiKey = this.apiKey, } = params;
23
24
  if (!apiKey) {
24
25
  return {
25
26
  success: false,
@@ -77,7 +78,7 @@ export class AnthropicIntelligenceTool extends oVirtualTool {
77
78
  async _tool_generate(request) {
78
79
  try {
79
80
  const params = request.params;
80
- const { model = this.defaultModel, prompt, system, max_tokens = 1000, apiKey, ...options } = params;
81
+ const { model = this.defaultModel, prompt, system, max_tokens = 1000, apiKey = this.apiKey, ...options } = params;
81
82
  if (!apiKey) {
82
83
  return {
83
84
  success: false,
@@ -143,7 +144,7 @@ export class AnthropicIntelligenceTool extends oVirtualTool {
143
144
  async _tool_list_models(request) {
144
145
  try {
145
146
  const params = request.params;
146
- const { apiKey } = params;
147
+ const { apiKey = this.apiKey } = params;
147
148
  if (!apiKey) {
148
149
  return {
149
150
  success: false,
@@ -184,7 +185,7 @@ export class AnthropicIntelligenceTool extends oVirtualTool {
184
185
  async _tool_model_info(request) {
185
186
  try {
186
187
  const params = request.params;
187
- const { model = this.defaultModel, apiKey } = params;
188
+ const { model = this.defaultModel, apiKey = this.apiKey } = params;
188
189
  if (!apiKey) {
189
190
  return {
190
191
  success: false,
@@ -232,7 +233,7 @@ export class AnthropicIntelligenceTool extends oVirtualTool {
232
233
  async _tool_status(request) {
233
234
  try {
234
235
  const params = request.params;
235
- const { apiKey } = params;
236
+ const { apiKey = this.apiKey } = params;
236
237
  if (!apiKey) {
237
238
  return {
238
239
  success: false,
@@ -1 +1 @@
1
- {"version":3,"file":"gemini-intelligence.tool.d.ts","sourceRoot":"","sources":["../../src/gemini-intelligence.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,QAAQ,EAAgB,MAAM,eAAe,CAAC;AACjE,OAAO,EAAS,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAiH7E,qBAAa,sBAAuB,SAAQ,YAAY;IACtD,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,YAAY,CAAU;gBAElB,MAAM,EAAE,WAAW;IAU/B;;OAEG;IACG,gBAAgB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAkF9D;;OAEG;IACG,cAAc,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAmF5D;;OAEG;IACG,iBAAiB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IA0C/D;;OAEG;IACG,gBAAgB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IA4C9D;;OAEG;IACG,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;CAiC3D"}
1
+ {"version":3,"file":"gemini-intelligence.tool.d.ts","sourceRoot":"","sources":["../../src/gemini-intelligence.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,QAAQ,EAAgB,MAAM,eAAe,CAAC;AACjE,OAAO,EAAS,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAiH7E,qBAAa,sBAAuB,SAAQ,YAAY;IACtD,OAAO,CAAC,MAAM,CAA4C;IAC1D,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,YAAY,CAAU;gBAElB,MAAM,EAAE,WAAW;IAU/B;;OAEG;IACG,gBAAgB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAkF9D;;OAEG;IACG,cAAc,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAmF5D;;OAEG;IACG,iBAAiB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IA0C/D;;OAEG;IACG,gBAAgB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IA4C9D;;OAEG;IACG,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;CAiC3D"}
@@ -10,6 +10,7 @@ export class GeminiIntelligenceTool extends oVirtualTool {
10
10
  methods: INTELLIGENCE_PARAMS,
11
11
  dependencies: [],
12
12
  });
13
+ this.apiKey = process.env.GEMINI_API_KEY || '';
13
14
  }
14
15
  /**
15
16
  * Chat completion with Gemini
@@ -3,6 +3,7 @@ import { oToolConfig, oVirtualTool, ToolResult } from '@olane/o-tool';
3
3
  export declare class GrokIntelligenceTool extends oVirtualTool {
4
4
  private baseUrl;
5
5
  private defaultModel;
6
+ private apiKey;
6
7
  constructor(config: oToolConfig);
7
8
  _tool_completion(request: oRequest): Promise<ToolResult>;
8
9
  _tool_generate(request: oRequest): Promise<ToolResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"grok-intelligence.tool.d.ts","sourceRoot":"","sources":["../../src/grok-intelligence.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AA8CtE,qBAAa,oBAAqB,SAAQ,YAAY;IACpD,OAAO,CAAC,OAAO,CAAiC;IAChD,OAAO,CAAC,YAAY,CAAyB;gBAEjC,MAAM,EAAE,WAAW;IAUzB,gBAAgB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAiExD,cAAc,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAqEtD,iBAAiB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAiCzD,gBAAgB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAgCxD,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;CA+B3D"}
1
+ {"version":3,"file":"grok-intelligence.tool.d.ts","sourceRoot":"","sources":["../../src/grok-intelligence.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AA8CtE,qBAAa,oBAAqB,SAAQ,YAAY;IACpD,OAAO,CAAC,OAAO,CAAiC;IAChD,OAAO,CAAC,YAAY,CAAyB;IAC7C,OAAO,CAAC,MAAM,CAA0C;gBAE5C,MAAM,EAAE,WAAW;IAUzB,gBAAgB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAiExD,cAAc,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAqEtD,iBAAiB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAiCzD,gBAAgB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAgCxD,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;CA+B3D"}
@@ -12,11 +12,12 @@ export class GrokIntelligenceTool extends oVirtualTool {
12
12
  });
13
13
  this.baseUrl = 'https://api.x.ai/v1';
14
14
  this.defaultModel = 'grok-3-mini';
15
+ this.apiKey = process.env.GROK_API_KEY || '';
15
16
  }
16
17
  async _tool_completion(request) {
17
18
  try {
18
19
  const params = request.params;
19
- const { model = this.defaultModel, messages, apiKey, ...options } = params;
20
+ const { model = this.defaultModel, messages, apiKey = this.apiKey, ...options } = params;
20
21
  const key = apiKey || process.env.GROK_API_KEY;
21
22
  if (!key) {
22
23
  return { success: false, error: 'Grok API key is required' };
@@ -69,7 +70,7 @@ export class GrokIntelligenceTool extends oVirtualTool {
69
70
  async _tool_generate(request) {
70
71
  try {
71
72
  const params = request.params;
72
- const { model = this.defaultModel, prompt, system, apiKey, ...options } = params;
73
+ const { model = this.defaultModel, prompt, system, apiKey = this.apiKey, ...options } = params;
73
74
  const key = apiKey || process.env.GROK_API_KEY;
74
75
  if (!key) {
75
76
  return { success: false, error: 'Grok API key is required' };
@@ -126,7 +127,7 @@ export class GrokIntelligenceTool extends oVirtualTool {
126
127
  async _tool_list_models(request) {
127
128
  try {
128
129
  const params = request.params;
129
- const { apiKey } = params;
130
+ const { apiKey = this.apiKey } = params;
130
131
  const key = apiKey || process.env.GROK_API_KEY;
131
132
  if (!key) {
132
133
  return { success: false, error: 'Grok API key is required' };
@@ -155,7 +156,7 @@ export class GrokIntelligenceTool extends oVirtualTool {
155
156
  async _tool_model_info(request) {
156
157
  try {
157
158
  const params = request.params;
158
- const { model = this.defaultModel, apiKey } = params;
159
+ const { model = this.defaultModel, apiKey = this.apiKey } = params;
159
160
  const key = apiKey || process.env.GROK_API_KEY;
160
161
  if (!key) {
161
162
  return { success: false, error: 'Grok API key is required' };
@@ -184,7 +185,7 @@ export class GrokIntelligenceTool extends oVirtualTool {
184
185
  async _tool_status(request) {
185
186
  try {
186
187
  const params = request.params;
187
- const { apiKey } = params;
188
+ const { apiKey = this.apiKey } = params;
188
189
  const key = apiKey || process.env.GROK_API_KEY;
189
190
  if (!key) {
190
191
  return {
@@ -1,10 +1,10 @@
1
1
  import { oToolConfig, oVirtualTool } from '@olane/o-tool';
2
2
  import { oAddress } from '@olane/o-core';
3
- import { oRequest } from '@olane/o-core';
4
3
  import { ToolResult } from '@olane/o-tool';
5
4
  import { LLMProviders } from './enums/llm-providers.enum.js';
6
5
  import { ConfigureRequest } from './interfaces/configure.request.js';
7
6
  import { HostModelProvider } from './enums/host-model-provider.enum.js';
7
+ import { PromptRequest } from './interfaces/prompt.request.js';
8
8
  export declare class IntelligenceTool extends oVirtualTool {
9
9
  private roundRobinIndex;
10
10
  constructor(config: oToolConfig);
@@ -19,13 +19,13 @@ export declare class IntelligenceTool extends oVirtualTool {
19
19
  provider: HostModelProvider;
20
20
  options: any;
21
21
  }>;
22
- chooseIntelligence(request: oRequest): Promise<{
22
+ chooseIntelligence(request: PromptRequest): Promise<{
23
23
  choice: oAddress;
24
24
  apiKey: string;
25
25
  options: any;
26
- method: string;
27
26
  }>;
28
27
  _tool_configure(request: ConfigureRequest): Promise<ToolResult>;
29
- _tool_prompt(request: oRequest): Promise<ToolResult>;
28
+ attemptUseOlaneIntelligence(request: PromptRequest): Promise<ToolResult | null>;
29
+ _tool_prompt(request: PromptRequest): Promise<ToolResult>;
30
30
  }
31
31
  //# 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;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAGxE,qBAAa,gBAAiB,SAAQ,YAAY;IAChD,OAAO,CAAC,eAAe,C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D,OAAO,CAAC,eAAe,CAAK;gBAChB,MAAM,EAAE,WAAW;IA0DzB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAmBnD,gBAAgB,IAAI,OAAO,CAAC;QAAE,QAAQ,EAAE,YAAY,CAAA;KAAE,CAAC;IA6DvD,iBAAiB,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAqEtE,kBAAkB,IAAI,OAAO,CAAC;QAClC,QAAQ,EAAE,iBAAiB,CAAC;QAC5B,OAAO,EAAE,GAAG,CAAC;KACd,CAAC;IA+BI,kBAAkB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC;QACxD,MAAM,EAAE,QAAQ,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,GAAG,CAAC;KACd,CAAC;IAWI,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;IA4C/D,2BAA2B,CAC/B,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IA8BvB,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC;CAwBhE"}
@@ -98,22 +98,28 @@ export class IntelligenceTool extends oVirtualTool {
98
98
  }
99
99
  // no preference found, ask the human
100
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();
110
- await this.use(new oAddress('o://secure'), {
111
- method: 'put',
112
- params: {
113
- key: IntelligenceStorageKeys.MODEL_PROVIDER_PREFERENCE,
114
- value: model,
115
- },
116
- });
101
+ try {
102
+ const modelResponse = await this.use(new oAddress('o://human'), {
103
+ method: 'question',
104
+ params: {
105
+ question: 'Which AI model do you want to use? (anthropic, openai, ollama, perplexity, grok)',
106
+ },
107
+ });
108
+ // process the human response
109
+ const { answer: modelHuman } = modelResponse.result.data;
110
+ model = modelHuman.toLowerCase();
111
+ await this.use(new oAddress('o://secure'), {
112
+ method: 'put',
113
+ params: {
114
+ key: IntelligenceStorageKeys.MODEL_PROVIDER_PREFERENCE,
115
+ value: model,
116
+ },
117
+ });
118
+ }
119
+ catch (error) {
120
+ this.logger.warn('Defaulting to anthropic');
121
+ model = LLMProviders.ANTHROPIC;
122
+ }
117
123
  return {
118
124
  provider: model,
119
125
  };
@@ -209,26 +215,12 @@ export class IntelligenceTool extends oVirtualTool {
209
215
  }
210
216
  async chooseIntelligence(request) {
211
217
  // 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
- method: 'prompt',
223
- };
224
- }
225
218
  const { provider } = await this.getModelProvider();
226
219
  const { apiKey } = await this.getProviderApiKey(provider);
227
220
  return {
228
221
  choice: new oAddress(`o://${provider}`),
229
222
  apiKey,
230
223
  options: {},
231
- method: 'completion',
232
224
  };
233
225
  }
234
226
  async _tool_configure(request) {
@@ -273,13 +265,40 @@ export class IntelligenceTool extends oVirtualTool {
273
265
  success: true,
274
266
  };
275
267
  }
268
+ async attemptUseOlaneIntelligence(request) {
269
+ const { prompt } = request.params;
270
+ const { provider: hostingProvider, options } = await this.getHostingProvider();
271
+ // forward to olane
272
+ if (hostingProvider === HostModelProvider.OLANE) {
273
+ const response = await this.use(new oAddress(options.address, [
274
+ multiaddr('/dns4/leader.olane.com/tcp/4000/tls/ws'),
275
+ ]), {
276
+ method: 'completion',
277
+ params: {
278
+ token: options.token,
279
+ messages: [
280
+ {
281
+ role: 'user',
282
+ content: prompt,
283
+ },
284
+ ],
285
+ },
286
+ });
287
+ return response.result.data;
288
+ }
289
+ return null;
290
+ }
276
291
  // we cannot wrap this tool use in a plan because it is a core dependency in all planning
277
292
  async _tool_prompt(request) {
278
293
  const { prompt } = request.params;
294
+ // attempt to forward to a remote intelligence tool
295
+ const olaneResult = await this.attemptUseOlaneIntelligence(request);
296
+ if (olaneResult) {
297
+ return olaneResult;
298
+ }
279
299
  const intelligence = await this.chooseIntelligence(request);
280
- this.logger.debug('Using AI provider: ', intelligence.choice);
281
300
  const response = await this.use(intelligence.choice, {
282
- method: intelligence.method,
301
+ method: 'completion',
283
302
  params: {
284
303
  apiKey: intelligence.apiKey,
285
304
  messages: [
@@ -0,0 +1,11 @@
1
+ import { oRequest } from '@olane/o-core';
2
+ import { RequestParams } from '@olane/o-protocol';
3
+ export interface CompletionRequest extends oRequest {
4
+ params: RequestParams & {
5
+ messages: {
6
+ role: 'user' | 'assistant';
7
+ content: string;
8
+ }[];
9
+ };
10
+ }
11
+ //# sourceMappingURL=completion.request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"completion.request.d.ts","sourceRoot":"","sources":["../../../src/interfaces/completion.request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,WAAW,iBAAkB,SAAQ,QAAQ;IACjD,MAAM,EAAE,aAAa,GAAG;QACtB,QAAQ,EAAE;YAAE,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;KAC7D,CAAC;CACH"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import { oRequest } from '@olane/o-core';
2
+ import { RequestParams } from '@olane/o-protocol';
3
+ export interface PromptRequest extends oRequest {
4
+ params: RequestParams & {
5
+ prompt: string;
6
+ };
7
+ }
8
+ //# sourceMappingURL=prompt.request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.request.d.ts","sourceRoot":"","sources":["../../../src/interfaces/prompt.request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,WAAW,aAAc,SAAQ,QAAQ;IAC7C,MAAM,EAAE,aAAa,GAAG;QACtB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH"}
@@ -0,0 +1 @@
1
+ export {};
@@ -4,6 +4,7 @@ export declare class OpenAIIntelligenceTool extends oVirtualTool {
4
4
  private baseUrl;
5
5
  private defaultModel;
6
6
  private organization?;
7
+ private apiKey;
7
8
  constructor(config: oToolConfig);
8
9
  /**
9
10
  * Chat completion with OpenAI
@@ -1 +1 @@
1
- {"version":3,"file":"openai-intelligence.tool.d.ts","sourceRoot":"","sources":["../../src/openai-intelligence.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAoHtE,qBAAa,sBAAuB,SAAQ,YAAY;IACtD,OAAO,CAAC,OAAO,CAAuC;IACtD,OAAO,CAAC,YAAY,CAAwB;IAC5C,OAAO,CAAC,YAAY,CAAC,CAAS;gBAElB,MAAM,EAAE,WAAW;IAU/B;;OAEG;IACG,gBAAgB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAyE9D;;OAEG;IACG,cAAc,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAmE5D;;OAEG;IACG,iBAAiB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAgD/D;;OAEG;IACG,gBAAgB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IA+C9D;;OAEG;IACG,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;CAuC3D"}
1
+ {"version":3,"file":"openai-intelligence.tool.d.ts","sourceRoot":"","sources":["../../src/openai-intelligence.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAoHtE,qBAAa,sBAAuB,SAAQ,YAAY;IACtD,OAAO,CAAC,OAAO,CAAuC;IACtD,OAAO,CAAC,YAAY,CAAwB;IAC5C,OAAO,CAAC,YAAY,CAAC,CAAS;IAC9B,OAAO,CAAC,MAAM,CAA4C;gBAE9C,MAAM,EAAE,WAAW;IAU/B;;OAEG;IACG,gBAAgB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAyE9D;;OAEG;IACG,cAAc,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAwE5D;;OAEG;IACG,iBAAiB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAgD/D;;OAEG;IACG,gBAAgB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IA+C9D;;OAEG;IACG,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;CAuC3D"}
@@ -12,6 +12,7 @@ export class OpenAIIntelligenceTool extends oVirtualTool {
12
12
  });
13
13
  this.baseUrl = 'https://api.openai.com/v1';
14
14
  this.defaultModel = 'gpt-5-mini';
15
+ this.apiKey = process.env.OPENAI_API_KEY || '';
15
16
  }
16
17
  /**
17
18
  * Chat completion with OpenAI
@@ -19,7 +20,7 @@ export class OpenAIIntelligenceTool extends oVirtualTool {
19
20
  async _tool_completion(request) {
20
21
  try {
21
22
  const params = request.params;
22
- const { model = this.defaultModel, messages, apiKey, ...options } = params;
23
+ const { model = this.defaultModel, messages, apiKey = this.apiKey, ...options } = params;
23
24
  if (!apiKey) {
24
25
  return {
25
26
  success: false,
@@ -80,7 +81,7 @@ export class OpenAIIntelligenceTool extends oVirtualTool {
80
81
  async _tool_generate(request) {
81
82
  try {
82
83
  const params = request.params;
83
- const { model = this.defaultModel, prompt, apiKey, ...options } = params;
84
+ const { model = this.defaultModel, prompt, apiKey = this.apiKey, ...options } = params;
84
85
  if (!apiKey) {
85
86
  return {
86
87
  success: false,
@@ -140,7 +141,7 @@ export class OpenAIIntelligenceTool extends oVirtualTool {
140
141
  async _tool_list_models(request) {
141
142
  try {
142
143
  const params = request.params;
143
- const { apiKey } = params;
144
+ const { apiKey = this.apiKey } = params;
144
145
  if (!apiKey) {
145
146
  return {
146
147
  success: false,
@@ -183,7 +184,7 @@ export class OpenAIIntelligenceTool extends oVirtualTool {
183
184
  async _tool_model_info(request) {
184
185
  try {
185
186
  const params = request.params;
186
- const { model = this.defaultModel, apiKey } = params;
187
+ const { model = this.defaultModel, apiKey = this.apiKey } = params;
187
188
  if (!apiKey) {
188
189
  return {
189
190
  success: false,
@@ -226,7 +227,7 @@ export class OpenAIIntelligenceTool extends oVirtualTool {
226
227
  async _tool_status(request) {
227
228
  try {
228
229
  const params = request.params;
229
- const { apiKey } = params;
230
+ const { apiKey = this.apiKey } = params;
230
231
  if (!apiKey) {
231
232
  return {
232
233
  success: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olane/o-intelligence",
3
- "version": "0.6.5",
3
+ "version": "0.6.7",
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.5",
58
- "@olane/o-core": "^0.6.5",
59
- "@olane/o-protocol": "^0.6.5",
60
- "@olane/o-tool": "^0.6.5"
57
+ "@olane/o-config": "^0.6.7",
58
+ "@olane/o-core": "^0.6.7",
59
+ "@olane/o-protocol": "^0.6.7",
60
+ "@olane/o-tool": "^0.6.7"
61
61
  },
62
62
  "dependencies": {
63
63
  "debug": "^4.4.1",