feat(pairing): extend type definitions with pairing and pairedUsers fields

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
程序员阿江(Relakkes) 2026-04-08 20:06:37 +08:00
parent be2e9acdaa
commit 88e7e14598
3 changed files with 53 additions and 0 deletions

View File

@ -8,9 +8,22 @@ import * as fs from 'node:fs'
import * as os from 'node:os'
import * as path from 'node:path'
export type PairedUser = {
userId: string | number
displayName: string
pairedAt: number
}
export type PairingState = {
code: string | null
expiresAt: number | null
createdAt: number | null
}
export type TelegramConfig = {
botToken: string
allowedUsers: number[]
pairedUsers: PairedUser[]
defaultWorkDir: string
}
@ -20,6 +33,7 @@ export type FeishuConfig = {
encryptKey: string
verificationToken: string
allowedUsers: string[]
pairedUsers: PairedUser[]
defaultWorkDir: string
streamingCard: boolean
}
@ -27,6 +41,7 @@ export type FeishuConfig = {
export type AdapterConfig = {
serverUrl: string
defaultProjectDir: string
pairing: PairingState
telegram: TelegramConfig
feishu: FeishuConfig
}
@ -51,13 +66,20 @@ export function loadConfig(): AdapterConfig {
const file = loadFile()
const tg = file.telegram ?? {}
const fs_ = file.feishu ?? {}
const pairing = file.pairing ?? {}
return {
serverUrl: process.env.ADAPTER_SERVER_URL || file.serverUrl || 'ws://127.0.0.1:3456',
defaultProjectDir: file.defaultProjectDir || '',
pairing: {
code: pairing.code ?? null,
expiresAt: pairing.expiresAt ?? null,
createdAt: pairing.createdAt ?? null,
},
telegram: {
botToken: process.env.TELEGRAM_BOT_TOKEN || tg.botToken || '',
allowedUsers: tg.allowedUsers ?? [],
pairedUsers: tg.pairedUsers ?? [],
defaultWorkDir: tg.defaultWorkDir || process.cwd(),
},
feishu: {
@ -66,6 +88,7 @@ export function loadConfig(): AdapterConfig {
encryptKey: process.env.FEISHU_ENCRYPT_KEY || fs_.encryptKey || '',
verificationToken: process.env.FEISHU_VERIFICATION_TOKEN || fs_.verificationToken || '',
allowedUsers: fs_.allowedUsers ?? [],
pairedUsers: fs_.pairedUsers ?? [],
defaultWorkDir: fs_.defaultWorkDir || process.cwd(),
streamingCard: fs_.streamingCard ?? false,
},

View File

@ -1,9 +1,23 @@
export type PairedUser = {
userId: string | number
displayName: string
pairedAt: number
}
export type PairingState = {
code: string | null
expiresAt: number | null
createdAt: number | null
}
export type AdapterFileConfig = {
serverUrl?: string
defaultProjectDir?: string
pairing?: PairingState
telegram?: {
botToken?: string
allowedUsers?: number[]
pairedUsers?: PairedUser[]
defaultWorkDir?: string
}
feishu?: {
@ -12,6 +26,7 @@ export type AdapterFileConfig = {
encryptKey?: string
verificationToken?: string
allowedUsers?: string[]
pairedUsers?: PairedUser[]
defaultWorkDir?: string
streamingCard?: boolean
}

View File

@ -10,12 +10,26 @@ import * as path from 'path'
import * as os from 'os'
import { ApiError } from '../middleware/errorHandler.js'
export type PairedUser = {
userId: string | number
displayName: string
pairedAt: number
}
export type PairingState = {
code?: string | null
expiresAt?: number | null
createdAt?: number | null
}
export type AdapterFileConfig = {
serverUrl?: string
defaultProjectDir?: string
pairing?: PairingState
telegram?: {
botToken?: string
allowedUsers?: number[]
pairedUsers?: PairedUser[]
defaultWorkDir?: string
}
feishu?: {
@ -24,6 +38,7 @@ export type AdapterFileConfig = {
encryptKey?: string
verificationToken?: string
allowedUsers?: string[]
pairedUsers?: PairedUser[]
defaultWorkDir?: string
streamingCard?: boolean
}