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
|
@@ -36,6 +36,8 @@ import { parseTimeArg, TIME_ARG_FORMATS, splitConfigBatchGetArgv } from '../../c
|
|
|
36
36
|
import { auditCommandAuthorization, auditFullAccessEvent, hashArgv } from '../auth/authorization-audit.js';
|
|
37
37
|
import { ResponseModeRegistry } from '../../response-system/registry.js';
|
|
38
38
|
import { registerBuiltinModes } from '../../response-system/modes/index.js';
|
|
39
|
+
import { executeResolvedRoleCommand, resolveRoleCommand } from '../../config/role-command-service.js';
|
|
40
|
+
import { applyApprovedRoleAssignment } from './role-menu.js';
|
|
39
41
|
import { executeResolvedContactCommand, resolveContactCommand } from '../../config/contact-operation-service.js';
|
|
40
42
|
import { hasTrustedFullAccessDelegation, trustedExecutionIdentityInput } from '../auth/agent-delegation.js';
|
|
41
43
|
import { executeManagedAidOperation, ManagedAidOperationError, managedAidShowViewForRole, resolveManagedAidOperation, } from '../../aun/aid/managed-operation.js';
|
|
@@ -56,45 +58,6 @@ import { resolveCurrentSessionLoopTarget, sessionLoopError } from '../session/se
|
|
|
56
58
|
export { isProcessLevelOwner } from './menu-handler.js';
|
|
57
59
|
const CLI_EXEC_TIMEOUT_MS = 15_000;
|
|
58
60
|
const CLI_EXEC_MAX_OUTPUT = 128 * 1024;
|
|
59
|
-
/**
|
|
60
|
-
* 写入用户级 ~/.claude/settings.json(与 Claude CLI 行为一致)
|
|
61
|
-
* ⚠️ 已禁用:按需求不再修改用户的 ~/.claude/settings.json 文件。
|
|
62
|
-
* 原会把 model/effortLevel 写入 settings.json(仅在找不到 owning agent 的 fallback 路径触发)。
|
|
63
|
-
* 现直接返回成功且不落盘;如需恢复,取消下方注释即可。
|
|
64
|
-
*/
|
|
65
|
-
function writeUserSettings(updates) {
|
|
66
|
-
void updates;
|
|
67
|
-
return { success: true };
|
|
68
|
-
/* eslint-disable no-unreachable */
|
|
69
|
-
// try {
|
|
70
|
-
// const settingsPath = path.join(os.homedir(), '.claude', 'settings.json');
|
|
71
|
-
// let settings: any = {};
|
|
72
|
-
//
|
|
73
|
-
// if (fs.existsSync(settingsPath)) {
|
|
74
|
-
// settings = JSON.parse(fs.readFileSync(settingsPath, 'utf-8'));
|
|
75
|
-
// }
|
|
76
|
-
//
|
|
77
|
-
// if (updates.model !== undefined) settings.model = updates.model;
|
|
78
|
-
// if (updates.effortLevel !== undefined) {
|
|
79
|
-
// if (updates.effortLevel === null) {
|
|
80
|
-
// delete settings.effortLevel;
|
|
81
|
-
// } else {
|
|
82
|
-
// settings.effortLevel = updates.effortLevel;
|
|
83
|
-
// }
|
|
84
|
-
// }
|
|
85
|
-
//
|
|
86
|
-
// const claudeDir = path.join(os.homedir(), '.claude');
|
|
87
|
-
// if (!fs.existsSync(claudeDir)) {
|
|
88
|
-
// fs.mkdirSync(claudeDir, { recursive: true });
|
|
89
|
-
// }
|
|
90
|
-
//
|
|
91
|
-
// fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2), 'utf-8');
|
|
92
|
-
// return { success: true };
|
|
93
|
-
// } catch (error: any) {
|
|
94
|
-
// return { success: false, error: error.message };
|
|
95
|
-
// }
|
|
96
|
-
/* eslint-enable no-unreachable */
|
|
97
|
-
}
|
|
98
61
|
function isAdminRole(role) {
|
|
99
62
|
return isManagementRole(role);
|
|
100
63
|
}
|
|
@@ -820,60 +783,6 @@ export class CommandHandler {
|
|
|
820
783
|
return owning.projectPath;
|
|
821
784
|
return process.cwd();
|
|
822
785
|
}
|
|
823
|
-
/**
|
|
824
|
-
* 持久化 baseagent.model:写到 agent config.json;找不到 owning agent 时
|
|
825
|
-
* 退到用户级 ~/.claude/settings.json(Claude 专用)。
|
|
826
|
-
*/
|
|
827
|
-
persistBaseagentModel(channel, baseagentName, newModel) {
|
|
828
|
-
const owning = this.getOwningAgent(channel);
|
|
829
|
-
if (owning) {
|
|
830
|
-
try {
|
|
831
|
-
owning.setBaseagentModel(newModel, baseagentName);
|
|
832
|
-
}
|
|
833
|
-
catch (e) {
|
|
834
|
-
return `⚠️ 写入 agent config 失败: ${e?.message || e}`;
|
|
835
|
-
}
|
|
836
|
-
return undefined;
|
|
837
|
-
}
|
|
838
|
-
// 无 owning agent(罕见,新结构下应当不会发生)→ 仅 Claude 走用户级 fallback
|
|
839
|
-
if (baseagentName !== 'claude') {
|
|
840
|
-
return `⚠️ 找不到通道 "${channel}" 所属的 self-agent`;
|
|
841
|
-
}
|
|
842
|
-
const updates = {};
|
|
843
|
-
if (newModel)
|
|
844
|
-
updates.model = newModel;
|
|
845
|
-
const writeResult = writeUserSettings(updates);
|
|
846
|
-
// writeUserSettings 已禁用写入,总是返回 success: true
|
|
847
|
-
if (!writeResult.success) {
|
|
848
|
-
return `⚠️ 写入用户配置失败: ${writeResult.error}`;
|
|
849
|
-
}
|
|
850
|
-
return undefined;
|
|
851
|
-
}
|
|
852
|
-
/**
|
|
853
|
-
* 持久化 baseagent.effort:写到 agent config.json;找不到时退到用户级 settings。
|
|
854
|
-
*/
|
|
855
|
-
persistBaseagentEffort(channel, baseagentName, newEffort) {
|
|
856
|
-
const owning = this.getOwningAgent(channel);
|
|
857
|
-
if (owning) {
|
|
858
|
-
try {
|
|
859
|
-
owning.setBaseagentEffort(newEffort, baseagentName);
|
|
860
|
-
}
|
|
861
|
-
catch (e) {
|
|
862
|
-
return `⚠️ 写入 agent config 失败: ${e?.message || e}`;
|
|
863
|
-
}
|
|
864
|
-
return undefined;
|
|
865
|
-
}
|
|
866
|
-
if (baseagentName !== 'claude') {
|
|
867
|
-
return `⚠️ 找不到通道 "${channel}" 所属的 self-agent`;
|
|
868
|
-
}
|
|
869
|
-
const updates = { effortLevel: newEffort ?? null };
|
|
870
|
-
const writeResult = writeUserSettings(updates);
|
|
871
|
-
// writeUserSettings 已禁用写入,总是返回 success: true
|
|
872
|
-
if (!writeResult.success) {
|
|
873
|
-
return `⚠️ 写入用户配置失败: ${writeResult.error}`;
|
|
874
|
-
}
|
|
875
|
-
return undefined;
|
|
876
|
-
}
|
|
877
786
|
/** 项目列表快捷访问(无 channel 上下文时的 fallback,尽量不用) */
|
|
878
787
|
get projects() {
|
|
879
788
|
return {};
|
|
@@ -2217,6 +2126,7 @@ export class CommandHandler {
|
|
|
2217
2126
|
const subject = buildAuthSubject({
|
|
2218
2127
|
selfAid: targetAid, actorId: grant.actorId, channel: grant.channel, channelType: grant.channelType,
|
|
2219
2128
|
channelId: conversationId, chatType: grant.chatType, conversationId,
|
|
2129
|
+
sessionId,
|
|
2220
2130
|
processOwners: ownerResolver.daemonOwners(),
|
|
2221
2131
|
});
|
|
2222
2132
|
if (targetAid !== grant.selfAid && !subject.isDaemonOwner) {
|
|
@@ -2246,6 +2156,39 @@ export class CommandHandler {
|
|
|
2246
2156
|
return ownershipFailure(error);
|
|
2247
2157
|
}
|
|
2248
2158
|
}
|
|
2159
|
+
/**
|
|
2160
|
+
* Agent-managed role-request CLI entrypoint. Submitting a request never
|
|
2161
|
+
* changes permissions; only the Agent owner can approve it, and approval is
|
|
2162
|
+
* what actually applies the relation role.
|
|
2163
|
+
*/
|
|
2164
|
+
async handleRoleOperation(argv, sessionId, delegationToken, delegationCommandHash) {
|
|
2165
|
+
if (!this.agentDelegationRegistry) {
|
|
2166
|
+
return { ok: false, code: 'DELEGATION_REQUIRED', error: 'Task delegation is not configured' };
|
|
2167
|
+
}
|
|
2168
|
+
const delegation = this.agentDelegationRegistry.validate(delegationToken, sessionId, delegationCommandHash);
|
|
2169
|
+
if (!delegation.ok)
|
|
2170
|
+
return { ok: false, code: delegation.code, error: delegation.reason };
|
|
2171
|
+
const session = await this.sessionManager.getSessionById(sessionId);
|
|
2172
|
+
if (!session)
|
|
2173
|
+
return { ok: false, code: 'INVALID_SESSION', error: 'Invalid session' };
|
|
2174
|
+
const grant = delegation.grant;
|
|
2175
|
+
const resolvedArgv = argv.includes('--self') ? argv : [...argv, '--self', grant.selfAid];
|
|
2176
|
+
const resolved = resolveRoleCommand(resolvedArgv);
|
|
2177
|
+
if (!resolved.ok)
|
|
2178
|
+
return { ok: false, code: resolved.code, error: resolved.reason };
|
|
2179
|
+
if (resolved.command.selfAid !== grant.selfAid) {
|
|
2180
|
+
return { ok: false, code: 'SCOPE_MISMATCH', error: 'Only the current Agent role requests can be targeted' };
|
|
2181
|
+
}
|
|
2182
|
+
try {
|
|
2183
|
+
const result = await executeResolvedRoleCommand(resolved.command, grant.actorId, applyApprovedRoleAssignment);
|
|
2184
|
+
if (!result.ok)
|
|
2185
|
+
return { ok: false, code: result.code, error: result.error, data: result.data };
|
|
2186
|
+
return { ok: true, result };
|
|
2187
|
+
}
|
|
2188
|
+
catch (error) {
|
|
2189
|
+
return { ok: false, code: 'ROLE_OPERATION_FAILED', error: error?.message ?? String(error) };
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2249
2192
|
async handleAidOperation(argv, sessionId, delegationToken, delegationCommandHash) {
|
|
2250
2193
|
if (!this.agentDelegationRegistry) {
|
|
2251
2194
|
return { ok: false, code: 'DELEGATION_REQUIRED', error: 'Task delegation is not configured' };
|
|
@@ -3267,6 +3210,13 @@ export class CommandHandler {
|
|
|
3267
3210
|
: 'read';
|
|
3268
3211
|
return intent(`ec.ctl.queue.${action}`);
|
|
3269
3212
|
}
|
|
3213
|
+
// 模型参数只在 Agent 级:写操作按 agent scope 鉴权(仅当前 Agent 的 owner/admin)。
|
|
3214
|
+
const agentIntent = (operation, extra = {}) => ({
|
|
3215
|
+
operation,
|
|
3216
|
+
scope: 'agent',
|
|
3217
|
+
source: 'agent-tool',
|
|
3218
|
+
args: { self: selfAid, ...extra },
|
|
3219
|
+
});
|
|
3270
3220
|
if (name === 'model') {
|
|
3271
3221
|
if (args.length === 0 || args[0] === 'list')
|
|
3272
3222
|
return intent('model.list');
|
|
@@ -3275,16 +3225,15 @@ export class CommandHandler {
|
|
|
3275
3225
|
if (args[0] === 'info')
|
|
3276
3226
|
return intent('model.info', { model: args[1] });
|
|
3277
3227
|
if (args[0] === 'reset')
|
|
3278
|
-
return
|
|
3279
|
-
if (args[0] === 'check')
|
|
3280
|
-
return
|
|
3281
|
-
}
|
|
3282
|
-
return intent('model.use', { model: args[0] });
|
|
3228
|
+
return agentIntent('model.reset');
|
|
3229
|
+
if (args[0] === 'check')
|
|
3230
|
+
return agentIntent('model.check');
|
|
3231
|
+
return agentIntent('model.use', { model: args[0] });
|
|
3283
3232
|
}
|
|
3284
3233
|
if (name === 'effort') {
|
|
3285
3234
|
return args.length === 0
|
|
3286
3235
|
? intent('model.effort.current')
|
|
3287
|
-
:
|
|
3236
|
+
: agentIntent('model.effort', { effort: args[0] });
|
|
3288
3237
|
}
|
|
3289
3238
|
if (name === 'restart') {
|
|
3290
3239
|
return { operation: 'system.restart', scope: 'process', source: 'agent-tool', args: { self: selfAid } };
|
|
@@ -101,7 +101,7 @@ async function handleOptions(self, args, context) {
|
|
|
101
101
|
{
|
|
102
102
|
option: 'access',
|
|
103
103
|
label: '访问设置',
|
|
104
|
-
description: '
|
|
104
|
+
description: '设置 Owner 名录与外部联系开关、指定 AID 名单、消息准入模式和准入控制消息限额',
|
|
105
105
|
},
|
|
106
106
|
],
|
|
107
107
|
});
|
|
@@ -266,6 +266,8 @@ async function handleAction(req, self, context) {
|
|
|
266
266
|
}
|
|
267
267
|
function isAccessUpdateResource(resource) {
|
|
268
268
|
return resource === 'policyMode'
|
|
269
|
+
|| resource === 'allowOwnerDirectoryContacts'
|
|
270
|
+
|| resource === 'allowOwnerAgentDirectory'
|
|
269
271
|
|| resource === 'allowExternalContacts'
|
|
270
272
|
|| resource === 'allowedAids'
|
|
271
273
|
|| resource === 'requestLimit';
|
|
@@ -284,9 +286,9 @@ function updateAccessResource(req, context, resource) {
|
|
|
284
286
|
return fail('INVALID_ARGUMENT', 'policyMode must be open, contacts, or owners');
|
|
285
287
|
}
|
|
286
288
|
}
|
|
287
|
-
else if (resource === 'allowExternalContacts') {
|
|
289
|
+
else if (resource === 'allowOwnerDirectoryContacts' || resource === 'allowOwnerAgentDirectory' || resource === 'allowExternalContacts') {
|
|
288
290
|
if (typeof decoded !== 'boolean') {
|
|
289
|
-
return fail('INVALID_ARGUMENT',
|
|
291
|
+
return fail('INVALID_ARGUMENT', `${resource} must be a JSON boolean`);
|
|
290
292
|
}
|
|
291
293
|
}
|
|
292
294
|
else if (resource === 'allowedAids') {
|
|
@@ -549,6 +551,12 @@ function accessPolicyWithUpdate(current, resource, decoded) {
|
|
|
549
551
|
if (resource === 'policyMode') {
|
|
550
552
|
return { ...current, policyMode: decoded };
|
|
551
553
|
}
|
|
554
|
+
if (resource === 'allowOwnerDirectoryContacts') {
|
|
555
|
+
return { ...current, allowOwnerDirectoryContacts: decoded };
|
|
556
|
+
}
|
|
557
|
+
if (resource === 'allowOwnerAgentDirectory') {
|
|
558
|
+
return { ...current, allowOwnerAgentDirectory: decoded };
|
|
559
|
+
}
|
|
552
560
|
if (resource === 'allowExternalContacts') {
|
|
553
561
|
return { ...current, allowExternalContacts: decoded };
|
|
554
562
|
}
|
|
@@ -2,10 +2,9 @@ import crypto from 'crypto';
|
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { isValidAid } from '../../aun/aid/validation.js';
|
|
5
|
-
import { isExplicitGroupId } from '../../aun/group/index.js';
|
|
6
5
|
import { isStaticAgentOwner } from '../../config/peer-role-resolver.js';
|
|
7
6
|
import { agentDir, agentRelationSharedDir } from '../../paths.js';
|
|
8
|
-
import { formatPeerKey } from '../relation/peer-identity.js';
|
|
7
|
+
import { formatPeerKey, readAunPeerKind } from '../relation/peer-identity.js';
|
|
9
8
|
export class DataRootError extends Error {
|
|
10
9
|
code;
|
|
11
10
|
data;
|
|
@@ -27,7 +26,8 @@ function isInside(root, candidate) {
|
|
|
27
26
|
}
|
|
28
27
|
function authenticatedPrincipal(subject) {
|
|
29
28
|
const principalId = String(subject.principalId ?? '').trim();
|
|
30
|
-
if (!isValidAid(principalId) ||
|
|
29
|
+
if (!isValidAid(principalId) || !subject.selfAid
|
|
30
|
+
|| readAunPeerKind(subject.selfAid, principalId, { routeKind: 'private' }).kind !== 'private') {
|
|
31
31
|
throw new DataRootError('ROOT_FORBIDDEN', 'A verified private AUN principal is required');
|
|
32
32
|
}
|
|
33
33
|
return principalId;
|
|
@@ -71,7 +71,8 @@ export class DataRootResolver {
|
|
|
71
71
|
throw new DataRootError('ROOT_FORBIDDEN', 'Only the Agent owner may select another relation');
|
|
72
72
|
}
|
|
73
73
|
const peerAid = explicitPeerAid || principalId;
|
|
74
|
-
|
|
74
|
+
const kind = readAunPeerKind(targetAid, peerAid, peerAid === principalId ? { routeKind: 'private' } : {});
|
|
75
|
+
if (!isValidAid(peerAid) || kind.kind !== 'private') {
|
|
75
76
|
throw new DataRootError('INVALID_ARGUMENT', 'args.peerAid must identify an AUN private-chat peer');
|
|
76
77
|
}
|
|
77
78
|
const peerKey = formatPeerKey('aun', peerAid);
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { CONSOLIDATION_MODES, MODE_SCOPE } from '../memory/consolidation-context.js';
|
|
11
11
|
import { formatQueueDetails } from '../memory/consolidation-queue-format.js';
|
|
12
|
+
import { FORGET_REASON_MAX_CHARS, normalizeForgetReason } from '../memory/forget-log.js';
|
|
12
13
|
import { MEMORY_SCOPES, isMemoryScope, memoryOverview, listMemoryFiles, formatMemoryFiles, readMemoryIndex, showMemoryFile, formatPendingNotes, showPendingNote, reindexScope, dropNote, archiveMemoryFile, restoreMemoryFile, } from '../memory/memory-admin.js';
|
|
13
14
|
const USAGE = [
|
|
14
15
|
'用法:',
|
|
@@ -19,8 +20,8 @@ const USAGE = [
|
|
|
19
20
|
' /memory index <scope> 查看 MEMORY.md 索引',
|
|
20
21
|
' /memory list <scope> [archived] 正式 / 已归档记忆列表',
|
|
21
22
|
' /memory show <scope> <slug> [archived] 查看单条记忆',
|
|
22
|
-
' /memory archive <scope> <slug> 归档记忆(可用 restore
|
|
23
|
-
' /memory restore <scope> <slug> 恢复已归档记忆',
|
|
23
|
+
' /memory archive <scope> <slug> [理由] 归档记忆(可用 restore 恢复),理由记入遗忘日志',
|
|
24
|
+
' /memory restore <scope> <slug> [理由] 恢复已归档记忆',
|
|
24
25
|
' /memory reindex <scope> 重建索引',
|
|
25
26
|
' /memory consolidate [mode] [scope] 拉起整理(mode: notes|generalize|promote|profile|forget;forget 需指定 scope)',
|
|
26
27
|
'scope: relation | agent | owner',
|
|
@@ -89,8 +90,8 @@ export function memoryHelpEntries(ctx) {
|
|
|
89
90
|
if (view.includes('relation'))
|
|
90
91
|
add('/memory note', '查看单条 note', '<slug>');
|
|
91
92
|
if (write.length > 0) {
|
|
92
|
-
add('/memory archive', '归档一条记忆', '<scope> <slug>');
|
|
93
|
-
add('/memory restore', '恢复已归档记忆', '<scope> <slug>');
|
|
93
|
+
add('/memory archive', '归档一条记忆', '<scope> <slug> [理由]');
|
|
94
|
+
add('/memory restore', '恢复已归档记忆', '<scope> <slug> [理由]');
|
|
94
95
|
if (write.includes('relation'))
|
|
95
96
|
add('/memory note drop', '撤销一条 note', '<slug>');
|
|
96
97
|
}
|
|
@@ -187,13 +188,20 @@ export async function handleMemorySlash(ctx) {
|
|
|
187
188
|
if (isPayload(scope))
|
|
188
189
|
return scope;
|
|
189
190
|
if (!args[2])
|
|
190
|
-
return error(`用法: /memory ${sub} <scope> <slug
|
|
191
|
+
return error(`用法: /memory ${sub} <scope> <slug> [理由]`);
|
|
192
|
+
// 理由可空(记「未注明理由」),给了就按遗忘理由的上限校验
|
|
193
|
+
const reason = normalizeForgetReason(args.slice(3).join(' '));
|
|
194
|
+
if ([...reason].length > FORGET_REASON_MAX_CHARS) {
|
|
195
|
+
return error(`理由不能超过 ${FORGET_REASON_MAX_CHARS} 字(当前 ${[...reason].length} 字)`);
|
|
196
|
+
}
|
|
197
|
+
const log = { reason, actorAid: ctx.actorAid };
|
|
191
198
|
if (sub === 'archive') {
|
|
192
|
-
await archiveMemoryFile(target, scope, args[2]);
|
|
199
|
+
await archiveMemoryFile(target, scope, args[2], log);
|
|
193
200
|
return result(`✅ 已归档 ${scope}/${args[2]},索引已重建\n恢复: /memory restore ${scope} ${args[2]}`);
|
|
194
201
|
}
|
|
195
|
-
await restoreMemoryFile(target, scope, args[2]);
|
|
196
|
-
|
|
202
|
+
const restored = await restoreMemoryFile(target, scope, args[2], log);
|
|
203
|
+
const from = restored.stamped ? `(取的是最新归档 ${restored.restoredFrom})` : '';
|
|
204
|
+
return result(`✅ 已恢复 ${scope}/${args[2]}${from},索引已重建`);
|
|
197
205
|
}
|
|
198
206
|
if (sub === 'reindex') {
|
|
199
207
|
const scope = needScope(args[1], true);
|
|
@@ -85,7 +85,7 @@ const ENTRIES = [
|
|
|
85
85
|
type: 'setting',
|
|
86
86
|
contexts: ['private_relation'],
|
|
87
87
|
name: 'session',
|
|
88
|
-
label: '
|
|
88
|
+
label: '当前会话 fullaccess',
|
|
89
89
|
section: 'relation_behavior',
|
|
90
90
|
order: 6,
|
|
91
91
|
query: { cmd: '/session', args: { view: 'fullaccess' }, operation: 'session.fullaccess.current', scope: 'relation' },
|
|
@@ -93,8 +93,7 @@ const ENTRIES = [
|
|
|
93
93
|
valueSchema: { type: 'boolean' },
|
|
94
94
|
control: 'toggle',
|
|
95
95
|
},
|
|
96
|
-
|
|
97
|
-
relation('effort.relation', 'effort', '推理强度', 20, '/effort', 'model.effort.current', { options: { cmd: '/effort', operation: 'model.effort.current', scope: 'relation', mode: 'dynamic', dependsOn: ['model.relation'] }, update: { cmd: '/effort', operation: 'model.effort', scope: 'relation' }, control: 'select' }),
|
|
96
|
+
// 模型与推理强度只在 Agent 级配置(见 model.agent / effort.agent),关系菜单不再提供。
|
|
98
97
|
relation('chatmode.relation', 'chatmode', '对话模式', 30, '/chatmode', 'chatmode.current', { options: { cmd: '/chatmode', operation: 'chatmode.current', scope: 'relation', mode: 'static', items: [{ value: 'interactive', label: '交互模式' }, { value: 'proactive', label: '主动模式' }] }, update: { cmd: '/chatmode', operation: 'chatmode.update', scope: 'relation' }, control: 'select' }),
|
|
99
98
|
relation('activity.relation', 'activity', '中间输出', 40, '/activity', 'activity.current', { options: { cmd: '/activity', operation: 'activity.current', scope: 'relation', mode: 'static', items: [{ value: 'all', label: '私聊显示' }, { value: 'text', label: '仅文字进展' }, { value: 'none', label: '全部静默' }] }, update: { cmd: '/activity', operation: 'activity.update', scope: 'relation' }, control: 'select' }),
|
|
100
99
|
{ id: 'task.activities', type: 'list', contexts: ['private_relation', 'group_relation'], name: 'task', label: '任务活动', section: 'relation_behavior', order: 45, query: { cmd: '/task', args: { view: 'activities' }, operation: 'task.activity.read', scope: 'relation', mode: 'dynamic' }, control: 'list' },
|
|
@@ -434,7 +433,7 @@ export async function getMenuCatalog(input) {
|
|
|
434
433
|
entries.push({ id: entry.id, type: entry.type, name: entry.name, label: entry.label, section: entry.section, order: entry.order, target: { scope: context.kind === 'agent' ? 'agent' : context.kind === 'process' ? 'process' : 'relation', ...(context.self ? { self: context.self } : {}), ...(context.peerKey ? { peerKey: context.peerKey } : {}) }, valueSchema: entry.valueSchema ?? { type: 'object' }, operations, wire: { name: entry.name, operations: { ...(wireBinding(entry.query, context) ? { query: wireBinding(entry.query, context) } : {}), ...(wireBinding(entry.options, context) ? { options: wireBinding(entry.options, context) } : {}), ...(wireBinding(entry.update, context) ? { update: wireBinding(entry.update, context) } : {}), ...(wireBinding(entry.action, context) ? { action: wireBinding(entry.action, context) } : {}) } }, ui: { control: entry.control ?? 'action' } });
|
|
435
434
|
if (entry.id === 'session.loop' || entry.id === 'session.fullaccess') {
|
|
436
435
|
const loopEntry = entries[entries.length - 1];
|
|
437
|
-
let target = { level: 'relation-main', scope: '
|
|
436
|
+
let target = { level: 'relation-main', scope: 'relation' };
|
|
438
437
|
if ((entry.id === 'session.loop' || entry.id === 'session.fullaccess') && input.resolveLoopTarget) {
|
|
439
438
|
try {
|
|
440
439
|
target = await input.resolveLoopTarget(context);
|
|
@@ -458,9 +457,9 @@ export async function getMenuCatalog(input) {
|
|
|
458
457
|
loopEntry.target = {
|
|
459
458
|
level: target.level,
|
|
460
459
|
sessionId: target.sessionId,
|
|
461
|
-
scope: target.level === 'topic-session' ? 'session' : '
|
|
460
|
+
scope: target.level === 'topic-session' ? 'session' : 'relation',
|
|
462
461
|
};
|
|
463
|
-
loopEntry.label = '
|
|
462
|
+
loopEntry.label = '当前会话 fullaccess';
|
|
464
463
|
loopEntry.ui = { control: entry.control };
|
|
465
464
|
}
|
|
466
465
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { memoryHelpEntries } from './memory-slash.js';
|
|
2
2
|
import { getBaseagentSnapshot, loadedBaseagentIds } from '../../agents/baseagent-availability.js';
|
|
3
|
-
import { normalizePeer,
|
|
3
|
+
import { normalizePeer, writeAgentModelConfig } from '../model/config-scope.js';
|
|
4
4
|
import { formatPeerKey } from '../relation/peer-identity.js';
|
|
5
5
|
import { modelMatches, getCatalog, getBaseagentCatalog, resolveCatalogModel, assertCatalogSelectable, CONFIGURABLE_EFFORTS, configurableEfforts } from '../model/model-catalog.js';
|
|
6
6
|
import { constrainResolvedModelForRole, filterModelsForRole, validateModelSelectionForRole } from '../model/model-permission.js';
|
|
@@ -28,7 +28,7 @@ import { read as cfgRead, resolveEffective, resolveEffectiveFieldWithSource, rou
|
|
|
28
28
|
import { execAgentAction, execAgentQuery, execAgentOptions, execAidAvatar, resolveProjectPath } from './agent-control.js';
|
|
29
29
|
import { readInitialization } from '../../cli/agent-create.js';
|
|
30
30
|
import { isValidAid } from '../../aun/aid/validation.js';
|
|
31
|
-
import { gatewayList, gatewayUpdate, gatewayDelete, gatewayTest, gatewayModels, gatewaySetPrice
|
|
31
|
+
import { gatewayList, gatewayUpdate, gatewayDelete, gatewayTest, gatewayModels, gatewaySetPrice } from '../../config/gateway-config.js';
|
|
32
32
|
import { displaySessionTitle } from '../session/session-title.js';
|
|
33
33
|
import { buildTranscriptTurns } from '../session/session-transcript.js';
|
|
34
34
|
import { buildForkHistorySnapshot, pageForkHistory } from '../session/session-manager.js';
|
|
@@ -44,7 +44,7 @@ import { isUnsupportedBaseagentConfigField } from '../../config/config-field-pol
|
|
|
44
44
|
import { splitConfigBatchGetArgv } from '../../cli/cli-argv.js';
|
|
45
45
|
import { chatmodeFieldForPeer, isPrivateChatmodeRoleLocked, resolveChatModeForField } from '../message/peer-mode.js';
|
|
46
46
|
import { PUBLIC_PERMISSION_MODES } from '../permission/mode.js';
|
|
47
|
-
import { isAgentFullAccessOwner, resolveRuntimePermissionMode, resolveRuntimeStringField, sessionFullAccessStatus, validateRuntimeStringFieldOverride, } from '../role/runtime-policy.js';
|
|
47
|
+
import { isAgentFullAccessOwner, resolveRuntimePermissionMode, resolveRuntimeStringField, sessionFullAccessStatus, updateRelationSessionFullAccess, validateRuntimeStringFieldOverride, } from '../role/runtime-policy.js';
|
|
48
48
|
import { isManagementRole } from '../../config/builtin-roles.js';
|
|
49
49
|
import { SYSTEM_CONTROL_CHANNEL } from '../system-channels.js';
|
|
50
50
|
import { logger } from '../../utils/logger.js';
|
|
@@ -735,11 +735,15 @@ function readMenuPermission(target) {
|
|
|
735
735
|
source: decision.decidedBy === 'role' ? 'role' : 'builtin',
|
|
736
736
|
};
|
|
737
737
|
}
|
|
738
|
+
/**
|
|
739
|
+
* 模型参数只在 Agent 级。旧客户端可能仍带 scope=relation 查询:读取结果与 Agent 级相同,
|
|
740
|
+
* 一律解析到 Agent 级;写入的鉴权固定为 agent scope(见 intent 映射)。
|
|
741
|
+
*/
|
|
738
742
|
function menuModelScope(args) {
|
|
739
|
-
const raw = menuStringArg(args, 'scope') ?? '
|
|
743
|
+
const raw = menuStringArg(args, 'scope') ?? 'agent';
|
|
740
744
|
if (raw === 'agent' || raw === 'relation')
|
|
741
|
-
return
|
|
742
|
-
return { error: `无效 scope: ${raw}
|
|
745
|
+
return 'agent';
|
|
746
|
+
return { error: `无效 scope: ${raw},模型参数只在 agent 级配置`, code: 'INVALID_SCOPE' };
|
|
743
747
|
}
|
|
744
748
|
function resolveMenuModelTarget(params) {
|
|
745
749
|
const scope = menuModelScope(params.args);
|
|
@@ -768,32 +772,10 @@ function resolveMenuModelTarget(params) {
|
|
|
768
772
|
?? this.parseDefaultBaseagent?.();
|
|
769
773
|
if (!baseagent)
|
|
770
774
|
return { error: '缺少 baseagent 参数', code: 'MISSING_BASEAGENT' };
|
|
771
|
-
|
|
772
|
-
if (scope === 'agent') {
|
|
773
|
-
return { scope, sel, role: params.role, baseagent, field: params.field, fieldPath: `baseagents.${baseagent}.${params.field}` };
|
|
774
|
-
}
|
|
775
|
-
const explicitPeer = menuStringArg(params.args, 'peer') ?? menuStringArg(params.args, 'peerKey');
|
|
776
|
-
let peerKey;
|
|
777
|
-
if (explicitPeer) {
|
|
778
|
-
const normalized = normalizeMenuPeer(explicitPeer);
|
|
779
|
-
if (typeof normalized !== 'string')
|
|
780
|
-
return normalized;
|
|
781
|
-
peerKey = normalized;
|
|
782
|
-
}
|
|
783
|
-
else {
|
|
784
|
-
const chatType = params.session?.chatType ?? params.explicitChatType ?? 'private';
|
|
785
|
-
const channelType = this.resolveChannelType?.(params.channel) ?? params.session?.channelType;
|
|
786
|
-
const peerKeyId = chatType === 'group'
|
|
787
|
-
? (params.session?.metadata?.groupId || params.channelId)
|
|
788
|
-
: (params.userId || params.session?.metadata?.peerId || params.channelId);
|
|
789
|
-
if (channelType && peerKeyId)
|
|
790
|
-
peerKey = formatPeerKey(channelType, peerKeyId);
|
|
791
|
-
}
|
|
792
|
-
if (!peerKey)
|
|
793
|
-
return { error: 'relation scope 需要 peer/peerKey,或可推导的当前对端', code: 'MISSING_PEER' };
|
|
794
|
-
return { scope, sel: { ...sel, peerKey }, role: params.role, baseagent, field: params.field, fieldPath: `baseagents.${baseagent}.${params.field}` };
|
|
775
|
+
return { scope, sel: { self }, role: params.role, baseagent, field: params.field, fieldPath: `baseagents.${baseagent}.${params.field}` };
|
|
795
776
|
}
|
|
796
|
-
|
|
777
|
+
/** 只读 Agent 级配置(含角色约束);未配置返回 null,不回落 runner 自带默认值。 */
|
|
778
|
+
function readMenuModel(target, _agent, _agentSessionId) {
|
|
797
779
|
try {
|
|
798
780
|
const fieldPath = menuModelConfigFieldPath(target);
|
|
799
781
|
const resolved = resolveEffectiveFieldWithSource(fieldPath, target.sel, { cache: true });
|
|
@@ -803,7 +785,7 @@ function readMenuModel(target, agent, agentSessionId) {
|
|
|
803
785
|
role: target.role,
|
|
804
786
|
baseagent: target.baseagent,
|
|
805
787
|
model: resolved.value,
|
|
806
|
-
resolveModelId: typeof
|
|
788
|
+
resolveModelId: typeof _agent?.resolveModelId === 'function' ? _agent.resolveModelId.bind(_agent) : undefined,
|
|
807
789
|
});
|
|
808
790
|
if (decision.model) {
|
|
809
791
|
return { value: decision.model, source: decision.constrained ? 'role' : toMenuSource(resolved.source) };
|
|
@@ -825,13 +807,7 @@ function readMenuModel(target, agent, agentSessionId) {
|
|
|
825
807
|
}
|
|
826
808
|
}
|
|
827
809
|
catch { }
|
|
828
|
-
|
|
829
|
-
? (typeof agent?.getModel === 'function' ? agent.getModel() : agent?.name)
|
|
830
|
-
: (typeof agent?.getEffort === 'function' ? agent.getEffort() : undefined);
|
|
831
|
-
return {
|
|
832
|
-
value: fallback ?? null,
|
|
833
|
-
source: fallback == null ? null : 'runner',
|
|
834
|
-
};
|
|
810
|
+
return { value: null, source: null };
|
|
835
811
|
}
|
|
836
812
|
function menuActivityScope(args) {
|
|
837
813
|
const raw = menuStringArg(args, 'scope') ?? 'relation';
|
|
@@ -895,10 +871,10 @@ function writeMenuActivity(target, value) {
|
|
|
895
871
|
}
|
|
896
872
|
function writeMenuModel(target, value) {
|
|
897
873
|
if (target.field === 'model') {
|
|
898
|
-
|
|
874
|
+
writeAgentModelConfig(target.sel.self, target.baseagent, { model: value });
|
|
899
875
|
}
|
|
900
876
|
else {
|
|
901
|
-
|
|
877
|
+
writeAgentModelConfig(target.sel.self, target.baseagent, { effort: value });
|
|
902
878
|
}
|
|
903
879
|
}
|
|
904
880
|
export function isProcessLevelOwner(peerId, owners) {
|
|
@@ -967,7 +943,9 @@ function buildMenuIntent(verb, cmdBase, args, action, value, fromControlChannel
|
|
|
967
943
|
source: 'menu',
|
|
968
944
|
args: { ...payload, ...(extra ?? {}) },
|
|
969
945
|
});
|
|
970
|
-
|
|
946
|
+
// 读取与写入都固定为 agent scope;客户端可能仍带 scope=relation,忽略它。
|
|
947
|
+
const modelScope = 'agent';
|
|
948
|
+
void args?.scope;
|
|
971
949
|
if (verb === 'query') {
|
|
972
950
|
if (cmdBase === '/baseagent-models')
|
|
973
951
|
return intent('baseagent.models.list', 'process');
|
|
@@ -1048,10 +1026,11 @@ function buildMenuIntent(verb, cmdBase, args, action, value, fromControlChannel
|
|
|
1048
1026
|
if (verb === 'update') {
|
|
1049
1027
|
if (cmdBase === '/baseagent')
|
|
1050
1028
|
return intent('agent.baseagent.update', 'agent', { baseagent: value });
|
|
1029
|
+
// 模型参数只在 Agent 级:写入一律按 agent scope 鉴权(仅 owner/admin)。
|
|
1051
1030
|
if (cmdBase === '/model')
|
|
1052
|
-
return intent('model.use',
|
|
1031
|
+
return intent('model.use', 'agent', { model: value });
|
|
1053
1032
|
if (cmdBase === '/effort')
|
|
1054
|
-
return intent('model.effort',
|
|
1033
|
+
return intent('model.effort', 'agent', { effort: value });
|
|
1055
1034
|
if (cmdBase === '/chatmode')
|
|
1056
1035
|
return intent('chatmode.update', args?.scope === 'agent' ? 'agent' : 'relation', { value });
|
|
1057
1036
|
if (cmdBase === '/mention')
|
|
@@ -1483,7 +1462,7 @@ export function getMenuItems(role, chatType = 'private', scope = 'agent', authSu
|
|
|
1483
1462
|
if (authSubject) {
|
|
1484
1463
|
const relationArgs = operationScope === 'relation'
|
|
1485
1464
|
? buildRelationIntentArgs({ selfAid: authSubject.selfAid, peerKey: authSubject.peerKey })
|
|
1486
|
-
: {};
|
|
1465
|
+
: operationScope === 'agent' && authSubject.selfAid ? { self: authSubject.selfAid } : {};
|
|
1487
1466
|
return authorizeOperation({
|
|
1488
1467
|
source: 'menu',
|
|
1489
1468
|
intent: { operation, scope: operationScope, source: 'menu', args: relationArgs },
|
|
@@ -1500,8 +1479,9 @@ export function getMenuItems(role, chatType = 'private', scope = 'agent', authSu
|
|
|
1500
1479
|
}).allow;
|
|
1501
1480
|
};
|
|
1502
1481
|
const canReadModel = canOperation('model.list', 'relation') || canOperation('model.current', 'relation');
|
|
1503
|
-
|
|
1504
|
-
const
|
|
1482
|
+
// 模型参数只在 Agent 级:切换与调强度都是 Agent 级写操作,仅 owner/admin。
|
|
1483
|
+
const canUseModel = canOperation('model.use', 'agent');
|
|
1484
|
+
const canSetEffort = canOperation('model.effort', 'agent');
|
|
1505
1485
|
const canSetChatmode = canOperation('chatmode.update', 'relation');
|
|
1506
1486
|
const canSetMentionmode = normalizedChatType === 'group' && canOperation('mentionmode.update', 'relation');
|
|
1507
1487
|
const canReadPermission = canOperation('permission.current', 'relation');
|
|
@@ -1970,7 +1950,7 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
1970
1950
|
const rawModels = catalog.models.map(m => m.id);
|
|
1971
1951
|
const models = filterModelsForRole(optionsIdentity.role, target.baseagent, rawModels, model => resolveCatalogModel(catalog, model), target.sel.self);
|
|
1972
1952
|
const requestedModel = menuStringArg(args, 'model') ?? menuStringArg(args, 'current');
|
|
1973
|
-
const currentModel = requestedModel || readMenuModel(target, agent, session?.agentSessionId).value ||
|
|
1953
|
+
const currentModel = requestedModel || readMenuModel(target, agent, session?.agentSessionId).value || '';
|
|
1974
1954
|
if (models.length > 0)
|
|
1975
1955
|
return models.map((m) => ({ value: m, label: modelDisplayLabel(agent, m) + (catalog.models.find(e => e.id === m)?.verification === 'unverified' ? ' [unverified]' : ''), selected: modelMatches(agent, m, currentModel) }));
|
|
1976
1956
|
}
|
|
@@ -2037,7 +2017,10 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
2037
2017
|
}
|
|
2038
2018
|
const requestedModel = menuStringArg(args, 'model') ?? menuStringArg(args, 'currentModel');
|
|
2039
2019
|
const modelTarget = { ...target, field: 'model', fieldPath: `baseagents.${target.baseagent}.model` };
|
|
2040
|
-
const currentModel = requestedModel ||
|
|
2020
|
+
const currentModel = requestedModel || readMenuModel(modelTarget, agent, session?.agentSessionId).value;
|
|
2021
|
+
// Agent 级没有模型时没有可选的推理强度。
|
|
2022
|
+
if (!currentModel)
|
|
2023
|
+
return [];
|
|
2041
2024
|
const efforts = await getAvailableEfforts(agent, currentModel);
|
|
2042
2025
|
const currentEffort = menuStringArg(args, 'effort') ?? menuStringArg(args, 'current') ?? readMenuModel(target, agent, session?.agentSessionId).value ?? 'auto';
|
|
2043
2026
|
const allItems = [...efforts, 'auto'];
|
|
@@ -2164,7 +2147,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2164
2147
|
return { error: '/fa 需要同一身份同时具备 Agent Owner 和 daemon Owner 权限', code: 'FORBIDDEN' };
|
|
2165
2148
|
}
|
|
2166
2149
|
const status = sessionFullAccessStatus(session, principalId);
|
|
2167
|
-
return { data: { ...status, sessionId: session.id
|
|
2150
|
+
return { data: { ...status, sessionId: session.id } };
|
|
2168
2151
|
}
|
|
2169
2152
|
const storageRequest = { type: 'menu.query', cmd, args };
|
|
2170
2153
|
if (isAgentStorageMenuRequest(storageRequest)) {
|
|
@@ -3063,15 +3046,18 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3063
3046
|
return { error: '/fa 需要私聊中同一身份同时具备 Agent Owner 和 daemon Owner 权限', code: 'FORBIDDEN' };
|
|
3064
3047
|
}
|
|
3065
3048
|
try {
|
|
3049
|
+
const status = sessionFullAccessStatus(session, principalId);
|
|
3050
|
+
if (status.globalEnabled) {
|
|
3051
|
+
return { data: { ...status, sessionId: session.id, ignored: true,
|
|
3052
|
+
message: 'Agent 全局 fullaccess 已开启,局部设置未修改。' } };
|
|
3053
|
+
}
|
|
3066
3054
|
if (isTopicSession(session)) {
|
|
3067
|
-
this.sessionManager.updateSessionFullAccess(session.id, {
|
|
3055
|
+
session = this.sessionManager.updateSessionFullAccess(session.id, {
|
|
3056
|
+
enabled: value, authorizedBy: principalId,
|
|
3057
|
+
});
|
|
3068
3058
|
}
|
|
3069
3059
|
else {
|
|
3070
|
-
|
|
3071
|
-
if (!config)
|
|
3072
|
-
return { error: '找不到当前 Agent 配置', code: 'NOT_FOUND' };
|
|
3073
|
-
config.fullaccess = { enabled: value };
|
|
3074
|
-
cfgWrite(ConfigTarget.Agent, config, { self: subject.selfAid });
|
|
3060
|
+
updateRelationSessionFullAccess(session, { enabled: value, authorizedBy: principalId });
|
|
3075
3061
|
}
|
|
3076
3062
|
auditFullAccessEvent({
|
|
3077
3063
|
event: value ? 'fullaccess.session-policy.configured' : 'fullaccess.session-policy.deescalated',
|
|
@@ -3081,9 +3067,9 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3081
3067
|
agentAid: subject.selfAid,
|
|
3082
3068
|
sessionId: session.id,
|
|
3083
3069
|
authorizedBy: principalId,
|
|
3084
|
-
reason: isTopicSession(session) ? 'topic session fullaccess updated via Menu' : '
|
|
3070
|
+
reason: isTopicSession(session) ? 'topic session fullaccess updated via Menu' : 'relation main-session fullaccess updated via Menu',
|
|
3085
3071
|
});
|
|
3086
|
-
return { data: {
|
|
3072
|
+
return { data: { ...sessionFullAccessStatus(session, principalId), sessionId: session.id } };
|
|
3087
3073
|
}
|
|
3088
3074
|
catch (error) {
|
|
3089
3075
|
return menuResultFailure(error);
|
|
@@ -3322,7 +3308,10 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3322
3308
|
return target;
|
|
3323
3309
|
const agent = this.getAgent(channel, target.baseagent);
|
|
3324
3310
|
const modelTarget = { ...target, field: 'model', fieldPath: `baseagents.${target.baseagent}.model` };
|
|
3325
|
-
const currentModel =
|
|
3311
|
+
const currentModel = readMenuModel(modelTarget, agent, session?.agentSessionId).value;
|
|
3312
|
+
if (!currentModel) {
|
|
3313
|
+
return { error: '当前 Agent 未配置模型,请先设置模型', code: 'MODEL_NOT_CONFIGURED' };
|
|
3314
|
+
}
|
|
3326
3315
|
const validEfforts = await getAvailableEfforts(agent, currentModel);
|
|
3327
3316
|
const allValid = [...validEfforts, 'auto'];
|
|
3328
3317
|
if (!allValid.includes(arg)) {
|
|
@@ -3608,7 +3597,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
3608
3597
|
if (authDenied)
|
|
3609
3598
|
return authDenied;
|
|
3610
3599
|
// ── /gateway action(进程级,gate 已确保 fromControlChannel) ──
|
|
3611
|
-
// test=连通性测试;delete=删除配置;models=模型+价格;set-price
|
|
3600
|
+
// test=连通性测试;delete=删除配置;models=模型+价格;set-price=改网关价格。
|
|
3612
3601
|
if (cmdBase === '/gateway') {
|
|
3613
3602
|
if (action === 'test')
|
|
3614
3603
|
return await gatewayTest(args);
|
|
@@ -3618,8 +3607,6 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
3618
3607
|
return await gatewayModels(args);
|
|
3619
3608
|
if (action === 'set-price')
|
|
3620
3609
|
return gatewaySetPrice(args);
|
|
3621
|
-
if (action === 'sync-env')
|
|
3622
|
-
return await gatewaySyncEnv(args);
|
|
3623
3610
|
return { error: `不支持 gateway action: ${action}`, code: 'NOT_SUPPORTED' };
|
|
3624
3611
|
}
|
|
3625
3612
|
const isMenuAdmin = isManagementRole(authIdentity.role);
|