@pixelbyte-software/pixcode 1.33.6 → 1.33.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/assets/index-B1ghfb4w.css +32 -0
  2. package/dist/assets/{index-D6ErCuvV.js → index-JU38YIxa.js} +148 -148
  3. package/dist/favicon.svg +8 -8
  4. package/dist/icons/icon-128x128.svg +9 -9
  5. package/dist/icons/icon-144x144.svg +9 -9
  6. package/dist/icons/icon-152x152.svg +9 -9
  7. package/dist/icons/icon-192x192.svg +9 -9
  8. package/dist/icons/icon-384x384.svg +9 -9
  9. package/dist/icons/icon-512x512.svg +9 -9
  10. package/dist/icons/icon-72x72.svg +9 -9
  11. package/dist/icons/icon-96x96.svg +9 -9
  12. package/dist/icons/icon-template.svg +9 -9
  13. package/dist/index.html +2 -2
  14. package/dist/logo.svg +12 -12
  15. package/package.json +1 -1
  16. package/server/database/db.js +794 -794
  17. package/server/database/json-store.js +194 -194
  18. package/server/modules/providers/list/opencode/opencode-auth.provider.ts +130 -130
  19. package/server/modules/providers/list/opencode/opencode-mcp.provider.ts +126 -126
  20. package/server/modules/providers/list/opencode/opencode-sessions.provider.ts +193 -193
  21. package/server/modules/providers/list/opencode/opencode.provider.ts +29 -29
  22. package/server/modules/providers/list/qwen/qwen-auth.provider.ts +145 -145
  23. package/server/modules/providers/list/qwen/qwen-mcp.provider.ts +114 -114
  24. package/server/modules/providers/list/qwen/qwen-sessions.provider.ts +218 -218
  25. package/server/modules/providers/list/qwen/qwen.provider.ts +21 -21
  26. package/server/modules/providers/shared/provider-configs.ts +142 -142
  27. package/server/qwen-code-cli.js +395 -395
  28. package/server/qwen-response-handler.js +73 -73
  29. package/server/routes/qwen.js +27 -27
  30. package/server/services/external-access.js +171 -171
  31. package/server/services/provider-credentials.js +155 -155
  32. package/server/services/provider-models.js +381 -381
  33. package/server/services/telegram/telegram-http-client.js +130 -130
  34. package/server/services/vapid-keys.js +36 -36
  35. package/server/utils/port-access.js +209 -209
  36. package/dist/assets/index-cWbTlXsr.css +0 -32
@@ -1,29 +1,29 @@
1
- import { AbstractProvider } from '@/modules/providers/shared/base/abstract.provider.js';
2
- import { OpencodeProviderAuth } from '@/modules/providers/list/opencode/opencode-auth.provider.js';
3
- import { OpencodeMcpProvider } from '@/modules/providers/list/opencode/opencode-mcp.provider.js';
4
- import { OpencodeSessionsProvider } from '@/modules/providers/list/opencode/opencode-sessions.provider.js';
5
- import type { IProviderAuth, IProviderSessions } from '@/shared/interfaces.js';
6
-
7
- /**
8
- * OpenCode provider.
9
- *
10
- * OpenCode (npm package: `opencode-ai`, binary: `opencode`) is a
11
- * multi-provider terminal coding agent. Unlike Claude/Codex/Gemini/Qwen
12
- * it uses XDG paths:
13
- * - config: `~/.config/opencode/opencode.json`
14
- * - data: `~/.local/share/opencode/` (auth.json, sessions, logs)
15
- *
16
- * Its permission system is granular (per-tool + per-pattern) rather than
17
- * the 2/3-mode toggle other CLIs expose. We surface that through the
18
- * Configuration tab and the opencode.json editor — the Permissions tab
19
- * exposes high-level presets only.
20
- */
21
- export class OpencodeProvider extends AbstractProvider {
22
- readonly mcp = new OpencodeMcpProvider();
23
- readonly auth: IProviderAuth = new OpencodeProviderAuth();
24
- readonly sessions: IProviderSessions = new OpencodeSessionsProvider();
25
-
26
- constructor() {
27
- super('opencode');
28
- }
29
- }
1
+ import { AbstractProvider } from '@/modules/providers/shared/base/abstract.provider.js';
2
+ import { OpencodeProviderAuth } from '@/modules/providers/list/opencode/opencode-auth.provider.js';
3
+ import { OpencodeMcpProvider } from '@/modules/providers/list/opencode/opencode-mcp.provider.js';
4
+ import { OpencodeSessionsProvider } from '@/modules/providers/list/opencode/opencode-sessions.provider.js';
5
+ import type { IProviderAuth, IProviderSessions } from '@/shared/interfaces.js';
6
+
7
+ /**
8
+ * OpenCode provider.
9
+ *
10
+ * OpenCode (npm package: `opencode-ai`, binary: `opencode`) is a
11
+ * multi-provider terminal coding agent. Unlike Claude/Codex/Gemini/Qwen
12
+ * it uses XDG paths:
13
+ * - config: `~/.config/opencode/opencode.json`
14
+ * - data: `~/.local/share/opencode/` (auth.json, sessions, logs)
15
+ *
16
+ * Its permission system is granular (per-tool + per-pattern) rather than
17
+ * the 2/3-mode toggle other CLIs expose. We surface that through the
18
+ * Configuration tab and the opencode.json editor — the Permissions tab
19
+ * exposes high-level presets only.
20
+ */
21
+ export class OpencodeProvider extends AbstractProvider {
22
+ readonly mcp = new OpencodeMcpProvider();
23
+ readonly auth: IProviderAuth = new OpencodeProviderAuth();
24
+ readonly sessions: IProviderSessions = new OpencodeSessionsProvider();
25
+
26
+ constructor() {
27
+ super('opencode');
28
+ }
29
+ }
@@ -1,145 +1,145 @@
1
- import { readFile } from 'node:fs/promises';
2
- import os from 'node:os';
3
- import path from 'node:path';
4
-
5
- import spawn from 'cross-spawn';
6
-
7
- import type { IProviderAuth } from '@/shared/interfaces.js';
8
- import type { ProviderAuthStatus } from '@/shared/types.js';
9
- import { readObjectRecord, readOptionalString } from '@/shared/utils.js';
10
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
11
- // @ts-ignore — plain-JS module, typed via inference
12
- import { getProviderCredentials } from '@/services/provider-credentials.js';
13
-
14
- type QwenCredentialsStatus = {
15
- authenticated: boolean;
16
- email: string | null;
17
- method: string | null;
18
- error?: string;
19
- };
20
-
21
- /**
22
- * Qwen Code auth checker.
23
- *
24
- * Qwen supports three credential surfaces — in priority order:
25
- * 1. `QWEN_API_KEY` env var (classic API key)
26
- * 2. `OPENAI_API_KEY` + `OPENAI_BASE_URL` env vars (OpenAI-compatible BYOK
27
- * — what the docs recommend for ModelScope, OpenRouter, and self-hosted)
28
- * 3. Local OAuth tokens at `~/.qwen/oauth_creds.json` (Qwen OAuth /
29
- * Alibaba Cloud Coding Plan cached credentials)
30
- * 4. `~/.qwen/settings.json` with an embedded `auth.method` + API key
31
- */
32
- export class QwenProviderAuth implements IProviderAuth {
33
- private checkInstalled(): boolean {
34
- const cliPath = process.env.QWEN_PATH || 'qwen';
35
- try {
36
- const result = spawn.sync(cliPath, ['--version'], { stdio: 'ignore', timeout: 5000 });
37
- return !result.error && result.status === 0;
38
- } catch {
39
- return false;
40
- }
41
- }
42
-
43
- async getStatus(): Promise<ProviderAuthStatus> {
44
- const installed = this.checkInstalled();
45
-
46
- if (!installed) {
47
- return {
48
- installed,
49
- provider: 'qwen',
50
- authenticated: false,
51
- email: null,
52
- method: null,
53
- error: 'Qwen Code CLI is not installed',
54
- };
55
- }
56
-
57
- const credentials = await this.checkCredentials();
58
-
59
- return {
60
- installed,
61
- provider: 'qwen',
62
- authenticated: credentials.authenticated,
63
- email: credentials.email,
64
- method: credentials.method,
65
- error: credentials.authenticated ? undefined : credentials.error || 'Not authenticated',
66
- };
67
- }
68
-
69
- private async checkCredentials(): Promise<QwenCredentialsStatus> {
70
- // Pixcode-managed credentials come first. If the user saved an API key
71
- // through our Settings > Agents > API Key form, we trust that no
72
- // matter what the environment or ~/.qwen/* files say. Base URL is
73
- // optional — some users point at Alibaba's default endpoint.
74
- try {
75
- const creds = await getProviderCredentials('qwen');
76
- if (creds?.apiKey) {
77
- const label = creds.baseUrl
78
- ? `API Key · ${(() => { try { return new URL(creds.baseUrl).host; } catch { return creds.baseUrl; } })()}`
79
- : 'API Key Auth';
80
- return { authenticated: true, email: label, method: 'pixcode_store' };
81
- }
82
- } catch { /* fall through */ }
83
-
84
- if (process.env.QWEN_API_KEY?.trim()) {
85
- return { authenticated: true, email: 'API Key Auth', method: 'api_key' };
86
- }
87
- // Loosened: base URL is optional. Qwen Code also works with the default
88
- // Alibaba endpoint baked into the CLI. Previously required both env vars
89
- // and silently failed when the user only pasted an API key.
90
- if (process.env.OPENAI_API_KEY?.trim()) {
91
- return { authenticated: true, email: 'OpenAI-Compatible Auth', method: 'api_key' };
92
- }
93
-
94
- // OAuth credentials file — written by `/auth` interactive flow.
95
- try {
96
- const credsPath = path.join(os.homedir(), '.qwen', 'oauth_creds.json');
97
- const content = await readFile(credsPath, 'utf8');
98
- const creds = readObjectRecord(JSON.parse(content)) ?? {};
99
- const accessToken = readOptionalString(creds.access_token);
100
- if (accessToken) {
101
- const email = readOptionalString(creds.email)
102
- ?? readOptionalString(creds.user_email)
103
- ?? 'OAuth Session';
104
- return { authenticated: true, email, method: 'credentials_file' };
105
- }
106
- } catch { /* fall through to settings.json */ }
107
-
108
- // settings.json — the API-key / OpenAI-compat authoring path.
109
- try {
110
- const settingsPath = path.join(os.homedir(), '.qwen', 'settings.json');
111
- const content = await readFile(settingsPath, 'utf8');
112
- const settings = readObjectRecord(JSON.parse(content)) ?? {};
113
- const auth = readObjectRecord(settings.auth) ?? {};
114
- const method = readOptionalString(auth.method) ?? readOptionalString(settings.authMethod);
115
- const apiKey = readOptionalString(auth.apiKey) ?? readOptionalString(settings.apiKey);
116
-
117
- if (apiKey) {
118
- return {
119
- authenticated: true,
120
- email: method ? `${method} (settings.json)` : 'API Key Auth',
121
- method: 'settings_file',
122
- };
123
- }
124
-
125
- if (method && method.toLowerCase().includes('oauth')) {
126
- // Settings file says OAuth is configured but the creds file isn't
127
- // readable — treat as a soft "not authenticated yet" rather than an
128
- // install error, because the browser flow may be mid-flight.
129
- return {
130
- authenticated: false,
131
- email: null,
132
- method: 'credentials_file',
133
- error: 'OAuth not yet complete — run `qwen` and finish `/auth`.',
134
- };
135
- }
136
- } catch { /* no settings yet */ }
137
-
138
- return {
139
- authenticated: false,
140
- email: null,
141
- method: null,
142
- error: 'Qwen Code is not configured',
143
- };
144
- }
145
- }
1
+ import { readFile } from 'node:fs/promises';
2
+ import os from 'node:os';
3
+ import path from 'node:path';
4
+
5
+ import spawn from 'cross-spawn';
6
+
7
+ import type { IProviderAuth } from '@/shared/interfaces.js';
8
+ import type { ProviderAuthStatus } from '@/shared/types.js';
9
+ import { readObjectRecord, readOptionalString } from '@/shared/utils.js';
10
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
11
+ // @ts-ignore — plain-JS module, typed via inference
12
+ import { getProviderCredentials } from '@/services/provider-credentials.js';
13
+
14
+ type QwenCredentialsStatus = {
15
+ authenticated: boolean;
16
+ email: string | null;
17
+ method: string | null;
18
+ error?: string;
19
+ };
20
+
21
+ /**
22
+ * Qwen Code auth checker.
23
+ *
24
+ * Qwen supports three credential surfaces — in priority order:
25
+ * 1. `QWEN_API_KEY` env var (classic API key)
26
+ * 2. `OPENAI_API_KEY` + `OPENAI_BASE_URL` env vars (OpenAI-compatible BYOK
27
+ * — what the docs recommend for ModelScope, OpenRouter, and self-hosted)
28
+ * 3. Local OAuth tokens at `~/.qwen/oauth_creds.json` (Qwen OAuth /
29
+ * Alibaba Cloud Coding Plan cached credentials)
30
+ * 4. `~/.qwen/settings.json` with an embedded `auth.method` + API key
31
+ */
32
+ export class QwenProviderAuth implements IProviderAuth {
33
+ private checkInstalled(): boolean {
34
+ const cliPath = process.env.QWEN_PATH || 'qwen';
35
+ try {
36
+ const result = spawn.sync(cliPath, ['--version'], { stdio: 'ignore', timeout: 5000 });
37
+ return !result.error && result.status === 0;
38
+ } catch {
39
+ return false;
40
+ }
41
+ }
42
+
43
+ async getStatus(): Promise<ProviderAuthStatus> {
44
+ const installed = this.checkInstalled();
45
+
46
+ if (!installed) {
47
+ return {
48
+ installed,
49
+ provider: 'qwen',
50
+ authenticated: false,
51
+ email: null,
52
+ method: null,
53
+ error: 'Qwen Code CLI is not installed',
54
+ };
55
+ }
56
+
57
+ const credentials = await this.checkCredentials();
58
+
59
+ return {
60
+ installed,
61
+ provider: 'qwen',
62
+ authenticated: credentials.authenticated,
63
+ email: credentials.email,
64
+ method: credentials.method,
65
+ error: credentials.authenticated ? undefined : credentials.error || 'Not authenticated',
66
+ };
67
+ }
68
+
69
+ private async checkCredentials(): Promise<QwenCredentialsStatus> {
70
+ // Pixcode-managed credentials come first. If the user saved an API key
71
+ // through our Settings > Agents > API Key form, we trust that no
72
+ // matter what the environment or ~/.qwen/* files say. Base URL is
73
+ // optional — some users point at Alibaba's default endpoint.
74
+ try {
75
+ const creds = await getProviderCredentials('qwen');
76
+ if (creds?.apiKey) {
77
+ const label = creds.baseUrl
78
+ ? `API Key · ${(() => { try { return new URL(creds.baseUrl).host; } catch { return creds.baseUrl; } })()}`
79
+ : 'API Key Auth';
80
+ return { authenticated: true, email: label, method: 'pixcode_store' };
81
+ }
82
+ } catch { /* fall through */ }
83
+
84
+ if (process.env.QWEN_API_KEY?.trim()) {
85
+ return { authenticated: true, email: 'API Key Auth', method: 'api_key' };
86
+ }
87
+ // Loosened: base URL is optional. Qwen Code also works with the default
88
+ // Alibaba endpoint baked into the CLI. Previously required both env vars
89
+ // and silently failed when the user only pasted an API key.
90
+ if (process.env.OPENAI_API_KEY?.trim()) {
91
+ return { authenticated: true, email: 'OpenAI-Compatible Auth', method: 'api_key' };
92
+ }
93
+
94
+ // OAuth credentials file — written by `/auth` interactive flow.
95
+ try {
96
+ const credsPath = path.join(os.homedir(), '.qwen', 'oauth_creds.json');
97
+ const content = await readFile(credsPath, 'utf8');
98
+ const creds = readObjectRecord(JSON.parse(content)) ?? {};
99
+ const accessToken = readOptionalString(creds.access_token);
100
+ if (accessToken) {
101
+ const email = readOptionalString(creds.email)
102
+ ?? readOptionalString(creds.user_email)
103
+ ?? 'OAuth Session';
104
+ return { authenticated: true, email, method: 'credentials_file' };
105
+ }
106
+ } catch { /* fall through to settings.json */ }
107
+
108
+ // settings.json — the API-key / OpenAI-compat authoring path.
109
+ try {
110
+ const settingsPath = path.join(os.homedir(), '.qwen', 'settings.json');
111
+ const content = await readFile(settingsPath, 'utf8');
112
+ const settings = readObjectRecord(JSON.parse(content)) ?? {};
113
+ const auth = readObjectRecord(settings.auth) ?? {};
114
+ const method = readOptionalString(auth.method) ?? readOptionalString(settings.authMethod);
115
+ const apiKey = readOptionalString(auth.apiKey) ?? readOptionalString(settings.apiKey);
116
+
117
+ if (apiKey) {
118
+ return {
119
+ authenticated: true,
120
+ email: method ? `${method} (settings.json)` : 'API Key Auth',
121
+ method: 'settings_file',
122
+ };
123
+ }
124
+
125
+ if (method && method.toLowerCase().includes('oauth')) {
126
+ // Settings file says OAuth is configured but the creds file isn't
127
+ // readable — treat as a soft "not authenticated yet" rather than an
128
+ // install error, because the browser flow may be mid-flight.
129
+ return {
130
+ authenticated: false,
131
+ email: null,
132
+ method: 'credentials_file',
133
+ error: 'OAuth not yet complete — run `qwen` and finish `/auth`.',
134
+ };
135
+ }
136
+ } catch { /* no settings yet */ }
137
+
138
+ return {
139
+ authenticated: false,
140
+ email: null,
141
+ method: null,
142
+ error: 'Qwen Code is not configured',
143
+ };
144
+ }
145
+ }
@@ -1,114 +1,114 @@
1
- import os from 'node:os';
2
- import path from 'node:path';
3
-
4
- import { McpProvider } from '@/modules/providers/shared/mcp/mcp.provider.js';
5
- import type { McpScope, ProviderMcpServer, UpsertProviderMcpServerInput } from '@/shared/types.js';
6
- import {
7
- AppError,
8
- readJsonConfig,
9
- readObjectRecord,
10
- readOptionalString,
11
- readStringArray,
12
- readStringRecord,
13
- writeJsonConfig,
14
- } from '@/shared/utils.js';
15
-
16
- /**
17
- * Qwen Code MCP provider. Qwen reads MCP servers out of the same
18
- * `settings.json` shape Gemini uses, just under `~/.qwen/` instead of
19
- * `~/.gemini/`. Supported transports and scopes match Gemini.
20
- */
21
- export class QwenMcpProvider extends McpProvider {
22
- constructor() {
23
- super('qwen', ['user', 'project'], ['stdio', 'http', 'sse']);
24
- }
25
-
26
- protected async readScopedServers(scope: McpScope, workspacePath: string): Promise<Record<string, unknown>> {
27
- const filePath = scope === 'user'
28
- ? path.join(os.homedir(), '.qwen', 'settings.json')
29
- : path.join(workspacePath, '.qwen', 'settings.json');
30
- const config = await readJsonConfig(filePath);
31
- return readObjectRecord(config.mcpServers) ?? {};
32
- }
33
-
34
- protected async writeScopedServers(
35
- scope: McpScope,
36
- workspacePath: string,
37
- servers: Record<string, unknown>,
38
- ): Promise<void> {
39
- const filePath = scope === 'user'
40
- ? path.join(os.homedir(), '.qwen', 'settings.json')
41
- : path.join(workspacePath, '.qwen', 'settings.json');
42
- const config = await readJsonConfig(filePath);
43
- config.mcpServers = servers;
44
- await writeJsonConfig(filePath, config);
45
- }
46
-
47
- protected buildServerConfig(input: UpsertProviderMcpServerInput): Record<string, unknown> {
48
- if (input.transport === 'stdio') {
49
- if (!input.command?.trim()) {
50
- throw new AppError('command is required for stdio MCP servers.', {
51
- code: 'MCP_COMMAND_REQUIRED',
52
- statusCode: 400,
53
- });
54
- }
55
- return {
56
- command: input.command,
57
- args: input.args ?? [],
58
- env: input.env ?? {},
59
- cwd: input.cwd,
60
- };
61
- }
62
-
63
- if (!input.url?.trim()) {
64
- throw new AppError('url is required for http/sse MCP servers.', {
65
- code: 'MCP_URL_REQUIRED',
66
- statusCode: 400,
67
- });
68
- }
69
-
70
- return {
71
- type: input.transport,
72
- url: input.url,
73
- headers: input.headers ?? {},
74
- };
75
- }
76
-
77
- protected normalizeServerConfig(
78
- scope: McpScope,
79
- name: string,
80
- rawConfig: unknown,
81
- ): ProviderMcpServer | null {
82
- if (!rawConfig || typeof rawConfig !== 'object') {
83
- return null;
84
- }
85
-
86
- const config = rawConfig as Record<string, unknown>;
87
- if (typeof config.command === 'string') {
88
- return {
89
- provider: 'qwen',
90
- name,
91
- scope,
92
- transport: 'stdio',
93
- command: config.command,
94
- args: readStringArray(config.args),
95
- env: readStringRecord(config.env),
96
- cwd: readOptionalString(config.cwd),
97
- };
98
- }
99
-
100
- if (typeof config.url === 'string') {
101
- const transport = readOptionalString(config.type) === 'sse' ? 'sse' : 'http';
102
- return {
103
- provider: 'qwen',
104
- name,
105
- scope,
106
- transport,
107
- url: config.url,
108
- headers: readStringRecord(config.headers),
109
- };
110
- }
111
-
112
- return null;
113
- }
114
- }
1
+ import os from 'node:os';
2
+ import path from 'node:path';
3
+
4
+ import { McpProvider } from '@/modules/providers/shared/mcp/mcp.provider.js';
5
+ import type { McpScope, ProviderMcpServer, UpsertProviderMcpServerInput } from '@/shared/types.js';
6
+ import {
7
+ AppError,
8
+ readJsonConfig,
9
+ readObjectRecord,
10
+ readOptionalString,
11
+ readStringArray,
12
+ readStringRecord,
13
+ writeJsonConfig,
14
+ } from '@/shared/utils.js';
15
+
16
+ /**
17
+ * Qwen Code MCP provider. Qwen reads MCP servers out of the same
18
+ * `settings.json` shape Gemini uses, just under `~/.qwen/` instead of
19
+ * `~/.gemini/`. Supported transports and scopes match Gemini.
20
+ */
21
+ export class QwenMcpProvider extends McpProvider {
22
+ constructor() {
23
+ super('qwen', ['user', 'project'], ['stdio', 'http', 'sse']);
24
+ }
25
+
26
+ protected async readScopedServers(scope: McpScope, workspacePath: string): Promise<Record<string, unknown>> {
27
+ const filePath = scope === 'user'
28
+ ? path.join(os.homedir(), '.qwen', 'settings.json')
29
+ : path.join(workspacePath, '.qwen', 'settings.json');
30
+ const config = await readJsonConfig(filePath);
31
+ return readObjectRecord(config.mcpServers) ?? {};
32
+ }
33
+
34
+ protected async writeScopedServers(
35
+ scope: McpScope,
36
+ workspacePath: string,
37
+ servers: Record<string, unknown>,
38
+ ): Promise<void> {
39
+ const filePath = scope === 'user'
40
+ ? path.join(os.homedir(), '.qwen', 'settings.json')
41
+ : path.join(workspacePath, '.qwen', 'settings.json');
42
+ const config = await readJsonConfig(filePath);
43
+ config.mcpServers = servers;
44
+ await writeJsonConfig(filePath, config);
45
+ }
46
+
47
+ protected buildServerConfig(input: UpsertProviderMcpServerInput): Record<string, unknown> {
48
+ if (input.transport === 'stdio') {
49
+ if (!input.command?.trim()) {
50
+ throw new AppError('command is required for stdio MCP servers.', {
51
+ code: 'MCP_COMMAND_REQUIRED',
52
+ statusCode: 400,
53
+ });
54
+ }
55
+ return {
56
+ command: input.command,
57
+ args: input.args ?? [],
58
+ env: input.env ?? {},
59
+ cwd: input.cwd,
60
+ };
61
+ }
62
+
63
+ if (!input.url?.trim()) {
64
+ throw new AppError('url is required for http/sse MCP servers.', {
65
+ code: 'MCP_URL_REQUIRED',
66
+ statusCode: 400,
67
+ });
68
+ }
69
+
70
+ return {
71
+ type: input.transport,
72
+ url: input.url,
73
+ headers: input.headers ?? {},
74
+ };
75
+ }
76
+
77
+ protected normalizeServerConfig(
78
+ scope: McpScope,
79
+ name: string,
80
+ rawConfig: unknown,
81
+ ): ProviderMcpServer | null {
82
+ if (!rawConfig || typeof rawConfig !== 'object') {
83
+ return null;
84
+ }
85
+
86
+ const config = rawConfig as Record<string, unknown>;
87
+ if (typeof config.command === 'string') {
88
+ return {
89
+ provider: 'qwen',
90
+ name,
91
+ scope,
92
+ transport: 'stdio',
93
+ command: config.command,
94
+ args: readStringArray(config.args),
95
+ env: readStringRecord(config.env),
96
+ cwd: readOptionalString(config.cwd),
97
+ };
98
+ }
99
+
100
+ if (typeof config.url === 'string') {
101
+ const transport = readOptionalString(config.type) === 'sse' ? 'sse' : 'http';
102
+ return {
103
+ provider: 'qwen',
104
+ name,
105
+ scope,
106
+ transport,
107
+ url: config.url,
108
+ headers: readStringRecord(config.headers),
109
+ };
110
+ }
111
+
112
+ return null;
113
+ }
114
+ }