@olane/o-tool-registry 0.6.6 → 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.
Files changed (136) hide show
  1. package/dist/auth/index.d.ts +4 -0
  2. package/dist/auth/index.d.ts.map +1 -0
  3. package/dist/auth/index.js +3 -0
  4. package/dist/auth/interfaces/index.d.ts +4 -0
  5. package/dist/auth/interfaces/index.d.ts.map +1 -0
  6. package/dist/auth/interfaces/index.js +3 -0
  7. package/dist/auth/interfaces/oAuth-tokens.interface.d.ts +9 -0
  8. package/dist/auth/interfaces/oAuth-tokens.interface.d.ts.map +1 -0
  9. package/dist/auth/interfaces/oAuth-tokens.interface.js +1 -0
  10. package/dist/auth/interfaces/oAuth-user-info.interface.d.ts +8 -0
  11. package/dist/auth/interfaces/oAuth-user-info.interface.d.ts.map +1 -0
  12. package/dist/auth/interfaces/oAuth-user-info.interface.js +1 -0
  13. package/dist/auth/interfaces/oAuth.config.d.ts +14 -0
  14. package/dist/auth/interfaces/oAuth.config.d.ts.map +1 -0
  15. package/dist/auth/interfaces/oAuth.config.js +1 -0
  16. package/dist/auth/methods/auth.methods.d.ts +5 -0
  17. package/dist/auth/methods/auth.methods.d.ts.map +1 -0
  18. package/dist/auth/methods/auth.methods.js +302 -0
  19. package/dist/auth/oAuth.tool.d.ts +20 -0
  20. package/dist/auth/oAuth.tool.d.ts.map +1 -0
  21. package/dist/auth/oAuth.tool.js +419 -0
  22. package/dist/embeddings/embeddings.tool.d.ts +6 -0
  23. package/dist/embeddings/embeddings.tool.d.ts.map +1 -0
  24. package/dist/embeddings/embeddings.tool.js +11 -0
  25. package/dist/embeddings/huggingface-text-embeddings.tool.d.ts +9 -0
  26. package/dist/embeddings/huggingface-text-embeddings.tool.d.ts.map +1 -0
  27. package/dist/embeddings/huggingface-text-embeddings.tool.js +21 -0
  28. package/dist/embeddings/index.d.ts +4 -0
  29. package/dist/embeddings/index.d.ts.map +1 -0
  30. package/dist/embeddings/index.js +3 -0
  31. package/dist/embeddings/methods/text-embeddings.method.d.ts +5 -0
  32. package/dist/embeddings/methods/text-embeddings.method.d.ts.map +1 -0
  33. package/dist/embeddings/methods/text-embeddings.method.js +29 -0
  34. package/dist/embeddings/text-embeddings.tool.d.ts +9 -0
  35. package/dist/embeddings/text-embeddings.tool.d.ts.map +1 -0
  36. package/dist/embeddings/text-embeddings.tool.js +13 -0
  37. package/dist/index.d.ts +7 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +6 -0
  40. package/dist/init.d.ts +3 -0
  41. package/dist/init.d.ts.map +1 -0
  42. package/dist/init.js +36 -0
  43. package/dist/intelligence/anthropic-intelligence.tool.d.ts +224 -0
  44. package/dist/intelligence/anthropic-intelligence.tool.d.ts.map +1 -0
  45. package/dist/intelligence/anthropic-intelligence.tool.js +477 -0
  46. package/dist/intelligence/gemini-intelligence.tool.d.ts +29 -0
  47. package/dist/intelligence/gemini-intelligence.tool.d.ts.map +1 -0
  48. package/dist/intelligence/gemini-intelligence.tool.js +267 -0
  49. package/dist/intelligence/index.d.ts +6 -0
  50. package/dist/intelligence/index.d.ts.map +1 -0
  51. package/dist/intelligence/index.js +5 -0
  52. package/dist/intelligence/intelligence.tool.d.ts +11 -0
  53. package/dist/intelligence/intelligence.tool.d.ts.map +1 -0
  54. package/dist/intelligence/intelligence.tool.js +120 -0
  55. package/dist/intelligence/methods/intelligence.methods.d.ts +5 -0
  56. package/dist/intelligence/methods/intelligence.methods.d.ts.map +1 -0
  57. package/dist/intelligence/methods/intelligence.methods.js +98 -0
  58. package/dist/intelligence/ollama-intelligence.tool.d.ts +36 -0
  59. package/dist/intelligence/ollama-intelligence.tool.d.ts.map +1 -0
  60. package/dist/intelligence/ollama-intelligence.tool.js +312 -0
  61. package/dist/intelligence/openai-intelligence.tool.d.ts +30 -0
  62. package/dist/intelligence/openai-intelligence.tool.d.ts.map +1 -0
  63. package/dist/intelligence/openai-intelligence.tool.js +255 -0
  64. package/dist/intelligence/perplexity-intelligence.tool.d.ts +27 -0
  65. package/dist/intelligence/perplexity-intelligence.tool.d.ts.map +1 -0
  66. package/dist/intelligence/perplexity-intelligence.tool.js +309 -0
  67. package/dist/mcp/index.d.ts +3 -0
  68. package/dist/mcp/index.d.ts.map +1 -0
  69. package/dist/mcp/index.js +2 -0
  70. package/dist/mcp/mcp-bridge.tool.d.ts +12 -0
  71. package/dist/mcp/mcp-bridge.tool.d.ts.map +1 -0
  72. package/dist/mcp/mcp-bridge.tool.js +126 -0
  73. package/dist/mcp/mcp.tool.d.ts +14 -0
  74. package/dist/mcp/mcp.tool.d.ts.map +1 -0
  75. package/dist/mcp/mcp.tool.js +83 -0
  76. package/dist/mcp/methods/mcp-bridge.methods.d.ts +5 -0
  77. package/dist/mcp/methods/mcp-bridge.methods.d.ts.map +1 -0
  78. package/dist/mcp/methods/mcp-bridge.methods.js +79 -0
  79. package/dist/nlp/index.d.ts +2 -0
  80. package/dist/nlp/index.d.ts.map +1 -0
  81. package/dist/nlp/index.js +1 -0
  82. package/dist/nlp/methods/nlp.methods.d.ts +5 -0
  83. package/dist/nlp/methods/nlp.methods.d.ts.map +1 -0
  84. package/dist/nlp/methods/nlp.methods.js +15 -0
  85. package/dist/nlp/ner.tool.d.ts +7 -0
  86. package/dist/nlp/ner.tool.d.ts.map +1 -0
  87. package/dist/nlp/ner.tool.js +25 -0
  88. package/dist/src/intelligence/anthropic-intelligence.tool.d.ts +224 -0
  89. package/dist/src/intelligence/anthropic-intelligence.tool.d.ts.map +1 -0
  90. package/dist/src/intelligence/anthropic-intelligence.tool.js +477 -0
  91. package/dist/src/intelligence/gemini-intelligence.tool.d.ts +29 -0
  92. package/dist/src/intelligence/gemini-intelligence.tool.d.ts.map +1 -0
  93. package/dist/src/intelligence/gemini-intelligence.tool.js +267 -0
  94. package/dist/src/intelligence/index.d.ts +6 -0
  95. package/dist/src/intelligence/index.d.ts.map +1 -0
  96. package/dist/src/intelligence/index.js +5 -0
  97. package/dist/src/intelligence/intelligence.tool.d.ts +11 -0
  98. package/dist/src/intelligence/intelligence.tool.d.ts.map +1 -0
  99. package/dist/src/intelligence/intelligence.tool.js +134 -0
  100. package/dist/src/intelligence/methods/intelligence.methods.d.ts +5 -0
  101. package/dist/src/intelligence/methods/intelligence.methods.d.ts.map +1 -0
  102. package/dist/src/intelligence/methods/intelligence.methods.js +132 -0
  103. package/dist/src/intelligence/ollama-intelligence.tool.d.ts +36 -0
  104. package/dist/src/intelligence/ollama-intelligence.tool.d.ts.map +1 -0
  105. package/dist/src/intelligence/ollama-intelligence.tool.js +312 -0
  106. package/dist/src/intelligence/openai-intelligence.tool.d.ts +30 -0
  107. package/dist/src/intelligence/openai-intelligence.tool.d.ts.map +1 -0
  108. package/dist/src/intelligence/openai-intelligence.tool.js +255 -0
  109. package/dist/src/intelligence/perplexity-intelligence.tool.d.ts +28 -0
  110. package/dist/src/intelligence/perplexity-intelligence.tool.d.ts.map +1 -0
  111. package/dist/src/intelligence/perplexity-intelligence.tool.js +310 -0
  112. package/dist/src/mcp/index.d.ts +3 -0
  113. package/dist/src/mcp/index.d.ts.map +1 -0
  114. package/dist/src/mcp/index.js +2 -0
  115. package/dist/src/mcp/mcp-bridge.tool.d.ts +12 -0
  116. package/dist/src/mcp/mcp-bridge.tool.d.ts.map +1 -0
  117. package/dist/src/mcp/mcp-bridge.tool.js +107 -0
  118. package/dist/src/mcp/mcp.tool.d.ts +15 -0
  119. package/dist/src/mcp/mcp.tool.d.ts.map +1 -0
  120. package/dist/src/mcp/mcp.tool.js +85 -0
  121. package/dist/src/mcp/methods/mcp-bridge.methods.d.ts +5 -0
  122. package/dist/src/mcp/methods/mcp-bridge.methods.d.ts.map +1 -0
  123. package/dist/src/mcp/methods/mcp-bridge.methods.js +58 -0
  124. package/dist/vector-store/index.d.ts +3 -0
  125. package/dist/vector-store/index.d.ts.map +1 -0
  126. package/dist/vector-store/index.js +2 -0
  127. package/dist/vector-store/langchain-memory.vector-store.tool.d.ts +14 -0
  128. package/dist/vector-store/langchain-memory.vector-store.tool.d.ts.map +1 -0
  129. package/dist/vector-store/langchain-memory.vector-store.tool.js +60 -0
  130. package/dist/vector-store/methods/vector-store.methods.d.ts +5 -0
  131. package/dist/vector-store/methods/vector-store.methods.d.ts.map +1 -0
  132. package/dist/vector-store/methods/vector-store.methods.js +60 -0
  133. package/dist/vector-store/vector-memory.tool.d.ts +11 -0
  134. package/dist/vector-store/vector-memory.tool.d.ts.map +1 -0
  135. package/dist/vector-store/vector-memory.tool.js +13 -0
  136. package/package.json +9 -9
@@ -0,0 +1,224 @@
1
+ import { oRequest } from '@olane/o-core';
2
+ import { oToolConfig, oVirtualTool, ToolResult } from '@olane/o-tool';
3
+ export declare class AnthropicIntelligenceTool extends oVirtualTool {
4
+ private defaultModel;
5
+ constructor(config: oToolConfig);
6
+ /**
7
+ * Chat completion with Anthropic
8
+ */
9
+ _tool_completion(request: oRequest): Promise<ToolResult>;
10
+ /**
11
+ * Generate text with Anthropic (using messages endpoint)
12
+ */
13
+ _tool_generate(request: oRequest): Promise<ToolResult>;
14
+ /**
15
+ * List available models
16
+ */
17
+ _tool_list_models(request: oRequest): Promise<ToolResult>;
18
+ /**
19
+ * Get model information
20
+ */
21
+ _tool_model_info(request: oRequest): Promise<ToolResult>;
22
+ /**
23
+ * Check API status
24
+ */
25
+ _tool_status(request: oRequest): Promise<ToolResult>;
26
+ /**
27
+ * Parameter definitions for completion
28
+ */
29
+ _params_completion(): {
30
+ type: string;
31
+ properties: {
32
+ model: {
33
+ type: string;
34
+ description: string;
35
+ default: string;
36
+ };
37
+ messages: {
38
+ type: string;
39
+ description: string;
40
+ items: {
41
+ type: string;
42
+ properties: {
43
+ role: {
44
+ type: string;
45
+ enum: string[];
46
+ description: string;
47
+ };
48
+ content: {
49
+ oneOf: ({
50
+ type: string;
51
+ description: string;
52
+ items?: undefined;
53
+ } | {
54
+ type: string;
55
+ description: string;
56
+ items: {
57
+ type: string;
58
+ properties: {
59
+ type: {
60
+ type: string;
61
+ enum: string[];
62
+ };
63
+ text: {
64
+ type: string;
65
+ };
66
+ source: {
67
+ type: string;
68
+ properties: {
69
+ type: {
70
+ type: string;
71
+ enum: string[];
72
+ };
73
+ media_type: {
74
+ type: string;
75
+ };
76
+ data: {
77
+ type: string;
78
+ };
79
+ };
80
+ };
81
+ };
82
+ };
83
+ })[];
84
+ };
85
+ };
86
+ required: string[];
87
+ };
88
+ };
89
+ system: {
90
+ type: string;
91
+ description: string;
92
+ };
93
+ max_tokens: {
94
+ type: string;
95
+ description: string;
96
+ default: number;
97
+ };
98
+ temperature: {
99
+ type: string;
100
+ description: string;
101
+ minimum: number;
102
+ maximum: number;
103
+ };
104
+ top_p: {
105
+ type: string;
106
+ description: string;
107
+ minimum: number;
108
+ maximum: number;
109
+ };
110
+ top_k: {
111
+ type: string;
112
+ description: string;
113
+ minimum: number;
114
+ };
115
+ stop_sequences: {
116
+ type: string;
117
+ description: string;
118
+ items: {
119
+ type: string;
120
+ };
121
+ };
122
+ metadata: {
123
+ type: string;
124
+ description: string;
125
+ properties: {
126
+ user_id: {
127
+ type: string;
128
+ description: string;
129
+ };
130
+ };
131
+ };
132
+ };
133
+ required: string[];
134
+ };
135
+ /**
136
+ * Parameter definitions for generate
137
+ */
138
+ _params_generate(): {
139
+ type: string;
140
+ properties: {
141
+ model: {
142
+ type: string;
143
+ description: string;
144
+ default: string;
145
+ };
146
+ prompt: {
147
+ type: string;
148
+ description: string;
149
+ };
150
+ system: {
151
+ type: string;
152
+ description: string;
153
+ };
154
+ max_tokens: {
155
+ type: string;
156
+ description: string;
157
+ default: number;
158
+ };
159
+ temperature: {
160
+ type: string;
161
+ description: string;
162
+ minimum: number;
163
+ maximum: number;
164
+ };
165
+ top_p: {
166
+ type: string;
167
+ description: string;
168
+ minimum: number;
169
+ maximum: number;
170
+ };
171
+ top_k: {
172
+ type: string;
173
+ description: string;
174
+ minimum: number;
175
+ };
176
+ stop_sequences: {
177
+ type: string;
178
+ description: string;
179
+ items: {
180
+ type: string;
181
+ };
182
+ };
183
+ metadata: {
184
+ type: string;
185
+ description: string;
186
+ properties: {
187
+ user_id: {
188
+ type: string;
189
+ description: string;
190
+ };
191
+ };
192
+ };
193
+ };
194
+ required: string[];
195
+ };
196
+ /**
197
+ * Parameter definitions for list_models
198
+ */
199
+ _params_list_models(): {
200
+ type: string;
201
+ properties: {};
202
+ };
203
+ /**
204
+ * Parameter definitions for model_info
205
+ */
206
+ _params_model_info(): {
207
+ type: string;
208
+ properties: {
209
+ model: {
210
+ type: string;
211
+ description: string;
212
+ default: string;
213
+ };
214
+ };
215
+ };
216
+ /**
217
+ * Parameter definitions for status
218
+ */
219
+ _params_status(): {
220
+ type: string;
221
+ properties: {};
222
+ };
223
+ }
224
+ //# sourceMappingURL=anthropic-intelligence.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anthropic-intelligence.tool.d.ts","sourceRoot":"","sources":["../../src/intelligence/anthropic-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;AAmG7E,qBAAa,yBAA0B,SAAQ,YAAY;IACzD,OAAO,CAAC,YAAY,CAA4B;gBAEpC,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;IACH,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA6DhB;;OAEG;IACH,mBAAmB;;;;IAOnB;;OAEG;IACH,kBAAkB;;;;;;;;;;IAalB;;OAEG;IACH,cAAc;;;;CAMf"}
@@ -0,0 +1,477 @@
1
+ import { oAddress } from '@olane/o-core';
2
+ import { oVirtualTool } from '@olane/o-tool';
3
+ import { INTELLIGENCE_PARAMS } from './methods/intelligence.methods.js';
4
+ export class AnthropicIntelligenceTool extends oVirtualTool {
5
+ constructor(config) {
6
+ super({
7
+ ...config,
8
+ address: new oAddress('o://anthropic'),
9
+ description: 'Intelligence tool using Anthropic LLM suite of models',
10
+ // shared parameters for all tools
11
+ methods: INTELLIGENCE_PARAMS,
12
+ dependencies: [],
13
+ });
14
+ this.defaultModel = 'claude-opus-4-20250514';
15
+ }
16
+ /**
17
+ * Chat completion with Anthropic
18
+ */
19
+ async _tool_completion(request) {
20
+ try {
21
+ const params = request.params;
22
+ const { model = this.defaultModel, messages, system, max_tokens = 1000, apiKey, } = params;
23
+ if (!apiKey) {
24
+ return {
25
+ success: false,
26
+ error: 'Anthropic API key is required',
27
+ };
28
+ }
29
+ if (!messages || !Array.isArray(messages)) {
30
+ return {
31
+ success: false,
32
+ error: '"messages" array is required',
33
+ };
34
+ }
35
+ const chatRequest = {
36
+ model: model,
37
+ max_tokens: max_tokens,
38
+ messages: messages,
39
+ system: system,
40
+ stream: false,
41
+ };
42
+ const response = await fetch(`https://api.anthropic.com/v1/messages`, {
43
+ method: 'POST',
44
+ headers: {
45
+ 'Content-Type': 'application/json',
46
+ 'x-api-key': apiKey,
47
+ 'anthropic-version': '2023-06-01',
48
+ },
49
+ body: JSON.stringify(chatRequest),
50
+ });
51
+ if (!response.ok) {
52
+ const errorText = await response.text();
53
+ return {
54
+ success: false,
55
+ error: `Anthropic API error: ${response.status} - ${errorText}`,
56
+ };
57
+ }
58
+ const result = (await response.json());
59
+ return {
60
+ message: result.content[0]?.text || '',
61
+ model: result.model,
62
+ usage: result.usage,
63
+ stop_reason: result.stop_reason,
64
+ stop_sequence: result.stop_sequence,
65
+ };
66
+ }
67
+ catch (error) {
68
+ return {
69
+ success: false,
70
+ error: `Failed to complete chat: ${error.message}`,
71
+ };
72
+ }
73
+ }
74
+ /**
75
+ * Generate text with Anthropic (using messages endpoint)
76
+ */
77
+ async _tool_generate(request) {
78
+ try {
79
+ const params = request.params;
80
+ const { model = this.defaultModel, prompt, system, max_tokens = 1000, apiKey, ...options } = params;
81
+ if (!apiKey) {
82
+ return {
83
+ success: false,
84
+ error: 'Anthropic API key is required',
85
+ };
86
+ }
87
+ if (!prompt) {
88
+ return {
89
+ success: false,
90
+ error: 'Prompt is required',
91
+ };
92
+ }
93
+ const messages = [
94
+ {
95
+ role: 'user',
96
+ content: prompt,
97
+ },
98
+ ];
99
+ const generateRequest = {
100
+ model: model,
101
+ max_tokens: max_tokens,
102
+ messages,
103
+ system: system,
104
+ stream: false,
105
+ ...options,
106
+ };
107
+ const response = await fetch(`https://api.anthropic.com/v1/messages`, {
108
+ method: 'POST',
109
+ headers: {
110
+ 'Content-Type': 'application/json',
111
+ 'x-api-key': apiKey,
112
+ 'anthropic-version': '2023-06-01',
113
+ },
114
+ body: JSON.stringify(generateRequest),
115
+ });
116
+ if (!response.ok) {
117
+ const errorText = await response.text();
118
+ return {
119
+ success: false,
120
+ error: `Anthropic API error: ${response.status} - ${errorText}`,
121
+ };
122
+ }
123
+ const result = (await response.json());
124
+ return {
125
+ success: true,
126
+ response: result.content[0]?.text || '',
127
+ model: result.model,
128
+ usage: result.usage,
129
+ stop_reason: result.stop_reason,
130
+ stop_sequence: result.stop_sequence,
131
+ };
132
+ }
133
+ catch (error) {
134
+ return {
135
+ success: false,
136
+ error: `Failed to generate text: ${error.message}`,
137
+ };
138
+ }
139
+ }
140
+ /**
141
+ * List available models
142
+ */
143
+ async _tool_list_models(request) {
144
+ try {
145
+ const params = request.params;
146
+ const { apiKey } = params;
147
+ if (!apiKey) {
148
+ return {
149
+ success: false,
150
+ error: 'Anthropic API key is required',
151
+ };
152
+ }
153
+ const response = await fetch(`https://api.anthropic.com/v1/models`, {
154
+ method: 'GET',
155
+ headers: {
156
+ 'x-api-key': apiKey,
157
+ 'anthropic-version': '2023-06-01',
158
+ },
159
+ });
160
+ if (!response.ok) {
161
+ const errorText = await response.text();
162
+ return {
163
+ success: false,
164
+ error: `Anthropic API error: ${response.status} - ${errorText}`,
165
+ };
166
+ }
167
+ const result = (await response.json());
168
+ return {
169
+ success: true,
170
+ response: result.data,
171
+ models: result.data,
172
+ };
173
+ }
174
+ catch (error) {
175
+ return {
176
+ success: false,
177
+ error: `Failed to list models: ${error.message}`,
178
+ };
179
+ }
180
+ }
181
+ /**
182
+ * Get model information
183
+ */
184
+ async _tool_model_info(request) {
185
+ try {
186
+ const params = request.params;
187
+ const { model = this.defaultModel, apiKey } = params;
188
+ if (!apiKey) {
189
+ return {
190
+ success: false,
191
+ error: 'Anthropic API key is required',
192
+ };
193
+ }
194
+ const response = await fetch(`https://api.anthropic.com/v1/models`, {
195
+ method: 'GET',
196
+ headers: {
197
+ 'x-api-key': apiKey,
198
+ 'anthropic-version': '2023-06-01',
199
+ },
200
+ });
201
+ if (!response.ok) {
202
+ const errorText = await response.text();
203
+ return {
204
+ success: false,
205
+ error: `Anthropic API error: ${response.status} - ${errorText}`,
206
+ };
207
+ }
208
+ const result = (await response.json());
209
+ const modelInfo = result.data.find((m) => m.id === model);
210
+ if (!modelInfo) {
211
+ return {
212
+ success: false,
213
+ error: `Model ${model} not found`,
214
+ };
215
+ }
216
+ return {
217
+ success: true,
218
+ response: modelInfo,
219
+ model: modelInfo,
220
+ };
221
+ }
222
+ catch (error) {
223
+ return {
224
+ success: false,
225
+ error: `Failed to get model info: ${error.message}`,
226
+ };
227
+ }
228
+ }
229
+ /**
230
+ * Check API status
231
+ */
232
+ async _tool_status(request) {
233
+ try {
234
+ const params = request.params;
235
+ const { apiKey } = params;
236
+ if (!apiKey) {
237
+ return {
238
+ success: false,
239
+ error: 'Anthropic API key is required',
240
+ };
241
+ }
242
+ const response = await fetch(`https://api.anthropic.com/v1/models`, {
243
+ method: 'GET',
244
+ headers: {
245
+ 'x-api-key': apiKey,
246
+ 'anthropic-version': '2023-06-01',
247
+ },
248
+ });
249
+ if (!response.ok) {
250
+ return {
251
+ success: false,
252
+ error: `Anthropic API is not accessible: ${response.status}`,
253
+ };
254
+ }
255
+ return {
256
+ success: true,
257
+ response: 'Anthropic API is accessible',
258
+ status: 'ok',
259
+ };
260
+ }
261
+ catch (error) {
262
+ return {
263
+ success: false,
264
+ error: `Failed to check status: ${error.message}`,
265
+ };
266
+ }
267
+ }
268
+ /**
269
+ * Parameter definitions for completion
270
+ */
271
+ _params_completion() {
272
+ return {
273
+ type: 'object',
274
+ properties: {
275
+ model: {
276
+ type: 'string',
277
+ description: 'The model to use for completion',
278
+ default: this.defaultModel,
279
+ },
280
+ messages: {
281
+ type: 'array',
282
+ description: 'Array of messages in the conversation',
283
+ items: {
284
+ type: 'object',
285
+ properties: {
286
+ role: {
287
+ type: 'string',
288
+ enum: ['user', 'assistant'],
289
+ description: 'The role of the message sender',
290
+ },
291
+ content: {
292
+ oneOf: [
293
+ {
294
+ type: 'string',
295
+ description: 'Text content',
296
+ },
297
+ {
298
+ type: 'array',
299
+ description: 'Array of content blocks',
300
+ items: {
301
+ type: 'object',
302
+ properties: {
303
+ type: {
304
+ type: 'string',
305
+ enum: ['text', 'image'],
306
+ },
307
+ text: {
308
+ type: 'string',
309
+ },
310
+ source: {
311
+ type: 'object',
312
+ properties: {
313
+ type: {
314
+ type: 'string',
315
+ enum: ['base64'],
316
+ },
317
+ media_type: {
318
+ type: 'string',
319
+ },
320
+ data: {
321
+ type: 'string',
322
+ },
323
+ },
324
+ },
325
+ },
326
+ },
327
+ },
328
+ ],
329
+ },
330
+ },
331
+ required: ['role', 'content'],
332
+ },
333
+ },
334
+ system: {
335
+ type: 'string',
336
+ description: 'System message to set the behavior of the assistant',
337
+ },
338
+ max_tokens: {
339
+ type: 'number',
340
+ description: 'Maximum number of tokens to generate',
341
+ default: 1000,
342
+ },
343
+ temperature: {
344
+ type: 'number',
345
+ description: 'Controls randomness in the response',
346
+ minimum: 0,
347
+ maximum: 1,
348
+ },
349
+ top_p: {
350
+ type: 'number',
351
+ description: 'Controls diversity via nucleus sampling',
352
+ minimum: 0,
353
+ maximum: 1,
354
+ },
355
+ top_k: {
356
+ type: 'number',
357
+ description: 'Controls diversity via top-k sampling',
358
+ minimum: 0,
359
+ },
360
+ stop_sequences: {
361
+ type: 'array',
362
+ description: 'Sequences that will stop generation',
363
+ items: {
364
+ type: 'string',
365
+ },
366
+ },
367
+ metadata: {
368
+ type: 'object',
369
+ description: 'Optional metadata',
370
+ properties: {
371
+ user_id: {
372
+ type: 'string',
373
+ description: 'User ID for tracking',
374
+ },
375
+ },
376
+ },
377
+ },
378
+ required: ['messages'],
379
+ };
380
+ }
381
+ /**
382
+ * Parameter definitions for generate
383
+ */
384
+ _params_generate() {
385
+ return {
386
+ type: 'object',
387
+ properties: {
388
+ model: {
389
+ type: 'string',
390
+ description: 'The model to use for generation',
391
+ default: this.defaultModel,
392
+ },
393
+ prompt: {
394
+ type: 'string',
395
+ description: 'The prompt to generate text from',
396
+ },
397
+ system: {
398
+ type: 'string',
399
+ description: 'System message to set the behavior of the assistant',
400
+ },
401
+ max_tokens: {
402
+ type: 'number',
403
+ description: 'Maximum number of tokens to generate',
404
+ default: 1000,
405
+ },
406
+ temperature: {
407
+ type: 'number',
408
+ description: 'Controls randomness in the response',
409
+ minimum: 0,
410
+ maximum: 1,
411
+ },
412
+ top_p: {
413
+ type: 'number',
414
+ description: 'Controls diversity via nucleus sampling',
415
+ minimum: 0,
416
+ maximum: 1,
417
+ },
418
+ top_k: {
419
+ type: 'number',
420
+ description: 'Controls diversity via top-k sampling',
421
+ minimum: 0,
422
+ },
423
+ stop_sequences: {
424
+ type: 'array',
425
+ description: 'Sequences that will stop generation',
426
+ items: {
427
+ type: 'string',
428
+ },
429
+ },
430
+ metadata: {
431
+ type: 'object',
432
+ description: 'Optional metadata',
433
+ properties: {
434
+ user_id: {
435
+ type: 'string',
436
+ description: 'User ID for tracking',
437
+ },
438
+ },
439
+ },
440
+ },
441
+ required: ['prompt'],
442
+ };
443
+ }
444
+ /**
445
+ * Parameter definitions for list_models
446
+ */
447
+ _params_list_models() {
448
+ return {
449
+ type: 'object',
450
+ properties: {},
451
+ };
452
+ }
453
+ /**
454
+ * Parameter definitions for model_info
455
+ */
456
+ _params_model_info() {
457
+ return {
458
+ type: 'object',
459
+ properties: {
460
+ model: {
461
+ type: 'string',
462
+ description: 'The model to get information about',
463
+ default: this.defaultModel,
464
+ },
465
+ },
466
+ };
467
+ }
468
+ /**
469
+ * Parameter definitions for status
470
+ */
471
+ _params_status() {
472
+ return {
473
+ type: 'object',
474
+ properties: {},
475
+ };
476
+ }
477
+ }