opc-agent 4.0.35 → 4.0.37
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 +31 -21
- package/package.json +1 -1
- package/serve-studio.js +13 -0
- package/src/core/runtime.ts +0 -14
- package/src/studio-ui/index.html +31 -21
- 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)
|
|
@@ -509,31 +509,41 @@
|
|
|
509
509
|
<div class="label">群组名称</div>
|
|
510
510
|
<input class="input" id="group-name" placeholder="例如:产品讨论组">
|
|
511
511
|
<div class="label" style="margin-top:16px;">协作模式</div>
|
|
512
|
-
<div class="card-grid" style="grid-template-columns: repeat(auto-fill, minmax(
|
|
513
|
-
<div class="card pattern-card active" onclick="selectPattern('debate')" id="pat-debate" style="padding:
|
|
514
|
-
<div style="font-size:
|
|
515
|
-
<div style="font-size:
|
|
516
|
-
<div style="font-size:
|
|
512
|
+
<div class="card-grid" style="grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap:16px; margin-bottom:16px;">
|
|
513
|
+
<div class="card pattern-card active" onclick="selectPattern('debate')" id="pat-debate" style="padding:20px;cursor:pointer;">
|
|
514
|
+
<div style="font-size:28px;margin-bottom:8px;">⚔️</div>
|
|
515
|
+
<div style="font-size:15px;font-weight:700;margin-bottom:6px;">Debate 辩论模式</div>
|
|
516
|
+
<div style="font-size:13px;color:var(--text-muted);line-height:1.5;margin-bottom:10px;">多个 Agent 围绕一个话题正反方辩论,最终由裁判 Agent 综合各方观点给出结论。</div>
|
|
517
|
+
<div style="font-size:12px;color:var(--accent);">💡 适合:决策分析、方案对比、风险评估</div>
|
|
518
|
+
<div style="font-size:12px;color:var(--green);margin-top:4px;">📤 产出:多角度分析报告 + 最终建议</div>
|
|
517
519
|
</div>
|
|
518
|
-
<div class="card pattern-card" onclick="selectPattern('voting')" id="pat-voting" style="padding:
|
|
519
|
-
<div style="font-size:
|
|
520
|
-
<div style="font-size:
|
|
521
|
-
<div style="font-size:
|
|
520
|
+
<div class="card pattern-card" onclick="selectPattern('voting')" id="pat-voting" style="padding:20px;cursor:pointer;">
|
|
521
|
+
<div style="font-size:28px;margin-bottom:8px;">🗳️</div>
|
|
522
|
+
<div style="font-size:15px;font-weight:700;margin-bottom:6px;">Voting 投票模式</div>
|
|
523
|
+
<div style="font-size:13px;color:var(--text-muted);line-height:1.5;margin-bottom:10px;">每个 Agent 独立给出判断和投票,汇总统计后输出多数意见和少数意见。</div>
|
|
524
|
+
<div style="font-size:12px;color:var(--accent);">💡 适合:质量评审、内容审核、多人打分</div>
|
|
525
|
+
<div style="font-size:12px;color:var(--green);margin-top:4px;">📤 产出:投票结果 + 各方理由汇总</div>
|
|
522
526
|
</div>
|
|
523
|
-
<div class="card pattern-card" onclick="selectPattern('pipeline')" id="pat-pipeline" style="padding:
|
|
524
|
-
<div style="font-size:
|
|
525
|
-
<div style="font-size:
|
|
526
|
-
<div style="font-size:
|
|
527
|
+
<div class="card pattern-card" onclick="selectPattern('pipeline')" id="pat-pipeline" style="padding:20px;cursor:pointer;">
|
|
528
|
+
<div style="font-size:28px;margin-bottom:8px;">🔗</div>
|
|
529
|
+
<div style="font-size:15px;font-weight:700;margin-bottom:6px;">Pipeline 流水线模式</div>
|
|
530
|
+
<div style="font-size:13px;color:var(--text-muted);line-height:1.5;margin-bottom:10px;">Agent A 的输出自动传给 Agent B 作为输入,逐步处理和加工,像工厂流水线。</div>
|
|
531
|
+
<div style="font-size:12px;color:var(--accent);">💡 适合:内容创作、数据处理、翻译校对</div>
|
|
532
|
+
<div style="font-size:12px;color:var(--green);margin-top:4px;">📤 产出:经过多轮加工的最终成果</div>
|
|
527
533
|
</div>
|
|
528
|
-
<div class="card pattern-card" onclick="selectPattern('hierarchy')" id="pat-hierarchy" style="padding:
|
|
529
|
-
<div style="font-size:
|
|
530
|
-
<div style="font-size:
|
|
531
|
-
<div style="font-size:
|
|
534
|
+
<div class="card pattern-card" onclick="selectPattern('hierarchy')" id="pat-hierarchy" style="padding:20px;cursor:pointer;">
|
|
535
|
+
<div style="font-size:28px;margin-bottom:8px;">🏛️</div>
|
|
536
|
+
<div style="font-size:15px;font-weight:700;margin-bottom:6px;">Hierarchy 层级模式</div>
|
|
537
|
+
<div style="font-size:13px;color:var(--text-muted);line-height:1.5;margin-bottom:10px;">一个主管 Agent 拆解任务分配给下属 Agent,收集结果后汇总报告。</div>
|
|
538
|
+
<div style="font-size:12px;color:var(--accent);">💡 适合:项目管理、调研收集、并行执行</div>
|
|
539
|
+
<div style="font-size:12px;color:var(--green);margin-top:4px;">📤 产出:汇总报告 + 各子任务结果</div>
|
|
532
540
|
</div>
|
|
533
|
-
<div class="card pattern-card" onclick="selectPattern('shared-memory')" id="pat-shared-memory" style="padding:
|
|
534
|
-
<div style="font-size:
|
|
535
|
-
<div style="font-size:
|
|
536
|
-
<div style="font-size:
|
|
541
|
+
<div class="card pattern-card" onclick="selectPattern('shared-memory')" id="pat-shared-memory" style="padding:20px;cursor:pointer;">
|
|
542
|
+
<div style="font-size:28px;margin-bottom:8px;">🧠</div>
|
|
543
|
+
<div style="font-size:15px;font-weight:700;margin-bottom:6px;">Shared Memory 共享记忆模式</div>
|
|
544
|
+
<div style="font-size:13px;color:var(--text-muted);line-height:1.5;margin-bottom:10px;">所有 Agent 共享一个知识空间,各自贡献信息,互相读取和补充,持续积累。</div>
|
|
545
|
+
<div style="font-size:12px;color:var(--accent);">💡 适合:知识构建、团队学习、长期项目</div>
|
|
546
|
+
<div style="font-size:12px;color:var(--green);margin-top:4px;">📤 产出:持续进化的共享知识库</div>
|
|
537
547
|
</div>
|
|
538
548
|
</div>
|
|
539
549
|
<div class="label">选择 Agent 成员</div>
|
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
|
@@ -509,31 +509,41 @@
|
|
|
509
509
|
<div class="label">群组名称</div>
|
|
510
510
|
<input class="input" id="group-name" placeholder="例如:产品讨论组">
|
|
511
511
|
<div class="label" style="margin-top:16px;">协作模式</div>
|
|
512
|
-
<div class="card-grid" style="grid-template-columns: repeat(auto-fill, minmax(
|
|
513
|
-
<div class="card pattern-card active" onclick="selectPattern('debate')" id="pat-debate" style="padding:
|
|
514
|
-
<div style="font-size:
|
|
515
|
-
<div style="font-size:
|
|
516
|
-
<div style="font-size:
|
|
512
|
+
<div class="card-grid" style="grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap:16px; margin-bottom:16px;">
|
|
513
|
+
<div class="card pattern-card active" onclick="selectPattern('debate')" id="pat-debate" style="padding:20px;cursor:pointer;">
|
|
514
|
+
<div style="font-size:28px;margin-bottom:8px;">⚔️</div>
|
|
515
|
+
<div style="font-size:15px;font-weight:700;margin-bottom:6px;">Debate 辩论模式</div>
|
|
516
|
+
<div style="font-size:13px;color:var(--text-muted);line-height:1.5;margin-bottom:10px;">多个 Agent 围绕一个话题正反方辩论,最终由裁判 Agent 综合各方观点给出结论。</div>
|
|
517
|
+
<div style="font-size:12px;color:var(--accent);">💡 适合:决策分析、方案对比、风险评估</div>
|
|
518
|
+
<div style="font-size:12px;color:var(--green);margin-top:4px;">📤 产出:多角度分析报告 + 最终建议</div>
|
|
517
519
|
</div>
|
|
518
|
-
<div class="card pattern-card" onclick="selectPattern('voting')" id="pat-voting" style="padding:
|
|
519
|
-
<div style="font-size:
|
|
520
|
-
<div style="font-size:
|
|
521
|
-
<div style="font-size:
|
|
520
|
+
<div class="card pattern-card" onclick="selectPattern('voting')" id="pat-voting" style="padding:20px;cursor:pointer;">
|
|
521
|
+
<div style="font-size:28px;margin-bottom:8px;">🗳️</div>
|
|
522
|
+
<div style="font-size:15px;font-weight:700;margin-bottom:6px;">Voting 投票模式</div>
|
|
523
|
+
<div style="font-size:13px;color:var(--text-muted);line-height:1.5;margin-bottom:10px;">每个 Agent 独立给出判断和投票,汇总统计后输出多数意见和少数意见。</div>
|
|
524
|
+
<div style="font-size:12px;color:var(--accent);">💡 适合:质量评审、内容审核、多人打分</div>
|
|
525
|
+
<div style="font-size:12px;color:var(--green);margin-top:4px;">📤 产出:投票结果 + 各方理由汇总</div>
|
|
522
526
|
</div>
|
|
523
|
-
<div class="card pattern-card" onclick="selectPattern('pipeline')" id="pat-pipeline" style="padding:
|
|
524
|
-
<div style="font-size:
|
|
525
|
-
<div style="font-size:
|
|
526
|
-
<div style="font-size:
|
|
527
|
+
<div class="card pattern-card" onclick="selectPattern('pipeline')" id="pat-pipeline" style="padding:20px;cursor:pointer;">
|
|
528
|
+
<div style="font-size:28px;margin-bottom:8px;">🔗</div>
|
|
529
|
+
<div style="font-size:15px;font-weight:700;margin-bottom:6px;">Pipeline 流水线模式</div>
|
|
530
|
+
<div style="font-size:13px;color:var(--text-muted);line-height:1.5;margin-bottom:10px;">Agent A 的输出自动传给 Agent B 作为输入,逐步处理和加工,像工厂流水线。</div>
|
|
531
|
+
<div style="font-size:12px;color:var(--accent);">💡 适合:内容创作、数据处理、翻译校对</div>
|
|
532
|
+
<div style="font-size:12px;color:var(--green);margin-top:4px;">📤 产出:经过多轮加工的最终成果</div>
|
|
527
533
|
</div>
|
|
528
|
-
<div class="card pattern-card" onclick="selectPattern('hierarchy')" id="pat-hierarchy" style="padding:
|
|
529
|
-
<div style="font-size:
|
|
530
|
-
<div style="font-size:
|
|
531
|
-
<div style="font-size:
|
|
534
|
+
<div class="card pattern-card" onclick="selectPattern('hierarchy')" id="pat-hierarchy" style="padding:20px;cursor:pointer;">
|
|
535
|
+
<div style="font-size:28px;margin-bottom:8px;">🏛️</div>
|
|
536
|
+
<div style="font-size:15px;font-weight:700;margin-bottom:6px;">Hierarchy 层级模式</div>
|
|
537
|
+
<div style="font-size:13px;color:var(--text-muted);line-height:1.5;margin-bottom:10px;">一个主管 Agent 拆解任务分配给下属 Agent,收集结果后汇总报告。</div>
|
|
538
|
+
<div style="font-size:12px;color:var(--accent);">💡 适合:项目管理、调研收集、并行执行</div>
|
|
539
|
+
<div style="font-size:12px;color:var(--green);margin-top:4px;">📤 产出:汇总报告 + 各子任务结果</div>
|
|
532
540
|
</div>
|
|
533
|
-
<div class="card pattern-card" onclick="selectPattern('shared-memory')" id="pat-shared-memory" style="padding:
|
|
534
|
-
<div style="font-size:
|
|
535
|
-
<div style="font-size:
|
|
536
|
-
<div style="font-size:
|
|
541
|
+
<div class="card pattern-card" onclick="selectPattern('shared-memory')" id="pat-shared-memory" style="padding:20px;cursor:pointer;">
|
|
542
|
+
<div style="font-size:28px;margin-bottom:8px;">🧠</div>
|
|
543
|
+
<div style="font-size:15px;font-weight:700;margin-bottom:6px;">Shared Memory 共享记忆模式</div>
|
|
544
|
+
<div style="font-size:13px;color:var(--text-muted);line-height:1.5;margin-bottom:10px;">所有 Agent 共享一个知识空间,各自贡献信息,互相读取和补充,持续积累。</div>
|
|
545
|
+
<div style="font-size:12px;color:var(--accent);">💡 适合:知识构建、团队学习、长期项目</div>
|
|
546
|
+
<div style="font-size:12px;color:var(--green);margin-top:4px;">📤 产出:持续进化的共享知识库</div>
|
|
537
547
|
</div>
|
|
538
548
|
</div>
|
|
539
549
|
<div class="label">选择 Agent 成员</div>
|
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); });
|