修复 Codex MCP type 配置并更新发布包

This commit is contained in:
shiyue
2026-10-08 14:55:58 +08:00
parent caf8947cd9
commit 747771a048
17 changed files with 181 additions and 4 deletions

View File

@@ -2,6 +2,7 @@
/** Gitea Workflow Codex/App 协议适配器离线单测。 */
const assert = require('node:assert/strict');
const { toCodexMcpServerConfig } = require('../lib/codex-mcp-config');
const {
buildGiteaMcpServerConfig,
buildGiteaThreadConfig,
@@ -17,6 +18,21 @@ const {
} = require('../lib/gitea-workflow-codex');
async function main() {
const legacyMcp = {
type: 'streamable_http',
url: 'https://mcp.example/tools',
bearer_token_env_var: 'MCP_TOKEN',
startup_timeout_sec: 20,
tool_timeout_sec: 120,
env: { type: '保留这个环境变量' },
};
const outgoingMcp = toCodexMcpServerConfig(legacyMcp);
assert.equal(Object.hasOwn(outgoingMcp, 'type'), false);
assert.equal(legacyMcp.type, 'streamable_http');
assert.notEqual(outgoingMcp, legacyMcp);
const { type: legacyType, ...connectionFields } = legacyMcp;
assert.deepEqual(outgoingMcp, connectionFields);
const mcp = buildGiteaMcpServerConfig({
host: 'https://gitea.example/',
accessToken: 'secret-token',
@@ -31,7 +47,10 @@ async function main() {
host: 'https://gitea.example',
accessToken: 'secret-token',
});
assert.equal(thread.config['mcp_servers.gitea'].type, 'stdio');
assert.equal(Object.hasOwn(thread.config['mcp_servers.gitea'], 'type'), false);
assert.equal(thread.mcpServer.type, 'stdio');
assert.equal(thread.config['mcp_servers.gitea'].command, 'gitea-mcp');
assert.deepEqual(thread.config['mcp_servers.gitea'].args.slice(0, 4), ['-t', 'stdio', '-H', 'https://gitea.example']);
assert.equal(thread.config['mcp_servers.gitea'].env.GITEA_ACCESS_TOKEN, 'secret-token');
assert.equal(Object.hasOwn(thread.config, 'model'), false);