@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.
Files changed (67) hide show
  1. package/dist/api-docs.html +395 -879
  2. package/dist/assets/{index-DpIcI9Q1.js → index-B_dU5AHA.js} +153 -165
  3. package/dist/favicon.svg +8 -8
  4. package/dist/icons/icon-128x128.svg +9 -9
  5. package/dist/icons/icon-144x144.svg +9 -9
  6. package/dist/icons/icon-152x152.svg +9 -9
  7. package/dist/icons/icon-192x192.svg +9 -9
  8. package/dist/icons/icon-384x384.svg +9 -9
  9. package/dist/icons/icon-512x512.svg +9 -9
  10. package/dist/icons/icon-72x72.svg +9 -9
  11. package/dist/icons/icon-96x96.svg +9 -9
  12. package/dist/icons/icon-template.svg +9 -9
  13. package/dist/index.html +1 -1
  14. package/dist/logo.svg +12 -12
  15. package/dist/openapi.yaml +1311 -0
  16. package/dist-server/server/gemini-cli.js +59 -0
  17. package/dist-server/server/gemini-cli.js.map +1 -1
  18. package/dist-server/server/index.js +6 -1
  19. package/dist-server/server/index.js.map +1 -1
  20. package/dist-server/server/middleware/auth.js +51 -9
  21. package/dist-server/server/middleware/auth.js.map +1 -1
  22. package/dist-server/server/modules/providers/list/opencode/opencode-sessions.provider.js +54 -15
  23. package/dist-server/server/modules/providers/list/opencode/opencode-sessions.provider.js.map +1 -1
  24. package/dist-server/server/modules/providers/list/qwen/qwen-sessions.provider.js +46 -0
  25. package/dist-server/server/modules/providers/list/qwen/qwen-sessions.provider.js.map +1 -1
  26. package/dist-server/server/modules/providers/provider.routes.js +32 -1
  27. package/dist-server/server/modules/providers/provider.routes.js.map +1 -1
  28. package/dist-server/server/opencode-cli.js +37 -1
  29. package/dist-server/server/opencode-cli.js.map +1 -1
  30. package/dist-server/server/opencode-response-handler.js +36 -34
  31. package/dist-server/server/opencode-response-handler.js.map +1 -1
  32. package/dist-server/server/routes/agent.js +187 -56
  33. package/dist-server/server/routes/agent.js.map +1 -1
  34. package/dist-server/server/routes/projects.js +134 -8
  35. package/dist-server/server/routes/projects.js.map +1 -1
  36. package/dist-server/server/services/provider-credentials.js +42 -8
  37. package/dist-server/server/services/provider-credentials.js.map +1 -1
  38. package/package.json +178 -178
  39. package/scripts/rest-sweep.mjs +93 -0
  40. package/server/database/db.js +794 -794
  41. package/server/database/json-store.js +194 -194
  42. package/server/gemini-cli.js +60 -0
  43. package/server/index.js +6 -1
  44. package/server/middleware/auth.js +50 -9
  45. package/server/modules/providers/list/opencode/opencode-auth.provider.ts +130 -130
  46. package/server/modules/providers/list/opencode/opencode-mcp.provider.ts +126 -126
  47. package/server/modules/providers/list/opencode/opencode-sessions.provider.ts +232 -193
  48. package/server/modules/providers/list/opencode/opencode.provider.ts +29 -29
  49. package/server/modules/providers/list/qwen/qwen-auth.provider.ts +145 -145
  50. package/server/modules/providers/list/qwen/qwen-mcp.provider.ts +114 -114
  51. package/server/modules/providers/list/qwen/qwen-sessions.provider.ts +265 -218
  52. package/server/modules/providers/list/qwen/qwen.provider.ts +21 -21
  53. package/server/modules/providers/provider.routes.ts +37 -4
  54. package/server/modules/providers/shared/provider-configs.ts +142 -142
  55. package/server/opencode-cli.js +37 -1
  56. package/server/opencode-response-handler.js +107 -100
  57. package/server/qwen-code-cli.js +395 -395
  58. package/server/qwen-response-handler.js +73 -73
  59. package/server/routes/agent.js +178 -58
  60. package/server/routes/projects.js +136 -8
  61. package/server/routes/qwen.js +27 -27
  62. package/server/services/external-access.js +171 -171
  63. package/server/services/provider-credentials.js +189 -155
  64. package/server/services/provider-models.js +381 -381
  65. package/server/services/telegram/telegram-http-client.js +130 -130
  66. package/server/services/vapid-keys.js +36 -36
  67. package/server/utils/port-access.js +209 -209
@@ -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
+ });