fogact 1.1.3
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/LICENSE +21 -0
- package/README.md +244 -0
- package/README.zh-CN.md +244 -0
- package/bin/cli.js +9 -0
- package/bin/web-server.js +1434 -0
- package/config/upstream.example.json +14 -0
- package/frontend/activate.html +249 -0
- package/frontend/admin/admin-panel-v2.js +1899 -0
- package/frontend/admin/index.html +705 -0
- package/frontend/assets/market-ui.css +1876 -0
- package/frontend/color-test.html +136 -0
- package/frontend/index.html +191 -0
- package/frontend/user/assets/AnnouncementDetail-Dvxmwz0A.js +12 -0
- package/frontend/user/assets/Announcements-CS1tF2mx.js +11 -0
- package/frontend/user/assets/CardBind-CsCxihhP.js +21 -0
- package/frontend/user/assets/CardContent.vue_vue_type_script_setup_true_lang-D2L-uqSl.js +1 -0
- package/frontend/user/assets/CardDescription.vue_vue_type_script_setup_true_lang-D-v5Pl7F.js +1 -0
- package/frontend/user/assets/CardTitle.vue_vue_type_script_setup_true_lang-a0CCN6D5.js +1 -0
- package/frontend/user/assets/Dashboard-rPsmltm5.js +51 -0
- package/frontend/user/assets/DashboardLayout-BUCWGlXC.css +1 -0
- package/frontend/user/assets/DashboardLayout-DDkxHYFj.js +80 -0
- package/frontend/user/assets/Input.vue_vue_type_script_setup_true_lang-B0SyPmYb.js +6 -0
- package/frontend/user/assets/Label.vue_vue_type_script_setup_true_lang-CxYORSgN.js +1 -0
- package/frontend/user/assets/Progress.vue_vue_type_script_setup_true_lang-2_QbPsEQ.js +1 -0
- package/frontend/user/assets/QuotaPack-B_tJ7Psm.js +6 -0
- package/frontend/user/assets/Renewal-BSDhDmwv.js +6 -0
- package/frontend/user/assets/ScrollArea.vue_vue_type_script_setup_true_lang-DMYwcfpz.js +1 -0
- package/frontend/user/assets/Separator.vue_vue_type_script_setup_true_lang-Ckg8EXj_.js +1 -0
- package/frontend/user/assets/Settings-CBdAa3lw.js +11 -0
- package/frontend/user/assets/TooltipTrigger.vue_vue_type_script_setup_true_lang-DtSBjzGo.js +16 -0
- package/frontend/user/assets/Welcome-7IfzEli4.css +1 -0
- package/frontend/user/assets/Welcome-Dtfp6oER.js +1 -0
- package/frontend/user/assets/_plugin-vue_export-helper-5cjT4u0R.js +16 -0
- package/frontend/user/assets/activity-wYWtyqTJ.js +6 -0
- package/frontend/user/assets/announcement-35mOnjRL.js +16 -0
- package/frontend/user/assets/calendar-BFNuCata.js +6 -0
- package/frontend/user/assets/chart-vendor-CULJE59K.js +37 -0
- package/frontend/user/assets/chevron-down-kDbuU1Py.js +6 -0
- package/frontend/user/assets/chevron-right-BayASIm0.js +6 -0
- package/frontend/user/assets/eye-CY62vip0.js +6 -0
- package/frontend/user/assets/gauge-C5NQ-mV8.js +6 -0
- package/frontend/user/assets/index-B8QSyYhS.css +1 -0
- package/frontend/user/assets/index-Da98HOxL.js +91 -0
- package/frontend/user/assets/link-2-DT5R5nGO.js +6 -0
- package/frontend/user/assets/package-rUbExUEn.js +6 -0
- package/frontend/user/assets/plus-CQc6C8wG.js +11 -0
- package/frontend/user/assets/refresh-cw-Y9hCloPL.js +6 -0
- package/frontend/user/assets/useUserPageRefresh-BYZvpNR9.js +1 -0
- package/frontend/user/assets/zap-l5zbZqrM.js +11 -0
- package/frontend/user/index.html +67 -0
- package/install.sh +402 -0
- package/lib/commands/activate.js +144 -0
- package/lib/commands/restore.js +102 -0
- package/lib/commands/test.js +40 -0
- package/lib/config/claude.js +81 -0
- package/lib/config/codex.js +164 -0
- package/lib/config/upstream.js +79 -0
- package/lib/index.js +164 -0
- package/lib/platforms/claude-code.js +35 -0
- package/lib/platforms/codex-cli.js +35 -0
- package/lib/platforms/editor-codex.js +138 -0
- package/lib/platforms/index.js +32 -0
- package/lib/platforms/openclaw.js +118 -0
- package/lib/platforms/opencode.js +89 -0
- package/lib/services/activation-orchestrator.js +666 -0
- package/lib/services/backup-service.js +162 -0
- package/lib/services/cliproxy-api.js +174 -0
- package/lib/services/database.js +461 -0
- package/lib/services/newapi.js +97 -0
- package/lib/services/node-service.js +49 -0
- package/lib/utils/json-file.js +33 -0
- package/package.json +53 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const os = require("os");
|
|
6
|
+
|
|
7
|
+
function getExtensionsDir(editor) {
|
|
8
|
+
if (editor === "vscode") {
|
|
9
|
+
return path.join(os.homedir(), ".vscode", "extensions");
|
|
10
|
+
}
|
|
11
|
+
if (editor === "cursor") {
|
|
12
|
+
return path.join(os.homedir(), ".cursor", "extensions");
|
|
13
|
+
}
|
|
14
|
+
throw new Error(`Unsupported editor: ${editor}`);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function getEditorName(editor) {
|
|
18
|
+
return editor === "vscode" ? "VSCode" : "Cursor";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function findCodexExtensionDir(editor) {
|
|
22
|
+
const extensionsDir = getExtensionsDir(editor);
|
|
23
|
+
if (!fs.existsSync(extensionsDir)) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const matches = fs.readdirSync(extensionsDir)
|
|
28
|
+
.filter((name) => name.startsWith("openai.chatgpt-"))
|
|
29
|
+
.sort();
|
|
30
|
+
|
|
31
|
+
if (matches.length === 0) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return path.join(extensionsDir, matches[matches.length - 1]);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function findWebviewAsset(extensionDir) {
|
|
39
|
+
const assetsDir = path.join(extensionDir, "webview", "assets");
|
|
40
|
+
if (!fs.existsSync(assetsDir)) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const matches = fs.readdirSync(assetsDir)
|
|
45
|
+
.filter((name) => /^index-[A-Za-z0-9_-]+\.js$/.test(name));
|
|
46
|
+
|
|
47
|
+
if (matches.length === 0) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return path.join(assetsDir, matches[0]);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function isPatched(content) {
|
|
55
|
+
return content.includes("email:'云驿YunYi'") || content.includes('email:"云驿YunYi"');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function patchCodexExtension(editor) {
|
|
59
|
+
const editorName = getEditorName(editor);
|
|
60
|
+
const extensionDir = findCodexExtensionDir(editor);
|
|
61
|
+
if (!extensionDir) {
|
|
62
|
+
return {
|
|
63
|
+
success: false,
|
|
64
|
+
skipped: true,
|
|
65
|
+
message: `${editorName} Codex 插件未安装`,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const assetPath = findWebviewAsset(extensionDir);
|
|
70
|
+
if (!assetPath) {
|
|
71
|
+
return {
|
|
72
|
+
success: false,
|
|
73
|
+
skipped: true,
|
|
74
|
+
message: `${editorName} Codex 插件资源文件未找到`,
|
|
75
|
+
files: [extensionDir],
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const content = fs.readFileSync(assetPath, "utf8");
|
|
80
|
+
if (isPatched(content)) {
|
|
81
|
+
return {
|
|
82
|
+
success: true,
|
|
83
|
+
message: `${editorName} Codex 插件已激活`,
|
|
84
|
+
files: [assetPath],
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const pattern = /(\w+)=\{isLoading:(\w+),openAIAuth:(\w+),isCopilotApiAvailable:(\w+),authMethod:(\w+),requiresAuth:(\w+),userId:(\w+),accountId:(\w+),email:(\w+),planAtLogin:(\w+),setAuthMethod:(\w+)\}/;
|
|
89
|
+
const replacement = "$1={isLoading:$2,openAIAuth:$3,isCopilotApiAvailable:$4,authMethod:'chatgpt',requiresAuth:$6,userId:$7,accountId:$8,email:'云驿YunYi',planAtLogin:$10,setAuthMethod:$11}";
|
|
90
|
+
|
|
91
|
+
if (!pattern.test(content)) {
|
|
92
|
+
return {
|
|
93
|
+
success: false,
|
|
94
|
+
skipped: true,
|
|
95
|
+
message: `${editorName} Codex 插件版本不兼容`,
|
|
96
|
+
files: [assetPath],
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
fs.writeFileSync(assetPath, content.replace(pattern, replacement), "utf8");
|
|
101
|
+
return {
|
|
102
|
+
success: true,
|
|
103
|
+
message: `${editorName} Codex 插件已激活`,
|
|
104
|
+
files: [assetPath],
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function createEditorCodexPlatform(editor) {
|
|
109
|
+
const editorName = getEditorName(editor);
|
|
110
|
+
return {
|
|
111
|
+
id: `${editor}-codex-plugin`,
|
|
112
|
+
name: `${editorName} Codex 插件`,
|
|
113
|
+
services: ["codex"],
|
|
114
|
+
required: false,
|
|
115
|
+
detect() {
|
|
116
|
+
const extensionsDir = getExtensionsDir(editor);
|
|
117
|
+
const extensionDir = findCodexExtensionDir(editor);
|
|
118
|
+
return {
|
|
119
|
+
installed: Boolean(extensionDir),
|
|
120
|
+
paths: extensionDir ? [extensionDir] : [extensionsDir],
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
activate() {
|
|
124
|
+
const result = patchCodexExtension(editor);
|
|
125
|
+
if (result.skipped) {
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
return result;
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
module.exports = {
|
|
134
|
+
createEditorCodexPlatform,
|
|
135
|
+
findCodexExtensionDir,
|
|
136
|
+
findWebviewAsset,
|
|
137
|
+
patchCodexExtension,
|
|
138
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { createClaudeCodePlatform } = require("./claude-code");
|
|
4
|
+
const { createCodexCliPlatform } = require("./codex-cli");
|
|
5
|
+
const { createOpenCodePlatform } = require("./opencode");
|
|
6
|
+
const { createOpenClawPlatform } = require("./openclaw");
|
|
7
|
+
const { createEditorCodexPlatform } = require("./editor-codex");
|
|
8
|
+
|
|
9
|
+
function getPlatforms() {
|
|
10
|
+
return [
|
|
11
|
+
createClaudeCodePlatform(),
|
|
12
|
+
createCodexCliPlatform(),
|
|
13
|
+
createOpenCodePlatform(),
|
|
14
|
+
createOpenClawPlatform(),
|
|
15
|
+
createEditorCodexPlatform("vscode"),
|
|
16
|
+
createEditorCodexPlatform("cursor"),
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function detectPlatforms(service) {
|
|
21
|
+
return getPlatforms()
|
|
22
|
+
.filter((platform) => platform.services.includes(service))
|
|
23
|
+
.map((platform) => ({
|
|
24
|
+
platform,
|
|
25
|
+
detection: platform.detect(),
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = {
|
|
30
|
+
detectPlatforms,
|
|
31
|
+
getPlatforms,
|
|
32
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const os = require("os");
|
|
6
|
+
const { getServiceBaseUrl } = require("../config/upstream");
|
|
7
|
+
const { readJsonFile, writeJsonFile } = require("../utils/json-file");
|
|
8
|
+
|
|
9
|
+
function getOpenClawDir() {
|
|
10
|
+
return path.join(os.homedir(), ".openclaw");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function getOpenClawConfigPath() {
|
|
14
|
+
return path.join(getOpenClawDir(), "openclaw.json");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function buildClaudeConfig(existingConfig, baseUrl, apiKey) {
|
|
18
|
+
const { models, agents, ...rest } = existingConfig || {};
|
|
19
|
+
const { defaults, ...agentRest } = agents || {};
|
|
20
|
+
return {
|
|
21
|
+
...rest,
|
|
22
|
+
models: {
|
|
23
|
+
mode: "merge",
|
|
24
|
+
providers: {
|
|
25
|
+
"newapi-claude": {
|
|
26
|
+
baseUrl,
|
|
27
|
+
apiKey,
|
|
28
|
+
auth: "api-key",
|
|
29
|
+
api: "anthropic-messages",
|
|
30
|
+
headers: {},
|
|
31
|
+
authHeader: false,
|
|
32
|
+
models: [],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
agents: {
|
|
37
|
+
...agentRest,
|
|
38
|
+
defaults: {
|
|
39
|
+
model: {
|
|
40
|
+
primary: "newapi-claude/claude-opus-4-6",
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function buildCodexConfig(existingConfig, baseUrl, apiKey) {
|
|
48
|
+
const { models, agents, ...rest } = existingConfig || {};
|
|
49
|
+
const { defaults, ...agentRest } = agents || {};
|
|
50
|
+
return {
|
|
51
|
+
...rest,
|
|
52
|
+
models: {
|
|
53
|
+
mode: "merge",
|
|
54
|
+
providers: {
|
|
55
|
+
"newapi-codex": {
|
|
56
|
+
baseUrl,
|
|
57
|
+
apiKey,
|
|
58
|
+
auth: "api-key",
|
|
59
|
+
api: "openai-responses",
|
|
60
|
+
headers: {},
|
|
61
|
+
authHeader: false,
|
|
62
|
+
models: [
|
|
63
|
+
{
|
|
64
|
+
id: "gpt-5.2",
|
|
65
|
+
name: "GPT 5.2",
|
|
66
|
+
reasoning: true,
|
|
67
|
+
input: ["text", "image"],
|
|
68
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
69
|
+
contextWindow: 128000,
|
|
70
|
+
maxTokens: 32768,
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
agents: {
|
|
77
|
+
...agentRest,
|
|
78
|
+
defaults: {
|
|
79
|
+
model: {
|
|
80
|
+
primary: "newapi-codex/gpt-5.2",
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function createOpenClawPlatform() {
|
|
88
|
+
return {
|
|
89
|
+
id: "openclaw",
|
|
90
|
+
name: "OpenClaw",
|
|
91
|
+
services: ["claude", "codex"],
|
|
92
|
+
required: false,
|
|
93
|
+
detect() {
|
|
94
|
+
return {
|
|
95
|
+
installed: fs.existsSync(getOpenClawConfigPath()),
|
|
96
|
+
paths: [getOpenClawConfigPath()],
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
activate(context) {
|
|
100
|
+
const configPath = getOpenClawConfigPath();
|
|
101
|
+
const existingConfig = readJsonFile(configPath, {});
|
|
102
|
+
const baseUrl = getServiceBaseUrl(context.upstream, context.service);
|
|
103
|
+
const nextConfig = context.service === "claude"
|
|
104
|
+
? buildClaudeConfig(existingConfig, baseUrl, context.apiKey)
|
|
105
|
+
: buildCodexConfig(existingConfig, baseUrl, context.apiKey);
|
|
106
|
+
|
|
107
|
+
writeJsonFile(configPath, nextConfig);
|
|
108
|
+
return { success: true, files: [configPath] };
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
module.exports = {
|
|
114
|
+
buildClaudeConfig,
|
|
115
|
+
buildCodexConfig,
|
|
116
|
+
createOpenClawPlatform,
|
|
117
|
+
getOpenClawConfigPath,
|
|
118
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const os = require("os");
|
|
6
|
+
const { getServiceBaseUrl } = require("../config/upstream");
|
|
7
|
+
const { readJsonFile, writeJsonFile } = require("../utils/json-file");
|
|
8
|
+
|
|
9
|
+
function getOpenCodeDir() {
|
|
10
|
+
return path.join(os.homedir(), ".config", "opencode");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function getOpenCodeConfigPath() {
|
|
14
|
+
return path.join(getOpenCodeDir(), "opencode.json");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function buildClaudeConfig(existingConfig, baseUrl, apiKey) {
|
|
18
|
+
const { model, small_model, ...rest } = existingConfig || {};
|
|
19
|
+
const provider = rest.provider || {};
|
|
20
|
+
provider.anthropic = {
|
|
21
|
+
name: "newapi-claude",
|
|
22
|
+
npm: "@ai-sdk/anthropic",
|
|
23
|
+
options: {
|
|
24
|
+
baseURL: `${baseUrl.replace(/\/+$/, "")}/v1`,
|
|
25
|
+
apiKey,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
$schema: "https://opencode.ai/config.json",
|
|
31
|
+
...rest,
|
|
32
|
+
model: "anthropic/claude-opus-4-6",
|
|
33
|
+
provider,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function buildCodexConfig(existingConfig, baseUrl, apiKey) {
|
|
38
|
+
const { model, small_model, ...rest } = existingConfig || {};
|
|
39
|
+
const provider = rest.provider || {};
|
|
40
|
+
provider.openai = {
|
|
41
|
+
name: "newapi-codex",
|
|
42
|
+
npm: "@ai-sdk/openai",
|
|
43
|
+
api: "responses",
|
|
44
|
+
options: {
|
|
45
|
+
baseURL: baseUrl,
|
|
46
|
+
apiKey,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
$schema: "https://opencode.ai/config.json",
|
|
52
|
+
...rest,
|
|
53
|
+
model: "openai/gpt-5.3-codex",
|
|
54
|
+
provider,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function createOpenCodePlatform() {
|
|
59
|
+
return {
|
|
60
|
+
id: "opencode",
|
|
61
|
+
name: "OpenCode",
|
|
62
|
+
services: ["claude", "codex"],
|
|
63
|
+
required: false,
|
|
64
|
+
detect() {
|
|
65
|
+
return {
|
|
66
|
+
installed: fs.existsSync(getOpenCodeConfigPath()),
|
|
67
|
+
paths: [getOpenCodeConfigPath()],
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
activate(context) {
|
|
71
|
+
const configPath = getOpenCodeConfigPath();
|
|
72
|
+
const existingConfig = readJsonFile(configPath, {});
|
|
73
|
+
const baseUrl = getServiceBaseUrl(context.upstream, context.service);
|
|
74
|
+
const nextConfig = context.service === "claude"
|
|
75
|
+
? buildClaudeConfig(existingConfig, baseUrl, context.apiKey)
|
|
76
|
+
: buildCodexConfig(existingConfig, baseUrl, context.apiKey);
|
|
77
|
+
|
|
78
|
+
writeJsonFile(configPath, nextConfig);
|
|
79
|
+
return { success: true, files: [configPath] };
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
module.exports = {
|
|
85
|
+
buildClaudeConfig,
|
|
86
|
+
buildCodexConfig,
|
|
87
|
+
createOpenCodePlatform,
|
|
88
|
+
getOpenCodeConfigPath,
|
|
89
|
+
};
|