evolcore 0.0.45 → 0.0.47
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 +113 -0
- package/bin/ecmsg.js +33 -23
- package/dist/ability/application-service.js +1 -2
- package/dist/ability/package.js +28 -0
- package/dist/agent-template/jobs.js +158 -36
- package/dist/agent-template/runtime.js +401 -34
- package/dist/agent-template/service.js +764 -369
- package/dist/agent-template/tool-runner.js +35 -17
- package/dist/agent-template/types.js +7 -4
- package/dist/agents/baseagent.js +10 -9
- package/dist/agents/claude-runner.js +22 -6
- package/dist/agents/codex/app-server-client.js +34 -27
- package/dist/agents/codex/diagnostics.js +18 -1
- package/dist/agents/codex-runner.js +3 -1
- package/dist/agents/ecagent-runner.js +3 -1
- package/dist/agents/gemini-runner.js +2 -1
- package/dist/aun/group/fs-download.js +1 -1
- package/dist/aun/menu/client.js +142 -182
- package/dist/aun/rpc/client.js +33 -17
- package/dist/aun/service-proxy.js +6 -23
- package/dist/channels/aun.js +675 -120
- package/dist/channels/daemon.js +1 -1
- package/dist/cli/agent-create.js +37 -10
- package/dist/cli/agent-template.js +105 -84
- package/dist/cli/agent.js +31 -18
- package/dist/cli/daemon-commands.js +42 -56
- package/dist/cli/daemon-lifecycle-client.js +55 -19
- package/dist/cli/directory.js +12 -4
- package/dist/cli/ecmsg-gateway.js +5 -2
- package/dist/cli/events-command.js +2 -1
- package/dist/cli/init-channel.js +2 -2
- package/dist/cli/init.js +57 -21
- package/dist/cli/integrity-command.js +2 -0
- package/dist/cli/managed-command-guard.js +20 -1
- package/dist/cli/menu-client.js +7 -5
- package/dist/cli/restart-monitor.js +135 -46
- package/dist/cli/services-command.js +28 -5
- package/dist/cli/task-context.js +83 -15
- package/dist/cli/upgrade-command.js +4 -2
- package/dist/config/config-field-policy.js +24 -0
- package/dist/config/config-manager.js +49 -19
- package/dist/config/peer-book-store.js +167 -127
- package/dist/config/peer-role-resolver.js +24 -4
- package/dist/config/provider-identity-migration.js +158 -6
- package/dist/config/provider-identity.js +10 -4
- package/dist/config/provider-ipc-service.js +10 -2
- package/dist/config/provider-local-sync.js +2 -2
- package/dist/config/providers-config.js +95 -10
- package/dist/config/providers-import.js +4 -6
- package/dist/config/providers.js +14 -3
- package/dist/config/role-store.js +1 -1
- package/dist/config/schema-migration.js +123 -16
- package/dist/config/schema-registry.js +6 -2
- package/dist/config-store.js +9 -1
- package/dist/core/agent-application-service.js +56 -29
- package/dist/core/agent-create-status.js +3 -1
- package/dist/core/agent-creation-claim.js +1 -0
- package/dist/core/agent-ipc-registration.js +2 -2
- package/dist/core/agent-reload-coordinator.js +38 -1
- package/dist/core/agent-runtime.js +91 -43
- package/dist/core/auth/agent-delegation.js +13 -3
- package/dist/core/auth/delegation-diagnostics.js +56 -15
- package/dist/core/auth/operation-authorizer.js +2 -2
- package/dist/core/auth/operation-catalog.js +3 -3
- package/dist/core/bootstrap-service.js +3 -0
- package/dist/core/capability/capability-manager.js +3 -1
- package/dist/core/channel-loader.js +29 -3
- package/dist/core/channel-runtime.js +1 -1
- package/dist/core/command/agent-control.js +6 -5
- package/dist/core/command/agent-template-menu.js +32 -97
- package/dist/core/command/eventcenter-menu.js +61 -13
- package/dist/core/command/menu-catalog.js +11 -4
- package/dist/core/command/menu-handler.js +39 -12
- package/dist/core/command/menu-protocol.js +8 -16
- package/dist/core/command/skill-slash.js +6 -2
- package/dist/core/command/slash-handler.js +4 -6
- package/dist/core/command/team-workspace-bootstrap.js +1 -2
- package/dist/core/command/team-workspace-management-store.js +83 -0
- package/dist/core/command/team-workspace-management.js +1 -2
- package/dist/core/command/team-workspace-team.js +26 -3
- package/dist/core/daemon-bootstrap.js +11 -9
- package/dist/core/daemon-control.js +4 -7
- package/dist/core/daemon-lifecycle.js +189 -143
- package/dist/core/evolagent-registry.js +50 -2
- package/dist/core/evolagent.js +2 -1
- package/dist/core/file-integrity/read.js +9 -16
- package/dist/core/file-integrity/store.js +94 -34
- package/dist/core/handoff/dispatcher.js +33 -7
- package/dist/core/handoff/runtime.js +8 -0
- package/dist/core/host-snapshot.js +9 -4
- package/dist/core/inference/text-inference.js +12 -2
- package/dist/core/initialization/service.js +22 -4
- package/dist/core/invoke/invoke-service.js +24 -3
- package/dist/core/ipc-registration.js +7 -3
- package/dist/core/memory/consolidation.js +6 -6
- package/dist/core/message/aun-ipc-sender.js +109 -7
- package/dist/core/message/contact-admission.js +6 -2
- package/dist/core/message/message-bridge.js +13 -0
- package/dist/core/message/message-queue.js +131 -30
- package/dist/core/message/pending-hints.js +8 -0
- package/dist/core/message/response-engine.js +48 -2
- package/dist/core/message/send-routing.js +3 -12
- package/dist/core/model/catalog-service.js +13 -0
- package/dist/core/model/model-catalog.js +57 -18
- package/dist/core/ownership/owner-resolver.js +27 -10
- package/dist/core/pack-auth.js +163 -31
- package/dist/core/pack-install.js +42 -1
- package/dist/{services/ledger.js → core/pack-ledger.js} +17 -6
- package/dist/core/permission/ec-command-parser.js +3 -1
- package/dist/core/permission/shell-environment.js +23 -0
- package/dist/core/rate-window.js +6 -1
- package/dist/core/relation/peer-identity.js +5 -1
- package/dist/core/relation/same-owner-proof.js +2 -1
- package/dist/core/session/adapters/claude-session-file-adapter.js +1 -1
- package/dist/core/session/session-file-health.js +36 -7
- package/dist/core/session/session-idle-monitor.js +0 -1
- package/dist/core/session/session-manager.js +14 -0
- package/dist/core/session/session-title.js +26 -6
- package/dist/core/skill/index-generator.js +3 -4
- package/dist/core/task/task-image-resources.js +1 -1
- package/dist/core/thread/thread-service.js +0 -1
- package/dist/core/thread/topic-id.js +8 -0
- package/dist/directory/owner-directory-admission.js +17 -0
- package/dist/directory/owner-directory-cache.js +3 -1
- package/dist/directory/owner-directory-markdown.js +145 -23
- package/dist/directory/owner-directory-policy.js +23 -0
- package/dist/directory/owner-directory-query-operation.js +20 -6
- package/dist/directory/owner-directory-search.js +47 -0
- package/dist/eck/message-renderer.js +171 -32
- package/dist/ecweb/basic-settings-service.js +7 -3
- package/dist/ecweb/providers-service.js +17 -10
- package/dist/ecweb/runtime/lifecycle.js +65 -16
- package/dist/ecweb/runtime/supervisor.js +79 -50
- package/dist/event-center/admission-materializer.js +1 -1
- package/dist/event-center/bus-gate.js +48 -4
- package/dist/event-center/bus-host.js +3 -3
- package/dist/event-center/center-config.js +57 -28
- package/dist/event-center/dispatcher.js +8 -0
- package/dist/event-center/event-log.js +69 -27
- package/dist/event-center/index-generator.js +6 -1
- package/dist/event-center/ipc-operation.js +66 -25
- package/dist/event-center/pack-loader.js +12 -55
- package/dist/event-center/pack-manager.js +5 -3
- package/dist/event-center/registry.js +48 -52
- package/dist/event-center/runtime.js +219 -81
- package/dist/event-center/script-runner.js +18 -7
- package/dist/event-center/types.js +9 -1
- package/dist/event-center/validation.js +33 -4
- package/dist/index.js +132 -75
- package/dist/ipc.js +35 -8
- package/dist/product.js +1 -0
- package/dist/proxy/manager.js +52 -11
- package/dist/proxy/service-supervisor.js +265 -67
- package/dist/services/dispatcher.js +26 -3
- package/dist/services/idempotency.js +128 -0
- package/dist/services/identity.js +3 -27
- package/dist/services/index-generator.js +5 -1
- package/dist/services/index.js +244 -45
- package/dist/services/ipc-operation.js +164 -20
- package/dist/services/pack-manager.js +37 -9
- package/dist/services/router.js +100 -31
- package/dist/services/script-runner.js +15 -4
- package/dist/services/service-payload.js +50 -2
- package/dist/services/validation.js +107 -3
- package/dist/trigger/scheduler.js +18 -4
- package/dist/trigger/script-sandbox.js +39 -2
- package/dist/trigger/state.js +7 -0
- package/dist/utils/aid-bind.js +155 -18
- package/dist/utils/atomic-write.js +3 -3
- package/dist/utils/cross-platform.js +59 -16
- package/dist/utils/error-utils.js +26 -1
- package/dist/utils/instance-registry.js +94 -35
- package/dist/utils/process-introspect.js +187 -27
- package/dist/utils/project-path.js +47 -3
- package/dist/utils/upgrade-jobs.js +4 -4
- package/dist/utils/windows-shell-trust.js +174 -68
- package/kits/docs/context-assembly.md +3 -3
- package/kits/docs/evolcore/agent.md +28 -10
- package/kits/docs/evolcore/aid.md +3 -1
- package/kits/docs/evolcore/config.md +22 -0
- package/kits/docs/evolcore/directory.md +46 -12
- package/kits/docs/evolcore/event-center.md +6 -6
- package/kits/docs/evolcore/group-collaboration.md +1 -1
- package/kits/docs/evolcore/menu-client.md +7 -5
- package/kits/docs/evolcore/menu-protocol.md +5 -3
- package/kits/docs/evolcore/msg.md +10 -3
- package/kits/docs/evolcore/provider.md +17 -5
- package/kits/docs/evolcore/services.md +145 -12
- package/kits/docs/evolcore/thread-chain.md +17 -9
- package/kits/docs/prompt-loading-architecture.md +4 -4
- package/kits/eck_message_manifest.json +46 -3
- package/kits/rules/04-relation.md +10 -2
- package/kits/rules/06-channel.md +2 -1
- package/kits/schemas/providers.schema.2.json +1 -0
- package/kits/skills/ec-group/SKILL.md +4 -0
- package/kits/skills/ec-skill/scripts/cli.mjs +1 -1
- package/kits/skills/ec-skill/scripts/skill.mjs +13 -2
- package/kits/skills/thread-ops/SKILL.md +8 -5
- package/kits/templates/message-fragments/group-batch-item.md +3 -0
- package/kits/templates/message-fragments/group-batch.md +1 -0
- package/kits/templates/message-fragments/item-group.md +4 -0
- package/kits/templates/message-fragments/item-private.md +4 -0
- package/kits/templates/message-fragments/thread-context.md +1 -1
- package/kits/templates/system-fragments/commands.md +5 -5
- package/kits/templates/system-fragments/managed-runtime.md +1 -1
- package/kits/templates/system-fragments/relation.md +11 -7
- package/package.json +3 -2
- package/scripts/agent-template/index.mjs +9 -4
- package/scripts/agent-template/inspect.mjs +16 -9
- package/scripts/agent-template/shared/plan.mjs +3 -33
- package/scripts/agent-template/shared/template-contract.mjs +186 -3
- package/scripts/agent-template/shared/template-package.mjs +119 -10
- package/scripts/agent-template/shared/template-runtime.mjs +49 -6
- package/scripts/agent-template/shared/template.mjs +5 -5
- package/scripts/agent-template/team-pack.mjs +245 -0
- package/scripts/agent-template/team-preview.mjs +111 -0
- package/scripts/aid-batch/identity-batch.mjs +143 -0
- package/dist/ability/versions.js +0 -32
- package/dist/aun/model-headers.js +0 -17
- package/dist/channels/builtin-plugins.js +0 -19
- package/dist/core/command/team-workspace-initializer.js +0 -2
- package/dist/core/command/team-workspace-job-store.js +0 -88
- package/dist/core/command/team-workspace-management-service.js +0 -2
- package/dist/core/contact-bind-registry.js +0 -27
- package/dist/event-center/ledger.js +0 -52
- package/dist/services/reply.js +0 -55
- package/kits/templates/message-fragments/item.md +0 -3
- package/scripts/agent-template/pack.mjs +0 -169
|
@@ -1,101 +1,37 @@
|
|
|
1
|
-
import { isValidAid } from '../../aun/aid/validation.js';
|
|
2
1
|
import { getAgentTemplateService } from '../../agent-template/service.js';
|
|
3
2
|
import { TEMPLATE_ACTIONS, templateError } from '../../agent-template/types.js';
|
|
4
3
|
import { authorizeFreshOperation } from '../auth/auth-gateway.js';
|
|
5
4
|
import { getProviderCatalog } from '../model/model-catalog.js';
|
|
5
|
+
const templateContract = await import(new URL('../../../scripts/agent-template/shared/template-contract.mjs', import.meta.url).href);
|
|
6
6
|
export function isTemplateRequest(request) {
|
|
7
|
-
return
|
|
8
|
-
&& (TEMPLATE_ACTIONS.includes(request.action) || request.args?.view === 'template-job');
|
|
7
|
+
return request.name === 'template' || request.cmd === '/template';
|
|
9
8
|
}
|
|
10
9
|
export function isProviderModelCatalog(request) {
|
|
11
10
|
return (request.name === 'model' || request.cmd === '/model') && request.args?.view === 'catalog' && request.args?.scope === 'process';
|
|
12
11
|
}
|
|
12
|
+
export function templateMenuAction(request) {
|
|
13
|
+
const args = { ...request.args };
|
|
14
|
+
let action = request.action;
|
|
15
|
+
if (request.type === 'menu.query') {
|
|
16
|
+
action = args.view === 'job' ? 'status' : args.view === 'capabilities' ? 'capabilities' : undefined;
|
|
17
|
+
delete args.view;
|
|
18
|
+
}
|
|
19
|
+
else if (request.type !== 'menu.action' || ['status', 'capabilities'].includes(action)) {
|
|
20
|
+
throw templateError('INVALID_ARGUMENT', 'Use the defined template Menu action or query');
|
|
21
|
+
}
|
|
22
|
+
if (!TEMPLATE_ACTIONS.includes(action))
|
|
23
|
+
throw templateError('INVALID_ARGUMENT', 'Unknown template action');
|
|
24
|
+
const normalize = templateContract.normalizeTemplateRequest;
|
|
25
|
+
if (!normalize)
|
|
26
|
+
throw templateError('RECOVERY_REQUIRED', 'Template contract update is in progress');
|
|
27
|
+
const normalized = normalize({ requestId: request.id ?? 'validation', action, args });
|
|
28
|
+
return { action, args: normalized.args };
|
|
29
|
+
}
|
|
13
30
|
export function validateTemplateRequest(request) {
|
|
14
31
|
try {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (value.providers !== undefined && !record(value.providers)
|
|
19
|
-
|| value.externalAids !== undefined && (!record(value.externalAids)
|
|
20
|
-
|| Object.entries(value.externalAids).some(([from, to]) => !isValidAid(from) || typeof to !== 'string' || !isValidAid(to)))) {
|
|
21
|
-
throw new Error('Invalid member Provider or external AID selections');
|
|
22
|
-
}
|
|
23
|
-
for (const [name, selection] of Object.entries(value.providers ?? {})) {
|
|
24
|
-
if (!['claude', 'codex', 'ecagent', 'gemini'].includes(name) || !record(selection)
|
|
25
|
-
|| Object.keys(selection).some(k => !['provider', 'model', 'effort'].includes(k))
|
|
26
|
-
|| !/^provider-\d{8}$/.test(selection.provider) || selection.model !== undefined && (typeof selection.model !== 'string' || !selection.model.trim())
|
|
27
|
-
|| selection.effort !== undefined && selection.effort !== null && !['low', 'medium', 'high', 'xhigh', 'max'].includes(selection.effort)) {
|
|
28
|
-
throw new Error('Invalid Provider/model/effort selection');
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
const args = request.args;
|
|
33
|
-
if (!args || typeof args !== 'object' || Array.isArray(args))
|
|
34
|
-
throw new Error('args object required');
|
|
35
|
-
let allowed;
|
|
36
|
-
if (args.view === 'template-job') {
|
|
37
|
-
if (request.type !== 'menu.query' || !!args.jobId === !!args.requestId)
|
|
38
|
-
throw new Error('Use query with jobId or requestId');
|
|
39
|
-
if (args.jobId !== undefined && !/^job_[a-f0-9-]{36}$/.test(args.jobId)
|
|
40
|
-
|| args.requestId !== undefined && (typeof args.requestId !== 'string' || !args.requestId.trim() || args.requestId.length > 200))
|
|
41
|
-
throw new Error('Invalid task identifier');
|
|
42
|
-
allowed = ['view', 'jobId', 'requestId'];
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
if (request.type !== 'menu.action')
|
|
46
|
-
throw new Error('Template actions use menu.action');
|
|
47
|
-
const fields = { inspect: ['aid'], build: ['aid', 'template', 'include'],
|
|
48
|
-
push: ['buildId', 'ownerAid', 'targetPath', 'releasedFindings'], pull: ['location', 'download', 'digest', 'targetAid', 'targets'],
|
|
49
|
-
deploy: ['pullId', 'providers', 'externalAids', 'members'] };
|
|
50
|
-
allowed = fields[request.action];
|
|
51
|
-
if (!allowed)
|
|
52
|
-
throw new Error('Unsupported template action');
|
|
53
|
-
if (['inspect', 'build'].includes(request.action) && !isValidAid(args.aid))
|
|
54
|
-
throw new Error('aid required');
|
|
55
|
-
if (request.action === 'build' && (!args.template?.version || !args.template?.name || !args.include))
|
|
56
|
-
throw new Error('template.version/name and include required');
|
|
57
|
-
if (request.action === 'pull' && (!isValidAid(args.location?.aid)
|
|
58
|
-
|| typeof args.location?.path !== 'string' || !args.location.path.startsWith('/templates/')
|
|
59
|
-
|| !/^[A-Za-z0-9]{10}$/.test(args.download?.shareId) || !/^sha256:[a-f0-9]{64}$/.test(args.digest)))
|
|
60
|
-
throw new Error('Invalid package location, shareId, digest or targetAid');
|
|
61
|
-
if (request.action === 'pull') {
|
|
62
|
-
if (args.targets === undefined) {
|
|
63
|
-
if (!isValidAid(args.targetAid))
|
|
64
|
-
throw new Error('targetAid or targets mapping required');
|
|
65
|
-
}
|
|
66
|
-
else if (args.targetAid !== undefined || !record(args.targets) || !Object.keys(args.targets).length
|
|
67
|
-
|| Object.entries(args.targets).some(([key, aid]) => !memberKey(key) || typeof aid !== 'string' || !isValidAid(aid))
|
|
68
|
-
|| new Set(Object.values(args.targets)).size !== Object.keys(args.targets).length) {
|
|
69
|
-
throw new Error('Map members to distinct existing Agent AIDs; do not mix targetAid and targets');
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (request.action === 'push' && (!/^build_[a-f0-9-]{36}$/.test(args.buildId) || !isValidAid(args.ownerAid)
|
|
73
|
-
|| typeof args.targetPath !== 'string' || !args.targetPath.startsWith('/templates/')
|
|
74
|
-
|| args.releasedFindings !== undefined && (!Array.isArray(args.releasedFindings) || !args.releasedFindings.every((f) => typeof f === 'string'))))
|
|
75
|
-
throw new Error('Invalid push arguments');
|
|
76
|
-
if (request.action === 'deploy' && (!/^pull_[a-f0-9-]{36}$/.test(args.pullId)
|
|
77
|
-
|| args.providers !== undefined && (!args.providers || typeof args.providers !== 'object' || Array.isArray(args.providers))
|
|
78
|
-
|| args.externalAids !== undefined && (!args.externalAids || typeof args.externalAids !== 'object' || Array.isArray(args.externalAids)
|
|
79
|
-
|| Object.entries(args.externalAids).some(([from, to]) => !isValidAid(from) || typeof to !== 'string' || !isValidAid(to)))))
|
|
80
|
-
throw new Error('Invalid deploy arguments');
|
|
81
|
-
if (request.action === 'deploy') {
|
|
82
|
-
validateSelections(args);
|
|
83
|
-
if (args.members !== undefined) {
|
|
84
|
-
if (!record(args.members) || args.providers !== undefined || args.externalAids !== undefined)
|
|
85
|
-
throw new Error('Use members or single-Agent selections');
|
|
86
|
-
for (const [key, selection] of Object.entries(args.members)) {
|
|
87
|
-
if (!memberKey(key) || !record(selection) || Object.keys(selection).some(k => !['providers', 'externalAids'].includes(k))) {
|
|
88
|
-
throw new Error('Invalid member selection');
|
|
89
|
-
}
|
|
90
|
-
validateSelections(selection);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
if (Object.keys(args).some(k => !allowed.includes(k)))
|
|
96
|
-
throw new Error('Unknown template argument');
|
|
97
|
-
if (request.agent !== undefined)
|
|
98
|
-
throw new Error('Use action target fields, not top-level agent');
|
|
32
|
+
if (!isTemplateRequest(request) || request.agent !== undefined)
|
|
33
|
+
throw templateError('INVALID_ARGUMENT', 'Template is a process operation');
|
|
34
|
+
templateMenuAction(request);
|
|
99
35
|
return null;
|
|
100
36
|
}
|
|
101
37
|
catch (error) {
|
|
@@ -104,24 +40,23 @@ export function validateTemplateRequest(request) {
|
|
|
104
40
|
}
|
|
105
41
|
export async function executeTemplateMenu(request, subject, source) {
|
|
106
42
|
try {
|
|
107
|
-
const
|
|
108
|
-
if (invalid)
|
|
109
|
-
throw templateError(invalid.code, invalid.message);
|
|
43
|
+
const { action, args } = templateMenuAction(request);
|
|
110
44
|
if (!subject?.fromControlChannel || !subject.isDaemonOwner || !subject.principalId
|
|
111
45
|
|| subject.processRole === 'daemon-service' || !subject.ecwebManagement && subject.menuEncrypted !== true) {
|
|
112
|
-
throw templateError('NOT_ALLOWED', 'Template operations require an encrypted DaemonOwner Control request'
|
|
46
|
+
throw templateError('NOT_ALLOWED', 'Template operations require an encrypted DaemonOwner Control request');
|
|
113
47
|
}
|
|
114
|
-
|
|
48
|
+
if (Object.values(args.members ?? {}).some((member) => member.source?.kind === 'directory')
|
|
49
|
+
|| args.source?.kind === 'file')
|
|
50
|
+
throw templateError('INVALID_ARGUMENT', 'Remote template calls cannot read host paths');
|
|
115
51
|
const decision = await authorizeFreshOperation({ source, subject,
|
|
116
|
-
intent: { operation, scope: 'process', source, args
|
|
52
|
+
intent: { operation: 'agent.template.' + action, scope: 'process', source, args } });
|
|
117
53
|
if (!decision.allow)
|
|
118
54
|
throw templateError('NOT_ALLOWED', 'Template operation denied');
|
|
119
|
-
|
|
120
|
-
return { data: request.type === 'menu.query' ? await service.query(subject.principalId, request.args)
|
|
121
|
-
: await service.action(subject.principalId, request.id, request.action, request.args) };
|
|
55
|
+
return { data: await getAgentTemplateService().action(subject.principalId, request.id, action, args) };
|
|
122
56
|
}
|
|
123
57
|
catch (error) {
|
|
124
|
-
return { error: error.message, code: error.code ?? 'TEMPLATE_FAILED',
|
|
58
|
+
return { error: error.message, code: error.code ?? 'TEMPLATE_FAILED',
|
|
59
|
+
...(error.details ? { data: error.details } : {}) };
|
|
125
60
|
}
|
|
126
61
|
}
|
|
127
62
|
export async function executeProviderModelCatalog(request, subject, source) {
|
|
@@ -9,8 +9,8 @@ import { atomicWriteJson } from '../../utils/atomic-write.js';
|
|
|
9
9
|
import { loadPacks } from '../../event-center/pack-loader.js';
|
|
10
10
|
import { validatePackJson } from '../../event-center/validation.js';
|
|
11
11
|
import { materializeAllowlist } from '../../event-center/admission-materializer.js';
|
|
12
|
-
import { EventLog } from '../../event-center/event-log.js';
|
|
13
|
-
const VIEWS = new Set(['center', 'rules', 'packs', 'register', 'subscribers', 'stats', 'publishStats', 'records']);
|
|
12
|
+
import { EventLog, PublicationLog } from '../../event-center/event-log.js';
|
|
13
|
+
const VIEWS = new Set(['center', 'rules', 'packs', 'register', 'subscribers', 'stats', 'publishStats', 'records', 'timeline']);
|
|
14
14
|
/** records 视图可接受的 event-log kind。 */
|
|
15
15
|
const RECORD_KINDS = new Set(['received', 'handled', 'dropped', 'filtered']);
|
|
16
16
|
/** records 视图单次最多返回条数;scan 上限防止大日志拖慢事件循环。 */
|
|
@@ -35,10 +35,11 @@ export function validateEventsMenuRequest(request) {
|
|
|
35
35
|
: view === 'rules' ? new Set(['view', 'event'])
|
|
36
36
|
: view === 'register' ? new Set(['view', 'packId', 'event'])
|
|
37
37
|
: view === 'records' ? new Set(['view', 'packId', 'event', 'kind', 'limit', 'includeData'])
|
|
38
|
-
: view === '
|
|
39
|
-
: view === '
|
|
40
|
-
: view === '
|
|
41
|
-
: new Set(['view', 'packId'])
|
|
38
|
+
: view === 'timeline' ? new Set(['view', 'packId', 'event', 'from', 'to', 'limit'])
|
|
39
|
+
: view === 'subscribers' ? new Set(['view', 'event'])
|
|
40
|
+
: view === 'stats' ? new Set(['view', 'event'])
|
|
41
|
+
: view === 'publishStats' ? new Set(['view', 'packId', 'event'])
|
|
42
|
+
: new Set(['view', 'packId']);
|
|
42
43
|
const unknown = Object.keys(values).find(key => !allowed.has(key));
|
|
43
44
|
if (unknown)
|
|
44
45
|
return { code: 'INVALID_ARGS', message: `events ${String(view ?? 'packs')} does not accept args.${unknown}` };
|
|
@@ -65,6 +66,25 @@ export function validateEventsMenuRequest(request) {
|
|
|
65
66
|
return { code: 'INVALID_ARGS', message: 'events records args.includeData must be a boolean' };
|
|
66
67
|
}
|
|
67
68
|
}
|
|
69
|
+
if (view === 'timeline') {
|
|
70
|
+
if (values.packId !== undefined && (typeof values.packId !== 'string' || !values.packId.trim())) {
|
|
71
|
+
return { code: 'INVALID_ARGS', message: 'events timeline args.packId must be a non-empty string' };
|
|
72
|
+
}
|
|
73
|
+
if (values.event !== undefined && (typeof values.event !== 'string' || !values.event.trim())) {
|
|
74
|
+
return { code: 'INVALID_ARGS', message: 'events timeline args.event must be a non-empty string' };
|
|
75
|
+
}
|
|
76
|
+
for (const key of ['from', 'to']) {
|
|
77
|
+
if (values[key] !== undefined && (!Number.isInteger(values[key]) || Number(values[key]) < 0)) {
|
|
78
|
+
return { code: 'INVALID_ARGS', message: `events timeline args.${key} must be a non-negative integer (epoch ms)` };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (values.from !== undefined && values.to !== undefined && Number(values.from) > Number(values.to)) {
|
|
82
|
+
return { code: 'INVALID_ARGS', message: 'events timeline args.from must not be greater than args.to' };
|
|
83
|
+
}
|
|
84
|
+
if (values.limit !== undefined && (!Number.isInteger(values.limit) || Number(values.limit) < 1 || Number(values.limit) > RECORDS_MAX_LIMIT)) {
|
|
85
|
+
return { code: 'INVALID_ARGS', message: `events timeline args.limit must be an integer in [1, ${RECORDS_MAX_LIMIT}]` };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
68
88
|
return undefined;
|
|
69
89
|
}
|
|
70
90
|
if (type === 'menu.update') {
|
|
@@ -145,6 +165,16 @@ function unitOf(context) {
|
|
|
145
165
|
}
|
|
146
166
|
return unit;
|
|
147
167
|
}
|
|
168
|
+
/** 逐包读最近日志行,补 packId,按 ts 升序合并;scanCapped 表示某包可能还有更早的匹配行。 */
|
|
169
|
+
function readPackLogs(packs, tail, scan, matches) {
|
|
170
|
+
const perPack = packs.map(pack => ({ packId: pack.id, lines: tail(pack, scan) }));
|
|
171
|
+
const scanned = perPack.reduce((total, item) => total + item.lines.length, 0);
|
|
172
|
+
const matched = perPack
|
|
173
|
+
.flatMap(item => item.lines.map(line => ({ packId: item.packId, ...line })))
|
|
174
|
+
.filter(matches)
|
|
175
|
+
.sort((left, right) => left.ts - right.ts);
|
|
176
|
+
return { matched, scanned, scanCapped: perPack.some(item => item.lines.length >= scan) };
|
|
177
|
+
}
|
|
148
178
|
export async function executeEventsQuery(context, args = {}) {
|
|
149
179
|
const unit = unitOf(context);
|
|
150
180
|
if ('code' in unit)
|
|
@@ -250,12 +280,7 @@ export async function executeEventsQuery(context, args = {}) {
|
|
|
250
280
|
}
|
|
251
281
|
// 每个包最多扫 scan 行;packId 省略时合并所有 enabled 包再按 ts 取最后 limit 条。
|
|
252
282
|
const scan = Math.min(RECORDS_MAX_SCAN, Math.max(limit * 5, 200));
|
|
253
|
-
const
|
|
254
|
-
const scanned = perPack.reduce((total, item) => total + item.lines.length, 0);
|
|
255
|
-
const matched = perPack
|
|
256
|
-
.flatMap(item => item.lines.map(line => ({ packId: item.packId, ...line })))
|
|
257
|
-
.filter(record => (!eventName || record.event === eventName) && (!kind || record.kind === kind))
|
|
258
|
-
.sort((left, right) => left.ts - right.ts);
|
|
283
|
+
const { matched, scanned, scanCapped } = readPackLogs(packs, (pack, count) => EventLog.forPack(pack).tail(count), scan, record => (!eventName || record.event === eventName) && (!kind || record.kind === kind));
|
|
259
284
|
const records = matched.slice(-limit).map(record => {
|
|
260
285
|
if (includeData || record.kind !== 'received')
|
|
261
286
|
return record;
|
|
@@ -265,7 +290,30 @@ export async function executeEventsQuery(context, args = {}) {
|
|
|
265
290
|
return {
|
|
266
291
|
records,
|
|
267
292
|
scanned,
|
|
268
|
-
truncated: matched.length > limit ||
|
|
293
|
+
truncated: matched.length > limit || scanCapped,
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
if (view === 'timeline') {
|
|
297
|
+
const packId = typeof args.packId === 'string' ? args.packId.trim() : undefined;
|
|
298
|
+
const eventName = typeof args.event === 'string' ? args.event : undefined;
|
|
299
|
+
const from = typeof args.from === 'number' && Number.isInteger(args.from) ? args.from : undefined;
|
|
300
|
+
const to = typeof args.to === 'number' && Number.isInteger(args.to) ? args.to : undefined;
|
|
301
|
+
const requestedLimit = typeof args.limit === 'number' && Number.isInteger(args.limit) ? args.limit : RECORDS_DEFAULT_LIMIT;
|
|
302
|
+
const limit = Math.min(RECORDS_MAX_LIMIT, Math.max(1, requestedLimit));
|
|
303
|
+
const packs = packId
|
|
304
|
+
? unit.state.enabledPacks.filter(pack => pack.id === packId)
|
|
305
|
+
: unit.state.enabledPacks;
|
|
306
|
+
if (packId && packs.length === 0) {
|
|
307
|
+
throw { code: 'PACK_NOT_FOUND', message: `pack not found or invalid: ${packId}` };
|
|
308
|
+
}
|
|
309
|
+
const scan = Math.min(RECORDS_MAX_SCAN, Math.max(limit * 5, 200));
|
|
310
|
+
const { matched, scanned, scanCapped } = readPackLogs(packs, (pack, count) => PublicationLog.forPack(pack).tail(count), scan, record => (!eventName || record.event === eventName)
|
|
311
|
+
&& (from === undefined || record.ts >= from)
|
|
312
|
+
&& (to === undefined || record.ts <= to));
|
|
313
|
+
return {
|
|
314
|
+
records: matched.slice(-limit),
|
|
315
|
+
scanned,
|
|
316
|
+
truncated: matched.length > limit || scanCapped,
|
|
269
317
|
};
|
|
270
318
|
}
|
|
271
319
|
// packs
|
|
@@ -127,6 +127,7 @@ const ENTRIES = [
|
|
|
127
127
|
{ id: 'event.packs', type: 'list', contexts: ['agent'], name: 'events', label: '事件包', section: 'agent', order: 82, query: { cmd: '/events', args: { view: 'packs' }, operation: 'event.packs.list', scope: 'agent' }, control: 'list' },
|
|
128
128
|
{ id: 'event.stats', type: 'list', contexts: ['agent'], name: 'events', label: '事件统计', section: 'agent', order: 83, query: { cmd: '/events', args: { view: 'stats' }, operation: 'event.stats.current', scope: 'agent' }, control: 'list' },
|
|
129
129
|
{ id: 'event.publishStats', type: 'list', contexts: ['agent'], name: 'events', label: '事件发布统计', section: 'agent', order: 83.5, query: { cmd: '/events', args: { view: 'publishStats' }, operation: 'event.publishStats.current', scope: 'agent' }, control: 'list' },
|
|
130
|
+
{ id: 'event.timeline', type: 'list', contexts: ['agent'], name: 'events', label: '事件时间线', section: 'agent', order: 83.7, query: { cmd: '/events', args: { view: 'timeline' }, operation: 'event.timeline.list', scope: 'agent' }, control: 'list' },
|
|
130
131
|
{ id: 'event.records', type: 'list', contexts: ['agent'], name: 'events', label: '事件分发记录', section: 'agent', order: 84, query: { cmd: '/events', args: { view: 'records' }, operation: 'event.records.list', scope: 'agent' }, control: 'list' },
|
|
131
132
|
{ id: 'baseagents.inventory', type: 'list', contexts: ['process'], name: 'baseagents', label: 'Base Agent 清单', section: 'process', order: 9, query: { cmd: '/baseagents', operation: 'system.status', scope: 'process' }, control: 'list' },
|
|
132
133
|
{ id: 'system.status', type: 'list', contexts: ['process'], name: 'system', label: '系统状态', section: 'process', order: 10, query: { cmd: '/system', operation: 'system.status', scope: 'process' }, control: 'list' },
|
|
@@ -142,10 +143,16 @@ const ENTRIES = [
|
|
|
142
143
|
{ id: 'agent.create', type: 'action', contexts: ['process'], name: 'agent', label: '创建 Agent', section: 'process', order: 50, action: { cmd: '/agent', action: 'create', operation: 'agent.create', scope: 'control' } },
|
|
143
144
|
{ id: 'agent.initialize', type: 'action', contexts: ['process'], name: 'agent', label: '初始化 Agent', section: 'process', order: 55, action: { cmd: '/agent', action: 'initialize', operation: 'agent.initialize', scope: 'control' } },
|
|
144
145
|
{ id: 'agent.reload', type: 'action', contexts: ['process'], name: 'agent', label: '重载 Agent', section: 'process', order: 60, action: { cmd: '/agent', action: 'reload', operation: 'agent.reload', scope: 'control' } },
|
|
145
|
-
...['inspect', 'build', 'push', 'pull', 'deploy'].map((action, index) => ({
|
|
146
|
-
id: 'agent.template.' + action, type: 'action', contexts: ['process'], name: '
|
|
147
|
-
label: '
|
|
148
|
-
action: { cmd: '/
|
|
146
|
+
...['inspect', 'build', 'push', 'pull', 'preview', 'deploy', 'resume', 'cancel'].map((action, index) => ({
|
|
147
|
+
id: 'agent.template.' + action, type: 'action', contexts: ['process'], name: 'template',
|
|
148
|
+
label: '模板 ' + action, section: 'process', order: 65 + index,
|
|
149
|
+
action: { cmd: '/template', action, operation: 'agent.template.' + action, scope: 'process' },
|
|
150
|
+
})),
|
|
151
|
+
...['job', 'capabilities'].map(view => ({
|
|
152
|
+
id: 'agent.template.' + (view === 'job' ? 'status' : view), type: 'list', contexts: ['process'],
|
|
153
|
+
name: 'template', label: '模板 ' + view, section: 'process', order: 74,
|
|
154
|
+
query: { cmd: '/template', args: { view }, operation: 'agent.template.' + (view === 'job' ? 'status' : view), scope: 'process' },
|
|
155
|
+
control: 'list',
|
|
149
156
|
})),
|
|
150
157
|
{ id: 'agent.delete', type: 'action', contexts: ['process'], name: 'agent', label: '删除 Agent', section: 'process', order: 70, action: { cmd: '/agent', action: 'delete', operation: 'agent.delete', scope: 'control' } },
|
|
151
158
|
];
|
|
@@ -23,7 +23,7 @@ import { resolveGlobalPkg } from '../../utils/npm-ops.js';
|
|
|
23
23
|
import { executeUpgradeAction, parseUpgradeMode } from '../../utils/upgrade-jobs.js';
|
|
24
24
|
import { launchMonitorAndConfirm, resolveCliEntry, isProcessRunning } from '../../utils/cross-platform.js';
|
|
25
25
|
import { cachedCliVersion } from '../../utils/cross-platform.js';
|
|
26
|
-
import {
|
|
26
|
+
import { hasLiveRestartMonitor } from '../../utils/instance-registry.js';
|
|
27
27
|
import { loadDefaults, loadDaemonConfig } from '../../config-store.js';
|
|
28
28
|
import { buildEcwebPairingUrl } from '../../ecweb/pairing.js';
|
|
29
29
|
import { WEB_PACKAGE_NAME, RESTART_REQUEST_ID_ENV, RUNTIME_HOME_ENV, SESSION_ID_ENV } from '../../product.js';
|
|
@@ -52,6 +52,7 @@ import { isAgentFullAccessOwner, resolveRuntimePermissionMode, resolveRuntimeStr
|
|
|
52
52
|
import { isManagementRole } from '../../config/builtin-roles.js';
|
|
53
53
|
import { SYSTEM_CONTROL_CHANNEL } from '../system-channels.js';
|
|
54
54
|
import { logger } from '../../utils/logger.js';
|
|
55
|
+
import { resolveProjectDefaultPath } from '../../utils/project-path.js';
|
|
55
56
|
import { shouldSuppressRealRestart, createRestartRequest, readRestartRequest, updateRestartRequest, removeRestartRequest } from '../../utils/restart-safety.js';
|
|
56
57
|
import { AGENT_DELEGATION_TOKEN_ENV } from '../auth/agent-delegation.js';
|
|
57
58
|
import { evolMenuResponseTransportMetadata, menuFailure, menuCommandForName, menuSuccess, normalizeMenuError, validateTaskActivityQueryArgs, validateSlashCommandsQueryArgs, validateConfigWriteScope, validateMenuRequest, } from './menu-protocol.js';
|
|
@@ -2263,8 +2264,8 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2263
2264
|
const cmdBase = cmd.trim().split(' ')[0];
|
|
2264
2265
|
if (!cmdBase)
|
|
2265
2266
|
return { error: '缺少命令', code: 'MISSING_CMD' };
|
|
2266
|
-
if (cmdBase === '/
|
|
2267
|
-
return executeTemplateMenu({ name: '
|
|
2267
|
+
if (cmdBase === '/template') {
|
|
2268
|
+
return executeTemplateMenu({ name: 'template', type: 'menu.query', args }, fromControlChannel ? authSubject : undefined, source);
|
|
2268
2269
|
}
|
|
2269
2270
|
if (cmdBase === '/model' && args?.scope === 'process' && args?.view === 'catalog') {
|
|
2270
2271
|
return executeProviderModelCatalog({ name: 'model', type: 'menu.query', args }, fromControlChannel ? authSubject : undefined, source);
|
|
@@ -2812,7 +2813,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2812
2813
|
}
|
|
2813
2814
|
if (cmdBase === '/pwd') {
|
|
2814
2815
|
const sessPath = session?.projectPath;
|
|
2815
|
-
const fallbackPath = evolagent?.config?.projects?.defaultPath;
|
|
2816
|
+
const fallbackPath = resolveProjectDefaultPath(evolagent?.config?.projects?.defaultPath);
|
|
2816
2817
|
const path = sessPath ?? fallbackPath ?? null;
|
|
2817
2818
|
const name = path ? this.getProjectName(path) : null;
|
|
2818
2819
|
const source = sessPath != null
|
|
@@ -3232,10 +3233,12 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
3232
3233
|
return { error: error?.message ?? String(error), code: error?.code ?? 'INTERNAL_ERROR' };
|
|
3233
3234
|
}
|
|
3234
3235
|
}
|
|
3235
|
-
if (view !== 'status')
|
|
3236
|
+
if (view !== 'status' && view !== 'basic') {
|
|
3236
3237
|
return { error: `Unsupported system view: ${String(view)}`, code: 'NOT_SUPPORTED' };
|
|
3238
|
+
}
|
|
3237
3239
|
const { readVersionInfo } = await import('../../utils/host-info.js');
|
|
3238
3240
|
const versions = readVersionInfo();
|
|
3241
|
+
const cpus = os.cpus();
|
|
3239
3242
|
const data = {
|
|
3240
3243
|
aid: loadDaemonConfig().aid ?? null,
|
|
3241
3244
|
pid: process.pid,
|
|
@@ -3246,7 +3249,20 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
3246
3249
|
uptime: Math.floor(process.uptime()),
|
|
3247
3250
|
version: versions.evolcore,
|
|
3248
3251
|
fastaunVersion: versions.fastaun,
|
|
3252
|
+
osName: os.type(),
|
|
3253
|
+
osRelease: os.release(),
|
|
3254
|
+
cpuModel: cpus[0]?.model ?? null,
|
|
3255
|
+
cpuCount: cpus.length,
|
|
3256
|
+
memoryTotalBytes: os.totalmem(),
|
|
3257
|
+
systemUptime: Math.floor(os.uptime()),
|
|
3249
3258
|
};
|
|
3259
|
+
// 首屏只读本机基本信息,不定位全局 npm 包,也不等待 CLI 可用性探测。
|
|
3260
|
+
if (view === 'basic') {
|
|
3261
|
+
return { data: {
|
|
3262
|
+
...data,
|
|
3263
|
+
ecwebVersion: versions.ecweb,
|
|
3264
|
+
} };
|
|
3265
|
+
}
|
|
3250
3266
|
// ecweb 是独立全局包,读其已装版本(与 /upgrade 一致)
|
|
3251
3267
|
const ecwebPkg = resolveGlobalPkg(WEB_PACKAGE_NAME);
|
|
3252
3268
|
if (ecwebPkg?.version)
|
|
@@ -3909,8 +3925,8 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
3909
3925
|
const cmdBase = cmd.trim().split(' ')[0];
|
|
3910
3926
|
if (!cmdBase)
|
|
3911
3927
|
return { error: '缺少命令', code: 'MISSING_CMD' };
|
|
3912
|
-
if (cmdBase === '/
|
|
3913
|
-
return executeTemplateMenu({ name: '
|
|
3928
|
+
if (cmdBase === '/template') {
|
|
3929
|
+
return executeTemplateMenu({ name: 'template', type: 'menu.action', id: requestId, action, args }, fromControlChannel ? authSubject : undefined, source);
|
|
3914
3930
|
}
|
|
3915
3931
|
if (cmdBase === '/provider') {
|
|
3916
3932
|
return executeProviderMenu({ name: 'provider', cmd, type: 'menu.action', args, action }, fromControlChannel ? authSubject : undefined, source);
|
|
@@ -4165,7 +4181,12 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4165
4181
|
return { error: '初始化状态无效', code: 'INITIALIZE_STATE_INVALID' };
|
|
4166
4182
|
}
|
|
4167
4183
|
}
|
|
4168
|
-
|
|
4184
|
+
try {
|
|
4185
|
+
a.project = previousProject ?? resolveProjectPath(a.project, a.aid ?? '', loadDefaults());
|
|
4186
|
+
}
|
|
4187
|
+
catch (error) {
|
|
4188
|
+
return menuResultFailure(error);
|
|
4189
|
+
}
|
|
4169
4190
|
}
|
|
4170
4191
|
else if (action === 'initialize' && a.resume !== true) {
|
|
4171
4192
|
const suppliedPlan = a.plan && typeof a.plan === 'object' && !Array.isArray(a.plan) ? a.plan : undefined;
|
|
@@ -4189,7 +4210,13 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4189
4210
|
return { error: '初始化状态无效', code: 'INITIALIZE_STATE_INVALID' };
|
|
4190
4211
|
}
|
|
4191
4212
|
}
|
|
4192
|
-
|
|
4213
|
+
let project;
|
|
4214
|
+
try {
|
|
4215
|
+
project = previousProject ?? resolveProjectPath(explicitProject, aid, loadDefaults());
|
|
4216
|
+
}
|
|
4217
|
+
catch (error) {
|
|
4218
|
+
return menuResultFailure(error);
|
|
4219
|
+
}
|
|
4193
4220
|
if (suppliedPlan)
|
|
4194
4221
|
a.plan = { ...suppliedPlan, project };
|
|
4195
4222
|
else
|
|
@@ -4980,7 +5007,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4980
5007
|
data: { reasonCode: 'RESTART_ENTRY_MISSING', entry: monitorEntry.entry },
|
|
4981
5008
|
};
|
|
4982
5009
|
}
|
|
4983
|
-
if (
|
|
5010
|
+
if (await hasLiveRestartMonitor()
|
|
4984
5011
|
|| !createRestartRequest(pendingFile, restartInfo, isProcessRunning)) {
|
|
4985
5012
|
return { error: '已有重启请求正在处理,请等待其结果,不要重复发起。', code: 'RESTART_ALREADY_PENDING' };
|
|
4986
5013
|
}
|
|
@@ -4995,12 +5022,12 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4995
5022
|
[SESSION_ID_ENV]: '',
|
|
4996
5023
|
[AGENT_DELEGATION_TOKEN_ENV]: '',
|
|
4997
5024
|
[RESTART_REQUEST_ID_ENV]: requestId,
|
|
4998
|
-
}, () => accepted(), () =>
|
|
5025
|
+
}, () => accepted(), () => hasLiveRestartMonitor({ requestId, phase: 'accepted' }), {
|
|
4999
5026
|
requestId,
|
|
5000
5027
|
timeoutMs: 8_000,
|
|
5001
5028
|
logFilePath,
|
|
5002
5029
|
onSpawn: pid => { updateRestartRequest(pendingFile, requestId, { launcherPid: pid }); },
|
|
5003
|
-
isPendingInRegistry: () =>
|
|
5030
|
+
isPendingInRegistry: () => hasLiveRestartMonitor({ requestId }),
|
|
5004
5031
|
});
|
|
5005
5032
|
if (!restartLaunch.ok) {
|
|
5006
5033
|
if (restartLaunch.pending) {
|
|
@@ -73,23 +73,14 @@ export const MENU_REQUEST_TYPES = new Set([
|
|
|
73
73
|
'menu.action',
|
|
74
74
|
]);
|
|
75
75
|
export function parseMenuEvent(value) {
|
|
76
|
-
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
77
|
-
throw Object.assign(new Error('Menu event must be an object'), { code: 'INVALID_EVENT' });
|
|
78
76
|
const event = value;
|
|
79
|
-
if (event.type !== 'menu.event' || !['upgrade.progress', 'upgrade.result', 'template.
|
|
80
|
-
|| typeof event.requestId !== 'string' || !event.requestId.
|
|
81
|
-
|| typeof event.
|
|
82
|
-
|| !
|
|
83
|
-
|
|
84
|
-
? ['building', 'scanning', 'uploading', 'downloading', 'verifying', 'preflight', 'backup', 'applying', 'reloading', 'publishing-profile', 'rollback']
|
|
85
|
-
: ['upgrade-check', 'downloading', 'tarball-check', 'preflight', 'restart']).includes(String(event.phase))
|
|
86
|
-
|| typeof event.status !== String.name.toLowerCase() || typeof event.message !== String.name.toLowerCase()) {
|
|
77
|
+
if (!event || event.type !== 'menu.event' || !['upgrade.progress', 'upgrade.result', 'template.job'].includes(event.event)
|
|
78
|
+
|| typeof event.requestId !== 'string' || !event.requestId || !/^job_[a-f0-9-]{36}$/.test(event.jobId)
|
|
79
|
+
|| !Number.isSafeInteger(event.seq) || event.seq < 1 || typeof event.phase !== 'string'
|
|
80
|
+
|| !(event.event === 'template.job' ? ['queued', 'running', 'paused', 'failed', 'cancelling', 'cancelled', 'succeeded']
|
|
81
|
+
: ['running', 'succeeded', 'failed']).includes(event.status)) {
|
|
87
82
|
throw Object.assign(new Error('Invalid Menu event'), { code: 'INVALID_EVENT' });
|
|
88
83
|
}
|
|
89
|
-
if (String(event.event).startsWith('template.') && ((event.event === 'template.progress' && event.status !== 'running')
|
|
90
|
-
|| event.event === 'template.result' && !['succeeded', 'failed'].includes(String(event.status)))) {
|
|
91
|
-
throw Object.assign(new Error('Invalid template event status'), { code: 'INVALID_EVENT' });
|
|
92
|
-
}
|
|
93
84
|
return value;
|
|
94
85
|
}
|
|
95
86
|
export function buildMenuClientProtectedHeaders(input) {
|
|
@@ -149,10 +140,10 @@ export function evaluateMenuClientCompatibility(input) {
|
|
|
149
140
|
const headers = parseMenuClientProtectedHeaders(input.protectedHeaders);
|
|
150
141
|
const clientName = headers.client_name ?? 'evol';
|
|
151
142
|
if (clientName === 'ec-menu-client') {
|
|
152
|
-
if (!
|
|
143
|
+
if (!parseStableSemver(headers.client_version)) {
|
|
153
144
|
return {
|
|
154
145
|
code: 'INVALID_CLIENT',
|
|
155
|
-
message: 'ec-menu-client requires
|
|
146
|
+
message: 'ec-menu-client requires a stable X.Y.Z client_version',
|
|
156
147
|
};
|
|
157
148
|
}
|
|
158
149
|
return null;
|
|
@@ -213,6 +204,7 @@ export const MENU_NAME_COMMANDS = Object.freeze({
|
|
|
213
204
|
'agent-data-root': '/agent-data-root',
|
|
214
205
|
'relation-data-root': '/relation-data-root',
|
|
215
206
|
'team-workspace': '/team-workspace',
|
|
207
|
+
'template': '/template',
|
|
216
208
|
'agent-storage-root': '/agent-storage-root',
|
|
217
209
|
storage: '/storage',
|
|
218
210
|
gateway: '/gateway',
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
import fs from 'fs';
|
|
14
14
|
import path from 'path';
|
|
15
15
|
import { spawnSync } from 'child_process';
|
|
16
|
-
import { agentDir, getPackageRoot, resolveRoot } from '../../paths.js';
|
|
16
|
+
import { agentDir, getPackageRoot, isDevMode, resolveRoot } from '../../paths.js';
|
|
17
|
+
import { isShippedPath, readVerifiedText } from '../file-integrity/read.js';
|
|
17
18
|
import { resolveAllSkillStates } from '../skill/switch-resolver.js';
|
|
18
19
|
import { readSkillDescription } from '../skill/index-generator.js';
|
|
19
20
|
import { evaluateWhen, loadManifest, resolvePathWithDiag, } from '../../eck/manifest-engine.js';
|
|
@@ -394,7 +395,10 @@ export async function handleSkillSlash(ctx) {
|
|
|
394
395
|
const skillMd = path.join(skill.skillDir, 'SKILL.md');
|
|
395
396
|
if (!fs.existsSync(skillMd))
|
|
396
397
|
return error(`SKILL.md 不存在: ${skillMd}`);
|
|
397
|
-
|
|
398
|
+
const checked = readVerifiedText(skillMd, { verify: isShippedPath(skillMd) && !isDevMode(), tag: 'skill' });
|
|
399
|
+
if (!checked)
|
|
400
|
+
return error(`SKILL.md 完整性校验失败,已拒绝加载: ${skillMd}`);
|
|
401
|
+
let content = checked.text;
|
|
398
402
|
if (!withFrontmatter) {
|
|
399
403
|
// 去掉 frontmatter(--- ... --- 块)
|
|
400
404
|
content = content.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n/, '');
|
|
@@ -38,7 +38,7 @@ import { normalizePermissionMode as normalizePermissionModeContract, PUBLIC_PERM
|
|
|
38
38
|
import { isManagementRole } from '../../config/builtin-roles.js';
|
|
39
39
|
import { isSystemControlChannel } from '../system-channels.js';
|
|
40
40
|
import { launchMonitorAndConfirm, resolveMonitorLaunch, cleanupMonitorStage, isProcessRunning } from '../../utils/cross-platform.js';
|
|
41
|
-
import {
|
|
41
|
+
import { hasLiveRestartMonitor } from '../../utils/instance-registry.js';
|
|
42
42
|
import { guardIdleCommand, guardGroupSlashCommand, guardKnownCommand, guardRoleCommand, guardThreadCommand, isRecognizedSlashCommand, normalizeSlashContent, parseFullAccessCommand, probeSessionActivity, } from './slash-gate.js';
|
|
43
43
|
import { MAX_AUN_ATTACHMENT_SIZE } from '../../aun/msg/upload.js';
|
|
44
44
|
import { DEFAULT_SESSION_LOOP_SECONDS, MAX_SESSION_LOOP_PROMPT_LENGTH, MAX_SESSION_LOOP_SECONDS, MIN_SESSION_LOOP_SECONDS, refreshSessionLoopTarget, resolveCurrentSessionLoopTarget, resolveSessionLoopTarget, sessionLoopPayload, validateIdleSeconds, writeSessionLoopConfig, } from '../session/session-idle-monitor.js';
|
|
@@ -3256,19 +3256,17 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3256
3256
|
const controlDir = daemonControlDir();
|
|
3257
3257
|
fs.mkdirSync(controlDir, { recursive: true });
|
|
3258
3258
|
const pendingFile = path.join(controlDir, 'restart-pending.json');
|
|
3259
|
-
if (
|
|
3259
|
+
if (await hasLiveRestartMonitor()
|
|
3260
3260
|
|| !createRestartRequest(pendingFile, restartInfo, isProcessRunning)) {
|
|
3261
3261
|
if (monitorEntry.stageDir)
|
|
3262
3262
|
cleanupMonitorStage(monitorEntry.stageDir);
|
|
3263
3263
|
return { code: 'RESTART_PENDING_CONFIRMATION', reason: '已有重启请求正在处理', requestId: restartInfo.requestId };
|
|
3264
3264
|
}
|
|
3265
|
-
const confirmation = await launchMonitorAndConfirm([...monitorEntry.args, 'restart-monitor', autoUpgrade ? '--apply-package-upgrades' : '--skip-package-upgrades'], { EVOLCORE_HOME: resolvePaths().root, ...monitorEntry.env, [RESTART_REQUEST_ID_ENV]: restartInfo.requestId }, pid =>
|
|
3266
|
-
&& m.record.requestId === restartInfo.requestId && m.record.phase === 'accepted'), pid => scanInstances().restartMonitors.some(m => m.alive && m.record.pid !== pid
|
|
3267
|
-
&& m.record.requestId === restartInfo.requestId && m.record.phase === 'accepted'), {
|
|
3265
|
+
const confirmation = await launchMonitorAndConfirm([...monitorEntry.args, 'restart-monitor', autoUpgrade ? '--apply-package-upgrades' : '--skip-package-upgrades'], { EVOLCORE_HOME: resolvePaths().root, ...monitorEntry.env, [RESTART_REQUEST_ID_ENV]: restartInfo.requestId }, pid => hasLiveRestartMonitor({ pid, requestId: restartInfo.requestId, phase: 'accepted' }), pid => hasLiveRestartMonitor({ excludePid: pid, requestId: restartInfo.requestId, phase: 'accepted' }), {
|
|
3268
3266
|
requestId: restartInfo.requestId,
|
|
3269
3267
|
logFilePath: path.join(resolvePaths().logs, `restart-launch-${restartInfo.requestId}.log`),
|
|
3270
3268
|
onSpawn: pid => { updateRestartRequest(pendingFile, restartInfo.requestId, { launcherPid: pid }); },
|
|
3271
|
-
isPendingInRegistry: () =>
|
|
3269
|
+
isPendingInRegistry: () => hasLiveRestartMonitor({ requestId: restartInfo.requestId }),
|
|
3272
3270
|
});
|
|
3273
3271
|
if (!confirmation.ok) {
|
|
3274
3272
|
if (confirmation.pending) {
|
|
@@ -6,8 +6,7 @@ import { isValidAid } from '../../aun/aid/validation.js';
|
|
|
6
6
|
import { teamWorkspaceStore } from './team-workspace-store.js';
|
|
7
7
|
import { ownerResolver } from '../ownership/owner-resolver.js';
|
|
8
8
|
import { ConfigTarget, read } from '../../config/config-manager.js';
|
|
9
|
-
import { teamWorkspaceManagementStore, readWorkspaceMarker, workspaceMarkerPath, } from './team-workspace-management-store.js';
|
|
10
|
-
import { teamWorkspaceJobStore } from './team-workspace-job-store.js';
|
|
9
|
+
import { teamWorkspaceManagementStore, teamWorkspaceJobStore, readWorkspaceMarker, workspaceMarkerPath, } from './team-workspace-management-store.js';
|
|
11
10
|
export class TeamWorkspaceBootstrapError extends Error {
|
|
12
11
|
code;
|
|
13
12
|
retryable;
|