mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-13 09:30:45 +08:00
重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
This commit is contained in:
parent
4a23b715a2
commit
dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions
72
openclaw/extensions/google/oauth.settings.ts
Normal file
72
openclaw/extensions/google/oauth.settings.ts
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { homedir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { isRecord, normalizeOptionalString } from "openclaw/plugin-sdk/text-runtime";
|
||||
|
||||
type OAuthSettingsFs = {
|
||||
existsSync: (path: Parameters<typeof existsSync>[0]) => ReturnType<typeof existsSync>;
|
||||
readFileSync: (path: Parameters<typeof readFileSync>[0], encoding: "utf8") => string;
|
||||
homedir: typeof homedir;
|
||||
};
|
||||
|
||||
const defaultFs: OAuthSettingsFs = {
|
||||
existsSync,
|
||||
readFileSync,
|
||||
homedir,
|
||||
};
|
||||
|
||||
let oauthSettingsFs: OAuthSettingsFs = defaultFs;
|
||||
|
||||
type GeminiCliAuthSettings = {
|
||||
security?: {
|
||||
auth?: {
|
||||
selectedType?: unknown;
|
||||
enforcedType?: unknown;
|
||||
};
|
||||
};
|
||||
selectedAuthType?: unknown;
|
||||
enforcedAuthType?: unknown;
|
||||
};
|
||||
|
||||
function readSettingsFile(): GeminiCliAuthSettings | null {
|
||||
const settingsPath = join(oauthSettingsFs.homedir(), ".gemini", "settings.json");
|
||||
if (!oauthSettingsFs.existsSync(settingsPath)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
const parsed = JSON.parse(oauthSettingsFs.readFileSync(settingsPath, "utf8")) as unknown;
|
||||
return isRecord(parsed) ? (parsed as GeminiCliAuthSettings) : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function setOAuthSettingsFsForTest(overrides?: Partial<OAuthSettingsFs>): void {
|
||||
oauthSettingsFs = overrides ? { ...defaultFs, ...overrides } : defaultFs;
|
||||
}
|
||||
|
||||
export function resolveGeminiCliSelectedAuthType(): string | undefined {
|
||||
const settings = readSettingsFile();
|
||||
if (settings) {
|
||||
const security = isRecord(settings.security) ? settings.security : undefined;
|
||||
const auth = isRecord(security?.auth) ? security.auth : undefined;
|
||||
const selectedAuthType =
|
||||
normalizeOptionalString(auth?.selectedType) ??
|
||||
normalizeOptionalString(auth?.enforcedType) ??
|
||||
normalizeOptionalString(settings.selectedAuthType) ??
|
||||
normalizeOptionalString(settings.enforcedAuthType);
|
||||
if (selectedAuthType) {
|
||||
return selectedAuthType;
|
||||
}
|
||||
}
|
||||
|
||||
if (process.env.GOOGLE_GENAI_USE_GCA === "true") {
|
||||
return "oauth-personal";
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function isGeminiCliPersonalOAuth(): boolean {
|
||||
return resolveGeminiCliSelectedAuthType() === "oauth-personal";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue