{"version":3,"sources":["../src/cli/commands/request-increase.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport { loadConfig, isLoggedIn } from \"@/cli/utils/governance/config\";\n\n/**\n * `langwatch request-increase` — Screen-8 tail of the budget-exceeded\n * flow. When the gateway 402's a request, it returns a signed\n * request_increase_url with the user/limit/spent params HMAC'd in.\n * The wrapper persists that URL on the way through; this command\n * opens the exact URL so the admin sees the request with the right\n * context.\n *\n * If no signed URL has been cached, fall back to the dashboard's\n * static request page.\n */\nexport const requestIncreaseCommand = async (\n  options?: { browser?: string },\n): Promise<void> => {\n  const cfg = loadConfig();\n  if (!isLoggedIn(cfg)) {\n    console.error(chalk.yellow(\"Not logged in. Run `langwatch login --device` first.\"));\n    process.exit(1);\n  }\n\n  const target =\n    cfg.last_request_increase_url ??\n    `${cfg.control_plane_url.replace(/\\/+$/, \"\")}/me/budget/request`;\n\n  console.log(`Opening ${target}`);\n  await openInBrowser(target, options?.browser);\n};\n\nasync function openInBrowser(url: string, override?: string): Promise<void> {\n  const choice = override ?? process.env.LANGWATCH_BROWSER ?? process.env.BROWSER ?? \"\";\n  if (choice === \"none\") return;\n  const open = (await import(\"open\")).default;\n  try {\n    if (!choice || choice === \"default\") {\n      await open(url);\n      return;\n    }\n    await open(url, { app: { name: choice } });\n  } catch {\n    /* see dashboard.ts */\n  }\n};\n"],"mappings":";;;;;;;AAAA,OAAO,WAAW;AAcX,IAAM,yBAAyB,OACpC,YACkB;AAhBpB;AAiBE,QAAM,MAAM,WAAW;AACvB,MAAI,CAAC,WAAW,GAAG,GAAG;AACpB,YAAQ,MAAM,MAAM,OAAO,sDAAsD,CAAC;AAClF,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,UACJ,SAAI,8BAAJ,YACA,GAAG,IAAI,kBAAkB,QAAQ,QAAQ,EAAE,CAAC;AAE9C,UAAQ,IAAI,WAAW,MAAM,EAAE;AAC/B,QAAM,cAAc,QAAQ,mCAAS,OAAO;AAC9C;AAEA,eAAe,cAAc,KAAa,UAAkC;AA/B5E;AAgCE,QAAM,UAAS,yCAAY,QAAQ,IAAI,sBAAxB,YAA6C,QAAQ,IAAI,YAAzD,YAAoE;AACnF,MAAI,WAAW,OAAQ;AACvB,QAAM,QAAQ,MAAM,OAAO,MAAM,GAAG;AACpC,MAAI;AACF,QAAI,CAAC,UAAU,WAAW,WAAW;AACnC,YAAM,KAAK,GAAG;AACd;AAAA,IACF;AACA,UAAM,KAAK,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,EAAE,CAAC;AAAA,EAC3C,SAAQ;AAAA,EAER;AACF;","names":[]}