Skip to content

Commit e9ceae4

Browse files
committed
fix: 修复编译时类型BUG
1 parent 87f7151 commit e9ceae4

File tree

5 files changed

+48
-57
lines changed

5 files changed

+48
-57
lines changed

dist/buildinfo.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

Lines changed: 39 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/lib/core/src/config/config.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,21 +116,14 @@ export class AnthropicConfig {
116116
ANTHROPIC_CHAT_MODELS_LIST = '';
117117
}
118118

119-
export type AIProviderConfig = OpenAIConfig &
120-
DallEConfig &
121-
AzureConfig &
122-
WorkersConfig &
123-
GeminiConfig &
124-
MistralConfig &
125-
CohereConfig &
126-
AnthropicConfig;
119+
type UserConfig = AgentShareConfig & OpenAIConfig & DallEConfig & AzureConfig & WorkersConfig & GeminiConfig & MistralConfig & CohereConfig & AnthropicConfig;
120+
export type AgentUserConfigKey = keyof UserConfig;
127121

128122
export class DefineKeys {
129123
DEFINE_KEYS: AgentUserConfigKey[] = [];
130124
}
131125

132-
export type AgentUserConfig = Record<string, any> & DefineKeys & AIProviderConfig;
133-
export type AgentUserConfigKey = keyof AIProviderConfig;
126+
export type AgentUserConfig = Record<string, any> & DefineKeys & UserConfig;
134127

135128
// -- 只能通过环境变量覆盖的配置 --
136129
export class EnvironmentConfig {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export const BUILD_TIMESTAMP = 1735032908;
2-
export const BUILD_VERSION = 'ce516de';
1+
export const BUILD_TIMESTAMP = 1735035314;
2+
export const BUILD_VERSION = '87f7151';

packages/lib/core/src/telegram/command/system.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { HistoryItem, HistoryModifierResult, UserMessageItem } from '#/agent';
2-
import type { WorkerContext } from '#/config';
2+
import type {AgentUserConfigKey, WorkerContext} from '#/config';
33
import type * as Telegram from 'telegram-bot-api-types';
44
import type { CommandHandler } from './types';
55
import { loadChatLLM, loadImageGen } from '#/agent';
@@ -129,7 +129,7 @@ export class SetEnvCommandHandler implements CommandHandler {
129129
const key = subcommand.slice(0, kv);
130130
const value = subcommand.slice(kv + 1);
131131
try {
132-
await context.execChangeAndSave({ [key]: value });
132+
await context.execChangeAndSave({ [key]: value } as Record<AgentUserConfigKey, any>);
133133
return sender.sendPlainText('Update user config success');
134134
} catch (e) {
135135
return sender.sendPlainText(`ERROR: ${(e as Error).message}`);
@@ -157,7 +157,7 @@ export class DelEnvCommandHandler implements CommandHandler {
157157
needAuth = TELEGRAM_AUTH_CHECKER.shareModeGroup;
158158
handle = async (message: Telegram.Message, subcommand: string, context: WorkerContext): Promise<Response> => {
159159
const sender = MessageSender.fromMessage(context.SHARE_CONTEXT.botToken, message);
160-
if (ENV.LOCK_USER_CONFIG_KEYS.includes(subcommand)) {
160+
if (ENV.LOCK_USER_CONFIG_KEYS.includes(subcommand as AgentUserConfigKey)) {
161161
const msg = `Key ${subcommand} is locked`;
162162
return sender.sendPlainText(msg);
163163
}

0 commit comments

Comments
 (0)