@bike4mind/cli 0.2.80-fix-cli-unauthenticated-ux.22453 → 0.2.80
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/commands/doctorCommand.mjs +1 -1
- package/dist/commands/headlessCommand.mjs +1 -1
- package/dist/commands/updateCommand.mjs +1 -1
- package/dist/index.mjs +50 -20
- package/dist/{tools-CQoBshaS.mjs → tools-BYBHpm5w.mjs} +8 -13
- package/dist/{updateChecker-BAFVL-0o.mjs → updateChecker-YklUziR2.mjs} +1 -1
- package/package.json +7 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { i as version, n as fetchLatestVersion, r as forceCheckForUpdate } from "../updateChecker-
|
|
2
|
+
import { i as version, n as fetchLatestVersion, r as forceCheckForUpdate } from "../updateChecker-YklUziR2.mjs";
|
|
3
3
|
import { execSync } from "child_process";
|
|
4
4
|
import { constants, existsSync, promises } from "fs";
|
|
5
5
|
import { homedir } from "os";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { B as CustomCommandStore, C as getApiUrl, E as generateCliTools, I as buildCoreSystemPrompt, P as setWebSocketToolExecutor, R as isReadOnlyTool, S as loadContextFiles, T as PermissionManager, U as SessionStore, V as CheckpointStore, _ as ServerLlmBackend, a as createBackgroundAgentTools, c as AgentStore, f as ApiClient, g as WebSocketLlmBackend, h as FallbackLlmBackend, i as createWriteTodosTool, l as SubagentOrchestrator, m as WebSocketConnectionManager, n as createFindDefinitionTool, o as BackgroundAgentManager, p as WebSocketToolExecutor, r as createTodoStore, s as createAgentDelegateTool, t as createGetFileStructureTool, u as createSkillTool, v as McpManager, z as ReActAgent } from "../tools-
|
|
2
|
+
import { B as CustomCommandStore, C as getApiUrl, E as generateCliTools, I as buildCoreSystemPrompt, P as setWebSocketToolExecutor, R as isReadOnlyTool, S as loadContextFiles, T as PermissionManager, U as SessionStore, V as CheckpointStore, _ as ServerLlmBackend, a as createBackgroundAgentTools, c as AgentStore, f as ApiClient, g as WebSocketLlmBackend, h as FallbackLlmBackend, i as createWriteTodosTool, l as SubagentOrchestrator, m as WebSocketConnectionManager, n as createFindDefinitionTool, o as BackgroundAgentManager, p as WebSocketToolExecutor, r as createTodoStore, s as createAgentDelegateTool, t as createGetFileStructureTool, u as createSkillTool, v as McpManager, z as ReActAgent } from "../tools-BYBHpm5w.mjs";
|
|
3
3
|
import { n as logger, t as ConfigStore } from "../ConfigStore-CG7DYbjy.mjs";
|
|
4
4
|
import { t as DEFAULT_SANDBOX_CONFIG } from "../types-DBEjF9YS.mjs";
|
|
5
5
|
import { t as createSandboxRuntime } from "../SandboxRuntimeAdapter-C1B4t20N.mjs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { i as version, r as forceCheckForUpdate } from "../updateChecker-
|
|
2
|
+
import { i as version, r as forceCheckForUpdate } from "../updateChecker-YklUziR2.mjs";
|
|
3
3
|
import { execSync } from "child_process";
|
|
4
4
|
//#region src/commands/updateCommand.ts
|
|
5
5
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { n as useCliStore, t as selectActiveBackgroundAgents } from "./store-Dw1nZX2Y.mjs";
|
|
3
|
-
import { A as DEFAULT_RETRY_CONFIG, B as CustomCommandStore, C as getApiUrl, D as ALWAYS_DENIED_FOR_AGENTS, E as generateCliTools, F as OllamaBackend, G as hasFileReferences, H as CommandHistoryStore, I as buildCoreSystemPrompt, J as mergeCommands, K as processFileReferences, L as buildSkillsPromptSection, M as clearFeatureModuleTools, N as registerFeatureModuleTools, O as DEFAULT_AGENT_MODEL, P as setWebSocketToolExecutor, R as isReadOnlyTool, S as loadContextFiles, T as PermissionManager, U as SessionStore, V as CheckpointStore, W as OAuthClient, X as searchFiles, Y as formatFileSize, Z as warmFileCache, _ as ServerLlmBackend, a as createBackgroundAgentTools, b as formatStep, c as AgentStore, d as parseAgentConfig, f as ApiClient, g as WebSocketLlmBackend, h as FallbackLlmBackend, i as createWriteTodosTool, j as DEFAULT_THOROUGHNESS, k as DEFAULT_MAX_ITERATIONS, l as SubagentOrchestrator, m as WebSocketConnectionManager, n as createFindDefinitionTool, o as BackgroundAgentManager, p as WebSocketToolExecutor, q as searchCommands, r as createTodoStore, s as createAgentDelegateTool, t as createGetFileStructureTool, u as createSkillTool, v as McpManager, w as getEnvironmentName, x as extractCompactInstructions, y as substituteArguments, z as ReActAgent } from "./tools-
|
|
3
|
+
import { A as DEFAULT_RETRY_CONFIG, B as CustomCommandStore, C as getApiUrl, D as ALWAYS_DENIED_FOR_AGENTS, E as generateCliTools, F as OllamaBackend, G as hasFileReferences, H as CommandHistoryStore, I as buildCoreSystemPrompt, J as mergeCommands, K as processFileReferences, L as buildSkillsPromptSection, M as clearFeatureModuleTools, N as registerFeatureModuleTools, O as DEFAULT_AGENT_MODEL, P as setWebSocketToolExecutor, R as isReadOnlyTool, S as loadContextFiles, T as PermissionManager, U as SessionStore, V as CheckpointStore, W as OAuthClient, X as searchFiles, Y as formatFileSize, Z as warmFileCache, _ as ServerLlmBackend, a as createBackgroundAgentTools, b as formatStep, c as AgentStore, d as parseAgentConfig, f as ApiClient, g as WebSocketLlmBackend, h as FallbackLlmBackend, i as createWriteTodosTool, j as DEFAULT_THOROUGHNESS, k as DEFAULT_MAX_ITERATIONS, l as SubagentOrchestrator, m as WebSocketConnectionManager, n as createFindDefinitionTool, o as BackgroundAgentManager, p as WebSocketToolExecutor, q as searchCommands, r as createTodoStore, s as createAgentDelegateTool, t as createGetFileStructureTool, u as createSkillTool, v as McpManager, w as getEnvironmentName, x as extractCompactInstructions, y as substituteArguments, z as ReActAgent } from "./tools-BYBHpm5w.mjs";
|
|
4
4
|
import { Dt as validateJupyterKernelName, Ot as validateNotebookPath$1, g as ChatModels, m as CREDIT_DEDUCT_TRANSACTION_TYPES, n as logger, t as ConfigStore } from "./ConfigStore-CG7DYbjy.mjs";
|
|
5
|
-
import { i as version, t as checkForUpdate } from "./updateChecker-
|
|
5
|
+
import { i as version, t as checkForUpdate } from "./updateChecker-YklUziR2.mjs";
|
|
6
6
|
import React, { useCallback, useEffect, useMemo, useReducer, useRef, useState } from "react";
|
|
7
7
|
import { Box, Static, Text, render, useApp, useInput } from "ink";
|
|
8
8
|
import { execSync } from "child_process";
|
|
@@ -4445,26 +4445,46 @@ function CliApp() {
|
|
|
4445
4445
|
console.warn("Failed to load custom commands:", error instanceof Error ? error.message : String(error));
|
|
4446
4446
|
}
|
|
4447
4447
|
const authTokens = await state.configStore.getAuthTokens();
|
|
4448
|
+
let isAuthenticated = false;
|
|
4448
4449
|
if (!authTokens) {
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4450
|
+
logger.debug("⚠️ Not authenticated.");
|
|
4451
|
+
logger.debug("💡 Run /login to authenticate with your B4M account.");
|
|
4452
|
+
logger.debug("📖 You can still browse help and documentation without authentication.");
|
|
4453
|
+
} else {
|
|
4454
|
+
const expiresAt = new Date(authTokens.expiresAt);
|
|
4455
|
+
if (expiresAt <= /* @__PURE__ */ new Date()) {
|
|
4456
|
+
console.log("\n⚠️ Authentication token expired.");
|
|
4457
|
+
console.log("💡 Run /login to re-authenticate with your B4M account.\n");
|
|
4458
|
+
await state.configStore.clearAuthTokens();
|
|
4459
|
+
} else {
|
|
4460
|
+
isAuthenticated = true;
|
|
4461
|
+
const daysUntilExpiry = Math.floor((expiresAt.getTime() - Date.now()) / (1e3 * 60 * 60 * 24));
|
|
4462
|
+
startupLog.push(`✅ Authenticated (expires in ${daysUntilExpiry} day${daysUntilExpiry !== 1 ? "s" : ""})`);
|
|
4463
|
+
}
|
|
4455
4464
|
}
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4465
|
+
if (!isAuthenticated) {
|
|
4466
|
+
console.log("ℹ️ AI features disabled. Available commands: /login, /help, /config\n");
|
|
4467
|
+
const minimalSession = {
|
|
4468
|
+
id: v4(),
|
|
4469
|
+
name: `Session ${(/* @__PURE__ */ new Date()).toLocaleString()}`,
|
|
4470
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4471
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4472
|
+
model: "unauthenticated",
|
|
4473
|
+
messages: [],
|
|
4474
|
+
metadata: {
|
|
4475
|
+
totalTokens: 0,
|
|
4476
|
+
totalCost: 0,
|
|
4477
|
+
toolCallCount: 0
|
|
4478
|
+
}
|
|
4479
|
+
};
|
|
4460
4480
|
setState((prev) => ({
|
|
4461
4481
|
...prev,
|
|
4462
|
-
|
|
4482
|
+
session: minimalSession,
|
|
4483
|
+
config
|
|
4463
4484
|
}));
|
|
4485
|
+
setIsInitialized(true);
|
|
4464
4486
|
return;
|
|
4465
4487
|
}
|
|
4466
|
-
const daysUntilExpiry = Math.floor((expiresAt.getTime() - Date.now()) / (1e3 * 60 * 60 * 24));
|
|
4467
|
-
startupLog.push(`✅ Authenticated (expires in ${daysUntilExpiry} day${daysUntilExpiry !== 1 ? "s" : ""})`);
|
|
4468
4488
|
const apiBaseURL = getApiUrl(config.apiConfig);
|
|
4469
4489
|
const envName = getEnvironmentName(config.apiConfig);
|
|
4470
4490
|
if (import.meta.url.includes("/src/") || process.env.NODE_ENV === "development" || envName !== "Bike4Mind") console.log(`🌍 API Environment: ${envName} (${apiBaseURL})`);
|
|
@@ -4959,7 +4979,13 @@ function CliApp() {
|
|
|
4959
4979
|
*/
|
|
4960
4980
|
const handleCustomCommandMessage = async (fullTemplate, displayMessage) => {
|
|
4961
4981
|
if (!state.agent || !state.session) {
|
|
4962
|
-
console.error("❌
|
|
4982
|
+
console.error("❌ Agent or session not initialized");
|
|
4983
|
+
return;
|
|
4984
|
+
}
|
|
4985
|
+
const authTokens = await state.configStore.getAuthTokens();
|
|
4986
|
+
if (!authTokens || new Date(authTokens.expiresAt) <= /* @__PURE__ */ new Date()) {
|
|
4987
|
+
console.log("\n❌ Authentication required to use AI features.");
|
|
4988
|
+
console.log("💡 Run /login to authenticate with your B4M account.\n");
|
|
4963
4989
|
return;
|
|
4964
4990
|
}
|
|
4965
4991
|
useCliStore.getState().setIsThinking(true);
|
|
@@ -5169,11 +5195,17 @@ function CliApp() {
|
|
|
5169
5195
|
};
|
|
5170
5196
|
const handleMessage = async (message) => {
|
|
5171
5197
|
if (!state.agent || !state.session) {
|
|
5172
|
-
console.error("❌
|
|
5198
|
+
console.error("❌ Agent or session not initialized");
|
|
5173
5199
|
return;
|
|
5174
5200
|
}
|
|
5175
5201
|
await state.commandHistoryStore.add(message);
|
|
5176
5202
|
setCommandHistory(await state.commandHistoryStore.list());
|
|
5203
|
+
const authTokens = await state.configStore.getAuthTokens();
|
|
5204
|
+
if (!authTokens || new Date(authTokens.expiresAt) <= /* @__PURE__ */ new Date()) {
|
|
5205
|
+
console.log("\n❌ Authentication required to use AI features.");
|
|
5206
|
+
console.log("💡 Run /login to authenticate with your B4M account.\n");
|
|
5207
|
+
return;
|
|
5208
|
+
}
|
|
5177
5209
|
const config = state.config;
|
|
5178
5210
|
let activeSession = state.session;
|
|
5179
5211
|
if (config?.preferences.autoCompact !== false && activeSession.messages.length >= 6) {
|
|
@@ -6807,9 +6839,7 @@ Multi-line Input:
|
|
|
6807
6839
|
...prev,
|
|
6808
6840
|
showLoginFlow: false
|
|
6809
6841
|
}));
|
|
6810
|
-
console.error(`\n❌ Login failed: ${error.message}`);
|
|
6811
|
-
console.log("Run b4m again when you're ready to authenticate.\n");
|
|
6812
|
-
exit();
|
|
6842
|
+
console.error(`\n❌ Login failed: ${error.message}\n`);
|
|
6813
6843
|
}
|
|
6814
6844
|
});
|
|
6815
6845
|
}
|
|
@@ -19514,18 +19514,14 @@ var ApiClient = class {
|
|
|
19514
19514
|
}, (error) => Promise.reject(error));
|
|
19515
19515
|
this.client.interceptors.response.use((response) => response, async (error) => {
|
|
19516
19516
|
const originalRequest = error.config;
|
|
19517
|
-
if (error.response?.status === 401) logger.
|
|
19517
|
+
if (error.response?.status === 401) logger.error("401 Unauthorized", error);
|
|
19518
19518
|
else if (error.response?.status === 403) logger.error("403 Forbidden", error);
|
|
19519
19519
|
if (error.response?.status === 401 && !originalRequest._retry) {
|
|
19520
19520
|
originalRequest._retry = true;
|
|
19521
|
+
logger.debug("AUTH: Attempting token refresh");
|
|
19521
19522
|
try {
|
|
19522
19523
|
const tokens = await this.configStore.getAuthTokens();
|
|
19523
19524
|
if (!tokens) throw new Error("Not authenticated");
|
|
19524
|
-
if (Date.now() - (new Date(tokens.expiresAt).getTime() - 10080 * 60 * 1e3) < 3600 * 1e3) {
|
|
19525
|
-
logger.debug("AUTH: Access token is fresh, skipping refresh — 401 is likely transient");
|
|
19526
|
-
return Promise.reject(error);
|
|
19527
|
-
}
|
|
19528
|
-
logger.debug("AUTH: Attempting token refresh");
|
|
19529
19525
|
const newTokens = await this.oauthClient.refreshToken(tokens.refreshToken);
|
|
19530
19526
|
logger.debug("AUTH: Token refresh successful");
|
|
19531
19527
|
const expiresAt = new Date(Date.now() + newTokens.expires_in * 1e3).toISOString();
|
|
@@ -19539,17 +19535,16 @@ var ApiClient = class {
|
|
|
19539
19535
|
logger.debug("AUTH: Retrying request with new token");
|
|
19540
19536
|
return this.client(originalRequest);
|
|
19541
19537
|
} catch (refreshError) {
|
|
19542
|
-
|
|
19543
|
-
|
|
19544
|
-
|
|
19545
|
-
|
|
19538
|
+
console.error("❌ Token refresh failed:", refreshError instanceof Error ? refreshError.message : "Unknown error");
|
|
19539
|
+
console.log("Please run `b4m login` again to re-authenticate.");
|
|
19540
|
+
logger.error("AUTH: Token refresh failed", refreshError);
|
|
19541
|
+
await this.configStore.clearAuthTokens();
|
|
19546
19542
|
throw new Error("Authentication expired. Please run `b4m login` again.");
|
|
19547
19543
|
}
|
|
19548
19544
|
}
|
|
19549
19545
|
if (error.response?.status === 401 && originalRequest._retry) {
|
|
19550
|
-
logger.debug("AUTH: Token refresh retry failed");
|
|
19551
|
-
|
|
19552
|
-
if (tokens && new Date(tokens.expiresAt) <= /* @__PURE__ */ new Date()) await this.configStore.clearAuthTokens();
|
|
19546
|
+
logger.debug("AUTH: Token refresh retry failed - clearing tokens");
|
|
19547
|
+
await this.configStore.clearAuthTokens();
|
|
19553
19548
|
throw new Error("Authentication failed. Please run /login to authenticate.");
|
|
19554
19549
|
}
|
|
19555
19550
|
return Promise.reject(error);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bike4mind/cli",
|
|
3
|
-
"version": "0.2.80
|
|
3
|
+
"version": "0.2.80",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Interactive CLI tool for Bike4Mind with ReAct agents",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -115,11 +115,11 @@
|
|
|
115
115
|
"zustand": "^4.5.4"
|
|
116
116
|
},
|
|
117
117
|
"devDependencies": {
|
|
118
|
-
"@bike4mind/agents": "0.4.
|
|
119
|
-
"@bike4mind/common": "2.85.
|
|
120
|
-
"@bike4mind/mcp": "1.35.
|
|
121
|
-
"@bike4mind/services": "2.75.3
|
|
122
|
-
"@bike4mind/utils": "2.17.
|
|
118
|
+
"@bike4mind/agents": "0.4.16",
|
|
119
|
+
"@bike4mind/common": "2.85.1",
|
|
120
|
+
"@bike4mind/mcp": "1.35.1",
|
|
121
|
+
"@bike4mind/services": "2.75.3",
|
|
122
|
+
"@bike4mind/utils": "2.17.3",
|
|
123
123
|
"@types/better-sqlite3": "^7.6.13",
|
|
124
124
|
"@types/jsonwebtoken": "^9.0.4",
|
|
125
125
|
"@types/node": "^22.9.0",
|
|
@@ -136,5 +136,5 @@
|
|
|
136
136
|
"optionalDependencies": {
|
|
137
137
|
"@vscode/ripgrep": "^1.17.1"
|
|
138
138
|
},
|
|
139
|
-
"gitHead": "
|
|
139
|
+
"gitHead": "81da56edf940f3dd9fbabcc1ee6baf83d5e61b16"
|
|
140
140
|
}
|