Skip to content

Commit

Permalink
fix: 修复编译时类型BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
TBXark committed Dec 24, 2024
1 parent 87f7151 commit e9ceae4
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 57 deletions.
2 changes: 1 addition & 1 deletion dist/buildinfo.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 39 additions & 41 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 3 additions & 10 deletions packages/lib/core/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,14 @@ export class AnthropicConfig {
ANTHROPIC_CHAT_MODELS_LIST = '';
}

export type AIProviderConfig = OpenAIConfig &
DallEConfig &
AzureConfig &
WorkersConfig &
GeminiConfig &
MistralConfig &
CohereConfig &
AnthropicConfig;
type UserConfig = AgentShareConfig & OpenAIConfig & DallEConfig & AzureConfig & WorkersConfig & GeminiConfig & MistralConfig & CohereConfig & AnthropicConfig;
export type AgentUserConfigKey = keyof UserConfig;

export class DefineKeys {
DEFINE_KEYS: AgentUserConfigKey[] = [];
}

export type AgentUserConfig = Record<string, any> & DefineKeys & AIProviderConfig;
export type AgentUserConfigKey = keyof AIProviderConfig;
export type AgentUserConfig = Record<string, any> & DefineKeys & UserConfig;

// -- 只能通过环境变量覆盖的配置 --
export class EnvironmentConfig {
Expand Down
4 changes: 2 additions & 2 deletions packages/lib/core/src/config/version.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const BUILD_TIMESTAMP = 1735032908;
export const BUILD_VERSION = 'ce516de';
export const BUILD_TIMESTAMP = 1735035314;
export const BUILD_VERSION = '87f7151';
6 changes: 3 additions & 3 deletions packages/lib/core/src/telegram/command/system.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { HistoryItem, HistoryModifierResult, UserMessageItem } from '#/agent';
import type { WorkerContext } from '#/config';
import type {AgentUserConfigKey, WorkerContext} from '#/config';
import type * as Telegram from 'telegram-bot-api-types';
import type { CommandHandler } from './types';
import { loadChatLLM, loadImageGen } from '#/agent';
Expand Down Expand Up @@ -129,7 +129,7 @@ export class SetEnvCommandHandler implements CommandHandler {
const key = subcommand.slice(0, kv);
const value = subcommand.slice(kv + 1);
try {
await context.execChangeAndSave({ [key]: value });
await context.execChangeAndSave({ [key]: value } as Record<AgentUserConfigKey, any>);
return sender.sendPlainText('Update user config success');
} catch (e) {
return sender.sendPlainText(`ERROR: ${(e as Error).message}`);
Expand Down Expand Up @@ -157,7 +157,7 @@ export class DelEnvCommandHandler implements CommandHandler {
needAuth = TELEGRAM_AUTH_CHECKER.shareModeGroup;
handle = async (message: Telegram.Message, subcommand: string, context: WorkerContext): Promise<Response> => {
const sender = MessageSender.fromMessage(context.SHARE_CONTEXT.botToken, message);
if (ENV.LOCK_USER_CONFIG_KEYS.includes(subcommand)) {
if (ENV.LOCK_USER_CONFIG_KEYS.includes(subcommand as AgentUserConfigKey)) {
const msg = `Key ${subcommand} is locked`;
return sender.sendPlainText(msg);
}
Expand Down

0 comments on commit e9ceae4

Please sign in to comment.