evolcore 0.0.43-test.6 → 0.0.43-test.8
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 +188 -58
- package/dist/agent-template/jobs.js +62 -0
- package/dist/agent-template/runtime.js +214 -0
- package/dist/agent-template/service.js +465 -0
- package/dist/agent-template/tool-runner.js +45 -0
- package/dist/agent-template/types.js +5 -0
- package/dist/agents/baseagent-availability.js +1 -1
- package/dist/agents/claude-runner.js +1 -1
- package/dist/agents/codex/app-server-client.js +22 -0
- package/dist/agents/codex-runner.js +69 -2
- package/dist/aun/aid/agentmd.js +56 -1
- package/dist/aun/aid/client.js +3 -1
- package/dist/aun/menu/client.js +3 -2
- package/dist/aun/msg/p2p.js +6 -1
- package/dist/channels/aun.js +277 -49
- package/dist/cli/agent-command.js +5 -0
- package/dist/cli/agent-create.js +7 -3
- package/dist/cli/agent-template.js +124 -0
- package/dist/cli/aun-commands.js +2 -2
- package/dist/cli/ctl-command.js +2 -1
- package/dist/cli/daemon-commands.js +11 -66
- package/dist/cli/daemon-lifecycle-client.js +61 -0
- package/dist/cli/ecmsg-gateway.js +35 -2
- package/dist/cli/events-command.js +109 -0
- package/dist/cli/index.js +60 -14
- package/dist/cli/invoke-command.js +182 -0
- package/dist/cli/managed-command-guard.js +6 -1
- package/dist/cli/net-check.js +1 -1
- package/dist/cli/restart-monitor.js +160 -83
- package/dist/cli/services-command.js +137 -0
- package/dist/cli/team-workspace-command.js +134 -0
- package/dist/cli/thread-command.js +103 -13
- package/dist/cli/watch-msg.js +1 -1
- package/dist/config/boot-log.js +8 -8
- 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 +45 -15
- package/dist/config-store.js +2 -1
- package/dist/core/agent-ipc-registration.js +25 -4
- package/dist/core/agent-reload-coordinator.js +6 -4
- package/dist/core/agent-runtime.js +106 -10
- package/dist/core/auth/delegation-authorization.js +66 -0
- package/dist/core/auth/operation-authorizer.js +2 -0
- package/dist/core/auth/operation-catalog.js +29 -0
- package/dist/core/baseagent-loader.js +60 -130
- package/dist/core/channel-loader.js +10 -1
- package/dist/core/channel-runtime.js +20 -12
- package/dist/core/command/agent-control.js +12 -2
- package/dist/core/command/agent-storage-menu.js +1 -1
- package/dist/core/command/agent-template-menu.js +147 -0
- package/dist/core/command/chatmode-config.js +2 -36
- package/dist/core/command/command-handler.js +80 -17
- package/dist/core/command/data-root-resolver.js +32 -23
- package/dist/core/command/eventcenter-menu.js +468 -0
- package/dist/core/command/menu-catalog.js +15 -0
- package/dist/core/command/menu-handler.js +216 -90
- package/dist/core/command/menu-protocol.js +71 -13
- 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 +22 -5
- package/dist/core/daemon-lifecycle.js +323 -191
- package/dist/core/handoff/runtime.js +45 -13
- 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 +50 -7
- package/dist/core/legacy-rename.js +41 -0
- package/dist/core/memory/consolidation.js +7 -5
- package/dist/core/message/aun-ipc-sender.js +252 -17
- package/dist/core/message/im-renderer.js +116 -85
- package/dist/core/message/message-bridge.js +4 -0
- package/dist/core/message/message-queue.js +66 -15
- 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 +29 -5
- package/dist/core/message/response-engine.js +194 -61
- package/dist/core/message/send-options.js +7 -4
- package/dist/core/message/send-routing.js +50 -5
- package/dist/core/ownership/owner-resolver.js +7 -0
- package/dist/core/pack-auth.js +94 -0
- package/dist/core/pack-install.js +194 -0
- package/dist/core/permission/ec-command-parser.js +51 -17
- package/dist/core/permission/protected-paths.js +12 -2
- package/dist/core/permission/shell-environment.js +9 -0
- package/dist/core/rate-window.js +48 -0
- package/dist/core/relation/peer-identity.js +28 -0
- package/dist/core/session/session-file-health.js +243 -0
- package/dist/core/session/session-fs-store.js +67 -28
- package/dist/core/session/session-idle-monitor.js +59 -19
- package/dist/core/session/session-manager.js +13 -4
- 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/core/thread/thread-service.js +52 -3
- 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/eck/message-renderer.js +2 -0
- 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 +124 -0
- package/dist/event-center/bus-gate.js +154 -0
- package/dist/event-center/bus-host.js +307 -0
- package/dist/event-center/bus-resolver.js +120 -0
- package/dist/event-center/center-config.js +127 -0
- package/dist/event-center/daemon.js +44 -0
- package/dist/event-center/directory-source.js +55 -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 +73 -0
- package/dist/event-center/ipc-operation.js +423 -0
- package/dist/event-center/ledger.js +52 -0
- package/dist/event-center/pack-loader.js +207 -0
- package/dist/event-center/pack-manager.js +85 -0
- package/dist/event-center/registry.js +463 -0
- package/dist/event-center/runtime.js +837 -0
- package/dist/event-center/script-runner.js +356 -0
- package/dist/event-center/types.js +51 -0
- package/dist/event-center/validation.js +435 -0
- package/dist/index.js +424 -135
- package/dist/ipc.js +106 -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/engines/v1/proactive-flow.js +4 -2
- 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 +550 -0
- package/dist/services/ledger.js +52 -0
- package/dist/services/message-log.js +112 -0
- package/dist/services/pack-manager.js +215 -0
- package/dist/services/reply.js +55 -0
- package/dist/services/router.js +98 -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/scheduler.js +38 -0
- package/dist/trigger/script-sandbox.js +170 -24
- 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/npm-ops.js +2 -1
- package/dist/utils/package-version-info.js +6 -3
- 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 +9 -15
- package/kits/docs/context-assembly.md +1 -1
- package/kits/docs/evolcore/INDEX.md +3 -1
- package/kits/docs/evolcore/ability.md +4 -0
- package/kits/docs/evolcore/agent.md +22 -1
- package/kits/docs/evolcore/aid.md +1 -1
- package/kits/docs/evolcore/event-center.md +227 -0
- package/kits/docs/evolcore/file-navigation.md +10 -264
- package/kits/docs/evolcore/fs.md +5 -3
- package/kits/docs/evolcore/group.md +1 -1
- package/kits/docs/evolcore/memory-architecture.md +2 -0
- package/kits/docs/evolcore/menu-protocol.md +28 -1
- package/kits/docs/evolcore/msg.md +21 -9
- package/kits/docs/evolcore/provider.md +3 -1
- package/kits/docs/evolcore/response.md +5 -5
- package/kits/docs/evolcore/services.md +294 -0
- package/kits/docs/evolcore/task.md +2 -0
- package/kits/docs/evolcore/team-workspace.md +41 -0
- package/kits/docs/evolcore/thread-chain.md +15 -3
- package/kits/eck_manifest.json +26 -0
- package/kits/rules/02-navigation.md +10 -1
- package/kits/rules/06-channel.md +1 -0
- 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-group/SKILL.md +5 -8
- 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/message-fragments/item.md +1 -1
- 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 +1 -5
- package/kits/templates/system-fragments/thread.md +13 -10
- package/package.json +5 -6
- package/scripts/agent-template/index.mjs +40 -0
- package/scripts/agent-template/inspect.mjs +240 -0
- package/scripts/agent-template/overlay.mjs +71 -0
- package/scripts/agent-template/pack.mjs +169 -0
- package/scripts/agent-template/shared/common.mjs +235 -0
- package/scripts/agent-template/shared/evolcore.mjs +75 -0
- package/scripts/agent-template/shared/plan.mjs +129 -0
- package/scripts/agent-template/shared/team-schema.json +70 -0
- package/scripts/agent-template/shared/template-contract.mjs +154 -0
- package/scripts/agent-template/shared/template-package.mjs +265 -0
- package/scripts/agent-template/shared/template-runtime.mjs +80 -0
- package/scripts/agent-template/shared/template.mjs +142 -0
- 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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { memoryHelpEntries } from './memory-slash.js';
|
|
2
2
|
import { executeProviderMenu } from './provider-menu.js';
|
|
3
|
+
import { executeTemplateMenu, executeProviderModelCatalog } from './agent-template-menu.js';
|
|
3
4
|
import { getBaseagentSnapshot, loadedBaseagentIds } from '../../agents/baseagent-availability.js';
|
|
4
5
|
import { resolveBaseagentModelSelection } from '../../agents/baseagent.js';
|
|
5
6
|
import { normalizePeer, writeAgentModelConfig } from '../model/config-scope.js';
|
|
@@ -63,15 +64,18 @@ import { roleMenuAction, roleMenuOperation, roleMenuOptions, roleMenuQuery, role
|
|
|
63
64
|
import { handleConnectMenu, connectMenuOperation } from './connect-menu.js';
|
|
64
65
|
import { groupMenuAuthorizationArgs, groupMenuIntent, handleGroupMenu, } from './group-menu.js';
|
|
65
66
|
import { getMenuCatalog, execMenuValueBatch, resolveExplicitMenuExecutionContext, resolveMenuCatalogContext, validateMenuCatalogArgs, validateMenuValueBatchArgs } from './menu-catalog.js';
|
|
67
|
+
import { execMenuQueryBatch } from './menu-query-batch.js';
|
|
66
68
|
import { probeSessionActivity } from './slash-gate.js';
|
|
67
69
|
import { dataRootFailure, dataRootResolver } from './data-root-resolver.js';
|
|
68
|
-
import { DataRootError,
|
|
69
|
-
import {
|
|
70
|
-
import {
|
|
70
|
+
import { DataRootError, teamWorkspaceStore, readTeamWorkspaceNavigation } from './team-workspace-store.js';
|
|
71
|
+
import { queryTeamWorkspaceCalendar } from './team-workspace-calendar.js';
|
|
72
|
+
import { teamWorkspaceItemsIndex, validateTeamWorkspaceItemsArgs } from './team-workspace-items.js';
|
|
73
|
+
import { executeTeamMembersAction, executeTeamMembersQuery, isTeamMembersMenuRequest } from './team-workspace-members-menu.js';
|
|
71
74
|
import { agentStorageMenuService, isAgentStorageMenuRequest } from './agent-storage-menu.js';
|
|
72
75
|
import { MAX_AUN_ATTACHMENT_SIZE } from '../../aun/msg/upload.js';
|
|
73
76
|
import { normalizeTopicLabel, normalizeTopicStatus, resolveTopicArchiveFilter, } from '../session/session-mapper.js';
|
|
74
77
|
import { notifyThreadRename } from '../thread/thread-operation.js';
|
|
78
|
+
import { executeEventsQuery, executeEventsUpdate } from './eventcenter-menu.js';
|
|
75
79
|
import { isAgentScopePath, isHClassPath, isLClassPath } from '../permission/protected-paths.js';
|
|
76
80
|
/**
|
|
77
81
|
* 获取 baseagent CLI 的版本号(claude/gemini/codex)。
|
|
@@ -456,17 +460,13 @@ function listDirectory(realPath, options) {
|
|
|
456
460
|
const code = e?.code === 'EACCES' || e?.code === 'EPERM' ? 'NO_PERMISSION' : 'EXEC_FAILED';
|
|
457
461
|
return { error: `目录读取失败: ${e?.message ?? e}`, code };
|
|
458
462
|
}
|
|
463
|
+
const workspaceStats = new Map();
|
|
459
464
|
dirents = dirents.filter(d => {
|
|
460
465
|
if (!includeHidden && d.name.startsWith('.'))
|
|
461
466
|
return false;
|
|
462
|
-
if (options.
|
|
463
|
-
return false;
|
|
464
|
-
if (options.paWorkspace && d.isSymbolicLink()) {
|
|
467
|
+
if (options.resolveWorkspaceChild) {
|
|
465
468
|
try {
|
|
466
|
-
|
|
467
|
-
const relative = path.relative(projectPath, target).split(path.sep).join('/');
|
|
468
|
-
if (!isInProject(target, projectPath) || isPaHiddenPath(relative))
|
|
469
|
-
return false;
|
|
469
|
+
workspaceStats.set(d.name, options.resolveWorkspaceChild(d.name));
|
|
470
470
|
}
|
|
471
471
|
catch {
|
|
472
472
|
return false;
|
|
@@ -476,7 +476,10 @@ function listDirectory(realPath, options) {
|
|
|
476
476
|
});
|
|
477
477
|
const entryInfoByName = new Map();
|
|
478
478
|
for (const dirent of dirents) {
|
|
479
|
-
|
|
479
|
+
const stat = workspaceStats.get(dirent.name);
|
|
480
|
+
entryInfoByName.set(dirent.name, stat
|
|
481
|
+
? { isDirectory: stat.isDirectory(), followTarget: true }
|
|
482
|
+
: getDirectoryEntryInfo(realPath, projectPath, role, dirent));
|
|
480
483
|
}
|
|
481
484
|
dirents.sort((a, b) => {
|
|
482
485
|
const ad = entryInfoByName.get(a.name)?.isDirectory ?? false;
|
|
@@ -552,6 +555,19 @@ function isDaemonControlSubject(subject) {
|
|
|
552
555
|
|| subject.processRole === 'daemon-owner'
|
|
553
556
|
|| subject.processRole === 'daemon-service';
|
|
554
557
|
}
|
|
558
|
+
export function isTeamWorkspaceOwnerSubject(subject) {
|
|
559
|
+
return subject.channelType === 'aun' && subject.chatType === 'private'
|
|
560
|
+
&& !subject.fromControlChannel
|
|
561
|
+
&& subject.role === 'owner' && !!subject.selfAid && !!subject.principalId
|
|
562
|
+
&& ownerResolver.isOwner(subject.selfAid, subject.principalId);
|
|
563
|
+
}
|
|
564
|
+
const EVENT_CENTER_OWNER_ONLY = 'Event center menus are available only to the current Agent Owner in a private AUN chat';
|
|
565
|
+
function eventsMenuContext(handler, subject) {
|
|
566
|
+
return {
|
|
567
|
+
registry: handler.eventCenter,
|
|
568
|
+
selfAid: subject.selfAid,
|
|
569
|
+
};
|
|
570
|
+
}
|
|
555
571
|
function modelDisplayLabel(agent, model) {
|
|
556
572
|
const full = agent.resolveModelId?.(model);
|
|
557
573
|
return full && full !== model ? `${model} (${full})` : model;
|
|
@@ -745,8 +761,7 @@ function readMenuChatmode(target) {
|
|
|
745
761
|
field: target.fieldPath,
|
|
746
762
|
configuredValue: resolved.value,
|
|
747
763
|
});
|
|
748
|
-
const mode = target.scope === 'agent'
|
|
749
|
-
&& (decision.effectiveValue !== 'paactive' || target.role === 'owner') ? decision.effectiveValue
|
|
764
|
+
const mode = target.scope === 'agent' ? decision.effectiveValue
|
|
750
765
|
: resolveChatModeForField({ ...target.sel, role: target.role, field: target.field });
|
|
751
766
|
if (isChatMode(mode)) {
|
|
752
767
|
return {
|
|
@@ -754,9 +769,6 @@ function readMenuChatmode(target) {
|
|
|
754
769
|
source: decision.decidedBy === 'role'
|
|
755
770
|
? 'role'
|
|
756
771
|
: toMenuSource(resolved.source) ?? 'builtin',
|
|
757
|
-
...(resolved.value === 'paactive' && mode !== 'paactive' ? {
|
|
758
|
-
fallbackReason: 'paactive 仅在 active AUN 人类 owner 私聊主会话或话题生效,当前场景或角色策略未满足条件。',
|
|
759
|
-
} : {}),
|
|
760
772
|
};
|
|
761
773
|
}
|
|
762
774
|
}
|
|
@@ -1422,13 +1434,13 @@ function buildRoleMenuContext(owner, channel, subject) {
|
|
|
1422
1434
|
...(owningAgent?.name ? (owner.getAvailableBaseagentsForOwner?.(owningAgent.name) ?? []) : []),
|
|
1423
1435
|
])),
|
|
1424
1436
|
listModels: async (baseagent) => {
|
|
1425
|
-
const runner = owner.
|
|
1437
|
+
const runner = await owner.ensureAgent(channel, baseagent, owningAgent?.aid);
|
|
1426
1438
|
if (!runner?.listModels)
|
|
1427
1439
|
return [];
|
|
1428
1440
|
return await runner.listModels() ?? [];
|
|
1429
1441
|
},
|
|
1430
1442
|
resolveModelId: (baseagent, model) => {
|
|
1431
|
-
const runner = owner.
|
|
1443
|
+
const runner = owner.getLoadedAgent?.(channel, baseagent);
|
|
1432
1444
|
return typeof runner?.resolveModelId === 'function' ? runner.resolveModelId(model) : undefined;
|
|
1433
1445
|
},
|
|
1434
1446
|
};
|
|
@@ -1919,8 +1931,8 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
1919
1931
|
if (!selfAid)
|
|
1920
1932
|
throw { code: 'FORBIDDEN', message: '当前 channel 无绑定 agent' };
|
|
1921
1933
|
const res = this.agentApplicationService
|
|
1922
|
-
? await execAgentQuery({ aid: selfAid }, this.agentApplicationService, agentFullAccessMenuSubject(subject, source))
|
|
1923
|
-
: await execAgentQuery({ aid: selfAid }, undefined, agentFullAccessMenuSubject(subject, source));
|
|
1934
|
+
? await execAgentQuery({ aid: selfAid }, this.agentApplicationService, agentFullAccessMenuSubject(subject, source), this.messageQueue)
|
|
1935
|
+
: await execAgentQuery({ aid: selfAid }, undefined, agentFullAccessMenuSubject(subject, source), this.messageQueue);
|
|
1924
1936
|
if ('error' in res)
|
|
1925
1937
|
throw { code: res.code, message: res.error };
|
|
1926
1938
|
const ag = res.data;
|
|
@@ -1984,7 +1996,7 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
1984
1996
|
}
|
|
1985
1997
|
if (!source.agentSessionId)
|
|
1986
1998
|
return [];
|
|
1987
|
-
const agent = this.
|
|
1999
|
+
const agent = await this.ensureAgent(channel, source.baseagent);
|
|
1988
2000
|
if (!agent.capabilities?.forkAtTurn || !agent.getSessionMessages || !agent.forkSessionAt)
|
|
1989
2001
|
return [];
|
|
1990
2002
|
const turns = buildTranscriptTurns(await agent.getSessionMessages(source.agentSessionId, source.projectPath));
|
|
@@ -2083,12 +2095,7 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
2083
2095
|
const available = requestedAgent?.name
|
|
2084
2096
|
? (this.getAvailableBaseagentsForOwner?.(requestedAgent.name) ?? [])
|
|
2085
2097
|
: 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 }));
|
|
2098
|
+
return available.map((id) => ({ value: id, label: id, selected: id === currentAgent }));
|
|
2092
2099
|
}
|
|
2093
2100
|
if (cmd === '/model') {
|
|
2094
2101
|
const target = resolveMenuModelTarget.call(this, {
|
|
@@ -2106,7 +2113,7 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
2106
2113
|
throw { code: target.code, message: target.error };
|
|
2107
2114
|
let agent;
|
|
2108
2115
|
try {
|
|
2109
|
-
agent = this.
|
|
2116
|
+
agent = await this.ensureAgent(channel, target.baseagent, target.sel.self);
|
|
2110
2117
|
}
|
|
2111
2118
|
catch (error) {
|
|
2112
2119
|
if (isDaemonControlSubject(subject)) {
|
|
@@ -2177,7 +2184,7 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
2177
2184
|
throw { code: target.code, message: target.error };
|
|
2178
2185
|
let agent;
|
|
2179
2186
|
try {
|
|
2180
|
-
agent = this.
|
|
2187
|
+
agent = await this.ensureAgent(channel, target.baseagent, target.sel.self);
|
|
2181
2188
|
}
|
|
2182
2189
|
catch (error) {
|
|
2183
2190
|
if (isDaemonControlSubject(subject)) {
|
|
@@ -2214,9 +2221,6 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
2214
2221
|
...(target.field !== 'group'
|
|
2215
2222
|
? [{ value: 'interactive', label: '交互模式', selected: currentMode === 'interactive' }] : []),
|
|
2216
2223
|
{ 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
2224
|
];
|
|
2221
2225
|
}
|
|
2222
2226
|
if (cmd === '/mention') {
|
|
@@ -2259,6 +2263,12 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2259
2263
|
const cmdBase = cmd.trim().split(' ')[0];
|
|
2260
2264
|
if (!cmdBase)
|
|
2261
2265
|
return { error: '缺少命令', code: 'MISSING_CMD' };
|
|
2266
|
+
if (cmdBase === '/agent' && args?.view === 'template-job') {
|
|
2267
|
+
return executeTemplateMenu({ name: 'agent', type: 'menu.query', args }, fromControlChannel ? authSubject : undefined, source);
|
|
2268
|
+
}
|
|
2269
|
+
if (cmdBase === '/model' && args?.scope === 'process' && args?.view === 'catalog') {
|
|
2270
|
+
return executeProviderModelCatalog({ name: 'model', type: 'menu.query', args }, fromControlChannel ? authSubject : undefined, source);
|
|
2271
|
+
}
|
|
2262
2272
|
if (cmdBase === '/provider') {
|
|
2263
2273
|
return executeProviderMenu({ name: 'provider', cmd, type: 'menu.query', args }, fromControlChannel ? authSubject : undefined, source);
|
|
2264
2274
|
}
|
|
@@ -2390,15 +2400,55 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2390
2400
|
return dataRootFailure(error);
|
|
2391
2401
|
}
|
|
2392
2402
|
}
|
|
2393
|
-
if (cmdBase === '/
|
|
2394
|
-
|
|
2403
|
+
if (cmdBase === '/events') {
|
|
2404
|
+
if (!isTeamWorkspaceOwnerSubject(subject))
|
|
2405
|
+
return { error: EVENT_CENTER_OWNER_ONLY, code: 'FORBIDDEN' };
|
|
2406
|
+
try {
|
|
2407
|
+
return { data: await executeEventsQuery(eventsMenuContext(this, subject), args ?? {}) };
|
|
2408
|
+
}
|
|
2409
|
+
catch (error) {
|
|
2410
|
+
if (error && typeof error === 'object' && 'code' in error)
|
|
2411
|
+
return { error: String(error.message ?? 'event center error'), code: String(error.code) };
|
|
2412
|
+
return { error: error instanceof Error ? error.message : String(error), code: 'INTERNAL_ERROR' };
|
|
2413
|
+
}
|
|
2414
|
+
}
|
|
2415
|
+
if (cmdBase === '/team-workspace') {
|
|
2416
|
+
if (!isTeamWorkspaceOwnerSubject(subject))
|
|
2417
|
+
return { error: 'Team Workspace Menu is available only to the current Agent Owner in a private AUN chat', code: 'FORBIDDEN' };
|
|
2418
|
+
if (args?.view === 'members')
|
|
2419
|
+
return executeTeamMembersQuery(subject.selfAid, args);
|
|
2420
|
+
const allowed = new Set(['view', 'protocolVersion', 'managementVersion', 'context', 'from', 'to', 'timezone', 'path', 'offset', 'limit', 'indexRevision', 'jobId']);
|
|
2395
2421
|
const unknown = Object.keys(args ?? {}).find(key => !allowed.has(key));
|
|
2396
2422
|
if (unknown)
|
|
2397
|
-
return { error: `
|
|
2398
|
-
if (!args || typeof args.view !== 'string' || !['navigation', 'calendar', 'items'].includes(args.view))
|
|
2399
|
-
return { error: '
|
|
2423
|
+
return { error: `team-workspace does not accept args.${unknown}`, code: 'INVALID_ARGUMENT' };
|
|
2424
|
+
if (!args || typeof args.view !== 'string' || !['navigation', 'calendar', 'items', 'workspace-info', 'job'].includes(args.view))
|
|
2425
|
+
return { error: 'team-workspace requires a supported view', code: 'INVALID_ARGUMENT' };
|
|
2426
|
+
if (['workspace-info', 'job'].includes(args.view)) {
|
|
2427
|
+
if (args.managementVersion !== 1)
|
|
2428
|
+
return { error: 'Management views require managementVersion=1', code: 'SCHEMA_VERSION_UNSUPPORTED' };
|
|
2429
|
+
const managementUnknown = Object.keys(args).find(key => args.view === 'job'
|
|
2430
|
+
? !['view', 'managementVersion', 'jobId'].includes(key)
|
|
2431
|
+
: !['view', 'managementVersion'].includes(key));
|
|
2432
|
+
if (managementUnknown)
|
|
2433
|
+
return { error: `Management view does not accept args.${managementUnknown}`, code: 'INVALID_ARGUMENT' };
|
|
2434
|
+
if (args.view === 'job' && (typeof args.jobId !== 'string' || !args.jobId.trim()))
|
|
2435
|
+
return { error: 'job view requires args.jobId', code: 'INVALID_ARGUMENT' };
|
|
2436
|
+
try {
|
|
2437
|
+
const management = this.teamWorkspaceManagementService;
|
|
2438
|
+
if (!management)
|
|
2439
|
+
return { error: 'Team workspace management is unavailable', code: 'DEPENDENCY_UNAVAILABLE' };
|
|
2440
|
+
return { data: args.view === 'workspace-info'
|
|
2441
|
+
? await management.workspaceInfo(subject)
|
|
2442
|
+
: await management.job(subject, args.jobId) };
|
|
2443
|
+
}
|
|
2444
|
+
catch (error) {
|
|
2445
|
+
return dataRootFailure(error);
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
if (args.managementVersion !== undefined || args.jobId !== undefined)
|
|
2449
|
+
return { error: 'managementVersion and jobId are only valid for management views', code: 'INVALID_ARGUMENT' };
|
|
2400
2450
|
if (args?.protocolVersion !== undefined && args.protocolVersion !== 1) {
|
|
2401
|
-
return { error: 'Unsupported
|
|
2451
|
+
return { error: 'Unsupported Team workspace protocol version', code: 'SCHEMA_VERSION_UNSUPPORTED' };
|
|
2402
2452
|
}
|
|
2403
2453
|
if (args.view !== 'calendar' && (args.from !== undefined || args.to !== undefined || args.timezone !== undefined)) {
|
|
2404
2454
|
return { error: 'from, to and timezone are only valid for calendar view', code: 'INVALID_ARGUMENT' };
|
|
@@ -2407,20 +2457,23 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2407
2457
|
return { error: 'path, offset, limit and indexRevision are only valid for items view', code: 'INVALID_ARGUMENT' };
|
|
2408
2458
|
}
|
|
2409
2459
|
try {
|
|
2460
|
+
if (this.teamWorkspaceManagementService)
|
|
2461
|
+
await this.teamWorkspaceManagementService.ensureReady(subject);
|
|
2410
2462
|
if (args.view === 'items')
|
|
2411
|
-
|
|
2412
|
-
const root = dataRootResolver.
|
|
2413
|
-
const navigation =
|
|
2414
|
-
const state =
|
|
2463
|
+
validateTeamWorkspaceItemsArgs(args);
|
|
2464
|
+
const root = dataRootResolver.issueTeamWorkspaceRoot(subject);
|
|
2465
|
+
const navigation = readTeamWorkspaceNavigation(root.targetAid);
|
|
2466
|
+
const state = teamWorkspaceStore.require(root.targetAid);
|
|
2415
2467
|
if (args.view === 'items') {
|
|
2416
|
-
const items = await
|
|
2468
|
+
const items = await teamWorkspaceItemsIndex.query(root.targetAid, state, args);
|
|
2417
2469
|
// Building the initial index yields to other requests. Recheck owner,
|
|
2418
2470
|
// binding and navigation before sending any cached private summary.
|
|
2419
|
-
dataRootResolver.
|
|
2420
|
-
const current =
|
|
2471
|
+
dataRootResolver.issueTeamWorkspaceRoot(subject);
|
|
2472
|
+
const current = teamWorkspaceStore.require(root.targetAid);
|
|
2421
2473
|
if (current.workspaceId !== state.workspaceId || current.ownerAid !== state.ownerAid
|
|
2422
|
-
|| current.rootPath !== state.rootPath || current.
|
|
2423
|
-
|
|
2474
|
+
|| current.rootPath !== state.rootPath || current.outputRootPath !== state.outputRootPath
|
|
2475
|
+
|| current.navigationRevision !== state.navigationRevision) {
|
|
2476
|
+
throw new DataRootError('WORKSPACE_CHANGED', 'Team workspace changed during query');
|
|
2424
2477
|
}
|
|
2425
2478
|
return { data: items };
|
|
2426
2479
|
}
|
|
@@ -2434,7 +2487,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2434
2487
|
.filter((definition) => this.canAccessTriggerDefinition(definition, userId ?? '', channel, isAdmin));
|
|
2435
2488
|
return {
|
|
2436
2489
|
data: {
|
|
2437
|
-
...
|
|
2490
|
+
...queryTeamWorkspaceCalendar({
|
|
2438
2491
|
state,
|
|
2439
2492
|
navigation,
|
|
2440
2493
|
scheduler: scheduler && visibleDefinitions
|
|
@@ -2456,10 +2509,10 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2456
2509
|
};
|
|
2457
2510
|
}
|
|
2458
2511
|
// Start preparing cards while the user is still in the conversation.
|
|
2459
|
-
|
|
2512
|
+
teamWorkspaceItemsIndex.warm(root.targetAid, state);
|
|
2460
2513
|
return {
|
|
2461
2514
|
data: {
|
|
2462
|
-
protocol: 'evol.
|
|
2515
|
+
protocol: 'evol.team-workspace',
|
|
2463
2516
|
protocolVersion: 1,
|
|
2464
2517
|
workspaceId: navigation.workspaceId,
|
|
2465
2518
|
navigationRevision: navigation.navigationRevision,
|
|
@@ -2683,8 +2736,8 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2683
2736
|
if (fromControlChannel) {
|
|
2684
2737
|
if (args?.aid) {
|
|
2685
2738
|
return this.agentApplicationService
|
|
2686
|
-
? await execAgentQuery(args, this.agentApplicationService, agentFullAccessMenuSubject(subject, source))
|
|
2687
|
-
: await execAgentQuery(args, undefined, agentFullAccessMenuSubject(subject, source));
|
|
2739
|
+
? await execAgentQuery(args, this.agentApplicationService, agentFullAccessMenuSubject(subject, source), this.messageQueue)
|
|
2740
|
+
: await execAgentQuery(args, undefined, agentFullAccessMenuSubject(subject, source), this.messageQueue);
|
|
2688
2741
|
}
|
|
2689
2742
|
return this.agentApplicationService
|
|
2690
2743
|
? await execAgentOptions(args, this.agentApplicationService)
|
|
@@ -2694,8 +2747,8 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2694
2747
|
if (!selfAid)
|
|
2695
2748
|
return { error: '当前 channel 无绑定 agent', code: 'FORBIDDEN' };
|
|
2696
2749
|
return this.agentApplicationService
|
|
2697
|
-
? await execAgentQuery({ ...(args ?? {}), aid: selfAid }, this.agentApplicationService, agentFullAccessMenuSubject(subject, source))
|
|
2698
|
-
: await execAgentQuery({ ...(args ?? {}), aid: selfAid }, undefined, agentFullAccessMenuSubject(subject, source));
|
|
2750
|
+
? await execAgentQuery({ ...(args ?? {}), aid: selfAid }, this.agentApplicationService, agentFullAccessMenuSubject(subject, source), this.messageQueue)
|
|
2751
|
+
: await execAgentQuery({ ...(args ?? {}), aid: selfAid }, undefined, agentFullAccessMenuSubject(subject, source), this.messageQueue);
|
|
2699
2752
|
}
|
|
2700
2753
|
// ── /gateway 查询(只读,列出全部作用域的网关配置;apiKey 已掩码) ──
|
|
2701
2754
|
if (cmdBase === '/gateway') {
|
|
@@ -2779,11 +2832,11 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2779
2832
|
return { data: { scope: 'retained-history', tasks: this.sessionManager.getRunnerTaskHistory(session.id) } };
|
|
2780
2833
|
}
|
|
2781
2834
|
const sessionKey = this.getQueueKey(session, channel, channelId);
|
|
2782
|
-
const sessionAgent = this.
|
|
2783
|
-
const isProcessing = this.messageQueue.isProcessing(sessionKey) || sessionAgent
|
|
2784
|
-
|| sessionAgent
|
|
2835
|
+
const sessionAgent = this.getLoadedAgent(channel, session.baseagent);
|
|
2836
|
+
const isProcessing = this.messageQueue.isProcessing(sessionKey) || sessionAgent?.hasActiveStream(sessionKey)
|
|
2837
|
+
|| sessionAgent?.hasActiveOperation?.(sessionKey) === true;
|
|
2785
2838
|
const queueLength = this.messageQueue.getQueueLength(sessionKey);
|
|
2786
|
-
const executionState = sessionAgent
|
|
2839
|
+
const executionState = sessionAgent?.getExecutionState?.(sessionKey);
|
|
2787
2840
|
const health = await this.sessionManager.getHealthStatus(session.id);
|
|
2788
2841
|
let processingDuration;
|
|
2789
2842
|
if (isProcessing && session.processingState) {
|
|
@@ -2866,7 +2919,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2866
2919
|
const candidate = async (session) => {
|
|
2867
2920
|
if (!session?.agentSessionId || session.channel !== channel || session.channelId !== channelId)
|
|
2868
2921
|
return undefined;
|
|
2869
|
-
const agent = this.
|
|
2922
|
+
const agent = await this.ensureAgent(channel, session.baseagent);
|
|
2870
2923
|
if (!agent.getSessionMessages)
|
|
2871
2924
|
return undefined;
|
|
2872
2925
|
try {
|
|
@@ -2908,11 +2961,11 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2908
2961
|
return { data: { scope: 'retained-history', tasks: this.sessionManager.getRunnerTaskHistory(topic.id) } };
|
|
2909
2962
|
}
|
|
2910
2963
|
const sessionKey = this.getQueueKey(topic, channel, channelId);
|
|
2911
|
-
const sessionAgent = this.
|
|
2912
|
-
const isProcessing = this.messageQueue.isProcessing(sessionKey) || sessionAgent
|
|
2913
|
-
|| sessionAgent
|
|
2964
|
+
const sessionAgent = this.getLoadedAgent(channel, topic.baseagent);
|
|
2965
|
+
const isProcessing = this.messageQueue.isProcessing(sessionKey) || sessionAgent?.hasActiveStream(sessionKey)
|
|
2966
|
+
|| sessionAgent?.hasActiveOperation?.(sessionKey) === true;
|
|
2914
2967
|
const queueLength = this.messageQueue.getQueueLength(sessionKey);
|
|
2915
|
-
const executionState = sessionAgent
|
|
2968
|
+
const executionState = sessionAgent?.getExecutionState?.(sessionKey);
|
|
2916
2969
|
const health = await this.sessionManager.getHealthStatus(topic.id);
|
|
2917
2970
|
let processingDuration;
|
|
2918
2971
|
if (isProcessing && topic.processingState) {
|
|
@@ -2980,7 +3033,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2980
3033
|
});
|
|
2981
3034
|
if ('error' in target)
|
|
2982
3035
|
return target;
|
|
2983
|
-
const agent = this.
|
|
3036
|
+
const agent = await this.ensureAgent(channel, target.baseagent, target.sel.self);
|
|
2984
3037
|
const current = readMenuModel(target, agent, session?.agentSessionId);
|
|
2985
3038
|
return {
|
|
2986
3039
|
data: {
|
|
@@ -3009,7 +3062,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
3009
3062
|
});
|
|
3010
3063
|
if ('error' in target)
|
|
3011
3064
|
return target;
|
|
3012
|
-
const agent = this.
|
|
3065
|
+
const agent = await this.ensureAgent(channel, target.baseagent, target.sel.self);
|
|
3013
3066
|
const current = readMenuModel(target, agent, session?.agentSessionId);
|
|
3014
3067
|
return {
|
|
3015
3068
|
data: {
|
|
@@ -3041,7 +3094,6 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
3041
3094
|
return {
|
|
3042
3095
|
data: {
|
|
3043
3096
|
mode: current.value,
|
|
3044
|
-
...(current.fallbackReason ? { fallbackReason: current.fallbackReason } : {}),
|
|
3045
3097
|
source: current.source,
|
|
3046
3098
|
scope: target.scope,
|
|
3047
3099
|
override: readMenuScopeOverride(target.scope, target.fieldPath, target.sel),
|
|
@@ -3273,6 +3325,7 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3273
3325
|
if (cmdBase === '/provider') {
|
|
3274
3326
|
return executeProviderMenu({ name: 'provider', cmd, type: 'menu.update', args, value }, fromControlChannel ? authSubject : undefined, source);
|
|
3275
3327
|
}
|
|
3328
|
+
const isEventCenterUpdate = cmdBase === '/events';
|
|
3276
3329
|
const isLoopUpdate = cmdBase === '/session' && args?.resource === 'loop';
|
|
3277
3330
|
const isFullAccessUpdate = cmdBase === '/session' && args?.resource === 'fullaccess';
|
|
3278
3331
|
if (isLoopUpdate) {
|
|
@@ -3286,7 +3339,7 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3286
3339
|
return { error: `idleSeconds 必须是 ${MIN_SESSION_LOOP_SECONDS}-${MAX_SESSION_LOOP_SECONDS} 的整数`, code: 'INVALID_ARGUMENT' };
|
|
3287
3340
|
}
|
|
3288
3341
|
}
|
|
3289
|
-
else if (!isFullAccessUpdate && typeof value !== 'string') {
|
|
3342
|
+
else if (!isFullAccessUpdate && !isEventCenterUpdate && typeof value !== 'string') {
|
|
3290
3343
|
return { error: 'value 必须是字符串', code: 'INVALID_ARGUMENT' };
|
|
3291
3344
|
}
|
|
3292
3345
|
if (isFullAccessUpdate && (typeof value !== 'boolean'
|
|
@@ -3343,6 +3396,39 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3343
3396
|
fromControlChannel,
|
|
3344
3397
|
subject: authSubject,
|
|
3345
3398
|
});
|
|
3399
|
+
if (isEventCenterUpdate) {
|
|
3400
|
+
if (!isTeamWorkspaceOwnerSubject(subject))
|
|
3401
|
+
return { error: EVENT_CENTER_OWNER_ONLY, code: 'FORBIDDEN' };
|
|
3402
|
+
let updateArgs = { ...(args ?? {}) };
|
|
3403
|
+
if (updateArgs.resource === 'center' && typeof value === 'boolean') {
|
|
3404
|
+
if (updateArgs.enabled !== undefined && updateArgs.enabled !== value) {
|
|
3405
|
+
return { error: 'events center args.enabled conflicts with value', code: 'INVALID_ARGUMENT' };
|
|
3406
|
+
}
|
|
3407
|
+
updateArgs.enabled = value;
|
|
3408
|
+
}
|
|
3409
|
+
else if (value !== undefined && updateArgs.resource !== 'center') {
|
|
3410
|
+
if (typeof value !== 'string')
|
|
3411
|
+
return { error: 'events structured value must be a JSON object string', code: 'INVALID_ARGUMENT' };
|
|
3412
|
+
let parsed;
|
|
3413
|
+
try {
|
|
3414
|
+
parsed = JSON.parse(value);
|
|
3415
|
+
}
|
|
3416
|
+
catch {
|
|
3417
|
+
return { error: 'events value must be valid JSON', code: 'INVALID_ARGUMENT' };
|
|
3418
|
+
}
|
|
3419
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
3420
|
+
return { error: 'events value must be a JSON object', code: 'INVALID_ARGUMENT' };
|
|
3421
|
+
updateArgs = { ...parsed, ...updateArgs };
|
|
3422
|
+
}
|
|
3423
|
+
try {
|
|
3424
|
+
return { data: await executeEventsUpdate(eventsMenuContext(this, subject), updateArgs) };
|
|
3425
|
+
}
|
|
3426
|
+
catch (error) {
|
|
3427
|
+
if (error && typeof error === 'object' && 'code' in error)
|
|
3428
|
+
return { error: String(error.message ?? 'event center error'), code: String(error.code) };
|
|
3429
|
+
return { error: error instanceof Error ? error.message : String(error), code: 'INTERNAL_ERROR' };
|
|
3430
|
+
}
|
|
3431
|
+
}
|
|
3346
3432
|
if (isLoopUpdate) {
|
|
3347
3433
|
try {
|
|
3348
3434
|
const route = { channel, channelId, selfAid: subject.selfAid ?? '', threadId: transportReplyContext?.threadId };
|
|
@@ -3558,6 +3644,7 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3558
3644
|
}
|
|
3559
3645
|
const previousBaseagent = evolagent.baseagent;
|
|
3560
3646
|
try {
|
|
3647
|
+
await this.ensureAgent(channel, arg, evolagent.aid);
|
|
3561
3648
|
evolagent.setActiveBaseagent(arg);
|
|
3562
3649
|
}
|
|
3563
3650
|
catch (error) {
|
|
@@ -3585,7 +3672,7 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3585
3672
|
});
|
|
3586
3673
|
if ('error' in target)
|
|
3587
3674
|
return target;
|
|
3588
|
-
const agent = this.
|
|
3675
|
+
const agent = await this.ensureAgent(channel, target.baseagent, target.sel.self);
|
|
3589
3676
|
const requestedModel = arg;
|
|
3590
3677
|
if (hasModelSwitcher(agent)) {
|
|
3591
3678
|
const catalog = await getCatalog(target.sel.self, target.baseagent);
|
|
@@ -3646,7 +3733,7 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3646
3733
|
});
|
|
3647
3734
|
if ('error' in target)
|
|
3648
3735
|
return target;
|
|
3649
|
-
const agent = this.
|
|
3736
|
+
const agent = await this.ensureAgent(channel, target.baseagent, target.sel.self);
|
|
3650
3737
|
const modelTarget = { ...target, field: 'model', fieldPath: `baseagents.${target.baseagent}.model` };
|
|
3651
3738
|
const currentModel = readMenuModel(modelTarget, agent, session?.agentSessionId).value;
|
|
3652
3739
|
if (!currentModel) {
|
|
@@ -3709,16 +3796,9 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3709
3796
|
if (target.field === 'group' && arg !== 'proactive') {
|
|
3710
3797
|
return { error: '群聊仅支持 proactive 模式', code: 'NOT_APPLICABLE' };
|
|
3711
3798
|
}
|
|
3712
|
-
if (arg === '
|
|
3713
|
-
return { error: 'paactive 模式仅限 owner', code: 'ROLE_VALUE_NOT_ALLOWED' };
|
|
3714
|
-
}
|
|
3715
|
-
if ((arg === 'interactive' || arg === 'paactive') && target.roleLocked) {
|
|
3799
|
+
if (arg === 'interactive' && target.roleLocked) {
|
|
3716
3800
|
return { error: '私聊交互模式仅限 owner/admin,当前角色固定为 proactive', code: 'ROLE_VALUE_NOT_ALLOWED' };
|
|
3717
3801
|
}
|
|
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
3802
|
const roleDecision = validateRuntimeStringFieldOverride({
|
|
3723
3803
|
selfAid: target.sel.self,
|
|
3724
3804
|
role: target.role,
|
|
@@ -3729,7 +3809,7 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3729
3809
|
return { error: roleDecision.message || '当前角色不允许修改对话模式', code: roleDecision.code || 'ROLE_VALUE_NOT_ALLOWED' };
|
|
3730
3810
|
}
|
|
3731
3811
|
try {
|
|
3732
|
-
writeChatmodeConfig(target, arg
|
|
3812
|
+
writeChatmodeConfig(target, arg);
|
|
3733
3813
|
}
|
|
3734
3814
|
catch (e) {
|
|
3735
3815
|
return { error: e?.message || String(e), code: e?.code || 'CONFIG_WRITE_FAILED', ...(e?.data !== undefined ? { data: e.data } : {}) };
|
|
@@ -3829,6 +3909,9 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
3829
3909
|
const cmdBase = cmd.trim().split(' ')[0];
|
|
3830
3910
|
if (!cmdBase)
|
|
3831
3911
|
return { error: '缺少命令', code: 'MISSING_CMD' };
|
|
3912
|
+
if (cmdBase === '/agent' && ['inspect', 'build', 'push', 'pull', 'deploy'].includes(action)) {
|
|
3913
|
+
return executeTemplateMenu({ name: 'agent', type: 'menu.action', id: requestId, action, args }, fromControlChannel ? authSubject : undefined, source);
|
|
3914
|
+
}
|
|
3832
3915
|
if (cmdBase === '/provider') {
|
|
3833
3916
|
return executeProviderMenu({ name: 'provider', cmd, type: 'menu.action', args, action }, fromControlChannel ? authSubject : undefined, source);
|
|
3834
3917
|
}
|
|
@@ -3891,6 +3974,34 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
3891
3974
|
return dataRootFailure(error);
|
|
3892
3975
|
}
|
|
3893
3976
|
}
|
|
3977
|
+
if (cmdBase === '/events') {
|
|
3978
|
+
if (!isTeamWorkspaceOwnerSubject(subject))
|
|
3979
|
+
return { error: EVENT_CENTER_OWNER_ONLY, code: 'FORBIDDEN' };
|
|
3980
|
+
try {
|
|
3981
|
+
return { data: await executeEventsUpdate(eventsMenuContext(this, subject), args ?? {}) };
|
|
3982
|
+
}
|
|
3983
|
+
catch (error) {
|
|
3984
|
+
if (error && typeof error === 'object' && 'code' in error)
|
|
3985
|
+
return { error: String(error.message ?? 'event center error'), code: String(error.code) };
|
|
3986
|
+
return { error: error instanceof Error ? error.message : String(error), code: 'INTERNAL_ERROR' };
|
|
3987
|
+
}
|
|
3988
|
+
}
|
|
3989
|
+
if (cmdBase === '/team-workspace') {
|
|
3990
|
+
if (!isTeamWorkspaceOwnerSubject(subject))
|
|
3991
|
+
return { error: 'Team Workspace Menu is available only to the current Agent Owner in a private AUN chat', code: 'FORBIDDEN' };
|
|
3992
|
+
if (isTeamMembersMenuRequest({ type: 'menu.action', action }))
|
|
3993
|
+
return executeTeamMembersAction(subject.selfAid, action, args);
|
|
3994
|
+
if (action !== 'retry-initialization')
|
|
3995
|
+
return { error: 'Unsupported team-workspace action', code: 'NOT_SUPPORTED' };
|
|
3996
|
+
if (!this.teamWorkspaceManagementService)
|
|
3997
|
+
return { error: 'Team workspace management is unavailable', code: 'DEPENDENCY_UNAVAILABLE' };
|
|
3998
|
+
try {
|
|
3999
|
+
return { data: await this.teamWorkspaceManagementService.retryInitialization(subject, args) };
|
|
4000
|
+
}
|
|
4001
|
+
catch (error) {
|
|
4002
|
+
return dataRootFailure(error);
|
|
4003
|
+
}
|
|
4004
|
+
}
|
|
3894
4005
|
if (cmdBase === '/system' && fromControlChannel && !subject.isDaemonOwner && subject.processRole !== 'daemon-service') {
|
|
3895
4006
|
return {
|
|
3896
4007
|
error: formatAuthorizationDenial('This daemon-level operation requires DaemonOwner.', 'DAEMON_OWNER_REQUIRED'),
|
|
@@ -4424,7 +4535,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4424
4535
|
return { error: '历史上下文分叉仅支持私聊', code: 'NOT_SUPPORTED' };
|
|
4425
4536
|
if (!source.agentSessionId)
|
|
4426
4537
|
return { error: '来源会话暂无对话历史', code: 'INVALID_STATE' };
|
|
4427
|
-
const agent = this.
|
|
4538
|
+
const agent = await this.ensureAgent(channel, source.baseagent);
|
|
4428
4539
|
if (!agent.capabilities?.forkAtTurn || !agent.getSessionMessages || !agent.forkSessionAt) {
|
|
4429
4540
|
return { error: `当前 Agent (${agent.name}) 不支持按轮次分叉`, code: 'NOT_SUPPORTED' };
|
|
4430
4541
|
}
|
|
@@ -4517,7 +4628,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4517
4628
|
if (!current.agentSessionId) {
|
|
4518
4629
|
return { error: '来源会话暂无对话历史', code: 'INVALID_STATE' };
|
|
4519
4630
|
}
|
|
4520
|
-
const currentAgent = this.
|
|
4631
|
+
const currentAgent = await this.ensureAgent(channel, current.baseagent);
|
|
4521
4632
|
if (!currentAgent.capabilities?.forkAtTurn || !currentAgent.getSessionMessages || !currentAgent.forkSessionAt) {
|
|
4522
4633
|
return { error: `当前 Agent (${currentAgent.name}) 不支持按轮次分叉`, code: 'NOT_SUPPORTED' };
|
|
4523
4634
|
}
|
|
@@ -4685,7 +4796,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4685
4796
|
}
|
|
4686
4797
|
if (topic.agentSessionId) {
|
|
4687
4798
|
try {
|
|
4688
|
-
const targetAgent = this.
|
|
4799
|
+
const targetAgent = await this.ensureAgent(channel, topic.baseagent);
|
|
4689
4800
|
await targetAgent.setSessionName?.(topic.agentSessionId, newName);
|
|
4690
4801
|
}
|
|
4691
4802
|
catch { }
|
|
@@ -4706,7 +4817,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4706
4817
|
if (!success)
|
|
4707
4818
|
return { error: '删除失败', code: 'DELETE_FAILED' };
|
|
4708
4819
|
this.eventBus.publish({ type: 'session:deleted', sessionId: topic.id });
|
|
4709
|
-
const targetAgent = this.
|
|
4820
|
+
const targetAgent = await this.ensureAgent(channel, topic.baseagent);
|
|
4710
4821
|
await targetAgent.closeSession?.(topic.id);
|
|
4711
4822
|
return { data: { deleted: true } };
|
|
4712
4823
|
}
|
|
@@ -4716,7 +4827,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4716
4827
|
if (!session)
|
|
4717
4828
|
return { error: '当前无活跃会话', code: 'NO_ACTIVE_SESSION' };
|
|
4718
4829
|
const sessionKey = this.getQueueKey(session, channel, channelId);
|
|
4719
|
-
const sessionAgent = this.
|
|
4830
|
+
const sessionAgent = await this.ensureAgent(channel, session.baseagent);
|
|
4720
4831
|
const hasActive = sessionAgent.hasActiveStream(sessionKey);
|
|
4721
4832
|
const queueLength = this.messageQueue.getQueueLength(sessionKey);
|
|
4722
4833
|
if (queueLength === 0 && !hasActive) {
|
|
@@ -4765,7 +4876,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4765
4876
|
return { error: '重命名失败', code: 'EXEC_FAILED' };
|
|
4766
4877
|
if (targetSession.agentSessionId) {
|
|
4767
4878
|
try {
|
|
4768
|
-
const targetAgent = this.
|
|
4879
|
+
const targetAgent = await this.ensureAgent(channel, targetSession.baseagent);
|
|
4769
4880
|
await targetAgent.setSessionName?.(targetSession.agentSessionId, newName);
|
|
4770
4881
|
}
|
|
4771
4882
|
catch { }
|
|
@@ -5271,13 +5382,16 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
5271
5382
|
if (args?.rootId !== undefined) {
|
|
5272
5383
|
try {
|
|
5273
5384
|
const resolved = dataRootResolver.resolvePath(args.rootId, subject, dirArg, 'directory');
|
|
5385
|
+
const workspace = resolved.scope === 'team' ? teamWorkspaceStore.require(resolved.targetAid) : undefined;
|
|
5274
5386
|
listed = listDirectory(resolved.realPath, {
|
|
5275
5387
|
offset,
|
|
5276
5388
|
limit,
|
|
5277
5389
|
includeHidden,
|
|
5278
5390
|
projectPath: resolved.rootPath,
|
|
5279
5391
|
role: undefined,
|
|
5280
|
-
|
|
5392
|
+
resolveWorkspaceChild: workspace
|
|
5393
|
+
? name => teamWorkspaceStore.resolvePath(workspace, path.posix.join(resolved.relativePath, name)).stat
|
|
5394
|
+
: undefined,
|
|
5281
5395
|
});
|
|
5282
5396
|
responsePath = resolved.relativePath;
|
|
5283
5397
|
dataRoot = resolved;
|
|
@@ -5428,6 +5542,8 @@ function isProcessLevelMenu(name, cmd) {
|
|
|
5428
5542
|
|| cmdToken === '/system' || cmdToken === '/agent' || cmdToken === '/gateway' || cmdToken === '/config' || cmdToken === '/baseagent-models' || cmdToken === '/baseagents';
|
|
5429
5543
|
}
|
|
5430
5544
|
function isProcessContextMenu(payload) {
|
|
5545
|
+
if ((payload?.name === 'model' || payload?.cmd === '/model') && payload?.args?.scope === 'process' && payload?.args?.view === 'catalog')
|
|
5546
|
+
return true;
|
|
5431
5547
|
const isCatalog = payload?.type === 'menu.list' && payload?.args?.view === 'catalog';
|
|
5432
5548
|
const isValueBatch = payload?.type === 'menu.query'
|
|
5433
5549
|
&& payload?.name === 'menu'
|
|
@@ -5471,10 +5587,11 @@ async function execMenuForSystemControl(payload, context) {
|
|
|
5471
5587
|
const requestedContextKind = payload?.args?.context?.kind;
|
|
5472
5588
|
const isRoleRequest = name === 'role' || compatCmd === '/role';
|
|
5473
5589
|
const isConnectRequest = name === 'connect' || compatCmd === '/connect';
|
|
5474
|
-
const requiresAgentTarget =
|
|
5475
|
-
|
|
5590
|
+
const requiresAgentTarget = (name === 'menu' && payload?.type === 'menu.query' && payload?.args?.view === 'queries')
|
|
5591
|
+
|| isRoleRequest || isConnectRequest || [
|
|
5592
|
+
'observable', 'baseagent', 'model', 'effort', 'trigger', 'capability', 'group', 'aid', 'team-workspace', 'slash-commands', 'events',
|
|
5476
5593
|
].includes(name)
|
|
5477
|
-
|| ['/observable', '/baseagent', '/model', '/effort', '/trigger', '/capability', '/group', '/aid', '/
|
|
5594
|
+
|| ['/observable', '/baseagent', '/model', '/effort', '/trigger', '/capability', '/group', '/aid', '/team-workspace', '/evolhelp', '/events'].includes(compatCmd ?? '')
|
|
5478
5595
|
|| (!isProcessLevel && requestedContextKind !== undefined && requestedContextKind !== 'process');
|
|
5479
5596
|
const target = isProcessLevel
|
|
5480
5597
|
? { channel: SYSTEM_CONTROL_CHANNEL }
|
|
@@ -5572,6 +5689,14 @@ async function execMenuForSystemControl(payload, context) {
|
|
|
5572
5689
|
return ecwebErr(id, name, 'NOT_SUPPORTED', `Unsupported menu.list view: ${String(payload.args.view)}`);
|
|
5573
5690
|
return menuSuccess({ id }, this.getMenuItems(trustedIdentity.role, 'private', 'control', trustedSubject));
|
|
5574
5691
|
case 'menu.query': {
|
|
5692
|
+
if (name === 'menu' && payload?.args?.view === 'queries') {
|
|
5693
|
+
const data = await execMenuQueryBatch({
|
|
5694
|
+
subject: trustedSubject, channelType: 'aun', channelScope: 'control',
|
|
5695
|
+
channelId: targetChannel, args: payload.args,
|
|
5696
|
+
execQuery: (entryCmd, resolvedChannelId, queryArgs, querySubject) => this.execMenuQuery(entryCmd, targetChannel, resolvedChannelId, querySubject.actorId, queryArgs, querySubject.chatType, true, querySubject.identity, querySubject, context.source),
|
|
5697
|
+
});
|
|
5698
|
+
return menuSuccess({ id, ...(name ? { name } : {}) }, data);
|
|
5699
|
+
}
|
|
5575
5700
|
if (name === 'menu' && payload?.args?.view === 'values') {
|
|
5576
5701
|
validateMenuValueBatchArgs(payload.args);
|
|
5577
5702
|
const data = await execMenuValueBatch({
|
|
@@ -5623,8 +5748,9 @@ async function execMenuForSystemControl(payload, context) {
|
|
|
5623
5748
|
case 'menu.update': {
|
|
5624
5749
|
if (!cmd)
|
|
5625
5750
|
return ecwebErr(id, name, 'MISSING_CMD', '缺少 name/cmd');
|
|
5626
|
-
|
|
5627
|
-
|
|
5751
|
+
const isEventsUpdate = name === 'events' || menuCommandToken(payload?.cmd) === '/events';
|
|
5752
|
+
if (!isEventsUpdate && (payload.value === undefined || payload.value === null
|
|
5753
|
+
|| (typeof payload.value === 'string' && payload.value.length === 0))) {
|
|
5628
5754
|
return ecwebErr(id, name, 'MISSING_VALUE', '缺少 value');
|
|
5629
5755
|
}
|
|
5630
5756
|
const execution = await resolveExplicitMenuExecutionContext({
|