evolcore 0.0.41 → 0.0.42
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 +36 -0
- package/bin/codex-managed-hook.mjs +9 -5
- package/dist/agents/baseagent.js +156 -16
- package/dist/agents/claude-runner.js +10 -3
- package/dist/agents/codex/catalog.js +8 -4
- package/dist/agents/codex-runner.js +236 -59
- package/dist/agents/ecagent-runner.js +82 -13
- package/dist/aun/aid/agentmd.js +106 -27
- package/dist/aun/aid/client.js +1 -1
- package/dist/aun/aid/control-aid.js +65 -13
- package/dist/aun/aid/identity.js +70 -4
- package/dist/aun/aid/index.js +2 -2
- package/dist/aun/service-proxy.js +25 -1
- package/dist/channels/aun.js +242 -209
- package/dist/channels/dingtalk.js +1 -1
- package/dist/channels/feishu.js +1 -1
- package/dist/channels/qqbot.js +1 -1
- package/dist/channels/wechat.js +1 -1
- package/dist/channels/wecom.js +1 -1
- package/dist/cli/agent-command.js +183 -3
- package/dist/cli/agent-create.js +92 -86
- package/dist/cli/agent.js +136 -1
- package/dist/cli/aun-commands.js +137 -35
- package/dist/cli/bench.js +8 -2
- package/dist/cli/command-log.js +1 -1
- package/dist/cli/daemon-commands.js +235 -51
- package/dist/cli/debug-mode.js +1 -1
- package/dist/cli/directory.js +170 -0
- package/dist/cli/index.js +40 -30
- package/dist/cli/init-channel.js +4 -4
- package/dist/cli/init.js +47 -32
- package/dist/cli/managed-command-guard.js +4 -1
- package/dist/cli/model.js +27 -18
- package/dist/cli/pa-workspace-command.js +191 -0
- package/dist/cli/{contact.js → peer.js} +19 -25
- package/dist/cli/restart-monitor.js +11 -4
- package/dist/cli/thread-command.js +47 -18
- package/dist/cli/version.js +18 -18
- package/dist/config/access-policy.js +29 -12
- package/dist/config/boot-log.js +65 -10
- package/dist/config/builtin-roles.js +2 -4
- package/dist/config/config-field-policy.js +3 -0
- package/dist/config/config-manager.js +28 -20
- package/dist/config/{contact-bind-code.js → peer-bind-code.js} +6 -6
- package/dist/config/{contact-book-store.js → peer-book-store.js} +75 -75
- package/dist/config/{contact-book-v2-startup.js → peer-book-v2-startup.js} +2 -2
- package/dist/config/{contact-book.js → peer-book.js} +47 -47
- package/dist/config/peer-operation-service.js +132 -0
- package/dist/config/{contact-request-service.js → peer-request-service.js} +90 -90
- package/dist/config/peer-role-resolver.js +3 -3
- package/dist/config/providers-config.js +17 -8
- package/dist/config/providers.js +1 -1
- package/dist/config/schema-migration.js +336 -39
- package/dist/core/agent-application-service.js +8 -2
- package/dist/core/agent-create-status.js +4 -5
- package/dist/core/agent-ipc-registration.js +5 -4
- package/dist/core/agent-runtime.js +30 -17
- package/dist/core/auth/operation-authorizer.js +0 -24
- package/dist/core/auth/operation-catalog.js +4 -20
- package/dist/core/baseagent-loader.js +27 -3
- package/dist/core/bootstrap-service.js +5 -22
- package/dist/core/capability/capability-manager.js +52 -35
- package/dist/core/channel-loader.js +43 -2
- package/dist/core/channel-runtime.js +2 -2
- package/dist/core/command/agent-control.js +54 -18
- package/dist/core/command/command-handler.js +92 -72
- package/dist/core/command/connect-menu.js +35 -42
- package/dist/core/command/daemon-diagnostics.js +41 -5
- package/dist/core/command/data-root-error.js +10 -0
- package/dist/core/command/data-root-resolver.js +53 -13
- package/dist/core/command/menu-catalog.js +1 -0
- package/dist/core/command/menu-handler.js +163 -65
- package/dist/core/command/menu-protocol.js +52 -0
- package/dist/core/command/pa-workspace-calendar.js +223 -0
- package/dist/core/command/pa-workspace-store.js +459 -0
- package/dist/core/command/role-menu.js +2 -2
- package/dist/core/command/slash-gate.js +1 -1
- package/dist/core/command/slash-handler.js +57 -41
- package/dist/core/daemon-lifecycle.js +90 -31
- package/dist/core/evolagent.js +6 -10
- package/dist/core/handoff/runtime.js +11 -4
- package/dist/core/host-snapshot.js +208 -0
- package/dist/core/initialization/service.js +152 -20
- package/dist/core/ipc-registration.js +33 -4
- package/dist/core/memory/batch-meta.js +27 -0
- package/dist/core/memory/consolidation-ops-records.js +44 -1
- package/dist/core/memory/consolidation.js +169 -27
- package/dist/core/message/aun-ipc-sender.js +2 -8
- package/dist/core/message/im-renderer.js +56 -3
- package/dist/core/message/message-admission.js +121 -124
- package/dist/core/message/message-bridge.js +38 -54
- package/dist/core/message/message-queue.js +7 -0
- package/dist/core/message/outbound.js +34 -9
- package/dist/core/message/response-engine.js +154 -73
- package/dist/core/model/catalog-service.js +1 -1
- package/dist/core/model/config-scope.js +2 -2
- package/dist/core/model/model-catalog.js +5 -4
- package/dist/core/model/model-diagnostics.js +6 -5
- package/dist/core/model/model-fallback.js +3 -6
- package/dist/core/model/model-permission.js +1 -1
- package/dist/core/ownership/owner-resolver.js +9 -9
- package/dist/core/permission/approval-gateway.js +1 -1
- package/dist/core/permission/ec-command-parser.js +2 -2
- package/dist/core/permission/tool-canonical.js +96 -46
- package/dist/core/permission/tool-error-code.js +41 -0
- package/dist/core/permission/tool-policy.js +71 -47
- package/dist/core/role/runtime-policy.js +1 -1
- package/dist/core/session/session-idle-monitor.js +10 -0
- package/dist/core/session/session-manager.js +2 -4
- package/dist/core/session/session-title.js +36 -8
- package/dist/core/system-session/memory.js +2 -7
- package/dist/core/thread/command-parser.js +6 -2
- package/dist/core/thread/ipc-operation.js +51 -36
- package/dist/core/thread/thread-operation.js +29 -61
- package/dist/core/thread/thread-service.js +57 -13
- package/dist/directory/canonical-digest.js +54 -0
- package/dist/directory/owner-directory-admission.js +114 -43
- package/dist/directory/owner-directory-agentmd-sync.js +89 -0
- package/dist/directory/owner-directory-cache.js +847 -459
- package/dist/directory/owner-directory-markdown.js +272 -0
- package/dist/directory/owner-directory-query-operation.js +195 -0
- package/dist/directory/owner-directory-remark-operation.js +147 -0
- package/dist/directory/owner-directory-remarks.js +145 -0
- package/dist/directory/owner-directory-scope.js +55 -0
- package/dist/directory/owner-directory-search.js +148 -0
- package/dist/directory/owner-directory-store.js +227 -0
- package/dist/eck/kit-renderer.js +1 -0
- package/dist/ecweb/basic-settings-service.js +4 -1
- package/dist/ecweb/message-context-service.js +13 -9
- package/dist/index.js +195 -37
- package/dist/ipc.js +86 -22
- package/dist/paths.js +11 -8
- package/dist/product.js +2 -0
- package/dist/proxy/manager.js +13 -2
- package/dist/proxy/service-supervisor.js +8 -1
- package/dist/trigger/history.js +23 -0
- package/dist/trigger/scheduler.js +3 -0
- package/dist/utils/atomic-write.js +21 -0
- package/dist/utils/cross-platform.js +35 -0
- package/dist/utils/ecweb-supervisor.js +42 -0
- package/dist/utils/error-utils.js +2 -1
- package/dist/utils/evolcore-version.js +19 -0
- package/dist/utils/host-info.js +242 -5
- package/dist/utils/instance-registry.js +28 -6
- package/dist/utils/logger.js +59 -14
- package/dist/utils/machine-info.js +46 -0
- package/dist/utils/process-introspect.js +166 -2
- package/dist/utils/startup-trace.js +245 -0
- package/ecagent/dist/agent-loop.js +27 -13
- package/ecagent/dist/harness/agent-harness.js +3 -3
- package/ecagent/dist/harness/types.d.ts +1 -0
- package/ecagent/dist/types.d.ts +1 -0
- package/kits/docs/INDEX.md +1 -1
- 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 +72 -0
- package/kits/docs/evolcore/INDEX.md +3 -2
- package/kits/docs/evolcore/agent-create.md +17 -27
- package/kits/docs/evolcore/agent.md +4 -1
- package/kits/docs/evolcore/aid.md +3 -1
- package/kits/docs/evolcore/config.md +16 -5
- package/kits/docs/evolcore/ctl.md +9 -0
- package/kits/docs/evolcore/ec-capabilities.md +19 -0
- package/kits/docs/evolcore/memory-consolidation-batches.md +79 -5
- package/kits/docs/evolcore/menu-exec-schema-commands.md +2 -1
- package/kits/docs/evolcore/menu-protocol.md +1 -0
- package/kits/docs/evolcore/model.md +13 -4
- package/kits/docs/evolcore/msg.md +1 -1
- package/kits/docs/evolcore/pa-workspace.md +51 -0
- package/kits/docs/evolcore/peer.md +73 -0
- package/kits/docs/evolcore/thread-chain.md +4 -1
- package/kits/eck_manifest.json +21 -0
- package/kits/rules/06-channel.md +1 -1
- package/kits/schemas/_meta.json +12 -1
- package/kits/schemas/agent-config.schema.16.json +6 -0
- package/kits/schemas/agent-config.schema.17.json +897 -0
- package/kits/schemas/daemon.schema.9.json +8 -1
- package/kits/skills/ec-agent-create/SKILL.md +2 -2
- package/kits/skills/ec-identity/SKILL.md +45 -27
- package/kits/skills/ec-service-proxy/SKILL.md +7 -2
- package/kits/skills/personal-assistant/references/03-data-flow-and-gaps.md +4 -5
- package/kits/skills/thread-ops/SKILL.md +11 -11
- package/kits/templates/bootstrap-welcome.md +3 -15
- package/kits/templates/message-fragments/item.md +1 -1
- package/kits/templates/system-fragments/bootstrap.md +24 -23
- package/kits/templates/system-fragments/commands.md +12 -5
- package/kits/templates/system-fragments/thread.md +18 -3
- package/package.json +6 -4
- package/dist/config/contact-operation-service.js +0 -235
- package/dist/directory/owner-directory-authorization.js +0 -309
- package/kits/docs/evolcore/contact.md +0 -78
- /package/dist/config/{contact-alias.js → peer-alias.js} +0 -0
|
@@ -6,6 +6,26 @@
|
|
|
6
6
|
* is fully isolated.
|
|
7
7
|
*/
|
|
8
8
|
import { logger } from '../utils/logger.js';
|
|
9
|
+
/**
|
|
10
|
+
* 有界并发 map:保持输入顺序返回结果。
|
|
11
|
+
*
|
|
12
|
+
* 不用 Promise.all 是因为这里的任务会拉起外部进程,全量并发会让它们同时抢 CPU;
|
|
13
|
+
* 也不需要通用工具库——只有这一处用。
|
|
14
|
+
*/
|
|
15
|
+
async function mapWithConcurrency(items, limit, fn) {
|
|
16
|
+
const results = new Array(items.length);
|
|
17
|
+
let cursor = 0;
|
|
18
|
+
const workers = Array.from({ length: Math.min(limit, items.length) }, async () => {
|
|
19
|
+
while (true) {
|
|
20
|
+
const index = cursor++;
|
|
21
|
+
if (index >= items.length)
|
|
22
|
+
return;
|
|
23
|
+
results[index] = await fn(items[index], index);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
await Promise.all(workers);
|
|
27
|
+
return results;
|
|
28
|
+
}
|
|
9
29
|
/** Agent Loader — produces one runner per (EvolAgent × baseagent). */
|
|
10
30
|
export class AgentLoader {
|
|
11
31
|
plugins = new Map();
|
|
@@ -23,9 +43,13 @@ export class AgentLoader {
|
|
|
23
43
|
async createAll(registry, callbacks, creationErrors) {
|
|
24
44
|
const instances = [];
|
|
25
45
|
const allAgents = registry.runnableAgents();
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
46
|
+
// 各 agent 的 runner 创建互不共享状态(每个 plugin 只读自己的 config,
|
|
47
|
+
// 结果写回各自的 instances 数组),串行只会把 21 个 agent 的创建时间叠加起来。
|
|
48
|
+
// 限并发而不是 Promise.all:codex 插件在缓存未命中时会拉起外部进程,全量并发会
|
|
49
|
+
// 在同一瞬间抢占 CPU。顺序按 allAgents 保持,输出与串行一致。
|
|
50
|
+
const created = await mapWithConcurrency(allAgents, 4, (agent) => this.createForAgent(agent, callbacks, creationErrors));
|
|
51
|
+
for (const agentInstances of created)
|
|
52
|
+
instances.push(...agentInstances);
|
|
29
53
|
return instances;
|
|
30
54
|
}
|
|
31
55
|
/** Create runners for one EvolAgent, used by runtime hot-load. */
|
|
@@ -4,13 +4,12 @@ import fs from 'fs';
|
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { randomBytes } from 'crypto';
|
|
6
6
|
import { kitsTemplatesDir, resolvePaths } from '../paths.js';
|
|
7
|
-
import {
|
|
7
|
+
import { resolveAgentDisplayName, verifyLocalAgentMd } from '../aun/aid/agentmd.js';
|
|
8
8
|
import { logger } from '../utils/logger.js';
|
|
9
9
|
import { readAgentWelcomeTemplate } from '../utils/welcome.js';
|
|
10
10
|
import { loadAgent, saveAgent } from '../config-store.js';
|
|
11
11
|
import { resolveAgentLifecycle, withLifecycleForWrite } from '../config/lifecycle.js';
|
|
12
12
|
import { renderTemplate } from '../eck/manifest-engine.js';
|
|
13
|
-
import { activeBaseagent } from './model/config-scope.js';
|
|
14
13
|
import { buildEnvelope } from './message/message-utils.js';
|
|
15
14
|
import { BOOTSTRAP_MESSAGE_TTL_MS, BOOTSTRAP_NOTIFICATION_WINDOW_MS, bootstrapInitialMessageOperationId, bootstrapInitialMessageOperationPrefix, bootstrapInitialRetryOperationId, cancelPendingBootstrapPrompts, postBootstrapWelcomeStatus, postBootstrapWelcomeOperationId, } from './bootstrap-messages.js';
|
|
16
15
|
import { findLatestMessageLogOperation } from './message/message-log.js';
|
|
@@ -292,7 +291,6 @@ export class BootstrapService {
|
|
|
292
291
|
}
|
|
293
292
|
try {
|
|
294
293
|
const agentName = this.resolveAgentDisplayName(aid);
|
|
295
|
-
const baseagent = this.resolveBaseagent(agent, aid);
|
|
296
294
|
const notificationState = this.bootstrapNotificationState({
|
|
297
295
|
aid,
|
|
298
296
|
channelType,
|
|
@@ -313,7 +311,7 @@ export class BootstrapService {
|
|
|
313
311
|
// approved original while the Owner may still be confirming its hash
|
|
314
312
|
// and ETag. Sending a welcome must not mutate that binding evidence.
|
|
315
313
|
if (channelType !== 'aun') {
|
|
316
|
-
await this.publishAgentMdIfSupported(ctx.adapter, aid
|
|
314
|
+
await this.publishAgentMdIfSupported(ctx.adapter, aid);
|
|
317
315
|
}
|
|
318
316
|
this.setLifecycle(agent, aid, 'bootstrapping');
|
|
319
317
|
lifecycleStarted = true;
|
|
@@ -325,7 +323,6 @@ export class BootstrapService {
|
|
|
325
323
|
agentName,
|
|
326
324
|
ownerName: ctx.recipientName || recipientId,
|
|
327
325
|
channel: channelType || ctx.channelKey,
|
|
328
|
-
baseagent,
|
|
329
326
|
});
|
|
330
327
|
const receipt = await ctx.adapter.send(buildEnvelope({
|
|
331
328
|
taskId: `bootstrap-${randomBytes(5).toString('hex')}`,
|
|
@@ -478,20 +475,12 @@ export class BootstrapService {
|
|
|
478
475
|
const templatePath = path.join(kitsTemplatesDir(), 'bootstrap-welcome.md');
|
|
479
476
|
const template = fs.existsSync(templatePath)
|
|
480
477
|
? fs.readFileSync(templatePath, 'utf-8')
|
|
481
|
-
: '你好,我是 {{agentName}}
|
|
478
|
+
: '你好,我是 {{agentName}},刚刚上线。你希望我平时主要帮你做些什么?随便说说就行,名字不合适也可以顺便告诉我换一个;想换头像的话,直接发张图片说“用这张当头像”。还没想好也没关系,回我一句就好,之后随时可以再聊。';
|
|
482
479
|
return renderTemplate(template, vars).trim();
|
|
483
480
|
}
|
|
484
481
|
resolveAgentDisplayName(aid) {
|
|
485
482
|
return resolveAgentDisplayName(aid) || aid.split('.')[0];
|
|
486
483
|
}
|
|
487
|
-
resolveBaseagent(agent, aid) {
|
|
488
|
-
try {
|
|
489
|
-
return agent?.baseagent || activeBaseagent(aid);
|
|
490
|
-
}
|
|
491
|
-
catch {
|
|
492
|
-
return 'unknown';
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
484
|
bootstrapNotificationState(input) {
|
|
496
485
|
const prefix = bootstrapInitialMessageOperationPrefix(input.aid);
|
|
497
486
|
const now = Date.now();
|
|
@@ -549,7 +538,7 @@ export class BootstrapService {
|
|
|
549
538
|
this.notifiedInProcess.delete(input.aid);
|
|
550
539
|
return { recentlyNotified, hasCompletedHistory, pending, failure };
|
|
551
540
|
}
|
|
552
|
-
async publishAgentMdIfSupported(adapter, aid
|
|
541
|
+
async publishAgentMdIfSupported(adapter, aid) {
|
|
553
542
|
if (typeof adapter.uploadAgentMd !== 'function')
|
|
554
543
|
return;
|
|
555
544
|
const verification = await verifyLocalAgentMd(aid);
|
|
@@ -560,12 +549,6 @@ export class BootstrapService {
|
|
|
560
549
|
if (verification.status !== 'missing') {
|
|
561
550
|
throw new Error(`Local agent.md cannot be safely republished for ${aid}: ${verification.reason ?? verification.status}`);
|
|
562
551
|
}
|
|
563
|
-
|
|
564
|
-
aid,
|
|
565
|
-
name: fallbackName,
|
|
566
|
-
type: 'agent',
|
|
567
|
-
});
|
|
568
|
-
await adapter.uploadAgentMd(content);
|
|
569
|
-
logger.info(`[Bootstrap] Published initial agent.md for ${aid}`);
|
|
552
|
+
logger.warn(`[Bootstrap] Skipping initial agent.md upload for ${aid}: a non-human AID must be Owner-bound before publication`);
|
|
570
553
|
}
|
|
571
554
|
}
|
|
@@ -46,6 +46,11 @@ export function getAgentCapabilityConfig(config, baseagent, type) {
|
|
|
46
46
|
const root = (config?.capabilities ?? {});
|
|
47
47
|
return normalizeCapabilityTypeConfig(root[baseagent]?.[type]);
|
|
48
48
|
}
|
|
49
|
+
/** Agent 级总开关:基座自带 skill 功能默认关闭,只有显式 true 才开放。 */
|
|
50
|
+
export function isBaseagentSkillsEnabled(config) {
|
|
51
|
+
return config?.baseagentSkills === true;
|
|
52
|
+
}
|
|
53
|
+
const BASEAGENT_SKILLS_DISABLED_REASON = '基座 skill 功能已被 agent 级 baseagentSkills 关闭';
|
|
49
54
|
export function queryCapabilityTypes(ctx, config, onlyType) {
|
|
50
55
|
const provider = getProvider(ctx.baseagent);
|
|
51
56
|
const types = onlyType ? [onlyType] : [...CAPABILITY_TYPES];
|
|
@@ -53,7 +58,9 @@ export function queryCapabilityTypes(ctx, config, onlyType) {
|
|
|
53
58
|
for (const type of types) {
|
|
54
59
|
const policy = getAgentCapabilityConfig(config, ctx.baseagent, type);
|
|
55
60
|
const support = provider.getSupport(type);
|
|
56
|
-
capabilities[type] =
|
|
61
|
+
capabilities[type] = type === 'skill' && !isBaseagentSkillsEnabled(config)
|
|
62
|
+
? { ...support, mode: policy.mode, canUpdate: false, reason: BASEAGENT_SKILLS_DISABLED_REASON }
|
|
63
|
+
: { ...support, mode: policy.mode };
|
|
57
64
|
}
|
|
58
65
|
return {
|
|
59
66
|
scope: 'project',
|
|
@@ -161,7 +168,9 @@ async function discoverCatalogForPolicy(provider, ctx, config, baseagent) {
|
|
|
161
168
|
const catalog = {};
|
|
162
169
|
for (const type of CAPABILITY_TYPES) {
|
|
163
170
|
const policy = getAgentCapabilityConfig(config, baseagent, type);
|
|
164
|
-
|
|
171
|
+
// 基座 skill 关闭时要逐个禁用已发现的技能,必须先扫目录。
|
|
172
|
+
const skillsLocked = type === 'skill' && !isBaseagentSkillsEnabled(config);
|
|
173
|
+
if (skillsLocked || policy.mode !== 'inherit' || Object.keys(policy.overrides).length > 0) {
|
|
165
174
|
try {
|
|
166
175
|
catalog[type] = await provider.discover(ctx, type);
|
|
167
176
|
}
|
|
@@ -175,18 +184,7 @@ async function discoverCatalogForPolicy(provider, ctx, config, baseagent) {
|
|
|
175
184
|
export async function resolveClaudeCapabilityRunOptionsForProject(config, projectPath, baseagent = 'claude') {
|
|
176
185
|
const provider = getProvider(baseagent);
|
|
177
186
|
const ctx = { aid: config?.aid ?? '', baseagent, projectPath };
|
|
178
|
-
const catalog =
|
|
179
|
-
for (const type of CAPABILITY_TYPES) {
|
|
180
|
-
const policy = getAgentCapabilityConfig(config, baseagent, type);
|
|
181
|
-
if (policy.mode !== 'inherit' || Object.keys(policy.overrides).length > 0) {
|
|
182
|
-
try {
|
|
183
|
-
catalog[type] = await provider.discover(ctx, type);
|
|
184
|
-
}
|
|
185
|
-
catch {
|
|
186
|
-
catalog[type] = [];
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
187
|
+
const catalog = await discoverCatalogForPolicy(provider, ctx, config, baseagent);
|
|
190
188
|
return resolveClaudeCapabilityRunOptions(config, baseagent, catalog);
|
|
191
189
|
}
|
|
192
190
|
export function resolveClaudeCapabilityRunOptions(config, baseagent = 'claude', catalog = {}) {
|
|
@@ -195,19 +193,26 @@ export function resolveClaudeCapabilityRunOptions(config, baseagent = 'claude',
|
|
|
195
193
|
const plugin = getAgentCapabilityConfig(config, baseagent, 'plugin');
|
|
196
194
|
const options = {};
|
|
197
195
|
const settings = {};
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
options.
|
|
196
|
+
if (!isBaseagentSkillsEnabled(config)) {
|
|
197
|
+
// 从模型上下文移除 Skill 工具,并清空技能清单(/技能名 也不再展开)。
|
|
198
|
+
options.disallowedTools = ['Skill'];
|
|
199
|
+
options.skills = [];
|
|
201
200
|
}
|
|
202
|
-
else
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
201
|
+
else {
|
|
202
|
+
const enabledSkills = Object.entries(skill.overrides).filter(([, v]) => v === 'enabled').map(([id]) => id);
|
|
203
|
+
if (skill.mode === 'all') {
|
|
204
|
+
options.skills = 'all';
|
|
205
|
+
}
|
|
206
|
+
else if (skill.mode === 'none') {
|
|
207
|
+
options.skills = enabledSkills;
|
|
208
|
+
}
|
|
209
|
+
const skillOverrides = {};
|
|
210
|
+
for (const [id, value] of Object.entries(skill.overrides)) {
|
|
211
|
+
skillOverrides[id] = value === 'enabled' ? 'on' : 'off';
|
|
212
|
+
}
|
|
213
|
+
if (Object.keys(skillOverrides).length > 0)
|
|
214
|
+
settings.skillOverrides = skillOverrides;
|
|
208
215
|
}
|
|
209
|
-
if (Object.keys(skillOverrides).length > 0)
|
|
210
|
-
settings.skillOverrides = skillOverrides;
|
|
211
216
|
const mcpCatalog = catalog.mcp ?? [];
|
|
212
217
|
const selectedMcpIds = resolveCapabilityIds(mcp, mcpCatalog);
|
|
213
218
|
const mcpServers = {};
|
|
@@ -271,19 +276,31 @@ export function resolveCodexCapabilityThreadConfig(config, baseagent = 'codex',
|
|
|
271
276
|
const plugin = getAgentCapabilityConfig(config, baseagent, 'plugin');
|
|
272
277
|
const skillEntries = [];
|
|
273
278
|
const skillCatalog = catalog.skill ?? [];
|
|
274
|
-
if (
|
|
279
|
+
if (!isBaseagentSkillsEnabled(config)) {
|
|
280
|
+
// 不注入技能清单、关闭内置技能,已发现的技能逐个禁用($技能名 也不再注入)。
|
|
275
281
|
for (const item of skillCatalog)
|
|
276
282
|
skillEntries.push({ name: item.id, enabled: false });
|
|
283
|
+
for (const name of Object.keys(skill.overrides)) {
|
|
284
|
+
if (!skillEntries.some(entry => entry.name === name))
|
|
285
|
+
skillEntries.push({ name, enabled: false });
|
|
286
|
+
}
|
|
287
|
+
mergeJsonObject(out, { skills: { include_instructions: false, bundled: { enabled: false }, config: skillEntries } });
|
|
277
288
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
289
|
+
else {
|
|
290
|
+
if (skill.mode === 'none') {
|
|
291
|
+
for (const item of skillCatalog)
|
|
292
|
+
skillEntries.push({ name: item.id, enabled: false });
|
|
293
|
+
}
|
|
294
|
+
for (const [name, override] of Object.entries(skill.overrides)) {
|
|
295
|
+
const existing = skillEntries.find(entry => entry.name === name);
|
|
296
|
+
if (existing)
|
|
297
|
+
existing.enabled = override === 'enabled';
|
|
298
|
+
else
|
|
299
|
+
skillEntries.push({ name, enabled: override === 'enabled' });
|
|
300
|
+
}
|
|
301
|
+
if (skillEntries.length > 0) {
|
|
302
|
+
mergeJsonObject(out, { skills: { config: skillEntries } });
|
|
303
|
+
}
|
|
287
304
|
}
|
|
288
305
|
const mcpCatalog = catalog.mcp ?? [];
|
|
289
306
|
const selectedMcpIds = resolveCapabilityIds(mcp, mcpCatalog);
|
|
@@ -143,8 +143,49 @@ export class ChannelLoader {
|
|
|
143
143
|
}
|
|
144
144
|
return connected;
|
|
145
145
|
}
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
/**
|
|
147
|
+
* 并行断开所有渠道。返回每个渠道各自的耗时,供停止甘特图/日志定位"谁慢"。
|
|
148
|
+
*
|
|
149
|
+
* `timeoutMs` 是整体预算:到点后不再等剩下的渠道,直接返回。
|
|
150
|
+
*
|
|
151
|
+
* 为什么需要这个预算:AUN 渠道的 `disconnect()` 会 await SDK 的 `close()`,
|
|
152
|
+
* 而 SDK 把关闭排在 transport 的 actor 队列里(内部注释叫"连接建立串行权")。
|
|
153
|
+
* 重连风暴期间队列里可能压着一个迟迟不结束的 connect setup,关闭就一起卡住
|
|
154
|
+
* ——实测出现过 20 个渠道同时进入 `close()`、18 秒内**一条 SDK 日志都没有**、
|
|
155
|
+
* 然后集体恢复的情况。进程反正要退出,socket 会随进程消失,不值得为它等满。
|
|
156
|
+
*
|
|
157
|
+
* 超时的渠道会单独打 WARN,便于事后确认是不是又碰上这种风暴。
|
|
158
|
+
*/
|
|
159
|
+
async disconnectAll(instances, { timeoutMs = 3_000 } = {}) {
|
|
160
|
+
const timings = [];
|
|
161
|
+
const workers = instances.map(async (inst) => {
|
|
162
|
+
const name = inst.adapter.channelName || inst.channelType || 'unknown';
|
|
163
|
+
const startedAt = Date.now();
|
|
164
|
+
let timedOut = false;
|
|
165
|
+
try {
|
|
166
|
+
await Promise.race([
|
|
167
|
+
inst.disconnect(),
|
|
168
|
+
new Promise(resolve => {
|
|
169
|
+
setTimeout(() => { timedOut = true; resolve(); }, timeoutMs);
|
|
170
|
+
}),
|
|
171
|
+
]);
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
logger.warn(`[Shutdown] channel disconnect failed: ${name}: ${error instanceof Error ? error.message : String(error)}`);
|
|
175
|
+
}
|
|
176
|
+
finally {
|
|
177
|
+
const durationMs = Date.now() - startedAt;
|
|
178
|
+
timings.push({ name, durationMs, timedOut });
|
|
179
|
+
if (timedOut) {
|
|
180
|
+
logger.warn(`[Shutdown] channel disconnect timed out after ${durationMs}ms, abandoning: ${name}`);
|
|
181
|
+
}
|
|
182
|
+
else if (durationMs >= 1_000) {
|
|
183
|
+
logger.warn(`[Shutdown] channel disconnect slow: ${name} ${durationMs}ms`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
await Promise.allSettled(workers);
|
|
188
|
+
return timings.sort((a, b) => b.durationMs - a.durationMs);
|
|
148
189
|
}
|
|
149
190
|
}
|
|
150
191
|
const SEP = '#';
|
|
@@ -5,7 +5,7 @@ import { removeRestartRequest } from '../utils/restart-safety.js';
|
|
|
5
5
|
import { tryParseChannelKey } from './channel-loader.js';
|
|
6
6
|
import { agentMdPath } from '../paths.js';
|
|
7
7
|
import { registerAdapterInteractions } from './interaction-router.js';
|
|
8
|
-
import { resolvePeerDisplayLabel } from '../config/
|
|
8
|
+
import { resolvePeerDisplayLabel } from '../config/peer-book.js';
|
|
9
9
|
import { sanitizeMenuLogValue } from './command/menu-protocol.js';
|
|
10
10
|
import { appendMessageLog, buildOutboundEntry } from './message/message-log.js';
|
|
11
11
|
import crypto from 'crypto';
|
|
@@ -81,7 +81,7 @@ export function createChannelConnectionRuntime(dependencies) {
|
|
|
81
81
|
const agent = dependencies.resolveOwningAgent(key, name);
|
|
82
82
|
if (instance.channelType === 'aun' && agent) {
|
|
83
83
|
const recoveries = queuePendingObserverHints(agent.aid, key);
|
|
84
|
-
if (dependencies.
|
|
84
|
+
if (dependencies.isStartupRecoveryPending())
|
|
85
85
|
dependencies.startupObserverRecoveries.push(...recoveries);
|
|
86
86
|
}
|
|
87
87
|
await Promise.all([
|
|
@@ -51,6 +51,35 @@ export function oneShotCreationView(aid, lifecycle, state) {
|
|
|
51
51
|
...(progress?.error ? { error: progress.error } : {}),
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* List projection must isolate a damaged initialization journal to its Agent.
|
|
56
|
+
* Keep the strict reader for mutation/query paths; this fallback only exposes
|
|
57
|
+
* the already-sanitized summary and never treats the Agent as ready.
|
|
58
|
+
*/
|
|
59
|
+
function oneShotCreationListView(aid, lifecycle) {
|
|
60
|
+
try {
|
|
61
|
+
const view = oneShotCreationView(aid, lifecycle);
|
|
62
|
+
if (!view)
|
|
63
|
+
return undefined;
|
|
64
|
+
const { usable: _usable, ...rest } = view;
|
|
65
|
+
return rest;
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
const summary = initializationSummary(aid);
|
|
69
|
+
const code = error?.code || 'INITIALIZE_STATE_INVALID';
|
|
70
|
+
const diagnostic = summary
|
|
71
|
+
? (() => {
|
|
72
|
+
const { mode: _mode, ...rest } = summary;
|
|
73
|
+
return { ...rest, code: rest.code || code };
|
|
74
|
+
})()
|
|
75
|
+
: {
|
|
76
|
+
status: 'failed', phase: 'unknown', complete: false,
|
|
77
|
+
code,
|
|
78
|
+
error: 'Initialization state is invalid', retryable: false,
|
|
79
|
+
};
|
|
80
|
+
return { initialization: { ...diagnostic, complete: false }, usable: false };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
54
83
|
async function execOneShotCreate(a, peerId, service, subject) {
|
|
55
84
|
if (!service?.initialization)
|
|
56
85
|
return { error: '初始化服务不可用', code: 'NOT_CONFIGURED' };
|
|
@@ -158,7 +187,7 @@ async function execOneShotCreate(a, peerId, service, subject) {
|
|
|
158
187
|
return initializationError(error);
|
|
159
188
|
}
|
|
160
189
|
}
|
|
161
|
-
const SUPPORTED_AGENT_PATCH_FIELDS = new Set(['aid', 'name', 'avatar', 'active_baseagent', 'baseagents', 'projects', 'owner', 'owners', 'fullaccess', 'chatmode', 'channels', 'channelOwners']);
|
|
190
|
+
const SUPPORTED_AGENT_PATCH_FIELDS = new Set(['aid', 'name', 'avatar', 'active_baseagent', 'baseagents', 'projects', 'owner', 'owners', 'fullaccess', 'baseagentSkills', 'chatmode', 'channels', 'channelOwners']);
|
|
162
191
|
const HIDDEN_VALUE = '[hidden]';
|
|
163
192
|
const SENSITIVE_CONFIG_KEYS = new Set([
|
|
164
193
|
'apikey',
|
|
@@ -990,6 +1019,9 @@ export async function execAgentUpdate(args, subject) {
|
|
|
990
1019
|
if (p.aid !== undefined) {
|
|
991
1020
|
return { error: 'aid 不可修改(AUN 身份绑定,如需换 AID 请删除后重建)', code: 'INVALID_ARGS' };
|
|
992
1021
|
}
|
|
1022
|
+
if (p.baseagentSkills !== undefined && typeof p.baseagentSkills !== 'boolean') {
|
|
1023
|
+
return { error: 'baseagentSkills 必须是布尔值', code: 'INVALID_ARGS' };
|
|
1024
|
+
}
|
|
993
1025
|
if (Object.hasOwn(p, 'avatar') && Object.keys(p).length !== 1) {
|
|
994
1026
|
return { error: 'avatar 不能与其他 patch 字段同时提交,请拆分为两次 update', code: 'INVALID_ARGS' };
|
|
995
1027
|
}
|
|
@@ -1028,7 +1060,7 @@ export async function execAgentUpdate(args, subject) {
|
|
|
1028
1060
|
return execAidAvatar({ aid: a.aid, data: p.avatar });
|
|
1029
1061
|
let touched = false;
|
|
1030
1062
|
const data = { aid: a.aid };
|
|
1031
|
-
const hasConfigPatch = p.active_baseagent !== undefined || p.baseagents !== undefined || p.projects !== undefined || p.owner !== undefined || p.owners !== undefined || p.fullaccess !== undefined || p.chatmode !== undefined || p.channels !== undefined || p.channelOwners !== undefined;
|
|
1063
|
+
const hasConfigPatch = p.active_baseagent !== undefined || p.baseagents !== undefined || p.projects !== undefined || p.owner !== undefined || p.owners !== undefined || p.fullaccess !== undefined || p.baseagentSkills !== undefined || p.chatmode !== undefined || p.channels !== undefined || p.channelOwners !== undefined;
|
|
1032
1064
|
if (p.active_baseagent !== undefined) {
|
|
1033
1065
|
if (typeof p.active_baseagent !== 'string' || !p.active_baseagent.trim()) {
|
|
1034
1066
|
return { error: `无效 active_baseagent: ${JSON.stringify(p.active_baseagent)}(必须是非空字符串)`, code: 'INVALID_ARGS' };
|
|
@@ -1067,6 +1099,14 @@ export async function execAgentUpdate(args, subject) {
|
|
|
1067
1099
|
config.fullaccess = { enabled: p.fullaccess.enabled };
|
|
1068
1100
|
touched = true;
|
|
1069
1101
|
}
|
|
1102
|
+
if (p.baseagentSkills !== undefined) {
|
|
1103
|
+
// 默认关闭:true 显式落盘,false 删除覆盖值回落缺省。
|
|
1104
|
+
if (p.baseagentSkills)
|
|
1105
|
+
config.baseagentSkills = true;
|
|
1106
|
+
else
|
|
1107
|
+
delete config.baseagentSkills;
|
|
1108
|
+
touched = true;
|
|
1109
|
+
}
|
|
1070
1110
|
if (p.chatmode !== undefined) {
|
|
1071
1111
|
config.chatmode = p.chatmode;
|
|
1072
1112
|
touched = true;
|
|
@@ -1231,21 +1271,17 @@ export async function execAgentOptions(args, service) {
|
|
|
1231
1271
|
? res.agents
|
|
1232
1272
|
: res.agents.filter((x) => x.status !== 'disabled');
|
|
1233
1273
|
let agents;
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
}
|
|
1247
|
-
catch (error) {
|
|
1248
|
-
return initializationError(error);
|
|
1249
|
-
}
|
|
1274
|
+
agents = listed.map((agent) => {
|
|
1275
|
+
const initialization = oneShotCreationListView(agent.aid, agent.lifecycle);
|
|
1276
|
+
return initialization ? {
|
|
1277
|
+
...agent,
|
|
1278
|
+
...(initialization.mode ? { mode: initialization.mode } : {}),
|
|
1279
|
+
...(initialization.lifecycle !== undefined ? { lifecycle: initialization.lifecycle } : {}),
|
|
1280
|
+
...(initialization.initialization ? { initialization: initialization.initialization } : {}),
|
|
1281
|
+
...(initialization.createProgress ? { createProgress: initialization.createProgress } : {}),
|
|
1282
|
+
...(initialization.ownership ? { ownership: initialization.ownership } : {}),
|
|
1283
|
+
...(initialization.usable !== undefined ? { usable: initialization.usable } : {}),
|
|
1284
|
+
} : agent;
|
|
1285
|
+
});
|
|
1250
1286
|
return { data: { agents, scope } };
|
|
1251
1287
|
}
|