evolcore 0.0.40 → 0.0.41-test.1
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 +94 -1
- package/bin/codex-managed-hook.mjs +11 -0
- package/bin/ec-safe-output.js +11 -1
- package/dist/agents/baseagent-availability.js +1 -1
- package/dist/agents/baseagent.js +20 -43
- package/dist/agents/claude-runner.js +197 -197
- package/dist/agents/codex-runner.js +535 -259
- package/dist/agents/ecagent-runner.js +31 -12
- package/dist/agents/gemini-runner.js +27 -7
- package/dist/agents/runner-types.js +11 -3
- package/dist/aun/ability-device-routing.js +26 -0
- package/dist/aun/aid/client.js +1 -1
- package/dist/aun/group/fs-download.js +39 -0
- package/dist/aun/group/identity.js +36 -13
- package/dist/aun/group/operations.js +5 -0
- package/dist/aun/msg/managed-operation.js +72 -11
- package/dist/aun/msg/p2p.js +32 -7
- package/dist/aun/service-proxy.js +36 -12
- package/dist/aun/storage/download.js +30 -0
- package/dist/aun/storage/index.js +14 -6
- package/dist/channels/aun.js +367 -24
- package/dist/channels/daemon.js +39 -5
- package/dist/cli/agent-command.js +2 -0
- package/dist/cli/agent-create.js +98 -19
- package/dist/cli/agent.js +10 -3
- package/dist/cli/aun-commands.js +85 -41
- package/dist/cli/daemon-commands.js +678 -688
- package/dist/cli/fs-command.js +64 -2
- package/dist/cli/index.js +48 -4
- package/dist/cli/managed-command-guard.js +4 -0
- package/dist/cli/model.js +40 -40
- package/dist/cli/proxy-command.js +92 -0
- package/dist/cli/restart-monitor.js +17 -0
- package/dist/cli/role.js +85 -0
- package/dist/cli/session-command.js +128 -13
- package/dist/cli/stats.js +60 -4
- package/dist/cli/trigger-command.js +2 -2
- package/dist/config/access-policy.js +8 -1
- package/dist/config/boot-log.js +38 -1
- package/dist/config/config-field-policy.js +5 -32
- package/dist/config/config-manager.js +46 -39
- package/dist/config/config-operation-service.js +8 -11
- package/dist/config/contact-book-store.js +47 -21
- package/dist/config/contact-book.js +18 -12
- package/dist/config/contact-operation-service.js +3 -4
- package/dist/config/contact-request-service.js +11 -0
- package/dist/config/daemon-services.js +11 -0
- package/dist/config/gateway-config.js +89 -595
- package/dist/config/peer-role-resolver.js +15 -11
- package/dist/config/providers-config.js +12 -7
- package/dist/config/providers-import.js +3 -21
- package/dist/config/resolved-config-op.js +3 -0
- package/dist/config/role-command-service.js +166 -0
- package/dist/config/role-request-service.js +193 -0
- package/dist/config/schema-migration.js +686 -25
- package/dist/config-store.js +79 -3
- package/dist/contracts/ecweb-instance.js +41 -0
- package/dist/contracts/ecweb-service-protocol.js +3 -1
- package/dist/core/agent-application-service.js +11 -1
- package/dist/core/agent-ipc-registration.js +4 -0
- package/dist/core/agent-runtime.js +1 -1
- package/dist/core/auth/agent-delegation.js +82 -6
- package/dist/core/auth/auth-gateway.js +1 -1
- package/dist/core/auth/authorization-audit.js +37 -9
- package/dist/core/auth/delegation-authorization.js +3 -1
- package/dist/core/auth/operation-authorizer.js +15 -0
- package/dist/core/auth/operation-catalog.js +39 -6
- package/dist/core/command/agent-control.js +94 -19
- package/dist/core/command/agent-storage-menu.js +5 -3
- package/dist/core/command/cli-intent-parser.js +2 -1
- package/dist/core/command/command-handler.js +105 -145
- package/dist/core/command/connect-menu.js +31 -2
- package/dist/core/command/data-root-resolver.js +5 -4
- package/dist/core/command/memory-slash.js +16 -8
- package/dist/core/command/menu-catalog.js +6 -6
- package/dist/core/command/menu-handler.js +87 -163
- package/dist/core/command/menu-protocol.js +9 -2
- package/dist/core/command/role-menu.js +148 -30
- package/dist/core/command/slash-gate.js +13 -10
- package/dist/core/command/slash-handler.js +157 -352
- package/dist/core/daemon-control.js +8 -14
- package/dist/core/event-catalog.js +15 -0
- package/dist/core/evolagent-registry.js +4 -4
- package/dist/core/evolagent.js +2 -2
- package/dist/core/inference/text-inference.js +31 -40
- package/dist/core/ipc-registration.js +24 -3
- package/dist/core/memory/consolidation-context.js +51 -5
- package/dist/core/memory/consolidation-ops-records.js +1 -1
- package/dist/core/memory/consolidation-trigger.js +190 -190
- package/dist/core/memory/consolidation.js +316 -29
- package/dist/core/memory/forget-log.js +96 -0
- package/dist/core/memory/index-manager.js +27 -5
- package/dist/core/memory/memory-admin.js +45 -5
- package/dist/core/memory/memory-writer.js +163 -18
- package/dist/core/memory/relation-idle-monitor.js +119 -58
- package/dist/core/memory/relation-sweep.js +44 -39
- package/dist/core/message/aun-ipc-sender.js +34 -7
- package/dist/core/message/aun-request-registry.js +97 -3
- package/dist/core/message/im-renderer.js +11 -4
- package/dist/core/message/message-admission.js +97 -8
- package/dist/core/message/message-bridge.js +71 -24
- package/dist/core/message/message-log.js +55 -0
- package/dist/core/message/message-queue.js +5 -5
- package/dist/core/message/response-engine.js +387 -144
- package/dist/core/model/catalog-service.js +4 -2
- package/dist/core/model/config-scope.js +24 -64
- package/dist/core/model/field-scope.js +1 -1
- package/dist/core/model/model-catalog.js +37 -47
- package/dist/core/model/model-diagnostics.js +4 -3
- package/dist/core/model/model-fallback.js +10 -7
- package/dist/core/model/model-permission.js +3 -2
- package/dist/core/ownership/owner-resolver.js +25 -23
- package/dist/core/permission/ec-command-parser.js +138 -5
- package/dist/core/permission/sandbox-runtime.js +18 -1
- package/dist/core/permission/tool-policy.js +42 -10
- package/dist/core/relation/peer-identity.js +64 -1
- package/dist/core/role/runtime-policy.js +72 -13
- package/dist/core/session/session-capsule.js +197 -0
- package/dist/core/session/session-idle-monitor.js +1 -1
- package/dist/core/session/session-manager.js +168 -14
- package/dist/core/session/session-mapper.js +2 -0
- package/dist/core/session/session-renew.js +3 -3
- package/dist/core/skill/index-generator.js +15 -5
- package/dist/core/system-session/memory.js +6 -1
- package/dist/core/thread/thread-service.js +19 -6
- package/dist/directory/owner-directory-admission.js +95 -0
- package/dist/directory/owner-directory-authorization.js +309 -0
- package/dist/directory/owner-directory-cache.js +635 -0
- package/dist/eck/kit-renderer.js +2 -2
- package/dist/ecweb/basic-settings-service.js +33 -40
- package/dist/ecweb/message-context-service.js +110 -0
- package/dist/index.js +79 -17
- package/dist/ipc.js +189 -17
- package/dist/paths.js +4 -0
- package/dist/proxy/command.js +122 -0
- package/dist/proxy/ipc-service.js +68 -0
- package/dist/proxy/manager.js +485 -0
- package/dist/proxy/service-supervisor.js +603 -0
- package/dist/response-system/engines/v1/proactive-flow.js +16 -6
- package/dist/stats/budget.js +1 -1
- package/dist/stats/db.js +15 -0
- package/dist/stats/index.js +2 -2
- package/dist/stats/price-resolver.js +304 -5
- package/dist/stats/query.js +82 -3
- package/dist/stats/writer.js +38 -5
- package/dist/trigger/feedback.js +18 -7
- package/dist/trigger/manager.js +20 -3
- package/dist/trigger/parser.js +6 -3
- package/dist/trigger/patch.js +1 -1
- package/dist/trigger/system-definitions.js +43 -7
- package/dist/trigger/validation.js +13 -5
- package/dist/utils/cross-platform.js +14 -0
- package/dist/utils/ecweb-supervisor.js +258 -83
- package/dist/utils/error-utils.js +16 -2
- package/dist/utils/logger.js +24 -5
- package/dist/utils/npm-ops.js +2 -1
- package/dist/utils/package-version-info.js +5 -3
- package/dist/utils/upgrade-jobs.js +45 -5
- package/kits/docs/INDEX.md +1 -1
- package/kits/docs/aun/ABILITY_CALLING.md +20 -2
- package/kits/docs/channels/aun.md +9 -0
- package/kits/docs/evolcore/INDEX.md +2 -1
- package/kits/docs/evolcore/agent-create.md +3 -2
- package/kits/docs/evolcore/agent.md +1 -1
- package/kits/docs/evolcore/config.md +18 -7
- package/kits/docs/evolcore/contact.md +3 -0
- package/kits/docs/evolcore/event.md +1 -0
- package/kits/docs/evolcore/fs.md +16 -0
- package/kits/docs/evolcore/memory-architecture.md +2 -2
- package/kits/docs/evolcore/memory-consolidation.md +32 -8
- package/kits/docs/evolcore/memory.md +1 -1
- package/kits/docs/evolcore/menu-protocol.md +36 -0
- package/kits/docs/evolcore/model.md +23 -20
- package/kits/docs/evolcore/msg.md +21 -8
- package/kits/docs/evolcore/session.md +14 -0
- package/kits/migrations/migrate-contact-book-v2.mjs +30 -11
- package/kits/schemas/_meta.json +37 -4
- package/kits/schemas/agent-config.schema.13.json +23 -3
- package/kits/schemas/agent-config.schema.16.json +891 -0
- package/kits/schemas/daemon.schema.9.json +366 -0
- package/kits/schemas/defaults.schema.5.json +406 -127
- package/kits/schemas/relation-config.schema.11.json +260 -0
- package/kits/schemas/role-config.schema.1.json +7 -7
- package/kits/skills/.switches.json +3 -7
- package/kits/skills/aid-ability/SKILL.md +35 -6
- package/kits/skills/ec-service-proxy/SKILL.md +118 -0
- package/kits/skills/ec-trigger/SKILL.md +13 -5
- package/kits/skills/personal-assistant/SKILL.md +176 -0
- package/kits/skills/personal-assistant/references/01-workspace-spec.md +333 -0
- package/kits/skills/personal-assistant/references/02-bootstrap.md +205 -0
- package/kits/skills/personal-assistant/references/03-data-flow-and-gaps.md +177 -0
- package/kits/skills/personal-assistant/references/04-frontend-contract.md +439 -0
- package/kits/skills/personal-assistant/references/05-directory-reference.md +292 -0
- package/kits/skills/personal-assistant/references/06-render-config.md +350 -0
- package/kits/skills/personal-assistant/schema/workspace.schema.json +85 -0
- package/kits/skills/personal-assistant/schema/workspace.v1.json +66 -0
- package/kits/skills/personal-assistant/scripts/archive.mjs +154 -0
- package/kits/skills/personal-assistant/scripts/check.mjs +114 -0
- package/kits/skills/personal-assistant/scripts/index-rebuild.mjs +252 -0
- package/kits/skills/personal-assistant/scripts/ingest.mjs +344 -0
- package/kits/skills/personal-assistant/scripts/init.mjs +270 -0
- package/kits/skills/personal-assistant/scripts/lib/apply.mjs +92 -0
- package/kits/skills/personal-assistant/scripts/lib/schema.mjs +96 -0
- package/kits/skills/personal-assistant/scripts/lib/time.mjs +28 -0
- package/kits/skills/personal-assistant/scripts/migrate.mjs +172 -0
- package/kits/skills/personal-assistant/scripts/search.mjs +172 -0
- package/kits/skills/personal-assistant/scripts/verify.mjs +196 -0
- package/kits/skills/personal-assistant/templates/INDEX.md.tpl +24 -0
- package/kits/skills/personal-assistant/templates/README.md.tpl +108 -0
- package/kits/skills/personal-assistant/triggers/ingest-daily.json +23 -0
- package/kits/skills/personal-assistant/triggers/memory-consolidate.json +23 -0
- package/kits/skills/personal-assistant/triggers/report-daily.json +23 -0
- package/kits/skills/personal-assistant/triggers/report-weekly.json +23 -0
- package/kits/templates/memory-consolidation/forget.md +19 -6
- package/kits/templates/memory-consolidation/notes.md +1 -1
- package/kits/templates/memory-consolidation/profile.md +2 -2
- package/kits/templates/memory-consolidation/promote.md +20 -3
- package/kits/templates/roles/member.json +8 -1
- package/kits/templates/session-capsule/recovery.md +5 -0
- package/kits/templates/session-capsule/renew.md +5 -0
- package/kits/templates/system-fragments/baseagent.md +2 -2
- package/kits/templates/system-fragments/bootstrap.md +6 -6
- package/kits/templates/system-fragments/channel.md +1 -1
- package/kits/templates/system-fragments/memory.md +4 -4
- package/package.json +7 -3
- package/dist/stats/billing.js +0 -215
|
@@ -12,7 +12,7 @@ import fs from 'fs';
|
|
|
12
12
|
import { ensureFreshPackageVersionInfo, refreshManagedPackageVersions } from '../../utils/package-version-info.js';
|
|
13
13
|
import { loadDaemonConfig } from '../../config-store.js';
|
|
14
14
|
import { remoteAccessService } from '../auth/remote-access-store.js';
|
|
15
|
-
import { read as cfgRead, resolveEffective, routeFieldPath, write as cfgWrite,
|
|
15
|
+
import { read as cfgRead, resolveEffective, routeFieldPath, write as cfgWrite, } from '../../config/config-manager.js';
|
|
16
16
|
import { execAgentAction } from './agent-control.js';
|
|
17
17
|
import { handleMemorySlash, memoryHelpEntries } from './memory-slash.js';
|
|
18
18
|
import { handleSkillSlash, skillHelpEntries } from './skill-slash.js';
|
|
@@ -20,14 +20,14 @@ import { handleTopicSlash, topicHelpEntries, canUseTopicSlash } from './topic-sl
|
|
|
20
20
|
import { authorizeOperation, authorizeFreshOperation, buildAuthSubject } from '../auth/auth-gateway.js';
|
|
21
21
|
import { getDaemonOwners, ownerResolver, refreshOwnershipForAuthorization, OWNERSHIP_CACHE_MAX_AGE_MS } from '../ownership/owner-resolver.js';
|
|
22
22
|
import { authorizationNextStep, formatAuthorizationDenial } from '../auth/authorization-denial.js';
|
|
23
|
-
import { resolvePermissionMode,
|
|
23
|
+
import { resolvePermissionMode, writeAgentModelConfig } from '../model/config-scope.js';
|
|
24
24
|
import { formatPeerKey } from '../relation/peer-identity.js';
|
|
25
25
|
import { auditFullAccessEvent } from '../auth/authorization-audit.js';
|
|
26
26
|
import { isMainSession, isTopicSession, isTopicThreadId, sessionTopicThreadId } from '../thread/topic-id.js';
|
|
27
27
|
import { modelMatches, getCatalog, assertCatalogSelectable, resolveCatalogModel, CONFIGURABLE_EFFORTS, configurableEfforts } from '../model/model-catalog.js';
|
|
28
28
|
import { formatModelCheck, runModelCheck } from '../model/model-diagnostics.js';
|
|
29
29
|
import { constrainResolvedModelForRole, filterModelsForRole, validateModelSelectionForRole } from '../model/model-permission.js';
|
|
30
|
-
import { isAgentFullAccessOwner, resolveRuntimeStringField, sessionFullAccessStatus, } from '../role/runtime-policy.js';
|
|
30
|
+
import { isAgentFullAccessOwner, resolveRuntimeStringField, sessionFullAccessStatus, updateRelationSessionFullAccess, } from '../role/runtime-policy.js';
|
|
31
31
|
import { displaySessionTitle } from '../session/session-title.js';
|
|
32
32
|
import { chatmodeFieldForPeer, isPrivateChatmodeRoleLocked, resolveChatModeForField } from '../message/peer-mode.js';
|
|
33
33
|
import { normalizePermissionMode as normalizePermissionModeContract, PUBLIC_PERMISSION_MODES } from '../permission/mode.js';
|
|
@@ -37,7 +37,7 @@ import { launchMonitorAndConfirm, resolveMonitorLaunch, cleanupMonitorStage, isP
|
|
|
37
37
|
import { scanInstances } from '../../utils/instance-registry.js';
|
|
38
38
|
import { guardIdleCommand, guardGroupSlashCommand, guardKnownCommand, guardRoleCommand, guardThreadCommand, isRecognizedSlashCommand, normalizeSlashContent, parseFullAccessCommand, probeSessionActivity, } from './slash-gate.js';
|
|
39
39
|
import { MAX_AUN_ATTACHMENT_SIZE } from '../../aun/msg/upload.js';
|
|
40
|
-
import { DEFAULT_SESSION_LOOP_SECONDS, MAX_SESSION_LOOP_SECONDS, MIN_SESSION_LOOP_SECONDS, refreshSessionLoopTarget, resolveCurrentSessionLoopTarget, sessionLoopPayload, validateIdleSeconds, writeSessionLoopConfig, } from '../session/session-idle-monitor.js';
|
|
40
|
+
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';
|
|
41
41
|
const allEfforts = CONFIGURABLE_EFFORTS;
|
|
42
42
|
const PERMISSION_MODE_KEYS = PUBLIC_PERMISSION_MODES;
|
|
43
43
|
function defaultSlashChatmode(field) {
|
|
@@ -511,7 +511,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
511
511
|
const canAccessSlashOperation = (operation, scope) => {
|
|
512
512
|
const args = scope === 'relation'
|
|
513
513
|
? buildSlashRelationIntentArgs({ selfAid: authSubject.selfAid, peerKey: authSubject.peerKey })
|
|
514
|
-
: {};
|
|
514
|
+
: scope === 'agent' && authSubject.selfAid ? { self: authSubject.selfAid } : {};
|
|
515
515
|
return authorizeOperation({
|
|
516
516
|
source: 'slash',
|
|
517
517
|
intent: { operation, scope, source: 'slash', args },
|
|
@@ -631,6 +631,9 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
631
631
|
}
|
|
632
632
|
const fullAccessControl = parseFullAccessCommand(normalizedContent);
|
|
633
633
|
if (fullAccessControl.matched) {
|
|
634
|
+
if (fullAccessControl.action === 'prompt') {
|
|
635
|
+
return { kind: 'command.error', text: '❌ /fa <任务信息> 只能由用户直接发送' };
|
|
636
|
+
}
|
|
634
637
|
if (activeChatType === 'group' || source === 'card-trigger') {
|
|
635
638
|
return { kind: 'command.error', text: '❌ /fa 仅支持私聊中的当前 EC 会话' };
|
|
636
639
|
}
|
|
@@ -640,21 +643,26 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
640
643
|
if (!commandSession || !agentAid) {
|
|
641
644
|
return { kind: 'command.error', text: '❌ 当前没有可绑定的 EC 会话' };
|
|
642
645
|
}
|
|
643
|
-
if (this.messageQueue.isProcessing(commandSession.id) || this.messageQueue.getQueueLength(commandSession.id) > 0) {
|
|
644
|
-
return { kind: 'command.error', text: '❌ 当前会话有任务执行中,结束后再修改 fullaccess' };
|
|
645
|
-
}
|
|
646
646
|
if (!principalId || !authSubject.isDaemonOwner || !isAgentFullAccessOwner(agentAid, principalId)) {
|
|
647
647
|
return { kind: 'command.error', text: '❌ /fa 需要同一身份同时具备 Agent Owner 和 daemon Owner 权限' };
|
|
648
648
|
}
|
|
649
|
+
const status = sessionFullAccessStatus(commandSession, principalId);
|
|
649
650
|
if (fullAccessControl.action === 'status') {
|
|
650
|
-
const
|
|
651
|
-
const scope = isTopicSession(commandSession) ? 'session' : 'agent';
|
|
651
|
+
const scope = isTopicSession(commandSession) ? 'session' : 'relation';
|
|
652
652
|
return {
|
|
653
653
|
kind: 'command.result',
|
|
654
654
|
text: '当前 fullaccess(' + scope + ',session=' + commandSession.id + '):'
|
|
655
|
-
+ (status.effective ? '开启' : '关闭')
|
|
655
|
+
+ (status.effective ? '开启' : '关闭')
|
|
656
|
+
+ '\nAgent 全局:' + (status.globalEnabled ? '开启(局部开关不生效)' : '关闭')
|
|
657
|
+
+ '\n局部开关:' + (status.localEnabled ? '开启' : '关闭'),
|
|
656
658
|
};
|
|
657
659
|
}
|
|
660
|
+
if (status.globalEnabled) {
|
|
661
|
+
return { kind: 'command.result', text: 'Agent 全局 fullaccess 已开启,/fa on/off 不生效;局部设置未修改。' };
|
|
662
|
+
}
|
|
663
|
+
if (this.messageQueue.isProcessing(commandSession.id) || this.messageQueue.getQueueLength(commandSession.id) > 0) {
|
|
664
|
+
return { kind: 'command.error', text: '❌ 当前会话有任务执行中,结束后再修改 fullaccess' };
|
|
665
|
+
}
|
|
658
666
|
const enabled = fullAccessControl.action === 'on';
|
|
659
667
|
try {
|
|
660
668
|
if (isTopicSession(commandSession)) {
|
|
@@ -669,11 +677,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
669
677
|
if (!latest || latest.id !== commandSession.id || !isMainSession(latest)) {
|
|
670
678
|
return { kind: 'command.error', text: '❌ 当前主会话已发生变化,请重新执行 /fa' };
|
|
671
679
|
}
|
|
672
|
-
|
|
673
|
-
if (!config)
|
|
674
|
-
return { kind: 'command.error', text: '❌ 找不到当前 Agent 配置' };
|
|
675
|
-
config.fullaccess = { enabled };
|
|
676
|
-
cfgWrite(ConfigTarget.Agent, config, { self: agentAid });
|
|
680
|
+
updateRelationSessionFullAccess(latest, { enabled, authorizedBy: principalId });
|
|
677
681
|
}
|
|
678
682
|
auditFullAccessEvent({
|
|
679
683
|
event: enabled ? 'fullaccess.session-policy.configured' : 'fullaccess.session-policy.deescalated',
|
|
@@ -683,11 +687,12 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
683
687
|
agentAid,
|
|
684
688
|
sessionId: commandSession.id,
|
|
685
689
|
authorizedBy: principalId,
|
|
686
|
-
reason: isTopicSession(commandSession) ? 'topic session fullaccess updated' : '
|
|
690
|
+
reason: isTopicSession(commandSession) ? 'topic session fullaccess updated' : 'relation main-session fullaccess updated',
|
|
687
691
|
});
|
|
688
692
|
return {
|
|
689
693
|
kind: 'command.result',
|
|
690
|
-
text: '✅ 当前
|
|
694
|
+
text: '✅ 当前' + (isTopicSession(commandSession) ? '话题 EC 会话' : '主会话')
|
|
695
|
+
+ ' fullaccess 已' + (enabled ? '开启' : '关闭'),
|
|
691
696
|
};
|
|
692
697
|
}
|
|
693
698
|
catch (error) {
|
|
@@ -836,8 +841,8 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
836
841
|
}
|
|
837
842
|
const canReadModel = canAccessSlashOperation('model.current', 'relation')
|
|
838
843
|
|| canAccessSlashOperation('model.list', 'relation');
|
|
839
|
-
const canUseModel = canAccessSlashOperation('model.use', '
|
|
840
|
-
const canSetEffort = canAccessSlashOperation('model.effort', '
|
|
844
|
+
const canUseModel = canAccessSlashOperation('model.use', 'agent');
|
|
845
|
+
const canSetEffort = canAccessSlashOperation('model.effort', 'agent');
|
|
841
846
|
const canReadPermission = canAccessSlashOperation('permission.current', 'relation');
|
|
842
847
|
const canAnswerPermission = canAccessSlashOperation('permission.answer', 'relation');
|
|
843
848
|
const canReadChatmode = canAccessSlashOperation('chatmode.current', 'relation');
|
|
@@ -848,7 +853,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
848
853
|
const appendProcessCommands = (lines) => {
|
|
849
854
|
if (!isDaemonOwner)
|
|
850
855
|
return;
|
|
851
|
-
lines.push('', '🛠️ 进程级运维:', ' /restart - 重启服务', ' /upgrade - 检查版本更新', ' /reload [aid] - 热重载 Agent 配置', ' /fa [on|off] -
|
|
856
|
+
lines.push('', '🛠️ 进程级运维:', ' /restart - 重启服务', ' /upgrade - 检查版本更新', ' /reload [aid] - 热重载 Agent 配置', ' /fa [on|off|<任务信息>] - 查看/切换会话 fullaccess,或单次执行任务', ' /pair - 获取远程控制配对码', ' /diag <问题描述> - 邀请或追加远程诊断;/diag stop 撤销授权');
|
|
852
857
|
};
|
|
853
858
|
if (!isAdmin && activeChatType === 'group') {
|
|
854
859
|
const lines = [
|
|
@@ -980,7 +985,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
980
985
|
...(isDaemonOwner ? [
|
|
981
986
|
' /restart - 重启服务',
|
|
982
987
|
' /reload [aid] - 热重载 Agent 配置',
|
|
983
|
-
' /fa [on|off] -
|
|
988
|
+
' /fa [on|off|<任务信息>] - 查看/切换会话 fullaccess,或单次执行任务',
|
|
984
989
|
' /pair - 获取远程控制配对码',
|
|
985
990
|
] : []),
|
|
986
991
|
...(!isDaemonOwner && isAdmin ? [
|
|
@@ -1073,8 +1078,8 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1073
1078
|
const cmds = [...loopHelp];
|
|
1074
1079
|
const canReadModel = canAccessSlashOperation('model.current', 'relation')
|
|
1075
1080
|
|| canAccessSlashOperation('model.list', 'relation');
|
|
1076
|
-
const canUseModel = canAccessSlashOperation('model.use', '
|
|
1077
|
-
const canSetEffort = canAccessSlashOperation('model.effort', '
|
|
1081
|
+
const canUseModel = canAccessSlashOperation('model.use', 'agent');
|
|
1082
|
+
const canSetEffort = canAccessSlashOperation('model.effort', 'agent');
|
|
1078
1083
|
const canReadPermission = canAccessSlashOperation('permission.current', 'relation');
|
|
1079
1084
|
const canAnswerPermission = canAccessSlashOperation('permission.answer', 'relation');
|
|
1080
1085
|
const canReadChatmode = canAccessSlashOperation('chatmode.current', 'relation');
|
|
@@ -1140,7 +1145,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1140
1145
|
cmds.push({ command: '/observable', args: '[true|false]', description: '查看或切换观察者模式', category: '运维', roles: ['owner'] });
|
|
1141
1146
|
}
|
|
1142
1147
|
if (isDaemonOwner) {
|
|
1143
|
-
cmds.push({ command: '/fa', aliases: ['/fullaccess'], args: '[on|off]', description: '
|
|
1148
|
+
cmds.push({ command: '/fa', aliases: ['/fullaccess'], args: '[on|off|<任务信息>]', description: '查看/切换当前 EC 会话 fullaccess,或单次执行 fullaccess 任务', category: '权限管理', roles: ['daemon-owner'] });
|
|
1144
1149
|
cmds.push({ command: '/restart', description: '重启服务', category: '运维', roles: ['daemon-owner'] });
|
|
1145
1150
|
cmds.push({ command: '/upgrade', description: '检查版本更新', category: '运维', roles: ['daemon-owner'] });
|
|
1146
1151
|
cmds.push({ command: '/reload', args: '[aid]', description: '热重载 Agent 配置', category: '运维', roles: ['daemon-owner'] });
|
|
@@ -1381,7 +1386,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1381
1386
|
initiatorId: userId,
|
|
1382
1387
|
kind: {
|
|
1383
1388
|
kind: 'command-card',
|
|
1384
|
-
title: '🔌
|
|
1389
|
+
title: '🔌 新会话默认 Baseagent',
|
|
1385
1390
|
buttons: available.map((a) => ({
|
|
1386
1391
|
label: a === activeBaseagent ? `✓ ${a}` : a,
|
|
1387
1392
|
command: `/baseagent ${a}`,
|
|
@@ -1400,9 +1405,9 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1400
1405
|
const list = available.map((a) => `${a === activeBaseagent ? ' ✓' : ' '} ${a}`).join('\n');
|
|
1401
1406
|
const canSwitchAgent = isOwner && !groupSlash;
|
|
1402
1407
|
if (canSwitchAgent) {
|
|
1403
|
-
return { kind: 'command.result', text:
|
|
1408
|
+
return { kind: 'command.result', text: `新会话默认 Baseagent: ${activeBaseagent}\n\n可用:\n${list}\n用法: /baseagent <name>` };
|
|
1404
1409
|
}
|
|
1405
|
-
return { kind: 'command.result', text:
|
|
1410
|
+
return { kind: 'command.result', text: `新会话默认 Baseagent: ${activeBaseagent}` };
|
|
1406
1411
|
}
|
|
1407
1412
|
if (!available.includes(args)) {
|
|
1408
1413
|
return { kind: 'command.error', text: `❌ 未知 Agent: ${args}\n可用: ${available.join(', ')}` };
|
|
@@ -1412,103 +1417,17 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1412
1417
|
}
|
|
1413
1418
|
const currentSession = await getExistingSessionForCommand();
|
|
1414
1419
|
const previousBaseagent = owningAgent.baseagent || this.parseDefaultBaseagent();
|
|
1415
|
-
const currentTopicThreadId = sessionTopicThreadId(currentSession);
|
|
1416
|
-
if (currentSession && currentTopicThreadId) {
|
|
1417
|
-
const rotation = await withIdleTopicBackend(currentSession.id, currentTopicThreadId, async (current) => {
|
|
1418
|
-
try {
|
|
1419
|
-
owningAgent.setActiveBaseagent(args);
|
|
1420
|
-
}
|
|
1421
|
-
catch (error) {
|
|
1422
|
-
return { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
1423
|
-
}
|
|
1424
|
-
try {
|
|
1425
|
-
const result = await this.sessionManager.rotateTopicBackend({
|
|
1426
|
-
sessionId: current.id,
|
|
1427
|
-
// withIdleTopicBackend 已校验 sessionTopicThreadId(current) === currentTopicThreadId
|
|
1428
|
-
expectedThreadId: currentTopicThreadId,
|
|
1429
|
-
baseagent: args,
|
|
1430
|
-
});
|
|
1431
|
-
return { ok: true, result };
|
|
1432
|
-
}
|
|
1433
|
-
catch (error) {
|
|
1434
|
-
try {
|
|
1435
|
-
owningAgent.setActiveBaseagent(previousBaseagent);
|
|
1436
|
-
}
|
|
1437
|
-
catch { }
|
|
1438
|
-
return { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
1439
|
-
}
|
|
1440
|
-
}, currentSession);
|
|
1441
|
-
if (!rotation.ok) {
|
|
1442
|
-
if (rotation.reason === 'busy')
|
|
1443
|
-
return { kind: 'command.error', text: '⚠️ 当前话题会话忙碌,无法切换 baseagent,请稍后再试' };
|
|
1444
|
-
if (rotation.reason === 'unknown')
|
|
1445
|
-
return { kind: 'command.error', text: '⚠️ 当前话题会话状态未知,无法安全切换 baseagent,请稍后再试' };
|
|
1446
|
-
return { kind: 'command.error', text: `❌ baseagent 切换失败:${rotation.reason === 'missing' ? '当前话题会话不存在' : '状态未知'}` };
|
|
1447
|
-
}
|
|
1448
|
-
if (!rotation.value.ok)
|
|
1449
|
-
return { kind: 'command.error', text: `❌ baseagent 切换失败:${rotation.value.error}` };
|
|
1450
|
-
this.eventBus.publish({ type: 'agent:baseagent-changed', aid: owningAgent.aid, baseagent: args, previousBaseagent, scope: 'agent', timestamp: Date.now() });
|
|
1451
|
-
return {
|
|
1452
|
-
kind: 'system.notice',
|
|
1453
|
-
text: `✓ 当前话题已切换 Baseagent: ${previousBaseagent} → ${args}\n 话题会话 ID 保持不变: ${currentSession.id}`,
|
|
1454
|
-
subtype: 'session.created',
|
|
1455
|
-
};
|
|
1456
|
-
}
|
|
1457
|
-
await interruptPausedSessionBeforeReplacement(currentSession);
|
|
1458
1420
|
try {
|
|
1459
1421
|
owningAgent.setActiveBaseagent(args);
|
|
1460
1422
|
}
|
|
1461
1423
|
catch (error) {
|
|
1462
1424
|
return { kind: 'command.error', text: `❌ ${error instanceof Error ? error.message : String(error)}` };
|
|
1463
1425
|
}
|
|
1464
|
-
let newSession;
|
|
1465
|
-
try {
|
|
1466
|
-
newSession = await this.sessionManager.createNewSession(channel, channelId, owningAgent.projectPath, undefined, args, currentSession?.metadata, { previousBaseagent, baseagentChanged: previousBaseagent !== args });
|
|
1467
|
-
}
|
|
1468
|
-
catch (error) {
|
|
1469
|
-
try {
|
|
1470
|
-
owningAgent.setActiveBaseagent(previousBaseagent);
|
|
1471
|
-
}
|
|
1472
|
-
catch { }
|
|
1473
|
-
return { kind: 'command.error', text: `❌ 创建新会话失败:${error instanceof Error ? error.message : String(error)}` };
|
|
1474
|
-
}
|
|
1475
|
-
if (currentSession) {
|
|
1476
|
-
const previousAgent = getActiveAgentIfAvailable();
|
|
1477
|
-
if (previousAgent) {
|
|
1478
|
-
await previousAgent.clearSession(currentSession.id, currentSession.agentSessionId || '', currentSession.projectPath);
|
|
1479
|
-
await previousAgent.closeSession(currentSession.id);
|
|
1480
|
-
}
|
|
1481
|
-
}
|
|
1482
1426
|
this.eventBus.publish({ type: 'agent:baseagent-changed', aid: owningAgent.aid, baseagent: args, previousBaseagent, scope: 'agent', timestamp: Date.now() });
|
|
1483
|
-
// 与 /new 一致:按 关系>角色>agent 解析新 backend 实际生效的 model/effort,
|
|
1484
|
-
// 而不是只显示 baseagent 名。
|
|
1485
|
-
const newBaseagentRunner = this.getAgent(channel, newSession.baseagent);
|
|
1486
|
-
const newModelTarget = resolveSlashRelationTarget.call(this, {
|
|
1487
|
-
session: newSession,
|
|
1488
|
-
channel,
|
|
1489
|
-
channelId,
|
|
1490
|
-
userId,
|
|
1491
|
-
selfAID,
|
|
1492
|
-
role: newSession.identity?.role || identity.role,
|
|
1493
|
-
chatType,
|
|
1494
|
-
});
|
|
1495
|
-
const newModelSelector = 'error' in newModelTarget
|
|
1496
|
-
? { self: selfAID ?? newSession.selfAID ?? this.resolveSelfAID(channel) }
|
|
1497
|
-
: newModelTarget;
|
|
1498
|
-
let sessionModelConfig = {};
|
|
1499
|
-
try {
|
|
1500
|
-
sessionModelConfig = (resolveEffective(newModelSelector, { cache: true }).baseagents || {})[args] || {};
|
|
1501
|
-
}
|
|
1502
|
-
catch { }
|
|
1503
|
-
const sessionBackendModel = sessionModelConfig.model || newBaseagentRunner?.getModel?.() || owningAgent?.model;
|
|
1504
|
-
const sessionBackendEffort = sessionModelConfig.effort
|
|
1505
|
-
?? newBaseagentRunner?.getEffort?.()
|
|
1506
|
-
?? owningAgent?.effort;
|
|
1507
|
-
const sessionBackendBits = [args, sessionBackendModel, sessionBackendEffort].filter(Boolean).join(' · ');
|
|
1508
1427
|
return {
|
|
1509
|
-
kind: '
|
|
1510
|
-
text: `✓
|
|
1511
|
-
|
|
1428
|
+
kind: 'command.result',
|
|
1429
|
+
text: `✓ 新会话默认 Baseagent: ${previousBaseagent} → ${args}`
|
|
1430
|
+
+ (currentSession ? `\n当前会话继续使用 ${currentSession.baseagent}。` : ''),
|
|
1512
1431
|
};
|
|
1513
1432
|
}
|
|
1514
1433
|
// /model 命令:查看或切换模型/推理强度
|
|
@@ -1548,7 +1467,6 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1548
1467
|
try {
|
|
1549
1468
|
const result = await runModelCheck({
|
|
1550
1469
|
self,
|
|
1551
|
-
peerKey,
|
|
1552
1470
|
role: modelSession?.identity?.role || identity.role,
|
|
1553
1471
|
baseagent: modelAgent.name,
|
|
1554
1472
|
});
|
|
@@ -1569,12 +1487,13 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1569
1487
|
return { kind: 'command.error', text: `模型网关检查失败: ${error instanceof Error ? error.message : String(error)}` };
|
|
1570
1488
|
}
|
|
1571
1489
|
}
|
|
1490
|
+
// 模型参数只在 Agent 级:reset 直接清除 Agent 级配置(鉴权用 agent scope)。
|
|
1572
1491
|
const resetAuthDenied = await authorizeIntent({
|
|
1573
1492
|
intent: {
|
|
1574
1493
|
operation: 'model.reset',
|
|
1575
|
-
scope: '
|
|
1494
|
+
scope: 'agent',
|
|
1576
1495
|
source: 'slash',
|
|
1577
|
-
args:
|
|
1496
|
+
args: { self: selfAID ?? this.resolveSelfAID(channel) },
|
|
1578
1497
|
},
|
|
1579
1498
|
identity,
|
|
1580
1499
|
session: modelSession,
|
|
@@ -1582,27 +1501,16 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1582
1501
|
channel,
|
|
1583
1502
|
channelId,
|
|
1584
1503
|
userId,
|
|
1585
|
-
selfAid:
|
|
1504
|
+
selfAid: selfAID ?? this.resolveSelfAID(channel),
|
|
1586
1505
|
isDaemonOwner,
|
|
1587
1506
|
});
|
|
1588
1507
|
if (resetAuthDenied)
|
|
1589
1508
|
return resetAuthDenied;
|
|
1590
|
-
const target = resolveSlashRelationTarget.call(this, {
|
|
1591
|
-
session: modelSession,
|
|
1592
|
-
channel,
|
|
1593
|
-
channelId,
|
|
1594
|
-
userId,
|
|
1595
|
-
selfAID: self,
|
|
1596
|
-
role: modelSession?.identity?.role || identity.role,
|
|
1597
|
-
chatType: modelChatType,
|
|
1598
|
-
});
|
|
1599
|
-
if ('error' in target)
|
|
1600
|
-
return { kind: 'command.error', text: `Cannot locate relation scope: ${target.error}` };
|
|
1601
1509
|
try {
|
|
1602
|
-
|
|
1510
|
+
writeAgentModelConfig(selfAID ?? modelSession?.selfAID ?? this.resolveSelfAID(channel), modelAgent.name, { model: null, effort: null });
|
|
1603
1511
|
}
|
|
1604
1512
|
catch (error) {
|
|
1605
|
-
return { kind: 'command.error', text: `Failed to reset
|
|
1513
|
+
return { kind: 'command.error', text: `Failed to reset Agent model settings: ${error?.message || error}` };
|
|
1606
1514
|
}
|
|
1607
1515
|
this.eventBus.publish({
|
|
1608
1516
|
type: 'runner:model-changed',
|
|
@@ -1613,8 +1521,8 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1613
1521
|
});
|
|
1614
1522
|
return {
|
|
1615
1523
|
kind: 'command.result',
|
|
1616
|
-
text: '✓
|
|
1617
|
-
structured: { ok: true, scope: '
|
|
1524
|
+
text: '✓ 已清除当前 Agent 的模型和推理强度设置',
|
|
1525
|
+
structured: { ok: true, scope: 'agent', self: selfAID ?? this.resolveSelfAID(channel) },
|
|
1618
1526
|
};
|
|
1619
1527
|
}
|
|
1620
1528
|
if (!args || args === 'list' || args === 'current') {
|
|
@@ -1668,9 +1576,11 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1668
1576
|
const models = hasModelSwitcher(modelAgent)
|
|
1669
1577
|
? filterModelsForRole(identity.role, fallbackBaseagent, rawModels, model => resolveCatalogModel(catalog, model), modelSelector.self)
|
|
1670
1578
|
: rawModels;
|
|
1671
|
-
|
|
1672
|
-
const
|
|
1673
|
-
const
|
|
1579
|
+
// 模型只在 Agent 级:未配置就是没有模型,不显示 runner 内置默认值。
|
|
1580
|
+
const currentModel = configuredModel ?? '';
|
|
1581
|
+
const currentModelLabel = currentModel ? modelDisplayLabel(modelAgent, currentModel) : '未配置(Agent 级未设置模型,无模型可用)';
|
|
1582
|
+
const efforts = currentModel ? await getAvailableEfforts(modelAgent, currentModel) : [];
|
|
1583
|
+
const currentEffort = configuredEffort ?? 'auto';
|
|
1674
1584
|
const canReadModelList = await canReadSlashModelList({
|
|
1675
1585
|
subject: authSubject,
|
|
1676
1586
|
identity,
|
|
@@ -1719,7 +1629,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1719
1629
|
if (args === 'current') {
|
|
1720
1630
|
return {
|
|
1721
1631
|
kind: 'command.result',
|
|
1722
|
-
text: `当前模型: ${
|
|
1632
|
+
text: `当前模型: ${currentModelLabel}${effortHint}`,
|
|
1723
1633
|
structured: { ok: true, model: currentModel, effort: currentEffort, baseagent: fallbackBaseagent },
|
|
1724
1634
|
};
|
|
1725
1635
|
}
|
|
@@ -1727,11 +1637,11 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1727
1637
|
const usage = !groupSlash && !args && isAdmin ? '\n\n用法: /model <模型>' : '';
|
|
1728
1638
|
return {
|
|
1729
1639
|
kind: 'command.result',
|
|
1730
|
-
text: `当前模型: ${
|
|
1640
|
+
text: `当前模型: ${currentModelLabel}${effortHint}${!currentModel || rawModels.includes(currentModel) ? '' : ' [当前配置,未列入目录]'}\n${catalogHint}\n\n可用模型:\n${modelList}${usage}`,
|
|
1731
1641
|
...(args === 'list' ? { structured: { ok: true, model: currentModel, effort: currentEffort, baseagent: fallbackBaseagent, models, revision: catalog.revision, source: catalog.source, freshness: catalog.freshness, diagnostics: catalog.diagnostics } } : {}),
|
|
1732
1642
|
};
|
|
1733
1643
|
}
|
|
1734
|
-
return { kind: 'command.result', text: `当前模型: ${
|
|
1644
|
+
return { kind: 'command.result', text: `当前模型: ${currentModelLabel}${effortHint}` };
|
|
1735
1645
|
}
|
|
1736
1646
|
const modelSession = await getExistingSessionForCommand();
|
|
1737
1647
|
const modelChatType = modelSession?.chatType
|
|
@@ -1744,13 +1654,9 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1744
1654
|
const earlyUseAuthDenied = await authorizeIntent({
|
|
1745
1655
|
intent: {
|
|
1746
1656
|
operation: 'model.use',
|
|
1747
|
-
scope: '
|
|
1657
|
+
scope: 'agent',
|
|
1748
1658
|
source: 'slash',
|
|
1749
|
-
args:
|
|
1750
|
-
args: { model: args.split(/\s+/)[0] },
|
|
1751
|
-
selfAid: selfAID ?? this.resolveSelfAID(channel),
|
|
1752
|
-
peerKey,
|
|
1753
|
-
}),
|
|
1659
|
+
args: { self: selfAID ?? this.resolveSelfAID(channel), model: args.split(/\s+/)[0] },
|
|
1754
1660
|
},
|
|
1755
1661
|
identity,
|
|
1756
1662
|
session: modelSession,
|
|
@@ -1767,21 +1673,10 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1767
1673
|
text: earlyUseAuthDenied.text.includes('无权限') ? earlyUseAuthDenied.text : `❌ 无权限:${earlyUseAuthDenied.text}`,
|
|
1768
1674
|
};
|
|
1769
1675
|
}
|
|
1770
|
-
// 切换模型写入
|
|
1676
|
+
// 切换模型写入 Agent 级 baseagents 配置;没有活跃会话时也不应创建空会话。
|
|
1771
1677
|
const fallbackBaseagent = modelSession?.baseagent || this.agentRegistry?.resolveByChannel(channel)?.baseagent || this.parseDefaultBaseagent();
|
|
1772
1678
|
const modelAgent = this.getAgent(channel, fallbackBaseagent);
|
|
1773
|
-
const
|
|
1774
|
-
session: modelSession,
|
|
1775
|
-
channel,
|
|
1776
|
-
channelId,
|
|
1777
|
-
userId,
|
|
1778
|
-
selfAID,
|
|
1779
|
-
role: modelSession?.identity?.role || identity.role,
|
|
1780
|
-
chatType: modelChatType,
|
|
1781
|
-
});
|
|
1782
|
-
const modelSelector = 'error' in relationTarget
|
|
1783
|
-
? { self: selfAID ?? modelSession?.selfAID ?? this.resolveSelfAID(channel) }
|
|
1784
|
-
: relationTarget;
|
|
1679
|
+
const modelSelector = { self: selfAID ?? modelSession?.selfAID ?? this.resolveSelfAID(channel) };
|
|
1785
1680
|
let configuredModel;
|
|
1786
1681
|
try {
|
|
1787
1682
|
configuredModel = (resolveEffective(modelSelector, { cache: true }).baseagents || {})[fallbackBaseagent]?.model;
|
|
@@ -1796,8 +1691,8 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1796
1691
|
let newEffort;
|
|
1797
1692
|
if (parts.length === 1) {
|
|
1798
1693
|
const arg = parts[0];
|
|
1799
|
-
const currentModel =
|
|
1800
|
-
const efforts = await getAvailableEfforts(modelAgent, currentModel);
|
|
1694
|
+
const currentModel = configuredModel ?? '';
|
|
1695
|
+
const efforts = currentModel ? await getAvailableEfforts(modelAgent, currentModel) : [];
|
|
1801
1696
|
// effort 相关参数统一转发到 /effort
|
|
1802
1697
|
if (efforts.includes(arg) || arg === 'auto') {
|
|
1803
1698
|
const delegated = await this.handle(`/effort ${arg}`, channel, channelId, undefined, userId, threadId);
|
|
@@ -1838,25 +1733,13 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1838
1733
|
newModel = modelArgRaw;
|
|
1839
1734
|
newEffort = effortArg;
|
|
1840
1735
|
}
|
|
1841
|
-
// 优先写关系级覆盖;只有无法定位关系且具备管理权限时才回退到 runner/agent 级。
|
|
1842
1736
|
if (newModel) {
|
|
1843
|
-
const modelChatType = modelSession?.chatType
|
|
1844
|
-
?? (chatType === 'private' || chatType === 'group' ? chatType : undefined);
|
|
1845
|
-
const peerKeyId = modelChatType === 'group'
|
|
1846
|
-
? (modelSession?.metadata?.groupId || channelId)
|
|
1847
|
-
: userId;
|
|
1848
|
-
const channelType = this.resolveChannelType(channel);
|
|
1849
|
-
const peerKey = channelType && peerKeyId ? formatPeerKey(channelType, peerKeyId) : undefined;
|
|
1850
1737
|
const useAuthDenied = await authorizeIntent({
|
|
1851
1738
|
intent: {
|
|
1852
1739
|
operation: 'model.use',
|
|
1853
|
-
scope: '
|
|
1740
|
+
scope: 'agent',
|
|
1854
1741
|
source: 'slash',
|
|
1855
|
-
args:
|
|
1856
|
-
args: { model: newModel },
|
|
1857
|
-
selfAid: selfAID ?? this.resolveSelfAID(channel),
|
|
1858
|
-
peerKey,
|
|
1859
|
-
}),
|
|
1742
|
+
args: { self: modelSelector.self, model: newModel },
|
|
1860
1743
|
},
|
|
1861
1744
|
identity,
|
|
1862
1745
|
session: modelSession,
|
|
@@ -1884,78 +1767,32 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1884
1767
|
// for configuration and replies, just like menu.update and local model use.
|
|
1885
1768
|
}
|
|
1886
1769
|
const changes = [];
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
role: relationTarget.role,
|
|
1893
|
-
}, modelAgent.name, {
|
|
1894
|
-
model: newModel,
|
|
1895
|
-
effort: newEffort,
|
|
1896
|
-
});
|
|
1897
|
-
}
|
|
1898
|
-
catch (e) {
|
|
1899
|
-
return { kind: 'command.error', text: `Failed to update relation model settings: ${e?.message || e}` };
|
|
1900
|
-
}
|
|
1901
|
-
if (newModel)
|
|
1902
|
-
changes.push(`模型: ${newModel}`);
|
|
1903
|
-
if (newEffort)
|
|
1904
|
-
changes.push(`推理强度: ${newEffort}`);
|
|
1905
|
-
this.eventBus.publish({
|
|
1906
|
-
type: 'runner:model-changed',
|
|
1907
|
-
sessionId: modelSession?.id,
|
|
1908
|
-
agentName: this.agentRegistry?.resolveByChannel(channel)?.name,
|
|
1909
|
-
baseagent: modelSession?.baseagent || modelAgent.name,
|
|
1910
|
-
model: newModel,
|
|
1911
|
-
effort: newEffort,
|
|
1912
|
-
timestamp: Date.now()
|
|
1913
|
-
});
|
|
1914
|
-
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
1915
|
-
return null;
|
|
1916
|
-
return { kind: 'command.result', text: `✓ 已切换\n ${changes.join('\n ')}` };
|
|
1770
|
+
const agentSelf = selfAID ?? modelSession?.selfAID ?? this.resolveSelfAID(channel);
|
|
1771
|
+
// 模型参数只在 Agent 级:直接写 Agent config,不再走关系级。
|
|
1772
|
+
// 鉴权已在 earlyUseAuthDenied 完成(agent scope, owner/admin only)。
|
|
1773
|
+
try {
|
|
1774
|
+
writeAgentModelConfig(agentSelf, modelAgent.name, { model: newModel ?? null, effort: newEffort ?? null });
|
|
1917
1775
|
}
|
|
1918
|
-
|
|
1919
|
-
return { kind: 'command.error', text: `
|
|
1776
|
+
catch (e) {
|
|
1777
|
+
return { kind: 'command.error', text: `Failed to update Agent model settings: ${e?.message || e}` };
|
|
1920
1778
|
}
|
|
1921
1779
|
if (newModel) {
|
|
1922
1780
|
modelAgent.setModel?.(newModel);
|
|
1923
|
-
this.eventBus.publish({
|
|
1924
|
-
type: 'runner:model-changed',
|
|
1925
|
-
sessionId: modelSession?.id,
|
|
1926
|
-
agentName: this.agentRegistry?.resolveByChannel(channel)?.name,
|
|
1927
|
-
baseagent: modelSession?.baseagent || modelAgent.name,
|
|
1928
|
-
model: newModel,
|
|
1929
|
-
effort: newEffort,
|
|
1930
|
-
timestamp: Date.now()
|
|
1931
|
-
});
|
|
1932
1781
|
changes.push(`模型: ${newModel}`);
|
|
1933
1782
|
}
|
|
1934
1783
|
if (newEffort) {
|
|
1935
1784
|
modelAgent.setEffort?.(newEffort);
|
|
1936
|
-
if (!newModel) {
|
|
1937
|
-
this.eventBus.publish({
|
|
1938
|
-
type: 'runner:model-changed',
|
|
1939
|
-
sessionId: modelSession?.id,
|
|
1940
|
-
agentName: this.agentRegistry?.resolveByChannel(channel)?.name,
|
|
1941
|
-
baseagent: modelSession?.baseagent || modelAgent.name,
|
|
1942
|
-
effort: newEffort,
|
|
1943
|
-
timestamp: Date.now(),
|
|
1944
|
-
});
|
|
1945
|
-
}
|
|
1946
1785
|
changes.push(`推理强度: ${newEffort}`);
|
|
1947
1786
|
}
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
return { kind: 'command.result', text: `${err}\n已更新运行时配置,但未持久化` };
|
|
1958
|
-
}
|
|
1787
|
+
this.eventBus.publish({
|
|
1788
|
+
type: 'runner:model-changed',
|
|
1789
|
+
sessionId: modelSession?.id,
|
|
1790
|
+
agentName: this.agentRegistry?.resolveByChannel(channel)?.name,
|
|
1791
|
+
baseagent: modelSession?.baseagent || modelAgent.name,
|
|
1792
|
+
model: newModel,
|
|
1793
|
+
effort: newEffort,
|
|
1794
|
+
timestamp: Date.now(),
|
|
1795
|
+
});
|
|
1959
1796
|
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
1960
1797
|
return null;
|
|
1961
1798
|
return { kind: 'command.result', text: `✓ 已切换\n ${changes.join('\n ')}` };
|
|
@@ -1967,18 +1804,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1967
1804
|
const effortSession = await getExistingSessionForCommand();
|
|
1968
1805
|
const fallbackBaseagent = effortSession?.baseagent || this.agentRegistry?.resolveByChannel(channel)?.baseagent || this.parseDefaultBaseagent();
|
|
1969
1806
|
const effortAgent = this.getAgent(channel, fallbackBaseagent);
|
|
1970
|
-
const
|
|
1971
|
-
session: effortSession,
|
|
1972
|
-
channel,
|
|
1973
|
-
channelId,
|
|
1974
|
-
userId,
|
|
1975
|
-
selfAID,
|
|
1976
|
-
role: effortSession?.identity?.role || identity.role,
|
|
1977
|
-
chatType,
|
|
1978
|
-
});
|
|
1979
|
-
const effortSelector = 'error' in effortTarget
|
|
1980
|
-
? { self: selfAID ?? effortSession?.selfAID ?? this.resolveSelfAID(channel) }
|
|
1981
|
-
: effortTarget;
|
|
1807
|
+
const effortSelector = { self: selfAID ?? effortSession?.selfAID ?? this.resolveSelfAID(channel) };
|
|
1982
1808
|
let modelConfig = {};
|
|
1983
1809
|
try {
|
|
1984
1810
|
modelConfig = (resolveEffective(effortSelector, { cache: true }).baseagents || {})[fallbackBaseagent] || {};
|
|
@@ -1986,9 +1812,12 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1986
1812
|
catch { }
|
|
1987
1813
|
const configuredModel = modelConfig.model;
|
|
1988
1814
|
const configuredEffort = modelConfig.effort;
|
|
1989
|
-
|
|
1815
|
+
if (!configuredModel) {
|
|
1816
|
+
return { kind: 'command.error', text: '⚠️ 当前 Agent 未配置模型,请 owner/admin 先用 /model 设置模型' };
|
|
1817
|
+
}
|
|
1818
|
+
const currentModel = configuredModel;
|
|
1990
1819
|
const efforts = await getAvailableEfforts(effortAgent, currentModel);
|
|
1991
|
-
const currentEffort = configuredEffort ??
|
|
1820
|
+
const currentEffort = configuredEffort ?? 'auto';
|
|
1992
1821
|
if (efforts.length === 0) {
|
|
1993
1822
|
return { kind: 'command.error', text: '⚠️ 当前模型不支持推理强度设置' };
|
|
1994
1823
|
}
|
|
@@ -2029,63 +1858,49 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2029
1858
|
const effortSession = await getExistingSessionForCommand();
|
|
2030
1859
|
const fallbackBaseagent = effortSession?.baseagent || this.agentRegistry?.resolveByChannel(channel)?.baseagent || this.parseDefaultBaseagent();
|
|
2031
1860
|
const effortAgent = this.getAgent(channel, fallbackBaseagent);
|
|
2032
|
-
const
|
|
2033
|
-
session: effortSession,
|
|
2034
|
-
channel,
|
|
2035
|
-
channelId,
|
|
2036
|
-
userId,
|
|
2037
|
-
selfAID,
|
|
2038
|
-
role: effortSession?.identity?.role || identity.role,
|
|
2039
|
-
chatType,
|
|
2040
|
-
});
|
|
2041
|
-
const effortSelector = 'error' in relationTarget
|
|
2042
|
-
? { self: selfAID ?? effortSession?.selfAID ?? this.resolveSelfAID(channel) }
|
|
2043
|
-
: relationTarget;
|
|
1861
|
+
const effortSelf = selfAID ?? effortSession?.selfAID ?? this.resolveSelfAID(channel);
|
|
2044
1862
|
let modelConfig = {};
|
|
2045
1863
|
try {
|
|
2046
|
-
modelConfig = (resolveEffective(
|
|
1864
|
+
modelConfig = (resolveEffective({ self: effortSelf }, { cache: true }).baseagents || {})[fallbackBaseagent] || {};
|
|
2047
1865
|
}
|
|
2048
1866
|
catch { }
|
|
2049
1867
|
const configuredModel = modelConfig.model;
|
|
2050
|
-
|
|
2051
|
-
|
|
1868
|
+
if (!configuredModel) {
|
|
1869
|
+
return { kind: 'command.error', text: '⚠️ 当前 Agent 未配置模型,请 owner/admin 先用 /model 设置模型' };
|
|
1870
|
+
}
|
|
1871
|
+
const currentModel = configuredModel;
|
|
2052
1872
|
const efforts = await getAvailableEfforts(effortAgent, currentModel);
|
|
2053
|
-
const currentEffort = configuredEffort ?? effortAgent.getEffort?.() ?? 'auto';
|
|
2054
1873
|
if (efforts.length === 0) {
|
|
2055
1874
|
return { kind: 'command.error', text: '⚠️ 当前模型不支持推理强度设置' };
|
|
2056
1875
|
}
|
|
2057
|
-
//
|
|
2058
|
-
|
|
1876
|
+
// 模型参数只在 Agent 级:写操作按 agent scope 鉴权(owner/admin)。
|
|
1877
|
+
const effortAuthDenied = await authorizeIntent({
|
|
1878
|
+
intent: {
|
|
1879
|
+
operation: 'model.effort',
|
|
1880
|
+
scope: 'agent',
|
|
1881
|
+
source: 'slash',
|
|
1882
|
+
args: { self: effortSelf, effort: args },
|
|
1883
|
+
},
|
|
1884
|
+
identity,
|
|
1885
|
+
session: effortSession,
|
|
1886
|
+
explicitChatType: effortSession?.chatType,
|
|
1887
|
+
channel,
|
|
1888
|
+
channelId,
|
|
1889
|
+
userId,
|
|
1890
|
+
selfAid: effortSelf,
|
|
1891
|
+
isDaemonOwner,
|
|
1892
|
+
});
|
|
1893
|
+
if (effortAuthDenied)
|
|
1894
|
+
return effortAuthDenied;
|
|
1895
|
+
// /effort auto:清除 Agent 级 effort(恢复 SDK 默认)
|
|
2059
1896
|
if (args === 'auto') {
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
role: relationTarget.role,
|
|
2066
|
-
}, effortAgent.name, { effort: null });
|
|
2067
|
-
}
|
|
2068
|
-
catch (e) {
|
|
2069
|
-
return { kind: 'command.error', text: `Failed to update relation effort: ${e?.message || e}` };
|
|
2070
|
-
}
|
|
2071
|
-
this.eventBus.publish({
|
|
2072
|
-
type: 'runner:model-changed',
|
|
2073
|
-
sessionId: effortSession?.id,
|
|
2074
|
-
agentName: this.agentRegistry?.resolveByChannel(channel)?.name,
|
|
2075
|
-
baseagent: effortSession?.baseagent || effortAgent.name,
|
|
2076
|
-
effort: 'auto',
|
|
2077
|
-
timestamp: Date.now(),
|
|
2078
|
-
});
|
|
2079
|
-
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
2080
|
-
return null;
|
|
2081
|
-
return { kind: 'command.result', text: '✓ 推理强度已恢复为 auto (SDK默认)' };
|
|
1897
|
+
try {
|
|
1898
|
+
writeAgentModelConfig(effortSelf, effortAgent.name, { effort: null });
|
|
1899
|
+
}
|
|
1900
|
+
catch (e) {
|
|
1901
|
+
return { kind: 'command.error', text: `Failed to clear Agent effort: ${e?.message || e}` };
|
|
2082
1902
|
}
|
|
2083
|
-
if (!isAdmin)
|
|
2084
|
-
return { kind: 'command.error', text: `Cannot locate relation scope: ${relationTarget.error}` };
|
|
2085
1903
|
effortAgent.setEffort?.(undefined);
|
|
2086
|
-
const err = this.persistBaseagentEffort(channel, effortAgent.name, undefined);
|
|
2087
|
-
if (err)
|
|
2088
|
-
return { kind: 'command.result', text: `${err}\n已更新运行时配置,但未持久化` };
|
|
2089
1904
|
this.eventBus.publish({
|
|
2090
1905
|
type: 'runner:model-changed',
|
|
2091
1906
|
sessionId: effortSession?.id,
|
|
@@ -2106,35 +1921,13 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2106
1921
|
return { kind: 'command.error', text: `❌ 无效参数: ${args}\n可选: ${efforts.join(' / ')} / auto` };
|
|
2107
1922
|
}
|
|
2108
1923
|
const newEffort = args;
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
role: relationTarget.role,
|
|
2115
|
-
}, effortAgent.name, { effort: newEffort });
|
|
2116
|
-
}
|
|
2117
|
-
catch (e) {
|
|
2118
|
-
return { kind: 'command.error', text: `Failed to update relation effort: ${e?.message || e}` };
|
|
2119
|
-
}
|
|
2120
|
-
this.eventBus.publish({
|
|
2121
|
-
type: 'runner:model-changed',
|
|
2122
|
-
sessionId: effortSession?.id,
|
|
2123
|
-
agentName: this.agentRegistry?.resolveByChannel(channel)?.name,
|
|
2124
|
-
baseagent: effortSession?.baseagent || effortAgent.name,
|
|
2125
|
-
effort: newEffort,
|
|
2126
|
-
timestamp: Date.now(),
|
|
2127
|
-
});
|
|
2128
|
-
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
2129
|
-
return null;
|
|
2130
|
-
return { kind: 'command.result', text: `✓ 推理强度: ${newEffort}` };
|
|
1924
|
+
try {
|
|
1925
|
+
writeAgentModelConfig(effortSelf, effortAgent.name, { effort: newEffort });
|
|
1926
|
+
}
|
|
1927
|
+
catch (e) {
|
|
1928
|
+
return { kind: 'command.error', text: `Failed to update Agent effort: ${e?.message || e}` };
|
|
2131
1929
|
}
|
|
2132
|
-
if (!isAdmin)
|
|
2133
|
-
return { kind: 'command.error', text: `Cannot locate relation scope: ${relationTarget.error}` };
|
|
2134
1930
|
effortAgent.setEffort?.(newEffort);
|
|
2135
|
-
const err = this.persistBaseagentEffort(channel, effortAgent.name, newEffort);
|
|
2136
|
-
if (err)
|
|
2137
|
-
return { kind: 'command.result', text: `${err}\n已更新运行时配置,但未持久化` };
|
|
2138
1931
|
this.eventBus.publish({
|
|
2139
1932
|
type: 'runner:model-changed',
|
|
2140
1933
|
sessionId: effortSession?.id,
|
|
@@ -2719,6 +2512,9 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2719
2512
|
catch {
|
|
2720
2513
|
compactConfig = {};
|
|
2721
2514
|
}
|
|
2515
|
+
if (typeof compactConfig.model !== 'string' || !compactConfig.model.trim()) {
|
|
2516
|
+
return { kind: 'command.error', text: `⚠️ 当前 Agent 未配置模型(baseagents.${compactBaseagent}.model),无法压缩。请 owner/admin 先用 /model 设置模型。` };
|
|
2517
|
+
}
|
|
2722
2518
|
const compactModelDecision = constrainResolvedModelForRole({
|
|
2723
2519
|
role: session.identity?.role || identity.role,
|
|
2724
2520
|
baseagent: compactBaseagent,
|
|
@@ -2854,13 +2650,32 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2854
2650
|
: mentionModeTarget.scope === 'relation' ? '本群' : 'Agent 全局';
|
|
2855
2651
|
const chatModeLine = `会话模式: ${chatMode}`;
|
|
2856
2652
|
const mentionModeLine = `@ 处理模式(${mentionScopeLabel}): ${mentionMode}`;
|
|
2653
|
+
const statusControlLines = [];
|
|
2654
|
+
const fullAccessPrincipalId = authSubject.principalId;
|
|
2655
|
+
if (session.chatType === 'private'
|
|
2656
|
+
&& authSubject.isDaemonOwner
|
|
2657
|
+
&& fullAccessPrincipalId
|
|
2658
|
+
&& session.selfAID
|
|
2659
|
+
&& isAgentFullAccessOwner(session.selfAID, fullAccessPrincipalId)
|
|
2660
|
+
&& sessionFullAccessStatus(session, fullAccessPrincipalId).effective) {
|
|
2661
|
+
statusControlLines.push('fullaccess: 开启');
|
|
2662
|
+
}
|
|
2663
|
+
if (canAccessSlashOperation('session.loop.current', 'relation')) {
|
|
2664
|
+
const loopTarget = resolveSessionLoopTarget(session);
|
|
2665
|
+
if (loopTarget) {
|
|
2666
|
+
const loopStatus = sessionLoopPayload(loopTarget);
|
|
2667
|
+
if (loopStatus.value === true && typeof loopStatus.idleSeconds === 'number') {
|
|
2668
|
+
statusControlLines.push(`loop 周期: ${loopStatus.idleSeconds} 秒`);
|
|
2669
|
+
}
|
|
2670
|
+
}
|
|
2671
|
+
}
|
|
2857
2672
|
if (isAdmin) {
|
|
2858
2673
|
const gitInfo = await getGitWorkingDirInfo(session.projectPath);
|
|
2859
2674
|
lines.push(`📊 ${isThread ? '话题' : '会话'}状态 (Agent: ${agentName}):`, `渠道: ${this.resolveChannelType(channel)} / 项目: ${projectName} / 会话: ${displaySessionTitle(session.name, '(未命名)')}`, `会话ID: ${session.id}`, `项目路径: ${session.projectPath}`);
|
|
2860
2675
|
if (gitInfo) {
|
|
2861
2676
|
lines.push(`Git: ${gitInfo}`);
|
|
2862
2677
|
}
|
|
2863
|
-
lines.push(`会话状态: ${sessionStatus} / 轮数: ${sessionTurns} / 已记录子任务数: ${sessionSubtasks}`, sessionRoleLine, chatModeLine, mentionModeLine);
|
|
2678
|
+
lines.push(`会话状态: ${sessionStatus} / 轮数: ${sessionTurns} / 已记录子任务数: ${sessionSubtasks}`, sessionRoleLine, chatModeLine, mentionModeLine, ...statusControlLines);
|
|
2864
2679
|
if (health.consecutiveErrors > 0) {
|
|
2865
2680
|
lines.push(`异常计数: ${health.consecutiveErrors}`);
|
|
2866
2681
|
}
|
|
@@ -2868,7 +2683,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2868
2683
|
}
|
|
2869
2684
|
else {
|
|
2870
2685
|
lines.push(`📊 ${isThread ? '话题' : '会话'}状态 (Agent: ${agentName}):`, `渠道: ${channel} / 项目: ${projectName} / ${session.baseagent}会话`);
|
|
2871
|
-
lines.push(`状态: ${sessionStatus} / 轮数: ${sessionTurns} / 已记录子任务数: ${sessionSubtasks}`, sessionRoleLine, chatModeLine, mentionModeLine, `最后活跃: ${timeStr}`);
|
|
2686
|
+
lines.push(`状态: ${sessionStatus} / 轮数: ${sessionTurns} / 已记录子任务数: ${sessionSubtasks}`, sessionRoleLine, chatModeLine, mentionModeLine, ...statusControlLines, `最后活跃: ${timeStr}`);
|
|
2872
2687
|
}
|
|
2873
2688
|
if (health.lastError) {
|
|
2874
2689
|
lines.push('');
|
|
@@ -3238,12 +3053,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3238
3053
|
}
|
|
3239
3054
|
// Archiving only changes list visibility; pending work must still be checked.
|
|
3240
3055
|
const allSessions = await this.sessionManager.listSessions(channel, channelId, { archiveFilter: 'all' });
|
|
3241
|
-
const
|
|
3242
|
-
.filter((s) => this.messageCache.hasMessages(s.id))
|
|
3243
|
-
.map((s) => {
|
|
3244
|
-
const count = this.messageCache.getCount(s.id);
|
|
3245
|
-
return `${s.projectPath} 有 ${count} 条新消息`;
|
|
3246
|
-
});
|
|
3056
|
+
const pendingResultCount = allSessions.reduce((count, session) => count + this.messageCache.getCount(session.id), 0);
|
|
3247
3057
|
const executeRestart = async () => {
|
|
3248
3058
|
const suppressRealRestart = shouldSuppressRealRestart();
|
|
3249
3059
|
let restartReplyContext = replyContext;
|
|
@@ -3411,26 +3221,20 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3411
3221
|
return true;
|
|
3412
3222
|
};
|
|
3413
3223
|
// 文本确认流程
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3224
|
+
const restartKey = `${channel}-${channelId}`;
|
|
3225
|
+
const controlDir = daemonControlDir();
|
|
3226
|
+
const restartConfirmFile = path.join(controlDir, `restart-confirm-${restartKey}.json`);
|
|
3227
|
+
if (fs.existsSync(restartConfirmFile)) {
|
|
3228
|
+
// 确认不设有效期;即使后台结果已读,下一次 /restart 也会消费确认。
|
|
3229
|
+
fs.unlinkSync(restartConfirmFile);
|
|
3230
|
+
}
|
|
3231
|
+
else if (pendingResultCount > 0) {
|
|
3417
3232
|
fs.mkdirSync(controlDir, { recursive: true });
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
fs.unlinkSync(restartConfirmFile);
|
|
3424
|
-
}
|
|
3425
|
-
else {
|
|
3426
|
-
fs.writeFileSync(restartConfirmFile, JSON.stringify({ timestamp: now }));
|
|
3427
|
-
return { kind: 'command.result', text: sessionsWithMessages.join('\n') + '\n再次输入 /restart 将强制重启。' };
|
|
3428
|
-
}
|
|
3429
|
-
}
|
|
3430
|
-
else {
|
|
3431
|
-
fs.writeFileSync(restartConfirmFile, JSON.stringify({ timestamp: Date.now() }));
|
|
3432
|
-
return { kind: 'command.result', text: sessionsWithMessages.join('\n') + '\n再次输入 /restart 将强制重启。' };
|
|
3433
|
-
}
|
|
3233
|
+
fs.writeFileSync(restartConfirmFile, JSON.stringify({ timestamp: Date.now() }));
|
|
3234
|
+
return {
|
|
3235
|
+
kind: 'command.result',
|
|
3236
|
+
text: `当前Agent对话有 ${pendingResultCount} 条后台结果待查看。再次输入 /restart 将强制重启服务。`,
|
|
3237
|
+
};
|
|
3434
3238
|
}
|
|
3435
3239
|
const restarted = await executeRestart();
|
|
3436
3240
|
if (typeof restarted === 'object' && restarted.code === 'RESTART_ENTRY_MISSING') {
|
|
@@ -4213,6 +4017,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
4213
4017
|
isAdmin,
|
|
4214
4018
|
isOwnerSelf: isOwner && !!memoryOwnerAid && (authSubject.principalId ?? userId) === memoryOwnerAid,
|
|
4215
4019
|
ownerAid: memoryOwnerAid,
|
|
4020
|
+
actorAid: authSubject.principalId ?? userId,
|
|
4216
4021
|
memoryConfig: memoryAgent?.config?.memory,
|
|
4217
4022
|
channelType: authSubject.channelType,
|
|
4218
4023
|
peerId: activeChatType === 'group' ? channelId : (userId ?? channelId),
|