evolcore 0.0.43-test.5 → 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 +95 -0
- package/bin/ecmsg.js +281 -81
- package/dist/agents/baseagent-availability.js +20 -5
- package/dist/agents/baseagent.js +2 -2
- package/dist/agents/claude-runner.js +19 -4
- package/dist/agents/codex/app-server-client.js +36 -3
- package/dist/agents/codex-runner.js +75 -8
- package/dist/aun/group/invite-service.js +3 -2
- package/dist/aun/msg/p2p.js +6 -1
- package/dist/aun/service-proxy.js +18 -6
- package/dist/channels/aun.js +306 -30
- package/dist/cli/agent-create.js +18 -8
- package/dist/cli/aun-commands.js +9 -1
- package/dist/cli/daemon-commands.js +34 -65
- package/dist/cli/daemon-lifecycle-client.js +61 -0
- package/dist/cli/ecmsg-gateway.js +38 -3
- package/dist/cli/events-command.js +73 -0
- package/dist/cli/index.js +31 -14
- package/dist/cli/init.js +75 -0
- package/dist/cli/invoke-command.js +182 -0
- package/dist/cli/managed-command-guard.js +6 -1
- package/dist/cli/provider-command.js +1 -1
- package/dist/cli/restart-monitor.js +67 -50
- package/dist/cli/services-command.js +111 -0
- package/dist/cli/task-context.js +38 -1
- package/dist/cli/team-workspace-command.js +134 -0
- package/dist/cli/thread-command.js +6 -2
- package/dist/cli/watch-logs.js +6 -4
- package/dist/cli/watch-msg.js +1 -1
- package/dist/config/boot-log.js +6 -4
- package/dist/config/builtin-roles.js +2 -2
- package/dist/config/config-field-policy.js +2 -2
- package/dist/config/config-manager.js +1 -8
- package/dist/config/invoke-ipc-service.js +118 -0
- package/dist/config/peer-role-resolver.js +1 -1
- package/dist/config/provider-identity-migration.js +92 -17
- package/dist/config/provider-local-sync.js +2 -0
- package/dist/config/providers-config.js +13 -0
- package/dist/config/providers-management.js +100 -10
- package/dist/config/role-service.js +8 -8
- package/dist/config/role-store.js +22 -22
- package/dist/config/schema-migration.js +86 -88
- package/dist/config/snapshot.js +70 -41
- package/dist/config-store.js +2 -1
- package/dist/core/agent-reload-coordinator.js +6 -4
- package/dist/core/agent-runtime.js +146 -15
- package/dist/core/auth/delegation-authorization.js +66 -0
- package/dist/core/auth/operation-catalog.js +20 -0
- package/dist/core/baseagent-loader.js +75 -42
- package/dist/core/channel-loader.js +45 -13
- package/dist/core/channel-runtime.js +116 -45
- 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 +58 -16
- 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 +206 -87
- package/dist/core/command/menu-protocol.js +142 -22
- package/dist/core/command/menu-query-batch.js +194 -0
- package/dist/core/command/role-menu.js +27 -15
- 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 +45 -15
- package/dist/core/daemon-lifecycle.js +478 -75
- package/dist/core/handoff/dispatcher.js +9 -3
- package/dist/core/handoff/runtime.js +130 -42
- package/dist/core/handoff/store.js +190 -2
- package/dist/core/handoff/types.js +5 -0
- package/dist/core/initialization/service.js +4 -4
- 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 +51 -11
- package/dist/core/lifecycle-notice.js +10 -4
- package/dist/core/memory/consolidation.js +7 -5
- package/dist/core/message/aun-ipc-sender.js +149 -19
- package/dist/core/message/im-renderer.js +28 -84
- package/dist/core/message/message-bridge.js +57 -4
- package/dist/core/message/message-queue.js +46 -4
- package/dist/core/message/message-utils.js +10 -2
- package/dist/core/message/peer-mode.js +7 -34
- package/dist/core/message/pending-hints.js +4 -10
- package/dist/core/message/response-engine.js +163 -52
- package/dist/core/message/send-options.js +7 -4
- package/dist/core/message/send-routing.js +55 -7
- package/dist/core/ownership/owner-resolver.js +8 -0
- package/dist/core/permission/ec-command-parser.js +14 -3
- package/dist/core/permission/protected-paths.js +12 -2
- package/dist/core/permission/shell-environment.js +9 -0
- package/dist/core/session/adapters/claude-session-file-adapter.js +24 -0
- package/dist/core/session/adapters/codex-session-file-adapter.js +80 -0
- package/dist/core/session/adapters/ecagent-session-file-adapter.js +22 -0
- package/dist/core/session/adapters/gemini-session-file-adapter.js +39 -0
- package/dist/core/session/session-file-health.js +243 -0
- package/dist/core/session/session-fs-store.js +163 -3
- package/dist/core/session/session-idle-monitor.js +9 -1
- package/dist/core/session/session-manager.js +36 -2
- 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 +42 -30
- package/dist/directory/owner-directory-cache.js +143 -126
- package/dist/directory/owner-directory-query-operation.js +9 -8
- 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 +14 -8
- package/dist/ecweb/runtime/supervisor.js +62 -30
- 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 +751 -268
- package/dist/ipc.js +66 -12
- package/dist/paths.js +20 -0
- package/dist/product.js +14 -0
- package/dist/proxy/manager.js +43 -18
- package/dist/proxy/service-supervisor.js +78 -35
- 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 +21 -1
- package/dist/trigger/audit.js +19 -4
- package/dist/trigger/authorization.js +14 -5
- package/dist/trigger/event-source.js +1 -1
- package/dist/trigger/history.js +176 -7
- package/dist/trigger/ipc-service.js +3 -1
- package/dist/trigger/manager.js +1 -3
- package/dist/trigger/scheduler.js +78 -5
- package/dist/trigger/script-sandbox.js +118 -22
- package/dist/utils/cross-platform.js +175 -13
- package/dist/utils/evolcore-version.js +69 -27
- package/dist/utils/host-info.js +11 -8
- package/dist/utils/instance-registry.js +19 -13
- package/dist/utils/npm-ops.js +48 -0
- package/dist/utils/process-introspect.js +109 -10
- package/dist/utils/startup-trace.js +222 -44
- package/dist/utils/windows-shell-trust.js +80 -6
- package/kits/docs/INDEX.md +2 -2
- package/kits/docs/aun/ABILITY_CALLING.md +10 -17
- package/kits/docs/context-assembly.md +1 -1
- package/kits/docs/evolcore/INDEX.md +5 -2
- package/kits/docs/evolcore/ability.md +4 -0
- package/kits/docs/evolcore/aid.md +1 -1
- package/kits/docs/evolcore/ctl.md +2 -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 +2 -2
- package/kits/docs/evolcore/memory-architecture.md +2 -0
- package/kits/docs/evolcore/menu-exec-schema-commands.md +1 -1
- package/kits/docs/evolcore/menu-protocol.md +21 -0
- package/kits/docs/evolcore/msg.md +27 -8
- package/kits/docs/evolcore/provider.md +23 -3
- 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 +45 -7
- package/kits/eck_message_manifest.json +3 -3
- package/kits/rules/02-navigation.md +10 -1
- package/kits/rules/06-channel.md +5 -6
- 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/daemon.schema.1.json +5 -0
- package/kits/schemas/daemon.schema.2.json +5 -0
- package/kits/schemas/daemon.schema.3.json +2 -1
- package/kits/schemas/daemon.schema.4.json +2 -1
- package/kits/schemas/daemon.schema.5.json +2 -1
- package/kits/schemas/daemon.schema.6.json +1 -1
- package/kits/schemas/daemon.schema.7.json +1 -1
- package/kits/schemas/daemon.schema.8.json +2 -1
- package/kits/schemas/daemon.schema.9.json +2 -1
- package/kits/schemas/relation-config.schema.12.json +2 -3
- package/kits/schemas/role-config.schema.2.json +4 -4
- package/kits/schemas/role-registry.schema.1.json +2 -2
- package/kits/schemas/single-session.schema.1.json +1 -1
- package/kits/schemas/single-session.schema.2.json +1 -1
- package/kits/schemas/single-session.schema.3.json +1 -1
- 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-group/SKILL.md +8 -5
- package/kits/skills/ec-group-collaboration/SKILL.md +7 -7
- package/kits/skills/ec-service-proxy/SKILL.md +34 -5
- package/kits/skills/ec-trigger/SKILL.md +4 -4
- 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/skills/thread-ops/SKILL.md +10 -10
- package/kits/templates/system-fragments/channel.md +3 -3
- package/kits/templates/system-fragments/commands.md +9 -7
- package/kits/templates/system-fragments/reply.md +2 -6
- package/kits/templates/system-fragments/session.md +1 -1
- package/kits/templates/system-fragments/thread.md +11 -9
- package/package.json +5 -6
- 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));
|
|
@@ -2032,9 +2043,14 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
2032
2043
|
}
|
|
2033
2044
|
}
|
|
2034
2045
|
const metadataOnly = args?.metadataOnly === true;
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2046
|
+
const topics = sessions.filter((s) => isTopicSession(s)
|
|
2047
|
+
&& (!hasLabel || s.label === label) && (!topicStatus || s.topicStatus === topicStatus));
|
|
2048
|
+
const items = [];
|
|
2049
|
+
for (let offset = 0; offset < topics.length; offset += 4) {
|
|
2050
|
+
items.push(...await Promise.all(topics.slice(offset, offset + 4)
|
|
2051
|
+
.map((s) => this.buildTopicMenuItem(s, metadataOnly))));
|
|
2052
|
+
}
|
|
2053
|
+
return items;
|
|
2038
2054
|
}
|
|
2039
2055
|
if (cmd === '/s' || cmd === '/session' || cmd === '/del') {
|
|
2040
2056
|
const sessions = await this.sessionManager.listSessions(channel, channelId);
|
|
@@ -2078,12 +2094,7 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
2078
2094
|
const available = requestedAgent?.name
|
|
2079
2095
|
? (this.getAvailableBaseagentsForOwner?.(requestedAgent.name) ?? [])
|
|
2080
2096
|
: this.getAvailableBaseagents(channel);
|
|
2081
|
-
|
|
2082
|
-
config: { active_baseagent: currentAgent }, loaded: available, probe: false,
|
|
2083
|
-
});
|
|
2084
|
-
return inventory.baseagents
|
|
2085
|
-
.filter(item => item.loaded === true)
|
|
2086
|
-
.map(item => ({ value: item.id, label: item.id, selected: item.id === currentAgent }));
|
|
2097
|
+
return available.map((id) => ({ value: id, label: id, selected: id === currentAgent }));
|
|
2087
2098
|
}
|
|
2088
2099
|
if (cmd === '/model') {
|
|
2089
2100
|
const target = resolveMenuModelTarget.call(this, {
|
|
@@ -2101,7 +2112,7 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
2101
2112
|
throw { code: target.code, message: target.error };
|
|
2102
2113
|
let agent;
|
|
2103
2114
|
try {
|
|
2104
|
-
agent = this.
|
|
2115
|
+
agent = await this.ensureAgent(channel, target.baseagent, target.sel.self);
|
|
2105
2116
|
}
|
|
2106
2117
|
catch (error) {
|
|
2107
2118
|
if (isDaemonControlSubject(subject)) {
|
|
@@ -2172,7 +2183,7 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
2172
2183
|
throw { code: target.code, message: target.error };
|
|
2173
2184
|
let agent;
|
|
2174
2185
|
try {
|
|
2175
|
-
agent = this.
|
|
2186
|
+
agent = await this.ensureAgent(channel, target.baseagent, target.sel.self);
|
|
2176
2187
|
}
|
|
2177
2188
|
catch (error) {
|
|
2178
2189
|
if (isDaemonControlSubject(subject)) {
|
|
@@ -2209,9 +2220,6 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
2209
2220
|
...(target.field !== 'group'
|
|
2210
2221
|
? [{ value: 'interactive', label: '交互模式', selected: currentMode === 'interactive' }] : []),
|
|
2211
2222
|
{ value: 'proactive', label: '主动模式', selected: currentMode === 'proactive' },
|
|
2212
|
-
...(target.field === 'private' && target.role === 'owner'
|
|
2213
|
-
&& (target.scope === 'agent' || target.sel.peerKey?.startsWith('aun#'))
|
|
2214
|
-
? [{ value: 'paactive', label: 'PA 模式', selected: currentMode === 'paactive' }] : []),
|
|
2215
2223
|
];
|
|
2216
2224
|
}
|
|
2217
2225
|
if (cmd === '/mention') {
|
|
@@ -2385,15 +2393,55 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2385
2393
|
return dataRootFailure(error);
|
|
2386
2394
|
}
|
|
2387
2395
|
}
|
|
2388
|
-
if (cmdBase === '/
|
|
2389
|
-
|
|
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']);
|
|
2390
2414
|
const unknown = Object.keys(args ?? {}).find(key => !allowed.has(key));
|
|
2391
2415
|
if (unknown)
|
|
2392
|
-
return { error: `
|
|
2393
|
-
if (!args || typeof args.view !== 'string' || !['navigation', 'calendar', 'items'].includes(args.view))
|
|
2394
|
-
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' };
|
|
2395
2443
|
if (args?.protocolVersion !== undefined && args.protocolVersion !== 1) {
|
|
2396
|
-
return { error: 'Unsupported
|
|
2444
|
+
return { error: 'Unsupported Team workspace protocol version', code: 'SCHEMA_VERSION_UNSUPPORTED' };
|
|
2397
2445
|
}
|
|
2398
2446
|
if (args.view !== 'calendar' && (args.from !== undefined || args.to !== undefined || args.timezone !== undefined)) {
|
|
2399
2447
|
return { error: 'from, to and timezone are only valid for calendar view', code: 'INVALID_ARGUMENT' };
|
|
@@ -2402,20 +2450,23 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2402
2450
|
return { error: 'path, offset, limit and indexRevision are only valid for items view', code: 'INVALID_ARGUMENT' };
|
|
2403
2451
|
}
|
|
2404
2452
|
try {
|
|
2453
|
+
if (this.teamWorkspaceManagementService)
|
|
2454
|
+
await this.teamWorkspaceManagementService.ensureReady(subject);
|
|
2405
2455
|
if (args.view === 'items')
|
|
2406
|
-
|
|
2407
|
-
const root = dataRootResolver.
|
|
2408
|
-
const navigation =
|
|
2409
|
-
const state =
|
|
2456
|
+
validateTeamWorkspaceItemsArgs(args);
|
|
2457
|
+
const root = dataRootResolver.issueTeamWorkspaceRoot(subject);
|
|
2458
|
+
const navigation = readTeamWorkspaceNavigation(root.targetAid);
|
|
2459
|
+
const state = teamWorkspaceStore.require(root.targetAid);
|
|
2410
2460
|
if (args.view === 'items') {
|
|
2411
|
-
const items = await
|
|
2461
|
+
const items = await teamWorkspaceItemsIndex.query(root.targetAid, state, args);
|
|
2412
2462
|
// Building the initial index yields to other requests. Recheck owner,
|
|
2413
2463
|
// binding and navigation before sending any cached private summary.
|
|
2414
|
-
dataRootResolver.
|
|
2415
|
-
const current =
|
|
2464
|
+
dataRootResolver.issueTeamWorkspaceRoot(subject);
|
|
2465
|
+
const current = teamWorkspaceStore.require(root.targetAid);
|
|
2416
2466
|
if (current.workspaceId !== state.workspaceId || current.ownerAid !== state.ownerAid
|
|
2417
|
-
|| current.rootPath !== state.rootPath || current.
|
|
2418
|
-
|
|
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');
|
|
2419
2470
|
}
|
|
2420
2471
|
return { data: items };
|
|
2421
2472
|
}
|
|
@@ -2429,7 +2480,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2429
2480
|
.filter((definition) => this.canAccessTriggerDefinition(definition, userId ?? '', channel, isAdmin));
|
|
2430
2481
|
return {
|
|
2431
2482
|
data: {
|
|
2432
|
-
...
|
|
2483
|
+
...queryTeamWorkspaceCalendar({
|
|
2433
2484
|
state,
|
|
2434
2485
|
navigation,
|
|
2435
2486
|
scheduler: scheduler && visibleDefinitions
|
|
@@ -2451,10 +2502,10 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2451
2502
|
};
|
|
2452
2503
|
}
|
|
2453
2504
|
// Start preparing cards while the user is still in the conversation.
|
|
2454
|
-
|
|
2505
|
+
teamWorkspaceItemsIndex.warm(root.targetAid, state);
|
|
2455
2506
|
return {
|
|
2456
2507
|
data: {
|
|
2457
|
-
protocol: 'evol.
|
|
2508
|
+
protocol: 'evol.team-workspace',
|
|
2458
2509
|
protocolVersion: 1,
|
|
2459
2510
|
workspaceId: navigation.workspaceId,
|
|
2460
2511
|
navigationRevision: navigation.navigationRevision,
|
|
@@ -2774,11 +2825,11 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2774
2825
|
return { data: { scope: 'retained-history', tasks: this.sessionManager.getRunnerTaskHistory(session.id) } };
|
|
2775
2826
|
}
|
|
2776
2827
|
const sessionKey = this.getQueueKey(session, channel, channelId);
|
|
2777
|
-
const sessionAgent = this.
|
|
2778
|
-
const isProcessing = this.messageQueue.isProcessing(sessionKey) || sessionAgent
|
|
2779
|
-
|| sessionAgent
|
|
2828
|
+
const sessionAgent = this.getLoadedAgent(channel, session.baseagent);
|
|
2829
|
+
const isProcessing = this.messageQueue.isProcessing(sessionKey) || sessionAgent?.hasActiveStream(sessionKey)
|
|
2830
|
+
|| sessionAgent?.hasActiveOperation?.(sessionKey) === true;
|
|
2780
2831
|
const queueLength = this.messageQueue.getQueueLength(sessionKey);
|
|
2781
|
-
const executionState = sessionAgent
|
|
2832
|
+
const executionState = sessionAgent?.getExecutionState?.(sessionKey);
|
|
2782
2833
|
const health = await this.sessionManager.getHealthStatus(session.id);
|
|
2783
2834
|
let processingDuration;
|
|
2784
2835
|
if (isProcessing && session.processingState) {
|
|
@@ -2861,7 +2912,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2861
2912
|
const candidate = async (session) => {
|
|
2862
2913
|
if (!session?.agentSessionId || session.channel !== channel || session.channelId !== channelId)
|
|
2863
2914
|
return undefined;
|
|
2864
|
-
const agent = this.
|
|
2915
|
+
const agent = await this.ensureAgent(channel, session.baseagent);
|
|
2865
2916
|
if (!agent.getSessionMessages)
|
|
2866
2917
|
return undefined;
|
|
2867
2918
|
try {
|
|
@@ -2903,11 +2954,11 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2903
2954
|
return { data: { scope: 'retained-history', tasks: this.sessionManager.getRunnerTaskHistory(topic.id) } };
|
|
2904
2955
|
}
|
|
2905
2956
|
const sessionKey = this.getQueueKey(topic, channel, channelId);
|
|
2906
|
-
const sessionAgent = this.
|
|
2907
|
-
const isProcessing = this.messageQueue.isProcessing(sessionKey) || sessionAgent
|
|
2908
|
-
|| sessionAgent
|
|
2957
|
+
const sessionAgent = this.getLoadedAgent(channel, topic.baseagent);
|
|
2958
|
+
const isProcessing = this.messageQueue.isProcessing(sessionKey) || sessionAgent?.hasActiveStream(sessionKey)
|
|
2959
|
+
|| sessionAgent?.hasActiveOperation?.(sessionKey) === true;
|
|
2909
2960
|
const queueLength = this.messageQueue.getQueueLength(sessionKey);
|
|
2910
|
-
const executionState = sessionAgent
|
|
2961
|
+
const executionState = sessionAgent?.getExecutionState?.(sessionKey);
|
|
2911
2962
|
const health = await this.sessionManager.getHealthStatus(topic.id);
|
|
2912
2963
|
let processingDuration;
|
|
2913
2964
|
if (isProcessing && topic.processingState) {
|
|
@@ -2975,7 +3026,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2975
3026
|
});
|
|
2976
3027
|
if ('error' in target)
|
|
2977
3028
|
return target;
|
|
2978
|
-
const agent = this.
|
|
3029
|
+
const agent = await this.ensureAgent(channel, target.baseagent, target.sel.self);
|
|
2979
3030
|
const current = readMenuModel(target, agent, session?.agentSessionId);
|
|
2980
3031
|
return {
|
|
2981
3032
|
data: {
|
|
@@ -3004,7 +3055,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
3004
3055
|
});
|
|
3005
3056
|
if ('error' in target)
|
|
3006
3057
|
return target;
|
|
3007
|
-
const agent = this.
|
|
3058
|
+
const agent = await this.ensureAgent(channel, target.baseagent, target.sel.self);
|
|
3008
3059
|
const current = readMenuModel(target, agent, session?.agentSessionId);
|
|
3009
3060
|
return {
|
|
3010
3061
|
data: {
|
|
@@ -3036,7 +3087,6 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
3036
3087
|
return {
|
|
3037
3088
|
data: {
|
|
3038
3089
|
mode: current.value,
|
|
3039
|
-
...(current.fallbackReason ? { fallbackReason: current.fallbackReason } : {}),
|
|
3040
3090
|
source: current.source,
|
|
3041
3091
|
scope: target.scope,
|
|
3042
3092
|
override: readMenuScopeOverride(target.scope, target.fieldPath, target.sel),
|
|
@@ -3268,6 +3318,7 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3268
3318
|
if (cmdBase === '/provider') {
|
|
3269
3319
|
return executeProviderMenu({ name: 'provider', cmd, type: 'menu.update', args, value }, fromControlChannel ? authSubject : undefined, source);
|
|
3270
3320
|
}
|
|
3321
|
+
const isEventCenterUpdate = cmdBase === '/events';
|
|
3271
3322
|
const isLoopUpdate = cmdBase === '/session' && args?.resource === 'loop';
|
|
3272
3323
|
const isFullAccessUpdate = cmdBase === '/session' && args?.resource === 'fullaccess';
|
|
3273
3324
|
if (isLoopUpdate) {
|
|
@@ -3281,7 +3332,7 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3281
3332
|
return { error: `idleSeconds 必须是 ${MIN_SESSION_LOOP_SECONDS}-${MAX_SESSION_LOOP_SECONDS} 的整数`, code: 'INVALID_ARGUMENT' };
|
|
3282
3333
|
}
|
|
3283
3334
|
}
|
|
3284
|
-
else if (!isFullAccessUpdate && typeof value !== 'string') {
|
|
3335
|
+
else if (!isFullAccessUpdate && !isEventCenterUpdate && typeof value !== 'string') {
|
|
3285
3336
|
return { error: 'value 必须是字符串', code: 'INVALID_ARGUMENT' };
|
|
3286
3337
|
}
|
|
3287
3338
|
if (isFullAccessUpdate && (typeof value !== 'boolean'
|
|
@@ -3338,6 +3389,39 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3338
3389
|
fromControlChannel,
|
|
3339
3390
|
subject: authSubject,
|
|
3340
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
|
+
}
|
|
3341
3425
|
if (isLoopUpdate) {
|
|
3342
3426
|
try {
|
|
3343
3427
|
const route = { channel, channelId, selfAid: subject.selfAid ?? '', threadId: transportReplyContext?.threadId };
|
|
@@ -3553,6 +3637,7 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3553
3637
|
}
|
|
3554
3638
|
const previousBaseagent = evolagent.baseagent;
|
|
3555
3639
|
try {
|
|
3640
|
+
await this.ensureAgent(channel, arg, evolagent.aid);
|
|
3556
3641
|
evolagent.setActiveBaseagent(arg);
|
|
3557
3642
|
}
|
|
3558
3643
|
catch (error) {
|
|
@@ -3580,7 +3665,7 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3580
3665
|
});
|
|
3581
3666
|
if ('error' in target)
|
|
3582
3667
|
return target;
|
|
3583
|
-
const agent = this.
|
|
3668
|
+
const agent = await this.ensureAgent(channel, target.baseagent, target.sel.self);
|
|
3584
3669
|
const requestedModel = arg;
|
|
3585
3670
|
if (hasModelSwitcher(agent)) {
|
|
3586
3671
|
const catalog = await getCatalog(target.sel.self, target.baseagent);
|
|
@@ -3641,7 +3726,7 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3641
3726
|
});
|
|
3642
3727
|
if ('error' in target)
|
|
3643
3728
|
return target;
|
|
3644
|
-
const agent = this.
|
|
3729
|
+
const agent = await this.ensureAgent(channel, target.baseagent, target.sel.self);
|
|
3645
3730
|
const modelTarget = { ...target, field: 'model', fieldPath: `baseagents.${target.baseagent}.model` };
|
|
3646
3731
|
const currentModel = readMenuModel(modelTarget, agent, session?.agentSessionId).value;
|
|
3647
3732
|
if (!currentModel) {
|
|
@@ -3704,16 +3789,9 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3704
3789
|
if (target.field === 'group' && arg !== 'proactive') {
|
|
3705
3790
|
return { error: '群聊仅支持 proactive 模式', code: 'NOT_APPLICABLE' };
|
|
3706
3791
|
}
|
|
3707
|
-
if (arg === '
|
|
3708
|
-
return { error: 'paactive 模式仅限 owner', code: 'ROLE_VALUE_NOT_ALLOWED' };
|
|
3709
|
-
}
|
|
3710
|
-
if ((arg === 'interactive' || arg === 'paactive') && target.roleLocked) {
|
|
3792
|
+
if (arg === 'interactive' && target.roleLocked) {
|
|
3711
3793
|
return { error: '私聊交互模式仅限 owner/admin,当前角色固定为 proactive', code: 'ROLE_VALUE_NOT_ALLOWED' };
|
|
3712
3794
|
}
|
|
3713
|
-
if (arg === 'paactive' && (target.field !== 'private'
|
|
3714
|
-
|| (target.scope === 'relation' && !target.sel.peerKey?.startsWith('aun#')))) {
|
|
3715
|
-
return { error: 'paactive 仅支持 AUN 人类私聊', code: 'NOT_APPLICABLE' };
|
|
3716
|
-
}
|
|
3717
3795
|
const roleDecision = validateRuntimeStringFieldOverride({
|
|
3718
3796
|
selfAid: target.sel.self,
|
|
3719
3797
|
role: target.role,
|
|
@@ -3724,7 +3802,7 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3724
3802
|
return { error: roleDecision.message || '当前角色不允许修改对话模式', code: roleDecision.code || 'ROLE_VALUE_NOT_ALLOWED' };
|
|
3725
3803
|
}
|
|
3726
3804
|
try {
|
|
3727
|
-
writeChatmodeConfig(target, arg
|
|
3805
|
+
writeChatmodeConfig(target, arg);
|
|
3728
3806
|
}
|
|
3729
3807
|
catch (e) {
|
|
3730
3808
|
return { error: e?.message || String(e), code: e?.code || 'CONFIG_WRITE_FAILED', ...(e?.data !== undefined ? { data: e.data } : {}) };
|
|
@@ -3886,6 +3964,34 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
3886
3964
|
return dataRootFailure(error);
|
|
3887
3965
|
}
|
|
3888
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
|
+
}
|
|
3889
3995
|
if (cmdBase === '/system' && fromControlChannel && !subject.isDaemonOwner && subject.processRole !== 'daemon-service') {
|
|
3890
3996
|
return {
|
|
3891
3997
|
error: formatAuthorizationDenial('This daemon-level operation requires DaemonOwner.', 'DAEMON_OWNER_REQUIRED'),
|
|
@@ -4419,7 +4525,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4419
4525
|
return { error: '历史上下文分叉仅支持私聊', code: 'NOT_SUPPORTED' };
|
|
4420
4526
|
if (!source.agentSessionId)
|
|
4421
4527
|
return { error: '来源会话暂无对话历史', code: 'INVALID_STATE' };
|
|
4422
|
-
const agent = this.
|
|
4528
|
+
const agent = await this.ensureAgent(channel, source.baseagent);
|
|
4423
4529
|
if (!agent.capabilities?.forkAtTurn || !agent.getSessionMessages || !agent.forkSessionAt) {
|
|
4424
4530
|
return { error: `当前 Agent (${agent.name}) 不支持按轮次分叉`, code: 'NOT_SUPPORTED' };
|
|
4425
4531
|
}
|
|
@@ -4512,7 +4618,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4512
4618
|
if (!current.agentSessionId) {
|
|
4513
4619
|
return { error: '来源会话暂无对话历史', code: 'INVALID_STATE' };
|
|
4514
4620
|
}
|
|
4515
|
-
const currentAgent = this.
|
|
4621
|
+
const currentAgent = await this.ensureAgent(channel, current.baseagent);
|
|
4516
4622
|
if (!currentAgent.capabilities?.forkAtTurn || !currentAgent.getSessionMessages || !currentAgent.forkSessionAt) {
|
|
4517
4623
|
return { error: `当前 Agent (${currentAgent.name}) 不支持按轮次分叉`, code: 'NOT_SUPPORTED' };
|
|
4518
4624
|
}
|
|
@@ -4680,7 +4786,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4680
4786
|
}
|
|
4681
4787
|
if (topic.agentSessionId) {
|
|
4682
4788
|
try {
|
|
4683
|
-
const targetAgent = this.
|
|
4789
|
+
const targetAgent = await this.ensureAgent(channel, topic.baseagent);
|
|
4684
4790
|
await targetAgent.setSessionName?.(topic.agentSessionId, newName);
|
|
4685
4791
|
}
|
|
4686
4792
|
catch { }
|
|
@@ -4701,7 +4807,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4701
4807
|
if (!success)
|
|
4702
4808
|
return { error: '删除失败', code: 'DELETE_FAILED' };
|
|
4703
4809
|
this.eventBus.publish({ type: 'session:deleted', sessionId: topic.id });
|
|
4704
|
-
const targetAgent = this.
|
|
4810
|
+
const targetAgent = await this.ensureAgent(channel, topic.baseagent);
|
|
4705
4811
|
await targetAgent.closeSession?.(topic.id);
|
|
4706
4812
|
return { data: { deleted: true } };
|
|
4707
4813
|
}
|
|
@@ -4711,7 +4817,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4711
4817
|
if (!session)
|
|
4712
4818
|
return { error: '当前无活跃会话', code: 'NO_ACTIVE_SESSION' };
|
|
4713
4819
|
const sessionKey = this.getQueueKey(session, channel, channelId);
|
|
4714
|
-
const sessionAgent = this.
|
|
4820
|
+
const sessionAgent = await this.ensureAgent(channel, session.baseagent);
|
|
4715
4821
|
const hasActive = sessionAgent.hasActiveStream(sessionKey);
|
|
4716
4822
|
const queueLength = this.messageQueue.getQueueLength(sessionKey);
|
|
4717
4823
|
if (queueLength === 0 && !hasActive) {
|
|
@@ -4760,7 +4866,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4760
4866
|
return { error: '重命名失败', code: 'EXEC_FAILED' };
|
|
4761
4867
|
if (targetSession.agentSessionId) {
|
|
4762
4868
|
try {
|
|
4763
|
-
const targetAgent = this.
|
|
4869
|
+
const targetAgent = await this.ensureAgent(channel, targetSession.baseagent);
|
|
4764
4870
|
await targetAgent.setSessionName?.(targetSession.agentSessionId, newName);
|
|
4765
4871
|
}
|
|
4766
4872
|
catch { }
|
|
@@ -5266,13 +5372,16 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
5266
5372
|
if (args?.rootId !== undefined) {
|
|
5267
5373
|
try {
|
|
5268
5374
|
const resolved = dataRootResolver.resolvePath(args.rootId, subject, dirArg, 'directory');
|
|
5375
|
+
const workspace = resolved.scope === 'team' ? teamWorkspaceStore.require(resolved.targetAid) : undefined;
|
|
5269
5376
|
listed = listDirectory(resolved.realPath, {
|
|
5270
5377
|
offset,
|
|
5271
5378
|
limit,
|
|
5272
5379
|
includeHidden,
|
|
5273
5380
|
projectPath: resolved.rootPath,
|
|
5274
5381
|
role: undefined,
|
|
5275
|
-
|
|
5382
|
+
resolveWorkspaceChild: workspace
|
|
5383
|
+
? name => teamWorkspaceStore.resolvePath(workspace, path.posix.join(resolved.relativePath, name)).stat
|
|
5384
|
+
: undefined,
|
|
5276
5385
|
});
|
|
5277
5386
|
responsePath = resolved.relativePath;
|
|
5278
5387
|
dataRoot = resolved;
|
|
@@ -5466,10 +5575,11 @@ async function execMenuForSystemControl(payload, context) {
|
|
|
5466
5575
|
const requestedContextKind = payload?.args?.context?.kind;
|
|
5467
5576
|
const isRoleRequest = name === 'role' || compatCmd === '/role';
|
|
5468
5577
|
const isConnectRequest = name === 'connect' || compatCmd === '/connect';
|
|
5469
|
-
const requiresAgentTarget =
|
|
5470
|
-
|
|
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',
|
|
5471
5581
|
].includes(name)
|
|
5472
|
-
|| ['/observable', '/baseagent', '/model', '/effort', '/trigger', '/capability', '/group', '/aid', '/
|
|
5582
|
+
|| ['/observable', '/baseagent', '/model', '/effort', '/trigger', '/capability', '/group', '/aid', '/team-workspace', '/evolhelp', '/events'].includes(compatCmd ?? '')
|
|
5473
5583
|
|| (!isProcessLevel && requestedContextKind !== undefined && requestedContextKind !== 'process');
|
|
5474
5584
|
const target = isProcessLevel
|
|
5475
5585
|
? { channel: SYSTEM_CONTROL_CHANNEL }
|
|
@@ -5567,6 +5677,14 @@ async function execMenuForSystemControl(payload, context) {
|
|
|
5567
5677
|
return ecwebErr(id, name, 'NOT_SUPPORTED', `Unsupported menu.list view: ${String(payload.args.view)}`);
|
|
5568
5678
|
return menuSuccess({ id }, this.getMenuItems(trustedIdentity.role, 'private', 'control', trustedSubject));
|
|
5569
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
|
+
}
|
|
5570
5688
|
if (name === 'menu' && payload?.args?.view === 'values') {
|
|
5571
5689
|
validateMenuValueBatchArgs(payload.args);
|
|
5572
5690
|
const data = await execMenuValueBatch({
|
|
@@ -5618,8 +5736,9 @@ async function execMenuForSystemControl(payload, context) {
|
|
|
5618
5736
|
case 'menu.update': {
|
|
5619
5737
|
if (!cmd)
|
|
5620
5738
|
return ecwebErr(id, name, 'MISSING_CMD', '缺少 name/cmd');
|
|
5621
|
-
|
|
5622
|
-
|
|
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))) {
|
|
5623
5742
|
return ecwebErr(id, name, 'MISSING_VALUE', '缺少 value');
|
|
5624
5743
|
}
|
|
5625
5744
|
const execution = await resolveExplicitMenuExecutionContext({
|