@corbat-tech/coco 2.25.9 → 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/index.d.ts CHANGED
@@ -519,6 +519,7 @@ declare const CocoConfigSchema: z.ZodObject<{
519
519
  temperature: z.ZodDefault<z.ZodNumber>;
520
520
  timeout: z.ZodDefault<z.ZodNumber>;
521
521
  }, z.core.$strip>>;
522
+ providerModels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
522
523
  quality: z.ZodDefault<z.ZodObject<{
523
524
  minScore: z.ZodDefault<z.ZodNumber>;
524
525
  minCoverage: z.ZodDefault<z.ZodNumber>;
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';
@@ -868,6 +868,7 @@ function createDefaultConfigObject(projectName, language = "typescript") {
868
868
  temperature: 0,
869
869
  timeout: 12e4
870
870
  },
871
+ providerModels: {},
871
872
  quality: {
872
873
  minScore: 85,
873
874
  minCoverage: 80,
@@ -1047,6 +1048,7 @@ var init_schema = __esm({
1047
1048
  temperature: 0,
1048
1049
  timeout: 12e4
1049
1050
  }),
1051
+ providerModels: z.record(z.string(), z.string()).optional(),
1050
1052
  quality: QualityConfigSchema.default({
1051
1053
  minScore: 85,
1052
1054
  minCoverage: 80,
@@ -1183,6 +1185,7 @@ function deepMergeConfig(base, override) {
1183
1185
  ...override,
1184
1186
  project: { ...base.project, ...override.project },
1185
1187
  provider: { ...base.provider, ...override.provider },
1188
+ providerModels: { ...base.providerModels, ...override.providerModels },
1186
1189
  quality: { ...base.quality, ...override.quality },
1187
1190
  persistence: { ...base.persistence, ...override.persistence },
1188
1191
  // Merge optional sections only if present in either base or override
@@ -14863,7 +14866,9 @@ var OpenAIProvider = class {
14863
14866
  input,
14864
14867
  instructions: instructions ?? void 0,
14865
14868
  max_output_tokens: options?.maxTokens ?? this.config.maxTokens ?? 8192,
14866
- ...supportsTemp && { temperature: options?.temperature ?? this.config.temperature ?? 0 },
14869
+ ...supportsTemp && {
14870
+ temperature: options?.temperature ?? this.config.temperature ?? 0
14871
+ },
14867
14872
  store: false
14868
14873
  });
14869
14874
  return {
@@ -14898,7 +14903,9 @@ var OpenAIProvider = class {
14898
14903
  instructions: instructions ?? void 0,
14899
14904
  tools,
14900
14905
  max_output_tokens: options?.maxTokens ?? this.config.maxTokens ?? 8192,
14901
- ...supportsTemp && { temperature: options?.temperature ?? this.config.temperature ?? 0 },
14906
+ ...supportsTemp && {
14907
+ temperature: options?.temperature ?? this.config.temperature ?? 0
14908
+ },
14902
14909
  store: false
14903
14910
  });
14904
14911
  let content = "";
@@ -27262,7 +27269,9 @@ function createProtectedMetadataCandidates(resourceUrl, headerUrl) {
27262
27269
  candidates.push(`${origin}/.well-known/oauth-protected-resource`);
27263
27270
  if (pathPart && pathPart !== "/") {
27264
27271
  candidates.push(`${origin}/.well-known/oauth-protected-resource${pathPart}`);
27265
- candidates.push(`${origin}/.well-known/oauth-protected-resource/${pathPart.replace(/^\//, "")}`);
27272
+ candidates.push(
27273
+ `${origin}/.well-known/oauth-protected-resource/${pathPart.replace(/^\//, "")}`
27274
+ );
27266
27275
  }
27267
27276
  return Array.from(new Set(candidates));
27268
27277
  }
@@ -28238,7 +28247,30 @@ function getMCPServerManager() {
28238
28247
  return globalManager;
28239
28248
  }
28240
28249
 
28250
+ // src/mcp/tools.ts
28251
+ init_errors2();
28252
+
28241
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
+ }
28242
28274
  var mcpListServersTool = defineTool({
28243
28275
  name: "mcp_list_servers",
28244
28276
  description: `Inspect Coco's MCP configuration and current runtime connections.
@@ -28252,14 +28284,9 @@ when you need to know which MCP servers are configured, connected, healthy, or w
28252
28284
  projectPath: z.string().optional().describe("Project path whose .mcp.json should be merged. Defaults to process.cwd()")
28253
28285
  }),
28254
28286
  async execute({ includeDisabled, includeTools, projectPath }) {
28255
- const registry = new MCPRegistryImpl();
28256
- await registry.load();
28257
- const resolvedProjectPath = projectPath || process.cwd();
28258
- const configuredServers = mergeMCPConfigs(
28259
- registry.listServers(),
28260
- await loadMCPServersFromCOCOConfig(),
28261
- await loadProjectMCPFile(resolvedProjectPath)
28262
- ).filter((server) => includeDisabled || server.enabled !== false);
28287
+ const configuredServers = (await loadConfiguredServers(projectPath)).filter(
28288
+ (server) => includeDisabled || server.enabled !== false
28289
+ );
28263
28290
  const manager = getMCPServerManager();
28264
28291
  const servers = [];
28265
28292
  for (const server of configuredServers) {
@@ -28290,7 +28317,55 @@ when you need to know which MCP servers are configured, connected, healthy, or w
28290
28317
  };
28291
28318
  }
28292
28319
  });
28293
- var mcpTools = [mcpListServersTool];
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];
28294
28369
  init_allowed_paths();
28295
28370
  var BLOCKED_SYSTEM_PATHS = [
28296
28371
  "/etc",