evolcore 0.0.41-test.0 → 0.0.41-test.2
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 +62 -0
- package/dist/agents/baseagent-availability.js +1 -1
- package/dist/agents/baseagent.js +88 -49
- package/dist/agents/claude-runner.js +177 -92
- package/dist/agents/codex-runner.js +146 -71
- package/dist/agents/ecagent-runner.js +1 -1
- package/dist/agents/gemini-runner.js +1 -1
- package/dist/aun/aid/agentmd.js +98 -11
- package/dist/aun/aid/client.js +1 -1
- package/dist/aun/aid/control-aid.js +26 -2
- package/dist/aun/aid/identity.js +91 -0
- package/dist/aun/aid/index.js +1 -1
- package/dist/aun/aid/managed-operation.js +1 -1
- package/dist/aun/aid/ownership-operation.js +23 -22
- package/dist/aun/group/fs-download.js +39 -0
- package/dist/aun/group/identity.js +36 -21
- package/dist/aun/group/operations.js +5 -0
- package/dist/aun/menu/client.js +27 -0
- package/dist/aun/msg/managed-operation.js +68 -7
- package/dist/aun/msg/p2p.js +8 -8
- package/dist/aun/service-proxy.js +53 -12
- package/dist/channels/aun.js +633 -32
- package/dist/channels/daemon.js +15 -1
- package/dist/cli/agent-command.js +5 -2
- package/dist/cli/agent-create.js +991 -233
- package/dist/cli/agent.js +49 -10
- package/dist/cli/aid-bind-command.js +48 -19
- package/dist/cli/aun-commands.js +48 -36
- package/dist/cli/daemon-commands.js +679 -697
- package/dist/cli/fs-command.js +64 -2
- package/dist/cli/index.js +72 -5
- package/dist/cli/init-channel.js +1 -1
- package/dist/cli/init.js +75 -1
- package/dist/cli/managed-command-guard.js +17 -1
- package/dist/cli/model.js +40 -40
- package/dist/cli/provider-command.js +57 -0
- package/dist/cli/proxy-command.js +92 -0
- package/dist/cli/restart-monitor.js +4 -2
- package/dist/cli/role.js +85 -0
- package/dist/cli/stats.js +10 -3
- package/dist/cli/task-context.js +19 -0
- package/dist/config/access-policy.js +7 -2
- package/dist/config/boot-log.js +39 -1
- package/dist/config/config-field-policy.js +17 -39
- package/dist/config/config-manager.js +183 -44
- package/dist/config/config-operation-service.js +5 -19
- package/dist/config/contact-book-store.js +47 -21
- package/dist/config/contact-book.js +18 -12
- package/dist/config/contact-operation-service.js +3 -4
- package/dist/config/contact-request-service.js +11 -0
- package/dist/config/daemon-services.js +11 -0
- package/dist/config/gateway-config.js +88 -594
- package/dist/config/owner-config.js +2 -2
- package/dist/config/peer-role-resolver.js +15 -12
- package/dist/config/provider-ipc-service.js +132 -0
- package/dist/config/provider-menu-request.js +58 -0
- package/dist/config/providers-config.js +12 -7
- package/dist/config/providers-import.js +3 -21
- package/dist/config/providers-management.js +78 -5
- package/dist/config/resolved-config-op.js +11 -1
- package/dist/config/role-command-service.js +166 -0
- package/dist/config/role-request-service.js +193 -0
- package/dist/config/schema-migration.js +1000 -25
- package/dist/config-store.js +89 -4
- package/dist/contracts/ecweb-instance.js +41 -0
- package/dist/contracts/ecweb-service-protocol.js +4 -1
- package/dist/core/agent-application-service.js +60 -11
- package/dist/core/agent-create-status.js +203 -0
- package/dist/core/agent-creation-claim.js +177 -0
- package/dist/core/agent-ipc-registration.js +39 -18
- package/dist/core/agent-runtime.js +194 -24
- package/dist/core/auth/agent-delegation.js +6 -3
- package/dist/core/auth/auth-gateway.js +67 -2
- package/dist/core/auth/authorization-audit.js +58 -11
- package/dist/core/auth/delegation-authorization.js +5 -2
- package/dist/core/auth/operation-authorizer.js +43 -6
- package/dist/core/auth/operation-catalog.js +45 -7
- package/dist/core/channel-loader.js +2 -0
- package/dist/core/command/agent-control.js +260 -21
- package/dist/core/command/agent-storage-menu.js +5 -3
- package/dist/core/command/cli-intent-parser.js +8 -3
- package/dist/core/command/command-handler.js +112 -154
- package/dist/core/command/connect-menu.js +11 -3
- package/dist/core/command/data-root-resolver.js +5 -4
- package/dist/core/command/memory-slash.js +16 -8
- package/dist/core/command/menu-catalog.js +10 -6
- package/dist/core/command/menu-handler.js +106 -73
- package/dist/core/command/menu-protocol.js +15 -1
- package/dist/core/command/provider-menu.js +46 -0
- package/dist/core/command/role-menu.js +147 -30
- package/dist/core/command/slash-handler.js +125 -255
- package/dist/core/daemon-control.js +26 -27
- package/dist/core/event-catalog.js +10 -0
- package/dist/core/evolagent-registry.js +7 -5
- package/dist/core/evolagent.js +10 -8
- package/dist/core/file-integrity/store.js +11 -0
- package/dist/core/handoff/ipc-registration.js +3 -0
- package/dist/core/inference/text-inference.js +31 -40
- package/dist/core/initialization/service.js +491 -0
- package/dist/core/ipc-registration.js +40 -24
- package/dist/core/memory/consolidation-context.js +51 -5
- package/dist/core/memory/consolidation-ops-records.js +96 -1
- package/dist/core/memory/consolidation-trigger.js +208 -191
- package/dist/core/memory/consolidation.js +333 -35
- package/dist/core/memory/index-manager.js +27 -5
- package/dist/core/memory/memory-admin.js +45 -5
- package/dist/core/memory/memory-writer.js +163 -18
- package/dist/core/memory/relation-idle-monitor.js +119 -58
- package/dist/core/memory/relation-sweep.js +55 -45
- package/dist/core/message/aun-ipc-sender.js +81 -69
- package/dist/core/message/im-renderer.js +25 -4
- package/dist/core/message/message-admission.js +89 -4
- package/dist/core/message/message-bridge.js +66 -21
- package/dist/core/message/response-engine.js +108 -35
- package/dist/core/model/catalog-service.js +5 -3
- package/dist/core/model/config-scope.js +29 -71
- package/dist/core/model/field-scope.js +1 -1
- package/dist/core/model/model-catalog.js +30 -41
- package/dist/core/model/model-diagnostics.js +4 -3
- package/dist/core/model/model-fallback.js +10 -7
- package/dist/core/model/model-permission.js +3 -2
- package/dist/core/ownership/owner-resolver.js +772 -158
- package/dist/core/permission/approval-gateway.js +103 -403
- package/dist/core/permission/ec-command-parser.js +62 -6
- package/dist/core/permission/index.js +1 -0
- package/dist/core/permission/permission-result.js +78 -0
- package/dist/core/permission/sandbox-runtime.js +18 -1
- package/dist/core/permission/tool-policy.js +21 -46
- package/dist/core/relation/peer-identity.js +64 -1
- package/dist/core/role/runtime-policy.js +72 -13
- package/dist/core/session/session-capsule.js +1 -1
- package/dist/core/session/session-idle-monitor.js +1 -1
- package/dist/core/session/session-manager.js +20 -0
- package/dist/core/session/session-renew.js +3 -3
- package/dist/core/skill/index-generator.js +15 -5
- package/dist/core/system-session/memory.js +43 -8
- package/dist/core/thread/thread-service.js +19 -6
- package/dist/directory/owner-directory-admission.js +95 -0
- package/dist/directory/owner-directory-authorization.js +309 -0
- package/dist/directory/owner-directory-cache.js +635 -0
- package/dist/eck/kit-renderer.js +2 -2
- package/dist/ecweb/basic-settings-service.js +33 -40
- package/dist/ecweb/init-menu.js +32 -0
- package/dist/ecweb/message-context-service.js +110 -0
- package/dist/index.js +93 -19
- package/dist/ipc.js +247 -29
- package/dist/paths.js +7 -0
- package/dist/proxy/command.js +122 -0
- package/dist/proxy/ipc-service.js +68 -0
- package/dist/proxy/manager.js +484 -0
- package/dist/proxy/service-supervisor.js +603 -0
- package/dist/response-system/engines/v1/proactive-flow.js +16 -6
- package/dist/trigger/authorization.js +27 -17
- package/dist/trigger/feedback.js +2 -3
- package/dist/trigger/ipc-service.js +105 -78
- package/dist/trigger/local-files.js +2 -1
- package/dist/trigger/manager.js +5 -3
- package/dist/trigger/scheduler.js +88 -6
- package/dist/utils/atomic-write.js +28 -0
- package/dist/utils/cross-platform.js +14 -0
- package/dist/utils/ecweb-supervisor.js +258 -83
- package/dist/utils/error-utils.js +26 -2
- package/dist/utils/logger.js +92 -6
- package/dist/utils/package-version-info.js +4 -2
- package/dist/utils/welcome.js +1 -1
- package/kits/docs/INDEX.md +1 -0
- package/kits/docs/aun/SDK.md +4 -1
- package/kits/docs/channels/aun.md +9 -0
- package/kits/docs/evolcore/INDEX.md +1 -0
- package/kits/docs/evolcore/agent.md +8 -1
- package/kits/docs/evolcore/aid.md +67 -17
- package/kits/docs/evolcore/config.md +28 -7
- package/kits/docs/evolcore/contact.md +3 -0
- package/kits/docs/evolcore/fs.md +11 -0
- package/kits/docs/evolcore/group.md +1 -1
- package/kits/docs/evolcore/memory-architecture.md +2 -2
- package/kits/docs/evolcore/memory-consolidation.md +32 -8
- package/kits/docs/evolcore/memory.md +1 -1
- package/kits/docs/evolcore/menu-protocol.md +4 -0
- package/kits/docs/evolcore/model.md +23 -20
- package/kits/docs/evolcore/msg.md +4 -7
- package/kits/docs/evolcore/provider.md +50 -0
- package/kits/docs/identity/AID_PROFILE_SPEC.md +52 -17
- package/kits/migrations/migrate-contact-book-v2.mjs +30 -11
- package/kits/rules/01-overview.md +3 -0
- package/kits/rules/04-relation.md +1 -1
- package/kits/schemas/_meta.json +37 -4
- package/kits/schemas/agent-config.schema.13.json +8 -3
- package/kits/schemas/agent-config.schema.16.json +891 -0
- package/kits/schemas/daemon.schema.9.json +366 -0
- package/kits/schemas/defaults.schema.5.json +406 -127
- package/kits/schemas/relation-config.schema.11.json +277 -0
- package/kits/schemas/role-config.schema.1.json +7 -7
- package/kits/skills/.switches.json +4 -0
- package/kits/skills/ec-agent-create/SKILL.md +3 -0
- package/kits/skills/ec-identity/SKILL.md +2 -2
- package/kits/skills/ec-service-proxy/SKILL.md +118 -0
- package/kits/skills/ec-skill/scripts/skill.mjs +6 -0
- package/kits/skills/personal-assistant/SKILL.md +176 -0
- package/kits/skills/personal-assistant/references/01-workspace-spec.md +333 -0
- package/kits/skills/personal-assistant/references/02-bootstrap.md +205 -0
- package/kits/skills/personal-assistant/references/03-data-flow-and-gaps.md +177 -0
- package/kits/skills/personal-assistant/references/04-frontend-contract.md +439 -0
- package/kits/skills/personal-assistant/references/05-directory-reference.md +292 -0
- package/kits/skills/personal-assistant/references/06-render-config.md +350 -0
- package/kits/skills/personal-assistant/schema/workspace.schema.json +85 -0
- package/kits/skills/personal-assistant/schema/workspace.v1.json +66 -0
- package/kits/skills/personal-assistant/scripts/archive.mjs +154 -0
- package/kits/skills/personal-assistant/scripts/check.mjs +114 -0
- package/kits/skills/personal-assistant/scripts/index-rebuild.mjs +252 -0
- package/kits/skills/personal-assistant/scripts/ingest.mjs +344 -0
- package/kits/skills/personal-assistant/scripts/init.mjs +270 -0
- package/kits/skills/personal-assistant/scripts/lib/apply.mjs +92 -0
- package/kits/skills/personal-assistant/scripts/lib/schema.mjs +96 -0
- package/kits/skills/personal-assistant/scripts/lib/time.mjs +28 -0
- package/kits/skills/personal-assistant/scripts/migrate.mjs +172 -0
- package/kits/skills/personal-assistant/scripts/search.mjs +172 -0
- package/kits/skills/personal-assistant/scripts/verify.mjs +196 -0
- package/kits/skills/personal-assistant/templates/INDEX.md.tpl +24 -0
- package/kits/skills/personal-assistant/templates/README.md.tpl +108 -0
- package/kits/skills/personal-assistant/triggers/ingest-daily.json +23 -0
- package/kits/skills/personal-assistant/triggers/memory-consolidate.json +23 -0
- package/kits/skills/personal-assistant/triggers/report-daily.json +23 -0
- package/kits/skills/personal-assistant/triggers/report-weekly.json +23 -0
- package/kits/skills/thread-ops/SKILL.md +5 -0
- package/kits/templates/memory-consolidation/forget.md +19 -6
- package/kits/templates/memory-consolidation/notes.md +1 -1
- package/kits/templates/memory-consolidation/profile.md +2 -2
- package/kits/templates/memory-consolidation/promote.md +20 -3
- package/kits/templates/roles/member.json +8 -1
- package/kits/templates/system-fragments/baseagent.md +2 -2
- package/kits/templates/system-fragments/memory.md +4 -4
- package/kits/templates/system-fragments/venue.md +1 -1
- package/package.json +7 -3
- package/dist/core/message/create-status.js +0 -96
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { resolvePaths } from '../paths.js';
|
|
4
|
+
import { readDelegationCredential, hashCurrentDelegatedCommand } from '../core/auth/agent-delegation.js';
|
|
5
|
+
import { parseProviderCommand } from '../config/provider-ipc-service.js';
|
|
6
|
+
import { queryDaemon, daemonUnavailableMessage, wantsHelp } from './help.js';
|
|
7
|
+
export async function cmdProvider(args) {
|
|
8
|
+
if (!args.length || wantsHelp(args)) {
|
|
9
|
+
console.log('用法: ec provider <命令> [--format json]\n\n'
|
|
10
|
+
+ ' list\n show <provider-id>\n create --file <path>\n import --file <path>\n'
|
|
11
|
+
+ ' update <provider-id> --file <path>\n delete <provider-id>\n\n'
|
|
12
|
+
+ '只允许宿主控制终端管理 process 级 Provider。文件必须为 UTF-8,最大 1 MiB。\n'
|
|
13
|
+
+ 'import 接受单 Provider 对象、单项映射或 providers 包装,始终创建新 ID。\n'
|
|
14
|
+
+ 'update 替换完整对象;<redacted> 保留原密钥。输出始终脱敏。');
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const json = args.some((value, index) => value === '--format=json' || (value === '--format' && args[index + 1] === 'json'));
|
|
18
|
+
try {
|
|
19
|
+
const parsed = parseProviderCommand(['provider', ...args]);
|
|
20
|
+
const argv = ['provider', parsed.operation,
|
|
21
|
+
...(parsed.providerId ? [parsed.providerId] : []),
|
|
22
|
+
...(parsed.file ? ['--file', path.resolve(parsed.file)] : []),
|
|
23
|
+
...(parsed.json ? ['--format', 'json'] : [])];
|
|
24
|
+
const sessionId = process.env.EVOLCORE_SESSION_ID;
|
|
25
|
+
const delegationToken = readDelegationCredential();
|
|
26
|
+
let controlToken;
|
|
27
|
+
if (!sessionId && !delegationToken) {
|
|
28
|
+
try {
|
|
29
|
+
controlToken = fs.readFileSync(resolvePaths().controlToken, 'utf8').trim();
|
|
30
|
+
}
|
|
31
|
+
catch { }
|
|
32
|
+
}
|
|
33
|
+
const { response, transportError } = await queryDaemon(resolvePaths().socket, {
|
|
34
|
+
type: 'provider.op', argv,
|
|
35
|
+
...(sessionId || delegationToken ? { sessionId, delegationToken, delegationCommandHash: hashCurrentDelegatedCommand() } : { controlToken }),
|
|
36
|
+
}, 30_000);
|
|
37
|
+
if (!response)
|
|
38
|
+
throw Object.assign(new Error(daemonUnavailableMessage(transportError, '无法连接 EvolCore daemon')), { code: 'DAEMON_UNAVAILABLE' });
|
|
39
|
+
if (json)
|
|
40
|
+
console.log(JSON.stringify(response, null, 2));
|
|
41
|
+
else if (response.ok === false)
|
|
42
|
+
console.error(response.error + ' (' + response.code + ')');
|
|
43
|
+
else
|
|
44
|
+
console.log(JSON.stringify(response.data, null, 2));
|
|
45
|
+
if (response.ok === false)
|
|
46
|
+
process.exitCode = 1;
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
const failure = error;
|
|
50
|
+
const result = { ok: false, code: failure.code ?? 'INVALID_ARGUMENT', error: failure.message ?? 'Provider command failed' };
|
|
51
|
+
if (json)
|
|
52
|
+
console.log(JSON.stringify(result, null, 2));
|
|
53
|
+
else
|
|
54
|
+
console.error(result.error);
|
|
55
|
+
process.exitCode = 1;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { resolvePaths } from '../paths.js';
|
|
3
|
+
import { queryDaemon, daemonUnavailableMessage } from './help.js';
|
|
4
|
+
import { readDelegationCredential, hashCurrentDelegatedCommand } from '../core/auth/agent-delegation.js';
|
|
5
|
+
function printJson(value) {
|
|
6
|
+
console.log(JSON.stringify(value, null, 2));
|
|
7
|
+
}
|
|
8
|
+
function help() {
|
|
9
|
+
console.log([
|
|
10
|
+
'用法: ec proxy <命令> [选项]',
|
|
11
|
+
'',
|
|
12
|
+
'只管理当前 daemon 中声明的 ServiceProxy 服务。',
|
|
13
|
+
'',
|
|
14
|
+
'命令:',
|
|
15
|
+
' list [--format json]',
|
|
16
|
+
' show <name> [--format json]',
|
|
17
|
+
' status <name> [--format json]',
|
|
18
|
+
' access <name> [--format json]',
|
|
19
|
+
' options [--format json]',
|
|
20
|
+
" build --file <service.json>|--json '<service-json>' --if-rev absent --operation-id <id>",
|
|
21
|
+
" update <name> --file <patch.json>|--json '<patch-json>' --if-rev <revision> --operation-id <id>",
|
|
22
|
+
' apply [--all] --operation-id <id>',
|
|
23
|
+
' publish|unpublish|remove|start|stop|restart|reload|reset-failure <name> --if-rev <revision> --operation-id <id>',
|
|
24
|
+
' job <operation-id> [--format json]',
|
|
25
|
+
'',
|
|
26
|
+
'通用:',
|
|
27
|
+
' --dry-run 校验并显示计划,不写入或执行',
|
|
28
|
+
' --format json 输出结构化结果',
|
|
29
|
+
'',
|
|
30
|
+
'新服务以 --if-rev absent 创建。变更前先查询 show/status 获取 configRev。',
|
|
31
|
+
].join('\n'));
|
|
32
|
+
}
|
|
33
|
+
export async function cmdProxy(args) {
|
|
34
|
+
if (!args.length || args[0] === '--help' || args[0] === '-h' || args[0] === 'help') {
|
|
35
|
+
help();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const sessionId = process.env.EVOLCORE_SESSION_ID;
|
|
39
|
+
const delegationToken = readDelegationCredential();
|
|
40
|
+
let controlToken;
|
|
41
|
+
if (!sessionId) {
|
|
42
|
+
try {
|
|
43
|
+
controlToken = fs.readFileSync(resolvePaths().controlToken, 'utf8').trim() || undefined;
|
|
44
|
+
}
|
|
45
|
+
catch { }
|
|
46
|
+
}
|
|
47
|
+
const { response, transportError } = await queryDaemon(resolvePaths().socket, {
|
|
48
|
+
type: 'proxy.op',
|
|
49
|
+
argv: ['proxy', ...args],
|
|
50
|
+
...(sessionId ? {
|
|
51
|
+
sessionId,
|
|
52
|
+
delegationToken,
|
|
53
|
+
delegationCommandHash: hashCurrentDelegatedCommand(),
|
|
54
|
+
} : controlToken ? { controlToken } : {}),
|
|
55
|
+
}, 120_000);
|
|
56
|
+
if (!response) {
|
|
57
|
+
throw Object.assign(new Error(daemonUnavailableMessage(transportError, '无法连接 EvolCore daemon')), { code: 'DAEMON_UNAVAILABLE' });
|
|
58
|
+
}
|
|
59
|
+
const formatIndex = args.indexOf('--format');
|
|
60
|
+
const isJson = (formatIndex >= 0 && args[formatIndex + 1] === 'json') || args.includes('--json');
|
|
61
|
+
if (response.ok === false) {
|
|
62
|
+
if (isJson)
|
|
63
|
+
printJson(response);
|
|
64
|
+
else
|
|
65
|
+
process.stderr.write((response.error ?? 'ServiceProxy 操作失败') + ' (' + (response.code ?? 'FAILED') + ')\n');
|
|
66
|
+
process.exitCode = 1;
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (isJson) {
|
|
70
|
+
printJson(response);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const result = response;
|
|
74
|
+
if (result.services) {
|
|
75
|
+
if (result.services.length === 0)
|
|
76
|
+
console.log('(无 ServiceProxy 服务)');
|
|
77
|
+
for (const service of result.services) {
|
|
78
|
+
console.log(service.name + ' enabled=' + service.enabled
|
|
79
|
+
+ ' proxy=' + service.proxy?.enabled + ' runtime=' + service.runtime?.state
|
|
80
|
+
+ ' configRev=' + service.configRev);
|
|
81
|
+
}
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (result.service) {
|
|
85
|
+
console.log(JSON.stringify(result.service, null, 2));
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (result.jobId)
|
|
89
|
+
console.log('✓ ' + (result.state ?? 'completed') + ' operationId=' + result.operationId + ' jobId=' + result.jobId);
|
|
90
|
+
else
|
|
91
|
+
console.log(JSON.stringify(result, null, 2));
|
|
92
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
-
import {
|
|
2
|
+
import { ipcHostQuery } from '../ipc.js';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { spawn, execFile } from 'child_process';
|
|
5
5
|
import { promisify } from 'util';
|
|
@@ -1234,7 +1234,9 @@ async function notifyDaemonOwners(p, message, log) {
|
|
|
1234
1234
|
log(`Daemon owner notification skipped: invalid daemon.json.aid ${daemonAid}`);
|
|
1235
1235
|
return;
|
|
1236
1236
|
}
|
|
1237
|
-
const response = await
|
|
1237
|
+
const response = await ipcHostQuery(p.socket, {
|
|
1238
|
+
type: 'aid.ownership', authMode: 'local-control', argv: ['aid', 'bind', 'status'],
|
|
1239
|
+
}, OWNER_NOTIFICATION_TIMEOUT_MS).catch(() => null);
|
|
1238
1240
|
const state = response?.ok ? response.state : undefined;
|
|
1239
1241
|
const owners = state?.subjectAid === daemonAid && state?.consensusStatus === 'consensus'
|
|
1240
1242
|
&& typeof state.ownerAid === 'string' && isValidAid(state.ownerAid) ? [state.ownerAid] : [];
|
package/dist/cli/role.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { resolvePaths } from '../paths.js';
|
|
2
|
+
import { executeResolvedRoleCommand, resolveRoleCommand, } from '../config/role-command-service.js';
|
|
3
|
+
import { applyApprovedRoleAssignment } from '../core/command/role-menu.js';
|
|
4
|
+
import { listStaticAgentOwners } from '../config/peer-role-resolver.js';
|
|
5
|
+
import { daemonUnavailableMessage, queryDaemon } from './help.js';
|
|
6
|
+
import { AGENT_DELEGATION_TOKEN_ENV, readDelegationCredential } from '../core/auth/agent-delegation.js';
|
|
7
|
+
import { getArgValue, isHelpFlag, wantsHelp } from './help.js';
|
|
8
|
+
export async function cmdRole(args) {
|
|
9
|
+
if (args.length === 0 || isHelpFlag(args[0]) || wantsHelp(args)) {
|
|
10
|
+
printHelp();
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const json = getArgValue(args, '--format') === 'json';
|
|
14
|
+
if (process.env.EVOLCORE_SESSION_ID) {
|
|
15
|
+
try {
|
|
16
|
+
const result = await runManaged(args, json);
|
|
17
|
+
output(result, json);
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
console.error(`❌ ${err.message ?? String(err)}`);
|
|
21
|
+
process.exitCode = 1;
|
|
22
|
+
}
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const resolved = resolveRoleCommand(args);
|
|
26
|
+
if (!resolved.ok)
|
|
27
|
+
fail(resolved.reason, resolved.code);
|
|
28
|
+
const selfAid = resolved.command.selfAid;
|
|
29
|
+
const actorAid = listStaticAgentOwners(selfAid)[0] ?? selfAid;
|
|
30
|
+
const result = await executeResolvedRoleCommand(resolved.command, actorAid, applyApprovedRoleAssignment);
|
|
31
|
+
if (!result.ok)
|
|
32
|
+
fail(result.error, result.code, result.data);
|
|
33
|
+
output(result, json);
|
|
34
|
+
}
|
|
35
|
+
function output(value, json) {
|
|
36
|
+
if (json)
|
|
37
|
+
console.log(JSON.stringify(value));
|
|
38
|
+
else
|
|
39
|
+
console.log(JSON.stringify(value, null, 2));
|
|
40
|
+
}
|
|
41
|
+
async function runManaged(args, json) {
|
|
42
|
+
const sessionId = process.env.EVOLCORE_SESSION_ID;
|
|
43
|
+
const delegationToken = readDelegationCredential();
|
|
44
|
+
if (!delegationToken)
|
|
45
|
+
fail(`${AGENT_DELEGATION_TOKEN_ENV} is not set for the active task`, 'DELEGATION_REQUIRED');
|
|
46
|
+
const { response, transportError } = await queryDaemon(resolvePaths().socket, {
|
|
47
|
+
type: 'role.op',
|
|
48
|
+
argv: ['role', ...args],
|
|
49
|
+
sessionId,
|
|
50
|
+
delegationToken,
|
|
51
|
+
}, 10_000);
|
|
52
|
+
if (!response) {
|
|
53
|
+
fail(daemonUnavailableMessage(transportError, 'Unable to connect to the evolcore daemon'), 'DAEMON_UNAVAILABLE');
|
|
54
|
+
}
|
|
55
|
+
if (!response.ok || !response.result) {
|
|
56
|
+
fail(response.error || 'role operation failed', response.code || 'ROLE_AUTH_FAILED', response.data);
|
|
57
|
+
}
|
|
58
|
+
return response.result;
|
|
59
|
+
}
|
|
60
|
+
function fail(message, code = 'INVALID_ARGUMENT', data) {
|
|
61
|
+
const error = new Error(message);
|
|
62
|
+
error.code = code;
|
|
63
|
+
if (data !== undefined)
|
|
64
|
+
error.data = data;
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
function printHelp() {
|
|
68
|
+
console.log(`Usage:
|
|
69
|
+
ec role request <peer-aid> --role <role-id> [--reason '<text>'] [--self <agent-aid>]
|
|
70
|
+
ec role list [--status pending|approved|rejected|expired] [--self <agent-aid>]
|
|
71
|
+
ec role approve <request-id> [--reason '<text>'] [--self <agent-aid>]
|
|
72
|
+
ec role reject <request-id> [--reason '<text>'] [--self <agent-aid>]
|
|
73
|
+
|
|
74
|
+
说明:
|
|
75
|
+
申请不会立即改变权限,只记录一条待审批请求,交由本 Agent 的 owner 审批。
|
|
76
|
+
approve / reject 只能由本 Agent 的 owner 执行;审批通过后才写入关系角色。
|
|
77
|
+
|
|
78
|
+
Options:
|
|
79
|
+
--self <agent-aid> 本端 agent AID;省略时从当前运行环境推断
|
|
80
|
+
--role <role-id> 申请提升到的角色(不能是 owner)
|
|
81
|
+
--status <status> 过滤请求状态
|
|
82
|
+
--reason <text> 申请或审批理由
|
|
83
|
+
--format json 输出 JSON
|
|
84
|
+
--help, -h 显示帮助`);
|
|
85
|
+
}
|
package/dist/cli/stats.js
CHANGED
|
@@ -142,9 +142,16 @@ async function resolveManagedStatsScope(flags, isJson, argv) {
|
|
|
142
142
|
if (!selfAid || !role || role === 'none') {
|
|
143
143
|
fail(isJson, 'NOT_ALLOWED', 'stats 在托管任务中需要已解析的关系身份与角色');
|
|
144
144
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
145
|
+
const fullAccessTask = runtime?.processRole === 'fullaccess-run'
|
|
146
|
+
&& runtime.dataScope === 'daemon' && runtime.permissionMode === 'fullaccess';
|
|
147
|
+
if (!fullAccessTask) {
|
|
148
|
+
for (const flag of MANAGED_FORBIDDEN_FLAGS) {
|
|
149
|
+
if (flags[flag])
|
|
150
|
+
fail(isJson, 'NOT_ALLOWED', `--${flag} 在托管任务中不可用`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (fullAccessTask) {
|
|
154
|
+
return { agentWide: true, agentAid: selfAid, role: 'fullaccess-run' };
|
|
148
155
|
}
|
|
149
156
|
if (AGENT_SCOPE_ROLES.has(role))
|
|
150
157
|
return { agentWide: true, agentAid: selfAid, role };
|
package/dist/cli/task-context.js
CHANGED
|
@@ -384,6 +384,25 @@ export async function readTaskRuntimeContextFromDaemon(sessionId, timeoutMs = 50
|
|
|
384
384
|
return undefined;
|
|
385
385
|
}
|
|
386
386
|
}
|
|
387
|
+
/**
|
|
388
|
+
* Fullaccess is a daemon-issued execution identity. Never infer it from the
|
|
389
|
+
* environment copy alone: child processes can receive that copy through an
|
|
390
|
+
* ordinary shell environment, while the daemon validates the bearer token and
|
|
391
|
+
* the live task grant before returning this context.
|
|
392
|
+
*/
|
|
393
|
+
export function isTrustedFullAccessRuntimeContext(context) {
|
|
394
|
+
return context?.permissionMode === 'fullaccess'
|
|
395
|
+
&& context.processRole === 'fullaccess-run'
|
|
396
|
+
&& context.dataScope === 'daemon'
|
|
397
|
+
&& typeof context.authorizedBy === 'string'
|
|
398
|
+
&& context.authorizedBy.length > 0;
|
|
399
|
+
}
|
|
400
|
+
export async function readVerifiedTaskRuntimeContext(env = process.env, timeoutMs = 1_000) {
|
|
401
|
+
const sessionId = env.EVOLCORE_SESSION_ID;
|
|
402
|
+
if (!sessionId || !readDelegationCredential(env))
|
|
403
|
+
return undefined;
|
|
404
|
+
return readTaskRuntimeContextFromDaemon(sessionId, timeoutMs, env);
|
|
405
|
+
}
|
|
387
406
|
export async function readBestTaskRuntimeContext(env = process.env) {
|
|
388
407
|
const envContext = readTaskRuntimeContextFromEnv(env);
|
|
389
408
|
const sessionId = env.EVOLCORE_SESSION_ID || envContext?.sessionId;
|
|
@@ -12,13 +12,16 @@ export class AccessPolicyError extends Error {
|
|
|
12
12
|
}
|
|
13
13
|
export const DEFAULT_ACCESS_POLICY = Object.freeze({
|
|
14
14
|
policyMode: 'open',
|
|
15
|
+
allowOwnerDirectoryContacts: true,
|
|
16
|
+
allowOwnerAgentDirectory: true,
|
|
17
|
+
allowExternalContacts: false,
|
|
15
18
|
requestLimit: Object.freeze({ maxTimes: 600, coolDown: 60 * 60 }),
|
|
16
19
|
});
|
|
17
20
|
export function listAgentOwners(selfAid) {
|
|
18
21
|
const agent = read(ConfigTarget.Agent, { self: selfAid }, { cache: true });
|
|
19
22
|
return validAgentOwnerIds(agent);
|
|
20
23
|
}
|
|
21
|
-
/** Missing AgentConfig.access
|
|
24
|
+
/** Missing AgentConfig.access disables ordinary external contacts; explicit policies are preserved. */
|
|
22
25
|
export function readAccessPolicy(selfAid) {
|
|
23
26
|
return readAccessPolicySnapshot(selfAid).policy;
|
|
24
27
|
}
|
|
@@ -91,7 +94,9 @@ function assertAccessPolicyWrite(input, agent, policy) {
|
|
|
91
94
|
function clonePolicy(policy) {
|
|
92
95
|
return {
|
|
93
96
|
policyMode: policy.policyMode,
|
|
94
|
-
|
|
97
|
+
allowOwnerDirectoryContacts: policy.allowOwnerDirectoryContacts ?? true,
|
|
98
|
+
allowOwnerAgentDirectory: policy.allowOwnerAgentDirectory ?? true,
|
|
99
|
+
allowExternalContacts: policy.allowExternalContacts ?? false,
|
|
95
100
|
allowedAids: [...(policy.allowedAids ?? [])],
|
|
96
101
|
requestLimit: { ...policy.requestLimit },
|
|
97
102
|
};
|
package/dist/config/boot-log.js
CHANGED
|
@@ -15,7 +15,7 @@ import { logger } from '../utils/logger.js';
|
|
|
15
15
|
import { autoMigrateIfNeeded } from '../config-store.js';
|
|
16
16
|
import { ConfigTarget, initConfigManager, notifyConfigWrite } from './config-manager.js';
|
|
17
17
|
import { ensureRoleConfigV4OnStartup, ensureRoleConfigV5OnStartup } from './role-migration-startup.js';
|
|
18
|
-
import { ensureAuxiliaryModelMigrationOnStartup } from './schema-migration.js';
|
|
18
|
+
import { ensureAgentModelProviderMigrationOnStartup, ensureAgentOnlyModelMigrationOnStartup, ensureAuxiliaryModelMigrationOnStartup, ensureProviderServiceTypeMigrationOnStartup, ensureRelationConfigVersionMigrationOnStartup } from './schema-migration.js';
|
|
19
19
|
import { ensureContactBookV2OnStartup } from './contact-book-v2-startup.js';
|
|
20
20
|
import { synchronizeAllManagementContactsSync } from './contact-book-store.js';
|
|
21
21
|
import { readInstalledEvolcoreVersion, readFastaunVersion } from '../utils/evolcore-version.js';
|
|
@@ -34,6 +34,44 @@ export async function prepareStartupConfig(recoverRoleMutations) {
|
|
|
34
34
|
logger.info(message);
|
|
35
35
|
console.error(message);
|
|
36
36
|
}
|
|
37
|
+
const agentOnlyModelMigration = await ensureAgentOnlyModelMigrationOnStartup();
|
|
38
|
+
if (agentOnlyModelMigration) {
|
|
39
|
+
const message = `✓ Agent model migration applied automatically: normalized ${agentOnlyModelMigration.changedFiles} file(s), registered ${agentOnlyModelMigration.summary.defaultsBaseagentsAdded ?? 0} backend name(s) in defaults`
|
|
40
|
+
+ (agentOnlyModelMigration.backup ? `; backup: ${agentOnlyModelMigration.backup}` : '');
|
|
41
|
+
logger.info(message);
|
|
42
|
+
console.error(message);
|
|
43
|
+
for (const detail of agentOnlyModelMigration.details) {
|
|
44
|
+
const actions = [...(detail.migrated ?? []), ...detail.removed];
|
|
45
|
+
logger.info(`[config] ${detail.file}: ${actions.length ? actions.join(', ') : 'registered missing backend names'}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const modelProviderMigration = await ensureAgentModelProviderMigrationOnStartup();
|
|
49
|
+
if (modelProviderMigration) {
|
|
50
|
+
const message = `✓ Agent model provider migration applied automatically: gateway information moved into providers.json, ${modelProviderMigration.changedFiles} file(s) updated`
|
|
51
|
+
+ (modelProviderMigration.backup ? `; backup: ${modelProviderMigration.backup}` : '');
|
|
52
|
+
logger.info(message);
|
|
53
|
+
console.error(message);
|
|
54
|
+
for (const detail of modelProviderMigration.details) {
|
|
55
|
+
logger.info(`[config] ${detail.file}${detail.removed.length ? `: removed ${detail.removed.join(', ')}` : ''}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const providerServiceTypeMigration = await ensureProviderServiceTypeMigrationOnStartup();
|
|
59
|
+
if (providerServiceTypeMigration) {
|
|
60
|
+
const message = `✓ Agent provider service type migration applied automatically: removed from ${providerServiceTypeMigration.changedFiles} config file(s)`
|
|
61
|
+
+ (providerServiceTypeMigration.backup ? `; backup: ${providerServiceTypeMigration.backup}` : '');
|
|
62
|
+
logger.info(message);
|
|
63
|
+
console.error(message);
|
|
64
|
+
for (const detail of providerServiceTypeMigration.details) {
|
|
65
|
+
logger.info(`[config] ${detail.file}: removed ${detail.removed.join(', ')}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const relationVersionMigration = await ensureRelationConfigVersionMigrationOnStartup();
|
|
69
|
+
if (relationVersionMigration) {
|
|
70
|
+
const message = `✓ Relation config version migration applied automatically: ${relationVersionMigration.changedFiles} file(s) restamped`
|
|
71
|
+
+ (relationVersionMigration.backup ? `; backup: ${relationVersionMigration.backup}` : '');
|
|
72
|
+
logger.info(message);
|
|
73
|
+
console.error(message);
|
|
74
|
+
}
|
|
37
75
|
const migration = await ensureRoleConfigV4OnStartup();
|
|
38
76
|
if (migration) {
|
|
39
77
|
const message = `✓ Role config v4 migration applied automatically: ${migration.changedFiles} file(s)`
|
|
@@ -21,16 +21,23 @@ const BEHAVIOR_TOP_FIELDS = new Set([
|
|
|
21
21
|
const BASEAGENT_BEHAVIOR_FIELDS = new Set([
|
|
22
22
|
'model',
|
|
23
23
|
'effort',
|
|
24
|
-
'auxiliaryModel',
|
|
25
|
-
'auxiliaryEffort',
|
|
26
24
|
'reasoning',
|
|
27
25
|
'agentProgressSummaries',
|
|
28
26
|
'excludeDynamicSections',
|
|
29
27
|
'enableRequestUserInput',
|
|
30
|
-
'approvalsReviewer',
|
|
31
|
-
'mode',
|
|
32
|
-
'useVertex',
|
|
33
28
|
]);
|
|
29
|
+
/** Model selection is Agent-owned; relation selectors may never read or write it. */
|
|
30
|
+
export function isAgentOnlyModelField(fieldPath) {
|
|
31
|
+
const parts = fieldPath.split('.');
|
|
32
|
+
return parts.length === 3
|
|
33
|
+
&& parts[0] === 'baseagents'
|
|
34
|
+
&& SUPPORTED_BASEAGENTS.has(parts[1])
|
|
35
|
+
&& (parts[2] === 'model' || parts[2] === 'effort' || parts[2] === 'reasoning');
|
|
36
|
+
}
|
|
37
|
+
/** Baseagent selection is Agent-owned as well. */
|
|
38
|
+
export function isAgentOnlyBaseagentField(fieldPath) {
|
|
39
|
+
return fieldPath === 'active_baseagent' || fieldPath === 'baseagents' || isAgentOnlyModelField(fieldPath);
|
|
40
|
+
}
|
|
34
41
|
const SUPPORTED_BASEAGENTS = new Set(['claude', 'codex', 'gemini', 'ecagent']);
|
|
35
42
|
/** Public behavior fields for a runner this version does not implement. */
|
|
36
43
|
export function isUnsupportedBaseagentConfigField(fieldPath) {
|
|
@@ -52,10 +59,10 @@ const SENSITIVE_TOP_FIELDS = new Set([
|
|
|
52
59
|
'owners',
|
|
53
60
|
'access',
|
|
54
61
|
'fullaccess',
|
|
62
|
+
'sessionFullAccess',
|
|
55
63
|
'admins',
|
|
56
64
|
'channels',
|
|
57
65
|
'aun',
|
|
58
|
-
'models',
|
|
59
66
|
'projects',
|
|
60
67
|
'capabilities',
|
|
61
68
|
'debug',
|
|
@@ -63,7 +70,6 @@ const SENSITIVE_TOP_FIELDS = new Set([
|
|
|
63
70
|
'roles',
|
|
64
71
|
'role',
|
|
65
72
|
'extra_backup',
|
|
66
|
-
'decision_model',
|
|
67
73
|
]);
|
|
68
74
|
const CRITICAL_AGENT_FIELDS = new Set(['owner', 'owners', 'admins', 'roles', 'access']);
|
|
69
75
|
const EFFORTS = new Set(['low', 'medium', 'high', 'xhigh', 'max']);
|
|
@@ -99,19 +105,13 @@ export function resolveConfigFieldRule(fieldPath, scope) {
|
|
|
99
105
|
const [, baseagent, leaf] = parts;
|
|
100
106
|
if (!SUPPORTED_BASEAGENTS.has(baseagent))
|
|
101
107
|
return { class: 'unknown' };
|
|
102
|
-
const normalizedLeaf = leaf === 'reasoning'
|
|
103
|
-
? 'effort'
|
|
104
|
-
: leaf === 'auxiliaryModel'
|
|
105
|
-
? 'model'
|
|
106
|
-
: leaf === 'auxiliaryEffort'
|
|
107
|
-
? 'effort'
|
|
108
|
-
: leaf;
|
|
108
|
+
const normalizedLeaf = leaf === 'reasoning' ? 'effort' : leaf;
|
|
109
109
|
const permissionKey = `baseagents.${baseagent}.${normalizedLeaf}`;
|
|
110
110
|
if (leaf === 'provider' && parts.length === 3)
|
|
111
111
|
return scalar(permissionKey, 'string', 'owner-only');
|
|
112
|
-
if (
|
|
112
|
+
if (leaf === 'model' && parts.length === 3)
|
|
113
113
|
return scalar(permissionKey, 'string');
|
|
114
|
-
if ((leaf === 'effort' || leaf === 'reasoning'
|
|
114
|
+
if ((leaf === 'effort' || leaf === 'reasoning') && parts.length === 3)
|
|
115
115
|
return scalar(permissionKey, 'effort');
|
|
116
116
|
if (baseagent === 'claude' && (leaf === 'agentProgressSummaries' || leaf === 'excludeDynamicSections') && parts.length === 3) {
|
|
117
117
|
return scalar(permissionKey, 'boolean');
|
|
@@ -119,13 +119,6 @@ export function resolveConfigFieldRule(fieldPath, scope) {
|
|
|
119
119
|
if (baseagent === 'codex' && leaf === 'enableRequestUserInput' && parts.length === 3) {
|
|
120
120
|
return scalar(permissionKey, 'boolean');
|
|
121
121
|
}
|
|
122
|
-
if (baseagent === 'codex' && leaf === 'approvalsReviewer' && parts.length === 3) {
|
|
123
|
-
return scalar(permissionKey, 'approvals-reviewer');
|
|
124
|
-
}
|
|
125
|
-
if (baseagent === 'gemini' && leaf === 'mode' && parts.length === 3)
|
|
126
|
-
return scalar(permissionKey, 'gemini-mode');
|
|
127
|
-
if (baseagent === 'gemini' && leaf === 'useVertex' && parts.length === 3)
|
|
128
|
-
return scalar(permissionKey, 'boolean');
|
|
129
122
|
return { class: 'sensitive' };
|
|
130
123
|
}
|
|
131
124
|
if (field === 'active_baseagent')
|
|
@@ -228,8 +221,8 @@ export function resolveConfigFieldRule(fieldPath, scope) {
|
|
|
228
221
|
// 数值参数:整理节奏与容量上限,均 owner-only
|
|
229
222
|
if (field === 'memory.idleHours'
|
|
230
223
|
|| field === 'memory.maxUnconsolidatedHours'
|
|
224
|
+
|| field === 'memory.minBatchItems'
|
|
231
225
|
|| field === 'memory.checkIntervalHours'
|
|
232
|
-
|| field === 'memory.backlogHours'
|
|
233
226
|
|| field === 'memory.indexMaxBytes'
|
|
234
227
|
|| field === 'memory.forgetAfterDays'
|
|
235
228
|
|| field === 'memory.profileRegenDays') {
|
|
@@ -269,13 +262,6 @@ export function relationFieldWriteOperation(fieldPath) {
|
|
|
269
262
|
}
|
|
270
263
|
if (field === 'mentionMode')
|
|
271
264
|
return 'mentionmode.update';
|
|
272
|
-
if (/^baseagents\.[^.]+\.model$/.test(field))
|
|
273
|
-
return 'model.use';
|
|
274
|
-
if (/^baseagents\.[^.]+\.auxiliaryModel$/.test(field))
|
|
275
|
-
return 'model.use';
|
|
276
|
-
if (/^baseagents\.[^.]+\.(?:effort|reasoning|auxiliaryEffort)$/.test(field)) {
|
|
277
|
-
return 'model.effort';
|
|
278
|
-
}
|
|
279
265
|
return undefined;
|
|
280
266
|
}
|
|
281
267
|
export function parseConfigFieldValue(fieldPath, rawValue) {
|
|
@@ -339,14 +325,6 @@ export function parseConfigFieldValue(fieldPath, rawValue) {
|
|
|
339
325
|
return raw === 'all' || raw === 'text' || raw === 'none'
|
|
340
326
|
? { ok: true, value: raw }
|
|
341
327
|
: { ok: false, reason: `Config field ${fieldPath} must be all, text, or none` };
|
|
342
|
-
case 'approvals-reviewer':
|
|
343
|
-
return ['user', 'auto_review', 'guardian_subagent'].includes(raw)
|
|
344
|
-
? { ok: true, value: raw }
|
|
345
|
-
: { ok: false, reason: `Config field ${fieldPath} has an invalid approvals reviewer` };
|
|
346
|
-
case 'gemini-mode':
|
|
347
|
-
return raw === 'cli' || raw === 'sdk'
|
|
348
|
-
? { ok: true, value: raw }
|
|
349
|
-
: { ok: false, reason: `Config field ${fieldPath} must be cli or sdk` };
|
|
350
328
|
case 'manifest-file':
|
|
351
329
|
return /^[A-Za-z0-9_-]+\.json$/.test(raw)
|
|
352
330
|
? { ok: true, value: raw }
|