opc-agent 4.0.34 → 4.0.36

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.
@@ -301,6 +301,7 @@
301
301
  /* Sidebar restructure */
302
302
  .sidebar-section-title { font-size: 11px; letter-spacing: 1px; color: var(--text-dim); margin: 20px 12px 8px; text-transform: uppercase; font-weight: 600; }
303
303
  .sidebar-divider { height: 1px; background: var(--border); margin: 8px 12px; }
304
+ .pattern-card.active { border-color: var(--accent); box-shadow: var(--glow-sm); }
304
305
  .agent-list-container { overflow-y: auto; flex: 1; min-height: 0; }
305
306
  .agent-list-item {
306
307
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 12px;
@@ -361,7 +362,17 @@
361
362
  <div style="padding: 12px 16px; color: var(--text-dim); font-size: 13px;">加载中...</div>
362
363
  </div>
363
364
 
364
- <!-- Section 2: Create -->
365
+ <!-- Section 2: Collaboration Groups -->
366
+ <div class="sidebar-divider"></div>
367
+ <div class="sidebar-section-title">👥 协作群组</div>
368
+ <div class="agent-list-container" id="groups-list" style="max-height:120px;">
369
+ <!-- dynamically loaded -->
370
+ </div>
371
+ <div class="nav-item" data-page="create-group" onclick="navigate('create-group')">
372
+ <span class="icon">➕</span> 新建群组
373
+ </div>
374
+
375
+ <!-- Section 3: Create Agent -->
365
376
  <div class="sidebar-divider"></div>
366
377
  <div class="nav-item" data-page="create" onclick="navigate('create')">
367
378
  <span class="icon">➕</span> 新建 Agent
@@ -490,6 +501,59 @@
490
501
  </div>
491
502
 
492
503
  <!-- Templates Page -->
504
+ <!-- Create Group Page -->
505
+ <div class="page" id="page-create-group">
506
+ <h1 class="page-title">新建协作群组</h1>
507
+ <p class="page-subtitle">选择协作模式,拉入 Agent,开始多角色协作</p>
508
+ <div class="card" style="max-width:600px;">
509
+ <div class="label">群组名称</div>
510
+ <input class="input" id="group-name" placeholder="例如:产品讨论组">
511
+ <div class="label" style="margin-top:16px;">协作模式</div>
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>
519
+ </div>
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>
526
+ </div>
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>
533
+ </div>
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>
540
+ </div>
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>
547
+ </div>
548
+ </div>
549
+ <div class="label">选择 Agent 成员</div>
550
+ <div id="group-agent-select" style="margin-bottom:16px;">
551
+ <p style="color:var(--text-muted);font-size:13px;">请先创建 Agent,再拉入群组</p>
552
+ </div>
553
+ <button class="btn btn-primary" onclick="createGroup()">✨ 创建群组</button>
554
+ </div>
555
+ </div>
556
+
493
557
  <div class="page" id="page-templates">
494
558
  <h1 class="page-title">Template Market</h1>
495
559
  <p class="page-subtitle">Browse 100+ ready-to-use agent templates across 19 industries</p>
@@ -1062,6 +1126,7 @@
1062
1126
  // === Init ===
1063
1127
  async function init() {
1064
1128
  await Promise.all([loadTemplates(), loadAgents()]);
1129
+ loadSidebarGroups();
1065
1130
  handleRoute();
1066
1131
  window.addEventListener('popstate', handleRoute);
1067
1132
  checkFirstRun();
@@ -1146,6 +1211,42 @@
1146
1211
  }
1147
1212
  }
1148
1213
 
1214
+ // --- Collaboration Groups ---
1215
+ let selectedPattern = 'debate';
1216
+ function selectPattern(pat) {
1217
+ selectedPattern = pat;
1218
+ document.querySelectorAll('.pattern-card').forEach(c => c.classList.remove('active'));
1219
+ const el = document.getElementById('pat-' + pat);
1220
+ if (el) el.classList.add('active');
1221
+ }
1222
+ async function loadGroupAgentSelect() {
1223
+ try {
1224
+ const res = await fetch('/api/agents');
1225
+ const data = await res.json();
1226
+ const agents = data.agents || data || [];
1227
+ const container = document.getElementById('group-agent-select');
1228
+ if (!agents.length) {
1229
+ container.innerHTML = '<p style="color:var(--text-muted);font-size:13px;">请先创建 Agent,再拉入群组</p>';
1230
+ return;
1231
+ }
1232
+ container.innerHTML = agents.map(a => `<label style="display:flex;align-items:center;gap:8px;padding:6px 0;cursor:pointer;"><input type="checkbox" class="group-agent-cb" value="${a.id}"> <span>${a.templateIcon || a.icon || '🤖'}</span> <span style="font-size:14px;">${a.name}</span></label>`).join('');
1233
+ } catch(e) { console.error('loadGroupAgentSelect error', e); }
1234
+ }
1235
+ async function createGroup() {
1236
+ const name = document.getElementById('group-name').value.trim();
1237
+ if (!name) { alert('请输入群组名称'); return; }
1238
+ const members = [...document.querySelectorAll('.group-agent-cb:checked')].map(cb => cb.value);
1239
+ if (members.length < 2) { alert('至少选择 2 个 Agent'); return; }
1240
+ // TODO: POST to /api/groups
1241
+ alert('群组 "' + name + '" 创建成功!模式: ' + selectedPattern + ', 成员: ' + members.length + ' 个 Agent');
1242
+ navigate('dashboard');
1243
+ }
1244
+ async function loadSidebarGroups() {
1245
+ // TODO: fetch /api/groups and render
1246
+ const container = document.getElementById('groups-list');
1247
+ if (container) container.innerHTML = '<div style="padding:6px 16px;color:var(--text-dim);font-size:12px;">暂无群组</div>';
1248
+ }
1249
+
1149
1250
  function navigateToAgent(agentId) {
1150
1251
  selectedAgentId = agentId;
1151
1252
  // Update sidebar active state
@@ -1261,6 +1362,7 @@
1261
1362
  if (page === 'global-models') { currentSettingsTab='models'; showSettings('models'); showPage('settings'); return; }
1262
1363
  if (page === 'global-memory') { currentSettingsTab='memory'; showSettings('memory'); showPage('settings'); return; }
1263
1364
  if (page === 'global-templates') { navigate('templates'); return; }
1365
+ if (page === 'create-group') { loadGroupAgentSelect(); }
1264
1366
  if (page === 'schedules') { loadSchedules(); }
1265
1367
  if (page === 'skills') { loadSkillsMarketplace(); }
1266
1368
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opc-agent",
3
- "version": "4.0.34",
3
+ "version": "4.0.36",
4
4
  "description": "Open Agent Framework — Build, test, and run AI Agents for business workstations",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -301,6 +301,7 @@
301
301
  /* Sidebar restructure */
302
302
  .sidebar-section-title { font-size: 11px; letter-spacing: 1px; color: var(--text-dim); margin: 20px 12px 8px; text-transform: uppercase; font-weight: 600; }
303
303
  .sidebar-divider { height: 1px; background: var(--border); margin: 8px 12px; }
304
+ .pattern-card.active { border-color: var(--accent); box-shadow: var(--glow-sm); }
304
305
  .agent-list-container { overflow-y: auto; flex: 1; min-height: 0; }
305
306
  .agent-list-item {
306
307
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 12px;
@@ -361,7 +362,17 @@
361
362
  <div style="padding: 12px 16px; color: var(--text-dim); font-size: 13px;">加载中...</div>
362
363
  </div>
363
364
 
364
- <!-- Section 2: Create -->
365
+ <!-- Section 2: Collaboration Groups -->
366
+ <div class="sidebar-divider"></div>
367
+ <div class="sidebar-section-title">👥 协作群组</div>
368
+ <div class="agent-list-container" id="groups-list" style="max-height:120px;">
369
+ <!-- dynamically loaded -->
370
+ </div>
371
+ <div class="nav-item" data-page="create-group" onclick="navigate('create-group')">
372
+ <span class="icon">➕</span> 新建群组
373
+ </div>
374
+
375
+ <!-- Section 3: Create Agent -->
365
376
  <div class="sidebar-divider"></div>
366
377
  <div class="nav-item" data-page="create" onclick="navigate('create')">
367
378
  <span class="icon">➕</span> 新建 Agent
@@ -490,6 +501,59 @@
490
501
  </div>
491
502
 
492
503
  <!-- Templates Page -->
504
+ <!-- Create Group Page -->
505
+ <div class="page" id="page-create-group">
506
+ <h1 class="page-title">新建协作群组</h1>
507
+ <p class="page-subtitle">选择协作模式,拉入 Agent,开始多角色协作</p>
508
+ <div class="card" style="max-width:600px;">
509
+ <div class="label">群组名称</div>
510
+ <input class="input" id="group-name" placeholder="例如:产品讨论组">
511
+ <div class="label" style="margin-top:16px;">协作模式</div>
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>
519
+ </div>
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>
526
+ </div>
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>
533
+ </div>
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>
540
+ </div>
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>
547
+ </div>
548
+ </div>
549
+ <div class="label">选择 Agent 成员</div>
550
+ <div id="group-agent-select" style="margin-bottom:16px;">
551
+ <p style="color:var(--text-muted);font-size:13px;">请先创建 Agent,再拉入群组</p>
552
+ </div>
553
+ <button class="btn btn-primary" onclick="createGroup()">✨ 创建群组</button>
554
+ </div>
555
+ </div>
556
+
493
557
  <div class="page" id="page-templates">
494
558
  <h1 class="page-title">Template Market</h1>
495
559
  <p class="page-subtitle">Browse 100+ ready-to-use agent templates across 19 industries</p>
@@ -1062,6 +1126,7 @@
1062
1126
  // === Init ===
1063
1127
  async function init() {
1064
1128
  await Promise.all([loadTemplates(), loadAgents()]);
1129
+ loadSidebarGroups();
1065
1130
  handleRoute();
1066
1131
  window.addEventListener('popstate', handleRoute);
1067
1132
  checkFirstRun();
@@ -1146,6 +1211,42 @@
1146
1211
  }
1147
1212
  }
1148
1213
 
1214
+ // --- Collaboration Groups ---
1215
+ let selectedPattern = 'debate';
1216
+ function selectPattern(pat) {
1217
+ selectedPattern = pat;
1218
+ document.querySelectorAll('.pattern-card').forEach(c => c.classList.remove('active'));
1219
+ const el = document.getElementById('pat-' + pat);
1220
+ if (el) el.classList.add('active');
1221
+ }
1222
+ async function loadGroupAgentSelect() {
1223
+ try {
1224
+ const res = await fetch('/api/agents');
1225
+ const data = await res.json();
1226
+ const agents = data.agents || data || [];
1227
+ const container = document.getElementById('group-agent-select');
1228
+ if (!agents.length) {
1229
+ container.innerHTML = '<p style="color:var(--text-muted);font-size:13px;">请先创建 Agent,再拉入群组</p>';
1230
+ return;
1231
+ }
1232
+ container.innerHTML = agents.map(a => `<label style="display:flex;align-items:center;gap:8px;padding:6px 0;cursor:pointer;"><input type="checkbox" class="group-agent-cb" value="${a.id}"> <span>${a.templateIcon || a.icon || '🤖'}</span> <span style="font-size:14px;">${a.name}</span></label>`).join('');
1233
+ } catch(e) { console.error('loadGroupAgentSelect error', e); }
1234
+ }
1235
+ async function createGroup() {
1236
+ const name = document.getElementById('group-name').value.trim();
1237
+ if (!name) { alert('请输入群组名称'); return; }
1238
+ const members = [...document.querySelectorAll('.group-agent-cb:checked')].map(cb => cb.value);
1239
+ if (members.length < 2) { alert('至少选择 2 个 Agent'); return; }
1240
+ // TODO: POST to /api/groups
1241
+ alert('群组 "' + name + '" 创建成功!模式: ' + selectedPattern + ', 成员: ' + members.length + ' 个 Agent');
1242
+ navigate('dashboard');
1243
+ }
1244
+ async function loadSidebarGroups() {
1245
+ // TODO: fetch /api/groups and render
1246
+ const container = document.getElementById('groups-list');
1247
+ if (container) container.innerHTML = '<div style="padding:6px 16px;color:var(--text-dim);font-size:12px;">暂无群组</div>';
1248
+ }
1249
+
1149
1250
  function navigateToAgent(agentId) {
1150
1251
  selectedAgentId = agentId;
1151
1252
  // Update sidebar active state
@@ -1261,6 +1362,7 @@
1261
1362
  if (page === 'global-models') { currentSettingsTab='models'; showSettings('models'); showPage('settings'); return; }
1262
1363
  if (page === 'global-memory') { currentSettingsTab='memory'; showSettings('memory'); showPage('settings'); return; }
1263
1364
  if (page === 'global-templates') { navigate('templates'); return; }
1365
+ if (page === 'create-group') { loadGroupAgentSelect(); }
1264
1366
  if (page === 'schedules') { loadSchedules(); }
1265
1367
  if (page === 'skills') { loadSkillsMarketplace(); }
1266
1368