evolcore 0.0.49 → 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 +64 -1
- 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 +280 -6
- 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 +4 -1
- 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 +29 -1
- package/dist/aun/msg/upload.js +126 -3
- package/dist/build-identity.json +1 -1
- package/dist/channels/aun.js +537 -189
- 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/ecmsg-gateway.js +11 -9
- package/dist/cli/index.js +23 -4
- package/dist/cli/init.js +39 -63
- package/dist/cli/managed-command-guard.js +1 -0
- package/dist/cli/menu-client.js +32 -7
- package/dist/cli/pay-command.js +30 -0
- package/dist/cli/provider-command.js +6 -2
- package/dist/cli/restart-monitor.js +2 -2
- package/dist/cli/services-command.js +11 -9
- package/dist/cli/thread-command.js +78 -12
- package/dist/config/access-policy.js +16 -3
- package/dist/config/config-field-policy.js +17 -8
- package/dist/config/config-manager.js +86 -46
- 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 +99 -16
- package/dist/config/providers-management.js +35 -19
- package/dist/config/resolved-config-op.js +1 -42
- 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/operation-authorizer.js +16 -1
- package/dist/core/auth/operation-catalog.js +50 -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 +15 -0
- 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 +91 -72
- package/dist/core/command/menu-protocol.js +5 -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/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 +2 -1
- package/dist/core/daemon-lifecycle.js +13 -5
- package/dist/core/evolagent-registry.js +12 -7
- 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 +4 -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 +98 -21
- package/dist/core/message/aun-request-registry.js +31 -0
- package/dist/core/message/message-bridge.js +105 -6
- package/dist/core/message/message-log.js +8 -0
- package/dist/core/message/message-queue.js +5 -3
- package/dist/core/message/peer-mode.js +15 -4
- package/dist/core/message/response-engine.js +23 -8
- package/dist/core/message/send-options.js +37 -3
- package/dist/core/message/send-routing.js +11 -7
- package/dist/core/model/model-catalog.js +5 -5
- package/dist/core/ownership/owner-resolver.js +12 -86
- package/dist/core/pack-auth.js +4 -0
- package/dist/core/permission/ec-command-parser.js +182 -58
- package/dist/core/permission/protected-paths.js +64 -9
- package/dist/core/permission/services-path-acl.js +9 -2
- package/dist/core/permission/tool-policy.js +21 -9
- 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/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 +52 -2
- package/dist/core/thread/types.js +15 -1
- package/dist/eck/kit-renderer.js +2 -1
- package/dist/ecweb/basic-settings-service.js +5 -9
- package/dist/ecweb/providers-service.js +4 -2
- package/dist/index.js +116 -41
- package/dist/ipc.js +58 -2
- 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 +176 -18
- package/dist/services/ipc-operation.js +204 -44
- package/dist/services/script-runner.js +515 -83
- package/dist/services/validation.js +109 -4
- 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 -20
- package/dist/utils/aid-bind.js +3 -0
- package/dist/utils/evolcore-version.js +2 -2
- package/dist/utils/host-info.js +73 -0
- package/dist/utils/logger.js +2 -2
- package/dist/utils/media-cache.js +190 -43
- 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/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 +7 -6
- package/kits/docs/evolcore/agent.md +36 -1
- package/kits/docs/evolcore/aid.md +20 -3
- package/kits/docs/evolcore/config.md +1 -1
- 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 +68 -10
- package/kits/docs/evolcore/pay.md +34 -0
- package/kits/docs/evolcore/provider.md +21 -0
- package/kits/docs/evolcore/services.md +46 -18
- package/kits/docs/evolcore/thread-chain.md +2 -0
- package/kits/docs/evolcore/tool-authorization.md +10 -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.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 +13 -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 +12 -5
- 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 +1 -1
- 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/system-fragments/channel.md +13 -4
- package/kits/templates/system-fragments/commands.md +4 -3
- 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 -129
- package/kits/templates/system-fragments/venue.md +16 -0
- package/package.json +4 -5
- package/scripts/agent-template/inspect.mjs +37 -23
- package/scripts/agent-template/overlay.mjs +20 -2
- package/scripts/agent-template/shared/common.mjs +16 -4
- package/scripts/agent-template/shared/team-schema.json +20 -4
- package/scripts/agent-template/shared/template-contract.mjs +53 -13
- package/scripts/agent-template/shared/template-package.mjs +90 -26
- package/scripts/agent-template/shared/template-runtime.mjs +111 -1
- package/scripts/agent-template/shared/template.mjs +65 -7
- package/scripts/agent-template/team-pack.mjs +89 -33
- 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
|
@@ -9,6 +9,7 @@ import { ConfigTarget, assertAgentAidAvailable, read as readConfig } from '../co
|
|
|
9
9
|
import { invalidateKitCache } from '../eck/kit-renderer.js';
|
|
10
10
|
import { logger } from '../utils/logger.js';
|
|
11
11
|
import fs from 'fs';
|
|
12
|
+
import { agentProjectChangeGate } from '../config-store.js';
|
|
12
13
|
import path from 'path';
|
|
13
14
|
import { resolvePaths } from '../paths.js';
|
|
14
15
|
import { ownerResolver } from './ownership/owner-resolver.js';
|
|
@@ -17,6 +18,7 @@ import { getAidStore, loadClient } from '../aun/aid/store.js';
|
|
|
17
18
|
import { isValidAid } from '../aun/aid/validation.js';
|
|
18
19
|
import { readPreparedTemplateIdentity } from '../agent-template/runtime.js';
|
|
19
20
|
import { readAgentCreationClaim } from './agent-creation-claim.js';
|
|
21
|
+
import { getCcAgentAid } from '../agents/claude-gateway/agent-registration.js';
|
|
20
22
|
export function loadStartupAgentRegistry(agentRegistry) {
|
|
21
23
|
agentRegistry.loadAll();
|
|
22
24
|
const agentInfos = agentRegistry.list();
|
|
@@ -44,9 +46,9 @@ export function loadStartupAgentRegistry(agentRegistry) {
|
|
|
44
46
|
const owners = duplicate.agents.map(owner => `${owner.aid}(${owner.channelName})`).join(', ');
|
|
45
47
|
logger.warn(`⚠ Duplicate channel credential: ${duplicate.fingerprint} claimed by ${owners}.`);
|
|
46
48
|
}
|
|
47
|
-
const primaryAgent = agentRegistry.runnableAgents()
|
|
49
|
+
const primaryAgent = agentRegistry.runnableAgents().find(agent => agent.aid !== getCcAgentAid());
|
|
48
50
|
const runtimeStatus = { state: primaryAgent ? 'starting' : 'empty' };
|
|
49
|
-
if (!primaryAgent && agentInfos.
|
|
51
|
+
if (!primaryAgent && agentInfos.some(agent => agent.aid !== getCcAgentAid())) {
|
|
50
52
|
runtimeStatus.state = 'error';
|
|
51
53
|
runtimeStatus.error = 'No runnable self-agent (all are error/disabled).';
|
|
52
54
|
logger.warn(`[startup] ${runtimeStatus.error} Control Plane will remain available.`);
|
|
@@ -74,7 +76,7 @@ export function createOnDemandAgentRunners(deps) {
|
|
|
74
76
|
await deps.coordinator.runRunnerOperation(aid, async () => {
|
|
75
77
|
assertRunning();
|
|
76
78
|
const agent = deps.agentRegistry.get(aid);
|
|
77
|
-
const available = agent && agent.config.enabled !== false && agent.status !== 'disabled' && agent.status !== 'stopped'
|
|
79
|
+
const available = agent && !agentProjectChangeGate(aid) && agent.config.enabled !== false && agent.status !== 'disabled' && agent.status !== 'stopped'
|
|
78
80
|
? deps.agentLoader.enabledBaseagents(agent) : [];
|
|
79
81
|
if (!agent || !available.includes(baseagent)) {
|
|
80
82
|
throw new BaseagentRunnerUnavailableError(aid, baseagent, available);
|
|
@@ -165,7 +167,7 @@ export async function createStartupAgentRunners({ agentRegistry, agentLoader, se
|
|
|
165
167
|
throw error;
|
|
166
168
|
}
|
|
167
169
|
activeSettled.add(agent.aid);
|
|
168
|
-
if (!instances.some(instance => instance.baseagent === agent.baseagent)) {
|
|
170
|
+
if (agent.aid !== getCcAgentAid() && !instances.some(instance => instance.baseagent === agent.baseagent)) {
|
|
169
171
|
agent.status = 'error';
|
|
170
172
|
agent.error = creationErrors.filter(error => error.evolagentName === agent.name)
|
|
171
173
|
.map(({ baseagent, message }) => `${baseagent}: ${message}`).join('; ')
|
|
@@ -189,9 +191,9 @@ export async function createStartupAgentRunners({ agentRegistry, agentLoader, se
|
|
|
189
191
|
throw error;
|
|
190
192
|
}
|
|
191
193
|
await activeReady(agent, instances, timing);
|
|
192
|
-
if (primaryAgent?.aid === agent.aid
|
|
194
|
+
if (agent.aid !== getCcAgentAid() && (primaryAgent?.aid === agent.aid
|
|
193
195
|
? !instances.some(instance => instance.baseagent === primaryBaseagent)
|
|
194
|
-
: !instances.some(instance => instance.baseagent === agent.baseagent)) {
|
|
196
|
+
: !instances.some(instance => instance.baseagent === agent.baseagent))) {
|
|
195
197
|
const errors = creationErrors.filter(error => error.evolagentName === agent.name);
|
|
196
198
|
agent.status = 'error';
|
|
197
199
|
agent.error = errors.length > 0
|
|
@@ -416,6 +418,7 @@ export function createAgentInitializationRuntime({ agentRegistry, agentMap, chan
|
|
|
416
418
|
const isConnected = (aid) => channelInstances.some(instance => instance.channelType === 'aun'
|
|
417
419
|
&& instance.channel.getAidState?.()?.aid === aid
|
|
418
420
|
&& instance.channel.getAidState?.()?.status === 'connected');
|
|
421
|
+
const ownerObservers = new Map();
|
|
419
422
|
return new AgentInitializationService({
|
|
420
423
|
preparedIdentity: (aid, ownerAid) => {
|
|
421
424
|
return readAgentCreationClaim(aid)?.teamJobId ? readPreparedTemplateIdentity(aid, ownerAid) : undefined;
|
|
@@ -468,7 +471,16 @@ export function createAgentInitializationRuntime({ agentRegistry, agentMap, chan
|
|
|
468
471
|
},
|
|
469
472
|
checkOwner: (aid, ownerAid) => isConnected(aid)
|
|
470
473
|
? checkInitializationOwner(aid, ownerAid, readInitialization(aid)?.mode === 'one_shot' ? 1 : undefined)
|
|
471
|
-
: checkBootstrapInitializationOwner(aid, ownerAid),
|
|
474
|
+
: ownerObservers.get(aid)?.check(ownerAid) ?? checkBootstrapInitializationOwner(aid, ownerAid),
|
|
475
|
+
watchOwner: (aid, onChange) => {
|
|
476
|
+
const observer = createInitializationOwnerObserver(aid, onChange);
|
|
477
|
+
ownerObservers.set(aid, observer);
|
|
478
|
+
return async () => {
|
|
479
|
+
if (ownerObservers.get(aid) === observer)
|
|
480
|
+
ownerObservers.delete(aid);
|
|
481
|
+
await observer.close();
|
|
482
|
+
};
|
|
483
|
+
},
|
|
472
484
|
publish: async (aid, content, ownerAid) => {
|
|
473
485
|
const { agentmdPut, agentmdPutInitializationProfile } = await import('../aun/aid/agentmd.js');
|
|
474
486
|
if (ownerAid)
|
|
@@ -738,6 +750,16 @@ const AUDITED_WORKFLOW_SHA256 = {
|
|
|
738
750
|
'0.5.35': '55b6d41331b4dfc6b377be9f4ff28d322af5e06fc4539c5d0120cb15419623f6',
|
|
739
751
|
// 0.5.36 retains the audited workflow; installed SDK preflight and execute boundaries were revalidated.
|
|
740
752
|
'0.5.36': '55b6d41331b4dfc6b377be9f4ff28d322af5e06fc4539c5d0120cb15419623f6',
|
|
753
|
+
// 0.5.37 ships byte-identical workflow bytes and dependencies (errors/ownership-v21) plus an
|
|
754
|
+
// unchanged injection block in client.js; the only ownership-related delta records the
|
|
755
|
+
// X-AUN-Owner-MD-SHA256 header after a completed agent.md download, leaving read/execute
|
|
756
|
+
// ordering untouched.
|
|
757
|
+
'0.5.37': '55b6d41331b4dfc6b377be9f4ff28d322af5e06fc4539c5d0120cb15419623f6',
|
|
758
|
+
// 0.5.38 changes exactly one thing: the `yaml` import moves from a static import to a lazy
|
|
759
|
+
// createRequire call inside parseOwnershipMessage, so the module no longer loads yaml at import
|
|
760
|
+
// time. No read/verify/execute ordering moved; start()/capture() still only read and verify, and
|
|
761
|
+
// every persist and notification still happens inside execute().
|
|
762
|
+
'0.5.38': '56d834587a3211a36e20a2574357b172f1d223b48b4d393b7b83989e2955d55d',
|
|
741
763
|
};
|
|
742
764
|
export function initializationBindPreflightFailure(error) {
|
|
743
765
|
if (!(error instanceof Error) || error.code !== 'ECONNRESET')
|
|
@@ -758,46 +780,164 @@ export function initializationBindPreflightFailure(error) {
|
|
|
758
780
|
}
|
|
759
781
|
}
|
|
760
782
|
/** Initial binding precedes the daemon channel; use an independent short slot. */
|
|
761
|
-
async function
|
|
783
|
+
async function openInitializationClient(aid, subscribe) {
|
|
762
784
|
let store;
|
|
763
785
|
let client;
|
|
764
|
-
|
|
786
|
+
const close = async () => {
|
|
787
|
+
// A close failure must not discard an exact task already returned by bind.
|
|
788
|
+
try {
|
|
789
|
+
await client?.close();
|
|
790
|
+
}
|
|
791
|
+
catch { /* preserve operation result */ }
|
|
792
|
+
try {
|
|
793
|
+
store?.close();
|
|
794
|
+
}
|
|
795
|
+
catch { /* preserve operation result */ }
|
|
796
|
+
};
|
|
765
797
|
try {
|
|
766
798
|
store = await getAidStore({ slotId: 'evolcore-initialization' });
|
|
767
799
|
client = await loadClient(store, aid);
|
|
768
800
|
if (client.currentAid?.aid !== aid || !client.currentAid.isCertValid() || !client.currentAid.isPrivateKeyValid()) {
|
|
769
801
|
throw Object.assign(new Error('Initialization identity is unavailable'), { code: 'INITIALIZE_IDENTITY_UNAVAILABLE' });
|
|
770
802
|
}
|
|
803
|
+
subscribe?.(client);
|
|
771
804
|
await client.connect({ connection_kind: 'short', short_ttl_ms: 120_000,
|
|
772
805
|
background_sync: false, auto_reconnect: false, connect_timeout: 10, call_timeout: 30 });
|
|
773
|
-
|
|
774
|
-
// audited read-only preflight as not started; all other failures stay unknown.
|
|
775
|
-
actionStarted = true;
|
|
776
|
-
return await action(client, store);
|
|
806
|
+
return { client, store, close };
|
|
777
807
|
}
|
|
778
808
|
catch (error) {
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
809
|
+
await close();
|
|
810
|
+
const original = error instanceof Error ? error : new Error(String(error));
|
|
811
|
+
throw Object.assign(new Error(original.message), {
|
|
812
|
+
code: 'INITIALIZE_BIND_NOT_STARTED', cause: error,
|
|
813
|
+
causeCode: error?.code,
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
async function withInitializationClient(aid, action) {
|
|
818
|
+
const connection = await openInitializationClient(aid);
|
|
819
|
+
try {
|
|
820
|
+
return await action(connection.client, connection.store);
|
|
788
821
|
}
|
|
789
822
|
finally {
|
|
790
|
-
|
|
791
|
-
try {
|
|
792
|
-
await client?.close();
|
|
793
|
-
}
|
|
794
|
-
catch { /* preserve operation result */ }
|
|
795
|
-
try {
|
|
796
|
-
store?.close();
|
|
797
|
-
}
|
|
798
|
-
catch { /* preserve operation result */ }
|
|
823
|
+
await connection.close();
|
|
799
824
|
}
|
|
800
825
|
}
|
|
826
|
+
/** Keep an event-capable short connection until hot-load, rebuilding it after loss or expiry. */
|
|
827
|
+
export function createInitializationOwnerObserver(aid, onChange) {
|
|
828
|
+
let current;
|
|
829
|
+
let stopped = false;
|
|
830
|
+
let retiring = Promise.resolve();
|
|
831
|
+
const retire = (entry) => {
|
|
832
|
+
if (entry.closed)
|
|
833
|
+
return retiring;
|
|
834
|
+
entry.closed = true;
|
|
835
|
+
if (current === entry)
|
|
836
|
+
current = undefined;
|
|
837
|
+
clearTimeout(entry.timer);
|
|
838
|
+
for (const subscription of entry.subscriptions)
|
|
839
|
+
subscription.unsubscribe();
|
|
840
|
+
const closing = entry.ready.then(connection => connection.close(), () => { });
|
|
841
|
+
retiring = Promise.allSettled([retiring, closing]).then(() => { });
|
|
842
|
+
return retiring;
|
|
843
|
+
};
|
|
844
|
+
const connection = () => {
|
|
845
|
+
if (stopped)
|
|
846
|
+
throw new Error('Initialization Owner observer is closed');
|
|
847
|
+
if (current)
|
|
848
|
+
return current;
|
|
849
|
+
const previousRetirement = retiring;
|
|
850
|
+
const entry = {
|
|
851
|
+
closed: false, subscriptions: [],
|
|
852
|
+
ready: Promise.resolve().then(async () => {
|
|
853
|
+
await previousRetirement;
|
|
854
|
+
if (stopped || entry.closed)
|
|
855
|
+
throw new Error('Initialization Owner observer is closed');
|
|
856
|
+
const opened = await openInitializationClient(aid, client => {
|
|
857
|
+
if (stopped || entry.closed)
|
|
858
|
+
throw new Error('Initialization Owner observer is closed');
|
|
859
|
+
const changed = () => {
|
|
860
|
+
if (!stopped && !entry.closed && current === entry)
|
|
861
|
+
onChange();
|
|
862
|
+
};
|
|
863
|
+
for (const event of ['ownership.request', 'ownership.pending', 'ownership.progress', 'ownership.completed',
|
|
864
|
+
'ownership.rejected', 'ownership.stopped', 'ownership.error', 'ownership.action_required']) {
|
|
865
|
+
entry.subscriptions.push(client.on(event, payload => {
|
|
866
|
+
if (payload && typeof payload === 'object' && 'sub_aid' in payload && payload.sub_aid === aid)
|
|
867
|
+
changed();
|
|
868
|
+
}));
|
|
869
|
+
}
|
|
870
|
+
entry.subscriptions.push(client.on('agentmd.changed', payload => { if (payload === aid)
|
|
871
|
+
changed(); }));
|
|
872
|
+
entry.subscriptions.push(client.on('agent_md_changed', payload => {
|
|
873
|
+
if (payload && typeof payload === 'object' && 'aid' in payload && payload.aid === aid)
|
|
874
|
+
changed();
|
|
875
|
+
}));
|
|
876
|
+
entry.subscriptions.push(client.on('storage.object_changed', payload => {
|
|
877
|
+
if (payload && typeof payload === 'object' && 'owner_aid' in payload && payload.owner_aid === aid
|
|
878
|
+
&& 'object_key' in payload && typeof payload.object_key === 'string'
|
|
879
|
+
&& payload.object_key.replace(/^\/+/, '') === 'agent.md')
|
|
880
|
+
changed();
|
|
881
|
+
}));
|
|
882
|
+
for (const event of ['state_change', 'connection.state']) {
|
|
883
|
+
entry.subscriptions.push(client.on(event, payload => {
|
|
884
|
+
if (stopped || entry.closed || current !== entry)
|
|
885
|
+
return;
|
|
886
|
+
const state = typeof payload === 'string' ? payload
|
|
887
|
+
: payload && typeof payload === 'object'
|
|
888
|
+
? ('state' in payload ? payload.state : 'status' in payload ? payload.status : undefined) : undefined;
|
|
889
|
+
if (entry.timer && typeof state === 'string' && state !== 'ready' && state !== 'connected') {
|
|
890
|
+
void retire(entry);
|
|
891
|
+
if (!stopped)
|
|
892
|
+
onChange();
|
|
893
|
+
}
|
|
894
|
+
}));
|
|
895
|
+
}
|
|
896
|
+
});
|
|
897
|
+
if (!entry.closed) {
|
|
898
|
+
// Renew before the gateway's 120-second short-session TTL.
|
|
899
|
+
entry.timer = setTimeout(() => {
|
|
900
|
+
if (stopped || entry.closed || current !== entry)
|
|
901
|
+
return;
|
|
902
|
+
void retire(entry);
|
|
903
|
+
if (!stopped)
|
|
904
|
+
onChange();
|
|
905
|
+
}, 110_000);
|
|
906
|
+
entry.timer.unref?.();
|
|
907
|
+
}
|
|
908
|
+
return opened;
|
|
909
|
+
}),
|
|
910
|
+
};
|
|
911
|
+
current = entry;
|
|
912
|
+
// Setup can finish after cancellation, or fail before the worker starts its check.
|
|
913
|
+
void entry.ready.catch(() => { void retire(entry); });
|
|
914
|
+
return entry;
|
|
915
|
+
};
|
|
916
|
+
connection();
|
|
917
|
+
return {
|
|
918
|
+
check: async (ownerAid) => {
|
|
919
|
+
let entry;
|
|
920
|
+
try {
|
|
921
|
+
entry = connection();
|
|
922
|
+
const { client } = await entry.ready;
|
|
923
|
+
if (stopped || entry.closed)
|
|
924
|
+
throw new Error('Initialization Owner observer is closed');
|
|
925
|
+
return await readBootstrapInitializationOwner(client, aid, ownerAid);
|
|
926
|
+
}
|
|
927
|
+
catch (error) {
|
|
928
|
+
if (entry)
|
|
929
|
+
await retire(entry);
|
|
930
|
+
return unavailableInitializationOwner(error);
|
|
931
|
+
}
|
|
932
|
+
},
|
|
933
|
+
close: async () => {
|
|
934
|
+
stopped = true;
|
|
935
|
+
if (current)
|
|
936
|
+
await retire(current);
|
|
937
|
+
await retiring;
|
|
938
|
+
},
|
|
939
|
+
};
|
|
940
|
+
}
|
|
801
941
|
export async function bindInitializationOwner(aid, ownerAid) {
|
|
802
942
|
return withInitializationClient(aid, async (client, store) => {
|
|
803
943
|
const { assertHumanAgentOwner } = await import('../aun/aid/agentmd.js');
|
|
@@ -826,30 +966,34 @@ export async function bindAgentCreationOwner(aid, ownerAid) {
|
|
|
826
966
|
/** Each bootstrap observation has a new SDK client and no cached consensus. */
|
|
827
967
|
export async function checkBootstrapInitializationOwner(aid, ownerAid) {
|
|
828
968
|
try {
|
|
829
|
-
return await withInitializationClient(aid,
|
|
830
|
-
const view = await client.checkOwnershipConsensus(aid, true);
|
|
831
|
-
const checkedAt = Date.now();
|
|
832
|
-
const details = {
|
|
833
|
-
...(['consensus', 'released', 'unbound', 'single_sided', 'invalid', 'unavailable', 'not_applicable'].includes(view.status)
|
|
834
|
-
? { consensusStatus: view.status } : {}),
|
|
835
|
-
...(Number.isSafeInteger(view.relation_version) && view.relation_version >= 0 ? { relationVersion: view.relation_version } : {}),
|
|
836
|
-
...(['locked', 'unlocked'].includes(view.lock) ? { lock: view.lock } : {}),
|
|
837
|
-
...(view.code ? { code: initializationErrorCode(view, 'INITIALIZE_OWNER_CHECK_FAILED') } : {}),
|
|
838
|
-
...(typeof view.retryable === 'boolean' ? { retryable: view.retryable } : {}),
|
|
839
|
-
};
|
|
840
|
-
if (view.status === 'consensus' && view.sub_aid === aid && view.lock === 'locked'
|
|
841
|
-
&& view.relation_version === 1 && typeof view.owner_aid === 'string' && isValidAid(view.owner_aid) && view.owner_aid !== aid) {
|
|
842
|
-
return { status: view.owner_aid === ownerAid ? 'confirmed' : 'conflict', ownerAid: view.owner_aid, checkedAt, ...details };
|
|
843
|
-
}
|
|
844
|
-
return { status: 'pending', checkedAt, ...details };
|
|
845
|
-
});
|
|
969
|
+
return await withInitializationClient(aid, client => readBootstrapInitializationOwner(client, aid, ownerAid));
|
|
846
970
|
}
|
|
847
971
|
catch (error) {
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
972
|
+
return unavailableInitializationOwner(error);
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
async function readBootstrapInitializationOwner(client, aid, ownerAid) {
|
|
976
|
+
const view = await client.checkOwnershipConsensus(aid, true);
|
|
977
|
+
const checkedAt = Date.now();
|
|
978
|
+
const details = {
|
|
979
|
+
...(['consensus', 'released', 'unbound', 'single_sided', 'invalid', 'unavailable', 'not_applicable'].includes(view.status)
|
|
980
|
+
? { consensusStatus: view.status } : {}),
|
|
981
|
+
...(Number.isSafeInteger(view.relation_version) && view.relation_version >= 0 ? { relationVersion: view.relation_version } : {}),
|
|
982
|
+
...(['locked', 'unlocked'].includes(view.lock) ? { lock: view.lock } : {}),
|
|
983
|
+
...(view.code ? { code: initializationErrorCode(view, 'INITIALIZE_OWNER_CHECK_FAILED') } : {}),
|
|
984
|
+
...(typeof view.retryable === 'boolean' ? { retryable: view.retryable } : {}),
|
|
985
|
+
};
|
|
986
|
+
if (view.status === 'consensus' && view.sub_aid === aid && view.lock === 'locked'
|
|
987
|
+
&& view.relation_version === 1 && typeof view.owner_aid === 'string' && isValidAid(view.owner_aid) && view.owner_aid !== aid) {
|
|
988
|
+
return { status: view.owner_aid === ownerAid ? 'confirmed' : 'conflict', ownerAid: view.owner_aid, checkedAt, ...details };
|
|
854
989
|
}
|
|
990
|
+
return { status: 'pending', checkedAt, ...details };
|
|
991
|
+
}
|
|
992
|
+
function unavailableInitializationOwner(error) {
|
|
993
|
+
// An unavailable observation never confirms a relation or replays bind.
|
|
994
|
+
const codeSource = error?.code === 'INITIALIZE_BIND_NOT_STARTED'
|
|
995
|
+
? { code: error.causeCode }
|
|
996
|
+
: error;
|
|
997
|
+
return { status: 'pending', consensusStatus: 'unavailable',
|
|
998
|
+
code: initializationErrorCode(codeSource, 'INITIALIZE_OWNER_CHECK_FAILED'), retryable: true };
|
|
855
999
|
}
|
|
@@ -47,6 +47,20 @@ export class AgentDelegationRegistry {
|
|
|
47
47
|
getRuntimeEpoch() {
|
|
48
48
|
return this.runtimeEpoch;
|
|
49
49
|
}
|
|
50
|
+
/** In-process continuation only; never accepts a grant reconstructed from IPC. */
|
|
51
|
+
isCurrentTaskGrant(grant) {
|
|
52
|
+
if (this.activeHashBySession.get(grant.sessionId) !== grant.tokenHash || this.grantsByHash.get(grant.tokenHash) !== grant)
|
|
53
|
+
return false;
|
|
54
|
+
if (grant.executionIdentity?.source === 'agent-policy') {
|
|
55
|
+
try {
|
|
56
|
+
assertAgentPolicyAuthorization(grant.executionIdentity);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
50
64
|
/** 发行正常 task delegation token */
|
|
51
65
|
issue(input) {
|
|
52
66
|
if (input.executionIdentity && !isValidFullAccessExecutionIdentity(input.executionIdentity)) {
|
|
@@ -8,7 +8,11 @@ import { formatPeerKey, parsePeerKey } from '../relation/peer-identity.js';
|
|
|
8
8
|
import { sameGroupAid } from '../../aun/group/identity.js';
|
|
9
9
|
import { ownerResolver } from '../ownership/owner-resolver.js';
|
|
10
10
|
const DAEMON_OWNER_PROCESS_OPERATIONS = new Set([
|
|
11
|
-
...['
|
|
11
|
+
...['preview', 'move', 'status', 'recover', 'resolve'].map(action => 'agent.project.' + action),
|
|
12
|
+
'agent.start', 'agent.stop',
|
|
13
|
+
...['inspect', 'build', 'push', 'pull', 'preview', 'deploy', 'status', 'resume', 'cancel', 'capabilities',
|
|
14
|
+
'register-team', 'team-members', 'prepare-member-install', 'resume-member-join',
|
|
15
|
+
'update-status', 'check-update', 'bind-update-source', 'confirm-update-source', 'preview-update', 'read-update-notice'].map(action => 'agent.template.' + action),
|
|
12
16
|
'model.provider.catalog',
|
|
13
17
|
'agent.list',
|
|
14
18
|
'agent.create',
|
|
@@ -183,6 +187,17 @@ function authorizeCommandInternal(ctx, resolvedConfigCommand) {
|
|
|
183
187
|
if (!authorizationTarget.ok) {
|
|
184
188
|
return denyDecision(ctx, 'SCOPE_MISMATCH', authorizationTarget.reason, operation, intent.scope, opMeta.dangerous);
|
|
185
189
|
}
|
|
190
|
+
if (operation === 'ability.remote.call' && ctx.permissionMode === 'readonly') {
|
|
191
|
+
return denyDecision(ctx, 'NOT_ALLOWED', 'Remote Ability calls require a writable task; readonly may inspect contracts and preview only', operation, intent.scope, opMeta.dangerous, 'remote-ability-readonly');
|
|
192
|
+
}
|
|
193
|
+
// Remote Ability is a protocol client, not local plugin administration or
|
|
194
|
+
// social messaging. Provider policy decides capability access. Task mode,
|
|
195
|
+
// current-Agent binding and approved delegated execution still apply.
|
|
196
|
+
if (operation.startsWith('ability.remote.')) {
|
|
197
|
+
if (intent.scope !== 'agent')
|
|
198
|
+
return denyDecision(ctx, 'SCOPE_MISMATCH', 'Remote Ability uses the current Agent scope', operation, intent.scope, opMeta.dangerous);
|
|
199
|
+
return { allow: true, operation, scope: intent.scope, role, dangerous: opMeta.dangerous, matchedRule: 'remote-ability-protocol' };
|
|
200
|
+
}
|
|
186
201
|
if (ctx.source === 'agent-tool' && opMeta.minimumPermissionMode === 'request'
|
|
187
202
|
&& !['request', 'bypass'].includes(ctx.permissionMode ?? '')) {
|
|
188
203
|
return denyDecision(ctx, 'NOT_ALLOWED', 'This operation requires a request or bypass task', operation, intent.scope, opMeta.dangerous, 'catalog-task-mode');
|
|
@@ -156,6 +156,12 @@ const PROVIDER_OPERATIONS = ['list', 'show', 'templates', 'create', 'import', 'u
|
|
|
156
156
|
allowDelegatedRead: ['list', 'show', 'templates'].includes(action) },
|
|
157
157
|
}));
|
|
158
158
|
const OPERATIONS = [
|
|
159
|
+
...['request', 'status', 'cancel', 'verify', 'refresh', 'update', 'complete'].map(kind => ({
|
|
160
|
+
id: `ec.pay.${kind}`, category: kind === 'status' ? 'read' : 'write-own',
|
|
161
|
+
dangerous: false, defaultScopes: ['agent'], sources: ['agent-tool'],
|
|
162
|
+
description: `Manage website payment ${kind}`, minimumAgentRole: 'owner',
|
|
163
|
+
requiredChatType: 'private', requiredChannelType: 'aun',
|
|
164
|
+
})),
|
|
159
165
|
{ id: 'invoke.execute', category: 'process', dangerous: false, defaultScopes: ['process'],
|
|
160
166
|
description: 'Invoke an already configured Provider', sources: ['agent-tool', 'control'],
|
|
161
167
|
authorizationPolicy: { authority: 'daemon-owner', scope: 'process', channel: 'control', allowDelegatedRead: true } },
|
|
@@ -192,6 +198,14 @@ const OPERATIONS = [
|
|
|
192
198
|
dangerous: action !== 'read', defaultScopes: ['agent'], description: 'Manage AID ability plugins: ' + action,
|
|
193
199
|
sources: ['agent-tool', 'control', 'ecweb'],
|
|
194
200
|
})),
|
|
201
|
+
...['list', 'discover', 'info', 'devices', 'preview', 'call', 'result'].map(action => ({
|
|
202
|
+
id: 'ability.remote.' + action,
|
|
203
|
+
category: action === 'call' ? 'write-own' : 'read',
|
|
204
|
+
dangerous: action === 'call', defaultScopes: ['agent'],
|
|
205
|
+
authorizationTarget: 'current-agent',
|
|
206
|
+
description: 'Use remote AID Ability: ' + action,
|
|
207
|
+
sources: ['agent-tool'],
|
|
208
|
+
})),
|
|
195
209
|
{
|
|
196
210
|
id: 'ec.directory.query',
|
|
197
211
|
category: 'read',
|
|
@@ -237,13 +251,25 @@ const OPERATIONS = [
|
|
|
237
251
|
description: '启动、停止、重载或守护本地服务',
|
|
238
252
|
sources: ['agent-tool'],
|
|
239
253
|
},
|
|
240
|
-
...['inspect', 'build', 'push', 'pull', 'preview', 'deploy', 'status', 'resume', 'cancel', 'capabilities'
|
|
254
|
+
...['inspect', 'build', 'push', 'pull', 'preview', 'deploy', 'status', 'resume', 'cancel', 'capabilities',
|
|
255
|
+
'register-team', 'team-members', 'prepare-member-install', 'resume-member-join',
|
|
256
|
+
'update-status', 'check-update', 'bind-update-source', 'confirm-update-source', 'preview-update', 'read-update-notice'].map(action => ({
|
|
241
257
|
id: 'agent.template.' + action, category: 'process',
|
|
242
|
-
dangerous: !['status', 'capabilities'].includes(action), defaultScopes: ['process'],
|
|
258
|
+
dangerous: !['status', 'capabilities', 'team-members', 'update-status', 'check-update'].includes(action), defaultScopes: ['process'],
|
|
243
259
|
description: 'Agent template ' + action, sources: ['menu', 'control', 'agent-tool', 'ecweb'],
|
|
244
260
|
})),
|
|
245
261
|
{ id: 'model.provider.catalog', category: 'process', dangerous: false, defaultScopes: ['process'],
|
|
246
262
|
description: 'Read a Provider model catalog without changing Agent configuration', sources: ['menu', 'control', 'ecweb'] },
|
|
263
|
+
...['preview', 'move', 'status', 'recover', 'resolve'].map(action => ({
|
|
264
|
+
id: 'agent.project.' + action, category: 'process',
|
|
265
|
+
dangerous: !['preview', 'status'].includes(action), defaultScopes: ['process'],
|
|
266
|
+
description: 'Agent project ' + action, sources: ['menu', 'control', 'agent-tool', 'ecweb'],
|
|
267
|
+
})),
|
|
268
|
+
...['stop', 'start'].map(action => ({
|
|
269
|
+
id: 'agent.' + action, category: 'process', dangerous: true,
|
|
270
|
+
defaultScopes: ['process'], description: 'Explicit Agent ' + action,
|
|
271
|
+
sources: ['agent-tool', 'control', 'ecweb', 'menu'],
|
|
272
|
+
})),
|
|
247
273
|
{
|
|
248
274
|
id: 'baseagent.models.list',
|
|
249
275
|
category: 'read',
|
|
@@ -376,6 +402,23 @@ const OPERATIONS = [
|
|
|
376
402
|
description: 'Update group mention mode',
|
|
377
403
|
sources: ['slash', 'menu'],
|
|
378
404
|
},
|
|
405
|
+
{
|
|
406
|
+
id: 'privatementionmode.current',
|
|
407
|
+
category: 'read',
|
|
408
|
+
dangerous: false,
|
|
409
|
+
defaultScopes: ['agent'],
|
|
410
|
+
description: 'Read Agent private mention mode',
|
|
411
|
+
sources: ['menu'],
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
id: 'privatementionmode.update',
|
|
415
|
+
category: 'write-agent',
|
|
416
|
+
dangerous: false,
|
|
417
|
+
defaultScopes: ['agent'],
|
|
418
|
+
minimumAgentRole: 'owner',
|
|
419
|
+
description: 'Update Agent private mention mode',
|
|
420
|
+
sources: ['menu'],
|
|
421
|
+
},
|
|
379
422
|
{
|
|
380
423
|
id: 'group.list',
|
|
381
424
|
category: 'read',
|
|
@@ -888,10 +931,10 @@ const OPERATIONS = [
|
|
|
888
931
|
description: '重建技能索引文件',
|
|
889
932
|
sources: ['agent-tool', 'slash', 'menu', 'control'],
|
|
890
933
|
},
|
|
891
|
-
...['list', 'list-peers', 'show', 'history', 'check-index', 'summary-show', 'summary-log', 'create', 'rename', 'label', 'status', 'delete', 'summary-set', 'summary-clear', 'rebuild-index'].map(action => ({
|
|
934
|
+
...['list', 'list-peers', 'show', 'history', 'check-index', 'summary-show', 'summary-log', 'create', 'rename', 'label', 'status', 'delete', 'summary-set', 'summary-clear', 'rebuild-index', 'reconcile-status'].map(action => ({
|
|
892
935
|
id: `ec.thread.${action}`,
|
|
893
936
|
category: (['list', 'list-peers', 'show', 'history', 'check-index', 'summary-show', 'summary-log'].includes(action)
|
|
894
|
-
? 'read' :
|
|
937
|
+
? 'read' : ['rebuild-index', 'reconcile-status'].includes(action) ? 'write-agent' : 'write-own'),
|
|
895
938
|
dangerous: false,
|
|
896
939
|
defaultScopes: ['relation', 'agent'],
|
|
897
940
|
description: `${action} managed conversation threads`,
|
|
@@ -1330,7 +1373,7 @@ const OPERATIONS = [
|
|
|
1330
1373
|
category: 'write-own',
|
|
1331
1374
|
dangerous: false,
|
|
1332
1375
|
defaultScopes: ['relation', 'agent'],
|
|
1333
|
-
description: '通过
|
|
1376
|
+
description: '通过 ecmsg send 发送私聊消息',
|
|
1334
1377
|
sources: ['agent-tool'],
|
|
1335
1378
|
},
|
|
1336
1379
|
{
|
|
@@ -1346,7 +1389,7 @@ const OPERATIONS = [
|
|
|
1346
1389
|
category: 'write-own',
|
|
1347
1390
|
dangerous: false,
|
|
1348
1391
|
defaultScopes: ['relation', 'agent'],
|
|
1349
|
-
description: '通过
|
|
1392
|
+
description: '通过 ecmsg send --file 发送私聊文件',
|
|
1350
1393
|
sources: ['agent-tool'],
|
|
1351
1394
|
},
|
|
1352
1395
|
{
|
|
@@ -1354,7 +1397,7 @@ const OPERATIONS = [
|
|
|
1354
1397
|
category: 'write-own',
|
|
1355
1398
|
dangerous: false,
|
|
1356
1399
|
defaultScopes: ['relation', 'agent'],
|
|
1357
|
-
description: '通过
|
|
1400
|
+
description: '通过 ecmsg send 发送群组消息',
|
|
1358
1401
|
sources: ['agent-tool'],
|
|
1359
1402
|
},
|
|
1360
1403
|
{
|
|
@@ -7,12 +7,24 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { logger } from '../utils/logger.js';
|
|
9
9
|
import { PluginHandle } from './plugin-lifecycle.js';
|
|
10
|
+
import { getCcAgentAid } from '../agents/claude-gateway/agent-registration.js';
|
|
11
|
+
import { validateBaseagentPluginConfigs } from '../agents/baseagent-plugin-descriptor.js';
|
|
10
12
|
/** Agent Loader — produces one runner per (EvolAgent × baseagent). */
|
|
11
13
|
export class AgentLoader {
|
|
12
14
|
plugins = new Map();
|
|
13
15
|
creationSlots = new Map();
|
|
14
16
|
enabledBaseagents(agent) {
|
|
15
|
-
|
|
17
|
+
if (agent.aid === getCcAgentAid())
|
|
18
|
+
return [];
|
|
19
|
+
return [...this.plugins].filter(([, plugin]) => {
|
|
20
|
+
try {
|
|
21
|
+
return plugin.isEnabled(agent);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
logger.warn(`Cannot probe plugin ${plugin.name}:`, error);
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}).map(([name]) => name);
|
|
16
28
|
}
|
|
17
29
|
async withCreationSlot(backend, create) {
|
|
18
30
|
let slots = this.creationSlots.get(backend);
|
|
@@ -39,6 +51,8 @@ export class AgentLoader {
|
|
|
39
51
|
}
|
|
40
52
|
this.plugins.set(plugin.name, plugin);
|
|
41
53
|
logger.debug(`Registered agent plugin: ${plugin.name}`);
|
|
54
|
+
return () => { if (this.plugins.get(plugin.name) === plugin)
|
|
55
|
+
this.plugins.delete(plugin.name); };
|
|
42
56
|
}
|
|
43
57
|
/**
|
|
44
58
|
* Create each Agent's selected backend. Other backends are created on demand.
|
|
@@ -91,12 +105,25 @@ export class AgentLoader {
|
|
|
91
105
|
}
|
|
92
106
|
/** Create runners for one EvolAgent, used by runtime hot-load. */
|
|
93
107
|
async createForAgent(agent, callbacks, creationErrors, selectPlugin = () => true, onCreating) {
|
|
108
|
+
if (agent.aid === getCcAgentAid())
|
|
109
|
+
return [];
|
|
94
110
|
const instances = [];
|
|
95
111
|
for (const [pluginName, plugin] of this.plugins) {
|
|
96
112
|
if (!selectPlugin(pluginName))
|
|
97
113
|
continue;
|
|
98
|
-
|
|
99
|
-
|
|
114
|
+
try {
|
|
115
|
+
if (!plugin.isEnabled(agent)) {
|
|
116
|
+
logger.debug(`Plugin '${pluginName}' disabled for agent '${agent.name}', skipping`);
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
const errors = validateBaseagentPluginConfigs({ [pluginName]: agent.config.baseagents?.[pluginName] });
|
|
120
|
+
if (errors.length)
|
|
121
|
+
throw new Error(errors.join('; '));
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
125
|
+
creationErrors?.push({ evolagentName: agent.name, baseagent: pluginName, message });
|
|
126
|
+
logger.error(`Cannot enable plugin ${pluginName} for ${agent.name}:`, error);
|
|
100
127
|
continue;
|
|
101
128
|
}
|
|
102
129
|
let teardown;
|
|
@@ -2,13 +2,22 @@ import { ConfigTarget, read, write } from '../../config/config-manager.js';
|
|
|
2
2
|
import { resolveProjectDefaultPath } from '../../utils/project-path.js';
|
|
3
3
|
import { ClaudeCapabilityProvider } from './providers/claude-capability-provider.js';
|
|
4
4
|
import { CodexCapabilityProvider } from './providers/codex-capability-provider.js';
|
|
5
|
-
import { GeminiCapabilityProvider } from './providers/gemini-capability-provider.js';
|
|
6
5
|
import { CAPABILITY_TYPES, isCapabilityType, normalizeCapabilityTypeConfig, resolveCapabilityEnabled, } from './types.js';
|
|
7
|
-
const PROVIDERS =
|
|
8
|
-
claude
|
|
9
|
-
codex
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
const PROVIDERS = new Map([
|
|
7
|
+
['claude', new ClaudeCapabilityProvider()],
|
|
8
|
+
['codex', new CodexCapabilityProvider()],
|
|
9
|
+
]);
|
|
10
|
+
/**
|
|
11
|
+
* 注册外部插件的 CapabilityProvider
|
|
12
|
+
* 由插件加载器调用
|
|
13
|
+
*/
|
|
14
|
+
export function registerCapabilityProvider(provider) {
|
|
15
|
+
if (PROVIDERS.has(provider.baseagent))
|
|
16
|
+
throw new Error(`Capability provider already registered: ${provider.baseagent}`);
|
|
17
|
+
PROVIDERS.set(provider.baseagent, provider);
|
|
18
|
+
return () => { if (PROVIDERS.get(provider.baseagent) === provider)
|
|
19
|
+
PROVIDERS.delete(provider.baseagent); };
|
|
20
|
+
}
|
|
12
21
|
export { CAPABILITY_TYPES, isCapabilityType, resolveCapabilityEnabled };
|
|
13
22
|
function defaultTypeConfig() {
|
|
14
23
|
return { mode: 'inherit', overrides: {} };
|
|
@@ -38,7 +47,7 @@ export function resolveCapabilityContext(input) {
|
|
|
38
47
|
};
|
|
39
48
|
}
|
|
40
49
|
export function getProvider(baseagent) {
|
|
41
|
-
return PROVIDERS
|
|
50
|
+
return PROVIDERS.get(baseagent) ?? {
|
|
42
51
|
baseagent,
|
|
43
52
|
getSupport: () => ({ mode: 'inherit', canUpdate: false, reason: `baseagent ${baseagent} 尚未支持 capability 管理` }),
|
|
44
53
|
discover: async () => [],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import { getOwners } from './ownership/owner-resolver.js';
|
|
3
3
|
import fs from 'fs';
|
|
4
|
-
import { removeRestartRequest } from '../utils/restart-safety.js';
|
|
4
|
+
import { readRestartRequest, 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';
|
|
@@ -300,7 +300,9 @@ export function createChannelStartupNotifications({ channelInstances, agentRegis
|
|
|
300
300
|
pendingRestartNoticeInFlight = (async () => {
|
|
301
301
|
if (pendingRestartNoticeSent || !fs.existsSync(pendingFile))
|
|
302
302
|
return;
|
|
303
|
-
const pending = JSON.parse(fs.readFileSync(pendingFile, 'utf-8'));
|
|
303
|
+
const pending = readRestartRequest(pendingFile) ?? JSON.parse(fs.readFileSync(pendingFile, 'utf-8'));
|
|
304
|
+
if (pending.status === 'failed' || pending.status === 'timeout')
|
|
305
|
+
return;
|
|
304
306
|
if (pending.requestId && pending.requesterPid) {
|
|
305
307
|
if (pending.requesterPid === process.pid)
|
|
306
308
|
return;
|