[Bug/Compat] opencode-go 上游强制要求 x-opencode-session 请求头,CCR 请求全部返回 400 MissingSessionID
// opencode-session.js -- register into the top level transformers in config.json, // and add "opencode-session" to the Transformer.use for the provider pointing to opencode.ai const os = require('os');
class OpenCodeSession { constructor(options) { options = options || {}; this.name = 'opencode-session'; this.headerName = options.headerName || 'x-opencode-session'; this.value = options.value || process.env.OPENCODE_SESSION_ID || 'ccr-' + String(os.hostname()).toLowerCase().replace(/[^a-z0-9_-]/g, ''); }
transformRequestIn(body) { const headers = {}; headers[this.headerName] = this.value; return { body, config: { headers } }; } }
module.exports = OpenCodeSession;
// config.json usage: { "transformers": [ { "path": "/absolute/path/to/opencode-session.js", "options": {} } ] }
// "Transformer": { "use": ["opencode-session"] }
内容来源: musistudio/claude-code-router