evolcore 0.0.43-test.1 → 0.0.43-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 +24 -1
- package/README.md +22 -0
- package/dist/agents/claude-runner.js +26 -2
- package/dist/agents/codex/app-server-client.js +12 -0
- package/dist/agents/codex-runner.js +49 -8
- package/dist/agents/ecagent-runner.js +26 -9
- package/dist/agents/gemini-runner.js +15 -12
- package/dist/agents/tool-time-context.js +55 -0
- package/dist/aun/menu/client.js +1 -1
- package/dist/aun/model-headers.js +17 -0
- package/dist/aun/msg/p2p.js +3 -0
- package/dist/channels/aun.js +484 -43
- package/dist/channels/builtin-plugins.js +16 -11
- package/dist/channels/dingtalk.js +83 -31
- package/dist/channels/feishu.js +29 -13
- package/dist/channels/qqbot.js +32 -11
- package/dist/channels/wechat.js +13 -3
- package/dist/channels/wecom.js +67 -27
- package/dist/cli/agent-command.js +3 -86
- package/dist/cli/agent-create.js +22 -6
- package/dist/cli/agent.js +1 -79
- package/dist/cli/aun-commands.js +1 -0
- package/dist/cli/config.js +1 -1
- package/dist/cli/daemon-commands.js +47 -2
- package/dist/cli/data-command.js +9 -1
- package/dist/cli/debug-mode.js +1 -1
- package/dist/cli/diag.js +1 -1
- package/dist/cli/directory.js +77 -64
- package/dist/cli/getmeta-command.js +1 -1
- package/dist/cli/index.js +79 -22
- package/dist/cli/init.js +1 -23
- package/dist/cli/link-rules.js +1 -1
- package/dist/cli/managed-command-guard.js +0 -1
- package/dist/cli/pa-workspace-command.js +36 -2
- package/dist/cli/peer.js +1 -1
- package/dist/cli/restart-monitor.js +17 -3
- package/dist/cli/role.js +1 -1
- package/dist/cli/session-command.js +1 -1
- package/dist/cli/stats.js +2 -2
- package/dist/cli/thread-command.js +1 -1
- package/dist/cli/watch-msg.js +1 -1
- package/dist/config/access-policy.js +1 -0
- package/dist/config/config-field-policy.js +2 -2
- package/dist/config/config-manager.js +7 -0
- package/dist/config/role-schema.js +4 -3
- package/dist/config/role-service.js +3 -3
- package/dist/config-store.js +75 -4
- package/dist/core/agent-ipc-registration.js +16 -59
- package/dist/core/auth/authorization-audit.js +52 -14
- package/dist/core/auth/operation-authorizer.js +0 -11
- package/dist/core/auth/operation-catalog.js +0 -18
- package/dist/core/channel-loader.js +152 -16
- package/dist/core/command/agent-control.js +2 -1
- package/dist/core/command/cli-intent-parser.js +0 -8
- package/dist/core/command/command-handler.js +17 -46
- package/dist/core/command/connect-menu.js +7 -3
- package/dist/core/command/menu-catalog.js +3 -2
- package/dist/core/command/menu-handler.js +51 -8
- package/dist/core/command/menu-protocol.js +20 -0
- package/dist/core/command/slash-handler.js +101 -40
- package/dist/core/daemon-file-cache.js +3 -3
- package/dist/core/evolagent-registry.js +5 -4
- package/dist/core/evolagent.js +5 -8
- package/dist/core/handoff/argv-parse.js +115 -0
- package/dist/core/handoff/ipc-registration.js +1 -1
- package/dist/core/ipc-registration.js +19 -2
- package/dist/core/memory/consolidation.js +8 -1
- package/dist/core/memory/relation-sweep.js +20 -8
- package/dist/core/message/aun-ipc-sender.js +28 -1
- package/dist/core/message/contact-admission.js +548 -0
- package/dist/core/message/im-renderer.js +69 -10
- package/dist/core/message/message-admission.js +28 -3
- package/dist/core/message/message-bridge.js +46 -5
- package/dist/core/message/message-utils.js +0 -5
- package/dist/core/message/peer-mode.js +44 -10
- package/dist/core/message/response-engine.js +268 -69
- package/dist/core/message/retry-scheduler.js +4 -0
- package/dist/core/permission/ec-command-parser.js +1 -28
- package/dist/core/permission/readonly-shell-query.js +34 -8
- package/dist/core/permission/tool-policy.js +50 -5
- package/dist/core/role/runtime-policy.js +14 -2
- package/dist/core/session/session-manager.js +9 -1
- package/dist/core/soul.js +66 -0
- package/dist/core/system-session/memory.js +2 -2
- package/dist/directory/contact-admission-paths.js +9 -0
- package/dist/directory/owner-directory-admission.js +128 -29
- package/dist/directory/owner-directory-cache.js +364 -50
- package/dist/directory/owner-directory-identity.js +60 -0
- package/dist/directory/owner-directory-markdown.js +120 -47
- package/dist/directory/owner-directory-policy.js +108 -0
- package/dist/directory/owner-directory-query-operation.js +219 -32
- package/dist/directory/owner-directory-remarks.js +29 -2
- package/dist/directory/owner-directory-search.js +50 -18
- package/dist/directory/owner-directory-store.js +150 -30
- package/dist/eck/kit-renderer.js +12 -5
- package/dist/eck/manifest-engine.js +55 -6
- package/dist/eck/message-renderer.js +5 -2
- package/dist/eck/paactive-context.js +45 -0
- package/dist/ecweb/basic-settings-service.js +2 -2
- package/dist/ecweb/message-context-service.js +24 -16
- package/dist/index.js +9 -5
- package/dist/ipc.js +1 -1
- package/dist/paths.js +26 -0
- package/dist/response-system/config-resolver.js +1 -1
- package/dist/response-system/engines/v1/index.js +4 -1
- package/dist/response-system/engines/v1/paactive-flow.js +18 -0
- package/dist/response-system/modes/single-session/index.js +7 -2
- package/dist/trigger/scheduler.js +3 -5
- package/dist/trigger/validation.js +4 -0
- package/dist/utils/error-utils.js +5 -2
- package/dist/utils/logger.js +13 -4
- package/dist/utils/npm-ops.js +2 -2
- package/dist/utils/windows-autostart.js +1 -1
- package/ecagent/dist/agent-loop.js +43 -1
- package/kits/docs/INDEX.md +1 -0
- package/kits/docs/context-assembly.md +21 -6
- package/kits/docs/eck_templates/INDEX.template.md +1 -2
- package/kits/docs/evolcore/INDEX.md +1 -1
- package/kits/docs/evolcore/agent-create.md +5 -5
- package/kits/docs/evolcore/agent.md +4 -9
- package/kits/docs/evolcore/directory.md +137 -0
- package/kits/docs/evolcore/menu-protocol.md +55 -0
- package/kits/docs/evolcore/response.md +7 -1
- package/kits/docs/evolcore/tool-authorization.md +1 -1
- package/kits/docs/evolcore/trigger.md +4 -0
- package/kits/docs/prompt-loading-architecture.md +6 -2
- package/kits/eck_manifest.auxiliary.json +1 -0
- package/kits/eck_manifest.json +57 -4
- package/kits/eck_manifest.memory.json +67 -3
- package/kits/eck_manifest.paactive.json +528 -0
- package/kits/eck_message_manifest.paactive.json +233 -0
- package/kits/rules/01-overview.md +2 -2
- package/kits/rules/03-identity.md +10 -9
- package/kits/rules/05-venue.md +2 -4
- package/kits/rules/06-channel.md +1 -1
- package/kits/schemas/_meta.json +31 -3
- package/kits/schemas/agent-config.schema.18.json +5 -0
- package/kits/schemas/agent-config.schema.19.json +924 -0
- package/kits/schemas/relation-config.schema.12.json +289 -0
- package/kits/schemas/role-config.schema.2.json +215 -0
- package/kits/skills/ec-skill/scripts/cli.mjs +3 -2
- package/kits/skills/ec-trigger/SKILL.md +4 -4
- package/kits/skills/personal-assistant/SKILL.md +109 -53
- package/kits/skills/personal-assistant/references/02-bootstrap.md +73 -30
- package/kits/skills/personal-assistant/scripts/clean.mjs +35 -18
- package/kits/skills/personal-assistant/scripts/init.mjs +41 -2
- package/kits/skills/personal-assistant/scripts/lib/persona.mjs +185 -0
- package/kits/skills/personal-assistant/scripts/migrate.mjs +55 -4
- package/kits/skills/personal-assistant/scripts/pa.mjs +173 -0
- package/kits/skills/personal-assistant/scripts/uninstall.mjs +130 -0
- package/kits/skills/personal-assistant/templates/persona-section.md +3 -3
- package/kits/templates/message-fragments/handoff-request-to-target.md +1 -1
- package/kits/templates/message-fragments/paactive/item.md +3 -0
- package/kits/templates/soul/00-GUIDE.md +61 -0
- package/kits/templates/soul/01-identity.md +5 -0
- package/kits/templates/soul/02-persona.md +11 -0
- package/kits/templates/soul/03-duties.md +5 -0
- package/kits/templates/soul/04-working-style.md +5 -0
- package/kits/templates/system-fragments/bootstrap.md +7 -7
- package/kits/templates/system-fragments/commands.md +3 -2
- package/kits/templates/system-fragments/directory-contacts.md +9 -0
- package/kits/templates/system-fragments/memory.md +1 -1
- package/kits/templates/system-fragments/paactive/channel.md +25 -0
- package/kits/templates/system-fragments/paactive/reply.md +25 -0
- package/kits/templates/system-fragments/paactive/session.md +32 -0
- package/kits/templates/system-fragments/personal-assistant.md +65 -0
- package/package.json +3 -2
- package/dist/cli/handoff-command.js +0 -353
- package/dist/directory/owner-directory-remark-operation.js +0 -147
- package/kits/docs/evolcore/self-summary.md +0 -29
|
@@ -169,16 +169,6 @@ const OPERATIONS = [
|
|
|
169
169
|
authorizationTarget: 'same-owner-agent',
|
|
170
170
|
authorizationPolicy: { authority: 'agent-owner', permissionMode: 'bypass', mode: 'require' },
|
|
171
171
|
},
|
|
172
|
-
{
|
|
173
|
-
id: 'ec.directory.remark',
|
|
174
|
-
category: 'write-own',
|
|
175
|
-
dangerous: false,
|
|
176
|
-
defaultScopes: ['agent'],
|
|
177
|
-
description: 'Manage the current Agent owner directory remarks',
|
|
178
|
-
sources: ['agent-tool'],
|
|
179
|
-
authorizationTarget: 'same-owner-agent',
|
|
180
|
-
authorizationPolicy: { authority: 'agent-owner', permissionMode: 'bypass', mode: 'require' },
|
|
181
|
-
},
|
|
182
172
|
...PROVIDER_OPERATIONS,
|
|
183
173
|
{
|
|
184
174
|
id: 'proxy.read',
|
|
@@ -829,14 +819,6 @@ const OPERATIONS = [
|
|
|
829
819
|
description: '获取 agent 配置(含凭证)',
|
|
830
820
|
sources: ['menu', 'menu.cli', 'control'],
|
|
831
821
|
},
|
|
832
|
-
{
|
|
833
|
-
id: 'agent.persona',
|
|
834
|
-
category: 'write-agent',
|
|
835
|
-
dangerous: false,
|
|
836
|
-
defaultScopes: ['agent'],
|
|
837
|
-
description: '读取或更新当前 Agent 的 persona.md',
|
|
838
|
-
sources: ['agent-tool', 'slash', 'menu', 'control'],
|
|
839
|
-
},
|
|
840
822
|
{
|
|
841
823
|
id: 'agent.welcome',
|
|
842
824
|
category: 'write-agent',
|
|
@@ -9,6 +9,10 @@ import { logger } from '../utils/logger.js';
|
|
|
9
9
|
import { assertAgentAidAvailable } from '../config/config-manager.js';
|
|
10
10
|
import { PluginHandle } from './plugin-lifecycle.js';
|
|
11
11
|
import { ContactBindRegistry } from './contact-bind-registry.js';
|
|
12
|
+
function isMissingChannelDependency(error) {
|
|
13
|
+
const code = error?.code;
|
|
14
|
+
return code === 'ERR_MODULE_NOT_FOUND' || code === 'MODULE_NOT_FOUND';
|
|
15
|
+
}
|
|
12
16
|
// ── Shared helpers for plugins ─────────────────────────────────────────────
|
|
13
17
|
/** Resolve showActivities for a single instance (instance overrides default). */
|
|
14
18
|
export function resolveShowActivities(inst) {
|
|
@@ -16,7 +20,7 @@ export function resolveShowActivities(inst) {
|
|
|
16
20
|
}
|
|
17
21
|
/**
|
|
18
22
|
* showMiddleResult / showIdleMonitor 策略。
|
|
19
|
-
* show_activities
|
|
23
|
+
* show_activities 对 interactive/paactive 私聊中间输出生效:
|
|
20
24
|
* all → 文本 + activity;text → 仅文本;none → 全部静默。
|
|
21
25
|
*/
|
|
22
26
|
export function middleOutputModePolicy(mode, chatType, _identity) {
|
|
@@ -32,6 +36,8 @@ export class ChannelLoader {
|
|
|
32
36
|
processDebug;
|
|
33
37
|
aunDefaultEncrypt;
|
|
34
38
|
plugins = new Map();
|
|
39
|
+
providerStatuses = new Map();
|
|
40
|
+
instanceStatuses = new Map();
|
|
35
41
|
contactBindRegistry = new ContactBindRegistry();
|
|
36
42
|
constructor(processDebug, aunDefaultEncrypt) {
|
|
37
43
|
this.processDebug = processDebug;
|
|
@@ -44,12 +50,84 @@ export class ChannelLoader {
|
|
|
44
50
|
if (plugin.contactBind)
|
|
45
51
|
this.contactBindRegistry.register(plugin.name, plugin.contactBind);
|
|
46
52
|
this.plugins.set(plugin.name, plugin);
|
|
53
|
+
this.providerStatuses.set(plugin.name, { channelType: plugin.name, status: 'loaded' });
|
|
47
54
|
logger.debug(`Registered channel plugin: ${plugin.name}`);
|
|
48
55
|
}
|
|
49
56
|
/** Look up a registered plugin by channel type (used by reload hooks). */
|
|
50
57
|
getPlugin(type) {
|
|
51
58
|
return this.plugins.get(type);
|
|
52
59
|
}
|
|
60
|
+
recordProviderFailure(channelType, error) {
|
|
61
|
+
if (this.plugins.has(channelType))
|
|
62
|
+
throw new Error(`Channel plugin '${channelType}' already registered`);
|
|
63
|
+
const missing = isMissingChannelDependency(error);
|
|
64
|
+
this.providerStatuses.set(channelType, {
|
|
65
|
+
channelType,
|
|
66
|
+
status: missing ? 'unavailable' : 'failed',
|
|
67
|
+
reason: missing
|
|
68
|
+
? { code: 'DEPENDENCY_MISSING', message: '渠道实现或依赖未安装' }
|
|
69
|
+
: { code: 'LOAD_FAILED', message: '渠道实现加载失败' },
|
|
70
|
+
});
|
|
71
|
+
logger.warn(`[ChannelLoader] Failed to load '${channelType}':`, error);
|
|
72
|
+
}
|
|
73
|
+
getSnapshot(agents) {
|
|
74
|
+
const configured = agents?.flatMap(agent => [
|
|
75
|
+
{ agentAid: agent.aid, channelType: 'aun', channelName: agent.effectiveChannelName('aun', 'main'), enabled: agent.config.enabled !== false },
|
|
76
|
+
...agent.config.channels.filter(inst => inst.type !== 'aun').map(inst => ({
|
|
77
|
+
agentAid: agent.aid, channelType: inst.type,
|
|
78
|
+
channelName: agent.effectiveChannelName(inst.type, inst.name),
|
|
79
|
+
enabled: agent.config.enabled !== false && inst.enabled !== false,
|
|
80
|
+
})),
|
|
81
|
+
]);
|
|
82
|
+
const entries = configured ? configured.map(config => {
|
|
83
|
+
const key = `${config.agentAid}::${config.channelName}`;
|
|
84
|
+
const recorded = this.instanceStatuses.get(key);
|
|
85
|
+
if (config.enabled && recorded?.snapshot.channelType === config.channelType)
|
|
86
|
+
return recorded;
|
|
87
|
+
const snapshot = {
|
|
88
|
+
agentAid: config.agentAid, channelName: config.channelName, channelType: config.channelType,
|
|
89
|
+
status: config.enabled ? 'disconnected' : 'disabled',
|
|
90
|
+
...(!config.enabled ? { reason: { code: 'CONFIG_DISABLED', message: '配置已禁用' } } : {}),
|
|
91
|
+
};
|
|
92
|
+
if (config.enabled && !this.plugins.has(config.channelType)) {
|
|
93
|
+
const provider = this.providerStatuses.get(config.channelType);
|
|
94
|
+
snapshot.status = provider?.status === 'failed' ? 'failed' : 'unavailable';
|
|
95
|
+
snapshot.reason = provider?.reason ?? { code: 'PROVIDER_NOT_FOUND', message: '渠道实现未注册' };
|
|
96
|
+
}
|
|
97
|
+
return { snapshot, runtime: undefined };
|
|
98
|
+
}) : [...this.instanceStatuses.values()];
|
|
99
|
+
const instances = entries.map(({ snapshot, runtime }) => {
|
|
100
|
+
const current = { ...snapshot, ...(snapshot.reason ? { reason: { ...snapshot.reason } } : {}) };
|
|
101
|
+
if (runtime && !runtime.lifecycle?.signal.aborted && snapshot.status !== 'connecting') {
|
|
102
|
+
try {
|
|
103
|
+
const live = runtime.channel.getStatus?.();
|
|
104
|
+
if (live?.connected === true) {
|
|
105
|
+
current.status = 'connected';
|
|
106
|
+
delete current.reason;
|
|
107
|
+
}
|
|
108
|
+
else if (live?.connected === false && current.status === 'connected') {
|
|
109
|
+
current.status = 'disconnected';
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
current.status = 'failed';
|
|
114
|
+
current.reason = { code: 'STATUS_FAILED', message: '渠道状态读取失败' };
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return current;
|
|
118
|
+
});
|
|
119
|
+
if (configured) {
|
|
120
|
+
const keys = new Set(configured.map(config => `${config.agentAid}::${config.channelName}`));
|
|
121
|
+
for (const [key, entry] of this.instanceStatuses) {
|
|
122
|
+
if (!keys.has(key) && !entry.runtime)
|
|
123
|
+
this.instanceStatuses.delete(key);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
providers: [...this.providerStatuses.values()].map(item => ({ ...item, ...(item.reason ? { reason: { ...item.reason } } : {}) })),
|
|
128
|
+
instances,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
53
131
|
/**
|
|
54
132
|
* Create all runtime channels for an agent directly from its config.channels[].
|
|
55
133
|
* AUN is always created implicitly from agent.aid (no explicit entry required).
|
|
@@ -85,11 +163,6 @@ export class ChannelLoader {
|
|
|
85
163
|
async _buildInstances(configInsts, ctx) {
|
|
86
164
|
const result = [];
|
|
87
165
|
for (const inst of configInsts) {
|
|
88
|
-
const plugin = this.plugins.get(inst.type);
|
|
89
|
-
if (!plugin) {
|
|
90
|
-
logger.debug(`No plugin for channel type '${inst.type}', skipping`);
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
166
|
try {
|
|
94
167
|
const runtime = await this.createInstance(inst, ctx);
|
|
95
168
|
if (runtime) {
|
|
@@ -97,7 +170,8 @@ export class ChannelLoader {
|
|
|
97
170
|
logger.info(`✓ Channel '${inst.name}' (${inst.type}) created`);
|
|
98
171
|
}
|
|
99
172
|
else {
|
|
100
|
-
|
|
173
|
+
const status = this.instanceStatuses.get(`${ctx.agentName}::${inst.name}`)?.snapshot;
|
|
174
|
+
logger.info(`Channel '${inst.name}' (${inst.type}) skipped: ${status?.reason?.code ?? status?.status}`);
|
|
101
175
|
}
|
|
102
176
|
}
|
|
103
177
|
catch (err) {
|
|
@@ -107,31 +181,92 @@ export class ChannelLoader {
|
|
|
107
181
|
return result;
|
|
108
182
|
}
|
|
109
183
|
async createInstance(inst, ctx) {
|
|
184
|
+
const key = `${ctx.agentName}::${inst.name}`;
|
|
185
|
+
const snapshot = {
|
|
186
|
+
agentAid: ctx.agentName, channelName: inst.name, channelType: inst.type, status: 'created',
|
|
187
|
+
};
|
|
188
|
+
const entry = { snapshot };
|
|
189
|
+
this.instanceStatuses.set(key, entry);
|
|
190
|
+
if (inst.enabled === false) {
|
|
191
|
+
snapshot.status = 'disabled';
|
|
192
|
+
snapshot.reason = { code: 'CONFIG_DISABLED', message: '渠道配置已禁用' };
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
110
195
|
const plugin = this.plugins.get(inst.type);
|
|
111
|
-
if (!plugin)
|
|
112
|
-
|
|
196
|
+
if (!plugin) {
|
|
197
|
+
const provider = this.providerStatuses.get(inst.type);
|
|
198
|
+
snapshot.status = provider?.status === 'failed' ? 'failed' : 'unavailable';
|
|
199
|
+
snapshot.reason = provider?.reason ?? { code: 'PROVIDER_NOT_FOUND', message: '渠道实现未注册' };
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
113
202
|
let teardown;
|
|
114
203
|
const lifecycle = new PluginHandle(`${ctx.agentName}::${inst.name}`, () => teardown?.());
|
|
115
204
|
try {
|
|
116
205
|
const runtime = await plugin.createInstance(inst, { ...ctx, lifecycle });
|
|
117
206
|
if (!runtime) {
|
|
207
|
+
snapshot.status = 'unavailable';
|
|
208
|
+
snapshot.reason = { code: 'INVALID_CONFIG', message: '渠道配置不完整或无效' };
|
|
118
209
|
await lifecycle.dispose();
|
|
119
210
|
return null;
|
|
120
211
|
}
|
|
121
212
|
teardown = runtime.disconnect.bind(runtime);
|
|
122
213
|
const connect = runtime.connect.bind(runtime);
|
|
123
214
|
runtime.lifecycle = lifecycle;
|
|
124
|
-
runtime
|
|
125
|
-
runtime.
|
|
215
|
+
entry.runtime = runtime;
|
|
216
|
+
runtime.disconnect = () => {
|
|
217
|
+
if (inst.type === 'aun' || (snapshot.status !== 'failed' && snapshot.status !== 'unavailable')) {
|
|
218
|
+
snapshot.status = 'disconnected';
|
|
219
|
+
delete snapshot.reason;
|
|
220
|
+
}
|
|
221
|
+
return lifecycle.dispose().catch(error => {
|
|
222
|
+
snapshot.status = 'failed';
|
|
223
|
+
snapshot.reason = { code: 'DISCONNECT_FAILED', message: '渠道资源清理失败' };
|
|
224
|
+
throw error;
|
|
225
|
+
}).finally(() => { entry.runtime = undefined; });
|
|
226
|
+
};
|
|
227
|
+
runtime.connect = () => {
|
|
228
|
+
lifecycle.assertActive();
|
|
229
|
+
snapshot.status = 'connecting';
|
|
230
|
+
delete snapshot.reason;
|
|
231
|
+
return Promise.resolve().then(() => { lifecycle.assertActive(); return connect(); }).then(() => {
|
|
232
|
+
lifecycle.assertActive();
|
|
233
|
+
snapshot.status = 'connected';
|
|
234
|
+
}).catch(async (error) => {
|
|
235
|
+
if (!lifecycle.signal.aborted) {
|
|
236
|
+
const missing = isMissingChannelDependency(error);
|
|
237
|
+
snapshot.status = missing ? 'unavailable' : 'failed';
|
|
238
|
+
snapshot.reason = missing
|
|
239
|
+
? { code: 'DEPENDENCY_MISSING', message: '渠道依赖未安装' }
|
|
240
|
+
: { code: 'CONNECT_FAILED', message: '渠道连接失败' };
|
|
241
|
+
if (inst.type !== 'aun') {
|
|
242
|
+
try {
|
|
243
|
+
await lifecycle.dispose();
|
|
244
|
+
}
|
|
245
|
+
catch (disposeError) {
|
|
246
|
+
logger.warn(`[ChannelLoader] Cleanup failed for ${lifecycle.owner}:`, disposeError);
|
|
247
|
+
}
|
|
248
|
+
entry.runtime = undefined;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
throw error;
|
|
252
|
+
});
|
|
253
|
+
};
|
|
126
254
|
return runtime;
|
|
127
255
|
}
|
|
128
256
|
catch (error) {
|
|
257
|
+
const missing = isMissingChannelDependency(error);
|
|
258
|
+
snapshot.status = missing ? 'unavailable' : 'failed';
|
|
259
|
+
snapshot.reason = missing
|
|
260
|
+
? { code: 'DEPENDENCY_MISSING', message: '渠道依赖未安装' }
|
|
261
|
+
: { code: 'CREATE_FAILED', message: '渠道实例创建失败' };
|
|
129
262
|
try {
|
|
130
263
|
await lifecycle.dispose();
|
|
131
264
|
}
|
|
132
265
|
catch (disposeError) {
|
|
133
266
|
logger.warn(`[ChannelLoader] Cleanup failed for ${lifecycle.owner}:`, disposeError);
|
|
134
267
|
}
|
|
268
|
+
if (missing && inst.type !== 'aun')
|
|
269
|
+
return null;
|
|
135
270
|
throw error;
|
|
136
271
|
}
|
|
137
272
|
}
|
|
@@ -173,7 +308,7 @@ export class ChannelLoader {
|
|
|
173
308
|
}
|
|
174
309
|
await Promise.allSettled(inflight);
|
|
175
310
|
if (failed.length > 0) {
|
|
176
|
-
logger.warn(`[connectAll] ${failed.length} channel(s) failed initial connect
|
|
311
|
+
logger.warn(`[connectAll] ${failed.length} channel(s) failed initial connect: ${failed.map(f => f.name).join(', ')}`);
|
|
177
312
|
}
|
|
178
313
|
return connected;
|
|
179
314
|
}
|
|
@@ -353,16 +488,13 @@ export function buildReloadHooks(deps) {
|
|
|
353
488
|
debug: channelLoader.processDebug,
|
|
354
489
|
aunDefaultEncrypt: channelLoader.aunDefaultEncrypt,
|
|
355
490
|
};
|
|
356
|
-
const plugin = channelLoader.getPlugin(cfgInst.type);
|
|
357
|
-
if (!plugin)
|
|
358
|
-
throw new Error(`[Reload] No plugin for channel type '${cfgInst.type}'`);
|
|
359
491
|
const effInst = { ...cfgInst, name: channelName };
|
|
360
492
|
const newInst = await channelLoader.createInstance(effInst, ctx);
|
|
361
493
|
if (!newInst) {
|
|
362
494
|
// createInstance returns null for a disabled / invalid-credential channel.
|
|
363
495
|
// Not an error: skip it. Throwing here would propagate to reload(), which
|
|
364
496
|
// turns it into agent error state and takes down every healthy channel too.
|
|
365
|
-
logger.warn(`[Reload] Channel ${channelName} (${cfgInst.type})
|
|
497
|
+
logger.warn(`[Reload] Channel ${channelName} (${cfgInst.type}) unavailable or disabled, skipping`);
|
|
366
498
|
return;
|
|
367
499
|
}
|
|
368
500
|
try {
|
|
@@ -382,6 +514,10 @@ export function buildReloadHooks(deps) {
|
|
|
382
514
|
const index = channelInstances.indexOf(newInst);
|
|
383
515
|
if (index >= 0)
|
|
384
516
|
channelInstances.splice(index, 1);
|
|
517
|
+
if (cfgInst.type !== 'aun' && isMissingChannelDependency(error)) {
|
|
518
|
+
logger.warn(`[Reload] Channel ${channelName} dependency unavailable, skipping`);
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
385
521
|
throw error;
|
|
386
522
|
}
|
|
387
523
|
},
|
|
@@ -145,7 +145,8 @@ async function execOneShotCreate(a, peerId, service, subject) {
|
|
|
145
145
|
return { error: '一步创建兼容入口不接受 plan/owners/ownerAid/avatarFile/force', code: 'INVALID_ARGS' };
|
|
146
146
|
}
|
|
147
147
|
if (a.chatmode !== undefined && (!a.chatmode || typeof a.chatmode !== 'object' || Array.isArray(a.chatmode)
|
|
148
|
-
|| Object.entries(a.chatmode).some(([key, value]) => !['private', 'group', 'nothuman'].includes(key)
|
|
148
|
+
|| Object.entries(a.chatmode).some(([key, value]) => !['private', 'group', 'nothuman'].includes(key)
|
|
149
|
+
|| !['interactive', 'proactive', ...(key === 'private' ? ['paactive'] : [])].includes(value)))) {
|
|
149
150
|
return { error: 'chatmode 必须包含有效的 private/group/nothuman 模式', code: 'INVALID_ARGS' };
|
|
150
151
|
}
|
|
151
152
|
let avatarUrl;
|
|
@@ -222,14 +222,6 @@ function parseAgentCommand(argv, source) {
|
|
|
222
222
|
return raw(source, argv, 'Invalid initialization arguments');
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
|
-
if (subcmd === 'persona') {
|
|
226
|
-
const tail = argv.at(-2) === '--format' && argv.at(-1) === 'json' ? argv.slice(0, -2) : argv;
|
|
227
|
-
const isShow = tail.length === 3 && tail[2] === 'show';
|
|
228
|
-
const isWrite = tail.length === 4 && (tail[2] === '--text' || tail[2] === '--file');
|
|
229
|
-
return isShow || isWrite
|
|
230
|
-
? recognized('agent.persona', 'agent', source, {}, argv)
|
|
231
|
-
: raw(source, argv, 'Invalid agent persona command');
|
|
232
|
-
}
|
|
233
225
|
if (subcmd === 'welcome') {
|
|
234
226
|
try {
|
|
235
227
|
const { action } = parseAgentWelcomeArgs(argv.slice(2));
|
|
@@ -15,6 +15,7 @@ import { logger } from '../../utils/logger.js';
|
|
|
15
15
|
import { resolvePeerRoleDetail, roleToSessionIdentity } from '../../config/peer-role-resolver.js';
|
|
16
16
|
import { ThreadService } from '../thread/thread-service.js';
|
|
17
17
|
import { isManagementRole } from '../../config/builtin-roles.js';
|
|
18
|
+
import { resolveAgentLifecycle } from '../../config/lifecycle.js';
|
|
18
19
|
import { formatPeerKey } from '../relation/peer-identity.js';
|
|
19
20
|
import { sameGroupAid } from '../../aun/group/index.js';
|
|
20
21
|
import crypto from 'crypto';
|
|
@@ -37,7 +38,6 @@ import { parseTimeArg, TIME_ARG_FORMATS, splitConfigBatchGetArgv } from '../../c
|
|
|
37
38
|
import { auditCommandAuthorization, auditFullAccessEvent, hashArgv } from '../auth/authorization-audit.js';
|
|
38
39
|
import { ResponseModeRegistry } from '../../response-system/registry.js';
|
|
39
40
|
import { registerBuiltinModes } from '../../response-system/modes/index.js';
|
|
40
|
-
import { DirectoryRemarkError, executeDirectoryRemarkCommand, resolveDirectoryRemarkCommand, } from '../../directory/owner-directory-remark-operation.js';
|
|
41
41
|
import { DirectoryQueryError, executeDirectoryQueryCommand, resolveDirectoryQueryCommand, } from '../../directory/owner-directory-query-operation.js';
|
|
42
42
|
import { executeResolvedRoleCommand, resolveRoleCommand } from '../../config/role-command-service.js';
|
|
43
43
|
import { applyApprovedRoleAssignment } from './role-menu.js';
|
|
@@ -56,7 +56,7 @@ import { constrainRuntimePermissionMode, resolveRuntimePermissionMode, validateR
|
|
|
56
56
|
import { parsePeerKey } from '../relation/peer-identity.js';
|
|
57
57
|
import { isQuickCommand } from './slash-gate.js';
|
|
58
58
|
import { handleSlashCommand } from './slash-handler.js';
|
|
59
|
-
import { resolveChatMode } from '../message/peer-mode.js';
|
|
59
|
+
import { isChatMode, resolveChatMode } from '../message/peer-mode.js';
|
|
60
60
|
import { execMenuAction as menuExecMenuAction, execMenuForEcweb as menuExecMenuForEcweb, execMenuForControl as menuExecMenuForControl, execMenuQuery as menuExecMenuQuery, execMenuUpdate as menuExecMenuUpdate, getMenuItems as menuGetMenuItems, getSubMenuItems as menuGetSubMenuItems, buildTopicForkSourcePayload, } from './menu-handler.js';
|
|
61
61
|
import { getMenuCatalog, execMenuValueBatch, validateMenuValueBatchArgs } from './menu-catalog.js';
|
|
62
62
|
import { resolveCurrentSessionLoopTarget, sessionLoopError } from '../session/session-idle-monitor.js';
|
|
@@ -1838,7 +1838,10 @@ export class CommandHandler {
|
|
|
1838
1838
|
if (meta?.replyContext?.replyInThread)
|
|
1839
1839
|
ctx.replyInThread = meta.replyContext.replyInThread;
|
|
1840
1840
|
const taskId = this.sessionManager.getActiveTaskId(session.id);
|
|
1841
|
-
const
|
|
1841
|
+
const taskChatmode = taskId && meta?.turnState?.active?.taskId === taskId
|
|
1842
|
+
? meta.turnState.active.recoveryContext?.chatmode
|
|
1843
|
+
: undefined;
|
|
1844
|
+
const chatmode = isChatMode(taskChatmode) ? taskChatmode : this.resolveEffectiveChatmodeForSession(session);
|
|
1842
1845
|
const encrypted = this.sessionManager.getSessionEncrypt(session.id);
|
|
1843
1846
|
// 诊断日志:记录 task_id 解析结果
|
|
1844
1847
|
logger.info(`[CommandHandler] buildCtlReplyContext: sessionId=${session.id} taskId=${taskId ?? 'none'} chatmode=${chatmode} threadId=${ctx.threadId ?? 'none'} replyTo=${ctx.replyToMessageId ?? 'none'} inThread=${ctx.replyInThread ?? false}`);
|
|
@@ -1868,6 +1871,9 @@ export class CommandHandler {
|
|
|
1868
1871
|
role: session.identity?.role,
|
|
1869
1872
|
chatType: session.chatType,
|
|
1870
1873
|
peerType,
|
|
1874
|
+
channelType,
|
|
1875
|
+
lifecycle: resolveAgentLifecycle(this.getOwningAgent(session.channel)?.config ?? {}),
|
|
1876
|
+
sessionType: session.sessionType ?? session.metadata?.sessionType ?? 'main',
|
|
1871
1877
|
});
|
|
1872
1878
|
}
|
|
1873
1879
|
catch {
|
|
@@ -2148,13 +2154,10 @@ export class CommandHandler {
|
|
|
2148
2154
|
}
|
|
2149
2155
|
}
|
|
2150
2156
|
/**
|
|
2151
|
-
* `ec directory
|
|
2152
|
-
*
|
|
2153
|
-
* 备注写的是**目标 Agent** 的目录,不是调用方自己的目录——个人助理要维护
|
|
2154
|
-
* 别的 agent 的名录备注,沙箱权限写不进去,所以统一由 daemon 落盘。
|
|
2157
|
+
* `ec directory ...`:只读查询 + 重算注入。
|
|
2155
2158
|
*
|
|
2159
|
+
* 备注不走命令——它是自己的 agent 目录下的一个 markdown 文件,由 Agent 直接读写。
|
|
2156
2160
|
* 权限边界:目标 Agent 必须是调用方自身,或者与调用方同属一个 Owner。
|
|
2157
|
-
* 这条限制防止一个 agent 借命令去改无关 Agent 的注入内容。
|
|
2158
2161
|
*/
|
|
2159
2162
|
async handleDirectoryOperation(argv, sessionId, delegationToken, delegationCommandHash) {
|
|
2160
2163
|
if (!this.agentDelegationRegistry) {
|
|
@@ -2166,9 +2169,8 @@ export class CommandHandler {
|
|
|
2166
2169
|
const session = await this.sessionManager.getSessionById(sessionId);
|
|
2167
2170
|
if (!session)
|
|
2168
2171
|
return { ok: false, code: 'INVALID_SESSION', error: 'Invalid session' };
|
|
2169
|
-
// argv 形如 ['directory', '<sub>', ...]
|
|
2170
|
-
const
|
|
2171
|
-
const subArgv = argv.slice(isRemark ? 2 : 1);
|
|
2172
|
+
// argv 形如 ['directory', '<sub>', ...]
|
|
2173
|
+
const subArgv = argv.slice(1);
|
|
2172
2174
|
const grantSelfAid = delegation.grant.selfAid.replace(/^@/, '');
|
|
2173
2175
|
const sessionSelfAid = session.selfAID?.replace(/^@/, '');
|
|
2174
2176
|
if (sessionSelfAid && sessionSelfAid !== grantSelfAid) {
|
|
@@ -2188,7 +2190,7 @@ export class CommandHandler {
|
|
|
2188
2190
|
catch {
|
|
2189
2191
|
return { ok: false, code: 'INVALID_DELEGATION', error: 'Delegation contains an invalid relation key' };
|
|
2190
2192
|
}
|
|
2191
|
-
const operation =
|
|
2193
|
+
const operation = 'ec.directory.query';
|
|
2192
2194
|
const subject = buildAuthSubject({
|
|
2193
2195
|
selfAid: grantSelfAid,
|
|
2194
2196
|
sessionId,
|
|
@@ -2217,41 +2219,12 @@ export class CommandHandler {
|
|
|
2217
2219
|
messageId: delegation.grant.messageId,
|
|
2218
2220
|
},
|
|
2219
2221
|
}, async (onExecutionStarted) => {
|
|
2220
|
-
const bodyFileIndex = isRemark ? subArgv.indexOf('--body-file') : -1;
|
|
2221
|
-
if (bodyFileIndex >= 0) {
|
|
2222
|
-
const rawBodyFile = subArgv[bodyFileIndex + 1];
|
|
2223
|
-
if (!rawBodyFile || rawBodyFile.startsWith('--') || bodyFileIndex !== subArgv.lastIndexOf('--body-file')) {
|
|
2224
|
-
return { ok: false, code: 'INVALID_ARGUMENT', error: '--body-file must occur once with a file path' };
|
|
2225
|
-
}
|
|
2226
|
-
try {
|
|
2227
|
-
const projectPath = path.resolve(session.projectPath);
|
|
2228
|
-
const tempPath = this.getManagedSessionTempDir(session);
|
|
2229
|
-
const allowedRoots = [projectPath, tempPath].filter((value) => !!value)
|
|
2230
|
-
.map(root => fs.realpathSync(root));
|
|
2231
|
-
const requestedPath = path.resolve(projectPath, rawBodyFile);
|
|
2232
|
-
const stat = fs.lstatSync(requestedPath);
|
|
2233
|
-
const realPath = fs.realpathSync(requestedPath);
|
|
2234
|
-
const inManagedTemp = !!tempPath && isSameOrDescendant(realPath, fs.realpathSync(tempPath));
|
|
2235
|
-
if (stat.isSymbolicLink() || !stat.isFile() || stat.size > 16 * 1024
|
|
2236
|
-
|| !allowedRoots.some(root => isSameOrDescendant(realPath, root))
|
|
2237
|
-
|| (!hasTrustedFullAccessDelegation(delegation.grant) && (isHClassPath(realPath) || isLClassPath(realPath)))
|
|
2238
|
-
|| (inManagedTemp && stat.nlink > 1)) {
|
|
2239
|
-
return { ok: false, code: 'INVALID_ARGUMENT', error: '--body-file must be a small regular file in the session project or TMPDIR' };
|
|
2240
|
-
}
|
|
2241
|
-
subArgv[bodyFileIndex + 1] = realPath;
|
|
2242
|
-
}
|
|
2243
|
-
catch (error) {
|
|
2244
|
-
return { ok: false, code: 'INVALID_ARGUMENT', error: `cannot access --body-file: ${error instanceof Error ? error.message : String(error)}` };
|
|
2245
|
-
}
|
|
2246
|
-
}
|
|
2247
2222
|
let command;
|
|
2248
2223
|
try {
|
|
2249
|
-
command =
|
|
2250
|
-
? resolveDirectoryRemarkCommand(subArgv)
|
|
2251
|
-
: resolveDirectoryQueryCommand(subArgv);
|
|
2224
|
+
command = resolveDirectoryQueryCommand(subArgv);
|
|
2252
2225
|
}
|
|
2253
2226
|
catch (error) {
|
|
2254
|
-
const known = error instanceof
|
|
2227
|
+
const known = error instanceof DirectoryQueryError;
|
|
2255
2228
|
return {
|
|
2256
2229
|
ok: false,
|
|
2257
2230
|
code: known ? error.code : 'INVALID_ARGUMENT',
|
|
@@ -2262,9 +2235,7 @@ export class CommandHandler {
|
|
|
2262
2235
|
return { ok: false, code: 'SCOPE_MISMATCH', error: 'Resolved Agent target does not match the authorized target' };
|
|
2263
2236
|
}
|
|
2264
2237
|
onExecutionStarted();
|
|
2265
|
-
const result =
|
|
2266
|
-
? executeDirectoryRemarkCommand(command)
|
|
2267
|
-
: await executeDirectoryQueryCommand(command);
|
|
2238
|
+
const result = await executeDirectoryQueryCommand(command);
|
|
2268
2239
|
return result.ok
|
|
2269
2240
|
? { ok: true, result }
|
|
2270
2241
|
: { ok: false, code: result.code, error: result.error };
|
|
@@ -265,6 +265,10 @@ async function handleAction(req, self, context) {
|
|
|
265
265
|
return actionReviewRequest(req, self, context, 'block');
|
|
266
266
|
return fail('NOT_SUPPORTED', `Unknown action: ${String(action)}`);
|
|
267
267
|
}
|
|
268
|
+
/** 会改变 `directory.md` / `identity.json` 内容的开关;改完必须重算注入。 */
|
|
269
|
+
const RENDER_AFFECTING_ACCESS_RESOURCES = new Set([
|
|
270
|
+
'allowInternalContacts', 'allowExternalContacts', 'allowAllContacts', 'allowedAids', 'deniedAids',
|
|
271
|
+
]);
|
|
268
272
|
function isAccessUpdateResource(resource) {
|
|
269
273
|
return resource === 'allowInternalContacts'
|
|
270
274
|
|| resource === 'allowExternalContacts'
|
|
@@ -315,9 +319,9 @@ function updateAccessResource(req, context, resource) {
|
|
|
315
319
|
expectedAccessRevision,
|
|
316
320
|
update: current => accessPolicyWithUpdate(current, resource, decoded),
|
|
317
321
|
});
|
|
318
|
-
//
|
|
319
|
-
//
|
|
320
|
-
if (result.changed && resource
|
|
322
|
+
// 影响 directory.md 的开关共五个:准入每次现读 config,立刻生效;注入内容是
|
|
323
|
+
// 渲染产物,不重算就停在旧版本。`requestLimit` 只控制拒绝提示的发送频率,不触发。
|
|
324
|
+
if (result.changed && RENDER_AFFECTING_ACCESS_RESOURCES.has(resource)) {
|
|
321
325
|
refreshDirectoryMarkdown(self);
|
|
322
326
|
}
|
|
323
327
|
return ok({
|
|
@@ -99,7 +99,7 @@ const ENTRIES = [
|
|
|
99
99
|
control: 'toggle',
|
|
100
100
|
},
|
|
101
101
|
// 模型与推理强度只在 Agent 级配置(见 model.agent / effort.agent),关系菜单不再提供。
|
|
102
|
-
relation('chatmode.relation', 'chatmode', '对话模式', 30, '/chatmode', 'chatmode.current', { options: { cmd: '/chatmode', operation: 'chatmode.current', scope: 'relation', mode: '
|
|
102
|
+
relation('chatmode.relation', 'chatmode', '对话模式', 30, '/chatmode', 'chatmode.current', { options: { cmd: '/chatmode', operation: 'chatmode.current', scope: 'relation', mode: 'dynamic' }, update: { cmd: '/chatmode', operation: 'chatmode.update', scope: 'relation' }, control: 'select' }),
|
|
103
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' }),
|
|
104
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' },
|
|
105
105
|
relation('permissionMode.relation', 'permission', '权限模式', 50, '/perm', 'permission.current', { query: { cmd: '/perm', args: { scope: 'role' }, operation: 'permission.current', scope: 'relation' }, options: undefined, update: { cmd: '/perm', operation: 'permission.current', scope: 'relation', supported: false }, control: 'select' }),
|
|
@@ -311,7 +311,8 @@ export function bindMenuExecutionContextArgs(args, context) {
|
|
|
311
311
|
return args;
|
|
312
312
|
const { context: _context, ...bound } = args ?? {};
|
|
313
313
|
const isSessionScoped = ['loop', 'fullaccess'].includes(String(bound.resource ?? bound.view ?? ''));
|
|
314
|
-
|
|
314
|
+
// Command inventories use the resolved subject, without configurable scope/peer selectors.
|
|
315
|
+
if (isSessionScoped || bound.view === 'commands')
|
|
315
316
|
return bound;
|
|
316
317
|
if (context.kind === 'private_relation' || context.kind === 'group_relation') {
|
|
317
318
|
if (bound.scope !== 'role')
|
|
@@ -43,7 +43,7 @@ import { authorizationDenialData, formatAuthorizationDenial } from '../auth/auth
|
|
|
43
43
|
import { evaluateRoleOperationCapability } from '../auth/operation-authorizer.js';
|
|
44
44
|
import { isUnsupportedBaseagentConfigField } from '../../config/config-field-policy.js';
|
|
45
45
|
import { splitConfigBatchGetArgv } from '../../cli/cli-argv.js';
|
|
46
|
-
import { chatmodeFieldForPeer, isPrivateChatmodeRoleLocked, resolveChatModeForField } from '../message/peer-mode.js';
|
|
46
|
+
import { chatmodeFieldForPeer, isChatMode, isPrivateChatmodeRoleLocked, resolveChatModeForField } from '../message/peer-mode.js';
|
|
47
47
|
import { PUBLIC_PERMISSION_MODES } from '../permission/mode.js';
|
|
48
48
|
import { isAgentFullAccessOwner, resolveRuntimePermissionMode, resolveRuntimeStringField, sessionFullAccessStatus, updateRelationSessionFullAccess, validateRuntimeStringFieldOverride, } from '../role/runtime-policy.js';
|
|
49
49
|
import { isManagementRole } from '../../config/builtin-roles.js';
|
|
@@ -51,7 +51,7 @@ import { SYSTEM_CONTROL_CHANNEL } from '../system-channels.js';
|
|
|
51
51
|
import { logger } from '../../utils/logger.js';
|
|
52
52
|
import { shouldSuppressRealRestart, createRestartRequest, readRestartRequest, updateRestartRequest, removeRestartRequest } from '../../utils/restart-safety.js';
|
|
53
53
|
import { AGENT_DELEGATION_TOKEN_ENV } from '../auth/agent-delegation.js';
|
|
54
|
-
import { evolMenuResponseTransportMetadata, menuFailure, menuCommandForName, menuSuccess, normalizeMenuError, validateTaskActivityQueryArgs, validateConfigWriteScope, validateMenuRequest, } from './menu-protocol.js';
|
|
54
|
+
import { evolMenuResponseTransportMetadata, menuFailure, menuCommandForName, menuSuccess, normalizeMenuError, validateTaskActivityQueryArgs, validateSlashCommandsQueryArgs, validateConfigWriteScope, validateMenuRequest, } from './menu-protocol.js';
|
|
55
55
|
import { parseMenuClientProtectedHeaders } from './menu-protocol.js';
|
|
56
56
|
import { TaskActivityStore } from '../task/task-activity-store.js';
|
|
57
57
|
import { DEFAULT_SESSION_LOOP_SECONDS, MAX_SESSION_LOOP_SECONDS, MIN_SESSION_LOOP_SECONDS, refreshSessionLoopTarget, resolveCurrentSessionLoopTarget, sessionLoopPayload, validateIdleSeconds, writeSessionLoopConfig, } from '../session/session-idle-monitor.js';
|
|
@@ -741,13 +741,17 @@ function readMenuChatmode(target) {
|
|
|
741
741
|
field: target.fieldPath,
|
|
742
742
|
configuredValue: resolved.value,
|
|
743
743
|
});
|
|
744
|
-
const mode =
|
|
745
|
-
|
|
744
|
+
const mode = target.scope === 'agent' ? decision.effectiveValue
|
|
745
|
+
: resolveChatModeForField({ ...target.sel, role: target.role, field: target.field });
|
|
746
|
+
if (isChatMode(mode)) {
|
|
746
747
|
return {
|
|
747
748
|
value: mode,
|
|
748
749
|
source: decision.decidedBy === 'role'
|
|
749
750
|
? 'role'
|
|
750
751
|
: toMenuSource(resolved.source) ?? 'builtin',
|
|
752
|
+
...(resolved.value === 'paactive' && mode !== 'paactive' ? {
|
|
753
|
+
fallbackReason: 'paactive 仅在 active AUN 人类 owner/admin 私聊主会话或话题生效,当前场景或角色策略未满足条件。',
|
|
754
|
+
} : {}),
|
|
751
755
|
};
|
|
752
756
|
}
|
|
753
757
|
}
|
|
@@ -2202,6 +2206,9 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
2202
2206
|
return [
|
|
2203
2207
|
{ value: 'interactive', label: '交互模式', selected: currentMode === 'interactive' },
|
|
2204
2208
|
{ value: 'proactive', label: '主动模式', selected: currentMode === 'proactive' },
|
|
2209
|
+
...(target.field === 'private' && !target.roleLocked
|
|
2210
|
+
&& (target.scope === 'agent' || target.sel.peerKey?.startsWith('aun#'))
|
|
2211
|
+
? [{ value: 'paactive', label: 'PA 模式', selected: currentMode === 'paactive' }] : []),
|
|
2205
2212
|
];
|
|
2206
2213
|
}
|
|
2207
2214
|
if (cmd === '/mention') {
|
|
@@ -2300,6 +2307,37 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2300
2307
|
fromControlChannel,
|
|
2301
2308
|
subject: authSubject,
|
|
2302
2309
|
});
|
|
2310
|
+
if (cmdBase === '/evolhelp') {
|
|
2311
|
+
const invalid = validateSlashCommandsQueryArgs(args);
|
|
2312
|
+
if (invalid)
|
|
2313
|
+
return { error: invalid.message, code: invalid.code };
|
|
2314
|
+
if (!subject.selfAid)
|
|
2315
|
+
return { error: 'slash-commands requires a target Agent', code: 'MISSING_AID' };
|
|
2316
|
+
if (!subject.allowAccess)
|
|
2317
|
+
return { error: '当前角色不能访问此 Agent', code: 'ROLE_ACCESS_DENIED' };
|
|
2318
|
+
try {
|
|
2319
|
+
const reply = await this._handleInternal('/evolhelp', channel, channelId, undefined, userId, transportReplyContext?.threadId, subject.chatType, undefined, undefined, subject.selfAid, subject.identity, subject, transportReplyContext, true);
|
|
2320
|
+
if (!reply || reply.kind !== 'command.result') {
|
|
2321
|
+
return {
|
|
2322
|
+
error: reply?.text || '无法获取 slash 指令清单',
|
|
2323
|
+
code: reply?.reasonCode || reply?.reason || 'EXEC_FAILED',
|
|
2324
|
+
};
|
|
2325
|
+
}
|
|
2326
|
+
const list = JSON.parse(reply.text);
|
|
2327
|
+
const level = args?.level ?? 'common';
|
|
2328
|
+
if (level === 'all')
|
|
2329
|
+
return { data: list };
|
|
2330
|
+
const commands = list.commands.filter(entry => level === 'common' ? entry.common === true : entry.common !== true);
|
|
2331
|
+
const categories = [
|
|
2332
|
+
...(level === 'common' ? ['常用'] : []),
|
|
2333
|
+
...new Set(commands.map(entry => entry.category)),
|
|
2334
|
+
];
|
|
2335
|
+
return { data: { commands, categories } };
|
|
2336
|
+
}
|
|
2337
|
+
catch (error) {
|
|
2338
|
+
return menuResultFailure(error);
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2303
2341
|
if (cmdBase === '/session' && args?.view === 'loop') {
|
|
2304
2342
|
if (Object.keys(args).some(key => key !== 'view' && key !== 'context')) {
|
|
2305
2343
|
return { error: 'session.loop query only accepts args.view', code: 'INVALID_ARGUMENT' };
|
|
@@ -2987,6 +3025,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2987
3025
|
return {
|
|
2988
3026
|
data: {
|
|
2989
3027
|
mode: current.value,
|
|
3028
|
+
...(current.fallbackReason ? { fallbackReason: current.fallbackReason } : {}),
|
|
2990
3029
|
source: current.source,
|
|
2991
3030
|
scope: target.scope,
|
|
2992
3031
|
override: readMenuScopeOverride(target.scope, target.fieldPath, target.sel),
|
|
@@ -3623,7 +3662,7 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3623
3662
|
};
|
|
3624
3663
|
}
|
|
3625
3664
|
if (cmdBase === '/chatmode') {
|
|
3626
|
-
if (arg
|
|
3665
|
+
if (!isChatMode(arg)) {
|
|
3627
3666
|
return { error: `无效模式: ${arg}`, code: 'INVALID_VALUE' };
|
|
3628
3667
|
}
|
|
3629
3668
|
const target = resolveMenuChatmodeTarget.call(this, {
|
|
@@ -3637,9 +3676,13 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3637
3676
|
});
|
|
3638
3677
|
if ('error' in target)
|
|
3639
3678
|
return target;
|
|
3640
|
-
if (arg === 'interactive' && target.roleLocked) {
|
|
3679
|
+
if ((arg === 'interactive' || arg === 'paactive') && target.roleLocked) {
|
|
3641
3680
|
return { error: '私聊交互模式仅限 owner/admin,当前角色固定为 proactive', code: 'ROLE_VALUE_NOT_ALLOWED' };
|
|
3642
3681
|
}
|
|
3682
|
+
if (arg === 'paactive' && (target.field !== 'private'
|
|
3683
|
+
|| (target.scope === 'relation' && !target.sel.peerKey?.startsWith('aun#')))) {
|
|
3684
|
+
return { error: 'paactive 仅支持 AUN 人类私聊', code: 'NOT_APPLICABLE' };
|
|
3685
|
+
}
|
|
3643
3686
|
const roleDecision = validateRuntimeStringFieldOverride({
|
|
3644
3687
|
selfAid: target.sel.self,
|
|
3645
3688
|
role: target.role,
|
|
@@ -5374,9 +5417,9 @@ async function execMenuForSystemControl(payload, context) {
|
|
|
5374
5417
|
const isRoleRequest = name === 'role' || compatCmd === '/role';
|
|
5375
5418
|
const isConnectRequest = name === 'connect' || compatCmd === '/connect';
|
|
5376
5419
|
const requiresAgentTarget = isRoleRequest || isConnectRequest || [
|
|
5377
|
-
'observable', 'baseagent', 'model', 'effort', 'trigger', 'capability', 'group', 'aid', 'pa-workspace',
|
|
5420
|
+
'observable', 'baseagent', 'model', 'effort', 'trigger', 'capability', 'group', 'aid', 'pa-workspace', 'slash-commands',
|
|
5378
5421
|
].includes(name)
|
|
5379
|
-
|| ['/observable', '/baseagent', '/model', '/effort', '/trigger', '/capability', '/group', '/aid', '/pa-workspace'].includes(compatCmd ?? '')
|
|
5422
|
+
|| ['/observable', '/baseagent', '/model', '/effort', '/trigger', '/capability', '/group', '/aid', '/pa-workspace', '/evolhelp'].includes(compatCmd ?? '')
|
|
5380
5423
|
|| (!isProcessLevel && requestedContextKind !== undefined && requestedContextKind !== 'process');
|
|
5381
5424
|
const target = isProcessLevel
|
|
5382
5425
|
? { channel: SYSTEM_CONTROL_CHANNEL }
|