MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / ensureToken

Function ensureToken

apps/cli/src/http/index.ts:77–87  ·  view source on GitHub ↗
(config: ChatLabConfig)

Source from the content-addressed store, hash-verified

75}
76
77function ensureToken(config: ChatLabConfig): string {
78 if (config.api.token) return config.api.token
79
80 const token = `clb_${crypto.randomBytes(32).toString('hex')}`
81 try {
82 writeConfigField('api', 'token', token)
83 } catch {
84 // best-effort: token still usable for this session
85 }
86 return token
87}
88
89/**
90 * 启动独立 HTTP API 服务

Callers 1

startHttpServerFunction · 0.85

Calls 1

writeConfigFieldFunction · 0.90

Tested by

no test coverage detected