mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-17 13:13:35 +08:00
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:
parent
be2e9acdaa
commit
88e7e14598
@ -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,
|
||||
},
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user