@corbat-tech/coco 2.25.10 → 2.25.12

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/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, readdir } from 'fs/promises';
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 && { temperature: options?.temperature ?? this.config.temperature ?? 0 },
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 && { temperature: options?.temperature ?? this.config.temperature ?? 0 },
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(`${origin}/.well-known/oauth-protected-resource/${pathPart.replace(/^\//, "")}`);
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
  }
@@ -27647,14 +27653,6 @@ var HTTPTransport = class {
27647
27653
  if (this.shouldAttemptOAuth()) {
27648
27654
  this.oauthToken = await getStoredMcpOAuthToken(this.config.url);
27649
27655
  }
27650
- const response = await this.sendRequestWithOAuthRetry(
27651
- "GET",
27652
- void 0,
27653
- this.abortController.signal
27654
- );
27655
- if (!response.ok && response.status !== 404) {
27656
- throw new Error(`HTTP ${response.status}: ${response.statusText}`);
27657
- }
27658
27656
  this.connected = true;
27659
27657
  } catch (error) {
27660
27658
  if (error instanceof MCPError) {
@@ -28241,7 +28239,30 @@ function getMCPServerManager() {
28241
28239
  return globalManager;
28242
28240
  }
28243
28241
 
28242
+ // src/mcp/tools.ts
28243
+ init_errors2();
28244
+
28244
28245
  // src/tools/mcp.ts
28246
+ async function loadConfiguredServers(projectPath) {
28247
+ const registry = new MCPRegistryImpl();
28248
+ await registry.load();
28249
+ const resolvedProjectPath = projectPath || process.cwd();
28250
+ return mergeMCPConfigs(
28251
+ registry.listServers(),
28252
+ await loadMCPServersFromCOCOConfig(),
28253
+ await loadProjectMCPFile(resolvedProjectPath)
28254
+ );
28255
+ }
28256
+ function findConfiguredServer(servers, requestedServer) {
28257
+ const normalized = requestedServer.trim().toLowerCase();
28258
+ return servers.find((server) => {
28259
+ const name = server.name.toLowerCase();
28260
+ if (name === normalized) return true;
28261
+ if (name.includes(normalized) || normalized.includes(name)) return true;
28262
+ if (name.includes("atlassian") && /^(atlassian|jira|confluence)$/.test(normalized)) return true;
28263
+ return false;
28264
+ });
28265
+ }
28245
28266
  var mcpListServersTool = defineTool({
28246
28267
  name: "mcp_list_servers",
28247
28268
  description: `Inspect Coco's MCP configuration and current runtime connections.
@@ -28255,14 +28276,9 @@ when you need to know which MCP servers are configured, connected, healthy, or w
28255
28276
  projectPath: z.string().optional().describe("Project path whose .mcp.json should be merged. Defaults to process.cwd()")
28256
28277
  }),
28257
28278
  async execute({ includeDisabled, includeTools, projectPath }) {
28258
- const registry = new MCPRegistryImpl();
28259
- await registry.load();
28260
- const resolvedProjectPath = projectPath || process.cwd();
28261
- const configuredServers = mergeMCPConfigs(
28262
- registry.listServers(),
28263
- await loadMCPServersFromCOCOConfig(),
28264
- await loadProjectMCPFile(resolvedProjectPath)
28265
- ).filter((server) => includeDisabled || server.enabled !== false);
28279
+ const configuredServers = (await loadConfiguredServers(projectPath)).filter(
28280
+ (server) => includeDisabled || server.enabled !== false
28281
+ );
28266
28282
  const manager = getMCPServerManager();
28267
28283
  const servers = [];
28268
28284
  for (const server of configuredServers) {
@@ -28293,7 +28309,55 @@ when you need to know which MCP servers are configured, connected, healthy, or w
28293
28309
  };
28294
28310
  }
28295
28311
  });
28296
- var mcpTools = [mcpListServersTool];
28312
+ var mcpConnectServerTool = defineTool({
28313
+ name: "mcp_connect_server",
28314
+ description: `Connect or reconnect a configured MCP server in the current Coco session.
28315
+
28316
+ Use this when mcp_list_servers shows a service as configured but disconnected, or when
28317
+ the user explicitly asks you to use a specific MCP service. This tool can trigger the
28318
+ built-in MCP OAuth browser login flow. Do not ask the user for raw tokens when this exists.`,
28319
+ category: "config",
28320
+ parameters: z.object({
28321
+ server: z.string().describe("Configured MCP server name, or a common alias like 'jira' or 'atlassian'"),
28322
+ includeTools: z.boolean().optional().default(true).describe("Include discovered MCP tool names after connecting"),
28323
+ projectPath: z.string().optional().describe("Project path whose .mcp.json should be merged. Defaults to process.cwd()")
28324
+ }),
28325
+ async execute({ server, includeTools, projectPath }) {
28326
+ const configuredServers = await loadConfiguredServers(projectPath);
28327
+ const target = findConfiguredServer(
28328
+ configuredServers.filter((configuredServer) => configuredServer.enabled !== false),
28329
+ server
28330
+ );
28331
+ if (!target) {
28332
+ throw new Error(`MCP server '${server}' is not configured`);
28333
+ }
28334
+ const manager = getMCPServerManager();
28335
+ const existingConnection = manager.getConnection(target.name);
28336
+ if (existingConnection && existingConnection.healthy === false) {
28337
+ await manager.stopServer(target.name);
28338
+ }
28339
+ const connection = await manager.startServer(target);
28340
+ let tools;
28341
+ if (includeTools) {
28342
+ try {
28343
+ const listed = await connection.client.listTools();
28344
+ tools = listed.tools.map((tool) => tool.name);
28345
+ } catch {
28346
+ tools = [];
28347
+ }
28348
+ }
28349
+ return {
28350
+ requestedServer: server,
28351
+ connected: true,
28352
+ healthy: true,
28353
+ toolCount: connection.toolCount,
28354
+ ...includeTools ? { tools: tools ?? [] } : {},
28355
+ authTriggered: target.transport === "http",
28356
+ message: `MCP server '${target.name}' is connected for this session.`
28357
+ };
28358
+ }
28359
+ });
28360
+ var mcpTools = [mcpListServersTool, mcpConnectServerTool];
28297
28361
  init_allowed_paths();
28298
28362
  var BLOCKED_SYSTEM_PATHS = [
28299
28363
  "/etc",