OpenClaw 完整备份 - 2026-03-21

This commit is contained in:
huan
2026-03-21 15:31:06 +08:00
commit 8dd73a1d62
569 changed files with 76792 additions and 0 deletions
@@ -0,0 +1,39 @@
"use strict";
/**
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*
* 应用所有者查询 — 复用 app-scope-checker 的 API 调用和统一 owner 定义。
*
* 所有 owner 判定统一使用 {@link getAppInfo} 返回的 `effectiveOwnerOpenId`。
* 不维护独立缓存,完全依赖 app-scope-checker 的 30s 缓存。
*/
import { getAppInfo } from './app-scope-checker';
import { larkLogger } from './lark-logger';
const log = larkLogger('core/app-owner-fallback');
// ---------------------------------------------------------------------------
// Public API
// ---------------------------------------------------------------------------
/**
* 获取应用的 effectiveOwnerOpenId。
*
* 复用 app-scope-checker 的 API 调用、缓存和统一 owner 定义(effectiveOwnerOpenId)。
* 查询失败时返回 undefinedfail-open)。
*
* @param account - 已配置的飞书账号信息
* @param sdk - 飞书 SDK 实例(必须已初始化 TAT)
* @returns 应用所有者的 open_id,如果查询失败则返回 undefined
*/
export async function getAppOwnerFallback(account,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
sdk) {
const { appId } = account;
try {
const appInfo = await getAppInfo(sdk, appId);
return appInfo.effectiveOwnerOpenId;
}
catch (err) {
log.warn(`failed to get owner for ${appId}: ${err instanceof Error ? err.message : err}`);
return undefined; // fail-open: 获取失败不阻塞业务
}
}