@modelzen/feishu-codex-bridge 0.1.4 → 0.1.6
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/cli.js +40 -5
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2764,6 +2764,27 @@ function connLabel(state) {
|
|
|
2764
2764
|
return state;
|
|
2765
2765
|
}
|
|
2766
2766
|
}
|
|
2767
|
+
function scopeStatusText(i) {
|
|
2768
|
+
if (i.missingScopes === void 0) return "\u672A\u80FD\u81EA\u52A8\u68C0\u67E5\uFF08\u51ED\u8BC1\u5931\u6548\u6216\u7F51\u7EDC\u95EE\u9898\uFF09";
|
|
2769
|
+
if (i.missingScopes.length === 0) return "\u5FC5\u9700\u6743\u9650\u9F50\u5168";
|
|
2770
|
+
return `\u7F3A\u5931 ${i.missingScopes.length} \u9879\uFF1A${i.missingScopes.join(" ")}`;
|
|
2771
|
+
}
|
|
2772
|
+
function scopeDiagnosis(i) {
|
|
2773
|
+
if (i.missingScopes === void 0) {
|
|
2774
|
+
return [
|
|
2775
|
+
md("- \u98DE\u4E66\u6743\u9650\uFF1A\u26A0\uFE0F \u65E0\u6CD5\u81EA\u52A8\u68C0\u67E5\uFF08\u51ED\u8BC1\u5931\u6548\u6216\u7F51\u7EDC\u4E0D\u901A\uFF09"),
|
|
2776
|
+
actions([linkButton("\u{1F511} \u53BB\u6743\u9650\u9875\u6838\u5BF9", i.scopeGrantUrl)])
|
|
2777
|
+
];
|
|
2778
|
+
}
|
|
2779
|
+
if (i.missingScopes.length === 0) {
|
|
2780
|
+
return [md("- \u98DE\u4E66\u6743\u9650\uFF1A\u2705 \u5FC5\u9700\u6743\u9650\u5DF2\u5168\u90E8\u5F00\u901A")];
|
|
2781
|
+
}
|
|
2782
|
+
return [
|
|
2783
|
+
md(`- \u98DE\u4E66\u6743\u9650\uFF1A\u274C \u7F3A ${i.missingScopes.length} \u9879 \u2014\u2014 \u5F00\u901A\u524D\u76F8\u5173\u529F\u80FD\uFF08\u6536\u53D1\u6D88\u606F / \u5361\u7247 / \u5EFA\u7FA4\u7B49\uFF09\u4E0D\u53EF\u7528`),
|
|
2784
|
+
note(`\u5F85\u5F00\u901A\uFF1A${i.missingScopes.join("\u3000")}`),
|
|
2785
|
+
actions([linkButton("\u{1F511} \u4E00\u952E\u53BB\u5F00\u901A\u8FD9\u4E9B\u6743\u9650", i.scopeGrantUrl)])
|
|
2786
|
+
];
|
|
2787
|
+
}
|
|
2767
2788
|
function codexDiagnosePrompt(i) {
|
|
2768
2789
|
return [
|
|
2769
2790
|
"\u6211\u5728\u7528 feishu-codex-bridge\uFF08\u98DE\u4E66 \u2194 \u672C\u5730 Codex \u6865\u63A5\uFF09\u9047\u5230\u95EE\u9898\uFF0C\u8BF7\u5E2E\u6211\u5B9A\u4F4D\u539F\u56E0\u5E76\u7ED9\u51FA\u4FEE\u590D\u6B65\u9AA4\u3002",
|
|
@@ -2778,6 +2799,7 @@ function codexDiagnosePrompt(i) {
|
|
|
2778
2799
|
"\u3010\u8FD0\u884C\u5FEB\u7167\u3011",
|
|
2779
2800
|
`- codex \u53EF\u7528\uFF1A${i.codexOk ? "\u662F" : "\u5426"}`,
|
|
2780
2801
|
`- \u98DE\u4E66\u957F\u8FDE\u63A5\uFF1A${i.conn}`,
|
|
2802
|
+
`- \u98DE\u4E66\u6743\u9650\uFF1A${scopeStatusText(i)}`,
|
|
2781
2803
|
"",
|
|
2782
2804
|
"\u3010\u8BF7\u4F60\u505A\u7684\u4E8B\u3011",
|
|
2783
2805
|
"1. \u8BFB\u53D6\u5E76\u5206\u6790\u65E5\u5FD7\uFF0C\u627E\u51FA\u6700\u8FD1\u7684\u62A5\u9519\u6216\u5F02\u5E38\u5806\u6808\uFF1A",
|
|
@@ -2794,6 +2816,7 @@ function codexDiagnosePrompt(i) {
|
|
|
2794
2816
|
}
|
|
2795
2817
|
function buildDoctorCard(i) {
|
|
2796
2818
|
const prompt = codexDiagnosePrompt(i);
|
|
2819
|
+
const hasProblem = !i.codexOk || i.missingScopes !== void 0 && i.missingScopes.length > 0;
|
|
2797
2820
|
return card(
|
|
2798
2821
|
[
|
|
2799
2822
|
md("**\u521D\u6B65\u8BCA\u65AD**"),
|
|
@@ -2801,6 +2824,7 @@ function buildDoctorCard(i) {
|
|
|
2801
2824
|
`- Codex\uFF1A${i.codexOk ? `\u2705 \u53EF\u7528${i.codexVer ? `\uFF08${i.codexVer}\uFF09` : ""}` : "\u274C \u4E0D\u53EF\u7528\uFF08\u68C0\u67E5 CODEX_BIN / PATH\uFF09"}`
|
|
2802
2825
|
),
|
|
2803
2826
|
md(`- \u98DE\u4E66\u957F\u8FDE\u63A5\uFF1A${connLabel(i.conn)}`),
|
|
2827
|
+
...scopeDiagnosis(i),
|
|
2804
2828
|
note(`bridge v${i.bridgeVer}\u3000\xB7\u3000Node ${i.node}\u3000\xB7\u3000${i.platform}`),
|
|
2805
2829
|
hr(),
|
|
2806
2830
|
md("**\u65E5\u5FD7\u8DEF\u5F84**"),
|
|
@@ -2815,7 +2839,7 @@ function buildDoctorCard(i) {
|
|
|
2815
2839
|
linkButton("\u{1F41E} \u63D0 Issue", `${REPO}/issues`)
|
|
2816
2840
|
])
|
|
2817
2841
|
],
|
|
2818
|
-
{ header: { title: "\u{1FA7A} \u8BCA\u65AD", template:
|
|
2842
|
+
{ header: { title: "\u{1FA7A} \u8BCA\u65AD", template: hasProblem ? "orange" : "blue" } }
|
|
2819
2843
|
);
|
|
2820
2844
|
}
|
|
2821
2845
|
function buildNewProjectFormCard(opts = {}) {
|
|
@@ -3041,9 +3065,9 @@ async function restartLaunchd() {
|
|
|
3041
3065
|
throw new Error(`launchd service \u672A\u5B89\u88C5\uFF1A${launchAgentPlistPath()}`);
|
|
3042
3066
|
}
|
|
3043
3067
|
if (isLoaded()) {
|
|
3044
|
-
const
|
|
3045
|
-
if (!
|
|
3046
|
-
|
|
3068
|
+
const kick = runLaunchctl(["kickstart", "-k", serviceTarget()]);
|
|
3069
|
+
if (!kick.ok) throw launchctlError("launchctl kickstart", kick);
|
|
3070
|
+
return statusLaunchd();
|
|
3047
3071
|
}
|
|
3048
3072
|
const bootstrap = runLaunchctl(["bootstrap", userTarget(), launchAgentPlistPath()]);
|
|
3049
3073
|
if (!bootstrap.ok) throw launchctlError("launchctl bootstrap", bootstrap);
|
|
@@ -4202,6 +4226,10 @@ function createOrchestrator(channel, cfg, fallbackCwd) {
|
|
|
4202
4226
|
}).on(DM.doctor, async ({ evt }) => {
|
|
4203
4227
|
if (!dmAdmin(evt.operator?.openId)) return;
|
|
4204
4228
|
const codexBin = resolveCodexBin();
|
|
4229
|
+
const app = cfg.accounts.app;
|
|
4230
|
+
const secret = await getSecret(secretKeyForApp(app.id)).catch(() => void 0);
|
|
4231
|
+
const scopeCheck = secret ? await validateAppCredentials(app.id, secret, app.tenant).catch(() => void 0) : void 0;
|
|
4232
|
+
const missingScopes = scopeCheck?.missingScopes;
|
|
4205
4233
|
const info = {
|
|
4206
4234
|
codexOk: await backend.isAvailable().catch(() => false),
|
|
4207
4235
|
codexVer: codexBin ? codexVersion(codexBin) : null,
|
|
@@ -4211,7 +4239,14 @@ function createOrchestrator(channel, cfg, fallbackCwd) {
|
|
|
4211
4239
|
platform: `${process.platform}-${process.arch}`,
|
|
4212
4240
|
logStdout: serviceStdoutPath(),
|
|
4213
4241
|
logStderr: serviceStderrPath(),
|
|
4214
|
-
configFile: paths.configFile
|
|
4242
|
+
configFile: paths.configFile,
|
|
4243
|
+
missingScopes,
|
|
4244
|
+
// 缺失时预选缺失项(精准开通);查不到/全开通时预选全部必需 scope 供核对。
|
|
4245
|
+
scopeGrantUrl: buildScopeGrantUrl(
|
|
4246
|
+
app.id,
|
|
4247
|
+
app.tenant,
|
|
4248
|
+
missingScopes && missingScopes.length ? missingScopes : void 0
|
|
4249
|
+
)
|
|
4215
4250
|
};
|
|
4216
4251
|
await sendManagedCard(channel, evt.chatId, buildDoctorCard(info), evt.messageId).catch(
|
|
4217
4252
|
(err) => log.fail("console", err, { cmd: "doctor" })
|