mpd-llm-cli 0.1.38 → 0.1.39
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/bundle/api.js +2 -2
- package/bundle/gemini.js +136 -9
- package/package.json +1 -1
package/bundle/api.js
CHANGED
|
@@ -27724,7 +27724,7 @@ async function createContentGeneratorConfig(model, authType) {
|
|
|
27724
27724
|
return contentGeneratorConfig;
|
|
27725
27725
|
}
|
|
27726
27726
|
async function createContentGenerator(config2, sessionId2) {
|
|
27727
|
-
const version2 = "0.1.
|
|
27727
|
+
const version2 = "0.1.39";
|
|
27728
27728
|
const httpOptions = {
|
|
27729
27729
|
headers: {
|
|
27730
27730
|
"User-Agent": `GeminiCLI/${version2} (${process.platform}; ${process.arch})`
|
|
@@ -166412,7 +166412,7 @@ async function getPackageJson() {
|
|
|
166412
166412
|
// packages/cli/src/utils/version.ts
|
|
166413
166413
|
async function getCliVersion() {
|
|
166414
166414
|
const pkgJson = await getPackageJson();
|
|
166415
|
-
return "0.1.
|
|
166415
|
+
return "0.1.39";
|
|
166416
166416
|
}
|
|
166417
166417
|
|
|
166418
166418
|
// packages/cli/src/config/sandboxConfig.ts
|
package/bundle/gemini.js
CHANGED
|
@@ -62351,7 +62351,7 @@ async function createContentGeneratorConfig(model, authType) {
|
|
|
62351
62351
|
return contentGeneratorConfig;
|
|
62352
62352
|
}
|
|
62353
62353
|
async function createContentGenerator(config2, sessionId2) {
|
|
62354
|
-
const version3 = "0.1.
|
|
62354
|
+
const version3 = "0.1.39";
|
|
62355
62355
|
const httpOptions = {
|
|
62356
62356
|
headers: {
|
|
62357
62357
|
"User-Agent": `GeminiCLI/${version3} (${process.platform}; ${process.arch})`
|
|
@@ -199411,7 +199411,7 @@ var init_langfuseClient = __esm({
|
|
|
199411
199411
|
userId,
|
|
199412
199412
|
metadata: {
|
|
199413
199413
|
...safeMetadata,
|
|
199414
|
-
cli_version: this.safeString("0.1.
|
|
199414
|
+
cli_version: this.safeString("0.1.39", "unknown"),
|
|
199415
199415
|
model: this.safeString(process.env.CUSTOM_LLM_MODEL_NAME, "gemini"),
|
|
199416
199416
|
auth_type: process.env.USE_CUSTOM_LLM ? "custom_llm" : "google_oauth",
|
|
199417
199417
|
environment: this.safeString(this.configManager.getConfig()?.environment, "unknown")
|
|
@@ -200578,7 +200578,7 @@ var init_langfuseIntegration = __esm({
|
|
|
200578
200578
|
const metadata = {
|
|
200579
200579
|
model: this.config.getModel(),
|
|
200580
200580
|
auth_type: this.config.getContentGeneratorConfig()?.authType,
|
|
200581
|
-
cli_version: "0.1.
|
|
200581
|
+
cli_version: "0.1.39",
|
|
200582
200582
|
start_time: (/* @__PURE__ */ new Date()).toISOString(),
|
|
200583
200583
|
session_id: this.sessionId
|
|
200584
200584
|
};
|
|
@@ -200637,7 +200637,7 @@ var init_langfuseIntegration = __esm({
|
|
|
200637
200637
|
totalCachedTokens: sessionStats.totalCachedTokens,
|
|
200638
200638
|
totalPromptTokens: sessionStats.totalPromptTokens,
|
|
200639
200639
|
metadata: {
|
|
200640
|
-
cli_version: "0.1.
|
|
200640
|
+
cli_version: "0.1.39",
|
|
200641
200641
|
auth_type: this.config.getContentGeneratorConfig()?.authType,
|
|
200642
200642
|
session_end_time: (/* @__PURE__ */ new Date()).toISOString()
|
|
200643
200643
|
}
|
|
@@ -200709,7 +200709,7 @@ var init_langfuseIntegration = __esm({
|
|
|
200709
200709
|
error,
|
|
200710
200710
|
metadata: {
|
|
200711
200711
|
session_id: this.sessionId,
|
|
200712
|
-
cli_version: "0.1.
|
|
200712
|
+
cli_version: "0.1.39",
|
|
200713
200713
|
auth_type: this.config.getContentGeneratorConfig()?.authType
|
|
200714
200714
|
}
|
|
200715
200715
|
});
|
|
@@ -205955,6 +205955,11 @@ var init_mpdaiConfig = __esm({
|
|
|
205955
205955
|
const config2 = this.loadConfig();
|
|
205956
205956
|
return config2?.retryAttempts || 3;
|
|
205957
205957
|
}
|
|
205958
|
+
getTokenUrl() {
|
|
205959
|
+
const config2 = this.loadConfig();
|
|
205960
|
+
if (!config2) return "http://lb-100-123-141-85.lbaas.jpe2f.dcnw.rakuten/api/auth/token";
|
|
205961
|
+
return `${config2.api.baseUrl}/api/auth/token`;
|
|
205962
|
+
}
|
|
205958
205963
|
};
|
|
205959
205964
|
}
|
|
205960
205965
|
});
|
|
@@ -207674,13 +207679,17 @@ var init_AuthService = __esm({
|
|
|
207674
207679
|
AuthService = class {
|
|
207675
207680
|
userJsonPath;
|
|
207676
207681
|
keysJsonPath;
|
|
207682
|
+
idTokenPath;
|
|
207677
207683
|
authApiUrl;
|
|
207684
|
+
tokenApiUrl;
|
|
207678
207685
|
mpdaiConfig;
|
|
207679
207686
|
constructor(authApiUrl) {
|
|
207680
207687
|
this.mpdaiConfig = MpdaiConfigManager.getInstance();
|
|
207681
207688
|
this.authApiUrl = authApiUrl || this.mpdaiConfig.getAuthUrl();
|
|
207689
|
+
this.tokenApiUrl = this.mpdaiConfig.getTokenUrl();
|
|
207682
207690
|
this.userJsonPath = join17(homedir12(), ".mpdai", "user.json");
|
|
207683
207691
|
this.keysJsonPath = join17(homedir12(), ".mpdai", "keys.json");
|
|
207692
|
+
this.idTokenPath = join17(homedir12(), ".mpdai", "id.token");
|
|
207684
207693
|
}
|
|
207685
207694
|
/**
|
|
207686
207695
|
* 检查本地是否存在用户凭据文件
|
|
@@ -207708,6 +207717,91 @@ var init_AuthService = __esm({
|
|
|
207708
207717
|
return null;
|
|
207709
207718
|
}
|
|
207710
207719
|
}
|
|
207720
|
+
/**
|
|
207721
|
+
* 检查是否有 username 但没有 encodedPassword
|
|
207722
|
+
*/
|
|
207723
|
+
hasUsernameWithoutPassword() {
|
|
207724
|
+
try {
|
|
207725
|
+
if (!this.hasLocalCredentials()) {
|
|
207726
|
+
return false;
|
|
207727
|
+
}
|
|
207728
|
+
const content = readFileSync11(this.userJsonPath, "utf-8");
|
|
207729
|
+
const credentials = JSON.parse(content);
|
|
207730
|
+
return !!(credentials.username && !credentials.encodedPassword);
|
|
207731
|
+
} catch (error) {
|
|
207732
|
+
return false;
|
|
207733
|
+
}
|
|
207734
|
+
}
|
|
207735
|
+
/**
|
|
207736
|
+
* 读取 id.token 文件
|
|
207737
|
+
*/
|
|
207738
|
+
readIdToken() {
|
|
207739
|
+
try {
|
|
207740
|
+
if (!existsSync12(this.idTokenPath)) {
|
|
207741
|
+
return null;
|
|
207742
|
+
}
|
|
207743
|
+
const token2 = readFileSync11(this.idTokenPath, "utf-8").trim();
|
|
207744
|
+
return token2 || null;
|
|
207745
|
+
} catch (error) {
|
|
207746
|
+
console.error("Failed to read id.token:", error);
|
|
207747
|
+
return null;
|
|
207748
|
+
}
|
|
207749
|
+
}
|
|
207750
|
+
/**
|
|
207751
|
+
* 解析 JWT token 的 payload 部分(不验证签名)
|
|
207752
|
+
*/
|
|
207753
|
+
parseJwtPayload(token2) {
|
|
207754
|
+
try {
|
|
207755
|
+
const parts = token2.split(".");
|
|
207756
|
+
if (parts.length !== 3) {
|
|
207757
|
+
throw new Error("Invalid JWT format");
|
|
207758
|
+
}
|
|
207759
|
+
const payload = parts[1];
|
|
207760
|
+
const base64 = payload.replace(/-/g, "+").replace(/_/g, "/");
|
|
207761
|
+
const padding = base64.length % 4;
|
|
207762
|
+
const paddedBase64 = padding ? base64 + "=".repeat(4 - padding) : base64;
|
|
207763
|
+
const decoded = Buffer.from(paddedBase64, "base64").toString("utf-8");
|
|
207764
|
+
return JSON.parse(decoded);
|
|
207765
|
+
} catch (error) {
|
|
207766
|
+
console.error("Failed to parse JWT payload:", error);
|
|
207767
|
+
return null;
|
|
207768
|
+
}
|
|
207769
|
+
}
|
|
207770
|
+
/**
|
|
207771
|
+
* 使用 token payload 进行认证
|
|
207772
|
+
*/
|
|
207773
|
+
async authenticateWithToken(tokenPayload) {
|
|
207774
|
+
const isDebugMode = process.env.DEBUG === "true" || process.env.DEBUG_MODE === "true" || process.env.dev === "true";
|
|
207775
|
+
try {
|
|
207776
|
+
if (isDebugMode) {
|
|
207777
|
+
console.log(`Attempting to authenticate with token API: ${this.tokenApiUrl}`);
|
|
207778
|
+
}
|
|
207779
|
+
const response = await fetch(this.tokenApiUrl, {
|
|
207780
|
+
method: "POST",
|
|
207781
|
+
headers: {
|
|
207782
|
+
"Content-Type": "application/json"
|
|
207783
|
+
},
|
|
207784
|
+
body: JSON.stringify(tokenPayload)
|
|
207785
|
+
});
|
|
207786
|
+
if (!response.ok) {
|
|
207787
|
+
throw new Error(`Token authentication failed: ${response.status} ${response.statusText}`);
|
|
207788
|
+
}
|
|
207789
|
+
const data = await response.json();
|
|
207790
|
+
if (!data.success) {
|
|
207791
|
+
throw new Error("Token authentication failed: Invalid token payload");
|
|
207792
|
+
}
|
|
207793
|
+
return data;
|
|
207794
|
+
} catch (error) {
|
|
207795
|
+
console.error("Token authentication error:", error);
|
|
207796
|
+
if (error instanceof Error && error.message.includes("fetch failed")) {
|
|
207797
|
+
console.error("\n\u274C \u65E0\u6CD5\u8FDE\u63A5\u5230\u8BA4\u8BC1\u670D\u52A1\u5668\uFF01");
|
|
207798
|
+
console.error("\u8BF7\u786E\u4FDD\u8BA4\u8BC1API\u670D\u52A1\u6B63\u5728\u8FD0\u884C:");
|
|
207799
|
+
console.error(` ${this.tokenApiUrl}`);
|
|
207800
|
+
console.error("\n\u5982\u679C\u60A8\u8FD8\u6CA1\u6709\u542F\u52A8\u8BA4\u8BC1\u670D\u52A1\uFF0C\u8BF7\u5148\u542F\u52A8\u5B83\u3002");
|
|
207801
|
+
}
|
|
207802
|
+
throw error;
|
|
207803
|
+
}
|
|
207804
|
+
}
|
|
207711
207805
|
/**
|
|
207712
207806
|
* 保存用户凭据到本地文件
|
|
207713
207807
|
*/
|
|
@@ -207833,6 +207927,39 @@ var init_AuthService = __esm({
|
|
|
207833
207927
|
async performAuthFlow() {
|
|
207834
207928
|
const isDebugMode = process.env.DEBUG === "true" || process.env.DEBUG_MODE === "true" || process.env.dev === "true";
|
|
207835
207929
|
let credentials = this.getLocalCredentials();
|
|
207930
|
+
if (this.hasUsernameWithoutPassword()) {
|
|
207931
|
+
if (isDebugMode) {
|
|
207932
|
+
console.log("Found username without password, trying token-based authentication...");
|
|
207933
|
+
}
|
|
207934
|
+
const idToken = this.readIdToken();
|
|
207935
|
+
if (idToken) {
|
|
207936
|
+
if (isDebugMode) {
|
|
207937
|
+
console.log("Found id.token file, parsing JWT payload...");
|
|
207938
|
+
}
|
|
207939
|
+
const tokenPayload = this.parseJwtPayload(idToken);
|
|
207940
|
+
if (tokenPayload) {
|
|
207941
|
+
if (isDebugMode) {
|
|
207942
|
+
console.log("JWT payload parsed successfully, using token authentication...");
|
|
207943
|
+
}
|
|
207944
|
+
const authResponse2 = await this.authenticateWithToken(tokenPayload);
|
|
207945
|
+
if (authResponse2.keys && authResponse2.keys.length > 0) {
|
|
207946
|
+
this.saveKeys(authResponse2.keys);
|
|
207947
|
+
if (isDebugMode) {
|
|
207948
|
+
console.log(`Saved ${authResponse2.keys.length} keys to local storage`);
|
|
207949
|
+
}
|
|
207950
|
+
}
|
|
207951
|
+
return authResponse2;
|
|
207952
|
+
} else {
|
|
207953
|
+
if (isDebugMode) {
|
|
207954
|
+
console.warn("Failed to parse JWT payload, falling back to password authentication...");
|
|
207955
|
+
}
|
|
207956
|
+
}
|
|
207957
|
+
} else {
|
|
207958
|
+
if (isDebugMode) {
|
|
207959
|
+
console.warn("id.token file not found or empty, falling back to password authentication...");
|
|
207960
|
+
}
|
|
207961
|
+
}
|
|
207962
|
+
}
|
|
207836
207963
|
if (!credentials) {
|
|
207837
207964
|
if (isDebugMode) {
|
|
207838
207965
|
console.log("No local credentials found, prompting for user input...");
|
|
@@ -276131,7 +276258,7 @@ var require_package7 = __commonJS({
|
|
|
276131
276258
|
"packages/router/package.json"(exports2, module2) {
|
|
276132
276259
|
module2.exports = {
|
|
276133
276260
|
name: "@mpdai/router",
|
|
276134
|
-
version: "0.1.
|
|
276261
|
+
version: "0.1.3",
|
|
276135
276262
|
description: "MPD AI Router - Route Claude Code to other LLM providers",
|
|
276136
276263
|
type: "module",
|
|
276137
276264
|
main: "dist/index.js",
|
|
@@ -310114,7 +310241,7 @@ import { promises as fs36 } from "fs";
|
|
|
310114
310241
|
import path40 from "path";
|
|
310115
310242
|
|
|
310116
310243
|
// packages/cli/src/generated/git-commit.ts
|
|
310117
|
-
var GIT_COMMIT_INFO = "
|
|
310244
|
+
var GIT_COMMIT_INFO = "ed0e6dd";
|
|
310118
310245
|
|
|
310119
310246
|
// node_modules/read-package-up/index.js
|
|
310120
310247
|
import path35 from "node:path";
|
|
@@ -310327,7 +310454,7 @@ async function getPackageJson() {
|
|
|
310327
310454
|
// packages/cli/src/utils/version.ts
|
|
310328
310455
|
async function getCliVersion() {
|
|
310329
310456
|
const pkgJson = await getPackageJson();
|
|
310330
|
-
return "0.1.
|
|
310457
|
+
return "0.1.39";
|
|
310331
310458
|
}
|
|
310332
310459
|
|
|
310333
310460
|
// packages/cli/src/ui/commands/memoryCommand.ts
|
|
@@ -331596,7 +331723,7 @@ var DataCollector = class {
|
|
|
331596
331723
|
// 提取元数据
|
|
331597
331724
|
extractMetadata(data) {
|
|
331598
331725
|
return {
|
|
331599
|
-
cli_version: "0.1.
|
|
331726
|
+
cli_version: "0.1.39",
|
|
331600
331727
|
model: process.env.CUSTOM_LLM_MODEL_NAME || "gemini",
|
|
331601
331728
|
auth_type: process.env.USE_CUSTOM_LLM ? "custom_llm" : "google_oauth",
|
|
331602
331729
|
project_path: data.projectPath,
|