@pixelbyte-software/pixcode 1.33.9 → 1.33.10
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 +395 -879
- package/dist/assets/{index-DpIcI9Q1.js → index-B_dU5AHA.js} +153 -165
- 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 +1 -1
- package/dist/logo.svg +12 -12
- package/dist/openapi.yaml +1311 -0
- package/dist-server/server/gemini-cli.js +59 -0
- package/dist-server/server/gemini-cli.js.map +1 -1
- package/dist-server/server/index.js +6 -1
- package/dist-server/server/index.js.map +1 -1
- package/dist-server/server/middleware/auth.js +51 -9
- package/dist-server/server/middleware/auth.js.map +1 -1
- package/dist-server/server/modules/providers/list/opencode/opencode-sessions.provider.js +54 -15
- package/dist-server/server/modules/providers/list/opencode/opencode-sessions.provider.js.map +1 -1
- package/dist-server/server/modules/providers/list/qwen/qwen-sessions.provider.js +46 -0
- package/dist-server/server/modules/providers/list/qwen/qwen-sessions.provider.js.map +1 -1
- package/dist-server/server/modules/providers/provider.routes.js +32 -1
- package/dist-server/server/modules/providers/provider.routes.js.map +1 -1
- package/dist-server/server/opencode-cli.js +37 -1
- package/dist-server/server/opencode-cli.js.map +1 -1
- package/dist-server/server/opencode-response-handler.js +36 -34
- package/dist-server/server/opencode-response-handler.js.map +1 -1
- package/dist-server/server/routes/agent.js +187 -56
- package/dist-server/server/routes/agent.js.map +1 -1
- package/dist-server/server/routes/projects.js +134 -8
- package/dist-server/server/routes/projects.js.map +1 -1
- package/dist-server/server/services/provider-credentials.js +42 -8
- package/dist-server/server/services/provider-credentials.js.map +1 -1
- package/package.json +178 -178
- package/scripts/rest-sweep.mjs +93 -0
- package/server/database/db.js +794 -794
- package/server/database/json-store.js +194 -194
- package/server/gemini-cli.js +60 -0
- package/server/index.js +6 -1
- package/server/middleware/auth.js +50 -9
- 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-sessions.provider.ts +232 -193
- 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-sessions.provider.ts +265 -218
- package/server/modules/providers/list/qwen/qwen.provider.ts +21 -21
- package/server/modules/providers/provider.routes.ts +37 -4
- package/server/modules/providers/shared/provider-configs.ts +142 -142
- package/server/opencode-cli.js +37 -1
- package/server/opencode-response-handler.js +107 -100
- package/server/qwen-code-cli.js +395 -395
- package/server/qwen-response-handler.js +73 -73
- package/server/routes/agent.js +178 -58
- package/server/routes/projects.js +136 -8
- package/server/routes/qwen.js +27 -27
- package/server/services/external-access.js +171 -171
- package/server/services/provider-credentials.js +189 -155
- 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
|
@@ -1,218 +1,265 @@
|
|
|
1
|
-
import sessionManager from '@/sessionManager.js';
|
|
2
|
-
import { getQwenCliSessionMessages } from '@/projects.js';
|
|
3
|
-
import type { IProviderSessions } from '@/shared/interfaces.js';
|
|
4
|
-
import type { AnyRecord, FetchHistoryOptions, FetchHistoryResult, NormalizedMessage } from '@/shared/types.js';
|
|
5
|
-
import { createNormalizedMessage, generateMessageId, readObjectRecord } from '@/shared/utils.js';
|
|
6
|
-
|
|
7
|
-
const PROVIDER = 'qwen';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Qwen Code sessions — structurally identical to Gemini since Qwen is a fork.
|
|
11
|
-
* Stream events have the same `type` taxonomy (message / tool_use /
|
|
12
|
-
* tool_result / result / error), and on-disk history files carry the same
|
|
13
|
-
* `role + content` message shape with optional part arrays.
|
|
14
|
-
*/
|
|
15
|
-
export class QwenSessionsProvider implements IProviderSessions {
|
|
16
|
-
normalizeMessage(rawMessage: unknown, sessionId: string | null): NormalizedMessage[] {
|
|
17
|
-
const raw = readObjectRecord(rawMessage);
|
|
18
|
-
if (!raw) return [];
|
|
19
|
-
|
|
20
|
-
const ts = raw.timestamp || new Date().toISOString();
|
|
21
|
-
const baseId = raw.uuid || generateMessageId('qwen');
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}));
|
|
90
|
-
}
|
|
91
|
-
return messages;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (raw.type === '
|
|
95
|
-
return [createNormalizedMessage({
|
|
96
|
-
id: baseId,
|
|
97
|
-
sessionId,
|
|
98
|
-
timestamp: ts,
|
|
99
|
-
provider: PROVIDER,
|
|
100
|
-
kind: '
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
1
|
+
import sessionManager from '@/sessionManager.js';
|
|
2
|
+
import { getQwenCliSessionMessages } from '@/projects.js';
|
|
3
|
+
import type { IProviderSessions } from '@/shared/interfaces.js';
|
|
4
|
+
import type { AnyRecord, FetchHistoryOptions, FetchHistoryResult, NormalizedMessage } from '@/shared/types.js';
|
|
5
|
+
import { createNormalizedMessage, generateMessageId, readObjectRecord } from '@/shared/utils.js';
|
|
6
|
+
|
|
7
|
+
const PROVIDER = 'qwen';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Qwen Code sessions — structurally identical to Gemini since Qwen is a fork.
|
|
11
|
+
* Stream events have the same `type` taxonomy (message / tool_use /
|
|
12
|
+
* tool_result / result / error), and on-disk history files carry the same
|
|
13
|
+
* `role + content` message shape with optional part arrays.
|
|
14
|
+
*/
|
|
15
|
+
export class QwenSessionsProvider implements IProviderSessions {
|
|
16
|
+
normalizeMessage(rawMessage: unknown, sessionId: string | null): NormalizedMessage[] {
|
|
17
|
+
const raw = readObjectRecord(rawMessage);
|
|
18
|
+
if (!raw) return [];
|
|
19
|
+
|
|
20
|
+
const ts = raw.timestamp || new Date().toISOString();
|
|
21
|
+
const baseId = raw.uuid || generateMessageId('qwen');
|
|
22
|
+
|
|
23
|
+
// Qwen Code stream-json (verified from `qwen --output-format stream-json --yolo`):
|
|
24
|
+
// { type:"system", subtype:"init", session_id, ... }
|
|
25
|
+
// { type:"assistant", uuid, session_id, message:{ role:"assistant", content:[{type:"text", text:"…"}], usage:{...} } }
|
|
26
|
+
// { type:"result", subtype:"success", result:"…final…", usage:{...} }
|
|
27
|
+
// The previous matcher (`type==='message' && role==='assistant'`) checked
|
|
28
|
+
// a shape Qwen has never emitted — every chat returned empty messages,
|
|
29
|
+
// including API-error messages like "[API Error: 401 invalid access token
|
|
30
|
+
// or token expired]" which then landed in the void instead of reaching
|
|
31
|
+
// the user. Match the real shape.
|
|
32
|
+
if (raw.type === 'assistant' && raw.message && typeof raw.message === 'object') {
|
|
33
|
+
const msg = raw.message as Record<string, unknown>;
|
|
34
|
+
const parts = Array.isArray(msg.content) ? (msg.content as Record<string, unknown>[]) : [];
|
|
35
|
+
const text = parts
|
|
36
|
+
.map((p) => (typeof p?.text === 'string' ? p.text : ''))
|
|
37
|
+
.filter(Boolean)
|
|
38
|
+
.join('');
|
|
39
|
+
const messages: NormalizedMessage[] = [];
|
|
40
|
+
if (text) {
|
|
41
|
+
messages.push(createNormalizedMessage({
|
|
42
|
+
id: baseId,
|
|
43
|
+
sessionId,
|
|
44
|
+
timestamp: ts,
|
|
45
|
+
provider: PROVIDER,
|
|
46
|
+
kind: 'stream_delta',
|
|
47
|
+
content: text,
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
// Surface tool_use parts inline so the agent route can see them too.
|
|
51
|
+
for (const part of parts) {
|
|
52
|
+
if (part?.type === 'tool_use') {
|
|
53
|
+
messages.push(createNormalizedMessage({
|
|
54
|
+
id: typeof part.id === 'string' ? part.id : generateMessageId('qwen'),
|
|
55
|
+
sessionId,
|
|
56
|
+
timestamp: ts,
|
|
57
|
+
provider: PROVIDER,
|
|
58
|
+
kind: 'tool_use',
|
|
59
|
+
toolName: typeof part.name === 'string' ? part.name : '',
|
|
60
|
+
toolInput: (part.input as AnyRecord) || {},
|
|
61
|
+
toolId: typeof part.id === 'string' ? part.id : '',
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return messages;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Legacy `type:"message"` shape — kept so any persisted history that
|
|
69
|
+
// pre-dates the stream-json migration still parses cleanly.
|
|
70
|
+
if (raw.type === 'message' && raw.role === 'assistant') {
|
|
71
|
+
const content = raw.content || '';
|
|
72
|
+
const messages: NormalizedMessage[] = [];
|
|
73
|
+
if (content) {
|
|
74
|
+
messages.push(createNormalizedMessage({
|
|
75
|
+
id: baseId,
|
|
76
|
+
sessionId,
|
|
77
|
+
timestamp: ts,
|
|
78
|
+
provider: PROVIDER,
|
|
79
|
+
kind: 'stream_delta',
|
|
80
|
+
content,
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
if (raw.delta !== true) {
|
|
84
|
+
messages.push(createNormalizedMessage({
|
|
85
|
+
sessionId,
|
|
86
|
+
timestamp: ts,
|
|
87
|
+
provider: PROVIDER,
|
|
88
|
+
kind: 'stream_end',
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
return messages;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (raw.type === 'tool_use') {
|
|
95
|
+
return [createNormalizedMessage({
|
|
96
|
+
id: baseId,
|
|
97
|
+
sessionId,
|
|
98
|
+
timestamp: ts,
|
|
99
|
+
provider: PROVIDER,
|
|
100
|
+
kind: 'tool_use',
|
|
101
|
+
toolName: raw.tool_name,
|
|
102
|
+
toolInput: raw.parameters || {},
|
|
103
|
+
toolId: raw.tool_id || baseId,
|
|
104
|
+
})];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (raw.type === 'tool_result') {
|
|
108
|
+
return [createNormalizedMessage({
|
|
109
|
+
id: baseId,
|
|
110
|
+
sessionId,
|
|
111
|
+
timestamp: ts,
|
|
112
|
+
provider: PROVIDER,
|
|
113
|
+
kind: 'tool_result',
|
|
114
|
+
toolId: raw.tool_id || '',
|
|
115
|
+
content: raw.output === undefined ? '' : String(raw.output),
|
|
116
|
+
isError: raw.status === 'error',
|
|
117
|
+
})];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (raw.type === 'result') {
|
|
121
|
+
const messages = [createNormalizedMessage({
|
|
122
|
+
sessionId,
|
|
123
|
+
timestamp: ts,
|
|
124
|
+
provider: PROVIDER,
|
|
125
|
+
kind: 'stream_end',
|
|
126
|
+
})];
|
|
127
|
+
if (raw.stats?.total_tokens) {
|
|
128
|
+
messages.push(createNormalizedMessage({
|
|
129
|
+
sessionId,
|
|
130
|
+
timestamp: ts,
|
|
131
|
+
provider: PROVIDER,
|
|
132
|
+
kind: 'status',
|
|
133
|
+
text: 'Complete',
|
|
134
|
+
tokens: raw.stats.total_tokens,
|
|
135
|
+
canInterrupt: false,
|
|
136
|
+
}));
|
|
137
|
+
}
|
|
138
|
+
return messages;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (raw.type === 'error') {
|
|
142
|
+
return [createNormalizedMessage({
|
|
143
|
+
id: baseId,
|
|
144
|
+
sessionId,
|
|
145
|
+
timestamp: ts,
|
|
146
|
+
provider: PROVIDER,
|
|
147
|
+
kind: 'error',
|
|
148
|
+
content: raw.error || raw.message || 'Unknown Qwen Code streaming error',
|
|
149
|
+
})];
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return [];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
async fetchHistory(
|
|
156
|
+
sessionId: string,
|
|
157
|
+
options: FetchHistoryOptions = {},
|
|
158
|
+
): Promise<FetchHistoryResult> {
|
|
159
|
+
const { limit = null, offset = 0 } = options;
|
|
160
|
+
|
|
161
|
+
let rawMessages: AnyRecord[];
|
|
162
|
+
try {
|
|
163
|
+
rawMessages = sessionManager.getSessionMessages(sessionId) as AnyRecord[];
|
|
164
|
+
if (rawMessages.length === 0) {
|
|
165
|
+
rawMessages = await getQwenCliSessionMessages(sessionId) as AnyRecord[];
|
|
166
|
+
}
|
|
167
|
+
} catch (error) {
|
|
168
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
169
|
+
console.warn(`[QwenProvider] Failed to load session ${sessionId}:`, message);
|
|
170
|
+
return { messages: [], total: 0, hasMore: false, offset: 0, limit: null };
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const normalized: NormalizedMessage[] = [];
|
|
174
|
+
for (let i = 0; i < rawMessages.length; i++) {
|
|
175
|
+
const raw = rawMessages[i];
|
|
176
|
+
const ts = raw.timestamp || new Date().toISOString();
|
|
177
|
+
const baseId = raw.uuid || generateMessageId('qwen');
|
|
178
|
+
|
|
179
|
+
const role = raw.message?.role || raw.role;
|
|
180
|
+
const content = raw.message?.content || raw.content;
|
|
181
|
+
|
|
182
|
+
if (!role || !content) continue;
|
|
183
|
+
|
|
184
|
+
const normalizedRole = role === 'user' ? 'user' : 'assistant';
|
|
185
|
+
|
|
186
|
+
if (Array.isArray(content)) {
|
|
187
|
+
for (let partIdx = 0; partIdx < content.length; partIdx++) {
|
|
188
|
+
const part = content[partIdx];
|
|
189
|
+
if (part.type === 'text' && part.text) {
|
|
190
|
+
normalized.push(createNormalizedMessage({
|
|
191
|
+
id: `${baseId}_${partIdx}`,
|
|
192
|
+
sessionId,
|
|
193
|
+
timestamp: ts,
|
|
194
|
+
provider: PROVIDER,
|
|
195
|
+
kind: 'text',
|
|
196
|
+
role: normalizedRole,
|
|
197
|
+
content: part.text,
|
|
198
|
+
}));
|
|
199
|
+
} else if (part.type === 'tool_use') {
|
|
200
|
+
normalized.push(createNormalizedMessage({
|
|
201
|
+
id: `${baseId}_${partIdx}`,
|
|
202
|
+
sessionId,
|
|
203
|
+
timestamp: ts,
|
|
204
|
+
provider: PROVIDER,
|
|
205
|
+
kind: 'tool_use',
|
|
206
|
+
toolName: part.name,
|
|
207
|
+
toolInput: part.input,
|
|
208
|
+
toolId: part.id || generateMessageId('qwen_tool'),
|
|
209
|
+
}));
|
|
210
|
+
} else if (part.type === 'tool_result') {
|
|
211
|
+
normalized.push(createNormalizedMessage({
|
|
212
|
+
id: `${baseId}_${partIdx}`,
|
|
213
|
+
sessionId,
|
|
214
|
+
timestamp: ts,
|
|
215
|
+
provider: PROVIDER,
|
|
216
|
+
kind: 'tool_result',
|
|
217
|
+
toolId: part.tool_use_id || '',
|
|
218
|
+
content: part.content === undefined ? '' : String(part.content),
|
|
219
|
+
isError: Boolean(part.is_error),
|
|
220
|
+
}));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
} else if (typeof content === 'string' && content.trim()) {
|
|
224
|
+
normalized.push(createNormalizedMessage({
|
|
225
|
+
id: baseId,
|
|
226
|
+
sessionId,
|
|
227
|
+
timestamp: ts,
|
|
228
|
+
provider: PROVIDER,
|
|
229
|
+
kind: 'text',
|
|
230
|
+
role: normalizedRole,
|
|
231
|
+
content,
|
|
232
|
+
}));
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const toolResultMap = new Map<string, NormalizedMessage>();
|
|
237
|
+
for (const msg of normalized) {
|
|
238
|
+
if (msg.kind === 'tool_result' && msg.toolId) {
|
|
239
|
+
toolResultMap.set(msg.toolId, msg);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
for (const msg of normalized) {
|
|
243
|
+
if (msg.kind === 'tool_use' && msg.toolId && toolResultMap.has(msg.toolId)) {
|
|
244
|
+
const toolResult = toolResultMap.get(msg.toolId);
|
|
245
|
+
if (toolResult) {
|
|
246
|
+
msg.toolResult = { content: toolResult.content, isError: toolResult.isError };
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const start = Math.max(0, offset);
|
|
252
|
+
const pageLimit = limit === null ? null : Math.max(0, limit);
|
|
253
|
+
const messages = pageLimit === null
|
|
254
|
+
? normalized.slice(start)
|
|
255
|
+
: normalized.slice(start, start + pageLimit);
|
|
256
|
+
|
|
257
|
+
return {
|
|
258
|
+
messages,
|
|
259
|
+
total: normalized.length,
|
|
260
|
+
hasMore: pageLimit === null ? false : start + pageLimit < normalized.length,
|
|
261
|
+
offset: start,
|
|
262
|
+
limit: pageLimit,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { AbstractProvider } from '@/modules/providers/shared/base/abstract.provider.js';
|
|
2
|
-
import { QwenProviderAuth } from '@/modules/providers/list/qwen/qwen-auth.provider.js';
|
|
3
|
-
import { QwenMcpProvider } from '@/modules/providers/list/qwen/qwen-mcp.provider.js';
|
|
4
|
-
import { QwenSessionsProvider } from '@/modules/providers/list/qwen/qwen-sessions.provider.js';
|
|
5
|
-
import type { IProviderAuth, IProviderSessions } from '@/shared/interfaces.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Qwen Code provider (Alibaba's Gemini CLI fork). The three sub-providers
|
|
9
|
-
* mirror the Gemini layout — Qwen shares the on-disk layout, config format,
|
|
10
|
-
* and stream-json protocol, so the auth/mcp/sessions modules are intentional
|
|
11
|
-
* structural twins.
|
|
12
|
-
*/
|
|
13
|
-
export class QwenProvider extends AbstractProvider {
|
|
14
|
-
readonly mcp = new QwenMcpProvider();
|
|
15
|
-
readonly auth: IProviderAuth = new QwenProviderAuth();
|
|
16
|
-
readonly sessions: IProviderSessions = new QwenSessionsProvider();
|
|
17
|
-
|
|
18
|
-
constructor() {
|
|
19
|
-
super('qwen');
|
|
20
|
-
}
|
|
21
|
-
}
|
|
1
|
+
import { AbstractProvider } from '@/modules/providers/shared/base/abstract.provider.js';
|
|
2
|
+
import { QwenProviderAuth } from '@/modules/providers/list/qwen/qwen-auth.provider.js';
|
|
3
|
+
import { QwenMcpProvider } from '@/modules/providers/list/qwen/qwen-mcp.provider.js';
|
|
4
|
+
import { QwenSessionsProvider } from '@/modules/providers/list/qwen/qwen-sessions.provider.js';
|
|
5
|
+
import type { IProviderAuth, IProviderSessions } from '@/shared/interfaces.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Qwen Code provider (Alibaba's Gemini CLI fork). The three sub-providers
|
|
9
|
+
* mirror the Gemini layout — Qwen shares the on-disk layout, config format,
|
|
10
|
+
* and stream-json protocol, so the auth/mcp/sessions modules are intentional
|
|
11
|
+
* structural twins.
|
|
12
|
+
*/
|
|
13
|
+
export class QwenProvider extends AbstractProvider {
|
|
14
|
+
readonly mcp = new QwenMcpProvider();
|
|
15
|
+
readonly auth: IProviderAuth = new QwenProviderAuth();
|
|
16
|
+
readonly sessions: IProviderSessions = new QwenSessionsProvider();
|
|
17
|
+
|
|
18
|
+
constructor() {
|
|
19
|
+
super('qwen');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -85,6 +85,31 @@ const PROVIDER_INSTALL_COMMANDS: Record<LLMProvider, string | null> = {
|
|
|
85
85
|
cursor: null,
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Per-provider manual install hints, surfaced when `/install` is called
|
|
90
|
+
* for a provider Pixcode can't sandbox-install (anything not on npm).
|
|
91
|
+
* Each entry includes platform-specific commands so the UI can show the
|
|
92
|
+
* right one for the user's host. Cursor is the only provider in this
|
|
93
|
+
* bucket today — it ships via curl|bash on POSIX and a downloadable
|
|
94
|
+
* installer on Windows. We deliberately don't pipe-to-bash from Pixcode,
|
|
95
|
+
* so the user runs it themselves.
|
|
96
|
+
*/
|
|
97
|
+
const PROVIDER_MANUAL_INSTALL: Partial<Record<LLMProvider, {
|
|
98
|
+
docsUrl: string;
|
|
99
|
+
steps: { platform: 'macos' | 'linux' | 'windows'; command: string }[];
|
|
100
|
+
note: string;
|
|
101
|
+
}>> = {
|
|
102
|
+
cursor: {
|
|
103
|
+
docsUrl: 'https://docs.cursor.com/en/cli/installation',
|
|
104
|
+
steps: [
|
|
105
|
+
{ platform: 'macos', command: 'curl https://cursor.com/install -fsS | bash' },
|
|
106
|
+
{ platform: 'linux', command: 'curl https://cursor.com/install -fsS | bash' },
|
|
107
|
+
{ platform: 'windows', command: 'iwr https://cursor.com/install.ps1 -useb | iex' },
|
|
108
|
+
],
|
|
109
|
+
note: 'Cursor ships outside npm — run the command for your platform in a separate terminal, then click "Refresh" on this page once the binary is on PATH.',
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
|
|
88
113
|
const router = express.Router();
|
|
89
114
|
|
|
90
115
|
const readPathParam = (value: unknown, name: string): string => {
|
|
@@ -450,10 +475,18 @@ router.post(
|
|
|
450
475
|
const packageName = PROVIDER_INSTALL_PACKAGES[parsed];
|
|
451
476
|
const installCmd = PROVIDER_INSTALL_COMMANDS[parsed];
|
|
452
477
|
if (!packageName || !installCmd) {
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
478
|
+
const manual = PROVIDER_MANUAL_INSTALL[parsed];
|
|
479
|
+
// Don't 4xx on this — the call ISN'T malformed, the provider is
|
|
480
|
+
// simply not npm-installable. Return 200 with a `manual` payload
|
|
481
|
+
// the UI can present as instructions instead of "install failed".
|
|
482
|
+
res.json(createApiSuccessResponse({
|
|
483
|
+
provider: parsed,
|
|
484
|
+
manual: manual || null,
|
|
485
|
+
message: manual
|
|
486
|
+
? `${parsed} ships outside npm. Run the platform-specific command, then refresh.`
|
|
487
|
+
: `${parsed} cannot be installed automatically — see the provider's documentation.`,
|
|
488
|
+
}));
|
|
489
|
+
return;
|
|
457
490
|
}
|
|
458
491
|
|
|
459
492
|
const job = createInstallJob({ provider: parsed, installCmd, packageName });
|