evolcore 0.0.42-test.0 → 0.0.43-test.0
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 +31 -2
- package/bin/ec-safe-output.js +4 -1
- package/dist/ability/application-service.js +882 -0
- package/dist/ability/authorization.js +70 -0
- package/dist/ability/command-contract.js +105 -0
- package/dist/ability/daemon.js +137 -0
- package/dist/ability/development.js +450 -0
- package/dist/ability/environment.js +75 -0
- package/dist/ability/interop-v1.js +547 -0
- package/dist/ability/management.js +79 -0
- package/dist/ability/package.js +264 -0
- package/dist/ability/provider.js +73 -0
- package/dist/ability/publication.js +107 -0
- package/dist/ability/resources.js +106 -0
- package/dist/ability/runtime.js +212 -0
- package/dist/ability/secrets.js +47 -0
- package/dist/ability/store.js +112 -0
- package/dist/ability/toolchain.js +69 -0
- package/dist/ability/types.js +14 -0
- package/dist/ability/versions.js +32 -0
- package/dist/agents/baseagent.js +2 -2
- package/dist/agents/claude-runner.js +4 -0
- package/dist/agents/codex-runner.js +81 -17
- package/dist/agents/ecagent-plugin-lazy.js +41 -0
- package/dist/agents/ecagent-runner.js +18 -11
- package/dist/aun/ability-device-routing.js +12 -1
- package/dist/aun/aid/agentmd.js +2 -2
- package/dist/aun/aid/identity.js +45 -0
- package/dist/aun/aid/index.js +1 -0
- package/dist/aun/aid/managed-operation.js +73 -2
- package/dist/channels/aun.js +64 -18
- package/dist/channels/builtin-plugins.js +14 -0
- package/dist/channels/dingtalk.js +78 -26
- package/dist/channels/feishu.js +89 -14
- package/dist/channels/qqbot.js +84 -19
- package/dist/channels/wechat.js +77 -19
- package/dist/channels/wecom.js +67 -22
- package/dist/cli/ability-command.js +92 -0
- package/dist/cli/aun-commands.js +124 -85
- package/dist/cli/daemon-commands.js +37 -85
- package/dist/cli/index.js +14 -0
- package/dist/cli/init.js +11 -13
- package/dist/cli/managed-command-guard.js +6 -0
- package/dist/cli/model.js +101 -104
- package/dist/cli/provider-command.js +6 -4
- package/dist/cli/restart-monitor.js +52 -11
- package/dist/cli/upgrade-command.js +102 -0
- package/dist/cli/version.js +1 -1
- package/dist/config/access-policy.js +4 -2
- package/dist/config/builtin-roles.js +1 -0
- package/dist/config/config-field-policy.js +4 -0
- package/dist/config/config-manager.js +7 -0
- package/dist/config/provider-ipc-service.js +10 -0
- package/dist/config/providers-config.js +12 -3
- package/dist/config/providers-management.js +45 -9
- package/dist/config/schema-migration.js +40 -22
- package/dist/contracts/ecweb-service-protocol.js +2 -1
- package/dist/core/auth/agent-delegation.js +21 -5
- package/dist/core/auth/auth-gateway.js +31 -9
- package/dist/core/auth/authorization-audit.js +52 -4
- package/dist/core/auth/delegation-authorization.js +140 -4
- package/dist/core/auth/operation-authorizer.js +114 -13
- package/dist/core/auth/operation-catalog.js +118 -4
- package/dist/core/baseagent-loader.js +14 -1
- package/dist/core/channel-loader.js +47 -9
- package/dist/core/channel-runtime.js +1 -1
- package/dist/core/command/agent-storage-menu.js +1 -1
- package/dist/core/command/cli-intent-parser.js +26 -13
- package/dist/core/command/command-handler.js +232 -76
- package/dist/core/command/connect-menu.js +10 -4
- package/dist/core/command/daemon-diagnostics.js +3 -3
- package/dist/core/command/data-root-resolver.js +2 -3
- package/dist/core/command/menu-catalog.js +10 -3
- package/dist/core/command/menu-handler.js +321 -46
- package/dist/core/command/menu-protocol.js +53 -7
- package/dist/core/command/pa-workspace-calendar.js +1 -2
- package/dist/core/command/pa-workspace-items.js +486 -0
- package/dist/core/command/pa-workspace-store.js +10 -1
- package/dist/core/command/slash-gate.js +2 -2
- package/dist/core/command/slash-handler.js +67 -25
- package/dist/core/contact-bind-registry.js +27 -0
- package/dist/core/daemon-control.js +3 -3
- package/dist/core/daemon-lifecycle.js +2 -1
- package/dist/core/event-bus.js +9 -2
- package/dist/core/handoff/ipc-registration.js +1 -0
- package/dist/core/host-snapshot.js +1 -2
- package/dist/core/initialization/service.js +32 -11
- package/dist/core/ipc-registration.js +18 -5
- package/dist/core/memory/consolidation-context.js +2 -2
- package/dist/core/message/aun-request-registry.js +99 -18
- package/dist/core/message/im-renderer.js +16 -11
- package/dist/core/message/message-admission.js +25 -20
- package/dist/core/message/message-bridge.js +21 -47
- package/dist/core/message/message-queue.js +3 -0
- package/dist/core/message/response-engine.js +7 -5
- package/dist/core/model/catalog-service.js +1 -1
- package/dist/core/permission/ec-command-parser.js +41 -9
- package/dist/core/permission/permission-result.js +1 -0
- package/dist/core/permission/protected-paths.js +25 -14
- package/dist/core/permission/tool-policy.js +108 -107
- package/dist/core/plugin-lifecycle.js +133 -0
- package/dist/core/runner-reload-transaction.js +4 -1
- package/dist/core/system-session/memory.js +16 -3
- package/dist/core/task/task-activity-store.js +50 -0
- package/dist/core/task/task-image-resources.js +140 -0
- package/dist/core/thread/ipc-operation.js +1 -1
- package/dist/core/thread/thread-service.js +0 -1
- package/dist/directory/canonical-digest.js +5 -3
- package/dist/directory/owner-directory-admission.js +22 -2
- package/dist/directory/owner-directory-cache.js +394 -60
- package/dist/directory/owner-directory-markdown.js +29 -2
- package/dist/directory/owner-directory-scope.js +35 -16
- package/dist/ecweb/basic-settings-service.js +4 -1
- package/dist/ecweb/pairing.js +41 -0
- package/dist/ecweb/providers-service.js +8 -1
- package/dist/{utils/ecweb-utils.js → ecweb/runtime/launch.js} +3 -27
- package/dist/ecweb/runtime/lifecycle.js +184 -0
- package/dist/{utils/ecweb-supervisor.js → ecweb/runtime/supervisor.js} +32 -27
- package/dist/index.js +34 -25
- package/dist/ipc.js +124 -7
- package/dist/response-system/engines/v1/proactive-flow.js +1 -1
- package/dist/trigger/authorization.js +2 -2
- package/dist/utils/atomic-write.js +24 -0
- package/dist/utils/avatar-upload.js +3 -1
- package/dist/utils/cross-platform.js +31 -2
- package/dist/utils/host-info.js +36 -0
- package/dist/utils/instance-registry.js +38 -11
- package/dist/utils/logger.js +9 -0
- package/dist/utils/{process-tree-stats.js → process-tree.js} +29 -0
- package/dist/utils/tool-summary.js +9 -1
- package/dist/utils/upgrade-jobs.js +96 -15
- package/dist/utils/windows-autostart.js +1 -1
- package/ecagent/README.md +19 -0
- package/ecagent/dist/harness/agent-harness.js +9 -0
- package/ecagent/dist/harness/env/nodejs.js +71 -11
- package/ecagent/dist/harness/env/windows-shell.d.ts +7 -0
- package/ecagent/dist/harness/env/windows-shell.js +132 -0
- package/kits/docs/aun/ABILITY_CALLING.md +38 -9
- package/kits/docs/evolcore/INDEX.md +5 -1
- package/kits/docs/evolcore/ability.md +181 -0
- package/kits/docs/evolcore/aid.md +20 -0
- package/kits/docs/evolcore/config.md +10 -6
- package/kits/docs/evolcore/menu-protocol.md +40 -1
- package/kits/docs/evolcore/provider.md +2 -2
- package/kits/docs/evolcore/tool-authorization.md +270 -0
- package/kits/runtime/ability-job.ps1 +41 -0
- package/kits/runtime/ability-runner.mjs +67 -0
- package/kits/runtime/ability-secret.ps1 +59 -0
- package/kits/runtime/ability-templates/go/main.go +59 -0
- package/kits/runtime/ability-templates/java/Json.java +67 -0
- package/kits/runtime/ability-templates/java/Runner.java +42 -0
- package/kits/runtime/ability-templates/python/runner.py +48 -0
- package/kits/runtime/ability-templates/rust/json.rs +87 -0
- package/kits/runtime/ability-templates/rust/runner.rs +35 -0
- package/kits/schemas/_meta.json +12 -1
- package/kits/schemas/ability-plugin.schema.1.json +107 -0
- package/kits/schemas/ability-project.schema.1.json +31 -0
- package/kits/schemas/agent-config.schema.16.json +20 -0
- package/kits/schemas/agent-config.schema.17.json +20 -0
- package/kits/schemas/agent-config.schema.18.json +917 -0
- package/kits/skills/.switches.json +4 -0
- package/kits/skills/aid-ability/SKILL.md +5 -4
- package/kits/skills/ec-ability/SKILL.md +67 -0
- package/kits/skills/ec-ability/references/contract-checklist.md +37 -0
- package/kits/skills/ec-ability/references/development.md +104 -0
- package/kits/skills/ec-ability/references/management.md +117 -0
- package/kits/skills/ec-ability/references/recovery.md +27 -0
- package/kits/skills/ec-ability/references/runtime-protocol.md +109 -0
- package/kits/skills/ec-ability/references/workflows.md +15 -0
- package/kits/skills/ec-service-proxy/SKILL.md +12 -0
- package/kits/skills/personal-assistant/SKILL.md +240 -6
- package/kits/skills/personal-assistant/references/02-bootstrap.md +78 -4
- package/kits/skills/personal-assistant/scripts/clean.mjs +397 -0
- package/kits/skills/personal-assistant/scripts/init.mjs +113 -25
- package/kits/skills/personal-assistant/scripts/lock.mjs +189 -0
- package/kits/skills/personal-assistant/scripts/migrate.mjs +35 -10
- package/kits/skills/personal-assistant/scripts/verify.mjs +2 -1
- package/kits/skills/personal-assistant/templates/persona-section.md +54 -0
- package/kits/skills/personal-assistant/triggers/ingest-daily.json +1 -1
- package/kits/templates/memory-consolidation/notes.md +1 -1
- package/kits/templates/system-fragments/channel.md +2 -1
- package/kits/templates/system-fragments/commands.md +1 -0
- package/package.json +4 -2
- package/dist/core/command/data-root-error.js +0 -10
- package/dist/utils/machine-info.js +0 -46
- package/dist/utils/process-tree-worker.js +0 -31
- package/dist/utils/windows-output.js +0 -36
|
@@ -7,7 +7,7 @@ import { formatPeerKey } from '../relation/peer-identity.js';
|
|
|
7
7
|
import { modelMatches, getCatalog, getBaseagentCatalog, resolveCatalogModel, assertCatalogSelectable, CONFIGURABLE_EFFORTS, configurableEfforts } from '../model/model-catalog.js';
|
|
8
8
|
import { constrainResolvedModelForRole, filterModelsForRole, validateModelSelectionForRole } from '../model/model-permission.js';
|
|
9
9
|
import { hasModelSwitcher } from '../../agents/runner-types.js';
|
|
10
|
-
import { resolvePaths, getPackageRoot, daemonControlDir } from '../../paths.js';
|
|
10
|
+
import { resolvePaths, getPackageRoot, daemonControlDir, resolveRoot } from '../../paths.js';
|
|
11
11
|
import { buildEnvelope, isDeliveryTarget, isDeliveryTargetForChannel, replyContextFromSession } from '../message/message-utils.js';
|
|
12
12
|
import { isMainSession, isTopicSession, sessionLocalTopicId, sessionTopicThreadId } from '../thread/topic-id.js';
|
|
13
13
|
import path from 'path';
|
|
@@ -18,13 +18,12 @@ import crypto from 'crypto';
|
|
|
18
18
|
import { CronExpressionParser } from 'cron-parser';
|
|
19
19
|
import { parseDuration } from '../../trigger/parser.js';
|
|
20
20
|
import { resolveGlobalPkg } from '../../utils/npm-ops.js';
|
|
21
|
-
import {
|
|
22
|
-
import { resolveUpgradeDistTag } from '../../utils/package-version-info.js';
|
|
23
|
-
import { readUpgradeJob, startUpgradeJob, structuredUpgradeCheck, upgradeJobView } from '../../utils/upgrade-jobs.js';
|
|
21
|
+
import { executeUpgradeAction, parseUpgradeMode } from '../../utils/upgrade-jobs.js';
|
|
24
22
|
import { launchMonitorAndConfirm, resolveCliEntry, isProcessRunning } from '../../utils/cross-platform.js';
|
|
25
23
|
import { cachedCliVersion } from '../../utils/cross-platform.js';
|
|
26
24
|
import { scanInstances } from '../../utils/instance-registry.js';
|
|
27
25
|
import { loadDefaults, loadDaemonConfig } from '../../config-store.js';
|
|
26
|
+
import { buildEcwebPairingUrl } from '../../ecweb/pairing.js';
|
|
28
27
|
import { WEB_PACKAGE_NAME, RESTART_REQUEST_ID_ENV, RUNTIME_HOME_ENV, SESSION_ID_ENV } from '../../product.js';
|
|
29
28
|
import { read as cfgRead, resolveEffective, resolveEffectiveFieldWithSource, routeFieldPath, write as cfgWrite, ConfigTarget, } from '../../config/config-manager.js';
|
|
30
29
|
import { agentCreateCapabilities, execAgentAction, execAgentQuery, execAgentOptions, execAidAvatar, resolveProjectPath } from './agent-control.js';
|
|
@@ -64,12 +63,14 @@ import { groupMenuAuthorizationArgs, groupMenuIntent, handleGroupMenu, } from '.
|
|
|
64
63
|
import { getMenuCatalog, execMenuValueBatch, resolveExplicitMenuExecutionContext, resolveMenuCatalogContext, validateMenuCatalogArgs, validateMenuValueBatchArgs } from './menu-catalog.js';
|
|
65
64
|
import { probeSessionActivity } from './slash-gate.js';
|
|
66
65
|
import { dataRootFailure, dataRootResolver } from './data-root-resolver.js';
|
|
67
|
-
import { isPaHiddenPath, paWorkspaceStore, readPaWorkspaceNavigation } from './pa-workspace-store.js';
|
|
66
|
+
import { DataRootError, isPaHiddenPath, paWorkspaceStore, readPaWorkspaceNavigation } from './pa-workspace-store.js';
|
|
68
67
|
import { queryPaWorkspaceCalendar } from './pa-workspace-calendar.js';
|
|
68
|
+
import { paWorkspaceItemsIndex, validatePaWorkspaceItemsArgs } from './pa-workspace-items.js';
|
|
69
69
|
import { agentStorageMenuService, isAgentStorageMenuRequest } from './agent-storage-menu.js';
|
|
70
70
|
import { MAX_AUN_ATTACHMENT_SIZE } from '../../aun/msg/upload.js';
|
|
71
71
|
import { normalizeTopicLabel, normalizeTopicStatus, resolveTopicArchiveFilter, } from '../session/session-mapper.js';
|
|
72
72
|
import { notifyThreadRename } from '../thread/thread-operation.js';
|
|
73
|
+
import { isAgentScopePath, isHClassPath, isLClassPath } from '../permission/protected-paths.js';
|
|
73
74
|
/**
|
|
74
75
|
* 获取 baseagent CLI 的版本号(claude/gemini/codex)。
|
|
75
76
|
* 失败返回 null(命令不存在或执行失败)。
|
|
@@ -301,6 +302,111 @@ function resolveMenuFilePath(input, projectPath, role, expectType) {
|
|
|
301
302
|
}
|
|
302
303
|
return { realPath, projectPath: realProjectPath, stat };
|
|
303
304
|
}
|
|
305
|
+
function parseProjectRelativePath(input) {
|
|
306
|
+
if (typeof input !== 'string' || !input.trim()) {
|
|
307
|
+
return { error: '缺少 path 参数', code: 'MISSING_VALUE' };
|
|
308
|
+
}
|
|
309
|
+
const raw = input.trim();
|
|
310
|
+
if (raw.includes('\0') || path.isAbsolute(raw) || path.win32.isAbsolute(raw)) {
|
|
311
|
+
return { error: '文件操作只接受项目内相对路径', code: 'NO_PERMISSION' };
|
|
312
|
+
}
|
|
313
|
+
const segments = raw.replace(/\\/g, '/').split('/');
|
|
314
|
+
if (segments.includes('..'))
|
|
315
|
+
return { error: '不支持 .. 路径穿越', code: 'NO_PERMISSION' };
|
|
316
|
+
const normalized = segments.filter(segment => segment && segment !== '.');
|
|
317
|
+
if (normalized.length === 0)
|
|
318
|
+
return { error: '不允许操作项目根目录', code: 'NO_PERMISSION' };
|
|
319
|
+
return normalized;
|
|
320
|
+
}
|
|
321
|
+
function projectMutationPathError(error, fallback) {
|
|
322
|
+
const code = error?.code;
|
|
323
|
+
if (code === 'ENOENT' || code === 'ENOTDIR')
|
|
324
|
+
return { error: '文件或目录不存在', code: 'NOT_FOUND' };
|
|
325
|
+
if (code === 'EACCES' || code === 'EPERM')
|
|
326
|
+
return { error: '无权限访问文件或目录', code: 'NO_PERMISSION' };
|
|
327
|
+
return { error: `${fallback}: ${error instanceof Error ? error.message : String(error)}`, code: 'EXEC_FAILED' };
|
|
328
|
+
}
|
|
329
|
+
function resolveProjectMutationPath(input, projectPath) {
|
|
330
|
+
if (!projectPath)
|
|
331
|
+
return { error: '无法解析当前 agent projectPath', code: 'NO_PROJECT' };
|
|
332
|
+
const parsed = parseProjectRelativePath(input);
|
|
333
|
+
if (!Array.isArray(parsed))
|
|
334
|
+
return parsed;
|
|
335
|
+
let realProjectPath;
|
|
336
|
+
try {
|
|
337
|
+
realProjectPath = fs.realpathSync(projectPath);
|
|
338
|
+
}
|
|
339
|
+
catch {
|
|
340
|
+
return { error: '无法解析当前 agent projectPath', code: 'NO_PROJECT' };
|
|
341
|
+
}
|
|
342
|
+
let current = realProjectPath;
|
|
343
|
+
for (let index = 0; index < parsed.length; index++) {
|
|
344
|
+
current = path.join(current, parsed[index]);
|
|
345
|
+
let stat;
|
|
346
|
+
try {
|
|
347
|
+
stat = fs.lstatSync(current);
|
|
348
|
+
}
|
|
349
|
+
catch (error) {
|
|
350
|
+
return projectMutationPathError(error, '读取路径失败');
|
|
351
|
+
}
|
|
352
|
+
if (stat.isSymbolicLink())
|
|
353
|
+
return { error: '文件操作不支持符号链接', code: 'NO_PERMISSION' };
|
|
354
|
+
if (index < parsed.length - 1 && !stat.isDirectory()) {
|
|
355
|
+
return { error: '路径中的父项不是目录', code: 'NOT_A_DIRECTORY' };
|
|
356
|
+
}
|
|
357
|
+
let realPath;
|
|
358
|
+
try {
|
|
359
|
+
realPath = fs.realpathSync(current);
|
|
360
|
+
}
|
|
361
|
+
catch (error) {
|
|
362
|
+
return projectMutationPathError(error, '解析路径失败');
|
|
363
|
+
}
|
|
364
|
+
if (!isInProject(realPath, realProjectPath)) {
|
|
365
|
+
return { error: '文件操作路径必须位于当前项目内', code: 'NO_PERMISSION' };
|
|
366
|
+
}
|
|
367
|
+
if (index === parsed.length - 1) {
|
|
368
|
+
return { projectPath: realProjectPath, absolutePath: realPath, relativePath: parsed.join('/'), stat };
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return { error: '无效路径', code: 'INVALID_ARGUMENT' };
|
|
372
|
+
}
|
|
373
|
+
function isProtectedProjectMutationPath(target, selfAid) {
|
|
374
|
+
const options = { root: resolveRoot(), selfAid };
|
|
375
|
+
return isHClassPath(target, options) || isLClassPath(target, options) || isAgentScopePath(target, options);
|
|
376
|
+
}
|
|
377
|
+
function resolveProjectMutationDestination(input, projectPath, selfAid) {
|
|
378
|
+
const parsed = parseProjectRelativePath(input);
|
|
379
|
+
if (!Array.isArray(parsed))
|
|
380
|
+
return parsed;
|
|
381
|
+
const basename = parsed[parsed.length - 1];
|
|
382
|
+
const parentRelative = parsed.slice(0, -1).join('/') || '.';
|
|
383
|
+
let parentPath = projectPath;
|
|
384
|
+
if (parsed.length > 1) {
|
|
385
|
+
const parent = resolveProjectMutationPath(parentRelative, projectPath);
|
|
386
|
+
if ('error' in parent)
|
|
387
|
+
return parent;
|
|
388
|
+
if (!parent.stat?.isDirectory())
|
|
389
|
+
return { error: '目标父路径不是目录', code: 'NOT_A_DIRECTORY' };
|
|
390
|
+
parentPath = parent.absolutePath;
|
|
391
|
+
}
|
|
392
|
+
const absolutePath = path.join(parentPath, basename);
|
|
393
|
+
try {
|
|
394
|
+
fs.lstatSync(absolutePath);
|
|
395
|
+
return { error: '目标路径已存在', code: 'CONFLICT' };
|
|
396
|
+
}
|
|
397
|
+
catch (error) {
|
|
398
|
+
if (error?.code !== 'ENOENT')
|
|
399
|
+
return projectMutationPathError(error, '检查目标路径失败');
|
|
400
|
+
}
|
|
401
|
+
if (isProtectedProjectMutationPath(absolutePath, selfAid)) {
|
|
402
|
+
return { error: '不能移动到 EvolCore 受保护路径', code: 'NO_PERMISSION' };
|
|
403
|
+
}
|
|
404
|
+
return {
|
|
405
|
+
projectPath,
|
|
406
|
+
absolutePath,
|
|
407
|
+
relativePath: parsed.join('/'),
|
|
408
|
+
};
|
|
409
|
+
}
|
|
304
410
|
function parseFileListOffset(value) {
|
|
305
411
|
const n = Number(value);
|
|
306
412
|
return Number.isFinite(n) ? Math.max(0, Math.floor(n)) : 0;
|
|
@@ -382,19 +488,17 @@ function listDirectory(realPath, options) {
|
|
|
382
488
|
const entries = page.map(dirent => {
|
|
383
489
|
const full = path.join(realPath, dirent.name);
|
|
384
490
|
const info = entryInfoByName.get(dirent.name) ?? { isDirectory: false, followTarget: true };
|
|
385
|
-
// Only stat when we need size/mtime (dirent already tells us if it's a directory)
|
|
386
491
|
let size = null;
|
|
387
492
|
let mtime = 0;
|
|
388
493
|
let birthtime = 0;
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
494
|
+
try {
|
|
495
|
+
const stat = info.followTarget ? fs.statSync(full) : fs.lstatSync(full);
|
|
496
|
+
if (!info.isDirectory)
|
|
392
497
|
size = stat.size;
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
}
|
|
396
|
-
catch { }
|
|
498
|
+
mtime = stat.mtimeMs;
|
|
499
|
+
birthtime = stat.birthtimeMs;
|
|
397
500
|
}
|
|
501
|
+
catch { }
|
|
398
502
|
return {
|
|
399
503
|
name: dirent.name,
|
|
400
504
|
type: info.isDirectory ? 'directory' : 'file',
|
|
@@ -1082,14 +1186,21 @@ function buildMenuIntent(verb, cmdBase, args, action, value, fromControlChannel
|
|
|
1082
1186
|
return intent('file.list', 'filesystem', { filePath: args?.path });
|
|
1083
1187
|
if (action === 'fetch')
|
|
1084
1188
|
return intent('file.fetch', 'filesystem', { filePath: args?.path });
|
|
1189
|
+
if (action === 'move')
|
|
1190
|
+
return intent('file.move', 'filesystem', { filePath: args?.path, destination: args?.destination });
|
|
1191
|
+
if (action === 'delete')
|
|
1192
|
+
return intent('file.delete', 'filesystem', { filePath: args?.path, mtime: args?.mtime });
|
|
1085
1193
|
}
|
|
1086
1194
|
if (cmdBase === '/gateway')
|
|
1087
1195
|
return intent('gateway.write', 'process', { action });
|
|
1088
1196
|
if (cmdBase === '/system') {
|
|
1089
1197
|
if (action === 'restart')
|
|
1090
1198
|
return intent('system.restart', 'process', { action });
|
|
1091
|
-
if (action === 'upgrade')
|
|
1092
|
-
|
|
1199
|
+
if (action === 'upgrade') {
|
|
1200
|
+
const mode = args?.mode ?? 'check';
|
|
1201
|
+
return intent(mode === 'check' ? 'system.upgrade.check'
|
|
1202
|
+
: mode === 'update' ? 'system.update' : 'system.update.status', 'process', { action, mode });
|
|
1203
|
+
}
|
|
1093
1204
|
if (action === 'check')
|
|
1094
1205
|
return intent('system.status', 'process', { action });
|
|
1095
1206
|
if (action === 'paircode')
|
|
@@ -1135,6 +1246,8 @@ function buildRelationIntentArgs(params) {
|
|
|
1135
1246
|
const out = { ...(params.args ?? {}) };
|
|
1136
1247
|
if (params.selfAid && out.self === undefined)
|
|
1137
1248
|
out.self = params.selfAid;
|
|
1249
|
+
if (params.selfAid && out.targetAgentAid === undefined)
|
|
1250
|
+
out.targetAgentAid = params.selfAid;
|
|
1138
1251
|
if (params.peerKey && out.peer === undefined && out.peerKey === undefined)
|
|
1139
1252
|
out.peer = params.peerKey;
|
|
1140
1253
|
return out;
|
|
@@ -1217,6 +1330,10 @@ async function authorizeMenuIntent(params) {
|
|
|
1217
1330
|
else if (intent.scope === 'agent' && subject.selfAid && intent.args.self === undefined) {
|
|
1218
1331
|
intent.args = { ...intent.args, self: subject.selfAid };
|
|
1219
1332
|
}
|
|
1333
|
+
if (intent.scope === 'agent' || intent.scope === 'relation') {
|
|
1334
|
+
const selectedAid = typeof intent.args.aid === 'string' ? intent.args.aid : subject.selfAid;
|
|
1335
|
+
intent.args = { ...intent.args, targetAgentAid: selectedAid };
|
|
1336
|
+
}
|
|
1220
1337
|
const source = params.source ?? 'menu';
|
|
1221
1338
|
intent.source = source;
|
|
1222
1339
|
const decision = await authorizeFreshOperation({
|
|
@@ -1489,6 +1606,8 @@ export function getMenuItems(role, chatType = 'private', scope = 'agent', authSu
|
|
|
1489
1606
|
const relationArgs = operationScope === 'relation'
|
|
1490
1607
|
? buildRelationIntentArgs({ selfAid: authSubject.selfAid, peerKey: authSubject.peerKey })
|
|
1491
1608
|
: operationScope === 'agent' && authSubject.selfAid ? { self: authSubject.selfAid } : {};
|
|
1609
|
+
if (authSubject.selfAid)
|
|
1610
|
+
relationArgs.targetAgentAid = authSubject.selfAid;
|
|
1492
1611
|
return authorizeOperation({
|
|
1493
1612
|
source: 'menu',
|
|
1494
1613
|
intent: { operation, scope: operationScope, source: 'menu', args: relationArgs },
|
|
@@ -2138,7 +2257,31 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2138
2257
|
const loadedContext = await this.loadMenuContext(channel, channelId);
|
|
2139
2258
|
const evolagent = loadedContext.evolagent;
|
|
2140
2259
|
let session = loadedContext.session;
|
|
2141
|
-
|
|
2260
|
+
let groupResourceSession = false;
|
|
2261
|
+
// Resource requests arrive over P2P even when the original activity is in a
|
|
2262
|
+
// group. Resolve only from daemon-owned task metadata, then require fresh
|
|
2263
|
+
// group membership below. Never accept a client-supplied group/session path.
|
|
2264
|
+
if (cmdBase === '/task' && args?.view === 'resource') {
|
|
2265
|
+
const invalid = validateTaskActivityQueryArgs(args);
|
|
2266
|
+
if (invalid)
|
|
2267
|
+
return { error: invalid.message, code: invalid.code };
|
|
2268
|
+
const selfAid = this.getOwningAgent?.(channel)?.aid ?? evolagent?.aid ?? authSubject?.selfAid;
|
|
2269
|
+
if (!fromControlChannel && selfAid) {
|
|
2270
|
+
const meta = new TaskActivityStore(selfAid).getMeta(args.taskId);
|
|
2271
|
+
if (meta?.chatType === 'group') {
|
|
2272
|
+
const original = meta.sessionId ? await this.sessionManager.getSessionById(meta.sessionId) : undefined;
|
|
2273
|
+
if (!original || original.deletedAt || original.selfAID !== selfAid
|
|
2274
|
+
|| original.channel !== channel || original.chatType !== 'group'
|
|
2275
|
+
|| original.channelId !== meta.groupId
|
|
2276
|
+
|| (transportReplyContext?.threadId && sessionTopicThreadId(original) !== transportReplyContext.threadId)) {
|
|
2277
|
+
return { error: 'Task is not available in this session', code: 'FORBIDDEN' };
|
|
2278
|
+
}
|
|
2279
|
+
session = original;
|
|
2280
|
+
groupResourceSession = true;
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
if (transportReplyContext?.threadId && !groupResourceSession) {
|
|
2142
2285
|
try {
|
|
2143
2286
|
session = await loadMenuTopicSession(this.sessionManager, channel, channelId, transportReplyContext.threadId);
|
|
2144
2287
|
}
|
|
@@ -2202,21 +2345,39 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2202
2345
|
}
|
|
2203
2346
|
}
|
|
2204
2347
|
if (cmdBase === '/pa-workspace') {
|
|
2205
|
-
const allowed = new Set(['view', 'protocolVersion', 'context', 'from', 'to', 'timezone']);
|
|
2348
|
+
const allowed = new Set(['view', 'protocolVersion', 'context', 'from', 'to', 'timezone', 'path', 'offset', 'limit', 'indexRevision']);
|
|
2206
2349
|
const unknown = Object.keys(args ?? {}).find(key => !allowed.has(key));
|
|
2207
2350
|
if (unknown)
|
|
2208
2351
|
return { error: `pa-workspace does not accept args.${unknown}`, code: 'INVALID_ARGUMENT' };
|
|
2209
|
-
if (args
|
|
2210
|
-
return { error: 'pa-workspace requires
|
|
2352
|
+
if (!args || typeof args.view !== 'string' || !['navigation', 'calendar', 'items'].includes(args.view))
|
|
2353
|
+
return { error: 'pa-workspace requires navigation, calendar or items view', code: 'INVALID_ARGUMENT' };
|
|
2211
2354
|
if (args?.protocolVersion !== undefined && args.protocolVersion !== 1) {
|
|
2212
2355
|
return { error: 'Unsupported PA workspace protocol version', code: 'SCHEMA_VERSION_UNSUPPORTED' };
|
|
2213
2356
|
}
|
|
2214
2357
|
if (args.view !== 'calendar' && (args.from !== undefined || args.to !== undefined || args.timezone !== undefined)) {
|
|
2215
2358
|
return { error: 'from, to and timezone are only valid for calendar view', code: 'INVALID_ARGUMENT' };
|
|
2216
2359
|
}
|
|
2360
|
+
if (args.view !== 'items' && ['path', 'offset', 'limit', 'indexRevision'].some(key => args[key] !== undefined)) {
|
|
2361
|
+
return { error: 'path, offset, limit and indexRevision are only valid for items view', code: 'INVALID_ARGUMENT' };
|
|
2362
|
+
}
|
|
2217
2363
|
try {
|
|
2364
|
+
if (args.view === 'items')
|
|
2365
|
+
validatePaWorkspaceItemsArgs(args);
|
|
2218
2366
|
const root = dataRootResolver.issuePaWorkspaceRoot(subject);
|
|
2219
2367
|
const navigation = readPaWorkspaceNavigation(root.targetAid);
|
|
2368
|
+
const state = paWorkspaceStore.require(root.targetAid);
|
|
2369
|
+
if (args.view === 'items') {
|
|
2370
|
+
const items = await paWorkspaceItemsIndex.query(root.targetAid, state, args);
|
|
2371
|
+
// Building the initial index yields to other requests. Recheck owner,
|
|
2372
|
+
// binding and navigation before sending any cached private summary.
|
|
2373
|
+
dataRootResolver.issuePaWorkspaceRoot(subject);
|
|
2374
|
+
const current = paWorkspaceStore.require(root.targetAid);
|
|
2375
|
+
if (current.workspaceId !== state.workspaceId || current.ownerAid !== state.ownerAid
|
|
2376
|
+
|| current.rootPath !== state.rootPath || current.navigationRevision !== state.navigationRevision) {
|
|
2377
|
+
throw new DataRootError('WORKSPACE_CHANGED', 'PA workspace changed during query');
|
|
2378
|
+
}
|
|
2379
|
+
return { data: items };
|
|
2380
|
+
}
|
|
2220
2381
|
if (args.view === 'calendar') {
|
|
2221
2382
|
const scheduler = this.getTriggerSchedulerForChannel?.(channel);
|
|
2222
2383
|
const isAdmin = isManagementRole(identity.role)
|
|
@@ -2228,7 +2389,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2228
2389
|
return {
|
|
2229
2390
|
data: {
|
|
2230
2391
|
...queryPaWorkspaceCalendar({
|
|
2231
|
-
state
|
|
2392
|
+
state,
|
|
2232
2393
|
navigation,
|
|
2233
2394
|
scheduler: scheduler && visibleDefinitions
|
|
2234
2395
|
? {
|
|
@@ -2248,6 +2409,8 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2248
2409
|
},
|
|
2249
2410
|
};
|
|
2250
2411
|
}
|
|
2412
|
+
// Start preparing cards while the user is still in the conversation.
|
|
2413
|
+
paWorkspaceItemsIndex.warm(root.targetAid, state);
|
|
2251
2414
|
return {
|
|
2252
2415
|
data: {
|
|
2253
2416
|
protocol: 'evol.pa-workspace',
|
|
@@ -2256,6 +2419,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2256
2419
|
navigationRevision: navigation.navigationRevision,
|
|
2257
2420
|
title: navigation.title,
|
|
2258
2421
|
entries: navigation.entries,
|
|
2422
|
+
itemIndex: { version: 1, maxPageSize: 20 },
|
|
2259
2423
|
fileRoot: {
|
|
2260
2424
|
rootId: root.rootId,
|
|
2261
2425
|
expiresAt: root.expiresAt,
|
|
@@ -2366,7 +2530,9 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2366
2530
|
}
|
|
2367
2531
|
return { data: args.view === 'activities'
|
|
2368
2532
|
? store.readList(args.taskId, args.offset ?? 0, args.limit ?? 50)
|
|
2369
|
-
:
|
|
2533
|
+
: args.view === 'resource'
|
|
2534
|
+
? store.readResource(args.taskId, args.activityId, args.resourceId, args.offset ?? 0)
|
|
2535
|
+
: store.readDetail(args.taskId, args.activityId) };
|
|
2370
2536
|
}
|
|
2371
2537
|
catch (error) {
|
|
2372
2538
|
if (error?.code === 'INVALID_CONTEXT') {
|
|
@@ -2929,7 +3095,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2929
3095
|
if (cmdBase === '/system') {
|
|
2930
3096
|
const view = args?.view ?? 'status';
|
|
2931
3097
|
if (view === 'version') {
|
|
2932
|
-
const { readVersionInfo } = await import('../../utils/
|
|
3098
|
+
const { readVersionInfo } = await import('../../utils/host-info.js');
|
|
2933
3099
|
const versions = readVersionInfo();
|
|
2934
3100
|
const data = {
|
|
2935
3101
|
version: versions.evolcore,
|
|
@@ -2961,7 +3127,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2961
3127
|
}
|
|
2962
3128
|
if (view !== 'status')
|
|
2963
3129
|
return { error: `Unsupported system view: ${String(view)}`, code: 'NOT_SUPPORTED' };
|
|
2964
|
-
const { readVersionInfo } = await import('../../utils/
|
|
3130
|
+
const { readVersionInfo } = await import('../../utils/host-info.js');
|
|
2965
3131
|
const versions = readVersionInfo();
|
|
2966
3132
|
const data = {
|
|
2967
3133
|
aid: loadDaemonConfig().aid ?? null,
|
|
@@ -3600,6 +3766,10 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
3600
3766
|
return { error: 'File search must be addressed to the current Agent AID', code: 'NOT_SUPPORTED' };
|
|
3601
3767
|
}
|
|
3602
3768
|
}
|
|
3769
|
+
if (cmdBase === '/file' && (action === 'move' || action === 'delete')
|
|
3770
|
+
&& (fromControlChannel || authSubject?.fromControlChannel)) {
|
|
3771
|
+
return { error: 'File mutations must be addressed to the current Agent AID', code: 'NOT_SUPPORTED' };
|
|
3772
|
+
}
|
|
3603
3773
|
const gated = gateControlScope.call(this, { cmdBase, action, args, channel, fromControlChannel });
|
|
3604
3774
|
if (gated)
|
|
3605
3775
|
return gated;
|
|
@@ -4672,7 +4842,10 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4672
4842
|
// Keep Menu pairing on the same daemon-owned store as /pair, ECWeb, and
|
|
4673
4843
|
// the local IPC endpoint. Each successful redemption consumes the code.
|
|
4674
4844
|
const pair = remoteAccessService.getPairingCode(subject.actorId, Date.now(), source === 'ecweb' ? 'ecweb-local' : 'menu');
|
|
4675
|
-
|
|
4845
|
+
// `url` is the one-click ECWeb login link (code in the fragment); null when
|
|
4846
|
+
// ECWeb is disabled or the daemon has no control AID. Additive field.
|
|
4847
|
+
const url = buildEcwebPairingUrl(loadDaemonConfig(), pair.code);
|
|
4848
|
+
return { data: { code: pair.code, expiresAt: pair.expiresAt, url } };
|
|
4676
4849
|
}
|
|
4677
4850
|
if (action === 'check') {
|
|
4678
4851
|
const r = await this.delegateAsAction(action, '/check', channel, channelId, userId, { overrideIdentity, authSubject: subject, threadId: transportReplyContext?.threadId, chatType: transportReplyContext?.delivery?.chatType, replyContext: transportReplyContext });
|
|
@@ -4680,28 +4853,19 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4680
4853
|
return r;
|
|
4681
4854
|
}
|
|
4682
4855
|
if (action === 'upgrade') {
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
if (typeof args?.jobId !== 'string' || !/^job_[a-f0-9-]{36}$/.test(args.jobId))
|
|
4690
|
-
return { error: '缺少或无效的 jobId', code: 'INVALID_ARGUMENT' };
|
|
4691
|
-
const job = readUpgradeJob(args.jobId);
|
|
4692
|
-
const scope = JSON.stringify([source, channel, channelId, subject.actorId, transportReplyContext?.toDeviceId, transportReplyContext?.threadId]);
|
|
4693
|
-
const expectedKey = job ? crypto.createHash('sha256').update(JSON.stringify([scope, job.requestId])).digest('hex') : undefined;
|
|
4694
|
-
return job && job.requestKey === expectedKey
|
|
4695
|
-
? { data: upgradeJobView(job) }
|
|
4696
|
-
: { error: '更新任务不存在或不可访问', code: 'NOT_FOUND' };
|
|
4856
|
+
let mode;
|
|
4857
|
+
try {
|
|
4858
|
+
mode = parseUpgradeMode(args);
|
|
4859
|
+
}
|
|
4860
|
+
catch (error) {
|
|
4861
|
+
return { error: error instanceof Error ? error.message : String(error), code: 'INVALID_ARGUMENT' };
|
|
4697
4862
|
}
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4863
|
+
try {
|
|
4864
|
+
return { data: await executeUpgradeAction(mode, requestId || crypto.randomUUID(), 'system-upgrade-singleton') };
|
|
4865
|
+
}
|
|
4866
|
+
catch (error) {
|
|
4867
|
+
return { error: error instanceof Error ? error.message : String(error), code: error.code ?? 'INTERNAL' };
|
|
4701
4868
|
}
|
|
4702
|
-
const distTag = resolveUpgradeDistTag();
|
|
4703
|
-
const results = await refreshManagedPackageVersions(VERSION_INFO_PACKAGES, { source: 'menu-upgrade', distTag, includeUninstalled: true });
|
|
4704
|
-
return { data: structuredUpgradeCheck(results, distTag) };
|
|
4705
4869
|
}
|
|
4706
4870
|
return { error: `不支持的 system action: ${action}`, code: 'NOT_SUPPORTED' };
|
|
4707
4871
|
}
|
|
@@ -4867,11 +5031,102 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4867
5031
|
}
|
|
4868
5032
|
return execution;
|
|
4869
5033
|
}
|
|
4870
|
-
// ── name=file
|
|
5034
|
+
// ── name=file:目录浏览、文件拉取与项目文件操作 ──
|
|
4871
5035
|
// list 返回 JSON 目录项;fetch 内部等价于 /file <path>,复用 resolveMenuFilePath 校验链 + adapter.send(result.file)。
|
|
4872
5036
|
// fetch 文件作为独立 result.file 消息异步发回;把请求 id 作为 correlationId 透传,
|
|
4873
5037
|
// 客户端用它把异步到达的文件消息对回这次 fetch 点击。
|
|
4874
5038
|
if (cmdBase === '/file') {
|
|
5039
|
+
if (action === 'move' || action === 'delete') {
|
|
5040
|
+
const allowedArgs = action === 'move'
|
|
5041
|
+
? new Set(['path', 'destination', 'context'])
|
|
5042
|
+
: new Set(['path', 'mtime', 'context']);
|
|
5043
|
+
const unknown = Object.keys(args ?? {}).find(key => !allowedArgs.has(key));
|
|
5044
|
+
if (unknown)
|
|
5045
|
+
return { error: `file.${action} does not accept args.${unknown}`, code: 'INVALID_ARGUMENT' };
|
|
5046
|
+
if (typeof args?.path !== 'string' || !args.path.trim()) {
|
|
5047
|
+
return { error: `file.${action} requires args.path`, code: 'INVALID_ARGUMENT' };
|
|
5048
|
+
}
|
|
5049
|
+
if (action === 'move' && (typeof args?.destination !== 'string' || !args.destination.trim())) {
|
|
5050
|
+
return { error: 'file.move requires args.destination', code: 'INVALID_ARGUMENT' };
|
|
5051
|
+
}
|
|
5052
|
+
if (action === 'delete' && (typeof args?.mtime !== 'number' || !Number.isFinite(args.mtime) || args.mtime < 0)) {
|
|
5053
|
+
return { error: 'file.delete requires a non-negative numeric args.mtime', code: 'INVALID_ARGUMENT' };
|
|
5054
|
+
}
|
|
5055
|
+
const projectPath = session?.projectPath ?? evolagent?.projectPath ?? this.getOwningAgent?.(channel)?.projectPath;
|
|
5056
|
+
const source = resolveProjectMutationPath(args.path, projectPath);
|
|
5057
|
+
if ('error' in source)
|
|
5058
|
+
return source;
|
|
5059
|
+
if (!source.stat)
|
|
5060
|
+
return { error: '源路径不存在', code: 'NOT_FOUND' };
|
|
5061
|
+
if (!source.stat.isFile() && !source.stat.isDirectory()) {
|
|
5062
|
+
return { error: '只支持普通文件和目录', code: 'NOT_SUPPORTED' };
|
|
5063
|
+
}
|
|
5064
|
+
if (isProtectedProjectMutationPath(source.absolutePath, subject.selfAid)) {
|
|
5065
|
+
return { error: '不能修改 EvolCore 受保护路径', code: 'NO_PERMISSION' };
|
|
5066
|
+
}
|
|
5067
|
+
if (action === 'move') {
|
|
5068
|
+
const destinationParts = parseProjectRelativePath(args.destination);
|
|
5069
|
+
if (!Array.isArray(destinationParts))
|
|
5070
|
+
return destinationParts;
|
|
5071
|
+
const lexicalDestination = path.join(source.projectPath, ...destinationParts);
|
|
5072
|
+
if (source.stat.isDirectory() && isInProject(lexicalDestination, source.absolutePath)) {
|
|
5073
|
+
return { error: '不能把目录移动到自身内部', code: 'INVALID_ARGUMENT' };
|
|
5074
|
+
}
|
|
5075
|
+
const destination = resolveProjectMutationDestination(args.destination, source.projectPath, subject.selfAid);
|
|
5076
|
+
if ('error' in destination)
|
|
5077
|
+
return destination;
|
|
5078
|
+
try {
|
|
5079
|
+
fs.renameSync(source.absolutePath, destination.absolutePath);
|
|
5080
|
+
const movedStat = fs.statSync(destination.absolutePath);
|
|
5081
|
+
return { data: {
|
|
5082
|
+
path: source.relativePath,
|
|
5083
|
+
destination: destination.relativePath,
|
|
5084
|
+
type: movedStat.isDirectory() ? 'directory' : 'file',
|
|
5085
|
+
size: movedStat.isDirectory() ? null : movedStat.size,
|
|
5086
|
+
mtime: movedStat.mtimeMs,
|
|
5087
|
+
} };
|
|
5088
|
+
}
|
|
5089
|
+
catch (error) {
|
|
5090
|
+
const code = error?.code;
|
|
5091
|
+
if (code === 'EEXIST' || code === 'ENOTEMPTY')
|
|
5092
|
+
return { error: '目标路径已存在', code: 'CONFLICT' };
|
|
5093
|
+
if (code === 'EXDEV')
|
|
5094
|
+
return { error: '不支持跨文件系统移动', code: 'NOT_SUPPORTED' };
|
|
5095
|
+
return projectMutationPathError(error, '移动失败');
|
|
5096
|
+
}
|
|
5097
|
+
}
|
|
5098
|
+
if (source.stat.mtimeMs !== args.mtime) {
|
|
5099
|
+
return { error: '文件或目录已变化,请刷新后重试', code: 'CONFLICT' };
|
|
5100
|
+
}
|
|
5101
|
+
try {
|
|
5102
|
+
if (source.stat.isDirectory()) {
|
|
5103
|
+
const children = fs.readdirSync(source.absolutePath, { withFileTypes: true });
|
|
5104
|
+
for (const child of children) {
|
|
5105
|
+
const childPath = path.join(source.absolutePath, child.name);
|
|
5106
|
+
const childStat = fs.lstatSync(childPath);
|
|
5107
|
+
if (child.isDirectory())
|
|
5108
|
+
return { error: '目录下仍有子目录,不能删除', code: 'CONFLICT' };
|
|
5109
|
+
if (!childStat.isFile())
|
|
5110
|
+
return { error: '目录包含不支持删除的文件类型', code: 'NOT_SUPPORTED' };
|
|
5111
|
+
if (isProtectedProjectMutationPath(childPath, subject.selfAid)) {
|
|
5112
|
+
return { error: '目录包含 EvolCore 受保护路径', code: 'NO_PERMISSION' };
|
|
5113
|
+
}
|
|
5114
|
+
}
|
|
5115
|
+
for (const child of children)
|
|
5116
|
+
fs.unlinkSync(path.join(source.absolutePath, child.name));
|
|
5117
|
+
fs.rmdirSync(source.absolutePath);
|
|
5118
|
+
return { data: { path: source.relativePath, deleted: true, type: 'directory' } };
|
|
5119
|
+
}
|
|
5120
|
+
fs.unlinkSync(source.absolutePath);
|
|
5121
|
+
return { data: { path: source.relativePath, deleted: true, type: 'file' } };
|
|
5122
|
+
}
|
|
5123
|
+
catch (error) {
|
|
5124
|
+
const code = error?.code;
|
|
5125
|
+
if (code === 'ENOTEMPTY' || code === 'EEXIST')
|
|
5126
|
+
return { error: '目录发生变化或仍有子项,不能删除', code: 'CONFLICT' };
|
|
5127
|
+
return projectMutationPathError(error, '删除失败');
|
|
5128
|
+
}
|
|
5129
|
+
}
|
|
4875
5130
|
if (action === 'search') {
|
|
4876
5131
|
for (const operation of ['file.list', ...(args.content !== undefined ? ['file.fetch'] : [])]) {
|
|
4877
5132
|
const denied = await authorizeMenuIntent.call(this, {
|
|
@@ -5092,6 +5347,9 @@ async function execMenuForSystemControl(payload, context) {
|
|
|
5092
5347
|
const isFileFetch = (payload?.type === 'menu.query'
|
|
5093
5348
|
|| (payload?.type === 'menu.action' && (payload?.action === 'fetch' || payload?.action === 'search')))
|
|
5094
5349
|
&& (name === 'file' || compatCmd === '/file');
|
|
5350
|
+
const isFileMutation = payload?.type === 'menu.action'
|
|
5351
|
+
&& (payload?.action === 'move' || payload?.action === 'delete')
|
|
5352
|
+
&& (name === 'file' || compatCmd === '/file');
|
|
5095
5353
|
const isDataRootQuery = payload?.type === 'menu.query'
|
|
5096
5354
|
&& (name === 'agent-data-root'
|
|
5097
5355
|
|| name === 'relation-data-root'
|
|
@@ -5102,6 +5360,9 @@ async function execMenuForSystemControl(payload, context) {
|
|
|
5102
5360
|
if (isFileFetch || isDataRootQuery || isRootedFile || isAgentStorageMenuRequest(payload ?? {})) {
|
|
5103
5361
|
return ecwebErr(id, name, 'NOT_SUPPORTED', 'Host/control 不支持数据根文件访问,请通过目标 Agent AID 请求');
|
|
5104
5362
|
}
|
|
5363
|
+
if (isFileMutation) {
|
|
5364
|
+
return ecwebErr(id, name, 'NOT_SUPPORTED', 'Host/control 不支持项目文件修改,请通过目标 Agent AID 请求');
|
|
5365
|
+
}
|
|
5105
5366
|
if (name === 'cli' || compatCmd === '/cli') {
|
|
5106
5367
|
const message = context.source === 'ecweb'
|
|
5107
5368
|
? 'cli 不在 ECWeb 控制范围'
|
|
@@ -5123,7 +5384,21 @@ async function execMenuForSystemControl(payload, context) {
|
|
|
5123
5384
|
if ('error' in target)
|
|
5124
5385
|
return ecwebErr(id, name, target.code, target.error);
|
|
5125
5386
|
const targetChannel = target.channel;
|
|
5126
|
-
const
|
|
5387
|
+
const requestedTargetAid = typeof payload?.agent === 'string' && payload.agent.trim()
|
|
5388
|
+
? payload.agent.trim()
|
|
5389
|
+
: typeof payload?.args?.aid === 'string' && payload.args.aid.trim()
|
|
5390
|
+
? payload.args.aid.trim()
|
|
5391
|
+
: undefined;
|
|
5392
|
+
if ((name === 'agent' || compatCmd === '/agent') && requestedTargetAid && !isValidAid(requestedTargetAid)) {
|
|
5393
|
+
return ecwebErr(id, name, 'INVALID_ARGUMENT', '无效 Agent AID');
|
|
5394
|
+
}
|
|
5395
|
+
// Agent management uses the selected configuration even when the Agent is
|
|
5396
|
+
// stopped and has no channel. Process actions keep their control identity.
|
|
5397
|
+
const isAgentManagement = (name === 'agent' || compatCmd === '/agent')
|
|
5398
|
+
&& (payload?.type === 'menu.query'
|
|
5399
|
+
|| (payload?.type === 'menu.action' && ['update', 'reload'].includes(payload.action)));
|
|
5400
|
+
const targetAid = (isAgentManagement ? requestedTargetAid : undefined)
|
|
5401
|
+
?? this.getOwningAgent?.(targetChannel)?.aid
|
|
5127
5402
|
?? this.getDaemonTriggerOwnerAid?.(targetChannel);
|
|
5128
5403
|
if (name === 'aid' || compatCmd === '/aid') {
|
|
5129
5404
|
const requestedAid = typeof payload?.args?.aid === 'string' ? payload.args.aid.trim().replace(/^@/, '') : '';
|