@causyne/agent 1.20.117 → 1.20.120

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 (82) hide show
  1. package/package.json +7 -2
  2. package/src/agentLoop.js +29 -12
  3. package/src/agentLoop.ts +29 -16
  4. package/src/browser/causyneBrowser.js +231 -136
  5. package/src/browser/causyneBrowser.ts +229 -140
  6. package/src/browser/searchProviders.js +41 -30
  7. package/src/browser/searchProviders.ts +24 -14
  8. package/src/browser/workspacePathSafety.js +50 -0
  9. package/src/browser/workspacePathSafety.ts +50 -0
  10. package/src/browser/workspacePreview.js +27 -4
  11. package/src/browser/workspacePreview.ts +28 -4
  12. package/src/cliMode.js +20 -4
  13. package/src/commands.js +12 -14
  14. package/src/creative/liveBridge.js +34 -1
  15. package/src/creative/liveBridge.ts +28 -1
  16. package/src/observer/evidence.js +23 -0
  17. package/src/observer/evidence.ts +21 -0
  18. package/src/plugins/pluginManager.js +74 -0
  19. package/src/providers/anthropic.js +33 -17
  20. package/src/providers/base.js +14 -0
  21. package/src/providers/dashscope-byok.js +13 -7
  22. package/src/providers/deepseek.js +13 -18
  23. package/src/providers/gemini.js +33 -25
  24. package/src/providers/moonshot.js +13 -12
  25. package/src/providers/ollama.js +21 -21
  26. package/src/providers/openai-compatible.js +12 -19
  27. package/src/providers/openrouter.js +20 -90
  28. package/src/providers/openrouter.ts +31 -94
  29. package/src/providers/qwen-byok.js +13 -7
  30. package/src/providers/toolContracts.js +9 -3
  31. package/src/providers/toolContracts.ts +9 -3
  32. package/src/providers/wireNormalizer.js +238 -0
  33. package/src/providers/wireNormalizer.ts +279 -0
  34. package/src/providers/xai.js +13 -12
  35. package/src/reporting.js +12 -4
  36. package/src/skillsManager.js +3 -2
  37. package/src/skillsManager.ts +3 -2
  38. package/src/tools/browserAutomator.js +13 -1
  39. package/src/tools/browserAutomator.ts +13 -0
  40. package/src/tools/creativeApps.js +2 -1
  41. package/src/tools/creativeApps.ts +2 -1
  42. package/src/tools/gameAssetFetcher.js +130 -26
  43. package/src/tools/gameAssetHarvester.js +80 -58
  44. package/src/tools/nativeEngine.js +1 -1
  45. package/src/tools/nativeEngine.ts +1 -1
  46. package/src/tools/pluginManager.js +17 -2
  47. package/src/tools/registry.js +13 -0
  48. package/src/tools/toolScanner.js +596 -140
  49. package/src/tools/toolScanner.ts +665 -147
  50. package/src/tools/toolSelfRepair.js +243 -114
  51. package/src/tools/toolSelfRepair.ts +262 -111
  52. package/src/tools/webFetch.js +161 -24
  53. package/src/tools/webFetch.ts +157 -22
  54. package/src/tools/webSearch.js +33 -4
  55. package/src/tools/webSearch.ts +27 -4
  56. package/src/tui/composerControls.js +16 -3
  57. package/src/tui/composerControls.ts +14 -3
  58. package/src/tui/prompt.js +122 -16
  59. package/src/tui/sessionPicker.js +132 -35
  60. package/src/tui/sessionPicker.ts +153 -32
  61. package/src/tui/sessionPickerView.js +277 -34
  62. package/src/tui/sessionPickerView.ts +328 -34
  63. package/src/tui/statusLine.js +3 -0
  64. package/src/tui/statusLine.ts +5 -0
  65. package/src/tui/usageCard.js +119 -47
  66. package/src/tui/usageCard.ts +133 -49
  67. package/src/tui/workspaceIdentity.js +133 -0
  68. package/src/tui/workspaceIdentity.ts +146 -0
  69. package/src/tui/workspaceSwitch.js +2 -0
  70. package/src/tui/workspaceSwitch.ts +1 -0
  71. package/src/verification/boundedExplorer.js +119 -0
  72. package/src/verification/cliProbe.js +116 -0
  73. package/src/verification/featureMap.js +78 -0
  74. package/src/verification/interactivePty.js +188 -0
  75. package/src/verification/propertyProbe.js +121 -0
  76. package/src/verification/ptyProbe.js +125 -0
  77. package/src/verification/skillCatalog.d.ts +1 -0
  78. package/src/verification/skillCatalog.js +60 -0
  79. package/src/verification/statechart.js +143 -0
  80. package/src/verification/uiRuntime.js +57 -0
  81. package/src/verificationPlan.js +1 -1
  82. package/src/verificationPlan.ts +1 -1
@@ -9,7 +9,8 @@
9
9
  import { LLMProvider } from './base.js';
10
10
  import { canonicalModelId } from '../modelIds.js';
11
11
  import { scanAndAdaptToolsForProvider } from '../tools/toolScanner.js';
12
- import { extractToolCallJsonObjects, resolveToolCallEnvelopeArguments } from '../implementationPlan.js';
12
+ import { extractTextToolCalls, normalizeOpenAIChatChoiceResponse, serializeAndDecodeArguments } from './wireNormalizer.js';
13
+ import { normalizeToolName } from '../tools/toolScanner.js';
13
14
  export const OPENROUTER_API_BASE = 'https://openrouter.ai/api/v1';
14
15
  export const OPENROUTER_CHAT_ENDPOINT = 'https://openrouter.ai/api/v1/chat/completions';
15
16
  export const OPENROUTER_DEFAULT_FREE_MODEL = 'openrouter/free';
@@ -89,10 +90,12 @@ export class OpenRouterProvider extends LLMProvider {
89
90
  if (options['jsonMode']) {
90
91
  payload['response_format'] = { type: 'json_object' };
91
92
  }
93
+ let freeFormPaths = new Map();
92
94
  if (options.tools && Array.isArray(options.tools) && options.tools.length > 0) {
93
95
  const scanReport = scanAndAdaptToolsForProvider(options.tools, 'openai');
94
96
  payload['tools'] = scanReport.adaptedTools;
95
97
  payload['tool_choice'] = 'auto';
98
+ freeFormPaths = scanReport.freeFormPaths;
96
99
  }
97
100
  const headers = {
98
101
  'Content-Type': 'application/json',
@@ -124,10 +127,10 @@ export class OpenRouterProvider extends LLMProvider {
124
127
  this.handleHttpErrors(response.status, errorText);
125
128
  }
126
129
  if (shouldStream && response.body) {
127
- return this.handleStreamingResponse(response, options);
130
+ return this.handleStreamingResponse(response, options, freeFormPaths);
128
131
  }
129
132
  else {
130
- return this.handleJsonResponse(response);
133
+ return this.handleJsonResponse(response, freeFormPaths);
131
134
  }
132
135
  }
133
136
  /**
@@ -153,36 +156,24 @@ export class OpenRouterProvider extends LLMProvider {
153
156
  /**
154
157
  * Process a non-streaming JSON response from OpenRouter.
155
158
  */
156
- async handleJsonResponse(response) {
159
+ async handleJsonResponse(response, freeFormPaths) {
157
160
  const data = (await response.json());
158
- let content = '';
159
- let toolCalls = [];
160
- let reasoningContent = '';
161
- if (data.choices && Array.isArray(data.choices) && data.choices[0]?.message) {
162
- const message = data.choices[0].message;
163
- content = message.content || '';
164
- toolCalls = this.normalizeToolCalls(message.tool_calls);
165
- reasoningContent = message.reasoning || message.reasoning_content || '';
166
- }
167
- if (toolCalls.length === 0 && content) {
168
- const extracted = this.extractToolCallsFromContent(content);
169
- if (extracted.length > 0) {
170
- toolCalls = extracted;
171
- }
172
- }
173
- const rawUsage = data.usage || { prompt_tokens: 0, completion_tokens: 0, total_tokens: 0 };
174
- const usage = this.normalizeUsage(rawUsage);
161
+ const normalized = normalizeOpenAIChatChoiceResponse(data, {
162
+ prefix: 'call_openrouter',
163
+ ...(freeFormPaths ? { freeFormPaths } : {})
164
+ });
165
+ const usage = this.normalizeUsage(normalized.rawUsage);
175
166
  return {
176
- content,
177
- toolCalls: toolCalls.length > 0 ? toolCalls : undefined,
178
- reasoningContent: reasoningContent || undefined,
167
+ content: normalized.content,
168
+ toolCalls: normalized.toolCalls,
169
+ reasoningContent: normalized.reasoningContent,
179
170
  usage
180
171
  };
181
172
  }
182
173
  /**
183
174
  * Process a streaming SSE response from OpenRouter.
184
175
  */
185
- async handleStreamingResponse(response, options) {
176
+ async handleStreamingResponse(response, options, freeFormPaths) {
186
177
  const reader = response.body.getReader();
187
178
  const decoder = new TextDecoder('utf-8');
188
179
  let content = '';
@@ -268,18 +259,19 @@ export class OpenRouterProvider extends LLMProvider {
268
259
  const toolCalls = [];
269
260
  for (const item of toolCallsMap.values()) {
270
261
  if (item.name) {
262
+ const cleanName = normalizeToolName(item.name);
271
263
  toolCalls.push({
272
264
  id: item.id,
273
265
  type: 'function',
274
266
  function: {
275
- name: item.name,
276
- arguments: item.arguments || '{}'
267
+ name: cleanName,
268
+ arguments: serializeAndDecodeArguments(item.arguments || '{}', cleanName, freeFormPaths)
277
269
  }
278
270
  });
279
271
  }
280
272
  }
281
273
  if (toolCalls.length === 0 && content) {
282
- const extracted = this.extractToolCallsFromContent(content);
274
+ const extracted = extractTextToolCalls(content, 'call_text', freeFormPaths);
283
275
  if (extracted.length > 0) {
284
276
  toolCalls.push(...extracted);
285
277
  }
@@ -292,66 +284,4 @@ export class OpenRouterProvider extends LLMProvider {
292
284
  usage
293
285
  };
294
286
  }
295
- /**
296
- * Extract tool calls embedded in content text (e.g. <tool_call> envelopes).
297
- */
298
- extractToolCallsFromContent(text) {
299
- const calls = [];
300
- if (!text || typeof text !== 'string')
301
- return calls;
302
- let index = 0;
303
- for (const parsed of extractToolCallJsonObjects(text)) {
304
- const fnObj = parsed.function && typeof parsed.function === 'object'
305
- ? parsed.function
306
- : null;
307
- const name = String(parsed.name || parsed.tool || fnObj?.name || '').trim();
308
- if (!name)
309
- continue;
310
- const rawArgs = resolveToolCallEnvelopeArguments(parsed);
311
- calls.push({
312
- id: `call_text_${Date.now()}_${index++}`,
313
- type: 'function',
314
- function: {
315
- name,
316
- arguments: typeof rawArgs === 'string' ? rawArgs : JSON.stringify(rawArgs || {})
317
- }
318
- });
319
- }
320
- return calls;
321
- }
322
- /**
323
- * Safely normalize tool calls from provider message.
324
- */
325
- normalizeToolCalls(rawCalls) {
326
- if (!Array.isArray(rawCalls))
327
- return [];
328
- const normalized = [];
329
- for (let i = 0; i < rawCalls.length; i++) {
330
- const tc = rawCalls[i];
331
- if (!tc || typeof tc !== 'object')
332
- continue;
333
- const id = typeof tc.id === 'string' && tc.id ? tc.id : `call_${i}_${Date.now()}`;
334
- const name = tc.function?.name || tc.name || '';
335
- if (!name || typeof name !== 'string')
336
- continue;
337
- let args = tc.function?.arguments;
338
- if (typeof args !== 'string') {
339
- try {
340
- args = JSON.stringify(args || {});
341
- }
342
- catch {
343
- args = '{}';
344
- }
345
- }
346
- normalized.push({
347
- id,
348
- type: 'function',
349
- function: {
350
- name,
351
- arguments: args
352
- }
353
- });
354
- }
355
- return normalized;
356
- }
357
287
  }
@@ -10,7 +10,12 @@
10
10
  import { LLMProvider } from './base.js';
11
11
  import { canonicalModelId } from '../modelIds.js';
12
12
  import { scanAndAdaptToolsForProvider } from '../tools/toolScanner.js';
13
- import { extractToolCallJsonObjects, resolveToolCallEnvelopeArguments } from '../implementationPlan.js';
13
+ import {
14
+ extractTextToolCalls,
15
+ normalizeOpenAIChatChoiceResponse,
16
+ serializeAndDecodeArguments
17
+ } from './wireNormalizer.js';
18
+ import { normalizeToolName } from '../tools/toolScanner.js';
14
19
  import type { ChatOptions, ChatResponse, ChatResponseUsage, ChatResponseToolCall } from './base.d.js';
15
20
 
16
21
  export const OPENROUTER_API_BASE = 'https://openrouter.ai/api/v1';
@@ -108,10 +113,12 @@ export class OpenRouterProvider extends LLMProvider {
108
113
  payload['response_format'] = { type: 'json_object' };
109
114
  }
110
115
 
116
+ let freeFormPaths = new Map<string, string[][]>();
111
117
  if (options.tools && Array.isArray(options.tools) && options.tools.length > 0) {
112
118
  const scanReport = scanAndAdaptToolsForProvider(options.tools, 'openai');
113
119
  payload['tools'] = scanReport.adaptedTools;
114
120
  payload['tool_choice'] = 'auto';
121
+ freeFormPaths = scanReport.freeFormPaths;
115
122
  }
116
123
 
117
124
  const headers: Record<string, string> = {
@@ -147,9 +154,9 @@ export class OpenRouterProvider extends LLMProvider {
147
154
  }
148
155
 
149
156
  if (shouldStream && response.body) {
150
- return this.handleStreamingResponse(response, options);
157
+ return this.handleStreamingResponse(response, options, freeFormPaths);
151
158
  } else {
152
- return this.handleJsonResponse(response);
159
+ return this.handleJsonResponse(response, freeFormPaths);
153
160
  }
154
161
  }
155
162
 
@@ -185,33 +192,21 @@ export class OpenRouterProvider extends LLMProvider {
185
192
  /**
186
193
  * Process a non-streaming JSON response from OpenRouter.
187
194
  */
188
- private async handleJsonResponse(response: Response): Promise<ChatResponse> {
195
+ private async handleJsonResponse(
196
+ response: Response,
197
+ freeFormPaths?: Map<string, string[][]>
198
+ ): Promise<ChatResponse> {
189
199
  const data = (await response.json()) as any;
190
- let content = '';
191
- let toolCalls: ChatResponseToolCall[] = [];
192
- let reasoningContent = '';
193
-
194
- if (data.choices && Array.isArray(data.choices) && data.choices[0]?.message) {
195
- const message = data.choices[0].message;
196
- content = message.content || '';
197
- toolCalls = this.normalizeToolCalls(message.tool_calls);
198
- reasoningContent = message.reasoning || message.reasoning_content || '';
199
- }
200
-
201
- if (toolCalls.length === 0 && content) {
202
- const extracted = this.extractToolCallsFromContent(content);
203
- if (extracted.length > 0) {
204
- toolCalls = extracted;
205
- }
206
- }
207
-
208
- const rawUsage = data.usage || { prompt_tokens: 0, completion_tokens: 0, total_tokens: 0 };
209
- const usage: ChatResponseUsage = this.normalizeUsage(rawUsage);
200
+ const normalized = normalizeOpenAIChatChoiceResponse(data, {
201
+ prefix: 'call_openrouter',
202
+ ...(freeFormPaths ? { freeFormPaths } : {})
203
+ });
204
+ const usage: ChatResponseUsage = this.normalizeUsage(normalized.rawUsage);
210
205
 
211
206
  return {
212
- content,
213
- toolCalls: toolCalls.length > 0 ? toolCalls : undefined,
214
- reasoningContent: reasoningContent || undefined,
207
+ content: normalized.content,
208
+ toolCalls: normalized.toolCalls,
209
+ reasoningContent: normalized.reasoningContent,
215
210
  usage
216
211
  };
217
212
  }
@@ -219,7 +214,11 @@ export class OpenRouterProvider extends LLMProvider {
219
214
  /**
220
215
  * Process a streaming SSE response from OpenRouter.
221
216
  */
222
- private async handleStreamingResponse(response: Response, options: ChatOptions): Promise<ChatResponse> {
217
+ private async handleStreamingResponse(
218
+ response: Response,
219
+ options: ChatOptions,
220
+ freeFormPaths?: Map<string, string[][]>
221
+ ): Promise<ChatResponse> {
223
222
  const reader = response.body!.getReader();
224
223
  const decoder = new TextDecoder('utf-8');
225
224
 
@@ -308,19 +307,20 @@ export class OpenRouterProvider extends LLMProvider {
308
307
  const toolCalls: ChatResponseToolCall[] = [];
309
308
  for (const item of toolCallsMap.values()) {
310
309
  if (item.name) {
310
+ const cleanName = normalizeToolName(item.name);
311
311
  toolCalls.push({
312
312
  id: item.id,
313
313
  type: 'function',
314
314
  function: {
315
- name: item.name,
316
- arguments: item.arguments || '{}'
315
+ name: cleanName,
316
+ arguments: serializeAndDecodeArguments(item.arguments || '{}', cleanName, freeFormPaths)
317
317
  }
318
318
  });
319
319
  }
320
320
  }
321
321
 
322
322
  if (toolCalls.length === 0 && content) {
323
- const extracted = this.extractToolCallsFromContent(content);
323
+ const extracted = extractTextToolCalls(content, 'call_text', freeFormPaths);
324
324
  if (extracted.length > 0) {
325
325
  toolCalls.push(...extracted);
326
326
  }
@@ -337,67 +337,4 @@ export class OpenRouterProvider extends LLMProvider {
337
337
  usage
338
338
  };
339
339
  }
340
-
341
- /**
342
- * Extract tool calls embedded in content text (e.g. <tool_call> envelopes).
343
- */
344
- private extractToolCallsFromContent(text: string): ChatResponseToolCall[] {
345
- const calls: ChatResponseToolCall[] = [];
346
- if (!text || typeof text !== 'string') return calls;
347
- let index = 0;
348
- for (const parsed of extractToolCallJsonObjects(text)) {
349
- const fnObj = parsed.function && typeof parsed.function === 'object'
350
- ? (parsed.function as Record<string, unknown>)
351
- : null;
352
- const name = String(parsed.name || parsed.tool || fnObj?.name || '').trim();
353
- if (!name) continue;
354
- const rawArgs = resolveToolCallEnvelopeArguments(parsed);
355
- calls.push({
356
- id: `call_text_${Date.now()}_${index++}`,
357
- type: 'function',
358
- function: {
359
- name,
360
- arguments: typeof rawArgs === 'string' ? rawArgs : JSON.stringify(rawArgs || {})
361
- }
362
- });
363
- }
364
- return calls;
365
- }
366
-
367
- /**
368
- * Safely normalize tool calls from provider message.
369
- */
370
- private normalizeToolCalls(rawCalls: any[]): ChatResponseToolCall[] {
371
- if (!Array.isArray(rawCalls)) return [];
372
- const normalized: ChatResponseToolCall[] = [];
373
-
374
- for (let i = 0; i < rawCalls.length; i++) {
375
- const tc = rawCalls[i];
376
- if (!tc || typeof tc !== 'object') continue;
377
-
378
- const id = typeof tc.id === 'string' && tc.id ? tc.id : `call_${i}_${Date.now()}`;
379
- const name = tc.function?.name || tc.name || '';
380
- if (!name || typeof name !== 'string') continue;
381
-
382
- let args = tc.function?.arguments;
383
- if (typeof args !== 'string') {
384
- try {
385
- args = JSON.stringify(args || {});
386
- } catch {
387
- args = '{}';
388
- }
389
- }
390
-
391
- normalized.push({
392
- id,
393
- type: 'function',
394
- function: {
395
- name,
396
- arguments: args
397
- }
398
- });
399
- }
400
-
401
- return normalized;
402
- }
403
340
  }
@@ -2,6 +2,7 @@ import { canonicalModelId } from '../modelIds.js';
2
2
  import { DEFAULT_MODEL_BY_PROVIDER } from '../modelCatalogue.js';
3
3
  import { LLMProvider } from './base.js';
4
4
  import { scanAndAdaptToolsForProvider } from '../tools/toolScanner.js';
5
+ import { normalizeOpenAIChatChoiceResponse } from './wireNormalizer.js';
5
6
 
6
7
  // Direct DashScope API connection for BYOK (unlike dashscope.js which is the proxy for Free Demo)
7
8
  export class QwenByokProvider extends LLMProvider {
@@ -34,10 +35,12 @@ export class QwenByokProvider extends LLMProvider {
34
35
  payload.response_format = { type: 'json_object' };
35
36
  }
36
37
 
37
- if (options.tools) {
38
+ let freeFormPaths = new Map();
39
+ if (options.tools && options.tools.length > 0) {
38
40
  const scanReport = scanAndAdaptToolsForProvider(options.tools, 'qwen');
39
41
  payload.tools = scanReport.adaptedTools;
40
42
  payload.tool_choice = "auto";
43
+ freeFormPaths = scanReport.freeFormPaths;
41
44
  }
42
45
 
43
46
  const response = await fetch(this.baseUrl, {
@@ -63,13 +66,16 @@ export class QwenByokProvider extends LLMProvider {
63
66
  }
64
67
 
65
68
  const data = await response.json();
66
- const content = data.choices[0].message.content;
67
- const toolCalls = data.choices[0].message.tool_calls;
68
-
69
+ const normalized = normalizeOpenAIChatChoiceResponse(data, {
70
+ prefix: 'call_qwen',
71
+ freeFormPaths
72
+ });
73
+
69
74
  return {
70
- content: content || '',
71
- toolCalls: (toolCalls && toolCalls.length > 0) ? toolCalls : undefined,
72
- usage: this.normalizeUsage(data.usage)
75
+ content: normalized.content,
76
+ toolCalls: normalized.toolCalls,
77
+ reasoningContent: normalized.reasoningContent,
78
+ usage: this.normalizeUsage(normalized.rawUsage)
73
79
  };
74
80
  }
75
81
  }
@@ -1,14 +1,20 @@
1
1
  import { createHash } from 'node:crypto';
2
+ import { normalizeToolName, normalizeUniversalSchema } from '../tools/toolScanner.js';
2
3
  const object = (value) => value !== null && typeof value === 'object' && !Array.isArray(value) ? value : {};
3
- /** Preserve constraints and nested schemas; text peers need more than parameter names. */
4
+ /** Preserve constraints and nested schemas while compiling union/combinator edge cases safely. */
4
5
  export function normalizeToolContracts(tools) {
5
6
  return tools.map(raw => {
6
7
  const tool = object(raw);
7
8
  const fn = object(tool.function);
9
+ const rawName = String(tool.name || fn.name || '');
10
+ const rawParams = object(tool.parameters || tool.input_schema || fn.parameters);
11
+ const cleanParams = Object.keys(rawParams).length > 0
12
+ ? object(normalizeUniversalSchema(rawParams, [], [], 'strict_json'))
13
+ : rawParams;
8
14
  return {
9
- name: String(tool.name || fn.name || ''),
15
+ name: rawName ? normalizeToolName(rawName) : '',
10
16
  description: String(tool.description || fn.description || ''),
11
- parameters: object(tool.parameters || tool.input_schema || fn.parameters)
17
+ parameters: cleanParams
12
18
  };
13
19
  }).filter(tool => tool.name).sort((a, b) => a.name.localeCompare(b.name));
14
20
  }
@@ -1,4 +1,5 @@
1
1
  import { createHash } from 'node:crypto';
2
+ import { normalizeToolName, normalizeUniversalSchema } from '../tools/toolScanner.js';
2
3
 
3
4
  type JsonObject = Record<string, unknown>;
4
5
  export interface ToolContract {
@@ -10,15 +11,20 @@ export interface ToolContract {
10
11
  const object = (value: unknown): JsonObject =>
11
12
  value !== null && typeof value === 'object' && !Array.isArray(value) ? value as JsonObject : {};
12
13
 
13
- /** Preserve constraints and nested schemas; text peers need more than parameter names. */
14
+ /** Preserve constraints and nested schemas while compiling union/combinator edge cases safely. */
14
15
  export function normalizeToolContracts(tools: readonly unknown[]): ToolContract[] {
15
16
  return tools.map(raw => {
16
17
  const tool = object(raw);
17
18
  const fn = object(tool.function);
19
+ const rawName = String(tool.name || fn.name || '');
20
+ const rawParams = object(tool.parameters || tool.input_schema || fn.parameters);
21
+ const cleanParams = Object.keys(rawParams).length > 0
22
+ ? object(normalizeUniversalSchema(rawParams, [], [], 'strict_json'))
23
+ : rawParams;
18
24
  return {
19
- name: String(tool.name || fn.name || ''),
25
+ name: rawName ? normalizeToolName(rawName) : '',
20
26
  description: String(tool.description || fn.description || ''),
21
- parameters: object(tool.parameters || tool.input_schema || fn.parameters)
27
+ parameters: cleanParams
22
28
  };
23
29
  }).filter(tool => tool.name).sort((a, b) => a.name.localeCompare(b.name));
24
30
  }