mirror of
https://github.com/dtzp555-max/ocm.git
synced 2026-07-22 05:25:08 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
15798e007d | ||
|
|
d3fdbcef6a |
+26
-4
@@ -428,6 +428,12 @@ async function handleApi(req, res, urlObj, body) {
|
|||||||
);
|
);
|
||||||
// For main agent without explicit binding, infer its accountId from first unclaimed telegram account
|
// For main agent without explicit binding, infer its accountId from first unclaimed telegram account
|
||||||
const mainInferredAccountId = telegramAccounts.find(a => !claimedAccounts.has(a)) || telegramAccounts[0] || null;
|
const mainInferredAccountId = telegramAccounts.find(a => !claimedAccounts.has(a)) || telegramAccounts[0] || null;
|
||||||
|
// Build map: agentId -> parentAgentId inferred from subagents.allowAgents
|
||||||
|
const allowAgentsParentMap = {};
|
||||||
|
list.forEach(parent => {
|
||||||
|
const allowed = parent.subagents?.allowAgents || [];
|
||||||
|
allowed.forEach(childId => { if (!allowAgentsParentMap[childId]) allowAgentsParentMap[childId] = parent.id; });
|
||||||
|
});
|
||||||
const enriched = list.map(a => {
|
const enriched = list.map(a => {
|
||||||
const binding = bindings.find(b => b.agentId === a.id && b.match?.peer?.kind === 'group');
|
const binding = bindings.find(b => b.agentId === a.id && b.match?.peer?.kind === 'group');
|
||||||
const groupId = binding?.match?.peer?.id || null;
|
const groupId = binding?.match?.peer?.id || null;
|
||||||
@@ -457,7 +463,9 @@ async function handleApi(req, res, urlObj, body) {
|
|||||||
// Workspace: explicit per-agent, or defaults.workspace for main
|
// Workspace: explicit per-agent, or defaults.workspace for main
|
||||||
const workspace = a.workspace || (isMain ? defaultWorkspace : null);
|
const workspace = a.workspace || (isMain ? defaultWorkspace : null);
|
||||||
return { ...a, workspace, groupId, requireMention: groupId ? (groups[groupId]?.requireMention ?? true) : null,
|
return { ...a, workspace, groupId, requireMention: groupId ? (groups[groupId]?.requireMention ?? true) : null,
|
||||||
effectiveModel: modelVal || defaults.model?.primary || '默认', hasOwnBot, accountId, parentAccountId, parentAgentId: a.parentAgentId || null, bindings: (bindings||[]).filter(b=>b.agentId===a.id).map(b=>({
|
effectiveModel: modelVal || defaults.model?.primary || '默认', hasOwnBot, accountId, parentAccountId,
|
||||||
|
parentAgentId: a.parentAgentId || (!hasOwnBot ? allowAgentsParentMap[a.id] : null) || null,
|
||||||
|
bindings: (bindings||[]).filter(b=>b.agentId===a.id).map(b=>({
|
||||||
idx: bindings.indexOf(b),
|
idx: bindings.indexOf(b),
|
||||||
channel: b.match?.channel || '',
|
channel: b.match?.channel || '',
|
||||||
accountId: b.match?.accountId || '',
|
accountId: b.match?.accountId || '',
|
||||||
@@ -3352,16 +3360,24 @@ function renderAgents() {
|
|||||||
// Build grouping: prefer explicit parentAgentId; fallback to telegram bot-root grouping.
|
// Build grouping: prefer explicit parentAgentId; fallback to telegram bot-root grouping.
|
||||||
const byId = {}; (S.agents||[]).forEach(a=>{ byId[a.id]=a; });
|
const byId = {}; (S.agents||[]).forEach(a=>{ byId[a.id]=a; });
|
||||||
|
|
||||||
// infer parentAgentId for legacy telegram sub-agents if missing
|
// infer parentAgentId for sub-agents if missing
|
||||||
const accountToRootId = {};
|
const accountToRootId = {};
|
||||||
(S.agents||[]).forEach(a=>{ if(a.hasOwnBot && a.accountId) accountToRootId[a.accountId]=a.id; });
|
(S.agents||[]).forEach(a=>{ if(a.hasOwnBot && a.accountId) accountToRootId[a.accountId]=a.id; });
|
||||||
(S.agents||[]).forEach(a=>{
|
(S.agents||[]).forEach(a=>{
|
||||||
if(!a.parentAgentId && !a.hasOwnBot && a.parentAccountId && accountToRootId[a.parentAccountId]){
|
if(a.parentAgentId || a.hasOwnBot || a.id === 'main') return; // already resolved or is a root
|
||||||
|
// Case 1: legacy telegram sub-agent with parentAccountId
|
||||||
|
if(a.parentAccountId && accountToRootId[a.parentAccountId]){
|
||||||
a._inferParentAgentId = accountToRootId[a.parentAccountId];
|
a._inferParentAgentId = accountToRootId[a.parentAccountId];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Case 2: orphan agent (no own bot, no parentAgentId, no binding-based inference)
|
||||||
|
// These are likely dynamically created sub-agents — default to 'main'
|
||||||
|
if(byId['main']){
|
||||||
|
a._inferParentAgentId = 'main';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const roots=[]; const childrenByRoot={}; const orphans=[];
|
const roots=[]; const childrenByRoot={};
|
||||||
(S.agents||[]).forEach(a=>{
|
(S.agents||[]).forEach(a=>{
|
||||||
const pid = a.parentAgentId || a._inferParentAgentId || '';
|
const pid = a.parentAgentId || a._inferParentAgentId || '';
|
||||||
if(pid && byId[pid]){
|
if(pid && byId[pid]){
|
||||||
@@ -3370,6 +3386,12 @@ function renderAgents() {
|
|||||||
roots.push(a);
|
roots.push(a);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// Sort roots: agents with own bot first (main always first among those), then orphans
|
||||||
|
roots.sort((a,b)=>{
|
||||||
|
if(a.id==='main') return -1; if(b.id==='main') return 1;
|
||||||
|
if(a.hasOwnBot && !b.hasOwnBot) return -1; if(!a.hasOwnBot && b.hasOwnBot) return 1;
|
||||||
|
return (a.name||a.id).localeCompare(b.name||b.id);
|
||||||
|
});
|
||||||
|
|
||||||
function fmtBinding(b){
|
function fmtBinding(b){
|
||||||
const ch = (b.channel||'').toLowerCase();
|
const ch = (b.channel||'').toLowerCase();
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "openclaw-manager",
|
"name": "openclaw-manager",
|
||||||
"version": "0.9.3",
|
"version": "0.9.4",
|
||||||
"description": "A local web UI for managing OpenClaw AI agents \u2014 no npm install required",
|
"description": "A local web UI for managing OpenClaw AI agents \u2014 no npm install required",
|
||||||
"main": "openclaw-manager.js",
|
"main": "openclaw-manager.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user