@juspay/neurolink
Version:
The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002
133 lines (132 loc) • 5.04 kB
TypeScript
/**
* NeuroLink Auth Command
*
* Unified authentication command for AI providers supporting:
* - API key authentication (traditional)
* - OAuth 2.1 authentication with PKCE (for Claude subscription)
*
* Subcommands:
* - login: Authenticate with a provider (supports --add/--label for multi-account)
* - logout: Clear stored credentials
* - status: Show authentication status
* - refresh: Manually refresh OAuth tokens
* - list: List all authenticated accounts
* - remove: Remove an authenticated account
*
* Currently supports:
* - Anthropic (API key + OAuth)
*/
import type { AccountQuota, AuthCommandArgs } from "../../types/index.js";
/**
* Handle the login subcommand
* `neurolink auth login <provider>`
*
* When --add is specified, saves tokens to the TokenStore with a compound key
* (e.g., "anthropic:alice") to support multi-account pools.
*/
export declare function handleLogin(argv: AuthCommandArgs): Promise<void>;
/**
* Handle Codex (ChatGPT) login by importing the current credential from
* `~/.codex/auth.json` into the account pool under a `codex:<label>` key.
*
* To add multiple ChatGPT accounts: `codex login` as account A, then
* `neurolink auth login codex --label a`; repeat for account B, etc. The proxy
* then pools all imported accounts and rotates automatically — no manual
* account switching during use.
*/
export declare function handleCodexLogin(argv: AuthCommandArgs): Promise<void>;
/**
* Format the dynamic per-plan limit windows (model-scoped weeklies such as
* Fable, plus any future kinds) as extra display lines. `session` and
* `weekly_all` are omitted — they already render as the SESSION / WEEKLY
* columns. Exported for the continuous test suite.
*/
export declare function formatQuotaWindowRows(quota: AccountQuota): string[];
/**
* Handle the list subcommand
* `neurolink auth list`
*
* Lists all authenticated accounts from the TokenStore.
*/
export declare function handleList(argv: AuthCommandArgs): Promise<void>;
/**
* Handle the remove subcommand
* `neurolink auth remove <provider> --label <label>` or `neurolink auth remove <provider> --account <key>`
*
* Removes an authenticated account from the TokenStore.
* When neither --label nor --account is given, removes the default (unlabelled) account
* for the specified provider.
*/
export declare function handleRemove(argv: AuthCommandArgs): Promise<void>;
/**
* Handle the logout subcommand
* `neurolink auth logout <provider>`
*/
export declare function handleLogout(argv: AuthCommandArgs): Promise<void>;
/**
* Handle the status subcommand
* `neurolink auth status [provider]`
*/
export declare function handleStatus(argv: AuthCommandArgs): Promise<void>;
/**
* Handle the refresh subcommand
* `neurolink auth refresh <provider>`
*/
export declare function handleRefresh(argv: AuthCommandArgs): Promise<void>;
export declare function handleCleanup(argv: AuthCommandArgs): Promise<void>;
/**
* Handle the enable subcommand
* `neurolink auth enable <account>`
*
* Re-enables a previously disabled account so it can be used by the proxy pool again.
*/
export declare function handleEnable(argv: AuthCommandArgs): Promise<void>;
export declare function handleDisable(argv: AuthCommandArgs): Promise<void>;
/**
* Inspect or clear the per-account rate-limit cooldowns the proxy persists.
*
* Without this there is no way to see why an account vanished from the pool, or
* to release one parked by a bad reset timestamp.
*/
export declare function handleCooldown(argv: AuthCommandArgs): Promise<void>;
/**
* Handle the set-primary subcommand
* `neurolink auth set-primary <email> [--config <path>]`
*
* Writes routing.primary-account to the proxy config YAML so the proxy
* tries this account first under fill-first/round-robin home semantics.
* Does not touch the token store.
*/
export declare function handleSetPrimary(argv: AuthCommandArgs): Promise<void>;
/**
* Handle the overage subcommand
* `neurolink auth overage <status|auto|always|never> [--config <path>]`
*
* Controls whether the pool may keep serving on paid extra usage once an
* account's subscription window is spent. Only `never` overrides the provider:
* nothing here can switch on extra usage that Anthropic reports as disabled.
*/
export declare function handleOverage(argv: AuthCommandArgs): Promise<void>;
/**
* Handle the get-primary subcommand
* `neurolink auth get-primary [--config <path>]`
*/
export declare function handleGetPrimary(argv: AuthCommandArgs): Promise<void>;
/**
* Handle the clear-primary subcommand
* `neurolink auth clear-primary [--config <path>]`
*/
export declare function handleClearPrimary(argv: AuthCommandArgs): Promise<void>;
/**
* Legacy main auth command handler
* @deprecated Use subcommand handlers instead
*/
export declare function handleAuth(argv: {
provider?: string;
method?: "api-key" | "oauth";
status?: boolean;
logout?: boolean;
nonInteractive?: boolean;
debug?: boolean;
}): Promise<void>;