evolcore 0.0.41-test.0 → 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 +49 -0
- package/dist/agents/baseagent-availability.js +1 -1
- package/dist/agents/baseagent.js +20 -43
- package/dist/agents/claude-runner.js +177 -92
- package/dist/agents/codex-runner.js +84 -28
- package/dist/agents/ecagent-runner.js +1 -1
- package/dist/agents/gemini-runner.js +1 -1
- package/dist/aun/group/fs-download.js +39 -0
- package/dist/aun/group/identity.js +36 -21
- package/dist/aun/group/operations.js +5 -0
- package/dist/aun/msg/managed-operation.js +68 -7
- package/dist/aun/msg/p2p.js +5 -0
- package/dist/aun/service-proxy.js +36 -12
- package/dist/channels/aun.js +334 -20
- package/dist/channels/daemon.js +15 -1
- package/dist/cli/aun-commands.js +4 -20
- package/dist/cli/daemon-commands.js +678 -697
- 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/role.js +85 -0
- package/dist/config/access-policy.js +7 -2
- 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 +5 -19
- 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 +88 -594
- package/dist/config/peer-role-resolver.js +13 -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-runtime.js +1 -1
- package/dist/core/auth/agent-delegation.js +2 -1
- package/dist/core/auth/auth-gateway.js +1 -1
- package/dist/core/auth/authorization-audit.js +17 -6
- 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 +31 -6
- package/dist/core/command/agent-control.js +3 -7
- 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 +48 -99
- package/dist/core/command/connect-menu.js +11 -3
- 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 +5 -6
- package/dist/core/command/menu-handler.js +49 -62
- package/dist/core/command/role-menu.js +147 -30
- package/dist/core/command/slash-handler.js +123 -254
- package/dist/core/daemon-control.js +8 -14
- 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 +6 -2
- 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 +189 -189
- 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 +8 -2
- package/dist/core/message/im-renderer.js +7 -4
- package/dist/core/message/message-admission.js +89 -4
- package/dist/core/message/message-bridge.js +31 -18
- package/dist/core/message/response-engine.js +77 -8
- 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 +30 -41
- 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 +23 -21
- package/dist/core/permission/ec-command-parser.js +30 -2
- package/dist/core/permission/sandbox-runtime.js +18 -1
- package/dist/core/permission/tool-policy.js +14 -3
- 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 +1 -1
- package/dist/core/session/session-idle-monitor.js +1 -1
- package/dist/core/session/session-manager.js +20 -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 +76 -14
- package/dist/ipc.js +170 -12
- 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/utils/cross-platform.js +14 -0
- package/dist/utils/ecweb-supervisor.js +258 -83
- package/dist/utils/error-utils.js +2 -2
- package/dist/utils/logger.js +24 -5
- package/dist/utils/package-version-info.js +4 -2
- package/kits/docs/channels/aun.md +9 -0
- package/kits/docs/evolcore/agent.md +1 -1
- package/kits/docs/evolcore/config.md +17 -6
- package/kits/docs/evolcore/contact.md +3 -0
- package/kits/docs/evolcore/fs.md +11 -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 +4 -0
- package/kits/docs/evolcore/model.md +23 -20
- package/kits/docs/evolcore/msg.md +4 -7
- 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 +8 -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/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/system-fragments/baseagent.md +2 -2
- package/kits/templates/system-fragments/memory.md +4 -4
- package/package.json +6 -2
|
@@ -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';
|
|
@@ -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 },
|
|
@@ -643,21 +643,26 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
643
643
|
if (!commandSession || !agentAid) {
|
|
644
644
|
return { kind: 'command.error', text: '❌ 当前没有可绑定的 EC 会话' };
|
|
645
645
|
}
|
|
646
|
-
if (this.messageQueue.isProcessing(commandSession.id) || this.messageQueue.getQueueLength(commandSession.id) > 0) {
|
|
647
|
-
return { kind: 'command.error', text: '❌ 当前会话有任务执行中,结束后再修改 fullaccess' };
|
|
648
|
-
}
|
|
649
646
|
if (!principalId || !authSubject.isDaemonOwner || !isAgentFullAccessOwner(agentAid, principalId)) {
|
|
650
647
|
return { kind: 'command.error', text: '❌ /fa 需要同一身份同时具备 Agent Owner 和 daemon Owner 权限' };
|
|
651
648
|
}
|
|
649
|
+
const status = sessionFullAccessStatus(commandSession, principalId);
|
|
652
650
|
if (fullAccessControl.action === 'status') {
|
|
653
|
-
const
|
|
654
|
-
const scope = isTopicSession(commandSession) ? 'session' : 'agent';
|
|
651
|
+
const scope = isTopicSession(commandSession) ? 'session' : 'relation';
|
|
655
652
|
return {
|
|
656
653
|
kind: 'command.result',
|
|
657
654
|
text: '当前 fullaccess(' + scope + ',session=' + commandSession.id + '):'
|
|
658
|
-
+ (status.effective ? '开启' : '关闭')
|
|
655
|
+
+ (status.effective ? '开启' : '关闭')
|
|
656
|
+
+ '\nAgent 全局:' + (status.globalEnabled ? '开启(局部开关不生效)' : '关闭')
|
|
657
|
+
+ '\n局部开关:' + (status.localEnabled ? '开启' : '关闭'),
|
|
659
658
|
};
|
|
660
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
|
+
}
|
|
661
666
|
const enabled = fullAccessControl.action === 'on';
|
|
662
667
|
try {
|
|
663
668
|
if (isTopicSession(commandSession)) {
|
|
@@ -672,11 +677,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
672
677
|
if (!latest || latest.id !== commandSession.id || !isMainSession(latest)) {
|
|
673
678
|
return { kind: 'command.error', text: '❌ 当前主会话已发生变化,请重新执行 /fa' };
|
|
674
679
|
}
|
|
675
|
-
|
|
676
|
-
if (!config)
|
|
677
|
-
return { kind: 'command.error', text: '❌ 找不到当前 Agent 配置' };
|
|
678
|
-
config.fullaccess = { enabled };
|
|
679
|
-
cfgWrite(ConfigTarget.Agent, config, { self: agentAid });
|
|
680
|
+
updateRelationSessionFullAccess(latest, { enabled, authorizedBy: principalId });
|
|
680
681
|
}
|
|
681
682
|
auditFullAccessEvent({
|
|
682
683
|
event: enabled ? 'fullaccess.session-policy.configured' : 'fullaccess.session-policy.deescalated',
|
|
@@ -686,11 +687,12 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
686
687
|
agentAid,
|
|
687
688
|
sessionId: commandSession.id,
|
|
688
689
|
authorizedBy: principalId,
|
|
689
|
-
reason: isTopicSession(commandSession) ? 'topic session fullaccess updated' : '
|
|
690
|
+
reason: isTopicSession(commandSession) ? 'topic session fullaccess updated' : 'relation main-session fullaccess updated',
|
|
690
691
|
});
|
|
691
692
|
return {
|
|
692
693
|
kind: 'command.result',
|
|
693
|
-
text: '✅ 当前
|
|
694
|
+
text: '✅ 当前' + (isTopicSession(commandSession) ? '话题 EC 会话' : '主会话')
|
|
695
|
+
+ ' fullaccess 已' + (enabled ? '开启' : '关闭'),
|
|
694
696
|
};
|
|
695
697
|
}
|
|
696
698
|
catch (error) {
|
|
@@ -839,8 +841,8 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
839
841
|
}
|
|
840
842
|
const canReadModel = canAccessSlashOperation('model.current', 'relation')
|
|
841
843
|
|| canAccessSlashOperation('model.list', 'relation');
|
|
842
|
-
const canUseModel = canAccessSlashOperation('model.use', '
|
|
843
|
-
const canSetEffort = canAccessSlashOperation('model.effort', '
|
|
844
|
+
const canUseModel = canAccessSlashOperation('model.use', 'agent');
|
|
845
|
+
const canSetEffort = canAccessSlashOperation('model.effort', 'agent');
|
|
844
846
|
const canReadPermission = canAccessSlashOperation('permission.current', 'relation');
|
|
845
847
|
const canAnswerPermission = canAccessSlashOperation('permission.answer', 'relation');
|
|
846
848
|
const canReadChatmode = canAccessSlashOperation('chatmode.current', 'relation');
|
|
@@ -1076,8 +1078,8 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1076
1078
|
const cmds = [...loopHelp];
|
|
1077
1079
|
const canReadModel = canAccessSlashOperation('model.current', 'relation')
|
|
1078
1080
|
|| canAccessSlashOperation('model.list', 'relation');
|
|
1079
|
-
const canUseModel = canAccessSlashOperation('model.use', '
|
|
1080
|
-
const canSetEffort = canAccessSlashOperation('model.effort', '
|
|
1081
|
+
const canUseModel = canAccessSlashOperation('model.use', 'agent');
|
|
1082
|
+
const canSetEffort = canAccessSlashOperation('model.effort', 'agent');
|
|
1081
1083
|
const canReadPermission = canAccessSlashOperation('permission.current', 'relation');
|
|
1082
1084
|
const canAnswerPermission = canAccessSlashOperation('permission.answer', 'relation');
|
|
1083
1085
|
const canReadChatmode = canAccessSlashOperation('chatmode.current', 'relation');
|
|
@@ -1465,7 +1467,6 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1465
1467
|
try {
|
|
1466
1468
|
const result = await runModelCheck({
|
|
1467
1469
|
self,
|
|
1468
|
-
peerKey,
|
|
1469
1470
|
role: modelSession?.identity?.role || identity.role,
|
|
1470
1471
|
baseagent: modelAgent.name,
|
|
1471
1472
|
});
|
|
@@ -1486,12 +1487,13 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1486
1487
|
return { kind: 'command.error', text: `模型网关检查失败: ${error instanceof Error ? error.message : String(error)}` };
|
|
1487
1488
|
}
|
|
1488
1489
|
}
|
|
1490
|
+
// 模型参数只在 Agent 级:reset 直接清除 Agent 级配置(鉴权用 agent scope)。
|
|
1489
1491
|
const resetAuthDenied = await authorizeIntent({
|
|
1490
1492
|
intent: {
|
|
1491
1493
|
operation: 'model.reset',
|
|
1492
|
-
scope: '
|
|
1494
|
+
scope: 'agent',
|
|
1493
1495
|
source: 'slash',
|
|
1494
|
-
args:
|
|
1496
|
+
args: { self: selfAID ?? this.resolveSelfAID(channel) },
|
|
1495
1497
|
},
|
|
1496
1498
|
identity,
|
|
1497
1499
|
session: modelSession,
|
|
@@ -1499,27 +1501,16 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1499
1501
|
channel,
|
|
1500
1502
|
channelId,
|
|
1501
1503
|
userId,
|
|
1502
|
-
selfAid:
|
|
1504
|
+
selfAid: selfAID ?? this.resolveSelfAID(channel),
|
|
1503
1505
|
isDaemonOwner,
|
|
1504
1506
|
});
|
|
1505
1507
|
if (resetAuthDenied)
|
|
1506
1508
|
return resetAuthDenied;
|
|
1507
|
-
const target = resolveSlashRelationTarget.call(this, {
|
|
1508
|
-
session: modelSession,
|
|
1509
|
-
channel,
|
|
1510
|
-
channelId,
|
|
1511
|
-
userId,
|
|
1512
|
-
selfAID: self,
|
|
1513
|
-
role: modelSession?.identity?.role || identity.role,
|
|
1514
|
-
chatType: modelChatType,
|
|
1515
|
-
});
|
|
1516
|
-
if ('error' in target)
|
|
1517
|
-
return { kind: 'command.error', text: `Cannot locate relation scope: ${target.error}` };
|
|
1518
1509
|
try {
|
|
1519
|
-
|
|
1510
|
+
writeAgentModelConfig(selfAID ?? modelSession?.selfAID ?? this.resolveSelfAID(channel), modelAgent.name, { model: null, effort: null });
|
|
1520
1511
|
}
|
|
1521
1512
|
catch (error) {
|
|
1522
|
-
return { kind: 'command.error', text: `Failed to reset
|
|
1513
|
+
return { kind: 'command.error', text: `Failed to reset Agent model settings: ${error?.message || error}` };
|
|
1523
1514
|
}
|
|
1524
1515
|
this.eventBus.publish({
|
|
1525
1516
|
type: 'runner:model-changed',
|
|
@@ -1530,8 +1521,8 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1530
1521
|
});
|
|
1531
1522
|
return {
|
|
1532
1523
|
kind: 'command.result',
|
|
1533
|
-
text: '✓
|
|
1534
|
-
structured: { ok: true, scope: '
|
|
1524
|
+
text: '✓ 已清除当前 Agent 的模型和推理强度设置',
|
|
1525
|
+
structured: { ok: true, scope: 'agent', self: selfAID ?? this.resolveSelfAID(channel) },
|
|
1535
1526
|
};
|
|
1536
1527
|
}
|
|
1537
1528
|
if (!args || args === 'list' || args === 'current') {
|
|
@@ -1585,9 +1576,11 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1585
1576
|
const models = hasModelSwitcher(modelAgent)
|
|
1586
1577
|
? filterModelsForRole(identity.role, fallbackBaseagent, rawModels, model => resolveCatalogModel(catalog, model), modelSelector.self)
|
|
1587
1578
|
: rawModels;
|
|
1588
|
-
|
|
1589
|
-
const
|
|
1590
|
-
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';
|
|
1591
1584
|
const canReadModelList = await canReadSlashModelList({
|
|
1592
1585
|
subject: authSubject,
|
|
1593
1586
|
identity,
|
|
@@ -1636,7 +1629,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1636
1629
|
if (args === 'current') {
|
|
1637
1630
|
return {
|
|
1638
1631
|
kind: 'command.result',
|
|
1639
|
-
text: `当前模型: ${
|
|
1632
|
+
text: `当前模型: ${currentModelLabel}${effortHint}`,
|
|
1640
1633
|
structured: { ok: true, model: currentModel, effort: currentEffort, baseagent: fallbackBaseagent },
|
|
1641
1634
|
};
|
|
1642
1635
|
}
|
|
@@ -1644,11 +1637,11 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1644
1637
|
const usage = !groupSlash && !args && isAdmin ? '\n\n用法: /model <模型>' : '';
|
|
1645
1638
|
return {
|
|
1646
1639
|
kind: 'command.result',
|
|
1647
|
-
text: `当前模型: ${
|
|
1640
|
+
text: `当前模型: ${currentModelLabel}${effortHint}${!currentModel || rawModels.includes(currentModel) ? '' : ' [当前配置,未列入目录]'}\n${catalogHint}\n\n可用模型:\n${modelList}${usage}`,
|
|
1648
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 } } : {}),
|
|
1649
1642
|
};
|
|
1650
1643
|
}
|
|
1651
|
-
return { kind: 'command.result', text: `当前模型: ${
|
|
1644
|
+
return { kind: 'command.result', text: `当前模型: ${currentModelLabel}${effortHint}` };
|
|
1652
1645
|
}
|
|
1653
1646
|
const modelSession = await getExistingSessionForCommand();
|
|
1654
1647
|
const modelChatType = modelSession?.chatType
|
|
@@ -1661,13 +1654,9 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1661
1654
|
const earlyUseAuthDenied = await authorizeIntent({
|
|
1662
1655
|
intent: {
|
|
1663
1656
|
operation: 'model.use',
|
|
1664
|
-
scope: '
|
|
1657
|
+
scope: 'agent',
|
|
1665
1658
|
source: 'slash',
|
|
1666
|
-
args:
|
|
1667
|
-
args: { model: args.split(/\s+/)[0] },
|
|
1668
|
-
selfAid: selfAID ?? this.resolveSelfAID(channel),
|
|
1669
|
-
peerKey,
|
|
1670
|
-
}),
|
|
1659
|
+
args: { self: selfAID ?? this.resolveSelfAID(channel), model: args.split(/\s+/)[0] },
|
|
1671
1660
|
},
|
|
1672
1661
|
identity,
|
|
1673
1662
|
session: modelSession,
|
|
@@ -1684,21 +1673,10 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1684
1673
|
text: earlyUseAuthDenied.text.includes('无权限') ? earlyUseAuthDenied.text : `❌ 无权限:${earlyUseAuthDenied.text}`,
|
|
1685
1674
|
};
|
|
1686
1675
|
}
|
|
1687
|
-
// 切换模型写入
|
|
1676
|
+
// 切换模型写入 Agent 级 baseagents 配置;没有活跃会话时也不应创建空会话。
|
|
1688
1677
|
const fallbackBaseagent = modelSession?.baseagent || this.agentRegistry?.resolveByChannel(channel)?.baseagent || this.parseDefaultBaseagent();
|
|
1689
1678
|
const modelAgent = this.getAgent(channel, fallbackBaseagent);
|
|
1690
|
-
const
|
|
1691
|
-
session: modelSession,
|
|
1692
|
-
channel,
|
|
1693
|
-
channelId,
|
|
1694
|
-
userId,
|
|
1695
|
-
selfAID,
|
|
1696
|
-
role: modelSession?.identity?.role || identity.role,
|
|
1697
|
-
chatType: modelChatType,
|
|
1698
|
-
});
|
|
1699
|
-
const modelSelector = 'error' in relationTarget
|
|
1700
|
-
? { self: selfAID ?? modelSession?.selfAID ?? this.resolveSelfAID(channel) }
|
|
1701
|
-
: relationTarget;
|
|
1679
|
+
const modelSelector = { self: selfAID ?? modelSession?.selfAID ?? this.resolveSelfAID(channel) };
|
|
1702
1680
|
let configuredModel;
|
|
1703
1681
|
try {
|
|
1704
1682
|
configuredModel = (resolveEffective(modelSelector, { cache: true }).baseagents || {})[fallbackBaseagent]?.model;
|
|
@@ -1713,8 +1691,8 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1713
1691
|
let newEffort;
|
|
1714
1692
|
if (parts.length === 1) {
|
|
1715
1693
|
const arg = parts[0];
|
|
1716
|
-
const currentModel =
|
|
1717
|
-
const efforts = await getAvailableEfforts(modelAgent, currentModel);
|
|
1694
|
+
const currentModel = configuredModel ?? '';
|
|
1695
|
+
const efforts = currentModel ? await getAvailableEfforts(modelAgent, currentModel) : [];
|
|
1718
1696
|
// effort 相关参数统一转发到 /effort
|
|
1719
1697
|
if (efforts.includes(arg) || arg === 'auto') {
|
|
1720
1698
|
const delegated = await this.handle(`/effort ${arg}`, channel, channelId, undefined, userId, threadId);
|
|
@@ -1755,25 +1733,13 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1755
1733
|
newModel = modelArgRaw;
|
|
1756
1734
|
newEffort = effortArg;
|
|
1757
1735
|
}
|
|
1758
|
-
// 优先写关系级覆盖;只有无法定位关系且具备管理权限时才回退到 runner/agent 级。
|
|
1759
1736
|
if (newModel) {
|
|
1760
|
-
const modelChatType = modelSession?.chatType
|
|
1761
|
-
?? (chatType === 'private' || chatType === 'group' ? chatType : undefined);
|
|
1762
|
-
const peerKeyId = modelChatType === 'group'
|
|
1763
|
-
? (modelSession?.metadata?.groupId || channelId)
|
|
1764
|
-
: userId;
|
|
1765
|
-
const channelType = this.resolveChannelType(channel);
|
|
1766
|
-
const peerKey = channelType && peerKeyId ? formatPeerKey(channelType, peerKeyId) : undefined;
|
|
1767
1737
|
const useAuthDenied = await authorizeIntent({
|
|
1768
1738
|
intent: {
|
|
1769
1739
|
operation: 'model.use',
|
|
1770
|
-
scope: '
|
|
1740
|
+
scope: 'agent',
|
|
1771
1741
|
source: 'slash',
|
|
1772
|
-
args:
|
|
1773
|
-
args: { model: newModel },
|
|
1774
|
-
selfAid: selfAID ?? this.resolveSelfAID(channel),
|
|
1775
|
-
peerKey,
|
|
1776
|
-
}),
|
|
1742
|
+
args: { self: modelSelector.self, model: newModel },
|
|
1777
1743
|
},
|
|
1778
1744
|
identity,
|
|
1779
1745
|
session: modelSession,
|
|
@@ -1801,78 +1767,32 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1801
1767
|
// for configuration and replies, just like menu.update and local model use.
|
|
1802
1768
|
}
|
|
1803
1769
|
const changes = [];
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
role: relationTarget.role,
|
|
1810
|
-
}, modelAgent.name, {
|
|
1811
|
-
model: newModel,
|
|
1812
|
-
effort: newEffort,
|
|
1813
|
-
});
|
|
1814
|
-
}
|
|
1815
|
-
catch (e) {
|
|
1816
|
-
return { kind: 'command.error', text: `Failed to update relation model settings: ${e?.message || e}` };
|
|
1817
|
-
}
|
|
1818
|
-
if (newModel)
|
|
1819
|
-
changes.push(`模型: ${newModel}`);
|
|
1820
|
-
if (newEffort)
|
|
1821
|
-
changes.push(`推理强度: ${newEffort}`);
|
|
1822
|
-
this.eventBus.publish({
|
|
1823
|
-
type: 'runner:model-changed',
|
|
1824
|
-
sessionId: modelSession?.id,
|
|
1825
|
-
agentName: this.agentRegistry?.resolveByChannel(channel)?.name,
|
|
1826
|
-
baseagent: modelSession?.baseagent || modelAgent.name,
|
|
1827
|
-
model: newModel,
|
|
1828
|
-
effort: newEffort,
|
|
1829
|
-
timestamp: Date.now()
|
|
1830
|
-
});
|
|
1831
|
-
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
1832
|
-
return null;
|
|
1833
|
-
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 });
|
|
1834
1775
|
}
|
|
1835
|
-
|
|
1836
|
-
return { kind: 'command.error', text: `
|
|
1776
|
+
catch (e) {
|
|
1777
|
+
return { kind: 'command.error', text: `Failed to update Agent model settings: ${e?.message || e}` };
|
|
1837
1778
|
}
|
|
1838
1779
|
if (newModel) {
|
|
1839
1780
|
modelAgent.setModel?.(newModel);
|
|
1840
|
-
this.eventBus.publish({
|
|
1841
|
-
type: 'runner:model-changed',
|
|
1842
|
-
sessionId: modelSession?.id,
|
|
1843
|
-
agentName: this.agentRegistry?.resolveByChannel(channel)?.name,
|
|
1844
|
-
baseagent: modelSession?.baseagent || modelAgent.name,
|
|
1845
|
-
model: newModel,
|
|
1846
|
-
effort: newEffort,
|
|
1847
|
-
timestamp: Date.now()
|
|
1848
|
-
});
|
|
1849
1781
|
changes.push(`模型: ${newModel}`);
|
|
1850
1782
|
}
|
|
1851
1783
|
if (newEffort) {
|
|
1852
1784
|
modelAgent.setEffort?.(newEffort);
|
|
1853
|
-
if (!newModel) {
|
|
1854
|
-
this.eventBus.publish({
|
|
1855
|
-
type: 'runner:model-changed',
|
|
1856
|
-
sessionId: modelSession?.id,
|
|
1857
|
-
agentName: this.agentRegistry?.resolveByChannel(channel)?.name,
|
|
1858
|
-
baseagent: modelSession?.baseagent || modelAgent.name,
|
|
1859
|
-
effort: newEffort,
|
|
1860
|
-
timestamp: Date.now(),
|
|
1861
|
-
});
|
|
1862
|
-
}
|
|
1863
1785
|
changes.push(`推理强度: ${newEffort}`);
|
|
1864
1786
|
}
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
return { kind: 'command.result', text: `${err}\n已更新运行时配置,但未持久化` };
|
|
1875
|
-
}
|
|
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
|
+
});
|
|
1876
1796
|
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
1877
1797
|
return null;
|
|
1878
1798
|
return { kind: 'command.result', text: `✓ 已切换\n ${changes.join('\n ')}` };
|
|
@@ -1884,18 +1804,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1884
1804
|
const effortSession = await getExistingSessionForCommand();
|
|
1885
1805
|
const fallbackBaseagent = effortSession?.baseagent || this.agentRegistry?.resolveByChannel(channel)?.baseagent || this.parseDefaultBaseagent();
|
|
1886
1806
|
const effortAgent = this.getAgent(channel, fallbackBaseagent);
|
|
1887
|
-
const
|
|
1888
|
-
session: effortSession,
|
|
1889
|
-
channel,
|
|
1890
|
-
channelId,
|
|
1891
|
-
userId,
|
|
1892
|
-
selfAID,
|
|
1893
|
-
role: effortSession?.identity?.role || identity.role,
|
|
1894
|
-
chatType,
|
|
1895
|
-
});
|
|
1896
|
-
const effortSelector = 'error' in effortTarget
|
|
1897
|
-
? { self: selfAID ?? effortSession?.selfAID ?? this.resolveSelfAID(channel) }
|
|
1898
|
-
: effortTarget;
|
|
1807
|
+
const effortSelector = { self: selfAID ?? effortSession?.selfAID ?? this.resolveSelfAID(channel) };
|
|
1899
1808
|
let modelConfig = {};
|
|
1900
1809
|
try {
|
|
1901
1810
|
modelConfig = (resolveEffective(effortSelector, { cache: true }).baseagents || {})[fallbackBaseagent] || {};
|
|
@@ -1903,9 +1812,12 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1903
1812
|
catch { }
|
|
1904
1813
|
const configuredModel = modelConfig.model;
|
|
1905
1814
|
const configuredEffort = modelConfig.effort;
|
|
1906
|
-
|
|
1815
|
+
if (!configuredModel) {
|
|
1816
|
+
return { kind: 'command.error', text: '⚠️ 当前 Agent 未配置模型,请 owner/admin 先用 /model 设置模型' };
|
|
1817
|
+
}
|
|
1818
|
+
const currentModel = configuredModel;
|
|
1907
1819
|
const efforts = await getAvailableEfforts(effortAgent, currentModel);
|
|
1908
|
-
const currentEffort = configuredEffort ??
|
|
1820
|
+
const currentEffort = configuredEffort ?? 'auto';
|
|
1909
1821
|
if (efforts.length === 0) {
|
|
1910
1822
|
return { kind: 'command.error', text: '⚠️ 当前模型不支持推理强度设置' };
|
|
1911
1823
|
}
|
|
@@ -1946,63 +1858,49 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1946
1858
|
const effortSession = await getExistingSessionForCommand();
|
|
1947
1859
|
const fallbackBaseagent = effortSession?.baseagent || this.agentRegistry?.resolveByChannel(channel)?.baseagent || this.parseDefaultBaseagent();
|
|
1948
1860
|
const effortAgent = this.getAgent(channel, fallbackBaseagent);
|
|
1949
|
-
const
|
|
1950
|
-
session: effortSession,
|
|
1951
|
-
channel,
|
|
1952
|
-
channelId,
|
|
1953
|
-
userId,
|
|
1954
|
-
selfAID,
|
|
1955
|
-
role: effortSession?.identity?.role || identity.role,
|
|
1956
|
-
chatType,
|
|
1957
|
-
});
|
|
1958
|
-
const effortSelector = 'error' in relationTarget
|
|
1959
|
-
? { self: selfAID ?? effortSession?.selfAID ?? this.resolveSelfAID(channel) }
|
|
1960
|
-
: relationTarget;
|
|
1861
|
+
const effortSelf = selfAID ?? effortSession?.selfAID ?? this.resolveSelfAID(channel);
|
|
1961
1862
|
let modelConfig = {};
|
|
1962
1863
|
try {
|
|
1963
|
-
modelConfig = (resolveEffective(
|
|
1864
|
+
modelConfig = (resolveEffective({ self: effortSelf }, { cache: true }).baseagents || {})[fallbackBaseagent] || {};
|
|
1964
1865
|
}
|
|
1965
1866
|
catch { }
|
|
1966
1867
|
const configuredModel = modelConfig.model;
|
|
1967
|
-
|
|
1968
|
-
|
|
1868
|
+
if (!configuredModel) {
|
|
1869
|
+
return { kind: 'command.error', text: '⚠️ 当前 Agent 未配置模型,请 owner/admin 先用 /model 设置模型' };
|
|
1870
|
+
}
|
|
1871
|
+
const currentModel = configuredModel;
|
|
1969
1872
|
const efforts = await getAvailableEfforts(effortAgent, currentModel);
|
|
1970
|
-
const currentEffort = configuredEffort ?? effortAgent.getEffort?.() ?? 'auto';
|
|
1971
1873
|
if (efforts.length === 0) {
|
|
1972
1874
|
return { kind: 'command.error', text: '⚠️ 当前模型不支持推理强度设置' };
|
|
1973
1875
|
}
|
|
1974
|
-
//
|
|
1975
|
-
|
|
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 默认)
|
|
1976
1896
|
if (args === 'auto') {
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
role: relationTarget.role,
|
|
1983
|
-
}, effortAgent.name, { effort: null });
|
|
1984
|
-
}
|
|
1985
|
-
catch (e) {
|
|
1986
|
-
return { kind: 'command.error', text: `Failed to update relation effort: ${e?.message || e}` };
|
|
1987
|
-
}
|
|
1988
|
-
this.eventBus.publish({
|
|
1989
|
-
type: 'runner:model-changed',
|
|
1990
|
-
sessionId: effortSession?.id,
|
|
1991
|
-
agentName: this.agentRegistry?.resolveByChannel(channel)?.name,
|
|
1992
|
-
baseagent: effortSession?.baseagent || effortAgent.name,
|
|
1993
|
-
effort: 'auto',
|
|
1994
|
-
timestamp: Date.now(),
|
|
1995
|
-
});
|
|
1996
|
-
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
1997
|
-
return null;
|
|
1998
|
-
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}` };
|
|
1999
1902
|
}
|
|
2000
|
-
if (!isAdmin)
|
|
2001
|
-
return { kind: 'command.error', text: `Cannot locate relation scope: ${relationTarget.error}` };
|
|
2002
1903
|
effortAgent.setEffort?.(undefined);
|
|
2003
|
-
const err = this.persistBaseagentEffort(channel, effortAgent.name, undefined);
|
|
2004
|
-
if (err)
|
|
2005
|
-
return { kind: 'command.result', text: `${err}\n已更新运行时配置,但未持久化` };
|
|
2006
1904
|
this.eventBus.publish({
|
|
2007
1905
|
type: 'runner:model-changed',
|
|
2008
1906
|
sessionId: effortSession?.id,
|
|
@@ -2023,35 +1921,13 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2023
1921
|
return { kind: 'command.error', text: `❌ 无效参数: ${args}\n可选: ${efforts.join(' / ')} / auto` };
|
|
2024
1922
|
}
|
|
2025
1923
|
const newEffort = args;
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
role: relationTarget.role,
|
|
2032
|
-
}, effortAgent.name, { effort: newEffort });
|
|
2033
|
-
}
|
|
2034
|
-
catch (e) {
|
|
2035
|
-
return { kind: 'command.error', text: `Failed to update relation effort: ${e?.message || e}` };
|
|
2036
|
-
}
|
|
2037
|
-
this.eventBus.publish({
|
|
2038
|
-
type: 'runner:model-changed',
|
|
2039
|
-
sessionId: effortSession?.id,
|
|
2040
|
-
agentName: this.agentRegistry?.resolveByChannel(channel)?.name,
|
|
2041
|
-
baseagent: effortSession?.baseagent || effortAgent.name,
|
|
2042
|
-
effort: newEffort,
|
|
2043
|
-
timestamp: Date.now(),
|
|
2044
|
-
});
|
|
2045
|
-
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
2046
|
-
return null;
|
|
2047
|
-
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}` };
|
|
2048
1929
|
}
|
|
2049
|
-
if (!isAdmin)
|
|
2050
|
-
return { kind: 'command.error', text: `Cannot locate relation scope: ${relationTarget.error}` };
|
|
2051
1930
|
effortAgent.setEffort?.(newEffort);
|
|
2052
|
-
const err = this.persistBaseagentEffort(channel, effortAgent.name, newEffort);
|
|
2053
|
-
if (err)
|
|
2054
|
-
return { kind: 'command.result', text: `${err}\n已更新运行时配置,但未持久化` };
|
|
2055
1931
|
this.eventBus.publish({
|
|
2056
1932
|
type: 'runner:model-changed',
|
|
2057
1933
|
sessionId: effortSession?.id,
|
|
@@ -2636,6 +2512,9 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2636
2512
|
catch {
|
|
2637
2513
|
compactConfig = {};
|
|
2638
2514
|
}
|
|
2515
|
+
if (typeof compactConfig.model !== 'string' || !compactConfig.model.trim()) {
|
|
2516
|
+
return { kind: 'command.error', text: `⚠️ 当前 Agent 未配置模型(baseagents.${compactBaseagent}.model),无法压缩。请 owner/admin 先用 /model 设置模型。` };
|
|
2517
|
+
}
|
|
2639
2518
|
const compactModelDecision = constrainResolvedModelForRole({
|
|
2640
2519
|
role: session.identity?.role || identity.role,
|
|
2641
2520
|
baseagent: compactBaseagent,
|
|
@@ -3174,12 +3053,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3174
3053
|
}
|
|
3175
3054
|
// Archiving only changes list visibility; pending work must still be checked.
|
|
3176
3055
|
const allSessions = await this.sessionManager.listSessions(channel, channelId, { archiveFilter: 'all' });
|
|
3177
|
-
const
|
|
3178
|
-
.filter((s) => this.messageCache.hasMessages(s.id))
|
|
3179
|
-
.map((s) => {
|
|
3180
|
-
const count = this.messageCache.getCount(s.id);
|
|
3181
|
-
return `${s.projectPath} 有 ${count} 条新消息`;
|
|
3182
|
-
});
|
|
3056
|
+
const pendingResultCount = allSessions.reduce((count, session) => count + this.messageCache.getCount(session.id), 0);
|
|
3183
3057
|
const executeRestart = async () => {
|
|
3184
3058
|
const suppressRealRestart = shouldSuppressRealRestart();
|
|
3185
3059
|
let restartReplyContext = replyContext;
|
|
@@ -3347,26 +3221,20 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3347
3221
|
return true;
|
|
3348
3222
|
};
|
|
3349
3223
|
// 文本确认流程
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
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) {
|
|
3353
3232
|
fs.mkdirSync(controlDir, { recursive: true });
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
fs.unlinkSync(restartConfirmFile);
|
|
3360
|
-
}
|
|
3361
|
-
else {
|
|
3362
|
-
fs.writeFileSync(restartConfirmFile, JSON.stringify({ timestamp: now }));
|
|
3363
|
-
return { kind: 'command.result', text: sessionsWithMessages.join('\n') + '\n再次输入 /restart 将强制重启。' };
|
|
3364
|
-
}
|
|
3365
|
-
}
|
|
3366
|
-
else {
|
|
3367
|
-
fs.writeFileSync(restartConfirmFile, JSON.stringify({ timestamp: Date.now() }));
|
|
3368
|
-
return { kind: 'command.result', text: sessionsWithMessages.join('\n') + '\n再次输入 /restart 将强制重启。' };
|
|
3369
|
-
}
|
|
3233
|
+
fs.writeFileSync(restartConfirmFile, JSON.stringify({ timestamp: Date.now() }));
|
|
3234
|
+
return {
|
|
3235
|
+
kind: 'command.result',
|
|
3236
|
+
text: `当前Agent对话有 ${pendingResultCount} 条后台结果待查看。再次输入 /restart 将强制重启服务。`,
|
|
3237
|
+
};
|
|
3370
3238
|
}
|
|
3371
3239
|
const restarted = await executeRestart();
|
|
3372
3240
|
if (typeof restarted === 'object' && restarted.code === 'RESTART_ENTRY_MISSING') {
|
|
@@ -4149,6 +4017,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
4149
4017
|
isAdmin,
|
|
4150
4018
|
isOwnerSelf: isOwner && !!memoryOwnerAid && (authSubject.principalId ?? userId) === memoryOwnerAid,
|
|
4151
4019
|
ownerAid: memoryOwnerAid,
|
|
4020
|
+
actorAid: authSubject.principalId ?? userId,
|
|
4152
4021
|
memoryConfig: memoryAgent?.config?.memory,
|
|
4153
4022
|
channelType: authSubject.channelType,
|
|
4154
4023
|
peerId: activeChatType === 'group' ? channelId : (userId ?? channelId),
|