evolcore 0.0.48 → 0.0.50
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 +97 -0
- package/bin/ecmsg.js +9 -4
- package/dist/ability/caller/authorization.js +21 -0
- package/dist/ability/caller/command.js +164 -0
- package/dist/ability/caller/contract.js +102 -0
- package/dist/ability/caller/daemon.js +158 -0
- package/dist/ability/caller/service.js +380 -0
- package/dist/ability/command-contract.js +5 -0
- package/dist/ability/daemon.js +5 -1
- package/dist/ability/interop-v1.js +10 -3
- package/dist/ability/management.js +1 -0
- package/dist/agent-template/jobs.js +173 -1
- package/dist/agent-template/runtime.js +285 -8
- package/dist/agent-template/service.js +1159 -40
- package/dist/agent-template/types.js +2 -1
- package/dist/agents/baseagent-availability.js +27 -3
- package/dist/agents/baseagent-capability-adapter.js +102 -0
- package/dist/agents/baseagent-plugin-descriptor.js +274 -0
- package/dist/agents/baseagent-plugin-loader.js +145 -0
- package/dist/agents/baseagent.js +68 -2
- package/dist/agents/claude-gateway/agent-registration.js +389 -0
- package/dist/agents/claude-gateway/binding.js +96 -0
- package/dist/agents/claude-gateway/inbox.js +138 -0
- package/dist/agents/claude-gateway/index.js +125 -0
- package/dist/agents/claude-gateway/listing.js +330 -0
- package/dist/agents/claude-gateway/router.js +328 -0
- package/dist/agents/claude-gateway/sessions.js +128 -0
- package/dist/agents/claude-gateway/terminal.js +250 -0
- package/dist/agents/claude-gateway/transcript.js +272 -0
- package/dist/agents/claude-gateway/types.js +14 -0
- package/dist/agents/claude-runner.js +6 -10
- package/dist/agents/codex-runner.js +9 -2
- package/dist/agents/{gemini-runner.js → gemini/gemini-runner.js} +17 -17
- package/dist/{core/session/adapters → agents/gemini}/gemini-session-file-adapter.js +2 -2
- package/dist/agents/gemini/index.js +51 -0
- package/dist/aun/aid/control-aid.js +52 -32
- package/dist/aun/group/invite-service.js +6 -36
- package/dist/aun/group/operations.js +6 -0
- package/dist/aun/msg/mention-schema.js +1 -1
- package/dist/aun/msg/p2p.js +31 -2
- package/dist/aun/msg/upload.js +126 -3
- package/dist/build-identity.json +1 -1
- package/dist/channels/aun.js +1175 -457
- package/dist/cli/ability-command.js +42 -0
- package/dist/cli/agent-command.js +20 -1
- package/dist/cli/agent-create.js +78 -18
- package/dist/cli/agent-template.js +5 -3
- package/dist/cli/agent.js +91 -0
- package/dist/cli/aun-commands.js +92 -34
- package/dist/cli/bench.js +5 -2
- package/dist/cli/config.js +22 -6
- package/dist/cli/daemon-commands.js +245 -101
- package/dist/cli/directory.js +6 -1
- package/dist/cli/ecmsg-gateway.js +11 -9
- package/dist/cli/index.js +30 -5
- package/dist/cli/init.js +39 -63
- package/dist/cli/managed-command-guard.js +3 -0
- package/dist/cli/menu-client.js +32 -7
- package/dist/cli/model.js +20 -5
- package/dist/cli/pay-command.js +30 -0
- package/dist/cli/provider-command.js +6 -2
- package/dist/cli/quota.js +89 -0
- package/dist/cli/restart-monitor.js +2 -2
- package/dist/cli/role.js +1 -0
- package/dist/cli/services-command.js +12 -9
- package/dist/cli/team-workspace-command.js +56 -2
- package/dist/cli/thread-command.js +78 -12
- package/dist/config/access-policy.js +16 -3
- package/dist/config/config-field-policy.js +88 -9
- package/dist/config/config-manager.js +97 -47
- package/dist/config/config-operation-service.js +22 -1
- package/dist/config/gateway-config.js +9 -8
- package/dist/config/owner-config.js +0 -16
- package/dist/config/peer-role-resolver.js +1 -7
- package/dist/config/providers-config.js +107 -20
- package/dist/config/providers-management.js +45 -21
- package/dist/config/resolved-config-op.js +4 -44
- package/dist/config/schema-migration.js +78 -5
- package/dist/config/schema-registry.js +52 -7
- package/dist/config-store.js +1309 -17
- package/dist/core/agent-application-service.js +220 -1
- package/dist/core/agent-ipc-registration.js +19 -2
- package/dist/core/agent-reload-coordinator.js +5 -0
- package/dist/core/agent-runtime.js +198 -54
- package/dist/core/auth/agent-delegation.js +14 -0
- package/dist/core/auth/delegation-authorization.js +33 -26
- package/dist/core/auth/operation-authorizer.js +16 -1
- package/dist/core/auth/operation-catalog.js +59 -7
- package/dist/core/baseagent-loader.js +30 -3
- package/dist/core/capability/capability-manager.js +16 -7
- package/dist/core/channel-runtime.js +4 -2
- package/dist/core/command/agent-control.js +20 -2
- package/dist/core/command/agent-template-menu.js +4 -3
- package/dist/core/command/cli-intent-parser.js +28 -0
- package/dist/core/command/command-handler.js +45 -2
- package/dist/core/command/menu-catalog.js +20 -4
- package/dist/core/command/menu-file-path.js +70 -0
- package/dist/core/command/menu-handler.js +97 -73
- package/dist/core/command/menu-protocol.js +29 -0
- package/dist/core/command/menu-query-batch.js +2 -2
- package/dist/core/command/private-mention-menu.js +71 -0
- package/dist/core/command/remote-shell.js +565 -0
- package/dist/core/command/slash-handler.js +17 -26
- package/dist/core/command/team-workspace-bootstrap.js +2 -1
- package/dist/core/command/topic-slash.js +7 -1
- package/dist/core/daemon-bootstrap.js +0 -4
- package/dist/core/daemon-control.js +58 -1
- package/dist/core/daemon-lifecycle.js +29 -7
- package/dist/core/evolagent-registry.js +18 -9
- package/dist/core/handoff/runtime.js +1 -1
- package/dist/core/host-snapshot.js +8 -3
- package/dist/core/initialization/service.js +3 -0
- package/dist/core/interaction-router.js +130 -0
- package/dist/core/ipc-registration.js +5 -0
- package/dist/core/memory/consolidation-context.js +2 -1
- package/dist/core/memory/consolidation.js +35 -64
- package/dist/core/message/aun-ipc-sender.js +213 -74
- package/dist/core/message/aun-request-registry.js +31 -0
- package/dist/core/message/contact-admission.js +91 -6
- package/dist/core/message/contact-pending-inbound.js +113 -0
- package/dist/core/message/contact-thread-approval.js +212 -0
- package/dist/core/message/im-renderer.js +40 -1
- package/dist/core/message/message-admission.js +5 -39
- package/dist/core/message/message-bridge.js +197 -45
- package/dist/core/message/message-log.js +32 -0
- package/dist/core/message/message-queue.js +102 -18
- package/dist/core/message/peer-mode.js +15 -4
- package/dist/core/message/response-engine.js +174 -26
- package/dist/core/message/send-options.js +37 -3
- package/dist/core/message/send-routing.js +11 -7
- package/dist/core/model/config-scope.js +6 -14
- package/dist/core/model/model-catalog.js +5 -5
- package/dist/core/model/model-diagnostics.js +19 -0
- package/dist/core/model/model-fallback.js +13 -2
- package/dist/core/ownership/owner-resolver.js +12 -86
- package/dist/core/pack-auth.js +7 -0
- package/dist/core/pack-install.js +1 -1
- package/dist/core/permission/ec-command-parser.js +288 -77
- package/dist/core/permission/protected-paths.js +64 -9
- package/dist/core/permission/services-path-acl.js +458 -0
- package/dist/core/permission/tool-policy.js +26 -10
- package/dist/core/relation/peer-identity.js +13 -0
- package/dist/core/session/adapters/claude-session-file-adapter.js +6 -2
- package/dist/core/session/adapters/codex-session-file-adapter.js +4 -0
- package/dist/core/session/session-manager.js +47 -10
- package/dist/core/session/session-mapper.js +16 -0
- package/dist/core/skill/index-generator.js +2 -3
- package/dist/core/skill/switch-resolver.js +3 -0
- package/dist/core/task/task-recovery-service.js +1 -0
- package/dist/core/thread/command-parser.js +4 -1
- package/dist/core/thread/ipc-operation.js +4 -2
- package/dist/core/thread/thread-operation.js +25 -10
- package/dist/core/thread/thread-service.js +294 -55
- package/dist/core/thread/topic-id.js +67 -2
- package/dist/core/thread/types.js +15 -1
- package/dist/directory/owner-directory-admission.js +11 -8
- package/dist/directory/owner-directory-cache.js +19 -0
- package/dist/directory/owner-directory-markdown.js +1 -1
- package/dist/directory/owner-directory-policy.js +5 -30
- package/dist/directory/owner-directory-request-operation.js +5 -2
- package/dist/eck/kit-renderer.js +3 -2
- package/dist/eck/message-renderer.js +28 -5
- package/dist/ecweb/basic-settings-service.js +5 -9
- package/dist/ecweb/providers-service.js +4 -2
- package/dist/ecweb/runtime/supervisor.js +36 -8
- package/dist/event-center/center-config.js +9 -5
- package/dist/event-center/dispatcher.js +10 -1
- package/dist/event-center/ipc-operation.js +19 -0
- package/dist/event-center/registry.js +20 -5
- package/dist/event-center/runtime.js +10 -7
- package/dist/index.js +120 -41
- package/dist/ipc.js +83 -3
- package/dist/outputs/authorization.js +16 -0
- package/dist/outputs/cards.js +336 -0
- package/dist/outputs/events.js +3 -2
- package/dist/outputs/protocol.js +1 -0
- package/dist/outputs/service.js +2 -15
- package/dist/paths.js +48 -1
- package/dist/pay/command.js +38 -0
- package/dist/pay/protocol.js +136 -0
- package/dist/pay/runtime.js +188 -0
- package/dist/pay/service.js +384 -0
- package/dist/pay/store.js +81 -0
- package/dist/response-system/engines/v1/proactive-flow.js +29 -2
- package/dist/services/dispatcher.js +23 -5
- package/dist/services/host/main.js +388 -0
- package/dist/services/host/protocol.js +118 -0
- package/dist/services/host/resident.js +310 -0
- package/dist/services/host-client.js +386 -0
- package/dist/services/host-deploy.js +180 -0
- package/dist/services/host-launch.js +117 -0
- package/dist/services/host-recycle.js +203 -0
- package/dist/services/host-runtime.js +802 -0
- package/dist/services/idempotency.js +44 -86
- package/dist/services/index-generator.js +4 -3
- package/dist/services/index.js +204 -22
- package/dist/services/ipc-operation.js +288 -44
- package/dist/services/pack-manager.js +1 -0
- package/dist/services/script-runner.js +515 -83
- package/dist/services/service-payload.js +13 -7
- package/dist/services/validation.js +109 -4
- package/dist/stats/budget.js +1 -1
- package/dist/stats/model-resolver.js +2 -2
- package/dist/stats/quota-query.js +95 -0
- package/dist/trigger/application-service.js +6 -4
- package/dist/trigger/local-files.js +19 -9
- package/dist/trigger/scheduler.js +22 -12
- package/dist/trigger/script-sandbox.js +51 -8
- package/dist/utils/aid-bind.js +3 -0
- package/dist/utils/atomic-write.js +22 -8
- package/dist/utils/evolcore-version.js +2 -2
- package/dist/utils/host-info.js +173 -1
- package/dist/utils/logger.js +2 -2
- package/dist/utils/media-cache.js +190 -43
- package/dist/utils/npm-ops.js +43 -8
- package/dist/utils/restart-safety.js +14 -1
- package/dist/utils/system-memory.js +113 -25
- package/dist/utils/systemd-lifecycle.js +154 -0
- package/dist/utils/windows-shell-trust.js +7 -3
- package/dist/workbench/service.js +1 -1
- package/kits/docs/INDEX.md +3 -2
- package/kits/docs/aun/AUN/346/266/210/346/201/257/347/261/273/345/236/213/344/270/216/345/261/236/346/200/247.md +1 -0
- package/kits/docs/channels/aun.md +1 -1
- package/kits/docs/evolcore/INDEX.md +9 -6
- package/kits/docs/evolcore/agent.md +36 -1
- package/kits/docs/evolcore/aid.md +45 -3
- package/kits/docs/evolcore/config.md +5 -2
- package/kits/docs/evolcore/directory.md +8 -9
- package/kits/docs/evolcore/group.md +2 -1
- package/kits/docs/evolcore/memory-tags.md +2 -0
- package/kits/docs/evolcore/menu-client.md +3 -3
- package/kits/docs/evolcore/menu-protocol.md +7 -0
- package/kits/docs/evolcore/model.md +3 -0
- package/kits/docs/evolcore/msg.md +77 -10
- package/kits/docs/evolcore/pay.md +34 -0
- package/kits/docs/evolcore/provider.md +22 -1
- package/kits/docs/evolcore/quota.md +54 -0
- package/kits/docs/evolcore/role.md +3 -0
- package/kits/docs/evolcore/services.md +46 -18
- package/kits/docs/evolcore/stats.md +2 -0
- package/kits/docs/evolcore/thread-chain.md +2 -0
- package/kits/docs/evolcore/tool-authorization.md +10 -0
- package/kits/docs/evolcore/trigger.md +2 -0
- package/kits/rules/01-overview.md +11 -32
- package/kits/rules/02-navigation.md +7 -0
- package/kits/rules/06-channel.md +3 -3
- package/kits/schemas/_meta.json +38 -5
- package/kits/schemas/agent-config.schema.20.json +24 -0
- package/kits/schemas/agent-config.schema.21.json +974 -0
- package/kits/schemas/agent-config.schema.22.json +977 -0
- package/kits/schemas/agent-config.schema.23.json +958 -0
- package/kits/schemas/daemon.schema.10.json +373 -0
- package/kits/schemas/daemon.schema.9.json +12 -0
- package/kits/schemas/defaults.schema.7.json +472 -0
- package/kits/schemas/providers.schema.3.json +18 -2
- package/kits/schemas/relation-config.schema.13.json +289 -0
- package/kits/skills/.switches.json +17 -1
- package/kits/skills/ability/SKILL.md +229 -34
- package/kits/skills/ability/STRUCTURE.md +333 -0
- package/kits/skills/ability/references/cli.md +208 -0
- package/kits/skills/ability/references/development.md +107 -37
- package/kits/skills/ability/references/management.md +106 -46
- package/kits/skills/ability/references/runtime-protocol.md +65 -63
- package/kits/skills/agent-output-cards/SKILL.md +64 -0
- package/kits/skills/ec-group/SKILL.md +8 -6
- package/kits/skills/ec-group/TASK.md +186 -0
- package/kits/skills/ec-group/WORKLOG.md +180 -0
- package/kits/skills/ec-group-collaboration/SKILL.md +3 -3
- package/kits/skills/ec-pay/SKILL.md +101 -0
- package/kits/skills/ec-pay/references/pay-cli.md +110 -0
- package/kits/skills/ec-provider/SKILL.md +58 -9
- package/kits/skills/{ec-service-proxy → ec-proxy}/SKILL.md +8 -5
- package/kits/skills/ec-service-call/SKILL.md +135 -0
- package/kits/skills/ec-service-pack/SKILL.md +277 -0
- package/kits/skills/ec-trigger/SKILL.md +1 -1
- package/kits/templates/memory-consolidation/notes.md +2 -2
- package/kits/templates/memory-consolidation/workflow.md +46 -0
- package/kits/templates/roles/visitor.json +1 -0
- package/kits/templates/system-fragments/channel.md +13 -4
- package/kits/templates/system-fragments/commands.md +5 -3
- package/kits/templates/system-fragments/directory-contacts.md +3 -4
- package/kits/templates/system-fragments/reply.md +1 -0
- package/kits/templates/system-fragments/session.md +1 -1
- package/kits/templates/system-fragments/thread.md +27 -128
- package/kits/templates/system-fragments/venue.md +27 -0
- package/package.json +4 -5
- package/scripts/agent-template/inspect.mjs +79 -29
- package/scripts/agent-template/overlay.mjs +20 -2
- package/scripts/agent-template/shared/common.mjs +24 -6
- package/scripts/agent-template/shared/team-schema.json +23 -5
- package/scripts/agent-template/shared/template-contract.mjs +107 -17
- package/scripts/agent-template/shared/template-package.mjs +254 -29
- package/scripts/agent-template/shared/template-runtime.mjs +145 -2
- package/scripts/agent-template/shared/template.mjs +67 -9
- package/scripts/agent-template/team-pack.mjs +132 -41
- package/scripts/agent-template/team-preview.mjs +249 -5
- package/kits/docs/aun/ABILITY_CALLING.md +0 -280
- package/kits/docs/evolcore/ability.md +0 -185
- package/kits/skills/ability/references/calling.md +0 -56
- package/kits/skills/ability/references/contract-checklist.md +0 -37
- package/kits/skills/ability/references/recovery.md +0 -27
- /package/dist/{core/capability/providers → agents/gemini}/gemini-capability-provider.js +0 -0
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { isSupportedBaseagent } from '../agents/baseagent.js';
|
|
1
2
|
import { SYSTEM_SESSION_TYPES } from '../core/system-session/types.js';
|
|
2
3
|
import { isValidAid } from '../aun/aid/validation.js';
|
|
3
4
|
const BEHAVIOR_TOP_FIELDS = new Set([
|
|
4
5
|
'active_baseagent',
|
|
5
6
|
'chatmode',
|
|
6
7
|
'mentionMode',
|
|
8
|
+
'privateMentionMode',
|
|
7
9
|
'autoMentionQuietWindowMs',
|
|
8
10
|
'groupSlashRequireMentions',
|
|
9
11
|
'responseMode',
|
|
@@ -33,21 +35,20 @@ export function isAgentOnlyModelField(fieldPath) {
|
|
|
33
35
|
const parts = fieldPath.split('.');
|
|
34
36
|
return parts.length === 3
|
|
35
37
|
&& parts[0] === 'baseagents'
|
|
36
|
-
&&
|
|
37
|
-
&& (parts[2] === 'model' || parts[2] === 'effort' || parts[2] === 'reasoning');
|
|
38
|
+
&& isSupportedBaseagent(parts[1])
|
|
39
|
+
&& (parts[2] === 'model' || parts[2] === 'effort' || parts[2] === 'reasoning' || parts[2] === 'fallback');
|
|
38
40
|
}
|
|
39
41
|
/** Baseagent selection is Agent-owned as well. */
|
|
40
42
|
export function isAgentOnlyBaseagentField(fieldPath) {
|
|
41
43
|
return fieldPath === 'active_baseagent' || fieldPath === 'baseagents' || isAgentOnlyModelField(fieldPath);
|
|
42
44
|
}
|
|
43
|
-
const SUPPORTED_BASEAGENTS = new Set(['claude', 'codex', 'gemini', 'ecagent']);
|
|
44
45
|
/** Public behavior fields for a runner this version does not implement. */
|
|
45
46
|
export function isUnsupportedBaseagentConfigField(fieldPath) {
|
|
46
47
|
const parts = fieldPath.split('.');
|
|
47
48
|
return parts.length === 3
|
|
48
49
|
&& parts[0] === 'baseagents'
|
|
49
50
|
&& /^[a-z][a-z0-9_-]*$/.test(parts[1])
|
|
50
|
-
&& !
|
|
51
|
+
&& !isSupportedBaseagent(parts[1])
|
|
51
52
|
&& BASEAGENT_BEHAVIOR_FIELDS.has(parts[2]);
|
|
52
53
|
}
|
|
53
54
|
const SENSITIVE_TOP_FIELDS = new Set([
|
|
@@ -57,8 +58,6 @@ const SENSITIVE_TOP_FIELDS = new Set([
|
|
|
57
58
|
'lifecycle',
|
|
58
59
|
'initialized',
|
|
59
60
|
'initialization',
|
|
60
|
-
'owner',
|
|
61
|
-
'owners',
|
|
62
61
|
'access',
|
|
63
62
|
'fullaccess',
|
|
64
63
|
'sessionFullAccess',
|
|
@@ -73,7 +72,7 @@ const SENSITIVE_TOP_FIELDS = new Set([
|
|
|
73
72
|
'role',
|
|
74
73
|
'extra_backup',
|
|
75
74
|
]);
|
|
76
|
-
const CRITICAL_AGENT_FIELDS = new Set(['
|
|
75
|
+
const CRITICAL_AGENT_FIELDS = new Set(['admins', 'roles', 'access']);
|
|
77
76
|
const EFFORTS = new Set(['low', 'medium', 'high', 'xhigh', 'max']);
|
|
78
77
|
function scalar(rolePermissionKey, valueKind, access = 'role-overridable') {
|
|
79
78
|
return { class: 'safe-scalar', access, rolePermissionKey, valueKind };
|
|
@@ -96,6 +95,15 @@ export function resolveConfigFieldRule(fieldPath, scope) {
|
|
|
96
95
|
const top = parts[0];
|
|
97
96
|
if (SENSITIVE_TOP_FIELDS.has(top))
|
|
98
97
|
return { class: 'sensitive' };
|
|
98
|
+
if (field === 'version')
|
|
99
|
+
return scalar(field, 'member-version', 'owner-only');
|
|
100
|
+
if (top === 'update') {
|
|
101
|
+
if (field === 'update')
|
|
102
|
+
return { ...readonlyObject('update'), access: 'owner-only' };
|
|
103
|
+
if (field === 'update.publisher')
|
|
104
|
+
return scalar('update', 'aid', 'owner-only');
|
|
105
|
+
return field === 'update.mode' ? scalar('update', 'update-mode', 'owner-only') : { class: 'unknown' };
|
|
106
|
+
}
|
|
99
107
|
if (top === 'Services') {
|
|
100
108
|
return parts.length === 3 && /^[A-Za-z0-9_-]+$/u.test(parts[1]) && ['provider', 'model', 'effort'].includes(parts[2])
|
|
101
109
|
? scalar(field, parts[2] === 'effort' ? 'effort' : 'string', 'owner-only')
|
|
@@ -105,16 +113,21 @@ export function resolveConfigFieldRule(fieldPath, scope) {
|
|
|
105
113
|
if (parts.length < 3)
|
|
106
114
|
return { class: 'sensitive' };
|
|
107
115
|
const [, baseagent, leaf] = parts;
|
|
108
|
-
if (!
|
|
116
|
+
if (!isSupportedBaseagent(baseagent))
|
|
109
117
|
return { class: 'unknown' };
|
|
110
118
|
const normalizedLeaf = leaf === 'reasoning' ? 'effort' : leaf;
|
|
111
119
|
const permissionKey = `baseagents.${baseagent}.${normalizedLeaf}`;
|
|
112
120
|
if (leaf === 'provider' && parts.length === 3)
|
|
113
121
|
return scalar(permissionKey, 'string', 'owner-only');
|
|
122
|
+
if (leaf === 'enabled' && parts.length === 3)
|
|
123
|
+
return scalar(permissionKey, 'boolean', 'owner-only');
|
|
114
124
|
if (leaf === 'model' && parts.length === 3)
|
|
115
125
|
return scalar(permissionKey, 'string');
|
|
116
126
|
if ((leaf === 'effort' || leaf === 'reasoning') && parts.length === 3)
|
|
117
127
|
return scalar(permissionKey, 'effort');
|
|
128
|
+
// 降级链是模型选择的一部分:Agent 级可写,但每项都要能换供应商,故 owner-only。
|
|
129
|
+
if (leaf === 'fallback' && parts.length === 3)
|
|
130
|
+
return scalar(permissionKey, 'fallback-chain', 'owner-only');
|
|
118
131
|
if (baseagent === 'claude' && (leaf === 'agentProgressSummaries' || leaf === 'excludeDynamicSections') && parts.length === 3) {
|
|
119
132
|
return scalar(permissionKey, 'boolean');
|
|
120
133
|
}
|
|
@@ -129,6 +142,8 @@ export function resolveConfigFieldRule(fieldPath, scope) {
|
|
|
129
142
|
return scalar(field, 'nonnegative-number');
|
|
130
143
|
if (field === 'mentionMode')
|
|
131
144
|
return scalar(field, 'mention-mode');
|
|
145
|
+
if (field === 'privateMentionMode')
|
|
146
|
+
return scalar(field, 'private-mention-mode', 'owner-only');
|
|
132
147
|
if (field === 'autoMentionQuietWindowMs')
|
|
133
148
|
return scalar(field, 'nonnegative-number');
|
|
134
149
|
if (field === 'groupSlashRequireMentions')
|
|
@@ -145,6 +160,8 @@ export function resolveConfigFieldRule(fieldPath, scope) {
|
|
|
145
160
|
return scalar('restartRecovery.enabled', 'boolean');
|
|
146
161
|
if (field === 'skills.watch')
|
|
147
162
|
return scalar('skills.watch', 'boolean');
|
|
163
|
+
if (field === 'ccAgent.enabled')
|
|
164
|
+
return scalar('ccAgent.enabled', 'boolean');
|
|
148
165
|
// 仅 agent-config 声明该字段,relation/defaults 由 schema 路由拒绝。
|
|
149
166
|
if (field === 'baseagentSkills')
|
|
150
167
|
return scalar(field, 'boolean', 'owner-only');
|
|
@@ -281,6 +298,50 @@ export function relationFieldWriteOperation(fieldPath) {
|
|
|
281
298
|
return 'mentionmode.update';
|
|
282
299
|
return undefined;
|
|
283
300
|
}
|
|
301
|
+
const MAX_FALLBACK_ITEMS = 3;
|
|
302
|
+
const PROVIDER_ID_PATTERN = /^[A-Za-z0-9_-]+$/;
|
|
303
|
+
/**
|
|
304
|
+
* 降级链的值是 JSON 数组,每项必须同时给出 provider / model / effort:
|
|
305
|
+
* 降级可能换用不同供应商的不同模型,缺任何一项都无法构造请求。
|
|
306
|
+
*/
|
|
307
|
+
function parseFallbackChainValue(fieldPath, raw) {
|
|
308
|
+
let parsed;
|
|
309
|
+
try {
|
|
310
|
+
parsed = JSON.parse(raw);
|
|
311
|
+
}
|
|
312
|
+
catch {
|
|
313
|
+
return { ok: false, reason: `Config field ${fieldPath} requires a JSON array of {provider, model, effort}` };
|
|
314
|
+
}
|
|
315
|
+
if (!Array.isArray(parsed)) {
|
|
316
|
+
return { ok: false, reason: `Config field ${fieldPath} requires a JSON array of {provider, model, effort}` };
|
|
317
|
+
}
|
|
318
|
+
if (parsed.length > MAX_FALLBACK_ITEMS) {
|
|
319
|
+
return { ok: false, reason: `Config field ${fieldPath} accepts at most ${MAX_FALLBACK_ITEMS} fallback entries` };
|
|
320
|
+
}
|
|
321
|
+
const entries = [];
|
|
322
|
+
for (const [index, item] of parsed.entries()) {
|
|
323
|
+
if (!item || typeof item !== 'object' || Array.isArray(item)) {
|
|
324
|
+
return { ok: false, reason: `Config field ${fieldPath} entry ${index} must be an object` };
|
|
325
|
+
}
|
|
326
|
+
const extra = Object.keys(item)
|
|
327
|
+
.filter(key => !['provider', 'model', 'effort'].includes(key));
|
|
328
|
+
if (extra.length) {
|
|
329
|
+
return { ok: false, reason: `Config field ${fieldPath} entry ${index} has unsupported keys: ${extra.join(', ')}` };
|
|
330
|
+
}
|
|
331
|
+
const { provider, model, effort } = item;
|
|
332
|
+
if (typeof provider !== 'string' || !PROVIDER_ID_PATTERN.test(provider)) {
|
|
333
|
+
return { ok: false, reason: `Config field ${fieldPath} entry ${index} needs a provider id` };
|
|
334
|
+
}
|
|
335
|
+
if (typeof model !== 'string' || !model.trim()) {
|
|
336
|
+
return { ok: false, reason: `Config field ${fieldPath} entry ${index} needs a non-empty model` };
|
|
337
|
+
}
|
|
338
|
+
if (typeof effort !== 'string' || !EFFORTS.has(effort)) {
|
|
339
|
+
return { ok: false, reason: `Config field ${fieldPath} entry ${index} needs an effort of ${[...EFFORTS].join(', ')}` };
|
|
340
|
+
}
|
|
341
|
+
entries.push({ provider, model: model.trim(), effort });
|
|
342
|
+
}
|
|
343
|
+
return { ok: true, value: entries };
|
|
344
|
+
}
|
|
284
345
|
export function parseConfigFieldValue(fieldPath, rawValue) {
|
|
285
346
|
const rule = resolveConfigFieldRule(fieldPath);
|
|
286
347
|
if (rule.class !== 'safe-scalar' || !rule.valueKind) {
|
|
@@ -290,10 +351,22 @@ export function parseConfigFieldValue(fieldPath, rawValue) {
|
|
|
290
351
|
return { ok: false, reason: `Config field ${fieldPath} requires a string CLI value` };
|
|
291
352
|
const raw = rawValue.trim();
|
|
292
353
|
switch (rule.valueKind) {
|
|
354
|
+
case 'member-version':
|
|
355
|
+
return /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$/.test(rawValue)
|
|
356
|
+
? { ok: true, value: rawValue }
|
|
357
|
+
: { ok: false, reason: `Config field ${fieldPath} must be an explicit x.y.z version` };
|
|
358
|
+
case 'aid':
|
|
359
|
+
return isValidAid(rawValue)
|
|
360
|
+
? { ok: true, value: rawValue }
|
|
361
|
+
: { ok: false, reason: `Config field ${fieldPath} must be a valid AID` };
|
|
362
|
+
case 'update-mode':
|
|
363
|
+
return ['auto', 'manual', 'disabled'].includes(rawValue)
|
|
364
|
+
? { ok: true, value: rawValue }
|
|
365
|
+
: { ok: false, reason: `Config field ${fieldPath} must be auto, manual, or disabled` };
|
|
293
366
|
case 'string':
|
|
294
367
|
return raw ? { ok: true, value: raw } : { ok: false, reason: `Config field ${fieldPath} cannot be empty` };
|
|
295
368
|
case 'baseagent':
|
|
296
|
-
return
|
|
369
|
+
return isSupportedBaseagent(raw)
|
|
297
370
|
? { ok: true, value: raw }
|
|
298
371
|
: { ok: false, reason: `Config field ${fieldPath} must name a supported baseagent` };
|
|
299
372
|
case 'boolean':
|
|
@@ -330,6 +403,8 @@ export function parseConfigFieldValue(fieldPath, rawValue) {
|
|
|
330
403
|
return EFFORTS.has(raw)
|
|
331
404
|
? { ok: true, value: raw }
|
|
332
405
|
: { ok: false, reason: `Config field ${fieldPath} must be one of ${[...EFFORTS].join(', ')}; use unset for auto` };
|
|
406
|
+
case 'fallback-chain':
|
|
407
|
+
return parseFallbackChainValue(fieldPath, raw);
|
|
333
408
|
case 'chatmode':
|
|
334
409
|
if (fieldPath.trim() === 'chatmode.group') {
|
|
335
410
|
return raw === 'proactive'
|
|
@@ -343,6 +418,10 @@ export function parseConfigFieldValue(fieldPath, rawValue) {
|
|
|
343
418
|
return raw === 'disabled' || raw === 'mention-only' || raw === 'auto'
|
|
344
419
|
? { ok: true, value: raw }
|
|
345
420
|
: { ok: false, reason: `Config field ${fieldPath} must be disabled, mention-only, or auto` };
|
|
421
|
+
case 'private-mention-mode':
|
|
422
|
+
return raw === 'disabled' || raw === 'mention-only'
|
|
423
|
+
? { ok: true, value: raw }
|
|
424
|
+
: { ok: false, reason: `Config field ${fieldPath} must be disabled or mention-only` };
|
|
346
425
|
case 'show-activities':
|
|
347
426
|
return raw === 'all' || raw === 'text' || raw === 'none'
|
|
348
427
|
? { ok: true, value: raw }
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* 详见 docs/config/01-overview.md
|
|
12
12
|
*/
|
|
13
13
|
import fs from 'fs';
|
|
14
|
+
import { validateBaseagentPluginConfigs } from '../agents/baseagent-plugin-descriptor.js';
|
|
14
15
|
import path from 'path';
|
|
15
16
|
import { ensureManagedLockParent, resolveManagedLockPath } from '../core/runtime-lock.js';
|
|
16
17
|
import crypto from 'crypto';
|
|
@@ -22,7 +23,7 @@ import { isValidAid } from '../aun/aid/validation.js';
|
|
|
22
23
|
import { normalizeAidDomain } from '../aun/aid/domain.js';
|
|
23
24
|
import { ensureRelationSharedDirectory } from '../core/relation/shared-data.js';
|
|
24
25
|
import { parseContactAlias } from './peer-alias.js';
|
|
25
|
-
import { loadSchema, listSchemaVersions, currentVersion, isSchemaName, } from './schema-registry.js';
|
|
26
|
+
import { loadSchema, listSchemaVersions, currentVersion, isSchemaName, schemaDefaultsLayer, } from './schema-registry.js';
|
|
26
27
|
import { mergeLayers } from './merge.js';
|
|
27
28
|
import { normalizeAgentLifecycle } from './lifecycle.js';
|
|
28
29
|
import { isAgentOnlyBaseagentField, isBehaviorConfigFieldPath } from './config-field-policy.js';
|
|
@@ -34,9 +35,9 @@ import { DAEMON_SCHEMA_NAME } from '../product.js';
|
|
|
34
35
|
import { normalizeDaemonServices } from './daemon-services.js';
|
|
35
36
|
import { assertProviderSelectionWrite, resolveProviderModelSettings, validateProvidersFile } from './providers-config.js';
|
|
36
37
|
import { resolveProviderSelectionModel } from '../core/model/model-catalog.js';
|
|
37
|
-
import { assertOwnerConfigRecord,
|
|
38
|
+
import { assertOwnerConfigRecord, normalizeOwnerConfigTree, withOwnerListCompatibility } from './owner-config.js';
|
|
38
39
|
import { getOwners, getPrimaryOwner, ownerResolver } from '../core/ownership/owner-resolver.js';
|
|
39
|
-
import { resolveBaseagentModelSelection } from '../agents/baseagent.js';
|
|
40
|
+
import { isSupportedBaseagent, resolveBaseagentModelSelection } from '../agents/baseagent.js';
|
|
40
41
|
import { assertProjectPathReference } from '../utils/project-path.js';
|
|
41
42
|
// AUN gateway discovery belongs to fastaun. Keep the retired gatewayUrl
|
|
42
43
|
// compatibility handling beside the rest of the configuration read/write
|
|
@@ -1033,9 +1034,6 @@ export function write(target, value, sel, opts = {}) {
|
|
|
1033
1034
|
const before = readTextOrNull(file);
|
|
1034
1035
|
const after = `${JSON.stringify(normalized, null, 2)}\n`;
|
|
1035
1036
|
commitAgentConfigTransactionSync(syncAid, [{ file, before, after }]);
|
|
1036
|
-
if (target === ConfigTarget.Agent) {
|
|
1037
|
-
ownerResolver.setAgentConfiguredOwners(syncAid, configuredOwnerList(normalized));
|
|
1038
|
-
}
|
|
1039
1037
|
finishConfigWrite(target, sel, file);
|
|
1040
1038
|
return;
|
|
1041
1039
|
}
|
|
@@ -1048,12 +1046,6 @@ export function write(target, value, sel, opts = {}) {
|
|
|
1048
1046
|
fs.chmodSync(protectedFile, 0o600);
|
|
1049
1047
|
}
|
|
1050
1048
|
}
|
|
1051
|
-
if (target === ConfigTarget.Agent && sel?.self) {
|
|
1052
|
-
ownerResolver.setAgentConfiguredOwners(sel.self, configuredOwnerList(normalized));
|
|
1053
|
-
}
|
|
1054
|
-
if (target === ConfigTarget.Process && typeof normalized?.aid === 'string') {
|
|
1055
|
-
ownerResolver.setConfiguredOwners(normalized.aid, configuredOwnerList(normalized));
|
|
1056
|
-
}
|
|
1057
1049
|
finishConfigWrite(target, sel, file);
|
|
1058
1050
|
}
|
|
1059
1051
|
/**
|
|
@@ -1083,25 +1075,6 @@ export function mutateConfig(target, sel, mutate) {
|
|
|
1083
1075
|
release();
|
|
1084
1076
|
}
|
|
1085
1077
|
}
|
|
1086
|
-
/** Retire both local compatibility fields after freshly confirmed protocol ownership. */
|
|
1087
|
-
export function clearConfiguredOwnerAfterConsensus(subjectAid, ownerAid) {
|
|
1088
|
-
const normalizedOwnerAid = ownerAid.trim();
|
|
1089
|
-
if (!isValidAid(normalizedOwnerAid) || subjectAid === ownerResolver.getDaemonAid())
|
|
1090
|
-
return false;
|
|
1091
|
-
const isConfirmed = () => {
|
|
1092
|
-
const state = ownerResolver.snapshot(subjectAid);
|
|
1093
|
-
return ownerResolver.owner(subjectAid) === normalizedOwnerAid && state.authorizationStatus === 'verified'
|
|
1094
|
-
&& state.consensus?.lock === 'locked' && state.consensus.sub_aid === subjectAid && !state.refreshFailure;
|
|
1095
|
-
};
|
|
1096
|
-
if (!isConfirmed())
|
|
1097
|
-
return false;
|
|
1098
|
-
return mutateConfig(ConfigTarget.Agent, { self: subjectAid }, config => {
|
|
1099
|
-
if (!isConfirmed())
|
|
1100
|
-
return;
|
|
1101
|
-
delete config.owner;
|
|
1102
|
-
delete config.owners;
|
|
1103
|
-
}).changed;
|
|
1104
|
-
}
|
|
1105
1078
|
function cloneConfigValue(value) {
|
|
1106
1079
|
return JSON.parse(JSON.stringify(value));
|
|
1107
1080
|
}
|
|
@@ -1263,6 +1236,7 @@ function ensureSchemaVersion(value, version) {
|
|
|
1263
1236
|
function validateOrThrow(schema, value, target) {
|
|
1264
1237
|
const ok = schema.validate(value);
|
|
1265
1238
|
const scopeErrors = [
|
|
1239
|
+
...validatePluginConfigForTarget(target, value),
|
|
1266
1240
|
...validateProcessOnlyFields(target, value),
|
|
1267
1241
|
...validateProcessAidDomain(target, value),
|
|
1268
1242
|
...validateProcessServiceNames(target, value),
|
|
@@ -1299,6 +1273,12 @@ function validateProcessOnlyFields(target, value) {
|
|
|
1299
1273
|
if (target === ConfigTarget.Process || !value || typeof value !== 'object')
|
|
1300
1274
|
return [];
|
|
1301
1275
|
const errors = [];
|
|
1276
|
+
if (target === ConfigTarget.Defaults || target === ConfigTarget.Relation) {
|
|
1277
|
+
for (const field of ['version', 'update'])
|
|
1278
|
+
if (Object.prototype.hasOwnProperty.call(value, field)) {
|
|
1279
|
+
errors.push(`/${field} is only allowed in Agent config`);
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1302
1282
|
if (Object.prototype.hasOwnProperty.call(value, 'debug')) {
|
|
1303
1283
|
errors.push('/debug is only allowed in process config');
|
|
1304
1284
|
}
|
|
@@ -1402,6 +1382,7 @@ export function validateConfig(target, value) {
|
|
|
1402
1382
|
}
|
|
1403
1383
|
const ok = schema.validate(normalized);
|
|
1404
1384
|
const errors = [
|
|
1385
|
+
...validatePluginConfigForTarget(target, normalized),
|
|
1405
1386
|
...validateProcessOnlyFields(target, normalized),
|
|
1406
1387
|
...validateProcessAidDomain(target, normalized),
|
|
1407
1388
|
...validateProcessServiceNames(target, normalized),
|
|
@@ -1528,9 +1509,15 @@ export function resolveAgentConfig(sel, opts = {}) {
|
|
|
1528
1509
|
const fields = loadSchema('agent-config').fields;
|
|
1529
1510
|
const agentConfig = sel.self ? read(ConfigTarget.Agent, sel, opts) : null;
|
|
1530
1511
|
const relationConfig = (sel.self && sel.peerKey) ? read(ConfigTarget.Relation, sel, opts) : null;
|
|
1512
|
+
// 每一层的 schema 默认值先于该层自己的配置文件进入覆盖链:某层文件没写参数时,
|
|
1513
|
+
// 该层仍以 schema default 出值。默认值挂在哪一层是设计决策,规则见
|
|
1514
|
+
// docs/config/11-default-value-levels.md。
|
|
1531
1515
|
const layers = [
|
|
1516
|
+
schemaDefaultsLayer('defaults'),
|
|
1532
1517
|
stripDefaultsLegacyModelFields(stripStaticOwnerField(normalizeDefaultsBehaviorCompat(read(ConfigTarget.Defaults, undefined, opts)))),
|
|
1518
|
+
schemaDefaultsLayer('agent-config'),
|
|
1533
1519
|
agentConfig,
|
|
1520
|
+
schemaDefaultsLayer('relation-config'),
|
|
1534
1521
|
stripRelationRoleData(stripStaticOwnerField(relationConfig)),
|
|
1535
1522
|
];
|
|
1536
1523
|
const merged = mergeLayers(layers, fields);
|
|
@@ -1592,21 +1579,50 @@ function stripStaticOwnerField(config) {
|
|
|
1592
1579
|
if (!config)
|
|
1593
1580
|
return config;
|
|
1594
1581
|
if (!Object.prototype.hasOwnProperty.call(config, 'owner')
|
|
1582
|
+
&& !Object.prototype.hasOwnProperty.call(config, 'version')
|
|
1583
|
+
&& !Object.prototype.hasOwnProperty.call(config, 'update')
|
|
1595
1584
|
&& !Object.prototype.hasOwnProperty.call(config, 'owners')
|
|
1596
1585
|
&& !Object.prototype.hasOwnProperty.call(config, 'admins')
|
|
1597
1586
|
&& !Object.prototype.hasOwnProperty.call(config, 'access')
|
|
1598
1587
|
&& !Object.prototype.hasOwnProperty.call(config, 'groupSlashRequireMentions')
|
|
1599
1588
|
&& !Object.prototype.hasOwnProperty.call(config, 'fullaccess'))
|
|
1600
1589
|
return config;
|
|
1601
|
-
const { owner: _owner, owners: _owners, admins: _admins, access: _access, groupSlashRequireMentions: _groupSlashRequireMentions, fullaccess: _fullaccess, ...rest } = config;
|
|
1590
|
+
const { owner: _owner, version: _memberVersion, update: _update, owners: _owners, admins: _admins, access: _access, groupSlashRequireMentions: _groupSlashRequireMentions, fullaccess: _fullaccess, ...rest } = config;
|
|
1602
1591
|
return rest;
|
|
1603
1592
|
}
|
|
1604
1593
|
function stripDefaultsLegacyModelFields(config) {
|
|
1605
1594
|
if (!config)
|
|
1606
1595
|
return config;
|
|
1607
1596
|
const { models: _models, decision_model: _decisionModel, ...rest } = config;
|
|
1597
|
+
if (rest.baseagents && typeof rest.baseagents === 'object' && !Array.isArray(rest.baseagents)) {
|
|
1598
|
+
const blocks = {};
|
|
1599
|
+
for (const [name, raw] of Object.entries(rest.baseagents)) {
|
|
1600
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
1601
|
+
blocks[name] = raw;
|
|
1602
|
+
continue;
|
|
1603
|
+
}
|
|
1604
|
+
const { enabled: _enabled, ...block } = raw;
|
|
1605
|
+
if (Object.keys(block).length || !Object.hasOwn(raw, 'enabled'))
|
|
1606
|
+
blocks[name] = block;
|
|
1607
|
+
}
|
|
1608
|
+
rest.baseagents = blocks;
|
|
1609
|
+
}
|
|
1608
1610
|
return rest;
|
|
1609
1611
|
}
|
|
1612
|
+
function validatePluginConfigForTarget(target, value) {
|
|
1613
|
+
if (target !== ConfigTarget.Agent && target !== ConfigTarget.Defaults)
|
|
1614
|
+
return [];
|
|
1615
|
+
const config = value;
|
|
1616
|
+
const errors = validateBaseagentPluginConfigs(config?.baseagents, target === ConfigTarget.Defaults);
|
|
1617
|
+
for (const name of Object.keys(config?.baseagents ?? {})) {
|
|
1618
|
+
if (!isSupportedBaseagent(name))
|
|
1619
|
+
errors.push(`/baseagents/${name}: plugin is not installed or discovered`);
|
|
1620
|
+
}
|
|
1621
|
+
if (config?.active_baseagent !== undefined && !isSupportedBaseagent(config.active_baseagent)) {
|
|
1622
|
+
errors.push('/active_baseagent: plugin is not installed or discovered');
|
|
1623
|
+
}
|
|
1624
|
+
return errors;
|
|
1625
|
+
}
|
|
1610
1626
|
function stripRelationRoleData(config) {
|
|
1611
1627
|
if (!config || (!Object.prototype.hasOwnProperty.call(config, 'role')
|
|
1612
1628
|
&& !Object.prototype.hasOwnProperty.call(config, 'roles')
|
|
@@ -1646,12 +1662,15 @@ function stripRelationRoleData(config) {
|
|
|
1646
1662
|
* 合并视图:只合并物理覆盖链 defaults → agent/config → relation/config。
|
|
1647
1663
|
*/
|
|
1648
1664
|
export function resolveEffective(sel, opts = {}) {
|
|
1665
|
+
// 默认值已经作为各层的值参与合并(见 resolveAgentConfig),这里不再补任何
|
|
1666
|
+
// 硬编码兜底:任何字段为 undefined 都表示"整条链都没配、且 schema 也没给默认值",
|
|
1667
|
+
// 那就是未配置。规则见 docs/config/11-default-value-levels.md。
|
|
1649
1668
|
const config = resolveAgentConfig(sel, opts);
|
|
1650
|
-
const observableDefault = loadSchema('agent-config').fields.get('observable')?.default;
|
|
1651
|
-
const autoMentionQuietWindowMsDefault = loadSchema('agent-config').fields.get('autoMentionQuietWindowMs')?.default;
|
|
1652
1669
|
const effective = {
|
|
1653
1670
|
$schema_version: config.$schema_version ?? currentVersion('agent-config'),
|
|
1654
1671
|
aid: config.aid ?? sel.self ?? '',
|
|
1672
|
+
...(config.version !== undefined ? { version: config.version } : {}),
|
|
1673
|
+
...(config.update !== undefined ? { update: config.update } : {}),
|
|
1655
1674
|
enabled: config.enabled,
|
|
1656
1675
|
lifecycle: config.lifecycle,
|
|
1657
1676
|
initialized: config.initialized,
|
|
@@ -1659,32 +1678,28 @@ export function resolveEffective(sel, opts = {}) {
|
|
|
1659
1678
|
owner: getPrimaryOwner(sel.self ?? config.aid ?? ''),
|
|
1660
1679
|
owners: getOwners(sel.self ?? config.aid ?? ''),
|
|
1661
1680
|
fullaccess: config.fullaccess,
|
|
1681
|
+
// access 是 Agent 级唯一来源,合并链上不会出现其它层的值;这里只做键序归一,
|
|
1682
|
+
// 保证 `ec config get access` 与 `connect view=access` 输出逐字节一致。
|
|
1683
|
+
access: normalizeAccessPolicy(config.access),
|
|
1662
1684
|
aun: config.aun,
|
|
1663
1685
|
channels: config.channels ?? [],
|
|
1664
1686
|
projects: config.projects,
|
|
1665
1687
|
capabilities: config.capabilities,
|
|
1666
|
-
ability:
|
|
1667
|
-
...config.ability,
|
|
1668
|
-
codeApproval: {
|
|
1669
|
-
...config.ability?.codeApproval,
|
|
1670
|
-
enabled: config.ability?.codeApproval?.enabled ?? true,
|
|
1671
|
-
},
|
|
1672
|
-
},
|
|
1688
|
+
ability: config.ability,
|
|
1673
1689
|
baseagentSkills: config.baseagentSkills,
|
|
1674
1690
|
readonlySourceDiagnostics: config.readonlySourceDiagnostics,
|
|
1675
|
-
|
|
1676
|
-
// factory default here so omitted observable fields are enabled at runtime.
|
|
1677
|
-
observable: config.observable ?? (typeof observableDefault === 'boolean' ? observableDefault : true),
|
|
1691
|
+
observable: config.observable,
|
|
1678
1692
|
extra_backup: config.extra_backup,
|
|
1679
1693
|
// Runtime configuration parameters
|
|
1680
1694
|
active_baseagent: config.active_baseagent,
|
|
1681
1695
|
baseagents: config.baseagents,
|
|
1682
1696
|
Services: config.Services,
|
|
1683
1697
|
chatmode: config.chatmode,
|
|
1698
|
+
// 群聊 @ 策略刻意不带默认值:未配置时要让服务端的 mention_mode 生效。
|
|
1684
1699
|
mentionMode: config.mentionMode,
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
groupSlashRequireMentions: config.groupSlashRequireMentions
|
|
1700
|
+
privateMentionMode: config.privateMentionMode,
|
|
1701
|
+
autoMentionQuietWindowMs: config.autoMentionQuietWindowMs,
|
|
1702
|
+
groupSlashRequireMentions: config.groupSlashRequireMentions,
|
|
1688
1703
|
responseMode: config.responseMode,
|
|
1689
1704
|
responseModeParams: config.responseModeParams,
|
|
1690
1705
|
flush_delay: config.flush_delay,
|
|
@@ -1710,6 +1725,35 @@ export function assertAgentModelConfigured(self, baseagent) {
|
|
|
1710
1725
|
throw new ConfigError('MODEL_NOT_CONFIGURED', `Configure baseagents.${backend}.model before enabling or selecting this backend`);
|
|
1711
1726
|
}
|
|
1712
1727
|
}
|
|
1728
|
+
/**
|
|
1729
|
+
* 按固定字段顺序重排准入策略,并裁掉未配置的键。
|
|
1730
|
+
*
|
|
1731
|
+
* 值本身全部来自合并链(defaults → agent 的 schema 默认值层 + 配置文件),这里
|
|
1732
|
+
* **不补任何默认值**:`allowExternalContacts` / `contactAdmission` 没有默认值,
|
|
1733
|
+
* 未配置就必须是未配置(个人助理按身份判定的逻辑依赖这一点)。只做两件事:
|
|
1734
|
+
* 固定键序(`ec config get access` 与 `connect view=access` 必须逐字节一致),
|
|
1735
|
+
* 以及 array 字段拷贝一份,避免调用方改写污染配置缓存。
|
|
1736
|
+
*/
|
|
1737
|
+
function normalizeAccessPolicy(policy) {
|
|
1738
|
+
if (!policy)
|
|
1739
|
+
return policy;
|
|
1740
|
+
return {
|
|
1741
|
+
...(policy.contactAdmission !== undefined ? { contactAdmission: policy.contactAdmission } : {}),
|
|
1742
|
+
...(policy.allowInternalContacts !== undefined ? { allowInternalContacts: policy.allowInternalContacts } : {}),
|
|
1743
|
+
// allowExternalContacts 没有 schema 默认值:未配置时保持缺席,由个人助理身份判定接管。
|
|
1744
|
+
...(policy.allowExternalContacts !== undefined ? { allowExternalContacts: policy.allowExternalContacts } : {}),
|
|
1745
|
+
...(policy.allowAllContacts !== undefined ? { allowAllContacts: policy.allowAllContacts } : {}),
|
|
1746
|
+
...(policy.allowedAids !== undefined ? { allowedAids: [...policy.allowedAids] } : {}),
|
|
1747
|
+
...(policy.deniedAids !== undefined ? { deniedAids: [...policy.deniedAids] } : {}),
|
|
1748
|
+
// requestLimit 的两个子字段在 agent-config schema 里有默认值,合并后必然齐全;
|
|
1749
|
+
// 兜底值只防 schema 被误删时算出 NaN 频控窗口(不 import DEFAULT_ACCESS_POLICY,
|
|
1750
|
+
// 那会造成 access-policy ↔ config-manager 的循环依赖)。
|
|
1751
|
+
requestLimit: {
|
|
1752
|
+
maxTimes: policy.requestLimit?.maxTimes ?? 600,
|
|
1753
|
+
coolDown: policy.requestLimit?.coolDown ?? 3600,
|
|
1754
|
+
},
|
|
1755
|
+
};
|
|
1756
|
+
}
|
|
1713
1757
|
function normalizeEffectiveCompatibility(effective) {
|
|
1714
1758
|
normalizeShowActivitiesCompat(effective);
|
|
1715
1759
|
const behavior = {};
|
|
@@ -1727,6 +1771,7 @@ const EFFECTIVE_BEHAVIOR_FIELDS = [
|
|
|
1727
1771
|
'baseagents',
|
|
1728
1772
|
'chatmode',
|
|
1729
1773
|
'mentionMode',
|
|
1774
|
+
'privateMentionMode',
|
|
1730
1775
|
'autoMentionQuietWindowMs',
|
|
1731
1776
|
'groupSlashRequireMentions',
|
|
1732
1777
|
'flush_delay',
|
|
@@ -1754,6 +1799,11 @@ export function routeFieldPath(fieldPath, scope) {
|
|
|
1754
1799
|
if (scope === 'relation' && isAgentOnlyBaseagentField(fieldPath)) {
|
|
1755
1800
|
throw new ConfigError('SCOPE_MISMATCH', `${fieldPath} is Agent-scoped and cannot be configured per relation`);
|
|
1756
1801
|
}
|
|
1802
|
+
// privateMentionMode 只存在于 agent-config:私聊提及模式是 Agent 的身份级开关,
|
|
1803
|
+
// 不按对端区分。显式拒绝,避免落成一条永远读不到的孤儿配置。
|
|
1804
|
+
if (scope === 'relation' && topField === 'privateMentionMode') {
|
|
1805
|
+
throw new ConfigError('SCOPE_MISMATCH', `${fieldPath} is Agent-scoped and cannot be configured per relation`);
|
|
1806
|
+
}
|
|
1757
1807
|
if (topField === 'sessionLoop') {
|
|
1758
1808
|
throw new ConfigError('SESSION_LOOP_MANAGED', 'sessionLoop is managed through the dedicated /loop or session Menu entry');
|
|
1759
1809
|
}
|
|
@@ -381,13 +381,20 @@ function executeGet(op, options) {
|
|
|
381
381
|
? diagnoseRelationLayer(op, withSource.source?.target === ConfigTarget.Relation)
|
|
382
382
|
: undefined;
|
|
383
383
|
if (withSource.source) {
|
|
384
|
+
// 顶层对象存在、叶子缺失(例如 access 写了 allowAllContacts 但没写
|
|
385
|
+
// requestLimit.coolDown):值按 schema default 回落,来源仍报告存储层,
|
|
386
|
+
// 让调用方知道"这块配过一部分"。
|
|
387
|
+
const value = withSource.value !== undefined
|
|
388
|
+
? withSource.value
|
|
389
|
+
: fieldSchemaDefault(op.route?.schema ?? 'agent-config', op.field);
|
|
384
390
|
return {
|
|
385
391
|
ok: true,
|
|
386
392
|
subcommand: 'get',
|
|
387
393
|
field: op.field,
|
|
388
|
-
value:
|
|
394
|
+
value: value ?? null,
|
|
389
395
|
scope: op.configScope,
|
|
390
396
|
source: withSource.source,
|
|
397
|
+
...(withSource.value === undefined && value !== undefined ? { schemaDefault: true } : {}),
|
|
391
398
|
...(note ? { note } : {}),
|
|
392
399
|
};
|
|
393
400
|
}
|
|
@@ -398,6 +405,20 @@ function executeGet(op, options) {
|
|
|
398
405
|
if (withSource.value !== undefined && !op.route) {
|
|
399
406
|
return { ok: true, subcommand: 'get', field: op.field, value: withSource.value, scope: op.configScope };
|
|
400
407
|
}
|
|
408
|
+
// 有 route 但没有任何存储层配置过:值来自 schema 默认值层(它作为该层的值参与了
|
|
409
|
+
// 合并,见 docs/config/11-default-value-levels.md)。必须标 schemaDefault,
|
|
410
|
+
// 否则文本输出会误报成一次普通取值。
|
|
411
|
+
if (withSource.value !== undefined && op.route) {
|
|
412
|
+
return {
|
|
413
|
+
ok: true,
|
|
414
|
+
subcommand: 'get',
|
|
415
|
+
field: op.field,
|
|
416
|
+
value: withSource.value,
|
|
417
|
+
scope: op.configScope,
|
|
418
|
+
schemaDefault: true,
|
|
419
|
+
...(note ? { note } : {}),
|
|
420
|
+
};
|
|
421
|
+
}
|
|
401
422
|
return getWithSchemaDefault(op, null, note);
|
|
402
423
|
}
|
|
403
424
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { listSupportedBaseagents } from '../agents/baseagent.js';
|
|
1
2
|
/**
|
|
2
3
|
* gateway-config.ts — baseagent 模型选择与 provider 指认管理。
|
|
3
4
|
*
|
|
@@ -23,7 +24,7 @@ import { logger } from '../utils/logger.js';
|
|
|
23
24
|
import { resolveProviderServiceForBaseagent } from './providers.js';
|
|
24
25
|
import { stripLegacyAunGatewayConfig } from './config-manager.js';
|
|
25
26
|
/** 已知 baseagent 类型(模型选择可管理范围)。 */
|
|
26
|
-
const
|
|
27
|
+
const gatewayTypes = () => listSupportedBaseagents();
|
|
27
28
|
const DISPLAY_NAMES = {
|
|
28
29
|
claude: 'Claude',
|
|
29
30
|
codex: 'Codex (OpenAI)',
|
|
@@ -74,7 +75,7 @@ function extractEntries(raw, scope) {
|
|
|
74
75
|
const ba = raw?.baseagents;
|
|
75
76
|
if (!ba || typeof ba !== 'object')
|
|
76
77
|
return out;
|
|
77
|
-
for (const type of
|
|
78
|
+
for (const type of gatewayTypes()) {
|
|
78
79
|
const c = ba[type];
|
|
79
80
|
if (!c || typeof c !== 'object')
|
|
80
81
|
continue;
|
|
@@ -104,7 +105,7 @@ export function gatewayList() {
|
|
|
104
105
|
gateways.push(...extractEntries(raw, aid));
|
|
105
106
|
}
|
|
106
107
|
const effective = computeEffective(aids);
|
|
107
|
-
return { data: { gateways, scopes: aids, types:
|
|
108
|
+
return { data: { gateways, scopes: aids, types: gatewayTypes(), effective } };
|
|
108
109
|
}
|
|
109
110
|
catch (e) {
|
|
110
111
|
logger.error('[gateway] gatewayList 执行出错:', e);
|
|
@@ -123,7 +124,7 @@ function computeEffective(aids) {
|
|
|
123
124
|
logger.error(`[GatewayConfig] active_baseagent is empty for aid=${aid}, skipping`);
|
|
124
125
|
continue;
|
|
125
126
|
}
|
|
126
|
-
if (!
|
|
127
|
+
if (!gatewayTypes().includes(activeRaw)) {
|
|
127
128
|
logger.error(`[GatewayConfig] unknown baseagent type '${activeRaw}' for aid=${aid}, skipping`);
|
|
128
129
|
continue;
|
|
129
130
|
}
|
|
@@ -143,7 +144,7 @@ function computeEffective(aids) {
|
|
|
143
144
|
// ── 写入 ──
|
|
144
145
|
/** 校验 type 合法。 */
|
|
145
146
|
function validateType(type) {
|
|
146
|
-
return typeof type === 'string' &&
|
|
147
|
+
return typeof type === 'string' && gatewayTypes().includes(type);
|
|
147
148
|
}
|
|
148
149
|
/** 网关连接信息(baseUrl/apiKey/headers/queryParams)只存在于 providers.json,Agent 级只选 provider。 */
|
|
149
150
|
const REMOVED_GATEWAY_FIELDS = ['baseUrl', 'apiKey', 'model', 'effort', 'reasoning', 'mode', 'useVertex', 'project', 'location'];
|
|
@@ -194,7 +195,7 @@ export async function gatewayUpdate(args) {
|
|
|
194
195
|
return { error: 'defaults 不承载 baseagent 配置;连接信息在 providers.json,模型选择在各 Agent 的 config.json', code: 'INVALID_ARGS' };
|
|
195
196
|
}
|
|
196
197
|
if (!validateType(type))
|
|
197
|
-
return { error: `无效 type: ${type}(可选 ${
|
|
198
|
+
return { error: `无效 type: ${type}(可选 ${gatewayTypes().join('/')})`, code: 'INVALID_ARGS' };
|
|
198
199
|
const built = buildPatch(type, args?.patch ?? {});
|
|
199
200
|
if ('error' in built)
|
|
200
201
|
return { error: built.error, code: 'INVALID_ARGS' };
|
|
@@ -256,12 +257,12 @@ function resolveGatewayCreds(scope, type) {
|
|
|
256
257
|
return {
|
|
257
258
|
baseUrl: resolved.baseUrl,
|
|
258
259
|
apiKey: resolved.apiKey,
|
|
259
|
-
headers: buildModelRequestHeaders({
|
|
260
|
+
headers: type === 'claude' || type === 'codex' || type === 'ecagent' ? buildModelRequestHeaders({
|
|
260
261
|
baseagent: type,
|
|
261
262
|
baseUrl: resolved.baseUrl,
|
|
262
263
|
agentAid: scope,
|
|
263
264
|
configuredHeaders: resolved.headers,
|
|
264
|
-
}),
|
|
265
|
+
}) : resolved.headers,
|
|
265
266
|
queryParams: resolved.queryParams,
|
|
266
267
|
};
|
|
267
268
|
}
|
|
@@ -21,17 +21,6 @@ export function firstConfiguredOwner(value) {
|
|
|
21
21
|
}
|
|
22
22
|
return undefined;
|
|
23
23
|
}
|
|
24
|
-
/** Runtime compatibility projection for binding-target input; this is not an authorization list. */
|
|
25
|
-
export function configuredOwnerList(value) {
|
|
26
|
-
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
27
|
-
return [];
|
|
28
|
-
const record = value;
|
|
29
|
-
const values = [record.owner, ...(Array.isArray(record.owners) ? record.owners : [])];
|
|
30
|
-
return [...new Set(values
|
|
31
|
-
.filter((candidate) => typeof candidate === 'string')
|
|
32
|
-
.map(candidate => candidate.trim())
|
|
33
|
-
.filter(Boolean))];
|
|
34
|
-
}
|
|
35
24
|
export function assertOwnerConfigRecord(value, label, validateId) {
|
|
36
25
|
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
37
26
|
return;
|
|
@@ -55,11 +44,6 @@ export function assertOwnerConfigRecord(value, label, validateId) {
|
|
|
55
44
|
}
|
|
56
45
|
});
|
|
57
46
|
}
|
|
58
|
-
for (const owner of configuredOwnerList(record)) {
|
|
59
|
-
if (validateId && !validateId(owner)) {
|
|
60
|
-
throw new Error(`${label}.owner is invalid: ${JSON.stringify(owner)}`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
47
|
}
|
|
64
48
|
/** Normalize one config record for persistence: write only the scalar owner. */
|
|
65
49
|
export function normalizeSingleOwnerRecord(value) {
|
|
@@ -9,7 +9,6 @@ import { isManagementRole } from './builtin-roles.js';
|
|
|
9
9
|
import { getRoleDefinition, getRoleRank, normalizeDefaultRole, roleExists } from './roles.js';
|
|
10
10
|
import { getStoredRoleRegistry, roleRegistryExists } from './role-store.js';
|
|
11
11
|
import { resolvePrincipal } from './peer-book.js';
|
|
12
|
-
import { configuredOwnerList } from './owner-config.js';
|
|
13
12
|
import { tryParseChannelKey } from '../core/channel-loader.js';
|
|
14
13
|
import { isValidAid } from '../aun/aid/validation.js';
|
|
15
14
|
import { getOwners, ownerResolver } from '../core/ownership/owner-resolver.js';
|
|
@@ -19,13 +18,8 @@ import { isOwnerDirectoryContact } from '../directory/owner-directory-admission.
|
|
|
19
18
|
export function isAuthenticated(userId) {
|
|
20
19
|
return isValidAid(String(userId || '').trim());
|
|
21
20
|
}
|
|
22
|
-
/** Return the protocol Owner
|
|
21
|
+
/** Return the protocol Owner. Configured values are never an authorization source. */
|
|
23
22
|
export function listStaticAgentOwners(aid, opts = {}) {
|
|
24
|
-
try {
|
|
25
|
-
const config = read(ConfigTarget.Agent, { self: aid }, { cache: opts.fresh !== true });
|
|
26
|
-
ownerResolver.setAgentConfiguredOwners(aid, configuredOwnerList(config));
|
|
27
|
-
}
|
|
28
|
-
catch { }
|
|
29
23
|
return ownerResolver.owners(aid);
|
|
30
24
|
}
|
|
31
25
|
/** Direct AUN relations with role=admin are the addressable Agent admin set. */
|