rush-ai 0.12.1 → 0.13.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/README.md +4 -1
- package/dist/{chunk-3X5X3ZTX.js → chunk-YKZIRW26.js} +23 -4
- package/dist/chunk-YKZIRW26.js.map +1 -0
- package/dist/index.js +77 -19
- package/dist/index.js.map +1 -1
- package/dist/{install-AGHG4XKQ.js → install-RTV2VWCC.js} +2 -2
- package/dist/{server-GQMH2YN4.js → server-Y2CXHDCK.js} +2 -2
- package/dist/skills/README.md +1 -3
- package/dist/skills/deploy-to-prod.md +7 -8
- package/dist/skills/hand-off.md +1 -2
- package/dist/skills/project-setup.md +203 -0
- package/dist/skills/push-local-project.md +6 -10
- package/package.json +1 -1
- package/skills/README.md +1 -3
- package/skills/deploy-to-prod.md +7 -8
- package/skills/hand-off.md +1 -2
- package/skills/project-setup.md +203 -0
- package/skills/push-local-project.md +6 -10
- package/dist/chunk-3X5X3ZTX.js.map +0 -1
- /package/dist/{install-AGHG4XKQ.js.map → install-RTV2VWCC.js.map} +0 -0
- /package/dist/{server-GQMH2YN4.js.map → server-Y2CXHDCK.js.map} +0 -0
package/README.md
CHANGED
|
@@ -116,11 +116,14 @@ rush-ai task status <id> --json
|
|
|
116
116
|
| `task list` / `task ls` | 列出我的任务 |
|
|
117
117
|
| `task cancel <id>` | 取消运行中的任务 |
|
|
118
118
|
| `task push` | 同步本地改动到 Rush(当前目录需要是 Rush 项目的 checkout) |
|
|
119
|
+
| `task link` | 把现有本地项目接入 Rush,附带 Supabase DB / OSS 上传(`--db` / `--oss`) |
|
|
119
120
|
| `task deploy <id>` | 发布 web-builder 产物到 prod(`--domain` / `--version` / `--env`) |
|
|
120
121
|
| `task versions <id>` | 列出 web-builder 任务的可发布版本 |
|
|
121
122
|
| `task domain check <prefix>` | 校验自定义域名前缀是否可用(需 `--task <id>`) |
|
|
122
123
|
|
|
123
|
-
>
|
|
124
|
+
> 命名迁移事实:0.10.0 起 `task init` 改名为 `task link`(对齐 `vercel link` / `netlify link` 语义);`task init` 作为 deprecated alias 在 0.13.0 移除。
|
|
125
|
+
>
|
|
126
|
+
> `task link` 产生的项目 `template = null`,目前还不能走 `task deploy` 自定义域名发布(待 epic #1096 Phase 2)。需要自定义域名时请走 `task create -a web-builder`。
|
|
124
127
|
|
|
125
128
|
### agent / MCP
|
|
126
129
|
|
|
@@ -85,6 +85,11 @@ var GLOBAL_DEFAULTS = {
|
|
|
85
85
|
api: DEFAULT_API,
|
|
86
86
|
collectMetrics: true
|
|
87
87
|
};
|
|
88
|
+
function isEmptyAuthEntry(entry) {
|
|
89
|
+
if (!entry || typeof entry !== "object") return false;
|
|
90
|
+
const auth = entry;
|
|
91
|
+
return !auth.token && auth.expiresAt == null && !auth.refreshToken && auth.method == null && !auth.tokenId && !auth.sourceUrl;
|
|
92
|
+
}
|
|
88
93
|
var globalStore = new Conf({
|
|
89
94
|
projectName: "rush-ai",
|
|
90
95
|
cwd: AUTH_CONFIG_DIR,
|
|
@@ -124,7 +129,10 @@ function migrateGlobalStoreIfNeeded() {
|
|
|
124
129
|
}
|
|
125
130
|
function migrateAuthStoreIfNeeded() {
|
|
126
131
|
const version = authStore.get("_version");
|
|
127
|
-
if (version === 3)
|
|
132
|
+
if (version === 3) {
|
|
133
|
+
pruneEmptyAuthEntries();
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
128
136
|
const hasOldFormat = authStore.has("token") || authStore.has("method");
|
|
129
137
|
const isEmpty = authStore.size === 0;
|
|
130
138
|
if (hasOldFormat) {
|
|
@@ -138,7 +146,9 @@ function migrateAuthStoreIfNeeded() {
|
|
|
138
146
|
};
|
|
139
147
|
authStore.clear();
|
|
140
148
|
authStore.set("_version", 3);
|
|
141
|
-
|
|
149
|
+
if (!isEmptyAuthEntry(oldAuth)) {
|
|
150
|
+
authStore.set("default", oldAuth);
|
|
151
|
+
}
|
|
142
152
|
return;
|
|
143
153
|
}
|
|
144
154
|
if (isEmpty) {
|
|
@@ -156,6 +166,15 @@ function migrateAuthStoreIfNeeded() {
|
|
|
156
166
|
}
|
|
157
167
|
}
|
|
158
168
|
authStore.set("_version", 3);
|
|
169
|
+
pruneEmptyAuthEntries();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function pruneEmptyAuthEntries() {
|
|
173
|
+
for (const key of Object.keys(authStore.store)) {
|
|
174
|
+
if (key === "_version") continue;
|
|
175
|
+
if (isEmptyAuthEntry(authStore.get(key))) {
|
|
176
|
+
authStore.delete(key);
|
|
177
|
+
}
|
|
159
178
|
}
|
|
160
179
|
}
|
|
161
180
|
migrateGlobalStoreIfNeeded();
|
|
@@ -224,7 +243,7 @@ function setAuthConfig(config) {
|
|
|
224
243
|
}
|
|
225
244
|
function clearAuthConfig() {
|
|
226
245
|
const profile = getActiveProfile();
|
|
227
|
-
authStore.
|
|
246
|
+
authStore.delete(profile);
|
|
228
247
|
}
|
|
229
248
|
function getGlobalConfig() {
|
|
230
249
|
const profile = getActiveProfile();
|
|
@@ -920,4 +939,4 @@ export {
|
|
|
920
939
|
setVerbosity,
|
|
921
940
|
createClient
|
|
922
941
|
};
|
|
923
|
-
//# sourceMappingURL=chunk-
|
|
942
|
+
//# sourceMappingURL=chunk-YKZIRW26.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/output/logger.ts","../src/version.ts","../src/util/config.ts","../src/util/auth.ts","../src/util/errors.ts","../src/util/verbosity.ts","../src/util/auth-session.ts","../src/util/retry.ts","../src/util/client.ts"],"sourcesContent":["import chalk from 'chalk';\n\n/**\n * Output utilities.\n *\n * Design principle: stdout is for **content** (data the user wants to pipe/redirect).\n * Status messages (success, warn, info, dim) go to **stderr** so they don't pollute pipes.\n *\n * rush-ai task create --agent rush --prompt \"generate HTML\" --json > task.json\n * # stdout → task.json (task data)\n * # stderr → \"Success! Task xxx created.\" (status info, visible in terminal)\n */\nexport const output = {\n /** Content output → stdout. Use for data the user may pipe/redirect. */\n log(message: string): void {\n console.log(message);\n },\n\n /** Status → stderr */\n success(message: string): void {\n console.error(chalk.green('Success!'), message);\n },\n\n /** Error → stderr */\n error(message: string): void {\n console.error(chalk.red('Error:'), message);\n },\n\n /** Warning → stderr */\n warn(message: string): void {\n console.error(chalk.yellow('Warning:'), message);\n },\n\n /** Info → stderr */\n info(message: string): void {\n console.error(chalk.cyan('Info:'), message);\n },\n\n /** Dim status → stderr */\n dim(message: string): void {\n console.error(chalk.dim(message));\n },\n\n table(data: Record<string, string>[]): void {\n console.table(data);\n },\n\n /** Newline → stderr (status separator) */\n newline(): void {\n console.error();\n },\n\n link(text: string, url: string): string {\n return chalk.cyan.underline(url);\n },\n\n bold(text: string): string {\n return chalk.bold(text);\n },\n};\n","import { readFileSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\n/**\n * Dynamically read version from package.json.\n *\n * Path resolution:\n * - tsup bundle: dist/index.js → __dirname = dist/ → ../package.json\n * - vitest source: src/version.ts → __dirname = src/ → ../package.json\n */\nexport function loadVersion(): string {\n const __dirname = dirname(fileURLToPath(import.meta.url));\n\n const candidates = [\n resolve(__dirname, '..', 'package.json'),\n resolve(__dirname, '..', '..', 'package.json'),\n ];\n\n for (const candidate of candidates) {\n try {\n const pkg = JSON.parse(readFileSync(candidate, 'utf-8'));\n if (pkg.name === 'rush-ai' && pkg.version) {\n return pkg.version;\n }\n } catch {\n // try next candidate\n }\n }\n console.error('[rush-ai] Warning: Could not read version from package.json');\n return '0.0.0-unknown';\n}\n\nexport const VERSION: string = loadVersion();\n","import { homedir } from 'node:os';\nimport { resolve } from 'node:path';\nimport Conf from 'conf';\n\nexport interface AuthConfig {\n token: string | null;\n expiresAt: number | null;\n refreshToken: string | null;\n /** How the token was obtained */\n method: 'cas' | 'api_key' | 'platform_token' | null;\n /** Platform Token jti (for remote revocation via DELETE /api/platform-tokens?id={tokenId}) */\n tokenId: string | null;\n /**\n * API base URL the token was issued against. Stored at login so we can\n * detect when the current profile's API URL drifts from where the token\n * came from (e.g. `config set api` pointed at a different environment).\n * `null` for tokens migrated from the v2 schema — treated as \"unknown\n * origin\", so we don't flag false positives on upgrade.\n */\n sourceUrl: string | null;\n}\n\nexport interface GlobalConfig {\n currentTeam: string | null;\n api: string;\n collectMetrics: boolean;\n}\n\nexport interface ProjectConfig {\n projectId: string | null;\n orgId: string | null;\n}\n\n// --- Profile store types ---\n\ninterface ProfiledGlobalStore {\n _version: number;\n activeProfile: string;\n profiles: Record<string, GlobalConfig>;\n}\n\ninterface ProfiledAuthStore {\n _version: number;\n [profileName: string]: AuthConfig | number; // profile entries + _version\n}\n\nconst AUTH_CONFIG_DIR = resolve(homedir(), '.rush');\nconst DEFAULT_API = 'https://rush.zhenguanyu.com';\n\nconst AUTH_DEFAULTS: AuthConfig = {\n token: null,\n expiresAt: null,\n refreshToken: null,\n method: null,\n tokenId: null,\n sourceUrl: null,\n};\n\nconst GLOBAL_DEFAULTS: GlobalConfig = {\n currentTeam: null,\n api: DEFAULT_API,\n collectMetrics: true,\n};\n\nfunction isEmptyAuthEntry(entry: unknown): boolean {\n if (!entry || typeof entry !== 'object') return false;\n const auth = entry as Partial<AuthConfig>;\n return (\n !auth.token &&\n auth.expiresAt == null &&\n !auth.refreshToken &&\n auth.method == null &&\n !auth.tokenId &&\n !auth.sourceUrl\n );\n}\n\n// --- Raw stores (untyped to support migration) ---\n\nconst globalStore = new Conf<Record<string, unknown>>({\n projectName: 'rush-ai',\n cwd: AUTH_CONFIG_DIR,\n configName: 'config',\n defaults: {},\n});\n\nconst authStore = new Conf<Record<string, unknown>>({\n projectName: 'rush-ai',\n cwd: AUTH_CONFIG_DIR,\n configName: 'auth',\n defaults: {},\n});\n\n// --- Migration ---\n\nfunction migrateGlobalStoreIfNeeded(): void {\n const version = globalStore.get('_version');\n if (version === 2) return; // Already migrated\n\n // Check if this is old format (has 'api' at top level but no 'profiles')\n const hasOldFormat = globalStore.has('api') && !globalStore.has('profiles');\n const isEmpty = globalStore.size === 0;\n\n if (hasOldFormat) {\n // Migrate old flat format → profile format\n const oldConfig: GlobalConfig = {\n currentTeam: (globalStore.get('currentTeam') as string | null) ?? null,\n api: (globalStore.get('api') as string) ?? DEFAULT_API,\n collectMetrics: (globalStore.get('collectMetrics') as boolean) ?? true,\n };\n\n globalStore.clear();\n globalStore.set('_version', 2);\n globalStore.set('activeProfile', 'default');\n globalStore.set('profiles', { default: oldConfig });\n } else if (isEmpty || !globalStore.has('profiles')) {\n // Fresh install or incomplete state — initialize\n globalStore.set('_version', 2);\n if (!globalStore.has('activeProfile')) {\n globalStore.set('activeProfile', 'default');\n }\n if (!globalStore.has('profiles')) {\n globalStore.set('profiles', { default: { ...GLOBAL_DEFAULTS } });\n }\n }\n}\n\nfunction migrateAuthStoreIfNeeded(): void {\n const version = authStore.get('_version');\n if (version === 3) {\n pruneEmptyAuthEntries();\n return;\n }\n\n // v1 → v3: legacy flat format (`token` at top level).\n const hasOldFormat = authStore.has('token') || authStore.has('method');\n const isEmpty = authStore.size === 0;\n\n if (hasOldFormat) {\n const oldAuth: AuthConfig = {\n token: (authStore.get('token') as string | null) ?? null,\n expiresAt: (authStore.get('expiresAt') as number | null) ?? null,\n refreshToken: (authStore.get('refreshToken') as string | null) ?? null,\n method: (authStore.get('method') as AuthConfig['method']) ?? null,\n tokenId: (authStore.get('tokenId') as string | null) ?? null,\n sourceUrl: null,\n };\n\n authStore.clear();\n authStore.set('_version', 3);\n if (!isEmptyAuthEntry(oldAuth)) {\n authStore.set('default', oldAuth);\n }\n return;\n }\n\n if (isEmpty) {\n authStore.set('_version', 3);\n return;\n }\n\n // v2 → v3: profile-shaped but missing `sourceUrl`. Backfill null.\n if (version === 2) {\n for (const key of Object.keys(authStore.store)) {\n if (key === '_version') continue;\n const entry = authStore.get(key);\n if (!entry || typeof entry !== 'object') continue;\n const asAuth = entry as Record<string, unknown>;\n if (!('sourceUrl' in asAuth)) {\n authStore.set(key, { ...asAuth, sourceUrl: null });\n }\n }\n authStore.set('_version', 3);\n pruneEmptyAuthEntries();\n }\n}\n\nfunction pruneEmptyAuthEntries(): void {\n for (const key of Object.keys(authStore.store)) {\n if (key === '_version') continue;\n if (isEmptyAuthEntry(authStore.get(key))) {\n authStore.delete(key);\n }\n }\n}\n\n// Run migrations on module load\nmigrateGlobalStoreIfNeeded();\nmigrateAuthStoreIfNeeded();\n\n// --- Profile helpers ---\n\n/**\n * Get the active profile name.\n * RUSH_PROFILE env var takes precedence over stored activeProfile.\n */\nexport function getActiveProfile(): string {\n return (\n process.env.RUSH_PROFILE ??\n (globalStore.get('activeProfile') as string) ??\n 'default'\n );\n}\n\nexport function setActiveProfile(name: string): void {\n const profiles =\n (globalStore.get('profiles') as Record<string, GlobalConfig>) ?? {};\n if (!profiles[name]) {\n throw new Error(\n `Profile '${name}' does not exist. Available: ${Object.keys(profiles).join(', ')}`\n );\n }\n globalStore.set('activeProfile', name);\n}\n\nexport function listProfiles(): string[] {\n const profiles =\n (globalStore.get('profiles') as Record<string, GlobalConfig>) ?? {};\n return Object.keys(profiles);\n}\n\nexport function createProfile(\n name: string,\n config?: Partial<GlobalConfig>\n): void {\n const profiles =\n (globalStore.get('profiles') as Record<string, GlobalConfig>) ?? {};\n if (profiles[name]) {\n throw new Error(`Profile '${name}' already exists.`);\n }\n // Inherit from default profile\n const defaultConfig = profiles.default ?? GLOBAL_DEFAULTS;\n profiles[name] = { ...defaultConfig, ...config };\n globalStore.set('profiles', profiles);\n}\n\nexport function deleteProfile(name: string): void {\n if (name === 'default') {\n throw new Error(\"Cannot delete the 'default' profile.\");\n }\n const active = getActiveProfile();\n if (name === active) {\n throw new Error(\n `Cannot delete the active profile '${name}'. Switch to another profile first.`\n );\n }\n const profiles =\n (globalStore.get('profiles') as Record<string, GlobalConfig>) ?? {};\n if (!profiles[name]) {\n throw new Error(`Profile '${name}' does not exist.`);\n }\n delete profiles[name];\n globalStore.set('profiles', profiles);\n\n // Also clear auth for this profile\n authStore.delete(name);\n}\n\n// --- Auth config (profile-aware) ---\n\nexport function getAuthConfig(): AuthConfig {\n const profile = getActiveProfile();\n const profileAuth = authStore.get(profile) as AuthConfig | undefined;\n return {\n token: profileAuth?.token ?? null,\n expiresAt: profileAuth?.expiresAt ?? null,\n refreshToken: profileAuth?.refreshToken ?? null,\n method: profileAuth?.method ?? null,\n tokenId: profileAuth?.tokenId ?? null,\n sourceUrl: profileAuth?.sourceUrl ?? null,\n };\n}\n\nexport function setAuthConfig(config: Partial<AuthConfig>): void {\n const profile = getActiveProfile();\n const current = (authStore.get(profile) as AuthConfig) ?? {\n ...AUTH_DEFAULTS,\n };\n authStore.set(profile, { ...current, ...config });\n}\n\n/** Clear auth for the current profile only */\nexport function clearAuthConfig(): void {\n const profile = getActiveProfile();\n authStore.delete(profile);\n}\n\n/** Clear auth for ALL profiles */\nexport function clearAllAuthConfig(): void {\n for (const key of Object.keys(authStore.store)) {\n if (key !== '_version') {\n authStore.delete(key);\n }\n }\n}\n\n// --- Global config (profile-aware) ---\n\nexport function getGlobalConfig(): GlobalConfig {\n const profile = getActiveProfile();\n const profiles =\n (globalStore.get('profiles') as Record<string, GlobalConfig>) ?? {};\n const profileConfig = profiles[profile] ?? GLOBAL_DEFAULTS;\n return {\n currentTeam: profileConfig.currentTeam ?? null,\n api: profileConfig.api ?? DEFAULT_API,\n collectMetrics: profileConfig.collectMetrics ?? true,\n };\n}\n\nexport function setGlobalConfig(config: Partial<GlobalConfig>): void {\n const profile = getActiveProfile();\n const profiles =\n (globalStore.get('profiles') as Record<string, GlobalConfig>) ?? {};\n const current = profiles[profile] ?? { ...GLOBAL_DEFAULTS };\n profiles[profile] = { ...current, ...config };\n globalStore.set('profiles', profiles);\n}\n\nexport function getConfigDir(): string {\n return AUTH_CONFIG_DIR;\n}\n\nexport function isLoggedIn(): boolean {\n const auth = getAuthConfig();\n if (!auth.token) return false;\n if (auth.expiresAt && Date.now() > auth.expiresAt) {\n // CAS tokens with refresh_token can still be renewed lazily by the client.\n return auth.method === 'cas' && Boolean(auth.refreshToken);\n }\n return true;\n}\n\n/** Normalize an API URL for comparison — strips trailing slashes + lowercases. */\nexport function normalizeApiUrl(url: string): string {\n return url.replace(/\\/+$/, '').toLowerCase();\n}\n\n/**\n * If the current profile's token was issued against a different API URL than\n * the profile currently points to, return both sides so the caller can prompt\n * the user to re-authenticate. Returns null when no mismatch (or when the\n * stored `sourceUrl` is null — migrated tokens with unknown origin). The\n * caller decides what to do; this function does NOT mutate or clear anything.\n *\n * @param overrideCurrentUrl use this URL instead of reading the current\n * global config. Useful when evaluating mismatch BEFORE writing a new API\n * URL in `config set`.\n */\nexport function checkAuthSourceMismatch(\n overrideCurrentUrl?: string\n): { stored: string; current: string } | null {\n const auth = getAuthConfig();\n if (!auth.token || !auth.sourceUrl) return null;\n const current = overrideCurrentUrl ?? getGlobalConfig().api;\n if (normalizeApiUrl(auth.sourceUrl) === normalizeApiUrl(current)) return null;\n return { stored: auth.sourceUrl, current };\n}\n\n/**\n * Get the config for a specific profile (for display purposes).\n */\nexport function getProfileConfig(name: string): GlobalConfig | null {\n const profiles =\n (globalStore.get('profiles') as Record<string, GlobalConfig>) ?? {};\n return profiles[name] ?? null;\n}\n\n/**\n * Get auth config for a specific profile (for display purposes).\n */\nexport function getProfileAuth(name: string): AuthConfig {\n const profileAuth = authStore.get(name) as AuthConfig | undefined;\n return {\n token: profileAuth?.token ?? null,\n expiresAt: profileAuth?.expiresAt ?? null,\n refreshToken: profileAuth?.refreshToken ?? null,\n method: profileAuth?.method ?? null,\n tokenId: profileAuth?.tokenId ?? null,\n sourceUrl: profileAuth?.sourceUrl ?? null,\n };\n}\n","import { getAuthConfig, getGlobalConfig } from './config.js';\n\nexport type AuthMethod = 'api_key' | 'cas' | 'platform_token' | null;\n\n/**\n * Determine the current authentication method.\n * Priority: RUSH_API_KEY env > stored CAS token > null\n */\nexport function getAuthMethod(): AuthMethod {\n if (process.env.RUSH_API_KEY) {\n return 'api_key';\n }\n const auth = getAuthConfig();\n if (auth.token) {\n // Use stored method if available; detect rush_sk_ prefix as fallback\n if (auth.method === 'api_key' || auth.token.startsWith('rush_sk_')) {\n return 'api_key';\n }\n if (auth.method === 'platform_token') {\n return 'platform_token';\n }\n return auth.method ?? 'cas';\n }\n return null;\n}\n\n/**\n * Get the active auth token.\n * Priority: RUSH_API_KEY env > stored token\n */\nexport function getAuthToken(): string | null {\n if (process.env.RUSH_API_KEY) {\n return process.env.RUSH_API_KEY;\n }\n const auth = getAuthConfig();\n return auth.token;\n}\n\nexport interface CasConfig {\n authorizeEndpoint: string;\n tokenEndpoint: string;\n revokeEndpoint: string;\n clientId: string;\n}\n\n/**\n * Get CAS PKCE configuration.\n * Supports env overrides for private deployments.\n */\nexport function getCasConfig(): CasConfig {\n const config = getGlobalConfig();\n const baseUrl = process.env.RUSH_API_URL ?? config.api;\n\n return {\n authorizeEndpoint:\n process.env.RUSH_CAS_AUTHORIZE_ENDPOINT ??\n `${baseUrl}/cas/oauth2/authorize`,\n tokenEndpoint:\n process.env.RUSH_CAS_TOKEN_ENDPOINT ?? `${baseUrl}/cas/oauth2/token`,\n revokeEndpoint:\n process.env.RUSH_CAS_REVOKE_ENDPOINT ?? `${baseUrl}/cas/oauth2/revoke`,\n clientId: process.env.RUSH_CAS_CLIENT_ID ?? 'rush-ai',\n };\n}\n\nexport interface Principal {\n provider: 'ldap' | 'service';\n subject: string;\n}\n\n/**\n * Build a Principal object from the current auth context.\n * M1: only ldap is supported.\n */\nexport function getPrincipal(subject: string): Principal {\n const method = getAuthMethod();\n return {\n provider: method === 'api_key' ? 'service' : 'ldap',\n subject,\n };\n}\n","export class RushError extends Error {\n public code: string;\n public meta: Record<string, unknown>;\n public exitCode: number;\n\n constructor(\n message: string,\n meta: Record<string, unknown> = {},\n code = 'RUSH_ERROR',\n exitCode = 2\n ) {\n super(message);\n this.name = 'RushError';\n this.code = code;\n this.meta = meta;\n this.exitCode = exitCode;\n }\n}\n\nexport class AuthError extends RushError {\n constructor(message = 'Not authenticated. Run `rush-ai auth login` first.') {\n super(message, {}, 'AUTH_ERROR', 3);\n this.name = 'AuthError';\n }\n}\n\nexport class TaskFailedError extends RushError {\n constructor(message: string, meta: Record<string, unknown> = {}) {\n super(message, meta, 'TASK_FAILED', 1);\n this.name = 'TaskFailedError';\n }\n}\n\n/**\n * Generate a user-friendly error message based on HTTP status.\n * Server-provided error messages take priority.\n */\nfunction friendlyMessage(status: number, serverMessage?: string): string {\n if (serverMessage) return serverMessage;\n\n switch (status) {\n case 401:\n return 'Authentication expired. Run `rush-ai auth login` to re-authenticate.';\n case 403:\n return 'Permission denied. You may not have access to this resource.';\n case 404:\n return 'Resource not found.';\n case 429:\n return 'Rate limited. The server is busy, please try again later.';\n case 502:\n case 503:\n case 504:\n return 'Service temporarily unavailable. Please try again in a moment.';\n default:\n return `Request failed with status ${status}.`;\n }\n}\n\nexport class ApiError extends RushError {\n public status: number;\n public retryAfter?: string;\n\n constructor(\n message: string,\n status: number,\n body?: string,\n retryAfter?: string\n ) {\n // Try to extract server error message from body\n let serverMessage: string | undefined;\n if (body) {\n try {\n const parsed = JSON.parse(body);\n if (parsed.error && typeof parsed.error === 'string') {\n serverMessage = parsed.error;\n }\n } catch {\n // Not JSON\n }\n }\n\n super(\n friendlyMessage(status, serverMessage),\n { status, body },\n 'API_ERROR'\n );\n this.name = 'ApiError';\n this.status = status;\n this.retryAfter = retryAfter;\n }\n}\n\nexport function isRushError(error: unknown): error is RushError {\n return error instanceof RushError;\n}\n","let _verbose = false;\nlet _debug = false;\n\nexport function setVerbosity(verbose: boolean, debug: boolean): void {\n _debug = debug;\n _verbose = verbose || debug;\n}\n\nexport const isVerbose = (): boolean => _verbose;\nexport const isDebug = (): boolean => _debug;\n","import { getAuthToken, getCasConfig } from './auth.js';\nimport { getAuthConfig, getGlobalConfig, setAuthConfig } from './config.js';\n\nconst VERIFY_PATH = '/api/skill-auth/me';\nconst REFRESH_SKEW_MS = 60_000;\nconst AUTH_REQUEST_TIMEOUT_MS = 8_000;\n\ninterface RefreshTokenResponse {\n access_token: string;\n expires_in?: number;\n refresh_token?: string;\n}\n\nexport interface AuthVerificationResult {\n valid: boolean;\n status: number | null;\n message?: string;\n}\n\nexport interface RefreshOptions {\n force?: boolean;\n refreshWindowMs?: number;\n}\n\nfunction getApiBaseUrl(): string {\n return process.env.RUSH_API_URL ?? getGlobalConfig().api;\n}\n\nfunction buildBearerHeaders(token: string): Record<string, string> {\n return {\n Authorization: `Bearer ${token}`,\n 'Content-Type': 'application/json',\n 'User-Agent': 'rush-ai/0.2.0',\n };\n}\n\nfunction shouldRefreshToken(options?: RefreshOptions): boolean {\n const auth = getAuthConfig();\n // Platform tokens don't support refresh; only CAS tokens do\n if (!auth.token || auth.method !== 'cas' || !auth.refreshToken) {\n return false;\n }\n if (options?.force) {\n return true;\n }\n if (!auth.expiresAt) {\n return false;\n }\n const refreshWindowMs = options?.refreshWindowMs ?? REFRESH_SKEW_MS;\n return Date.now() >= auth.expiresAt - refreshWindowMs;\n}\n\nexport async function refreshCasAccessToken(\n options?: RefreshOptions\n): Promise<boolean> {\n if (process.env.RUSH_API_KEY || !shouldRefreshToken(options)) {\n return false;\n }\n\n const auth = getAuthConfig();\n if (!auth.refreshToken) {\n return false;\n }\n\n const cas = getCasConfig();\n const body = new URLSearchParams({\n grant_type: 'refresh_token',\n refresh_token: auth.refreshToken,\n client_id: cas.clientId,\n }).toString();\n\n try {\n const response = await fetch(cas.tokenEndpoint, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n body,\n signal: AbortSignal.timeout(AUTH_REQUEST_TIMEOUT_MS),\n });\n\n if (!response.ok) {\n return false;\n }\n\n const tokenData = (await response.json()) as RefreshTokenResponse;\n if (!tokenData.access_token) {\n return false;\n }\n\n const expiresAt = tokenData.expires_in\n ? Date.now() + tokenData.expires_in * 1000\n : auth.expiresAt;\n\n setAuthConfig({\n token: tokenData.access_token,\n expiresAt,\n refreshToken: tokenData.refresh_token ?? auth.refreshToken,\n method: 'cas',\n });\n\n return true;\n } catch {\n return false;\n }\n}\n\nexport async function verifyTokenOnline(\n token: string\n): Promise<AuthVerificationResult> {\n const url = `${getApiBaseUrl()}${VERIFY_PATH}`;\n\n try {\n const response = await fetch(url, {\n method: 'GET',\n headers: buildBearerHeaders(token),\n signal: AbortSignal.timeout(AUTH_REQUEST_TIMEOUT_MS),\n });\n\n if (response.ok) {\n return { valid: true, status: response.status };\n }\n\n const message = await response.text().catch(() => undefined);\n return {\n valid: false,\n status: response.status,\n message: message || `Server rejected token (${response.status})`,\n };\n } catch (error) {\n return {\n valid: false,\n status: null,\n message: `Network error: ${error instanceof Error ? error.message : 'unknown'}`,\n };\n }\n}\n\nexport async function verifyCurrentAuthSession(): Promise<AuthVerificationResult> {\n const token = getAuthToken();\n if (!token) {\n return {\n valid: false,\n status: null,\n message: 'Not authenticated',\n };\n }\n\n await refreshCasAccessToken();\n\n let activeToken = getAuthToken();\n if (!activeToken) {\n return {\n valid: false,\n status: null,\n message: 'Not authenticated',\n };\n }\n\n const result = await verifyTokenOnline(activeToken);\n if (result.valid || result.status !== 401 || process.env.RUSH_API_KEY) {\n return result;\n }\n\n const refreshed = await refreshCasAccessToken({ force: true });\n if (!refreshed) {\n return result;\n }\n\n activeToken = getAuthToken();\n if (!activeToken) {\n return result;\n }\n return verifyTokenOnline(activeToken);\n}\n\nasync function revokeToken(\n revokeEndpoint: string,\n clientId: string,\n token: string,\n tokenTypeHint: 'access_token' | 'refresh_token'\n): Promise<boolean> {\n const body = new URLSearchParams({\n token,\n token_type_hint: tokenTypeHint,\n client_id: clientId,\n }).toString();\n\n try {\n const response = await fetch(revokeEndpoint, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n body,\n signal: AbortSignal.timeout(AUTH_REQUEST_TIMEOUT_MS),\n });\n return response.ok;\n } catch {\n return false;\n }\n}\n\nexport async function revokeCurrentSession(): Promise<boolean> {\n if (process.env.RUSH_API_KEY) {\n return false;\n }\n\n const auth = getAuthConfig();\n\n if (auth.method === 'platform_token') {\n return revokePlatformToken();\n }\n\n if (auth.method !== 'cas') {\n return false;\n }\n\n const cas = getCasConfig();\n const candidates: Array<{\n token: string;\n hint: 'access_token' | 'refresh_token';\n }> = [];\n if (auth.refreshToken) {\n candidates.push({ token: auth.refreshToken, hint: 'refresh_token' });\n }\n if (auth.token) {\n candidates.push({ token: auth.token, hint: 'access_token' });\n }\n\n if (candidates.length === 0) {\n return false;\n }\n\n let anyRevoked = false;\n for (const candidate of candidates) {\n const revoked = await revokeToken(\n cas.revokeEndpoint,\n cas.clientId,\n candidate.token,\n candidate.hint\n );\n if (revoked) {\n anyRevoked = true;\n }\n }\n\n return anyRevoked;\n}\n\n/** @deprecated Use revokeCurrentSession instead */\nexport const revokeCurrentCasSession = revokeCurrentSession;\n\nasync function revokePlatformToken(): Promise<boolean> {\n const auth = getAuthConfig();\n if (!auth.tokenId || !auth.token) {\n return false;\n }\n\n const baseUrl = getApiBaseUrl();\n const url = `${baseUrl}/api/platform-tokens?id=${encodeURIComponent(auth.tokenId)}`;\n\n try {\n const response = await fetch(url, {\n method: 'DELETE',\n headers: {\n Authorization: `Bearer ${auth.token}`,\n 'User-Agent': 'rush-ai/0.2.0',\n },\n signal: AbortSignal.timeout(AUTH_REQUEST_TIMEOUT_MS),\n });\n return response.ok;\n } catch {\n return false;\n }\n}\n","import { ApiError, RushError } from './errors.js';\n\nexport interface RetryOptions {\n /** Maximum number of retries (default: 3, total attempts = maxRetries + 1) */\n maxRetries?: number;\n /** Base delay in ms for exponential backoff (default: 1000) */\n baseDelay?: number;\n /** Maximum delay in ms (default: 30000) */\n maxDelay?: number;\n /** HTTP status codes eligible for retry (default: [429, 502, 503, 504]) */\n retryableStatuses?: number[];\n /** AbortSignal to cancel retries */\n signal?: AbortSignal;\n /** Called before each retry with attempt number (1-based) and delay in ms */\n onRetry?: (attempt: number, delayMs: number, status?: number) => void;\n}\n\n/**\n * Parse the Retry-After HTTP header value.\n * Supports both seconds (integer) and HTTP-date formats.\n * Returns delay in milliseconds, or null if unparseable.\n */\nexport function parseRetryAfter(value: string): number | null {\n // Try as integer seconds first\n const seconds = Number(value);\n if (!Number.isNaN(seconds) && seconds >= 0) {\n return seconds * 1000;\n }\n\n // Try as HTTP-date\n const date = new Date(value);\n if (!Number.isNaN(date.getTime())) {\n const delayMs = date.getTime() - Date.now();\n return delayMs > 0 ? delayMs : 0;\n }\n\n return null;\n}\n\n/**\n * Calculate delay with exponential backoff and jitter.\n */\nfunction calculateDelay(\n attempt: number,\n baseDelay: number,\n maxDelay: number\n): number {\n const exponential = baseDelay * 2 ** attempt;\n const jitter = Math.random() * baseDelay * 0.5;\n return Math.min(exponential + jitter, maxDelay);\n}\n\nfunction isRetryableError(\n error: unknown,\n retryableStatuses: number[]\n): boolean {\n // Network errors (fetch failures) are retryable\n if (error instanceof RushError && error.code === 'NETWORK_ERROR') {\n return true;\n }\n\n // API errors with retryable status codes\n if (error instanceof ApiError && retryableStatuses.includes(error.status)) {\n return true;\n }\n\n return false;\n}\n\nfunction getRetryAfterFromError(error: unknown): number | null {\n if (error instanceof ApiError && error.status === 429) {\n // Use Retry-After HTTP header (propagated via ApiError.retryAfter)\n if (error.retryAfter) {\n return parseRetryAfter(error.retryAfter);\n }\n }\n return null;\n}\n\n/**\n * Wrap an async function with retry logic using exponential backoff.\n *\n * Important: This should only be used for idempotent operations.\n * The caller (RushClient) is responsible for only wrapping GET/HEAD/DELETE.\n */\nexport async function withRetry<T>(\n fn: () => Promise<T>,\n options: RetryOptions = {}\n): Promise<T> {\n const {\n maxRetries = 3,\n baseDelay = 1000,\n maxDelay = 30_000,\n retryableStatuses = [429, 502, 503, 504],\n signal,\n onRetry,\n } = options;\n\n let lastError: unknown;\n\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n // Check abort before each attempt\n if (signal?.aborted) {\n throw lastError ?? new RushError('Request aborted', {}, 'ABORT_ERROR');\n }\n\n try {\n return await fn();\n } catch (error) {\n lastError = error;\n\n // Don't retry if this is the last attempt\n if (attempt >= maxRetries) {\n throw error;\n }\n\n // Don't retry non-retryable errors\n if (!isRetryableError(error, retryableStatuses)) {\n throw error;\n }\n\n // Check abort before waiting\n if (signal?.aborted) {\n throw error;\n }\n\n // Calculate delay: use Retry-After if available (for 429), otherwise backoff\n let delayMs: number;\n const retryAfterMs = getRetryAfterFromError(error);\n if (retryAfterMs !== null) {\n // Cap Retry-After at 120 seconds\n delayMs = Math.min(retryAfterMs, 120_000);\n } else {\n delayMs = calculateDelay(attempt, baseDelay, maxDelay);\n }\n\n const status = error instanceof ApiError ? error.status : undefined;\n onRetry?.(attempt + 1, delayMs, status);\n\n // Wait with abort support\n await new Promise<void>((resolve, reject) => {\n const timer = setTimeout(resolve, delayMs);\n if (signal) {\n const onAbort = () => {\n clearTimeout(timer);\n reject(lastError);\n };\n signal.addEventListener('abort', onAbort, { once: true });\n // Clean up listener after timer fires\n const origResolve = resolve;\n setTimeout(() => {\n signal.removeEventListener('abort', onAbort);\n origResolve();\n }, delayMs);\n }\n });\n }\n }\n\n // Should never reach here, but TypeScript needs it\n throw lastError;\n}\n","import { output } from '../output/logger.js';\nimport { VERSION } from '../version.js';\nimport { getAuthToken } from './auth.js';\nimport { refreshCasAccessToken } from './auth-session.js';\nimport { getAuthConfig, getGlobalConfig } from './config.js';\nimport { ApiError, RushError } from './errors.js';\nimport { withRetry } from './retry.js';\nimport { isDebug, isVerbose } from './verbosity.js';\n\nconst SENSITIVE_HEADERS = [\n 'authorization',\n 'cookie',\n 'set-cookie',\n 'x-api-key',\n];\n\nfunction maskSensitiveHeaders(headers: Headers): Record<string, string> {\n const result: Record<string, string> = {};\n headers.forEach((value, key) => {\n result[key] = SENSITIVE_HEADERS.includes(key.toLowerCase())\n ? '[REDACTED]'\n : value;\n });\n return result;\n}\n\nexport interface FetchOptions extends RequestInit {\n json?: boolean;\n}\n\nexport interface ApiResponse<T = unknown> {\n ok: boolean;\n status: number;\n data: T;\n}\n\nexport interface ApiErrorBody {\n error: string;\n code: string;\n retryable: boolean;\n}\n\nexport class RushClient {\n private baseUrl: string;\n\n constructor() {\n const config = getGlobalConfig();\n const raw = process.env.RUSH_API_URL ?? config.api;\n this.baseUrl = raw.replace(/\\/+$/, '');\n }\n\n private async getHeaders(): Promise<Record<string, string>> {\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'User-Agent': `rush-ai/${VERSION}`,\n };\n\n if (!process.env.RUSH_API_KEY) {\n await refreshCasAccessToken();\n }\n\n const token = getAuthToken();\n if (token) {\n // Both CAS token and service account API key (rush_sk_*) use Bearer.\n // Backend distinguishes by the rush_sk_ prefix.\n headers.Authorization = `Bearer ${token}`;\n }\n\n // Test mode: skip CAS auth in non-production environments\n if (process.env.RUSH_TEST_MODE === 'integration-test') {\n headers['X-Test-Mode'] = 'integration-test';\n }\n\n return headers;\n }\n\n /**\n * Merge default headers with per-request overrides. A `null` override value\n * drops the default entirely — used by multipart POSTs that need fetch to\n * synthesize its own Content-Type with a boundary. An empty string stays as\n * an empty-value header so callers can still send one intentionally.\n */\n private mergeHeaders(\n base: Record<string, string>,\n overrides: Record<string, string | null>\n ): Record<string, string> {\n const merged: Record<string, string> = { ...base };\n for (const [key, value] of Object.entries(overrides)) {\n if (value === null) {\n delete merged[key];\n } else {\n merged[key] = value;\n }\n }\n return merged;\n }\n\n private async performRequest(\n url: string,\n options: RequestInit,\n retryOnUnauthorized = true\n ): Promise<Response> {\n // Override headers may use `null` as a sentinel to drop a default\n // (see mergeHeaders). The public fetch signature doesn't know about this,\n // so we cast narrowly here.\n const requestHeaders =\n (options.headers as Record<string, string | null>) ?? {};\n const headers = await this.getHeaders();\n\n try {\n const response = await fetch(url, {\n ...options,\n headers: this.mergeHeaders(headers, requestHeaders),\n });\n\n if (\n response.status === 401 &&\n retryOnUnauthorized &&\n !process.env.RUSH_API_KEY\n ) {\n const auth = getAuthConfig();\n const canRefresh = auth.method === 'cas' && Boolean(auth.refreshToken);\n if (canRefresh && (await refreshCasAccessToken({ force: true }))) {\n const retryHeaders = await this.getHeaders();\n return await fetch(url, {\n ...options,\n headers: this.mergeHeaders(retryHeaders, requestHeaders),\n });\n }\n }\n\n return response;\n } catch (err) {\n throw new RushError(\n `Network error: ${err instanceof Error ? err.message : 'Failed to connect'}`,\n { url },\n 'NETWORK_ERROR'\n );\n }\n }\n\n /** Idempotent HTTP methods eligible for automatic retry */\n private static readonly RETRYABLE_METHODS = ['GET', 'HEAD', 'DELETE'];\n\n /**\n * Internal fetch with response parsing and error handling (no retry).\n */\n private async _doFetch<T = unknown>(\n path: string,\n options: FetchOptions = {}\n ): Promise<ApiResponse<T>> {\n const { json = true, ...fetchOptions } = options;\n const url = `${this.baseUrl}${path}`;\n const method = (fetchOptions.method ?? 'GET').toUpperCase();\n const startTime = Date.now();\n\n if (isVerbose()) {\n output.dim(`→ ${method} ${url}`);\n }\n\n const response = await this.performRequest(url, fetchOptions);\n\n if (isVerbose()) {\n output.dim(\n `← ${response.status} ${response.statusText} (${Date.now() - startTime}ms)`\n );\n }\n\n if (isDebug()) {\n output.dim(\n ` Response headers: ${JSON.stringify(maskSensitiveHeaders(response.headers))}`\n );\n }\n\n if (!response.ok) {\n const errorBody = await response.text().catch(() => 'Unknown error');\n const retryAfter = response.headers.get('retry-after') ?? undefined;\n\n throw new ApiError(\n `API request failed: ${response.status} ${response.statusText}`,\n response.status,\n errorBody,\n retryAfter\n );\n }\n\n const data = json\n ? ((await response.json()) as T)\n : ((await response.text()) as T);\n\n return {\n ok: true,\n status: response.status,\n data,\n };\n }\n\n /**\n * Fetch with response parsing, error handling, and automatic retry\n * for idempotent methods (GET, HEAD, DELETE).\n */\n async fetch<T = unknown>(\n path: string,\n options: FetchOptions = {}\n ): Promise<ApiResponse<T>> {\n const method = (options.method ?? 'GET').toUpperCase();\n const isRetryable = RushClient.RETRYABLE_METHODS.includes(method);\n\n if (!isRetryable) {\n return this._doFetch<T>(path, options);\n }\n\n return withRetry(() => this._doFetch<T>(path, options), {\n signal: options.signal ?? undefined,\n onRetry: (attempt, delayMs, status) => {\n const statusInfo = status ? ` (${status})` : '';\n console.error(\n `\\u27F3 Retrying ${method} ${path}${statusInfo} (attempt ${attempt}) in ${(delayMs / 1000).toFixed(1)}s...`\n );\n },\n });\n }\n\n /**\n * Raw fetch for streaming (SSE) responses.\n * Returns the raw Response object.\n */\n async fetchRaw(path: string, options: RequestInit = {}): Promise<Response> {\n const url = `${this.baseUrl}${path}`;\n\n const response = await this.performRequest(url, options);\n\n if (!response.ok) {\n const errorBody = await response.text().catch(() => 'Unknown error');\n throw new ApiError(\n `API request failed: ${response.status} ${response.statusText}`,\n response.status,\n errorBody\n );\n }\n\n return response;\n }\n\n async get<T = unknown>(path: string): Promise<ApiResponse<T>> {\n return this.fetch<T>(path, { method: 'GET' });\n }\n\n async post<T = unknown>(\n path: string,\n body?: unknown\n ): Promise<ApiResponse<T>> {\n return this.fetch<T>(path, {\n method: 'POST',\n body: body ? JSON.stringify(body) : undefined,\n });\n }\n\n /**\n * POST multipart/form-data. The default `Content-Type: application/json`\n * must be removed so fetch can set its own multipart boundary — passing\n * `null` as the header value tells mergeHeaders to drop the key.\n */\n async postFormData<T = unknown>(\n path: string,\n formData: FormData\n ): Promise<ApiResponse<T>> {\n return this._doFetch<T>(path, {\n method: 'POST',\n body: formData,\n // Cast: RequestInit.headers doesn't include null; mergeHeaders handles it.\n headers: { 'Content-Type': null } as unknown as HeadersInit,\n });\n }\n\n async put<T = unknown>(\n path: string,\n body?: unknown\n ): Promise<ApiResponse<T>> {\n return this.fetch<T>(path, {\n method: 'PUT',\n body: body ? JSON.stringify(body) : undefined,\n });\n }\n\n async delete<T = unknown>(path: string): Promise<ApiResponse<T>> {\n return this.fetch<T>(path, { method: 'DELETE' });\n }\n}\n\nexport function createClient(): RushClient {\n return new RushClient();\n}\n"],"mappings":";;;AAAA,OAAO,WAAW;AAYX,IAAM,SAAS;AAAA;AAAA,EAEpB,IAAI,SAAuB;AACzB,YAAQ,IAAI,O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,SAAS,CAAC;AAAA,EACjD;AACF;AAEO,SAAS,eAA2B;AACzC,SAAO,IAAI,WAAW;AACxB;","names":["resolve","resolve"]}
|
package/dist/index.js
CHANGED
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
setGlobalConfig,
|
|
38
38
|
setVerbosity,
|
|
39
39
|
verifyCurrentAuthSession
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-YKZIRW26.js";
|
|
41
41
|
|
|
42
42
|
// src/index.ts
|
|
43
43
|
import chalk7 from "chalk";
|
|
@@ -404,6 +404,11 @@ async function loginViaBrowser(jsonMode) {
|
|
|
404
404
|
const baseUrl = getApiBaseUrl();
|
|
405
405
|
const state = randomBytes(16).toString("hex");
|
|
406
406
|
return new Promise((resolve21, reject) => {
|
|
407
|
+
let authSaved = false;
|
|
408
|
+
const rejectLogin = (error) => {
|
|
409
|
+
clearAuthConfig();
|
|
410
|
+
reject(error);
|
|
411
|
+
};
|
|
407
412
|
const server = createServer(async (req, res) => {
|
|
408
413
|
try {
|
|
409
414
|
const url = new URL(req.url ?? "/", "http://localhost");
|
|
@@ -426,7 +431,7 @@ async function loginViaBrowser(jsonMode) {
|
|
|
426
431
|
)
|
|
427
432
|
);
|
|
428
433
|
server.close();
|
|
429
|
-
|
|
434
|
+
rejectLogin(new AuthError(`Browser authentication failed: ${desc}`));
|
|
430
435
|
return;
|
|
431
436
|
}
|
|
432
437
|
if (!code || returnedState !== state) {
|
|
@@ -439,7 +444,7 @@ async function loginViaBrowser(jsonMode) {
|
|
|
439
444
|
)
|
|
440
445
|
);
|
|
441
446
|
server.close();
|
|
442
|
-
|
|
447
|
+
rejectLogin(
|
|
443
448
|
new AuthError("Invalid callback: missing code or state mismatch")
|
|
444
449
|
);
|
|
445
450
|
return;
|
|
@@ -461,7 +466,7 @@ async function loginViaBrowser(jsonMode) {
|
|
|
461
466
|
)
|
|
462
467
|
);
|
|
463
468
|
server.close();
|
|
464
|
-
|
|
469
|
+
rejectLogin(new AuthError(`Token exchange failed: ${errorText}`));
|
|
465
470
|
return;
|
|
466
471
|
}
|
|
467
472
|
const tokenData = await tokenResponse.json();
|
|
@@ -474,6 +479,7 @@ async function loginViaBrowser(jsonMode) {
|
|
|
474
479
|
tokenId: tokenData.token_id,
|
|
475
480
|
sourceUrl: baseUrl
|
|
476
481
|
});
|
|
482
|
+
authSaved = true;
|
|
477
483
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
478
484
|
res.end(
|
|
479
485
|
getHtmlPage(
|
|
@@ -503,11 +509,14 @@ async function loginViaBrowser(jsonMode) {
|
|
|
503
509
|
resolve21();
|
|
504
510
|
} catch (err) {
|
|
505
511
|
server.close();
|
|
506
|
-
|
|
507
|
-
err instanceof
|
|
508
|
-
`Authentication error: ${err instanceof Error ? err.message : "Unknown"}`
|
|
509
|
-
)
|
|
512
|
+
const authError = err instanceof AuthError ? err : new AuthError(
|
|
513
|
+
`Authentication error: ${err instanceof Error ? err.message : "Unknown"}`
|
|
510
514
|
);
|
|
515
|
+
if (authSaved) {
|
|
516
|
+
reject(authError);
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
rejectLogin(authError);
|
|
511
520
|
}
|
|
512
521
|
});
|
|
513
522
|
server.listen(0, "127.0.0.1", () => {
|
|
@@ -530,7 +539,7 @@ async function loginViaBrowser(jsonMode) {
|
|
|
530
539
|
});
|
|
531
540
|
const timeoutId = setTimeout(() => {
|
|
532
541
|
server.close();
|
|
533
|
-
|
|
542
|
+
rejectLogin(new AuthError("Authentication timed out after 5 minutes"));
|
|
534
543
|
}, 3e5);
|
|
535
544
|
server.on("close", () => clearTimeout(timeoutId));
|
|
536
545
|
});
|
|
@@ -909,6 +918,17 @@ function hasUncommittedChanges(projectPath) {
|
|
|
909
918
|
return false;
|
|
910
919
|
}
|
|
911
920
|
}
|
|
921
|
+
function hasAnyCommit(projectPath) {
|
|
922
|
+
try {
|
|
923
|
+
execFileSync("git", ["rev-parse", "--verify", "--quiet", "HEAD"], {
|
|
924
|
+
cwd: projectPath,
|
|
925
|
+
stdio: "pipe"
|
|
926
|
+
});
|
|
927
|
+
return true;
|
|
928
|
+
} catch {
|
|
929
|
+
return false;
|
|
930
|
+
}
|
|
931
|
+
}
|
|
912
932
|
function gitAddAndCommit(projectPath, message) {
|
|
913
933
|
execFileSync("git", ["add", "-A"], { cwd: projectPath, stdio: "pipe" });
|
|
914
934
|
execFileSync("git", ["commit", "-m", message, "--allow-empty"], {
|
|
@@ -3798,7 +3818,7 @@ function truncate3(str, max) {
|
|
|
3798
3818
|
function registerMcpCommand(program) {
|
|
3799
3819
|
const mcp = program.command("mcp").description("MCP server and platform MCP discovery");
|
|
3800
3820
|
mcp.command("serve").description("Start the MCP stdio server").action(async () => {
|
|
3801
|
-
const { startMcpServer } = await import("./server-
|
|
3821
|
+
const { startMcpServer } = await import("./server-Y2CXHDCK.js");
|
|
3802
3822
|
await startMcpServer();
|
|
3803
3823
|
});
|
|
3804
3824
|
mcp.command("list").alias("ls").description("List available MCP servers on the platform").option("-c, --category <category>", "Filter by category").option("-t, --tag <tag>", "Filter by tag").option("-s, --search <query>", "Search by name or description").option("--transport <type>", "Filter by transport type (stdio|sse|http)").option(
|
|
@@ -3920,7 +3940,7 @@ function registerMcpCommand(program) {
|
|
|
3920
3940
|
"Set credential values (e.g. --set TOKEN=xxx KEY=yyy)"
|
|
3921
3941
|
).action(async (mcpId, opts) => {
|
|
3922
3942
|
const format = resolveFormat(program.opts());
|
|
3923
|
-
const { runMcpInstall, printMcpInstallSummary } = await import("./install-
|
|
3943
|
+
const { runMcpInstall, printMcpInstallSummary } = await import("./install-RTV2VWCC.js");
|
|
3924
3944
|
let setValues;
|
|
3925
3945
|
if (opts.set) {
|
|
3926
3946
|
setValues = {};
|
|
@@ -3981,7 +4001,7 @@ function registerMcpCommand(program) {
|
|
|
3981
4001
|
"Comma-separated targets: claude-desktop,claude-code (default: both)"
|
|
3982
4002
|
).action(async (mcpId, opts) => {
|
|
3983
4003
|
const format = resolveFormat(program.opts());
|
|
3984
|
-
const { runMcpUninstall, printMcpUninstallSummary } = await import("./install-
|
|
4004
|
+
const { runMcpUninstall, printMcpUninstallSummary } = await import("./install-RTV2VWCC.js");
|
|
3985
4005
|
try {
|
|
3986
4006
|
const result = await runMcpUninstall({
|
|
3987
4007
|
mcpId,
|
|
@@ -9854,7 +9874,7 @@ function registerPushSubcommand(task, program) {
|
|
|
9854
9874
|
);
|
|
9855
9875
|
}
|
|
9856
9876
|
const previewUrl = taskInfo.previewUrl ?? envFile.PREVIEW_URL ?? null;
|
|
9857
|
-
const chatUrl = `https://rush.zhenguanyu.com/
|
|
9877
|
+
const chatUrl = `https://rush.zhenguanyu.com/next/${projectId}`;
|
|
9858
9878
|
const result = {
|
|
9859
9879
|
projectId,
|
|
9860
9880
|
previewUrl,
|
|
@@ -10082,19 +10102,19 @@ async function preflight(client, projectId, commitHash, env, resolved) {
|
|
|
10082
10102
|
{ taskId: projectId, reason: "nextjs_env_test_unsupported" }
|
|
10083
10103
|
);
|
|
10084
10104
|
}
|
|
10085
|
-
let
|
|
10105
|
+
let availability;
|
|
10086
10106
|
try {
|
|
10087
|
-
|
|
10088
|
-
`/api/projects/${encodeURIComponent(projectId)}/database/
|
|
10107
|
+
availability = await client.get(
|
|
10108
|
+
`/api/projects/${encodeURIComponent(projectId)}/database/availability`
|
|
10089
10109
|
);
|
|
10090
10110
|
} catch (err) {
|
|
10091
10111
|
throw toStepError("preflight", err, { taskId: projectId });
|
|
10092
10112
|
}
|
|
10093
|
-
if (!
|
|
10113
|
+
if (!availability.data.hasSelectedDatabase) {
|
|
10094
10114
|
throw new DeployStepError(
|
|
10095
10115
|
"preflight",
|
|
10096
|
-
"
|
|
10097
|
-
{ taskId: projectId, reason: "
|
|
10116
|
+
"Required database is not configured. Open the Web UI to provision it before deploying.",
|
|
10117
|
+
{ taskId: projectId, reason: "database_not_configured" }
|
|
10098
10118
|
);
|
|
10099
10119
|
}
|
|
10100
10120
|
return;
|
|
@@ -10439,6 +10459,44 @@ function registerLinkSubcommand(task, program) {
|
|
|
10439
10459
|
);
|
|
10440
10460
|
}
|
|
10441
10461
|
const projectId = env.PROJECT_ID;
|
|
10462
|
+
const justProvisionedPod = env.STATE === "pod-only" && !!env.GIT_REMOTE;
|
|
10463
|
+
if (justProvisionedPod && env.GIT_REMOTE) {
|
|
10464
|
+
if (format !== "json") output.info("Pushing local code to Rush...");
|
|
10465
|
+
if (!isGitRepo(projectPath)) {
|
|
10466
|
+
gitInit(projectPath);
|
|
10467
|
+
}
|
|
10468
|
+
if (hasUncommittedChanges(projectPath)) {
|
|
10469
|
+
gitAddAndCommit(projectPath, "link to rush");
|
|
10470
|
+
}
|
|
10471
|
+
if (!hasAnyCommit(projectPath)) {
|
|
10472
|
+
gitAddAndCommit(projectPath, "link to rush");
|
|
10473
|
+
}
|
|
10474
|
+
const pushResult = gitPushUrl(projectPath, env.GIT_REMOTE);
|
|
10475
|
+
if (!pushResult.success) {
|
|
10476
|
+
throw new RushError(
|
|
10477
|
+
`Initial git push failed: ${pushResult.stderr}
|
|
10478
|
+
Check your VPN / SSO session and rerun \`rush-ai task link\`.`,
|
|
10479
|
+
{ projectId },
|
|
10480
|
+
"LINK_PUSH_FAILED",
|
|
10481
|
+
1
|
|
10482
|
+
);
|
|
10483
|
+
}
|
|
10484
|
+
try {
|
|
10485
|
+
const client = createClient();
|
|
10486
|
+
await client.post(
|
|
10487
|
+
"/api/repository/sync/pull",
|
|
10488
|
+
{ projectId }
|
|
10489
|
+
);
|
|
10490
|
+
} catch (err) {
|
|
10491
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
10492
|
+
if (format !== "json") {
|
|
10493
|
+
output.warn(
|
|
10494
|
+
`Pod sync failed (push itself succeeded): ${message}. Run \`rush-ai task push\` to retry if the preview is empty.`
|
|
10495
|
+
);
|
|
10496
|
+
}
|
|
10497
|
+
}
|
|
10498
|
+
if (format !== "json") output.success("Code pushed to Rush");
|
|
10499
|
+
}
|
|
10442
10500
|
const alreadyHasDbCreds = Boolean(env.DATABASE_URL || env.SUPABASE_URL);
|
|
10443
10501
|
if (wantDb && !alreadyHasDbCreds) {
|
|
10444
10502
|
if (format !== "json") output.info("Creating Supabase database...");
|