@pixelbyte-software/pixcode 1.33.11 → 1.35.0
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.
- package/dist/api-docs.html +162 -9
- package/dist/assets/index-B8w57E1r.css +32 -0
- package/dist/assets/index-Djuh0wHV.js +854 -0
- package/dist/favicon.svg +8 -8
- package/dist/icons/icon-128x128.svg +9 -9
- package/dist/icons/icon-144x144.svg +9 -9
- package/dist/icons/icon-152x152.svg +9 -9
- package/dist/icons/icon-192x192.svg +9 -9
- package/dist/icons/icon-384x384.svg +9 -9
- package/dist/icons/icon-512x512.svg +9 -9
- package/dist/icons/icon-72x72.svg +9 -9
- package/dist/icons/icon-96x96.svg +9 -9
- package/dist/icons/icon-template.svg +9 -9
- package/dist/index.html +2 -2
- package/dist/logo.svg +12 -12
- package/dist/openapi.yaml +383 -1
- package/dist-server/server/claude-sdk.js +38 -7
- package/dist-server/server/claude-sdk.js.map +1 -1
- package/dist-server/server/cli.js +12 -17
- package/dist-server/server/cli.js.map +1 -1
- package/dist-server/server/daemon-manager.js +98 -51
- package/dist-server/server/daemon-manager.js.map +1 -1
- package/dist-server/server/database/json-store.js +8 -5
- package/dist-server/server/database/json-store.js.map +1 -1
- package/dist-server/server/index.js +34 -9
- package/dist-server/server/index.js.map +1 -1
- package/dist-server/server/modules/orchestration/a2a/adapter-registry.js +73 -0
- package/dist-server/server/modules/orchestration/a2a/adapter-registry.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/abstract-a2a.adapter.js +17 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/abstract-a2a.adapter.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/claude-code.adapter.js +234 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/claude-code.adapter.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/codex.adapter.js +202 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/codex.adapter.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/cursor.adapter.js +205 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/cursor.adapter.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/gemini.adapter.js +205 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/gemini.adapter.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/opencode.adapter.js +205 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/opencode.adapter.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/qwen.adapter.js +205 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/qwen.adapter.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/agent-card.js +50 -0
- package/dist-server/server/modules/orchestration/a2a/agent-card.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/auth.middleware.js +25 -0
- package/dist-server/server/modules/orchestration/a2a/auth.middleware.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/bus.js +34 -0
- package/dist-server/server/modules/orchestration/a2a/bus.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/routes.js +497 -0
- package/dist-server/server/modules/orchestration/a2a/routes.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/task-store.js +144 -0
- package/dist-server/server/modules/orchestration/a2a/task-store.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/types.js +6 -0
- package/dist-server/server/modules/orchestration/a2a/types.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/validator.js +101 -0
- package/dist-server/server/modules/orchestration/a2a/validator.js.map +1 -0
- package/dist-server/server/modules/orchestration/index.js +24 -0
- package/dist-server/server/modules/orchestration/index.js.map +1 -0
- package/dist-server/server/modules/orchestration/preview/port-watcher.js +90 -0
- package/dist-server/server/modules/orchestration/preview/port-watcher.js.map +1 -0
- package/dist-server/server/modules/orchestration/preview/preview-proxy.js +58 -0
- package/dist-server/server/modules/orchestration/preview/preview-proxy.js.map +1 -0
- package/dist-server/server/modules/orchestration/preview/types.js +2 -0
- package/dist-server/server/modules/orchestration/preview/types.js.map +1 -0
- package/dist-server/server/modules/orchestration/tasks/orchestration-task-store.js +37 -0
- package/dist-server/server/modules/orchestration/tasks/orchestration-task-store.js.map +1 -0
- package/dist-server/server/modules/orchestration/tasks/orchestration-task.routes.js +68 -0
- package/dist-server/server/modules/orchestration/tasks/orchestration-task.routes.js.map +1 -0
- package/dist-server/server/modules/orchestration/tasks/orchestration-task.service.js +128 -0
- package/dist-server/server/modules/orchestration/tasks/orchestration-task.service.js.map +1 -0
- package/dist-server/server/modules/orchestration/tasks/orchestration-task.types.js +2 -0
- package/dist-server/server/modules/orchestration/tasks/orchestration-task.types.js.map +1 -0
- package/dist-server/server/modules/orchestration/workflows/built-in-workflows.js +126 -0
- package/dist-server/server/modules/orchestration/workflows/built-in-workflows.js.map +1 -0
- package/dist-server/server/modules/orchestration/workflows/workflow-runner.js +1047 -0
- package/dist-server/server/modules/orchestration/workflows/workflow-runner.js.map +1 -0
- package/dist-server/server/modules/orchestration/workflows/workflow-store.js +76 -0
- package/dist-server/server/modules/orchestration/workflows/workflow-store.js.map +1 -0
- package/dist-server/server/modules/orchestration/workflows/workflow.routes.js +151 -0
- package/dist-server/server/modules/orchestration/workflows/workflow.routes.js.map +1 -0
- package/dist-server/server/modules/orchestration/workflows/workflow.types.js +2 -0
- package/dist-server/server/modules/orchestration/workflows/workflow.types.js.map +1 -0
- package/dist-server/server/modules/orchestration/workflows/workspace-target.js +98 -0
- package/dist-server/server/modules/orchestration/workflows/workspace-target.js.map +1 -0
- package/dist-server/server/modules/orchestration/workspace/docker-workspace.js +122 -0
- package/dist-server/server/modules/orchestration/workspace/docker-workspace.js.map +1 -0
- package/dist-server/server/modules/orchestration/workspace/path-safety.js +48 -0
- package/dist-server/server/modules/orchestration/workspace/path-safety.js.map +1 -0
- package/dist-server/server/modules/orchestration/workspace/types.js +11 -0
- package/dist-server/server/modules/orchestration/workspace/types.js.map +1 -0
- package/dist-server/server/modules/orchestration/workspace/workspace-manager.js +80 -0
- package/dist-server/server/modules/orchestration/workspace/workspace-manager.js.map +1 -0
- package/dist-server/server/modules/orchestration/workspace/worktree-workspace.js +96 -0
- package/dist-server/server/modules/orchestration/workspace/worktree-workspace.js.map +1 -0
- package/dist-server/server/modules/providers/index.js +3 -0
- package/dist-server/server/modules/providers/index.js.map +1 -0
- package/dist-server/server/openai-codex.js +35 -4
- package/dist-server/server/openai-codex.js.map +1 -1
- package/dist-server/server/routes/taskmaster.js +106 -89
- package/dist-server/server/routes/taskmaster.js.map +1 -1
- package/package.json +3 -1
- package/scripts/smoke/a2a-roundtrip.mjs +167 -0
- package/scripts/smoke/orchestration-api.mjs +172 -0
- package/scripts/smoke/orchestration-live-run.mjs +176 -0
- package/server/claude-sdk.js +48 -7
- package/server/cli.js +12 -17
- package/server/daemon-manager.js +90 -51
- package/server/database/db.js +794 -794
- package/server/database/json-store.js +8 -5
- package/server/index.js +49 -9
- package/server/modules/orchestration/a2a/adapter-registry.ts +108 -0
- package/server/modules/orchestration/a2a/adapters/abstract-a2a.adapter.ts +55 -0
- package/server/modules/orchestration/a2a/adapters/claude-code.adapter.ts +284 -0
- package/server/modules/orchestration/a2a/adapters/codex.adapter.ts +244 -0
- package/server/modules/orchestration/a2a/adapters/cursor.adapter.ts +249 -0
- package/server/modules/orchestration/a2a/adapters/gemini.adapter.ts +248 -0
- package/server/modules/orchestration/a2a/adapters/opencode.adapter.ts +248 -0
- package/server/modules/orchestration/a2a/adapters/qwen.adapter.ts +248 -0
- package/server/modules/orchestration/a2a/agent-card.ts +55 -0
- package/server/modules/orchestration/a2a/auth.middleware.ts +29 -0
- package/server/modules/orchestration/a2a/bus.ts +46 -0
- package/server/modules/orchestration/a2a/routes.ts +577 -0
- package/server/modules/orchestration/a2a/task-store.ts +178 -0
- package/server/modules/orchestration/a2a/types.ts +125 -0
- package/server/modules/orchestration/a2a/validator.ts +113 -0
- package/server/modules/orchestration/index.ts +66 -0
- package/server/modules/orchestration/preview/port-watcher.ts +112 -0
- package/server/modules/orchestration/preview/preview-proxy.ts +60 -0
- package/server/modules/orchestration/preview/types.ts +19 -0
- package/server/modules/orchestration/tasks/orchestration-task-store.ts +45 -0
- package/server/modules/orchestration/tasks/orchestration-task.routes.ts +73 -0
- package/server/modules/orchestration/tasks/orchestration-task.service.ts +145 -0
- package/server/modules/orchestration/tasks/orchestration-task.types.ts +29 -0
- package/server/modules/orchestration/workflows/built-in-workflows.ts +127 -0
- package/server/modules/orchestration/workflows/workflow-runner.ts +1206 -0
- package/server/modules/orchestration/workflows/workflow-store.ts +97 -0
- package/server/modules/orchestration/workflows/workflow.routes.ts +169 -0
- package/server/modules/orchestration/workflows/workflow.types.ts +70 -0
- package/server/modules/orchestration/workflows/workspace-target.ts +120 -0
- package/server/modules/orchestration/workspace/docker-workspace.ts +135 -0
- package/server/modules/orchestration/workspace/path-safety.ts +55 -0
- package/server/modules/orchestration/workspace/types.ts +52 -0
- package/server/modules/orchestration/workspace/workspace-manager.ts +97 -0
- package/server/modules/orchestration/workspace/worktree-workspace.ts +125 -0
- package/server/modules/providers/index.ts +2 -0
- package/server/modules/providers/list/opencode/opencode-auth.provider.ts +130 -130
- package/server/modules/providers/list/opencode/opencode-mcp.provider.ts +126 -126
- package/server/modules/providers/list/opencode/opencode.provider.ts +29 -29
- package/server/modules/providers/list/qwen/qwen-auth.provider.ts +145 -145
- package/server/modules/providers/list/qwen/qwen-mcp.provider.ts +114 -114
- package/server/modules/providers/list/qwen/qwen.provider.ts +21 -21
- package/server/modules/providers/shared/provider-configs.ts +142 -142
- package/server/openai-codex.js +40 -4
- package/server/qwen-code-cli.js +395 -395
- package/server/qwen-response-handler.js +73 -73
- package/server/routes/qwen.js +27 -27
- package/server/routes/taskmaster.js +116 -91
- package/server/services/external-access.js +171 -171
- package/server/services/provider-models.js +381 -381
- package/server/services/telegram/telegram-http-client.js +130 -130
- package/server/services/vapid-keys.js +36 -36
- package/server/utils/port-access.js +209 -209
- package/dist/assets/index-B1ghfb4w.css +0 -32
- package/dist/assets/index-oLYHJ2X5.js +0 -852
|
@@ -1,126 +1,126 @@
|
|
|
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
|
-
* OpenCode MCP provider.
|
|
18
|
-
*
|
|
19
|
-
* OpenCode's MCP servers live under the top-level `mcp` key in
|
|
20
|
-
* `opencode.json` (global at `~/.config/opencode/opencode.json`, project at
|
|
21
|
-
* `<workspace>/opencode.json`). Each entry is either a local stdio command
|
|
22
|
-
* (`{ command, args, env }`) or a remote server (`{ type: "remote", url,
|
|
23
|
-
* headers, enabled }`). OpenCode's schema also supports an `enabled: false`
|
|
24
|
-
* flag we preserve on write but don't surface in the UI yet.
|
|
25
|
-
*/
|
|
26
|
-
export class OpencodeMcpProvider extends McpProvider {
|
|
27
|
-
constructor() {
|
|
28
|
-
super('opencode', ['user', 'project'], ['stdio', 'http', 'sse']);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
protected async readScopedServers(scope: McpScope, workspacePath: string): Promise<Record<string, unknown>> {
|
|
32
|
-
const filePath = scope === 'user'
|
|
33
|
-
? path.join(os.homedir(), '.config', 'opencode', 'opencode.json')
|
|
34
|
-
: path.join(workspacePath, 'opencode.json');
|
|
35
|
-
const config = await readJsonConfig(filePath);
|
|
36
|
-
return readObjectRecord(config.mcp) ?? {};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
protected async writeScopedServers(
|
|
40
|
-
scope: McpScope,
|
|
41
|
-
workspacePath: string,
|
|
42
|
-
servers: Record<string, unknown>,
|
|
43
|
-
): Promise<void> {
|
|
44
|
-
const filePath = scope === 'user'
|
|
45
|
-
? path.join(os.homedir(), '.config', 'opencode', 'opencode.json')
|
|
46
|
-
: path.join(workspacePath, 'opencode.json');
|
|
47
|
-
const config = await readJsonConfig(filePath);
|
|
48
|
-
config.mcp = servers;
|
|
49
|
-
await writeJsonConfig(filePath, config);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
protected buildServerConfig(input: UpsertProviderMcpServerInput): Record<string, unknown> {
|
|
53
|
-
if (input.transport === 'stdio') {
|
|
54
|
-
if (!input.command?.trim()) {
|
|
55
|
-
throw new AppError('command is required for stdio MCP servers.', {
|
|
56
|
-
code: 'MCP_COMMAND_REQUIRED',
|
|
57
|
-
statusCode: 400,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
type: 'local',
|
|
62
|
-
command: input.command,
|
|
63
|
-
args: input.args ?? [],
|
|
64
|
-
env: input.env ?? {},
|
|
65
|
-
cwd: input.cwd,
|
|
66
|
-
enabled: true,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (!input.url?.trim()) {
|
|
71
|
-
throw new AppError('url is required for http/sse MCP servers.', {
|
|
72
|
-
code: 'MCP_URL_REQUIRED',
|
|
73
|
-
statusCode: 400,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return {
|
|
78
|
-
type: 'remote',
|
|
79
|
-
url: input.url,
|
|
80
|
-
headers: input.headers ?? {},
|
|
81
|
-
enabled: true,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
protected normalizeServerConfig(
|
|
86
|
-
scope: McpScope,
|
|
87
|
-
name: string,
|
|
88
|
-
rawConfig: unknown,
|
|
89
|
-
): ProviderMcpServer | null {
|
|
90
|
-
if (!rawConfig || typeof rawConfig !== 'object') {
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const config = rawConfig as Record<string, unknown>;
|
|
95
|
-
const opencodeType = readOptionalString(config.type);
|
|
96
|
-
|
|
97
|
-
// Local (stdio) entries — either type: "local" explicitly or any entry
|
|
98
|
-
// with a command field (pre-type schemas).
|
|
99
|
-
if (opencodeType === 'local' || typeof config.command === 'string') {
|
|
100
|
-
return {
|
|
101
|
-
provider: 'opencode',
|
|
102
|
-
name,
|
|
103
|
-
scope,
|
|
104
|
-
transport: 'stdio',
|
|
105
|
-
command: typeof config.command === 'string' ? config.command : '',
|
|
106
|
-
args: readStringArray(config.args),
|
|
107
|
-
env: readStringRecord(config.env),
|
|
108
|
-
cwd: readOptionalString(config.cwd),
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// Remote entries — type: "remote" or any entry with a url field.
|
|
113
|
-
if (opencodeType === 'remote' || typeof config.url === 'string') {
|
|
114
|
-
return {
|
|
115
|
-
provider: 'opencode',
|
|
116
|
-
name,
|
|
117
|
-
scope,
|
|
118
|
-
transport: 'http',
|
|
119
|
-
url: typeof config.url === 'string' ? config.url : '',
|
|
120
|
-
headers: readStringRecord(config.headers),
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
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
|
+
* OpenCode MCP provider.
|
|
18
|
+
*
|
|
19
|
+
* OpenCode's MCP servers live under the top-level `mcp` key in
|
|
20
|
+
* `opencode.json` (global at `~/.config/opencode/opencode.json`, project at
|
|
21
|
+
* `<workspace>/opencode.json`). Each entry is either a local stdio command
|
|
22
|
+
* (`{ command, args, env }`) or a remote server (`{ type: "remote", url,
|
|
23
|
+
* headers, enabled }`). OpenCode's schema also supports an `enabled: false`
|
|
24
|
+
* flag we preserve on write but don't surface in the UI yet.
|
|
25
|
+
*/
|
|
26
|
+
export class OpencodeMcpProvider extends McpProvider {
|
|
27
|
+
constructor() {
|
|
28
|
+
super('opencode', ['user', 'project'], ['stdio', 'http', 'sse']);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
protected async readScopedServers(scope: McpScope, workspacePath: string): Promise<Record<string, unknown>> {
|
|
32
|
+
const filePath = scope === 'user'
|
|
33
|
+
? path.join(os.homedir(), '.config', 'opencode', 'opencode.json')
|
|
34
|
+
: path.join(workspacePath, 'opencode.json');
|
|
35
|
+
const config = await readJsonConfig(filePath);
|
|
36
|
+
return readObjectRecord(config.mcp) ?? {};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
protected async writeScopedServers(
|
|
40
|
+
scope: McpScope,
|
|
41
|
+
workspacePath: string,
|
|
42
|
+
servers: Record<string, unknown>,
|
|
43
|
+
): Promise<void> {
|
|
44
|
+
const filePath = scope === 'user'
|
|
45
|
+
? path.join(os.homedir(), '.config', 'opencode', 'opencode.json')
|
|
46
|
+
: path.join(workspacePath, 'opencode.json');
|
|
47
|
+
const config = await readJsonConfig(filePath);
|
|
48
|
+
config.mcp = servers;
|
|
49
|
+
await writeJsonConfig(filePath, config);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
protected buildServerConfig(input: UpsertProviderMcpServerInput): Record<string, unknown> {
|
|
53
|
+
if (input.transport === 'stdio') {
|
|
54
|
+
if (!input.command?.trim()) {
|
|
55
|
+
throw new AppError('command is required for stdio MCP servers.', {
|
|
56
|
+
code: 'MCP_COMMAND_REQUIRED',
|
|
57
|
+
statusCode: 400,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
type: 'local',
|
|
62
|
+
command: input.command,
|
|
63
|
+
args: input.args ?? [],
|
|
64
|
+
env: input.env ?? {},
|
|
65
|
+
cwd: input.cwd,
|
|
66
|
+
enabled: true,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (!input.url?.trim()) {
|
|
71
|
+
throw new AppError('url is required for http/sse MCP servers.', {
|
|
72
|
+
code: 'MCP_URL_REQUIRED',
|
|
73
|
+
statusCode: 400,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
type: 'remote',
|
|
79
|
+
url: input.url,
|
|
80
|
+
headers: input.headers ?? {},
|
|
81
|
+
enabled: true,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
protected normalizeServerConfig(
|
|
86
|
+
scope: McpScope,
|
|
87
|
+
name: string,
|
|
88
|
+
rawConfig: unknown,
|
|
89
|
+
): ProviderMcpServer | null {
|
|
90
|
+
if (!rawConfig || typeof rawConfig !== 'object') {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const config = rawConfig as Record<string, unknown>;
|
|
95
|
+
const opencodeType = readOptionalString(config.type);
|
|
96
|
+
|
|
97
|
+
// Local (stdio) entries — either type: "local" explicitly or any entry
|
|
98
|
+
// with a command field (pre-type schemas).
|
|
99
|
+
if (opencodeType === 'local' || typeof config.command === 'string') {
|
|
100
|
+
return {
|
|
101
|
+
provider: 'opencode',
|
|
102
|
+
name,
|
|
103
|
+
scope,
|
|
104
|
+
transport: 'stdio',
|
|
105
|
+
command: typeof config.command === 'string' ? config.command : '',
|
|
106
|
+
args: readStringArray(config.args),
|
|
107
|
+
env: readStringRecord(config.env),
|
|
108
|
+
cwd: readOptionalString(config.cwd),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Remote entries — type: "remote" or any entry with a url field.
|
|
113
|
+
if (opencodeType === 'remote' || typeof config.url === 'string') {
|
|
114
|
+
return {
|
|
115
|
+
provider: 'opencode',
|
|
116
|
+
name,
|
|
117
|
+
scope,
|
|
118
|
+
transport: 'http',
|
|
119
|
+
url: typeof config.url === 'string' ? config.url : '',
|
|
120
|
+
headers: readStringRecord(config.headers),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -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
|
+
}
|