snowcode 0.9.21 → 0.9.23

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/dist/cli.mjs +146 -19
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -125648,7 +125648,7 @@ var init_metadata = __esm(() => {
125648
125648
  isClaudeAiAuth: isClaudeAISubscriber(),
125649
125649
  version: "99.0.0",
125650
125650
  versionBase: getVersionBase(),
125651
- buildTime: "2026-04-05T03:49:47.637Z",
125651
+ buildTime: "2026-04-05T04:06:45.418Z",
125652
125652
  deploymentEnvironment: env2.detectDeploymentEnvironment(),
125653
125653
  ...isEnvTruthy(process.env.GITHUB_ACTIONS) && {
125654
125654
  githubEventName: process.env.GITHUB_EVENT_NAME,
@@ -130678,7 +130678,7 @@ function compareVersions(a2, b) {
130678
130678
  return 0;
130679
130679
  }
130680
130680
  function getCurrentVersion() {
130681
- const displayVersion = (typeof MACRO !== "undefined" ? "0.9.21" : undefined) ?? (() => {
130681
+ const displayVersion = (typeof MACRO !== "undefined" ? "0.9.23" : undefined) ?? (() => {
130682
130682
  try {
130683
130683
  const pkg = require2("../../package.json");
130684
130684
  return pkg.version;
@@ -130893,10 +130893,11 @@ async function printStartupScreen() {
130893
130893
  const sLen = ` ● ${sL} Ready — type /help to begin`.length;
130894
130894
  out.push(boxRow(sRow, W2, sLen));
130895
130895
  out.push(`${rgb(...BORDER)}╚${"═".repeat(W2 - 2)}╝${RESET}`);
130896
- const _ver = "0.9.21";
130896
+ const _ver = "0.9.23";
130897
+ const _currentVersion = getCurrentVersion();
130897
130898
  const _update = await getAvailableUpdateWithRefresh({ timeoutMs: 1200 });
130898
130899
  out.push(` ${DIM}${rgb(...DIMCOL)}snowcode v${_ver}${RESET}`);
130899
- if (_update) {
130900
+ if (_update && compareVersions(_update, _currentVersion) > 0) {
130900
130901
  out.push(` ${rgb(...ACCENT)}★ Update available v${_update} → /update${RESET}`);
130901
130902
  }
130902
130903
  out.push("");
@@ -370951,7 +370952,7 @@ function getAnthropicEnvMetadata() {
370951
370952
  function getBuildAgeMinutes() {
370952
370953
  if (false)
370953
370954
  ;
370954
- const buildTime = new Date("2026-04-05T03:49:47.637Z").getTime();
370955
+ const buildTime = new Date("2026-04-05T04:06:45.418Z").getTime();
370955
370956
  if (isNaN(buildTime))
370956
370957
  return;
370957
370958
  return Math.floor((Date.now() - buildTime) / 60000);
@@ -411623,8 +411624,13 @@ function OAuthFlow({
411623
411624
  }, undefined, false, undefined, this),
411624
411625
  /* @__PURE__ */ jsx_dev_runtime209.jsxDEV(ThemedText, {
411625
411626
  dimColor: true,
411626
- children: "R replace existing · K keep existing · Esc cancel"
411627
- }, undefined, false, undefined, this)
411627
+ children: [
411628
+ duplicateDecision?.replaceHint ?? "R replace existing",
411629
+ " · ",
411630
+ duplicateDecision?.keepHint ?? "K keep existing",
411631
+ " · Esc cancel"
411632
+ ]
411633
+ }, undefined, true, undefined, this)
411628
411634
  ]
411629
411635
  }, undefined, true, undefined, this);
411630
411636
  return /* @__PURE__ */ jsx_dev_runtime209.jsxDEV(ThemedBox_default, {
@@ -412212,9 +412218,64 @@ function AuthCommand({
412212
412218
  code_verifier: verifier
412213
412219
  }, "codex_oauth");
412214
412220
  const email3 = emailFromTokens(tokens);
412221
+ const accountId = parseChatgptAccountId(tokens.access_token) ?? parseChatgptAccountId(tokens.id_token);
412215
412222
  persistCodexOauthSession(tokens);
412216
- addAccount({ type: "codex_oauth", label: `Codex: ${email3}`, email: email3, refreshToken: tokens.refresh_token, enabled: true });
412217
412223
  process.env.OPENAI_API_KEY = "chatgpt-oauth";
412224
+ const matchingAccounts = loadAccounts().accounts.filter((account) => account.type === "codex_oauth" && account.email?.trim().toLowerCase() === email3.trim().toLowerCase()).sort((left, right) => Date.parse(right.addedAt || "") - Date.parse(left.addedAt || ""));
412225
+ if (matchingAccounts.length > 0) {
412226
+ return {
412227
+ email: email3,
412228
+ refreshToken: tokens.refresh_token ?? "",
412229
+ duplicateDecision: {
412230
+ message: `This Codex account already exists: ${email3}`,
412231
+ replaceHint: "R replace existing",
412232
+ keepHint: "K keep both",
412233
+ onReplace: () => {
412234
+ const [primary, ...duplicates] = matchingAccounts;
412235
+ updateAccount(primary.id, {
412236
+ label: `Codex: ${email3}`,
412237
+ email: email3,
412238
+ accountId,
412239
+ refreshToken: tokens.refresh_token ?? primary.refreshToken,
412240
+ enabled: true
412241
+ });
412242
+ for (const duplicate of duplicates) {
412243
+ removeAccount(duplicate.id);
412244
+ }
412245
+ appendAuthLog("codex_oauth", `account replaced email=${email3} removedDuplicates=${duplicates.length}`);
412246
+ return {
412247
+ email: email3,
412248
+ refreshToken: tokens.refresh_token ?? primary.refreshToken ?? "",
412249
+ completionMessage: `Codex account updated: ${email3}`
412250
+ };
412251
+ },
412252
+ onKeep: () => {
412253
+ addAccount({
412254
+ type: "codex_oauth",
412255
+ label: `Codex: ${email3}`,
412256
+ email: email3,
412257
+ accountId,
412258
+ refreshToken: tokens.refresh_token,
412259
+ enabled: true
412260
+ });
412261
+ appendAuthLog("codex_oauth", `duplicate account saved email=${email3}`);
412262
+ return {
412263
+ email: email3,
412264
+ refreshToken: tokens.refresh_token ?? "",
412265
+ completionMessage: `Codex duplicate account added: ${email3}`
412266
+ };
412267
+ }
412268
+ }
412269
+ };
412270
+ }
412271
+ addAccount({
412272
+ type: "codex_oauth",
412273
+ label: `Codex: ${email3}`,
412274
+ email: email3,
412275
+ accountId,
412276
+ refreshToken: tokens.refresh_token,
412277
+ enabled: true
412278
+ });
412218
412279
  appendAuthLog("codex_oauth", `account saved email=${email3}`);
412219
412280
  return { email: email3, refreshToken: tokens.refresh_token ?? "" };
412220
412281
  },
@@ -449520,6 +449581,13 @@ function UsageBar({ value, width = 12 }) {
449520
449581
  function err2(e) {
449521
449582
  return e instanceof Error ? e.message : String(e);
449522
449583
  }
449584
+ function normalizeEmail(value) {
449585
+ const trimmed = value?.trim().toLowerCase();
449586
+ return trimmed || null;
449587
+ }
449588
+ function sortNewestFirst(accounts) {
449589
+ return [...accounts].sort((left, right) => Date.parse(right.addedAt || "") - Date.parse(left.addedAt || ""));
449590
+ }
449523
449591
  async function withRetry2(fn, retries = 3) {
449524
449592
  let lastError;
449525
449593
  for (let attempt = 1;attempt <= retries; attempt++) {
@@ -449807,15 +449875,73 @@ ${errorBody}`);
449807
449875
  throw new Error("Codex token refresh returned no access token");
449808
449876
  return json2;
449809
449877
  }
449878
+ async function refreshCodexTokenWithFallback(account) {
449879
+ const candidates = [];
449880
+ const seen = new Set;
449881
+ const pushCandidate = (refreshToken, candidateAccount, accountId) => {
449882
+ const trimmed = refreshToken?.trim();
449883
+ if (!trimmed || seen.has(trimmed))
449884
+ return;
449885
+ seen.add(trimmed);
449886
+ candidates.push({
449887
+ refreshToken: trimmed,
449888
+ account: candidateAccount,
449889
+ accountId: accountId ?? candidateAccount?.accountId
449890
+ });
449891
+ };
449892
+ pushCandidate(account.refreshToken, account, account.accountId);
449893
+ const accountEmail = normalizeEmail(account.email);
449894
+ if (accountEmail) {
449895
+ const siblingAccounts = sortNewestFirst(loadAccounts().accounts.filter((item) => item.enabled && item.type === "codex_oauth" && item.id !== account.id && normalizeEmail(item.email) === accountEmail));
449896
+ for (const sibling of siblingAccounts) {
449897
+ pushCandidate(sibling.refreshToken, sibling, sibling.accountId);
449898
+ }
449899
+ }
449900
+ const authJsonCredentials = resolveCodexApiCredentials();
449901
+ const enabledCodexAccounts = loadAccounts().accounts.filter((item) => item.enabled && item.type === "codex_oauth" && item.refreshToken);
449902
+ if (authJsonCredentials.refreshToken && (!account.accountId || authJsonCredentials.accountId === account.accountId || enabledCodexAccounts.length === 1)) {
449903
+ pushCandidate(authJsonCredentials.refreshToken, undefined, authJsonCredentials.accountId);
449904
+ }
449905
+ let lastError;
449906
+ for (const candidate of candidates) {
449907
+ try {
449908
+ const tokenResponse = await refreshCodexToken(candidate.refreshToken);
449909
+ const rotatedRefreshToken = tokenResponse.refresh_token ?? candidate.refreshToken;
449910
+ if (candidate.account?.id && rotatedRefreshToken !== candidate.account.refreshToken) {
449911
+ updateAccount(candidate.account.id, {
449912
+ refreshToken: rotatedRefreshToken
449913
+ });
449914
+ }
449915
+ if (account.id !== candidate.account?.id && rotatedRefreshToken !== account.refreshToken) {
449916
+ updateAccount(account.id, {
449917
+ refreshToken: rotatedRefreshToken,
449918
+ ...candidate.accountId ? { accountId: candidate.accountId } : {}
449919
+ });
449920
+ }
449921
+ return {
449922
+ tokenResponse,
449923
+ accountId: candidate.accountId
449924
+ };
449925
+ } catch (error42) {
449926
+ lastError = error42;
449927
+ }
449928
+ }
449929
+ throw lastError ?? new Error("Codex session expired. Re-run /auth for that ChatGPT account.");
449930
+ }
449810
449931
  async function fetchCodex(account) {
449811
- const tokenResponse = await refreshCodexToken(account.refreshToken);
449932
+ const { tokenResponse, accountId } = await refreshCodexTokenWithFallback(account);
449812
449933
  const token = tokenResponse.access_token;
449813
449934
  if (tokenResponse.refresh_token && tokenResponse.refresh_token !== account.refreshToken) {
449814
449935
  updateAccount(account.id, { refreshToken: tokenResponse.refresh_token });
449815
449936
  }
449816
449937
  const headers = { Authorization: `Bearer ${token}`, "User-Agent": "codex-cli" };
449817
- if (account.email)
449818
- headers["ChatGPT-Account-Id"] = account.email;
449938
+ const resolvedAccountId = account.accountId ?? accountId;
449939
+ if (resolvedAccountId) {
449940
+ headers["ChatGPT-Account-Id"] = resolvedAccountId;
449941
+ if (resolvedAccountId !== account.accountId) {
449942
+ updateAccount(account.id, { accountId: resolvedAccountId });
449943
+ }
449944
+ }
449819
449945
  const res = await fetch(CODEX_USAGE_URL, { headers });
449820
449946
  if (!res.ok) {
449821
449947
  const errorBody = await res.text().catch(() => "unknown error");
@@ -450420,6 +450546,7 @@ var React94, import_react161, jsx_dev_runtime278, AG_CLOUDCODE_BASE = "https://c
450420
450546
  var init_usage2 = __esm(() => {
450421
450547
  init_ink2();
450422
450548
  init_accountManager();
450549
+ init_providerConfig();
450423
450550
  init_antigravityOAuth();
450424
450551
  init_antigravityLocalSessions();
450425
450552
  init_antigravityLocalUsage();
@@ -464814,7 +464941,7 @@ var init_bridge_kick = __esm(() => {
464814
464941
  var call59 = async () => {
464815
464942
  return {
464816
464943
  type: "text",
464817
- value: `${"99.0.0"} (built ${"2026-04-05T03:49:47.637Z"})`
464944
+ value: `${"99.0.0"} (built ${"2026-04-05T04:06:45.418Z"})`
464818
464945
  };
464819
464946
  }, version2, version_default;
464820
464947
  var init_version = __esm(() => {
@@ -538276,7 +538403,7 @@ function WelcomeV2() {
538276
538403
  dimColor: true,
538277
538404
  children: [
538278
538405
  "v",
538279
- "0.9.21",
538406
+ "0.9.23",
538280
538407
  " "
538281
538408
  ]
538282
538409
  }, undefined, true, undefined, this)
@@ -538476,7 +538603,7 @@ function WelcomeV2() {
538476
538603
  dimColor: true,
538477
538604
  children: [
538478
538605
  "v",
538479
- "0.9.21",
538606
+ "0.9.23",
538480
538607
  " "
538481
538608
  ]
538482
538609
  }, undefined, true, undefined, this)
@@ -538702,7 +538829,7 @@ function AppleTerminalWelcomeV2(t0) {
538702
538829
  dimColor: true,
538703
538830
  children: [
538704
538831
  "v",
538705
- "0.9.21",
538832
+ "0.9.23",
538706
538833
  " "
538707
538834
  ]
538708
538835
  }, undefined, true, undefined, this);
@@ -538956,7 +539083,7 @@ function AppleTerminalWelcomeV2(t0) {
538956
539083
  dimColor: true,
538957
539084
  children: [
538958
539085
  "v",
538959
- "0.9.21",
539086
+ "0.9.23",
538960
539087
  " "
538961
539088
  ]
538962
539089
  }, undefined, true, undefined, this);
@@ -559077,7 +559204,7 @@ Usage: claude --remote "your task description"`, () => gracefulShutdown(1));
559077
559204
  pendingHookMessages
559078
559205
  }, renderAndRun);
559079
559206
  }
559080
- }).version("0.9.21 (Snowcode)", "-v, --version", "Output the version number");
559207
+ }).version("0.9.23 (Snowcode)", "-v, --version", "Output the version number");
559081
559208
  program.option("-w, --worktree [name]", "Create a new git worktree for this session (optionally specify a name)");
559082
559209
  program.option("--tmux", "Create a tmux session for the worktree (requires --worktree). Uses iTerm2 native panes when available; use --tmux=classic for traditional tmux.");
559083
559210
  if (canUserConfigureAdvisor()) {
@@ -559638,7 +559765,7 @@ function validateProviderEnvOrExit() {
559638
559765
  async function main2() {
559639
559766
  const args = process.argv.slice(2);
559640
559767
  if (args.length === 1 && (args[0] === "--version" || args[0] === "-v" || args[0] === "-V")) {
559641
- console.log(`${"0.9.21"} (Snowcode)`);
559768
+ console.log(`${"0.9.23"} (Snowcode)`);
559642
559769
  return;
559643
559770
  }
559644
559771
  validateProviderEnvOrExit();
@@ -559727,4 +559854,4 @@ async function main2() {
559727
559854
  }
559728
559855
  main2();
559729
559856
 
559730
- //# debugId=E43E7FACDA558B6964756E2164756E21
559857
+ //# debugId=C9A769673304C1DF64756E2164756E21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snowcode",
3
- "version": "0.9.21",
3
+ "version": "0.9.23",
4
4
  "description": "It's cold outside, isn't it?",
5
5
  "type": "module",
6
6
  "bin": {