converse-mcp-server 3.7.1 → 4.1.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/.env.example +22 -3
- package/README.md +86 -49
- package/docs/API.md +160 -18
- package/docs/EXAMPLES.md +38 -0
- package/docs/PROVIDERS.md +92 -52
- package/package.json +1 -1
- package/src/config.js +36 -6
- package/src/decisionProviders/index.js +174 -0
- package/src/decisionProviders/systemOne.js +199 -0
- package/src/prompts/helpPrompt.js +50 -3
- package/src/providers/anthropic.js +5 -1
- package/src/providers/claude.js +39 -88
- package/src/providers/codex.js +73 -144
- package/src/providers/copilot.js +42 -149
- package/src/providers/deepseek.js +1 -0
- package/src/providers/gemini-cli.js +64 -97
- package/src/providers/google.js +5 -1
- package/src/providers/mistral.js +5 -1
- package/src/providers/openai-compatible.js +4 -1
- package/src/providers/openai.js +5 -1
- package/src/providers/openrouter.js +2 -1
- package/src/providers/xai.js +5 -1
- package/src/services/summarizationService.js +45 -49
- package/src/tools/chat.js +56 -52
- package/src/tools/decide.js +312 -0
- package/src/tools/index.js +2 -0
- package/src/tools/modes/roundtable.js +60 -49
- package/src/utils/localProviderAuth.js +63 -0
- package/src/utils/modelCatalog.js +38 -0
- package/src/utils/modelRouting.js +580 -343
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local Provider Availability Probes
|
|
3
|
+
*
|
|
4
|
+
* Cheap, synchronous checks for the CLI/SDK providers: the SDK package
|
|
5
|
+
* resolves and a credential is present. They never spawn a process or call a
|
|
6
|
+
* network endpoint, so they cannot prove a login is still valid — a stale
|
|
7
|
+
* credential surfaces as an auth error at invoke time, where bare-name and
|
|
8
|
+
* "auto" routing fail over to the next provider.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { existsSync } from 'node:fs';
|
|
12
|
+
import { homedir } from 'node:os';
|
|
13
|
+
import { join } from 'node:path';
|
|
14
|
+
|
|
15
|
+
const resolvedPackages = new Map();
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Whether an npm package resolves from this module. Cached per process:
|
|
19
|
+
* installing a package requires a restart to load it anyway.
|
|
20
|
+
* @param {string} packageName
|
|
21
|
+
* @returns {boolean}
|
|
22
|
+
*/
|
|
23
|
+
export function isPackageResolvable(packageName) {
|
|
24
|
+
if (!resolvedPackages.has(packageName)) {
|
|
25
|
+
let resolvable;
|
|
26
|
+
try {
|
|
27
|
+
import.meta.resolve(packageName);
|
|
28
|
+
resolvable = true;
|
|
29
|
+
} catch {
|
|
30
|
+
resolvable = false;
|
|
31
|
+
}
|
|
32
|
+
resolvedPackages.set(packageName, resolvable);
|
|
33
|
+
}
|
|
34
|
+
return resolvedPackages.get(packageName);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Codex credentials: CODEX_API_KEY, or the ChatGPT login file the Codex CLI
|
|
39
|
+
* writes to $CODEX_HOME/auth.json (default ~/.codex).
|
|
40
|
+
* @param {object} config
|
|
41
|
+
* @returns {boolean}
|
|
42
|
+
*/
|
|
43
|
+
export function hasCodexCredentials(config) {
|
|
44
|
+
if (config?.providers?.codexapikey) return true;
|
|
45
|
+
const codexHome = process.env.CODEX_HOME || join(homedir(), '.codex');
|
|
46
|
+
return existsSync(join(codexHome, 'auth.json'));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Claude Code credentials: an OAuth token or API key in the environment the
|
|
51
|
+
* spawned CLI inherits, or the login file in $CLAUDE_CONFIG_DIR (default
|
|
52
|
+
* ~/.claude). macOS keeps the login in the Keychain, which cannot be read
|
|
53
|
+
* without spawning a process, so a login there is assumed.
|
|
54
|
+
* @returns {boolean}
|
|
55
|
+
*/
|
|
56
|
+
export function hasClaudeCredentials() {
|
|
57
|
+
if (process.env.CLAUDE_CODE_OAUTH_TOKEN || process.env.ANTHROPIC_API_KEY) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
if (process.platform === 'darwin') return true;
|
|
61
|
+
const configDir = process.env.CLAUDE_CONFIG_DIR || join(homedir(), '.claude');
|
|
62
|
+
return existsSync(join(configDir, '.credentials.json'));
|
|
63
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model Catalog Helpers
|
|
3
|
+
*
|
|
4
|
+
* Every provider keeps a catalog keyed by canonical model ID, each entry
|
|
5
|
+
* carrying an `aliases` array. These helpers are the single lookup rule for
|
|
6
|
+
* those catalogs: case-insensitive, canonical ID first, then aliases.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Canonical catalog ID for a name, or null.
|
|
11
|
+
* @param {Object<string, {aliases?: string[]}>} catalog
|
|
12
|
+
* @param {string} name - Canonical ID or alias
|
|
13
|
+
* @returns {string|null}
|
|
14
|
+
*/
|
|
15
|
+
export function findCatalogId(catalog, name) {
|
|
16
|
+
const lower = String(name ?? '').trim().toLowerCase();
|
|
17
|
+
if (!lower || !catalog) return null;
|
|
18
|
+
for (const id of Object.keys(catalog)) {
|
|
19
|
+
if (id.toLowerCase() === lower) return id;
|
|
20
|
+
}
|
|
21
|
+
for (const [id, entry] of Object.entries(catalog)) {
|
|
22
|
+
if (entry?.aliases?.some((alias) => String(alias).toLowerCase() === lower)) {
|
|
23
|
+
return id;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Catalog entry for a name, or null.
|
|
31
|
+
* @param {Object<string, object>} catalog
|
|
32
|
+
* @param {string} name - Canonical ID or alias
|
|
33
|
+
* @returns {object|null}
|
|
34
|
+
*/
|
|
35
|
+
export function findCatalogEntry(catalog, name) {
|
|
36
|
+
const id = findCatalogId(catalog, name);
|
|
37
|
+
return id ? catalog[id] : null;
|
|
38
|
+
}
|