opc-agent 4.0.36 → 4.0.38
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/core/runtime.js +0 -14
- package/dist/studio-ui/index.html +3 -3
- package/package.json +1 -1
- package/serve-studio.js +13 -0
- package/src/core/runtime.ts +0 -14
- package/src/studio-ui/index.html +3 -3
- package/srv-err.txt +0 -0
- package/srv-out.txt +1 -0
- package/test-studio3.js +75 -0
- package/test-studio4.js +41 -0
- package/tmp-sc.js +1716 -0
package/dist/core/runtime.js
CHANGED
|
@@ -342,20 +342,6 @@ class AgentRuntime {
|
|
|
342
342
|
this.logger.info('Scheduler started');
|
|
343
343
|
}
|
|
344
344
|
this.logger.info('Agent started');
|
|
345
|
-
// Auto-start Studio UI
|
|
346
|
-
try {
|
|
347
|
-
const { StudioServer } = require('../studio/server');
|
|
348
|
-
const studioPort = 4000;
|
|
349
|
-
const studio = new StudioServer({ port: studioPort, agentDir: process.cwd() });
|
|
350
|
-
await studio.start();
|
|
351
|
-
this.logger.info(`Studio UI ready → http://localhost:${studioPort}`);
|
|
352
|
-
console.log(` Studio: http://localhost:${studioPort}`);
|
|
353
|
-
}
|
|
354
|
-
catch (e) {
|
|
355
|
-
const msg = e?.message || String(e);
|
|
356
|
-
this.logger.warn('Studio UI failed to start: ' + msg);
|
|
357
|
-
console.log(` Studio: ⚠️ failed - ${msg}`);
|
|
358
|
-
}
|
|
359
345
|
}
|
|
360
346
|
async stop() {
|
|
361
347
|
if (!this.agent)
|
|
@@ -299,13 +299,13 @@
|
|
|
299
299
|
}
|
|
300
300
|
|
|
301
301
|
/* Sidebar restructure */
|
|
302
|
-
.sidebar-section-title { font-size:
|
|
302
|
+
.sidebar-section-title { font-size: 13px; letter-spacing: 0.5px; color: var(--text-dim); margin: 20px 16px 8px; text-transform: uppercase; font-weight: 600; }
|
|
303
303
|
.sidebar-divider { height: 1px; background: var(--border); margin: 8px 12px; }
|
|
304
304
|
.pattern-card.active { border-color: var(--accent); box-shadow: var(--glow-sm); }
|
|
305
305
|
.agent-list-container { overflow-y: auto; flex: 1; min-height: 0; }
|
|
306
306
|
.agent-list-item {
|
|
307
307
|
display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 12px;
|
|
308
|
-
cursor: pointer; color: var(--text-muted); transition: all 0.2s ease; font-size:
|
|
308
|
+
cursor: pointer; color: var(--text-muted); transition: all 0.2s ease; font-size: 15px; margin-bottom: 2px; position: relative;
|
|
309
309
|
}
|
|
310
310
|
.agent-list-item:hover { background: var(--bg-hover); color: var(--text); transform: translateX(4px); }
|
|
311
311
|
.agent-list-item.active { background: var(--accent-light); color: #fff; font-weight: 600; box-shadow: var(--glow-sm); border: 1px solid var(--border); }
|
|
@@ -1125,7 +1125,7 @@
|
|
|
1125
1125
|
|
|
1126
1126
|
// === Init ===
|
|
1127
1127
|
async function init() {
|
|
1128
|
-
await Promise.all([loadTemplates(), loadAgents()]);
|
|
1128
|
+
await Promise.all([loadTemplates(), loadAgents(), loadSidebarAgents()]);
|
|
1129
1129
|
loadSidebarGroups();
|
|
1130
1130
|
handleRoute();
|
|
1131
1131
|
window.addEventListener('popstate', handleRoute);
|
package/package.json
CHANGED
package/serve-studio.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const http = require('http');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const html = fs.readFileSync(__dirname + '/dist/studio-ui/index.html', 'utf-8');
|
|
4
|
+
const srv = http.createServer((req, res) => {
|
|
5
|
+
if (req.url === '/api/agents') {
|
|
6
|
+
res.end(JSON.stringify({agents:[{id:'a1',name:'客服小助手',templateIcon:'🤖',status:'online'},{id:'a2',name:'销售顾问',templateIcon:'💼',status:'offline'}]}));
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (req.url === '/api/templates') { res.end(JSON.stringify([])); return; }
|
|
10
|
+
res.writeHead(200, {'Content-Type':'text/html; charset=utf-8'});
|
|
11
|
+
res.end(html);
|
|
12
|
+
});
|
|
13
|
+
srv.listen(4449, '0.0.0.0', () => console.log('Studio test server ready: http://localhost:4449'));
|
package/src/core/runtime.ts
CHANGED
|
@@ -320,20 +320,6 @@ export class AgentRuntime {
|
|
|
320
320
|
this.logger.info('Scheduler started');
|
|
321
321
|
}
|
|
322
322
|
this.logger.info('Agent started');
|
|
323
|
-
|
|
324
|
-
// Auto-start Studio UI
|
|
325
|
-
try {
|
|
326
|
-
const { StudioServer } = require('../studio/server');
|
|
327
|
-
const studioPort = 4000;
|
|
328
|
-
const studio = new StudioServer({ port: studioPort, agentDir: process.cwd() });
|
|
329
|
-
await studio.start();
|
|
330
|
-
this.logger.info(`Studio UI ready → http://localhost:${studioPort}`);
|
|
331
|
-
console.log(` Studio: http://localhost:${studioPort}`);
|
|
332
|
-
} catch (e: any) {
|
|
333
|
-
const msg = e?.message || String(e);
|
|
334
|
-
this.logger.warn('Studio UI failed to start: ' + msg);
|
|
335
|
-
console.log(` Studio: ⚠️ failed - ${msg}`);
|
|
336
|
-
}
|
|
337
323
|
}
|
|
338
324
|
|
|
339
325
|
async stop(): Promise<void> {
|
package/src/studio-ui/index.html
CHANGED
|
@@ -299,13 +299,13 @@
|
|
|
299
299
|
}
|
|
300
300
|
|
|
301
301
|
/* Sidebar restructure */
|
|
302
|
-
.sidebar-section-title { font-size:
|
|
302
|
+
.sidebar-section-title { font-size: 13px; letter-spacing: 0.5px; color: var(--text-dim); margin: 20px 16px 8px; text-transform: uppercase; font-weight: 600; }
|
|
303
303
|
.sidebar-divider { height: 1px; background: var(--border); margin: 8px 12px; }
|
|
304
304
|
.pattern-card.active { border-color: var(--accent); box-shadow: var(--glow-sm); }
|
|
305
305
|
.agent-list-container { overflow-y: auto; flex: 1; min-height: 0; }
|
|
306
306
|
.agent-list-item {
|
|
307
307
|
display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 12px;
|
|
308
|
-
cursor: pointer; color: var(--text-muted); transition: all 0.2s ease; font-size:
|
|
308
|
+
cursor: pointer; color: var(--text-muted); transition: all 0.2s ease; font-size: 15px; margin-bottom: 2px; position: relative;
|
|
309
309
|
}
|
|
310
310
|
.agent-list-item:hover { background: var(--bg-hover); color: var(--text); transform: translateX(4px); }
|
|
311
311
|
.agent-list-item.active { background: var(--accent-light); color: #fff; font-weight: 600; box-shadow: var(--glow-sm); border: 1px solid var(--border); }
|
|
@@ -1125,7 +1125,7 @@
|
|
|
1125
1125
|
|
|
1126
1126
|
// === Init ===
|
|
1127
1127
|
async function init() {
|
|
1128
|
-
await Promise.all([loadTemplates(), loadAgents()]);
|
|
1128
|
+
await Promise.all([loadTemplates(), loadAgents(), loadSidebarAgents()]);
|
|
1129
1129
|
loadSidebarGroups();
|
|
1130
1130
|
handleRoute();
|
|
1131
1131
|
window.addEventListener('popstate', handleRoute);
|
package/srv-err.txt
ADDED
|
File without changes
|
package/srv-out.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Studio test server ready: http://localhost:4449
|
package/test-studio3.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const puppeteer = require('puppeteer-core');
|
|
2
|
+
(async () => {
|
|
3
|
+
const browser = await puppeteer.launch({executablePath: 'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe', headless: true, args:['--no-sandbox']});
|
|
4
|
+
const page = await browser.newPage();
|
|
5
|
+
const errors = [];
|
|
6
|
+
page.on('pageerror', e => errors.push(e.message));
|
|
7
|
+
page.on('console', m => { if(m.type()==='error') errors.push(m.text()); });
|
|
8
|
+
await page.goto('http://localhost:4449', {waitUntil:'networkidle0', timeout:10000});
|
|
9
|
+
|
|
10
|
+
// Check sidebar structure
|
|
11
|
+
const sidebar = await page.evaluate(() => {
|
|
12
|
+
const items = document.querySelectorAll('.sidebar .nav-item, .sidebar .agent-list-item, .sidebar .sidebar-section-title');
|
|
13
|
+
return Array.from(items).map(el => el.textContent.trim().substring(0, 40));
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// Check navigate
|
|
17
|
+
const navType = await page.evaluate(() => typeof navigate);
|
|
18
|
+
|
|
19
|
+
// Try global-models
|
|
20
|
+
const modelsResult = await page.evaluate(() => {
|
|
21
|
+
navigate('global-models');
|
|
22
|
+
const pages = document.querySelectorAll('.page');
|
|
23
|
+
for (const p of pages) {
|
|
24
|
+
if (p.style.display === 'block') return p.id;
|
|
25
|
+
}
|
|
26
|
+
return 'none-visible';
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Try create-group
|
|
30
|
+
const groupResult = await page.evaluate(() => {
|
|
31
|
+
navigate('create-group');
|
|
32
|
+
const pages = document.querySelectorAll('.page');
|
|
33
|
+
for (const p of pages) {
|
|
34
|
+
if (p.style.display === 'block') return p.id;
|
|
35
|
+
}
|
|
36
|
+
return 'none-visible';
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Check agent list
|
|
40
|
+
const agentList = await page.evaluate(() => {
|
|
41
|
+
const container = document.getElementById('sidebar-agent-list');
|
|
42
|
+
return container ? container.children.length + ' items' : 'NOT FOUND';
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// Check groups list
|
|
46
|
+
const groupsList = await page.evaluate(() => {
|
|
47
|
+
const container = document.getElementById('groups-list');
|
|
48
|
+
return container ? container.innerHTML.substring(0, 100) : 'NOT FOUND';
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Try navigateToAgent
|
|
52
|
+
const agentDetail = await page.evaluate(() => {
|
|
53
|
+
if (typeof navigateToAgent === 'function') {
|
|
54
|
+
navigateToAgent('agent-1');
|
|
55
|
+
const pages = document.querySelectorAll('.page');
|
|
56
|
+
for (const p of pages) {
|
|
57
|
+
if (p.style.display === 'block') return p.id;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return typeof navigateToAgent;
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
console.log('=== Studio Test Results ===');
|
|
64
|
+
console.log('JS Errors:', errors.length ? errors.join('; ') : 'NONE');
|
|
65
|
+
console.log('Sidebar items:', JSON.stringify(sidebar, null, 2));
|
|
66
|
+
console.log('navigate type:', navType);
|
|
67
|
+
console.log('global-models:', modelsResult);
|
|
68
|
+
console.log('create-group:', groupResult);
|
|
69
|
+
console.log('agent list:', agentList);
|
|
70
|
+
console.log('groups list:', groupsList);
|
|
71
|
+
console.log('agent detail:', agentDetail);
|
|
72
|
+
|
|
73
|
+
await browser.close();
|
|
74
|
+
process.exit(0);
|
|
75
|
+
})().catch(e => { console.error('FAIL:', e.message); process.exit(1); });
|
package/test-studio4.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const puppeteer = require('puppeteer-core');
|
|
2
|
+
(async () => {
|
|
3
|
+
const browser = await puppeteer.launch({executablePath: 'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe', headless: true, args:['--no-sandbox']});
|
|
4
|
+
const page = await browser.newPage();
|
|
5
|
+
const errors = [];
|
|
6
|
+
page.on('pageerror', e => errors.push(e.message));
|
|
7
|
+
await page.goto('http://localhost:4449', {waitUntil:'networkidle0', timeout:10000});
|
|
8
|
+
|
|
9
|
+
const result = await page.evaluate(() => {
|
|
10
|
+
// Test create-group
|
|
11
|
+
navigate('create-group');
|
|
12
|
+
const el = document.getElementById('page-create-group');
|
|
13
|
+
if (!el) return 'page-create-group element NOT FOUND';
|
|
14
|
+
const hasActive = el.classList.contains('active');
|
|
15
|
+
const computedDisplay = window.getComputedStyle(el).display;
|
|
16
|
+
return `found=true, active=${hasActive}, display=${computedDisplay}`;
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const result2 = await page.evaluate(() => {
|
|
20
|
+
navigate('global-models');
|
|
21
|
+
const el = document.getElementById('page-settings');
|
|
22
|
+
if (!el) return 'page-settings NOT FOUND';
|
|
23
|
+
return `active=${el.classList.contains('active')}, display=${window.getComputedStyle(el).display}`;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const result3 = await page.evaluate(() => {
|
|
27
|
+
// Check agent detail
|
|
28
|
+
navigateToAgent('a1');
|
|
29
|
+
const el = document.getElementById('page-agent-detail');
|
|
30
|
+
if (!el) return 'page-agent-detail NOT FOUND';
|
|
31
|
+
return `active=${el.classList.contains('active')}, display=${window.getComputedStyle(el).display}`;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
console.log('JS errors:', errors.length ? errors : 'NONE');
|
|
35
|
+
console.log('create-group:', result);
|
|
36
|
+
console.log('global-models:', result2);
|
|
37
|
+
console.log('agent-detail:', result3);
|
|
38
|
+
|
|
39
|
+
await browser.close();
|
|
40
|
+
process.exit(0);
|
|
41
|
+
})().catch(e => { console.error('FAIL:', e.message); process.exit(1); });
|