@pixelbyte-software/pixcode 1.33.7 → 1.33.9

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 (34) hide show
  1. package/dist/assets/{index-BQizjYZ6.js → index-DpIcI9Q1.js} +138 -138
  2. package/dist/favicon.svg +8 -8
  3. package/dist/icons/icon-128x128.svg +9 -9
  4. package/dist/icons/icon-144x144.svg +9 -9
  5. package/dist/icons/icon-152x152.svg +9 -9
  6. package/dist/icons/icon-192x192.svg +9 -9
  7. package/dist/icons/icon-384x384.svg +9 -9
  8. package/dist/icons/icon-512x512.svg +9 -9
  9. package/dist/icons/icon-72x72.svg +9 -9
  10. package/dist/icons/icon-96x96.svg +9 -9
  11. package/dist/icons/icon-template.svg +9 -9
  12. package/dist/index.html +1 -1
  13. package/dist/logo.svg +12 -12
  14. package/package.json +1 -1
  15. package/server/database/db.js +794 -794
  16. package/server/database/json-store.js +194 -194
  17. package/server/modules/providers/list/opencode/opencode-auth.provider.ts +130 -130
  18. package/server/modules/providers/list/opencode/opencode-mcp.provider.ts +126 -126
  19. package/server/modules/providers/list/opencode/opencode-sessions.provider.ts +193 -193
  20. package/server/modules/providers/list/opencode/opencode.provider.ts +29 -29
  21. package/server/modules/providers/list/qwen/qwen-auth.provider.ts +145 -145
  22. package/server/modules/providers/list/qwen/qwen-mcp.provider.ts +114 -114
  23. package/server/modules/providers/list/qwen/qwen-sessions.provider.ts +218 -218
  24. package/server/modules/providers/list/qwen/qwen.provider.ts +21 -21
  25. package/server/modules/providers/shared/provider-configs.ts +142 -142
  26. package/server/qwen-code-cli.js +395 -395
  27. package/server/qwen-response-handler.js +73 -73
  28. package/server/routes/qwen.js +27 -27
  29. package/server/services/external-access.js +171 -171
  30. package/server/services/provider-credentials.js +155 -155
  31. package/server/services/provider-models.js +381 -381
  32. package/server/services/telegram/telegram-http-client.js +130 -130
  33. package/server/services/vapid-keys.js +36 -36
  34. package/server/utils/port-access.js +209 -209
@@ -1,218 +1,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
- if (raw.type === 'message' && raw.role === 'assistant') {
24
- const content = raw.content || '';
25
- const messages: NormalizedMessage[] = [];
26
- if (content) {
27
- messages.push(createNormalizedMessage({
28
- id: baseId,
29
- sessionId,
30
- timestamp: ts,
31
- provider: PROVIDER,
32
- kind: 'stream_delta',
33
- content,
34
- }));
35
- }
36
- if (raw.delta !== true) {
37
- messages.push(createNormalizedMessage({
38
- sessionId,
39
- timestamp: ts,
40
- provider: PROVIDER,
41
- kind: 'stream_end',
42
- }));
43
- }
44
- return messages;
45
- }
46
-
47
- if (raw.type === 'tool_use') {
48
- return [createNormalizedMessage({
49
- id: baseId,
50
- sessionId,
51
- timestamp: ts,
52
- provider: PROVIDER,
53
- kind: 'tool_use',
54
- toolName: raw.tool_name,
55
- toolInput: raw.parameters || {},
56
- toolId: raw.tool_id || baseId,
57
- })];
58
- }
59
-
60
- if (raw.type === 'tool_result') {
61
- return [createNormalizedMessage({
62
- id: baseId,
63
- sessionId,
64
- timestamp: ts,
65
- provider: PROVIDER,
66
- kind: 'tool_result',
67
- toolId: raw.tool_id || '',
68
- content: raw.output === undefined ? '' : String(raw.output),
69
- isError: raw.status === 'error',
70
- })];
71
- }
72
-
73
- if (raw.type === 'result') {
74
- const messages = [createNormalizedMessage({
75
- sessionId,
76
- timestamp: ts,
77
- provider: PROVIDER,
78
- kind: 'stream_end',
79
- })];
80
- if (raw.stats?.total_tokens) {
81
- messages.push(createNormalizedMessage({
82
- sessionId,
83
- timestamp: ts,
84
- provider: PROVIDER,
85
- kind: 'status',
86
- text: 'Complete',
87
- tokens: raw.stats.total_tokens,
88
- canInterrupt: false,
89
- }));
90
- }
91
- return messages;
92
- }
93
-
94
- if (raw.type === 'error') {
95
- return [createNormalizedMessage({
96
- id: baseId,
97
- sessionId,
98
- timestamp: ts,
99
- provider: PROVIDER,
100
- kind: 'error',
101
- content: raw.error || raw.message || 'Unknown Qwen Code streaming error',
102
- })];
103
- }
104
-
105
- return [];
106
- }
107
-
108
- async fetchHistory(
109
- sessionId: string,
110
- options: FetchHistoryOptions = {},
111
- ): Promise<FetchHistoryResult> {
112
- const { limit = null, offset = 0 } = options;
113
-
114
- let rawMessages: AnyRecord[];
115
- try {
116
- rawMessages = sessionManager.getSessionMessages(sessionId) as AnyRecord[];
117
- if (rawMessages.length === 0) {
118
- rawMessages = await getQwenCliSessionMessages(sessionId) as AnyRecord[];
119
- }
120
- } catch (error) {
121
- const message = error instanceof Error ? error.message : String(error);
122
- console.warn(`[QwenProvider] Failed to load session ${sessionId}:`, message);
123
- return { messages: [], total: 0, hasMore: false, offset: 0, limit: null };
124
- }
125
-
126
- const normalized: NormalizedMessage[] = [];
127
- for (let i = 0; i < rawMessages.length; i++) {
128
- const raw = rawMessages[i];
129
- const ts = raw.timestamp || new Date().toISOString();
130
- const baseId = raw.uuid || generateMessageId('qwen');
131
-
132
- const role = raw.message?.role || raw.role;
133
- const content = raw.message?.content || raw.content;
134
-
135
- if (!role || !content) continue;
136
-
137
- const normalizedRole = role === 'user' ? 'user' : 'assistant';
138
-
139
- if (Array.isArray(content)) {
140
- for (let partIdx = 0; partIdx < content.length; partIdx++) {
141
- const part = content[partIdx];
142
- if (part.type === 'text' && part.text) {
143
- normalized.push(createNormalizedMessage({
144
- id: `${baseId}_${partIdx}`,
145
- sessionId,
146
- timestamp: ts,
147
- provider: PROVIDER,
148
- kind: 'text',
149
- role: normalizedRole,
150
- content: part.text,
151
- }));
152
- } else if (part.type === 'tool_use') {
153
- normalized.push(createNormalizedMessage({
154
- id: `${baseId}_${partIdx}`,
155
- sessionId,
156
- timestamp: ts,
157
- provider: PROVIDER,
158
- kind: 'tool_use',
159
- toolName: part.name,
160
- toolInput: part.input,
161
- toolId: part.id || generateMessageId('qwen_tool'),
162
- }));
163
- } else if (part.type === 'tool_result') {
164
- normalized.push(createNormalizedMessage({
165
- id: `${baseId}_${partIdx}`,
166
- sessionId,
167
- timestamp: ts,
168
- provider: PROVIDER,
169
- kind: 'tool_result',
170
- toolId: part.tool_use_id || '',
171
- content: part.content === undefined ? '' : String(part.content),
172
- isError: Boolean(part.is_error),
173
- }));
174
- }
175
- }
176
- } else if (typeof content === 'string' && content.trim()) {
177
- normalized.push(createNormalizedMessage({
178
- id: baseId,
179
- sessionId,
180
- timestamp: ts,
181
- provider: PROVIDER,
182
- kind: 'text',
183
- role: normalizedRole,
184
- content,
185
- }));
186
- }
187
- }
188
-
189
- const toolResultMap = new Map<string, NormalizedMessage>();
190
- for (const msg of normalized) {
191
- if (msg.kind === 'tool_result' && msg.toolId) {
192
- toolResultMap.set(msg.toolId, msg);
193
- }
194
- }
195
- for (const msg of normalized) {
196
- if (msg.kind === 'tool_use' && msg.toolId && toolResultMap.has(msg.toolId)) {
197
- const toolResult = toolResultMap.get(msg.toolId);
198
- if (toolResult) {
199
- msg.toolResult = { content: toolResult.content, isError: toolResult.isError };
200
- }
201
- }
202
- }
203
-
204
- const start = Math.max(0, offset);
205
- const pageLimit = limit === null ? null : Math.max(0, limit);
206
- const messages = pageLimit === null
207
- ? normalized.slice(start)
208
- : normalized.slice(start, start + pageLimit);
209
-
210
- return {
211
- messages,
212
- total: normalized.length,
213
- hasMore: pageLimit === null ? false : start + pageLimit < normalized.length,
214
- offset: start,
215
- limit: pageLimit,
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
+ if (raw.type === 'message' && raw.role === 'assistant') {
24
+ const content = raw.content || '';
25
+ const messages: NormalizedMessage[] = [];
26
+ if (content) {
27
+ messages.push(createNormalizedMessage({
28
+ id: baseId,
29
+ sessionId,
30
+ timestamp: ts,
31
+ provider: PROVIDER,
32
+ kind: 'stream_delta',
33
+ content,
34
+ }));
35
+ }
36
+ if (raw.delta !== true) {
37
+ messages.push(createNormalizedMessage({
38
+ sessionId,
39
+ timestamp: ts,
40
+ provider: PROVIDER,
41
+ kind: 'stream_end',
42
+ }));
43
+ }
44
+ return messages;
45
+ }
46
+
47
+ if (raw.type === 'tool_use') {
48
+ return [createNormalizedMessage({
49
+ id: baseId,
50
+ sessionId,
51
+ timestamp: ts,
52
+ provider: PROVIDER,
53
+ kind: 'tool_use',
54
+ toolName: raw.tool_name,
55
+ toolInput: raw.parameters || {},
56
+ toolId: raw.tool_id || baseId,
57
+ })];
58
+ }
59
+
60
+ if (raw.type === 'tool_result') {
61
+ return [createNormalizedMessage({
62
+ id: baseId,
63
+ sessionId,
64
+ timestamp: ts,
65
+ provider: PROVIDER,
66
+ kind: 'tool_result',
67
+ toolId: raw.tool_id || '',
68
+ content: raw.output === undefined ? '' : String(raw.output),
69
+ isError: raw.status === 'error',
70
+ })];
71
+ }
72
+
73
+ if (raw.type === 'result') {
74
+ const messages = [createNormalizedMessage({
75
+ sessionId,
76
+ timestamp: ts,
77
+ provider: PROVIDER,
78
+ kind: 'stream_end',
79
+ })];
80
+ if (raw.stats?.total_tokens) {
81
+ messages.push(createNormalizedMessage({
82
+ sessionId,
83
+ timestamp: ts,
84
+ provider: PROVIDER,
85
+ kind: 'status',
86
+ text: 'Complete',
87
+ tokens: raw.stats.total_tokens,
88
+ canInterrupt: false,
89
+ }));
90
+ }
91
+ return messages;
92
+ }
93
+
94
+ if (raw.type === 'error') {
95
+ return [createNormalizedMessage({
96
+ id: baseId,
97
+ sessionId,
98
+ timestamp: ts,
99
+ provider: PROVIDER,
100
+ kind: 'error',
101
+ content: raw.error || raw.message || 'Unknown Qwen Code streaming error',
102
+ })];
103
+ }
104
+
105
+ return [];
106
+ }
107
+
108
+ async fetchHistory(
109
+ sessionId: string,
110
+ options: FetchHistoryOptions = {},
111
+ ): Promise<FetchHistoryResult> {
112
+ const { limit = null, offset = 0 } = options;
113
+
114
+ let rawMessages: AnyRecord[];
115
+ try {
116
+ rawMessages = sessionManager.getSessionMessages(sessionId) as AnyRecord[];
117
+ if (rawMessages.length === 0) {
118
+ rawMessages = await getQwenCliSessionMessages(sessionId) as AnyRecord[];
119
+ }
120
+ } catch (error) {
121
+ const message = error instanceof Error ? error.message : String(error);
122
+ console.warn(`[QwenProvider] Failed to load session ${sessionId}:`, message);
123
+ return { messages: [], total: 0, hasMore: false, offset: 0, limit: null };
124
+ }
125
+
126
+ const normalized: NormalizedMessage[] = [];
127
+ for (let i = 0; i < rawMessages.length; i++) {
128
+ const raw = rawMessages[i];
129
+ const ts = raw.timestamp || new Date().toISOString();
130
+ const baseId = raw.uuid || generateMessageId('qwen');
131
+
132
+ const role = raw.message?.role || raw.role;
133
+ const content = raw.message?.content || raw.content;
134
+
135
+ if (!role || !content) continue;
136
+
137
+ const normalizedRole = role === 'user' ? 'user' : 'assistant';
138
+
139
+ if (Array.isArray(content)) {
140
+ for (let partIdx = 0; partIdx < content.length; partIdx++) {
141
+ const part = content[partIdx];
142
+ if (part.type === 'text' && part.text) {
143
+ normalized.push(createNormalizedMessage({
144
+ id: `${baseId}_${partIdx}`,
145
+ sessionId,
146
+ timestamp: ts,
147
+ provider: PROVIDER,
148
+ kind: 'text',
149
+ role: normalizedRole,
150
+ content: part.text,
151
+ }));
152
+ } else if (part.type === 'tool_use') {
153
+ normalized.push(createNormalizedMessage({
154
+ id: `${baseId}_${partIdx}`,
155
+ sessionId,
156
+ timestamp: ts,
157
+ provider: PROVIDER,
158
+ kind: 'tool_use',
159
+ toolName: part.name,
160
+ toolInput: part.input,
161
+ toolId: part.id || generateMessageId('qwen_tool'),
162
+ }));
163
+ } else if (part.type === 'tool_result') {
164
+ normalized.push(createNormalizedMessage({
165
+ id: `${baseId}_${partIdx}`,
166
+ sessionId,
167
+ timestamp: ts,
168
+ provider: PROVIDER,
169
+ kind: 'tool_result',
170
+ toolId: part.tool_use_id || '',
171
+ content: part.content === undefined ? '' : String(part.content),
172
+ isError: Boolean(part.is_error),
173
+ }));
174
+ }
175
+ }
176
+ } else if (typeof content === 'string' && content.trim()) {
177
+ normalized.push(createNormalizedMessage({
178
+ id: baseId,
179
+ sessionId,
180
+ timestamp: ts,
181
+ provider: PROVIDER,
182
+ kind: 'text',
183
+ role: normalizedRole,
184
+ content,
185
+ }));
186
+ }
187
+ }
188
+
189
+ const toolResultMap = new Map<string, NormalizedMessage>();
190
+ for (const msg of normalized) {
191
+ if (msg.kind === 'tool_result' && msg.toolId) {
192
+ toolResultMap.set(msg.toolId, msg);
193
+ }
194
+ }
195
+ for (const msg of normalized) {
196
+ if (msg.kind === 'tool_use' && msg.toolId && toolResultMap.has(msg.toolId)) {
197
+ const toolResult = toolResultMap.get(msg.toolId);
198
+ if (toolResult) {
199
+ msg.toolResult = { content: toolResult.content, isError: toolResult.isError };
200
+ }
201
+ }
202
+ }
203
+
204
+ const start = Math.max(0, offset);
205
+ const pageLimit = limit === null ? null : Math.max(0, limit);
206
+ const messages = pageLimit === null
207
+ ? normalized.slice(start)
208
+ : normalized.slice(start, start + pageLimit);
209
+
210
+ return {
211
+ messages,
212
+ total: normalized.length,
213
+ hasMore: pageLimit === null ? false : start + pageLimit < normalized.length,
214
+ offset: start,
215
+ limit: pageLimit,
216
+ };
217
+ }
218
+ }
@@ -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
+ }