refactor: 全面转向 CLI 驱动架构与底层 SDK,裁撤繁杂 MCP 工具并参考 seal-home 规范
This commit is contained in:
1 parent
3d549e2e2f
commit
e7aa8a86cc
19 files changed
+1228
-589
No files matched your search
@@ -0,0 +1,45 @@
|
||||
import readline from "readline";
|
||||
import { loadCorpConfigs } from "../core/config/loader.js";
|
||||
import { CorpContext } from "../core/config/manager.js";
|
||||
import { CorpConfig } from "../core/config/types.js";
|
||||
import { createEkbClient } from "../core/auth/ekb.js";
|
||||
import { getEasoClient } from "../core/auth/easo.js";
|
||||
import { CliRuntime } from "./types.js";
|
||||
|
||||
export function initCorpRuntime(corpIdOption?: string, jsonMode: boolean = false): CliRuntime {
|
||||
const corps = loadCorpConfigs();
|
||||
const corpContext = new CorpContext(corps);
|
||||
|
||||
if (corpIdOption) {
|
||||
corpContext.switchCorp(corpIdOption);
|
||||
}
|
||||
|
||||
return {
|
||||
corpContext,
|
||||
selectedCorp: corpContext.getCurrent(),
|
||||
jsonMode,
|
||||
};
|
||||
}
|
||||
|
||||
export async function createClientsForCorp(corp: CorpConfig) {
|
||||
const ekbClient = await createEkbClient(corp);
|
||||
const { client: easoClient } = await getEasoClient(corp);
|
||||
return {
|
||||
corp,
|
||||
ekbClient,
|
||||
easoClient,
|
||||
};
|
||||
}
|
||||
|
||||
export function prompt(question: string): Promise<string> {
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
});
|
||||
return new Promise((resolve) => {
|
||||
rl.question(question, (answer) => {
|
||||
rl.close();
|
||||
resolve(answer.trim());
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user