@larktask/aamp-feishu-task-agent 0.1.1-dev.2 → 0.1.1-dev.3
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.
|
@@ -75,6 +75,10 @@ const FEISHU_START_CONCURRENCY = 4;
|
|
|
75
75
|
const CONFIG_SCHEMA = 'aamp.feishu-task-agent.bindings';
|
|
76
76
|
const CONFIG_VERSION = 1;
|
|
77
77
|
const PROFILE_DOMAINS = ['task'];
|
|
78
|
+
const OPEN_API_DOMAIN_BY_TENANT_BRAND = Object.freeze({
|
|
79
|
+
feishu: 'https://open.feishu.cn',
|
|
80
|
+
lark: 'https://open.larksuite.com',
|
|
81
|
+
});
|
|
78
82
|
|
|
79
83
|
const secrets = new Set();
|
|
80
84
|
const managedProcesses = new Set();
|
|
@@ -782,6 +786,7 @@ function validateBinding(binding, index) {
|
|
|
782
786
|
assertString(binding.environment?.name, `bindings[${index}].environment.name`);
|
|
783
787
|
assertString(binding.bot?.app_id, `bindings[${index}].bot.app_id`);
|
|
784
788
|
assertString(binding.bot?.app_secret, `bindings[${index}].bot.app_secret`);
|
|
789
|
+
normalizeTenantBrand(binding.bot?.tenant_brand, `bindings[${index}].bot.tenant_brand`);
|
|
785
790
|
const metadata = resolveTaskAgentMetadata(binding.agent_type);
|
|
786
791
|
if (metadata.executionLocation === 'local') {
|
|
787
792
|
assertString(binding.bot?.lark_cli_profile, `bindings[${index}].bot.lark_cli_profile`);
|
|
@@ -841,12 +846,26 @@ function bindingExpectation(binding) {
|
|
|
841
846
|
};
|
|
842
847
|
}
|
|
843
848
|
|
|
849
|
+
function normalizeTenantBrand(value, field = 'tenant_brand') {
|
|
850
|
+
if (value === undefined || value === null || value === '') return 'feishu';
|
|
851
|
+
if (value !== 'feishu' && value !== 'lark') {
|
|
852
|
+
throw new Error(`${field} 仅支持 feishu/lark`);
|
|
853
|
+
}
|
|
854
|
+
return value;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
function openApiDomainForTenantBrand(value) {
|
|
858
|
+
return OPEN_API_DOMAIN_BY_TENANT_BRAND[normalizeTenantBrand(value)];
|
|
859
|
+
}
|
|
860
|
+
|
|
844
861
|
function sameBindingRelationship(existing, candidate) {
|
|
845
862
|
return Boolean(existing && candidate
|
|
846
863
|
&& existing.agent_type === candidate.agent_type
|
|
847
864
|
&& existing.aamp_host === candidate.aamp_host
|
|
848
865
|
&& existing.environment?.name === candidate.environment?.name
|
|
849
|
-
&& existing.bot?.app_id === candidate.bot?.app_id
|
|
866
|
+
&& existing.bot?.app_id === candidate.bot?.app_id
|
|
867
|
+
&& normalizeTenantBrand(existing.bot?.tenant_brand)
|
|
868
|
+
=== normalizeTenantBrand(candidate.bot?.tenant_brand));
|
|
850
869
|
}
|
|
851
870
|
|
|
852
871
|
async function upsertBindings(intents) {
|
|
@@ -2140,6 +2159,7 @@ function feishuArgs(binding, larkCliBin, target) {
|
|
|
2140
2159
|
...targetArgs,
|
|
2141
2160
|
'--app-id', binding.bot.app_id,
|
|
2142
2161
|
'--bot-name', binding.bot.display_name || binding.bot.app_id,
|
|
2162
|
+
'--domain', openApiDomainForTenantBrand(binding.bot.tenant_brand),
|
|
2143
2163
|
...(metadata.executionLocation === 'local' ? [
|
|
2144
2164
|
'--use-feishu-cli',
|
|
2145
2165
|
'--feishu-cli-profile', binding.bot.lark_cli_profile,
|
|
@@ -3093,21 +3113,8 @@ async function discoverAgents() {
|
|
|
3093
3113
|
return agents;
|
|
3094
3114
|
}
|
|
3095
3115
|
|
|
3096
|
-
|
|
3097
|
-
const agent = DEFAULT_AGENT || await chooseOne('请选择要绑定的智能体:', agents, agentSelectionDisplayName);
|
|
3098
|
-
const registered = await runBootstrapHelper('__register-binding', agent);
|
|
3099
|
-
addSecret(registered.app_secret);
|
|
3116
|
+
function buildPendingBinding(agent, registered, bindingId = randomId(), timestamp = nowIso()) {
|
|
3100
3117
|
const metadata = resolveTaskAgentMetadata(agent);
|
|
3101
|
-
if (!registered.app_id || !registered.app_secret
|
|
3102
|
-
|| (metadata.executionLocation === 'local' && !registered.lark_cli_profile)) {
|
|
3103
|
-
throw new Error('飞书应用授权结果不完整');
|
|
3104
|
-
}
|
|
3105
|
-
if (selectedAppIds.has(registered.app_id)) {
|
|
3106
|
-
throw new Error(`Bot ${registered.app_id} 已经选择过,不能重复绑定`);
|
|
3107
|
-
}
|
|
3108
|
-
selectedAppIds.add(registered.app_id);
|
|
3109
|
-
const bindingId = randomId();
|
|
3110
|
-
const timestamp = nowIso();
|
|
3111
3118
|
return {
|
|
3112
3119
|
binding_id: bindingId,
|
|
3113
3120
|
agent_type: agent,
|
|
@@ -3115,6 +3122,7 @@ async function createDraft(agents, selectedAppIds) {
|
|
|
3115
3122
|
app_id: registered.app_id,
|
|
3116
3123
|
app_secret: registered.app_secret,
|
|
3117
3124
|
display_name: registered.display_name || registered.app_id,
|
|
3125
|
+
tenant_brand: normalizeTenantBrand(registered.tenant_brand, 'registered.tenant_brand'),
|
|
3118
3126
|
...(metadata.executionLocation === 'local' ? { lark_cli_profile: registered.lark_cli_profile } : {}),
|
|
3119
3127
|
},
|
|
3120
3128
|
environment: { name: 'online' },
|
|
@@ -3126,6 +3134,22 @@ async function createDraft(agents, selectedAppIds) {
|
|
|
3126
3134
|
};
|
|
3127
3135
|
}
|
|
3128
3136
|
|
|
3137
|
+
async function createDraft(agents, selectedAppIds) {
|
|
3138
|
+
const agent = DEFAULT_AGENT || await chooseOne('请选择要绑定的智能体:', agents, agentSelectionDisplayName);
|
|
3139
|
+
const registered = await runBootstrapHelper('__register-binding', agent);
|
|
3140
|
+
addSecret(registered.app_secret);
|
|
3141
|
+
const metadata = resolveTaskAgentMetadata(agent);
|
|
3142
|
+
if (!registered.app_id || !registered.app_secret
|
|
3143
|
+
|| (metadata.executionLocation === 'local' && !registered.lark_cli_profile)) {
|
|
3144
|
+
throw new Error('飞书应用授权结果不完整');
|
|
3145
|
+
}
|
|
3146
|
+
if (selectedAppIds.has(registered.app_id)) {
|
|
3147
|
+
throw new Error(`Bot ${registered.app_id} 已经选择过,不能重复绑定`);
|
|
3148
|
+
}
|
|
3149
|
+
selectedAppIds.add(registered.app_id);
|
|
3150
|
+
return buildPendingBinding(agent, registered);
|
|
3151
|
+
}
|
|
3152
|
+
|
|
3129
3153
|
async function runBindingSession(mode) {
|
|
3130
3154
|
const store = await loadStore();
|
|
3131
3155
|
throwIfStopping();
|
|
@@ -3437,6 +3461,7 @@ if (isMainModule) {
|
|
|
3437
3461
|
}
|
|
3438
3462
|
|
|
3439
3463
|
export {
|
|
3464
|
+
buildPendingBinding,
|
|
3440
3465
|
bindingExpectation,
|
|
3441
3466
|
acpBridgeAgentPolicy,
|
|
3442
3467
|
commitPreparedAgentBindings,
|
|
@@ -5,6 +5,7 @@ umask 077
|
|
|
5
5
|
AGENT=""
|
|
6
6
|
APP_ID=""
|
|
7
7
|
APP_SECRET=""
|
|
8
|
+
APP_TENANT_BRAND="feishu"
|
|
8
9
|
BOT_NAME=""
|
|
9
10
|
LARK_CLI_PROFILE=""
|
|
10
11
|
AGENT_EXECUTION_LOCATION=""
|
|
@@ -111,7 +112,7 @@ AAMP_TASK_DEFAULT_FEISHU_BRIDGE_PKG="$FEISHU_BRIDGE_PKG"
|
|
|
111
112
|
AAMP_TASK_DEFAULT_AIME_ACP_PKG="$AIME_ACP_PKG"
|
|
112
113
|
AAMP_TASK_AGENT_NAME="${AAMP_TASK_AGENT_NAME:-@larktask/aamp-feishu-task-agent}"
|
|
113
114
|
AAMP_TASK_AGENT_LEGACY_NAME="${AAMP_TASK_AGENT_LEGACY_NAME:-@zengxingyuan/aamp-feishu-task-agent}"
|
|
114
|
-
AAMP_TASK_AGENT_VERSION="0.1.1-dev.
|
|
115
|
+
AAMP_TASK_AGENT_VERSION="0.1.1-dev.3"
|
|
115
116
|
AAMP_TASK_AGENT_CHANNEL="${AAMP_TASK_AGENT_CHANNEL:-dev}"
|
|
116
117
|
AAMP_STALE_PROCESS_CLEANUP="${AAMP_STALE_PROCESS_CLEANUP:-false}"
|
|
117
118
|
AAMP_STALE_PROCESS_SECONDS="${AAMP_STALE_PROCESS_SECONDS:-86400}"
|
|
@@ -1815,12 +1816,13 @@ for (const bot of bots) {
|
|
|
1815
1816
|
const profile = String(bot?.profile || "").trim();
|
|
1816
1817
|
const name = String(bot?.display_name || appId).trim();
|
|
1817
1818
|
const appSecret = String(bot?.app_secret || "").trim();
|
|
1819
|
+
const tenantBrand = bot?.tenant_brand === "lark" ? "lark" : "feishu";
|
|
1818
1820
|
if (!appId || !profile || seen.has(appId) || activeAppIds.has(appId)) continue;
|
|
1819
1821
|
if (!appSecret) {
|
|
1820
1822
|
continue;
|
|
1821
1823
|
}
|
|
1822
1824
|
seen.add(appId);
|
|
1823
|
-
console.log([appId, name, profile, appSecret].join("\t"));
|
|
1825
|
+
console.log([appId, name, profile, appSecret, tenantBrand].join("\t"));
|
|
1824
1826
|
}
|
|
1825
1827
|
'
|
|
1826
1828
|
}
|
|
@@ -2003,7 +2005,12 @@ process.exit(bots.some((bot) => String(bot?.app_id || "").trim() && String(bot?.
|
|
|
2003
2005
|
|
|
2004
2006
|
task_profile_name_for_app_id() {
|
|
2005
2007
|
local app_id="$1"
|
|
2006
|
-
|
|
2008
|
+
local tenant_brand="${2:-feishu}"
|
|
2009
|
+
case "$tenant_brand" in
|
|
2010
|
+
feishu) printf 'aamp-feishu-task-%s' "$app_id" ;;
|
|
2011
|
+
lark) printf 'aamp-feishu-task-%s-lark' "$app_id" ;;
|
|
2012
|
+
*) agent_fail "unsupported tenant brand: $tenant_brand" ;;
|
|
2013
|
+
esac
|
|
2007
2014
|
}
|
|
2008
2015
|
|
|
2009
2016
|
save_bot_config() {
|
|
@@ -2011,14 +2018,20 @@ save_bot_config() {
|
|
|
2011
2018
|
local app_id="$2"
|
|
2012
2019
|
local profile="$3"
|
|
2013
2020
|
local app_secret="${4:-}"
|
|
2021
|
+
local tenant_brand="${5:-feishu}"
|
|
2014
2022
|
mkdir -p "$(dirname "$BOT_CONFIG_FILE")"
|
|
2015
|
-
|
|
2023
|
+
case "$tenant_brand" in
|
|
2024
|
+
feishu|lark) ;;
|
|
2025
|
+
*) agent_fail "unsupported tenant brand: $tenant_brand" ;;
|
|
2026
|
+
esac
|
|
2027
|
+
BOT_CONFIG_FILE="$BOT_CONFIG_FILE" BOT_NAME="$bot_name" BOT_APP_ID="$app_id" BOT_PROFILE="$profile" BOT_APP_SECRET="$app_secret" BOT_TENANT_BRAND="$tenant_brand" FEISHU_TASK_PROFILE_DOMAINS="$FEISHU_TASK_PROFILE_DOMAINS" FEISHU_SCOPE_MANIFEST_VERSION="$FEISHU_SCOPE_MANIFEST_VERSION" FEISHU_USER_AUTH_MODE="$FEISHU_USER_AUTH_MODE" node -e '
|
|
2016
2028
|
const fs = require("fs");
|
|
2017
2029
|
const file = process.env.BOT_CONFIG_FILE;
|
|
2018
2030
|
const appSecret = String(process.env.BOT_APP_SECRET || "").trim();
|
|
2019
2031
|
const next = {
|
|
2020
2032
|
display_name: process.env.BOT_NAME || process.env.BOT_APP_ID,
|
|
2021
2033
|
app_id: process.env.BOT_APP_ID,
|
|
2034
|
+
tenant_brand: process.env.BOT_TENANT_BRAND || "feishu",
|
|
2022
2035
|
...(appSecret ? { app_secret: appSecret } : {}),
|
|
2023
2036
|
profile: process.env.BOT_PROFILE,
|
|
2024
2037
|
auth_mode: "lark-cli",
|
|
@@ -2621,11 +2634,16 @@ ensure_lark_cli_profile_locked() {
|
|
|
2621
2634
|
local app_id="$1"
|
|
2622
2635
|
local app_secret="$2"
|
|
2623
2636
|
local profile="$3"
|
|
2637
|
+
local tenant_brand="${4:-feishu}"
|
|
2624
2638
|
local auth_excludes
|
|
2625
2639
|
local required_scopes
|
|
2626
2640
|
|
|
2627
2641
|
initialize_feishu_scope_manifest
|
|
2628
2642
|
validate_feishu_user_auth_mode
|
|
2643
|
+
case "$tenant_brand" in
|
|
2644
|
+
feishu|lark) ;;
|
|
2645
|
+
*) agent_fail "unsupported tenant brand: $tenant_brand" ;;
|
|
2646
|
+
esac
|
|
2629
2647
|
|
|
2630
2648
|
if "$LARK_CLI_CMD" profile list 2>/dev/null | grep -F "\"$profile\"" >/dev/null 2>&1; then
|
|
2631
2649
|
agent_detail "lark-cli profile already exists: $profile"
|
|
@@ -2635,6 +2653,7 @@ ensure_lark_cli_profile_locked() {
|
|
|
2635
2653
|
printf '%s\n' "$app_secret" | "$LARK_CLI_CMD" profile add \
|
|
2636
2654
|
--name "$profile" \
|
|
2637
2655
|
--app-id "$app_id" \
|
|
2656
|
+
--brand "$tenant_brand" \
|
|
2638
2657
|
--app-secret-stdin
|
|
2639
2658
|
fi
|
|
2640
2659
|
|
|
@@ -2705,17 +2724,19 @@ select_existing_bot_or_create() {
|
|
|
2705
2724
|
local names=()
|
|
2706
2725
|
local profiles=()
|
|
2707
2726
|
local app_secrets=()
|
|
2727
|
+
local tenant_brands=()
|
|
2708
2728
|
local bot_labels=()
|
|
2709
|
-
local app_id name profile app_secret
|
|
2729
|
+
local app_id name profile app_secret tenant_brand
|
|
2710
2730
|
local index create_index selected
|
|
2711
2731
|
|
|
2712
2732
|
acquire_bot_selection_lock
|
|
2713
|
-
while IFS=$'\t' read -r app_id name profile app_secret; do
|
|
2733
|
+
while IFS=$'\t' read -r app_id name profile app_secret tenant_brand; do
|
|
2714
2734
|
[ -n "$app_id" ] || continue
|
|
2715
2735
|
app_ids+=("$app_id")
|
|
2716
2736
|
names+=("${name:-$app_id}")
|
|
2717
2737
|
profiles+=("$profile")
|
|
2718
2738
|
app_secrets+=("$app_secret")
|
|
2739
|
+
tenant_brands+=("${tenant_brand:-feishu}")
|
|
2719
2740
|
bot_labels+=("${name:-$app_id} ($app_id)")
|
|
2720
2741
|
done < <(load_bot_configs)
|
|
2721
2742
|
|
|
@@ -2754,11 +2775,12 @@ select_existing_bot_or_create() {
|
|
|
2754
2775
|
BOT_NAME="${names[$index]}"
|
|
2755
2776
|
LARK_CLI_PROFILE="${profiles[$index]}"
|
|
2756
2777
|
APP_SECRET="${app_secrets[$index]:-}"
|
|
2778
|
+
APP_TENANT_BRAND="${tenant_brands[$index]:-feishu}"
|
|
2757
2779
|
reserve_selected_bot "$APP_ID" "$LARK_CLI_PROFILE" "$BOT_NAME"
|
|
2758
2780
|
release_bot_selection_lock
|
|
2759
2781
|
agent_detail "using Feishu bot: $BOT_NAME ($APP_ID, profile=$LARK_CLI_PROFILE)"
|
|
2760
2782
|
agent_log "正在检查飞书授权..."
|
|
2761
|
-
ensure_lark_cli_profile "$APP_ID" "$APP_SECRET" "$LARK_CLI_PROFILE"
|
|
2783
|
+
ensure_lark_cli_profile "$APP_ID" "$APP_SECRET" "$LARK_CLI_PROFILE" "$APP_TENANT_BRAND"
|
|
2762
2784
|
}
|
|
2763
2785
|
|
|
2764
2786
|
register_feishu_app() {
|
|
@@ -2808,6 +2830,7 @@ const userScopes = splitList(process.env.FEISHU_APP_SCOPES_USER);
|
|
|
2808
2830
|
const tenantEvents = splitList(process.env.FEISHU_APP_EVENTS_TENANT);
|
|
2809
2831
|
const userEvents = splitList(process.env.FEISHU_APP_EVENTS_USER);
|
|
2810
2832
|
const appName = process.env.FEISHU_APP_PRESET_NAME || '飞书 CLI';
|
|
2833
|
+
let detectedTenantBrand = 'feishu';
|
|
2811
2834
|
|
|
2812
2835
|
function userLog(message) {
|
|
2813
2836
|
writeSync(5, `${message}\n`);
|
|
@@ -2860,15 +2883,24 @@ const result = await lark.registerApp({
|
|
|
2860
2883
|
},
|
|
2861
2884
|
onStatusChange(info) {
|
|
2862
2885
|
if (info.status === 'polling') return;
|
|
2886
|
+
if (info.status === 'domain_switched') detectedTenantBrand = 'lark';
|
|
2863
2887
|
console.log(`[aamp-one-click] registerApp status: ${info.status}`);
|
|
2864
2888
|
},
|
|
2865
2889
|
});
|
|
2866
2890
|
|
|
2867
|
-
|
|
2891
|
+
const reportedTenantBrand = result?.user_info?.tenant_brand;
|
|
2892
|
+
const tenantBrand = reportedTenantBrand === undefined || reportedTenantBrand === null || reportedTenantBrand === ''
|
|
2893
|
+
? detectedTenantBrand
|
|
2894
|
+
: reportedTenantBrand;
|
|
2895
|
+
const tenantBrandIsSupported = tenantBrand === 'feishu' || tenantBrand === 'lark';
|
|
2896
|
+
const openApiDomain = tenantBrand === 'lark' ? lark.Domain.Lark : lark.Domain.Feishu;
|
|
2897
|
+
|
|
2898
|
+
async function fetchRegisteredAppName(appId, appSecret, domain) {
|
|
2868
2899
|
try {
|
|
2869
2900
|
const client = new lark.Client({
|
|
2870
2901
|
appId,
|
|
2871
2902
|
appSecret,
|
|
2903
|
+
domain,
|
|
2872
2904
|
});
|
|
2873
2905
|
const response = await client.application.application.get({
|
|
2874
2906
|
path: { app_id: appId },
|
|
@@ -2882,11 +2914,14 @@ async function fetchRegisteredAppName(appId, appSecret) {
|
|
|
2882
2914
|
}
|
|
2883
2915
|
}
|
|
2884
2916
|
|
|
2885
|
-
const registeredAppName =
|
|
2917
|
+
const registeredAppName = tenantBrandIsSupported
|
|
2918
|
+
? await fetchRegisteredAppName(result.client_id, result.client_secret, openApiDomain)
|
|
2919
|
+
: '';
|
|
2886
2920
|
const resultPayload = {
|
|
2887
2921
|
app_id: result.client_id,
|
|
2888
2922
|
app_secret: result.client_secret,
|
|
2889
2923
|
app_name: registeredAppName || appName,
|
|
2924
|
+
tenant_brand: tenantBrand,
|
|
2890
2925
|
};
|
|
2891
2926
|
await import('node:fs/promises').then(({ writeFile }) => writeFile(process.env.AAMP_REGISTER_APP_RESULT_FILE, JSON.stringify(resultPayload)));
|
|
2892
2927
|
console.log(`[aamp-one-click] Feishu app registration completed: ${result.client_id}`);
|
|
@@ -2914,24 +2949,29 @@ NODE
|
|
|
2914
2949
|
APP_ID="$(node -e 'const fs = require("fs"); const data = JSON.parse(fs.readFileSync(process.argv[1], "utf8")); process.stdout.write(data.app_id || "")' "$register_result_file")"
|
|
2915
2950
|
APP_SECRET="$(node -e 'const fs = require("fs"); const data = JSON.parse(fs.readFileSync(process.argv[1], "utf8")); process.stdout.write(data.app_secret || "")' "$register_result_file")"
|
|
2916
2951
|
bot_name="$(node -e 'const fs = require("fs"); const data = JSON.parse(fs.readFileSync(process.argv[1], "utf8")); process.stdout.write(data.app_name || "")' "$register_result_file")"
|
|
2952
|
+
APP_TENANT_BRAND="$(node -e 'const fs = require("fs"); const data = JSON.parse(fs.readFileSync(process.argv[1], "utf8")); process.stdout.write(data.tenant_brand || "feishu")' "$register_result_file")"
|
|
2917
2953
|
: >"$register_result_file"
|
|
2918
2954
|
[ -n "$APP_ID" ] && [ -n "$APP_SECRET" ] || agent_fail "Feishu app registration returned incomplete credentials"
|
|
2955
|
+
case "$APP_TENANT_BRAND" in
|
|
2956
|
+
feishu|lark) ;;
|
|
2957
|
+
*) agent_fail "Feishu app registration returned unsupported tenant brand: $APP_TENANT_BRAND" ;;
|
|
2958
|
+
esac
|
|
2919
2959
|
|
|
2920
2960
|
bot_name="${bot_name:-$default_name}"
|
|
2921
2961
|
BOT_NAME="$bot_name"
|
|
2922
2962
|
if [ "$AGENT_EXECUTION_LOCATION" = "remote" ]; then
|
|
2923
2963
|
LARK_CLI_PROFILE=""
|
|
2924
2964
|
else
|
|
2925
|
-
LARK_CLI_PROFILE="$(task_profile_name_for_app_id "$APP_ID")"
|
|
2965
|
+
LARK_CLI_PROFILE="$(task_profile_name_for_app_id "$APP_ID" "$APP_TENANT_BRAND")"
|
|
2926
2966
|
source_lark_env
|
|
2927
|
-
ensure_lark_cli_profile "$APP_ID" "$APP_SECRET" "$LARK_CLI_PROFILE"
|
|
2967
|
+
ensure_lark_cli_profile "$APP_ID" "$APP_SECRET" "$LARK_CLI_PROFILE" "$APP_TENANT_BRAND"
|
|
2928
2968
|
fi
|
|
2929
2969
|
if [ "$AAMP_TASK_INTERNAL" = "true" ]; then
|
|
2930
2970
|
agent_detail "Feishu Bot 已授权:$BOT_NAME ($APP_ID)"
|
|
2931
2971
|
return 0
|
|
2932
2972
|
fi
|
|
2933
2973
|
acquire_bot_selection_lock
|
|
2934
|
-
save_bot_config "$bot_name" "$APP_ID" "$LARK_CLI_PROFILE" "$APP_SECRET"
|
|
2974
|
+
save_bot_config "$bot_name" "$APP_ID" "$LARK_CLI_PROFILE" "$APP_SECRET" "$APP_TENANT_BRAND"
|
|
2935
2975
|
reserve_selected_bot "$APP_ID" "$LARK_CLI_PROFILE" "$bot_name"
|
|
2936
2976
|
release_bot_selection_lock
|
|
2937
2977
|
agent_log "saved Feishu task profile config: $bot_name ($APP_ID, profile=$LARK_CLI_PROFILE)"
|
|
@@ -4941,9 +4981,9 @@ run_internal_register_binding() {
|
|
|
4941
4981
|
load_agent_metadata
|
|
4942
4982
|
register_feishu_app
|
|
4943
4983
|
if [ "$AGENT_EXECUTION_LOCATION" = "remote" ]; then
|
|
4944
|
-
emit_internal_result "{\"app_id\":\"$(json_escape "$APP_ID")\",\"app_secret\":\"$(json_escape "$APP_SECRET")\",\"display_name\":\"$(json_escape "$BOT_NAME")\",\"auth_mode\":\"app-secret\"}"
|
|
4984
|
+
emit_internal_result "{\"app_id\":\"$(json_escape "$APP_ID")\",\"app_secret\":\"$(json_escape "$APP_SECRET")\",\"display_name\":\"$(json_escape "$BOT_NAME")\",\"tenant_brand\":\"$(json_escape "$APP_TENANT_BRAND")\",\"auth_mode\":\"app-secret\"}"
|
|
4945
4985
|
else
|
|
4946
|
-
emit_internal_result "{\"app_id\":\"$(json_escape "$APP_ID")\",\"app_secret\":\"$(json_escape "$APP_SECRET")\",\"display_name\":\"$(json_escape "$BOT_NAME")\",\"lark_cli_profile\":\"$(json_escape "$LARK_CLI_PROFILE")\",\"auth_mode\":\"lark-cli\"}"
|
|
4986
|
+
emit_internal_result "{\"app_id\":\"$(json_escape "$APP_ID")\",\"app_secret\":\"$(json_escape "$APP_SECRET")\",\"display_name\":\"$(json_escape "$BOT_NAME")\",\"tenant_brand\":\"$(json_escape "$APP_TENANT_BRAND")\",\"lark_cli_profile\":\"$(json_escape "$LARK_CLI_PROFILE")\",\"auth_mode\":\"lark-cli\"}"
|
|
4947
4987
|
fi
|
|
4948
4988
|
}
|
|
4949
4989
|
|
|
@@ -5002,11 +5042,13 @@ run_internal_ensure_profile() {
|
|
|
5002
5042
|
APP_ID="$(binding_json_field bot.app_id)"
|
|
5003
5043
|
APP_SECRET="$(binding_json_field bot.app_secret)"
|
|
5004
5044
|
BOT_NAME="$(binding_json_field bot.display_name)"
|
|
5045
|
+
APP_TENANT_BRAND="$(binding_json_field bot.tenant_brand)"
|
|
5046
|
+
APP_TENANT_BRAND="${APP_TENANT_BRAND:-feishu}"
|
|
5005
5047
|
LARK_CLI_PROFILE="$(binding_json_field bot.lark_cli_profile)"
|
|
5006
5048
|
[ -n "$APP_ID" ] && [ -n "$APP_SECRET" ] && [ -n "$LARK_CLI_PROFILE" ] || agent_fail "binding is missing Feishu credentials or profile"
|
|
5007
5049
|
AAMP_TASK_INTERNAL_BINDING_JSON=""
|
|
5008
5050
|
source_lark_env
|
|
5009
|
-
ensure_lark_cli_profile "$APP_ID" "$APP_SECRET" "$LARK_CLI_PROFILE"
|
|
5051
|
+
ensure_lark_cli_profile "$APP_ID" "$APP_SECRET" "$LARK_CLI_PROFILE" "$APP_TENANT_BRAND"
|
|
5010
5052
|
APP_SECRET=""
|
|
5011
5053
|
emit_internal_result "{\"lark_cli_bin\":\"$(json_escape "$LARK_CLI_CMD")\",\"lark_cli_config_dir\":\"$(json_escape "${LARKSUITE_CLI_CONFIG_DIR:-}")\"}"
|
|
5012
5054
|
}
|