style: fix formatting
This commit is contained in:
committed by
Peter Steinberger
parent
a399fa36c8
commit
05bd100f7a
@@ -14,7 +14,7 @@ export type AuthChoiceOption = {
|
|||||||
|
|
||||||
function formatOAuthHint(
|
function formatOAuthHint(
|
||||||
expires?: number,
|
expires?: number,
|
||||||
opts?: { allowStale?: boolean }
|
opts?: { allowStale?: boolean },
|
||||||
): string {
|
): string {
|
||||||
const rich = isRich();
|
const rich = isRich();
|
||||||
if (!expires) {
|
if (!expires) {
|
||||||
@@ -33,8 +33,8 @@ function formatOAuthHint(
|
|||||||
minutes >= 120
|
minutes >= 120
|
||||||
? `${Math.round(minutes / 60)}h`
|
? `${Math.round(minutes / 60)}h`
|
||||||
: minutes >= 60
|
: minutes >= 60
|
||||||
? "1h"
|
? "1h"
|
||||||
: `${Math.max(minutes, 1)}m`;
|
: `${Math.max(minutes, 1)}m`;
|
||||||
const label = `token ok · expires in ${duration}`;
|
const label = `token ok · expires in ${duration}`;
|
||||||
if (minutes <= 10) {
|
if (minutes <= 10) {
|
||||||
return colorize(rich, theme.warn, label);
|
return colorize(rich, theme.warn, label);
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ import { OPENCODE_ZEN_DEFAULT_MODEL } from "./opencode-zen-model-default.js";
|
|||||||
export async function warnIfModelConfigLooksOff(
|
export async function warnIfModelConfigLooksOff(
|
||||||
config: ClawdbotConfig,
|
config: ClawdbotConfig,
|
||||||
prompter: WizardPrompter,
|
prompter: WizardPrompter,
|
||||||
options?: { agentId?: string; agentDir?: string }
|
options?: { agentId?: string; agentDir?: string },
|
||||||
) {
|
) {
|
||||||
const agentModelOverride = options?.agentId
|
const agentModelOverride = options?.agentId
|
||||||
? resolveAgentConfig(config, options.agentId)?.model?.trim()
|
? resolveAgentConfig(config, options.agentId)?.model?.trim()
|
||||||
@@ -96,11 +96,11 @@ export async function warnIfModelConfigLooksOff(
|
|||||||
});
|
});
|
||||||
if (catalog.length > 0) {
|
if (catalog.length > 0) {
|
||||||
const known = catalog.some(
|
const known = catalog.some(
|
||||||
(entry) => entry.provider === ref.provider && entry.id === ref.model
|
(entry) => entry.provider === ref.provider && entry.id === ref.model,
|
||||||
);
|
);
|
||||||
if (!known) {
|
if (!known) {
|
||||||
warnings.push(
|
warnings.push(
|
||||||
`Model not found: ${ref.provider}/${ref.model}. Update agents.defaults.model or run /models list.`
|
`Model not found: ${ref.provider}/${ref.model}. Update agents.defaults.model or run /models list.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ export async function warnIfModelConfigLooksOff(
|
|||||||
const customKey = getCustomProviderApiKey(config, ref.provider);
|
const customKey = getCustomProviderApiKey(config, ref.provider);
|
||||||
if (!hasProfile && !envKey && !customKey) {
|
if (!hasProfile && !envKey && !customKey) {
|
||||||
warnings.push(
|
warnings.push(
|
||||||
`No auth configured for provider "${ref.provider}". The agent may fail until credentials are added.`
|
`No auth configured for provider "${ref.provider}". The agent may fail until credentials are added.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ export async function warnIfModelConfigLooksOff(
|
|||||||
const hasCodex = listProfilesForProvider(store, "openai-codex").length > 0;
|
const hasCodex = listProfilesForProvider(store, "openai-codex").length > 0;
|
||||||
if (hasCodex) {
|
if (hasCodex) {
|
||||||
warnings.push(
|
warnings.push(
|
||||||
`Detected OpenAI Codex OAuth. Consider setting agents.defaults.model to ${OPENAI_CODEX_DEFAULT_MODEL}.`
|
`Detected OpenAI Codex OAuth. Consider setting agents.defaults.model to ${OPENAI_CODEX_DEFAULT_MODEL}.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,7 +145,7 @@ export async function applyAuthChoice(params: {
|
|||||||
if (!params.agentId) return;
|
if (!params.agentId) return;
|
||||||
await params.prompter.note(
|
await params.prompter.note(
|
||||||
`Default model set to ${model} for agent "${params.agentId}".`,
|
`Default model set to ${model} for agent "${params.agentId}".`,
|
||||||
"Model configured"
|
"Model configured",
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -161,7 +161,7 @@ export async function applyAuthChoice(params: {
|
|||||||
'Choose "Always Allow" so the launchd gateway can start without prompts.',
|
'Choose "Always Allow" so the launchd gateway can start without prompts.',
|
||||||
'If you choose "Allow" or "Deny", each restart will block on a Keychain alert.',
|
'If you choose "Allow" or "Deny", each restart will block on a Keychain alert.',
|
||||||
].join("\n"),
|
].join("\n"),
|
||||||
"Claude CLI Keychain"
|
"Claude CLI Keychain",
|
||||||
);
|
);
|
||||||
const proceed = await params.prompter.confirm({
|
const proceed = await params.prompter.confirm({
|
||||||
message: "Check Keychain for Claude CLI credentials now?",
|
message: "Check Keychain for Claude CLI credentials now?",
|
||||||
@@ -192,14 +192,14 @@ export async function applyAuthChoice(params: {
|
|||||||
if (res.error) {
|
if (res.error) {
|
||||||
await params.prompter.note(
|
await params.prompter.note(
|
||||||
`Failed to run claude: ${String(res.error)}`,
|
`Failed to run claude: ${String(res.error)}`,
|
||||||
"Claude setup-token"
|
"Claude setup-token",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await params.prompter.note(
|
await params.prompter.note(
|
||||||
"`claude setup-token` requires an interactive TTY.",
|
"`claude setup-token` requires an interactive TTY.",
|
||||||
"Claude setup-token"
|
"Claude setup-token",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,7 +211,7 @@ export async function applyAuthChoice(params: {
|
|||||||
process.platform === "darwin"
|
process.platform === "darwin"
|
||||||
? 'No Claude CLI credentials found in Keychain ("Claude Code-credentials") or ~/.claude/.credentials.json.'
|
? 'No Claude CLI credentials found in Keychain ("Claude Code-credentials") or ~/.claude/.credentials.json.'
|
||||||
: "No Claude CLI credentials found at ~/.claude/.credentials.json.",
|
: "No Claude CLI credentials found at ~/.claude/.credentials.json.",
|
||||||
"Claude CLI OAuth"
|
"Claude CLI OAuth",
|
||||||
);
|
);
|
||||||
return { config: nextConfig, agentModelOverride };
|
return { config: nextConfig, agentModelOverride };
|
||||||
}
|
}
|
||||||
@@ -230,13 +230,13 @@ export async function applyAuthChoice(params: {
|
|||||||
"This will run `claude setup-token` to create a long-lived Anthropic token.",
|
"This will run `claude setup-token` to create a long-lived Anthropic token.",
|
||||||
"Requires an interactive TTY and a Claude Pro/Max subscription.",
|
"Requires an interactive TTY and a Claude Pro/Max subscription.",
|
||||||
].join("\n"),
|
].join("\n"),
|
||||||
"Anthropic setup-token"
|
"Anthropic setup-token",
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!process.stdin.isTTY) {
|
if (!process.stdin.isTTY) {
|
||||||
await params.prompter.note(
|
await params.prompter.note(
|
||||||
"`claude setup-token` requires an interactive TTY.",
|
"`claude setup-token` requires an interactive TTY.",
|
||||||
"Anthropic setup-token"
|
"Anthropic setup-token",
|
||||||
);
|
);
|
||||||
return { config: nextConfig, agentModelOverride };
|
return { config: nextConfig, agentModelOverride };
|
||||||
}
|
}
|
||||||
@@ -254,14 +254,14 @@ export async function applyAuthChoice(params: {
|
|||||||
if (res.error) {
|
if (res.error) {
|
||||||
await params.prompter.note(
|
await params.prompter.note(
|
||||||
`Failed to run claude: ${String(res.error)}`,
|
`Failed to run claude: ${String(res.error)}`,
|
||||||
"Anthropic setup-token"
|
"Anthropic setup-token",
|
||||||
);
|
);
|
||||||
return { config: nextConfig, agentModelOverride };
|
return { config: nextConfig, agentModelOverride };
|
||||||
}
|
}
|
||||||
if (typeof res.status === "number" && res.status !== 0) {
|
if (typeof res.status === "number" && res.status !== 0) {
|
||||||
await params.prompter.note(
|
await params.prompter.note(
|
||||||
`claude setup-token failed (exit ${res.status})`,
|
`claude setup-token failed (exit ${res.status})`,
|
||||||
"Anthropic setup-token"
|
"Anthropic setup-token",
|
||||||
);
|
);
|
||||||
return { config: nextConfig, agentModelOverride };
|
return { config: nextConfig, agentModelOverride };
|
||||||
}
|
}
|
||||||
@@ -272,7 +272,7 @@ export async function applyAuthChoice(params: {
|
|||||||
if (!store.profiles[CLAUDE_CLI_PROFILE_ID]) {
|
if (!store.profiles[CLAUDE_CLI_PROFILE_ID]) {
|
||||||
await params.prompter.note(
|
await params.prompter.note(
|
||||||
`No Claude CLI credentials found after setup-token. Expected ${CLAUDE_CLI_PROFILE_ID}.`,
|
`No Claude CLI credentials found after setup-token. Expected ${CLAUDE_CLI_PROFILE_ID}.`,
|
||||||
"Anthropic setup-token"
|
"Anthropic setup-token",
|
||||||
);
|
);
|
||||||
return { config: nextConfig, agentModelOverride };
|
return { config: nextConfig, agentModelOverride };
|
||||||
}
|
}
|
||||||
@@ -292,7 +292,7 @@ export async function applyAuthChoice(params: {
|
|||||||
"Run `claude setup-token` in your terminal.",
|
"Run `claude setup-token` in your terminal.",
|
||||||
"Then paste the generated token below.",
|
"Then paste the generated token below.",
|
||||||
].join("\n"),
|
].join("\n"),
|
||||||
"Anthropic token"
|
"Anthropic token",
|
||||||
);
|
);
|
||||||
|
|
||||||
const tokenRaw = await params.prompter.text({
|
const tokenRaw = await params.prompter.text({
|
||||||
@@ -342,7 +342,7 @@ export async function applyAuthChoice(params: {
|
|||||||
}
|
}
|
||||||
await params.prompter.note(
|
await params.prompter.note(
|
||||||
`Copied OPENAI_API_KEY to ${result.path} for launchd compatibility.`,
|
`Copied OPENAI_API_KEY to ${result.path} for launchd compatibility.`,
|
||||||
"OpenAI API key"
|
"OpenAI API key",
|
||||||
);
|
);
|
||||||
return { config: nextConfig, agentModelOverride };
|
return { config: nextConfig, agentModelOverride };
|
||||||
}
|
}
|
||||||
@@ -360,7 +360,7 @@ export async function applyAuthChoice(params: {
|
|||||||
process.env.OPENAI_API_KEY = trimmed;
|
process.env.OPENAI_API_KEY = trimmed;
|
||||||
await params.prompter.note(
|
await params.prompter.note(
|
||||||
`Saved OPENAI_API_KEY to ${result.path} for launchd compatibility.`,
|
`Saved OPENAI_API_KEY to ${result.path} for launchd compatibility.`,
|
||||||
"OpenAI API key"
|
"OpenAI API key",
|
||||||
);
|
);
|
||||||
} else if (params.authChoice === "openai-codex") {
|
} else if (params.authChoice === "openai-codex") {
|
||||||
const isRemote = isRemoteEnvironment();
|
const isRemote = isRemoteEnvironment();
|
||||||
@@ -376,7 +376,7 @@ export async function applyAuthChoice(params: {
|
|||||||
"If the callback doesn't auto-complete, paste the redirect URL.",
|
"If the callback doesn't auto-complete, paste the redirect URL.",
|
||||||
"OpenAI OAuth uses localhost:1455 for the callback.",
|
"OpenAI OAuth uses localhost:1455 for the callback.",
|
||||||
].join("\n"),
|
].join("\n"),
|
||||||
"OpenAI Codex OAuth"
|
"OpenAI Codex OAuth",
|
||||||
);
|
);
|
||||||
const spin = params.prompter.progress("Starting OAuth flow…");
|
const spin = params.prompter.progress("Starting OAuth flow…");
|
||||||
let manualCodePromise: Promise<string> | undefined;
|
let manualCodePromise: Promise<string> | undefined;
|
||||||
@@ -386,7 +386,7 @@ export async function applyAuthChoice(params: {
|
|||||||
if (isRemote) {
|
if (isRemote) {
|
||||||
spin.stop("OAuth URL ready");
|
spin.stop("OAuth URL ready");
|
||||||
params.runtime.log(
|
params.runtime.log(
|
||||||
`\nOpen this URL in your LOCAL browser:\n\n${url}\n`
|
`\nOpen this URL in your LOCAL browser:\n\n${url}\n`,
|
||||||
);
|
);
|
||||||
manualCodePromise = params.prompter
|
manualCodePromise = params.prompter
|
||||||
.text({
|
.text({
|
||||||
@@ -418,7 +418,7 @@ export async function applyAuthChoice(params: {
|
|||||||
await writeOAuthCredentials(
|
await writeOAuthCredentials(
|
||||||
"openai-codex" as unknown as OAuthProvider,
|
"openai-codex" as unknown as OAuthProvider,
|
||||||
creds,
|
creds,
|
||||||
params.agentDir
|
params.agentDir,
|
||||||
);
|
);
|
||||||
nextConfig = applyAuthProfileConfig(nextConfig, {
|
nextConfig = applyAuthProfileConfig(nextConfig, {
|
||||||
profileId: "openai-codex:default",
|
profileId: "openai-codex:default",
|
||||||
@@ -431,7 +431,7 @@ export async function applyAuthChoice(params: {
|
|||||||
if (applied.changed) {
|
if (applied.changed) {
|
||||||
await params.prompter.note(
|
await params.prompter.note(
|
||||||
`Default model set to ${OPENAI_CODEX_DEFAULT_MODEL}`,
|
`Default model set to ${OPENAI_CODEX_DEFAULT_MODEL}`,
|
||||||
"Model configured"
|
"Model configured",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -444,7 +444,7 @@ export async function applyAuthChoice(params: {
|
|||||||
params.runtime.error(String(err));
|
params.runtime.error(String(err));
|
||||||
await params.prompter.note(
|
await params.prompter.note(
|
||||||
"Trouble with OAuth? See https://docs.clawd.bot/start/faq",
|
"Trouble with OAuth? See https://docs.clawd.bot/start/faq",
|
||||||
"OAuth help"
|
"OAuth help",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (params.authChoice === "codex-cli") {
|
} else if (params.authChoice === "codex-cli") {
|
||||||
@@ -452,7 +452,7 @@ export async function applyAuthChoice(params: {
|
|||||||
if (!store.profiles[CODEX_CLI_PROFILE_ID]) {
|
if (!store.profiles[CODEX_CLI_PROFILE_ID]) {
|
||||||
await params.prompter.note(
|
await params.prompter.note(
|
||||||
"No Codex CLI credentials found at ~/.codex/auth.json.",
|
"No Codex CLI credentials found at ~/.codex/auth.json.",
|
||||||
"Codex CLI OAuth"
|
"Codex CLI OAuth",
|
||||||
);
|
);
|
||||||
return { config: nextConfig, agentModelOverride };
|
return { config: nextConfig, agentModelOverride };
|
||||||
}
|
}
|
||||||
@@ -467,7 +467,7 @@ export async function applyAuthChoice(params: {
|
|||||||
if (applied.changed) {
|
if (applied.changed) {
|
||||||
await params.prompter.note(
|
await params.prompter.note(
|
||||||
`Default model set to ${OPENAI_CODEX_DEFAULT_MODEL}`,
|
`Default model set to ${OPENAI_CODEX_DEFAULT_MODEL}`,
|
||||||
"Model configured"
|
"Model configured",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -488,7 +488,7 @@ export async function applyAuthChoice(params: {
|
|||||||
"Sign in with your Google account that has Antigravity access.",
|
"Sign in with your Google account that has Antigravity access.",
|
||||||
"The callback will be captured automatically on localhost:51121.",
|
"The callback will be captured automatically on localhost:51121.",
|
||||||
].join("\n"),
|
].join("\n"),
|
||||||
"Google Antigravity OAuth"
|
"Google Antigravity OAuth",
|
||||||
);
|
);
|
||||||
const spin = params.prompter.progress("Starting OAuth flow…");
|
const spin = params.prompter.progress("Starting OAuth flow…");
|
||||||
let oauthCreds: OAuthCredentials | null = null;
|
let oauthCreds: OAuthCredentials | null = null;
|
||||||
@@ -498,7 +498,7 @@ export async function applyAuthChoice(params: {
|
|||||||
if (isRemote) {
|
if (isRemote) {
|
||||||
spin.stop("OAuth URL ready");
|
spin.stop("OAuth URL ready");
|
||||||
params.runtime.log(
|
params.runtime.log(
|
||||||
`\nOpen this URL in your LOCAL browser:\n\n${url}\n`
|
`\nOpen this URL in your LOCAL browser:\n\n${url}\n`,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
spin.update("Complete sign-in in browser…");
|
spin.update("Complete sign-in in browser…");
|
||||||
@@ -506,14 +506,14 @@ export async function applyAuthChoice(params: {
|
|||||||
params.runtime.log(`Open: ${url}`);
|
params.runtime.log(`Open: ${url}`);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(msg) => spin.update(msg)
|
(msg) => spin.update(msg),
|
||||||
);
|
);
|
||||||
spin.stop("Antigravity OAuth complete");
|
spin.stop("Antigravity OAuth complete");
|
||||||
if (oauthCreds) {
|
if (oauthCreds) {
|
||||||
await writeOAuthCredentials(
|
await writeOAuthCredentials(
|
||||||
"google-antigravity",
|
"google-antigravity",
|
||||||
oauthCreds,
|
oauthCreds,
|
||||||
params.agentDir
|
params.agentDir,
|
||||||
);
|
);
|
||||||
nextConfig = applyAuthProfileConfig(nextConfig, {
|
nextConfig = applyAuthProfileConfig(nextConfig, {
|
||||||
profileId: `google-antigravity:${oauthCreds.email ?? "default"}`,
|
profileId: `google-antigravity:${oauthCreds.email ?? "default"}`,
|
||||||
@@ -558,7 +558,7 @@ export async function applyAuthChoice(params: {
|
|||||||
};
|
};
|
||||||
await params.prompter.note(
|
await params.prompter.note(
|
||||||
`Default model set to ${modelKey}`,
|
`Default model set to ${modelKey}`,
|
||||||
"Model configured"
|
"Model configured",
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
agentModelOverride = modelKey;
|
agentModelOverride = modelKey;
|
||||||
@@ -570,7 +570,7 @@ export async function applyAuthChoice(params: {
|
|||||||
params.runtime.error(String(err));
|
params.runtime.error(String(err));
|
||||||
await params.prompter.note(
|
await params.prompter.note(
|
||||||
"Trouble with OAuth? See https://docs.clawd.bot/start/faq",
|
"Trouble with OAuth? See https://docs.clawd.bot/start/faq",
|
||||||
"OAuth help"
|
"OAuth help",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (params.authChoice === "gemini-api-key") {
|
} else if (params.authChoice === "gemini-api-key") {
|
||||||
@@ -590,7 +590,7 @@ export async function applyAuthChoice(params: {
|
|||||||
if (applied.changed) {
|
if (applied.changed) {
|
||||||
await params.prompter.note(
|
await params.prompter.note(
|
||||||
`Default model set to ${GOOGLE_GEMINI_DEFAULT_MODEL}`,
|
`Default model set to ${GOOGLE_GEMINI_DEFAULT_MODEL}`,
|
||||||
"Model configured"
|
"Model configured",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -659,7 +659,7 @@ export async function applyAuthChoice(params: {
|
|||||||
"Get your API key at: https://opencode.ai/auth",
|
"Get your API key at: https://opencode.ai/auth",
|
||||||
"Requires an active OpenCode Zen subscription.",
|
"Requires an active OpenCode Zen subscription.",
|
||||||
].join("\n"),
|
].join("\n"),
|
||||||
"OpenCode Zen"
|
"OpenCode Zen",
|
||||||
);
|
);
|
||||||
const key = await params.prompter.text({
|
const key = await params.prompter.text({
|
||||||
message: "Enter OpenCode Zen API key",
|
message: "Enter OpenCode Zen API key",
|
||||||
@@ -675,7 +675,7 @@ export async function applyAuthChoice(params: {
|
|||||||
nextConfig = applyOpencodeZenConfig(nextConfig);
|
nextConfig = applyOpencodeZenConfig(nextConfig);
|
||||||
await params.prompter.note(
|
await params.prompter.note(
|
||||||
`Default model set to ${OPENCODE_ZEN_DEFAULT_MODEL}`,
|
`Default model set to ${OPENCODE_ZEN_DEFAULT_MODEL}`,
|
||||||
"Model configured"
|
"Model configured",
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
nextConfig = applyOpencodeZenConfig(nextConfig);
|
nextConfig = applyOpencodeZenConfig(nextConfig);
|
||||||
|
|||||||
Reference in New Issue
Block a user