ather-code 0.34.5 → 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.
- package/dist/cli.mjs +139 -99
- package/dist/sdk.mjs +739 -349
- 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.
|
|
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
|
|
11834
|
-
if (!
|
|
11835
|
-
|
|
11836
|
-
|
|
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
|
-
|
|
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,
|
|
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 =
|
|
11869
|
-
GATEWAY_HOSTNAME =
|
|
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://
|
|
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://
|
|
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
|
|
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 =
|
|
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.
|
|
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.
|
|
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.
|
|
104462
|
+
version: "0.34.7",
|
|
104374
104463
|
versionBase: getVersionBase(),
|
|
104375
|
-
buildTime: "2026-10-
|
|
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.
|
|
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.
|
|
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.
|
|
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://
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
-
"
|
|
165572
|
+
"ather-code.com",
|
|
165484
165573
|
"code.claude.com",
|
|
165485
165574
|
"modelcontextprotocol.io",
|
|
165486
165575
|
"github.com/anthropics",
|
|
@@ -221251,6 +221340,282 @@ var init_postSamplingHooks = __esm(() => {
|
|
|
221251
221340
|
postSamplingHooks = [];
|
|
221252
221341
|
});
|
|
221253
221342
|
|
|
221343
|
+
// src/services/orchestrator/managerReview.ts
|
|
221344
|
+
var SKIP_DIRS;
|
|
221345
|
+
var init_managerReview = __esm(() => {
|
|
221346
|
+
init_debug();
|
|
221347
|
+
SKIP_DIRS = new Set([
|
|
221348
|
+
"node_modules",
|
|
221349
|
+
".git",
|
|
221350
|
+
"dist",
|
|
221351
|
+
"build",
|
|
221352
|
+
"out",
|
|
221353
|
+
".next",
|
|
221354
|
+
"coverage",
|
|
221355
|
+
".cache",
|
|
221356
|
+
"vendor"
|
|
221357
|
+
]);
|
|
221358
|
+
});
|
|
221359
|
+
|
|
221360
|
+
// src/services/orchestrator/state.ts
|
|
221361
|
+
function createOrchestratorState(missionTitle, tasks = []) {
|
|
221362
|
+
return {
|
|
221363
|
+
missionTitle: missionTitle.trim() || "Untitled mission",
|
|
221364
|
+
tasks,
|
|
221365
|
+
activeWorkerId: null,
|
|
221366
|
+
consecutiveFails: 0
|
|
221367
|
+
};
|
|
221368
|
+
}
|
|
221369
|
+
function resetConsecutiveFails(state2) {
|
|
221370
|
+
state2.consecutiveFails = 0;
|
|
221371
|
+
return state2;
|
|
221372
|
+
}
|
|
221373
|
+
function recordManagerFail(state2) {
|
|
221374
|
+
state2.consecutiveFails += 1;
|
|
221375
|
+
return state2.consecutiveFails;
|
|
221376
|
+
}
|
|
221377
|
+
function isHalted(state2) {
|
|
221378
|
+
return state2.consecutiveFails >= MAX_CONSECUTIVE_FAILS;
|
|
221379
|
+
}
|
|
221380
|
+
var MAX_CONSECUTIVE_FAILS = 3;
|
|
221381
|
+
|
|
221382
|
+
// src/services/orchestrator/missionStore.ts
|
|
221383
|
+
function initialState(missionTitle) {
|
|
221384
|
+
return {
|
|
221385
|
+
state: createOrchestratorState(missionTitle),
|
|
221386
|
+
workerLog: [],
|
|
221387
|
+
managerReviews: [],
|
|
221388
|
+
tokensUsed: 0,
|
|
221389
|
+
statusMessage: "Waiting for the worker…",
|
|
221390
|
+
startedAt: Date.now(),
|
|
221391
|
+
interruptedUntil: 0,
|
|
221392
|
+
active: false,
|
|
221393
|
+
completed: false,
|
|
221394
|
+
completedAt: 0,
|
|
221395
|
+
completionMessage: ""
|
|
221396
|
+
};
|
|
221397
|
+
}
|
|
221398
|
+
function publish2(next) {
|
|
221399
|
+
snapshot2 = next;
|
|
221400
|
+
for (const listener2 of listeners3) {
|
|
221401
|
+
try {
|
|
221402
|
+
listener2();
|
|
221403
|
+
} catch {}
|
|
221404
|
+
}
|
|
221405
|
+
}
|
|
221406
|
+
function markMissionComplete(message = "Orchestration Complete") {
|
|
221407
|
+
if (snapshot2.completed)
|
|
221408
|
+
return;
|
|
221409
|
+
publish2({
|
|
221410
|
+
...snapshot2,
|
|
221411
|
+
active: false,
|
|
221412
|
+
completed: true,
|
|
221413
|
+
completedAt: Date.now(),
|
|
221414
|
+
completionMessage: message,
|
|
221415
|
+
statusMessage: message
|
|
221416
|
+
});
|
|
221417
|
+
}
|
|
221418
|
+
function markMissionHalted(message) {
|
|
221419
|
+
publish2({
|
|
221420
|
+
...snapshot2,
|
|
221421
|
+
active: false,
|
|
221422
|
+
completed: true,
|
|
221423
|
+
completedAt: Date.now(),
|
|
221424
|
+
completionMessage: "Orchestration Complete",
|
|
221425
|
+
statusMessage: "Halted — human intervention required."
|
|
221426
|
+
});
|
|
221427
|
+
}
|
|
221428
|
+
function setMissionStatus(statusMessage) {
|
|
221429
|
+
publish2({ ...snapshot2, statusMessage });
|
|
221430
|
+
}
|
|
221431
|
+
function appendWorkerLog(line) {
|
|
221432
|
+
const trimmed = line.trim();
|
|
221433
|
+
if (!trimmed)
|
|
221434
|
+
return;
|
|
221435
|
+
const workerLog = [...snapshot2.workerLog, trimmed].slice(-MISSION_LOG_LIMIT);
|
|
221436
|
+
publish2({ ...snapshot2, workerLog });
|
|
221437
|
+
}
|
|
221438
|
+
function appendManagerReview(status, toolName, reason) {
|
|
221439
|
+
reviewSequence += 1;
|
|
221440
|
+
const entry = {
|
|
221441
|
+
id: reviewSequence,
|
|
221442
|
+
status,
|
|
221443
|
+
toolName,
|
|
221444
|
+
reason: reason.trim(),
|
|
221445
|
+
at: Date.now()
|
|
221446
|
+
};
|
|
221447
|
+
const managerReviews = [...snapshot2.managerReviews, entry].slice(-MISSION_REVIEW_LIMIT);
|
|
221448
|
+
publish2({
|
|
221449
|
+
...snapshot2,
|
|
221450
|
+
managerReviews,
|
|
221451
|
+
interruptedUntil: status === "FAIL" ? Date.now() + MISSION_INTERRUPT_FLASH_MS : snapshot2.interruptedUntil
|
|
221452
|
+
});
|
|
221453
|
+
}
|
|
221454
|
+
function addMissionTokens(tokens) {
|
|
221455
|
+
if (!Number.isFinite(tokens) || tokens <= 0)
|
|
221456
|
+
return;
|
|
221457
|
+
publish2({ ...snapshot2, tokensUsed: snapshot2.tokensUsed + Math.round(tokens) });
|
|
221458
|
+
}
|
|
221459
|
+
function setMissionFails(consecutiveFails) {
|
|
221460
|
+
publish2({
|
|
221461
|
+
...snapshot2,
|
|
221462
|
+
state: { ...snapshot2.state, consecutiveFails }
|
|
221463
|
+
});
|
|
221464
|
+
}
|
|
221465
|
+
function setMissionTasks(tasks) {
|
|
221466
|
+
publish2({ ...snapshot2, state: { ...snapshot2.state, tasks } });
|
|
221467
|
+
}
|
|
221468
|
+
function syncMissionTasksFromTodos(todos) {
|
|
221469
|
+
if (!Array.isArray(todos))
|
|
221470
|
+
return;
|
|
221471
|
+
const statusMap = {
|
|
221472
|
+
pending: "pending",
|
|
221473
|
+
in_progress: "running",
|
|
221474
|
+
completed: "success"
|
|
221475
|
+
};
|
|
221476
|
+
const tasks = [];
|
|
221477
|
+
todos.forEach((todo, index) => {
|
|
221478
|
+
if (!todo || typeof todo !== "object")
|
|
221479
|
+
return;
|
|
221480
|
+
const record2 = todo;
|
|
221481
|
+
const title = typeof record2.content === "string" ? record2.content : typeof record2.title === "string" ? record2.title : `Task ${index + 1}`;
|
|
221482
|
+
const rawStatus = typeof record2.status === "string" ? record2.status : "pending";
|
|
221483
|
+
tasks.push({
|
|
221484
|
+
id: String(index + 1),
|
|
221485
|
+
title,
|
|
221486
|
+
status: statusMap[rawStatus] ?? "pending"
|
|
221487
|
+
});
|
|
221488
|
+
});
|
|
221489
|
+
if (tasks.length > 0)
|
|
221490
|
+
setMissionTasks(tasks);
|
|
221491
|
+
}
|
|
221492
|
+
var MISSION_LOG_LIMIT = 50, MISSION_REVIEW_LIMIT = 20, MISSION_INTERRUPT_FLASH_MS = 1200, snapshot2, reviewSequence = 0, listeners3;
|
|
221493
|
+
var init_missionStore = __esm(() => {
|
|
221494
|
+
snapshot2 = initialState("Untitled mission");
|
|
221495
|
+
listeners3 = new Set;
|
|
221496
|
+
});
|
|
221497
|
+
|
|
221498
|
+
// src/services/orchestrator/supervision.ts
|
|
221499
|
+
function buildHaltInjection(reason) {
|
|
221500
|
+
const sentence = reason.trim().replace(/[.!?]+$/, "");
|
|
221501
|
+
return `${INTERRUPT_PREFIX}: The Manager aborted your action. Reason: ${sentence}. Re-evaluate immediately.`;
|
|
221502
|
+
}
|
|
221503
|
+
function buildSupervisorHaltMessage() {
|
|
221504
|
+
return `\uD83D\uDED1 SUPERVISOR HALT: Worker failed ${MAX_CONSECUTIVE_FAILS} times. Human intervention required.`;
|
|
221505
|
+
}
|
|
221506
|
+
function stopSupervision() {
|
|
221507
|
+
if (!active)
|
|
221508
|
+
return;
|
|
221509
|
+
active = null;
|
|
221510
|
+
activeReviewer = null;
|
|
221511
|
+
const logger = activeLogger;
|
|
221512
|
+
activeLogger = null;
|
|
221513
|
+
logger?.({ type: "stopped" });
|
|
221514
|
+
markMissionComplete();
|
|
221515
|
+
}
|
|
221516
|
+
function emit2(event) {
|
|
221517
|
+
try {
|
|
221518
|
+
activeLogger?.(event);
|
|
221519
|
+
} catch (error40) {
|
|
221520
|
+
logForDebugging(`[orchestrator] supervision logger failed: ${String(error40)}`);
|
|
221521
|
+
}
|
|
221522
|
+
}
|
|
221523
|
+
function buildTaskContext(state2) {
|
|
221524
|
+
const tasks = state2.tasks.length ? state2.tasks.map((task) => `- [${task.status}] ${task.title}${task.detail ? ` — ${task.detail}` : ""}`).join(`
|
|
221525
|
+
`) : "(no task list — single-action review)";
|
|
221526
|
+
return [
|
|
221527
|
+
`MISSION: ${state2.missionTitle}`,
|
|
221528
|
+
`WORKER: ${state2.activeWorkerId ?? "main"}`,
|
|
221529
|
+
`STRIKES: ${state2.consecutiveFails}/${MAX_CONSECUTIVE_FAILS}`,
|
|
221530
|
+
`TASKS:
|
|
221531
|
+
${tasks}`
|
|
221532
|
+
].join(`
|
|
221533
|
+
`);
|
|
221534
|
+
}
|
|
221535
|
+
function describeToolCall(toolInput) {
|
|
221536
|
+
if (!toolInput || typeof toolInput !== "object")
|
|
221537
|
+
return "";
|
|
221538
|
+
const input = toolInput;
|
|
221539
|
+
if (typeof input.command === "string")
|
|
221540
|
+
return `$ ${input.command}`;
|
|
221541
|
+
if (typeof input.file_path === "string")
|
|
221542
|
+
return input.file_path;
|
|
221543
|
+
if (typeof input.pattern === "string")
|
|
221544
|
+
return `/${input.pattern}/`;
|
|
221545
|
+
try {
|
|
221546
|
+
return JSON.stringify(toolInput).slice(0, 80);
|
|
221547
|
+
} catch {
|
|
221548
|
+
return "";
|
|
221549
|
+
}
|
|
221550
|
+
}
|
|
221551
|
+
async function reviewProposedToolCall(toolName, toolInput, options2 = {}) {
|
|
221552
|
+
const supervision = active;
|
|
221553
|
+
const reviewer = activeReviewer;
|
|
221554
|
+
if (!supervision || !reviewer || supervision.halted)
|
|
221555
|
+
return null;
|
|
221556
|
+
const recentToolCalls = [...supervision.toolWindow];
|
|
221557
|
+
try {
|
|
221558
|
+
appendWorkerLog(`${toolName} ${describeToolCall(toolInput)}`);
|
|
221559
|
+
setMissionStatus(`Manager reviewing ${toolName}…`);
|
|
221560
|
+
const verdict = await reviewer({
|
|
221561
|
+
taskContext: buildTaskContext(supervision.state),
|
|
221562
|
+
toolName,
|
|
221563
|
+
toolInput,
|
|
221564
|
+
recentToolCalls,
|
|
221565
|
+
signal: options2.signal,
|
|
221566
|
+
onUsage: addMissionTokens
|
|
221567
|
+
});
|
|
221568
|
+
supervision.toolWindow.push({ toolName, toolInput });
|
|
221569
|
+
if (supervision.toolWindow.length > 3) {
|
|
221570
|
+
supervision.toolWindow.splice(0, supervision.toolWindow.length - 3);
|
|
221571
|
+
}
|
|
221572
|
+
if (verdict.status === "PASS") {
|
|
221573
|
+
resetConsecutiveFails(supervision.state);
|
|
221574
|
+
setMissionFails(0);
|
|
221575
|
+
appendManagerReview("PASS", toolName, "");
|
|
221576
|
+
setMissionStatus("Worker executing…");
|
|
221577
|
+
if (toolName === "TodoWrite" && toolInput && typeof toolInput === "object") {
|
|
221578
|
+
syncMissionTasksFromTodos(toolInput.todos);
|
|
221579
|
+
}
|
|
221580
|
+
emit2({ type: "review-pass", toolName });
|
|
221581
|
+
return null;
|
|
221582
|
+
}
|
|
221583
|
+
const reason = verdict.reason || "action rejected by the Manager";
|
|
221584
|
+
const fails = recordManagerFail(supervision.state);
|
|
221585
|
+
setMissionFails(fails);
|
|
221586
|
+
appendManagerReview("FAIL", toolName, reason);
|
|
221587
|
+
appendWorkerLog("\uD83D\uDED1 Manager aborted the action");
|
|
221588
|
+
setMissionStatus("Interrupted — re-evaluating…");
|
|
221589
|
+
emit2({ type: "review-fail", toolName, reason, fails });
|
|
221590
|
+
if (supervision.abortController.signal.aborted) {
|
|
221591
|
+
supervision.abortController = new AbortController;
|
|
221592
|
+
}
|
|
221593
|
+
supervision.abortController.abort(reason);
|
|
221594
|
+
const injected = buildHaltInjection(reason);
|
|
221595
|
+
emit2({ type: "interrupt", toolName, reason, injected });
|
|
221596
|
+
if (isHalted(supervision.state)) {
|
|
221597
|
+
const message = buildSupervisorHaltMessage();
|
|
221598
|
+
supervision.halted = true;
|
|
221599
|
+
lastHalt = { message, reason };
|
|
221600
|
+
markMissionHalted(message);
|
|
221601
|
+
emit2({ type: "halt", fails, message });
|
|
221602
|
+
stopSupervision();
|
|
221603
|
+
return `${injected}
|
|
221604
|
+
${message}`;
|
|
221605
|
+
}
|
|
221606
|
+
return injected;
|
|
221607
|
+
} catch (error40) {
|
|
221608
|
+
logForDebugging(`[orchestrator] supervisor review failed for ${toolName}: ${String(error40)}`);
|
|
221609
|
+
return null;
|
|
221610
|
+
}
|
|
221611
|
+
}
|
|
221612
|
+
var INTERRUPT_PREFIX = "[SYSTEM HALT]", active = null, activeReviewer = null, activeLogger = null, lastHalt = null;
|
|
221613
|
+
var init_supervision = __esm(() => {
|
|
221614
|
+
init_debug();
|
|
221615
|
+
init_managerReview();
|
|
221616
|
+
init_missionStore();
|
|
221617
|
+
});
|
|
221618
|
+
|
|
221254
221619
|
// src/utils/doomLoop.ts
|
|
221255
221620
|
var exports_doomLoop = {};
|
|
221256
221621
|
__export(exports_doomLoop, {
|
|
@@ -222857,6 +223222,24 @@ async function* runToolUse(toolUse, assistantMessage, canUseTool, toolUseContext
|
|
|
222857
223222
|
};
|
|
222858
223223
|
return;
|
|
222859
223224
|
}
|
|
223225
|
+
const supervisorHalt = await reviewProposedToolCall(toolName, toolUse.input);
|
|
223226
|
+
if (supervisorHalt) {
|
|
223227
|
+
yield {
|
|
223228
|
+
message: createUserMessage({
|
|
223229
|
+
content: [
|
|
223230
|
+
{
|
|
223231
|
+
type: "tool_result",
|
|
223232
|
+
content: `<tool_use_error>${supervisorHalt}</tool_use_error>`,
|
|
223233
|
+
is_error: true,
|
|
223234
|
+
tool_use_id: toolUse.id
|
|
223235
|
+
}
|
|
223236
|
+
],
|
|
223237
|
+
toolUseResult: supervisorHalt,
|
|
223238
|
+
sourceToolAssistantUUID: assistantMessage.uuid
|
|
223239
|
+
})
|
|
223240
|
+
};
|
|
223241
|
+
return;
|
|
223242
|
+
}
|
|
222860
223243
|
const toolInput = toolUse.input;
|
|
222861
223244
|
try {
|
|
222862
223245
|
if (toolUseContext.abortController.signal.aborted) {
|
|
@@ -223696,6 +224079,7 @@ var init_toolExecution = __esm(() => {
|
|
|
223696
224079
|
init_metadata();
|
|
223697
224080
|
init_state();
|
|
223698
224081
|
init_Tool();
|
|
224082
|
+
init_supervision();
|
|
223699
224083
|
init_bashPermissions();
|
|
223700
224084
|
init_prompt3();
|
|
223701
224085
|
init_prompt4();
|
|
@@ -229748,7 +230132,7 @@ function getAnthropicEnvMetadata() {
|
|
|
229748
230132
|
function getBuildAgeMinutes() {
|
|
229749
230133
|
if (false)
|
|
229750
230134
|
;
|
|
229751
|
-
const buildTime = new Date("2026-10-
|
|
230135
|
+
const buildTime = new Date("2026-10-20T18:00:47.716Z").getTime();
|
|
229752
230136
|
if (isNaN(buildTime))
|
|
229753
230137
|
return;
|
|
229754
230138
|
return Math.floor((Date.now() - buildTime) / 60000);
|
|
@@ -240756,10 +241140,10 @@ async function* openaiStreamToAnthropic(response, model, signal, isOllama, reque
|
|
|
240756
241140
|
xmlToolCallText = combined.slice(openIdx);
|
|
240757
241141
|
} else {
|
|
240758
241142
|
const keep = trailingXmlOpenerPrefixLen(combined, allowHy3ToolCalls);
|
|
240759
|
-
const
|
|
241143
|
+
const emit3 = keep > 0 ? combined.slice(0, combined.length - keep) : combined;
|
|
240760
241144
|
xmlHoldback = keep > 0 ? combined.slice(combined.length - keep) : "";
|
|
240761
|
-
if (
|
|
240762
|
-
yield* emitTextDelta(
|
|
241145
|
+
if (emit3)
|
|
241146
|
+
yield* emitTextDelta(emit3);
|
|
240763
241147
|
}
|
|
240764
241148
|
}
|
|
240765
241149
|
}
|
|
@@ -240848,18 +241232,18 @@ async function* openaiStreamToAnthropic(response, model, signal, isOllama, reque
|
|
|
240848
241232
|
};
|
|
240849
241233
|
}
|
|
240850
241234
|
} else if (tc.function?.arguments) {
|
|
240851
|
-
const
|
|
240852
|
-
if (
|
|
241235
|
+
const active2 = activeToolCalls.get(tc.index);
|
|
241236
|
+
if (active2) {
|
|
240853
241237
|
if (tc.function.arguments) {
|
|
240854
|
-
|
|
241238
|
+
active2.jsonBuffer += tc.function.arguments;
|
|
240855
241239
|
}
|
|
240856
|
-
if (
|
|
241240
|
+
if (active2.normalizeAtStop) {
|
|
240857
241241
|
continue;
|
|
240858
241242
|
}
|
|
240859
241243
|
throwIfStreamAborted2(signal);
|
|
240860
241244
|
yield {
|
|
240861
241245
|
type: "content_block_delta",
|
|
240862
|
-
index:
|
|
241246
|
+
index: active2.index,
|
|
240863
241247
|
delta: {
|
|
240864
241248
|
type: "input_json_delta",
|
|
240865
241249
|
partial_json: tc.function.arguments
|
|
@@ -242079,10 +242463,12 @@ var init_creditsTracker = __esm(() => {
|
|
|
242079
242463
|
|
|
242080
242464
|
// src/services/api/openaiShim/requestExecutor.ts
|
|
242081
242465
|
function mapFreeGatewayStatusToCode(status) {
|
|
242466
|
+
if (status === 401)
|
|
242467
|
+
return "ATHER-AUTH-001";
|
|
242082
242468
|
if (status === 402)
|
|
242083
242469
|
return "ATHER-AUTHZ-001";
|
|
242084
242470
|
if (status === 403)
|
|
242085
|
-
return "ATHER-
|
|
242471
|
+
return "ATHER-AUTH-008";
|
|
242086
242472
|
if (status === 400 || status === 404 || status === 422)
|
|
242087
242473
|
return "ATHER-PROV-003";
|
|
242088
242474
|
if (status >= 500)
|
|
@@ -242178,11 +242564,14 @@ async function executeOpenAIRequest(context2) {
|
|
|
242178
242564
|
...filterUnsupportedCustomHeaders(filterAnthropicHeaders2(options2?.headers))
|
|
242179
242565
|
};
|
|
242180
242566
|
const isGemini = isGeminiMode();
|
|
242181
|
-
|
|
242567
|
+
let routeCredential = resolveRouteCredentialValue2({
|
|
242182
242568
|
routeId: runtimeShimContext.routeId ?? undefined,
|
|
242183
242569
|
baseUrl: request.baseUrl,
|
|
242184
242570
|
processEnv: requestProcessEnv
|
|
242185
242571
|
});
|
|
242572
|
+
if (!routeCredential && runtimeShimContext.routeId === "free-gateway" && isFreeProxyBaseUrl(request.baseUrl)) {
|
|
242573
|
+
routeCredential = getAtherFreeAuth()?.token;
|
|
242574
|
+
}
|
|
242186
242575
|
const isXaiRoute = runtimeShimContext.routeId === "xai" || isXaiBaseUrl2(request.baseUrl);
|
|
242187
242576
|
const openCodeGoSessionId = runtimeShimContext.routeId === "opencode-go" ? getSessionId4() : null;
|
|
242188
242577
|
const openAIApiKeysPoolRaw = routeAcceptsGenericOpenAICredentials && parseCredentialList2(requestProcessEnv.OPENAI_API_KEYS).length > 0 ? requestProcessEnv.OPENAI_API_KEYS : undefined;
|
|
@@ -242836,6 +243225,7 @@ var CREDENTIAL_POOL_COOLDOWN_MS = 30000;
|
|
|
242836
243225
|
var init_requestExecutor = __esm(() => {
|
|
242837
243226
|
init_commandcode();
|
|
242838
243227
|
init_free_gateway();
|
|
243228
|
+
init_atherCodeClient();
|
|
242839
243229
|
init_providerSecrets();
|
|
242840
243230
|
init_providerCustomHeaders();
|
|
242841
243231
|
init_registry();
|
|
@@ -256505,12 +256895,12 @@ class Project {
|
|
|
256505
256895
|
}
|
|
256506
256896
|
});
|
|
256507
256897
|
}
|
|
256508
|
-
async insertFileHistorySnapshot(messageId,
|
|
256898
|
+
async insertFileHistorySnapshot(messageId, snapshot3, isSnapshotUpdate) {
|
|
256509
256899
|
return this.trackWrite(async () => {
|
|
256510
256900
|
const fileHistoryMessage = {
|
|
256511
256901
|
type: "file-history-snapshot",
|
|
256512
256902
|
messageId,
|
|
256513
|
-
snapshot:
|
|
256903
|
+
snapshot: snapshot3,
|
|
256514
256904
|
isSnapshotUpdate
|
|
256515
256905
|
};
|
|
256516
256906
|
await this.appendEntry(fileHistoryMessage);
|
|
@@ -256521,9 +256911,9 @@ class Project {
|
|
|
256521
256911
|
await this.appendEntry(queueOp);
|
|
256522
256912
|
});
|
|
256523
256913
|
}
|
|
256524
|
-
async insertAttributionSnapshot(
|
|
256914
|
+
async insertAttributionSnapshot(snapshot3) {
|
|
256525
256915
|
return this.trackWrite(async () => {
|
|
256526
|
-
await this.appendEntry(
|
|
256916
|
+
await this.appendEntry(snapshot3);
|
|
256527
256917
|
});
|
|
256528
256918
|
}
|
|
256529
256919
|
async insertContentReplacement(replacements2, agentId) {
|
|
@@ -256743,11 +257133,11 @@ async function recordQueueOperation(queueOp) {
|
|
|
256743
257133
|
async function removeTranscriptMessage(targetUuid) {
|
|
256744
257134
|
await getProject().removeMessageByUuid(targetUuid);
|
|
256745
257135
|
}
|
|
256746
|
-
async function recordFileHistorySnapshot(messageId,
|
|
256747
|
-
await getProject().insertFileHistorySnapshot(messageId,
|
|
257136
|
+
async function recordFileHistorySnapshot(messageId, snapshot3, isSnapshotUpdate) {
|
|
257137
|
+
await getProject().insertFileHistorySnapshot(messageId, snapshot3, isSnapshotUpdate);
|
|
256748
257138
|
}
|
|
256749
|
-
async function recordAttributionSnapshot(
|
|
256750
|
-
await getProject().insertAttributionSnapshot(
|
|
257139
|
+
async function recordAttributionSnapshot(snapshot3) {
|
|
257140
|
+
await getProject().insertAttributionSnapshot(snapshot3);
|
|
256751
257141
|
}
|
|
256752
257142
|
async function recordContentReplacement(replacements2, agentId) {
|
|
256753
257143
|
await getProject().insertContentReplacement(replacements2, agentId);
|
|
@@ -256776,14 +257166,14 @@ async function recordContextCollapseCommit(commit) {
|
|
|
256776
257166
|
...commit
|
|
256777
257167
|
});
|
|
256778
257168
|
}
|
|
256779
|
-
async function recordContextCollapseSnapshot(
|
|
257169
|
+
async function recordContextCollapseSnapshot(snapshot3) {
|
|
256780
257170
|
const sessionId = getSessionId();
|
|
256781
257171
|
if (!sessionId)
|
|
256782
257172
|
return;
|
|
256783
257173
|
await getProject().appendEntry({
|
|
256784
257174
|
type: "marble-origami-snapshot",
|
|
256785
257175
|
sessionId,
|
|
256786
|
-
...
|
|
257176
|
+
...snapshot3
|
|
256787
257177
|
});
|
|
256788
257178
|
}
|
|
256789
257179
|
async function flushSessionStorage() {
|
|
@@ -257431,13 +257821,13 @@ function buildFileHistorySnapshotChain(fileHistorySnapshots, conversation) {
|
|
|
257431
257821
|
if (!snapshotMessage) {
|
|
257432
257822
|
continue;
|
|
257433
257823
|
}
|
|
257434
|
-
const { snapshot:
|
|
257435
|
-
const existingIndex = isSnapshotUpdate ? indexByMessageId.get(
|
|
257824
|
+
const { snapshot: snapshot3, isSnapshotUpdate } = snapshotMessage;
|
|
257825
|
+
const existingIndex = isSnapshotUpdate ? indexByMessageId.get(snapshot3.messageId) : undefined;
|
|
257436
257826
|
if (existingIndex === undefined) {
|
|
257437
|
-
indexByMessageId.set(
|
|
257438
|
-
snapshots.push(
|
|
257827
|
+
indexByMessageId.set(snapshot3.messageId, snapshots.length);
|
|
257828
|
+
snapshots.push(snapshot3);
|
|
257439
257829
|
} else {
|
|
257440
|
-
snapshots[existingIndex] =
|
|
257830
|
+
snapshots[existingIndex] = snapshot3;
|
|
257441
257831
|
}
|
|
257442
257832
|
}
|
|
257443
257833
|
return snapshots;
|
|
@@ -259118,7 +259508,7 @@ var init_sessionStorage = __esm(() => {
|
|
|
259118
259508
|
init_slowOperations();
|
|
259119
259509
|
init_transcriptFileLock();
|
|
259120
259510
|
init_uuid();
|
|
259121
|
-
VERSION3 = typeof MACRO !== "undefined" ? "0.34.
|
|
259511
|
+
VERSION3 = typeof MACRO !== "undefined" ? "0.34.7" : "unknown";
|
|
259122
259512
|
MAX_TOMBSTONE_REWRITE_BYTES = 50 * 1024 * 1024;
|
|
259123
259513
|
TRANSCRIPT_COPY_CHUNK_BYTES = 64 * 1024;
|
|
259124
259514
|
transcriptRewriteHooksForTesting = {};
|
|
@@ -260585,7 +260975,7 @@ var init_filesystem = __esm(() => {
|
|
|
260585
260975
|
});
|
|
260586
260976
|
getBundledSkillsRoot = memoize_default(function getBundledSkillsRoot2() {
|
|
260587
260977
|
const nonce = randomBytes10(16).toString("hex");
|
|
260588
|
-
return join95(getAtherCodeTempDir(), "bundled-skills", "0.34.
|
|
260978
|
+
return join95(getAtherCodeTempDir(), "bundled-skills", "0.34.7", nonce);
|
|
260589
260979
|
});
|
|
260590
260980
|
getResolvedWorkingDirPaths = memoize_default(getPathsForPermissionCheck);
|
|
260591
260981
|
});
|
|
@@ -275092,7 +275482,7 @@ function buildSystemInitMessage(inputs) {
|
|
|
275092
275482
|
slash_commands: inputs.commands.filter((c7) => c7.userInvocable !== false).map((c7) => c7.name),
|
|
275093
275483
|
apiKeySource: getAtherApiKeyWithSource().source,
|
|
275094
275484
|
betas: getSdkBetas(),
|
|
275095
|
-
ather_code_code_version: "0.34.
|
|
275485
|
+
ather_code_code_version: "0.34.7",
|
|
275096
275486
|
output_style: outputStyle,
|
|
275097
275487
|
agents: inputs.agents.map((agent) => agent.agentType),
|
|
275098
275488
|
skills: inputs.skills.filter((s) => s.userInvocable !== false).map((skill) => skill.name),
|