@corbat-tech/coco 2.25.10 → 2.25.11
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/dist/cli/index.js +392 -281
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +85 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import fs4__default, { readFileSync, constants } from 'fs';
|
|
|
4
4
|
import * as path17 from 'path';
|
|
5
5
|
import path17__default, { dirname, join, basename, resolve } from 'path';
|
|
6
6
|
import * as fs16 from 'fs/promises';
|
|
7
|
-
import fs16__default, { access, readFile, writeFile, mkdir
|
|
7
|
+
import fs16__default, { access, readFile, readdir, writeFile, mkdir } from 'fs/promises';
|
|
8
8
|
import { randomUUID, randomBytes, createHash } from 'crypto';
|
|
9
9
|
import * as http from 'http';
|
|
10
10
|
import { fileURLToPath, URL as URL$1 } from 'url';
|
|
@@ -14866,7 +14866,9 @@ var OpenAIProvider = class {
|
|
|
14866
14866
|
input,
|
|
14867
14867
|
instructions: instructions ?? void 0,
|
|
14868
14868
|
max_output_tokens: options?.maxTokens ?? this.config.maxTokens ?? 8192,
|
|
14869
|
-
...supportsTemp && {
|
|
14869
|
+
...supportsTemp && {
|
|
14870
|
+
temperature: options?.temperature ?? this.config.temperature ?? 0
|
|
14871
|
+
},
|
|
14870
14872
|
store: false
|
|
14871
14873
|
});
|
|
14872
14874
|
return {
|
|
@@ -14901,7 +14903,9 @@ var OpenAIProvider = class {
|
|
|
14901
14903
|
instructions: instructions ?? void 0,
|
|
14902
14904
|
tools,
|
|
14903
14905
|
max_output_tokens: options?.maxTokens ?? this.config.maxTokens ?? 8192,
|
|
14904
|
-
...supportsTemp && {
|
|
14906
|
+
...supportsTemp && {
|
|
14907
|
+
temperature: options?.temperature ?? this.config.temperature ?? 0
|
|
14908
|
+
},
|
|
14905
14909
|
store: false
|
|
14906
14910
|
});
|
|
14907
14911
|
let content = "";
|
|
@@ -27265,7 +27269,9 @@ function createProtectedMetadataCandidates(resourceUrl, headerUrl) {
|
|
|
27265
27269
|
candidates.push(`${origin}/.well-known/oauth-protected-resource`);
|
|
27266
27270
|
if (pathPart && pathPart !== "/") {
|
|
27267
27271
|
candidates.push(`${origin}/.well-known/oauth-protected-resource${pathPart}`);
|
|
27268
|
-
candidates.push(
|
|
27272
|
+
candidates.push(
|
|
27273
|
+
`${origin}/.well-known/oauth-protected-resource/${pathPart.replace(/^\//, "")}`
|
|
27274
|
+
);
|
|
27269
27275
|
}
|
|
27270
27276
|
return Array.from(new Set(candidates));
|
|
27271
27277
|
}
|
|
@@ -28241,7 +28247,30 @@ function getMCPServerManager() {
|
|
|
28241
28247
|
return globalManager;
|
|
28242
28248
|
}
|
|
28243
28249
|
|
|
28250
|
+
// src/mcp/tools.ts
|
|
28251
|
+
init_errors2();
|
|
28252
|
+
|
|
28244
28253
|
// src/tools/mcp.ts
|
|
28254
|
+
async function loadConfiguredServers(projectPath) {
|
|
28255
|
+
const registry = new MCPRegistryImpl();
|
|
28256
|
+
await registry.load();
|
|
28257
|
+
const resolvedProjectPath = projectPath || process.cwd();
|
|
28258
|
+
return mergeMCPConfigs(
|
|
28259
|
+
registry.listServers(),
|
|
28260
|
+
await loadMCPServersFromCOCOConfig(),
|
|
28261
|
+
await loadProjectMCPFile(resolvedProjectPath)
|
|
28262
|
+
);
|
|
28263
|
+
}
|
|
28264
|
+
function findConfiguredServer(servers, requestedServer) {
|
|
28265
|
+
const normalized = requestedServer.trim().toLowerCase();
|
|
28266
|
+
return servers.find((server) => {
|
|
28267
|
+
const name = server.name.toLowerCase();
|
|
28268
|
+
if (name === normalized) return true;
|
|
28269
|
+
if (name.includes(normalized) || normalized.includes(name)) return true;
|
|
28270
|
+
if (name.includes("atlassian") && /^(atlassian|jira|confluence)$/.test(normalized)) return true;
|
|
28271
|
+
return false;
|
|
28272
|
+
});
|
|
28273
|
+
}
|
|
28245
28274
|
var mcpListServersTool = defineTool({
|
|
28246
28275
|
name: "mcp_list_servers",
|
|
28247
28276
|
description: `Inspect Coco's MCP configuration and current runtime connections.
|
|
@@ -28255,14 +28284,9 @@ when you need to know which MCP servers are configured, connected, healthy, or w
|
|
|
28255
28284
|
projectPath: z.string().optional().describe("Project path whose .mcp.json should be merged. Defaults to process.cwd()")
|
|
28256
28285
|
}),
|
|
28257
28286
|
async execute({ includeDisabled, includeTools, projectPath }) {
|
|
28258
|
-
const
|
|
28259
|
-
|
|
28260
|
-
|
|
28261
|
-
const configuredServers = mergeMCPConfigs(
|
|
28262
|
-
registry.listServers(),
|
|
28263
|
-
await loadMCPServersFromCOCOConfig(),
|
|
28264
|
-
await loadProjectMCPFile(resolvedProjectPath)
|
|
28265
|
-
).filter((server) => includeDisabled || server.enabled !== false);
|
|
28287
|
+
const configuredServers = (await loadConfiguredServers(projectPath)).filter(
|
|
28288
|
+
(server) => includeDisabled || server.enabled !== false
|
|
28289
|
+
);
|
|
28266
28290
|
const manager = getMCPServerManager();
|
|
28267
28291
|
const servers = [];
|
|
28268
28292
|
for (const server of configuredServers) {
|
|
@@ -28293,7 +28317,55 @@ when you need to know which MCP servers are configured, connected, healthy, or w
|
|
|
28293
28317
|
};
|
|
28294
28318
|
}
|
|
28295
28319
|
});
|
|
28296
|
-
var
|
|
28320
|
+
var mcpConnectServerTool = defineTool({
|
|
28321
|
+
name: "mcp_connect_server",
|
|
28322
|
+
description: `Connect or reconnect a configured MCP server in the current Coco session.
|
|
28323
|
+
|
|
28324
|
+
Use this when mcp_list_servers shows a service as configured but disconnected, or when
|
|
28325
|
+
the user explicitly asks you to use a specific MCP service. This tool can trigger the
|
|
28326
|
+
built-in MCP OAuth browser login flow. Do not ask the user for raw tokens when this exists.`,
|
|
28327
|
+
category: "config",
|
|
28328
|
+
parameters: z.object({
|
|
28329
|
+
server: z.string().describe("Configured MCP server name, or a common alias like 'jira' or 'atlassian'"),
|
|
28330
|
+
includeTools: z.boolean().optional().default(true).describe("Include discovered MCP tool names after connecting"),
|
|
28331
|
+
projectPath: z.string().optional().describe("Project path whose .mcp.json should be merged. Defaults to process.cwd()")
|
|
28332
|
+
}),
|
|
28333
|
+
async execute({ server, includeTools, projectPath }) {
|
|
28334
|
+
const configuredServers = await loadConfiguredServers(projectPath);
|
|
28335
|
+
const target = findConfiguredServer(
|
|
28336
|
+
configuredServers.filter((configuredServer) => configuredServer.enabled !== false),
|
|
28337
|
+
server
|
|
28338
|
+
);
|
|
28339
|
+
if (!target) {
|
|
28340
|
+
throw new Error(`MCP server '${server}' is not configured`);
|
|
28341
|
+
}
|
|
28342
|
+
const manager = getMCPServerManager();
|
|
28343
|
+
const existingConnection = manager.getConnection(target.name);
|
|
28344
|
+
if (existingConnection && existingConnection.healthy === false) {
|
|
28345
|
+
await manager.stopServer(target.name);
|
|
28346
|
+
}
|
|
28347
|
+
const connection = await manager.startServer(target);
|
|
28348
|
+
let tools;
|
|
28349
|
+
if (includeTools) {
|
|
28350
|
+
try {
|
|
28351
|
+
const listed = await connection.client.listTools();
|
|
28352
|
+
tools = listed.tools.map((tool) => tool.name);
|
|
28353
|
+
} catch {
|
|
28354
|
+
tools = [];
|
|
28355
|
+
}
|
|
28356
|
+
}
|
|
28357
|
+
return {
|
|
28358
|
+
requestedServer: server,
|
|
28359
|
+
connected: true,
|
|
28360
|
+
healthy: true,
|
|
28361
|
+
toolCount: connection.toolCount,
|
|
28362
|
+
...includeTools ? { tools: tools ?? [] } : {},
|
|
28363
|
+
authTriggered: target.transport === "http",
|
|
28364
|
+
message: `MCP server '${target.name}' is connected for this session.`
|
|
28365
|
+
};
|
|
28366
|
+
}
|
|
28367
|
+
});
|
|
28368
|
+
var mcpTools = [mcpListServersTool, mcpConnectServerTool];
|
|
28297
28369
|
init_allowed_paths();
|
|
28298
28370
|
var BLOCKED_SYSTEM_PATHS = [
|
|
28299
28371
|
"/etc",
|