aai-lark-bridge 0.2.24 → 0.2.25

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 CHANGED
@@ -4,7 +4,7 @@ import { Command } from "commander";
4
4
  // package.json
5
5
  var package_default = {
6
6
  name: "aai-lark-bridge",
7
- version: "0.2.24",
7
+ version: "0.2.25",
8
8
  description: "Lark AI Native Bridge - Lark\u57FA\u7840\u8BBE\u65BD\u5C42\u548CCLI\u96C6\u6210",
9
9
  type: "module",
10
10
  main: "./dist/index.js",
@@ -19417,6 +19417,16 @@ function isAppTokenInvalid(r) {
19417
19417
  return /\b9999166[1-8]\b|token_invalid/.test(`${r.stdout}
19418
19418
  ${r.stderr}`);
19419
19419
  }
19420
+ function brandOfTenant(tenant) {
19421
+ return tenant === "feishu" ? "feishu" : "lark";
19422
+ }
19423
+ function sourceBrand(sourceConfigFile) {
19424
+ try {
19425
+ return brandOfTenant(JSON.parse(readFileSync5(sourceConfigFile, "utf8")).accounts?.app?.tenant);
19426
+ } catch {
19427
+ return "lark";
19428
+ }
19429
+ }
19420
19430
  var FETCH_SCRIPT = `
19421
19431
  const chunks = [];
19422
19432
  process.stdin.on('data', (c) => chunks.push(c)).on('end', async () => {
@@ -19462,7 +19472,7 @@ function realAppTokenFetcher(sourceConfigFile) {
19462
19472
  cred = res.values?.[ref.id];
19463
19473
  }
19464
19474
  if (!cred) throw new Error("\u53D6\u4E0D\u5230 App Secret");
19465
- const host = app.tenant === "feishu" ? "https://open.feishu.cn" : "https://open.larksuite.com";
19475
+ const host = brandOfTenant(app.tenant) === "feishu" ? "https://open.feishu.cn" : "https://open.larksuite.com";
19466
19476
  const out = JSON.parse(
19467
19477
  await run(process.execPath, ["--no-warnings", "-e", FETCH_SCRIPT], JSON.stringify({ url: `${host}/open-apis/auth/v3/tenant_access_token/internal`, appId: app.id, secret: cred }), { ...process.env, NODE_USE_ENV_PROXY: "1" }, 2e4)
19468
19478
  );
@@ -19609,9 +19619,11 @@ function createGateway(opts) {
19609
19619
  const userDir = (openId) => join27(tokenRoot, openId);
19610
19620
  const authorizedMark = (openId) => join27(userDir(openId), ".authorized");
19611
19621
  const isAuthorized = (openId) => existsSync9(authorizedMark(openId));
19622
+ const brand = sourceBrand(opts.larkSourceConfig);
19612
19623
  function env(dir) {
19613
19624
  return {
19614
19625
  ...buildLarkChannelEnv({ larkCliSourceConfigFile: opts.larkSourceConfig, larkCliConfigDir: dir }),
19626
+ LARKSUITE_CLI_BRAND: brand,
19615
19627
  LARKSUITE_CLI_DATA_DIR: dir,
19616
19628
  LARKSUITE_CLI_NO_UPDATE_NOTIFIER: "1",
19617
19629
  LARKSUITE_CLI_NO_SKILLS_NOTIFIER: "1"