@pixelbyte-software/pixcode 1.53.11 โ 1.53.12
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/assets/index-BEyC4q_s.css +32 -0
- package/dist/assets/{index-Bo8oVc2f.js โ index-kP_gZ-wL.js} +178 -178
- package/dist/index.html +2 -2
- package/dist-server/server/database/db.js +26 -0
- package/dist-server/server/database/db.js.map +1 -1
- package/dist-server/server/index.js +258 -52
- package/dist-server/server/index.js.map +1 -1
- package/dist-server/server/projects.js +126 -43
- package/dist-server/server/projects.js.map +1 -1
- package/dist-server/server/routes/plugins.js +364 -0
- package/dist-server/server/routes/plugins.js.map +1 -1
- package/dist-server/server/services/telegram/control-center.js +169 -5
- package/dist-server/server/services/telegram/control-center.js.map +1 -1
- package/dist-server/server/services/telegram/translations.js +28 -2
- package/dist-server/server/services/telegram/translations.js.map +1 -1
- package/package.json +1 -1
- package/server/database/db.js +26 -0
- package/server/index.js +280 -57
- package/server/projects.js +128 -41
- package/server/routes/plugins.js +370 -0
- package/server/services/telegram/control-center.js +173 -5
- package/server/services/telegram/translations.js +28 -2
- package/dist/assets/index-FhOsv2Yy.css +0 -32
package/server/routes/plugins.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import http from 'http';
|
|
3
3
|
import fs from 'fs';
|
|
4
|
+
import os from 'os';
|
|
4
5
|
|
|
5
6
|
import mime from 'mime-types';
|
|
6
7
|
import express from 'express';
|
|
@@ -24,6 +25,375 @@ import {
|
|
|
24
25
|
} from '../utils/plugin-process-manager.js';
|
|
25
26
|
|
|
26
27
|
const router = express.Router();
|
|
28
|
+
const MARKETPLACE_SOURCES_PATH = path.join(os.homedir(), '.pixcode', 'marketplace-sources.json');
|
|
29
|
+
const MARKETPLACE_SEARCH_TIMEOUT_MS = 8000;
|
|
30
|
+
const ALL_CLI_COMPATIBILITY = ['claude', 'codex', 'cursor', 'gemini', 'qwen', 'opencode'];
|
|
31
|
+
|
|
32
|
+
const CURATED_MARKETPLACE_ENTRIES = [
|
|
33
|
+
{
|
|
34
|
+
id: 'github:hesreallyhim/awesome-claude-code',
|
|
35
|
+
name: 'Awesome Claude Code',
|
|
36
|
+
type: 'skill-library',
|
|
37
|
+
category: 'popular',
|
|
38
|
+
sourceUrl: 'https://github.com/hesreallyhim/awesome-claude-code',
|
|
39
|
+
repo: 'hesreallyhim/awesome-claude-code',
|
|
40
|
+
description: 'Curated skills, slash commands, hooks, orchestration patterns, and agent resources.',
|
|
41
|
+
stars: 46000,
|
|
42
|
+
forks: 0,
|
|
43
|
+
updatedAt: null,
|
|
44
|
+
compatibleCli: ALL_CLI_COMPATIBILITY,
|
|
45
|
+
installKind: 'source',
|
|
46
|
+
tags: ['skills', 'agents', 'commands'],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: 'github:sickn33/antigravity-awesome-skills',
|
|
50
|
+
name: 'Antigravity Awesome Skills',
|
|
51
|
+
type: 'skill-library',
|
|
52
|
+
category: 'popular',
|
|
53
|
+
sourceUrl: 'https://github.com/sickn33/antigravity-awesome-skills',
|
|
54
|
+
repo: 'sickn33/antigravity-awesome-skills',
|
|
55
|
+
description: 'Large installable library of cross-CLI agent skills for Claude, Codex, Cursor, Gemini, and more.',
|
|
56
|
+
stars: 40000,
|
|
57
|
+
forks: 0,
|
|
58
|
+
updatedAt: null,
|
|
59
|
+
compatibleCli: ALL_CLI_COMPATIBILITY,
|
|
60
|
+
installKind: 'source',
|
|
61
|
+
tags: ['skills', 'multi-cli'],
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: 'github:wshobson/agents',
|
|
65
|
+
name: 'Agents',
|
|
66
|
+
type: 'agent-pack',
|
|
67
|
+
category: 'popular',
|
|
68
|
+
sourceUrl: 'https://github.com/wshobson/agents',
|
|
69
|
+
repo: 'wshobson/agents',
|
|
70
|
+
description: 'Multi-harness agent pack and marketplace patterns for Claude Code, Codex CLI, Cursor, OpenCode, Copilot, and Gemini.',
|
|
71
|
+
stars: 36000,
|
|
72
|
+
forks: 0,
|
|
73
|
+
updatedAt: null,
|
|
74
|
+
compatibleCli: ALL_CLI_COMPATIBILITY,
|
|
75
|
+
installKind: 'source',
|
|
76
|
+
tags: ['agents', 'multi-cli'],
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: 'github:alirezarezvani/claude-skills',
|
|
80
|
+
name: 'Claude Skills',
|
|
81
|
+
type: 'skill-library',
|
|
82
|
+
category: 'popular',
|
|
83
|
+
sourceUrl: 'https://github.com/alirezarezvani/claude-skills',
|
|
84
|
+
repo: 'alirezarezvani/claude-skills',
|
|
85
|
+
description: 'Broad skill, agent, and plugin collection for Claude Code, Codex, Gemini CLI, Cursor, and related tools.',
|
|
86
|
+
stars: 18000,
|
|
87
|
+
forks: 0,
|
|
88
|
+
updatedAt: null,
|
|
89
|
+
compatibleCli: ALL_CLI_COMPATIBILITY,
|
|
90
|
+
installKind: 'source',
|
|
91
|
+
tags: ['skills', 'plugins'],
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
id: 'github:voltagent/awesome-agent-skills',
|
|
95
|
+
name: 'Awesome Agent Skills',
|
|
96
|
+
type: 'skill-library',
|
|
97
|
+
category: 'skills',
|
|
98
|
+
sourceUrl: 'https://github.com/VoltAgent/awesome-agent-skills',
|
|
99
|
+
repo: 'VoltAgent/awesome-agent-skills',
|
|
100
|
+
description: 'Cross-agent skill catalogue covering Claude, Codex, Cursor, Gemini, and OpenCode ecosystems.',
|
|
101
|
+
stars: 0,
|
|
102
|
+
forks: 0,
|
|
103
|
+
updatedAt: null,
|
|
104
|
+
compatibleCli: ALL_CLI_COMPATIBILITY,
|
|
105
|
+
installKind: 'source',
|
|
106
|
+
tags: ['skills', 'catalog'],
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
id: 'github:awesome-opencode/awesome-opencode',
|
|
110
|
+
name: 'Awesome OpenCode',
|
|
111
|
+
type: 'native-plugin',
|
|
112
|
+
category: 'plugin',
|
|
113
|
+
sourceUrl: 'https://github.com/awesome-opencode/awesome-opencode',
|
|
114
|
+
repo: 'awesome-opencode/awesome-opencode',
|
|
115
|
+
description: 'Curated OpenCode plugins, themes, agents, projects, and resources.',
|
|
116
|
+
stars: 8000,
|
|
117
|
+
forks: 0,
|
|
118
|
+
updatedAt: null,
|
|
119
|
+
compatibleCli: ['opencode'],
|
|
120
|
+
installKind: 'source',
|
|
121
|
+
tags: ['opencode', 'plugins'],
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
id: 'github:jenslys/opencode-gemini-auth',
|
|
125
|
+
name: 'OpenCode Gemini Auth',
|
|
126
|
+
type: 'native-plugin',
|
|
127
|
+
category: 'plugin',
|
|
128
|
+
sourceUrl: 'https://github.com/jenslys/opencode-gemini-auth',
|
|
129
|
+
repo: 'jenslys/opencode-gemini-auth',
|
|
130
|
+
description: 'OpenCode authentication plugin for Gemini accounts.',
|
|
131
|
+
stars: 0,
|
|
132
|
+
forks: 0,
|
|
133
|
+
updatedAt: null,
|
|
134
|
+
compatibleCli: ['opencode', 'gemini'],
|
|
135
|
+
installKind: 'source',
|
|
136
|
+
tags: ['opencode', 'auth'],
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
id: 'github:supermemoryai/opencode-supermemory',
|
|
140
|
+
name: 'OpenCode Supermemory',
|
|
141
|
+
type: 'native-plugin',
|
|
142
|
+
category: 'plugin',
|
|
143
|
+
sourceUrl: 'https://github.com/supermemoryai/opencode-supermemory',
|
|
144
|
+
repo: 'supermemoryai/opencode-supermemory',
|
|
145
|
+
description: 'Supermemory integration plugin for OpenCode.',
|
|
146
|
+
stars: 0,
|
|
147
|
+
forks: 0,
|
|
148
|
+
updatedAt: null,
|
|
149
|
+
compatibleCli: ['opencode'],
|
|
150
|
+
installKind: 'source',
|
|
151
|
+
tags: ['opencode', 'memory'],
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
id: 'github:griffinmartin/opencode-claude-auth',
|
|
155
|
+
name: 'OpenCode Claude Auth',
|
|
156
|
+
type: 'native-plugin',
|
|
157
|
+
category: 'plugin',
|
|
158
|
+
sourceUrl: 'https://github.com/griffinmartin/opencode-claude-auth',
|
|
159
|
+
repo: 'griffinmartin/opencode-claude-auth',
|
|
160
|
+
description: 'OpenCode plugin that reuses Claude Code credentials.',
|
|
161
|
+
stars: 0,
|
|
162
|
+
forks: 0,
|
|
163
|
+
updatedAt: null,
|
|
164
|
+
compatibleCli: ['opencode', 'claude'],
|
|
165
|
+
installKind: 'source',
|
|
166
|
+
tags: ['opencode', 'auth'],
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
id: 'github:othmanadi/planning-with-files',
|
|
170
|
+
name: 'Planning With Files',
|
|
171
|
+
type: 'skill-library',
|
|
172
|
+
category: 'workflow',
|
|
173
|
+
sourceUrl: 'https://github.com/OthmanAdi/planning-with-files',
|
|
174
|
+
repo: 'OthmanAdi/planning-with-files',
|
|
175
|
+
description: 'Persistent file-based planning skill for multiple AI coding CLIs.',
|
|
176
|
+
stars: 0,
|
|
177
|
+
forks: 0,
|
|
178
|
+
updatedAt: null,
|
|
179
|
+
compatibleCli: ALL_CLI_COMPATIBILITY,
|
|
180
|
+
installKind: 'source',
|
|
181
|
+
tags: ['planning', 'workflow'],
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
id: 'github:safishamsi/graphify',
|
|
185
|
+
name: 'Graphify',
|
|
186
|
+
type: 'skill-library',
|
|
187
|
+
category: 'workflow',
|
|
188
|
+
sourceUrl: 'https://github.com/safishamsi/graphify',
|
|
189
|
+
repo: 'safishamsi/graphify',
|
|
190
|
+
description: 'Knowledge graph skill for Claude Code, Codex, OpenCode, Cursor, Gemini, and other coding agents.',
|
|
191
|
+
stars: 0,
|
|
192
|
+
forks: 0,
|
|
193
|
+
updatedAt: null,
|
|
194
|
+
compatibleCli: ALL_CLI_COMPATIBILITY,
|
|
195
|
+
installKind: 'source',
|
|
196
|
+
tags: ['knowledge-graph', 'memory'],
|
|
197
|
+
},
|
|
198
|
+
];
|
|
199
|
+
|
|
200
|
+
function ensurePixcodeConfigDir() {
|
|
201
|
+
const dir = path.dirname(MARKETPLACE_SOURCES_PATH);
|
|
202
|
+
if (!fs.existsSync(dir)) {
|
|
203
|
+
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function readMarketplaceSources() {
|
|
208
|
+
try {
|
|
209
|
+
if (!fs.existsSync(MARKETPLACE_SOURCES_PATH)) return [];
|
|
210
|
+
const parsed = JSON.parse(fs.readFileSync(MARKETPLACE_SOURCES_PATH, 'utf-8'));
|
|
211
|
+
return Array.isArray(parsed?.sources) ? parsed.sources : [];
|
|
212
|
+
} catch {
|
|
213
|
+
return [];
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function writeMarketplaceSources(sources) {
|
|
218
|
+
ensurePixcodeConfigDir();
|
|
219
|
+
fs.writeFileSync(
|
|
220
|
+
MARKETPLACE_SOURCES_PATH,
|
|
221
|
+
JSON.stringify({ version: 1, sources }, null, 2),
|
|
222
|
+
{ mode: 0o600 },
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function parseGithubRepoFromUrl(sourceUrl) {
|
|
227
|
+
try {
|
|
228
|
+
const url = new URL(sourceUrl);
|
|
229
|
+
if (url.hostname !== 'github.com' && url.hostname !== 'www.github.com') return null;
|
|
230
|
+
const [owner, repo] = url.pathname.replace(/^\/+/, '').split('/');
|
|
231
|
+
if (!owner || !repo) return null;
|
|
232
|
+
return `${owner}/${repo.replace(/\.git$/, '')}`;
|
|
233
|
+
} catch {
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function marketplaceIdForSource(sourceUrl, fallbackName = '') {
|
|
239
|
+
const repo = parseGithubRepoFromUrl(sourceUrl);
|
|
240
|
+
if (repo) return `github:${repo.toLowerCase()}`;
|
|
241
|
+
return `source:${String(fallbackName || sourceUrl).toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '').slice(0, 80)}`;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function inferCliCompatibility(text) {
|
|
245
|
+
const haystack = String(text || '').toLowerCase();
|
|
246
|
+
const matches = ALL_CLI_COMPATIBILITY.filter((cli) => haystack.includes(cli));
|
|
247
|
+
if (haystack.includes('claude code') && !matches.includes('claude')) matches.push('claude');
|
|
248
|
+
if (haystack.includes('open code') && !matches.includes('opencode')) matches.push('opencode');
|
|
249
|
+
return matches.length > 0 ? [...new Set(matches)] : ALL_CLI_COMPATIBILITY;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function inferMarketplaceType(text) {
|
|
253
|
+
const haystack = String(text || '').toLowerCase();
|
|
254
|
+
if (haystack.includes('agent')) return 'agent-pack';
|
|
255
|
+
if (haystack.includes('plugin') || haystack.includes('opencode')) return 'native-plugin';
|
|
256
|
+
return 'skill-library';
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function normalizeMarketplaceSource(input) {
|
|
260
|
+
const sourceUrl = typeof input?.sourceUrl === 'string' ? input.sourceUrl.trim() : '';
|
|
261
|
+
if (!sourceUrl.startsWith('https://github.com/')) {
|
|
262
|
+
throw new Error('Only public GitHub HTTPS sources are supported for global market sources.');
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const repo = parseGithubRepoFromUrl(sourceUrl);
|
|
266
|
+
const name = String(input?.name || repo || 'GitHub source').trim().slice(0, 120);
|
|
267
|
+
const description = String(input?.description || '').trim().slice(0, 500);
|
|
268
|
+
const compatibleCli = Array.isArray(input?.compatibleCli)
|
|
269
|
+
? input.compatibleCli.filter((cli) => ALL_CLI_COMPATIBILITY.includes(cli))
|
|
270
|
+
: inferCliCompatibility(`${name} ${description} ${repo || ''}`);
|
|
271
|
+
|
|
272
|
+
return {
|
|
273
|
+
id: marketplaceIdForSource(sourceUrl, name),
|
|
274
|
+
name,
|
|
275
|
+
type: ['skill-library', 'agent-pack', 'native-plugin', 'pixcode-plugin'].includes(input?.type)
|
|
276
|
+
? input.type
|
|
277
|
+
: inferMarketplaceType(`${name} ${description}`),
|
|
278
|
+
category: typeof input?.category === 'string' ? input.category.slice(0, 40) : 'installed',
|
|
279
|
+
sourceUrl,
|
|
280
|
+
repo,
|
|
281
|
+
description,
|
|
282
|
+
stars: Number.isFinite(Number(input?.stars)) ? Number(input.stars) : 0,
|
|
283
|
+
forks: Number.isFinite(Number(input?.forks)) ? Number(input.forks) : 0,
|
|
284
|
+
updatedAt: typeof input?.updatedAt === 'string' ? input.updatedAt : null,
|
|
285
|
+
compatibleCli: compatibleCli.length > 0 ? compatibleCli : ALL_CLI_COMPATIBILITY,
|
|
286
|
+
installKind: input?.installKind === 'pixcode-plugin' ? 'pixcode-plugin' : 'source',
|
|
287
|
+
tags: Array.isArray(input?.tags) ? input.tags.filter((tag) => typeof tag === 'string').slice(0, 8) : [],
|
|
288
|
+
addedAt: typeof input?.addedAt === 'string' ? input.addedAt : new Date().toISOString(),
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function githubRepoToMarketplaceEntry(repo, category = 'search') {
|
|
293
|
+
const text = `${repo.full_name || ''} ${repo.description || ''} ${repo.topics?.join(' ') || ''}`;
|
|
294
|
+
return {
|
|
295
|
+
id: `github:${String(repo.full_name || repo.html_url || repo.id).toLowerCase()}`,
|
|
296
|
+
name: repo.name || repo.full_name || 'GitHub repository',
|
|
297
|
+
type: inferMarketplaceType(text),
|
|
298
|
+
category,
|
|
299
|
+
sourceUrl: repo.html_url,
|
|
300
|
+
repo: repo.full_name || null,
|
|
301
|
+
description: repo.description || '',
|
|
302
|
+
stars: repo.stargazers_count || 0,
|
|
303
|
+
forks: repo.forks_count || 0,
|
|
304
|
+
updatedAt: repo.updated_at || null,
|
|
305
|
+
compatibleCli: inferCliCompatibility(text),
|
|
306
|
+
installKind: 'source',
|
|
307
|
+
tags: Array.isArray(repo.topics) ? repo.topics.slice(0, 6) : [],
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// GET /marketplace โ curated global skill/plugin market plus added sources.
|
|
312
|
+
router.get('/marketplace', (req, res) => {
|
|
313
|
+
try {
|
|
314
|
+
res.json({
|
|
315
|
+
entries: CURATED_MARKETPLACE_ENTRIES,
|
|
316
|
+
installedSources: readMarketplaceSources(),
|
|
317
|
+
categories: ['popular', 'skills', 'plugin', 'workflow', 'new'],
|
|
318
|
+
});
|
|
319
|
+
} catch (err) {
|
|
320
|
+
res.status(500).json({ error: 'Failed to read marketplace', details: err.message });
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
// GET /marketplace/search?q=... โ live GitHub repository discovery for skill/plugin sources.
|
|
325
|
+
router.get('/marketplace/search', async (req, res) => {
|
|
326
|
+
const q = String(req.query.q || '').trim().slice(0, 120);
|
|
327
|
+
const sort = req.query.sort === 'new' ? 'updated' : 'stars';
|
|
328
|
+
const baseQuery = q || 'agent skills plugin cli claude codex cursor gemini opencode';
|
|
329
|
+
const searchQuery = `${baseQuery} in:name,description,readme`;
|
|
330
|
+
const controller = new AbortController();
|
|
331
|
+
const timeout = setTimeout(() => controller.abort(), MARKETPLACE_SEARCH_TIMEOUT_MS);
|
|
332
|
+
|
|
333
|
+
try {
|
|
334
|
+
const url = new URL('https://api.github.com/search/repositories');
|
|
335
|
+
url.searchParams.set('q', searchQuery);
|
|
336
|
+
url.searchParams.set('sort', sort);
|
|
337
|
+
url.searchParams.set('order', 'desc');
|
|
338
|
+
url.searchParams.set('per_page', '12');
|
|
339
|
+
const response = await fetch(url, {
|
|
340
|
+
signal: controller.signal,
|
|
341
|
+
headers: {
|
|
342
|
+
accept: 'application/vnd.github+json',
|
|
343
|
+
'user-agent': 'pixcode-marketplace',
|
|
344
|
+
},
|
|
345
|
+
});
|
|
346
|
+
if (!response.ok) {
|
|
347
|
+
const detail = await response.text().catch(() => '');
|
|
348
|
+
return res.status(response.status).json({
|
|
349
|
+
error: 'GitHub search failed',
|
|
350
|
+
details: detail.slice(0, 500) || response.statusText,
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const body = await response.json();
|
|
355
|
+
const entries = Array.isArray(body?.items)
|
|
356
|
+
? body.items.map((repo) => githubRepoToMarketplaceEntry(repo, sort === 'updated' ? 'new' : 'popular'))
|
|
357
|
+
: [];
|
|
358
|
+
res.json({ entries });
|
|
359
|
+
} catch (err) {
|
|
360
|
+
const status = err?.name === 'AbortError' ? 504 : 502;
|
|
361
|
+
res.status(status).json({ error: 'GitHub search failed', details: err.message });
|
|
362
|
+
} finally {
|
|
363
|
+
clearTimeout(timeout);
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
// POST /marketplace/sources โ add a global cross-CLI skill/plugin source.
|
|
368
|
+
router.post('/marketplace/sources', (req, res) => {
|
|
369
|
+
try {
|
|
370
|
+
const source = normalizeMarketplaceSource(req.body?.entry || req.body || {});
|
|
371
|
+
const sources = readMarketplaceSources();
|
|
372
|
+
const existingIndex = sources.findIndex((item) => item.id === source.id || item.sourceUrl === source.sourceUrl);
|
|
373
|
+
if (existingIndex >= 0) {
|
|
374
|
+
sources[existingIndex] = { ...sources[existingIndex], ...source, addedAt: sources[existingIndex].addedAt || source.addedAt };
|
|
375
|
+
} else {
|
|
376
|
+
sources.unshift(source);
|
|
377
|
+
}
|
|
378
|
+
writeMarketplaceSources(sources.slice(0, 200));
|
|
379
|
+
res.json({ success: true, source, installedSources: readMarketplaceSources() });
|
|
380
|
+
} catch (err) {
|
|
381
|
+
res.status(400).json({ error: 'Failed to add source', details: err.message });
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
// DELETE /marketplace/sources/:id โ remove a global source by id.
|
|
386
|
+
router.delete('/marketplace/sources/:id', (req, res) => {
|
|
387
|
+
try {
|
|
388
|
+
const id = String(req.params.id || '');
|
|
389
|
+
const sources = readMarketplaceSources();
|
|
390
|
+
const next = sources.filter((source) => source.id !== id);
|
|
391
|
+
writeMarketplaceSources(next);
|
|
392
|
+
res.json({ success: true, installedSources: next });
|
|
393
|
+
} catch (err) {
|
|
394
|
+
res.status(400).json({ error: 'Failed to remove source', details: err.message });
|
|
395
|
+
}
|
|
396
|
+
});
|
|
27
397
|
|
|
28
398
|
// GET / โ List all installed plugins (includes server running status)
|
|
29
399
|
router.get('/', (req, res) => {
|
|
@@ -75,6 +75,8 @@ const CONTROL_COMMANDS = new Set([
|
|
|
75
75
|
'/workflow',
|
|
76
76
|
'/orchestrate',
|
|
77
77
|
'/cancel',
|
|
78
|
+
'/terminal',
|
|
79
|
+
'/detach',
|
|
78
80
|
'menu',
|
|
79
81
|
]);
|
|
80
82
|
|
|
@@ -509,16 +511,27 @@ function startActivityHeartbeat({ bot, chatId, activity }) {
|
|
|
509
511
|
}
|
|
510
512
|
|
|
511
513
|
function stateSummary(lang, state) {
|
|
512
|
-
|
|
514
|
+
const lines = [
|
|
513
515
|
`${t(lang, 'control.summary.project')}: ${state.selectedProjectName || t(lang, 'control.notSelected')}`,
|
|
514
516
|
`${t(lang, 'control.summary.provider')}: ${state.selectedProvider}${state.selectedModel ? ` / ${state.selectedModel}` : ''}`,
|
|
515
517
|
`${t(lang, 'control.summary.workflow')}: ${state.selectedWorkflowId || t(lang, 'control.notSelected')}`,
|
|
516
518
|
`${t(lang, 'control.summary.progress')}: ${state.progressMode}`,
|
|
517
|
-
]
|
|
519
|
+
];
|
|
520
|
+
if (state.activeTerminal) {
|
|
521
|
+
lines.push(`${t(lang, 'control.summary.terminal')}: ${state.activeTerminal.provider} / ${state.activeTerminal.projectLabel || state.activeTerminal.projectName || compact(state.activeTerminal.projectPath, 50)}`);
|
|
522
|
+
}
|
|
523
|
+
return lines.join('\n');
|
|
518
524
|
}
|
|
519
525
|
|
|
520
|
-
function
|
|
526
|
+
function terminalControlKeyboard(lang) {
|
|
521
527
|
return [
|
|
528
|
+
[button(t(lang, 'control.button.terminalRefresh'), 'terminal_status'), button(t(lang, 'control.button.detachTerminal'), 'detach_terminal')],
|
|
529
|
+
[button(t(lang, 'control.button.mainMenu'), 'menu')],
|
|
530
|
+
];
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
function mainMenuKeyboard(lang, state = null) {
|
|
534
|
+
const keyboard = [
|
|
522
535
|
[button(t(lang, 'control.button.projects'), 'projects'), button(t(lang, 'control.button.provider'), 'providers')],
|
|
523
536
|
[button(t(lang, 'control.button.models'), 'models'), button(t(lang, 'control.button.workflows'), 'workflows')],
|
|
524
537
|
[button(t(lang, 'control.button.runs'), 'runs'), button(t(lang, 'control.button.approvals'), 'approvals')],
|
|
@@ -527,6 +540,10 @@ function mainMenuKeyboard(lang) {
|
|
|
527
540
|
[button(t(lang, 'control.button.install'), 'install_menu'), button(t(lang, 'control.button.auth'), 'auth_menu')],
|
|
528
541
|
[button(t(lang, 'control.button.settings'), 'settings')],
|
|
529
542
|
];
|
|
543
|
+
if (state?.activeTerminal) {
|
|
544
|
+
keyboard.splice(1, 0, [button(t(lang, 'control.button.terminal'), 'terminal_status'), button(t(lang, 'control.button.detachTerminal'), 'detach_terminal')]);
|
|
545
|
+
}
|
|
546
|
+
return keyboard;
|
|
530
547
|
}
|
|
531
548
|
|
|
532
549
|
export async function showMainMenu({ bot, chatId, link, editMessageId, notice }) {
|
|
@@ -535,7 +552,7 @@ export async function showMainMenu({ bot, chatId, link, editMessageId, notice })
|
|
|
535
552
|
const prefix = notice ? `${notice}\n\n` : '';
|
|
536
553
|
await send(bot, chatId, `${prefix}${t(lang, 'control.menu')}\n\n${stateSummary(lang, state)}`, {
|
|
537
554
|
editMessageId,
|
|
538
|
-
reply_markup: { inline_keyboard: mainMenuKeyboard(lang) },
|
|
555
|
+
reply_markup: { inline_keyboard: mainMenuKeyboard(lang, state) },
|
|
539
556
|
});
|
|
540
557
|
}
|
|
541
558
|
|
|
@@ -549,8 +566,146 @@ async function showCommandPalette({ bot, chatId, link, editMessageId, unknown =
|
|
|
549
566
|
const prefix = unknown ? `${t(lang, 'control.unknownCommand')}\n\n` : '';
|
|
550
567
|
await send(bot, chatId, `${prefix}${t(lang, 'control.help')}\n\n${t(lang, 'control.examples')}`, {
|
|
551
568
|
editMessageId,
|
|
552
|
-
reply_markup: { inline_keyboard: mainMenuKeyboard(lang) },
|
|
569
|
+
reply_markup: { inline_keyboard: mainMenuKeyboard(lang, getState(link.user_id)) },
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
function getActiveTerminal(state) {
|
|
574
|
+
const terminal = state?.activeTerminal;
|
|
575
|
+
if (
|
|
576
|
+
!terminal ||
|
|
577
|
+
!PROVIDERS.includes(terminal.provider) ||
|
|
578
|
+
typeof terminal.projectPath !== 'string' ||
|
|
579
|
+
!terminal.projectPath.trim()
|
|
580
|
+
) {
|
|
581
|
+
return null;
|
|
582
|
+
}
|
|
583
|
+
return terminal;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
function terminalProjectLabel(terminal) {
|
|
587
|
+
return terminal?.projectLabel || terminal?.projectName || terminal?.projectPath || '-';
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
function terminalOutputUrl(terminal, maxChars = 3200) {
|
|
591
|
+
const params = new URLSearchParams({
|
|
592
|
+
provider: terminal.provider,
|
|
593
|
+
projectPath: terminal.projectPath,
|
|
594
|
+
maxChars: String(maxChars),
|
|
553
595
|
});
|
|
596
|
+
if (terminal.tabId) params.set('tabId', terminal.tabId);
|
|
597
|
+
if (terminal.sessionId) params.set('sessionId', terminal.sessionId);
|
|
598
|
+
return `/api/shell/sessions/provider-output?${params.toString()}`;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
function renderTerminalSnapshot(lang, terminal, data, { prefix = '' } = {}) {
|
|
602
|
+
const active = data?.active !== false;
|
|
603
|
+
const lifecycle = data?.terminalState || data?.lifecycleState || (active ? 'running' : 'not running');
|
|
604
|
+
const output = String(data?.output || '').trim();
|
|
605
|
+
const lines = [
|
|
606
|
+
prefix || t(lang, active ? 'control.terminalAttached' : 'control.terminalNotRunning'),
|
|
607
|
+
'',
|
|
608
|
+
`๐ค ${t(lang, 'control.activity.provider')}: ${terminal.provider}`,
|
|
609
|
+
`๐ ${t(lang, 'control.activity.project')}: ${compact(terminalProjectLabel(terminal), 90)}`,
|
|
610
|
+
`๐ ${t(lang, 'control.activity.status')}: ${lifecycle}`,
|
|
611
|
+
];
|
|
612
|
+
if (terminal.sessionId || data?.sessionId) {
|
|
613
|
+
lines.push(`๐งต ${t(lang, 'control.activity.session')}: ${terminal.sessionId || data.sessionId}`);
|
|
614
|
+
}
|
|
615
|
+
if (output) {
|
|
616
|
+
lines.push('', `๐ฌ ${t(lang, 'control.activity.output')}:`);
|
|
617
|
+
lines.push(truncate(output, 2400));
|
|
618
|
+
} else {
|
|
619
|
+
lines.push('', t(lang, 'control.terminalNoOutput'));
|
|
620
|
+
}
|
|
621
|
+
return truncate(lines.join('\n'), 3400);
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
async function showActiveTerminalStatus({ bot, chatId, link, editMessageId }) {
|
|
625
|
+
const lang = languageFor(link);
|
|
626
|
+
const state = getState(link.user_id);
|
|
627
|
+
const terminal = getActiveTerminal(state);
|
|
628
|
+
if (!terminal) {
|
|
629
|
+
await send(bot, chatId, t(lang, 'control.noActiveTerminal'), {
|
|
630
|
+
editMessageId,
|
|
631
|
+
reply_markup: { inline_keyboard: [[button(t(lang, 'control.button.mainMenu'), 'menu')]] },
|
|
632
|
+
});
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
try {
|
|
636
|
+
const data = await localApi(link.user_id, terminalOutputUrl(terminal), { timeoutMs: 12_000 });
|
|
637
|
+
await send(bot, chatId, renderTerminalSnapshot(lang, terminal, data), {
|
|
638
|
+
editMessageId,
|
|
639
|
+
parse_mode: undefined,
|
|
640
|
+
reply_markup: { inline_keyboard: terminalControlKeyboard(lang) },
|
|
641
|
+
});
|
|
642
|
+
} catch (error) {
|
|
643
|
+
await send(bot, chatId, t(lang, 'control.terminalStatusFailed', { error: error?.message || String(error) }), {
|
|
644
|
+
editMessageId,
|
|
645
|
+
reply_markup: { inline_keyboard: terminalControlKeyboard(lang) },
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
async function detachActiveTerminal({ bot, chatId, link, editMessageId }) {
|
|
651
|
+
const lang = languageFor(link);
|
|
652
|
+
updateTelegramControlState(link.user_id, { activeTerminal: null });
|
|
653
|
+
await send(bot, chatId, t(lang, 'control.terminalDetached'), {
|
|
654
|
+
editMessageId,
|
|
655
|
+
reply_markup: { inline_keyboard: [[button(t(lang, 'control.button.mainMenu'), 'menu')]] },
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
async function sendToActiveTerminal({ bot, chatId, link, text }) {
|
|
660
|
+
const lang = languageFor(link);
|
|
661
|
+
const state = getState(link.user_id);
|
|
662
|
+
const terminal = getActiveTerminal(state);
|
|
663
|
+
if (!terminal) return false;
|
|
664
|
+
if (state.remoteControlEnabled === false) {
|
|
665
|
+
await send(bot, chatId, t(lang, 'control.disabled'));
|
|
666
|
+
return true;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
const sent = await send(bot, chatId, t(lang, 'control.terminalSending', {
|
|
670
|
+
provider: terminal.provider,
|
|
671
|
+
project: terminalProjectLabel(terminal),
|
|
672
|
+
}), {
|
|
673
|
+
parse_mode: undefined,
|
|
674
|
+
reply_markup: { inline_keyboard: terminalControlKeyboard(lang) },
|
|
675
|
+
});
|
|
676
|
+
const editMessageId = sent?.message_id || sent?.message?.message_id || null;
|
|
677
|
+
|
|
678
|
+
try {
|
|
679
|
+
await localApi(link.user_id, '/api/shell/sessions/provider-input', {
|
|
680
|
+
method: 'POST',
|
|
681
|
+
timeoutMs: 15_000,
|
|
682
|
+
body: {
|
|
683
|
+
provider: terminal.provider,
|
|
684
|
+
projectPath: terminal.projectPath,
|
|
685
|
+
tabId: terminal.tabId,
|
|
686
|
+
sessionId: terminal.sessionId,
|
|
687
|
+
input: text,
|
|
688
|
+
submit: true,
|
|
689
|
+
},
|
|
690
|
+
});
|
|
691
|
+
await new Promise((resolve) => setTimeout(resolve, 700));
|
|
692
|
+
const data = await localApi(link.user_id, terminalOutputUrl(terminal), { timeoutMs: 12_000 });
|
|
693
|
+
await send(bot, chatId, renderTerminalSnapshot(lang, terminal, data, {
|
|
694
|
+
prefix: t(lang, 'control.terminalSent'),
|
|
695
|
+
}), {
|
|
696
|
+
editMessageId,
|
|
697
|
+
parse_mode: undefined,
|
|
698
|
+
reply_markup: { inline_keyboard: terminalControlKeyboard(lang) },
|
|
699
|
+
});
|
|
700
|
+
} catch (error) {
|
|
701
|
+
await send(bot, chatId, t(lang, 'control.terminalSendFailed', {
|
|
702
|
+
error: error?.message || String(error),
|
|
703
|
+
}), {
|
|
704
|
+
editMessageId,
|
|
705
|
+
reply_markup: { inline_keyboard: terminalControlKeyboard(lang) },
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
return true;
|
|
554
709
|
}
|
|
555
710
|
|
|
556
711
|
async function listProjects() {
|
|
@@ -1646,6 +1801,14 @@ async function handleCommand({ bot, chatId, link, text }) {
|
|
|
1646
1801
|
await showSessions({ bot, chatId, link });
|
|
1647
1802
|
return true;
|
|
1648
1803
|
}
|
|
1804
|
+
if (command === '/terminal') {
|
|
1805
|
+
await showActiveTerminalStatus({ bot, chatId, link });
|
|
1806
|
+
return true;
|
|
1807
|
+
}
|
|
1808
|
+
if (command === '/detach') {
|
|
1809
|
+
await detachActiveTerminal({ bot, chatId, link });
|
|
1810
|
+
return true;
|
|
1811
|
+
}
|
|
1649
1812
|
if (command === '/newchat') {
|
|
1650
1813
|
await startNewChat({ bot, chatId, link });
|
|
1651
1814
|
return true;
|
|
@@ -1736,6 +1899,9 @@ async function handleTelegramControlMessageInternal({ bot, msg, link }) {
|
|
|
1736
1899
|
if (await handleCommand({ bot, chatId, link, text })) return true;
|
|
1737
1900
|
|
|
1738
1901
|
const state = getState(link.user_id);
|
|
1902
|
+
if (getActiveTerminal(state)) {
|
|
1903
|
+
return sendToActiveTerminal({ bot, chatId, link, text });
|
|
1904
|
+
}
|
|
1739
1905
|
if (state.routerEnabled === false) return false;
|
|
1740
1906
|
if (!state.remoteControlEnabled) {
|
|
1741
1907
|
await send(bot, chatId, t(languageFor(link), 'control.disabled'));
|
|
@@ -1836,6 +2002,8 @@ async function handleTelegramControlCallbackInternal({ bot, query, link }) {
|
|
|
1836
2002
|
if (action === 'control_room') return showControlRoom({ bot, chatId, link, editMessageId });
|
|
1837
2003
|
if (action === 'webhooks') return showWebhookMenu({ bot, chatId, link, editMessageId });
|
|
1838
2004
|
if (action === 'sessions') return showSessions({ bot, chatId, link, editMessageId });
|
|
2005
|
+
if (action === 'terminal_status') return showActiveTerminalStatus({ bot, chatId, link, editMessageId });
|
|
2006
|
+
if (action === 'detach_terminal') return detachActiveTerminal({ bot, chatId, link, editMessageId });
|
|
1839
2007
|
if (action === 'new_chat') return startNewChat({ bot, chatId, link, editMessageId });
|
|
1840
2008
|
if (action === 'install_menu') return showInstallMenu({ bot, chatId, link, editMessageId });
|
|
1841
2009
|
if (action === 'auth_menu') return showAuthMenu({ bot, chatId, link, editMessageId });
|