evolcore 0.0.41-test.0 → 0.0.41-test.2
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 +62 -0
- package/dist/agents/baseagent-availability.js +1 -1
- package/dist/agents/baseagent.js +88 -49
- package/dist/agents/claude-runner.js +177 -92
- package/dist/agents/codex-runner.js +146 -71
- package/dist/agents/ecagent-runner.js +1 -1
- package/dist/agents/gemini-runner.js +1 -1
- package/dist/aun/aid/agentmd.js +98 -11
- package/dist/aun/aid/client.js +1 -1
- package/dist/aun/aid/control-aid.js +26 -2
- package/dist/aun/aid/identity.js +91 -0
- package/dist/aun/aid/index.js +1 -1
- package/dist/aun/aid/managed-operation.js +1 -1
- package/dist/aun/aid/ownership-operation.js +23 -22
- 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/menu/client.js +27 -0
- package/dist/aun/msg/managed-operation.js +68 -7
- package/dist/aun/msg/p2p.js +8 -8
- package/dist/aun/service-proxy.js +53 -12
- package/dist/channels/aun.js +633 -32
- package/dist/channels/daemon.js +15 -1
- package/dist/cli/agent-command.js +5 -2
- package/dist/cli/agent-create.js +991 -233
- package/dist/cli/agent.js +49 -10
- package/dist/cli/aid-bind-command.js +48 -19
- package/dist/cli/aun-commands.js +48 -36
- package/dist/cli/daemon-commands.js +679 -697
- package/dist/cli/fs-command.js +64 -2
- package/dist/cli/index.js +72 -5
- package/dist/cli/init-channel.js +1 -1
- package/dist/cli/init.js +75 -1
- package/dist/cli/managed-command-guard.js +17 -1
- package/dist/cli/model.js +40 -40
- package/dist/cli/provider-command.js +57 -0
- package/dist/cli/proxy-command.js +92 -0
- package/dist/cli/restart-monitor.js +4 -2
- package/dist/cli/role.js +85 -0
- package/dist/cli/stats.js +10 -3
- package/dist/cli/task-context.js +19 -0
- package/dist/config/access-policy.js +7 -2
- package/dist/config/boot-log.js +39 -1
- package/dist/config/config-field-policy.js +17 -39
- package/dist/config/config-manager.js +183 -44
- 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/owner-config.js +2 -2
- package/dist/config/peer-role-resolver.js +15 -12
- package/dist/config/provider-ipc-service.js +132 -0
- package/dist/config/provider-menu-request.js +58 -0
- package/dist/config/providers-config.js +12 -7
- package/dist/config/providers-import.js +3 -21
- package/dist/config/providers-management.js +78 -5
- package/dist/config/resolved-config-op.js +11 -1
- package/dist/config/role-command-service.js +166 -0
- package/dist/config/role-request-service.js +193 -0
- package/dist/config/schema-migration.js +1000 -25
- package/dist/config-store.js +89 -4
- package/dist/contracts/ecweb-instance.js +41 -0
- package/dist/contracts/ecweb-service-protocol.js +4 -1
- package/dist/core/agent-application-service.js +60 -11
- package/dist/core/agent-create-status.js +203 -0
- package/dist/core/agent-creation-claim.js +177 -0
- package/dist/core/agent-ipc-registration.js +39 -18
- package/dist/core/agent-runtime.js +194 -24
- package/dist/core/auth/agent-delegation.js +6 -3
- package/dist/core/auth/auth-gateway.js +67 -2
- package/dist/core/auth/authorization-audit.js +58 -11
- package/dist/core/auth/delegation-authorization.js +5 -2
- package/dist/core/auth/operation-authorizer.js +43 -6
- package/dist/core/auth/operation-catalog.js +45 -7
- package/dist/core/channel-loader.js +2 -0
- package/dist/core/command/agent-control.js +260 -21
- package/dist/core/command/agent-storage-menu.js +5 -3
- package/dist/core/command/cli-intent-parser.js +8 -3
- package/dist/core/command/command-handler.js +112 -154
- 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 +10 -6
- package/dist/core/command/menu-handler.js +106 -73
- package/dist/core/command/menu-protocol.js +15 -1
- package/dist/core/command/provider-menu.js +46 -0
- package/dist/core/command/role-menu.js +147 -30
- package/dist/core/command/slash-handler.js +125 -255
- package/dist/core/daemon-control.js +26 -27
- package/dist/core/event-catalog.js +10 -0
- package/dist/core/evolagent-registry.js +7 -5
- package/dist/core/evolagent.js +10 -8
- package/dist/core/file-integrity/store.js +11 -0
- package/dist/core/handoff/ipc-registration.js +3 -0
- package/dist/core/inference/text-inference.js +31 -40
- package/dist/core/initialization/service.js +491 -0
- package/dist/core/ipc-registration.js +40 -24
- package/dist/core/memory/consolidation-context.js +51 -5
- package/dist/core/memory/consolidation-ops-records.js +96 -1
- package/dist/core/memory/consolidation-trigger.js +208 -191
- package/dist/core/memory/consolidation.js +333 -35
- 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 +55 -45
- package/dist/core/message/aun-ipc-sender.js +81 -69
- package/dist/core/message/im-renderer.js +25 -4
- package/dist/core/message/message-admission.js +89 -4
- package/dist/core/message/message-bridge.js +66 -21
- package/dist/core/message/response-engine.js +108 -35
- package/dist/core/model/catalog-service.js +5 -3
- package/dist/core/model/config-scope.js +29 -71
- 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 +772 -158
- package/dist/core/permission/approval-gateway.js +103 -403
- package/dist/core/permission/ec-command-parser.js +62 -6
- package/dist/core/permission/index.js +1 -0
- package/dist/core/permission/permission-result.js +78 -0
- package/dist/core/permission/sandbox-runtime.js +18 -1
- package/dist/core/permission/tool-policy.js +21 -46
- 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 +43 -8
- 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/init-menu.js +32 -0
- package/dist/ecweb/message-context-service.js +110 -0
- package/dist/index.js +93 -19
- package/dist/ipc.js +247 -29
- package/dist/paths.js +7 -0
- package/dist/proxy/command.js +122 -0
- package/dist/proxy/ipc-service.js +68 -0
- package/dist/proxy/manager.js +484 -0
- package/dist/proxy/service-supervisor.js +603 -0
- package/dist/response-system/engines/v1/proactive-flow.js +16 -6
- package/dist/trigger/authorization.js +27 -17
- package/dist/trigger/feedback.js +2 -3
- package/dist/trigger/ipc-service.js +105 -78
- package/dist/trigger/local-files.js +2 -1
- package/dist/trigger/manager.js +5 -3
- package/dist/trigger/scheduler.js +88 -6
- package/dist/utils/atomic-write.js +28 -0
- package/dist/utils/cross-platform.js +14 -0
- package/dist/utils/ecweb-supervisor.js +258 -83
- package/dist/utils/error-utils.js +26 -2
- package/dist/utils/logger.js +92 -6
- package/dist/utils/package-version-info.js +4 -2
- package/dist/utils/welcome.js +1 -1
- package/kits/docs/INDEX.md +1 -0
- package/kits/docs/aun/SDK.md +4 -1
- package/kits/docs/channels/aun.md +9 -0
- package/kits/docs/evolcore/INDEX.md +1 -0
- package/kits/docs/evolcore/agent.md +8 -1
- package/kits/docs/evolcore/aid.md +67 -17
- package/kits/docs/evolcore/config.md +28 -7
- package/kits/docs/evolcore/contact.md +3 -0
- package/kits/docs/evolcore/fs.md +11 -0
- package/kits/docs/evolcore/group.md +1 -1
- 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/docs/evolcore/provider.md +50 -0
- package/kits/docs/identity/AID_PROFILE_SPEC.md +52 -17
- package/kits/migrations/migrate-contact-book-v2.mjs +30 -11
- package/kits/rules/01-overview.md +3 -0
- package/kits/rules/04-relation.md +1 -1
- 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 +277 -0
- package/kits/schemas/role-config.schema.1.json +7 -7
- package/kits/skills/.switches.json +4 -0
- package/kits/skills/ec-agent-create/SKILL.md +3 -0
- package/kits/skills/ec-identity/SKILL.md +2 -2
- package/kits/skills/ec-service-proxy/SKILL.md +118 -0
- package/kits/skills/ec-skill/scripts/skill.mjs +6 -0
- 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/skills/thread-ops/SKILL.md +5 -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/kits/templates/system-fragments/venue.md +1 -1
- package/package.json +7 -3
- package/dist/core/message/create-status.js +0 -96
|
@@ -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';
|
|
@@ -400,9 +400,11 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
400
400
|
chatType = undefined;
|
|
401
401
|
// 解析身份(按实例名)
|
|
402
402
|
const narrowedChatType = chatType === 'group' ? 'group' : chatType === 'private' ? 'private' : undefined;
|
|
403
|
+
const normalizedContent = normalizeSlashContent(content);
|
|
403
404
|
await refreshOwnershipForAuthorization(selfAID ?? this.agentRegistry?.resolveByChannel(channel)?.aid ?? this.resolveSelfAID(channel), {
|
|
404
405
|
maxAgeMs: OWNERSHIP_CACHE_MAX_AGE_MS,
|
|
405
406
|
allowTransient: true,
|
|
407
|
+
includeDaemon: /^\/(?:restart|upgrade|reload|pair|fa|fullaccess|diag)(?:\s|$)/i.test(normalizedContent),
|
|
406
408
|
});
|
|
407
409
|
const identityConversationId = narrowedChatType === 'group' ? channelId : userId;
|
|
408
410
|
const resolvedIdentity = overrideIdentity ?? this.sessionManager.resolveIdentity(channel, userId, narrowedChatType, identityConversationId);
|
|
@@ -439,7 +441,6 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
439
441
|
}
|
|
440
442
|
};
|
|
441
443
|
// 规范化命令(将别名转换为完整命令)
|
|
442
|
-
const normalizedContent = normalizeSlashContent(content);
|
|
443
444
|
if (normalizedContent !== content) {
|
|
444
445
|
logger.debug(`[CommandHandler] normalized: "${content}" -> "${normalizedContent}"`);
|
|
445
446
|
}
|
|
@@ -511,7 +512,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
511
512
|
const canAccessSlashOperation = (operation, scope) => {
|
|
512
513
|
const args = scope === 'relation'
|
|
513
514
|
? buildSlashRelationIntentArgs({ selfAid: authSubject.selfAid, peerKey: authSubject.peerKey })
|
|
514
|
-
: {};
|
|
515
|
+
: scope === 'agent' && authSubject.selfAid ? { self: authSubject.selfAid } : {};
|
|
515
516
|
return authorizeOperation({
|
|
516
517
|
source: 'slash',
|
|
517
518
|
intent: { operation, scope, source: 'slash', args },
|
|
@@ -643,21 +644,26 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
643
644
|
if (!commandSession || !agentAid) {
|
|
644
645
|
return { kind: 'command.error', text: '❌ 当前没有可绑定的 EC 会话' };
|
|
645
646
|
}
|
|
646
|
-
if (this.messageQueue.isProcessing(commandSession.id) || this.messageQueue.getQueueLength(commandSession.id) > 0) {
|
|
647
|
-
return { kind: 'command.error', text: '❌ 当前会话有任务执行中,结束后再修改 fullaccess' };
|
|
648
|
-
}
|
|
649
647
|
if (!principalId || !authSubject.isDaemonOwner || !isAgentFullAccessOwner(agentAid, principalId)) {
|
|
650
648
|
return { kind: 'command.error', text: '❌ /fa 需要同一身份同时具备 Agent Owner 和 daemon Owner 权限' };
|
|
651
649
|
}
|
|
650
|
+
const status = sessionFullAccessStatus(commandSession, principalId);
|
|
652
651
|
if (fullAccessControl.action === 'status') {
|
|
653
|
-
const
|
|
654
|
-
const scope = isTopicSession(commandSession) ? 'session' : 'agent';
|
|
652
|
+
const scope = isTopicSession(commandSession) ? 'session' : 'relation';
|
|
655
653
|
return {
|
|
656
654
|
kind: 'command.result',
|
|
657
655
|
text: '当前 fullaccess(' + scope + ',session=' + commandSession.id + '):'
|
|
658
|
-
+ (status.effective ? '开启' : '关闭')
|
|
656
|
+
+ (status.effective ? '开启' : '关闭')
|
|
657
|
+
+ '\nAgent 全局:' + (status.globalEnabled ? '开启(局部开关不生效)' : '关闭')
|
|
658
|
+
+ '\n局部开关:' + (status.localEnabled ? '开启' : '关闭'),
|
|
659
659
|
};
|
|
660
660
|
}
|
|
661
|
+
if (status.globalEnabled) {
|
|
662
|
+
return { kind: 'command.result', text: 'Agent 全局 fullaccess 已开启,/fa on/off 不生效;局部设置未修改。' };
|
|
663
|
+
}
|
|
664
|
+
if (this.messageQueue.isProcessing(commandSession.id) || this.messageQueue.getQueueLength(commandSession.id) > 0) {
|
|
665
|
+
return { kind: 'command.error', text: '❌ 当前会话有任务执行中,结束后再修改 fullaccess' };
|
|
666
|
+
}
|
|
661
667
|
const enabled = fullAccessControl.action === 'on';
|
|
662
668
|
try {
|
|
663
669
|
if (isTopicSession(commandSession)) {
|
|
@@ -672,11 +678,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
672
678
|
if (!latest || latest.id !== commandSession.id || !isMainSession(latest)) {
|
|
673
679
|
return { kind: 'command.error', text: '❌ 当前主会话已发生变化,请重新执行 /fa' };
|
|
674
680
|
}
|
|
675
|
-
|
|
676
|
-
if (!config)
|
|
677
|
-
return { kind: 'command.error', text: '❌ 找不到当前 Agent 配置' };
|
|
678
|
-
config.fullaccess = { enabled };
|
|
679
|
-
cfgWrite(ConfigTarget.Agent, config, { self: agentAid });
|
|
681
|
+
updateRelationSessionFullAccess(latest, { enabled, authorizedBy: principalId });
|
|
680
682
|
}
|
|
681
683
|
auditFullAccessEvent({
|
|
682
684
|
event: enabled ? 'fullaccess.session-policy.configured' : 'fullaccess.session-policy.deescalated',
|
|
@@ -686,11 +688,12 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
686
688
|
agentAid,
|
|
687
689
|
sessionId: commandSession.id,
|
|
688
690
|
authorizedBy: principalId,
|
|
689
|
-
reason: isTopicSession(commandSession) ? 'topic session fullaccess updated' : '
|
|
691
|
+
reason: isTopicSession(commandSession) ? 'topic session fullaccess updated' : 'relation main-session fullaccess updated',
|
|
690
692
|
});
|
|
691
693
|
return {
|
|
692
694
|
kind: 'command.result',
|
|
693
|
-
text: '✅ 当前
|
|
695
|
+
text: '✅ 当前' + (isTopicSession(commandSession) ? '话题 EC 会话' : '主会话')
|
|
696
|
+
+ ' fullaccess 已' + (enabled ? '开启' : '关闭'),
|
|
694
697
|
};
|
|
695
698
|
}
|
|
696
699
|
catch (error) {
|
|
@@ -839,8 +842,8 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
839
842
|
}
|
|
840
843
|
const canReadModel = canAccessSlashOperation('model.current', 'relation')
|
|
841
844
|
|| canAccessSlashOperation('model.list', 'relation');
|
|
842
|
-
const canUseModel = canAccessSlashOperation('model.use', '
|
|
843
|
-
const canSetEffort = canAccessSlashOperation('model.effort', '
|
|
845
|
+
const canUseModel = canAccessSlashOperation('model.use', 'agent');
|
|
846
|
+
const canSetEffort = canAccessSlashOperation('model.effort', 'agent');
|
|
844
847
|
const canReadPermission = canAccessSlashOperation('permission.current', 'relation');
|
|
845
848
|
const canAnswerPermission = canAccessSlashOperation('permission.answer', 'relation');
|
|
846
849
|
const canReadChatmode = canAccessSlashOperation('chatmode.current', 'relation');
|
|
@@ -1076,8 +1079,8 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1076
1079
|
const cmds = [...loopHelp];
|
|
1077
1080
|
const canReadModel = canAccessSlashOperation('model.current', 'relation')
|
|
1078
1081
|
|| canAccessSlashOperation('model.list', 'relation');
|
|
1079
|
-
const canUseModel = canAccessSlashOperation('model.use', '
|
|
1080
|
-
const canSetEffort = canAccessSlashOperation('model.effort', '
|
|
1082
|
+
const canUseModel = canAccessSlashOperation('model.use', 'agent');
|
|
1083
|
+
const canSetEffort = canAccessSlashOperation('model.effort', 'agent');
|
|
1081
1084
|
const canReadPermission = canAccessSlashOperation('permission.current', 'relation');
|
|
1082
1085
|
const canAnswerPermission = canAccessSlashOperation('permission.answer', 'relation');
|
|
1083
1086
|
const canReadChatmode = canAccessSlashOperation('chatmode.current', 'relation');
|
|
@@ -1465,7 +1468,6 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1465
1468
|
try {
|
|
1466
1469
|
const result = await runModelCheck({
|
|
1467
1470
|
self,
|
|
1468
|
-
peerKey,
|
|
1469
1471
|
role: modelSession?.identity?.role || identity.role,
|
|
1470
1472
|
baseagent: modelAgent.name,
|
|
1471
1473
|
});
|
|
@@ -1486,12 +1488,13 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1486
1488
|
return { kind: 'command.error', text: `模型网关检查失败: ${error instanceof Error ? error.message : String(error)}` };
|
|
1487
1489
|
}
|
|
1488
1490
|
}
|
|
1491
|
+
// 模型参数只在 Agent 级:reset 直接清除 Agent 级配置(鉴权用 agent scope)。
|
|
1489
1492
|
const resetAuthDenied = await authorizeIntent({
|
|
1490
1493
|
intent: {
|
|
1491
1494
|
operation: 'model.reset',
|
|
1492
|
-
scope: '
|
|
1495
|
+
scope: 'agent',
|
|
1493
1496
|
source: 'slash',
|
|
1494
|
-
args:
|
|
1497
|
+
args: { self: selfAID ?? this.resolveSelfAID(channel) },
|
|
1495
1498
|
},
|
|
1496
1499
|
identity,
|
|
1497
1500
|
session: modelSession,
|
|
@@ -1499,27 +1502,16 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1499
1502
|
channel,
|
|
1500
1503
|
channelId,
|
|
1501
1504
|
userId,
|
|
1502
|
-
selfAid:
|
|
1505
|
+
selfAid: selfAID ?? this.resolveSelfAID(channel),
|
|
1503
1506
|
isDaemonOwner,
|
|
1504
1507
|
});
|
|
1505
1508
|
if (resetAuthDenied)
|
|
1506
1509
|
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
1510
|
try {
|
|
1519
|
-
|
|
1511
|
+
writeAgentModelConfig(selfAID ?? modelSession?.selfAID ?? this.resolveSelfAID(channel), modelAgent.name, { model: null, effort: null });
|
|
1520
1512
|
}
|
|
1521
1513
|
catch (error) {
|
|
1522
|
-
return { kind: 'command.error', text: `Failed to reset
|
|
1514
|
+
return { kind: 'command.error', text: `Failed to reset Agent model settings: ${error?.message || error}` };
|
|
1523
1515
|
}
|
|
1524
1516
|
this.eventBus.publish({
|
|
1525
1517
|
type: 'runner:model-changed',
|
|
@@ -1530,8 +1522,8 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1530
1522
|
});
|
|
1531
1523
|
return {
|
|
1532
1524
|
kind: 'command.result',
|
|
1533
|
-
text: '✓
|
|
1534
|
-
structured: { ok: true, scope: '
|
|
1525
|
+
text: '✓ 已清除当前 Agent 的模型和推理强度设置',
|
|
1526
|
+
structured: { ok: true, scope: 'agent', self: selfAID ?? this.resolveSelfAID(channel) },
|
|
1535
1527
|
};
|
|
1536
1528
|
}
|
|
1537
1529
|
if (!args || args === 'list' || args === 'current') {
|
|
@@ -1585,9 +1577,11 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1585
1577
|
const models = hasModelSwitcher(modelAgent)
|
|
1586
1578
|
? filterModelsForRole(identity.role, fallbackBaseagent, rawModels, model => resolveCatalogModel(catalog, model), modelSelector.self)
|
|
1587
1579
|
: rawModels;
|
|
1588
|
-
|
|
1589
|
-
const
|
|
1590
|
-
const
|
|
1580
|
+
// 模型只在 Agent 级:未配置就是没有模型,不显示 runner 内置默认值。
|
|
1581
|
+
const currentModel = configuredModel ?? '';
|
|
1582
|
+
const currentModelLabel = currentModel ? modelDisplayLabel(modelAgent, currentModel) : '未配置(Agent 级未设置模型,无模型可用)';
|
|
1583
|
+
const efforts = currentModel ? await getAvailableEfforts(modelAgent, currentModel) : [];
|
|
1584
|
+
const currentEffort = configuredEffort ?? 'auto';
|
|
1591
1585
|
const canReadModelList = await canReadSlashModelList({
|
|
1592
1586
|
subject: authSubject,
|
|
1593
1587
|
identity,
|
|
@@ -1636,7 +1630,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1636
1630
|
if (args === 'current') {
|
|
1637
1631
|
return {
|
|
1638
1632
|
kind: 'command.result',
|
|
1639
|
-
text: `当前模型: ${
|
|
1633
|
+
text: `当前模型: ${currentModelLabel}${effortHint}`,
|
|
1640
1634
|
structured: { ok: true, model: currentModel, effort: currentEffort, baseagent: fallbackBaseagent },
|
|
1641
1635
|
};
|
|
1642
1636
|
}
|
|
@@ -1644,11 +1638,11 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1644
1638
|
const usage = !groupSlash && !args && isAdmin ? '\n\n用法: /model <模型>' : '';
|
|
1645
1639
|
return {
|
|
1646
1640
|
kind: 'command.result',
|
|
1647
|
-
text: `当前模型: ${
|
|
1641
|
+
text: `当前模型: ${currentModelLabel}${effortHint}${!currentModel || rawModels.includes(currentModel) ? '' : ' [当前配置,未列入目录]'}\n${catalogHint}\n\n可用模型:\n${modelList}${usage}`,
|
|
1648
1642
|
...(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
1643
|
};
|
|
1650
1644
|
}
|
|
1651
|
-
return { kind: 'command.result', text: `当前模型: ${
|
|
1645
|
+
return { kind: 'command.result', text: `当前模型: ${currentModelLabel}${effortHint}` };
|
|
1652
1646
|
}
|
|
1653
1647
|
const modelSession = await getExistingSessionForCommand();
|
|
1654
1648
|
const modelChatType = modelSession?.chatType
|
|
@@ -1661,13 +1655,9 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1661
1655
|
const earlyUseAuthDenied = await authorizeIntent({
|
|
1662
1656
|
intent: {
|
|
1663
1657
|
operation: 'model.use',
|
|
1664
|
-
scope: '
|
|
1658
|
+
scope: 'agent',
|
|
1665
1659
|
source: 'slash',
|
|
1666
|
-
args:
|
|
1667
|
-
args: { model: args.split(/\s+/)[0] },
|
|
1668
|
-
selfAid: selfAID ?? this.resolveSelfAID(channel),
|
|
1669
|
-
peerKey,
|
|
1670
|
-
}),
|
|
1660
|
+
args: { self: selfAID ?? this.resolveSelfAID(channel), model: args.split(/\s+/)[0] },
|
|
1671
1661
|
},
|
|
1672
1662
|
identity,
|
|
1673
1663
|
session: modelSession,
|
|
@@ -1684,21 +1674,10 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1684
1674
|
text: earlyUseAuthDenied.text.includes('无权限') ? earlyUseAuthDenied.text : `❌ 无权限:${earlyUseAuthDenied.text}`,
|
|
1685
1675
|
};
|
|
1686
1676
|
}
|
|
1687
|
-
// 切换模型写入
|
|
1677
|
+
// 切换模型写入 Agent 级 baseagents 配置;没有活跃会话时也不应创建空会话。
|
|
1688
1678
|
const fallbackBaseagent = modelSession?.baseagent || this.agentRegistry?.resolveByChannel(channel)?.baseagent || this.parseDefaultBaseagent();
|
|
1689
1679
|
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;
|
|
1680
|
+
const modelSelector = { self: selfAID ?? modelSession?.selfAID ?? this.resolveSelfAID(channel) };
|
|
1702
1681
|
let configuredModel;
|
|
1703
1682
|
try {
|
|
1704
1683
|
configuredModel = (resolveEffective(modelSelector, { cache: true }).baseagents || {})[fallbackBaseagent]?.model;
|
|
@@ -1713,8 +1692,8 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1713
1692
|
let newEffort;
|
|
1714
1693
|
if (parts.length === 1) {
|
|
1715
1694
|
const arg = parts[0];
|
|
1716
|
-
const currentModel =
|
|
1717
|
-
const efforts = await getAvailableEfforts(modelAgent, currentModel);
|
|
1695
|
+
const currentModel = configuredModel ?? '';
|
|
1696
|
+
const efforts = currentModel ? await getAvailableEfforts(modelAgent, currentModel) : [];
|
|
1718
1697
|
// effort 相关参数统一转发到 /effort
|
|
1719
1698
|
if (efforts.includes(arg) || arg === 'auto') {
|
|
1720
1699
|
const delegated = await this.handle(`/effort ${arg}`, channel, channelId, undefined, userId, threadId);
|
|
@@ -1755,25 +1734,13 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1755
1734
|
newModel = modelArgRaw;
|
|
1756
1735
|
newEffort = effortArg;
|
|
1757
1736
|
}
|
|
1758
|
-
// 优先写关系级覆盖;只有无法定位关系且具备管理权限时才回退到 runner/agent 级。
|
|
1759
1737
|
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
1738
|
const useAuthDenied = await authorizeIntent({
|
|
1768
1739
|
intent: {
|
|
1769
1740
|
operation: 'model.use',
|
|
1770
|
-
scope: '
|
|
1741
|
+
scope: 'agent',
|
|
1771
1742
|
source: 'slash',
|
|
1772
|
-
args:
|
|
1773
|
-
args: { model: newModel },
|
|
1774
|
-
selfAid: selfAID ?? this.resolveSelfAID(channel),
|
|
1775
|
-
peerKey,
|
|
1776
|
-
}),
|
|
1743
|
+
args: { self: modelSelector.self, model: newModel },
|
|
1777
1744
|
},
|
|
1778
1745
|
identity,
|
|
1779
1746
|
session: modelSession,
|
|
@@ -1801,78 +1768,32 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1801
1768
|
// for configuration and replies, just like menu.update and local model use.
|
|
1802
1769
|
}
|
|
1803
1770
|
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 ')}` };
|
|
1771
|
+
const agentSelf = selfAID ?? modelSession?.selfAID ?? this.resolveSelfAID(channel);
|
|
1772
|
+
// 模型参数只在 Agent 级:直接写 Agent config,不再走关系级。
|
|
1773
|
+
// 鉴权已在 earlyUseAuthDenied 完成(agent scope, owner/admin only)。
|
|
1774
|
+
try {
|
|
1775
|
+
writeAgentModelConfig(agentSelf, modelAgent.name, { model: newModel ?? null, effort: newEffort ?? null });
|
|
1834
1776
|
}
|
|
1835
|
-
|
|
1836
|
-
return { kind: 'command.error', text: `
|
|
1777
|
+
catch (e) {
|
|
1778
|
+
return { kind: 'command.error', text: `Failed to update Agent model settings: ${e?.message || e}` };
|
|
1837
1779
|
}
|
|
1838
1780
|
if (newModel) {
|
|
1839
1781
|
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
1782
|
changes.push(`模型: ${newModel}`);
|
|
1850
1783
|
}
|
|
1851
1784
|
if (newEffort) {
|
|
1852
1785
|
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
1786
|
changes.push(`推理强度: ${newEffort}`);
|
|
1864
1787
|
}
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
return { kind: 'command.result', text: `${err}\n已更新运行时配置,但未持久化` };
|
|
1875
|
-
}
|
|
1788
|
+
this.eventBus.publish({
|
|
1789
|
+
type: 'runner:model-changed',
|
|
1790
|
+
sessionId: modelSession?.id,
|
|
1791
|
+
agentName: this.agentRegistry?.resolveByChannel(channel)?.name,
|
|
1792
|
+
baseagent: modelSession?.baseagent || modelAgent.name,
|
|
1793
|
+
model: newModel,
|
|
1794
|
+
effort: newEffort,
|
|
1795
|
+
timestamp: Date.now(),
|
|
1796
|
+
});
|
|
1876
1797
|
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
1877
1798
|
return null;
|
|
1878
1799
|
return { kind: 'command.result', text: `✓ 已切换\n ${changes.join('\n ')}` };
|
|
@@ -1884,18 +1805,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1884
1805
|
const effortSession = await getExistingSessionForCommand();
|
|
1885
1806
|
const fallbackBaseagent = effortSession?.baseagent || this.agentRegistry?.resolveByChannel(channel)?.baseagent || this.parseDefaultBaseagent();
|
|
1886
1807
|
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;
|
|
1808
|
+
const effortSelector = { self: selfAID ?? effortSession?.selfAID ?? this.resolveSelfAID(channel) };
|
|
1899
1809
|
let modelConfig = {};
|
|
1900
1810
|
try {
|
|
1901
1811
|
modelConfig = (resolveEffective(effortSelector, { cache: true }).baseagents || {})[fallbackBaseagent] || {};
|
|
@@ -1903,9 +1813,12 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1903
1813
|
catch { }
|
|
1904
1814
|
const configuredModel = modelConfig.model;
|
|
1905
1815
|
const configuredEffort = modelConfig.effort;
|
|
1906
|
-
|
|
1816
|
+
if (!configuredModel) {
|
|
1817
|
+
return { kind: 'command.error', text: '⚠️ 当前 Agent 未配置模型,请 owner/admin 先用 /model 设置模型' };
|
|
1818
|
+
}
|
|
1819
|
+
const currentModel = configuredModel;
|
|
1907
1820
|
const efforts = await getAvailableEfforts(effortAgent, currentModel);
|
|
1908
|
-
const currentEffort = configuredEffort ??
|
|
1821
|
+
const currentEffort = configuredEffort ?? 'auto';
|
|
1909
1822
|
if (efforts.length === 0) {
|
|
1910
1823
|
return { kind: 'command.error', text: '⚠️ 当前模型不支持推理强度设置' };
|
|
1911
1824
|
}
|
|
@@ -1946,63 +1859,49 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1946
1859
|
const effortSession = await getExistingSessionForCommand();
|
|
1947
1860
|
const fallbackBaseagent = effortSession?.baseagent || this.agentRegistry?.resolveByChannel(channel)?.baseagent || this.parseDefaultBaseagent();
|
|
1948
1861
|
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;
|
|
1862
|
+
const effortSelf = selfAID ?? effortSession?.selfAID ?? this.resolveSelfAID(channel);
|
|
1961
1863
|
let modelConfig = {};
|
|
1962
1864
|
try {
|
|
1963
|
-
modelConfig = (resolveEffective(
|
|
1865
|
+
modelConfig = (resolveEffective({ self: effortSelf }, { cache: true }).baseagents || {})[fallbackBaseagent] || {};
|
|
1964
1866
|
}
|
|
1965
1867
|
catch { }
|
|
1966
1868
|
const configuredModel = modelConfig.model;
|
|
1967
|
-
|
|
1968
|
-
|
|
1869
|
+
if (!configuredModel) {
|
|
1870
|
+
return { kind: 'command.error', text: '⚠️ 当前 Agent 未配置模型,请 owner/admin 先用 /model 设置模型' };
|
|
1871
|
+
}
|
|
1872
|
+
const currentModel = configuredModel;
|
|
1969
1873
|
const efforts = await getAvailableEfforts(effortAgent, currentModel);
|
|
1970
|
-
const currentEffort = configuredEffort ?? effortAgent.getEffort?.() ?? 'auto';
|
|
1971
1874
|
if (efforts.length === 0) {
|
|
1972
1875
|
return { kind: 'command.error', text: '⚠️ 当前模型不支持推理强度设置' };
|
|
1973
1876
|
}
|
|
1974
|
-
//
|
|
1975
|
-
|
|
1877
|
+
// 模型参数只在 Agent 级:写操作按 agent scope 鉴权(owner/admin)。
|
|
1878
|
+
const effortAuthDenied = await authorizeIntent({
|
|
1879
|
+
intent: {
|
|
1880
|
+
operation: 'model.effort',
|
|
1881
|
+
scope: 'agent',
|
|
1882
|
+
source: 'slash',
|
|
1883
|
+
args: { self: effortSelf, effort: args },
|
|
1884
|
+
},
|
|
1885
|
+
identity,
|
|
1886
|
+
session: effortSession,
|
|
1887
|
+
explicitChatType: effortSession?.chatType,
|
|
1888
|
+
channel,
|
|
1889
|
+
channelId,
|
|
1890
|
+
userId,
|
|
1891
|
+
selfAid: effortSelf,
|
|
1892
|
+
isDaemonOwner,
|
|
1893
|
+
});
|
|
1894
|
+
if (effortAuthDenied)
|
|
1895
|
+
return effortAuthDenied;
|
|
1896
|
+
// /effort auto:清除 Agent 级 effort(恢复 SDK 默认)
|
|
1976
1897
|
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默认)' };
|
|
1898
|
+
try {
|
|
1899
|
+
writeAgentModelConfig(effortSelf, effortAgent.name, { effort: null });
|
|
1900
|
+
}
|
|
1901
|
+
catch (e) {
|
|
1902
|
+
return { kind: 'command.error', text: `Failed to clear Agent effort: ${e?.message || e}` };
|
|
1999
1903
|
}
|
|
2000
|
-
if (!isAdmin)
|
|
2001
|
-
return { kind: 'command.error', text: `Cannot locate relation scope: ${relationTarget.error}` };
|
|
2002
1904
|
effortAgent.setEffort?.(undefined);
|
|
2003
|
-
const err = this.persistBaseagentEffort(channel, effortAgent.name, undefined);
|
|
2004
|
-
if (err)
|
|
2005
|
-
return { kind: 'command.result', text: `${err}\n已更新运行时配置,但未持久化` };
|
|
2006
1905
|
this.eventBus.publish({
|
|
2007
1906
|
type: 'runner:model-changed',
|
|
2008
1907
|
sessionId: effortSession?.id,
|
|
@@ -2023,35 +1922,13 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2023
1922
|
return { kind: 'command.error', text: `❌ 无效参数: ${args}\n可选: ${efforts.join(' / ')} / auto` };
|
|
2024
1923
|
}
|
|
2025
1924
|
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}` };
|
|
1925
|
+
try {
|
|
1926
|
+
writeAgentModelConfig(effortSelf, effortAgent.name, { effort: newEffort });
|
|
1927
|
+
}
|
|
1928
|
+
catch (e) {
|
|
1929
|
+
return { kind: 'command.error', text: `Failed to update Agent effort: ${e?.message || e}` };
|
|
2048
1930
|
}
|
|
2049
|
-
if (!isAdmin)
|
|
2050
|
-
return { kind: 'command.error', text: `Cannot locate relation scope: ${relationTarget.error}` };
|
|
2051
1931
|
effortAgent.setEffort?.(newEffort);
|
|
2052
|
-
const err = this.persistBaseagentEffort(channel, effortAgent.name, newEffort);
|
|
2053
|
-
if (err)
|
|
2054
|
-
return { kind: 'command.result', text: `${err}\n已更新运行时配置,但未持久化` };
|
|
2055
1932
|
this.eventBus.publish({
|
|
2056
1933
|
type: 'runner:model-changed',
|
|
2057
1934
|
sessionId: effortSession?.id,
|
|
@@ -2636,6 +2513,9 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2636
2513
|
catch {
|
|
2637
2514
|
compactConfig = {};
|
|
2638
2515
|
}
|
|
2516
|
+
if (typeof compactConfig.model !== 'string' || !compactConfig.model.trim()) {
|
|
2517
|
+
return { kind: 'command.error', text: `⚠️ 当前 Agent 未配置模型(baseagents.${compactBaseagent}.model),无法压缩。请 owner/admin 先用 /model 设置模型。` };
|
|
2518
|
+
}
|
|
2639
2519
|
const compactModelDecision = constrainResolvedModelForRole({
|
|
2640
2520
|
role: session.identity?.role || identity.role,
|
|
2641
2521
|
baseagent: compactBaseagent,
|
|
@@ -3174,12 +3054,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3174
3054
|
}
|
|
3175
3055
|
// Archiving only changes list visibility; pending work must still be checked.
|
|
3176
3056
|
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
|
-
});
|
|
3057
|
+
const pendingResultCount = allSessions.reduce((count, session) => count + this.messageCache.getCount(session.id), 0);
|
|
3183
3058
|
const executeRestart = async () => {
|
|
3184
3059
|
const suppressRealRestart = shouldSuppressRealRestart();
|
|
3185
3060
|
let restartReplyContext = replyContext;
|
|
@@ -3347,26 +3222,20 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3347
3222
|
return true;
|
|
3348
3223
|
};
|
|
3349
3224
|
// 文本确认流程
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3225
|
+
const restartKey = `${channel}-${channelId}`;
|
|
3226
|
+
const controlDir = daemonControlDir();
|
|
3227
|
+
const restartConfirmFile = path.join(controlDir, `restart-confirm-${restartKey}.json`);
|
|
3228
|
+
if (fs.existsSync(restartConfirmFile)) {
|
|
3229
|
+
// 确认不设有效期;即使后台结果已读,下一次 /restart 也会消费确认。
|
|
3230
|
+
fs.unlinkSync(restartConfirmFile);
|
|
3231
|
+
}
|
|
3232
|
+
else if (pendingResultCount > 0) {
|
|
3353
3233
|
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
|
-
}
|
|
3234
|
+
fs.writeFileSync(restartConfirmFile, JSON.stringify({ timestamp: Date.now() }));
|
|
3235
|
+
return {
|
|
3236
|
+
kind: 'command.result',
|
|
3237
|
+
text: `当前Agent对话有 ${pendingResultCount} 条后台结果待查看。再次输入 /restart 将强制重启服务。`,
|
|
3238
|
+
};
|
|
3370
3239
|
}
|
|
3371
3240
|
const restarted = await executeRestart();
|
|
3372
3241
|
if (typeof restarted === 'object' && restarted.code === 'RESTART_ENTRY_MISSING') {
|
|
@@ -4149,6 +4018,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
4149
4018
|
isAdmin,
|
|
4150
4019
|
isOwnerSelf: isOwner && !!memoryOwnerAid && (authSubject.principalId ?? userId) === memoryOwnerAid,
|
|
4151
4020
|
ownerAid: memoryOwnerAid,
|
|
4021
|
+
actorAid: authSubject.principalId ?? userId,
|
|
4152
4022
|
memoryConfig: memoryAgent?.config?.memory,
|
|
4153
4023
|
channelType: authSubject.channelType,
|
|
4154
4024
|
peerId: activeChatType === 'group' ? channelId : (userId ?? channelId),
|