@pixelbyte-software/pixcode 1.35.0 → 1.35.2

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 (36) hide show
  1. package/dist/assets/{index-Djuh0wHV.js → index-D1-AIL_5.js} +133 -133
  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/dist-server/server/modules/orchestration/preview/preview-proxy.js +3 -3
  15. package/dist-server/server/modules/orchestration/preview/preview-proxy.js.map +1 -1
  16. package/package.json +1 -1
  17. package/server/database/db.js +794 -794
  18. package/server/modules/orchestration/a2a/agent-card.ts +55 -55
  19. package/server/modules/orchestration/a2a/auth.middleware.ts +29 -29
  20. package/server/modules/orchestration/a2a/bus.ts +46 -46
  21. package/server/modules/orchestration/preview/preview-proxy.ts +3 -3
  22. package/server/modules/providers/list/opencode/opencode-auth.provider.ts +130 -130
  23. package/server/modules/providers/list/opencode/opencode-mcp.provider.ts +126 -126
  24. package/server/modules/providers/list/opencode/opencode.provider.ts +29 -29
  25. package/server/modules/providers/list/qwen/qwen-auth.provider.ts +145 -145
  26. package/server/modules/providers/list/qwen/qwen-mcp.provider.ts +114 -114
  27. package/server/modules/providers/list/qwen/qwen.provider.ts +21 -21
  28. package/server/modules/providers/shared/provider-configs.ts +142 -142
  29. package/server/qwen-code-cli.js +395 -395
  30. package/server/qwen-response-handler.js +73 -73
  31. package/server/routes/qwen.js +27 -27
  32. package/server/services/external-access.js +171 -171
  33. package/server/services/provider-models.js +381 -381
  34. package/server/services/telegram/telegram-http-client.js +130 -130
  35. package/server/services/vapid-keys.js +36 -36
  36. package/server/utils/port-access.js +209 -209
@@ -1,130 +1,130 @@
1
- import { EventEmitter } from 'node:events';
2
-
3
- /**
4
- * Minimal Telegram Bot API client.
5
- *
6
- * Replaces `node-telegram-bot-api` which pulled in the deprecated
7
- * `request` / `har-validator` / `uuid@3` chain (~30 transitive packages,
8
- * npm install warnings on every fresh box). The Bot API itself is just
9
- * HTTP, and we only use two endpoints (getUpdates polling + sendMessage),
10
- * so 100 lines of fetch is all that's needed. Exposes the same surface
11
- * the bot.js consumer relied on: `getMe()`, `sendMessage()`, `on('message'|'polling_error')`,
12
- * `stopPolling()`.
13
- *
14
- * No third-party deps — uses Node 22's built-in `fetch`.
15
- */
16
-
17
- const API_BASE = 'https://api.telegram.org/bot';
18
-
19
- class TelegramApiError extends Error {
20
- constructor(method, body, httpStatus) {
21
- const description = body?.description || `HTTP ${httpStatus}`;
22
- super(`Telegram ${method} failed: ${description}`);
23
- this.name = 'TelegramApiError';
24
- this.method = method;
25
- this.httpStatus = httpStatus;
26
- // Mirror the shape node-telegram-bot-api exposed so upstream error
27
- // handling (401/409 checks in bot.js) keeps working unchanged.
28
- this.response = { statusCode: httpStatus, body };
29
- this.code = body?.error_code || httpStatus;
30
- }
31
- }
32
-
33
- /**
34
- * Call a Bot API method by name. Returns the `result` field on success,
35
- * throws a TelegramApiError otherwise.
36
- */
37
- async function callApi(token, method, params, { signal } = {}) {
38
- const url = `${API_BASE}${token}/${method}`;
39
- const res = await fetch(url, {
40
- method: 'POST',
41
- headers: { 'Content-Type': 'application/json' },
42
- body: JSON.stringify(params || {}),
43
- signal,
44
- });
45
- let body;
46
- try { body = await res.json(); } catch { body = null; }
47
- if (!res.ok || !body?.ok) {
48
- throw new TelegramApiError(method, body, res.status);
49
- }
50
- return body.result;
51
- }
52
-
53
- export class TelegramHttpBot extends EventEmitter {
54
- constructor(token, { polling = true, pollTimeoutSec = 30 } = {}) {
55
- super();
56
- if (!token) throw new Error('TelegramHttpBot: token is required');
57
- this._token = token;
58
- this._pollTimeoutSec = pollTimeoutSec;
59
- this._offset = 0;
60
- this._polling = false;
61
- this._abortController = null;
62
- if (polling) this._startPolling();
63
- }
64
-
65
- // ---------- Public API (mirrors node-telegram-bot-api surface) ----------
66
-
67
- async getMe() {
68
- return callApi(this._token, 'getMe', {});
69
- }
70
-
71
- async sendMessage(chatId, text, extra = {}) {
72
- return callApi(this._token, 'sendMessage', {
73
- chat_id: chatId,
74
- text,
75
- ...extra,
76
- });
77
- }
78
-
79
- async stopPolling(_opts = {}) {
80
- this._polling = false;
81
- try { this._abortController?.abort(); } catch { /* ignore */ }
82
- this._abortController = null;
83
- }
84
-
85
- // ---------- Polling loop ----------
86
-
87
- async _startPolling() {
88
- this._polling = true;
89
- // Kick off a non-awaited loop. Each iteration long-polls getUpdates for
90
- // up to pollTimeoutSec, then loops immediately. We deliberately serialize
91
- // (no concurrent long-polls) because Telegram rejects that with 409.
92
- (async () => {
93
- while (this._polling) {
94
- this._abortController = new AbortController();
95
- try {
96
- const updates = await callApi(
97
- this._token,
98
- 'getUpdates',
99
- {
100
- offset: this._offset,
101
- timeout: this._pollTimeoutSec,
102
- allowed_updates: ['message'],
103
- },
104
- { signal: this._abortController.signal },
105
- );
106
- for (const update of updates) {
107
- if (typeof update.update_id === 'number') {
108
- this._offset = Math.max(this._offset, update.update_id + 1);
109
- }
110
- if (update.message) {
111
- try { this.emit('message', update.message); } catch (err) {
112
- // Don't let a listener exception break the poll loop.
113
- this.emit('polling_error', err);
114
- }
115
- }
116
- }
117
- } catch (err) {
118
- // AbortError is the expected path when stopPolling() is called.
119
- if (err?.name === 'AbortError' || !this._polling) break;
120
- this.emit('polling_error', err);
121
- // Back off before retrying — rapid retries on 401/409 would
122
- // otherwise spin at 100% CPU. Upstream consumer's polling_error
123
- // handler may also call stopBot() on 401/409 which flips _polling
124
- // off and breaks the loop on the next tick.
125
- await new Promise((r) => setTimeout(r, 2000));
126
- }
127
- }
128
- })();
129
- }
130
- }
1
+ import { EventEmitter } from 'node:events';
2
+
3
+ /**
4
+ * Minimal Telegram Bot API client.
5
+ *
6
+ * Replaces `node-telegram-bot-api` which pulled in the deprecated
7
+ * `request` / `har-validator` / `uuid@3` chain (~30 transitive packages,
8
+ * npm install warnings on every fresh box). The Bot API itself is just
9
+ * HTTP, and we only use two endpoints (getUpdates polling + sendMessage),
10
+ * so 100 lines of fetch is all that's needed. Exposes the same surface
11
+ * the bot.js consumer relied on: `getMe()`, `sendMessage()`, `on('message'|'polling_error')`,
12
+ * `stopPolling()`.
13
+ *
14
+ * No third-party deps — uses Node 22's built-in `fetch`.
15
+ */
16
+
17
+ const API_BASE = 'https://api.telegram.org/bot';
18
+
19
+ class TelegramApiError extends Error {
20
+ constructor(method, body, httpStatus) {
21
+ const description = body?.description || `HTTP ${httpStatus}`;
22
+ super(`Telegram ${method} failed: ${description}`);
23
+ this.name = 'TelegramApiError';
24
+ this.method = method;
25
+ this.httpStatus = httpStatus;
26
+ // Mirror the shape node-telegram-bot-api exposed so upstream error
27
+ // handling (401/409 checks in bot.js) keeps working unchanged.
28
+ this.response = { statusCode: httpStatus, body };
29
+ this.code = body?.error_code || httpStatus;
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Call a Bot API method by name. Returns the `result` field on success,
35
+ * throws a TelegramApiError otherwise.
36
+ */
37
+ async function callApi(token, method, params, { signal } = {}) {
38
+ const url = `${API_BASE}${token}/${method}`;
39
+ const res = await fetch(url, {
40
+ method: 'POST',
41
+ headers: { 'Content-Type': 'application/json' },
42
+ body: JSON.stringify(params || {}),
43
+ signal,
44
+ });
45
+ let body;
46
+ try { body = await res.json(); } catch { body = null; }
47
+ if (!res.ok || !body?.ok) {
48
+ throw new TelegramApiError(method, body, res.status);
49
+ }
50
+ return body.result;
51
+ }
52
+
53
+ export class TelegramHttpBot extends EventEmitter {
54
+ constructor(token, { polling = true, pollTimeoutSec = 30 } = {}) {
55
+ super();
56
+ if (!token) throw new Error('TelegramHttpBot: token is required');
57
+ this._token = token;
58
+ this._pollTimeoutSec = pollTimeoutSec;
59
+ this._offset = 0;
60
+ this._polling = false;
61
+ this._abortController = null;
62
+ if (polling) this._startPolling();
63
+ }
64
+
65
+ // ---------- Public API (mirrors node-telegram-bot-api surface) ----------
66
+
67
+ async getMe() {
68
+ return callApi(this._token, 'getMe', {});
69
+ }
70
+
71
+ async sendMessage(chatId, text, extra = {}) {
72
+ return callApi(this._token, 'sendMessage', {
73
+ chat_id: chatId,
74
+ text,
75
+ ...extra,
76
+ });
77
+ }
78
+
79
+ async stopPolling(_opts = {}) {
80
+ this._polling = false;
81
+ try { this._abortController?.abort(); } catch { /* ignore */ }
82
+ this._abortController = null;
83
+ }
84
+
85
+ // ---------- Polling loop ----------
86
+
87
+ async _startPolling() {
88
+ this._polling = true;
89
+ // Kick off a non-awaited loop. Each iteration long-polls getUpdates for
90
+ // up to pollTimeoutSec, then loops immediately. We deliberately serialize
91
+ // (no concurrent long-polls) because Telegram rejects that with 409.
92
+ (async () => {
93
+ while (this._polling) {
94
+ this._abortController = new AbortController();
95
+ try {
96
+ const updates = await callApi(
97
+ this._token,
98
+ 'getUpdates',
99
+ {
100
+ offset: this._offset,
101
+ timeout: this._pollTimeoutSec,
102
+ allowed_updates: ['message'],
103
+ },
104
+ { signal: this._abortController.signal },
105
+ );
106
+ for (const update of updates) {
107
+ if (typeof update.update_id === 'number') {
108
+ this._offset = Math.max(this._offset, update.update_id + 1);
109
+ }
110
+ if (update.message) {
111
+ try { this.emit('message', update.message); } catch (err) {
112
+ // Don't let a listener exception break the poll loop.
113
+ this.emit('polling_error', err);
114
+ }
115
+ }
116
+ }
117
+ } catch (err) {
118
+ // AbortError is the expected path when stopPolling() is called.
119
+ if (err?.name === 'AbortError' || !this._polling) break;
120
+ this.emit('polling_error', err);
121
+ // Back off before retrying — rapid retries on 401/409 would
122
+ // otherwise spin at 100% CPU. Upstream consumer's polling_error
123
+ // handler may also call stopBot() on 401/409 which flips _polling
124
+ // off and breaks the loop on the next tick.
125
+ await new Promise((r) => setTimeout(r, 2000));
126
+ }
127
+ }
128
+ })();
129
+ }
130
+ }
@@ -1,36 +1,36 @@
1
- import webPush from 'web-push';
2
-
3
- import { vapidKeysDb } from '../database/db.js';
4
-
5
- let cachedKeys = null;
6
-
7
- function ensureVapidKeys() {
8
- if (cachedKeys) return cachedKeys;
9
-
10
- const row = vapidKeysDb.getLatest();
11
- if (row) {
12
- cachedKeys = { publicKey: row.public_key, privateKey: row.private_key };
13
- return cachedKeys;
14
- }
15
-
16
- const keys = webPush.generateVAPIDKeys();
17
- vapidKeysDb.insert(keys.publicKey, keys.privateKey);
18
- cachedKeys = keys;
19
- return cachedKeys;
20
- }
21
-
22
- function getPublicKey() {
23
- return ensureVapidKeys().publicKey;
24
- }
25
-
26
- function configureWebPush() {
27
- const keys = ensureVapidKeys();
28
- webPush.setVapidDetails(
29
- 'mailto:noreply@pixcode.local',
30
- keys.publicKey,
31
- keys.privateKey
32
- );
33
- console.log('Web Push notifications configured');
34
- }
35
-
36
- export { ensureVapidKeys, getPublicKey, configureWebPush };
1
+ import webPush from 'web-push';
2
+
3
+ import { vapidKeysDb } from '../database/db.js';
4
+
5
+ let cachedKeys = null;
6
+
7
+ function ensureVapidKeys() {
8
+ if (cachedKeys) return cachedKeys;
9
+
10
+ const row = vapidKeysDb.getLatest();
11
+ if (row) {
12
+ cachedKeys = { publicKey: row.public_key, privateKey: row.private_key };
13
+ return cachedKeys;
14
+ }
15
+
16
+ const keys = webPush.generateVAPIDKeys();
17
+ vapidKeysDb.insert(keys.publicKey, keys.privateKey);
18
+ cachedKeys = keys;
19
+ return cachedKeys;
20
+ }
21
+
22
+ function getPublicKey() {
23
+ return ensureVapidKeys().publicKey;
24
+ }
25
+
26
+ function configureWebPush() {
27
+ const keys = ensureVapidKeys();
28
+ webPush.setVapidDetails(
29
+ 'mailto:noreply@pixcode.local',
30
+ keys.publicKey,
31
+ keys.privateKey
32
+ );
33
+ console.log('Web Push notifications configured');
34
+ }
35
+
36
+ export { ensureVapidKeys, getPublicKey, configureWebPush };