evolcore 0.0.47 → 0.0.48
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 +56 -1
- package/bin/ec-build.mjs +86 -0
- package/dist/agent-template/jobs.js +12 -4
- package/dist/agent-template/runtime.js +139 -39
- package/dist/agent-template/service.js +66 -13
- package/dist/agents/baseagent.js +60 -20
- package/dist/agents/claude-runner.js +34 -17
- package/dist/agents/codex-runner.js +31 -16
- package/dist/agents/ecagent-runner.js +7 -4
- package/dist/agents/gemini-runner.js +5 -2
- package/dist/agents/runner-types.js +5 -21
- package/dist/aun/aid/agentmd.js +5 -1
- package/dist/aun/service-proxy.js +4 -2
- package/dist/build-identity.json +1 -0
- package/dist/channels/aun.js +81 -24
- package/dist/channels/daemon.js +9 -25
- package/dist/cli/aun-commands.js +86 -51
- package/dist/cli/code-stats.js +19 -8
- package/dist/cli/command-log.js +1 -1
- package/dist/cli/daemon-commands.js +44 -43
- package/dist/cli/directory.js +7 -1
- package/dist/cli/ecmsg-gateway.js +5 -2
- package/dist/cli/index.js +2 -8
- package/dist/cli/init-channel.js +4 -6
- package/dist/cli/init.js +72 -50
- package/dist/cli/invoke-command.js +1 -1
- package/dist/cli/provider-command.js +74 -13
- package/dist/cli/role.js +61 -17
- package/dist/cli/stats.js +3 -3
- package/dist/cli/thread-command.js +16 -51
- package/dist/config/boot-log.js +3 -9
- package/dist/config/builtin-roles.js +5 -7
- package/dist/config/config-manager.js +2 -6
- package/dist/config/daemon-services.js +30 -3
- package/dist/config/gateway-config.js +2 -2
- package/dist/config/invoke-ipc-service.js +6 -4
- package/dist/config/peer-bind-code.js +3 -4
- package/dist/config/peer-book-store.js +62 -229
- package/dist/config/peer-book.js +26 -27
- package/dist/config/peer-role-resolver.js +16 -1
- package/dist/config/provider-identity-migration.js +4 -1
- package/dist/config/provider-ipc-service.js +56 -11
- package/dist/config/provider-menu-request.js +24 -5
- package/dist/config/provider-templates.js +127 -0
- package/dist/config/providers-config.js +59 -8
- package/dist/config/providers-management.js +467 -49
- package/dist/config/role-command-service.js +248 -1
- package/dist/config/schema-migration.js +105 -4
- package/dist/core/agent-application-service.js +6 -1
- package/dist/core/agent-runtime.js +4 -0
- package/dist/core/auth/agent-delegation.js +2 -1
- package/dist/core/auth/auth-gateway.js +2 -1
- package/dist/core/auth/delegation-authorization.js +3 -0
- package/dist/core/auth/operation-authorizer.js +25 -0
- package/dist/core/auth/operation-catalog.js +28 -64
- package/dist/core/capability/providers/codex-capability-provider.js +7 -8
- package/dist/core/channel-loader.js +18 -0
- package/dist/core/command/agent-control.js +32 -0
- package/dist/core/command/command-handler.js +81 -85
- package/dist/core/command/menu-catalog.js +1 -0
- package/dist/core/command/menu-handler.js +61 -149
- package/dist/core/command/menu-protocol.js +7 -1
- package/dist/core/command/provider-menu.js +13 -3
- package/dist/core/command/role-menu.js +47 -23
- package/dist/core/command/slash-handler.js +26 -43
- package/dist/core/command/team-workspace-items.js +81 -12
- package/dist/core/command/team-workspace-team.js +9 -71
- package/dist/core/command/topic-slash.js +9 -30
- package/dist/core/daemon-bootstrap.js +8 -1
- package/dist/core/daemon-control.js +7 -7
- package/dist/core/evolagent-registry.js +14 -1
- package/dist/core/file-integrity/store.js +2 -0
- package/dist/core/handoff/runtime.js +37 -1
- package/dist/core/inference/text-inference.js +3 -1
- package/dist/core/initialization/service.js +11 -6
- package/dist/core/interaction-router.js +3 -0
- package/dist/core/invoke/executors/text.js +72 -19
- package/dist/core/ipc-registration.js +2 -1
- package/dist/core/message/aun-ipc-sender.js +165 -55
- package/dist/core/message/im-renderer.js +1 -1
- package/dist/core/message/message-bridge.js +51 -334
- package/dist/core/message/message-log.js +5 -0
- package/dist/core/message/message-queue.js +22 -0
- package/dist/core/message/message-utils.js +8 -0
- package/dist/core/message/response-engine.js +429 -116
- package/dist/core/message/send-routing.js +5 -1
- package/dist/core/model/catalog-service.js +31 -11
- package/dist/core/model/model-capabilities.js +22 -4
- package/dist/core/model/model-catalog.js +1 -0
- package/dist/core/ownership/owner-resolver.js +328 -50
- package/dist/core/permission/protected-paths.js +6 -6
- package/dist/core/relation/peer-identity.js +23 -1
- package/dist/core/relation/same-owner-proof.js +81 -112
- package/dist/core/session/adapters/codex-session-file-adapter.js +96 -15
- package/dist/core/session/session-file-health.js +13 -7
- package/dist/core/session/session-fs-store.js +91 -35
- package/dist/core/session/session-manager.js +68 -24
- package/dist/core/session/session-mapper.js +14 -34
- package/dist/core/session/session-transcript.js +5 -1
- package/dist/core/task/task-activity-store.js +84 -0
- package/dist/core/task/task-recovery-service.js +12 -0
- package/dist/core/thread/command-parser.js +7 -12
- package/dist/core/thread/thread-context-storage.js +3 -2
- package/dist/core/thread/thread-operation.js +2 -13
- package/dist/core/thread/thread-service.js +15 -46
- package/dist/directory/owner-directory-admission.js +1 -1
- package/dist/directory/owner-directory-cache.js +45 -28
- package/dist/directory/owner-directory-markdown.js +13 -1
- package/dist/directory/owner-directory-query-operation.js +29 -3
- package/dist/directory/owner-directory-remarks.js +11 -3
- package/dist/eck/message-renderer.js +84 -24
- package/dist/ecweb/basic-settings-service.js +3 -1
- package/dist/ecweb/message-context-service.js +1 -1
- package/dist/ecweb/pairing.js +4 -3
- package/dist/ecweb/providers-service.js +26 -1
- package/dist/ecweb/runtime/lifecycle.js +18 -8
- package/dist/ecweb/runtime/proxy-access.js +74 -0
- package/dist/ecweb/runtime/supervisor.js +4 -2
- package/dist/event-center/registry.js +13 -2
- package/dist/event-center/runtime.js +103 -11
- package/dist/event-center/script-runner.js +5 -5
- package/dist/index.js +92 -59
- package/dist/ipc.js +13 -2
- package/dist/outputs/events.js +62 -0
- package/dist/outputs/protocol.js +102 -0
- package/dist/outputs/service.js +279 -0
- package/dist/paths.js +3 -0
- package/dist/proxy/manager.js +43 -13
- package/dist/services/index.js +89 -4
- package/dist/services/ipc-operation.js +4 -15
- package/dist/services/pack-manager.js +12 -1
- package/dist/services/router.js +21 -6
- package/dist/services/script-runner.js +5 -4
- package/dist/services/validation.js +1 -1
- package/dist/stats/budget.js +1 -1
- package/dist/stats/db.js +19 -0
- package/dist/stats/index.js +1 -1
- package/dist/stats/{price-resolver.js → model-resolver.js} +305 -24
- package/dist/stats/normalizer.js +2 -0
- package/dist/stats/query.js +35 -27
- package/dist/stats/role-budget.js +5 -2
- package/dist/stats/writer.js +10 -6
- package/dist/trigger/audit.js +7 -0
- package/dist/trigger/authorization.js +105 -11
- package/dist/trigger/feedback.js +10 -0
- package/dist/trigger/history.js +37 -11
- package/dist/trigger/ipc-service.js +12 -1
- package/dist/trigger/manager.js +1 -0
- package/dist/trigger/scheduler.js +7 -5
- package/dist/trigger/script-executor.js +2 -1
- package/dist/trigger/script-sandbox.js +9 -3
- package/dist/trigger/validation.js +22 -0
- package/dist/utils/cross-platform.js +73 -26
- package/dist/utils/error-dict.json +94 -4
- package/dist/utils/error-utils.js +27 -4
- package/dist/utils/evolcore-version.js +36 -65
- package/dist/utils/msg-diag.js +1 -0
- package/dist/utils/process-introspect.js +12 -7
- package/dist/utils/process-tree.js +50 -2
- package/dist/utils/windows-shell-trust.js +2 -0
- package/dist/workbench/protocol.js +80 -0
- package/dist/workbench/service.js +359 -0
- package/ecagent/dist/types.d.ts +6 -2
- package/kits/docs/context-assembly.md +1 -1
- package/kits/docs/evolcore/INDEX.md +2 -2
- package/kits/docs/evolcore/config.md +12 -0
- package/kits/docs/evolcore/directory.md +22 -3
- package/kits/docs/evolcore/ecweb-lifecycle.md +15 -0
- package/kits/docs/evolcore/model.md +10 -0
- package/kits/docs/evolcore/peer.md +19 -65
- package/kits/docs/evolcore/provider.md +123 -3
- package/kits/docs/evolcore/role.md +80 -0
- package/kits/docs/evolcore/services.md +6 -6
- package/kits/docs/evolcore/team-workspace.md +1 -1
- package/kits/docs/evolcore/thread-chain.md +14 -15
- package/kits/docs/evolcore/tool-authorization.md +5 -0
- package/kits/docs/evolcore/trigger.md +10 -0
- package/kits/eck_message_manifest.json +12 -0
- package/kits/provider-templates.json +1213 -0
- package/kits/rules/04-relation.md +3 -3
- package/kits/schemas/_meta.json +14 -2
- package/kits/schemas/contact-book.schema.4.json +52 -0
- package/kits/schemas/providers.schema.3.json +200 -0
- package/kits/skills/.switches.json +4 -0
- package/kits/skills/ability/references/calling.md +1 -1
- package/kits/skills/ec-group/SKILL.md +2 -2
- package/kits/skills/ec-identity/SKILL.md +19 -72
- package/kits/skills/ec-provider/SKILL.md +221 -0
- package/kits/skills/ec-provider/scripts/check-model.mjs +80 -0
- package/kits/skills/ec-trigger/SKILL.md +1 -1
- package/kits/skills/thread-ops/SKILL.md +34 -21
- package/kits/templates/message-fragments/group-batch-item.md +1 -1
- package/kits/templates/message-fragments/group-batch.md +1 -1
- package/kits/templates/message-fragments/inject-default.md +1 -1
- package/kits/templates/message-fragments/interrupt-insert.md +1 -0
- package/kits/templates/message-fragments/item-group.md +1 -1
- package/kits/templates/message-fragments/item-private.md +1 -1
- package/kits/templates/message-fragments/thread-context.md +1 -1
- package/kits/templates/message-fragments/trigger-session.md +1 -1
- package/kits/templates/message-fragments/trigger-thread-check.md +1 -1
- package/kits/templates/roles/admin.json +2 -19
- package/kits/templates/roles/member.json +0 -3
- package/kits/templates/system-fragments/baseagent.md +6 -0
- package/kits/templates/system-fragments/commands.md +3 -3
- package/kits/templates/system-fragments/managed-runtime.md +1 -1
- package/kits/templates/system-fragments/relation.md +1 -1
- package/kits/templates/system-fragments/thread.md +6 -5
- package/package.json +6 -4
- package/scripts/agent-template/inspect.mjs +4 -1
- package/scripts/agent-template/shared/common.mjs +2 -3
- package/scripts/agent-template/shared/template-contract.mjs +2 -1
- package/scripts/agent-template/shared/template-package.mjs +9 -2
- package/scripts/agent-template/shared/template-runtime.mjs +20 -5
- package/scripts/agent-template/team-pack.mjs +6 -3
- package/dist/cli/peer.js +0 -127
- package/dist/config/peer-operation-service.js +0 -132
- package/dist/config/peer-request-service.js +0 -532
- package/dist/core/command/connect-menu.js +0 -624
|
@@ -5,7 +5,7 @@ import { canonicalizeEvolcoreCommandArgv } from '../core/permission/ec-command-p
|
|
|
5
5
|
import { isMainSessionThreadId, resolveThreadRef } from '../core/thread/topic-id.js';
|
|
6
6
|
import { parseTimeArg, TIME_ARG_FORMATS } from './cli-argv.js';
|
|
7
7
|
import { readTaskRuntimeContextFromEnv } from './task-context.js';
|
|
8
|
-
const TOPIC_STATUSES = ['
|
|
8
|
+
const TOPIC_STATUSES = ['active', 'closed', 'archived'];
|
|
9
9
|
const SORT_ORDERS = ['recent', 'created'];
|
|
10
10
|
const HELP_TEXT = `
|
|
11
11
|
用法: ec thread <command> [options]
|
|
@@ -17,8 +17,7 @@ const HELP_TEXT = `
|
|
|
17
17
|
history <ref> 读取话题历史消息
|
|
18
18
|
create <peer> --name 新建话题(对端类型按关系证据自动识别,--group/--private 可覆盖)
|
|
19
19
|
rename <ref> <名称> 修改话题名称(仅本端)
|
|
20
|
-
|
|
21
|
-
status <ref> <状态> 更新话题业务状态
|
|
20
|
+
status <ref> <状态> 更新话题状态(active|closed|archived)
|
|
22
21
|
delete <ref> 删除话题(session 文件移入 _trash)
|
|
23
22
|
summary show <ref> 查看当前 summary
|
|
24
23
|
summary set <ref> <内容> --name <新标题|-> 写入 summary(--name 必填;- 表示不改名)
|
|
@@ -39,9 +38,7 @@ const HELP_TEXT = `
|
|
|
39
38
|
main:<aidA>:<aidB> 主话题
|
|
40
39
|
|
|
41
40
|
list 选项:
|
|
42
|
-
--status <s> 过滤状态 (
|
|
43
|
-
--label <l> 过滤标签
|
|
44
|
-
--unlabeled 仅未标记话题
|
|
41
|
+
--status <s> 过滤状态 (active|closed|archived)
|
|
45
42
|
--sort recent|created 排序方式(默认 recent)
|
|
46
43
|
--page <n> 页码
|
|
47
44
|
--limit <n> 每页条数
|
|
@@ -68,14 +65,13 @@ summary set 选项:
|
|
|
68
65
|
|
|
69
66
|
create 选项:
|
|
70
67
|
--name <名称> 话题名称(必填)
|
|
71
|
-
--
|
|
72
|
-
--status <状态> 初始状态(默认 pending)
|
|
68
|
+
--status <状态> 初始状态(默认 active)
|
|
73
69
|
--group 群话题(默认私聊)
|
|
74
70
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
71
|
+
状态值: active | closed | archived
|
|
72
|
+
active 默认。正常讨论,收到消息即处理。
|
|
73
|
+
closed 模型判定讨论完毕。收到新消息自动回退 active。
|
|
74
|
+
archived 不再响应。收到消息回复"话题已归档"(群聊静默丢弃)。
|
|
79
75
|
|
|
80
76
|
--format json 以 JSON 格式输出
|
|
81
77
|
--self <selfAid> 宿主终端必填,指定本端 AID;托管会话由运行时注入,不写
|
|
@@ -142,16 +138,12 @@ function printEmptyThreadList(result, echoSelf) {
|
|
|
142
138
|
const filters = [];
|
|
143
139
|
if (result.status)
|
|
144
140
|
filters.push(`--status ${result.status}`);
|
|
145
|
-
if (result.label)
|
|
146
|
-
filters.push(`--label "${result.label}"`);
|
|
147
|
-
if (result.unlabeled)
|
|
148
|
-
filters.push('--unlabeled');
|
|
149
141
|
console.log(` 原因: 该对端共 ${result.peerTopicCount} 个话题,均不匹配${filters.length ? ' ' + filters.join(' ') : '当前过滤条件'}`);
|
|
150
142
|
console.log(` 下一步: ec thread list ${peer}${self} # 去掉过滤条件`);
|
|
151
143
|
return;
|
|
152
144
|
}
|
|
153
145
|
if (result.hasMainChat) {
|
|
154
|
-
console.log(' 原因:
|
|
146
|
+
console.log(' 原因: 该对端只有主话题往来,没有独立话题;主话题不参与状态过滤');
|
|
155
147
|
console.log(` 下一步: ec thread history ${peer}${self}`);
|
|
156
148
|
return;
|
|
157
149
|
}
|
|
@@ -202,7 +194,7 @@ function printItem(item, opts) {
|
|
|
202
194
|
// 打印的就是可直接作为 `--thread` 的值:话题是 threadId,主话题是
|
|
203
195
|
// `main:<aid>:<aid>`。不再拼 `<peer>/` 前缀——那种写法从不可消费。
|
|
204
196
|
console.log(`${obj.threadId}${running}${internal}`);
|
|
205
|
-
//
|
|
197
|
+
// 名称只放名称本身:状态单独一行,避免污染标题(标题会被 summary set --name 引用)。
|
|
206
198
|
// 主话题加 `[主话题]` 前缀,与话题区分开;前缀只在展示层加,
|
|
207
199
|
// 不进索引与 session 的 name 字段,避免被 summary set --name 当成真实标题。
|
|
208
200
|
const namePrefix = isMainSessionThreadId(obj.threadId) ? '[主话题] ' : '';
|
|
@@ -212,10 +204,8 @@ function printItem(item, opts) {
|
|
|
212
204
|
console.log(` 名称: ${namePrefix}${displayName}`);
|
|
213
205
|
if (isMainSessionThreadId(String(obj.threadId)))
|
|
214
206
|
console.log(' 状态: 不适用(主话题没有业务状态)');
|
|
215
|
-
else if (obj.topicStatus)
|
|
207
|
+
else if (obj.topicStatus && obj.topicStatus !== 'active')
|
|
216
208
|
console.log(` 状态: ${obj.topicStatus}`);
|
|
217
|
-
if (obj.label)
|
|
218
|
-
console.log(` 标签: ${obj.label}`);
|
|
219
209
|
if (obj.createdAt)
|
|
220
210
|
console.log(` 创建: ${new Date(obj.createdAt).toLocaleString('zh-CN')}`);
|
|
221
211
|
// list 场景下 lastActiveAt 已由消息日志派生,故称"活跃";show 场景下它仍是索引里的
|
|
@@ -279,8 +269,7 @@ function printItem(item, opts) {
|
|
|
279
269
|
const selfArg = opts?.echoSelf ? ` --self ${opts.echoSelf}` : '';
|
|
280
270
|
const sortArg = result.sort ? ` --sort ${result.sort}` : ' --sort recent';
|
|
281
271
|
const statusArg = result.status ? ` --status ${result.status}` : '';
|
|
282
|
-
|
|
283
|
-
console.log(`下一页: ec thread list ${peerArg}${selfArg} --page ${nextPage} --limit ${result.limit}${sortArg}${statusArg}${labelArg}`);
|
|
272
|
+
console.log(`下一页: ec thread list ${peerArg}${selfArg} --page ${nextPage} --limit ${result.limit}${sortArg}${statusArg}`);
|
|
284
273
|
}
|
|
285
274
|
return;
|
|
286
275
|
}
|
|
@@ -366,11 +355,9 @@ export async function runThreadCommand(args) {
|
|
|
366
355
|
process.exitCode = 1;
|
|
367
356
|
return;
|
|
368
357
|
}
|
|
369
|
-
const label = argValue(args, '--label');
|
|
370
|
-
const unlabeled = hasFlag(args, '--unlabeled');
|
|
371
358
|
const page = argValue(args, '--page') ? Number(argValue(args, '--page')) : undefined;
|
|
372
359
|
const limit = argValue(args, '--limit') ? Number(argValue(args, '--limit')) : undefined;
|
|
373
|
-
const resp = await sendOp({ op: 'list', selfAid, peer, status: statusVal,
|
|
360
|
+
const resp = await sendOp({ op: 'list', selfAid, peer, status: statusVal, sort: sortVal, page, limit });
|
|
374
361
|
if (!resp.ok) {
|
|
375
362
|
console.error(`✗ ${resp.error}`);
|
|
376
363
|
process.exitCode = 1;
|
|
@@ -460,14 +447,13 @@ export async function runThreadCommand(args) {
|
|
|
460
447
|
process.exitCode = 1;
|
|
461
448
|
return;
|
|
462
449
|
}
|
|
463
|
-
const label = argValue(args, '--label');
|
|
464
450
|
const topicStatus = argValue(args, '--status');
|
|
465
451
|
// 对端类型:显式 --group / --private 优先;都不写时 daemon 侧按关系证据
|
|
466
452
|
// 推断(这里不能自行补值——daemon 会用 argv 重建请求,两者必须一致)。
|
|
467
453
|
const peerKind = hasFlag(args, '--group')
|
|
468
454
|
? 'group'
|
|
469
455
|
: hasFlag(args, '--private') ? 'private' : undefined;
|
|
470
|
-
const resp = await sendOp({ op: 'create', selfAid, peer, name,
|
|
456
|
+
const resp = await sendOp({ op: 'create', selfAid, peer, name, topicStatus, peerKind });
|
|
471
457
|
if (!resp.ok) {
|
|
472
458
|
console.error(`✗ ${resp.error}`);
|
|
473
459
|
process.exitCode = 1;
|
|
@@ -503,27 +489,6 @@ export async function runThreadCommand(args) {
|
|
|
503
489
|
printResult(resp.result, jsonFormat);
|
|
504
490
|
break;
|
|
505
491
|
}
|
|
506
|
-
case 'label': {
|
|
507
|
-
const ref = args[1];
|
|
508
|
-
if (!ref) {
|
|
509
|
-
console.error('用法: ec thread label <ref> <标签>');
|
|
510
|
-
process.exitCode = 1;
|
|
511
|
-
return;
|
|
512
|
-
}
|
|
513
|
-
const target = resolveRef(ref);
|
|
514
|
-
if (!target)
|
|
515
|
-
return;
|
|
516
|
-
const { peer, threadId } = target;
|
|
517
|
-
const label = hasFlag(args, '--clear') ? null : args[2] ?? null;
|
|
518
|
-
const resp = await sendOp({ op: 'label', selfAid, peer, threadId, label });
|
|
519
|
-
if (!resp.ok) {
|
|
520
|
-
console.error(`✗ ${resp.error}`);
|
|
521
|
-
process.exitCode = 1;
|
|
522
|
-
return;
|
|
523
|
-
}
|
|
524
|
-
console.log(label === null ? '✓ 标签已清除' : `✓ 标签设为: ${label}`);
|
|
525
|
-
break;
|
|
526
|
-
}
|
|
527
492
|
case 'status': {
|
|
528
493
|
const ref = args[1];
|
|
529
494
|
const statusVal = args[2];
|
|
@@ -590,7 +555,7 @@ export async function runThreadCommand(args) {
|
|
|
590
555
|
}
|
|
591
556
|
else {
|
|
592
557
|
if (missing > 0) {
|
|
593
|
-
console.warn(`⚠ [严重] ${missing} 条话题 session 文件缺失——rebuild 后这些话题的 rename/
|
|
558
|
+
console.warn(`⚠ [严重] ${missing} 条话题 session 文件缺失——rebuild 后这些话题的 rename/status 改动将回退`);
|
|
594
559
|
}
|
|
595
560
|
if (stale > 0) {
|
|
596
561
|
console.warn(`⚠ [轻微] ${stale} 条话题属性与 session 文件最后一行不一致(写盘时序),rebuild-index 可修复`);
|
|
@@ -623,7 +588,7 @@ export async function runThreadCommand(args) {
|
|
|
623
588
|
}
|
|
624
589
|
else {
|
|
625
590
|
if (missing > 0) {
|
|
626
|
-
console.warn(`⚠ [严重] ${missing} 条话题 session 文件缺失——rebuild 后这些话题的 rename/
|
|
591
|
+
console.warn(`⚠ [严重] ${missing} 条话题 session 文件缺失——rebuild 后这些话题的 rename/status 改动将回退`);
|
|
627
592
|
}
|
|
628
593
|
if (stale > 0) {
|
|
629
594
|
console.warn(`⚠ [轻微] ${stale} 条话题属性与 session 文件最后一行不一致(写盘时序),rebuild-index 可修复`);
|
package/dist/config/boot-log.js
CHANGED
|
@@ -15,9 +15,8 @@ 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 { ensureAccessPolicyMigrationOnStartup, ensureAgentModelProviderMigrationOnStartup, ensureAgentOnlyModelMigrationOnStartup, ensureAuxiliaryModelMigrationOnStartup, ensurePeerFileRenameOnStartup, ensureStartupConfigCompatibilityMigrationOnStartup, ensureProviderServiceTypeMigrationOnStartup, ensureProviderIdentityMigrationOnStartup, ensureRelationConfigVersionMigrationOnStartup, invalidateMigrationReadCache, withMigrationReadCache, } from './schema-migration.js';
|
|
18
|
+
import { ensureAccessPolicyMigrationOnStartup, ensureAgentModelProviderMigrationOnStartup, ensureAgentOnlyModelMigrationOnStartup, ensureAuxiliaryModelMigrationOnStartup, ensurePeerFileRenameOnStartup, ensurePeerStateOnStartup, ensureStartupConfigCompatibilityMigrationOnStartup, ensureProviderServiceTypeMigrationOnStartup, ensureProviderIdentityMigrationOnStartup, ensureRelationConfigVersionMigrationOnStartup, invalidateMigrationReadCache, withMigrationReadCache, } from './schema-migration.js';
|
|
19
19
|
import { ensureContactBookV2OnStartup } from './peer-book-v2-startup.js';
|
|
20
|
-
import { synchronizeAllManagementPeersSync } from './peer-book-store.js';
|
|
21
20
|
import { readInstalledEvolcoreVersion, readFastaunVersion } from '../utils/evolcore-version.js';
|
|
22
21
|
import { readCurrent, readWVersion, writeWVersion, materializeVersion, listAllVersions, diffVersions, snapshot, isConfigSnapshotsEnabled, ensureStartupConfigSnapshot, incrementSuccessCount, retentionCleanup, writeSnapshotConfigFile, removeSnapshotConfigFile, snapshotManagesFile, } from './snapshot.js';
|
|
23
22
|
const MAX_LINES = 300;
|
|
@@ -162,6 +161,8 @@ export async function prepareStartupConfig(recoverRoleMutations, onStep) {
|
|
|
162
161
|
logger.info(message);
|
|
163
162
|
console.error(message);
|
|
164
163
|
}
|
|
164
|
+
step('peerState');
|
|
165
|
+
await ensurePeerStateOnStartup();
|
|
165
166
|
step('contactBook');
|
|
166
167
|
const contactMigration = await ensureContactBookV2OnStartup();
|
|
167
168
|
if (contactMigration) {
|
|
@@ -170,13 +171,6 @@ export async function prepareStartupConfig(recoverRoleMutations, onStep) {
|
|
|
170
171
|
logger.info(message);
|
|
171
172
|
console.error(message);
|
|
172
173
|
}
|
|
173
|
-
step('syncContacts');
|
|
174
|
-
const synchronizedContacts = synchronizeAllManagementPeersSync();
|
|
175
|
-
if (synchronizedContacts > 0) {
|
|
176
|
-
const message = `✓ Contact management identities synchronized: ${synchronizedContacts} agent(s)`;
|
|
177
|
-
logger.info(message);
|
|
178
|
-
console.error(message);
|
|
179
|
-
}
|
|
180
174
|
}
|
|
181
175
|
export async function initializeStartupConfig(abort) {
|
|
182
176
|
try {
|
|
@@ -32,12 +32,10 @@ export function getBuiltinRolesConfig() {
|
|
|
32
32
|
*/
|
|
33
33
|
export function getManagementCommandPermissions(role) {
|
|
34
34
|
return {
|
|
35
|
-
'
|
|
36
|
-
'
|
|
37
|
-
'
|
|
38
|
-
'
|
|
39
|
-
'role.assign': { allow: true, scopes: ['agent'] },
|
|
40
|
-
'role.revoke': { allow: true, scopes: ['agent'] },
|
|
35
|
+
'agent.access.read': { allow: true, scopes: ['agent'], constraints: { requireAgentOwner: true } },
|
|
36
|
+
'agent.access.write': { allow: true, scopes: ['agent'], constraints: { requireAgentOwner: true } },
|
|
37
|
+
'role.assign': { allow: true, scopes: ['agent'], constraints: { requireAgentOwner: true, targetCurrentAgentOnly: true } },
|
|
38
|
+
'role.revoke': { allow: true, scopes: ['agent'], constraints: { requireAgentOwner: true, targetCurrentAgentOnly: true } },
|
|
41
39
|
'role.policy.read': { allow: true, scopes: ['agent'] },
|
|
42
40
|
'role.relation.read': { allow: true, scopes: ['agent'] },
|
|
43
41
|
'agent.baseagent.update': { allow: true, scopes: ['agent'], constraints: { requireAgentOwner: true, targetCurrentAgentOnly: true } },
|
|
@@ -57,7 +55,7 @@ export function getManagementCommandPermissions(role) {
|
|
|
57
55
|
'config.get': { allow: true, scopes: ['agent', 'relation'] },
|
|
58
56
|
'config.set': { allow: true, scopes: ['agent', 'relation'] },
|
|
59
57
|
'config.unset': { allow: true, scopes: ['agent', 'relation'] },
|
|
60
|
-
'role.policy.write': { allow:
|
|
58
|
+
'role.policy.write': { allow: false, dangerous: true, scopes: ['agent'] },
|
|
61
59
|
'ec.aid.show': { allow: true, dangerous: true, scopes: ['agent'], constraints: { targetCurrentAgentOnly: true, requireAgentAdmin: true } },
|
|
62
60
|
'ec.aid.list': { allow: true, dangerous: true, scopes: ['agent'], constraints: { requireAgentOwner: true } },
|
|
63
61
|
'ec.aid.lookup': { allow: true, scopes: ['agent'] },
|
|
@@ -29,7 +29,7 @@ import { isAgentOnlyBaseagentField, isBehaviorConfigFieldPath } from './config-f
|
|
|
29
29
|
import { clearRoleStoreCache, isRoleName } from './role-store.js';
|
|
30
30
|
import { writeRoleDefinition, writeRoleRegistry } from './role-service.js';
|
|
31
31
|
import { normalizeRoleEffortCompat, normalizeRoleGroupChatmodeCompat } from './role-schema.js';
|
|
32
|
-
import { mutatePeerBookTransactionSync, resolvePeerAidKind } from './peer-book-store.js';
|
|
32
|
+
import { commitAgentConfigTransactionSync, mutatePeerBookTransactionSync, resolvePeerAidKind } from './peer-book-store.js';
|
|
33
33
|
import { DAEMON_SCHEMA_NAME } from '../product.js';
|
|
34
34
|
import { normalizeDaemonServices } from './daemon-services.js';
|
|
35
35
|
import { assertProviderSelectionWrite, resolveProviderModelSettings, validateProvidersFile } from './providers-config.js';
|
|
@@ -1032,11 +1032,7 @@ export function write(target, value, sel, opts = {}) {
|
|
|
1032
1032
|
}
|
|
1033
1033
|
const before = readTextOrNull(file);
|
|
1034
1034
|
const after = `${JSON.stringify(normalized, null, 2)}\n`;
|
|
1035
|
-
|
|
1036
|
-
selfAid: syncAid,
|
|
1037
|
-
actor: target === ConfigTarget.Agent ? 'agent-management-role-sync' : 'relation-management-role-sync',
|
|
1038
|
-
mutation: { type: 'sync-management-roles' },
|
|
1039
|
-
}, [{ file, before, after }]);
|
|
1035
|
+
commitAgentConfigTransactionSync(syncAid, [{ file, before, after }]);
|
|
1040
1036
|
if (target === ConfigTarget.Agent) {
|
|
1041
1037
|
ownerResolver.setAgentConfiguredOwners(syncAid, configuredOwnerList(normalized));
|
|
1042
1038
|
}
|
|
@@ -13,6 +13,7 @@ export function serviceRuntimeMode(service) {
|
|
|
13
13
|
return service.runtime?.mode ?? (service.name === 'ecweb' ? 'managed' : 'external');
|
|
14
14
|
}
|
|
15
15
|
export const DEFAULT_ECWEB_PORT = 42705;
|
|
16
|
+
export const DEFAULT_ECWEB_PROXY_VISIBILITY = 'public';
|
|
16
17
|
function isRecord(value) {
|
|
17
18
|
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
18
19
|
}
|
|
@@ -109,7 +110,7 @@ export function normalizeDaemonServices(raw, warn) {
|
|
|
109
110
|
};
|
|
110
111
|
services.push({ name, enabled: true, proxy });
|
|
111
112
|
}
|
|
112
|
-
if (legacyEcweb || legacyEcwebProxy) {
|
|
113
|
+
if (legacyEcweb || legacyEcwebProxy || legacyProxy?.enabled === false) {
|
|
113
114
|
const service = ecwebIndex >= 0
|
|
114
115
|
? services[ecwebIndex]
|
|
115
116
|
: {
|
|
@@ -117,7 +118,7 @@ export function normalizeDaemonServices(raw, warn) {
|
|
|
117
118
|
// The old ECWeb lifecycle switch and Service Proxy switch were
|
|
118
119
|
// independent. Preserve that distinction during migration: a
|
|
119
120
|
// proxy-only config must not start managing the local process.
|
|
120
|
-
enabled: legacyEcweb?.enabled === true,
|
|
121
|
+
enabled: legacyEcweb?.enabled === true || (!legacyEcweb && !legacyEcwebProxy),
|
|
121
122
|
};
|
|
122
123
|
if (legacyEcweb) {
|
|
123
124
|
if (service.enabled === undefined && typeof legacyEcweb.enabled === 'boolean')
|
|
@@ -129,6 +130,8 @@ export function normalizeDaemonServices(raw, warn) {
|
|
|
129
130
|
throw new Error('daemon.json.services[ecweb].proxy must be an object before legacy proxy settings can be migrated');
|
|
130
131
|
}
|
|
131
132
|
const proxy = { ...(service.proxy ?? {}) };
|
|
133
|
+
if (proxy.enabled === undefined && legacyProxy?.enabled === false)
|
|
134
|
+
proxy.enabled = false;
|
|
132
135
|
if (legacyEcwebProxy) {
|
|
133
136
|
if (proxy.enabled === undefined) {
|
|
134
137
|
proxy.enabled = legacyProxy?.enabled === true && legacyEcwebProxy.enabled !== false;
|
|
@@ -151,6 +154,7 @@ export function normalizeDaemonServices(raw, warn) {
|
|
|
151
154
|
if (proxy.metadata === undefined && isRecord(legacyEcwebProxy.metadata)) {
|
|
152
155
|
proxy.metadata = { ...legacyEcwebProxy.metadata };
|
|
153
156
|
}
|
|
157
|
+
// Preserve the former implicit policy when migrating existing services.
|
|
154
158
|
if (proxy.enabled === true && proxy.visibility === undefined)
|
|
155
159
|
proxy.visibility = 'private';
|
|
156
160
|
}
|
|
@@ -171,8 +175,28 @@ export function normalizeDaemonServices(raw, warn) {
|
|
|
171
175
|
export function findService(services, name) {
|
|
172
176
|
return (services ?? []).find((service) => service.name === name);
|
|
173
177
|
}
|
|
178
|
+
/** Runtime defaults only: reading these values never persists them. */
|
|
174
179
|
export function ecwebService(services) {
|
|
175
|
-
|
|
180
|
+
const service = findService(services, 'ecweb');
|
|
181
|
+
return {
|
|
182
|
+
...service,
|
|
183
|
+
name: 'ecweb',
|
|
184
|
+
enabled: service?.enabled ?? true,
|
|
185
|
+
port: service?.port ?? DEFAULT_ECWEB_PORT,
|
|
186
|
+
proxy: {
|
|
187
|
+
enabled: true,
|
|
188
|
+
source: 'instance',
|
|
189
|
+
serviceType: 'http',
|
|
190
|
+
visibility: DEFAULT_ECWEB_PROXY_VISIBILITY,
|
|
191
|
+
...service?.proxy,
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
export function resolveDaemonServices(services) {
|
|
196
|
+
const ecweb = ecwebService(services);
|
|
197
|
+
return findService(services, 'ecweb')
|
|
198
|
+
? services.map(service => service.name === 'ecweb' ? ecweb : service)
|
|
199
|
+
: [ecweb, ...(services ?? [])];
|
|
176
200
|
}
|
|
177
201
|
export function upsertService(services, patch) {
|
|
178
202
|
const current = services ?? [];
|
|
@@ -196,3 +220,6 @@ export function setEcwebEnabled(services, enabled, port = ecwebService(services)
|
|
|
196
220
|
port,
|
|
197
221
|
});
|
|
198
222
|
}
|
|
223
|
+
export function prepareEcwebInitialization(services) {
|
|
224
|
+
return resolveDaemonServices(services);
|
|
225
|
+
}
|
|
@@ -17,7 +17,7 @@ import { resolvePaths } from '../paths.js';
|
|
|
17
17
|
import { saveAgent } from '../config-store.js';
|
|
18
18
|
import { buildModelRequestHeaders } from '../agents/request-identity.js';
|
|
19
19
|
import { appendV1RequestPath } from '../agents/request-identity.js';
|
|
20
|
-
import { resolvePriceRow } from '../stats/
|
|
20
|
+
import { resolvePriceRow } from '../stats/model-resolver.js';
|
|
21
21
|
import { ipcQuery } from '../ipc.js';
|
|
22
22
|
import { logger } from '../utils/logger.js';
|
|
23
23
|
import { resolveProviderServiceForBaseagent } from './providers.js';
|
|
@@ -423,7 +423,7 @@ export function gatewaySetPrice(args) {
|
|
|
423
423
|
try {
|
|
424
424
|
const dir = path.join(resolvePaths().root, 'data', 'stats');
|
|
425
425
|
fs.mkdirSync(dir, { recursive: true });
|
|
426
|
-
// 写入网关价格覆盖层(
|
|
426
|
+
// 写入网关价格覆盖层(model-resolver 的「优先级1 用户手动设置网关价」读此文件)。
|
|
427
427
|
// 注意:必须是 model-prices-gateway.jsonl,不是 model-prices.jsonl(后者是官方价表)。
|
|
428
428
|
const file = path.join(dir, 'model-prices-gateway.jsonl');
|
|
429
429
|
const mode = 0o600; // owner-only read/write for security
|
|
@@ -63,16 +63,18 @@ export function parseInvokeArgv(argv) {
|
|
|
63
63
|
const retriesRaw = options.get('--retries');
|
|
64
64
|
if (retriesRaw !== undefined && !/^\d+$/u.test(retriesRaw))
|
|
65
65
|
argumentError('--retries must be a non-negative integer');
|
|
66
|
-
//
|
|
66
|
+
// Preserve managed argv for authorization; parse duration syntax only after it is bound.
|
|
67
67
|
const timeoutRaw = options.get('--timeout-ms') ?? options.get('--timeout');
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
const timeout = timeoutRaw === undefined ? undefined : /^(\d+)\s*(ms|s|m|h)?$/u.exec(timeoutRaw);
|
|
69
|
+
if (timeoutRaw !== undefined && !timeout)
|
|
70
|
+
argumentError('timeout must be a positive duration');
|
|
71
|
+
const timeoutMs = timeout ? Number(timeout[1]) * ({ ms: 1, s: 1000, m: 60_000, h: 3_600_000 }[timeout[2] || 'ms'] ?? 1) : undefined;
|
|
70
72
|
return {
|
|
71
73
|
providerId,
|
|
72
74
|
serviceType,
|
|
73
75
|
model: options.get('--model'),
|
|
74
76
|
out: options.get('--out'),
|
|
75
|
-
timeoutMs
|
|
77
|
+
timeoutMs,
|
|
76
78
|
retries: retriesRaw === undefined ? undefined : Number(retriesRaw),
|
|
77
79
|
dryRun: flags.has('--dry-run'),
|
|
78
80
|
input: hasInput ? options.get('--input') : undefined,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { randomInt } from 'crypto';
|
|
2
2
|
import { isValidAid } from '../aun/aid/validation.js';
|
|
3
|
-
import {
|
|
3
|
+
import { isPeerBindingEligible } from './peer-book.js';
|
|
4
4
|
import { formatContactAlias, normalizeContactChannelKey } from './peer-alias.js';
|
|
5
5
|
import { mutatePeerBookSync } from './peer-book-store.js';
|
|
6
6
|
export const CONTACT_BIND_CODE_TTL_MS = 10 * 60 * 1000;
|
|
@@ -34,9 +34,8 @@ export class ContactBindCodeRegistry {
|
|
|
34
34
|
return { ok: false, error: `invalid channelName: ${req.channelName}` };
|
|
35
35
|
if (!isValidAid(primaryId))
|
|
36
36
|
return { ok: false, error: `invalid primaryId: ${req.primaryId}` };
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return { ok: false, error: `only an active contact or Agent owner can bind an identity: ${primaryId}` };
|
|
37
|
+
if (!isPeerBindingEligible(selfAid, primaryId)) {
|
|
38
|
+
return { ok: false, error: `only an admitted principal can bind an identity: ${primaryId}` };
|
|
40
39
|
}
|
|
41
40
|
if (requestedCode && !/^\d{6}$/.test(requestedCode))
|
|
42
41
|
return { ok: false, error: 'binding code must be 6 digits' };
|