ather-code 0.34.6 → 0.34.7

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 (3) hide show
  1. package/dist/cli.mjs +36 -36
  2. package/dist/sdk.mjs +421 -326
  3. package/package.json +1 -1
package/dist/sdk.mjs CHANGED
@@ -10126,7 +10126,7 @@ var init_version = __esm(() => {
10126
10126
  import_semver = __toESM(require_semver2(), 1);
10127
10127
  fallbackBuildVersion = (() => {
10128
10128
  try {
10129
- return "0.34.6";
10129
+ return "0.34.7";
10130
10130
  } catch {
10131
10131
  return "0.0.0";
10132
10132
  }
@@ -11514,298 +11514,6 @@ var init_dashscope_intl = __esm(() => {
11514
11514
  });
11515
11515
  });
11516
11516
 
11517
- // src/errors/registry.ts
11518
- function interpolate(template, params = {}) {
11519
- return template.replace(/<([a-zA-Z][a-zA-Z0-9_]*)>/g, (match, key) => {
11520
- const value = params[key];
11521
- return value === undefined ? match : String(value);
11522
- });
11523
- }
11524
- function atherMessage(code, params = {}) {
11525
- return interpolate(ATHER_ERRORS[code].message, params);
11526
- }
11527
- var ATHER_ERRORS, ATHER_ERROR_CODES, AtherCodedError;
11528
- var init_registry = __esm(() => {
11529
- ATHER_ERRORS = {
11530
- "ATHER-MODEL-001": {
11531
- code: "ATHER-MODEL-001",
11532
- category: "MODEL",
11533
- message: "Model unavailable: <model>",
11534
- hint: "Run /models to pick another, or /models refresh.",
11535
- severity: "error",
11536
- retryable: false,
11537
- internalCause: "The provider returned model_not_found for the requested model."
11538
- },
11539
- "ATHER-MODEL-002": {
11540
- code: "ATHER-MODEL-002",
11541
- category: "MODEL",
11542
- message: "Model returned an empty response.",
11543
- hint: "Try again once, or switch models with /models.",
11544
- severity: "error",
11545
- retryable: true,
11546
- internalCause: "The provider returned a completion with no content blocks."
11547
- },
11548
- "ATHER-MODEL-003": {
11549
- code: "ATHER-MODEL-003",
11550
- category: "MODEL",
11551
- message: "Model does not support the requested feature.",
11552
- hint: "Pick a model that supports it via /models.",
11553
- severity: "error",
11554
- retryable: false,
11555
- internalCause: "The provider rejected the request as unsupported for this model."
11556
- },
11557
- "ATHER-AUTH-001": {
11558
- code: "ATHER-AUTH-001",
11559
- category: "AUTH",
11560
- message: "Not signed in.",
11561
- hint: "Run /link to sign in.",
11562
- severity: "error",
11563
- retryable: false,
11564
- internalCause: "No valid stored session when one was required."
11565
- },
11566
- "ATHER-AUTH-002": {
11567
- code: "ATHER-AUTH-002",
11568
- category: "AUTH",
11569
- message: "Session expired.",
11570
- hint: "Run /link again.",
11571
- severity: "warn",
11572
- retryable: false,
11573
- internalCause: "Stored session exp is in the past, within the skew guard."
11574
- },
11575
- "ATHER-AUTH-003": {
11576
- code: "ATHER-AUTH-003",
11577
- category: "AUTH",
11578
- message: "Session file was corrupt and has been reset.",
11579
- hint: "Run /link again.",
11580
- severity: "warn",
11581
- retryable: false,
11582
- internalCause: "Session JSON failed to parse or failed the shape contract."
11583
- },
11584
- "ATHER-AUTH-004": {
11585
- code: "ATHER-AUTH-004",
11586
- category: "AUTH",
11587
- message: "Sign-in timed out.",
11588
- hint: "Run /link again.",
11589
- severity: "warn",
11590
- retryable: false,
11591
- internalCause: "Device flow poll hit the TTL without an authorized decision."
11592
- },
11593
- "ATHER-AUTH-005": {
11594
- code: "ATHER-AUTH-005",
11595
- category: "AUTH",
11596
- message: "Sign-in was denied.",
11597
- hint: "Run /link again if this was not you.",
11598
- severity: "warn",
11599
- retryable: false,
11600
- internalCause: "Authorization endpoint returned access_denied."
11601
- },
11602
- "ATHER-AUTH-006": {
11603
- code: "ATHER-AUTH-006",
11604
- category: "AUTH",
11605
- message: "Cannot reach the sign-in server.",
11606
- hint: "Check your connection and try again.",
11607
- severity: "error",
11608
- retryable: true,
11609
- internalCause: "Network failure contacting the auth origin."
11610
- },
11611
- "ATHER-AUTH-007": {
11612
- code: "ATHER-AUTH-007",
11613
- category: "AUTH",
11614
- message: "Sign-in server rejected the request.",
11615
- hint: "Try again later.",
11616
- severity: "error",
11617
- retryable: true,
11618
- internalCause: "Auth origin returned a 5xx or an unexpected error shape."
11619
- },
11620
- "ATHER-RATE-001": {
11621
- code: "ATHER-RATE-001",
11622
- category: "RATE",
11623
- message: "Provider busy. Try again in a moment, or /model to switch.",
11624
- hint: "Nothing was changed on your account.",
11625
- severity: "error",
11626
- retryable: false,
11627
- internalCause: "The provider refused the request and the silent retry budget was exhausted."
11628
- },
11629
- "ATHER-RATE-002": {
11630
- code: "ATHER-RATE-002",
11631
- category: "RATE",
11632
- message: "Local model is busy; the request will continue automatically.",
11633
- hint: "Waiting for the local model to free up.",
11634
- severity: "info",
11635
- retryable: true,
11636
- internalCause: "Local request budget exhausted; attempt deferred."
11637
- },
11638
- "ATHER-RATE-003": {
11639
- code: "ATHER-RATE-003",
11640
- category: "RATE",
11641
- message: "Credits exhausted for the current UTC day.",
11642
- hint: "Credits reset at UTC midnight, or switch to a BYOK provider.",
11643
- severity: "error",
11644
- retryable: false,
11645
- internalCause: "Local credit estimate for the UTC day reached zero."
11646
- },
11647
- "ATHER-NET-001": {
11648
- code: "ATHER-NET-001",
11649
- category: "NET",
11650
- message: "Request timed out after <n>s.",
11651
- hint: "Try again, or check your connection.",
11652
- severity: "error",
11653
- retryable: true,
11654
- internalCause: "The request exceeded its timeout budget."
11655
- },
11656
- "ATHER-NET-002": {
11657
- code: "ATHER-NET-002",
11658
- category: "NET",
11659
- message: "Network unreachable.",
11660
- hint: "Check your connection and try again.",
11661
- severity: "error",
11662
- retryable: true,
11663
- internalCause: "Transport reported the host could not be reached."
11664
- },
11665
- "ATHER-NET-003": {
11666
- code: "ATHER-NET-003",
11667
- category: "NET",
11668
- message: "Stream stalled and was aborted.",
11669
- hint: "Try again.",
11670
- severity: "error",
11671
- retryable: true,
11672
- internalCause: "No stream progress within the stall window."
11673
- },
11674
- "ATHER-PROV-001": {
11675
- code: "ATHER-PROV-001",
11676
- category: "PROV",
11677
- message: "Gateway URL not configured.",
11678
- hint: "Set ATHER_FREE_GATEWAY_URL in your environment.",
11679
- severity: "error",
11680
- retryable: false,
11681
- internalCause: "ATHER_FREE_GATEWAY_URL was unset at the point of use."
11682
- },
11683
- "ATHER-PROV-002": {
11684
- code: "ATHER-PROV-002",
11685
- category: "PROV",
11686
- message: "Auth URL not configured.",
11687
- hint: "Set ATHER_FREE_AUTH_URL in your environment.",
11688
- severity: "error",
11689
- retryable: false,
11690
- internalCause: "ATHER_FREE_AUTH_URL was unset at the point of use."
11691
- },
11692
- "ATHER-PROV-003": {
11693
- code: "ATHER-PROV-003",
11694
- category: "PROV",
11695
- message: "Provider credentials missing or invalid.",
11696
- hint: "Check the provider settings, or run /link for Ather Free.",
11697
- severity: "error",
11698
- retryable: false,
11699
- internalCause: "Credential pool had no usable lease for the route."
11700
- },
11701
- "ATHER-CFG-001": {
11702
- code: "ATHER-CFG-001",
11703
- category: "CFG",
11704
- message: "Config file unreadable or corrupt.",
11705
- hint: "Delete the file in ~/.ather-code and restart.",
11706
- severity: "error",
11707
- retryable: false,
11708
- internalCause: "Local config JSON failed to parse."
11709
- },
11710
- "ATHER-CFG-002": {
11711
- code: "ATHER-CFG-002",
11712
- category: "CFG",
11713
- message: "Cannot write to ~/.ather-code.",
11714
- hint: "Check folder permissions.",
11715
- severity: "error",
11716
- retryable: false,
11717
- internalCause: "Write into the config home failed."
11718
- },
11719
- "ATHER-TOOL-001": {
11720
- code: "ATHER-TOOL-001",
11721
- category: "TOOL",
11722
- message: "Tool <name> failed: <reason>",
11723
- hint: "Check the tool inputs and try again.",
11724
- severity: "error",
11725
- retryable: false,
11726
- internalCause: "Tool execution threw a non-abort error."
11727
- },
11728
- "ATHER-TOOL-002": {
11729
- code: "ATHER-TOOL-002",
11730
- category: "TOOL",
11731
- message: "Tool <name> exceeded the time limit.",
11732
- hint: "Try again, or narrow what the tool has to do.",
11733
- severity: "error",
11734
- retryable: true,
11735
- internalCause: "Tool exceeded its wall-clock budget and was aborted."
11736
- },
11737
- "ATHER-TOOL-003": {
11738
- code: "ATHER-TOOL-003",
11739
- category: "TOOL",
11740
- message: "Tool <name> is disabled for this session after repeated failures.",
11741
- hint: "Restart the session to re-enable it.",
11742
- severity: "warn",
11743
- retryable: false,
11744
- internalCause: "Failure counter for this tool hit the disable threshold."
11745
- },
11746
- "ATHER-AGENT-001": {
11747
- code: "ATHER-AGENT-001",
11748
- category: "AGENT",
11749
- message: "Reached maximum turns (<turns>).",
11750
- hint: "Send a new message to continue, or raise AGENT_MAX_TURNS.",
11751
- severity: "warn",
11752
- retryable: false,
11753
- internalCause: "The per-prompt turn budget was exhausted."
11754
- },
11755
- "ATHER-AUTHZ-001": {
11756
- code: "ATHER-AUTHZ-001",
11757
- category: "AUTHZ",
11758
- message: "Permission denied for this action.",
11759
- hint: "Grant the permission, or choose another action.",
11760
- severity: "error",
11761
- retryable: false,
11762
- internalCause: "Permission layer rejected the requested action."
11763
- },
11764
- "ATHER-AUTHZ-002": {
11765
- code: "ATHER-AUTHZ-002",
11766
- category: "AUTHZ",
11767
- message: "Action requires confirmation.",
11768
- hint: "Approve or deny.",
11769
- severity: "info",
11770
- retryable: false,
11771
- internalCause: "Action is gated behind an interactive confirmation."
11772
- },
11773
- "ATHER-INT-001": {
11774
- code: "ATHER-INT-001",
11775
- category: "INT",
11776
- message: "Internal error.",
11777
- hint: "Report at github.com/bguser30-maker/ather-code.",
11778
- severity: "error",
11779
- retryable: false,
11780
- internalCause: "Unmapped error reached the top-level renderer."
11781
- },
11782
- "ATHER-CTX-001": {
11783
- code: "ATHER-CTX-001",
11784
- category: "CTX",
11785
- message: "Conversation context could not be compacted and was force-sent.",
11786
- hint: "Run /compact, undo recent large output, or start a new session with /new.",
11787
- severity: "warn",
11788
- retryable: false,
11789
- internalCause: "All compaction fallbacks exhausted; request sent without further reduction."
11790
- }
11791
- };
11792
- ATHER_ERROR_CODES = Object.keys(ATHER_ERRORS);
11793
- AtherCodedError = class AtherCodedError extends Error {
11794
- code;
11795
- params;
11796
- rawCause;
11797
- retry;
11798
- constructor(code, options = {}) {
11799
- super(atherMessage(code, options.params ?? {}));
11800
- this.name = "AtherCodedError";
11801
- this.code = code;
11802
- this.params = options.params ?? {};
11803
- this.retry = options.retry;
11804
- this.rawCause = options.cause === undefined ? undefined : options.cause instanceof Error ? options.cause.message : String(options.cause);
11805
- }
11806
- };
11807
- });
11808
-
11809
11517
  // src/integrations/modelMapping.ts
11810
11518
  function isRecord5(value) {
11811
11519
  return typeof value === "object" && value !== null;
@@ -11830,13 +11538,23 @@ function isFreeModel(id, raw) {
11830
11538
  }
11831
11539
 
11832
11540
  // src/integrations/gateways/free-gateway.ts
11833
- function getFreeGatewayBaseUrl() {
11834
- if (!RAW_GATEWAY_URL) {
11835
- throw new AtherCodedError("ATHER-PROV-001", {
11836
- cause: GATEWAY_URL_MISSING_INTERNAL_CAUSE
11837
- });
11541
+ function resolveFreeGatewayBaseUrl(raw) {
11542
+ if (!raw)
11543
+ return ATHER_FREE_PROXY_URL;
11544
+ const trimmed = raw.replace(/\/+$/, "");
11545
+ if (trimmed.includes("/api/proxy"))
11546
+ return trimmed;
11547
+ return new URL(trimmed).origin + "/api/gateway";
11548
+ }
11549
+ function isFreeProxyBaseUrl(baseUrl) {
11550
+ try {
11551
+ return new URL(baseUrl).origin === new URL(ATHER_FREE_PROXY_URL).origin && new URL(baseUrl).pathname.startsWith("/api/proxy");
11552
+ } catch {
11553
+ return false;
11838
11554
  }
11839
- return new URL(RAW_GATEWAY_URL).origin + "/api/gateway";
11555
+ }
11556
+ function getFreeGatewayBaseUrl() {
11557
+ return resolveFreeGatewayBaseUrl(process.env.ATHER_FREE_PROXY_URL ?? RAW_GATEWAY_URL);
11840
11558
  }
11841
11559
  function mapFreeGatewayModel(raw) {
11842
11560
  if (!isRecord5(raw)) {
@@ -11861,12 +11579,11 @@ function mapFreeGatewayModel(raw) {
11861
11579
  ...free ? { notes: "Free" } : {}
11862
11580
  };
11863
11581
  }
11864
- var RAW_GATEWAY_URL, GATEWAY_URL_MISSING_INTERNAL_CAUSE = "ATHER_FREE_GATEWAY_URL is not set. Set it to the Ather Free endpoint URL before using Ather Free.", GATEWAY_API_KEY_ENV_VAR = "ATHER_FREE_GATEWAY_API_KEY", FREE_GATEWAY_BASE_URL, GATEWAY_HOSTNAME, UNCONFIGURED_GATEWAY_BASE_URL = "https://ather-free.invalid/api/gateway", free_gateway_default;
11582
+ var RAW_GATEWAY_URL, ATHER_FREE_PROXY_URL = "https://ather-code-auth.vercel.app/api/proxy", GATEWAY_API_KEY_ENV_VAR = "ATHER_FREE_GATEWAY_API_KEY", FREE_GATEWAY_BASE_URL, GATEWAY_HOSTNAME, UNCONFIGURED_GATEWAY_BASE_URL = "https://ather-free.invalid/api/gateway", free_gateway_default;
11865
11583
  var init_free_gateway = __esm(() => {
11866
- init_registry();
11867
11584
  RAW_GATEWAY_URL = process.env.ATHER_FREE_GATEWAY_URL;
11868
- FREE_GATEWAY_BASE_URL = RAW_GATEWAY_URL ? new URL(RAW_GATEWAY_URL).origin + "/api/gateway" : undefined;
11869
- GATEWAY_HOSTNAME = RAW_GATEWAY_URL ? new URL(RAW_GATEWAY_URL).hostname : undefined;
11585
+ FREE_GATEWAY_BASE_URL = resolveFreeGatewayBaseUrl(process.env.ATHER_FREE_PROXY_URL ?? RAW_GATEWAY_URL);
11586
+ GATEWAY_HOSTNAME = new URL(FREE_GATEWAY_BASE_URL).hostname;
11870
11587
  free_gateway_default = defineGateway({
11871
11588
  id: "free-gateway",
11872
11589
  label: "Ather Free",
@@ -30896,10 +30613,10 @@ var init_oauth = __esm(() => {
30896
30613
  CONSOLE_AUTHORIZE_URL: "https://platform.claude.com/oauth/authorize",
30897
30614
  ATHER_CODE_AI_AUTHORIZE_URL: "https://ather-code.com/cai/oauth/authorize",
30898
30615
  CLAUDE_AI_ORIGIN: "https://claude.ai",
30899
- TOKEN_URL: "https://platform.ather-code.com/v1/oauth/token",
30616
+ TOKEN_URL: "https://ather-code.com/v1/oauth/token",
30900
30617
  API_KEY_URL: "about:blank",
30901
30618
  ROLES_URL: "about:blank",
30902
- CONSOLE_SUCCESS_URL: "https://platform.ather-code.com/buy_credits?returnUrl=/oauth/code/success%3Fapp%3Dather-code-code",
30619
+ CONSOLE_SUCCESS_URL: "https://ather-code.com/buy_credits?returnUrl=/oauth/code/success%3Fapp%3Dather-code-code",
30903
30620
  ATHER_CODEAI_SUCCESS_URL: "https://platform.claude.com/oauth/code/success?app=claude-code",
30904
30621
  MANUAL_REDIRECT_URL: "https://platform.claude.com/oauth/code/callback",
30905
30622
  CLIENT_ID: "9d1c250a-e61b-44d9-88ed-5944d1962f5e",
@@ -31863,6 +31580,307 @@ var init_codexCredentials = __esm(() => {
31863
31580
  init_codexOAuthShared();
31864
31581
  });
31865
31582
 
31583
+ // src/errors/registry.ts
31584
+ function interpolate(template, params = {}) {
31585
+ return template.replace(/<([a-zA-Z][a-zA-Z0-9_]*)>/g, (match, key) => {
31586
+ const value = params[key];
31587
+ return value === undefined ? match : String(value);
31588
+ });
31589
+ }
31590
+ function atherMessage(code, params = {}) {
31591
+ return interpolate(ATHER_ERRORS[code].message, params);
31592
+ }
31593
+ var ATHER_ERRORS, ATHER_ERROR_CODES, AtherCodedError;
31594
+ var init_registry = __esm(() => {
31595
+ ATHER_ERRORS = {
31596
+ "ATHER-MODEL-001": {
31597
+ code: "ATHER-MODEL-001",
31598
+ category: "MODEL",
31599
+ message: "Model unavailable: <model>",
31600
+ hint: "Run /models to pick another, or /models refresh.",
31601
+ severity: "error",
31602
+ retryable: false,
31603
+ internalCause: "The provider returned model_not_found for the requested model."
31604
+ },
31605
+ "ATHER-MODEL-002": {
31606
+ code: "ATHER-MODEL-002",
31607
+ category: "MODEL",
31608
+ message: "Model returned an empty response.",
31609
+ hint: "Try again once, or switch models with /models.",
31610
+ severity: "error",
31611
+ retryable: true,
31612
+ internalCause: "The provider returned a completion with no content blocks."
31613
+ },
31614
+ "ATHER-MODEL-003": {
31615
+ code: "ATHER-MODEL-003",
31616
+ category: "MODEL",
31617
+ message: "Model does not support the requested feature.",
31618
+ hint: "Pick a model that supports it via /models.",
31619
+ severity: "error",
31620
+ retryable: false,
31621
+ internalCause: "The provider rejected the request as unsupported for this model."
31622
+ },
31623
+ "ATHER-AUTH-001": {
31624
+ code: "ATHER-AUTH-001",
31625
+ category: "AUTH",
31626
+ message: "Not signed in.",
31627
+ hint: "Run /link to sign in.",
31628
+ severity: "error",
31629
+ retryable: false,
31630
+ internalCause: "No valid stored session when one was required."
31631
+ },
31632
+ "ATHER-AUTH-002": {
31633
+ code: "ATHER-AUTH-002",
31634
+ category: "AUTH",
31635
+ message: "Session expired.",
31636
+ hint: "Run /link again.",
31637
+ severity: "warn",
31638
+ retryable: false,
31639
+ internalCause: "Stored session exp is in the past, within the skew guard."
31640
+ },
31641
+ "ATHER-AUTH-003": {
31642
+ code: "ATHER-AUTH-003",
31643
+ category: "AUTH",
31644
+ message: "Session file was corrupt and has been reset.",
31645
+ hint: "Run /link again.",
31646
+ severity: "warn",
31647
+ retryable: false,
31648
+ internalCause: "Session JSON failed to parse or failed the shape contract."
31649
+ },
31650
+ "ATHER-AUTH-004": {
31651
+ code: "ATHER-AUTH-004",
31652
+ category: "AUTH",
31653
+ message: "Sign-in timed out.",
31654
+ hint: "Run /link again.",
31655
+ severity: "warn",
31656
+ retryable: false,
31657
+ internalCause: "Device flow poll hit the TTL without an authorized decision."
31658
+ },
31659
+ "ATHER-AUTH-005": {
31660
+ code: "ATHER-AUTH-005",
31661
+ category: "AUTH",
31662
+ message: "Sign-in was denied.",
31663
+ hint: "Run /link again if this was not you.",
31664
+ severity: "warn",
31665
+ retryable: false,
31666
+ internalCause: "Authorization endpoint returned access_denied."
31667
+ },
31668
+ "ATHER-AUTH-006": {
31669
+ code: "ATHER-AUTH-006",
31670
+ category: "AUTH",
31671
+ message: "Cannot reach the sign-in server.",
31672
+ hint: "Check your connection and try again.",
31673
+ severity: "error",
31674
+ retryable: true,
31675
+ internalCause: "Network failure contacting the auth origin."
31676
+ },
31677
+ "ATHER-AUTH-007": {
31678
+ code: "ATHER-AUTH-007",
31679
+ category: "AUTH",
31680
+ message: "Sign-in server rejected the request.",
31681
+ hint: "Try again later.",
31682
+ severity: "error",
31683
+ retryable: true,
31684
+ internalCause: "Auth origin returned a 5xx or an unexpected error shape."
31685
+ },
31686
+ "ATHER-AUTH-008": {
31687
+ code: "ATHER-AUTH-008",
31688
+ category: "AUTH",
31689
+ message: "Ather Free daily quota exceeded.",
31690
+ hint: "Try again tomorrow, or switch to your own provider key.",
31691
+ severity: "error",
31692
+ retryable: false,
31693
+ internalCause: "The server-side proxy rejected the request for quota."
31694
+ },
31695
+ "ATHER-RATE-001": {
31696
+ code: "ATHER-RATE-001",
31697
+ category: "RATE",
31698
+ message: "Provider busy. Try again in a moment, or /model to switch.",
31699
+ hint: "Nothing was changed on your account.",
31700
+ severity: "error",
31701
+ retryable: false,
31702
+ internalCause: "The provider refused the request and the silent retry budget was exhausted."
31703
+ },
31704
+ "ATHER-RATE-002": {
31705
+ code: "ATHER-RATE-002",
31706
+ category: "RATE",
31707
+ message: "Local model is busy; the request will continue automatically.",
31708
+ hint: "Waiting for the local model to free up.",
31709
+ severity: "info",
31710
+ retryable: true,
31711
+ internalCause: "Local request budget exhausted; attempt deferred."
31712
+ },
31713
+ "ATHER-RATE-003": {
31714
+ code: "ATHER-RATE-003",
31715
+ category: "RATE",
31716
+ message: "Credits exhausted for the current UTC day.",
31717
+ hint: "Credits reset at UTC midnight, or switch to a BYOK provider.",
31718
+ severity: "error",
31719
+ retryable: false,
31720
+ internalCause: "Local credit estimate for the UTC day reached zero."
31721
+ },
31722
+ "ATHER-NET-001": {
31723
+ code: "ATHER-NET-001",
31724
+ category: "NET",
31725
+ message: "Request timed out after <n>s.",
31726
+ hint: "Try again, or check your connection.",
31727
+ severity: "error",
31728
+ retryable: true,
31729
+ internalCause: "The request exceeded its timeout budget."
31730
+ },
31731
+ "ATHER-NET-002": {
31732
+ code: "ATHER-NET-002",
31733
+ category: "NET",
31734
+ message: "Network unreachable.",
31735
+ hint: "Check your connection and try again.",
31736
+ severity: "error",
31737
+ retryable: true,
31738
+ internalCause: "Transport reported the host could not be reached."
31739
+ },
31740
+ "ATHER-NET-003": {
31741
+ code: "ATHER-NET-003",
31742
+ category: "NET",
31743
+ message: "Stream stalled and was aborted.",
31744
+ hint: "Try again.",
31745
+ severity: "error",
31746
+ retryable: true,
31747
+ internalCause: "No stream progress within the stall window."
31748
+ },
31749
+ "ATHER-PROV-001": {
31750
+ code: "ATHER-PROV-001",
31751
+ category: "PROV",
31752
+ message: "Gateway URL not configured.",
31753
+ hint: "Set ATHER_FREE_GATEWAY_URL in your environment.",
31754
+ severity: "error",
31755
+ retryable: false,
31756
+ internalCause: "ATHER_FREE_GATEWAY_URL was unset at the point of use."
31757
+ },
31758
+ "ATHER-PROV-002": {
31759
+ code: "ATHER-PROV-002",
31760
+ category: "PROV",
31761
+ message: "Auth URL not configured.",
31762
+ hint: "Set ATHER_FREE_AUTH_URL in your environment.",
31763
+ severity: "error",
31764
+ retryable: false,
31765
+ internalCause: "ATHER_FREE_AUTH_URL was unset at the point of use."
31766
+ },
31767
+ "ATHER-PROV-003": {
31768
+ code: "ATHER-PROV-003",
31769
+ category: "PROV",
31770
+ message: "Provider credentials missing or invalid.",
31771
+ hint: "Check the provider settings, or run /link for Ather Free.",
31772
+ severity: "error",
31773
+ retryable: false,
31774
+ internalCause: "Credential pool had no usable lease for the route."
31775
+ },
31776
+ "ATHER-CFG-001": {
31777
+ code: "ATHER-CFG-001",
31778
+ category: "CFG",
31779
+ message: "Config file unreadable or corrupt.",
31780
+ hint: "Delete the file in ~/.ather-code and restart.",
31781
+ severity: "error",
31782
+ retryable: false,
31783
+ internalCause: "Local config JSON failed to parse."
31784
+ },
31785
+ "ATHER-CFG-002": {
31786
+ code: "ATHER-CFG-002",
31787
+ category: "CFG",
31788
+ message: "Cannot write to ~/.ather-code.",
31789
+ hint: "Check folder permissions.",
31790
+ severity: "error",
31791
+ retryable: false,
31792
+ internalCause: "Write into the config home failed."
31793
+ },
31794
+ "ATHER-TOOL-001": {
31795
+ code: "ATHER-TOOL-001",
31796
+ category: "TOOL",
31797
+ message: "Tool <name> failed: <reason>",
31798
+ hint: "Check the tool inputs and try again.",
31799
+ severity: "error",
31800
+ retryable: false,
31801
+ internalCause: "Tool execution threw a non-abort error."
31802
+ },
31803
+ "ATHER-TOOL-002": {
31804
+ code: "ATHER-TOOL-002",
31805
+ category: "TOOL",
31806
+ message: "Tool <name> exceeded the time limit.",
31807
+ hint: "Try again, or narrow what the tool has to do.",
31808
+ severity: "error",
31809
+ retryable: true,
31810
+ internalCause: "Tool exceeded its wall-clock budget and was aborted."
31811
+ },
31812
+ "ATHER-TOOL-003": {
31813
+ code: "ATHER-TOOL-003",
31814
+ category: "TOOL",
31815
+ message: "Tool <name> is disabled for this session after repeated failures.",
31816
+ hint: "Restart the session to re-enable it.",
31817
+ severity: "warn",
31818
+ retryable: false,
31819
+ internalCause: "Failure counter for this tool hit the disable threshold."
31820
+ },
31821
+ "ATHER-AGENT-001": {
31822
+ code: "ATHER-AGENT-001",
31823
+ category: "AGENT",
31824
+ message: "Reached maximum turns (<turns>).",
31825
+ hint: "Send a new message to continue, or raise AGENT_MAX_TURNS.",
31826
+ severity: "warn",
31827
+ retryable: false,
31828
+ internalCause: "The per-prompt turn budget was exhausted."
31829
+ },
31830
+ "ATHER-AUTHZ-001": {
31831
+ code: "ATHER-AUTHZ-001",
31832
+ category: "AUTHZ",
31833
+ message: "Permission denied for this action.",
31834
+ hint: "Grant the permission, or choose another action.",
31835
+ severity: "error",
31836
+ retryable: false,
31837
+ internalCause: "Permission layer rejected the requested action."
31838
+ },
31839
+ "ATHER-AUTHZ-002": {
31840
+ code: "ATHER-AUTHZ-002",
31841
+ category: "AUTHZ",
31842
+ message: "Action requires confirmation.",
31843
+ hint: "Approve or deny.",
31844
+ severity: "info",
31845
+ retryable: false,
31846
+ internalCause: "Action is gated behind an interactive confirmation."
31847
+ },
31848
+ "ATHER-INT-001": {
31849
+ code: "ATHER-INT-001",
31850
+ category: "INT",
31851
+ message: "Internal error.",
31852
+ hint: "Report at github.com/bguser30-maker/ather-code.",
31853
+ severity: "error",
31854
+ retryable: false,
31855
+ internalCause: "Unmapped error reached the top-level renderer."
31856
+ },
31857
+ "ATHER-CTX-001": {
31858
+ code: "ATHER-CTX-001",
31859
+ category: "CTX",
31860
+ message: "Conversation context could not be compacted and was force-sent.",
31861
+ hint: "Run /compact, undo recent large output, or start a new session with /new.",
31862
+ severity: "warn",
31863
+ retryable: false,
31864
+ internalCause: "All compaction fallbacks exhausted; request sent without further reduction."
31865
+ }
31866
+ };
31867
+ ATHER_ERROR_CODES = Object.keys(ATHER_ERRORS);
31868
+ AtherCodedError = class AtherCodedError extends Error {
31869
+ code;
31870
+ params;
31871
+ rawCause;
31872
+ retry;
31873
+ constructor(code, options = {}) {
31874
+ super(atherMessage(code, options.params ?? {}));
31875
+ this.name = "AtherCodedError";
31876
+ this.code = code;
31877
+ this.params = options.params ?? {};
31878
+ this.retry = options.retry;
31879
+ this.rawCause = options.cause === undefined ? undefined : options.cause instanceof Error ? options.cause.message : String(options.cause);
31880
+ }
31881
+ };
31882
+ });
31883
+
31866
31884
  // node_modules/chalk/source/vendor/ansi-styles/index.js
31867
31885
  function assembleStyles() {
31868
31886
  const codes = new Map;
@@ -32369,6 +32387,10 @@ ${hintLine}`;
32369
32387
  ${hintLine}
32370
32388
  ${causeLine}`;
32371
32389
  }
32390
+ function emitAtherError(code, params = {}, options = {}) {
32391
+ console.error(renderAtherError(code, params, options));
32392
+ return code;
32393
+ }
32372
32394
  function redactSecrets(input) {
32373
32395
  return input.replace(/\bBearer\s+[A-Za-z0-9._~+/-]+=*/gi, "Bearer <redacted>").replace(/\beyJ[A-Za-z0-9._-]{8,}/g, "<redacted-jwt>").replace(/\b([A-Za-z0-9_]*(?:SECRET|TOKEN|PASSWORD|API_?KEY)[A-Za-z0-9_]*)\s*=\s*[^\s,;]+/gi, "$1=<redacted>");
32374
32396
  }
@@ -32444,6 +32466,73 @@ import {
32444
32466
  function getSessionFilePath(configDir) {
32445
32467
  return join7(configDir ?? getAtherCodeConfigHomeDir(), SESSION_FILE_NAME);
32446
32468
  }
32469
+ function decodeJwtPayload2(token) {
32470
+ try {
32471
+ const parts = token.split(".");
32472
+ if (parts.length !== 3)
32473
+ return null;
32474
+ const payload = JSON.parse(Buffer.from(parts[1], "base64").toString("utf8"));
32475
+ if (typeof payload !== "object" || payload === null)
32476
+ return null;
32477
+ return payload;
32478
+ } catch {
32479
+ return null;
32480
+ }
32481
+ }
32482
+ function isJwtExpired(token) {
32483
+ const payload = decodeJwtPayload2(token);
32484
+ if (!payload)
32485
+ return true;
32486
+ const exp = payload.exp;
32487
+ if (typeof exp !== "number")
32488
+ return true;
32489
+ const nowSeconds = Math.floor(Date.now() / 1000);
32490
+ return nowSeconds >= exp + JWT_CLOCK_SKEW_SECONDS;
32491
+ }
32492
+ function getAtherFreeAuth() {
32493
+ const filePath = getSessionFilePath();
32494
+ if (!existsSync2(filePath)) {
32495
+ return null;
32496
+ }
32497
+ let state;
32498
+ try {
32499
+ const raw = readFileSync5(filePath, "utf8");
32500
+ const parsed = JSON.parse(raw);
32501
+ if (typeof parsed?.token !== "string" || !parsed.token) {
32502
+ throw new Error("missing token");
32503
+ }
32504
+ if (typeof parsed.expiresAt !== "string" || !parsed.expiresAt) {
32505
+ throw new Error("missing expiresAt");
32506
+ }
32507
+ if (typeof parsed.provider !== "string" || typeof parsed.githubLogin !== "string" || typeof parsed.userId !== "string" || typeof parsed.authUrl !== "string") {
32508
+ throw new Error("missing required fields");
32509
+ }
32510
+ state = parsed;
32511
+ } catch {
32512
+ try {
32513
+ rmSync2(filePath, { force: true });
32514
+ } catch {}
32515
+ emitAtherError("ATHER-AUTH-003");
32516
+ return null;
32517
+ }
32518
+ const expiresAtMs = new Date(state.expiresAt).getTime();
32519
+ if (Number.isNaN(expiresAtMs)) {
32520
+ try {
32521
+ rmSync2(filePath, { force: true });
32522
+ } catch {}
32523
+ emitAtherError("ATHER-AUTH-003");
32524
+ return null;
32525
+ }
32526
+ if (expiresAtMs - Date.now() < JWT_CLOCK_SKEW_SECONDS * 1000) {
32527
+ emitAtherError("ATHER-AUTH-002");
32528
+ return null;
32529
+ }
32530
+ if (isJwtExpired(state.token)) {
32531
+ emitAtherError("ATHER-AUTH-002");
32532
+ return null;
32533
+ }
32534
+ return state;
32535
+ }
32447
32536
  function clearAtherFreeAuth() {
32448
32537
  const filePath = getSessionFilePath();
32449
32538
  try {
@@ -32451,7 +32540,7 @@ function clearAtherFreeAuth() {
32451
32540
  logForDebugging(`Cleared Ather Free session at ${filePath}`);
32452
32541
  } catch {}
32453
32542
  }
32454
- var SESSION_FILE_NAME = "session.json", AtherFreeAuthError, AtherFreeRateLimitError;
32543
+ var SESSION_FILE_NAME = "session.json", AtherFreeAuthError, AtherFreeRateLimitError, JWT_CLOCK_SKEW_SECONDS = 60;
32455
32544
  var init_atherCodeClient = __esm(() => {
32456
32545
  init_envUtils();
32457
32546
  init_debug();
@@ -50896,7 +50985,7 @@ function requireTrustedXaiOAuthEndpoint(endpoint, label) {
50896
50985
  }
50897
50986
  return endpoint;
50898
50987
  }
50899
- function decodeJwtPayload2(token) {
50988
+ function decodeJwtPayload3(token) {
50900
50989
  if (!token)
50901
50990
  return;
50902
50991
  const parts = token.split(".");
@@ -50913,7 +51002,7 @@ function decodeJwtPayload2(token) {
50913
51002
  }
50914
51003
  }
50915
51004
  function deriveExpiresMsFromJwt(token) {
50916
- const payload = decodeJwtPayload2(token);
51005
+ const payload = decodeJwtPayload3(token);
50917
51006
  if (!payload)
50918
51007
  return;
50919
51008
  const exp = payload.exp;
@@ -71313,7 +71402,7 @@ function getAttributionHeader(fingerprint, policy) {
71313
71402
  if (!policy.generate) {
71314
71403
  return "";
71315
71404
  }
71316
- const version2 = `${"0.34.6"}.${fingerprint}`;
71405
+ const version2 = `${"0.34.7"}.${fingerprint}`;
71317
71406
  const entrypoint = process.env.ATHER_CODE_ENTRYPOINT ?? "unknown";
71318
71407
  const cch = "";
71319
71408
  const workload = getWorkload();
@@ -104330,7 +104419,7 @@ var init_metadata = __esm(() => {
104330
104419
  COMPOUND_OPERATOR_REGEX = /\s*(?:&&|\|\||[;|])\s*/;
104331
104420
  WHITESPACE_REGEX = /\s+/;
104332
104421
  getVersionBase = memoize_default(() => {
104333
- const match = "0.34.6".match(/^\d+\.\d+\.\d+(?:-[a-z]+)?/);
104422
+ const match = "0.34.7".match(/^\d+\.\d+\.\d+(?:-[a-z]+)?/);
104334
104423
  return match ? match[0] : undefined;
104335
104424
  });
104336
104425
  buildEnvContext = memoize_default(async () => {
@@ -104370,9 +104459,9 @@ var init_metadata = __esm(() => {
104370
104459
  isGithubAction: isEnvTruthy(process.env.GITHUB_ACTIONS),
104371
104460
  isAtherCodeAction: isEnvTruthy(process.env.ATHER_CODE_ACTION),
104372
104461
  isAtherCodeAiAuth: isAtherSubscriber(),
104373
- version: "0.34.6",
104462
+ version: "0.34.7",
104374
104463
  versionBase: getVersionBase(),
104375
- buildTime: "2026-10-20T15:21:52.038Z",
104464
+ buildTime: "2026-10-20T18:00:47.716Z",
104376
104465
  deploymentEnvironment: env3.detectDeploymentEnvironment(),
104377
104466
  ...isEnvTruthy(process.env.GITHUB_ACTIONS) && {
104378
104467
  githubEventName: process.env.GITHUB_EVENT_NAME,
@@ -112587,7 +112676,7 @@ var init_effort = __esm(() => {
112587
112676
  // src/utils/userAgent.ts
112588
112677
  function getAtherCodeUserAgent() {
112589
112678
  try {
112590
- return `ather-code/${"0.34.6"}`;
112679
+ return `ather-code/${"0.34.7"}`;
112591
112680
  } catch {
112592
112681
  return "ather-code/0.0.0";
112593
112682
  }
@@ -112599,7 +112688,7 @@ function getUserAgent() {
112599
112688
  const clientApp = process.env.ATHER_CODE_AGENT_SDK_CLIENT_APP ? `, client-app/${process.env.ATHER_CODE_AGENT_SDK_CLIENT_APP}` : "";
112600
112689
  const workload = getWorkload();
112601
112690
  const workloadSuffix = workload ? `, workload/${workload}` : "";
112602
- return `ather-code/${"0.34.6"} (${"external"}, ${process.env.ATHER_CODE_ENTRYPOINT ?? "cli"}${agentSdkVersion}${clientApp}${workloadSuffix})`;
112691
+ return `ather-code/${"0.34.7"} (${"external"}, ${process.env.ATHER_CODE_ENTRYPOINT ?? "cli"}${agentSdkVersion}${clientApp}${workloadSuffix})`;
112603
112692
  }
112604
112693
  function getMCPUserAgent() {
112605
112694
  const parts = [];
@@ -112613,7 +112702,7 @@ function getMCPUserAgent() {
112613
112702
  parts.push(`client-app/${process.env.ATHER_CODE_AGENT_SDK_CLIENT_APP}`);
112614
112703
  }
112615
112704
  const suffix = parts.length > 0 ? ` (${parts.join(", ")})` : "";
112616
- return `ather-code/${"0.34.6"}${suffix}`;
112705
+ return `ather-code/${"0.34.7"}${suffix}`;
112617
112706
  }
112618
112707
  function getWebFetchUserAgent() {
112619
112708
  const supportUrl = isFirstPartyAnthropicProvider() ? "https://support.anthropic.com/" : "https://github.com/Atharva/ather-code";
@@ -138547,7 +138636,7 @@ Complete the user's request by providing accurate, documentation-based guidance.
138547
138636
  function getFeedbackGuideline() {
138548
138637
  return `- When you cannot find an answer or the feature doesn't exist, direct the user to ${"report the issue at https://github.com/Atharva/ather-code/issues"}`;
138549
138638
  }
138550
- var ATHER_CODE_DOCS_MAP_URL = "https://code.claude.com/docs/en/claude_code_docs_map.md", CDP_DOCS_MAP_URL = "https://platform.ather-code.com/llms.txt", ATHER_CODE_GUIDE_AGENT_TYPE = "ather-code-code-guide", ATHER_CODE_GUIDE_AGENT;
138639
+ var ATHER_CODE_DOCS_MAP_URL = "https://code.claude.com/docs/en/claude_code_docs_map.md", CDP_DOCS_MAP_URL = "https://ather-code.com/llms.txt", ATHER_CODE_GUIDE_AGENT_TYPE = "ather-code-code-guide", ATHER_CODE_GUIDE_AGENT;
138551
138640
  var init_atherCodeGuideAgent = __esm(() => {
138552
138641
  init_prompt4();
138553
138642
  init_prompt();
@@ -149980,7 +150069,7 @@ function computeFingerprint(messageText2, version2) {
149980
150069
  }
149981
150070
  function computeFingerprintFromMessages(messages) {
149982
150071
  const firstMessageText = extractFirstMessageText(messages);
149983
- return computeFingerprint(firstMessageText, "0.34.6");
150072
+ return computeFingerprint(firstMessageText, "0.34.7");
149984
150073
  }
149985
150074
  var FINGERPRINT_SALT = "59cf53e54c78";
149986
150075
  var init_fingerprint = () => {};
@@ -150022,7 +150111,7 @@ async function sideQuery(opts) {
150022
150111
  betas.push(STRUCTURED_OUTPUTS_BETA_HEADER);
150023
150112
  }
150024
150113
  const messageText2 = extractFirstUserMessageText(messages);
150025
- const fingerprint = computeFingerprint(messageText2, "0.34.6");
150114
+ const fingerprint = computeFingerprint(messageText2, "0.34.7");
150026
150115
  const attributionPolicy = resolveCurrentAnthropicAttributionPolicy({
150027
150116
  attributionEnabled: isAttributionHeaderEnabled()
150028
150117
  });
@@ -151319,7 +151408,7 @@ var init_client2 = __esm(() => {
151319
151408
  const client = new Client({
151320
151409
  name: "ather-code-code",
151321
151410
  title: "Ather Code",
151322
- version: "0.34.6",
151411
+ version: "0.34.7",
151323
151412
  description: "Ather Code — a terminal coding agent that works with any model provider",
151324
151413
  websiteUrl: PRODUCT_URL
151325
151414
  }, {
@@ -165480,7 +165569,7 @@ function isPreapprovedHost(hostname3, pathname) {
165480
165569
  var PREAPPROVED_HOSTS, HOSTNAME_ONLY, PATH_PREFIXES;
165481
165570
  var init_preapproved = __esm(() => {
165482
165571
  PREAPPROVED_HOSTS = new Set([
165483
- "platform.ather-code.com",
165572
+ "ather-code.com",
165484
165573
  "code.claude.com",
165485
165574
  "modelcontextprotocol.io",
165486
165575
  "github.com/anthropics",
@@ -230043,7 +230132,7 @@ function getAnthropicEnvMetadata() {
230043
230132
  function getBuildAgeMinutes() {
230044
230133
  if (false)
230045
230134
  ;
230046
- const buildTime = new Date("2026-10-20T15:21:52.038Z").getTime();
230135
+ const buildTime = new Date("2026-10-20T18:00:47.716Z").getTime();
230047
230136
  if (isNaN(buildTime))
230048
230137
  return;
230049
230138
  return Math.floor((Date.now() - buildTime) / 60000);
@@ -242374,10 +242463,12 @@ var init_creditsTracker = __esm(() => {
242374
242463
 
242375
242464
  // src/services/api/openaiShim/requestExecutor.ts
242376
242465
  function mapFreeGatewayStatusToCode(status) {
242466
+ if (status === 401)
242467
+ return "ATHER-AUTH-001";
242377
242468
  if (status === 402)
242378
242469
  return "ATHER-AUTHZ-001";
242379
242470
  if (status === 403)
242380
- return "ATHER-AUTHZ-002";
242471
+ return "ATHER-AUTH-008";
242381
242472
  if (status === 400 || status === 404 || status === 422)
242382
242473
  return "ATHER-PROV-003";
242383
242474
  if (status >= 500)
@@ -242473,11 +242564,14 @@ async function executeOpenAIRequest(context2) {
242473
242564
  ...filterUnsupportedCustomHeaders(filterAnthropicHeaders2(options2?.headers))
242474
242565
  };
242475
242566
  const isGemini = isGeminiMode();
242476
- const routeCredential = resolveRouteCredentialValue2({
242567
+ let routeCredential = resolveRouteCredentialValue2({
242477
242568
  routeId: runtimeShimContext.routeId ?? undefined,
242478
242569
  baseUrl: request.baseUrl,
242479
242570
  processEnv: requestProcessEnv
242480
242571
  });
242572
+ if (!routeCredential && runtimeShimContext.routeId === "free-gateway" && isFreeProxyBaseUrl(request.baseUrl)) {
242573
+ routeCredential = getAtherFreeAuth()?.token;
242574
+ }
242481
242575
  const isXaiRoute = runtimeShimContext.routeId === "xai" || isXaiBaseUrl2(request.baseUrl);
242482
242576
  const openCodeGoSessionId = runtimeShimContext.routeId === "opencode-go" ? getSessionId4() : null;
242483
242577
  const openAIApiKeysPoolRaw = routeAcceptsGenericOpenAICredentials && parseCredentialList2(requestProcessEnv.OPENAI_API_KEYS).length > 0 ? requestProcessEnv.OPENAI_API_KEYS : undefined;
@@ -243131,6 +243225,7 @@ var CREDENTIAL_POOL_COOLDOWN_MS = 30000;
243131
243225
  var init_requestExecutor = __esm(() => {
243132
243226
  init_commandcode();
243133
243227
  init_free_gateway();
243228
+ init_atherCodeClient();
243134
243229
  init_providerSecrets();
243135
243230
  init_providerCustomHeaders();
243136
243231
  init_registry();
@@ -259413,7 +259508,7 @@ var init_sessionStorage = __esm(() => {
259413
259508
  init_slowOperations();
259414
259509
  init_transcriptFileLock();
259415
259510
  init_uuid();
259416
- VERSION3 = typeof MACRO !== "undefined" ? "0.34.6" : "unknown";
259511
+ VERSION3 = typeof MACRO !== "undefined" ? "0.34.7" : "unknown";
259417
259512
  MAX_TOMBSTONE_REWRITE_BYTES = 50 * 1024 * 1024;
259418
259513
  TRANSCRIPT_COPY_CHUNK_BYTES = 64 * 1024;
259419
259514
  transcriptRewriteHooksForTesting = {};
@@ -260880,7 +260975,7 @@ var init_filesystem = __esm(() => {
260880
260975
  });
260881
260976
  getBundledSkillsRoot = memoize_default(function getBundledSkillsRoot2() {
260882
260977
  const nonce = randomBytes10(16).toString("hex");
260883
- return join95(getAtherCodeTempDir(), "bundled-skills", "0.34.6", nonce);
260978
+ return join95(getAtherCodeTempDir(), "bundled-skills", "0.34.7", nonce);
260884
260979
  });
260885
260980
  getResolvedWorkingDirPaths = memoize_default(getPathsForPermissionCheck);
260886
260981
  });
@@ -275387,7 +275482,7 @@ function buildSystemInitMessage(inputs) {
275387
275482
  slash_commands: inputs.commands.filter((c7) => c7.userInvocable !== false).map((c7) => c7.name),
275388
275483
  apiKeySource: getAtherApiKeyWithSource().source,
275389
275484
  betas: getSdkBetas(),
275390
- ather_code_code_version: "0.34.6",
275485
+ ather_code_code_version: "0.34.7",
275391
275486
  output_style: outputStyle,
275392
275487
  agents: inputs.agents.map((agent) => agent.agentType),
275393
275488
  skills: inputs.skills.filter((s) => s.userInvocable !== false).map((skill) => skill.name),