模型通道:接管官方 API Key 通道指向弹匣网关(GLM-5.3 / GLM-5.3-Flash) 登录:浏览器取一次性接入码 → 换成员专属 key → 写入 DSH 凭据 工具面:MCP 暴露查汇总/查任务/查项目/建任务/完成/改期/whoami 面板:侧边栏入口,个人看板 + 角色可见范围 + 行内操作 离职吊销:成员停用即吊销名下全部 TDB key 发布配置:scope 包名、私有 registry 锁定、prepack 自动构建、prepublishOnly 检查
54 lines
2.4 KiB
JavaScript
54 lines
2.4 KiB
JavaScript
#!/usr/bin/env node
|
|
// 验证:本人的 per-user key 能否过公司网关;DSH 链路(OpenAI 格式) 与 弹匣链路(Anthropic 格式) 是否都可用。
|
|
// 只发最小请求(max_tokens=16),不打印任何 key。
|
|
import { readFileSync } from 'node:fs'
|
|
import { homedir } from 'node:os'
|
|
import { join } from 'node:path'
|
|
|
|
const cfgPath = join(homedir(), 'Documents/Essay_AI/Essay_system/dsh-markmag/.local-credentials.json')
|
|
const cfg = JSON.parse(readFileSync(cfgPath, 'utf8'))
|
|
const key = cfg.key2 || cfg.key1
|
|
const BASE = 'https://brain.sidaocai.cn'
|
|
|
|
async function call(name, url, headers, body) {
|
|
const t0 = Date.now()
|
|
try {
|
|
const res = await fetch(url, {
|
|
method: 'POST',
|
|
headers: { 'content-type': 'application/json', ...headers },
|
|
body: JSON.stringify(body),
|
|
signal: AbortSignal.timeout(40000),
|
|
})
|
|
const text = await res.text()
|
|
const ms = Date.now() - t0
|
|
console.log(`[${name}] status=${res.status} ${ms}ms`)
|
|
console.log(' body:', text.slice(0, 400).replace(/\n/g, ' '))
|
|
return res.status
|
|
} catch (e) {
|
|
console.log(`[${name}] FAIL ${Date.now() - t0}ms err=${e.name}: ${e.message}`)
|
|
return -1
|
|
}
|
|
}
|
|
|
|
console.log('key source: key2 =', Boolean(cfg.key2), ' key1 =', Boolean(cfg.key1))
|
|
|
|
// A. 弹匣链路:Anthropic messages
|
|
await call('A-anthropic/claude-code', BASE + '/tdb-api/claude-code/default/v1/messages',
|
|
{ 'x-api-key': key, 'anthropic-version': '2023-06-01' },
|
|
{ model: 'deepseek-v4-pro', max_tokens: 16, messages: [{ role: 'user', content: 'ping' }] })
|
|
|
|
// B. DSH 链路:OpenAI chat/completions + 团队头
|
|
await call('B-openai/dsh', BASE + '/tdb-api/dsh/default/chat/completions',
|
|
{ authorization: 'Bearer ' + key, 'x-team-id': 'team-oek7kp1cy7', 'x-agent-id': 'agt-of5x44h7ns' },
|
|
{ model: 'deepseek-v4-pro', max_tokens: 16, messages: [{ role: 'user', content: 'ping' }] })
|
|
|
|
// C. DSH 链路但不带头(看团队头是否必需)
|
|
await call('C-openai/dsh-no-header', BASE + '/tdb-api/dsh/default/chat/completions',
|
|
{ authorization: 'Bearer ' + key },
|
|
{ model: 'deepseek-v4-pro', max_tokens: 16, messages: [{ role: 'user', content: 'ping' }] })
|
|
|
|
// D. 坏 key(确认鉴权是否真的在拦)
|
|
await call('D-bad-key', BASE + '/tdb-api/dsh/default/chat/completions',
|
|
{ authorization: 'Bearer sk-mem-INVALID_INVALID_INVALID' },
|
|
{ model: 'deepseek-v4-pro', max_tokens: 16, messages: [{ role: 'user', content: 'ping' }] })
|