@causyne/agent 1.13.0 → 1.14.0
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.
- package/package.json +1 -1
- package/src/acp/agentCatalog.js +389 -0
- package/src/acp/agentCatalog.ts +455 -0
- package/src/acp/client.js +127 -4
- package/src/acp/client.ts +145 -5
- package/src/acp/peerProfiles.js +81 -3
- package/src/acp/peerProfiles.ts +85 -4
- package/src/acp/protocol.js +2 -0
- package/src/acp/protocol.ts +19 -0
- package/src/agentLoop.js +33 -12
- package/src/commands.js +108 -0
- package/src/entrypoint.js +11 -0
- package/src/providers/anthropic.js +5 -13
- package/src/providers/dashscope-byok.js +3 -4
- package/src/providers/deepseek.js +3 -4
- package/src/providers/gemini.js +17 -101
- package/src/providers/moonshot.js +3 -4
- package/src/providers/ollama.js +3 -4
- package/src/providers/openai-compatible.js +3 -4
- package/src/providers/qwen-byok.js +3 -4
- package/src/providers/xai.js +3 -4
- package/src/tools/peerAgent.js +115 -31
- package/src/tools/peerAgent.ts +143 -32
- package/src/tools/registry.js +144 -16
- package/src/tools/toolScanner.js +349 -0
- package/src/tools/toolScanner.ts +451 -0
- package/src/tools/toolSelfRepair.js +759 -0
- package/src/tools/toolSelfRepair.ts +846 -0
package/src/commands.js
CHANGED
|
@@ -27,6 +27,12 @@ import {
|
|
|
27
27
|
} from './mcp/mcpRegistry.js';
|
|
28
28
|
import { analyzeFiles, formatFindings } from './slopDetector.js';
|
|
29
29
|
import { suggestMovements, formatMovementBrief, DESIGN_MOVEMENTS } from './designPalettes.js';
|
|
30
|
+
import {
|
|
31
|
+
loadPeerProfiles, addPeerProfile, removePeerProfile, listAllPeers, getPeerProfile
|
|
32
|
+
} from './acp/peerProfiles.js';
|
|
33
|
+
import {
|
|
34
|
+
detectAllPeers, testPeerHandshake, BUILTIN_PEER_PRESETS
|
|
35
|
+
} from './acp/agentCatalog.js';
|
|
30
36
|
import fs from 'fs';
|
|
31
37
|
import os from 'os';
|
|
32
38
|
import path from 'path';
|
|
@@ -856,6 +862,108 @@ export const COMMANDS = [
|
|
|
856
862
|
}
|
|
857
863
|
},
|
|
858
864
|
|
|
865
|
+
{
|
|
866
|
+
name: 'peers',
|
|
867
|
+
scope: 'local',
|
|
868
|
+
usage: '/peers [detect | test <id> | add <id> <command…> | remove <id>]',
|
|
869
|
+
description: 'Manage, discover, and test external ACP peer agents (Claude Code, OpenCode, Codex, Gemini, Hermes, etc.)',
|
|
870
|
+
dialogTitle: 'ACP peer agents',
|
|
871
|
+
run: async (argv) => {
|
|
872
|
+
const [action, peerId, ...rest] = argv;
|
|
873
|
+
|
|
874
|
+
if (action === 'detect') {
|
|
875
|
+
const detected = await detectAllPeers();
|
|
876
|
+
const lines = ['Discovered ACP Peer Agents', ''];
|
|
877
|
+
for (const item of detected) {
|
|
878
|
+
const statusIcon = item.status === 'ready' ? '✅' : (item.status === 'needs_auth' ? '⚠️ ' : '❌');
|
|
879
|
+
lines.push(` ${statusIcon} ${item.id} (${item.label}) — ${item.status.toUpperCase()}`);
|
|
880
|
+
lines.push(` Command: ${item.command} ${item.args.join(' ')}`);
|
|
881
|
+
if (item.details) lines.push(` Details: ${item.details}`);
|
|
882
|
+
if (item.setupInstruction) lines.push(` Setup: ${item.setupInstruction}`);
|
|
883
|
+
}
|
|
884
|
+
lines.push('');
|
|
885
|
+
lines.push('Use /peers test <id> to test zero-token handshake against a specific peer.');
|
|
886
|
+
return ok(lines.join('\n'));
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
if (action === 'test') {
|
|
890
|
+
if (!peerId) return fail('Usage: /peers test <id>');
|
|
891
|
+
const profile = getPeerProfile(peerId);
|
|
892
|
+
if (!profile) return fail(`No peer agent found for "${peerId}". Try /peers detect to see available agents.`);
|
|
893
|
+
|
|
894
|
+
const handshake = await testPeerHandshake({
|
|
895
|
+
command: profile.command,
|
|
896
|
+
args: profile.args,
|
|
897
|
+
cwd: profile.cwd || process.cwd(),
|
|
898
|
+
timeoutMs: 15000
|
|
899
|
+
});
|
|
900
|
+
|
|
901
|
+
if (handshake.ready) {
|
|
902
|
+
const name = handshake.agentInfo ? `${handshake.agentInfo.name} ${handshake.agentInfo.version}` : profile.label;
|
|
903
|
+
return ok(
|
|
904
|
+
`✅ ACP Peer Test Passed: "${peerId}"\n\n`
|
|
905
|
+
+ `Agent: ${name}\n`
|
|
906
|
+
+ `Command: ${profile.command} ${profile.args.join(' ')}\n`
|
|
907
|
+
+ `Policy: ${profile.policy}\n`
|
|
908
|
+
+ `Auth Methods: ${handshake.authMethods?.join(', ') || 'none'}\n\n`
|
|
909
|
+
+ `Ready to receive delegated tasks via peer_agent_delegate.`
|
|
910
|
+
);
|
|
911
|
+
} else {
|
|
912
|
+
return fail(
|
|
913
|
+
`❌ ACP Peer Test Failed: "${peerId}"\n\n`
|
|
914
|
+
+ `Error: ${handshake.error || 'Handshake failed'}\n`
|
|
915
|
+
+ `Command: ${profile.command} ${profile.args.join(' ')}`
|
|
916
|
+
);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
if (action === 'add') {
|
|
921
|
+
if (!peerId) return fail('Usage: /peers add <id> <command> [args…]');
|
|
922
|
+
if (rest.length === 0) return fail(`Give "${peerId}" a command to run (e.g. opencode acp).`);
|
|
923
|
+
|
|
924
|
+
const newProfile = {
|
|
925
|
+
id: peerId.trim().toLowerCase(),
|
|
926
|
+
label: peerId,
|
|
927
|
+
command: rest[0],
|
|
928
|
+
args: rest.slice(1),
|
|
929
|
+
cwd: null,
|
|
930
|
+
policy: 'read-only',
|
|
931
|
+
timeoutSeconds: 180,
|
|
932
|
+
env: {}
|
|
933
|
+
};
|
|
934
|
+
|
|
935
|
+
const res = addPeerProfile(newProfile);
|
|
936
|
+
if (!res.ok) return fail(`Could not save peer: ${res.error}`);
|
|
937
|
+
return ok(`Added peer "${peerId}" [policy: read-only]. Edit ~/.causyne/peers.json to customize policy, timeout, or environment.`);
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
if (action === 'remove') {
|
|
941
|
+
if (!peerId) return fail('Usage: /peers remove <id>');
|
|
942
|
+
const res = removePeerProfile(peerId);
|
|
943
|
+
if (!res.ok) return fail(res.error || `Could not remove peer "${peerId}".`);
|
|
944
|
+
return ok(`Removed peer profile "${peerId}".`);
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
if (action) {
|
|
948
|
+
return fail(`Unknown peers action "${action}". Try: detect, test, add, remove, or peers on its own to list.`);
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
// Default: list all configured and discovered peers
|
|
952
|
+
const peers = listAllPeers();
|
|
953
|
+
const lines = ['Configured & Preset ACP Peer Agents', ''];
|
|
954
|
+
for (const peer of peers) {
|
|
955
|
+
lines.push(` • ${peer.id} (${peer.label}) [policy: ${peer.policy}, timeout: ${peer.timeoutSeconds}s]`);
|
|
956
|
+
lines.push(` Command: ${peer.command} ${peer.args.join(' ')}`);
|
|
957
|
+
}
|
|
958
|
+
lines.push('');
|
|
959
|
+
lines.push('Commands:');
|
|
960
|
+
lines.push(' /peers detect Scan local system for installed ACP agents');
|
|
961
|
+
lines.push(' /peers test <id> Verify zero-token connection to an agent');
|
|
962
|
+
lines.push(' /peers add <id> Add or override a peer command');
|
|
963
|
+
return ok(lines.join('\n'));
|
|
964
|
+
}
|
|
965
|
+
},
|
|
966
|
+
|
|
859
967
|
{
|
|
860
968
|
name: 'slop',
|
|
861
969
|
scope: 'local',
|
package/src/entrypoint.js
CHANGED
|
@@ -187,6 +187,17 @@ program
|
|
|
187
187
|
process.exit(result.ok ? 0 : 1);
|
|
188
188
|
});
|
|
189
189
|
|
|
190
|
+
program
|
|
191
|
+
.command('peers [action] [args...]')
|
|
192
|
+
.description('Manage external ACP peer agents: detect, list, test, add, remove')
|
|
193
|
+
.allowUnknownOption()
|
|
194
|
+
.action(async (action, args) => {
|
|
195
|
+
const argv = action ? [action, ...(args || [])] : [];
|
|
196
|
+
const result = await runCommand('peers', argv, { surface: 'terminal' });
|
|
197
|
+
console.log('\n' + result.output + '\n');
|
|
198
|
+
process.exit(result.ok ? 0 : 1);
|
|
199
|
+
});
|
|
200
|
+
|
|
190
201
|
program
|
|
191
202
|
.command('exec <command>')
|
|
192
203
|
.description('Quick execute a command using the agent terminal')
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { canonicalModelId } from '../modelIds.js';
|
|
2
2
|
import { DEFAULT_MODEL_BY_PROVIDER } from '../modelCatalogue.js';
|
|
3
3
|
import { LLMProvider } from './base.js';
|
|
4
|
+
import { scanAndAdaptToolsForProvider } from '../tools/toolScanner.js';
|
|
4
5
|
|
|
5
6
|
// Models that support server-side tool search (defer_loading + tool_reference
|
|
6
7
|
// expansion). On these, Causyne hands Anthropic the complete 69-tool catalogue
|
|
@@ -306,20 +307,11 @@ export class AnthropicProvider extends LLMProvider {
|
|
|
306
307
|
const useToolSearch = this.supportsToolSearch();
|
|
307
308
|
const coreToolCount = Number.isInteger(options.coreToolCount) ? options.coreToolCount : options.tools.length;
|
|
308
309
|
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
name: toolObj.name,
|
|
313
|
-
description: toolObj.description || '',
|
|
314
|
-
input_schema: toolObj.parameters || toolObj.input_schema || { type: 'object', properties: {} }
|
|
315
|
-
};
|
|
316
|
-
// Beyond the core toolset, let the API hold schemas server-side and
|
|
317
|
-
// surface them only when Claude searches for them.
|
|
318
|
-
if (useToolSearch && index >= coreToolCount) {
|
|
319
|
-
tool.defer_loading = true;
|
|
320
|
-
}
|
|
321
|
-
return tool;
|
|
310
|
+
const scanReport = scanAndAdaptToolsForProvider(options.tools, 'anthropic', {
|
|
311
|
+
useToolSearch,
|
|
312
|
+
coreToolCount
|
|
322
313
|
});
|
|
314
|
+
const converted = scanReport.adaptedTools;
|
|
323
315
|
|
|
324
316
|
if (useToolSearch) {
|
|
325
317
|
payload.tools = [
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { canonicalModelId } from '../modelIds.js';
|
|
2
2
|
import { DEFAULT_MODEL_BY_PROVIDER } from '../modelCatalogue.js';
|
|
3
3
|
import { LLMProvider } from './base.js';
|
|
4
|
+
import { scanAndAdaptToolsForProvider } from '../tools/toolScanner.js';
|
|
4
5
|
|
|
5
6
|
// Direct DashScope API connection for BYOK (unlike dashscope.js which is the proxy for Free Demo)
|
|
6
7
|
export class DashscopeByokProvider extends LLMProvider {
|
|
@@ -44,10 +45,8 @@ export class DashscopeByokProvider extends LLMProvider {
|
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
if (options.tools) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
function: tool.function ? tool.function : tool
|
|
50
|
-
}));
|
|
48
|
+
const scanReport = scanAndAdaptToolsForProvider(options.tools, 'dashscope');
|
|
49
|
+
payload.tools = scanReport.adaptedTools;
|
|
51
50
|
payload.tool_choice = "auto";
|
|
52
51
|
}
|
|
53
52
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { canonicalModelId } from '../modelIds.js';
|
|
2
2
|
import { DEFAULT_MODEL_BY_PROVIDER } from '../modelCatalogue.js';
|
|
3
3
|
import { LLMProvider } from './base.js';
|
|
4
|
+
import { scanAndAdaptToolsForProvider } from '../tools/toolScanner.js';
|
|
4
5
|
|
|
5
6
|
export class DeepSeekProvider extends LLMProvider {
|
|
6
7
|
constructor(config) {
|
|
@@ -38,10 +39,8 @@ export class DeepSeekProvider extends LLMProvider {
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
if (options.tools) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
function: tool.function ? tool.function : tool
|
|
44
|
-
}));
|
|
42
|
+
const scanReport = scanAndAdaptToolsForProvider(options.tools, 'deepseek');
|
|
43
|
+
payload.tools = scanReport.adaptedTools;
|
|
45
44
|
payload.tool_choice = "auto";
|
|
46
45
|
}
|
|
47
46
|
|
package/src/providers/gemini.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { canonicalModelId } from '../modelIds.js';
|
|
2
2
|
import { DEFAULT_MODEL_BY_PROVIDER } from '../modelCatalogue.js';
|
|
3
3
|
import { LLMProvider, mimeTypeForAudioFormat } from './base.js';
|
|
4
|
+
import {
|
|
5
|
+
scanAndAdaptToolsForProvider,
|
|
6
|
+
decodeFreeFormArguments,
|
|
7
|
+
adaptSchemaForGemini,
|
|
8
|
+
isEmptyObjectSchema
|
|
9
|
+
} from '../tools/toolScanner.js';
|
|
10
|
+
|
|
11
|
+
export { adaptSchemaForGemini, isEmptyObjectSchema };
|
|
4
12
|
|
|
5
13
|
// Gemini's FunctionDeclaration schema is an OpenAPI subset, and it is strict in
|
|
6
14
|
// two ways that matter here:
|
|
@@ -14,84 +22,7 @@ import { LLMProvider, mimeTypeForAudioFormat } from './base.js';
|
|
|
14
22
|
// Rather than delete those parameters and lose the capability, free-form maps
|
|
15
23
|
// travel as JSON strings and are decoded again on the way back, so the tool
|
|
16
24
|
// still receives a real object. The paths that were rewritten are recorded per
|
|
17
|
-
// tool so the decode knows exactly where to look.
|
|
18
|
-
|
|
19
|
-
const FREE_FORM_NOTE = ' Pass this as a JSON object encoded in a string, for example {"key":"value"}.';
|
|
20
|
-
|
|
21
|
-
function isEmptyObjectSchema(schema) {
|
|
22
|
-
return schema
|
|
23
|
-
&& schema.type === 'object'
|
|
24
|
-
&& (!schema.properties || Object.keys(schema.properties).length === 0);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Rewrite one JSON Schema into Gemini's subset.
|
|
29
|
-
*
|
|
30
|
-
* @param {object} schema The source schema.
|
|
31
|
-
* @param {Array} path Segments walked so far; '[]' denotes array items.
|
|
32
|
-
* @param {Array} rewritten Collects the paths converted to JSON strings.
|
|
33
|
-
* @returns {object} A schema Gemini will accept.
|
|
34
|
-
*/
|
|
35
|
-
function adaptSchemaForGemini(schema, path, rewritten) {
|
|
36
|
-
if (Array.isArray(schema)) {
|
|
37
|
-
return schema.map(entry => adaptSchemaForGemini(entry, path, rewritten));
|
|
38
|
-
}
|
|
39
|
-
if (schema === null || typeof schema !== 'object') {
|
|
40
|
-
return schema;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const adapted = {};
|
|
44
|
-
for (const [key, value] of Object.entries(schema)) {
|
|
45
|
-
if (key === 'additionalProperties') continue;
|
|
46
|
-
|
|
47
|
-
if (key === 'properties' && value && typeof value === 'object') {
|
|
48
|
-
const properties = {};
|
|
49
|
-
for (const [name, child] of Object.entries(value)) {
|
|
50
|
-
const childPath = [...path, name];
|
|
51
|
-
if (isEmptyObjectSchema(child)) {
|
|
52
|
-
rewritten.push(childPath);
|
|
53
|
-
properties[name] = {
|
|
54
|
-
type: 'string',
|
|
55
|
-
description: (child.description || 'Free-form object.') + FREE_FORM_NOTE
|
|
56
|
-
};
|
|
57
|
-
} else {
|
|
58
|
-
properties[name] = adaptSchemaForGemini(child, childPath, rewritten);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
adapted.properties = properties;
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (key === 'items') {
|
|
66
|
-
adapted.items = adaptSchemaForGemini(value, [...path, '[]'], rewritten);
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
adapted[key] = adaptSchemaForGemini(value, path, rewritten);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return adapted;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/** Walk a decoded argument object and JSON.parse the fields that were stringified. */
|
|
77
|
-
function decodeFreeFormArgs(args, paths) {
|
|
78
|
-
if (!args || paths.length === 0) return args;
|
|
79
|
-
|
|
80
|
-
for (const path of paths) {
|
|
81
|
-
applyAtPath(args, path, value => {
|
|
82
|
-
if (typeof value !== 'string') return value;
|
|
83
|
-
try {
|
|
84
|
-
return JSON.parse(value);
|
|
85
|
-
} catch (e) {
|
|
86
|
-
// The model sent something that is not JSON. Hand it through untouched
|
|
87
|
-
// rather than destroying the argument.
|
|
88
|
-
return value;
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return args;
|
|
94
|
-
}
|
|
25
|
+
// tool so the decode knows exactly where to look. Handled universally via toolScanner.
|
|
95
26
|
|
|
96
27
|
function applyAtPath(node, path, transform) {
|
|
97
28
|
if (node === null || typeof node !== 'object') return;
|
|
@@ -270,31 +201,15 @@ export class GeminiProvider extends LLMProvider {
|
|
|
270
201
|
payload.systemInstruction = { parts: systemParts };
|
|
271
202
|
}
|
|
272
203
|
|
|
273
|
-
// Map tools
|
|
274
|
-
|
|
275
|
-
const freeFormPaths = new Map();
|
|
204
|
+
// Map tools using the universal toolScanner
|
|
205
|
+
let freeFormPaths = new Map();
|
|
276
206
|
|
|
277
207
|
if (options.tools && options.tools.length > 0) {
|
|
208
|
+
const scanReport = scanAndAdaptToolsForProvider(options.tools, 'gemini');
|
|
278
209
|
payload.tools = [{
|
|
279
|
-
functionDeclarations:
|
|
280
|
-
const toolObj = t.function ? t.function : t;
|
|
281
|
-
const declaration = {
|
|
282
|
-
name: toolObj.name,
|
|
283
|
-
description: toolObj.description || ''
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
const source = toolObj.parameters || toolObj.input_schema;
|
|
287
|
-
// A tool that takes no arguments must omit `parameters` entirely —
|
|
288
|
-
// an OBJECT with empty properties is rejected outright.
|
|
289
|
-
if (source && !isEmptyObjectSchema(source)) {
|
|
290
|
-
const rewritten = [];
|
|
291
|
-
declaration.parameters = adaptSchemaForGemini(source, [], rewritten);
|
|
292
|
-
if (rewritten.length > 0) freeFormPaths.set(toolObj.name, rewritten);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
return declaration;
|
|
296
|
-
})
|
|
210
|
+
functionDeclarations: scanReport.adaptedTools
|
|
297
211
|
}];
|
|
212
|
+
freeFormPaths = scanReport.freeFormPaths;
|
|
298
213
|
}
|
|
299
214
|
|
|
300
215
|
const response = await fetch(this.baseUrl, {
|
|
@@ -322,9 +237,10 @@ export class GeminiProvider extends LLMProvider {
|
|
|
322
237
|
if (part.text) {
|
|
323
238
|
content += part.text;
|
|
324
239
|
} else if (part.functionCall) {
|
|
325
|
-
const
|
|
240
|
+
const paths = freeFormPaths.get(part.functionCall.name) || [];
|
|
241
|
+
const args = decodeFreeFormArguments(
|
|
326
242
|
part.functionCall.args || {},
|
|
327
|
-
|
|
243
|
+
paths
|
|
328
244
|
);
|
|
329
245
|
toolCalls.push({
|
|
330
246
|
id: `call_${Math.random().toString(36).substr(2, 9)}`,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { canonicalModelId } from '../modelIds.js';
|
|
2
2
|
import { DEFAULT_MODEL_BY_PROVIDER } from '../modelCatalogue.js';
|
|
3
3
|
import { LLMProvider } from './base.js';
|
|
4
|
+
import { scanAndAdaptToolsForProvider } from '../tools/toolScanner.js';
|
|
4
5
|
|
|
5
6
|
export class MoonshotProvider extends LLMProvider {
|
|
6
7
|
constructor(config) {
|
|
@@ -37,10 +38,8 @@ export class MoonshotProvider extends LLMProvider {
|
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
if (options.tools) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
function: tool.function ? tool.function : tool
|
|
43
|
-
}));
|
|
41
|
+
const scanReport = scanAndAdaptToolsForProvider(options.tools, 'moonshot');
|
|
42
|
+
payload.tools = scanReport.adaptedTools;
|
|
44
43
|
payload.tool_choice = "auto";
|
|
45
44
|
}
|
|
46
45
|
|
package/src/providers/ollama.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { canonicalModelId } from '../modelIds.js';
|
|
2
2
|
import { DEFAULT_MODEL_BY_PROVIDER } from '../modelCatalogue.js';
|
|
3
3
|
import { LLMProvider } from './base.js';
|
|
4
|
+
import { scanAndAdaptToolsForProvider } from '../tools/toolScanner.js';
|
|
4
5
|
|
|
5
6
|
export class OllamaProvider extends LLMProvider {
|
|
6
7
|
constructor(config) {
|
|
@@ -53,10 +54,8 @@ export class OllamaProvider extends LLMProvider {
|
|
|
53
54
|
};
|
|
54
55
|
|
|
55
56
|
if (options.tools) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
function: tool.function ? tool.function : tool
|
|
59
|
-
}));
|
|
57
|
+
const scanReport = scanAndAdaptToolsForProvider(options.tools, 'ollama');
|
|
58
|
+
payload.tools = scanReport.adaptedTools;
|
|
60
59
|
}
|
|
61
60
|
|
|
62
61
|
const response = await fetch(this.baseUrl, {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { canonicalModelId } from '../modelIds.js';
|
|
2
2
|
import { DEFAULT_MODEL_BY_PROVIDER } from '../modelCatalogue.js';
|
|
3
3
|
import { LLMProvider } from './base.js';
|
|
4
|
+
import { scanAndAdaptToolsForProvider } from '../tools/toolScanner.js';
|
|
4
5
|
|
|
5
6
|
export class OpenAICompatibleProvider extends LLMProvider {
|
|
6
7
|
constructor(config) {
|
|
@@ -37,10 +38,8 @@ export class OpenAICompatibleProvider extends LLMProvider {
|
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
if (options.tools) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
function: tool.function ? tool.function : tool
|
|
43
|
-
}));
|
|
41
|
+
const scanReport = scanAndAdaptToolsForProvider(options.tools, 'openai');
|
|
42
|
+
payload.tools = scanReport.adaptedTools;
|
|
44
43
|
payload.tool_choice = "auto";
|
|
45
44
|
}
|
|
46
45
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { canonicalModelId } from '../modelIds.js';
|
|
2
2
|
import { DEFAULT_MODEL_BY_PROVIDER } from '../modelCatalogue.js';
|
|
3
3
|
import { LLMProvider } from './base.js';
|
|
4
|
+
import { scanAndAdaptToolsForProvider } from '../tools/toolScanner.js';
|
|
4
5
|
|
|
5
6
|
// Direct DashScope API connection for BYOK (unlike dashscope.js which is the proxy for Free Demo)
|
|
6
7
|
export class QwenByokProvider extends LLMProvider {
|
|
@@ -34,10 +35,8 @@ export class QwenByokProvider extends LLMProvider {
|
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
if (options.tools) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
function: tool.function ? tool.function : tool
|
|
40
|
-
}));
|
|
38
|
+
const scanReport = scanAndAdaptToolsForProvider(options.tools, 'qwen');
|
|
39
|
+
payload.tools = scanReport.adaptedTools;
|
|
41
40
|
payload.tool_choice = "auto";
|
|
42
41
|
}
|
|
43
42
|
|
package/src/providers/xai.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { canonicalModelId } from '../modelIds.js';
|
|
2
2
|
import { DEFAULT_MODEL_BY_PROVIDER } from '../modelCatalogue.js';
|
|
3
3
|
import { LLMProvider } from './base.js';
|
|
4
|
+
import { scanAndAdaptToolsForProvider } from '../tools/toolScanner.js';
|
|
4
5
|
|
|
5
6
|
export class XAIProvider extends LLMProvider {
|
|
6
7
|
constructor(config) {
|
|
@@ -37,10 +38,8 @@ export class XAIProvider extends LLMProvider {
|
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
if (options.tools) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
function: tool.function ? tool.function : tool
|
|
43
|
-
}));
|
|
41
|
+
const scanReport = scanAndAdaptToolsForProvider(options.tools, 'xai');
|
|
42
|
+
payload.tools = scanReport.adaptedTools;
|
|
44
43
|
payload.tool_choice = "auto";
|
|
45
44
|
}
|
|
46
45
|
|