evolcore 0.0.43-test.6 → 0.0.43-test.7
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/CHANGELOG.md +48 -0
- package/bin/ecmsg.js +171 -54
- package/dist/agents/baseagent-availability.js +1 -1
- package/dist/agents/codex/app-server-client.js +22 -0
- package/dist/agents/codex-runner.js +69 -2
- package/dist/aun/msg/p2p.js +6 -1
- package/dist/channels/aun.js +234 -21
- package/dist/cli/agent-create.js +2 -2
- package/dist/cli/daemon-commands.js +6 -66
- package/dist/cli/daemon-lifecycle-client.js +61 -0
- package/dist/cli/ecmsg-gateway.js +35 -2
- package/dist/cli/events-command.js +73 -0
- package/dist/cli/index.js +31 -14
- package/dist/cli/invoke-command.js +182 -0
- package/dist/cli/managed-command-guard.js +6 -1
- package/dist/cli/restart-monitor.js +45 -47
- package/dist/cli/services-command.js +111 -0
- package/dist/cli/team-workspace-command.js +134 -0
- package/dist/cli/thread-command.js +6 -2
- package/dist/cli/watch-msg.js +1 -1
- package/dist/config/config-field-policy.js +2 -2
- package/dist/config/config-manager.js +0 -7
- package/dist/config/invoke-ipc-service.js +118 -0
- package/dist/config/schema-migration.js +6 -1
- package/dist/config-store.js +2 -1
- package/dist/core/agent-reload-coordinator.js +6 -4
- package/dist/core/agent-runtime.js +104 -10
- package/dist/core/auth/delegation-authorization.js +66 -0
- package/dist/core/auth/operation-catalog.js +20 -0
- package/dist/core/baseagent-loader.js +60 -130
- package/dist/core/channel-loader.js +10 -1
- package/dist/core/channel-runtime.js +4 -3
- package/dist/core/command/agent-control.js +1 -1
- package/dist/core/command/agent-storage-menu.js +1 -1
- package/dist/core/command/chatmode-config.js +2 -36
- package/dist/core/command/command-handler.js +53 -11
- package/dist/core/command/data-root-resolver.js +32 -23
- package/dist/core/command/eventcenter-menu.js +338 -0
- package/dist/core/command/menu-catalog.js +8 -0
- package/dist/core/command/menu-handler.js +198 -84
- package/dist/core/command/menu-protocol.js +60 -11
- package/dist/core/command/menu-query-batch.js +194 -0
- package/dist/core/command/slash-gate.js +1 -1
- package/dist/core/command/slash-handler.js +34 -42
- package/dist/core/command/team-workspace-bootstrap.js +350 -0
- package/dist/core/command/{pa-workspace-calendar.js → team-workspace-calendar.js} +7 -7
- package/dist/core/command/team-workspace-initializer.js +2 -0
- package/dist/core/command/{pa-workspace-items.js → team-workspace-items.js} +83 -68
- package/dist/core/command/team-workspace-job-store.js +88 -0
- package/dist/core/command/team-workspace-management-service.js +2 -0
- package/dist/core/command/team-workspace-management-store.js +96 -0
- package/dist/core/command/team-workspace-management.js +265 -0
- package/dist/core/command/team-workspace-members-menu.js +88 -0
- package/dist/core/command/team-workspace-store.js +612 -0
- package/dist/core/command/team-workspace-team.js +193 -0
- package/dist/core/daemon-control.js +8 -5
- package/dist/core/daemon-lifecycle.js +132 -73
- package/dist/core/handoff/runtime.js +3 -3
- package/dist/core/invoke/executors/index.js +13 -0
- package/dist/core/invoke/executors/media.js +283 -0
- package/dist/core/invoke/executors/text.js +198 -0
- package/dist/core/invoke/invoke-service.js +157 -0
- package/dist/core/invoke/style-router.js +48 -0
- package/dist/core/invoke/types.js +19 -0
- package/dist/core/ipc-registration.js +46 -7
- package/dist/core/memory/consolidation.js +7 -5
- package/dist/core/message/aun-ipc-sender.js +147 -17
- package/dist/core/message/im-renderer.js +28 -84
- package/dist/core/message/message-bridge.js +4 -0
- package/dist/core/message/message-utils.js +10 -2
- package/dist/core/message/peer-mode.js +7 -34
- package/dist/core/message/response-engine.js +157 -54
- package/dist/core/message/send-options.js +7 -4
- package/dist/core/message/send-routing.js +43 -5
- package/dist/core/ownership/owner-resolver.js +7 -0
- package/dist/core/permission/ec-command-parser.js +3 -2
- package/dist/core/permission/protected-paths.js +12 -2
- package/dist/core/permission/shell-environment.js +9 -0
- package/dist/core/session/session-file-health.js +243 -0
- package/dist/core/session/session-fs-store.js +2 -3
- package/dist/core/task/task-recovery-service.js +13 -2
- package/dist/core/thread/command-parser.js +9 -2
- package/dist/core/thread/thread-operation.js +21 -2
- package/dist/core/thread/thread-route.js +13 -2
- package/dist/directory/owner-directory-admission.js +40 -53
- package/dist/directory/owner-directory-cache.js +89 -113
- package/dist/directory/owner-directory-query-operation.js +8 -10
- package/dist/eck/kit-renderer.js +7 -5
- package/dist/ecweb/basic-settings-service.js +1 -1
- package/dist/ecweb/message-context-service.js +0 -4
- package/dist/ecweb/runtime/lifecycle.js +6 -2
- package/dist/ecweb/runtime/supervisor.js +19 -4
- package/dist/event-center/admission-materializer.js +114 -0
- package/dist/event-center/bus-gate.js +136 -0
- package/dist/event-center/bus-host.js +290 -0
- package/dist/event-center/bus-resolver.js +120 -0
- package/dist/event-center/center-config.js +100 -0
- package/dist/event-center/client-factory.js +50 -0
- package/dist/event-center/daemon.js +45 -0
- package/dist/event-center/directory-source.js +53 -0
- package/dist/event-center/dispatcher.js +157 -0
- package/dist/event-center/event-log.js +110 -0
- package/dist/event-center/index-generator.js +63 -0
- package/dist/event-center/ipc-operation.js +308 -0
- package/dist/event-center/ledger.js +52 -0
- package/dist/event-center/pack-loader.js +202 -0
- package/dist/event-center/pack-manager.js +85 -0
- package/dist/event-center/registry.js +238 -0
- package/dist/event-center/runtime.js +641 -0
- package/dist/event-center/script-runner.js +356 -0
- package/dist/event-center/types.js +35 -0
- package/dist/event-center/validation.js +413 -0
- package/dist/index.js +285 -99
- package/dist/ipc.js +66 -12
- package/dist/paths.js +20 -0
- package/dist/product.js +14 -0
- package/dist/proxy/manager.js +5 -1
- package/dist/proxy/service-supervisor.js +13 -4
- package/dist/response-system/engines/v1/index.js +0 -1
- package/dist/response-system/modes/single-session/index.js +1 -1
- package/dist/services/dispatcher.js +100 -0
- package/dist/services/idempotency.js +90 -0
- package/dist/services/identity.js +52 -0
- package/dist/services/index-generator.js +70 -0
- package/dist/services/index.js +449 -0
- package/dist/services/ipc-operation.js +458 -0
- package/dist/services/ledger.js +52 -0
- package/dist/services/message-log.js +112 -0
- package/dist/services/pack-manager.js +204 -0
- package/dist/services/reply.js +55 -0
- package/dist/services/router.js +95 -0
- package/dist/services/script-runner.js +422 -0
- package/dist/services/service-payload.js +70 -0
- package/dist/services/types.js +18 -0
- package/dist/services/validation.js +297 -0
- package/dist/trigger/application-service.js +18 -0
- package/dist/trigger/event-source.js +1 -1
- package/dist/trigger/ipc-service.js +3 -1
- package/dist/trigger/script-sandbox.js +118 -22
- package/dist/utils/cross-platform.js +24 -10
- package/dist/utils/evolcore-version.js +69 -27
- package/dist/utils/instance-registry.js +19 -13
- package/dist/utils/process-introspect.js +45 -9
- package/dist/utils/startup-trace.js +74 -37
- package/dist/utils/windows-shell-trust.js +80 -6
- package/kits/docs/INDEX.md +2 -2
- package/kits/docs/aun/ABILITY_CALLING.md +7 -14
- package/kits/docs/context-assembly.md +1 -1
- package/kits/docs/evolcore/INDEX.md +2 -0
- package/kits/docs/evolcore/ability.md +4 -0
- package/kits/docs/evolcore/aid.md +1 -1
- package/kits/docs/evolcore/event-center.md +207 -0
- package/kits/docs/evolcore/file-navigation.md +10 -264
- package/kits/docs/evolcore/fs.md +3 -2
- package/kits/docs/evolcore/group.md +1 -1
- package/kits/docs/evolcore/memory-architecture.md +2 -0
- package/kits/docs/evolcore/menu-protocol.md +21 -0
- package/kits/docs/evolcore/msg.md +15 -3
- package/kits/docs/evolcore/provider.md +3 -1
- package/kits/docs/evolcore/response.md +5 -5
- package/kits/docs/evolcore/services.md +277 -0
- package/kits/docs/evolcore/task.md +2 -0
- package/kits/docs/evolcore/team-workspace.md +41 -0
- package/kits/eck_manifest.json +26 -0
- package/kits/rules/02-navigation.md +10 -1
- package/kits/schemas/_meta.json +17 -6
- package/kits/schemas/agent-config.schema.19.json +5 -7
- package/kits/schemas/agent-config.schema.20.json +936 -0
- package/kits/schemas/relation-config.schema.12.json +2 -3
- package/kits/schemas/role-config.schema.2.json +4 -4
- package/kits/skills/.switches.json +1 -5
- package/kits/skills/ability/SKILL.md +56 -0
- package/kits/skills/ability/references/calling.md +56 -0
- package/kits/skills/{ec-ability → ability}/references/contract-checklist.md +1 -1
- package/kits/skills/{ec-ability → ability}/references/development.md +9 -33
- package/kits/skills/{ec-ability → ability}/references/management.md +2 -2
- package/kits/skills/{ec-ability → ability}/references/recovery.md +1 -1
- package/kits/skills/{ec-ability → ability}/references/runtime-protocol.md +2 -0
- package/kits/skills/ec-agent-create/SKILL.md +0 -1
- package/kits/skills/ec-service-proxy/SKILL.md +34 -5
- package/kits/skills/personal-assistant/SKILL.md +6 -6
- package/kits/skills/personal-assistant/references/02-bootstrap.md +4 -4
- package/kits/skills/personal-assistant/scripts/clean.mjs +4 -4
- package/kits/skills/personal-assistant/scripts/init.mjs +2 -2
- package/kits/skills/personal-assistant/scripts/pa.mjs +4 -4
- package/kits/templates/system-fragments/channel.md +3 -3
- package/kits/templates/system-fragments/commands.md +5 -3
- package/kits/templates/system-fragments/reply.md +0 -5
- package/kits/templates/system-fragments/thread.md +10 -8
- package/package.json +3 -5
- package/dist/cli/pa-workspace-command.js +0 -225
- package/dist/core/command/pa-workspace-store.js +0 -468
- package/dist/core/relation/pa-team.js +0 -132
- package/kits/docs/evolcore/pa-workspace.md +0 -51
- package/kits/skills/aid-ability/SKILL.md +0 -244
- package/kits/skills/ec-ability/SKILL.md +0 -67
- package/kits/skills/ec-ability/references/workflows.md +0 -15
|
@@ -63,15 +63,18 @@ import { roleMenuAction, roleMenuOperation, roleMenuOptions, roleMenuQuery, role
|
|
|
63
63
|
import { handleConnectMenu, connectMenuOperation } from './connect-menu.js';
|
|
64
64
|
import { groupMenuAuthorizationArgs, groupMenuIntent, handleGroupMenu, } from './group-menu.js';
|
|
65
65
|
import { getMenuCatalog, execMenuValueBatch, resolveExplicitMenuExecutionContext, resolveMenuCatalogContext, validateMenuCatalogArgs, validateMenuValueBatchArgs } from './menu-catalog.js';
|
|
66
|
+
import { execMenuQueryBatch } from './menu-query-batch.js';
|
|
66
67
|
import { probeSessionActivity } from './slash-gate.js';
|
|
67
68
|
import { dataRootFailure, dataRootResolver } from './data-root-resolver.js';
|
|
68
|
-
import { DataRootError,
|
|
69
|
-
import {
|
|
70
|
-
import {
|
|
69
|
+
import { DataRootError, teamWorkspaceStore, readTeamWorkspaceNavigation } from './team-workspace-store.js';
|
|
70
|
+
import { queryTeamWorkspaceCalendar } from './team-workspace-calendar.js';
|
|
71
|
+
import { teamWorkspaceItemsIndex, validateTeamWorkspaceItemsArgs } from './team-workspace-items.js';
|
|
72
|
+
import { executeTeamMembersAction, executeTeamMembersQuery, isTeamMembersMenuRequest } from './team-workspace-members-menu.js';
|
|
71
73
|
import { agentStorageMenuService, isAgentStorageMenuRequest } from './agent-storage-menu.js';
|
|
72
74
|
import { MAX_AUN_ATTACHMENT_SIZE } from '../../aun/msg/upload.js';
|
|
73
75
|
import { normalizeTopicLabel, normalizeTopicStatus, resolveTopicArchiveFilter, } from '../session/session-mapper.js';
|
|
74
76
|
import { notifyThreadRename } from '../thread/thread-operation.js';
|
|
77
|
+
import { executeEventsQuery, executeEventsUpdate } from './eventcenter-menu.js';
|
|
75
78
|
import { isAgentScopePath, isHClassPath, isLClassPath } from '../permission/protected-paths.js';
|
|
76
79
|
/**
|
|
77
80
|
* 获取 baseagent CLI 的版本号(claude/gemini/codex)。
|
|
@@ -456,17 +459,13 @@ function listDirectory(realPath, options) {
|
|
|
456
459
|
const code = e?.code === 'EACCES' || e?.code === 'EPERM' ? 'NO_PERMISSION' : 'EXEC_FAILED';
|
|
457
460
|
return { error: `目录读取失败: ${e?.message ?? e}`, code };
|
|
458
461
|
}
|
|
462
|
+
const workspaceStats = new Map();
|
|
459
463
|
dirents = dirents.filter(d => {
|
|
460
464
|
if (!includeHidden && d.name.startsWith('.'))
|
|
461
465
|
return false;
|
|
462
|
-
if (options.
|
|
463
|
-
return false;
|
|
464
|
-
if (options.paWorkspace && d.isSymbolicLink()) {
|
|
466
|
+
if (options.resolveWorkspaceChild) {
|
|
465
467
|
try {
|
|
466
|
-
|
|
467
|
-
const relative = path.relative(projectPath, target).split(path.sep).join('/');
|
|
468
|
-
if (!isInProject(target, projectPath) || isPaHiddenPath(relative))
|
|
469
|
-
return false;
|
|
468
|
+
workspaceStats.set(d.name, options.resolveWorkspaceChild(d.name));
|
|
470
469
|
}
|
|
471
470
|
catch {
|
|
472
471
|
return false;
|
|
@@ -476,7 +475,10 @@ function listDirectory(realPath, options) {
|
|
|
476
475
|
});
|
|
477
476
|
const entryInfoByName = new Map();
|
|
478
477
|
for (const dirent of dirents) {
|
|
479
|
-
|
|
478
|
+
const stat = workspaceStats.get(dirent.name);
|
|
479
|
+
entryInfoByName.set(dirent.name, stat
|
|
480
|
+
? { isDirectory: stat.isDirectory(), followTarget: true }
|
|
481
|
+
: getDirectoryEntryInfo(realPath, projectPath, role, dirent));
|
|
480
482
|
}
|
|
481
483
|
dirents.sort((a, b) => {
|
|
482
484
|
const ad = entryInfoByName.get(a.name)?.isDirectory ?? false;
|
|
@@ -552,6 +554,19 @@ function isDaemonControlSubject(subject) {
|
|
|
552
554
|
|| subject.processRole === 'daemon-owner'
|
|
553
555
|
|| subject.processRole === 'daemon-service';
|
|
554
556
|
}
|
|
557
|
+
export function isTeamWorkspaceOwnerSubject(subject) {
|
|
558
|
+
return subject.channelType === 'aun' && subject.chatType === 'private'
|
|
559
|
+
&& !subject.fromControlChannel
|
|
560
|
+
&& subject.role === 'owner' && !!subject.selfAid && !!subject.principalId
|
|
561
|
+
&& ownerResolver.isOwner(subject.selfAid, subject.principalId);
|
|
562
|
+
}
|
|
563
|
+
const EVENT_CENTER_OWNER_ONLY = 'Event center menus are available only to the current Agent Owner in a private AUN chat';
|
|
564
|
+
function eventsMenuContext(handler, subject) {
|
|
565
|
+
return {
|
|
566
|
+
registry: handler.eventCenter,
|
|
567
|
+
selfAid: subject.selfAid,
|
|
568
|
+
};
|
|
569
|
+
}
|
|
555
570
|
function modelDisplayLabel(agent, model) {
|
|
556
571
|
const full = agent.resolveModelId?.(model);
|
|
557
572
|
return full && full !== model ? `${model} (${full})` : model;
|
|
@@ -745,8 +760,7 @@ function readMenuChatmode(target) {
|
|
|
745
760
|
field: target.fieldPath,
|
|
746
761
|
configuredValue: resolved.value,
|
|
747
762
|
});
|
|
748
|
-
const mode = target.scope === 'agent'
|
|
749
|
-
&& (decision.effectiveValue !== 'paactive' || target.role === 'owner') ? decision.effectiveValue
|
|
763
|
+
const mode = target.scope === 'agent' ? decision.effectiveValue
|
|
750
764
|
: resolveChatModeForField({ ...target.sel, role: target.role, field: target.field });
|
|
751
765
|
if (isChatMode(mode)) {
|
|
752
766
|
return {
|
|
@@ -754,9 +768,6 @@ function readMenuChatmode(target) {
|
|
|
754
768
|
source: decision.decidedBy === 'role'
|
|
755
769
|
? 'role'
|
|
756
770
|
: toMenuSource(resolved.source) ?? 'builtin',
|
|
757
|
-
...(resolved.value === 'paactive' && mode !== 'paactive' ? {
|
|
758
|
-
fallbackReason: 'paactive 仅在 active AUN 人类 owner 私聊主会话或话题生效,当前场景或角色策略未满足条件。',
|
|
759
|
-
} : {}),
|
|
760
771
|
};
|
|
761
772
|
}
|
|
762
773
|
}
|
|
@@ -1422,13 +1433,13 @@ function buildRoleMenuContext(owner, channel, subject) {
|
|
|
1422
1433
|
...(owningAgent?.name ? (owner.getAvailableBaseagentsForOwner?.(owningAgent.name) ?? []) : []),
|
|
1423
1434
|
])),
|
|
1424
1435
|
listModels: async (baseagent) => {
|
|
1425
|
-
const runner = owner.
|
|
1436
|
+
const runner = await owner.ensureAgent(channel, baseagent, owningAgent?.aid);
|
|
1426
1437
|
if (!runner?.listModels)
|
|
1427
1438
|
return [];
|
|
1428
1439
|
return await runner.listModels() ?? [];
|
|
1429
1440
|
},
|
|
1430
1441
|
resolveModelId: (baseagent, model) => {
|
|
1431
|
-
const runner = owner.
|
|
1442
|
+
const runner = owner.getLoadedAgent?.(channel, baseagent);
|
|
1432
1443
|
return typeof runner?.resolveModelId === 'function' ? runner.resolveModelId(model) : undefined;
|
|
1433
1444
|
},
|
|
1434
1445
|
};
|
|
@@ -1984,7 +1995,7 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
1984
1995
|
}
|
|
1985
1996
|
if (!source.agentSessionId)
|
|
1986
1997
|
return [];
|
|
1987
|
-
const agent = this.
|
|
1998
|
+
const agent = await this.ensureAgent(channel, source.baseagent);
|
|
1988
1999
|
if (!agent.capabilities?.forkAtTurn || !agent.getSessionMessages || !agent.forkSessionAt)
|
|
1989
2000
|
return [];
|
|
1990
2001
|
const turns = buildTranscriptTurns(await agent.getSessionMessages(source.agentSessionId, source.projectPath));
|
|
@@ -2083,12 +2094,7 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
2083
2094
|
const available = requestedAgent?.name
|
|
2084
2095
|
? (this.getAvailableBaseagentsForOwner?.(requestedAgent.name) ?? [])
|
|
2085
2096
|
: this.getAvailableBaseagents(channel);
|
|
2086
|
-
|
|
2087
|
-
config: { active_baseagent: currentAgent }, loaded: available, probe: false,
|
|
2088
|
-
});
|
|
2089
|
-
return inventory.baseagents
|
|
2090
|
-
.filter(item => item.loaded === true)
|
|
2091
|
-
.map(item => ({ value: item.id, label: item.id, selected: item.id === currentAgent }));
|
|
2097
|
+
return available.map((id) => ({ value: id, label: id, selected: id === currentAgent }));
|
|
2092
2098
|
}
|
|
2093
2099
|
if (cmd === '/model') {
|
|
2094
2100
|
const target = resolveMenuModelTarget.call(this, {
|
|
@@ -2106,7 +2112,7 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
2106
2112
|
throw { code: target.code, message: target.error };
|
|
2107
2113
|
let agent;
|
|
2108
2114
|
try {
|
|
2109
|
-
agent = this.
|
|
2115
|
+
agent = await this.ensureAgent(channel, target.baseagent, target.sel.self);
|
|
2110
2116
|
}
|
|
2111
2117
|
catch (error) {
|
|
2112
2118
|
if (isDaemonControlSubject(subject)) {
|
|
@@ -2177,7 +2183,7 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
2177
2183
|
throw { code: target.code, message: target.error };
|
|
2178
2184
|
let agent;
|
|
2179
2185
|
try {
|
|
2180
|
-
agent = this.
|
|
2186
|
+
agent = await this.ensureAgent(channel, target.baseagent, target.sel.self);
|
|
2181
2187
|
}
|
|
2182
2188
|
catch (error) {
|
|
2183
2189
|
if (isDaemonControlSubject(subject)) {
|
|
@@ -2214,9 +2220,6 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
2214
2220
|
...(target.field !== 'group'
|
|
2215
2221
|
? [{ value: 'interactive', label: '交互模式', selected: currentMode === 'interactive' }] : []),
|
|
2216
2222
|
{ value: 'proactive', label: '主动模式', selected: currentMode === 'proactive' },
|
|
2217
|
-
...(target.field === 'private' && target.role === 'owner'
|
|
2218
|
-
&& (target.scope === 'agent' || target.sel.peerKey?.startsWith('aun#'))
|
|
2219
|
-
? [{ value: 'paactive', label: 'PA 模式', selected: currentMode === 'paactive' }] : []),
|
|
2220
2223
|
];
|
|
2221
2224
|
}
|
|
2222
2225
|
if (cmd === '/mention') {
|
|
@@ -2390,15 +2393,55 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2390
2393
|
return dataRootFailure(error);
|
|
2391
2394
|
}
|
|
2392
2395
|
}
|
|
2393
|
-
if (cmdBase === '/
|
|
2394
|
-
|
|
2396
|
+
if (cmdBase === '/events') {
|
|
2397
|
+
if (!isTeamWorkspaceOwnerSubject(subject))
|
|
2398
|
+
return { error: EVENT_CENTER_OWNER_ONLY, code: 'FORBIDDEN' };
|
|
2399
|
+
try {
|
|
2400
|
+
return { data: await executeEventsQuery(eventsMenuContext(this, subject), args ?? {}) };
|
|
2401
|
+
}
|
|
2402
|
+
catch (error) {
|
|
2403
|
+
if (error && typeof error === 'object' && 'code' in error)
|
|
2404
|
+
return { error: String(error.message ?? 'event center error'), code: String(error.code) };
|
|
2405
|
+
return { error: error instanceof Error ? error.message : String(error), code: 'INTERNAL_ERROR' };
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
if (cmdBase === '/team-workspace') {
|
|
2409
|
+
if (!isTeamWorkspaceOwnerSubject(subject))
|
|
2410
|
+
return { error: 'Team Workspace Menu is available only to the current Agent Owner in a private AUN chat', code: 'FORBIDDEN' };
|
|
2411
|
+
if (args?.view === 'members')
|
|
2412
|
+
return executeTeamMembersQuery(subject.selfAid, args);
|
|
2413
|
+
const allowed = new Set(['view', 'protocolVersion', 'managementVersion', 'context', 'from', 'to', 'timezone', 'path', 'offset', 'limit', 'indexRevision', 'jobId']);
|
|
2395
2414
|
const unknown = Object.keys(args ?? {}).find(key => !allowed.has(key));
|
|
2396
2415
|
if (unknown)
|
|
2397
|
-
return { error: `
|
|
2398
|
-
if (!args || typeof args.view !== 'string' || !['navigation', 'calendar', 'items'].includes(args.view))
|
|
2399
|
-
return { error: '
|
|
2416
|
+
return { error: `team-workspace does not accept args.${unknown}`, code: 'INVALID_ARGUMENT' };
|
|
2417
|
+
if (!args || typeof args.view !== 'string' || !['navigation', 'calendar', 'items', 'workspace-info', 'job'].includes(args.view))
|
|
2418
|
+
return { error: 'team-workspace requires a supported view', code: 'INVALID_ARGUMENT' };
|
|
2419
|
+
if (['workspace-info', 'job'].includes(args.view)) {
|
|
2420
|
+
if (args.managementVersion !== 1)
|
|
2421
|
+
return { error: 'Management views require managementVersion=1', code: 'SCHEMA_VERSION_UNSUPPORTED' };
|
|
2422
|
+
const managementUnknown = Object.keys(args).find(key => args.view === 'job'
|
|
2423
|
+
? !['view', 'managementVersion', 'jobId'].includes(key)
|
|
2424
|
+
: !['view', 'managementVersion'].includes(key));
|
|
2425
|
+
if (managementUnknown)
|
|
2426
|
+
return { error: `Management view does not accept args.${managementUnknown}`, code: 'INVALID_ARGUMENT' };
|
|
2427
|
+
if (args.view === 'job' && (typeof args.jobId !== 'string' || !args.jobId.trim()))
|
|
2428
|
+
return { error: 'job view requires args.jobId', code: 'INVALID_ARGUMENT' };
|
|
2429
|
+
try {
|
|
2430
|
+
const management = this.teamWorkspaceManagementService;
|
|
2431
|
+
if (!management)
|
|
2432
|
+
return { error: 'Team workspace management is unavailable', code: 'DEPENDENCY_UNAVAILABLE' };
|
|
2433
|
+
return { data: args.view === 'workspace-info'
|
|
2434
|
+
? await management.workspaceInfo(subject)
|
|
2435
|
+
: await management.job(subject, args.jobId) };
|
|
2436
|
+
}
|
|
2437
|
+
catch (error) {
|
|
2438
|
+
return dataRootFailure(error);
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
if (args.managementVersion !== undefined || args.jobId !== undefined)
|
|
2442
|
+
return { error: 'managementVersion and jobId are only valid for management views', code: 'INVALID_ARGUMENT' };
|
|
2400
2443
|
if (args?.protocolVersion !== undefined && args.protocolVersion !== 1) {
|
|
2401
|
-
return { error: 'Unsupported
|
|
2444
|
+
return { error: 'Unsupported Team workspace protocol version', code: 'SCHEMA_VERSION_UNSUPPORTED' };
|
|
2402
2445
|
}
|
|
2403
2446
|
if (args.view !== 'calendar' && (args.from !== undefined || args.to !== undefined || args.timezone !== undefined)) {
|
|
2404
2447
|
return { error: 'from, to and timezone are only valid for calendar view', code: 'INVALID_ARGUMENT' };
|
|
@@ -2407,20 +2450,23 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2407
2450
|
return { error: 'path, offset, limit and indexRevision are only valid for items view', code: 'INVALID_ARGUMENT' };
|
|
2408
2451
|
}
|
|
2409
2452
|
try {
|
|
2453
|
+
if (this.teamWorkspaceManagementService)
|
|
2454
|
+
await this.teamWorkspaceManagementService.ensureReady(subject);
|
|
2410
2455
|
if (args.view === 'items')
|
|
2411
|
-
|
|
2412
|
-
const root = dataRootResolver.
|
|
2413
|
-
const navigation =
|
|
2414
|
-
const state =
|
|
2456
|
+
validateTeamWorkspaceItemsArgs(args);
|
|
2457
|
+
const root = dataRootResolver.issueTeamWorkspaceRoot(subject);
|
|
2458
|
+
const navigation = readTeamWorkspaceNavigation(root.targetAid);
|
|
2459
|
+
const state = teamWorkspaceStore.require(root.targetAid);
|
|
2415
2460
|
if (args.view === 'items') {
|
|
2416
|
-
const items = await
|
|
2461
|
+
const items = await teamWorkspaceItemsIndex.query(root.targetAid, state, args);
|
|
2417
2462
|
// Building the initial index yields to other requests. Recheck owner,
|
|
2418
2463
|
// binding and navigation before sending any cached private summary.
|
|
2419
|
-
dataRootResolver.
|
|
2420
|
-
const current =
|
|
2464
|
+
dataRootResolver.issueTeamWorkspaceRoot(subject);
|
|
2465
|
+
const current = teamWorkspaceStore.require(root.targetAid);
|
|
2421
2466
|
if (current.workspaceId !== state.workspaceId || current.ownerAid !== state.ownerAid
|
|
2422
|
-
|| current.rootPath !== state.rootPath || current.
|
|
2423
|
-
|
|
2467
|
+
|| current.rootPath !== state.rootPath || current.outputRootPath !== state.outputRootPath
|
|
2468
|
+
|| current.navigationRevision !== state.navigationRevision) {
|
|
2469
|
+
throw new DataRootError('WORKSPACE_CHANGED', 'Team workspace changed during query');
|
|
2424
2470
|
}
|
|
2425
2471
|
return { data: items };
|
|
2426
2472
|
}
|
|
@@ -2434,7 +2480,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2434
2480
|
.filter((definition) => this.canAccessTriggerDefinition(definition, userId ?? '', channel, isAdmin));
|
|
2435
2481
|
return {
|
|
2436
2482
|
data: {
|
|
2437
|
-
...
|
|
2483
|
+
...queryTeamWorkspaceCalendar({
|
|
2438
2484
|
state,
|
|
2439
2485
|
navigation,
|
|
2440
2486
|
scheduler: scheduler && visibleDefinitions
|
|
@@ -2456,10 +2502,10 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2456
2502
|
};
|
|
2457
2503
|
}
|
|
2458
2504
|
// Start preparing cards while the user is still in the conversation.
|
|
2459
|
-
|
|
2505
|
+
teamWorkspaceItemsIndex.warm(root.targetAid, state);
|
|
2460
2506
|
return {
|
|
2461
2507
|
data: {
|
|
2462
|
-
protocol: 'evol.
|
|
2508
|
+
protocol: 'evol.team-workspace',
|
|
2463
2509
|
protocolVersion: 1,
|
|
2464
2510
|
workspaceId: navigation.workspaceId,
|
|
2465
2511
|
navigationRevision: navigation.navigationRevision,
|
|
@@ -2779,11 +2825,11 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2779
2825
|
return { data: { scope: 'retained-history', tasks: this.sessionManager.getRunnerTaskHistory(session.id) } };
|
|
2780
2826
|
}
|
|
2781
2827
|
const sessionKey = this.getQueueKey(session, channel, channelId);
|
|
2782
|
-
const sessionAgent = this.
|
|
2783
|
-
const isProcessing = this.messageQueue.isProcessing(sessionKey) || sessionAgent
|
|
2784
|
-
|| sessionAgent
|
|
2828
|
+
const sessionAgent = this.getLoadedAgent(channel, session.baseagent);
|
|
2829
|
+
const isProcessing = this.messageQueue.isProcessing(sessionKey) || sessionAgent?.hasActiveStream(sessionKey)
|
|
2830
|
+
|| sessionAgent?.hasActiveOperation?.(sessionKey) === true;
|
|
2785
2831
|
const queueLength = this.messageQueue.getQueueLength(sessionKey);
|
|
2786
|
-
const executionState = sessionAgent
|
|
2832
|
+
const executionState = sessionAgent?.getExecutionState?.(sessionKey);
|
|
2787
2833
|
const health = await this.sessionManager.getHealthStatus(session.id);
|
|
2788
2834
|
let processingDuration;
|
|
2789
2835
|
if (isProcessing && session.processingState) {
|
|
@@ -2866,7 +2912,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2866
2912
|
const candidate = async (session) => {
|
|
2867
2913
|
if (!session?.agentSessionId || session.channel !== channel || session.channelId !== channelId)
|
|
2868
2914
|
return undefined;
|
|
2869
|
-
const agent = this.
|
|
2915
|
+
const agent = await this.ensureAgent(channel, session.baseagent);
|
|
2870
2916
|
if (!agent.getSessionMessages)
|
|
2871
2917
|
return undefined;
|
|
2872
2918
|
try {
|
|
@@ -2908,11 +2954,11 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2908
2954
|
return { data: { scope: 'retained-history', tasks: this.sessionManager.getRunnerTaskHistory(topic.id) } };
|
|
2909
2955
|
}
|
|
2910
2956
|
const sessionKey = this.getQueueKey(topic, channel, channelId);
|
|
2911
|
-
const sessionAgent = this.
|
|
2912
|
-
const isProcessing = this.messageQueue.isProcessing(sessionKey) || sessionAgent
|
|
2913
|
-
|| sessionAgent
|
|
2957
|
+
const sessionAgent = this.getLoadedAgent(channel, topic.baseagent);
|
|
2958
|
+
const isProcessing = this.messageQueue.isProcessing(sessionKey) || sessionAgent?.hasActiveStream(sessionKey)
|
|
2959
|
+
|| sessionAgent?.hasActiveOperation?.(sessionKey) === true;
|
|
2914
2960
|
const queueLength = this.messageQueue.getQueueLength(sessionKey);
|
|
2915
|
-
const executionState = sessionAgent
|
|
2961
|
+
const executionState = sessionAgent?.getExecutionState?.(sessionKey);
|
|
2916
2962
|
const health = await this.sessionManager.getHealthStatus(topic.id);
|
|
2917
2963
|
let processingDuration;
|
|
2918
2964
|
if (isProcessing && topic.processingState) {
|
|
@@ -2980,7 +3026,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2980
3026
|
});
|
|
2981
3027
|
if ('error' in target)
|
|
2982
3028
|
return target;
|
|
2983
|
-
const agent = this.
|
|
3029
|
+
const agent = await this.ensureAgent(channel, target.baseagent, target.sel.self);
|
|
2984
3030
|
const current = readMenuModel(target, agent, session?.agentSessionId);
|
|
2985
3031
|
return {
|
|
2986
3032
|
data: {
|
|
@@ -3009,7 +3055,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
3009
3055
|
});
|
|
3010
3056
|
if ('error' in target)
|
|
3011
3057
|
return target;
|
|
3012
|
-
const agent = this.
|
|
3058
|
+
const agent = await this.ensureAgent(channel, target.baseagent, target.sel.self);
|
|
3013
3059
|
const current = readMenuModel(target, agent, session?.agentSessionId);
|
|
3014
3060
|
return {
|
|
3015
3061
|
data: {
|
|
@@ -3041,7 +3087,6 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
3041
3087
|
return {
|
|
3042
3088
|
data: {
|
|
3043
3089
|
mode: current.value,
|
|
3044
|
-
...(current.fallbackReason ? { fallbackReason: current.fallbackReason } : {}),
|
|
3045
3090
|
source: current.source,
|
|
3046
3091
|
scope: target.scope,
|
|
3047
3092
|
override: readMenuScopeOverride(target.scope, target.fieldPath, target.sel),
|
|
@@ -3273,6 +3318,7 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3273
3318
|
if (cmdBase === '/provider') {
|
|
3274
3319
|
return executeProviderMenu({ name: 'provider', cmd, type: 'menu.update', args, value }, fromControlChannel ? authSubject : undefined, source);
|
|
3275
3320
|
}
|
|
3321
|
+
const isEventCenterUpdate = cmdBase === '/events';
|
|
3276
3322
|
const isLoopUpdate = cmdBase === '/session' && args?.resource === 'loop';
|
|
3277
3323
|
const isFullAccessUpdate = cmdBase === '/session' && args?.resource === 'fullaccess';
|
|
3278
3324
|
if (isLoopUpdate) {
|
|
@@ -3286,7 +3332,7 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3286
3332
|
return { error: `idleSeconds 必须是 ${MIN_SESSION_LOOP_SECONDS}-${MAX_SESSION_LOOP_SECONDS} 的整数`, code: 'INVALID_ARGUMENT' };
|
|
3287
3333
|
}
|
|
3288
3334
|
}
|
|
3289
|
-
else if (!isFullAccessUpdate && typeof value !== 'string') {
|
|
3335
|
+
else if (!isFullAccessUpdate && !isEventCenterUpdate && typeof value !== 'string') {
|
|
3290
3336
|
return { error: 'value 必须是字符串', code: 'INVALID_ARGUMENT' };
|
|
3291
3337
|
}
|
|
3292
3338
|
if (isFullAccessUpdate && (typeof value !== 'boolean'
|
|
@@ -3343,6 +3389,39 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3343
3389
|
fromControlChannel,
|
|
3344
3390
|
subject: authSubject,
|
|
3345
3391
|
});
|
|
3392
|
+
if (isEventCenterUpdate) {
|
|
3393
|
+
if (!isTeamWorkspaceOwnerSubject(subject))
|
|
3394
|
+
return { error: EVENT_CENTER_OWNER_ONLY, code: 'FORBIDDEN' };
|
|
3395
|
+
let updateArgs = { ...(args ?? {}) };
|
|
3396
|
+
if (updateArgs.resource === 'center' && typeof value === 'boolean') {
|
|
3397
|
+
if (updateArgs.enabled !== undefined && updateArgs.enabled !== value) {
|
|
3398
|
+
return { error: 'events center args.enabled conflicts with value', code: 'INVALID_ARGUMENT' };
|
|
3399
|
+
}
|
|
3400
|
+
updateArgs.enabled = value;
|
|
3401
|
+
}
|
|
3402
|
+
else if (value !== undefined && updateArgs.resource !== 'center') {
|
|
3403
|
+
if (typeof value !== 'string')
|
|
3404
|
+
return { error: 'events structured value must be a JSON object string', code: 'INVALID_ARGUMENT' };
|
|
3405
|
+
let parsed;
|
|
3406
|
+
try {
|
|
3407
|
+
parsed = JSON.parse(value);
|
|
3408
|
+
}
|
|
3409
|
+
catch {
|
|
3410
|
+
return { error: 'events value must be valid JSON', code: 'INVALID_ARGUMENT' };
|
|
3411
|
+
}
|
|
3412
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
3413
|
+
return { error: 'events value must be a JSON object', code: 'INVALID_ARGUMENT' };
|
|
3414
|
+
updateArgs = { ...parsed, ...updateArgs };
|
|
3415
|
+
}
|
|
3416
|
+
try {
|
|
3417
|
+
return { data: await executeEventsUpdate(eventsMenuContext(this, subject), updateArgs) };
|
|
3418
|
+
}
|
|
3419
|
+
catch (error) {
|
|
3420
|
+
if (error && typeof error === 'object' && 'code' in error)
|
|
3421
|
+
return { error: String(error.message ?? 'event center error'), code: String(error.code) };
|
|
3422
|
+
return { error: error instanceof Error ? error.message : String(error), code: 'INTERNAL_ERROR' };
|
|
3423
|
+
}
|
|
3424
|
+
}
|
|
3346
3425
|
if (isLoopUpdate) {
|
|
3347
3426
|
try {
|
|
3348
3427
|
const route = { channel, channelId, selfAid: subject.selfAid ?? '', threadId: transportReplyContext?.threadId };
|
|
@@ -3558,6 +3637,7 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3558
3637
|
}
|
|
3559
3638
|
const previousBaseagent = evolagent.baseagent;
|
|
3560
3639
|
try {
|
|
3640
|
+
await this.ensureAgent(channel, arg, evolagent.aid);
|
|
3561
3641
|
evolagent.setActiveBaseagent(arg);
|
|
3562
3642
|
}
|
|
3563
3643
|
catch (error) {
|
|
@@ -3585,7 +3665,7 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3585
3665
|
});
|
|
3586
3666
|
if ('error' in target)
|
|
3587
3667
|
return target;
|
|
3588
|
-
const agent = this.
|
|
3668
|
+
const agent = await this.ensureAgent(channel, target.baseagent, target.sel.self);
|
|
3589
3669
|
const requestedModel = arg;
|
|
3590
3670
|
if (hasModelSwitcher(agent)) {
|
|
3591
3671
|
const catalog = await getCatalog(target.sel.self, target.baseagent);
|
|
@@ -3646,7 +3726,7 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3646
3726
|
});
|
|
3647
3727
|
if ('error' in target)
|
|
3648
3728
|
return target;
|
|
3649
|
-
const agent = this.
|
|
3729
|
+
const agent = await this.ensureAgent(channel, target.baseagent, target.sel.self);
|
|
3650
3730
|
const modelTarget = { ...target, field: 'model', fieldPath: `baseagents.${target.baseagent}.model` };
|
|
3651
3731
|
const currentModel = readMenuModel(modelTarget, agent, session?.agentSessionId).value;
|
|
3652
3732
|
if (!currentModel) {
|
|
@@ -3709,16 +3789,9 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3709
3789
|
if (target.field === 'group' && arg !== 'proactive') {
|
|
3710
3790
|
return { error: '群聊仅支持 proactive 模式', code: 'NOT_APPLICABLE' };
|
|
3711
3791
|
}
|
|
3712
|
-
if (arg === '
|
|
3713
|
-
return { error: 'paactive 模式仅限 owner', code: 'ROLE_VALUE_NOT_ALLOWED' };
|
|
3714
|
-
}
|
|
3715
|
-
if ((arg === 'interactive' || arg === 'paactive') && target.roleLocked) {
|
|
3792
|
+
if (arg === 'interactive' && target.roleLocked) {
|
|
3716
3793
|
return { error: '私聊交互模式仅限 owner/admin,当前角色固定为 proactive', code: 'ROLE_VALUE_NOT_ALLOWED' };
|
|
3717
3794
|
}
|
|
3718
|
-
if (arg === 'paactive' && (target.field !== 'private'
|
|
3719
|
-
|| (target.scope === 'relation' && !target.sel.peerKey?.startsWith('aun#')))) {
|
|
3720
|
-
return { error: 'paactive 仅支持 AUN 人类私聊', code: 'NOT_APPLICABLE' };
|
|
3721
|
-
}
|
|
3722
3795
|
const roleDecision = validateRuntimeStringFieldOverride({
|
|
3723
3796
|
selfAid: target.sel.self,
|
|
3724
3797
|
role: target.role,
|
|
@@ -3729,7 +3802,7 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3729
3802
|
return { error: roleDecision.message || '当前角色不允许修改对话模式', code: roleDecision.code || 'ROLE_VALUE_NOT_ALLOWED' };
|
|
3730
3803
|
}
|
|
3731
3804
|
try {
|
|
3732
|
-
writeChatmodeConfig(target, arg
|
|
3805
|
+
writeChatmodeConfig(target, arg);
|
|
3733
3806
|
}
|
|
3734
3807
|
catch (e) {
|
|
3735
3808
|
return { error: e?.message || String(e), code: e?.code || 'CONFIG_WRITE_FAILED', ...(e?.data !== undefined ? { data: e.data } : {}) };
|
|
@@ -3891,6 +3964,34 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
3891
3964
|
return dataRootFailure(error);
|
|
3892
3965
|
}
|
|
3893
3966
|
}
|
|
3967
|
+
if (cmdBase === '/events') {
|
|
3968
|
+
if (!isTeamWorkspaceOwnerSubject(subject))
|
|
3969
|
+
return { error: EVENT_CENTER_OWNER_ONLY, code: 'FORBIDDEN' };
|
|
3970
|
+
try {
|
|
3971
|
+
return { data: await executeEventsUpdate(eventsMenuContext(this, subject), args ?? {}) };
|
|
3972
|
+
}
|
|
3973
|
+
catch (error) {
|
|
3974
|
+
if (error && typeof error === 'object' && 'code' in error)
|
|
3975
|
+
return { error: String(error.message ?? 'event center error'), code: String(error.code) };
|
|
3976
|
+
return { error: error instanceof Error ? error.message : String(error), code: 'INTERNAL_ERROR' };
|
|
3977
|
+
}
|
|
3978
|
+
}
|
|
3979
|
+
if (cmdBase === '/team-workspace') {
|
|
3980
|
+
if (!isTeamWorkspaceOwnerSubject(subject))
|
|
3981
|
+
return { error: 'Team Workspace Menu is available only to the current Agent Owner in a private AUN chat', code: 'FORBIDDEN' };
|
|
3982
|
+
if (isTeamMembersMenuRequest({ type: 'menu.action', action }))
|
|
3983
|
+
return executeTeamMembersAction(subject.selfAid, action, args);
|
|
3984
|
+
if (action !== 'retry-initialization')
|
|
3985
|
+
return { error: 'Unsupported team-workspace action', code: 'NOT_SUPPORTED' };
|
|
3986
|
+
if (!this.teamWorkspaceManagementService)
|
|
3987
|
+
return { error: 'Team workspace management is unavailable', code: 'DEPENDENCY_UNAVAILABLE' };
|
|
3988
|
+
try {
|
|
3989
|
+
return { data: await this.teamWorkspaceManagementService.retryInitialization(subject, args) };
|
|
3990
|
+
}
|
|
3991
|
+
catch (error) {
|
|
3992
|
+
return dataRootFailure(error);
|
|
3993
|
+
}
|
|
3994
|
+
}
|
|
3894
3995
|
if (cmdBase === '/system' && fromControlChannel && !subject.isDaemonOwner && subject.processRole !== 'daemon-service') {
|
|
3895
3996
|
return {
|
|
3896
3997
|
error: formatAuthorizationDenial('This daemon-level operation requires DaemonOwner.', 'DAEMON_OWNER_REQUIRED'),
|
|
@@ -4424,7 +4525,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4424
4525
|
return { error: '历史上下文分叉仅支持私聊', code: 'NOT_SUPPORTED' };
|
|
4425
4526
|
if (!source.agentSessionId)
|
|
4426
4527
|
return { error: '来源会话暂无对话历史', code: 'INVALID_STATE' };
|
|
4427
|
-
const agent = this.
|
|
4528
|
+
const agent = await this.ensureAgent(channel, source.baseagent);
|
|
4428
4529
|
if (!agent.capabilities?.forkAtTurn || !agent.getSessionMessages || !agent.forkSessionAt) {
|
|
4429
4530
|
return { error: `当前 Agent (${agent.name}) 不支持按轮次分叉`, code: 'NOT_SUPPORTED' };
|
|
4430
4531
|
}
|
|
@@ -4517,7 +4618,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4517
4618
|
if (!current.agentSessionId) {
|
|
4518
4619
|
return { error: '来源会话暂无对话历史', code: 'INVALID_STATE' };
|
|
4519
4620
|
}
|
|
4520
|
-
const currentAgent = this.
|
|
4621
|
+
const currentAgent = await this.ensureAgent(channel, current.baseagent);
|
|
4521
4622
|
if (!currentAgent.capabilities?.forkAtTurn || !currentAgent.getSessionMessages || !currentAgent.forkSessionAt) {
|
|
4522
4623
|
return { error: `当前 Agent (${currentAgent.name}) 不支持按轮次分叉`, code: 'NOT_SUPPORTED' };
|
|
4523
4624
|
}
|
|
@@ -4685,7 +4786,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4685
4786
|
}
|
|
4686
4787
|
if (topic.agentSessionId) {
|
|
4687
4788
|
try {
|
|
4688
|
-
const targetAgent = this.
|
|
4789
|
+
const targetAgent = await this.ensureAgent(channel, topic.baseagent);
|
|
4689
4790
|
await targetAgent.setSessionName?.(topic.agentSessionId, newName);
|
|
4690
4791
|
}
|
|
4691
4792
|
catch { }
|
|
@@ -4706,7 +4807,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4706
4807
|
if (!success)
|
|
4707
4808
|
return { error: '删除失败', code: 'DELETE_FAILED' };
|
|
4708
4809
|
this.eventBus.publish({ type: 'session:deleted', sessionId: topic.id });
|
|
4709
|
-
const targetAgent = this.
|
|
4810
|
+
const targetAgent = await this.ensureAgent(channel, topic.baseagent);
|
|
4710
4811
|
await targetAgent.closeSession?.(topic.id);
|
|
4711
4812
|
return { data: { deleted: true } };
|
|
4712
4813
|
}
|
|
@@ -4716,7 +4817,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4716
4817
|
if (!session)
|
|
4717
4818
|
return { error: '当前无活跃会话', code: 'NO_ACTIVE_SESSION' };
|
|
4718
4819
|
const sessionKey = this.getQueueKey(session, channel, channelId);
|
|
4719
|
-
const sessionAgent = this.
|
|
4820
|
+
const sessionAgent = await this.ensureAgent(channel, session.baseagent);
|
|
4720
4821
|
const hasActive = sessionAgent.hasActiveStream(sessionKey);
|
|
4721
4822
|
const queueLength = this.messageQueue.getQueueLength(sessionKey);
|
|
4722
4823
|
if (queueLength === 0 && !hasActive) {
|
|
@@ -4765,7 +4866,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4765
4866
|
return { error: '重命名失败', code: 'EXEC_FAILED' };
|
|
4766
4867
|
if (targetSession.agentSessionId) {
|
|
4767
4868
|
try {
|
|
4768
|
-
const targetAgent = this.
|
|
4869
|
+
const targetAgent = await this.ensureAgent(channel, targetSession.baseagent);
|
|
4769
4870
|
await targetAgent.setSessionName?.(targetSession.agentSessionId, newName);
|
|
4770
4871
|
}
|
|
4771
4872
|
catch { }
|
|
@@ -5271,13 +5372,16 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
5271
5372
|
if (args?.rootId !== undefined) {
|
|
5272
5373
|
try {
|
|
5273
5374
|
const resolved = dataRootResolver.resolvePath(args.rootId, subject, dirArg, 'directory');
|
|
5375
|
+
const workspace = resolved.scope === 'team' ? teamWorkspaceStore.require(resolved.targetAid) : undefined;
|
|
5274
5376
|
listed = listDirectory(resolved.realPath, {
|
|
5275
5377
|
offset,
|
|
5276
5378
|
limit,
|
|
5277
5379
|
includeHidden,
|
|
5278
5380
|
projectPath: resolved.rootPath,
|
|
5279
5381
|
role: undefined,
|
|
5280
|
-
|
|
5382
|
+
resolveWorkspaceChild: workspace
|
|
5383
|
+
? name => teamWorkspaceStore.resolvePath(workspace, path.posix.join(resolved.relativePath, name)).stat
|
|
5384
|
+
: undefined,
|
|
5281
5385
|
});
|
|
5282
5386
|
responsePath = resolved.relativePath;
|
|
5283
5387
|
dataRoot = resolved;
|
|
@@ -5471,10 +5575,11 @@ async function execMenuForSystemControl(payload, context) {
|
|
|
5471
5575
|
const requestedContextKind = payload?.args?.context?.kind;
|
|
5472
5576
|
const isRoleRequest = name === 'role' || compatCmd === '/role';
|
|
5473
5577
|
const isConnectRequest = name === 'connect' || compatCmd === '/connect';
|
|
5474
|
-
const requiresAgentTarget =
|
|
5475
|
-
|
|
5578
|
+
const requiresAgentTarget = (name === 'menu' && payload?.type === 'menu.query' && payload?.args?.view === 'queries')
|
|
5579
|
+
|| isRoleRequest || isConnectRequest || [
|
|
5580
|
+
'observable', 'baseagent', 'model', 'effort', 'trigger', 'capability', 'group', 'aid', 'team-workspace', 'slash-commands', 'events',
|
|
5476
5581
|
].includes(name)
|
|
5477
|
-
|| ['/observable', '/baseagent', '/model', '/effort', '/trigger', '/capability', '/group', '/aid', '/
|
|
5582
|
+
|| ['/observable', '/baseagent', '/model', '/effort', '/trigger', '/capability', '/group', '/aid', '/team-workspace', '/evolhelp', '/events'].includes(compatCmd ?? '')
|
|
5478
5583
|
|| (!isProcessLevel && requestedContextKind !== undefined && requestedContextKind !== 'process');
|
|
5479
5584
|
const target = isProcessLevel
|
|
5480
5585
|
? { channel: SYSTEM_CONTROL_CHANNEL }
|
|
@@ -5572,6 +5677,14 @@ async function execMenuForSystemControl(payload, context) {
|
|
|
5572
5677
|
return ecwebErr(id, name, 'NOT_SUPPORTED', `Unsupported menu.list view: ${String(payload.args.view)}`);
|
|
5573
5678
|
return menuSuccess({ id }, this.getMenuItems(trustedIdentity.role, 'private', 'control', trustedSubject));
|
|
5574
5679
|
case 'menu.query': {
|
|
5680
|
+
if (name === 'menu' && payload?.args?.view === 'queries') {
|
|
5681
|
+
const data = await execMenuQueryBatch({
|
|
5682
|
+
subject: trustedSubject, channelType: 'aun', channelScope: 'control',
|
|
5683
|
+
channelId: targetChannel, args: payload.args,
|
|
5684
|
+
execQuery: (entryCmd, resolvedChannelId, queryArgs, querySubject) => this.execMenuQuery(entryCmd, targetChannel, resolvedChannelId, querySubject.actorId, queryArgs, querySubject.chatType, true, querySubject.identity, querySubject, context.source),
|
|
5685
|
+
});
|
|
5686
|
+
return menuSuccess({ id, ...(name ? { name } : {}) }, data);
|
|
5687
|
+
}
|
|
5575
5688
|
if (name === 'menu' && payload?.args?.view === 'values') {
|
|
5576
5689
|
validateMenuValueBatchArgs(payload.args);
|
|
5577
5690
|
const data = await execMenuValueBatch({
|
|
@@ -5623,8 +5736,9 @@ async function execMenuForSystemControl(payload, context) {
|
|
|
5623
5736
|
case 'menu.update': {
|
|
5624
5737
|
if (!cmd)
|
|
5625
5738
|
return ecwebErr(id, name, 'MISSING_CMD', '缺少 name/cmd');
|
|
5626
|
-
|
|
5627
|
-
|
|
5739
|
+
const isEventsUpdate = name === 'events' || menuCommandToken(payload?.cmd) === '/events';
|
|
5740
|
+
if (!isEventsUpdate && (payload.value === undefined || payload.value === null
|
|
5741
|
+
|| (typeof payload.value === 'string' && payload.value.length === 0))) {
|
|
5628
5742
|
return ecwebErr(id, name, 'MISSING_VALUE', '缺少 value');
|
|
5629
5743
|
}
|
|
5630
5744
|
const execution = await resolveExplicitMenuExecutionContext({
|