@dosu/cli 0.35.3 → 0.36.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.
Files changed (2) hide show
  1. package/bin/dosu.js +32 -12
  2. package/package.json +1 -1
package/bin/dosu.js CHANGED
@@ -2098,17 +2098,24 @@ var init_commander = __esm(() => {
2098
2098
  });
2099
2099
 
2100
2100
  // src/config/identity.ts
2101
- function getAccessTokenUserID(accessToken) {
2101
+ function getAccessTokenClaim(accessToken, claim) {
2102
2102
  try {
2103
2103
  const payload = accessToken.split(".")[1];
2104
2104
  if (!payload)
2105
2105
  return;
2106
2106
  const decoded = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
2107
- return typeof decoded.sub === "string" && decoded.sub.length > 0 ? decoded.sub : undefined;
2107
+ const value = decoded[claim];
2108
+ return typeof value === "string" && value.length > 0 ? value : undefined;
2108
2109
  } catch {
2109
2110
  return;
2110
2111
  }
2111
2112
  }
2113
+ function getAccessTokenUserID(accessToken) {
2114
+ return getAccessTokenClaim(accessToken, "sub");
2115
+ }
2116
+ function getAccessTokenOAuthClientID(accessToken) {
2117
+ return getAccessTokenClaim(accessToken, "client_id");
2118
+ }
2112
2119
 
2113
2120
  // src/config/schema.ts
2114
2121
  var MODE_OSS = "oss", CONFIG_SCHEMA_VERSION = 2;
@@ -2452,14 +2459,18 @@ class Client {
2452
2459
  if (!session?.refresh_token)
2453
2460
  throw new Error("no refresh token available");
2454
2461
  const supabaseURL = getSupabaseURL();
2455
- const endpoint = `${supabaseURL}/auth/v1/token?grant_type=refresh_token`;
2462
+ const oauthClientID = getAccessTokenOAuthClientID(session.access_token);
2463
+ const endpoint = oauthClientID ? `${supabaseURL}/auth/v1/oauth/token` : `${supabaseURL}/auth/v1/token?grant_type=refresh_token`;
2464
+ const headers = oauthClientID ? { "Content-Type": "application/x-www-form-urlencoded" } : { "Content-Type": "application/json", apikey: getSupabaseAnonKey() };
2465
+ const body = oauthClientID ? new URLSearchParams({
2466
+ grant_type: "refresh_token",
2467
+ refresh_token: session.refresh_token,
2468
+ client_id: oauthClientID
2469
+ }).toString() : JSON.stringify({ refresh_token: session.refresh_token });
2456
2470
  const resp = await fetch(endpoint, {
2457
2471
  method: "POST",
2458
- headers: {
2459
- "Content-Type": "application/json",
2460
- apikey: getSupabaseAnonKey()
2461
- },
2462
- body: JSON.stringify({ refresh_token: session.refresh_token })
2472
+ headers,
2473
+ body
2463
2474
  });
2464
2475
  if (resp.status !== 200) {
2465
2476
  throw new Error(`refresh failed with status ${resp.status}`);
@@ -4748,7 +4759,7 @@ var init_dist4 = __esm(() => {
4748
4759
  function getVersionString() {
4749
4760
  return `v${VERSION}`;
4750
4761
  }
4751
- var VERSION = "0.35.3", INSTALL_CHANNEL = "npm";
4762
+ var VERSION = "0.36.0", INSTALL_CHANNEL = "npm";
4752
4763
 
4753
4764
  // src/debug/logger.ts
4754
4765
  import {
@@ -4882,7 +4893,7 @@ var init_logger = __esm(() => {
4882
4893
  });
4883
4894
 
4884
4895
  // src/client/contract.ts
4885
- var CLI_CONTRACT_HASH = "8735e566b0ed";
4896
+ var CLI_CONTRACT_HASH = "663c43d2937c";
4886
4897
 
4887
4898
  // src/client/trpc.ts
4888
4899
  var exports_trpc = {};
@@ -13633,6 +13644,7 @@ init_commander();
13633
13644
  init_config();
13634
13645
  init_logger();
13635
13646
  var import_picocolors5 = __toESM(require_picocolors(), 1);
13647
+ var DEFAULT_TIMEOUT_SECONDS = 600;
13636
13648
  function requireConfig2() {
13637
13649
  const cfg = loadConfig();
13638
13650
  if (!cfg.active_account?.target?.api_key) {
@@ -13646,16 +13658,24 @@ function requireConfig2() {
13646
13658
  return cfg;
13647
13659
  }
13648
13660
  function askCommand() {
13649
- const cmd = new Command("ask").description("Ask a question and get an AI-generated answer").argument("<question>", "The question to ask").option("--session <id>", "Continue a previous ask session").option("--json", "Output as JSON").action(async (question, opts) => {
13661
+ const cmd = new Command("ask").description("Ask a question and get an AI-generated answer").argument("<question>", "The question to ask").option("--session <id>", "Continue a previous ask session").option("--timeout <seconds>", `Request timeout in seconds (default: ${DEFAULT_TIMEOUT_SECONDS})`).option("--json", "Output as JSON").action(async (question, opts) => {
13650
13662
  const cfg = requireConfig2();
13651
13663
  const backendURL = getBackendURL();
13652
13664
  if (!backendURL) {
13653
13665
  console.error(import_picocolors5.default.red("Backend URL not configured."));
13654
13666
  process.exit(1);
13655
13667
  }
13668
+ let timeoutSeconds = DEFAULT_TIMEOUT_SECONDS;
13669
+ if (opts.timeout !== undefined) {
13670
+ timeoutSeconds = Number(opts.timeout);
13671
+ if (!Number.isFinite(timeoutSeconds) || timeoutSeconds <= 0) {
13672
+ console.error(import_picocolors5.default.red("--timeout must be a positive number of seconds."));
13673
+ process.exit(1);
13674
+ }
13675
+ }
13656
13676
  logger.debug("ask", `Asking: ${question}`);
13657
13677
  const controller = new AbortController;
13658
- const timeout = setTimeout(() => controller.abort(), 120000);
13678
+ const timeout = setTimeout(() => controller.abort(), timeoutSeconds * 1000);
13659
13679
  try {
13660
13680
  const resp = await fetch(`${backendURL}/ask`, {
13661
13681
  method: "POST",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dosu/cli",
3
- "version": "0.35.3",
3
+ "version": "0.36.0",
4
4
  "type": "module",
5
5
  "description": "Dosu CLI - Manage MCP servers for AI tools",
6
6
  "license": "MIT",