Spaces:
Running
Running
File size: 1,795 Bytes
fb4d8fe | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | import type { ChannelId } from "../channels/plugins/types.js";
import type { NativeCommandsSetting } from "./types.js";
import { normalizeChannelId } from "../channels/plugins/index.js";
function resolveAutoDefault(providerId?: ChannelId): boolean {
const id = normalizeChannelId(providerId);
if (!id) {
return false;
}
if (id === "discord" || id === "telegram") {
return true;
}
if (id === "slack") {
return false;
}
return false;
}
export function resolveNativeSkillsEnabled(params: {
providerId: ChannelId;
providerSetting?: NativeCommandsSetting;
globalSetting?: NativeCommandsSetting;
}): boolean {
const { providerId, providerSetting, globalSetting } = params;
const setting = providerSetting === undefined ? globalSetting : providerSetting;
if (setting === true) {
return true;
}
if (setting === false) {
return false;
}
return resolveAutoDefault(providerId);
}
export function resolveNativeCommandsEnabled(params: {
providerId: ChannelId;
providerSetting?: NativeCommandsSetting;
globalSetting?: NativeCommandsSetting;
}): boolean {
const { providerId, providerSetting, globalSetting } = params;
const setting = providerSetting === undefined ? globalSetting : providerSetting;
if (setting === true) {
return true;
}
if (setting === false) {
return false;
}
// auto or undefined -> heuristic
return resolveAutoDefault(providerId);
}
export function isNativeCommandsExplicitlyDisabled(params: {
providerSetting?: NativeCommandsSetting;
globalSetting?: NativeCommandsSetting;
}): boolean {
const { providerSetting, globalSetting } = params;
if (providerSetting === false) {
return true;
}
if (providerSetting === undefined) {
return globalSetting === false;
}
return false;
}
|