evolcore 0.0.43-test.6 → 0.0.43-test.8
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 +95 -0
- package/bin/ecmsg.js +188 -58
- package/dist/agent-template/jobs.js +62 -0
- package/dist/agent-template/runtime.js +214 -0
- package/dist/agent-template/service.js +465 -0
- package/dist/agent-template/tool-runner.js +45 -0
- package/dist/agent-template/types.js +5 -0
- package/dist/agents/baseagent-availability.js +1 -1
- package/dist/agents/claude-runner.js +1 -1
- package/dist/agents/codex/app-server-client.js +22 -0
- package/dist/agents/codex-runner.js +69 -2
- package/dist/aun/aid/agentmd.js +56 -1
- package/dist/aun/aid/client.js +3 -1
- package/dist/aun/menu/client.js +3 -2
- package/dist/aun/msg/p2p.js +6 -1
- package/dist/channels/aun.js +277 -49
- package/dist/cli/agent-command.js +5 -0
- package/dist/cli/agent-create.js +7 -3
- package/dist/cli/agent-template.js +124 -0
- package/dist/cli/aun-commands.js +2 -2
- package/dist/cli/ctl-command.js +2 -1
- package/dist/cli/daemon-commands.js +11 -66
- package/dist/cli/daemon-lifecycle-client.js +61 -0
- package/dist/cli/ecmsg-gateway.js +35 -2
- package/dist/cli/events-command.js +109 -0
- package/dist/cli/index.js +60 -14
- package/dist/cli/invoke-command.js +182 -0
- package/dist/cli/managed-command-guard.js +6 -1
- package/dist/cli/net-check.js +1 -1
- package/dist/cli/restart-monitor.js +160 -83
- package/dist/cli/services-command.js +137 -0
- package/dist/cli/team-workspace-command.js +134 -0
- package/dist/cli/thread-command.js +103 -13
- package/dist/cli/watch-msg.js +1 -1
- package/dist/config/boot-log.js +8 -8
- package/dist/config/config-field-policy.js +2 -2
- package/dist/config/config-manager.js +0 -7
- package/dist/config/invoke-ipc-service.js +118 -0
- package/dist/config/schema-migration.js +45 -15
- package/dist/config-store.js +2 -1
- package/dist/core/agent-ipc-registration.js +25 -4
- package/dist/core/agent-reload-coordinator.js +6 -4
- package/dist/core/agent-runtime.js +106 -10
- package/dist/core/auth/delegation-authorization.js +66 -0
- package/dist/core/auth/operation-authorizer.js +2 -0
- package/dist/core/auth/operation-catalog.js +29 -0
- package/dist/core/baseagent-loader.js +60 -130
- package/dist/core/channel-loader.js +10 -1
- package/dist/core/channel-runtime.js +20 -12
- package/dist/core/command/agent-control.js +12 -2
- package/dist/core/command/agent-storage-menu.js +1 -1
- package/dist/core/command/agent-template-menu.js +147 -0
- package/dist/core/command/chatmode-config.js +2 -36
- package/dist/core/command/command-handler.js +80 -17
- package/dist/core/command/data-root-resolver.js +32 -23
- package/dist/core/command/eventcenter-menu.js +468 -0
- package/dist/core/command/menu-catalog.js +15 -0
- package/dist/core/command/menu-handler.js +216 -90
- package/dist/core/command/menu-protocol.js +71 -13
- package/dist/core/command/menu-query-batch.js +194 -0
- package/dist/core/command/slash-gate.js +1 -1
- package/dist/core/command/slash-handler.js +34 -42
- package/dist/core/command/team-workspace-bootstrap.js +350 -0
- package/dist/core/command/{pa-workspace-calendar.js → team-workspace-calendar.js} +7 -7
- package/dist/core/command/team-workspace-initializer.js +2 -0
- package/dist/core/command/{pa-workspace-items.js → team-workspace-items.js} +83 -68
- package/dist/core/command/team-workspace-job-store.js +88 -0
- package/dist/core/command/team-workspace-management-service.js +2 -0
- package/dist/core/command/team-workspace-management-store.js +96 -0
- package/dist/core/command/team-workspace-management.js +265 -0
- package/dist/core/command/team-workspace-members-menu.js +88 -0
- package/dist/core/command/team-workspace-store.js +612 -0
- package/dist/core/command/team-workspace-team.js +193 -0
- package/dist/core/daemon-control.js +22 -5
- package/dist/core/daemon-lifecycle.js +323 -191
- package/dist/core/handoff/runtime.js +45 -13
- package/dist/core/invoke/executors/index.js +13 -0
- package/dist/core/invoke/executors/media.js +283 -0
- package/dist/core/invoke/executors/text.js +198 -0
- package/dist/core/invoke/invoke-service.js +157 -0
- package/dist/core/invoke/style-router.js +48 -0
- package/dist/core/invoke/types.js +19 -0
- package/dist/core/ipc-registration.js +50 -7
- package/dist/core/legacy-rename.js +41 -0
- package/dist/core/memory/consolidation.js +7 -5
- package/dist/core/message/aun-ipc-sender.js +252 -17
- package/dist/core/message/im-renderer.js +116 -85
- package/dist/core/message/message-bridge.js +4 -0
- package/dist/core/message/message-queue.js +66 -15
- package/dist/core/message/message-utils.js +10 -2
- package/dist/core/message/peer-mode.js +7 -34
- package/dist/core/message/pending-hints.js +29 -5
- package/dist/core/message/response-engine.js +194 -61
- package/dist/core/message/send-options.js +7 -4
- package/dist/core/message/send-routing.js +50 -5
- package/dist/core/ownership/owner-resolver.js +7 -0
- package/dist/core/pack-auth.js +94 -0
- package/dist/core/pack-install.js +194 -0
- package/dist/core/permission/ec-command-parser.js +51 -17
- package/dist/core/permission/protected-paths.js +12 -2
- package/dist/core/permission/shell-environment.js +9 -0
- package/dist/core/rate-window.js +48 -0
- package/dist/core/relation/peer-identity.js +28 -0
- package/dist/core/session/session-file-health.js +243 -0
- package/dist/core/session/session-fs-store.js +67 -28
- package/dist/core/session/session-idle-monitor.js +59 -19
- package/dist/core/session/session-manager.js +13 -4
- package/dist/core/task/task-recovery-service.js +13 -2
- package/dist/core/thread/command-parser.js +9 -2
- package/dist/core/thread/thread-operation.js +21 -2
- package/dist/core/thread/thread-route.js +13 -2
- package/dist/core/thread/thread-service.js +52 -3
- package/dist/directory/owner-directory-admission.js +40 -53
- package/dist/directory/owner-directory-cache.js +89 -113
- package/dist/directory/owner-directory-query-operation.js +8 -10
- package/dist/eck/kit-renderer.js +7 -5
- package/dist/eck/message-renderer.js +2 -0
- package/dist/ecweb/basic-settings-service.js +1 -1
- package/dist/ecweb/message-context-service.js +0 -4
- package/dist/ecweb/runtime/lifecycle.js +6 -2
- package/dist/ecweb/runtime/supervisor.js +19 -4
- package/dist/event-center/admission-materializer.js +124 -0
- package/dist/event-center/bus-gate.js +154 -0
- package/dist/event-center/bus-host.js +307 -0
- package/dist/event-center/bus-resolver.js +120 -0
- package/dist/event-center/center-config.js +127 -0
- package/dist/event-center/daemon.js +44 -0
- package/dist/event-center/directory-source.js +55 -0
- package/dist/event-center/dispatcher.js +157 -0
- package/dist/event-center/event-log.js +110 -0
- package/dist/event-center/index-generator.js +73 -0
- package/dist/event-center/ipc-operation.js +423 -0
- package/dist/event-center/ledger.js +52 -0
- package/dist/event-center/pack-loader.js +207 -0
- package/dist/event-center/pack-manager.js +85 -0
- package/dist/event-center/registry.js +463 -0
- package/dist/event-center/runtime.js +837 -0
- package/dist/event-center/script-runner.js +356 -0
- package/dist/event-center/types.js +51 -0
- package/dist/event-center/validation.js +435 -0
- package/dist/index.js +424 -135
- package/dist/ipc.js +106 -12
- package/dist/paths.js +20 -0
- package/dist/product.js +14 -0
- package/dist/proxy/manager.js +5 -1
- package/dist/proxy/service-supervisor.js +13 -4
- package/dist/response-system/engines/v1/index.js +0 -1
- package/dist/response-system/engines/v1/proactive-flow.js +4 -2
- package/dist/response-system/modes/single-session/index.js +1 -1
- package/dist/services/dispatcher.js +100 -0
- package/dist/services/idempotency.js +90 -0
- package/dist/services/identity.js +52 -0
- package/dist/services/index-generator.js +70 -0
- package/dist/services/index.js +449 -0
- package/dist/services/ipc-operation.js +550 -0
- package/dist/services/ledger.js +52 -0
- package/dist/services/message-log.js +112 -0
- package/dist/services/pack-manager.js +215 -0
- package/dist/services/reply.js +55 -0
- package/dist/services/router.js +98 -0
- package/dist/services/script-runner.js +422 -0
- package/dist/services/service-payload.js +70 -0
- package/dist/services/types.js +18 -0
- package/dist/services/validation.js +297 -0
- package/dist/trigger/application-service.js +18 -0
- package/dist/trigger/event-source.js +1 -1
- package/dist/trigger/ipc-service.js +3 -1
- package/dist/trigger/scheduler.js +38 -0
- package/dist/trigger/script-sandbox.js +170 -24
- package/dist/utils/cross-platform.js +24 -10
- package/dist/utils/evolcore-version.js +69 -27
- package/dist/utils/instance-registry.js +19 -13
- package/dist/utils/npm-ops.js +2 -1
- package/dist/utils/package-version-info.js +6 -3
- package/dist/utils/process-introspect.js +45 -9
- package/dist/utils/startup-trace.js +74 -37
- package/dist/utils/windows-shell-trust.js +80 -6
- package/kits/docs/INDEX.md +2 -2
- package/kits/docs/aun/ABILITY_CALLING.md +9 -15
- package/kits/docs/context-assembly.md +1 -1
- package/kits/docs/evolcore/INDEX.md +3 -1
- package/kits/docs/evolcore/ability.md +4 -0
- package/kits/docs/evolcore/agent.md +22 -1
- package/kits/docs/evolcore/aid.md +1 -1
- package/kits/docs/evolcore/event-center.md +227 -0
- package/kits/docs/evolcore/file-navigation.md +10 -264
- package/kits/docs/evolcore/fs.md +5 -3
- package/kits/docs/evolcore/group.md +1 -1
- package/kits/docs/evolcore/memory-architecture.md +2 -0
- package/kits/docs/evolcore/menu-protocol.md +28 -1
- package/kits/docs/evolcore/msg.md +21 -9
- package/kits/docs/evolcore/provider.md +3 -1
- package/kits/docs/evolcore/response.md +5 -5
- package/kits/docs/evolcore/services.md +294 -0
- package/kits/docs/evolcore/task.md +2 -0
- package/kits/docs/evolcore/team-workspace.md +41 -0
- package/kits/docs/evolcore/thread-chain.md +15 -3
- package/kits/eck_manifest.json +26 -0
- package/kits/rules/02-navigation.md +10 -1
- package/kits/rules/06-channel.md +1 -0
- package/kits/schemas/_meta.json +17 -6
- package/kits/schemas/agent-config.schema.19.json +5 -7
- package/kits/schemas/agent-config.schema.20.json +936 -0
- package/kits/schemas/relation-config.schema.12.json +2 -3
- package/kits/schemas/role-config.schema.2.json +4 -4
- package/kits/skills/.switches.json +1 -5
- package/kits/skills/ability/SKILL.md +56 -0
- package/kits/skills/ability/references/calling.md +56 -0
- package/kits/skills/{ec-ability → ability}/references/contract-checklist.md +1 -1
- package/kits/skills/{ec-ability → ability}/references/development.md +9 -33
- package/kits/skills/{ec-ability → ability}/references/management.md +2 -2
- package/kits/skills/{ec-ability → ability}/references/recovery.md +1 -1
- package/kits/skills/{ec-ability → ability}/references/runtime-protocol.md +2 -0
- package/kits/skills/ec-agent-create/SKILL.md +0 -1
- package/kits/skills/ec-group/SKILL.md +5 -8
- package/kits/skills/ec-group-collaboration/SKILL.md +7 -7
- package/kits/skills/ec-service-proxy/SKILL.md +34 -5
- package/kits/skills/ec-trigger/SKILL.md +4 -4
- package/kits/skills/personal-assistant/SKILL.md +6 -6
- package/kits/skills/personal-assistant/references/02-bootstrap.md +4 -4
- package/kits/skills/personal-assistant/scripts/clean.mjs +4 -4
- package/kits/skills/personal-assistant/scripts/init.mjs +2 -2
- package/kits/skills/personal-assistant/scripts/pa.mjs +4 -4
- package/kits/skills/thread-ops/SKILL.md +10 -10
- package/kits/templates/message-fragments/item.md +1 -1
- package/kits/templates/system-fragments/channel.md +3 -3
- package/kits/templates/system-fragments/commands.md +5 -3
- package/kits/templates/system-fragments/reply.md +1 -5
- package/kits/templates/system-fragments/thread.md +13 -10
- package/package.json +5 -6
- package/scripts/agent-template/index.mjs +40 -0
- package/scripts/agent-template/inspect.mjs +240 -0
- package/scripts/agent-template/overlay.mjs +71 -0
- package/scripts/agent-template/pack.mjs +169 -0
- package/scripts/agent-template/shared/common.mjs +235 -0
- package/scripts/agent-template/shared/evolcore.mjs +75 -0
- package/scripts/agent-template/shared/plan.mjs +129 -0
- package/scripts/agent-template/shared/team-schema.json +70 -0
- package/scripts/agent-template/shared/template-contract.mjs +154 -0
- package/scripts/agent-template/shared/template-package.mjs +265 -0
- package/scripts/agent-template/shared/template-runtime.mjs +80 -0
- package/scripts/agent-template/shared/template.mjs +142 -0
- package/dist/cli/pa-workspace-command.js +0 -225
- package/dist/core/command/pa-workspace-store.js +0 -468
- package/dist/core/relation/pa-team.js +0 -132
- package/kits/docs/evolcore/pa-workspace.md +0 -51
- package/kits/skills/aid-ability/SKILL.md +0 -244
- package/kits/skills/ec-ability/SKILL.md +0 -67
- package/kits/skills/ec-ability/references/workflows.md +0 -15
|
@@ -191,7 +191,8 @@ class OwnerDirectoryCoordinator {
|
|
|
191
191
|
// 优先用发起方自己:它一定想拿到这份数据,结果也直接回给它。
|
|
192
192
|
// 只有它自身不可用(授权失效/已退役/刚被远端拒过)时才退到别人,避免出现
|
|
193
193
|
// 「A 触发、却被 B 的代拉结果覆盖」这种观测不到的错配。
|
|
194
|
-
|
|
194
|
+
// 执行者资格只看"实例还活着、没被远端拒过"——没有本地凭证可审了。
|
|
195
|
+
const usable = (cache) => !cache.isRetired() && !cache.isRevoked();
|
|
195
196
|
if (preferred && usable(preferred) && !preferred.pullBlocked())
|
|
196
197
|
return preferred;
|
|
197
198
|
for (const cache of this.caches) {
|
|
@@ -400,7 +401,7 @@ export class OwnerDirectoryCache {
|
|
|
400
401
|
if (this.options.isCurrent && !this.options.isCurrent())
|
|
401
402
|
return false;
|
|
402
403
|
const version = this.options.relationVersion;
|
|
403
|
-
for (const file of [path.join(contactAdmissionDirectory(this.options.selfAid), 'binding.json'), this.
|
|
404
|
+
for (const file of [path.join(contactAdmissionDirectory(this.options.selfAid), 'binding.json'), this.cachePath('contacts'), this.syncStatePath()]) {
|
|
404
405
|
let raw;
|
|
405
406
|
try {
|
|
406
407
|
raw = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
@@ -420,6 +421,12 @@ export class OwnerDirectoryCache {
|
|
|
420
421
|
}
|
|
421
422
|
return true;
|
|
422
423
|
}
|
|
424
|
+
isRevoked() {
|
|
425
|
+
return this.readSyncState().revoked === true;
|
|
426
|
+
}
|
|
427
|
+
canApply() {
|
|
428
|
+
return this.canMutate() && !this.isRevoked();
|
|
429
|
+
}
|
|
423
430
|
/** Local probes must not remove another runtime's in-progress atomic write. */
|
|
424
431
|
readLocalJson(file) {
|
|
425
432
|
try {
|
|
@@ -432,14 +439,19 @@ export class OwnerDirectoryCache {
|
|
|
432
439
|
}
|
|
433
440
|
}
|
|
434
441
|
/**
|
|
435
|
-
*
|
|
442
|
+
* 处理 Owner 的授权结果。
|
|
443
|
+
*
|
|
444
|
+
* `authorization.json` 已废弃;明确撤权状态单独保存在关系代际绑定的同步状态中。
|
|
445
|
+
* 这里只剩两件事——校验身份、按状态分流:
|
|
446
|
+
*
|
|
447
|
+
* - 撤销 / 拒绝:持久化撤权并删本地快照,阻止共享缓存重新落地;
|
|
448
|
+
* - 生效:清撤权状态、失败计数和拉取封锁,让下一次需要时能去取 contacts.json。
|
|
436
449
|
*
|
|
437
|
-
*
|
|
450
|
+
* 「要不要在远端取 contacts.json」由 storage ACL 与远端拒绝结果决定,不由本地票据决定。
|
|
438
451
|
*/
|
|
439
452
|
saveAuthorization(result) {
|
|
440
453
|
if (!this.canMutate())
|
|
441
454
|
return;
|
|
442
|
-
logger.info(`[OwnerDirectoryCache] Saving authorization for Owner ${this.options.ownerAid}, status: ${result.status}`);
|
|
443
455
|
if (result.owner_aid !== this.options.ownerAid || result.grantee_aid !== this.options.selfAid) {
|
|
444
456
|
throw new OwnerDirectoryCacheError('INVALID_GRANT', 'directory/access result identity is invalid');
|
|
445
457
|
}
|
|
@@ -451,36 +463,30 @@ export class OwnerDirectoryCache {
|
|
|
451
463
|
fs.mkdirSync(path.dirname(marker), { recursive: true, mode: 0o700 });
|
|
452
464
|
atomicWriteJson(marker, { ownerAid: this.options.ownerAid, granteeAid: this.options.selfAid, relationVersion: this.options.relationVersion });
|
|
453
465
|
}
|
|
454
|
-
//
|
|
466
|
+
// 撤销/拒绝:不留快照,准入随即回落到"名录不可用"。
|
|
455
467
|
if (result.status !== 'active' && result.status !== 'sync_pending' && result.status !== 'revoke_pending') {
|
|
456
468
|
this.revokeAuthorization(result.status);
|
|
457
469
|
return;
|
|
458
470
|
}
|
|
459
|
-
|
|
460
|
-
schemaVersion: 2,
|
|
461
|
-
relationVersion: this.options.relationVersion,
|
|
462
|
-
ownerAid: this.options.ownerAid,
|
|
463
|
-
granteeAid: this.options.selfAid,
|
|
464
|
-
grantedAt: this.now(),
|
|
465
|
-
expiresAt: grantExpiryMs(result),
|
|
466
|
-
};
|
|
467
|
-
fs.mkdirSync(this.options.directory, { recursive: true, mode: 0o700 });
|
|
468
|
-
atomicWriteJson(this.authorizationPath(), grant);
|
|
469
|
-
fs.chmodSync(this.authorizationPath(), 0o600);
|
|
471
|
+
this.writeRevocationState(false);
|
|
470
472
|
this.clearPullFailures();
|
|
471
|
-
logger.info(`[OwnerDirectoryCache]
|
|
473
|
+
logger.info(`[OwnerDirectoryCache] Owner directory grant applied: status=${result.status} (no local credential stored)`);
|
|
472
474
|
this._logAction({
|
|
473
475
|
action: 'auth',
|
|
474
476
|
generation: this.appliedGeneration,
|
|
475
|
-
detail:
|
|
477
|
+
detail: `授权生效 status=${result.status}`,
|
|
476
478
|
});
|
|
477
479
|
void this.updateSyncState(state => ({ ...state, blockedScopes: [] })).then(() => this.refreshMarkdown());
|
|
478
480
|
}
|
|
479
481
|
/**
|
|
480
482
|
* 是否具备使用名录的条件。
|
|
481
483
|
*
|
|
482
|
-
*
|
|
483
|
-
*
|
|
484
|
+
* 明确撤权优先拒绝,其余情况检查本地快照。准入由 `directory.md` + access 开关控制,
|
|
485
|
+
* 这里只回答「有没有可读的数据」。
|
|
486
|
+
*
|
|
487
|
+
* `authorization.json` 不参与这个判断:它(曾经)只表达「能不能去远端取
|
|
488
|
+
* contacts.json」,属于拉取能力,不是读本地数据的前置条件。拿到文件就能用,
|
|
489
|
+
* 过期与否、文件在不在都不拦。
|
|
484
490
|
*
|
|
485
491
|
* **拉取被拒不算不可用**:某次拉取被远端拒绝只影响「谁来拉」(见 `pullBlocked`),
|
|
486
492
|
* 不影响准入、查询和本地读取。数据由 owner 级共享缓存供给,别的 agent 拉到一样能用;
|
|
@@ -489,13 +495,10 @@ export class OwnerDirectoryCache {
|
|
|
489
495
|
scopeAccess(scope) {
|
|
490
496
|
return this.scopeAccessUnavailableReason(scope) ? 'unavailable' : 'authorized';
|
|
491
497
|
}
|
|
492
|
-
scopeAccessUnavailableReason(
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
if (grant.expiresAt > 0 && grant.expiresAt <= this.now())
|
|
497
|
-
return 'authorization_expired';
|
|
498
|
-
return undefined;
|
|
498
|
+
scopeAccessUnavailableReason(scope) {
|
|
499
|
+
if (this.isRevoked())
|
|
500
|
+
return 'revoked';
|
|
501
|
+
return existsAtomic(this.cachePath(scope ?? OWNER_DIRECTORY_SCOPES[0])) ? undefined : 'snapshot_missing';
|
|
499
502
|
}
|
|
500
503
|
/**
|
|
501
504
|
* 本实例最近一次拉取是否被远端拒绝过。
|
|
@@ -508,7 +511,7 @@ export class OwnerDirectoryCache {
|
|
|
508
511
|
}
|
|
509
512
|
// ── Pending update ──────────────────────────────────────────────────────────
|
|
510
513
|
writePendingUpdate(update) {
|
|
511
|
-
if (!this.
|
|
514
|
+
if (!this.canApply())
|
|
512
515
|
return;
|
|
513
516
|
const stored = { schemaVersion: 1, ...update, relationVersion: this.options.relationVersion };
|
|
514
517
|
fs.mkdirSync(this.options.directory, { recursive: true, mode: 0o700 });
|
|
@@ -535,6 +538,8 @@ export class OwnerDirectoryCache {
|
|
|
535
538
|
if (senderAid !== this.options.ownerAid) {
|
|
536
539
|
throw new OwnerDirectoryCacheError('UNTRUSTED_OWNER_EVENT', `directory change sender is not the authorized Owner: sender=${senderAid} expected=${this.options.ownerAid}`);
|
|
537
540
|
}
|
|
541
|
+
if (!this.canApply())
|
|
542
|
+
return;
|
|
538
543
|
// 报到协调者:这是「agent 只负责报告、daemon 统一维护共享区」的入口。
|
|
539
544
|
// 协调者保留**最新的**一份通知;拉取成功的判据是「拉到的东西不比它旧」,
|
|
540
545
|
// 而不是「追上它声明的那个 digest」——声明值可能已经是过期快照。
|
|
@@ -577,12 +582,19 @@ export class OwnerDirectoryCache {
|
|
|
577
582
|
+ (published?.updatedAtMs !== undefined ? ` updatedAtMs=${published.updatedAtMs}` : ''),
|
|
578
583
|
});
|
|
579
584
|
}
|
|
580
|
-
/**
|
|
585
|
+
/**
|
|
586
|
+
* 授权被明确撤销或拒绝时,清掉本地快照,避免继续拿旧数据做准入判断。
|
|
587
|
+
*
|
|
588
|
+
* **这是唯一的撤权通道**:先持久化撤权状态,再删除本地数据,防止共享广播恢复旧数据。
|
|
589
|
+
* 存量机器上遗留的 `authorization.json` 一并清掉,避免残留文件误导排查。
|
|
590
|
+
*/
|
|
581
591
|
revokeAuthorization(status) {
|
|
582
592
|
if (!this.canMutate())
|
|
583
593
|
return;
|
|
594
|
+
this.writeRevocationState(true);
|
|
595
|
+
this.clearPendingUpdate();
|
|
584
596
|
this.clearPullFailures();
|
|
585
|
-
atomicRemove(this.
|
|
597
|
+
atomicRemove(this.legacyAuthorizationPath());
|
|
586
598
|
atomicRemove(this.cachePath(OWNER_DIRECTORY_SCOPES[0]));
|
|
587
599
|
// 落地镜像一并删掉:留着它会让"已同步到共享区某一版"的结论在授权恢复后
|
|
588
600
|
// 依然成立,热路径据此跳过本该重做的一次落地。
|
|
@@ -617,7 +629,7 @@ export class OwnerDirectoryCache {
|
|
|
617
629
|
return;
|
|
618
630
|
_startupCheckDone.add(key);
|
|
619
631
|
const scope = OWNER_DIRECTORY_SCOPES[0];
|
|
620
|
-
if (this.
|
|
632
|
+
if (existsAtomic(this.cachePath(scope)))
|
|
621
633
|
return;
|
|
622
634
|
if (this.options.relationVersion === undefined && this.readCachedSnapshot(scope))
|
|
623
635
|
return;
|
|
@@ -640,6 +652,8 @@ export class OwnerDirectoryCache {
|
|
|
640
652
|
* 代价都不一样——混在一起会让"来一条消息"既可能发网络请求又可能写盘。
|
|
641
653
|
*/
|
|
642
654
|
async processPendingIfNeeded(trigger) {
|
|
655
|
+
if (!this.canApply())
|
|
656
|
+
return;
|
|
643
657
|
if (this.options.relationVersion === undefined)
|
|
644
658
|
return this.processPendingOnce(trigger);
|
|
645
659
|
if (this.pendingInFlight)
|
|
@@ -769,6 +783,8 @@ export class OwnerDirectoryCache {
|
|
|
769
783
|
* - 没人拉 → 协调者挑一个持有效授权的实例代为拉取
|
|
770
784
|
*/
|
|
771
785
|
async fetchToSharedCache(digests, trigger = 'unspecified', operationId) {
|
|
786
|
+
if (!this.canApply())
|
|
787
|
+
throw new OwnerDirectoryCacheError('NOT_AUTHORIZED', 'owner directory access is revoked or retired');
|
|
772
788
|
const coordinator = coordinatorFor(this.options.ownerAid);
|
|
773
789
|
const hintDigest = digests?.[OWNER_DIRECTORY_SCOPES[0]];
|
|
774
790
|
// ① 共享区已经是最新 → 0 次网络。判据优先用内存代号,命中不了才读盘。
|
|
@@ -794,11 +810,11 @@ export class OwnerDirectoryCache {
|
|
|
794
810
|
const outcome = coordinator.pulling
|
|
795
811
|
? await coordinator.pulling
|
|
796
812
|
: await this._startCoordinatedPull(coordinator, trigger, operationId, hintDigest);
|
|
797
|
-
//
|
|
813
|
+
// 远端明确拒绝:标记 blocked 让别的 agent 去拉,重试没有意义。逐个 scope 处理,
|
|
798
814
|
// 因为一次拉取里可能多个 scope 都被拒;共用同一个 Promise 的调用方也各自执行这一步。
|
|
815
|
+
// 只认远端结论,本地不再有凭证可以判"该不该被拒"。
|
|
799
816
|
for (const scope of outcome.denied) {
|
|
800
|
-
|
|
801
|
-
await this.blockScope(scope);
|
|
817
|
+
await this.blockScope(scope);
|
|
802
818
|
}
|
|
803
819
|
const complete = this._assertComplete(outcome.data, outcome.failures);
|
|
804
820
|
return complete;
|
|
@@ -889,7 +905,7 @@ export class OwnerDirectoryCache {
|
|
|
889
905
|
*/
|
|
890
906
|
_commitSharedCache(data, trigger, operationId, startedAt) {
|
|
891
907
|
// 退役的运行时不能替当前关系写共享文件。
|
|
892
|
-
if (this.
|
|
908
|
+
if (!this.canApply())
|
|
893
909
|
return false;
|
|
894
910
|
const ok = this._writeSharedCache(data, trigger, operationId, startedAt);
|
|
895
911
|
if (!ok)
|
|
@@ -940,7 +956,7 @@ export class OwnerDirectoryCache {
|
|
|
940
956
|
* 在这里做,否则调用方会把"一个字节都没拉下来"当成成功,把 pending 清掉。
|
|
941
957
|
*/
|
|
942
958
|
_assertComplete(fetched, failures) {
|
|
943
|
-
const missing = OWNER_DIRECTORY_SCOPES.filter(scope =>
|
|
959
|
+
const missing = OWNER_DIRECTORY_SCOPES.filter(scope => !fetched[scope]);
|
|
944
960
|
if (missing.length > 0) {
|
|
945
961
|
// 带上根因:上层只看到 "fetch incomplete" 会把内容不合格误判成"拉不到"。
|
|
946
962
|
const detail = missing
|
|
@@ -971,6 +987,8 @@ export class OwnerDirectoryCache {
|
|
|
971
987
|
return promise;
|
|
972
988
|
}
|
|
973
989
|
async _applyFromSharedCacheOnce() {
|
|
990
|
+
if (!this.canApply())
|
|
991
|
+
return false;
|
|
974
992
|
// 热路径的「要不要干活」由调用方(`applyFromSharedCacheWithin` →
|
|
975
993
|
// `hasPendingSharedUpdate` 的两次 stat)先判定,这里不再按内存代号早退:
|
|
976
994
|
// 代号与文件时间戳是两套判据,任意一套抢在前面 return 都会让另一套
|
|
@@ -999,6 +1017,8 @@ export class OwnerDirectoryCache {
|
|
|
999
1017
|
return false;
|
|
1000
1018
|
}
|
|
1001
1019
|
await this._applyAll(fetched);
|
|
1020
|
+
if (!this.canApply())
|
|
1021
|
+
return false;
|
|
1002
1022
|
const applied = coordinatorFor(this.options.ownerAid).epoch;
|
|
1003
1023
|
if (applied)
|
|
1004
1024
|
this.appliedGeneration = applied.generation;
|
|
@@ -1022,6 +1042,8 @@ export class OwnerDirectoryCache {
|
|
|
1022
1042
|
* 共享区没有新版本时同理立刻返回——纯内存比较,不产生任何 IO。
|
|
1023
1043
|
*/
|
|
1024
1044
|
async applyFromSharedCacheWithin(timeoutMs) {
|
|
1045
|
+
if (this.isRevoked())
|
|
1046
|
+
return false;
|
|
1025
1047
|
// 共享区根本没有内容(从没拉成功过)时立刻返回 false,不等超时也不发网络。
|
|
1026
1048
|
// 必须先判这一步:`hasPendingSharedUpdate()` 在共享区缺失时也会返回 false,
|
|
1027
1049
|
// 但那个 false 的含义是「没有新内容」,不是「什么都不用做」。
|
|
@@ -1082,18 +1104,21 @@ export class OwnerDirectoryCache {
|
|
|
1082
1104
|
*/
|
|
1083
1105
|
async _applyAll(fetched) {
|
|
1084
1106
|
const apply = async () => {
|
|
1107
|
+
if (!this.canApply())
|
|
1108
|
+
return;
|
|
1085
1109
|
for (const scope of OWNER_DIRECTORY_SCOPES) {
|
|
1086
1110
|
const file = fetched[scope];
|
|
1087
1111
|
if (!file)
|
|
1088
1112
|
continue;
|
|
1089
|
-
//
|
|
1090
|
-
// 不降级、不涉及远端 ACL。授权只管"能不能从远端拉",两个环节分开。
|
|
1113
|
+
// 共享落地不要求本地授权凭证,但必须遵守明确撤权和关系代际边界。
|
|
1091
1114
|
await this._applyFile(scope, file);
|
|
1092
1115
|
}
|
|
1093
1116
|
};
|
|
1094
1117
|
const next = this.applyTail.then(apply);
|
|
1095
1118
|
this.applyTail = next.catch(() => { });
|
|
1096
1119
|
await next;
|
|
1120
|
+
if (!this.canApply())
|
|
1121
|
+
return;
|
|
1097
1122
|
// 对账:落地完后认下当前代号,热路径从此只比内存。
|
|
1098
1123
|
// 放在这里而不是各调用方,是因为落地有三条入口(拉取后、共享区读回、
|
|
1099
1124
|
// 广播),漏掉任何一条都会让热路径反复读盘。
|
|
@@ -1643,7 +1668,7 @@ export class OwnerDirectoryCache {
|
|
|
1643
1668
|
}
|
|
1644
1669
|
// ── Internal: applyFile ──────────────────────────────────────────────────────
|
|
1645
1670
|
async _applyFile(scope, file) {
|
|
1646
|
-
if (!this.
|
|
1671
|
+
if (!this.canApply())
|
|
1647
1672
|
return;
|
|
1648
1673
|
const prev = this.readCachedSnapshot(scope);
|
|
1649
1674
|
const localDigest = prev?.contentDigest;
|
|
@@ -1660,7 +1685,7 @@ export class OwnerDirectoryCache {
|
|
|
1660
1685
|
}
|
|
1661
1686
|
const attemptedAt = this.now();
|
|
1662
1687
|
await this.updateFileState(scope, { lastAttemptAt: attemptedAt, status: 'syncing', error: undefined });
|
|
1663
|
-
if (!this.
|
|
1688
|
+
if (!this.canApply())
|
|
1664
1689
|
return;
|
|
1665
1690
|
try {
|
|
1666
1691
|
const entries = file.entries.map(e => normalizeEntry(e));
|
|
@@ -1689,7 +1714,7 @@ export class OwnerDirectoryCache {
|
|
|
1689
1714
|
...(file.openPaContext ? { openPaContext: file.openPaContext } : {}),
|
|
1690
1715
|
};
|
|
1691
1716
|
this.options.onSnapshotApplying?.(snapshot);
|
|
1692
|
-
if (!this.
|
|
1717
|
+
if (!this.canApply())
|
|
1693
1718
|
return;
|
|
1694
1719
|
archiveSnapshot(path.dirname(this.cachePath(scope)), scope);
|
|
1695
1720
|
const prevMeta = prev ? { owner: prev.owner, personalAssistant: prev.personalAssistant } : undefined;
|
|
@@ -1726,7 +1751,7 @@ export class OwnerDirectoryCache {
|
|
|
1726
1751
|
});
|
|
1727
1752
|
this.refreshMarkdown();
|
|
1728
1753
|
try {
|
|
1729
|
-
if (!this.
|
|
1754
|
+
if (!this.canApply())
|
|
1730
1755
|
return;
|
|
1731
1756
|
if (this.options.onSnapshotChanged && changes.length > 0) {
|
|
1732
1757
|
const agentMdAids = collectAgentMdRefreshAids(changes, nextMeta, prevMeta, snapshot);
|
|
@@ -1753,8 +1778,9 @@ export class OwnerDirectoryCache {
|
|
|
1753
1778
|
}
|
|
1754
1779
|
// ── Internal: readCachedSnapshot ────────────────────────────────────────────
|
|
1755
1780
|
readCachedSnapshot(scope) {
|
|
1756
|
-
|
|
1757
|
-
|
|
1781
|
+
if (this.isRevoked())
|
|
1782
|
+
return undefined;
|
|
1783
|
+
// 本地快照不要求授权凭证;明确撤权是独立的拒绝边界。
|
|
1758
1784
|
const stamp = this.cacheStamp(scope);
|
|
1759
1785
|
const cached = this.snapshotCache.get(scope);
|
|
1760
1786
|
if (cached !== undefined && cached.stamp === stamp)
|
|
@@ -1867,6 +1893,12 @@ export class OwnerDirectoryCache {
|
|
|
1867
1893
|
this.stateWriteTail = run.catch(() => { });
|
|
1868
1894
|
await run;
|
|
1869
1895
|
}
|
|
1896
|
+
writeRevocationState(revoked) {
|
|
1897
|
+
const state = { ...this.readSyncState(), relationVersion: this.options.relationVersion, revoked };
|
|
1898
|
+
fs.mkdirSync(this.options.directory, { recursive: true, mode: 0o700 });
|
|
1899
|
+
atomicWriteJson(this.syncStatePath(), state);
|
|
1900
|
+
fs.chmodSync(this.syncStatePath(), 0o600);
|
|
1901
|
+
}
|
|
1870
1902
|
readSyncState() {
|
|
1871
1903
|
const raw = this.readLocalJson(this.syncStatePath());
|
|
1872
1904
|
if (!isRecord(raw) || raw.schemaVersion !== 1 || raw.ownerAid !== this.options.ownerAid
|
|
@@ -1876,56 +1908,12 @@ export class OwnerDirectoryCache {
|
|
|
1876
1908
|
}
|
|
1877
1909
|
return {
|
|
1878
1910
|
schemaVersion: 1, ownerAid: this.options.ownerAid, granteeAid: this.options.selfAid,
|
|
1911
|
+
relationVersion: raw.relationVersion,
|
|
1912
|
+
revoked: raw.revoked === true,
|
|
1879
1913
|
files: raw.files,
|
|
1880
1914
|
blockedScopes: Array.isArray(raw.blockedScopes) ? raw.blockedScopes.filter(isOwnerDirectoryScope) : [],
|
|
1881
1915
|
};
|
|
1882
1916
|
}
|
|
1883
|
-
/**
|
|
1884
|
-
* 读授权快照。
|
|
1885
|
-
*
|
|
1886
|
-
* 兼容 v1:旧版本按 scope 记录授权(`activeScopes: ['agents','contacts']`),
|
|
1887
|
-
* 里面还可能带着已经废弃的 `agents`。**未知或多余的 scope 不会作废整份授权**——
|
|
1888
|
-
* 那会让升级当场断掉拉取。v1 只要能证明"允许读名录"就算有效,过期时间取
|
|
1889
|
-
* contacts 的那一份。
|
|
1890
|
-
*/
|
|
1891
|
-
loadGrant() {
|
|
1892
|
-
const raw = this.readLocalJson(this.authorizationPath());
|
|
1893
|
-
if (!isRecord(raw))
|
|
1894
|
-
return undefined;
|
|
1895
|
-
if (raw.ownerAid !== this.options.ownerAid || raw.granteeAid !== this.options.selfAid)
|
|
1896
|
-
return undefined;
|
|
1897
|
-
if (this.options.relationVersion !== undefined && typeof raw.relationVersion === 'number' && raw.relationVersion !== this.options.relationVersion)
|
|
1898
|
-
return undefined;
|
|
1899
|
-
if (raw.schemaVersion === 2) {
|
|
1900
|
-
if (!Number.isSafeInteger(raw.grantedAt) || !Number.isSafeInteger(raw.expiresAt))
|
|
1901
|
-
return undefined;
|
|
1902
|
-
return {
|
|
1903
|
-
schemaVersion: 2,
|
|
1904
|
-
ownerAid: this.options.ownerAid,
|
|
1905
|
-
granteeAid: this.options.selfAid,
|
|
1906
|
-
grantedAt: raw.grantedAt,
|
|
1907
|
-
expiresAt: raw.expiresAt,
|
|
1908
|
-
};
|
|
1909
|
-
}
|
|
1910
|
-
if (raw.schemaVersion === 1) {
|
|
1911
|
-
if (typeof raw.status !== 'string' || !GRANT_STATUSES.has(raw.status))
|
|
1912
|
-
return undefined;
|
|
1913
|
-
if (!Array.isArray(raw.activeScopes) || !raw.activeScopes.includes('contacts'))
|
|
1914
|
-
return undefined;
|
|
1915
|
-
const expiryMap = isRecord(raw.expiresAtByScope) ? raw.expiresAtByScope : {};
|
|
1916
|
-
const expiresAt = Number(expiryMap['contacts'] ?? 0);
|
|
1917
|
-
if (!Number.isSafeInteger(expiresAt) || expiresAt < 0)
|
|
1918
|
-
return undefined;
|
|
1919
|
-
return {
|
|
1920
|
-
schemaVersion: 2,
|
|
1921
|
-
ownerAid: this.options.ownerAid,
|
|
1922
|
-
granteeAid: this.options.selfAid,
|
|
1923
|
-
grantedAt: Number.isSafeInteger(raw.storedAt) ? raw.storedAt : 0,
|
|
1924
|
-
expiresAt,
|
|
1925
|
-
};
|
|
1926
|
-
}
|
|
1927
|
-
return undefined;
|
|
1928
|
-
}
|
|
1929
1917
|
/**
|
|
1930
1918
|
* 重算并写回 `directory.md`。
|
|
1931
1919
|
*
|
|
@@ -2009,18 +1997,15 @@ export class OwnerDirectoryCache {
|
|
|
2009
1997
|
/**
|
|
2010
1998
|
* 名录是否**确证**已不可用。
|
|
2011
1999
|
*
|
|
2012
|
-
*
|
|
2013
|
-
*
|
|
2014
|
-
*
|
|
2015
|
-
* 2. 授权有效但快照文件确实不在盘上(含热备)——此时没有可渲染的内容。
|
|
2000
|
+
* 唯一的判据是快照文件不在盘上(含热备)——没有授权凭证这一层了,读不到数据
|
|
2001
|
+
* 就是全部原因。撤销授权走 `revokeAuthorization`,它会把快照删掉,在这里
|
|
2002
|
+
* 表现为 true,语义仍然成立。
|
|
2016
2003
|
*
|
|
2017
2004
|
* 快照文件存在却读不出(解析失败、字段校验不过、原子写窗口)时返回 false:
|
|
2018
2005
|
* 这是"暂时读不到",不是"名录没了",调用方应保留旧注入而不是删掉。
|
|
2019
2006
|
*/
|
|
2020
2007
|
directoryGone() {
|
|
2021
|
-
|
|
2022
|
-
return true;
|
|
2023
|
-
return !existsAtomic(this.cachePath('contacts'));
|
|
2008
|
+
return this.isRevoked() || !existsAtomic(this.cachePath('contacts'));
|
|
2024
2009
|
}
|
|
2025
2010
|
/**
|
|
2026
2011
|
* 备注集合,带目录指纹缓存。
|
|
@@ -2039,7 +2024,12 @@ export class OwnerDirectoryCache {
|
|
|
2039
2024
|
this.remarksStampCache = stamp === null ? undefined : { stamp, remarks };
|
|
2040
2025
|
return remarks;
|
|
2041
2026
|
}
|
|
2042
|
-
|
|
2027
|
+
/**
|
|
2028
|
+
* 已废弃的授权凭证路径,**只用于清理存量文件**,不参与任何判断,也不再写入。
|
|
2029
|
+
*
|
|
2030
|
+
* 撤权时顺手删掉遗留文件;其他路径一律不读它。
|
|
2031
|
+
*/
|
|
2032
|
+
legacyAuthorizationPath() { return path.join(this.options.directory, 'authorization.json'); }
|
|
2043
2033
|
syncStatePath() { return path.join(this.options.directory, 'sync-state.json'); }
|
|
2044
2034
|
pendingPath() { return path.join(this.options.directory, 'pending.json'); }
|
|
2045
2035
|
cachePath(scope) {
|
|
@@ -2050,20 +2040,6 @@ export class OwnerDirectoryCache {
|
|
|
2050
2040
|
}
|
|
2051
2041
|
}
|
|
2052
2042
|
// ── Module-level helpers ─────────────────────────────────────────────────────
|
|
2053
|
-
/**
|
|
2054
|
-
* 从 `directory/access` 的结果里取过期时间。
|
|
2055
|
-
*
|
|
2056
|
-
* 协议按 scope 给过期时间,名录只剩一份,取 contacts 的那份;都没给就不过期。
|
|
2057
|
-
* 状态不是 active 的授权(revoked/expired)直接记 0,由 `scopeAccess` 之外的
|
|
2058
|
-
* 语义处理——这里只回答"读到什么时候"。
|
|
2059
|
-
*/
|
|
2060
|
-
function grantExpiryMs(result) {
|
|
2061
|
-
if (result.status !== 'active' && result.status !== 'sync_pending' && result.status !== 'revoke_pending')
|
|
2062
|
-
return 0;
|
|
2063
|
-
const map = isRecord(result.expires_at_by_scope) ? result.expires_at_by_scope : {};
|
|
2064
|
-
const value = Number(map['contacts'] ?? 0);
|
|
2065
|
-
return Number.isSafeInteger(value) && value >= 0 ? value : 0;
|
|
2066
|
-
}
|
|
2067
2043
|
function parseIdentityField(value) {
|
|
2068
2044
|
if (!isRecord(value) || typeof value.aid !== 'string' || typeof value.name !== 'string')
|
|
2069
2045
|
return undefined;
|
|
@@ -21,7 +21,7 @@ import { describeEntry, filterDirectory, } from './owner-directory-search.js';
|
|
|
21
21
|
import { isInternalEntry, ownerRefAid } from './owner-directory-scope.js';
|
|
22
22
|
import { editDistance, normalizeDirectoryText, sameDirectoryName, stripTrailingParenthetical, } from './owner-directory-text.js';
|
|
23
23
|
import { ownerResolver } from '../core/ownership/owner-resolver.js';
|
|
24
|
-
import {
|
|
24
|
+
import { snapshotOwnerAid, refreshOwnerDirectory, syncOwnerDirectoryForLookup } from './owner-directory-admission.js';
|
|
25
25
|
import { getPeerSnapshot } from '../config/peer-book.js';
|
|
26
26
|
import { resolveEntryContactable } from './owner-directory-policy.js';
|
|
27
27
|
/** `info` 按名字命中时的默认上限。 */
|
|
@@ -104,19 +104,17 @@ export async function executeDirectoryQueryCommand(command) {
|
|
|
104
104
|
if (!fs.existsSync(agentDir(command.selfAid))) {
|
|
105
105
|
return { ok: false, code: 'AGENT_NOT_FOUND', error: `agent ${command.selfAid} does not exist` };
|
|
106
106
|
}
|
|
107
|
-
// ownerAid
|
|
108
|
-
|
|
109
|
-
const ownerAid = authorizedOwnerAid(directory, command.selfAid);
|
|
107
|
+
// ownerAid 取自快照信封:快照自证归属,离线也能用。解析器只在没有快照时兜底。
|
|
108
|
+
const ownerAid = snapshotOwnerAid(directory, command.selfAid) ?? ownerResolver.owner(command.selfAid);
|
|
110
109
|
if (!ownerAid) {
|
|
111
|
-
return { ok: false, code: 'NOT_AUTHORIZED', error: 'directory is not
|
|
110
|
+
return { ok: false, code: 'NOT_AUTHORIZED', error: 'directory is not available for this agent' };
|
|
112
111
|
}
|
|
113
112
|
const cache = new OwnerDirectoryCache({ selfAid: command.selfAid, ownerAid, directory });
|
|
114
113
|
const scope = OWNER_DIRECTORY_SCOPES[0];
|
|
115
114
|
const accessReason = cache.scopeAccessUnavailableReason(scope);
|
|
116
|
-
//
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return { ok: false, code: 'NOT_AUTHORIZED', error: 'directory is not authorized for this agent' };
|
|
115
|
+
// 明确撤权不允许刷新;仅缺少快照时允许刷新恢复数据。
|
|
116
|
+
if (accessReason && (command.action !== 'refresh' || accessReason !== 'snapshot_missing')) {
|
|
117
|
+
return { ok: false, code: 'NOT_AUTHORIZED', error: 'directory is not available for this agent' };
|
|
120
118
|
}
|
|
121
119
|
// refresh 要在快照判空之前处理:它存在的意义正是"本地没有或太旧,去拉一次"。
|
|
122
120
|
if (command.action === 'refresh') {
|
|
@@ -292,7 +290,7 @@ function readBlockedAidsFromSnapshot(directory) {
|
|
|
292
290
|
* `ec directory info <名字>` 看详情。只查 `entries` 会让最该查到的两个人查不到。
|
|
293
291
|
* 与已有条目同 AID 时以条目为准,避免同一个人出现两次。
|
|
294
292
|
*
|
|
295
|
-
*
|
|
293
|
+
* 两者在快照解析阶段已经和快照信封里的 `ownerAid` 做过一致性校验,
|
|
296
294
|
* 所以补成条目时按“已核验”处理,否则他们会被自己的归属门禁判成外部。
|
|
297
295
|
*/
|
|
298
296
|
function withIdentityEntries(snapshot) {
|
package/dist/eck/kit-renderer.js
CHANGED
|
@@ -84,7 +84,7 @@ export function renderKitSections(ctx, manifestFile = DEFAULT_MANIFEST_FILE) {
|
|
|
84
84
|
const vars = {
|
|
85
85
|
...ctx.vars,
|
|
86
86
|
...(resolvedLifecycle === null ? {} : { lifecycle: resolvedLifecycle }),
|
|
87
|
-
activePush: ctx.vars.chatMode === 'proactive'
|
|
87
|
+
activePush: ctx.vars.chatMode === 'proactive',
|
|
88
88
|
};
|
|
89
89
|
const renderCtx = { ...ctx, vars };
|
|
90
90
|
const pathMappings = buildPathMappings(vars);
|
|
@@ -239,13 +239,15 @@ const PARAM_DESCRIPTIONS = {
|
|
|
239
239
|
lifecycle: '当前 agent 生命周期(created/ownerpending/bootstrapping/active)',
|
|
240
240
|
isBootstrapping: '当前 agent 是否处于 bootstrap 首次设定阶段',
|
|
241
241
|
hasPersona: '是否有自我定义内容(soul/ 下除指南外有非空文件)',
|
|
242
|
+
hasServicePacks: '是否有已激活的服务包(services/*/pack.json 且 requires 对名片通过)',
|
|
243
|
+
hasEventPacks: '是否有已启用的事件包(events/*/pack.json 且 enabled)',
|
|
242
244
|
hasOwnerDirectory: '是否有 Owner 名录注入文件($AGENT_DIR/directory/directory.md)',
|
|
243
|
-
ownerAid: 'Owner 的 AID
|
|
244
|
-
ownerName: 'Owner
|
|
245
|
+
ownerAid: 'Owner 的 AID(归属协议共识为准,与记忆写入同源;名录快照仅在与之一致时提供名字)',
|
|
246
|
+
ownerName: 'Owner 的显示名(名录快照,且仅在快照 Owner 与协议 Owner 一致时有值)',
|
|
245
247
|
personalAssistantAid: '个人助理的 AID(名录快照;没有个人助理时为空)',
|
|
246
248
|
personalAssistantName: '个人助理的显示名(名录快照)',
|
|
247
249
|
isPersonalAssistant: '当前 agent 是否就是 Owner 的个人助理(即时比较,读不到身份时为 false)',
|
|
248
|
-
isOwner: '当前 agent
|
|
250
|
+
isOwner: '当前 agent 是否就是协议确认的 Owner(即时比较;Owner 通常是人,一般恒为 false)',
|
|
249
251
|
contactsState: '准入现状一句话:内部联系人/外部联系人/名录外的人分别可不可联系',
|
|
250
252
|
peerId: '对端在该渠道的原生 ID',
|
|
251
253
|
peerKey: '对端跨渠道唯一标识(channel#urlEncode(peerId))',
|
|
@@ -280,7 +282,7 @@ const PARAM_DESCRIPTIONS = {
|
|
|
280
282
|
weekday: '当前本地星期几(按 timezone+locale)',
|
|
281
283
|
osInfo: '操作系统及版本(如 Windows 11 Pro (win32 10.0.26200))',
|
|
282
284
|
threadId: '话题 ID(多话题路由时)',
|
|
283
|
-
chatMode: '会话模式(interactive=同步交互 / proactive
|
|
285
|
+
chatMode: '会话模式(interactive=同步交互 / proactive=主动推送)',
|
|
284
286
|
activePush: '是否通过托管发送命令发送正式回复(true/false)',
|
|
285
287
|
isTriggerTask: '当前任务是否来源于 Trigger(true/false)',
|
|
286
288
|
proactivePreTool1stMsgChk: 'proactive 前置工具首消息检查(true/false)',
|
|
@@ -112,6 +112,8 @@ function renderOneItem(item, sessionVars, sessionCache, contentSentinel) {
|
|
|
112
112
|
peerId: item.peerId ?? sessionVars.peerId,
|
|
113
113
|
peerName: item.peerName ?? sessionVars.peerName,
|
|
114
114
|
peerType: item.peerType ?? sessionVars.peerType,
|
|
115
|
+
// 本端给自己派的任务:信封头标「跨话题自派」,让模型分清「我派的活」和「对端说的话」。
|
|
116
|
+
selfAddressed: item.selfAddressed || undefined,
|
|
115
117
|
peerRole: item.peerRole ?? sessionVars.peerRole,
|
|
116
118
|
sameDevice: item.sameDevice ?? sessionVars.sameDevice,
|
|
117
119
|
sameNetwork: item.sameNetwork ?? sessionVars.sameNetwork,
|
|
@@ -509,7 +509,7 @@ function validateDefaultsValue(fieldPath, value) {
|
|
|
509
509
|
return;
|
|
510
510
|
}
|
|
511
511
|
if (fieldPath === 'config.chatMode') {
|
|
512
|
-
if (!['interactive', 'proactive'
|
|
512
|
+
if (!['interactive', 'proactive'].includes(String(value)))
|
|
513
513
|
throw makeError(`${fieldPath} is invalid`, 'INVALID_SETTINGS_VALUE');
|
|
514
514
|
return;
|
|
515
515
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { isValidAid } from '../aun/aid/validation.js';
|
|
2
2
|
import { resolvePeerDisplayLabel } from '../config/peer-book.js';
|
|
3
3
|
import { resolvePeerRoleDetail } from '../config/peer-role-resolver.js';
|
|
4
|
-
import { ConfigTarget, read } from '../config/config-manager.js';
|
|
5
|
-
import { resolveAgentLifecycle } from '../config/lifecycle.js';
|
|
6
4
|
import { resolveChatMode } from '../core/message/peer-mode.js';
|
|
7
5
|
import { resolvePermissionMode } from '../core/model/config-scope.js';
|
|
8
6
|
import { formatPeerKey } from '../core/relation/peer-identity.js';
|
|
@@ -102,8 +100,6 @@ export function createEcwebMessageContextProvider(sessionManager, resolveRuntime
|
|
|
102
100
|
chatMode: resolveChatMode({
|
|
103
101
|
self: identity.selfAid, peerKey, role, chatType, peerType,
|
|
104
102
|
channelType: identity.channelType,
|
|
105
|
-
lifecycle: resolveAgentLifecycle(read(ConfigTarget.Agent, { self: identity.selfAid }) ?? {}),
|
|
106
|
-
sessionType: scopedSession?.sessionType ?? scopedSession?.metadata?.sessionType ?? 'main',
|
|
107
103
|
}),
|
|
108
104
|
...(peerLabels ? { peerLabels } : {}),
|
|
109
105
|
};
|
|
@@ -23,6 +23,8 @@ async function sameProcess(identity) {
|
|
|
23
23
|
* Prefer a cooperative IPC request for supervised children on every platform.
|
|
24
24
|
* Windows taskkill without /F cannot invoke Node's SIGTERM handler; only
|
|
25
25
|
* POSIX can use SIGTERM when no parent-child IPC channel is available.
|
|
26
|
+
* The cooperative callback must use the captured ChildProcess IPC channel,
|
|
27
|
+
* never a PID-addressed transport. That handle cannot address a reused PID.
|
|
26
28
|
*/
|
|
27
29
|
const IPC_GRACEFUL_STOP_MS = 3_000;
|
|
28
30
|
const POSIX_GRACEFUL_STOP_MS = 1_000;
|
|
@@ -49,14 +51,16 @@ export async function stopEcwebProcess(identity, timeoutMs = FORCED_STOP_MS, onT
|
|
|
49
51
|
catch { }
|
|
50
52
|
}
|
|
51
53
|
};
|
|
52
|
-
if (!await sameProcess(identity))
|
|
53
|
-
return;
|
|
54
54
|
if (requestGracefulStop) {
|
|
55
|
+
// Ask our actual child first. Fresh OS identity queries are only needed
|
|
56
|
+
// before falling back to PID-addressed signals, including on IPC failure.
|
|
55
57
|
if (await waitForExit(false, IPC_GRACEFUL_STOP_MS, requestGracefulStop))
|
|
56
58
|
return;
|
|
57
59
|
if (!await sameProcess(identity))
|
|
58
60
|
return;
|
|
59
61
|
}
|
|
62
|
+
else if (!await sameProcess(identity))
|
|
63
|
+
return;
|
|
60
64
|
if (!platform.isWindows && await waitForExit(false, POSIX_GRACEFUL_STOP_MS))
|
|
61
65
|
return;
|
|
62
66
|
if (!await sameProcess(identity))
|