@corbat-tech/coco 2.25.2 → 2.25.4

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 CHANGED
@@ -5948,10 +5948,9 @@ var init_gemini = __esm({
5948
5948
  });
5949
5949
  }
5950
5950
  }
5951
+ history.push({ role: "function", parts: functionResponses });
5951
5952
  if (isLastMessage) {
5952
- lastUserMessage = functionResponses;
5953
- } else {
5954
- history.push({ role: "user", parts: functionResponses });
5953
+ lastUserMessage = "";
5955
5954
  }
5956
5955
  } else {
5957
5956
  const parts = this.convertContent(msg.content);
@@ -21296,12 +21295,29 @@ var init_http = __esm({
21296
21295
  });
21297
21296
  let response = await doFetch();
21298
21297
  if (response.status !== 401 || !this.shouldAttemptOAuth()) {
21298
+ if (this.shouldAttemptOAuth() && !this.oauthToken && response.headers.get("www-authenticate")) {
21299
+ await this.ensureOAuthToken(response.headers.get("www-authenticate"));
21300
+ response = await doFetch();
21301
+ }
21299
21302
  return response;
21300
21303
  }
21301
21304
  await this.ensureOAuthToken(response.headers.get("www-authenticate"));
21302
21305
  response = await doFetch();
21303
21306
  return response;
21304
21307
  }
21308
+ looksLikeAuthErrorMessage(message) {
21309
+ if (!message) return false;
21310
+ const msg = message.toLowerCase();
21311
+ const hasStrongAuthSignal = msg.includes("unauthorized") || msg.includes("unauthorised") || msg.includes("authentication") || msg.includes("oauth") || msg.includes("access token") || msg.includes("bearer") || msg.includes("not authenticated") || msg.includes("not logged") || msg.includes("login") || msg.includes("generate") && msg.includes("token");
21312
+ const hasVendorHint = msg.includes("gemini cli") || msg.includes("jira") || msg.includes("confluence") || msg.includes("atlassian");
21313
+ const hasWeakAuthSignal = msg.includes("authenticate") || msg.includes("token") || msg.includes("authorization");
21314
+ return hasStrongAuthSignal || // Vendor-specific hints alone are not enough; require an auth-related token too.
21315
+ hasVendorHint && hasWeakAuthSignal;
21316
+ }
21317
+ isJsonRpcAuthError(payload) {
21318
+ if (!payload.error) return false;
21319
+ return this.looksLikeAuthErrorMessage(payload.error.message);
21320
+ }
21305
21321
  /**
21306
21322
  * Connect to the HTTP transport
21307
21323
  */
@@ -21365,6 +21381,22 @@ var init_http = __esm({
21365
21381
  throw new MCPTransportError(`HTTP error ${response.status}: ${response.statusText}`);
21366
21382
  }
21367
21383
  const data = await response.json();
21384
+ if (this.shouldAttemptOAuth() && this.isJsonRpcAuthError(data)) {
21385
+ await this.ensureOAuthToken(response.headers.get("www-authenticate"));
21386
+ const retryResponse = await this.sendRequestWithOAuthRetry(
21387
+ "POST",
21388
+ JSON.stringify(message),
21389
+ abortController.signal
21390
+ );
21391
+ if (!retryResponse.ok) {
21392
+ throw new MCPTransportError(
21393
+ `HTTP error ${retryResponse.status}: ${retryResponse.statusText}`
21394
+ );
21395
+ }
21396
+ const retryData = await retryResponse.json();
21397
+ this.messageCallback?.(retryData);
21398
+ return;
21399
+ }
21368
21400
  this.messageCallback?.(data);
21369
21401
  return;
21370
21402
  } catch (error) {
@@ -38212,9 +38244,6 @@ async function savePermissionPreference(key, value) {
38212
38244
  }
38213
38245
  async function shouldShowPermissionSuggestion() {
38214
38246
  const prefs = await loadPermissionPreferences();
38215
- if (prefs.recommendedAllowlistPrompted) {
38216
- return false;
38217
- }
38218
38247
  if (prefs.recommendedAllowlistDismissed) {
38219
38248
  return false;
38220
38249
  }
@@ -38230,7 +38259,6 @@ async function applyRecommendedPermissions() {
38230
38259
  await savePermissionPreference("recommendedAllowlistApplied", true);
38231
38260
  }
38232
38261
  async function showPermissionSuggestion() {
38233
- await savePermissionPreference("recommendedAllowlistPrompted", true);
38234
38262
  console.log();
38235
38263
  console.log(chalk.magenta.bold(" \u{1F4CB} Recommended Permissions"));
38236
38264
  console.log();
@@ -38257,6 +38285,7 @@ async function showPermissionSuggestion() {
38257
38285
  return;
38258
38286
  }
38259
38287
  if (action === "dismiss") {
38288
+ await savePermissionPreference("recommendedAllowlistPrompted", true);
38260
38289
  await savePermissionPreference("recommendedAllowlistDismissed", true);
38261
38290
  console.log(chalk.dim(" Won't show again. Use /permissions to apply later."));
38262
38291
  return;
@@ -38272,6 +38301,7 @@ async function showPermissionSuggestion() {
38272
38301
  }
38273
38302
  }
38274
38303
  await applyRecommendedPermissions();
38304
+ await savePermissionPreference("recommendedAllowlistPrompted", true);
38275
38305
  console.log(chalk.green(" \u2713 Recommended permissions applied"));
38276
38306
  console.log(chalk.dim(" Use /permissions to review or modify anytime."));
38277
38307
  }
@@ -52831,6 +52861,13 @@ async function startRepl(options = {}) {
52831
52861
  if (activeCount > 0) {
52832
52862
  logger2.info(`[MCP] ${activeCount} MCP server(s) active`);
52833
52863
  }
52864
+ const failedServers = enabledServers.map((s) => s.name).filter((name) => !connections.has(name));
52865
+ if (failedServers.length > 0) {
52866
+ p26.log.warn(
52867
+ `MCP startup check: ${failedServers.length} server(s) failed to connect: ${failedServers.join(", ")}`
52868
+ );
52869
+ p26.log.message(chalk.dim("Run /mcp health <name> to inspect details."));
52870
+ }
52834
52871
  }
52835
52872
  } catch (mcpError) {
52836
52873
  logger2.warn(