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
|
@@ -67,6 +67,11 @@ const relation = (id, name, label, order, cmd, operation, extra) => ({
|
|
|
67
67
|
...extra,
|
|
68
68
|
});
|
|
69
69
|
const ENTRIES = [
|
|
70
|
+
{ id: 'provider.list', type: 'list', contexts: ['process'], name: 'provider', label: 'Provider 注册表', section: 'process', order: 80, query: { cmd: '/provider', args: { scope: 'process', view: 'list' }, operation: 'provider.list', scope: 'process' }, control: 'list' },
|
|
71
|
+
{ id: 'provider.create', type: 'action', contexts: ['process'], name: 'provider', label: '创建 Provider', section: 'process', order: 81, action: { cmd: '/provider', action: 'create', args: { scope: 'process' }, operation: 'provider.create', scope: 'process' } },
|
|
72
|
+
{ id: 'provider.import', type: 'action', contexts: ['process'], name: 'provider', label: '导入 Provider JSON', section: 'process', order: 82, action: { cmd: '/provider', action: 'import', args: { scope: 'process' }, operation: 'provider.import', scope: 'process' } },
|
|
73
|
+
{ id: 'provider.update', type: 'setting', contexts: ['process'], name: 'provider', label: '更新 Provider', section: 'process', order: 83, update: { cmd: '/provider', args: { scope: 'process', resource: 'provider' }, operation: 'provider.update', scope: 'process' }, valueSchema: { type: 'string' }, control: 'json' },
|
|
74
|
+
{ id: 'provider.delete', type: 'action', contexts: ['process'], name: 'provider', label: '删除 Provider', section: 'process', order: 84, action: { cmd: '/provider', action: 'delete', args: { scope: 'process' }, operation: 'provider.delete', scope: 'process' } },
|
|
70
75
|
{
|
|
71
76
|
id: 'session.loop',
|
|
72
77
|
type: 'setting',
|
|
@@ -85,7 +90,7 @@ const ENTRIES = [
|
|
|
85
90
|
type: 'setting',
|
|
86
91
|
contexts: ['private_relation'],
|
|
87
92
|
name: 'session',
|
|
88
|
-
label: '
|
|
93
|
+
label: '当前会话 fullaccess',
|
|
89
94
|
section: 'relation_behavior',
|
|
90
95
|
order: 6,
|
|
91
96
|
query: { cmd: '/session', args: { view: 'fullaccess' }, operation: 'session.fullaccess.current', scope: 'relation' },
|
|
@@ -93,8 +98,7 @@ const ENTRIES = [
|
|
|
93
98
|
valueSchema: { type: 'boolean' },
|
|
94
99
|
control: 'toggle',
|
|
95
100
|
},
|
|
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' }),
|
|
101
|
+
// 模型与推理强度只在 Agent 级配置(见 model.agent / effort.agent),关系菜单不再提供。
|
|
98
102
|
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
103
|
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
104
|
{ 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 +438,7 @@ export async function getMenuCatalog(input) {
|
|
|
434
438
|
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
439
|
if (entry.id === 'session.loop' || entry.id === 'session.fullaccess') {
|
|
436
440
|
const loopEntry = entries[entries.length - 1];
|
|
437
|
-
let target = { level: 'relation-main', scope: '
|
|
441
|
+
let target = { level: 'relation-main', scope: 'relation' };
|
|
438
442
|
if ((entry.id === 'session.loop' || entry.id === 'session.fullaccess') && input.resolveLoopTarget) {
|
|
439
443
|
try {
|
|
440
444
|
target = await input.resolveLoopTarget(context);
|
|
@@ -458,9 +462,9 @@ export async function getMenuCatalog(input) {
|
|
|
458
462
|
loopEntry.target = {
|
|
459
463
|
level: target.level,
|
|
460
464
|
sessionId: target.sessionId,
|
|
461
|
-
scope: target.level === 'topic-session' ? 'session' : '
|
|
465
|
+
scope: target.level === 'topic-session' ? 'session' : 'relation',
|
|
462
466
|
};
|
|
463
|
-
loopEntry.label = '
|
|
467
|
+
loopEntry.label = '当前会话 fullaccess';
|
|
464
468
|
loopEntry.ui = { control: entry.control };
|
|
465
469
|
}
|
|
466
470
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { memoryHelpEntries } from './memory-slash.js';
|
|
2
|
+
import { executeProviderMenu } from './provider-menu.js';
|
|
2
3
|
import { getBaseagentSnapshot, loadedBaseagentIds } from '../../agents/baseagent-availability.js';
|
|
3
|
-
import { normalizePeer,
|
|
4
|
+
import { normalizePeer, writeAgentModelConfig } from '../model/config-scope.js';
|
|
4
5
|
import { formatPeerKey } from '../relation/peer-identity.js';
|
|
5
6
|
import { modelMatches, getCatalog, getBaseagentCatalog, resolveCatalogModel, assertCatalogSelectable, CONFIGURABLE_EFFORTS, configurableEfforts } from '../model/model-catalog.js';
|
|
6
7
|
import { constrainResolvedModelForRole, filterModelsForRole, validateModelSelectionForRole } from '../model/model-permission.js';
|
|
@@ -25,10 +26,10 @@ import { scanInstances } from '../../utils/instance-registry.js';
|
|
|
25
26
|
import { loadDefaults, loadDaemonConfig } from '../../config-store.js';
|
|
26
27
|
import { WEB_PACKAGE_NAME, RESTART_REQUEST_ID_ENV, RUNTIME_HOME_ENV, SESSION_ID_ENV } from '../../product.js';
|
|
27
28
|
import { read as cfgRead, resolveEffective, resolveEffectiveFieldWithSource, routeFieldPath, write as cfgWrite, ConfigTarget, } from '../../config/config-manager.js';
|
|
28
|
-
import { execAgentAction, execAgentQuery, execAgentOptions, execAidAvatar, resolveProjectPath } from './agent-control.js';
|
|
29
|
+
import { agentCreateCapabilities, execAgentAction, execAgentQuery, execAgentOptions, execAidAvatar, resolveProjectPath } from './agent-control.js';
|
|
29
30
|
import { readInitialization } from '../../cli/agent-create.js';
|
|
30
31
|
import { isValidAid } from '../../aun/aid/validation.js';
|
|
31
|
-
import { gatewayList, gatewayUpdate, gatewayDelete, gatewayTest, gatewayModels, gatewaySetPrice
|
|
32
|
+
import { gatewayList, gatewayUpdate, gatewayDelete, gatewayTest, gatewayModels, gatewaySetPrice } from '../../config/gateway-config.js';
|
|
32
33
|
import { displaySessionTitle } from '../session/session-title.js';
|
|
33
34
|
import { buildTranscriptTurns } from '../session/session-transcript.js';
|
|
34
35
|
import { buildForkHistorySnapshot, pageForkHistory } from '../session/session-manager.js';
|
|
@@ -44,7 +45,7 @@ import { isUnsupportedBaseagentConfigField } from '../../config/config-field-pol
|
|
|
44
45
|
import { splitConfigBatchGetArgv } from '../../cli/cli-argv.js';
|
|
45
46
|
import { chatmodeFieldForPeer, isPrivateChatmodeRoleLocked, resolveChatModeForField } from '../message/peer-mode.js';
|
|
46
47
|
import { PUBLIC_PERMISSION_MODES } from '../permission/mode.js';
|
|
47
|
-
import { isAgentFullAccessOwner, resolveRuntimePermissionMode, resolveRuntimeStringField, sessionFullAccessStatus, validateRuntimeStringFieldOverride, } from '../role/runtime-policy.js';
|
|
48
|
+
import { isAgentFullAccessOwner, resolveRuntimePermissionMode, resolveRuntimeStringField, sessionFullAccessStatus, updateRelationSessionFullAccess, validateRuntimeStringFieldOverride, } from '../role/runtime-policy.js';
|
|
48
49
|
import { isManagementRole } from '../../config/builtin-roles.js';
|
|
49
50
|
import { SYSTEM_CONTROL_CHANNEL } from '../system-channels.js';
|
|
50
51
|
import { logger } from '../../utils/logger.js';
|
|
@@ -735,11 +736,12 @@ function readMenuPermission(target) {
|
|
|
735
736
|
source: decision.decidedBy === 'role' ? 'role' : 'builtin',
|
|
736
737
|
};
|
|
737
738
|
}
|
|
739
|
+
/** Model and effort menus are valid only in Agent settings. */
|
|
738
740
|
function menuModelScope(args) {
|
|
739
|
-
const raw = menuStringArg(args, 'scope') ?? '
|
|
741
|
+
const raw = menuStringArg(args, 'scope') ?? 'agent';
|
|
740
742
|
if (raw === 'agent' || raw === 'relation')
|
|
741
|
-
return
|
|
742
|
-
return { error: `无效 scope: ${raw}
|
|
743
|
+
return 'agent';
|
|
744
|
+
return { error: `无效 scope: ${raw},模型参数只在 agent 级配置`, code: 'INVALID_SCOPE' };
|
|
743
745
|
}
|
|
744
746
|
function resolveMenuModelTarget(params) {
|
|
745
747
|
const scope = menuModelScope(params.args);
|
|
@@ -768,32 +770,10 @@ function resolveMenuModelTarget(params) {
|
|
|
768
770
|
?? this.parseDefaultBaseagent?.();
|
|
769
771
|
if (!baseagent)
|
|
770
772
|
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}` };
|
|
773
|
+
return { scope, sel: { self }, role: params.role, baseagent, field: params.field, fieldPath: `baseagents.${baseagent}.${params.field}` };
|
|
795
774
|
}
|
|
796
|
-
|
|
775
|
+
/** 只读 Agent 级配置(含角色约束);未配置返回 null,不回落 runner 自带默认值。 */
|
|
776
|
+
function readMenuModel(target, _agent, _agentSessionId) {
|
|
797
777
|
try {
|
|
798
778
|
const fieldPath = menuModelConfigFieldPath(target);
|
|
799
779
|
const resolved = resolveEffectiveFieldWithSource(fieldPath, target.sel, { cache: true });
|
|
@@ -803,7 +783,7 @@ function readMenuModel(target, agent, agentSessionId) {
|
|
|
803
783
|
role: target.role,
|
|
804
784
|
baseagent: target.baseagent,
|
|
805
785
|
model: resolved.value,
|
|
806
|
-
resolveModelId: typeof
|
|
786
|
+
resolveModelId: typeof _agent?.resolveModelId === 'function' ? _agent.resolveModelId.bind(_agent) : undefined,
|
|
807
787
|
});
|
|
808
788
|
if (decision.model) {
|
|
809
789
|
return { value: decision.model, source: decision.constrained ? 'role' : toMenuSource(resolved.source) };
|
|
@@ -825,13 +805,7 @@ function readMenuModel(target, agent, agentSessionId) {
|
|
|
825
805
|
}
|
|
826
806
|
}
|
|
827
807
|
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
|
-
};
|
|
808
|
+
return { value: null, source: null };
|
|
835
809
|
}
|
|
836
810
|
function menuActivityScope(args) {
|
|
837
811
|
const raw = menuStringArg(args, 'scope') ?? 'relation';
|
|
@@ -895,10 +869,10 @@ function writeMenuActivity(target, value) {
|
|
|
895
869
|
}
|
|
896
870
|
function writeMenuModel(target, value) {
|
|
897
871
|
if (target.field === 'model') {
|
|
898
|
-
|
|
872
|
+
writeAgentModelConfig(target.sel.self, target.baseagent, { model: value });
|
|
899
873
|
}
|
|
900
874
|
else {
|
|
901
|
-
|
|
875
|
+
writeAgentModelConfig(target.sel.self, target.baseagent, { effort: value });
|
|
902
876
|
}
|
|
903
877
|
}
|
|
904
878
|
export function isProcessLevelOwner(peerId, owners) {
|
|
@@ -915,6 +889,8 @@ export const SELF_MANAGE_AGENT_ACTIONS = new Set(['update', 'reload']);
|
|
|
915
889
|
/** 判断 (cmdBase, action) 是否为进程级操作(仅控制 channel 可执行)。
|
|
916
890
|
* /system 全部进程级;/agent 仅 create/delete/enable/disable 进程级;其余关系级。 */
|
|
917
891
|
export function isProcessLevelAction(cmdBase, action) {
|
|
892
|
+
if (cmdBase === '/provider')
|
|
893
|
+
return true;
|
|
918
894
|
if (cmdBase === '/baseagent-models')
|
|
919
895
|
return true;
|
|
920
896
|
if (cmdBase === '/system')
|
|
@@ -967,7 +943,10 @@ function buildMenuIntent(verb, cmdBase, args, action, value, fromControlChannel
|
|
|
967
943
|
source: 'menu',
|
|
968
944
|
args: { ...payload, ...(extra ?? {}) },
|
|
969
945
|
});
|
|
970
|
-
|
|
946
|
+
// Legacy relation-menu requests must not be silently promoted into Agent reads.
|
|
947
|
+
const modelScope = verb === 'update'
|
|
948
|
+
? 'agent'
|
|
949
|
+
: args?.scope === 'relation' ? 'relation' : 'agent';
|
|
971
950
|
if (verb === 'query') {
|
|
972
951
|
if (cmdBase === '/baseagent-models')
|
|
973
952
|
return intent('baseagent.models.list', 'process');
|
|
@@ -1048,10 +1027,11 @@ function buildMenuIntent(verb, cmdBase, args, action, value, fromControlChannel
|
|
|
1048
1027
|
if (verb === 'update') {
|
|
1049
1028
|
if (cmdBase === '/baseagent')
|
|
1050
1029
|
return intent('agent.baseagent.update', 'agent', { baseagent: value });
|
|
1030
|
+
// 模型参数只在 Agent 级:写入一律按 agent scope 鉴权(仅 owner/admin)。
|
|
1051
1031
|
if (cmdBase === '/model')
|
|
1052
|
-
return intent('model.use',
|
|
1032
|
+
return intent('model.use', 'agent', { model: value });
|
|
1053
1033
|
if (cmdBase === '/effort')
|
|
1054
|
-
return intent('model.effort',
|
|
1034
|
+
return intent('model.effort', 'agent', { effort: value });
|
|
1055
1035
|
if (cmdBase === '/chatmode')
|
|
1056
1036
|
return intent('chatmode.update', args?.scope === 'agent' ? 'agent' : 'relation', { value });
|
|
1057
1037
|
if (cmdBase === '/mention')
|
|
@@ -1110,8 +1090,6 @@ function buildMenuIntent(verb, cmdBase, args, action, value, fromControlChannel
|
|
|
1110
1090
|
if (cmdBase === '/trigger') {
|
|
1111
1091
|
if (action === 'create' || action === 'set')
|
|
1112
1092
|
return intent('trigger.create', 'relation', { action });
|
|
1113
|
-
if (action === 'show')
|
|
1114
|
-
return intent('trigger.show', 'relation', { action });
|
|
1115
1093
|
if (action === 'history')
|
|
1116
1094
|
return intent('trigger.history', 'relation', { action });
|
|
1117
1095
|
if (action === 'enable' || action === 'disable')
|
|
@@ -1483,7 +1461,7 @@ export function getMenuItems(role, chatType = 'private', scope = 'agent', authSu
|
|
|
1483
1461
|
if (authSubject) {
|
|
1484
1462
|
const relationArgs = operationScope === 'relation'
|
|
1485
1463
|
? buildRelationIntentArgs({ selfAid: authSubject.selfAid, peerKey: authSubject.peerKey })
|
|
1486
|
-
: {};
|
|
1464
|
+
: operationScope === 'agent' && authSubject.selfAid ? { self: authSubject.selfAid } : {};
|
|
1487
1465
|
return authorizeOperation({
|
|
1488
1466
|
source: 'menu',
|
|
1489
1467
|
intent: { operation, scope: operationScope, source: 'menu', args: relationArgs },
|
|
@@ -1500,8 +1478,9 @@ export function getMenuItems(role, chatType = 'private', scope = 'agent', authSu
|
|
|
1500
1478
|
}).allow;
|
|
1501
1479
|
};
|
|
1502
1480
|
const canReadModel = canOperation('model.list', 'relation') || canOperation('model.current', 'relation');
|
|
1503
|
-
|
|
1504
|
-
const
|
|
1481
|
+
// 模型参数只在 Agent 级:切换与调强度都是 Agent 级写操作,仅 owner/admin。
|
|
1482
|
+
const canUseModel = canOperation('model.use', 'agent');
|
|
1483
|
+
const canSetEffort = canOperation('model.effort', 'agent');
|
|
1505
1484
|
const canSetChatmode = canOperation('chatmode.update', 'relation');
|
|
1506
1485
|
const canSetMentionmode = normalizedChatType === 'group' && canOperation('mentionmode.update', 'relation');
|
|
1507
1486
|
const canReadPermission = canOperation('permission.current', 'relation');
|
|
@@ -1774,6 +1753,12 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
1774
1753
|
lifecycle: ag.lifecycle ?? null,
|
|
1775
1754
|
baseagent: ag.baseagent ?? null,
|
|
1776
1755
|
projectPath: ag.projectPath ?? null,
|
|
1756
|
+
...(ag.mode === 'one_shot' ? {
|
|
1757
|
+
mode: ag.mode,
|
|
1758
|
+
initialization: ag.initialization,
|
|
1759
|
+
createProgress: ag.createProgress,
|
|
1760
|
+
ownership: ag.ownership,
|
|
1761
|
+
} : {}),
|
|
1777
1762
|
}));
|
|
1778
1763
|
}
|
|
1779
1764
|
// agent channel:直接读取自身,避免先枚举全部 Agent 再过滤。
|
|
@@ -1793,6 +1778,12 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
1793
1778
|
lifecycle: ag.lifecycle ?? null,
|
|
1794
1779
|
baseagent: ag.baseagent ?? null,
|
|
1795
1780
|
projectPath: ag.projectPath ?? null,
|
|
1781
|
+
...(ag.mode === 'one_shot' ? {
|
|
1782
|
+
mode: ag.mode,
|
|
1783
|
+
initialization: ag.initialization,
|
|
1784
|
+
createProgress: ag.createProgress,
|
|
1785
|
+
ownership: ag.ownership,
|
|
1786
|
+
} : {}),
|
|
1796
1787
|
}];
|
|
1797
1788
|
}
|
|
1798
1789
|
if (cmd === '/capability') {
|
|
@@ -1887,9 +1878,10 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
1887
1878
|
throw { code: 'INVALID_ARGS', message: error.message };
|
|
1888
1879
|
}
|
|
1889
1880
|
}
|
|
1881
|
+
const metadataOnly = args?.metadataOnly === true;
|
|
1890
1882
|
return sessions
|
|
1891
1883
|
.filter((s) => isTopicSession(s) && (!hasLabel || s.label === label) && (!topicStatus || s.topicStatus === topicStatus))
|
|
1892
|
-
.map((s) => this.buildTopicMenuItem(s));
|
|
1884
|
+
.map((s) => this.buildTopicMenuItem(s, metadataOnly));
|
|
1893
1885
|
}
|
|
1894
1886
|
if (cmd === '/s' || cmd === '/session' || cmd === '/del') {
|
|
1895
1887
|
const sessions = await this.sessionManager.listSessions(channel, channelId);
|
|
@@ -1970,7 +1962,7 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
1970
1962
|
const rawModels = catalog.models.map(m => m.id);
|
|
1971
1963
|
const models = filterModelsForRole(optionsIdentity.role, target.baseagent, rawModels, model => resolveCatalogModel(catalog, model), target.sel.self);
|
|
1972
1964
|
const requestedModel = menuStringArg(args, 'model') ?? menuStringArg(args, 'current');
|
|
1973
|
-
const currentModel = requestedModel || readMenuModel(target, agent, session?.agentSessionId).value ||
|
|
1965
|
+
const currentModel = requestedModel || readMenuModel(target, agent, session?.agentSessionId).value || '';
|
|
1974
1966
|
if (models.length > 0)
|
|
1975
1967
|
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
1968
|
}
|
|
@@ -2037,7 +2029,10 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
2037
2029
|
}
|
|
2038
2030
|
const requestedModel = menuStringArg(args, 'model') ?? menuStringArg(args, 'currentModel');
|
|
2039
2031
|
const modelTarget = { ...target, field: 'model', fieldPath: `baseagents.${target.baseagent}.model` };
|
|
2040
|
-
const currentModel = requestedModel ||
|
|
2032
|
+
const currentModel = requestedModel || readMenuModel(modelTarget, agent, session?.agentSessionId).value;
|
|
2033
|
+
// Agent 级没有模型时没有可选的推理强度。
|
|
2034
|
+
if (!currentModel)
|
|
2035
|
+
return [];
|
|
2041
2036
|
const efforts = await getAvailableEfforts(agent, currentModel);
|
|
2042
2037
|
const currentEffort = menuStringArg(args, 'effort') ?? menuStringArg(args, 'current') ?? readMenuModel(target, agent, session?.agentSessionId).value ?? 'auto';
|
|
2043
2038
|
const allItems = [...efforts, 'auto'];
|
|
@@ -2102,6 +2097,9 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2102
2097
|
const cmdBase = cmd.trim().split(' ')[0];
|
|
2103
2098
|
if (!cmdBase)
|
|
2104
2099
|
return { error: '缺少命令', code: 'MISSING_CMD' };
|
|
2100
|
+
if (cmdBase === '/provider') {
|
|
2101
|
+
return executeProviderMenu({ name: 'provider', cmd, type: 'menu.query', args }, fromControlChannel ? authSubject : undefined, source);
|
|
2102
|
+
}
|
|
2105
2103
|
const isRequesterRoleQuery = cmdBase === '/role' && args?.view === 'requester';
|
|
2106
2104
|
if (isRequesterRoleQuery && Object.keys(args).some(key => key !== 'view')) {
|
|
2107
2105
|
return { error: 'role requester query only accepts args.view', code: 'INVALID_ARGUMENT' };
|
|
@@ -2164,7 +2162,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2164
2162
|
return { error: '/fa 需要同一身份同时具备 Agent Owner 和 daemon Owner 权限', code: 'FORBIDDEN' };
|
|
2165
2163
|
}
|
|
2166
2164
|
const status = sessionFullAccessStatus(session, principalId);
|
|
2167
|
-
return { data: { ...status, sessionId: session.id
|
|
2165
|
+
return { data: { ...status, sessionId: session.id } };
|
|
2168
2166
|
}
|
|
2169
2167
|
const storageRequest = { type: 'menu.query', cmd, args };
|
|
2170
2168
|
if (isAgentStorageMenuRequest(storageRequest)) {
|
|
@@ -2848,6 +2846,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2848
2846
|
}
|
|
2849
2847
|
catch { }
|
|
2850
2848
|
data.avatarCreateSupported = true;
|
|
2849
|
+
data.agentCreate = agentCreateCapabilities();
|
|
2851
2850
|
return { data };
|
|
2852
2851
|
}
|
|
2853
2852
|
if (view === 'monitor') {
|
|
@@ -2964,6 +2963,9 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
2964
2963
|
const cmdBase = cmd.trim().split(' ')[0];
|
|
2965
2964
|
if (!cmdBase)
|
|
2966
2965
|
return { error: '缺少命令', code: 'MISSING_CMD' };
|
|
2966
|
+
if (cmdBase === '/provider') {
|
|
2967
|
+
return executeProviderMenu({ name: 'provider', cmd, type: 'menu.update', args, value }, fromControlChannel ? authSubject : undefined, source);
|
|
2968
|
+
}
|
|
2967
2969
|
const isLoopUpdate = cmdBase === '/session' && args?.resource === 'loop';
|
|
2968
2970
|
const isFullAccessUpdate = cmdBase === '/session' && args?.resource === 'fullaccess';
|
|
2969
2971
|
if (isLoopUpdate) {
|
|
@@ -3063,15 +3065,18 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3063
3065
|
return { error: '/fa 需要私聊中同一身份同时具备 Agent Owner 和 daemon Owner 权限', code: 'FORBIDDEN' };
|
|
3064
3066
|
}
|
|
3065
3067
|
try {
|
|
3068
|
+
const status = sessionFullAccessStatus(session, principalId);
|
|
3069
|
+
if (status.globalEnabled) {
|
|
3070
|
+
return { data: { ...status, sessionId: session.id, ignored: true,
|
|
3071
|
+
message: 'Agent 全局 fullaccess 已开启,局部设置未修改。' } };
|
|
3072
|
+
}
|
|
3066
3073
|
if (isTopicSession(session)) {
|
|
3067
|
-
this.sessionManager.updateSessionFullAccess(session.id, {
|
|
3074
|
+
session = this.sessionManager.updateSessionFullAccess(session.id, {
|
|
3075
|
+
enabled: value, authorizedBy: principalId,
|
|
3076
|
+
});
|
|
3068
3077
|
}
|
|
3069
3078
|
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 });
|
|
3079
|
+
updateRelationSessionFullAccess(session, { enabled: value, authorizedBy: principalId });
|
|
3075
3080
|
}
|
|
3076
3081
|
auditFullAccessEvent({
|
|
3077
3082
|
event: value ? 'fullaccess.session-policy.configured' : 'fullaccess.session-policy.deescalated',
|
|
@@ -3081,9 +3086,9 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3081
3086
|
agentAid: subject.selfAid,
|
|
3082
3087
|
sessionId: session.id,
|
|
3083
3088
|
authorizedBy: principalId,
|
|
3084
|
-
reason: isTopicSession(session) ? 'topic session fullaccess updated via Menu' : '
|
|
3089
|
+
reason: isTopicSession(session) ? 'topic session fullaccess updated via Menu' : 'relation main-session fullaccess updated via Menu',
|
|
3085
3090
|
});
|
|
3086
|
-
return { data: {
|
|
3091
|
+
return { data: { ...sessionFullAccessStatus(session, principalId), sessionId: session.id } };
|
|
3087
3092
|
}
|
|
3088
3093
|
catch (error) {
|
|
3089
3094
|
return menuResultFailure(error);
|
|
@@ -3322,7 +3327,10 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3322
3327
|
return target;
|
|
3323
3328
|
const agent = this.getAgent(channel, target.baseagent);
|
|
3324
3329
|
const modelTarget = { ...target, field: 'model', fieldPath: `baseagents.${target.baseagent}.model` };
|
|
3325
|
-
const currentModel =
|
|
3330
|
+
const currentModel = readMenuModel(modelTarget, agent, session?.agentSessionId).value;
|
|
3331
|
+
if (!currentModel) {
|
|
3332
|
+
return { error: '当前 Agent 未配置模型,请先设置模型', code: 'MODEL_NOT_CONFIGURED' };
|
|
3333
|
+
}
|
|
3326
3334
|
const validEfforts = await getAvailableEfforts(agent, currentModel);
|
|
3327
3335
|
const allValid = [...validEfforts, 'auto'];
|
|
3328
3336
|
if (!allValid.includes(arg)) {
|
|
@@ -3490,6 +3498,9 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
3490
3498
|
const cmdBase = cmd.trim().split(' ')[0];
|
|
3491
3499
|
if (!cmdBase)
|
|
3492
3500
|
return { error: '缺少命令', code: 'MISSING_CMD' };
|
|
3501
|
+
if (cmdBase === '/provider') {
|
|
3502
|
+
return executeProviderMenu({ name: 'provider', cmd, type: 'menu.action', args, action }, fromControlChannel ? authSubject : undefined, source);
|
|
3503
|
+
}
|
|
3493
3504
|
if (!action)
|
|
3494
3505
|
return { error: '缺少 action', code: 'MISSING_VALUE' };
|
|
3495
3506
|
if (cmdBase === '/file' && action === 'search') {
|
|
@@ -3607,8 +3618,18 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
3607
3618
|
});
|
|
3608
3619
|
if (authDenied)
|
|
3609
3620
|
return authDenied;
|
|
3621
|
+
// Both create and initialize policies apply to the compatibility adapter.
|
|
3622
|
+
if (cmdBase === '/agent' && action === 'create' && args?.initialize === true) {
|
|
3623
|
+
const initializeDenied = await authorizeMenuIntent.call(this, {
|
|
3624
|
+
intent: buildMenuIntent('action', cmdBase, args, 'initialize', undefined, fromControlChannel),
|
|
3625
|
+
identity: authIdentity, subject, session: authSession, explicitChatType,
|
|
3626
|
+
channel, channelId, userId, fromControlChannel, source,
|
|
3627
|
+
});
|
|
3628
|
+
if (initializeDenied)
|
|
3629
|
+
return initializeDenied;
|
|
3630
|
+
}
|
|
3610
3631
|
// ── /gateway action(进程级,gate 已确保 fromControlChannel) ──
|
|
3611
|
-
// test=连通性测试;delete=删除配置;models=模型+价格;set-price
|
|
3632
|
+
// test=连通性测试;delete=删除配置;models=模型+价格;set-price=改网关价格。
|
|
3612
3633
|
if (cmdBase === '/gateway') {
|
|
3613
3634
|
if (action === 'test')
|
|
3614
3635
|
return await gatewayTest(args);
|
|
@@ -3618,8 +3639,6 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
3618
3639
|
return await gatewayModels(args);
|
|
3619
3640
|
if (action === 'set-price')
|
|
3620
3641
|
return gatewaySetPrice(args);
|
|
3621
|
-
if (action === 'sync-env')
|
|
3622
|
-
return await gatewaySyncEnv(args);
|
|
3623
3642
|
return { error: `不支持 gateway action: ${action}`, code: 'NOT_SUPPORTED' };
|
|
3624
3643
|
}
|
|
3625
3644
|
const isMenuAdmin = isManagementRole(authIdentity.role);
|
|
@@ -3673,8 +3692,19 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
3673
3692
|
args = { ...(args ?? {}), aid: selfAid };
|
|
3674
3693
|
}
|
|
3675
3694
|
const a = { ...(args ?? {}) };
|
|
3676
|
-
if (action === 'create') {
|
|
3677
|
-
a.project
|
|
3695
|
+
if (action === 'create' && a.resume !== true && a.cancel !== true) {
|
|
3696
|
+
if (a.project !== undefined && typeof a.project !== 'string')
|
|
3697
|
+
return { error: 'project 必须是字符串', code: 'INVALID_ARGS' };
|
|
3698
|
+
let previousProject;
|
|
3699
|
+
if (a.initialize === true && !a.project?.trim() && typeof a.aid === 'string' && isValidAid(a.aid)) {
|
|
3700
|
+
try {
|
|
3701
|
+
previousProject = readInitialization(a.aid)?.plan.project;
|
|
3702
|
+
}
|
|
3703
|
+
catch {
|
|
3704
|
+
return { error: '初始化状态无效', code: 'INITIALIZE_STATE_INVALID' };
|
|
3705
|
+
}
|
|
3706
|
+
}
|
|
3707
|
+
a.project = previousProject ?? resolveProjectPath(a.project, a.aid ?? '', loadDefaults());
|
|
3678
3708
|
}
|
|
3679
3709
|
else if (action === 'initialize' && a.resume !== true) {
|
|
3680
3710
|
const suppliedPlan = a.plan && typeof a.plan === 'object' && !Array.isArray(a.plan) ? a.plan : undefined;
|
|
@@ -3803,6 +3833,9 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
3803
3833
|
const triggerScheduler = this.getTriggerSchedulerForChannel?.(channel);
|
|
3804
3834
|
if (!triggerScheduler)
|
|
3805
3835
|
return { error: '触发器功能未启用', code: 'NOT_SUPPORTED' };
|
|
3836
|
+
if (action === 'show') {
|
|
3837
|
+
return { error: 'Trigger details use menu.query with args.view="detail"', code: 'NOT_SUPPORTED' };
|
|
3838
|
+
}
|
|
3806
3839
|
if (action === 'create' || action === 'set') {
|
|
3807
3840
|
// args 结构化 → 直接组装 ParsedTriggerSet(绕过 parseTriggerSet 文本解析,无注入风险)
|
|
3808
3841
|
if (!args?.scheduleType || (args.scheduleType !== 'once' && !args?.scheduleValue) || !args?.prompt) {
|
|
@@ -4690,7 +4723,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4690
4723
|
const executionIntent = parsedCommands[0]?.intent;
|
|
4691
4724
|
const ownershipOperation = executionIntent?.operation;
|
|
4692
4725
|
let rawExecution;
|
|
4693
|
-
if (ownershipOperation === 'ec.aid.bind' || ownershipOperation === 'ec.aid.bind.status') {
|
|
4726
|
+
if (ownershipOperation === 'ec.aid.bind' || ownershipOperation === 'ec.aid.transfer' || ownershipOperation === 'ec.aid.bind.status') {
|
|
4694
4727
|
try {
|
|
4695
4728
|
rawExecution = { data: { ok: true, state: await executeOwnershipCommand(parseOwnershipCommand(argv), cliSelfAid) } };
|
|
4696
4729
|
}
|
|
@@ -4698,7 +4731,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4698
4731
|
const failure = ownershipFailure(error);
|
|
4699
4732
|
const code = ['INVALID_ARGUMENT', 'INVALID_AID', 'INVALID_OWNER', 'INVALID_OPERATION'].includes(failure.code) ? 'INVALID_ARGUMENT'
|
|
4700
4733
|
: ['SUBJECT_REQUIRED', 'SUBJECT_UNAVAILABLE', 'REQUEST_NOT_FOUND', 'not_found'].includes(failure.code) ? 'NOT_FOUND'
|
|
4701
|
-
: ['OWNER_ALREADY_BOUND', 'BIND_CONFLICT', 'BIND_UNCERTAIN', 'CONSENSUS_REQUIRED', 'CLIENT_REPLACED', 'conflict', 'owner_locked'].includes(failure.code)
|
|
4734
|
+
: ['OWNER_ALREADY_BOUND', 'BIND_CONFLICT', 'TRANSFER_CONFLICT', 'BIND_UNCERTAIN', 'CONSENSUS_REQUIRED', 'CLIENT_REPLACED', 'conflict', 'owner_locked'].includes(failure.code)
|
|
4702
4735
|
? 'CONFLICT' : 'INTERNAL_ERROR';
|
|
4703
4736
|
rawExecution = { error: failure.error, code, data: failure };
|
|
4704
4737
|
}
|
|
@@ -4940,7 +4973,7 @@ function menuCommandToken(cmd) {
|
|
|
4940
4973
|
}
|
|
4941
4974
|
function isProcessLevelMenu(name, cmd) {
|
|
4942
4975
|
const cmdToken = menuCommandToken(cmd);
|
|
4943
|
-
return name === 'system' || name === 'agent' || name === 'gateway' || name === 'config' || name === 'baseagent-models' || name === 'baseagents'
|
|
4976
|
+
return name === 'provider' || cmdToken === '/provider' || name === 'system' || name === 'agent' || name === 'gateway' || name === 'config' || name === 'baseagent-models' || name === 'baseagents'
|
|
4944
4977
|
|| cmdToken === '/system' || cmdToken === '/agent' || cmdToken === '/gateway' || cmdToken === '/config' || cmdToken === '/baseagent-models' || cmdToken === '/baseagents';
|
|
4945
4978
|
}
|
|
4946
4979
|
function isProcessContextMenu(payload) {
|
|
@@ -5023,6 +5056,7 @@ async function execMenuForSystemControl(payload, context) {
|
|
|
5023
5056
|
}
|
|
5024
5057
|
: undefined,
|
|
5025
5058
|
});
|
|
5059
|
+
trustedSubject.menuEncrypted = context.encrypted;
|
|
5026
5060
|
const trustedIdentity = trustedSubject.identity;
|
|
5027
5061
|
trustedSubject.agentFullAccessManagement = context.source === 'control' && context.authMethod === 'daemon-owner';
|
|
5028
5062
|
const cmd = name ? (menuCommandForName(name) ?? payload.cmd) : payload.cmd;
|
|
@@ -5161,7 +5195,6 @@ async function execMenuForSystemControl(payload, context) {
|
|
|
5161
5195
|
}
|
|
5162
5196
|
/** ECWeb 专用入口:只信任 IPC 信封中的服务端认证上下文,不信任 Menu payload 自报身份。 */
|
|
5163
5197
|
export async function execMenuForEcweb(payload, trusted) {
|
|
5164
|
-
await refreshOwnershipForAuthorization(undefined, { maxAgeMs: OWNERSHIP_CACHE_MAX_AGE_MS, allowTransient: true });
|
|
5165
5198
|
const id = payload?.id ?? '';
|
|
5166
5199
|
const name = payload?.name;
|
|
5167
5200
|
const validationError = validateMenuRequest(payload ?? {});
|
|
@@ -5205,12 +5238,12 @@ export async function execMenuForEcweb(payload, trusted) {
|
|
|
5205
5238
|
* process authorization path. The authenticated envelope peerId remains the
|
|
5206
5239
|
* requester; token mode maps to a configured owner as its management actor. */
|
|
5207
5240
|
export async function execMenuForControl(payload, peerId, auth = {}) {
|
|
5208
|
-
await refreshOwnershipForAuthorization(undefined, { maxAgeMs: OWNERSHIP_CACHE_MAX_AGE_MS, allowTransient: true });
|
|
5209
5241
|
const id = payload?.id ?? '';
|
|
5210
5242
|
const name = payload?.name;
|
|
5211
5243
|
const validationError = validateMenuRequest(payload ?? {});
|
|
5212
5244
|
if (validationError)
|
|
5213
5245
|
return menuFailure({ id, ...(name ? { name } : {}) }, validationError);
|
|
5246
|
+
await refreshOwnershipForAuthorization(undefined, { maxAgeMs: OWNERSHIP_CACHE_MAX_AGE_MS, allowTransient: true });
|
|
5214
5247
|
const owners = getDaemonOwners();
|
|
5215
5248
|
const compatCmd = menuCommandToken(payload?.cmd);
|
|
5216
5249
|
const isRoleRequest = name === 'role' || compatCmd === '/role';
|
|
@@ -6,6 +6,7 @@ import { compareStableSemver, parseStableSemver } from '../../utils/stable-semve
|
|
|
6
6
|
import { logger } from '../../utils/logger.js';
|
|
7
7
|
import { validateIdleSeconds } from '../session/session-idle-monitor.js';
|
|
8
8
|
import { parseFileSearchArgs } from './file-search.js';
|
|
9
|
+
import { validateProviderMenuRequest } from '../../config/provider-menu-request.js';
|
|
9
10
|
export const MENU_REQUEST_TYPES = new Set([
|
|
10
11
|
'menu.token.request',
|
|
11
12
|
'menu.list',
|
|
@@ -143,6 +144,7 @@ export const MENU_NAME_COMMANDS = Object.freeze({
|
|
|
143
144
|
agent: '/agent',
|
|
144
145
|
aid: '/aid',
|
|
145
146
|
trigger: '/trigger',
|
|
147
|
+
provider: '/provider',
|
|
146
148
|
file: '/file',
|
|
147
149
|
'agent-data-root': '/agent-data-root',
|
|
148
150
|
'relation-data-root': '/relation-data-root',
|
|
@@ -334,6 +336,9 @@ export function validateMenuRequest(request) {
|
|
|
334
336
|
if (request.args !== undefined && (!request.args || typeof request.args !== 'object' || Array.isArray(request.args))) {
|
|
335
337
|
return { code: 'INVALID_ARGUMENT', message: 'Menu request args must be an object' };
|
|
336
338
|
}
|
|
339
|
+
if (request.name === 'provider' || firstCommandToken(request.cmd) === '/provider') {
|
|
340
|
+
return validateProviderMenuRequest(request);
|
|
341
|
+
}
|
|
337
342
|
if (request.name === 'task' || request.cmd === '/task') {
|
|
338
343
|
if (type !== 'menu.query')
|
|
339
344
|
return { code: 'NOT_SUPPORTED', message: 'task only supports menu.query' };
|
|
@@ -521,7 +526,8 @@ const STABLE_CODES = new Set([
|
|
|
521
526
|
'INITIALIZE_PLAN_CONFLICT', 'INITIALIZE_OWNER_MISMATCH', 'INITIALIZE_CANCELLED',
|
|
522
527
|
'INITIALIZE_STATE_INVALID', 'INITIALIZE_TARGET_CHANGED', 'INITIALIZE_TARGET_EXISTS',
|
|
523
528
|
'INITIALIZE_AGENTMD_VERIFY_FAILED', 'INITIALIZE_OWNER_CONFLICT', 'INITIALIZE_AVATAR_FAILED',
|
|
524
|
-
'INITIALIZE_FAILED', 'MODEL_UNAVAILABLE',
|
|
529
|
+
'INITIALIZE_FAILED', 'MODEL_UNAVAILABLE', 'MODEL_NOT_CONFIGURED', 'BASEAGENT_REQUIRED',
|
|
530
|
+
'CONTROL_AID_RESERVED', 'CONTROL_AID_CONFLICT', 'HOST_AID_RESERVED', 'AGENT_IDENTITY_UNVERIFIED',
|
|
525
531
|
]);
|
|
526
532
|
export function normalizeMenuError(error) {
|
|
527
533
|
const source = error && typeof error === 'object' ? error : {};
|
|
@@ -538,6 +544,8 @@ export function normalizeMenuError(error) {
|
|
|
538
544
|
code = 'INVALID_ARGUMENT';
|
|
539
545
|
else if (rawCode === 'UNKNOWN_NAME' || rawCode === 'NOT_APPLICABLE' || rawCode === 'UNSUPPORTED_FIELD')
|
|
540
546
|
code = 'NOT_SUPPORTED';
|
|
547
|
+
else if (rawCode === 'UNKNOWN_FIELD' || rawCode === 'INVALID_CONFIG_VALUE' || rawCode === 'INVALID_CONFIG_COMMAND')
|
|
548
|
+
code = 'INVALID_ARGUMENT';
|
|
541
549
|
else if (rawCode === 'NO_PERMISSION' || rawCode === 'SCOPE_MISMATCH')
|
|
542
550
|
code = 'PERMISSION_DENIED';
|
|
543
551
|
else if (rawCode === 'DANGEROUS_NOT_GRANTED')
|
|
@@ -660,6 +668,8 @@ const SENSITIVE_LOG_KEY = /(?:^|[_-])(?:api[_-]?key|access[_-]?token|refresh[_-]
|
|
|
660
668
|
const SENSITIVE_LOG_ARG = /(?:api[_-]?key|access[_-]?token|refresh[_-]?token|menu[_-]?token|token|secret|password|passwd|credential|authorization|cookie|private[_-]?key|seed)/i;
|
|
661
669
|
function isSensitiveLogKey(key) {
|
|
662
670
|
const normalized = key.replace(/([a-z0-9])([A-Z])/g, '$1_$2');
|
|
671
|
+
if (/^(?:provider|providers|provider_config)$/i.test(normalized))
|
|
672
|
+
return true;
|
|
663
673
|
return SENSITIVE_LOG_KEY.test(normalized) || /^(?:next[_-]?)?cursor$|^(?:download[_-]?)?url$|^ticket$/i.test(normalized);
|
|
664
674
|
}
|
|
665
675
|
function sanitizeInlineLogSecrets(value) {
|
|
@@ -765,6 +775,10 @@ function menuFlowBaseRecord(request, context) {
|
|
|
765
775
|
};
|
|
766
776
|
}
|
|
767
777
|
function menuRequestBusinessFields(request) {
|
|
778
|
+
if (request.name === 'provider' || firstCommandToken(request.cmd) === '/provider') {
|
|
779
|
+
return { type: request.type, name: 'provider', action: ['create', 'import', 'delete'].includes(String(request.action)) ? request.action : undefined,
|
|
780
|
+
args: '[REDACTED_PROVIDER_INPUT]', ...(request.value === undefined ? {} : { value: '[REDACTED_PROVIDER_INPUT]' }) };
|
|
781
|
+
}
|
|
768
782
|
return sanitizeMenuLogValue({
|
|
769
783
|
type: request.type,
|
|
770
784
|
name: request.name,
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { createProvider, parseProviderImport, readProvidersSnapshot, updateProvider } from '../../config/providers-management.js';
|
|
2
|
+
import { parseProviderObject, providerFailure } from '../../config/provider-ipc-service.js';
|
|
3
|
+
import { validateProviderMenuRequest } from '../../config/provider-menu-request.js';
|
|
4
|
+
import { authorizeFreshOperation } from '../auth/auth-gateway.js';
|
|
5
|
+
export async function executeProviderMenu(request, subject, source) {
|
|
6
|
+
const validation = validateProviderMenuRequest(request);
|
|
7
|
+
if (validation)
|
|
8
|
+
return { error: validation.message, code: validation.code };
|
|
9
|
+
if (!subject?.fromControlChannel || !subject.isDaemonOwner || subject.processRole === 'daemon-service') {
|
|
10
|
+
return { error: 'Provider management requires a DaemonOwner control context', code: 'FORBIDDEN' };
|
|
11
|
+
}
|
|
12
|
+
if (request.type !== 'menu.query' && !subject.ecwebManagement && subject.menuEncrypted !== true) {
|
|
13
|
+
return { error: 'Provider mutations require an encrypted Control Menu request', code: 'FORBIDDEN' };
|
|
14
|
+
}
|
|
15
|
+
const args = request.args;
|
|
16
|
+
const operation = request.type === 'menu.query' ? args.view === 'detail' ? 'show' : 'list'
|
|
17
|
+
: request.type === 'menu.update' ? 'update' : request.action;
|
|
18
|
+
const decision = await authorizeFreshOperation({
|
|
19
|
+
source, subject,
|
|
20
|
+
intent: { operation: 'provider.' + operation, scope: 'process', source,
|
|
21
|
+
args: args.providerId ? { providerId: args.providerId } : {} },
|
|
22
|
+
auditMetadata: subject.auditMetadata,
|
|
23
|
+
});
|
|
24
|
+
if (!decision.allow)
|
|
25
|
+
return { error: 'Provider operation is not permitted', code: 'FORBIDDEN' };
|
|
26
|
+
try {
|
|
27
|
+
if (operation === 'list' || operation === 'show') {
|
|
28
|
+
const snapshot = readProvidersSnapshot();
|
|
29
|
+
if (operation === 'list')
|
|
30
|
+
return { data: snapshot };
|
|
31
|
+
const provider = snapshot.providers[args.providerId];
|
|
32
|
+
return provider ? { data: { providerId: args.providerId, provider, revision: snapshot.revision } }
|
|
33
|
+
: { error: 'Provider not found', code: 'NOT_FOUND' };
|
|
34
|
+
}
|
|
35
|
+
if (operation === 'create' || operation === 'import') {
|
|
36
|
+
const value = operation === 'import' ? parseProviderImport(args.text) : args.provider;
|
|
37
|
+
return { data: await createProvider({ revision: args.expectedRevision, value }) };
|
|
38
|
+
}
|
|
39
|
+
return { data: await updateProvider({ providerId: args.providerId, revision: args.expectedRevision,
|
|
40
|
+
value: operation === 'update' ? parseProviderObject(request.value) : undefined, remove: operation === 'delete' }) };
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
const failure = providerFailure(error);
|
|
44
|
+
return { error: failure.error, code: failure.code, ...(failure.data === undefined ? {} : { data: failure.data }) };
|
|
45
|
+
}
|
|
46
|
+
}
|