evolcore 0.0.47 → 0.0.49
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 +90 -1
- package/bin/ec-build.mjs +86 -0
- package/dist/agent-template/jobs.js +12 -4
- package/dist/agent-template/runtime.js +143 -40
- package/dist/agent-template/service.js +66 -13
- package/dist/agents/baseagent.js +60 -20
- package/dist/agents/claude-runner.js +34 -17
- package/dist/agents/codex-runner.js +36 -17
- package/dist/agents/ecagent-runner.js +7 -4
- package/dist/agents/gemini-runner.js +5 -2
- package/dist/agents/runner-types.js +5 -21
- package/dist/aun/aid/agentmd.js +5 -1
- package/dist/aun/msg/p2p.js +2 -1
- package/dist/aun/service-proxy.js +4 -2
- package/dist/build-identity.json +1 -0
- package/dist/channels/aun.js +722 -295
- package/dist/channels/daemon.js +9 -25
- package/dist/cli/aun-commands.js +86 -51
- package/dist/cli/code-stats.js +19 -8
- package/dist/cli/command-log.js +1 -1
- package/dist/cli/daemon-commands.js +44 -43
- package/dist/cli/directory.js +13 -2
- package/dist/cli/ecmsg-gateway.js +5 -2
- package/dist/cli/index.js +9 -9
- package/dist/cli/init-channel.js +4 -6
- package/dist/cli/init.js +72 -50
- package/dist/cli/invoke-command.js +1 -1
- package/dist/cli/managed-command-guard.js +2 -0
- package/dist/cli/model.js +20 -5
- package/dist/cli/provider-command.js +74 -13
- package/dist/cli/quota.js +89 -0
- package/dist/cli/role.js +62 -17
- package/dist/cli/services-command.js +1 -0
- package/dist/cli/stats.js +3 -3
- package/dist/cli/team-workspace-command.js +56 -2
- package/dist/cli/thread-command.js +16 -51
- package/dist/config/boot-log.js +3 -9
- package/dist/config/builtin-roles.js +5 -7
- package/dist/config/config-field-policy.js +71 -1
- package/dist/config/config-manager.js +13 -7
- package/dist/config/daemon-services.js +30 -3
- package/dist/config/gateway-config.js +2 -2
- package/dist/config/invoke-ipc-service.js +6 -4
- package/dist/config/peer-bind-code.js +3 -4
- package/dist/config/peer-book-store.js +62 -229
- package/dist/config/peer-book.js +26 -27
- package/dist/config/peer-role-resolver.js +16 -1
- package/dist/config/provider-identity-migration.js +4 -1
- package/dist/config/provider-ipc-service.js +56 -11
- package/dist/config/provider-menu-request.js +24 -5
- package/dist/config/provider-templates.js +127 -0
- package/dist/config/providers-config.js +67 -12
- package/dist/config/providers-management.js +477 -51
- package/dist/config/resolved-config-op.js +3 -2
- package/dist/config/role-command-service.js +248 -1
- package/dist/config/schema-migration.js +105 -4
- package/dist/core/agent-application-service.js +6 -1
- package/dist/core/agent-runtime.js +4 -0
- package/dist/core/auth/agent-delegation.js +2 -1
- package/dist/core/auth/auth-gateway.js +2 -1
- package/dist/core/auth/delegation-authorization.js +36 -26
- package/dist/core/auth/operation-authorizer.js +25 -0
- package/dist/core/auth/operation-catalog.js +37 -64
- package/dist/core/capability/providers/codex-capability-provider.js +7 -8
- package/dist/core/channel-loader.js +18 -0
- package/dist/core/command/agent-control.js +32 -0
- package/dist/core/command/cli-intent-parser.js +13 -0
- package/dist/core/command/command-handler.js +126 -87
- package/dist/core/command/menu-catalog.js +1 -0
- package/dist/core/command/menu-handler.js +67 -150
- package/dist/core/command/menu-protocol.js +31 -1
- package/dist/core/command/provider-menu.js +13 -3
- package/dist/core/command/remote-shell.js +565 -0
- package/dist/core/command/role-menu.js +47 -23
- package/dist/core/command/slash-handler.js +26 -43
- package/dist/core/command/team-workspace-items.js +81 -12
- package/dist/core/command/team-workspace-team.js +9 -71
- package/dist/core/command/topic-slash.js +9 -30
- package/dist/core/daemon-bootstrap.js +8 -1
- package/dist/core/daemon-control.js +64 -8
- package/dist/core/daemon-lifecycle.js +16 -2
- package/dist/core/evolagent-registry.js +20 -3
- package/dist/core/file-integrity/store.js +2 -0
- package/dist/core/handoff/runtime.js +37 -1
- package/dist/core/inference/text-inference.js +3 -1
- package/dist/core/initialization/service.js +11 -6
- package/dist/core/interaction-router.js +3 -0
- package/dist/core/invoke/executors/text.js +72 -19
- package/dist/core/ipc-registration.js +3 -1
- package/dist/core/message/aun-ipc-sender.js +279 -107
- package/dist/core/message/contact-admission.js +91 -6
- package/dist/core/message/contact-pending-inbound.js +113 -0
- package/dist/core/message/contact-thread-approval.js +212 -0
- package/dist/core/message/im-renderer.js +41 -2
- package/dist/core/message/message-admission.js +5 -39
- package/dist/core/message/message-bridge.js +140 -370
- package/dist/core/message/message-log.js +29 -0
- package/dist/core/message/message-queue.js +119 -15
- package/dist/core/message/message-utils.js +8 -0
- package/dist/core/message/response-engine.js +580 -134
- package/dist/core/message/send-routing.js +5 -1
- package/dist/core/model/catalog-service.js +31 -11
- package/dist/core/model/config-scope.js +6 -14
- package/dist/core/model/model-capabilities.js +22 -4
- package/dist/core/model/model-catalog.js +1 -0
- package/dist/core/model/model-diagnostics.js +19 -0
- package/dist/core/model/model-fallback.js +13 -2
- package/dist/core/ownership/owner-resolver.js +328 -50
- package/dist/core/pack-auth.js +3 -0
- package/dist/core/pack-install.js +1 -1
- package/dist/core/permission/ec-command-parser.js +106 -19
- package/dist/core/permission/protected-paths.js +6 -6
- package/dist/core/permission/services-path-acl.js +451 -0
- package/dist/core/permission/tool-policy.js +5 -1
- package/dist/core/relation/peer-identity.js +36 -1
- package/dist/core/relation/same-owner-proof.js +81 -112
- package/dist/core/session/adapters/codex-session-file-adapter.js +96 -15
- package/dist/core/session/session-file-health.js +13 -7
- package/dist/core/session/session-fs-store.js +91 -35
- package/dist/core/session/session-manager.js +68 -24
- package/dist/core/session/session-mapper.js +14 -34
- package/dist/core/session/session-transcript.js +5 -1
- package/dist/core/task/task-activity-store.js +84 -0
- package/dist/core/task/task-recovery-service.js +13 -0
- package/dist/core/thread/command-parser.js +7 -12
- package/dist/core/thread/thread-context-storage.js +3 -2
- package/dist/core/thread/thread-operation.js +2 -13
- package/dist/core/thread/thread-service.js +15 -46
- package/dist/core/thread/topic-id.js +15 -0
- package/dist/directory/owner-directory-admission.js +12 -9
- package/dist/directory/owner-directory-cache.js +64 -28
- package/dist/directory/owner-directory-markdown.js +14 -2
- package/dist/directory/owner-directory-policy.js +5 -30
- package/dist/directory/owner-directory-query-operation.js +29 -3
- package/dist/directory/owner-directory-remarks.js +11 -3
- package/dist/directory/owner-directory-request-operation.js +5 -2
- package/dist/eck/kit-renderer.js +1 -1
- package/dist/eck/message-renderer.js +112 -29
- package/dist/ecweb/basic-settings-service.js +3 -1
- package/dist/ecweb/message-context-service.js +1 -1
- package/dist/ecweb/pairing.js +4 -3
- package/dist/ecweb/providers-service.js +26 -1
- package/dist/ecweb/runtime/lifecycle.js +18 -8
- package/dist/ecweb/runtime/proxy-access.js +74 -0
- package/dist/ecweb/runtime/supervisor.js +36 -6
- package/dist/event-center/center-config.js +9 -5
- package/dist/event-center/dispatcher.js +10 -1
- package/dist/event-center/ipc-operation.js +19 -0
- package/dist/event-center/registry.js +29 -3
- package/dist/event-center/runtime.js +106 -11
- package/dist/event-center/script-runner.js +5 -5
- package/dist/index.js +96 -59
- package/dist/ipc.js +38 -3
- package/dist/outputs/authorization.js +16 -0
- package/dist/outputs/cards.js +336 -0
- package/dist/outputs/events.js +63 -0
- package/dist/outputs/protocol.js +103 -0
- package/dist/outputs/service.js +266 -0
- package/dist/paths.js +3 -0
- package/dist/proxy/manager.js +43 -13
- package/dist/services/index.js +114 -5
- package/dist/services/ipc-operation.js +88 -15
- package/dist/services/pack-manager.js +13 -1
- package/dist/services/router.js +21 -6
- package/dist/services/script-runner.js +5 -4
- package/dist/services/service-payload.js +13 -7
- package/dist/services/validation.js +1 -1
- package/dist/stats/budget.js +2 -2
- package/dist/stats/db.js +19 -0
- package/dist/stats/index.js +1 -1
- package/dist/stats/{price-resolver.js → model-resolver.js} +304 -23
- package/dist/stats/normalizer.js +2 -0
- package/dist/stats/query.js +35 -27
- package/dist/stats/quota-query.js +95 -0
- package/dist/stats/role-budget.js +5 -2
- package/dist/stats/writer.js +10 -6
- package/dist/trigger/audit.js +7 -0
- package/dist/trigger/authorization.js +105 -11
- package/dist/trigger/feedback.js +10 -0
- package/dist/trigger/history.js +37 -11
- package/dist/trigger/ipc-service.js +12 -1
- package/dist/trigger/manager.js +1 -0
- package/dist/trigger/scheduler.js +7 -5
- package/dist/trigger/script-executor.js +2 -1
- package/dist/trigger/script-sandbox.js +21 -3
- package/dist/trigger/validation.js +22 -0
- package/dist/utils/atomic-write.js +22 -8
- package/dist/utils/cross-platform.js +73 -26
- package/dist/utils/error-dict.json +94 -4
- package/dist/utils/error-utils.js +27 -4
- package/dist/utils/evolcore-version.js +36 -65
- package/dist/utils/host-info.js +100 -1
- package/dist/utils/msg-diag.js +1 -0
- package/dist/utils/npm-ops.js +43 -8
- package/dist/utils/process-introspect.js +12 -7
- package/dist/utils/process-tree.js +50 -2
- package/dist/utils/windows-shell-trust.js +2 -0
- package/dist/workbench/protocol.js +80 -0
- package/dist/workbench/service.js +359 -0
- package/ecagent/dist/types.d.ts +6 -2
- package/kits/docs/context-assembly.md +1 -1
- package/kits/docs/evolcore/INDEX.md +4 -2
- package/kits/docs/evolcore/aid.md +25 -0
- package/kits/docs/evolcore/config.md +16 -1
- package/kits/docs/evolcore/directory.md +30 -12
- package/kits/docs/evolcore/ecweb-lifecycle.md +15 -0
- package/kits/docs/evolcore/model.md +10 -0
- package/kits/docs/evolcore/msg.md +9 -0
- package/kits/docs/evolcore/peer.md +19 -65
- package/kits/docs/evolcore/provider.md +124 -4
- package/kits/docs/evolcore/quota.md +54 -0
- package/kits/docs/evolcore/role.md +83 -0
- package/kits/docs/evolcore/services.md +6 -6
- package/kits/docs/evolcore/stats.md +2 -0
- package/kits/docs/evolcore/team-workspace.md +1 -1
- package/kits/docs/evolcore/thread-chain.md +14 -15
- package/kits/docs/evolcore/tool-authorization.md +5 -0
- package/kits/docs/evolcore/trigger.md +12 -0
- package/kits/eck_message_manifest.json +12 -0
- package/kits/provider-templates.json +1213 -0
- package/kits/rules/04-relation.md +3 -3
- package/kits/schemas/_meta.json +14 -2
- package/kits/schemas/agent-config.schema.20.json +24 -0
- package/kits/schemas/contact-book.schema.4.json +52 -0
- package/kits/schemas/providers.schema.3.json +200 -0
- package/kits/skills/.switches.json +8 -0
- package/kits/skills/ability/references/calling.md +1 -1
- package/kits/skills/agent-output-cards/SKILL.md +57 -0
- package/kits/skills/ec-group/SKILL.md +2 -2
- package/kits/skills/ec-identity/SKILL.md +19 -72
- package/kits/skills/ec-provider/SKILL.md +270 -0
- package/kits/skills/ec-provider/scripts/check-model.mjs +80 -0
- package/kits/skills/ec-trigger/SKILL.md +1 -1
- package/kits/skills/thread-ops/SKILL.md +34 -21
- package/kits/templates/message-fragments/group-batch-item.md +1 -1
- package/kits/templates/message-fragments/group-batch.md +1 -1
- package/kits/templates/message-fragments/inject-default.md +1 -1
- package/kits/templates/message-fragments/interrupt-insert.md +1 -0
- package/kits/templates/message-fragments/item-group.md +1 -1
- package/kits/templates/message-fragments/item-private.md +1 -1
- package/kits/templates/message-fragments/thread-context.md +1 -1
- package/kits/templates/message-fragments/trigger-session.md +1 -1
- package/kits/templates/message-fragments/trigger-thread-check.md +1 -1
- package/kits/templates/roles/admin.json +2 -19
- package/kits/templates/roles/member.json +0 -3
- package/kits/templates/roles/visitor.json +1 -0
- package/kits/templates/system-fragments/baseagent.md +6 -0
- package/kits/templates/system-fragments/commands.md +4 -3
- package/kits/templates/system-fragments/directory-contacts.md +3 -4
- package/kits/templates/system-fragments/managed-runtime.md +1 -1
- package/kits/templates/system-fragments/relation.md +1 -1
- package/kits/templates/system-fragments/thread.md +7 -5
- package/kits/templates/system-fragments/venue.md +11 -0
- package/package.json +6 -4
- package/scripts/agent-template/inspect.mjs +50 -11
- package/scripts/agent-template/shared/common.mjs +11 -6
- package/scripts/agent-template/shared/team-schema.json +6 -4
- package/scripts/agent-template/shared/template-contract.mjs +62 -11
- package/scripts/agent-template/shared/template-package.mjs +189 -21
- package/scripts/agent-template/shared/template-runtime.mjs +54 -6
- package/scripts/agent-template/shared/template.mjs +2 -2
- package/scripts/agent-template/team-pack.mjs +52 -14
- package/dist/cli/peer.js +0 -127
- package/dist/config/peer-operation-service.js +0 -132
- package/dist/config/peer-request-service.js +0 -532
- package/dist/core/command/connect-menu.js +0 -624
package/dist/index.js
CHANGED
|
@@ -15,12 +15,11 @@ import { CodexSessionFileAdapter } from './core/session/adapters/codex-session-f
|
|
|
15
15
|
import { GeminiSessionFileAdapter } from './core/session/adapters/gemini-session-file-adapter.js';
|
|
16
16
|
import { EcagentSessionFileAdapter } from './core/session/adapters/ecagent-session-file-adapter.js';
|
|
17
17
|
import { loadDefaults, loadAllAgents, migrateIdentitiesIfNeeded, loadDaemonConfig, initializeEckSnapshotsConfig } from './config-store.js';
|
|
18
|
+
import { RoleQuotaQuestions } from './config/role-command-service.js';
|
|
18
19
|
import { inspectClaudeSandboxDependencies, formatClaudeSandboxDependencies } from './core/permission/sandbox-runtime.js';
|
|
19
20
|
import { migrateRelationSharedDirectories } from './core/relation/shared-data.js';
|
|
20
21
|
import { DEFAULT_ECWEB_PORT, ecwebService, serviceRuntimeMode } from './config/daemon-services.js';
|
|
21
22
|
import { ConfigTarget, clearConfiguredOwnerAfterConsensus, onConfigWrite, } from './config/config-manager.js';
|
|
22
|
-
import { expirePendingPeerRequests } from './config/peer-request-service.js';
|
|
23
|
-
import { synchronizeOwnershipPeersSync } from './config/peer-book-store.js';
|
|
24
23
|
import { createSessionIdentityResolver } from './config/peer-role-resolver.js';
|
|
25
24
|
import { initializeStartupConfig, prepareStartupConfig, recordStartupConfig } from './config/boot-log.js';
|
|
26
25
|
import { CONFIG_SCHEMA_VERSION } from './types.js';
|
|
@@ -32,7 +31,6 @@ import { GeminiAgentPlugin } from './agents/gemini-runner.js';
|
|
|
32
31
|
// 不要静态导入 ecagent-runner:它连带整个 ecagent 运行时(typebox 占了模块图
|
|
33
32
|
// 三分之一的 resolve),而绝大多数部署并不使用 ecagent。这里用懒加载外壳。
|
|
34
33
|
import { EcagentAgentPluginLazy } from './agents/ecagent-plugin-lazy.js';
|
|
35
|
-
import { AUNChannelPlugin } from './channels/aun.js';
|
|
36
34
|
import { registerAbilityPlatform } from './ability/daemon.js';
|
|
37
35
|
import { assertAunEncryptionSeedPolicy } from './aun/aid/encryption-seed-policy.js';
|
|
38
36
|
import { BindService } from './utils/aid-bind.js';
|
|
@@ -48,6 +46,7 @@ import { HandoffRuntime } from './core/handoff/runtime.js';
|
|
|
48
46
|
import { startDaemonControlAid } from './core/daemon-control.js';
|
|
49
47
|
import { createDelegationAuthorizer } from './core/auth/delegation-authorization.js';
|
|
50
48
|
import { registerProxyIpcExecutor } from './proxy/ipc-service.js';
|
|
49
|
+
import { readServiceProxySnapshot } from './proxy/manager.js';
|
|
51
50
|
import { ownerResolver, getDaemonOwners, getPrimaryOwner } from './core/ownership/owner-resolver.js';
|
|
52
51
|
import { StartupTaskQueue, startupConnectionBudget, StartupGate, discoverStartupWork, recoverStartupObserverHints, StartupHandoffRecovery, resumePendingSessions, createDaemonShutdown, daemonConversationTotalExecutionMs, daemonConversationWatchdogMs, daemonIdleTimeoutMs, startupTaskReadiness, } from './core/daemon-lifecycle.js';
|
|
53
52
|
import { createLifecycleNoticeService } from './core/lifecycle-notice.js';
|
|
@@ -72,7 +71,7 @@ import { releaseSessionPathGrants } from './core/permission/session-path-grants.
|
|
|
72
71
|
import { InteractionRouter } from './core/interaction-router.js';
|
|
73
72
|
import { GroupInviteReviewService } from './aun/group/invite-service.js';
|
|
74
73
|
import { AgentDelegationRegistry, } from './core/auth/agent-delegation.js';
|
|
75
|
-
import { ChannelLoader } from './core/channel-loader.js';
|
|
74
|
+
import { ChannelLoader, registerBuiltinChannelPlugins } from './core/channel-loader.js';
|
|
76
75
|
import { registerChannelInstance as registerChannelRuntimeInstance, createChannelStartupNotifications, registerChannelHealthNotifications, bindStartupChannelsToAgents, createAgentStorageClientResolver, createDefaultChannelPolicy, createChannelConnectionRuntime, preloadChannelThreads, } from './core/channel-runtime.js';
|
|
77
76
|
import { createIpcStatusProvider, registerDaemonIpc } from './core/ipc-registration.js';
|
|
78
77
|
import { AgentLoader } from './core/baseagent-loader.js';
|
|
@@ -93,6 +92,9 @@ import { authenticatedTriggerActor as authenticateTriggerActor, authenticatedTri
|
|
|
93
92
|
import { TargetSessionLockRegistry } from './trigger/session-lock.js';
|
|
94
93
|
import { buildTriggerScheduler, createTriggerChannelResolver, TriggerSchedulerRegistry } from './trigger/application-service.js';
|
|
95
94
|
import { createDaemonEventCenter } from './event-center/daemon.js';
|
|
95
|
+
import { setOutputChangePublisher } from './outputs/service.js';
|
|
96
|
+
import { setOutputCardsNotificationsAvailable } from './outputs/cards.js';
|
|
97
|
+
import { setWorkbenchChangePublisher, setWorkbenchRuntimeProvider, notifyWorkbenchRuntimeChanged } from './workbench/service.js';
|
|
96
98
|
import { DaemonChannel } from './channels/daemon.js';
|
|
97
99
|
import { DAEMON_RUNTIME_EPOCH_ENV, ensureProcessManagedTempDir } from './cli/task-context.js';
|
|
98
100
|
import fs from 'fs';
|
|
@@ -269,7 +271,7 @@ async function main() {
|
|
|
269
271
|
priorityStartupGate.settle('cancelled');
|
|
270
272
|
normalStartupGate.settle('cancelled');
|
|
271
273
|
});
|
|
272
|
-
//
|
|
274
|
+
// Read build-time markers after task admission; startup never hashes the tree.
|
|
273
275
|
// Keep status pending until the background release instead of competing
|
|
274
276
|
// with recovery metadata reads. Bootstrap-only daemons have no task gate.
|
|
275
277
|
void trace.track('daemon.versionReport', async (phase) => {
|
|
@@ -331,7 +333,7 @@ async function main() {
|
|
|
331
333
|
}
|
|
332
334
|
if (bindBootstrapMode && process.env.EVOLCORE_WEB_INIT !== '1' && daemonCfg.aid && loadAllAgents().agents.length === 0) {
|
|
333
335
|
priorityStartupGate.settle('ready');
|
|
334
|
-
await runBindBootstrapDaemon(daemonCfg);
|
|
336
|
+
await runBindBootstrapDaemon(daemonCfg, ecwebSupervisor);
|
|
335
337
|
// The pairing-only daemon has no Agent task gate.
|
|
336
338
|
normalStartupGate.settle('ready');
|
|
337
339
|
return;
|
|
@@ -667,14 +669,6 @@ async function main() {
|
|
|
667
669
|
trace.mark('daemon.channelInstances', `${channelInstances.length} 个渠道实例`);
|
|
668
670
|
logger.info(`✓ Created ${channelInstances.length} channel instance(s)`);
|
|
669
671
|
let bootstrapService;
|
|
670
|
-
const contactRequestExpiryTimer = daemonPluginLifecycle.setInterval(() => {
|
|
671
|
-
for (const agent of agentRegistry.runnableAgents()) {
|
|
672
|
-
void expirePendingPeerRequests(agent.aid).catch(error => {
|
|
673
|
-
logger.warn(`[contact-request] Pending expiry sweep failed: self=${agent.aid} error=${error instanceof Error ? error.message : String(error)}`);
|
|
674
|
-
});
|
|
675
|
-
}
|
|
676
|
-
}, 60_000);
|
|
677
|
-
contactRequestExpiryTimer.unref?.();
|
|
678
672
|
const bindService = daemonCfg.aid
|
|
679
673
|
? new BindService({
|
|
680
674
|
receiverAid: daemonCfg.aid,
|
|
@@ -692,14 +686,6 @@ async function main() {
|
|
|
692
686
|
if (startupCancelled)
|
|
693
687
|
return;
|
|
694
688
|
permissionGateway.revalidatePendingApprovals(subjectAid);
|
|
695
|
-
if (agentRegistry.get(subjectAid)) {
|
|
696
|
-
try {
|
|
697
|
-
synchronizeOwnershipPeersSync(subjectAid);
|
|
698
|
-
}
|
|
699
|
-
catch (error) {
|
|
700
|
-
logOwnershipEvent('contacts.sync_failed', { subjectAid, ownerAid, errorCode: ownershipErrorCode(error) }, true);
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
689
|
if (!ownerAid)
|
|
704
690
|
return;
|
|
705
691
|
initializationServiceForOwnerRecovery?.resumeForOwner(subjectAid, ownerAid);
|
|
@@ -868,6 +854,33 @@ async function main() {
|
|
|
868
854
|
return (client ?? null);
|
|
869
855
|
},
|
|
870
856
|
});
|
|
857
|
+
setOutputChangePublisher((aid, data) => {
|
|
858
|
+
void eventCenter.publishAgentEvent(aid, 'team.outputs.changed', data).catch(() => { });
|
|
859
|
+
}, aid => eventCenter.get(aid)?.runtime.nativeOutputAvailable === true);
|
|
860
|
+
setOutputCardsNotificationsAvailable(aid => eventCenter.get(aid)?.runtime.nativeOutputAvailable === true);
|
|
861
|
+
setWorkbenchChangePublisher((aid, data) => {
|
|
862
|
+
void eventCenter.publishAgentEvent(aid, 'team.workbench.changed', data).catch(() => { });
|
|
863
|
+
}, aid => eventCenter.get(aid)?.runtime.nativeOutputAvailable === true);
|
|
864
|
+
setWorkbenchRuntimeProvider(aid => {
|
|
865
|
+
const agent = agentRegistry.get(aid);
|
|
866
|
+
return agent ? { status: agent.status, tasks: responseEngine.getWorkbenchTasks(aid) } : undefined;
|
|
867
|
+
});
|
|
868
|
+
const workbenchLifecycle = (event) => {
|
|
869
|
+
if ('aid' in event && typeof event.aid === 'string')
|
|
870
|
+
notifyWorkbenchRuntimeChanged(event.aid);
|
|
871
|
+
};
|
|
872
|
+
for (const type of ['agent:started', 'agent:stopped', 'agent:enabled', 'agent:disabled', 'agent:error']) {
|
|
873
|
+
eventBus.subscribe(type, workbenchLifecycle);
|
|
874
|
+
}
|
|
875
|
+
onShutdown(() => {
|
|
876
|
+
setWorkbenchRuntimeProvider();
|
|
877
|
+
setWorkbenchChangePublisher();
|
|
878
|
+
setOutputChangePublisher(undefined);
|
|
879
|
+
setOutputCardsNotificationsAvailable();
|
|
880
|
+
for (const type of ['agent:started', 'agent:stopped', 'agent:enabled', 'agent:disabled', 'agent:error']) {
|
|
881
|
+
eventBus.unsubscribe(type, workbenchLifecycle);
|
|
882
|
+
}
|
|
883
|
+
});
|
|
871
884
|
cmdHandler.setEventCenter(eventCenter);
|
|
872
885
|
// ECK 能力清单变量:只读两个运行时的内存包集合,不扫目录。
|
|
873
886
|
responseEngine.setCapabilityIndexes(selfAid => ({
|
|
@@ -1148,6 +1161,7 @@ async function main() {
|
|
|
1148
1161
|
pendingFile,
|
|
1149
1162
|
upmsg,
|
|
1150
1163
|
});
|
|
1164
|
+
let getProxyTransport;
|
|
1151
1165
|
const startupObserverRecoveries = [];
|
|
1152
1166
|
let startupRecoveryPending = true;
|
|
1153
1167
|
const lifecycleNotices = createLifecycleNoticeService({
|
|
@@ -1292,17 +1306,7 @@ async function main() {
|
|
|
1292
1306
|
return triggerSchedulers.statusSummary(from, Date.now());
|
|
1293
1307
|
},
|
|
1294
1308
|
getStatusSnapshot,
|
|
1295
|
-
getServiceProxySnapshot: () => (
|
|
1296
|
-
source: 'daemon-config',
|
|
1297
|
-
items: (daemonCfg.services ?? []).filter(service => !!service.proxy || service.name === 'ecweb').map(service => ({
|
|
1298
|
-
name: service.name,
|
|
1299
|
-
serviceEnabled: service.enabled === true,
|
|
1300
|
-
proxyEnabled: service.proxy?.enabled === true,
|
|
1301
|
-
source: service.proxy?.source ?? null,
|
|
1302
|
-
serviceType: service.proxy?.serviceType ?? null,
|
|
1303
|
-
visibility: service.proxy?.visibility ?? null,
|
|
1304
|
-
})),
|
|
1305
|
-
}),
|
|
1309
|
+
getServiceProxySnapshot: () => readServiceProxySnapshot(getProxyTransport?.()),
|
|
1306
1310
|
}), async (argv, sessionId, delegationToken, delegationCommandHash) => {
|
|
1307
1311
|
const delegation = agentDelegationRegistry.validate(delegationToken, sessionId, delegationCommandHash);
|
|
1308
1312
|
if (!delegation.ok)
|
|
@@ -1435,6 +1439,7 @@ async function main() {
|
|
|
1435
1439
|
initializationServiceForOwnerRecovery = agentInitializationService;
|
|
1436
1440
|
agentApplicationService.setInitializationService(agentInitializationService);
|
|
1437
1441
|
cmdHandler.setAgentApplicationService(agentApplicationService);
|
|
1442
|
+
const templateRecoveryMutes = new Set();
|
|
1438
1443
|
setAgentTemplateService(createAgentTemplateRuntime({
|
|
1439
1444
|
holdHandoff: (aid, token) => handoffRuntime.holdAgent(aid, token),
|
|
1440
1445
|
initialization: agentInitializationService, application: agentApplicationService,
|
|
@@ -1446,7 +1451,9 @@ async function main() {
|
|
|
1446
1451
|
&& instance.channel.getAidState?.()?.status === 'connected');
|
|
1447
1452
|
},
|
|
1448
1453
|
registry: agentRegistry, coordinator: reloadCoordinator,
|
|
1449
|
-
reloadInsideGate: async (aid) => {
|
|
1454
|
+
reloadInsideGate: async (aid, recoveryJobId, restoreStopped) => {
|
|
1455
|
+
await agentRegistry.reload(aid, reloadHooks, { recoveryJobId, preserveStopped: true, restoreStopped });
|
|
1456
|
+
},
|
|
1450
1457
|
getControl: () => controlChannel,
|
|
1451
1458
|
waitForControl: async () => {
|
|
1452
1459
|
const deadline = Date.now() + 60_000;
|
|
@@ -1455,20 +1462,37 @@ async function main() {
|
|
|
1455
1462
|
}
|
|
1456
1463
|
},
|
|
1457
1464
|
getScheduler: aid => triggerSchedulers.get(aid),
|
|
1465
|
+
pauseEvents: (aid, token) => eventCenter.pauseForMutation(aid, token),
|
|
1458
1466
|
recoveryComplete: (aid, succeeded) => {
|
|
1459
|
-
if (succeeded && templateStartupRecovery.pending.has(aid)) {
|
|
1467
|
+
if (succeeded && (templateStartupRecovery.pending.has(aid) || templateRecoveryMutes.has(aid))) {
|
|
1460
1468
|
const agent = agentRegistry.get(aid);
|
|
1461
|
-
if (agent)
|
|
1469
|
+
if (agent && agent.status !== 'disabled')
|
|
1462
1470
|
messageQueue.unmuteAgent(agent.name);
|
|
1471
|
+
if (agent?.error === 'Template installation requires recovery')
|
|
1472
|
+
delete agent.error;
|
|
1463
1473
|
templateStartupRecovery.pending.delete(aid);
|
|
1474
|
+
templateRecoveryMutes.delete(aid);
|
|
1464
1475
|
}
|
|
1465
1476
|
},
|
|
1466
|
-
block: aid => {
|
|
1477
|
+
block: async (aid) => {
|
|
1467
1478
|
const agent = agentRegistry.get(aid);
|
|
1468
|
-
if (agent)
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1479
|
+
if (!agent)
|
|
1480
|
+
return;
|
|
1481
|
+
agent.status = 'disabled';
|
|
1482
|
+
agent.error = 'Template installation requires recovery';
|
|
1483
|
+
if (!messageQueue.isAgentMuted(agent.name))
|
|
1484
|
+
templateRecoveryMutes.add(aid);
|
|
1485
|
+
messageQueue.muteAgent(agent.name);
|
|
1486
|
+
const { createRunnerReloadTransaction } = await import('./core/runner-reload-transaction.js');
|
|
1487
|
+
const runners = createRunnerReloadTransaction({ aid, agentMap, staged: [] });
|
|
1488
|
+
runners.commit();
|
|
1489
|
+
const settlements = await Promise.allSettled([
|
|
1490
|
+
messageQueue.interruptByAgentAndWait(agent.name), triggerSchedulers.remove(aid), runners.finalize(),
|
|
1491
|
+
...agent.channelInstanceNames().map(name => reloadHooks.disconnectChannel(name)),
|
|
1492
|
+
]);
|
|
1493
|
+
const failures = settlements.filter(result => result.status === 'rejected');
|
|
1494
|
+
if (failures.length)
|
|
1495
|
+
throw new AggregateError(failures.map(result => result.reason), 'Template runtime cleanup incomplete');
|
|
1472
1496
|
},
|
|
1473
1497
|
}));
|
|
1474
1498
|
for (const aid of templateStartupRecovery.pending) {
|
|
@@ -1574,6 +1598,7 @@ async function main() {
|
|
|
1574
1598
|
waitForServices: waitForBackgroundStartup,
|
|
1575
1599
|
connectChannel: channel => trace.track('daemon.controlChannelConnect', phase => connectionQueue.run(() => { phase('running'); return channel.connect(); }, () => !startupCancelled), undefined, { initialPhase: 'queued' }),
|
|
1576
1600
|
onServiceProxyManager: manager => {
|
|
1601
|
+
getProxyTransport = () => manager.transportSnapshot();
|
|
1577
1602
|
const authorizeManagedOperation = createDelegationAuthorizer({
|
|
1578
1603
|
agentDelegationRegistry,
|
|
1579
1604
|
sessionManager,
|
|
@@ -1586,6 +1611,36 @@ async function main() {
|
|
|
1586
1611
|
});
|
|
1587
1612
|
},
|
|
1588
1613
|
});
|
|
1614
|
+
if (controlChannel && daemonCfg.aid) {
|
|
1615
|
+
const channel = controlChannel;
|
|
1616
|
+
const daemonAid = daemonCfg.aid;
|
|
1617
|
+
const quotaQuestions = new RoleQuotaQuestions(interactionRouter);
|
|
1618
|
+
channel.interactionCallback = response => interactionRouter.handleAsync({ ...response, channelKey: 'control' });
|
|
1619
|
+
processor.setRoleQuotaNotifier(request => quotaQuestions.present({ request, daemonAid, transport: {
|
|
1620
|
+
channelKey: 'control',
|
|
1621
|
+
send: async (ownerAid, interaction) => {
|
|
1622
|
+
if (interaction.kind.kind !== 'action')
|
|
1623
|
+
return false;
|
|
1624
|
+
const card = interaction.kind;
|
|
1625
|
+
const result = await channel.sendContentPayload(ownerAid, {
|
|
1626
|
+
type: 'action_card', title: card.title, text: card.body, sensitive: true,
|
|
1627
|
+
actions: [...card.buttons.map(button => ({ label: button.label, value: button.key, behavior: 'reply' })),
|
|
1628
|
+
{ label: '输入新额度', behavior: 'compose', sensitive: true,
|
|
1629
|
+
compose_timeout_ms: Math.max(0, interaction.expiresAt - Date.now()) }],
|
|
1630
|
+
}, { contentKind: 'card', dedupeKey: interaction.id,
|
|
1631
|
+
ttl: Math.max(0, interaction.expiresAt - Date.now()),
|
|
1632
|
+
context: { delivery: { chatType: 'private' }, metadata: { encrypted: true } },
|
|
1633
|
+
postSend: { type: 'register_interaction_card', requestId: interaction.id, isCommandCard: false,
|
|
1634
|
+
initiatorAid: ownerAid, sensitive: true, expiresAt: interaction.expiresAt, delivery: { chatType: 'private' } }, });
|
|
1635
|
+
return ((result.status === undefined || result.status === 'sent') && !!result.messageId)
|
|
1636
|
+
|| ((result.status === 'retry' || result.queued === true) && !!result.outboxId);
|
|
1637
|
+
},
|
|
1638
|
+
invalidate: id => channel.invalidateInteraction(id),
|
|
1639
|
+
notice: async (ownerAid, text) => {
|
|
1640
|
+
await channel.sendStructuredOrThrow(ownerAid, { type: 'notice', text, subtype: 'role_quota' }, { delivery: { chatType: 'private' }, metadata: { encrypted: true } });
|
|
1641
|
+
},
|
|
1642
|
+
} }));
|
|
1643
|
+
}
|
|
1589
1644
|
// ── 连接所有渠道(后台首连,AUN/任意渠道故障不阻塞 daemon 主流程)──
|
|
1590
1645
|
trace.point('daemon.channelConnectDispatch');
|
|
1591
1646
|
const channelConnectTimings = new Map(channelInstances.map(instance => {
|
|
@@ -2094,21 +2149,3 @@ if (isMainScript(import.meta.url)) {
|
|
|
2094
2149
|
process.exit(1);
|
|
2095
2150
|
});
|
|
2096
2151
|
}
|
|
2097
|
-
async function registerBuiltinChannelPlugins(channelLoader) {
|
|
2098
|
-
channelLoader.register(new AUNChannelPlugin());
|
|
2099
|
-
const providers = [
|
|
2100
|
-
['feishu', async () => new (await import('./channels/feishu.js')).FeishuChannelPlugin()],
|
|
2101
|
-
['wechat', async () => new (await import('./channels/wechat.js')).WechatChannelPlugin()],
|
|
2102
|
-
['dingtalk', async () => new (await import('./channels/dingtalk.js')).DingtalkChannelPlugin()],
|
|
2103
|
-
['qqbot', async () => new (await import('./channels/qqbot.js')).QQBotChannelPlugin()],
|
|
2104
|
-
['wecom', async () => new (await import('./channels/wecom.js')).WecomChannelPlugin()],
|
|
2105
|
-
];
|
|
2106
|
-
for (const [channelType, load] of providers) {
|
|
2107
|
-
try {
|
|
2108
|
-
channelLoader.register(await load());
|
|
2109
|
-
}
|
|
2110
|
-
catch (error) {
|
|
2111
|
-
channelLoader.recordProviderFailure(channelType, error);
|
|
2112
|
-
}
|
|
2113
|
-
}
|
|
2114
|
-
}
|
package/dist/ipc.js
CHANGED
|
@@ -7,6 +7,7 @@ import os from 'os';
|
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import { execFile } from 'node:child_process';
|
|
9
9
|
import { logger, logOwnershipEvent } from './utils/logger.js';
|
|
10
|
+
import { readEffectiveCpuCount } from './utils/host-info.js';
|
|
10
11
|
import { fileCache } from './core/daemon-file-cache.js';
|
|
11
12
|
import { DAEMON_RUNTIME_EPOCH_ENV, isTrustedFullAccessRuntimeContext } from './cli/task-context.js';
|
|
12
13
|
import { HANDOFF_QUERY_MAX_LIMIT, HANDOFF_STATES } from './core/handoff/types.js';
|
|
@@ -99,6 +100,7 @@ const MEMORY_COMMAND_ENDPOINTS = new Set([
|
|
|
99
100
|
'memory.create', 'memory.update', 'memory.archive', 'memory.demote', 'memory.consolidate',
|
|
100
101
|
]);
|
|
101
102
|
const DELEGATED_ARGV_ENDPOINTS = new Set([
|
|
103
|
+
'quota.op',
|
|
102
104
|
'agent.op', 'ability.op', 'config.op', 'peer.op', 'aid.op', 'aid.ownership', 'group.op', 'msg.op', 'fs.op', 'proxy.op', 'provider.op', 'invoke.op',
|
|
103
105
|
'upgrade.op',
|
|
104
106
|
'ctl', 'diag', 'menu-client.request', 'task.resume', 'queue.op', 'storage.auth', 'storage.upload',
|
|
@@ -246,6 +248,7 @@ export class IpcServer {
|
|
|
246
248
|
configOperationExecutor;
|
|
247
249
|
peerOperationExecutor;
|
|
248
250
|
roleOperationExecutor;
|
|
251
|
+
quotaOperationExecutor;
|
|
249
252
|
aidOperationExecutor;
|
|
250
253
|
directoryOperationExecutor;
|
|
251
254
|
groupOperationExecutor;
|
|
@@ -368,6 +371,9 @@ export class IpcServer {
|
|
|
368
371
|
setRoleOperationExecutor(executor) {
|
|
369
372
|
this.roleOperationExecutor = executor;
|
|
370
373
|
}
|
|
374
|
+
setQuotaOperationExecutor(executor) {
|
|
375
|
+
this.quotaOperationExecutor = executor;
|
|
376
|
+
}
|
|
371
377
|
setSkillRefreshExecutor(executor) {
|
|
372
378
|
this.skillRefreshExecutor = executor;
|
|
373
379
|
}
|
|
@@ -469,7 +475,7 @@ export class IpcServer {
|
|
|
469
475
|
snapshot: {
|
|
470
476
|
ts: Date.now(),
|
|
471
477
|
uptimeMs: Math.round(process.uptime() * 1000),
|
|
472
|
-
cpuCount:
|
|
478
|
+
cpuCount: readEffectiveCpuCount(),
|
|
473
479
|
memory: {
|
|
474
480
|
rss: processTreeRss,
|
|
475
481
|
heapUsed: mem.heapUsed,
|
|
@@ -2477,12 +2483,41 @@ export class IpcServer {
|
|
|
2477
2483
|
}
|
|
2478
2484
|
return await this.peerOperationExecutor(argv, sessionId, delegationToken, typeof cmd.delegationCommandHash === 'string' ? cmd.delegationCommandHash : undefined);
|
|
2479
2485
|
}
|
|
2486
|
+
case 'quota.op': {
|
|
2487
|
+
if (!this.quotaOperationExecutor)
|
|
2488
|
+
return { ok: false, code: 'NOT_CONFIGURED', error: 'quota.op not configured; restart the host after building' };
|
|
2489
|
+
if (!Array.isArray(cmd.argv) || cmd.argv.some((value) => typeof value !== 'string')) {
|
|
2490
|
+
return { ok: false, code: 'INVALID_REQUEST', error: 'invalid argv' };
|
|
2491
|
+
}
|
|
2492
|
+
const delegated = cmd.sessionId !== undefined || cmd.delegationToken !== undefined || cmd.actorSessionId !== undefined;
|
|
2493
|
+
if (!delegated) {
|
|
2494
|
+
if (!this.hasValidControlToken(cmd.controlToken))
|
|
2495
|
+
return { ok: false, code: 'CONTROL_TOKEN_REQUIRED', error: 'Host quota queries require a valid control token' };
|
|
2496
|
+
return await this.quotaOperationExecutor(cmd.argv, '', undefined, undefined, true);
|
|
2497
|
+
}
|
|
2498
|
+
if (typeof cmd.sessionId !== 'string' || !cmd.sessionId)
|
|
2499
|
+
return { ok: false, code: 'INVALID_REQUEST', error: 'missing sessionId' };
|
|
2500
|
+
if (typeof cmd.delegationToken !== 'string' || !cmd.delegationToken)
|
|
2501
|
+
return { ok: false, code: 'INVALID_DELEGATION', error: 'missing delegationToken' };
|
|
2502
|
+
return await this.quotaOperationExecutor(cmd.argv, cmd.sessionId, cmd.delegationToken, typeof cmd.delegationCommandHash === 'string' ? cmd.delegationCommandHash : undefined);
|
|
2503
|
+
}
|
|
2480
2504
|
case 'role.op': {
|
|
2481
2505
|
if (!this.roleOperationExecutor)
|
|
2482
2506
|
return { ok: false, code: 'NOT_CONFIGURED', error: 'role.op not configured' };
|
|
2483
2507
|
const { argv, sessionId, delegationToken } = cmd;
|
|
2484
|
-
if (!Array.isArray(argv) || argv.some(value => typeof value !== 'string')
|
|
2485
|
-
return { ok: false, code: 'INVALID_REQUEST', error: '
|
|
2508
|
+
if (!Array.isArray(argv) || argv.some(value => typeof value !== 'string')) {
|
|
2509
|
+
return { ok: false, code: 'INVALID_REQUEST', error: 'invalid argv' };
|
|
2510
|
+
}
|
|
2511
|
+
const delegated = cmd.sessionId !== undefined || cmd.delegationToken !== undefined
|
|
2512
|
+
|| cmd.actorSessionId !== undefined;
|
|
2513
|
+
if (!delegated) {
|
|
2514
|
+
if (!this.hasValidControlToken(cmd.controlToken)) {
|
|
2515
|
+
return { ok: false, code: 'CONTROL_TOKEN_REQUIRED', error: 'Host role operations require a valid control token' };
|
|
2516
|
+
}
|
|
2517
|
+
return await this.roleOperationExecutor(argv, '', undefined, undefined, true);
|
|
2518
|
+
}
|
|
2519
|
+
if (!sessionId) {
|
|
2520
|
+
return { ok: false, code: 'INVALID_REQUEST', error: 'missing sessionId' };
|
|
2486
2521
|
}
|
|
2487
2522
|
if (delegationToken !== undefined && typeof delegationToken !== 'string') {
|
|
2488
2523
|
return { ok: false, code: 'INVALID_DELEGATION', error: 'delegationToken must be a string' };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ownerResolver, OWNERSHIP_AUTHORIZATION_MAX_AGE_MS } from '../core/ownership/owner-resolver.js';
|
|
2
|
+
import { DataRootError } from '../core/command/team-workspace-store.js';
|
|
3
|
+
export async function authorizeOutput(aid, from) {
|
|
4
|
+
const view = await ownerResolver.refresh(aid, { maxAgeMs: OWNERSHIP_AUTHORIZATION_MAX_AGE_MS, source: 'outputs.read', allowTransient: false });
|
|
5
|
+
if (view.authorizationStatus !== 'verified' || view.ownerAid !== from || view.refreshFailure?.fallbackUsed
|
|
6
|
+
|| (view.validUntil ?? 0) <= Date.now()) {
|
|
7
|
+
throw new DataRootError('OUTPUT_FORBIDDEN', 'Current protocol Owner authorization is required');
|
|
8
|
+
}
|
|
9
|
+
return `${view.ownerAid}:${view.revision}`;
|
|
10
|
+
}
|
|
11
|
+
export function currentOutputOwner(aid, from, generation) {
|
|
12
|
+
const view = ownerResolver.snapshot(aid);
|
|
13
|
+
return view.authorizationStatus === 'verified' && !view.refreshFailure?.fallbackUsed
|
|
14
|
+
&& (view.validUntil ?? 0) > Date.now()
|
|
15
|
+
&& view.ownerAid === from && `${view.ownerAid}:${view.revision}` === generation;
|
|
16
|
+
}
|