claudish 13.1.0 → 13.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +834 -360
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -575,7 +575,7 @@ var init_onepassword_config = __esm(() => {
|
|
|
575
575
|
});
|
|
576
576
|
|
|
577
577
|
// src/version.ts
|
|
578
|
-
var VERSION = "13.
|
|
578
|
+
var VERSION = "13.3.0";
|
|
579
579
|
|
|
580
580
|
// src/logger.ts
|
|
581
581
|
import { appendFile, existsSync as existsSync2, mkdirSync, readdirSync, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
|
|
@@ -6484,6 +6484,12 @@ function isOptInWireId(wireId) {
|
|
|
6484
6484
|
return /-contributor(?:-free)?$/i.test(wireId.split("/").pop() ?? wireId);
|
|
6485
6485
|
}
|
|
6486
6486
|
function isOptInConnection(connection) {
|
|
6487
|
+
if ("contentUse" in connection) {
|
|
6488
|
+
if (connection.contentUse === "contributor")
|
|
6489
|
+
return true;
|
|
6490
|
+
if (connection.contentUse === "standard")
|
|
6491
|
+
return false;
|
|
6492
|
+
}
|
|
6487
6493
|
return typeof connection.externalModelId === "string" && isOptInWireId(connection.externalModelId);
|
|
6488
6494
|
}
|
|
6489
6495
|
function splitOptInConnections(entry) {
|
|
@@ -6715,6 +6721,7 @@ var init_catalog_route_bindings = __esm(() => {
|
|
|
6715
6721
|
vertex: { routeId: "vertex", routeProfileId: "google-cloud" },
|
|
6716
6722
|
deepseek: { routeId: "deepseek", routeProfileId: "direct-api" },
|
|
6717
6723
|
mistralai: { routeId: "mistralai", routeProfileId: "direct-api" },
|
|
6724
|
+
"meta-muse-code": { routeId: "meta", routeProfileId: "muse-code-subscription" },
|
|
6718
6725
|
meta: { routeId: "meta", routeProfileId: "direct-api" }
|
|
6719
6726
|
};
|
|
6720
6727
|
LOOKUP_ONLY_ROUTE_BINDINGS = {
|
|
@@ -10403,9 +10410,6 @@ function acceptsReasoningEffort(modelId) {
|
|
|
10403
10410
|
return reasoning.supported === true && reasoning.control === "effort";
|
|
10404
10411
|
return true;
|
|
10405
10412
|
}
|
|
10406
|
-
function catalogReasoningFor(modelId) {
|
|
10407
|
-
return lookupModelReasoning(norm(modelId)) ?? lookupModelReasoning(modelId);
|
|
10408
|
-
}
|
|
10409
10413
|
function rememberReasoningEffortRejected(modelId) {
|
|
10410
10414
|
const id = norm(modelId);
|
|
10411
10415
|
if (!id || learnedRejects.has(id))
|
|
@@ -10530,7 +10534,7 @@ var init_grok_model_dialect = __esm(() => {
|
|
|
10530
10534
|
return;
|
|
10531
10535
|
}
|
|
10532
10536
|
let value;
|
|
10533
|
-
const reasoning =
|
|
10537
|
+
const reasoning = this.lookupReasoningCapability();
|
|
10534
10538
|
const clamped = reasoning ? this.clampToAdvertisedEffort(effort, reasoning) : undefined;
|
|
10535
10539
|
if (clamped) {
|
|
10536
10540
|
value = clamped;
|
|
@@ -10878,6 +10882,324 @@ var init_minimax_model_dialect = __esm(() => {
|
|
|
10878
10882
|
};
|
|
10879
10883
|
});
|
|
10880
10884
|
|
|
10885
|
+
// src/providers/keychain.ts
|
|
10886
|
+
function syncRun(args, stdin) {
|
|
10887
|
+
try {
|
|
10888
|
+
const proc = Bun.spawnSync([SECURITY_BIN, ...args], {
|
|
10889
|
+
stdin: stdin === undefined ? "ignore" : new TextEncoder().encode(stdin),
|
|
10890
|
+
stdout: "pipe",
|
|
10891
|
+
stderr: "pipe",
|
|
10892
|
+
timeout: SPAWN_TIMEOUT_MS
|
|
10893
|
+
});
|
|
10894
|
+
return normalizeResult(proc.exitCode, proc.signalCode, decode(proc.stdout), decode(proc.stderr));
|
|
10895
|
+
} catch (err) {
|
|
10896
|
+
return { code: 1, stdout: "", stderr: err instanceof Error ? err.message : String(err) };
|
|
10897
|
+
}
|
|
10898
|
+
}
|
|
10899
|
+
async function asyncRun(args, stdin) {
|
|
10900
|
+
try {
|
|
10901
|
+
const proc = Bun.spawn([SECURITY_BIN, ...args], {
|
|
10902
|
+
stdin: stdin === undefined ? "ignore" : new TextEncoder().encode(stdin),
|
|
10903
|
+
stdout: "pipe",
|
|
10904
|
+
stderr: "pipe",
|
|
10905
|
+
timeout: SPAWN_TIMEOUT_MS
|
|
10906
|
+
});
|
|
10907
|
+
const [stdout, stderr, exitCode] = await Promise.all([
|
|
10908
|
+
new Response(proc.stdout).text(),
|
|
10909
|
+
new Response(proc.stderr).text(),
|
|
10910
|
+
proc.exited
|
|
10911
|
+
]);
|
|
10912
|
+
return normalizeResult(exitCode, proc.signalCode, stdout, stderr);
|
|
10913
|
+
} catch (err) {
|
|
10914
|
+
return { code: 1, stdout: "", stderr: err instanceof Error ? err.message : String(err) };
|
|
10915
|
+
}
|
|
10916
|
+
}
|
|
10917
|
+
function spawnAsyncRun(args, stdin) {
|
|
10918
|
+
try {
|
|
10919
|
+
const proc = Bun.spawn([SECURITY_BIN, ...args], {
|
|
10920
|
+
stdin: stdin === undefined ? "ignore" : new TextEncoder().encode(stdin),
|
|
10921
|
+
stdout: "pipe",
|
|
10922
|
+
stderr: "pipe"
|
|
10923
|
+
});
|
|
10924
|
+
const done = Promise.all([
|
|
10925
|
+
new Response(proc.stdout).text(),
|
|
10926
|
+
new Response(proc.stderr).text(),
|
|
10927
|
+
proc.exited
|
|
10928
|
+
]).then(([stdout, stderr, exitCode]) => normalizeResult(exitCode, proc.signalCode, stdout, stderr), (err) => ({
|
|
10929
|
+
code: 1,
|
|
10930
|
+
stdout: "",
|
|
10931
|
+
stderr: err instanceof Error ? err.message : String(err)
|
|
10932
|
+
}));
|
|
10933
|
+
return { done, pid: proc.pid };
|
|
10934
|
+
} catch (err) {
|
|
10935
|
+
return {
|
|
10936
|
+
done: Promise.resolve({
|
|
10937
|
+
code: 1,
|
|
10938
|
+
stdout: "",
|
|
10939
|
+
stderr: err instanceof Error ? err.message : String(err)
|
|
10940
|
+
}),
|
|
10941
|
+
pid: undefined
|
|
10942
|
+
};
|
|
10943
|
+
}
|
|
10944
|
+
}
|
|
10945
|
+
function decode(buf) {
|
|
10946
|
+
return buf ? new TextDecoder().decode(buf) : "";
|
|
10947
|
+
}
|
|
10948
|
+
function normalizeResult(exitCode, signalCode, stdout, stderr) {
|
|
10949
|
+
if (typeof exitCode === "number")
|
|
10950
|
+
return { code: exitCode, stdout, stderr };
|
|
10951
|
+
const detail = signalCode ? `killed by ${signalCode}` : "terminated without an exit code";
|
|
10952
|
+
return { code: -1, stdout, stderr: stderr.trim() || `security ${detail}` };
|
|
10953
|
+
}
|
|
10954
|
+
function invalidateKeychainCache() {
|
|
10955
|
+
listMemo = null;
|
|
10956
|
+
valueMemo.clear();
|
|
10957
|
+
}
|
|
10958
|
+
function now() {
|
|
10959
|
+
return Date.now();
|
|
10960
|
+
}
|
|
10961
|
+
function isValidKeychainVarName(name) {
|
|
10962
|
+
return ENV_VAR_NAME.test(name);
|
|
10963
|
+
}
|
|
10964
|
+
function describeUnstorableValue(value) {
|
|
10965
|
+
if (value.length === 0)
|
|
10966
|
+
return "value is empty";
|
|
10967
|
+
if (CONTROL_CHARS.test(value)) {
|
|
10968
|
+
return "value contains control characters (tab/newline/etc), which the keychain read path cannot represent unambiguously";
|
|
10969
|
+
}
|
|
10970
|
+
return null;
|
|
10971
|
+
}
|
|
10972
|
+
function isKeychainSupported() {
|
|
10973
|
+
return deps.platform() === "darwin";
|
|
10974
|
+
}
|
|
10975
|
+
function keychainUnavailableReason() {
|
|
10976
|
+
if (!isKeychainSupported()) {
|
|
10977
|
+
return `the macOS Keychain is only available on macOS (this is ${deps.platform()})`;
|
|
10978
|
+
}
|
|
10979
|
+
return null;
|
|
10980
|
+
}
|
|
10981
|
+
function stripOneTrailingNewline(out) {
|
|
10982
|
+
return out.endsWith(`
|
|
10983
|
+
`) ? out.slice(0, -1) : out;
|
|
10984
|
+
}
|
|
10985
|
+
function keychainFileArgs() {
|
|
10986
|
+
const file = process.env.CLAUDISH_KEYCHAIN_FILE;
|
|
10987
|
+
return file ? [file] : [];
|
|
10988
|
+
}
|
|
10989
|
+
function findArgs(envVar) {
|
|
10990
|
+
return [
|
|
10991
|
+
"find-generic-password",
|
|
10992
|
+
"-s",
|
|
10993
|
+
KEYCHAIN_SERVICE,
|
|
10994
|
+
"-a",
|
|
10995
|
+
envVar,
|
|
10996
|
+
"-w",
|
|
10997
|
+
...keychainFileArgs()
|
|
10998
|
+
];
|
|
10999
|
+
}
|
|
11000
|
+
function interpretRead(envVar, res) {
|
|
11001
|
+
if (res.code === 0) {
|
|
11002
|
+
const value = stripOneTrailingNewline(res.stdout);
|
|
11003
|
+
return value.length > 0 ? value : null;
|
|
11004
|
+
}
|
|
11005
|
+
if (res.code === EXIT_ITEM_NOT_FOUND)
|
|
11006
|
+
return null;
|
|
11007
|
+
throw new KeychainError(`Keychain lookup for ${envVar} failed: ${res.stderr.trim() || `security exited ${res.code}`}`, res.code);
|
|
11008
|
+
}
|
|
11009
|
+
function readKeychainSecret(envVar) {
|
|
11010
|
+
if (!isKeychainSupported())
|
|
11011
|
+
return null;
|
|
11012
|
+
const cached = valueMemo.get(envVar);
|
|
11013
|
+
const at = now();
|
|
11014
|
+
if (cached && at - cached.at < MEMO_TTL_MS)
|
|
11015
|
+
return cached.value;
|
|
11016
|
+
const value = interpretRead(envVar, deps.run(findArgs(envVar)));
|
|
11017
|
+
valueMemo.set(envVar, { at, value });
|
|
11018
|
+
return value;
|
|
11019
|
+
}
|
|
11020
|
+
async function readKeychainSecretAsync(envVar) {
|
|
11021
|
+
if (!isKeychainSupported())
|
|
11022
|
+
return null;
|
|
11023
|
+
const cached = valueMemo.get(envVar);
|
|
11024
|
+
const at = now();
|
|
11025
|
+
if (cached && at - cached.at < MEMO_TTL_MS)
|
|
11026
|
+
return cached.value;
|
|
11027
|
+
const value = interpretRead(envVar, await deps.runAsync(findArgs(envVar)));
|
|
11028
|
+
valueMemo.set(envVar, { at, value });
|
|
11029
|
+
return value;
|
|
11030
|
+
}
|
|
11031
|
+
function genericPasswordArgs(query, withValue) {
|
|
11032
|
+
return [
|
|
11033
|
+
"find-generic-password",
|
|
11034
|
+
"-s",
|
|
11035
|
+
query.service,
|
|
11036
|
+
...query.account !== undefined ? ["-a", query.account] : [],
|
|
11037
|
+
...withValue ? ["-w"] : [],
|
|
11038
|
+
...query.keychainFile !== undefined ? [query.keychainFile] : keychainFileArgs()
|
|
11039
|
+
];
|
|
11040
|
+
}
|
|
11041
|
+
function interpretGenericPassword(res, withValue) {
|
|
11042
|
+
if (res.code === 0) {
|
|
11043
|
+
if (!withValue)
|
|
11044
|
+
return { kind: "found" };
|
|
11045
|
+
const value = stripOneTrailingNewline(res.stdout);
|
|
11046
|
+
return value.length > 0 ? { kind: "found", value } : { kind: "absent" };
|
|
11047
|
+
}
|
|
11048
|
+
if (res.code === EXIT_ITEM_NOT_FOUND)
|
|
11049
|
+
return { kind: "absent" };
|
|
11050
|
+
return {
|
|
11051
|
+
kind: "failed",
|
|
11052
|
+
code: res.code,
|
|
11053
|
+
error: res.stderr.trim() || `security exited ${res.code}`
|
|
11054
|
+
};
|
|
11055
|
+
}
|
|
11056
|
+
async function findGenericPasswordPresence(query) {
|
|
11057
|
+
if (!isKeychainSupported())
|
|
11058
|
+
return { kind: "absent" };
|
|
11059
|
+
const res = await deps.spawnAsync(genericPasswordArgs(query, false)).done;
|
|
11060
|
+
return interpretGenericPassword(res, false);
|
|
11061
|
+
}
|
|
11062
|
+
function startGenericPasswordRead(query) {
|
|
11063
|
+
if (!isKeychainSupported()) {
|
|
11064
|
+
return { done: Promise.resolve({ kind: "absent" }), pid: undefined };
|
|
11065
|
+
}
|
|
11066
|
+
const spawn = deps.spawnAsync(genericPasswordArgs(query, true));
|
|
11067
|
+
return { done: spawn.done.then((res) => interpretGenericPassword(res, true)), pid: spawn.pid };
|
|
11068
|
+
}
|
|
11069
|
+
function enumerateKeychainVars() {
|
|
11070
|
+
if (!isKeychainSupported())
|
|
11071
|
+
return { names: [], failed: false };
|
|
11072
|
+
const at = now();
|
|
11073
|
+
if (listMemo && at - listMemo.at < MEMO_TTL_MS)
|
|
11074
|
+
return listMemo.value;
|
|
11075
|
+
const res = deps.run(["dump-keychain", ...keychainFileArgs()]);
|
|
11076
|
+
const value = res.code === 0 ? { names: parseDumpAccounts(res.stdout), failed: false } : {
|
|
11077
|
+
names: [],
|
|
11078
|
+
failed: true,
|
|
11079
|
+
error: res.stderr.trim() || `security exited ${res.code}`
|
|
11080
|
+
};
|
|
11081
|
+
listMemo = { at, value };
|
|
11082
|
+
return value;
|
|
11083
|
+
}
|
|
11084
|
+
function listKeychainVars() {
|
|
11085
|
+
return enumerateKeychainVars().names;
|
|
11086
|
+
}
|
|
11087
|
+
function parseDumpAccounts(dump) {
|
|
11088
|
+
const found = new Set;
|
|
11089
|
+
for (const block of dump.split(/\nkeychain: /)) {
|
|
11090
|
+
if (!block.includes(SVCE_MATCH))
|
|
11091
|
+
continue;
|
|
11092
|
+
const m = block.match(ACCT_ATTR);
|
|
11093
|
+
if (m?.[1] && isValidKeychainVarName(m[1]))
|
|
11094
|
+
found.add(m[1]);
|
|
11095
|
+
}
|
|
11096
|
+
return Array.from(found).sort();
|
|
11097
|
+
}
|
|
11098
|
+
function lookupKeychainVar(envVar) {
|
|
11099
|
+
if (!isKeychainSupported())
|
|
11100
|
+
return { present: false, failed: false };
|
|
11101
|
+
const cached = valueMemo.get(envVar);
|
|
11102
|
+
if (cached && now() - cached.at < MEMO_TTL_MS && cached.value !== null) {
|
|
11103
|
+
return { present: true, failed: false };
|
|
11104
|
+
}
|
|
11105
|
+
const listed = enumerateKeychainVars();
|
|
11106
|
+
return { present: listed.names.includes(envVar), failed: listed.failed };
|
|
11107
|
+
}
|
|
11108
|
+
function toHex(value) {
|
|
11109
|
+
return Buffer.from(value, "utf8").toString("hex");
|
|
11110
|
+
}
|
|
11111
|
+
function quoteForStdin(value) {
|
|
11112
|
+
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
|
|
11113
|
+
}
|
|
11114
|
+
function writeKeychainSecret(envVar, value) {
|
|
11115
|
+
const unsupported = keychainUnavailableReason();
|
|
11116
|
+
if (unsupported)
|
|
11117
|
+
throw new KeychainError(`Cannot write ${envVar}: ${unsupported}`);
|
|
11118
|
+
if (!isValidKeychainVarName(envVar)) {
|
|
11119
|
+
throw new KeychainError(`Cannot write "${envVar}": not a valid environment variable name`);
|
|
11120
|
+
}
|
|
11121
|
+
const unstorable = describeUnstorableValue(value);
|
|
11122
|
+
if (unstorable)
|
|
11123
|
+
throw new KeychainError(`Cannot store ${envVar}: ${unstorable}`);
|
|
11124
|
+
invalidateKeychainCache();
|
|
11125
|
+
const cmd = [
|
|
11126
|
+
"add-generic-password",
|
|
11127
|
+
"-s",
|
|
11128
|
+
quoteForStdin(KEYCHAIN_SERVICE),
|
|
11129
|
+
"-a",
|
|
11130
|
+
quoteForStdin(envVar),
|
|
11131
|
+
"-l",
|
|
11132
|
+
quoteForStdin(`${KEYCHAIN_SERVICE}: ${envVar}`),
|
|
11133
|
+
"-D",
|
|
11134
|
+
quoteForStdin("application password"),
|
|
11135
|
+
"-j",
|
|
11136
|
+
quoteForStdin("Stored by claudish"),
|
|
11137
|
+
"-X",
|
|
11138
|
+
quoteForStdin(toHex(value)),
|
|
11139
|
+
"-U",
|
|
11140
|
+
"-T",
|
|
11141
|
+
quoteForStdin(SECURITY_BIN),
|
|
11142
|
+
...keychainFileArgs().map(quoteForStdin)
|
|
11143
|
+
].join(" ");
|
|
11144
|
+
const res = deps.run(["-i"], `${cmd}
|
|
11145
|
+
`);
|
|
11146
|
+
if (res.code !== 0) {
|
|
11147
|
+
throw new KeychainError(`Failed to store ${envVar} in the keychain: ${res.stderr.trim() || `security exited ${res.code}`}`, res.code);
|
|
11148
|
+
}
|
|
11149
|
+
invalidateKeychainCache();
|
|
11150
|
+
const readBack = readKeychainSecret(envVar);
|
|
11151
|
+
if (readBack !== value) {
|
|
11152
|
+
throw new KeychainError(`Keychain write for ${envVar} did not round-trip \u2014 the stored value differs from what was written. ` + "The item may exceed the keychain's size limit; nothing should be assumed saved.");
|
|
11153
|
+
}
|
|
11154
|
+
}
|
|
11155
|
+
function deleteKeychainSecret(envVar) {
|
|
11156
|
+
if (!isKeychainSupported())
|
|
11157
|
+
return false;
|
|
11158
|
+
invalidateKeychainCache();
|
|
11159
|
+
const res = deps.run([
|
|
11160
|
+
"delete-generic-password",
|
|
11161
|
+
"-s",
|
|
11162
|
+
KEYCHAIN_SERVICE,
|
|
11163
|
+
"-a",
|
|
11164
|
+
envVar,
|
|
11165
|
+
...keychainFileArgs()
|
|
11166
|
+
]);
|
|
11167
|
+
invalidateKeychainCache();
|
|
11168
|
+
if (res.code === 0)
|
|
11169
|
+
return true;
|
|
11170
|
+
if (res.code === EXIT_ITEM_NOT_FOUND)
|
|
11171
|
+
return false;
|
|
11172
|
+
throw new KeychainError(`Failed to delete ${envVar} from the keychain: ${res.stderr.trim() || `security exited ${res.code}`}`, res.code);
|
|
11173
|
+
}
|
|
11174
|
+
function valueTail2(value) {
|
|
11175
|
+
if (value.length <= 6)
|
|
11176
|
+
return "\u2022\u2022\u2022\u2022";
|
|
11177
|
+
return `\u2022\u2022\u2022\u2022${value.slice(-4)}`;
|
|
11178
|
+
}
|
|
11179
|
+
var KEYCHAIN_SERVICE = "claudish", SECURITY_BIN = "/usr/bin/security", EXIT_ITEM_NOT_FOUND = 44, MEMO_TTL_MS = 3000, SPAWN_TIMEOUT_MS = 1e4, KeychainError, defaultDeps, deps, listMemo = null, valueMemo, CONTROL_CHARS, ENV_VAR_NAME, ACCT_ATTR, SVCE_MATCH;
|
|
11180
|
+
var init_keychain = __esm(() => {
|
|
11181
|
+
KeychainError = class KeychainError extends Error {
|
|
11182
|
+
exitCode;
|
|
11183
|
+
constructor(message, exitCode) {
|
|
11184
|
+
super(message);
|
|
11185
|
+
this.exitCode = exitCode;
|
|
11186
|
+
this.name = "KeychainError";
|
|
11187
|
+
}
|
|
11188
|
+
};
|
|
11189
|
+
defaultDeps = {
|
|
11190
|
+
platform: () => process.platform,
|
|
11191
|
+
run: syncRun,
|
|
11192
|
+
runAsync: asyncRun,
|
|
11193
|
+
spawnAsync: spawnAsyncRun
|
|
11194
|
+
};
|
|
11195
|
+
deps = defaultDeps;
|
|
11196
|
+
valueMemo = new Map;
|
|
11197
|
+
CONTROL_CHARS = /[\u0000-\u001F\u007F]/;
|
|
11198
|
+
ENV_VAR_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
11199
|
+
ACCT_ATTR = /"acct"<blob>=(?:0x[0-9A-Fa-f]*\s+)?"([^"]*)"/;
|
|
11200
|
+
SVCE_MATCH = `"svce"<blob>="${KEYCHAIN_SERVICE}"`;
|
|
11201
|
+
});
|
|
11202
|
+
|
|
10881
11203
|
// src/auth/antigravity-client-version.ts
|
|
10882
11204
|
function getAgyClientVersion() {
|
|
10883
11205
|
return version;
|
|
@@ -10999,6 +11321,46 @@ function defaultReadAgyVersion() {
|
|
|
10999
11321
|
return null;
|
|
11000
11322
|
}
|
|
11001
11323
|
}
|
|
11324
|
+
function defaultAntigravityTokenDeps() {
|
|
11325
|
+
return { ...defaultDeps2 };
|
|
11326
|
+
}
|
|
11327
|
+
async function raceDeadline(work, deadlineAt) {
|
|
11328
|
+
let timer;
|
|
11329
|
+
const timedOut = new Promise((resolve) => {
|
|
11330
|
+
timer = setTimeout(() => resolve("timeout"), Math.max(0, deadlineAt - Date.now()));
|
|
11331
|
+
});
|
|
11332
|
+
try {
|
|
11333
|
+
return await Promise.race([work, timedOut]);
|
|
11334
|
+
} finally {
|
|
11335
|
+
if (timer)
|
|
11336
|
+
clearTimeout(timer);
|
|
11337
|
+
}
|
|
11338
|
+
}
|
|
11339
|
+
function classifyKeychainFailure(code) {
|
|
11340
|
+
return KEYCHAIN_LOCKED_EXIT_CODES.has(code) ? { kind: "locked" } : { kind: "failed" };
|
|
11341
|
+
}
|
|
11342
|
+
async function readAntigravityStoreClassified(deadlineMs) {
|
|
11343
|
+
if (process.env.CLAUDISH_DISABLE_KEYCHAIN === "1")
|
|
11344
|
+
return { kind: "failed" };
|
|
11345
|
+
const deadlineAt = Date.now() + deadlineMs;
|
|
11346
|
+
const query = { service: KC_SERVICE, account: KC_ACCOUNT };
|
|
11347
|
+
const presence = await raceDeadline(findGenericPasswordPresence(query), deadlineAt);
|
|
11348
|
+
if (presence === "timeout")
|
|
11349
|
+
return { kind: "timeout" };
|
|
11350
|
+
if (presence.kind === "absent")
|
|
11351
|
+
return { kind: "absent" };
|
|
11352
|
+
if (presence.kind === "failed")
|
|
11353
|
+
return classifyKeychainFailure(presence.code);
|
|
11354
|
+
const read = await raceDeadline(startGenericPasswordRead(query).done, deadlineAt);
|
|
11355
|
+
if (read === "timeout")
|
|
11356
|
+
return { kind: "timeout" };
|
|
11357
|
+
if (read.kind === "absent")
|
|
11358
|
+
return { kind: "absent" };
|
|
11359
|
+
if (read.kind === "failed")
|
|
11360
|
+
return classifyKeychainFailure(read.code);
|
|
11361
|
+
const raw = (read.value ?? "").trim();
|
|
11362
|
+
return raw.length > 0 ? { kind: "present", raw } : { kind: "absent" };
|
|
11363
|
+
}
|
|
11002
11364
|
function parseRecord(raw) {
|
|
11003
11365
|
if (!raw)
|
|
11004
11366
|
return null;
|
|
@@ -11020,11 +11382,11 @@ function parseRecord(raw) {
|
|
|
11020
11382
|
function encodeRecord(rec) {
|
|
11021
11383
|
return PREFIX + Buffer.from(JSON.stringify(rec), "utf8").toString("base64");
|
|
11022
11384
|
}
|
|
11023
|
-
function readSharedAntigravityToken(deps =
|
|
11385
|
+
function readSharedAntigravityToken(deps = defaultDeps2) {
|
|
11024
11386
|
const rec = parseRecord(deps.readStore());
|
|
11025
11387
|
return rec ? rec.token : null;
|
|
11026
11388
|
}
|
|
11027
|
-
function hasSharedAntigravityToken(deps =
|
|
11389
|
+
function hasSharedAntigravityToken(deps = defaultDeps2) {
|
|
11028
11390
|
const now = Date.now();
|
|
11029
11391
|
if (cachedHasToken && now - cachedHasToken.at < HAS_TOKEN_TTL_MS)
|
|
11030
11392
|
return cachedHasToken.value;
|
|
@@ -11037,7 +11399,7 @@ function hasSharedAntigravityToken(deps = defaultDeps) {
|
|
|
11037
11399
|
cachedHasToken = { at: now, value };
|
|
11038
11400
|
return value;
|
|
11039
11401
|
}
|
|
11040
|
-
function writeSharedAntigravityToken(tok, deps =
|
|
11402
|
+
function writeSharedAntigravityToken(tok, deps = defaultDeps2) {
|
|
11041
11403
|
const existing = parseRecord(deps.readStore());
|
|
11042
11404
|
const base = existing ?? { token: tok };
|
|
11043
11405
|
const merged = {
|
|
@@ -11046,7 +11408,7 @@ function writeSharedAntigravityToken(tok, deps = defaultDeps) {
|
|
|
11046
11408
|
};
|
|
11047
11409
|
deps.writeStore(encodeRecord(merged));
|
|
11048
11410
|
}
|
|
11049
|
-
function deleteSharedAntigravityToken(deps =
|
|
11411
|
+
function deleteSharedAntigravityToken(deps = defaultDeps2) {
|
|
11050
11412
|
(deps.deleteStore ?? defaultDeleteStore)();
|
|
11051
11413
|
_resetAntigravityTokenState();
|
|
11052
11414
|
}
|
|
@@ -11107,7 +11469,7 @@ function describeRefreshFailure(outcome) {
|
|
|
11107
11469
|
return "The Antigravity session is expired and the Antigravity CLI refreshed it without " + "producing a valid token \u2014 the session has most likely been revoked. " + "Run `claudish login antigravity`.";
|
|
11108
11470
|
}
|
|
11109
11471
|
}
|
|
11110
|
-
function getValidAntigravityAccessToken(deps =
|
|
11472
|
+
function getValidAntigravityAccessToken(deps = defaultDeps2) {
|
|
11111
11473
|
if (inFlight)
|
|
11112
11474
|
return inFlight;
|
|
11113
11475
|
inFlight = resolveValidToken(deps).finally(() => {
|
|
@@ -11115,7 +11477,7 @@ function getValidAntigravityAccessToken(deps = defaultDeps) {
|
|
|
11115
11477
|
});
|
|
11116
11478
|
return inFlight;
|
|
11117
11479
|
}
|
|
11118
|
-
async function forceRefreshAntigravityToken(deps =
|
|
11480
|
+
async function forceRefreshAntigravityToken(deps = defaultDeps2) {
|
|
11119
11481
|
if (process.platform !== "darwin") {
|
|
11120
11482
|
throw terminalCredentialError("[Antigravity] The shared Antigravity token store is macOS-only for now. " + "Use g@<model> with GEMINI_API_KEY on this platform.");
|
|
11121
11483
|
}
|
|
@@ -11156,10 +11518,11 @@ function _resetAntigravityTokenState() {
|
|
|
11156
11518
|
cachedHasToken = null;
|
|
11157
11519
|
invalidateReadStoreMemo();
|
|
11158
11520
|
}
|
|
11159
|
-
var KC_SERVICE = "gemini", KC_ACCOUNT = "antigravity", PREFIX = "go-keyring-base64:", EXPIRY_SKEW_MS = 120000, AGY_REFRESH_TIMEOUT_MS = 12000, AGY_VERSION_TIMEOUT_MS = 5000, READ_STORE_TTL_MS = 3000, cachedRawStore = null,
|
|
11521
|
+
var KC_SERVICE = "gemini", KC_ACCOUNT = "antigravity", PREFIX = "go-keyring-base64:", EXPIRY_SKEW_MS = 120000, AGY_REFRESH_TIMEOUT_MS = 12000, AGY_VERSION_TIMEOUT_MS = 5000, READ_STORE_TTL_MS = 3000, cachedRawStore = null, defaultDeps2, KEYCHAIN_LOCKED_EXIT_CODES, cachedHasToken = null, HAS_TOKEN_TTL_MS = 5000, inFlight = null;
|
|
11160
11522
|
var init_antigravity_token = __esm(() => {
|
|
11161
11523
|
init_logger();
|
|
11162
|
-
|
|
11524
|
+
init_keychain();
|
|
11525
|
+
defaultDeps2 = {
|
|
11163
11526
|
readStore: defaultReadStore,
|
|
11164
11527
|
writeStore: defaultWriteStore,
|
|
11165
11528
|
deleteStore: defaultDeleteStore,
|
|
@@ -11167,6 +11530,7 @@ var init_antigravity_token = __esm(() => {
|
|
|
11167
11530
|
readAgyVersion: defaultReadAgyVersion,
|
|
11168
11531
|
now: () => Date.now()
|
|
11169
11532
|
};
|
|
11533
|
+
KEYCHAIN_LOCKED_EXIT_CODES = new Set([36, 51, 128]);
|
|
11170
11534
|
});
|
|
11171
11535
|
|
|
11172
11536
|
// src/auth/antigravity-user.ts
|
|
@@ -11182,11 +11546,18 @@ function makeTerminalSetupError(message) {
|
|
|
11182
11546
|
err.terminal = true;
|
|
11183
11547
|
return err;
|
|
11184
11548
|
}
|
|
11549
|
+
function resolveAntigravityClientVersion() {
|
|
11550
|
+
const agy = getAgyClientVersion();
|
|
11551
|
+
return agy ? { version: agy, source: "agy" } : { version: AGY_FALLBACK_CLIENT_VERSION, source: "fallback" };
|
|
11552
|
+
}
|
|
11185
11553
|
function antigravityClientVersion() {
|
|
11186
|
-
return
|
|
11554
|
+
return resolveAntigravityClientVersion().version;
|
|
11555
|
+
}
|
|
11556
|
+
function userAgentFor(version) {
|
|
11557
|
+
return `antigravity/cli/${version} (aidev_client; os_type=${process.platform}; arch=${process.arch}; auth_method=consumer)`;
|
|
11187
11558
|
}
|
|
11188
11559
|
function buildAntigravityUserAgent() {
|
|
11189
|
-
return
|
|
11560
|
+
return userAgentFor(antigravityClientVersion());
|
|
11190
11561
|
}
|
|
11191
11562
|
function resetAntigravityUserCache() {
|
|
11192
11563
|
cachedAgProjectId = null;
|
|
@@ -11278,6 +11649,45 @@ function flattenAgentModelSorts(sorts) {
|
|
|
11278
11649
|
}
|
|
11279
11650
|
return ids.length > 0 ? ids : undefined;
|
|
11280
11651
|
}
|
|
11652
|
+
async function fetchAntigravityAvailableModelsRaw(accessToken, projectId, opts) {
|
|
11653
|
+
const url = `${apiBase()}:fetchAvailableModels`;
|
|
11654
|
+
const { version, source } = resolveAntigravityClientVersion();
|
|
11655
|
+
const base = {
|
|
11656
|
+
url,
|
|
11657
|
+
clientVersion: version,
|
|
11658
|
+
clientVersionSource: source
|
|
11659
|
+
};
|
|
11660
|
+
let res;
|
|
11661
|
+
try {
|
|
11662
|
+
res = await fetch(url, {
|
|
11663
|
+
method: "POST",
|
|
11664
|
+
headers: {
|
|
11665
|
+
Authorization: `Bearer ${accessToken}`,
|
|
11666
|
+
"Content-Type": "application/json",
|
|
11667
|
+
"User-Agent": userAgentFor(version)
|
|
11668
|
+
},
|
|
11669
|
+
body: JSON.stringify({ project: projectId }),
|
|
11670
|
+
...opts?.signal ? { signal: opts.signal } : {}
|
|
11671
|
+
});
|
|
11672
|
+
} catch (error) {
|
|
11673
|
+
return { ...base, kind: "unreachable", error };
|
|
11674
|
+
}
|
|
11675
|
+
const fetchedAt = new Date((opts?.now ?? Date.now)()).toISOString();
|
|
11676
|
+
const answered = { ...base, kind: "answered", status: res.status, fetchedAt };
|
|
11677
|
+
if (!res.ok)
|
|
11678
|
+
return { ...answered, body: { kind: "unread" } };
|
|
11679
|
+
let text;
|
|
11680
|
+
try {
|
|
11681
|
+
text = await res.text();
|
|
11682
|
+
} catch {
|
|
11683
|
+
return { ...answered, body: { kind: "read-failed" } };
|
|
11684
|
+
}
|
|
11685
|
+
try {
|
|
11686
|
+
return { ...answered, body: { kind: "json", text, value: JSON.parse(text) } };
|
|
11687
|
+
} catch {
|
|
11688
|
+
return { ...answered, body: { kind: "not-json" } };
|
|
11689
|
+
}
|
|
11690
|
+
}
|
|
11281
11691
|
async function getServedAntigravityModels(accessToken, projectId, opts) {
|
|
11282
11692
|
const now = Date.now();
|
|
11283
11693
|
const version = antigravityClientVersion();
|
|
@@ -11290,17 +11700,15 @@ async function getServedAntigravityModels(accessToken, projectId, opts) {
|
|
|
11290
11700
|
return agServedCache;
|
|
11291
11701
|
}
|
|
11292
11702
|
try {
|
|
11293
|
-
const
|
|
11294
|
-
|
|
11295
|
-
|
|
11296
|
-
|
|
11297
|
-
|
|
11298
|
-
|
|
11299
|
-
}
|
|
11300
|
-
|
|
11301
|
-
|
|
11302
|
-
if (res.ok) {
|
|
11303
|
-
const data = await res.json();
|
|
11703
|
+
const raw = await fetchAntigravityAvailableModelsRaw(accessToken, projectId);
|
|
11704
|
+
if (raw.kind === "unreachable") {
|
|
11705
|
+
log(`[Antigravity] fetchAvailableModels error: ${raw.error}`);
|
|
11706
|
+
} else if (raw.status < 200 || raw.status >= 300) {
|
|
11707
|
+
log(`[Antigravity] fetchAvailableModels failed: ${raw.status}`);
|
|
11708
|
+
} else if (raw.body.kind !== "json") {
|
|
11709
|
+
log(`[Antigravity] fetchAvailableModels error: ${raw.body.kind === "not-json" ? "the body is not JSON" : "the body could not be read"}`);
|
|
11710
|
+
} else {
|
|
11711
|
+
const data = raw.body.value;
|
|
11304
11712
|
const servedIds = data.models ? Object.keys(data.models) : [];
|
|
11305
11713
|
const defaultId = typeof data.defaultAgentModelId === "string" ? data.defaultAgentModelId : null;
|
|
11306
11714
|
if (servedIds.length > 0) {
|
|
@@ -11347,11 +11755,9 @@ async function getServedAntigravityModels(accessToken, projectId, opts) {
|
|
|
11347
11755
|
...agentModelIds ? { agentModelIds } : {}
|
|
11348
11756
|
};
|
|
11349
11757
|
agServedCacheAt = now;
|
|
11350
|
-
agServedCacheVersion =
|
|
11758
|
+
agServedCacheVersion = raw.clientVersion;
|
|
11351
11759
|
return agServedCache;
|
|
11352
11760
|
}
|
|
11353
|
-
} else {
|
|
11354
|
-
log(`[Antigravity] fetchAvailableModels failed: ${res.status}`);
|
|
11355
11761
|
}
|
|
11356
11762
|
} catch (err) {
|
|
11357
11763
|
log(`[Antigravity] fetchAvailableModels error: ${err}`);
|
|
@@ -12914,7 +13320,7 @@ async function performRefresh(cred) {
|
|
|
12914
13320
|
method: "POST",
|
|
12915
13321
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
12916
13322
|
body,
|
|
12917
|
-
signal: AbortSignal.timeout(
|
|
13323
|
+
signal: AbortSignal.timeout(refreshTimeoutMs)
|
|
12918
13324
|
});
|
|
12919
13325
|
} catch (error) {
|
|
12920
13326
|
throw Object.assign(new Error(`Could not reach ${tokenEndpoint} to refresh the Grok token: ${error.message}`, { cause: markOwnTimeout(error) }), { claudishEndpoint: tokenEndpoint });
|
|
@@ -12980,13 +13386,14 @@ function refreshShared(cred) {
|
|
|
12980
13386
|
}
|
|
12981
13387
|
return refreshInFlight;
|
|
12982
13388
|
}
|
|
12983
|
-
var GROK_PROXY_URL_ENV = "GROK_PROXY_URL", DEFAULT_GROK_PROXY_URL = "https://cli-chat-proxy.grok.com/v1", GROK_CLIENT_IDENTIFIER = "grok-shell", FALLBACK_GROK_CLIENT_VERSION = "1.0.4", LEGACY_SCOPE = "https://accounts.x.ai/sign-in", EXPIRY_SKEW_MS2, grokHomeOverride = null, claudishOAuthPathOverride = null, GROK_CHANNEL_URL = "https://x.ai/cli/stable", liveClientVersion = null, SIGN_IN_HINT, refreshInFlight = null;
|
|
13389
|
+
var GROK_PROXY_URL_ENV = "GROK_PROXY_URL", DEFAULT_GROK_PROXY_URL = "https://cli-chat-proxy.grok.com/v1", GROK_CLIENT_IDENTIFIER = "grok-shell", FALLBACK_GROK_CLIENT_VERSION = "1.0.4", LEGACY_SCOPE = "https://accounts.x.ai/sign-in", EXPIRY_SKEW_MS2, grokHomeOverride = null, claudishOAuthPathOverride = null, GROK_CHANNEL_URL = "https://x.ai/cli/stable", liveClientVersion = null, SIGN_IN_HINT, refreshInFlight = null, refreshTimeoutMs;
|
|
12984
13390
|
var init_grok_credentials = __esm(() => {
|
|
12985
13391
|
init_grok_oauth();
|
|
12986
13392
|
init_connection_error();
|
|
12987
13393
|
init_transient_retry();
|
|
12988
13394
|
EXPIRY_SKEW_MS2 = 5 * 60 * 1000;
|
|
12989
13395
|
SIGN_IN_HINT = "Run `claudish login grok` (no Grok CLI required \u2014 SuperGrok or X Premium+ subscription). " + "An existing `grok login` (~/.grok/auth.json) is also picked up automatically.";
|
|
13396
|
+
refreshTimeoutMs = TOKEN_REFRESH_TIMEOUT_MS;
|
|
12990
13397
|
});
|
|
12991
13398
|
|
|
12992
13399
|
// src/auth/quota/sources/grok.ts
|
|
@@ -16959,7 +17366,7 @@ var init_errors2 = __esm(() => {
|
|
|
16959
17366
|
});
|
|
16960
17367
|
|
|
16961
17368
|
// ../../node_modules/.bun/zod@4.1.13/node_modules/zod/v4/classic/parse.js
|
|
16962
|
-
var parse4, parseAsync2, safeParse2, safeParseAsync2, encode,
|
|
17369
|
+
var parse4, parseAsync2, safeParse2, safeParseAsync2, encode, decode2, encodeAsync, decodeAsync, safeEncode, safeDecode, safeEncodeAsync, safeDecodeAsync;
|
|
16963
17370
|
var init_parse2 = __esm(() => {
|
|
16964
17371
|
init_core2();
|
|
16965
17372
|
init_errors2();
|
|
@@ -16968,7 +17375,7 @@ var init_parse2 = __esm(() => {
|
|
|
16968
17375
|
safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
16969
17376
|
safeParseAsync2 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
16970
17377
|
encode = /* @__PURE__ */ _encode(ZodRealError);
|
|
16971
|
-
|
|
17378
|
+
decode2 = /* @__PURE__ */ _decode(ZodRealError);
|
|
16972
17379
|
encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
|
|
16973
17380
|
decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
|
|
16974
17381
|
safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
|
|
@@ -17173,7 +17580,7 @@ var init_schemas2 = __esm(() => {
|
|
|
17173
17580
|
inst.safeParseAsync = async (data, params) => safeParseAsync2(inst, data, params);
|
|
17174
17581
|
inst.spa = inst.safeParseAsync;
|
|
17175
17582
|
inst.encode = (data, params) => encode(inst, data, params);
|
|
17176
|
-
inst.decode = (data, params) =>
|
|
17583
|
+
inst.decode = (data, params) => decode2(inst, data, params);
|
|
17177
17584
|
inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
|
|
17178
17585
|
inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
|
|
17179
17586
|
inst.safeEncode = (data, params) => safeEncode(inst, data, params);
|
|
@@ -22950,324 +23357,6 @@ var init_antigravity_credential = __esm(() => {
|
|
|
22950
23357
|
init_antigravity_user();
|
|
22951
23358
|
});
|
|
22952
23359
|
|
|
22953
|
-
// src/providers/keychain.ts
|
|
22954
|
-
function syncRun(args, stdin) {
|
|
22955
|
-
try {
|
|
22956
|
-
const proc = Bun.spawnSync([SECURITY_BIN, ...args], {
|
|
22957
|
-
stdin: stdin === undefined ? "ignore" : new TextEncoder().encode(stdin),
|
|
22958
|
-
stdout: "pipe",
|
|
22959
|
-
stderr: "pipe",
|
|
22960
|
-
timeout: SPAWN_TIMEOUT_MS
|
|
22961
|
-
});
|
|
22962
|
-
return normalizeResult(proc.exitCode, proc.signalCode, decode2(proc.stdout), decode2(proc.stderr));
|
|
22963
|
-
} catch (err) {
|
|
22964
|
-
return { code: 1, stdout: "", stderr: err instanceof Error ? err.message : String(err) };
|
|
22965
|
-
}
|
|
22966
|
-
}
|
|
22967
|
-
async function asyncRun(args, stdin) {
|
|
22968
|
-
try {
|
|
22969
|
-
const proc = Bun.spawn([SECURITY_BIN, ...args], {
|
|
22970
|
-
stdin: stdin === undefined ? "ignore" : new TextEncoder().encode(stdin),
|
|
22971
|
-
stdout: "pipe",
|
|
22972
|
-
stderr: "pipe",
|
|
22973
|
-
timeout: SPAWN_TIMEOUT_MS
|
|
22974
|
-
});
|
|
22975
|
-
const [stdout, stderr, exitCode] = await Promise.all([
|
|
22976
|
-
new Response(proc.stdout).text(),
|
|
22977
|
-
new Response(proc.stderr).text(),
|
|
22978
|
-
proc.exited
|
|
22979
|
-
]);
|
|
22980
|
-
return normalizeResult(exitCode, proc.signalCode, stdout, stderr);
|
|
22981
|
-
} catch (err) {
|
|
22982
|
-
return { code: 1, stdout: "", stderr: err instanceof Error ? err.message : String(err) };
|
|
22983
|
-
}
|
|
22984
|
-
}
|
|
22985
|
-
function spawnAsyncRun(args, stdin) {
|
|
22986
|
-
try {
|
|
22987
|
-
const proc = Bun.spawn([SECURITY_BIN, ...args], {
|
|
22988
|
-
stdin: stdin === undefined ? "ignore" : new TextEncoder().encode(stdin),
|
|
22989
|
-
stdout: "pipe",
|
|
22990
|
-
stderr: "pipe"
|
|
22991
|
-
});
|
|
22992
|
-
const done = Promise.all([
|
|
22993
|
-
new Response(proc.stdout).text(),
|
|
22994
|
-
new Response(proc.stderr).text(),
|
|
22995
|
-
proc.exited
|
|
22996
|
-
]).then(([stdout, stderr, exitCode]) => normalizeResult(exitCode, proc.signalCode, stdout, stderr), (err) => ({
|
|
22997
|
-
code: 1,
|
|
22998
|
-
stdout: "",
|
|
22999
|
-
stderr: err instanceof Error ? err.message : String(err)
|
|
23000
|
-
}));
|
|
23001
|
-
return { done, pid: proc.pid };
|
|
23002
|
-
} catch (err) {
|
|
23003
|
-
return {
|
|
23004
|
-
done: Promise.resolve({
|
|
23005
|
-
code: 1,
|
|
23006
|
-
stdout: "",
|
|
23007
|
-
stderr: err instanceof Error ? err.message : String(err)
|
|
23008
|
-
}),
|
|
23009
|
-
pid: undefined
|
|
23010
|
-
};
|
|
23011
|
-
}
|
|
23012
|
-
}
|
|
23013
|
-
function decode2(buf) {
|
|
23014
|
-
return buf ? new TextDecoder().decode(buf) : "";
|
|
23015
|
-
}
|
|
23016
|
-
function normalizeResult(exitCode, signalCode, stdout, stderr) {
|
|
23017
|
-
if (typeof exitCode === "number")
|
|
23018
|
-
return { code: exitCode, stdout, stderr };
|
|
23019
|
-
const detail = signalCode ? `killed by ${signalCode}` : "terminated without an exit code";
|
|
23020
|
-
return { code: -1, stdout, stderr: stderr.trim() || `security ${detail}` };
|
|
23021
|
-
}
|
|
23022
|
-
function invalidateKeychainCache() {
|
|
23023
|
-
listMemo = null;
|
|
23024
|
-
valueMemo.clear();
|
|
23025
|
-
}
|
|
23026
|
-
function now() {
|
|
23027
|
-
return Date.now();
|
|
23028
|
-
}
|
|
23029
|
-
function isValidKeychainVarName(name) {
|
|
23030
|
-
return ENV_VAR_NAME.test(name);
|
|
23031
|
-
}
|
|
23032
|
-
function describeUnstorableValue(value) {
|
|
23033
|
-
if (value.length === 0)
|
|
23034
|
-
return "value is empty";
|
|
23035
|
-
if (CONTROL_CHARS.test(value)) {
|
|
23036
|
-
return "value contains control characters (tab/newline/etc), which the keychain read path cannot represent unambiguously";
|
|
23037
|
-
}
|
|
23038
|
-
return null;
|
|
23039
|
-
}
|
|
23040
|
-
function isKeychainSupported() {
|
|
23041
|
-
return deps.platform() === "darwin";
|
|
23042
|
-
}
|
|
23043
|
-
function keychainUnavailableReason() {
|
|
23044
|
-
if (!isKeychainSupported()) {
|
|
23045
|
-
return `the macOS Keychain is only available on macOS (this is ${deps.platform()})`;
|
|
23046
|
-
}
|
|
23047
|
-
return null;
|
|
23048
|
-
}
|
|
23049
|
-
function stripOneTrailingNewline(out) {
|
|
23050
|
-
return out.endsWith(`
|
|
23051
|
-
`) ? out.slice(0, -1) : out;
|
|
23052
|
-
}
|
|
23053
|
-
function keychainFileArgs() {
|
|
23054
|
-
const file = process.env.CLAUDISH_KEYCHAIN_FILE;
|
|
23055
|
-
return file ? [file] : [];
|
|
23056
|
-
}
|
|
23057
|
-
function findArgs(envVar) {
|
|
23058
|
-
return [
|
|
23059
|
-
"find-generic-password",
|
|
23060
|
-
"-s",
|
|
23061
|
-
KEYCHAIN_SERVICE,
|
|
23062
|
-
"-a",
|
|
23063
|
-
envVar,
|
|
23064
|
-
"-w",
|
|
23065
|
-
...keychainFileArgs()
|
|
23066
|
-
];
|
|
23067
|
-
}
|
|
23068
|
-
function interpretRead(envVar, res) {
|
|
23069
|
-
if (res.code === 0) {
|
|
23070
|
-
const value = stripOneTrailingNewline(res.stdout);
|
|
23071
|
-
return value.length > 0 ? value : null;
|
|
23072
|
-
}
|
|
23073
|
-
if (res.code === EXIT_ITEM_NOT_FOUND)
|
|
23074
|
-
return null;
|
|
23075
|
-
throw new KeychainError(`Keychain lookup for ${envVar} failed: ${res.stderr.trim() || `security exited ${res.code}`}`, res.code);
|
|
23076
|
-
}
|
|
23077
|
-
function readKeychainSecret(envVar) {
|
|
23078
|
-
if (!isKeychainSupported())
|
|
23079
|
-
return null;
|
|
23080
|
-
const cached = valueMemo.get(envVar);
|
|
23081
|
-
const at = now();
|
|
23082
|
-
if (cached && at - cached.at < MEMO_TTL_MS)
|
|
23083
|
-
return cached.value;
|
|
23084
|
-
const value = interpretRead(envVar, deps.run(findArgs(envVar)));
|
|
23085
|
-
valueMemo.set(envVar, { at, value });
|
|
23086
|
-
return value;
|
|
23087
|
-
}
|
|
23088
|
-
async function readKeychainSecretAsync(envVar) {
|
|
23089
|
-
if (!isKeychainSupported())
|
|
23090
|
-
return null;
|
|
23091
|
-
const cached = valueMemo.get(envVar);
|
|
23092
|
-
const at = now();
|
|
23093
|
-
if (cached && at - cached.at < MEMO_TTL_MS)
|
|
23094
|
-
return cached.value;
|
|
23095
|
-
const value = interpretRead(envVar, await deps.runAsync(findArgs(envVar)));
|
|
23096
|
-
valueMemo.set(envVar, { at, value });
|
|
23097
|
-
return value;
|
|
23098
|
-
}
|
|
23099
|
-
function genericPasswordArgs(query, withValue) {
|
|
23100
|
-
return [
|
|
23101
|
-
"find-generic-password",
|
|
23102
|
-
"-s",
|
|
23103
|
-
query.service,
|
|
23104
|
-
...query.account !== undefined ? ["-a", query.account] : [],
|
|
23105
|
-
...withValue ? ["-w"] : [],
|
|
23106
|
-
...query.keychainFile !== undefined ? [query.keychainFile] : keychainFileArgs()
|
|
23107
|
-
];
|
|
23108
|
-
}
|
|
23109
|
-
function interpretGenericPassword(res, withValue) {
|
|
23110
|
-
if (res.code === 0) {
|
|
23111
|
-
if (!withValue)
|
|
23112
|
-
return { kind: "found" };
|
|
23113
|
-
const value = stripOneTrailingNewline(res.stdout);
|
|
23114
|
-
return value.length > 0 ? { kind: "found", value } : { kind: "absent" };
|
|
23115
|
-
}
|
|
23116
|
-
if (res.code === EXIT_ITEM_NOT_FOUND)
|
|
23117
|
-
return { kind: "absent" };
|
|
23118
|
-
return {
|
|
23119
|
-
kind: "failed",
|
|
23120
|
-
code: res.code,
|
|
23121
|
-
error: res.stderr.trim() || `security exited ${res.code}`
|
|
23122
|
-
};
|
|
23123
|
-
}
|
|
23124
|
-
async function findGenericPasswordPresence(query) {
|
|
23125
|
-
if (!isKeychainSupported())
|
|
23126
|
-
return { kind: "absent" };
|
|
23127
|
-
const res = await deps.spawnAsync(genericPasswordArgs(query, false)).done;
|
|
23128
|
-
return interpretGenericPassword(res, false);
|
|
23129
|
-
}
|
|
23130
|
-
function startGenericPasswordRead(query) {
|
|
23131
|
-
if (!isKeychainSupported()) {
|
|
23132
|
-
return { done: Promise.resolve({ kind: "absent" }), pid: undefined };
|
|
23133
|
-
}
|
|
23134
|
-
const spawn = deps.spawnAsync(genericPasswordArgs(query, true));
|
|
23135
|
-
return { done: spawn.done.then((res) => interpretGenericPassword(res, true)), pid: spawn.pid };
|
|
23136
|
-
}
|
|
23137
|
-
function enumerateKeychainVars() {
|
|
23138
|
-
if (!isKeychainSupported())
|
|
23139
|
-
return { names: [], failed: false };
|
|
23140
|
-
const at = now();
|
|
23141
|
-
if (listMemo && at - listMemo.at < MEMO_TTL_MS)
|
|
23142
|
-
return listMemo.value;
|
|
23143
|
-
const res = deps.run(["dump-keychain", ...keychainFileArgs()]);
|
|
23144
|
-
const value = res.code === 0 ? { names: parseDumpAccounts(res.stdout), failed: false } : {
|
|
23145
|
-
names: [],
|
|
23146
|
-
failed: true,
|
|
23147
|
-
error: res.stderr.trim() || `security exited ${res.code}`
|
|
23148
|
-
};
|
|
23149
|
-
listMemo = { at, value };
|
|
23150
|
-
return value;
|
|
23151
|
-
}
|
|
23152
|
-
function listKeychainVars() {
|
|
23153
|
-
return enumerateKeychainVars().names;
|
|
23154
|
-
}
|
|
23155
|
-
function parseDumpAccounts(dump) {
|
|
23156
|
-
const found = new Set;
|
|
23157
|
-
for (const block of dump.split(/\nkeychain: /)) {
|
|
23158
|
-
if (!block.includes(SVCE_MATCH))
|
|
23159
|
-
continue;
|
|
23160
|
-
const m = block.match(ACCT_ATTR);
|
|
23161
|
-
if (m?.[1] && isValidKeychainVarName(m[1]))
|
|
23162
|
-
found.add(m[1]);
|
|
23163
|
-
}
|
|
23164
|
-
return Array.from(found).sort();
|
|
23165
|
-
}
|
|
23166
|
-
function lookupKeychainVar(envVar) {
|
|
23167
|
-
if (!isKeychainSupported())
|
|
23168
|
-
return { present: false, failed: false };
|
|
23169
|
-
const cached = valueMemo.get(envVar);
|
|
23170
|
-
if (cached && now() - cached.at < MEMO_TTL_MS && cached.value !== null) {
|
|
23171
|
-
return { present: true, failed: false };
|
|
23172
|
-
}
|
|
23173
|
-
const listed = enumerateKeychainVars();
|
|
23174
|
-
return { present: listed.names.includes(envVar), failed: listed.failed };
|
|
23175
|
-
}
|
|
23176
|
-
function toHex(value) {
|
|
23177
|
-
return Buffer.from(value, "utf8").toString("hex");
|
|
23178
|
-
}
|
|
23179
|
-
function quoteForStdin(value) {
|
|
23180
|
-
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
|
|
23181
|
-
}
|
|
23182
|
-
function writeKeychainSecret(envVar, value) {
|
|
23183
|
-
const unsupported = keychainUnavailableReason();
|
|
23184
|
-
if (unsupported)
|
|
23185
|
-
throw new KeychainError(`Cannot write ${envVar}: ${unsupported}`);
|
|
23186
|
-
if (!isValidKeychainVarName(envVar)) {
|
|
23187
|
-
throw new KeychainError(`Cannot write "${envVar}": not a valid environment variable name`);
|
|
23188
|
-
}
|
|
23189
|
-
const unstorable = describeUnstorableValue(value);
|
|
23190
|
-
if (unstorable)
|
|
23191
|
-
throw new KeychainError(`Cannot store ${envVar}: ${unstorable}`);
|
|
23192
|
-
invalidateKeychainCache();
|
|
23193
|
-
const cmd = [
|
|
23194
|
-
"add-generic-password",
|
|
23195
|
-
"-s",
|
|
23196
|
-
quoteForStdin(KEYCHAIN_SERVICE),
|
|
23197
|
-
"-a",
|
|
23198
|
-
quoteForStdin(envVar),
|
|
23199
|
-
"-l",
|
|
23200
|
-
quoteForStdin(`${KEYCHAIN_SERVICE}: ${envVar}`),
|
|
23201
|
-
"-D",
|
|
23202
|
-
quoteForStdin("application password"),
|
|
23203
|
-
"-j",
|
|
23204
|
-
quoteForStdin("Stored by claudish"),
|
|
23205
|
-
"-X",
|
|
23206
|
-
quoteForStdin(toHex(value)),
|
|
23207
|
-
"-U",
|
|
23208
|
-
"-T",
|
|
23209
|
-
quoteForStdin(SECURITY_BIN),
|
|
23210
|
-
...keychainFileArgs().map(quoteForStdin)
|
|
23211
|
-
].join(" ");
|
|
23212
|
-
const res = deps.run(["-i"], `${cmd}
|
|
23213
|
-
`);
|
|
23214
|
-
if (res.code !== 0) {
|
|
23215
|
-
throw new KeychainError(`Failed to store ${envVar} in the keychain: ${res.stderr.trim() || `security exited ${res.code}`}`, res.code);
|
|
23216
|
-
}
|
|
23217
|
-
invalidateKeychainCache();
|
|
23218
|
-
const readBack = readKeychainSecret(envVar);
|
|
23219
|
-
if (readBack !== value) {
|
|
23220
|
-
throw new KeychainError(`Keychain write for ${envVar} did not round-trip \u2014 the stored value differs from what was written. ` + "The item may exceed the keychain's size limit; nothing should be assumed saved.");
|
|
23221
|
-
}
|
|
23222
|
-
}
|
|
23223
|
-
function deleteKeychainSecret(envVar) {
|
|
23224
|
-
if (!isKeychainSupported())
|
|
23225
|
-
return false;
|
|
23226
|
-
invalidateKeychainCache();
|
|
23227
|
-
const res = deps.run([
|
|
23228
|
-
"delete-generic-password",
|
|
23229
|
-
"-s",
|
|
23230
|
-
KEYCHAIN_SERVICE,
|
|
23231
|
-
"-a",
|
|
23232
|
-
envVar,
|
|
23233
|
-
...keychainFileArgs()
|
|
23234
|
-
]);
|
|
23235
|
-
invalidateKeychainCache();
|
|
23236
|
-
if (res.code === 0)
|
|
23237
|
-
return true;
|
|
23238
|
-
if (res.code === EXIT_ITEM_NOT_FOUND)
|
|
23239
|
-
return false;
|
|
23240
|
-
throw new KeychainError(`Failed to delete ${envVar} from the keychain: ${res.stderr.trim() || `security exited ${res.code}`}`, res.code);
|
|
23241
|
-
}
|
|
23242
|
-
function valueTail2(value) {
|
|
23243
|
-
if (value.length <= 6)
|
|
23244
|
-
return "\u2022\u2022\u2022\u2022";
|
|
23245
|
-
return `\u2022\u2022\u2022\u2022${value.slice(-4)}`;
|
|
23246
|
-
}
|
|
23247
|
-
var KEYCHAIN_SERVICE = "claudish", SECURITY_BIN = "/usr/bin/security", EXIT_ITEM_NOT_FOUND = 44, MEMO_TTL_MS = 3000, SPAWN_TIMEOUT_MS = 1e4, KeychainError, defaultDeps2, deps, listMemo = null, valueMemo, CONTROL_CHARS, ENV_VAR_NAME, ACCT_ATTR, SVCE_MATCH;
|
|
23248
|
-
var init_keychain = __esm(() => {
|
|
23249
|
-
KeychainError = class KeychainError extends Error {
|
|
23250
|
-
exitCode;
|
|
23251
|
-
constructor(message, exitCode) {
|
|
23252
|
-
super(message);
|
|
23253
|
-
this.exitCode = exitCode;
|
|
23254
|
-
this.name = "KeychainError";
|
|
23255
|
-
}
|
|
23256
|
-
};
|
|
23257
|
-
defaultDeps2 = {
|
|
23258
|
-
platform: () => process.platform,
|
|
23259
|
-
run: syncRun,
|
|
23260
|
-
runAsync: asyncRun,
|
|
23261
|
-
spawnAsync: spawnAsyncRun
|
|
23262
|
-
};
|
|
23263
|
-
deps = defaultDeps2;
|
|
23264
|
-
valueMemo = new Map;
|
|
23265
|
-
CONTROL_CHARS = /[\u0000-\u001F\u007F]/;
|
|
23266
|
-
ENV_VAR_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
23267
|
-
ACCT_ATTR = /"acct"<blob>=(?:0x[0-9A-Fa-f]*\s+)?"([^"]*)"/;
|
|
23268
|
-
SVCE_MATCH = `"svce"<blob>="${KEYCHAIN_SERVICE}"`;
|
|
23269
|
-
});
|
|
23270
|
-
|
|
23271
23360
|
// src/auth/credentials/local-api-key.ts
|
|
23272
23361
|
function resolveLocalApiKey(q) {
|
|
23273
23362
|
return realValue(process.env[q.envVar]) || (q.aliases ?? []).map((a) => realValue(process.env[a])).find((v) => !!v) || realValue(getApiKey(q.envVar));
|
|
@@ -35488,6 +35577,9 @@ function effectiveBaseUrl(registryBaseUrl, definitionBaseUrl, resolvedBaseUrl) {
|
|
|
35488
35577
|
}
|
|
35489
35578
|
return { baseUrl: resolvedBaseUrl.replace(/\/+$/, ""), overridden: true };
|
|
35490
35579
|
}
|
|
35580
|
+
function requestBaseUrl(connection, api) {
|
|
35581
|
+
return connection.provider === "meta-muse-code" ? `${MUSE_CODE_BASE_URL}/v1` : connectionBaseUrl(connection, api);
|
|
35582
|
+
}
|
|
35491
35583
|
function describeConnectionWire(connection) {
|
|
35492
35584
|
const where = `${connection.route.routeId}/${connection.route.routeProfileId} \xB7 ${connection.externalModelId}`;
|
|
35493
35585
|
const { wire } = connection;
|
|
@@ -35497,7 +35589,7 @@ function describeConnectionWire(connection) {
|
|
|
35497
35589
|
const apis = Object.keys(connection.profile.apis).join(", ") || "none";
|
|
35498
35590
|
return `${where}: wire unknown \u2014 tries ${apis} in turn`;
|
|
35499
35591
|
}
|
|
35500
|
-
const base =
|
|
35592
|
+
const base = requestBaseUrl(connection, wire.api);
|
|
35501
35593
|
const url = base ? wireRequestUrl(base, wire.api, connection.externalModelId) : "no base URL";
|
|
35502
35594
|
const status = (value) => typeof value === "string" ? value : value.status;
|
|
35503
35595
|
const parts = [`${wire.api} ${url}`, `limit ${status(wire.tokenParam)}`];
|
|
@@ -35666,11 +35758,14 @@ function tryInTurn(ctx, definitionName, connection, why) {
|
|
|
35666
35758
|
};
|
|
35667
35759
|
}
|
|
35668
35760
|
function buildKnownWireHandler(ctx, definitionName, connection, wire) {
|
|
35669
|
-
const registryBase =
|
|
35761
|
+
const registryBase = requestBaseUrl(connection, wire.api);
|
|
35670
35762
|
if (!registryBase)
|
|
35671
35763
|
return null;
|
|
35672
35764
|
const definition = getProviderByName(definitionName);
|
|
35673
|
-
const { baseUrl, overridden } = effectiveBaseUrl(registryBase, definition?.baseUrl, ctx.provider.baseUrl);
|
|
35765
|
+
const { baseUrl, overridden } = definitionName === "meta-muse-code" ? { baseUrl: registryBase, overridden: false } : effectiveBaseUrl(registryBase, definition?.baseUrl, ctx.provider.baseUrl);
|
|
35766
|
+
if (definitionName === "meta-muse-code" && ctx.provider.baseUrl && ctx.provider.baseUrl !== definition?.baseUrl) {
|
|
35767
|
+
log(`[Wire] meta-muse-code: user base URL ignored \u2192 ${baseUrl}`);
|
|
35768
|
+
}
|
|
35674
35769
|
const url = wireRequestUrl(baseUrl, wire.api, connection.externalModelId);
|
|
35675
35770
|
if (overridden)
|
|
35676
35771
|
log(`[Wire] ${definitionName}: base URL overridden by user config \u2192 ${baseUrl}`);
|
|
@@ -35698,6 +35793,7 @@ var init_wire_handler = __esm(() => {
|
|
|
35698
35793
|
init_catalog_client();
|
|
35699
35794
|
init_connection_resolver();
|
|
35700
35795
|
init_connection_wire();
|
|
35796
|
+
init_muse_mint();
|
|
35701
35797
|
init_provider_definitions();
|
|
35702
35798
|
init_anthropic_compat();
|
|
35703
35799
|
init_gemini_apikey();
|
|
@@ -50334,12 +50430,15 @@ function projectRecommendations(recommendations, catalog, richModels = [], now =
|
|
|
50334
50430
|
const priority = (rankByTier.get(recommended.tier) ?? 0) + 1;
|
|
50335
50431
|
rankByTier.set(recommended.tier, priority);
|
|
50336
50432
|
const rich = richById.get(recommended.modelId);
|
|
50433
|
+
const nativeProvider = nativeProviderForVendor(rich?.provider ?? model.provider ?? "");
|
|
50434
|
+
const nativeRouteAvailable = Boolean(nativeProvider && model.aggregators?.some((connection) => connection.routeStatus === "mapped" && catalogRouteMatchesProvider(connection.route, nativeProvider)));
|
|
50337
50435
|
const subscription = recommended.tier === "subscription" ? subscriptionRouteFor(recommended, model, catalog.plans) : undefined;
|
|
50338
50436
|
models.push({
|
|
50339
50437
|
id: recommended.modelId,
|
|
50340
50438
|
name: rich?.displayName ?? model.displayName ?? recommended.modelId,
|
|
50341
50439
|
description: rich?.description ?? "",
|
|
50342
50440
|
provider: rich?.provider ?? model.provider ?? "",
|
|
50441
|
+
nativeRouteAvailable,
|
|
50343
50442
|
recommendationTier: recommended.tier,
|
|
50344
50443
|
priority,
|
|
50345
50444
|
pricing: {
|
|
@@ -50546,7 +50645,7 @@ function uniqueRecommendedModels(entries) {
|
|
|
50546
50645
|
}
|
|
50547
50646
|
function collectRoutingPrefixes(group, getNativePrefix) {
|
|
50548
50647
|
const slug = (group.primary.provider || "").toLowerCase();
|
|
50549
|
-
const native = getNativePrefix(slug);
|
|
50648
|
+
const native = group.primary.nativeRouteAvailable === false ? null : getNativePrefix(slug);
|
|
50550
50649
|
const seen = new Set;
|
|
50551
50650
|
const out = [];
|
|
50552
50651
|
if (native) {
|
|
@@ -50791,13 +50890,14 @@ function getAvailableModels() {
|
|
|
50791
50890
|
_cachedModelIds = result;
|
|
50792
50891
|
return result;
|
|
50793
50892
|
}
|
|
50794
|
-
var RECOMMENDATION_SECTIONS, RECOMMENDATION_TIER_INDEX, _cachedModelInfo = null, _cachedModelIds = null, _cachedRecommendedModels = null, FIREBASE_BASE_URL = "https://us-central1-claudish-6da10.cloudfunctions.net/queryModels", FIREBASE_RECOMMENDED_URL, RECOMMENDED_PROJECTION_VERSION =
|
|
50893
|
+
var RECOMMENDATION_SECTIONS, RECOMMENDATION_TIER_INDEX, _cachedModelInfo = null, _cachedModelIds = null, _cachedRecommendedModels = null, FIREBASE_BASE_URL = "https://us-central1-claudish-6da10.cloudfunctions.net/queryModels", FIREBASE_RECOMMENDED_URL, RECOMMENDED_PROJECTION_VERSION = 2, RECOMMENDED_MODELS_CACHE_PATH, RECOMMENDED_FETCH_TIMEOUT_MS = 5000, SEARCH_FETCH_TIMEOUT_MS = 1e4, RECOMMENDED_ROUTE_TIER_ORDER;
|
|
50795
50894
|
var init_model_loader = __esm(() => {
|
|
50796
50895
|
init_all_models_cache();
|
|
50797
50896
|
init_auto_route();
|
|
50798
50897
|
init_cache_ttl();
|
|
50799
50898
|
init_catalog_client();
|
|
50800
50899
|
init_catalog_route_bindings();
|
|
50900
|
+
init_route_candidates();
|
|
50801
50901
|
RECOMMENDATION_SECTIONS = [
|
|
50802
50902
|
{ recommendationTier: "flagship", title: "Flagship", quickPickEligible: true },
|
|
50803
50903
|
{
|
|
@@ -67970,6 +68070,9 @@ ${h("SUBCOMMANDS")}
|
|
|
67970
68070
|
${green("claudish providers")} ${yellow("[--json]")} Show provider credential status (no key material)
|
|
67971
68071
|
${green("claudish quota")} ${yellow("[provider]")} Show remaining quota/usage (alias: usage)
|
|
67972
68072
|
${green("claudish serve")} ${yellow("--port <n> --models <p>")} Run the Claude Desktop redirect gateway
|
|
68073
|
+
${green("claudish subscription models antigravity")} ${yellow("--raw --json")}
|
|
68074
|
+
Print the raw Antigravity fetchAvailableModels
|
|
68075
|
+
${dim("body as one JSON line (for models-index)")}
|
|
67973
68076
|
${green("claudish update")} Check for updates and install the latest version
|
|
67974
68077
|
|
|
67975
68078
|
${bold("Profiles:")}
|
|
@@ -69380,6 +69483,7 @@ var init_pane_launch = __esm(() => {
|
|
|
69380
69483
|
"serve",
|
|
69381
69484
|
"providers",
|
|
69382
69485
|
"keychain",
|
|
69486
|
+
"subscription",
|
|
69383
69487
|
"hooks",
|
|
69384
69488
|
"team",
|
|
69385
69489
|
"login",
|
|
@@ -81093,6 +81197,364 @@ var init_keychain_command = __esm(() => {
|
|
|
81093
81197
|
VALUE_FLAGS = new Set(["--config", "--from", "--only"]);
|
|
81094
81198
|
});
|
|
81095
81199
|
|
|
81200
|
+
// src/subscription-models-command.ts
|
|
81201
|
+
var exports_subscription_models_command = {};
|
|
81202
|
+
__export(exports_subscription_models_command, {
|
|
81203
|
+
EXIT: () => EXIT,
|
|
81204
|
+
FAILURE_CODES: () => FAILURE_CODES,
|
|
81205
|
+
INTERNAL_ERROR_MESSAGE: () => INTERNAL_ERROR_MESSAGE,
|
|
81206
|
+
SECRET_GUARD_MESSAGE: () => SECRET_GUARD_MESSAGE,
|
|
81207
|
+
SUBSCRIPTION_MODELS_USAGE: () => SUBSCRIPTION_MODELS_USAGE,
|
|
81208
|
+
SUBSCRIPTION_MODEL_LIST_SCHEMA: () => SUBSCRIPTION_MODEL_LIST_SCHEMA,
|
|
81209
|
+
defaultSubscriptionModelsDeps: () => defaultSubscriptionModelsDeps,
|
|
81210
|
+
exitCodeFor: () => exitCodeFor,
|
|
81211
|
+
parseSubscriptionModelsArgs: () => parseSubscriptionModelsArgs,
|
|
81212
|
+
reportSubscriptionInternalError: () => reportSubscriptionInternalError,
|
|
81213
|
+
runAntigravityRawModelList: () => runAntigravityRawModelList,
|
|
81214
|
+
subscriptionModelsCommand: () => subscriptionModelsCommand
|
|
81215
|
+
});
|
|
81216
|
+
function exitCodeFor(failure) {
|
|
81217
|
+
if (failure.class === "internal")
|
|
81218
|
+
return failure.code === "usage" ? EXIT.usage : EXIT.internal;
|
|
81219
|
+
return EXIT[failure.class];
|
|
81220
|
+
}
|
|
81221
|
+
function defaultSubscriptionModelsDeps() {
|
|
81222
|
+
return {
|
|
81223
|
+
platform: () => process.platform,
|
|
81224
|
+
readStore: readAntigravityStoreClassified,
|
|
81225
|
+
tokenDeps: defaultAntigravityTokenDeps,
|
|
81226
|
+
now: () => Date.now(),
|
|
81227
|
+
httpTimeoutMs: 30000,
|
|
81228
|
+
keychainDeadlineMs: 1e4,
|
|
81229
|
+
writeStdout: (line) => new Promise((resolve, reject) => {
|
|
81230
|
+
process.stdout.write(line, (err) => err ? reject(err) : resolve());
|
|
81231
|
+
}),
|
|
81232
|
+
writeStderr: (line) => {
|
|
81233
|
+
process.stderr.write(line);
|
|
81234
|
+
}
|
|
81235
|
+
};
|
|
81236
|
+
}
|
|
81237
|
+
function parseSubscriptionModelsArgs(argv) {
|
|
81238
|
+
const positionals = argv.filter((a) => !a.startsWith("-"));
|
|
81239
|
+
const flags = argv.filter((a) => a.startsWith("-"));
|
|
81240
|
+
const positionalsOk = positionals.length === 2 && positionals[0] === "models" && positionals[1] === "antigravity";
|
|
81241
|
+
const flagsOk = flags.length === 2 && flags.includes("--raw") && flags.includes("--json");
|
|
81242
|
+
return positionalsOk && flagsOk ? { ok: true, provider: "antigravity" } : { ok: false };
|
|
81243
|
+
}
|
|
81244
|
+
function addSecret(secrets, value) {
|
|
81245
|
+
if (typeof value === "string" && value.length > 0)
|
|
81246
|
+
secrets.values.add(value);
|
|
81247
|
+
}
|
|
81248
|
+
function buildEnvelope(facts, failure, body) {
|
|
81249
|
+
return {
|
|
81250
|
+
schema: SUBSCRIPTION_MODEL_LIST_SCHEMA,
|
|
81251
|
+
...facts.provider !== undefined ? { provider: facts.provider } : {},
|
|
81252
|
+
claudishVersion: VERSION,
|
|
81253
|
+
...facts.fetchedAt !== undefined ? { fetchedAt: facts.fetchedAt } : {},
|
|
81254
|
+
...facts.sourceUrl !== undefined ? { sourceUrl: facts.sourceUrl } : {},
|
|
81255
|
+
...facts.clientVersion !== undefined ? { clientVersion: facts.clientVersion } : {},
|
|
81256
|
+
...facts.clientVersionSource !== undefined ? { clientVersionSource: facts.clientVersionSource } : {},
|
|
81257
|
+
tokenRefreshed: facts.tokenRefreshed,
|
|
81258
|
+
...facts.httpStatus !== undefined ? { httpStatus: facts.httpStatus } : {},
|
|
81259
|
+
...failure ? { failure } : {},
|
|
81260
|
+
...body !== undefined ? { body } : {}
|
|
81261
|
+
};
|
|
81262
|
+
}
|
|
81263
|
+
function failureOf2(cls, code, httpStatus) {
|
|
81264
|
+
return { class: cls, code, ...httpStatus !== undefined ? { httpStatus } : {} };
|
|
81265
|
+
}
|
|
81266
|
+
function stripUserinfo(url) {
|
|
81267
|
+
try {
|
|
81268
|
+
const parsed = new URL(url);
|
|
81269
|
+
parsed.username = "";
|
|
81270
|
+
parsed.password = "";
|
|
81271
|
+
return parsed.toString();
|
|
81272
|
+
} catch {
|
|
81273
|
+
return url.replace(/^([a-z][a-z0-9+.-]*:\/\/)[^@/]*@/i, "$1");
|
|
81274
|
+
}
|
|
81275
|
+
}
|
|
81276
|
+
function storeReadFailure(read) {
|
|
81277
|
+
switch (read.kind) {
|
|
81278
|
+
case "absent":
|
|
81279
|
+
return failureOf2("credential_missing", "keychain_item_absent");
|
|
81280
|
+
case "locked":
|
|
81281
|
+
return failureOf2("keychain_locked", "keychain_locked");
|
|
81282
|
+
case "timeout":
|
|
81283
|
+
return failureOf2("keychain_locked", "keychain_read_timeout");
|
|
81284
|
+
default:
|
|
81285
|
+
return failureOf2("keychain_locked", "keychain_read_failed");
|
|
81286
|
+
}
|
|
81287
|
+
}
|
|
81288
|
+
function tokenFailure(refreshCalled, outcome) {
|
|
81289
|
+
if (!refreshCalled)
|
|
81290
|
+
return failureOf2("credential_missing", "token_unparseable");
|
|
81291
|
+
switch (outcome?.kind) {
|
|
81292
|
+
case "not-installed":
|
|
81293
|
+
return failureOf2("mint_failed", "agy_missing");
|
|
81294
|
+
case "timeout":
|
|
81295
|
+
return failureOf2("mint_failed", "agy_refresh_timeout");
|
|
81296
|
+
case "ran":
|
|
81297
|
+
return failureOf2("mint_failed", "agy_refresh_no_valid_token");
|
|
81298
|
+
default:
|
|
81299
|
+
return failureOf2("mint_failed", "agy_refresh_failed");
|
|
81300
|
+
}
|
|
81301
|
+
}
|
|
81302
|
+
function loadCodeAssistFailure(err) {
|
|
81303
|
+
const fields = err ?? {};
|
|
81304
|
+
const status = typeof fields.upstreamStatus === "number" ? fields.upstreamStatus : undefined;
|
|
81305
|
+
if (status !== undefined) {
|
|
81306
|
+
if (status === 429)
|
|
81307
|
+
return failureOf2("network", "load_code_assist_429", status);
|
|
81308
|
+
if (status >= 500 && status <= 599)
|
|
81309
|
+
return failureOf2("network", "load_code_assist_5xx", status);
|
|
81310
|
+
return failureOf2("mint_failed", "load_code_assist_4xx", status);
|
|
81311
|
+
}
|
|
81312
|
+
if (err instanceof SyntaxError)
|
|
81313
|
+
return failureOf2("mint_failed", "load_code_assist_bad_body");
|
|
81314
|
+
if (fields.terminal === true)
|
|
81315
|
+
return failureOf2("mint_failed", "load_code_assist_no_project");
|
|
81316
|
+
return failureOf2("network", "load_code_assist_network_error");
|
|
81317
|
+
}
|
|
81318
|
+
function listFailure(value, status) {
|
|
81319
|
+
const models = value !== null && typeof value === "object" && !Array.isArray(value) ? value.models : undefined;
|
|
81320
|
+
if (models === null || typeof models !== "object" || Array.isArray(models)) {
|
|
81321
|
+
return failureOf2("list_incomplete", "models_absent", status);
|
|
81322
|
+
}
|
|
81323
|
+
if (Object.keys(models).length === 0) {
|
|
81324
|
+
return failureOf2("list_incomplete", "models_empty", status);
|
|
81325
|
+
}
|
|
81326
|
+
return null;
|
|
81327
|
+
}
|
|
81328
|
+
async function raceTimeout(work, ms) {
|
|
81329
|
+
let timer;
|
|
81330
|
+
const timedOut = new Promise((resolve) => {
|
|
81331
|
+
timer = setTimeout(() => resolve(TIMED_OUT), ms);
|
|
81332
|
+
});
|
|
81333
|
+
work.catch(() => {});
|
|
81334
|
+
try {
|
|
81335
|
+
return await Promise.race([work, timedOut]);
|
|
81336
|
+
} finally {
|
|
81337
|
+
if (timer)
|
|
81338
|
+
clearTimeout(timer);
|
|
81339
|
+
}
|
|
81340
|
+
}
|
|
81341
|
+
function fail(facts, failure) {
|
|
81342
|
+
return { envelope: buildEnvelope(facts, failure), exitCode: exitCodeFor(failure) };
|
|
81343
|
+
}
|
|
81344
|
+
function lineOf(envelope) {
|
|
81345
|
+
return `${JSON.stringify(envelope)}
|
|
81346
|
+
`;
|
|
81347
|
+
}
|
|
81348
|
+
function containsSecret(secrets, ...texts) {
|
|
81349
|
+
for (const secret of secrets.values) {
|
|
81350
|
+
if (texts.some((text) => text?.includes(secret)))
|
|
81351
|
+
return true;
|
|
81352
|
+
}
|
|
81353
|
+
return false;
|
|
81354
|
+
}
|
|
81355
|
+
function safeStderr(deps, line) {
|
|
81356
|
+
try {
|
|
81357
|
+
deps.writeStderr(line);
|
|
81358
|
+
} catch {}
|
|
81359
|
+
}
|
|
81360
|
+
async function writeInternalFailure(deps, facts, code, stderrLine, secrets) {
|
|
81361
|
+
const failure = failureOf2("internal", code);
|
|
81362
|
+
safeStderr(deps, `${stderrLine}
|
|
81363
|
+
`);
|
|
81364
|
+
const line = lineOf(buildEnvelope(facts, failure));
|
|
81365
|
+
if (!secrets || !containsSecret(secrets, line)) {
|
|
81366
|
+
try {
|
|
81367
|
+
await deps.writeStdout(line);
|
|
81368
|
+
} catch {}
|
|
81369
|
+
}
|
|
81370
|
+
return exitCodeFor(failure);
|
|
81371
|
+
}
|
|
81372
|
+
async function reportSubscriptionInternalError(deps) {
|
|
81373
|
+
let resolved;
|
|
81374
|
+
try {
|
|
81375
|
+
resolved = deps ?? defaultSubscriptionModelsDeps();
|
|
81376
|
+
} catch {
|
|
81377
|
+
process.stderr.write(`${INTERNAL_ERROR_MESSAGE}
|
|
81378
|
+
`);
|
|
81379
|
+
return EXIT.internal;
|
|
81380
|
+
}
|
|
81381
|
+
return writeInternalFailure(resolved, { tokenRefreshed: false }, "internal_error", INTERNAL_ERROR_MESSAGE);
|
|
81382
|
+
}
|
|
81383
|
+
async function obtainAccessToken(deps, facts, secrets, preRaw) {
|
|
81384
|
+
const base = deps.tokenDeps();
|
|
81385
|
+
let firstRead = true;
|
|
81386
|
+
let refreshCalled = false;
|
|
81387
|
+
let refreshOutcome = null;
|
|
81388
|
+
const laterReads = [];
|
|
81389
|
+
const observed = {
|
|
81390
|
+
...base,
|
|
81391
|
+
readStore: () => {
|
|
81392
|
+
if (firstRead) {
|
|
81393
|
+
firstRead = false;
|
|
81394
|
+
return preRaw;
|
|
81395
|
+
}
|
|
81396
|
+
const raw = base.readStore();
|
|
81397
|
+
if (raw)
|
|
81398
|
+
laterReads.push(raw);
|
|
81399
|
+
return raw;
|
|
81400
|
+
},
|
|
81401
|
+
runAgyRefresh: () => {
|
|
81402
|
+
refreshCalled = true;
|
|
81403
|
+
facts.tokenRefreshed = true;
|
|
81404
|
+
refreshOutcome = base.runAgyRefresh();
|
|
81405
|
+
return refreshOutcome;
|
|
81406
|
+
}
|
|
81407
|
+
};
|
|
81408
|
+
let accessToken;
|
|
81409
|
+
try {
|
|
81410
|
+
accessToken = await getValidAntigravityAccessToken(observed);
|
|
81411
|
+
} catch {
|
|
81412
|
+
return { ok: false, result: fail(facts, tokenFailure(refreshCalled, refreshOutcome)) };
|
|
81413
|
+
}
|
|
81414
|
+
addSecret(secrets, accessToken);
|
|
81415
|
+
for (const raw of [preRaw, ...laterReads]) {
|
|
81416
|
+
addSecret(secrets, raw);
|
|
81417
|
+
addSecret(secrets, readSharedAntigravityToken({ ...base, readStore: () => raw })?.refresh_token);
|
|
81418
|
+
}
|
|
81419
|
+
return { ok: true, accessToken };
|
|
81420
|
+
}
|
|
81421
|
+
function classifyAvailableModels(facts, raw, timedOut) {
|
|
81422
|
+
facts.sourceUrl = stripUserinfo(raw.url);
|
|
81423
|
+
facts.clientVersion = raw.clientVersion;
|
|
81424
|
+
facts.clientVersionSource = raw.clientVersionSource;
|
|
81425
|
+
const networkCode = timedOut ? "fetch_available_models_timeout" : "fetch_available_models_network_error";
|
|
81426
|
+
if (raw.kind === "unreachable")
|
|
81427
|
+
return fail(facts, failureOf2("network", networkCode));
|
|
81428
|
+
facts.fetchedAt = raw.fetchedAt;
|
|
81429
|
+
facts.httpStatus = raw.status;
|
|
81430
|
+
if (raw.status < 200 || raw.status >= 300) {
|
|
81431
|
+
return { envelope: buildEnvelope(facts), exitCode: EXIT.ok };
|
|
81432
|
+
}
|
|
81433
|
+
switch (raw.body.kind) {
|
|
81434
|
+
case "json": {
|
|
81435
|
+
const incomplete = listFailure(raw.body.value, raw.status);
|
|
81436
|
+
if (incomplete)
|
|
81437
|
+
return fail(facts, incomplete);
|
|
81438
|
+
return {
|
|
81439
|
+
envelope: buildEnvelope(facts, undefined, raw.body.text),
|
|
81440
|
+
exitCode: EXIT.ok,
|
|
81441
|
+
bodyText: raw.body.text
|
|
81442
|
+
};
|
|
81443
|
+
}
|
|
81444
|
+
case "not-json":
|
|
81445
|
+
return fail(facts, failureOf2("list_incomplete", "body_not_json", raw.status));
|
|
81446
|
+
default:
|
|
81447
|
+
return fail(facts, failureOf2("network", networkCode, raw.status));
|
|
81448
|
+
}
|
|
81449
|
+
}
|
|
81450
|
+
async function determine(deps, secrets, facts) {
|
|
81451
|
+
if (deps.platform() !== "darwin") {
|
|
81452
|
+
return fail(facts, failureOf2("credential_missing", "platform_unsupported"));
|
|
81453
|
+
}
|
|
81454
|
+
const read = await deps.readStore(deps.keychainDeadlineMs);
|
|
81455
|
+
if (read.kind !== "present")
|
|
81456
|
+
return fail(facts, storeReadFailure(read));
|
|
81457
|
+
addSecret(secrets, read.raw);
|
|
81458
|
+
const token = await obtainAccessToken(deps, facts, secrets, read.raw);
|
|
81459
|
+
if (!token.ok)
|
|
81460
|
+
return token.result;
|
|
81461
|
+
const version = resolveAntigravityClientVersion();
|
|
81462
|
+
facts.clientVersion = version.version;
|
|
81463
|
+
facts.clientVersionSource = version.source;
|
|
81464
|
+
let projectId;
|
|
81465
|
+
try {
|
|
81466
|
+
const setup = await raceTimeout(setupAntigravityUser(token.accessToken), deps.httpTimeoutMs);
|
|
81467
|
+
if (setup === TIMED_OUT)
|
|
81468
|
+
return fail(facts, failureOf2("network", "load_code_assist_timeout"));
|
|
81469
|
+
projectId = setup.projectId;
|
|
81470
|
+
} catch (err) {
|
|
81471
|
+
return fail(facts, loadCodeAssistFailure(err));
|
|
81472
|
+
}
|
|
81473
|
+
addSecret(secrets, projectId);
|
|
81474
|
+
const controller = new AbortController;
|
|
81475
|
+
const timer = setTimeout(() => controller.abort(), deps.httpTimeoutMs);
|
|
81476
|
+
try {
|
|
81477
|
+
const raw = await fetchAntigravityAvailableModelsRaw(token.accessToken, projectId, {
|
|
81478
|
+
signal: controller.signal,
|
|
81479
|
+
now: deps.now
|
|
81480
|
+
});
|
|
81481
|
+
return classifyAvailableModels(facts, raw, controller.signal.aborted);
|
|
81482
|
+
} finally {
|
|
81483
|
+
clearTimeout(timer);
|
|
81484
|
+
}
|
|
81485
|
+
}
|
|
81486
|
+
async function runAntigravityRawModelList(deps) {
|
|
81487
|
+
const secrets = { values: new Set };
|
|
81488
|
+
const facts = { provider: "antigravity", tokenRefreshed: false };
|
|
81489
|
+
let line;
|
|
81490
|
+
let exitCode;
|
|
81491
|
+
let bodyText;
|
|
81492
|
+
try {
|
|
81493
|
+
const result = await determine(deps, secrets, facts);
|
|
81494
|
+
line = lineOf(result.envelope);
|
|
81495
|
+
exitCode = result.exitCode;
|
|
81496
|
+
bodyText = result.bodyText;
|
|
81497
|
+
} catch {
|
|
81498
|
+
return writeInternalFailure(deps, { provider: facts.provider, tokenRefreshed: facts.tokenRefreshed }, "internal_error", INTERNAL_ERROR_MESSAGE, secrets);
|
|
81499
|
+
}
|
|
81500
|
+
if (containsSecret(secrets, line, bodyText)) {
|
|
81501
|
+
return writeInternalFailure(deps, facts, "secret_guard", SECRET_GUARD_MESSAGE, secrets);
|
|
81502
|
+
}
|
|
81503
|
+
try {
|
|
81504
|
+
await deps.writeStdout(line);
|
|
81505
|
+
} catch {
|
|
81506
|
+
safeStderr(deps, `${INTERNAL_ERROR_MESSAGE}
|
|
81507
|
+
`);
|
|
81508
|
+
return EXIT.internal;
|
|
81509
|
+
}
|
|
81510
|
+
return exitCode;
|
|
81511
|
+
}
|
|
81512
|
+
async function subscriptionModelsCommand(argv, deps = defaultSubscriptionModelsDeps()) {
|
|
81513
|
+
if (!parseSubscriptionModelsArgs(argv).ok) {
|
|
81514
|
+
return writeInternalFailure(deps, { tokenRefreshed: false }, "usage", SUBSCRIPTION_MODELS_USAGE);
|
|
81515
|
+
}
|
|
81516
|
+
return runAntigravityRawModelList(deps);
|
|
81517
|
+
}
|
|
81518
|
+
var SUBSCRIPTION_MODEL_LIST_SCHEMA = "claudish.subscription-model-list.v1", FAILURE_CODES, EXIT, SUBSCRIPTION_MODELS_USAGE = "usage: claudish subscription models antigravity --raw --json", SECRET_GUARD_MESSAGE = "[claudish subscription] refused: output contained a credential value", INTERNAL_ERROR_MESSAGE = "[claudish subscription] internal error", TIMED_OUT;
|
|
81519
|
+
var init_subscription_models_command = __esm(() => {
|
|
81520
|
+
init_antigravity_token();
|
|
81521
|
+
init_antigravity_user();
|
|
81522
|
+
FAILURE_CODES = {
|
|
81523
|
+
credential_missing: ["platform_unsupported", "keychain_item_absent", "token_unparseable"],
|
|
81524
|
+
keychain_locked: ["keychain_locked", "keychain_read_timeout", "keychain_read_failed"],
|
|
81525
|
+
mint_failed: [
|
|
81526
|
+
"agy_missing",
|
|
81527
|
+
"agy_refresh_failed",
|
|
81528
|
+
"agy_refresh_timeout",
|
|
81529
|
+
"agy_refresh_no_valid_token",
|
|
81530
|
+
"load_code_assist_4xx",
|
|
81531
|
+
"load_code_assist_no_project",
|
|
81532
|
+
"load_code_assist_bad_body"
|
|
81533
|
+
],
|
|
81534
|
+
network: [
|
|
81535
|
+
"load_code_assist_network_error",
|
|
81536
|
+
"load_code_assist_429",
|
|
81537
|
+
"load_code_assist_5xx",
|
|
81538
|
+
"load_code_assist_timeout",
|
|
81539
|
+
"fetch_available_models_network_error",
|
|
81540
|
+
"fetch_available_models_timeout"
|
|
81541
|
+
],
|
|
81542
|
+
list_incomplete: ["models_absent", "models_empty", "body_not_json"],
|
|
81543
|
+
internal: ["usage", "secret_guard", "internal_error"]
|
|
81544
|
+
};
|
|
81545
|
+
EXIT = {
|
|
81546
|
+
ok: 0,
|
|
81547
|
+
internal: 1,
|
|
81548
|
+
usage: 2,
|
|
81549
|
+
credential_missing: 3,
|
|
81550
|
+
keychain_locked: 4,
|
|
81551
|
+
mint_failed: 5,
|
|
81552
|
+
network: 6,
|
|
81553
|
+
list_incomplete: 7
|
|
81554
|
+
};
|
|
81555
|
+
TIMED_OUT = Symbol("timed-out");
|
|
81556
|
+
});
|
|
81557
|
+
|
|
81096
81558
|
// src/auth/antigravity-oauth.ts
|
|
81097
81559
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
81098
81560
|
import { existsSync as existsSync39, unlinkSync as unlinkSync9 } from "fs";
|
|
@@ -89489,7 +89951,7 @@ class InteractiveDriver {
|
|
|
89489
89951
|
try {
|
|
89490
89952
|
this.binding.fireEnd(outcome);
|
|
89491
89953
|
} catch {}
|
|
89492
|
-
await
|
|
89954
|
+
await raceTimeout2(this.binding.endSettled?.() ?? Promise.resolve(), SESSION_END_WAIT_MS);
|
|
89493
89955
|
try {
|
|
89494
89956
|
this.binding.sweepInbox?.();
|
|
89495
89957
|
} catch {}
|
|
@@ -90132,7 +90594,7 @@ function fileSizeOf(path) {
|
|
|
90132
90594
|
return 0;
|
|
90133
90595
|
}
|
|
90134
90596
|
}
|
|
90135
|
-
function
|
|
90597
|
+
function raceTimeout2(p, ms) {
|
|
90136
90598
|
return new Promise((resolve) => {
|
|
90137
90599
|
const t = setTimeout(resolve, ms);
|
|
90138
90600
|
p.then(() => {
|
|
@@ -91145,13 +91607,15 @@ function mergeUserSettingsIfPresent(config, tempSettingsPath, statusLine, proxyA
|
|
|
91145
91607
|
async function resolveLocalContextWindow(spec, cachePath) {
|
|
91146
91608
|
const parsed = parseModelSpec(spec);
|
|
91147
91609
|
let provider = parsed.provider;
|
|
91610
|
+
let wireId = parsed.model;
|
|
91148
91611
|
if (!parsed.isExplicitProvider) {
|
|
91149
91612
|
const plan = await route(spec);
|
|
91150
91613
|
if (plan.kind !== "ok")
|
|
91151
91614
|
return null;
|
|
91152
91615
|
provider = plan.primary.provider;
|
|
91616
|
+
wireId = parseModelSpec(plan.primary.modelSpec).model;
|
|
91153
91617
|
}
|
|
91154
|
-
const win = await discoverContextWindow(provider, parsed.model) ??
|
|
91618
|
+
const win = await discoverContextWindow(provider, wireId) ?? lookupModelForProvider(parsed.model, provider, cachePath) ?? (wireId !== parsed.model ? lookupModelForProvider(wireId, provider, cachePath) : null);
|
|
91155
91619
|
return {
|
|
91156
91620
|
modelId: parsed.model,
|
|
91157
91621
|
window: typeof win === "number" && win > 0 ? win : null
|
|
@@ -94421,6 +94885,7 @@ function classifyStartupKind() {
|
|
|
94421
94885
|
"stats",
|
|
94422
94886
|
"providers",
|
|
94423
94887
|
"keychain",
|
|
94888
|
+
"subscription",
|
|
94424
94889
|
"login",
|
|
94425
94890
|
"logout",
|
|
94426
94891
|
"quota",
|
|
@@ -94558,6 +95023,7 @@ var isConfigCommand = firstPositional === "config";
|
|
|
94558
95023
|
var isServeCommand = firstPositional === "serve";
|
|
94559
95024
|
var isProvidersCommand = firstPositional === "providers";
|
|
94560
95025
|
var isKeychainCommand = firstPositional === "keychain";
|
|
95026
|
+
var isSubscriptionCommand = firstPositional === "subscription";
|
|
94561
95027
|
var isHooksCommand = firstPositional === "hooks";
|
|
94562
95028
|
var isTeamCommand = firstPositional === "team";
|
|
94563
95029
|
var isLoginCommand = firstPositional === "login";
|
|
@@ -94603,6 +95069,14 @@ if (isMcpMode) {
|
|
|
94603
95069
|
console.error(`[claudish keychain] ${e instanceof Error ? e.message : String(e)}`);
|
|
94604
95070
|
process.exit(1);
|
|
94605
95071
|
}));
|
|
95072
|
+
} else if (isSubscriptionCommand) {
|
|
95073
|
+
const subscriptionArgIndex = args.indexOf("subscription");
|
|
95074
|
+
const subscriptionModule = () => Promise.resolve().then(() => (init_subscription_models_command(), exports_subscription_models_command));
|
|
95075
|
+
subscriptionModule().then((m) => m.subscriptionModelsCommand(args.slice(subscriptionArgIndex + 1))).catch(() => subscriptionModule().then((m) => m.reportSubscriptionInternalError()).catch(() => {
|
|
95076
|
+
process.stderr.write(`[claudish subscription] internal error
|
|
95077
|
+
`);
|
|
95078
|
+
return 1;
|
|
95079
|
+
})).then((code) => process.exit(code));
|
|
94606
95080
|
} else if (isLoginCommand) {
|
|
94607
95081
|
const loginProviderArg = args.find((a, i) => i > args.indexOf("login") && !a.startsWith("-"));
|
|
94608
95082
|
Promise.resolve().then(() => (init_auth_commands(), {})).then((m) => loginCommand(loginProviderArg).catch(handlePromptExit));
|