@pixelbyte-software/pixcode 1.33.7 → 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 (34) hide show
  1. package/dist/assets/{index-BQizjYZ6.js → index-JU38YIxa.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,73 +1,73 @@
1
- // Qwen Code Response Handler — stream-json parser.
2
- // Qwen Code is a fork of Gemini CLI and emits the same NDJSON stream-json
3
- // event shape (type: init | message | tool_use | tool_result | result | error).
4
- // This handler is intentionally a structural twin of gemini-response-handler;
5
- // the split keeps provider normalization clean and lets the two evolve
6
- // independently if Qwen's protocol ever diverges.
7
- import { sessionsService } from './modules/providers/services/sessions.service.js';
8
-
9
- class QwenResponseHandler {
10
- constructor(ws, options = {}) {
11
- this.ws = ws;
12
- this.buffer = '';
13
- this.onContentFragment = options.onContentFragment || null;
14
- this.onInit = options.onInit || null;
15
- this.onToolUse = options.onToolUse || null;
16
- this.onToolResult = options.onToolResult || null;
17
- }
18
-
19
- processData(data) {
20
- this.buffer += data;
21
-
22
- const lines = this.buffer.split('\n');
23
- this.buffer = lines.pop() || '';
24
-
25
- for (const line of lines) {
26
- if (!line.trim()) continue;
27
- try {
28
- const event = JSON.parse(line);
29
- this.handleEvent(event);
30
- } catch {
31
- // Not a JSON line — debug output or CLI warning, ignore.
32
- }
33
- }
34
- }
35
-
36
- handleEvent(event) {
37
- const sid = typeof this.ws.getSessionId === 'function' ? this.ws.getSessionId() : null;
38
-
39
- if (event.type === 'init') {
40
- if (this.onInit) this.onInit(event);
41
- return;
42
- }
43
-
44
- if (event.type === 'message' && event.role === 'assistant') {
45
- const content = event.content || '';
46
- if (this.onContentFragment && content) this.onContentFragment(content);
47
- } else if (event.type === 'tool_use' && this.onToolUse) {
48
- this.onToolUse(event);
49
- } else if (event.type === 'tool_result' && this.onToolResult) {
50
- this.onToolResult(event);
51
- }
52
-
53
- const normalized = sessionsService.normalizeMessage('qwen', event, sid);
54
- for (const msg of normalized) {
55
- this.ws.send(msg);
56
- }
57
- }
58
-
59
- forceFlush() {
60
- if (this.buffer.trim()) {
61
- try {
62
- const event = JSON.parse(this.buffer);
63
- this.handleEvent(event);
64
- } catch { /* ignore */ }
65
- }
66
- }
67
-
68
- destroy() {
69
- this.buffer = '';
70
- }
71
- }
72
-
73
- export default QwenResponseHandler;
1
+ // Qwen Code Response Handler — stream-json parser.
2
+ // Qwen Code is a fork of Gemini CLI and emits the same NDJSON stream-json
3
+ // event shape (type: init | message | tool_use | tool_result | result | error).
4
+ // This handler is intentionally a structural twin of gemini-response-handler;
5
+ // the split keeps provider normalization clean and lets the two evolve
6
+ // independently if Qwen's protocol ever diverges.
7
+ import { sessionsService } from './modules/providers/services/sessions.service.js';
8
+
9
+ class QwenResponseHandler {
10
+ constructor(ws, options = {}) {
11
+ this.ws = ws;
12
+ this.buffer = '';
13
+ this.onContentFragment = options.onContentFragment || null;
14
+ this.onInit = options.onInit || null;
15
+ this.onToolUse = options.onToolUse || null;
16
+ this.onToolResult = options.onToolResult || null;
17
+ }
18
+
19
+ processData(data) {
20
+ this.buffer += data;
21
+
22
+ const lines = this.buffer.split('\n');
23
+ this.buffer = lines.pop() || '';
24
+
25
+ for (const line of lines) {
26
+ if (!line.trim()) continue;
27
+ try {
28
+ const event = JSON.parse(line);
29
+ this.handleEvent(event);
30
+ } catch {
31
+ // Not a JSON line — debug output or CLI warning, ignore.
32
+ }
33
+ }
34
+ }
35
+
36
+ handleEvent(event) {
37
+ const sid = typeof this.ws.getSessionId === 'function' ? this.ws.getSessionId() : null;
38
+
39
+ if (event.type === 'init') {
40
+ if (this.onInit) this.onInit(event);
41
+ return;
42
+ }
43
+
44
+ if (event.type === 'message' && event.role === 'assistant') {
45
+ const content = event.content || '';
46
+ if (this.onContentFragment && content) this.onContentFragment(content);
47
+ } else if (event.type === 'tool_use' && this.onToolUse) {
48
+ this.onToolUse(event);
49
+ } else if (event.type === 'tool_result' && this.onToolResult) {
50
+ this.onToolResult(event);
51
+ }
52
+
53
+ const normalized = sessionsService.normalizeMessage('qwen', event, sid);
54
+ for (const msg of normalized) {
55
+ this.ws.send(msg);
56
+ }
57
+ }
58
+
59
+ forceFlush() {
60
+ if (this.buffer.trim()) {
61
+ try {
62
+ const event = JSON.parse(this.buffer);
63
+ this.handleEvent(event);
64
+ } catch { /* ignore */ }
65
+ }
66
+ }
67
+
68
+ destroy() {
69
+ this.buffer = '';
70
+ }
71
+ }
72
+
73
+ export default QwenResponseHandler;
@@ -1,27 +1,27 @@
1
- import express from 'express';
2
-
3
- import sessionManager from '../sessionManager.js';
4
- import { sessionNamesDb } from '../database/db.js';
5
-
6
- const router = express.Router();
7
-
8
- // Delete a Qwen Code session — mirrors the Gemini/Codex routes so the UI's
9
- // unified delete flow works identically regardless of the active provider.
10
- router.delete('/sessions/:sessionId', async (req, res) => {
11
- try {
12
- const { sessionId } = req.params;
13
-
14
- if (!sessionId || typeof sessionId !== 'string' || !/^[a-zA-Z0-9_.-]{1,100}$/.test(sessionId)) {
15
- return res.status(400).json({ success: false, error: 'Invalid session ID format' });
16
- }
17
-
18
- await sessionManager.deleteSession(sessionId);
19
- sessionNamesDb.deleteName(sessionId, 'qwen');
20
- res.json({ success: true });
21
- } catch (error) {
22
- console.error(`Error deleting Qwen session ${req.params.sessionId}:`, error);
23
- res.status(500).json({ success: false, error: error.message });
24
- }
25
- });
26
-
27
- export default router;
1
+ import express from 'express';
2
+
3
+ import sessionManager from '../sessionManager.js';
4
+ import { sessionNamesDb } from '../database/db.js';
5
+
6
+ const router = express.Router();
7
+
8
+ // Delete a Qwen Code session — mirrors the Gemini/Codex routes so the UI's
9
+ // unified delete flow works identically regardless of the active provider.
10
+ router.delete('/sessions/:sessionId', async (req, res) => {
11
+ try {
12
+ const { sessionId } = req.params;
13
+
14
+ if (!sessionId || typeof sessionId !== 'string' || !/^[a-zA-Z0-9_.-]{1,100}$/.test(sessionId)) {
15
+ return res.status(400).json({ success: false, error: 'Invalid session ID format' });
16
+ }
17
+
18
+ await sessionManager.deleteSession(sessionId);
19
+ sessionNamesDb.deleteName(sessionId, 'qwen');
20
+ res.json({ success: true });
21
+ } catch (error) {
22
+ console.error(`Error deleting Qwen session ${req.params.sessionId}:`, error);
23
+ res.status(500).json({ success: false, error: error.message });
24
+ }
25
+ });
26
+
27
+ export default router;
@@ -1,171 +1,171 @@
1
- import { spawn } from 'node:child_process';
2
-
3
- /**
4
- * External-access service.
5
- *
6
- * Previously exposed a UPnP auto-port-forward path via `nat-upnp`, but that
7
- * package pulled in the deprecated `request` / `har-validator` / `uuid@3`
8
- * chain (noise at every install). Cloudflared and ngrok cover the same
9
- * "publish my laptop to the internet" use case with a better security
10
- * posture (no permanent port in the router firewall), so we kept the
11
- * tunnel flow and dropped UPnP entirely. If UPnP becomes a user-demanded
12
- * feature again we can bring it back via a maintained package like
13
- * `@achingbrain/nat-port-mapper`.
14
- */
15
-
16
- // Keep the UPnP getter + no-op togglers so callers still compile, but they
17
- // always report "unavailable". This is transitional — the routes layer no
18
- // longer surfaces them either, so nothing in the live codebase hits these.
19
- const UPNP_UNAVAILABLE = Object.freeze({
20
- mapped: false,
21
- port: null,
22
- externalIp: null,
23
- externalUrl: null,
24
- error: 'UPnP auto-port-forward was removed in v1.32. Use cloudflared or ngrok tunnels instead.',
25
- });
26
- export const getUpnpState = () => UPNP_UNAVAILABLE;
27
-
28
- // ============================================================================
29
- // Tunnel: detect cloudflared / ngrok and spawn; extract the public URL from
30
- // stdout. We keep a single live tunnel per process — starting a new one
31
- // stops the previous one to avoid dangling child processes.
32
- // ============================================================================
33
-
34
- let tunnelProc = null;
35
- let tunnelState = {
36
- running: false,
37
- binary: null, // 'cloudflared' | 'ngrok'
38
- url: null,
39
- error: null,
40
- log: [],
41
- };
42
-
43
- const appendLog = (line) => {
44
- // Tunnels can be noisy. Cap the tail we retain so a long-running tunnel
45
- // doesn't grow the log into an OOM risk.
46
- tunnelState.log.push(line);
47
- if (tunnelState.log.length > 200) tunnelState.log.shift();
48
- };
49
-
50
- const detectBinary = async () => {
51
- const candidates = ['cloudflared', 'ngrok'];
52
- for (const name of candidates) {
53
- try {
54
- // `which` isn't guaranteed on Windows; we probe with `--version` instead
55
- // so the same code path works on Unix and Windows Command Prompt.
56
- await new Promise((resolve, reject) => {
57
- const child = spawn(name, ['--version'], { stdio: 'ignore' });
58
- child.on('error', reject);
59
- child.on('exit', (code) => (code === 0 ? resolve() : reject(new Error(`exit ${code}`))));
60
- });
61
- return name;
62
- } catch {
63
- // try next
64
- }
65
- }
66
- return null;
67
- };
68
-
69
- const cloudflareUrlRegex = /https?:\/\/[a-z0-9.-]+trycloudflare\.com/i;
70
- const ngrokUrlRegex = /https?:\/\/[a-z0-9.-]+\.ngrok(-free)?\.(app|io)/i;
71
-
72
- const buildTunnelArgs = (binary, port) => {
73
- if (binary === 'cloudflared') return ['tunnel', '--url', `http://localhost:${port}`];
74
- if (binary === 'ngrok') return ['http', String(port), '--log', 'stdout', '--log-format', 'logfmt'];
75
- throw new Error(`Unsupported tunnel binary: ${binary}`);
76
- };
77
-
78
- const extractUrl = (binary, text) => {
79
- if (binary === 'cloudflared') return text.match(cloudflareUrlRegex)?.[0] ?? null;
80
- if (binary === 'ngrok') return text.match(ngrokUrlRegex)?.[0] ?? null;
81
- return null;
82
- };
83
-
84
- export const startTunnel = async ({ port }) => {
85
- if (tunnelProc) {
86
- // Already running — tell the caller to stop it first rather than silently
87
- // replacing, which would orphan the old child and lie about state.
88
- throw new Error('Tunnel already running; stop it first');
89
- }
90
-
91
- const binary = await detectBinary();
92
- if (!binary) {
93
- tunnelState = { running: false, binary: null, url: null, error: 'No tunnel binary found', log: [] };
94
- const err = new Error('No tunnel binary found (tried cloudflared, ngrok)');
95
- err.code = 'ENOENT_TUNNEL';
96
- throw err;
97
- }
98
-
99
- const args = buildTunnelArgs(binary, port);
100
- const child = spawn(binary, args, { stdio: ['ignore', 'pipe', 'pipe'] });
101
- tunnelProc = child;
102
- tunnelState = { running: true, binary, url: null, error: null, log: [] };
103
-
104
- const handleChunk = (chunk) => {
105
- const text = chunk.toString();
106
- text.split(/\r?\n/).filter(Boolean).forEach(appendLog);
107
- if (!tunnelState.url) {
108
- const url = extractUrl(binary, text);
109
- if (url) tunnelState.url = url;
110
- }
111
- };
112
-
113
- child.stdout.on('data', handleChunk);
114
- child.stderr.on('data', handleChunk);
115
- child.on('exit', (code) => {
116
- tunnelProc = null;
117
- tunnelState = {
118
- running: false,
119
- binary,
120
- url: null,
121
- error: code === 0 ? null : `Tunnel exited with code ${code}`,
122
- log: tunnelState.log,
123
- };
124
- });
125
-
126
- // Wait up to 15s for the public URL to appear in the log. We don't block
127
- // indefinitely — if the binary is hanging on login/auth, the UI should see
128
- // a clear failure instead of a spinner that never resolves.
129
- const start = Date.now();
130
- while (Date.now() - start < 15000) {
131
- if (tunnelState.url) return tunnelState;
132
- if (!tunnelProc) break; // process died early
133
- // eslint-disable-next-line no-await-in-loop
134
- await new Promise((r) => setTimeout(r, 250));
135
- }
136
-
137
- if (!tunnelState.url) {
138
- // If we never captured a URL, kill the child so we don't leak it.
139
- try { child.kill(); } catch { /* ignore */ }
140
- tunnelProc = null;
141
- tunnelState = { ...tunnelState, running: false, error: 'Tunnel did not report a public URL' };
142
- throw new Error(tunnelState.error);
143
- }
144
-
145
- return tunnelState;
146
- };
147
-
148
- export const stopTunnel = async () => {
149
- if (!tunnelProc) {
150
- tunnelState = { running: false, binary: null, url: null, error: null, log: [] };
151
- return tunnelState;
152
- }
153
- try {
154
- tunnelProc.kill();
155
- } catch {
156
- // already dead
157
- }
158
- tunnelProc = null;
159
- tunnelState = { running: false, binary: null, url: null, error: null, log: [] };
160
- return tunnelState;
161
- };
162
-
163
- export const getTunnelState = () => tunnelState;
164
-
165
- // Explicit cleanup so the server process can shut down without leaking the
166
- // child tunnel process.
167
- process.on('exit', () => {
168
- if (tunnelProc) {
169
- try { tunnelProc.kill(); } catch { /* ignore */ }
170
- }
171
- });
1
+ import { spawn } from 'node:child_process';
2
+
3
+ /**
4
+ * External-access service.
5
+ *
6
+ * Previously exposed a UPnP auto-port-forward path via `nat-upnp`, but that
7
+ * package pulled in the deprecated `request` / `har-validator` / `uuid@3`
8
+ * chain (noise at every install). Cloudflared and ngrok cover the same
9
+ * "publish my laptop to the internet" use case with a better security
10
+ * posture (no permanent port in the router firewall), so we kept the
11
+ * tunnel flow and dropped UPnP entirely. If UPnP becomes a user-demanded
12
+ * feature again we can bring it back via a maintained package like
13
+ * `@achingbrain/nat-port-mapper`.
14
+ */
15
+
16
+ // Keep the UPnP getter + no-op togglers so callers still compile, but they
17
+ // always report "unavailable". This is transitional — the routes layer no
18
+ // longer surfaces them either, so nothing in the live codebase hits these.
19
+ const UPNP_UNAVAILABLE = Object.freeze({
20
+ mapped: false,
21
+ port: null,
22
+ externalIp: null,
23
+ externalUrl: null,
24
+ error: 'UPnP auto-port-forward was removed in v1.32. Use cloudflared or ngrok tunnels instead.',
25
+ });
26
+ export const getUpnpState = () => UPNP_UNAVAILABLE;
27
+
28
+ // ============================================================================
29
+ // Tunnel: detect cloudflared / ngrok and spawn; extract the public URL from
30
+ // stdout. We keep a single live tunnel per process — starting a new one
31
+ // stops the previous one to avoid dangling child processes.
32
+ // ============================================================================
33
+
34
+ let tunnelProc = null;
35
+ let tunnelState = {
36
+ running: false,
37
+ binary: null, // 'cloudflared' | 'ngrok'
38
+ url: null,
39
+ error: null,
40
+ log: [],
41
+ };
42
+
43
+ const appendLog = (line) => {
44
+ // Tunnels can be noisy. Cap the tail we retain so a long-running tunnel
45
+ // doesn't grow the log into an OOM risk.
46
+ tunnelState.log.push(line);
47
+ if (tunnelState.log.length > 200) tunnelState.log.shift();
48
+ };
49
+
50
+ const detectBinary = async () => {
51
+ const candidates = ['cloudflared', 'ngrok'];
52
+ for (const name of candidates) {
53
+ try {
54
+ // `which` isn't guaranteed on Windows; we probe with `--version` instead
55
+ // so the same code path works on Unix and Windows Command Prompt.
56
+ await new Promise((resolve, reject) => {
57
+ const child = spawn(name, ['--version'], { stdio: 'ignore' });
58
+ child.on('error', reject);
59
+ child.on('exit', (code) => (code === 0 ? resolve() : reject(new Error(`exit ${code}`))));
60
+ });
61
+ return name;
62
+ } catch {
63
+ // try next
64
+ }
65
+ }
66
+ return null;
67
+ };
68
+
69
+ const cloudflareUrlRegex = /https?:\/\/[a-z0-9.-]+trycloudflare\.com/i;
70
+ const ngrokUrlRegex = /https?:\/\/[a-z0-9.-]+\.ngrok(-free)?\.(app|io)/i;
71
+
72
+ const buildTunnelArgs = (binary, port) => {
73
+ if (binary === 'cloudflared') return ['tunnel', '--url', `http://localhost:${port}`];
74
+ if (binary === 'ngrok') return ['http', String(port), '--log', 'stdout', '--log-format', 'logfmt'];
75
+ throw new Error(`Unsupported tunnel binary: ${binary}`);
76
+ };
77
+
78
+ const extractUrl = (binary, text) => {
79
+ if (binary === 'cloudflared') return text.match(cloudflareUrlRegex)?.[0] ?? null;
80
+ if (binary === 'ngrok') return text.match(ngrokUrlRegex)?.[0] ?? null;
81
+ return null;
82
+ };
83
+
84
+ export const startTunnel = async ({ port }) => {
85
+ if (tunnelProc) {
86
+ // Already running — tell the caller to stop it first rather than silently
87
+ // replacing, which would orphan the old child and lie about state.
88
+ throw new Error('Tunnel already running; stop it first');
89
+ }
90
+
91
+ const binary = await detectBinary();
92
+ if (!binary) {
93
+ tunnelState = { running: false, binary: null, url: null, error: 'No tunnel binary found', log: [] };
94
+ const err = new Error('No tunnel binary found (tried cloudflared, ngrok)');
95
+ err.code = 'ENOENT_TUNNEL';
96
+ throw err;
97
+ }
98
+
99
+ const args = buildTunnelArgs(binary, port);
100
+ const child = spawn(binary, args, { stdio: ['ignore', 'pipe', 'pipe'] });
101
+ tunnelProc = child;
102
+ tunnelState = { running: true, binary, url: null, error: null, log: [] };
103
+
104
+ const handleChunk = (chunk) => {
105
+ const text = chunk.toString();
106
+ text.split(/\r?\n/).filter(Boolean).forEach(appendLog);
107
+ if (!tunnelState.url) {
108
+ const url = extractUrl(binary, text);
109
+ if (url) tunnelState.url = url;
110
+ }
111
+ };
112
+
113
+ child.stdout.on('data', handleChunk);
114
+ child.stderr.on('data', handleChunk);
115
+ child.on('exit', (code) => {
116
+ tunnelProc = null;
117
+ tunnelState = {
118
+ running: false,
119
+ binary,
120
+ url: null,
121
+ error: code === 0 ? null : `Tunnel exited with code ${code}`,
122
+ log: tunnelState.log,
123
+ };
124
+ });
125
+
126
+ // Wait up to 15s for the public URL to appear in the log. We don't block
127
+ // indefinitely — if the binary is hanging on login/auth, the UI should see
128
+ // a clear failure instead of a spinner that never resolves.
129
+ const start = Date.now();
130
+ while (Date.now() - start < 15000) {
131
+ if (tunnelState.url) return tunnelState;
132
+ if (!tunnelProc) break; // process died early
133
+ // eslint-disable-next-line no-await-in-loop
134
+ await new Promise((r) => setTimeout(r, 250));
135
+ }
136
+
137
+ if (!tunnelState.url) {
138
+ // If we never captured a URL, kill the child so we don't leak it.
139
+ try { child.kill(); } catch { /* ignore */ }
140
+ tunnelProc = null;
141
+ tunnelState = { ...tunnelState, running: false, error: 'Tunnel did not report a public URL' };
142
+ throw new Error(tunnelState.error);
143
+ }
144
+
145
+ return tunnelState;
146
+ };
147
+
148
+ export const stopTunnel = async () => {
149
+ if (!tunnelProc) {
150
+ tunnelState = { running: false, binary: null, url: null, error: null, log: [] };
151
+ return tunnelState;
152
+ }
153
+ try {
154
+ tunnelProc.kill();
155
+ } catch {
156
+ // already dead
157
+ }
158
+ tunnelProc = null;
159
+ tunnelState = { running: false, binary: null, url: null, error: null, log: [] };
160
+ return tunnelState;
161
+ };
162
+
163
+ export const getTunnelState = () => tunnelState;
164
+
165
+ // Explicit cleanup so the server process can shut down without leaking the
166
+ // child tunnel process.
167
+ process.on('exit', () => {
168
+ if (tunnelProc) {
169
+ try { tunnelProc.kill(); } catch { /* ignore */ }
170
+ }
171
+ });