evolcore 0.0.43-test.1 → 0.0.43-test.3
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 +31 -1
- package/README.md +22 -0
- package/dist/agents/claude-runner.js +26 -2
- package/dist/agents/codex/app-server-client.js +12 -0
- package/dist/agents/codex-runner.js +49 -8
- package/dist/agents/ecagent-runner.js +39 -15
- package/dist/agents/gemini-runner.js +15 -12
- package/dist/agents/tool-time-context.js +55 -0
- package/dist/aun/aid/agentmd.js +21 -1
- package/dist/aun/menu/client.js +1 -1
- package/dist/aun/model-headers.js +17 -0
- package/dist/aun/msg/p2p.js +7 -2
- package/dist/channels/aun.js +522 -50
- package/dist/channels/builtin-plugins.js +16 -11
- package/dist/channels/daemon.js +4 -0
- package/dist/channels/dingtalk.js +83 -31
- package/dist/channels/feishu.js +29 -13
- package/dist/channels/qqbot.js +32 -11
- package/dist/channels/wechat.js +13 -3
- package/dist/channels/wecom.js +67 -27
- package/dist/cli/agent-command.js +3 -86
- package/dist/cli/agent-create.js +20 -6
- package/dist/cli/agent.js +1 -79
- package/dist/cli/aun-commands.js +18 -19
- package/dist/cli/config.js +1 -1
- package/dist/cli/daemon-commands.js +47 -2
- package/dist/cli/data-command.js +9 -1
- package/dist/cli/debug-mode.js +1 -1
- package/dist/cli/diag.js +1 -1
- package/dist/cli/directory.js +149 -91
- package/dist/cli/getmeta-command.js +1 -1
- package/dist/cli/index.js +79 -22
- package/dist/cli/init.js +1 -23
- package/dist/cli/link-rules.js +1 -1
- package/dist/cli/managed-command-guard.js +0 -1
- package/dist/cli/pa-workspace-command.js +36 -2
- package/dist/cli/peer.js +3 -2
- package/dist/cli/restart-monitor.js +17 -3
- package/dist/cli/role.js +1 -1
- package/dist/cli/session-command.js +1 -1
- package/dist/cli/stats.js +2 -2
- package/dist/cli/task-context.js +3 -1
- package/dist/cli/thread-command.js +1 -1
- package/dist/cli/watch-msg.js +1 -1
- package/dist/config/builtin-role-templates.js +2 -2
- package/dist/config/builtin-roles.js +2 -1
- package/dist/config/config-field-policy.js +7 -2
- package/dist/config/config-manager.js +32 -10
- package/dist/config/peer-role-resolver.js +23 -1
- package/dist/config/role-schema.js +29 -4
- package/dist/config/role-service.js +12 -7
- package/dist/config/role-store.js +30 -8
- package/dist/config-store.js +75 -4
- package/dist/core/agent-ipc-registration.js +16 -59
- package/dist/core/auth/auth-gateway.js +14 -4
- package/dist/core/auth/authorization-audit.js +52 -14
- package/dist/core/auth/operation-authorizer.js +17 -11
- package/dist/core/auth/operation-catalog.js +5 -13
- package/dist/core/channel-loader.js +152 -16
- package/dist/core/channel-runtime.js +5 -0
- package/dist/core/command/agent-control.js +2 -1
- package/dist/core/command/agentmd-menu-request.js +50 -0
- package/dist/core/command/agentmd-menu.js +156 -0
- package/dist/core/command/cli-intent-parser.js +0 -8
- package/dist/core/command/command-handler.js +47 -40
- package/dist/core/command/connect-menu.js +7 -3
- package/dist/core/command/menu-catalog.js +16 -2
- package/dist/core/command/menu-handler.js +107 -14
- package/dist/core/command/menu-protocol.js +28 -0
- package/dist/core/command/role-menu.js +23 -9
- package/dist/core/command/slash-handler.js +139 -51
- package/dist/core/daemon-file-cache.js +3 -3
- package/dist/core/daemon-lifecycle.js +9 -1
- package/dist/core/evolagent-registry.js +5 -4
- package/dist/core/evolagent.js +10 -12
- package/dist/core/handoff/argv-parse.js +115 -0
- package/dist/core/handoff/ipc-registration.js +1 -1
- package/dist/core/ipc-registration.js +19 -2
- package/dist/core/lifecycle-notice.js +185 -0
- package/dist/core/memory/consolidation.js +8 -1
- package/dist/core/memory/relation-sweep.js +20 -8
- package/dist/core/message/aun-ipc-sender.js +35 -2
- package/dist/core/message/contact-admission.js +530 -0
- package/dist/core/message/im-renderer.js +111 -16
- package/dist/core/message/message-admission.js +29 -54
- package/dist/core/message/message-bridge.js +62 -8
- package/dist/core/message/message-utils.js +9 -5
- package/dist/core/message/peer-mode.js +55 -13
- package/dist/core/message/response-engine.js +298 -78
- package/dist/core/message/retry-scheduler.js +4 -0
- package/dist/core/ownership/owner-resolver.js +72 -34
- package/dist/core/permission/ec-command-parser.js +25 -38
- package/dist/core/permission/readonly-shell-query.js +34 -8
- package/dist/core/permission/tool-policy.js +50 -5
- package/dist/core/relation/pa-team.js +127 -0
- package/dist/core/role/runtime-policy.js +18 -5
- package/dist/core/session/session-manager.js +9 -1
- package/dist/core/soul.js +66 -0
- package/dist/core/system-session/memory.js +2 -2
- package/dist/core/thread/thread-service.js +6 -4
- package/dist/directory/contact-admission-paths.js +9 -0
- package/dist/directory/owner-directory-admission.js +125 -29
- package/dist/directory/owner-directory-cache.js +554 -58
- package/dist/directory/owner-directory-identity.js +60 -0
- package/dist/directory/owner-directory-markdown.js +154 -58
- package/dist/directory/owner-directory-policy.js +108 -0
- package/dist/directory/owner-directory-query-operation.js +399 -90
- package/dist/directory/owner-directory-remarks.js +29 -2
- package/dist/directory/owner-directory-request-operation.js +76 -0
- package/dist/directory/owner-directory-scope.js +35 -4
- package/dist/directory/owner-directory-search.js +118 -33
- package/dist/directory/owner-directory-store.js +117 -30
- package/dist/directory/owner-directory-text.js +60 -0
- package/dist/eck/kit-renderer.js +18 -8
- package/dist/eck/manifest-engine.js +55 -6
- package/dist/ecweb/basic-settings-service.js +2 -2
- package/dist/ecweb/message-context-service.js +28 -16
- package/dist/index.js +20 -5
- package/dist/ipc.js +1 -1
- package/dist/paths.js +29 -1
- package/dist/product.js +1 -0
- package/dist/response-system/config-resolver.js +1 -1
- package/dist/response-system/engines/v1/index.js +2 -1
- package/dist/response-system/modes/single-session/index.js +7 -2
- package/dist/trigger/scheduler.js +7 -4
- package/dist/trigger/validation.js +4 -0
- package/dist/utils/error-utils.js +12 -7
- package/dist/utils/logger.js +13 -4
- package/dist/utils/npm-ops.js +2 -2
- package/dist/utils/windows-autostart.js +1 -1
- package/ecagent/README.md +18 -0
- package/ecagent/dist/agent-loop.js +43 -1
- package/ecagent/dist/harness/agent-harness.d.ts +2 -0
- package/ecagent/dist/harness/agent-harness.js +24 -8
- package/ecagent/dist/harness/compaction/compaction.js +3 -0
- package/ecagent/dist/harness/types.d.ts +1 -0
- package/kits/docs/INDEX.md +1 -0
- package/kits/docs/channels/aun.md +1 -1
- package/kits/docs/context-assembly.md +21 -6
- package/kits/docs/eck_templates/INDEX.template.md +1 -2
- package/kits/docs/evolcore/INDEX.md +4 -1
- package/kits/docs/evolcore/agent-create.md +5 -5
- package/kits/docs/evolcore/agent.md +4 -9
- package/kits/docs/evolcore/directory.md +227 -0
- package/kits/docs/evolcore/ecweb-lifecycle.md +26 -0
- package/kits/docs/evolcore/file-navigation.md +265 -0
- package/kits/docs/evolcore/menu-protocol.md +55 -0
- package/kits/docs/evolcore/msg.md +1 -0
- package/kits/docs/evolcore/peer.md +2 -1
- package/kits/docs/evolcore/response.md +7 -1
- package/kits/docs/evolcore/task.md +2 -0
- package/kits/docs/evolcore/tool-authorization.md +1 -1
- package/kits/docs/evolcore/trigger.md +4 -0
- package/kits/docs/identity/ROLE_DETAIL.md +2 -0
- package/kits/docs/prompt-loading-architecture.md +6 -2
- package/kits/eck_manifest.auxiliary.json +1 -0
- package/kits/eck_manifest.json +64 -7
- package/kits/eck_manifest.memory.json +93 -4
- package/kits/rules/01-overview.md +2 -2
- package/kits/rules/03-identity.md +10 -9
- package/kits/rules/05-venue.md +2 -4
- package/kits/rules/06-channel.md +1 -1
- package/kits/schemas/_meta.json +44 -3
- package/kits/schemas/agent-config.schema.18.json +5 -0
- package/kits/schemas/agent-config.schema.19.json +924 -0
- package/kits/schemas/agent-config.schema.20.json +925 -0
- package/kits/schemas/relation-config.schema.12.json +289 -0
- package/kits/schemas/relation-config.schema.13.json +289 -0
- package/kits/schemas/role-config.schema.2.json +215 -0
- package/kits/schemas/role-config.schema.3.json +1038 -0
- package/kits/schemas/role-registry.schema.1.json +3 -2
- package/kits/skills/ec-skill/scripts/cli.mjs +3 -2
- package/kits/skills/ec-trigger/SKILL.md +4 -4
- package/kits/skills/personal-assistant/SKILL.md +109 -53
- package/kits/skills/personal-assistant/references/02-bootstrap.md +73 -30
- package/kits/skills/personal-assistant/scripts/clean.mjs +35 -18
- package/kits/skills/personal-assistant/scripts/init.mjs +41 -2
- package/kits/skills/personal-assistant/scripts/lib/persona.mjs +185 -0
- package/kits/skills/personal-assistant/scripts/migrate.mjs +55 -4
- package/kits/skills/personal-assistant/scripts/pa.mjs +173 -0
- package/kits/skills/personal-assistant/scripts/uninstall.mjs +130 -0
- package/kits/skills/personal-assistant/templates/persona-section.md +3 -3
- package/kits/templates/message-fragments/handoff-request-to-target.md +1 -1
- package/kits/templates/soul/00-GUIDE.md +39 -0
- package/kits/templates/soul/01-identity.md +5 -0
- package/kits/templates/soul/02-persona.md +11 -0
- package/kits/templates/soul/03-duties.md +5 -0
- package/kits/templates/soul/04-working-style.md +5 -0
- package/kits/templates/system-fragments/bootstrap.md +7 -7
- package/kits/templates/system-fragments/channel.md +2 -2
- package/kits/templates/system-fragments/commands.md +3 -2
- package/kits/templates/system-fragments/directory-contacts.md +9 -0
- package/kits/templates/system-fragments/memory.md +1 -1
- package/kits/templates/system-fragments/personal-assistant.md +50 -0
- package/kits/templates/system-fragments/reply.md +7 -0
- package/kits/templates/system-fragments/session.md +6 -2
- package/package.json +3 -2
- package/dist/cli/handoff-command.js +0 -353
- package/dist/directory/owner-directory-remark-operation.js +0 -147
- package/kits/docs/evolcore/self-summary.md +0 -29
|
@@ -5,6 +5,7 @@ import { ConfigTarget, read, resolveEffectiveWithSources, write } from '../../co
|
|
|
5
5
|
import { getBuiltinRolesConfig, getRoleDefinition, isValidUserRoleName, readRolesConfig, } from '../../config/roles.js';
|
|
6
6
|
import { BUILTIN_USER_ROLES, MANAGEMENT_ROLES, expectedRoleRank, isManagementRole } from '../../config/builtin-roles.js';
|
|
7
7
|
import { checkRoleAccess, isStaticAgentOwner, resolvePeerRoleDetail } from '../../config/peer-role-resolver.js';
|
|
8
|
+
import { preparePaTeamQualification } from '../relation/pa-team.js';
|
|
8
9
|
import { relationFieldWriteOperation, resolveRoleFieldPermission, } from '../../config/config-field-policy.js';
|
|
9
10
|
import { evaluateRoleOperationCapability } from '../auth/operation-authorizer.js';
|
|
10
11
|
import { listOperations } from '../auth/operation-catalog.js';
|
|
@@ -476,17 +477,19 @@ function updateDefaultRoles(context, args, value) {
|
|
|
476
477
|
const self = context.self;
|
|
477
478
|
if (!isObject(value))
|
|
478
479
|
throw invalidJsonType(self, 'defaultRoles', 'object');
|
|
479
|
-
assertOnlyKeys(value, ['private', 'group'], 'defaultRoles', self);
|
|
480
|
+
assertOnlyKeys(value, ['private', 'group', 'paTeam'], 'defaultRoles', self);
|
|
480
481
|
if (!Object.prototype.hasOwnProperty.call(value, 'private') || !Object.prototype.hasOwnProperty.call(value, 'group')) {
|
|
481
482
|
throw validationFailed(self, undefined, [{ field: 'defaultRoles', code: 'MISSING_FIELD', message: 'private and group are required' }]);
|
|
482
483
|
}
|
|
484
|
+
const registry = readRoleRegistry(self);
|
|
483
485
|
const nextDefaults = {
|
|
484
486
|
private: validateAssignableRole(value.private, self, 'defaultRoles.private'),
|
|
485
487
|
group: validateAssignableRole(value.group, self, 'defaultRoles.group'),
|
|
488
|
+
paTeam: validateAssignableRole(Object.prototype.hasOwnProperty.call(value, 'paTeam')
|
|
489
|
+
? value.paTeam ?? 'member' : registry.defaultRoles.paTeam ?? 'member', self, 'defaultRoles.paTeam'),
|
|
486
490
|
};
|
|
487
491
|
assertPolicyRevision(self, args);
|
|
488
|
-
const
|
|
489
|
-
const changesAdminDefault = ['private', 'group'].some(scene => registry.defaultRoles[scene] !== nextDefaults[scene]
|
|
492
|
+
const changesAdminDefault = ['private', 'group', 'paTeam'].some(scene => registry.defaultRoles[scene] !== nextDefaults[scene]
|
|
490
493
|
&& (registry.defaultRoles[scene] === 'admin' || nextDefaults[scene] === 'admin'));
|
|
491
494
|
if (!isDaemonOwnerControl(context) && context.actorRole !== 'owner' && changesAdminDefault) {
|
|
492
495
|
throw roleError('NOT_ALLOWED', 'Only an owner can set or replace an admin default role', self, {
|
|
@@ -741,9 +744,10 @@ async function deleteRole(context, args) {
|
|
|
741
744
|
const registry = readRoleRegistry(self);
|
|
742
745
|
const nextRegistry = clone(registry);
|
|
743
746
|
nextRegistry.roles = nextRegistry.roles.filter(item => item !== roleId);
|
|
744
|
-
for (const scene of ['private', 'group']) {
|
|
745
|
-
|
|
746
|
-
|
|
747
|
+
for (const scene of ['private', 'group', 'paTeam']) {
|
|
748
|
+
const current = scene === 'paTeam' ? nextRegistry.defaultRoles[scene] ?? 'member' : nextRegistry.defaultRoles[scene];
|
|
749
|
+
if (current === roleId)
|
|
750
|
+
nextRegistry.defaultRoles[scene] = replacement ?? (scene === 'paTeam' ? 'member' : null);
|
|
747
751
|
}
|
|
748
752
|
const changes = [
|
|
749
753
|
{
|
|
@@ -775,7 +779,7 @@ async function assignmentInventory(context, args, policyRevision) {
|
|
|
775
779
|
const items = [];
|
|
776
780
|
if (args?.includeDefaults !== false) {
|
|
777
781
|
const defaults = effectiveDefaultRoles(self);
|
|
778
|
-
for (const scene of ['private', 'group']) {
|
|
782
|
+
for (const scene of ['private', 'group', 'paTeam']) {
|
|
779
783
|
const roleId = defaults[scene];
|
|
780
784
|
if (roleId && (!roleFilter || roleFilter === roleId)) {
|
|
781
785
|
items.push({ target: { kind: 'default', scene }, roleId, relationRevision: null });
|
|
@@ -819,6 +823,8 @@ async function targetSnapshot(context, args, policyRevision) {
|
|
|
819
823
|
const target = context.fromControlChannel
|
|
820
824
|
? normalized
|
|
821
825
|
: await validateTargetExists(context, normalized, { allowAuthenticatedPrivateActor: true });
|
|
826
|
+
if (target.kind === 'private')
|
|
827
|
+
await preparePaTeamQualification(self, target.peerAid);
|
|
822
828
|
const relation = readRelation(target.peerKey, self);
|
|
823
829
|
const roleView = targetRoleView(self, target, relation?.config ?? null);
|
|
824
830
|
const override = target.kind === 'private'
|
|
@@ -1306,7 +1312,7 @@ function readAgent(self) {
|
|
|
1306
1312
|
}
|
|
1307
1313
|
function effectiveDefaultRoles(self) {
|
|
1308
1314
|
const defaults = readRolesConfig(self).defaultRoles ?? {};
|
|
1309
|
-
return { private: defaults.private ?? null, group: defaults.group ?? null };
|
|
1315
|
+
return { private: defaults.private ?? null, group: defaults.group ?? null, paTeam: defaults.paTeam ?? 'member' };
|
|
1310
1316
|
}
|
|
1311
1317
|
function policyDocument(agent) {
|
|
1312
1318
|
const store = readRoleStore(agent.aid);
|
|
@@ -1488,7 +1494,7 @@ function relationTargetKind(self, config, channelId, known = { groups: new Set()
|
|
|
1488
1494
|
}
|
|
1489
1495
|
function countRoleUsage(self, relations, roleId) {
|
|
1490
1496
|
const configuredDefaults = effectiveDefaultRoles(self);
|
|
1491
|
-
const defaultScenes = ['private', 'group'].filter(scene => configuredDefaults[scene] === roleId);
|
|
1497
|
+
const defaultScenes = ['private', 'group', 'paTeam'].filter(scene => configuredDefaults[scene] === roleId);
|
|
1492
1498
|
let privateRelations = 0;
|
|
1493
1499
|
let groupRelations = 0;
|
|
1494
1500
|
for (const relation of relations) {
|
|
@@ -1525,6 +1531,14 @@ function validateRoleDomainTransactionChanges(self, registry, changes) {
|
|
|
1525
1531
|
field: 'registry', code: 'SCHEMA_INVALID', message: error.message ?? 'invalid role registry',
|
|
1526
1532
|
})));
|
|
1527
1533
|
}
|
|
1534
|
+
const validatedRegistry = registry;
|
|
1535
|
+
for (const scene of ['private', 'group', 'paTeam']) {
|
|
1536
|
+
const roleId = scene === 'paTeam' ? validatedRegistry.defaultRoles[scene] ?? 'member' : validatedRegistry.defaultRoles[scene];
|
|
1537
|
+
if (roleId !== null && (roleId === 'owner' || !validatedRegistry.roles.includes(roleId))) {
|
|
1538
|
+
throw validationFailed(self, roleId, [{ field: `defaultRoles.${scene}`, code: 'INVALID_ROLE',
|
|
1539
|
+
message: 'Default role must reference an assignable registered role' }]);
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1528
1542
|
for (const change of changes) {
|
|
1529
1543
|
if (!change.after || !change.file.endsWith('.json') || change.file.endsWith('index.json'))
|
|
1530
1544
|
continue;
|
|
@@ -24,6 +24,7 @@ import { getDaemonOwners, ownerResolver, refreshOwnershipForAuthorization, OWNER
|
|
|
24
24
|
import { authorizationNextStep, formatAuthorizationDenial } from '../auth/authorization-denial.js';
|
|
25
25
|
import { resolvePermissionMode, writeAgentModelConfig } from '../model/config-scope.js';
|
|
26
26
|
import { formatPeerKey } from '../relation/peer-identity.js';
|
|
27
|
+
import { preparePaTeamQualification } from '../relation/pa-team.js';
|
|
27
28
|
import { auditFullAccessEvent } from '../auth/authorization-audit.js';
|
|
28
29
|
import { isMainSession, isTopicSession, isTopicThreadId, sessionTopicThreadId } from '../thread/topic-id.js';
|
|
29
30
|
import { modelMatches, getCatalog, assertCatalogSelectable, resolveCatalogModel, CONFIGURABLE_EFFORTS, configurableEfforts } from '../model/model-catalog.js';
|
|
@@ -31,7 +32,7 @@ import { formatModelCheck, runModelCheck } from '../model/model-diagnostics.js';
|
|
|
31
32
|
import { constrainResolvedModelForRole, filterModelsForRole, validateModelSelectionForRole } from '../model/model-permission.js';
|
|
32
33
|
import { isAgentFullAccessOwner, resolveRuntimeStringField, sessionFullAccessStatus, updateRelationSessionFullAccess, } from '../role/runtime-policy.js';
|
|
33
34
|
import { displaySessionTitle } from '../session/session-title.js';
|
|
34
|
-
import { chatmodeFieldForPeer, isPrivateChatmodeRoleLocked, resolveChatModeForField } from '../message/peer-mode.js';
|
|
35
|
+
import { chatmodeFieldForPeer, isChatMode, isPrivateChatmodeRoleLocked, resolveChatModeForField } from '../message/peer-mode.js';
|
|
35
36
|
import { normalizePermissionMode as normalizePermissionModeContract, PUBLIC_PERMISSION_MODES } from '../permission/mode.js';
|
|
36
37
|
import { isManagementRole } from '../../config/builtin-roles.js';
|
|
37
38
|
import { isSystemControlChannel } from '../system-channels.js';
|
|
@@ -42,6 +43,9 @@ import { MAX_AUN_ATTACHMENT_SIZE } from '../../aun/msg/upload.js';
|
|
|
42
43
|
import { DEFAULT_SESSION_LOOP_SECONDS, MAX_SESSION_LOOP_SECONDS, MIN_SESSION_LOOP_SECONDS, refreshSessionLoopTarget, resolveCurrentSessionLoopTarget, resolveSessionLoopTarget, sessionLoopPayload, validateIdleSeconds, writeSessionLoopConfig, } from '../session/session-idle-monitor.js';
|
|
43
44
|
const allEfforts = CONFIGURABLE_EFFORTS;
|
|
44
45
|
const PERMISSION_MODE_KEYS = PUBLIC_PERMISSION_MODES;
|
|
46
|
+
function formatSessionPolicyStatus(name, scope, enabled, updated = false) {
|
|
47
|
+
return `${updated ? '✅ ' : ''}${name} 当前生效:${enabled ? '开启' : '关闭'}(${scope})`;
|
|
48
|
+
}
|
|
45
49
|
function formatUpgradeEvent(event) {
|
|
46
50
|
if (event.event === 'upgrade.progress')
|
|
47
51
|
return `⏳ ${event.message}`;
|
|
@@ -88,7 +92,7 @@ function resolveSlashChatmodeTarget(params) {
|
|
|
88
92
|
function readSlashChatmode(target) {
|
|
89
93
|
try {
|
|
90
94
|
const mode = resolveChatModeForField({ ...target.sel, role: target.role, field: target.field });
|
|
91
|
-
return mode
|
|
95
|
+
return isChatMode(mode)
|
|
92
96
|
? mode
|
|
93
97
|
: defaultSlashChatmode(target.field);
|
|
94
98
|
}
|
|
@@ -428,6 +432,9 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
428
432
|
allowTransient: true,
|
|
429
433
|
includeDaemon: /^\/(?:restart|upgrade|update|reload|pair|fa|fullaccess|diag)(?:\s|$)/i.test(normalizedContent),
|
|
430
434
|
});
|
|
435
|
+
if (this.resolveChannelType(channel) === 'aun' && narrowedChatType === 'private') {
|
|
436
|
+
await preparePaTeamQualification(selfAID ?? this.agentRegistry?.resolveByChannel(channel)?.aid ?? this.resolveSelfAID(channel), userId);
|
|
437
|
+
}
|
|
431
438
|
const identityConversationId = narrowedChatType === 'group' ? channelId : userId;
|
|
432
439
|
const resolvedIdentity = overrideIdentity ?? this.sessionManager.resolveIdentity(channel, userId, narrowedChatType, identityConversationId);
|
|
433
440
|
const authSubject = overrideSubject ?? buildAuthSubject({
|
|
@@ -492,6 +499,8 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
492
499
|
|| topicAuthSession?.chatType
|
|
493
500
|
|| activeSession?.chatType
|
|
494
501
|
|| (chatType === 'group' ? 'group' : 'private');
|
|
502
|
+
const chatmodeChoices = activeChatType === 'group' ? 'proactive'
|
|
503
|
+
: identity.role === 'owner' ? 'interactive|proactive|paactive' : 'interactive|proactive';
|
|
495
504
|
const groupSlash = applyGroupSlashPolicy && activeChatType === 'group';
|
|
496
505
|
if (applyGroupSlashPolicy) {
|
|
497
506
|
const groupGuard = guardGroupSlashCommand(normalizedContent, activeChatType);
|
|
@@ -621,7 +630,12 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
621
630
|
try {
|
|
622
631
|
const current = await refreshSessionLoopTarget(this.sessionManager, route, target);
|
|
623
632
|
const payload = sessionLoopPayload(current);
|
|
624
|
-
return {
|
|
633
|
+
return {
|
|
634
|
+
kind: 'system.notice',
|
|
635
|
+
text: formatSessionPolicyStatus('idle 触发', current.level, payload.value === true)
|
|
636
|
+
+ (payload.value ? `(${payload.idleSeconds} 秒)` : ''),
|
|
637
|
+
subtype: 'session.loop.current',
|
|
638
|
+
};
|
|
625
639
|
}
|
|
626
640
|
catch (error) {
|
|
627
641
|
return { kind: 'command.error', text: `❌ ${error instanceof Error ? error.message : String(error)}` };
|
|
@@ -649,7 +663,12 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
649
663
|
const payload = sessionLoopPayload(updated);
|
|
650
664
|
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
651
665
|
return null;
|
|
652
|
-
return {
|
|
666
|
+
return {
|
|
667
|
+
kind: 'system.notice',
|
|
668
|
+
text: formatSessionPolicyStatus('idle 触发', updated.level, payload.value === true, true)
|
|
669
|
+
+ (payload.value ? `(${payload.idleSeconds} 秒)` : ''),
|
|
670
|
+
subtype: 'session.loop.updated',
|
|
671
|
+
};
|
|
653
672
|
}
|
|
654
673
|
catch (error) {
|
|
655
674
|
return { kind: 'command.error', text: `❌ ${error instanceof Error ? error.message : String(error)}` };
|
|
@@ -673,30 +692,36 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
673
692
|
return { kind: 'command.error', text: '❌ /fa 需要同一身份同时具备 Agent Owner 和 daemon Owner 权限' };
|
|
674
693
|
}
|
|
675
694
|
const status = sessionFullAccessStatus(commandSession, principalId);
|
|
695
|
+
const formatStatus = (current, updated = false) => formatSessionPolicyStatus('fullaccess', current.scope, current.effective, updated)
|
|
696
|
+
+ ';Agent 全局:' + (current.globalEnabled ? '开启' : '关闭')
|
|
697
|
+
+ ';作用域设置:' + (current.localEnabled ? '开启' : '关闭')
|
|
698
|
+
+ (current.globalEnabled ? '(被全局覆盖)' : '');
|
|
676
699
|
if (fullAccessControl.action === 'status') {
|
|
677
|
-
const scope = isTopicSession(commandSession) ? 'session' : 'relation';
|
|
678
700
|
return {
|
|
679
|
-
kind: '
|
|
680
|
-
text:
|
|
681
|
-
|
|
682
|
-
+ '\nAgent 全局:' + (status.globalEnabled ? '开启(局部开关不生效)' : '关闭')
|
|
683
|
-
+ '\n局部开关:' + (status.localEnabled ? '开启' : '关闭'),
|
|
701
|
+
kind: 'system.notice',
|
|
702
|
+
text: formatStatus(status),
|
|
703
|
+
subtype: 'session.fullaccess.current',
|
|
684
704
|
};
|
|
685
705
|
}
|
|
686
706
|
if (status.globalEnabled) {
|
|
687
|
-
return {
|
|
707
|
+
return {
|
|
708
|
+
kind: 'system.notice',
|
|
709
|
+
text: formatStatus(status) + ';Agent 全局已开启,当前作用域设置未修改。',
|
|
710
|
+
subtype: 'session.fullaccess.unchanged',
|
|
711
|
+
};
|
|
688
712
|
}
|
|
689
713
|
if (this.messageQueue.isProcessing(commandSession.id) || this.messageQueue.getQueueLength(commandSession.id) > 0) {
|
|
690
714
|
return { kind: 'command.error', text: '❌ 当前会话有任务执行中,结束后再修改 fullaccess' };
|
|
691
715
|
}
|
|
692
716
|
const enabled = fullAccessControl.action === 'on';
|
|
693
717
|
try {
|
|
718
|
+
let updatedSession;
|
|
694
719
|
if (isTopicSession(commandSession)) {
|
|
695
720
|
const latest = await this.sessionManager.getThreadSession(channel, channelId, threadId);
|
|
696
721
|
if (!latest || latest.id !== commandSession.id || !isTopicSession(latest)) {
|
|
697
722
|
return { kind: 'command.error', text: '❌ 当前话题已发生变化,请重新执行 /fa' };
|
|
698
723
|
}
|
|
699
|
-
this.sessionManager.updateSessionFullAccess(latest.id, { enabled, authorizedBy: principalId });
|
|
724
|
+
updatedSession = this.sessionManager.updateSessionFullAccess(latest.id, { enabled, authorizedBy: principalId });
|
|
700
725
|
}
|
|
701
726
|
else {
|
|
702
727
|
const latest = await this.sessionManager.getActiveSession(channel, channelId);
|
|
@@ -704,6 +729,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
704
729
|
return { kind: 'command.error', text: '❌ 当前主会话已发生变化,请重新执行 /fa' };
|
|
705
730
|
}
|
|
706
731
|
updateRelationSessionFullAccess(latest, { enabled, authorizedBy: principalId });
|
|
732
|
+
updatedSession = latest;
|
|
707
733
|
}
|
|
708
734
|
auditFullAccessEvent({
|
|
709
735
|
event: enabled ? 'fullaccess.session-policy.configured' : 'fullaccess.session-policy.deescalated',
|
|
@@ -716,9 +742,9 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
716
742
|
reason: isTopicSession(commandSession) ? 'topic session fullaccess updated' : 'relation main-session fullaccess updated',
|
|
717
743
|
});
|
|
718
744
|
return {
|
|
719
|
-
kind: '
|
|
720
|
-
text:
|
|
721
|
-
|
|
745
|
+
kind: 'system.notice',
|
|
746
|
+
text: formatStatus(sessionFullAccessStatus(updatedSession, principalId), true),
|
|
747
|
+
subtype: 'session.fullaccess.updated',
|
|
722
748
|
};
|
|
723
749
|
}
|
|
724
750
|
catch (error) {
|
|
@@ -894,7 +920,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
894
920
|
...((canReadChatmode || canSetChatmode || canReadMentionmode || canSetMentionmode) ? [
|
|
895
921
|
'',
|
|
896
922
|
'💬 聊天设置:',
|
|
897
|
-
...(canReadChatmode || canSetChatmode ? [` /chatmode${canSetChatmode ?
|
|
923
|
+
...(canReadChatmode || canSetChatmode ? [` /chatmode${canSetChatmode ? ` [${chatmodeChoices}]` : ''} - 查看${canSetChatmode ? '或切换' : ''}会话模式`] : []),
|
|
898
924
|
...(canReadLoop ? [` /loop${canUpdateLoop ? ' [on [seconds]|off]' : ''} - 查看${canUpdateLoop ? '或设置' : ''}当前会话的单次闲置触发`] : []),
|
|
899
925
|
...(canReadMentionmode || canSetMentionmode ? [` /mention${canSetMentionmode ? ' [mention-only|disabled]' : ''} - 查看${canSetMentionmode ? '或切换' : ''}群聊 @ 处理模式`] : []),
|
|
900
926
|
] : []),
|
|
@@ -938,7 +964,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
938
964
|
...((canReadChatmode || canSetChatmode) ? [
|
|
939
965
|
'',
|
|
940
966
|
'💬 聊天设置:',
|
|
941
|
-
` /chatmode${canSetChatmode ?
|
|
967
|
+
` /chatmode${canSetChatmode ? ` [${chatmodeChoices}]` : ''} - 查看${canSetChatmode ? '或切换' : ''}会话模式`,
|
|
942
968
|
] : []),
|
|
943
969
|
...(canReadLoop ? ['', ` /loop${canUpdateLoop ? ' [on [seconds]|off]' : ''} - 查看${canUpdateLoop ? '或设置' : ''}当前会话的单次闲置触发`] : []),
|
|
944
970
|
...(canReadPermission || canAnswerPermission ? [
|
|
@@ -986,7 +1012,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
986
1012
|
'',
|
|
987
1013
|
'💬 聊天设置:',
|
|
988
1014
|
' /activity [all|text|none] - 查看/控制中间输出显示模式',
|
|
989
|
-
...(canReadChatmode || canSetChatmode ? [` /chatmode${canSetChatmode ?
|
|
1015
|
+
...(canReadChatmode || canSetChatmode ? [` /chatmode${canSetChatmode ? ` [${chatmodeChoices}]` : ''} - 查看${canSetChatmode ? '/切换' : ''}会话模式(被动响应或主动推进)`] : []),
|
|
990
1016
|
...(canReadMentionmode || canSetMentionmode ? [` /mention${canSetMentionmode ? ' [mention-only|disabled]' : ''} - 查看${canSetMentionmode ? '/切换' : ''}群聊 @ 处理模式`] : []),
|
|
991
1017
|
...(canReadLoop ? [` /loop${canUpdateLoop ? ' [on [seconds]|off]' : ''} - 查看${canUpdateLoop ? '或设置' : ''}当前会话的单次闲置触发`] : []),
|
|
992
1018
|
'',
|
|
@@ -1055,6 +1081,18 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1055
1081
|
}
|
|
1056
1082
|
// /evolhelp 命令:返回 JSON 格式的命令列表(供程序解析)
|
|
1057
1083
|
if (normalizedContent === '/evolhelp') {
|
|
1084
|
+
const commonCommands = new Set([
|
|
1085
|
+
'/new', '/status', '/pause', '/resume', '/stop', '/compact', '/model', '/effort',
|
|
1086
|
+
'/thread', '/thread rename', '/thread summary', '/thread summary set',
|
|
1087
|
+
]);
|
|
1088
|
+
// 常用是筛选分类;保留原分类和顺序,不复制条目或改变现有可见范围。
|
|
1089
|
+
const commandList = (commands) => ({
|
|
1090
|
+
kind: 'command.result',
|
|
1091
|
+
text: JSON.stringify({
|
|
1092
|
+
commands: commands.map(entry => commonCommands.has(entry.command) ? { ...entry, common: true } : entry),
|
|
1093
|
+
categories: ['常用', ...new Set(commands.map(entry => entry.category))],
|
|
1094
|
+
}),
|
|
1095
|
+
});
|
|
1058
1096
|
const canReadLoop = canAccessSlashOperation('session.loop.current', 'relation');
|
|
1059
1097
|
const canUpdateLoop = canAccessSlashOperation('session.loop.update', 'relation');
|
|
1060
1098
|
const loopHelp = canReadLoop || canUpdateLoop ? [{
|
|
@@ -1099,7 +1137,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1099
1137
|
}),
|
|
1100
1138
|
];
|
|
1101
1139
|
commands.splice(insertAt + groupMemoryEntries.length, 0, ...groupExtras);
|
|
1102
|
-
return
|
|
1140
|
+
return commandList(commands);
|
|
1103
1141
|
}
|
|
1104
1142
|
const cmds = [...loopHelp];
|
|
1105
1143
|
const canReadModel = canAccessSlashOperation('model.current', 'relation')
|
|
@@ -1186,15 +1224,14 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1186
1224
|
cmds.push({ command: '/file', args: isOwner ? '[channel] <path>' : '<path>', description: '发送项目内文件', category: '工具', roles: [identity.role] });
|
|
1187
1225
|
// 聊天设置
|
|
1188
1226
|
if (canReadChatmode || canSetChatmode)
|
|
1189
|
-
cmds.push({ command: '/chatmode', ...(canSetChatmode ? { args:
|
|
1227
|
+
cmds.push({ command: '/chatmode', ...(canSetChatmode ? { args: `[${chatmodeChoices}]` } : {}), description: `查看${canSetChatmode ? '/切换' : ''}会话模式(被动响应或主动推进)`, category: '聊天设置', roles: [identity.role] });
|
|
1190
1228
|
if (canReadMentionmode || canSetMentionmode)
|
|
1191
1229
|
cmds.push({ command: '/mention', ...(canSetMentionmode ? { args: '[mention-only|disabled]' } : {}), description: `查看${canSetMentionmode ? '/切换' : ''}群聊 @ 处理模式`, category: '聊天设置', roles: [identity.role] });
|
|
1192
1230
|
// 交互
|
|
1193
1231
|
cmds.push({ command: '/ask', args: '<选项>', description: '回答 Agent 的交互式问题', category: '运维', roles: ['visitor', 'member', 'admin', 'owner'] });
|
|
1194
1232
|
// 帮助
|
|
1195
1233
|
cmds.push({ command: '/help', description: '显示帮助信息', category: '帮助', roles: ['visitor', 'member', 'admin', 'owner'] });
|
|
1196
|
-
|
|
1197
|
-
return { kind: 'command.result', text: JSON.stringify({ commands: cmds, categories }) };
|
|
1234
|
+
return commandList(cmds);
|
|
1198
1235
|
}
|
|
1199
1236
|
// /perm 命令:权限模式查询 + 权限审批(快速路径,不进入消息队列)
|
|
1200
1237
|
if (normalizedContent.startsWith('/perm')) {
|
|
@@ -1358,19 +1395,22 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1358
1395
|
}
|
|
1359
1396
|
if (normalizedContent === '/pause') {
|
|
1360
1397
|
const pauseSession = await getExistingSessionForCommand();
|
|
1361
|
-
if (!pauseSession)
|
|
1362
|
-
return { kind: '
|
|
1398
|
+
if (!pauseSession) {
|
|
1399
|
+
return { kind: 'system.notice', text: '当前没有活跃会话', subtype: 'session.pause.idle' };
|
|
1400
|
+
}
|
|
1363
1401
|
const pauseAgent = this.getAgent(channel, pauseSession.baseagent);
|
|
1364
1402
|
const hasActiveTask = pauseAgent.hasActiveStream(pauseSession.id)
|
|
1365
1403
|
|| this.messageQueue.isProcessing(pauseSession.id);
|
|
1366
|
-
if (!hasActiveTask)
|
|
1367
|
-
return { kind: '
|
|
1404
|
+
if (!hasActiveTask) {
|
|
1405
|
+
return { kind: 'system.notice', text: '当前没有正在处理的任务', subtype: 'session.pause.idle' };
|
|
1406
|
+
}
|
|
1368
1407
|
const requested = this.processor.pauseSession(pauseSession.id);
|
|
1369
1408
|
return {
|
|
1370
|
-
kind: '
|
|
1409
|
+
kind: 'system.notice',
|
|
1371
1410
|
text: requested
|
|
1372
1411
|
? '✓ 已请求暂停,任务将在下一次工具调用前暂停'
|
|
1373
1412
|
: '当前任务已请求暂停或正在暂停',
|
|
1413
|
+
subtype: 'session.pause.requested',
|
|
1374
1414
|
};
|
|
1375
1415
|
}
|
|
1376
1416
|
if (normalizedContent.startsWith('/resume ')) {
|
|
@@ -1378,18 +1418,22 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1378
1418
|
}
|
|
1379
1419
|
if (normalizedContent === '/resume') {
|
|
1380
1420
|
const resumeSession = await getExistingSessionForCommand();
|
|
1381
|
-
if (!resumeSession)
|
|
1382
|
-
return { kind: '
|
|
1421
|
+
if (!resumeSession) {
|
|
1422
|
+
return { kind: 'system.notice', text: '当前没有活跃会话', subtype: 'session.resume.idle' };
|
|
1423
|
+
}
|
|
1383
1424
|
const resumed = await this.processor.recoverTask({
|
|
1384
1425
|
sessionId: resumeSession.id,
|
|
1385
1426
|
agentAid: resumeSession.selfAID,
|
|
1386
1427
|
peerId: userId,
|
|
1387
1428
|
encrypted: replyContext?.metadata?.encrypted,
|
|
1388
1429
|
});
|
|
1389
|
-
return
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1430
|
+
return resumed.ok
|
|
1431
|
+
? {
|
|
1432
|
+
kind: 'system.notice',
|
|
1433
|
+
text: resumed.message ?? '已继续当前任务',
|
|
1434
|
+
subtype: 'session.resumed',
|
|
1435
|
+
}
|
|
1436
|
+
: { kind: 'command.error', text: resumed.message ?? '任务恢复失败' };
|
|
1393
1437
|
}
|
|
1394
1438
|
// /baseagent 命令:查看或切换 Agent 后端
|
|
1395
1439
|
if (normalizedContent === '/baseagent' || normalizedContent.startsWith('/baseagent ')) {
|
|
@@ -2037,7 +2081,11 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2037
2081
|
const res = await execAgentAction('reload', { aid: targetAid }, userId ?? '', this.eventBus, this.agentApplicationService);
|
|
2038
2082
|
if ('error' in res)
|
|
2039
2083
|
return { kind: 'command.error', text: `❌ reload 失败:${res.error}` };
|
|
2040
|
-
return {
|
|
2084
|
+
return {
|
|
2085
|
+
kind: 'system.notice',
|
|
2086
|
+
text: `✅ Agent ${targetAid} 配置已重载`,
|
|
2087
|
+
subtype: 'agent.reloaded',
|
|
2088
|
+
};
|
|
2041
2089
|
}
|
|
2042
2090
|
// /agent, /aid, /rpc, /storage — 仅限顶级 CLI 调用,slash 输入拒绝
|
|
2043
2091
|
if (normalizedContent === '/agent' || normalizedContent.startsWith('/agent ') ||
|
|
@@ -2150,7 +2198,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2150
2198
|
return null;
|
|
2151
2199
|
return { kind: 'command.result', text: `✅ 中间输出模式: ${activityArg}(${label})` };
|
|
2152
2200
|
}
|
|
2153
|
-
// /chatmode
|
|
2201
|
+
// /chatmode 命令:私聊提供 interactive/proactive/paactive,群聊固定 proactive
|
|
2154
2202
|
// - 查看:所有人可用
|
|
2155
2203
|
// - 设置:单聊任何角色可设置;群聊仅管理员可设置
|
|
2156
2204
|
if (normalizedContent === '/chatmode' || normalizedContent.startsWith('/chatmode ')) {
|
|
@@ -2160,8 +2208,12 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2160
2208
|
const currentMode = getEffectiveChatmode(existingChatmodeSession);
|
|
2161
2209
|
// 尝试发送 CommandCard 卡片
|
|
2162
2210
|
const modes = [
|
|
2163
|
-
|
|
2211
|
+
...(activeChatType !== 'group'
|
|
2212
|
+
? [{ key: 'interactive', name: '交互模式', desc: '被动响应:收到消息时才回复,回复直接显示' }] : []),
|
|
2164
2213
|
{ key: 'proactive', name: '主动模式', desc: '主动推进:流式输出静默,由 Agent 自调 ctl send 发声' },
|
|
2214
|
+
...((existingChatmodeSession?.channelType ?? this.resolveChannelType?.(channel)) === 'aun'
|
|
2215
|
+
&& activeChatType === 'private' && identity.role === 'owner'
|
|
2216
|
+
? [{ key: 'paactive', name: 'PA 模式', desc: '自动文本显示为 activity,正式回复由 Agent 显式发送' }] : []),
|
|
2165
2217
|
];
|
|
2166
2218
|
const interaction = {
|
|
2167
2219
|
type: 'interaction',
|
|
@@ -2193,10 +2245,13 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2193
2245
|
return null;
|
|
2194
2246
|
// 卡片降级:fall through 到下方文本输出
|
|
2195
2247
|
// 降级:文本
|
|
2196
|
-
return { kind: 'command.result', text: `会话模式: ${currentMode} 用法: /chatmode
|
|
2248
|
+
return { kind: 'command.result', text: `会话模式: ${currentMode} 用法: /chatmode <${chatmodeChoices}>` };
|
|
2249
|
+
}
|
|
2250
|
+
if (!isChatMode(arg)) {
|
|
2251
|
+
return { kind: 'command.error', text: `❌ 无效模式: ${arg}\n可选: ${chatmodeChoices.split('|').join(' / ')}` };
|
|
2197
2252
|
}
|
|
2198
|
-
if (
|
|
2199
|
-
return { kind: 'command.error', text:
|
|
2253
|
+
if (activeChatType === 'group' && arg !== 'proactive') {
|
|
2254
|
+
return { kind: 'command.error', text: '❌ 群聊仅支持 proactive 模式' };
|
|
2200
2255
|
}
|
|
2201
2256
|
if (activeChatType === 'group' && !isAdmin) {
|
|
2202
2257
|
return { kind: 'command.error', text: '❌ 群聊中切换会话模式仅限管理员使用' };
|
|
@@ -2215,12 +2270,21 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2215
2270
|
return { kind: 'command.error', text: `❌ ${target.error}` };
|
|
2216
2271
|
}
|
|
2217
2272
|
const currentMode = readSlashChatmode(target);
|
|
2273
|
+
if (target.field === 'group' && arg !== 'proactive') {
|
|
2274
|
+
return { kind: 'command.error', text: '❌ 群聊仅支持 proactive 模式' };
|
|
2275
|
+
}
|
|
2276
|
+
if (arg === 'paactive' && identity.role !== 'owner') {
|
|
2277
|
+
return { kind: 'command.error', text: '❌ paactive 模式仅限 owner' };
|
|
2278
|
+
}
|
|
2218
2279
|
if (arg === currentMode) {
|
|
2219
2280
|
return { kind: 'command.result', text: `📋 当前会话模式已是 ${arg}` };
|
|
2220
2281
|
}
|
|
2221
|
-
if (arg === 'interactive' && isPrivateChatmodeRoleLocked(target.field, target.role)) {
|
|
2282
|
+
if ((arg === 'interactive' || arg === 'paactive') && isPrivateChatmodeRoleLocked(target.field, target.role)) {
|
|
2222
2283
|
return { kind: 'command.error', text: '❌ 私聊交互模式仅限 owner/admin,当前角色固定为 proactive' };
|
|
2223
2284
|
}
|
|
2285
|
+
if (arg === 'paactive' && (target.field !== 'private' || !target.sel.peerKey?.startsWith('aun#'))) {
|
|
2286
|
+
return { kind: 'command.error', text: '❌ paactive 仅支持 AUN 人类私聊' };
|
|
2287
|
+
}
|
|
2224
2288
|
// 仅在真正需要切换时才要求会话空闲
|
|
2225
2289
|
if (chatmodeSession && threadId) {
|
|
2226
2290
|
const threadSession = await this.sessionManager.getThreadSession(channel, channelId, threadId);
|
|
@@ -2373,8 +2437,9 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2373
2437
|
}
|
|
2374
2438
|
if (normalizedContent === '/stop') {
|
|
2375
2439
|
const stopSession = await getExistingSessionForCommand();
|
|
2376
|
-
if (!stopSession)
|
|
2377
|
-
return { kind: '
|
|
2440
|
+
if (!stopSession) {
|
|
2441
|
+
return { kind: 'system.notice', text: '当前没有正在处理的任务', subtype: 'session.stop.idle' };
|
|
2442
|
+
}
|
|
2378
2443
|
const stopAgent = this.getAgent(channel, stopSession.baseagent);
|
|
2379
2444
|
const sessionKey = stopSession.id;
|
|
2380
2445
|
this.processor?.clearPauseSession?.(sessionKey);
|
|
@@ -2385,7 +2450,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2385
2450
|
// Even an idle session can have an undelivered task:error recovery.
|
|
2386
2451
|
// Persist the stop fence before acknowledging that nothing is running.
|
|
2387
2452
|
await this.processor.interruptSession(sessionKey, 'stop');
|
|
2388
|
-
return { kind: '
|
|
2453
|
+
return { kind: 'system.notice', text: '当前没有正在处理的任务', subtype: 'session.stop.idle' };
|
|
2389
2454
|
}
|
|
2390
2455
|
// 发布中断事件,让 MessageProcessor 标记为 interrupted(而非 done)
|
|
2391
2456
|
this.eventBus.publish({
|
|
@@ -2396,7 +2461,11 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2396
2461
|
agentAid: stopSession.selfAID,
|
|
2397
2462
|
});
|
|
2398
2463
|
await this.processor.interruptSession(sessionKey, 'stop');
|
|
2399
|
-
return {
|
|
2464
|
+
return {
|
|
2465
|
+
kind: 'system.notice',
|
|
2466
|
+
text: '✓ 已发送中断信号,任务将尽快停止',
|
|
2467
|
+
subtype: 'session.stopped',
|
|
2468
|
+
};
|
|
2400
2469
|
}
|
|
2401
2470
|
// /clear 已移除:Claude/Codex/Gemini 对“清空当前 backend 历史”的语义不一致。
|
|
2402
2471
|
// 统一使用 /new 创建新会话来开始全新上下文。
|
|
@@ -2530,7 +2599,12 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2530
2599
|
return { kind: 'command.error', text: `❌ 当前 Agent (${currentSessionAgent.name}) 不支持 /compact` };
|
|
2531
2600
|
}
|
|
2532
2601
|
if (sendMessage) {
|
|
2533
|
-
|
|
2602
|
+
const text = '⏳ 正在压缩会话上下文...';
|
|
2603
|
+
await sendMessage(channelId, text, this.getReplyContext(session), {
|
|
2604
|
+
kind: 'system.notice',
|
|
2605
|
+
text,
|
|
2606
|
+
subtype: 'session.compacting',
|
|
2607
|
+
});
|
|
2534
2608
|
}
|
|
2535
2609
|
// Resolve the same relation/agent effective model used for normal turns.
|
|
2536
2610
|
// The runner instance's model is only the final fallback; without this
|
|
@@ -2596,8 +2670,9 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2596
2670
|
const compactResult = compacted;
|
|
2597
2671
|
if (compactResult === true || compactResult?.ok === true) {
|
|
2598
2672
|
return {
|
|
2599
|
-
kind: '
|
|
2673
|
+
kind: 'system.notice',
|
|
2600
2674
|
text: '✅ 会话压缩完成',
|
|
2675
|
+
subtype: 'session.compacted',
|
|
2601
2676
|
};
|
|
2602
2677
|
}
|
|
2603
2678
|
else {
|
|
@@ -3248,7 +3323,11 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3248
3323
|
},
|
|
3249
3324
|
},
|
|
3250
3325
|
});
|
|
3251
|
-
await adapter.send(envelope, {
|
|
3326
|
+
await adapter.send(envelope, {
|
|
3327
|
+
kind: 'system.notice',
|
|
3328
|
+
text: '🔄 重启监控已接管,服务正在重启;完成后会另行通知。',
|
|
3329
|
+
subtype: 'system.restart.pending',
|
|
3330
|
+
});
|
|
3252
3331
|
// 等待消息发送完成后再延迟 kill
|
|
3253
3332
|
await new Promise(resolve => setTimeout(resolve, 500));
|
|
3254
3333
|
}
|
|
@@ -3274,8 +3353,9 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3274
3353
|
fs.mkdirSync(controlDir, { recursive: true });
|
|
3275
3354
|
fs.writeFileSync(restartConfirmFile, JSON.stringify({ timestamp: Date.now() }));
|
|
3276
3355
|
return {
|
|
3277
|
-
kind: '
|
|
3356
|
+
kind: 'system.notice',
|
|
3278
3357
|
text: `当前Agent对话有 ${pendingResultCount} 条后台结果待查看。再次输入 /restart 将强制重启服务。`,
|
|
3358
|
+
subtype: 'system.restart.confirmation_required',
|
|
3279
3359
|
};
|
|
3280
3360
|
}
|
|
3281
3361
|
const restarted = await executeRestart();
|
|
@@ -3493,9 +3573,13 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3493
3573
|
const sizeStr = stat.size < 1024 ? `${stat.size} B`
|
|
3494
3574
|
: stat.size < 1024 * 1024 ? `${(stat.size / 1024).toFixed(1)} KB`
|
|
3495
3575
|
: `${(stat.size / 1024 / 1024).toFixed(1)} MB`;
|
|
3496
|
-
return {
|
|
3576
|
+
return {
|
|
3577
|
+
kind: 'system.notice',
|
|
3578
|
+
text: isCrossChannel
|
|
3497
3579
|
? `📎 文件已通过 ${targetLabel} 发送: ${filePath} (${sizeStr})`
|
|
3498
|
-
: `✅ 已发送: ${filePath} (${sizeStr})
|
|
3580
|
+
: `✅ 已发送: ${filePath} (${sizeStr})`,
|
|
3581
|
+
subtype: 'file.sent',
|
|
3582
|
+
};
|
|
3499
3583
|
}
|
|
3500
3584
|
catch (error) {
|
|
3501
3585
|
logger.error('[CommandHandler] /file failed:', error);
|
|
@@ -3820,7 +3904,11 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3820
3904
|
return { kind: 'command.error', text: `❌ 重命名失败` };
|
|
3821
3905
|
}
|
|
3822
3906
|
this.eventBus.publish({ type: 'session:renamed', sessionId: session.id, oldName, newName });
|
|
3823
|
-
return {
|
|
3907
|
+
return {
|
|
3908
|
+
kind: 'system.notice',
|
|
3909
|
+
text: `✓ 已将当前会话重命名为: ${newName}`,
|
|
3910
|
+
subtype: 'session.renamed',
|
|
3911
|
+
};
|
|
3824
3912
|
}
|
|
3825
3913
|
// /del 命令:删除指定会话(仅解绑,不删除文件)
|
|
3826
3914
|
if (normalizedContent.startsWith('/del ')) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* FileCache —— 统一的文件缓存(daemon-only)。
|
|
3
3
|
*
|
|
4
|
-
* daemon 每条消息处理时读大量文件(manifest、fragment、md、
|
|
5
|
-
*
|
|
4
|
+
* daemon 每条消息处理时读大量文件(manifest、fragment、md、persona 等)。
|
|
5
|
+
* 本类统一缓存"文件 → 解析后内容",按策略门控变化检查。
|
|
6
6
|
*
|
|
7
7
|
* 设计与边界详见 docs/file-cache-design.md:
|
|
8
8
|
* - 不接管 EvolAgent 的 merged config(agent/defaults 由 EvolAgent 持有权威副本)。
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* 策略(reload/重启永远全量失效,无视策略;策略只决定"平时每次读怎么检查"):
|
|
13
13
|
* - on-reload:平时不检查,直接用缓存(kits 文件)。靠 reload/重启刷新。
|
|
14
14
|
* - manual:同 on-reload,额外支持显式 invalidate(file) 单刷。
|
|
15
|
-
* - mtime:每次读 statSync 门控 size + mtime,变了自动重读(
|
|
15
|
+
* - mtime:每次读 statSync 门控 size + mtime,变了自动重读(soul/*.md、config.json)。
|
|
16
16
|
*
|
|
17
17
|
* 容量:项数可无界增长的组(如 relation-prefs,每 peer 一文件)设 LRU 硬上限
|
|
18
18
|
* (见 GROUP_CAPS),命中/写入移到末尾、超限驱逐同组最旧项;无 timer。
|
|
@@ -166,7 +166,7 @@ export function resumePendingSessions({ sessionManager, messageQueue, droppedTri
|
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
export function createDaemonShutdown({ disposePluginResources, ipcServer, readySignalPath, bindService, ecwebSupervisor, messageQueue, permissionGateway, removePermissionConfigListener, stopStatsPersistence, triggerSchedulers, agentMap, eventBus, removeGroupInviteConfigListener, groupInviteReviewService, channelLoader, channelInstances, controlChannel, sessionManager, removeAll, exit, }) {
|
|
169
|
+
export function createDaemonShutdown({ disposePluginResources, lifecycleNotices, ipcServer, readySignalPath, bindService, ecwebSupervisor, messageQueue, permissionGateway, removePermissionConfigListener, stopStatsPersistence, triggerSchedulers, agentMap, eventBus, removeGroupInviteConfigListener, groupInviteReviewService, channelLoader, channelInstances, controlChannel, sessionManager, removeAll, exit, }) {
|
|
170
170
|
let shutdownSignal = 'unknown';
|
|
171
171
|
let shutdownInProgress = false;
|
|
172
172
|
return async (signal, traceId) => {
|
|
@@ -175,6 +175,14 @@ export function createDaemonShutdown({ disposePluginResources, ipcServer, readyS
|
|
|
175
175
|
shutdownInProgress = true;
|
|
176
176
|
if (signal)
|
|
177
177
|
shutdownSignal = signal;
|
|
178
|
+
// 先停掉还没发完的上线通知,避免和下面的下线通知交叉。
|
|
179
|
+
try {
|
|
180
|
+
lifecycleNotices?.beginShutdown();
|
|
181
|
+
}
|
|
182
|
+
catch { }
|
|
183
|
+
// 下线提示是 best-effort:发起后不等待,退出流程照常继续。
|
|
184
|
+
// 注意必须在这里触发——后面 daemon.channels 会断开 AUN 连接。
|
|
185
|
+
void lifecycleNotices?.sendOffline(shutdownSignal)?.catch(() => { });
|
|
178
186
|
const pid = process.pid;
|
|
179
187
|
const ppid = process.ppid;
|
|
180
188
|
logger.info(`\n\nShutting down gracefully... (signal=${shutdownSignal}, pid=${pid}, ppid=${ppid})`);
|
|
@@ -2,7 +2,8 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { EvolAgent } from './evolagent.js';
|
|
4
4
|
import { logger } from '../utils/logger.js';
|
|
5
|
-
import {
|
|
5
|
+
import { aidLocalDir } from '../paths.js';
|
|
6
|
+
import { readSoulContent } from './soul.js';
|
|
6
7
|
import { invalidateAgentDisplayName, resolveAgentDisplayName } from '../aun/aid/agentmd.js';
|
|
7
8
|
import { loadAllAgents, ensureAgentDirSkeleton, loadAgent, validateAgentConfig, } from '../config-store.js';
|
|
8
9
|
import { ConfigTarget, assertAgentAidAvailable, read as readConfig, resolveEffective } from '../config/config-manager.js';
|
|
@@ -585,9 +586,9 @@ export class EvolAgentRegistry {
|
|
|
585
586
|
if (cached !== undefined)
|
|
586
587
|
return cached;
|
|
587
588
|
try {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
589
|
+
// 只从 soul 里真正写了内容的文件抠名字;指南与空分册不参与。
|
|
590
|
+
const content = readSoulContent(aid);
|
|
591
|
+
if (content) {
|
|
591
592
|
const bold = content.match(/我[叫是]\s*\*{1,2}(.+?)\*{1,2}/);
|
|
592
593
|
if (bold?.[1] && bold[1] !== aid) {
|
|
593
594
|
this.personalNameCache.set(aid, bold[1]);
|