evolcore 0.0.43-test.3 → 0.0.43-test.5
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 +82 -0
- package/bin/ecmsg.js +492 -0
- package/bin/install-codex-managed-hooks.mjs +130 -8
- package/dist/ability/application-service.js +37 -0
- package/dist/ability/resources.js +28 -0
- package/dist/ability/runtime.js +6 -1
- package/dist/agents/claude-runner.js +7 -5
- package/dist/agents/codex/app-server-client.js +0 -12
- package/dist/agents/codex-runner.js +12 -54
- package/dist/agents/ecagent-runner.js +130 -35
- package/dist/aun/aid/agentmd.js +56 -12
- package/dist/aun/aid/control-aid.js +15 -0
- package/dist/aun/aid/identity.js +8 -0
- package/dist/aun/aid/ownership-operation.js +12 -3
- package/dist/aun/menu/client.js +8 -7
- package/dist/aun/menu/index.js +1 -1
- package/dist/aun/menu/transport.js +8 -5
- package/dist/aun/service-proxy.js +3 -0
- package/dist/channels/aun.js +56 -22
- package/dist/channels/daemon.js +12 -4
- package/dist/cli/agent-command.js +5 -0
- package/dist/cli/agent-create.js +32 -8
- package/dist/cli/agent.js +9 -3
- package/dist/cli/aid-bind-command.js +3 -0
- package/dist/cli/aun-commands.js +12 -5
- package/dist/cli/code-stats.js +451 -213
- package/dist/cli/ctl-command.js +1 -3
- package/dist/cli/daemon-commands.js +42 -21
- package/dist/cli/directory.js +7 -8
- package/dist/cli/ecmsg-gateway.js +204 -0
- package/dist/cli/getmeta-command.js +2 -1
- package/dist/cli/index.js +6 -0
- package/dist/cli/init.js +58 -18
- package/dist/cli/provider-command.js +82 -5
- package/dist/cli/restart-monitor.js +11 -19
- package/dist/cli/stats.js +8 -1
- package/dist/cli/task-context.js +3 -0
- package/dist/cli/trigger-command.js +20 -14
- package/dist/config/boot-log.js +23 -2
- package/dist/config/config-field-policy.js +2 -0
- package/dist/config/config-manager.js +13 -17
- package/dist/config/daemon-services.js +1 -0
- package/dist/config/peer-role-resolver.js +6 -6
- package/dist/config/provider-identity-migration.js +202 -0
- package/dist/config/provider-identity.js +37 -0
- package/dist/config/provider-ipc-service.js +40 -3
- package/dist/config/provider-local-sync.js +153 -0
- package/dist/config/providers-config.js +32 -4
- package/dist/config/providers-management.js +144 -68
- package/dist/config/providers.js +4 -1
- package/dist/config/role-schema.js +3 -3
- package/dist/config/schema-migration.js +188 -3
- package/dist/core/agent-application-service.js +11 -0
- package/dist/core/agent-ipc-registration.js +2 -0
- package/dist/core/agent-runtime.js +45 -11
- package/dist/core/auth/auth-gateway.js +8 -6
- package/dist/core/auth/delegation-diagnostics.js +6 -2
- package/dist/core/auth/operation-authorizer.js +5 -2
- package/dist/core/auth/operation-catalog.js +6 -4
- package/dist/core/baseagent-loader.js +11 -3
- package/dist/core/bootstrap-service.js +8 -0
- package/dist/core/channel-loader.js +61 -23
- package/dist/core/command/agent-control.js +4 -1
- package/dist/core/command/chatmode-config.js +46 -0
- package/dist/core/command/cli-intent-parser.js +2 -1
- package/dist/core/command/command-handler.js +16 -20
- package/dist/core/command/daemon-diagnostics.js +2 -1
- package/dist/core/command/menu-catalog.js +1 -1
- package/dist/core/command/menu-handler.js +16 -16
- package/dist/core/command/menu-protocol.js +4 -2
- package/dist/core/command/provider-menu.js +4 -2
- package/dist/core/command/role-menu.js +2 -2
- package/dist/core/command/slash-handler.js +56 -42
- package/dist/core/daemon-lifecycle.js +35 -17
- package/dist/core/event-catalog.js +19 -0
- package/dist/core/evolagent-registry.js +3 -0
- package/dist/core/handoff/runtime.js +9 -3
- package/dist/core/initialization/service.js +4 -3
- package/dist/core/ipc-registration.js +6 -0
- package/dist/core/message/aun-ipc-sender.js +81 -3
- package/dist/core/message/im-renderer.js +24 -19
- package/dist/core/message/message-admission.js +13 -2
- package/dist/core/message/response-engine.js +40 -41
- package/dist/core/message/send-options.js +40 -0
- package/dist/core/message/send-routing.js +310 -0
- package/dist/core/model/model-capabilities.js +37 -0
- package/dist/core/model/model-catalog.js +6 -2
- package/dist/core/ownership/owner-resolver.js +117 -14
- package/dist/core/permission/ec-command-parser.js +195 -27
- package/dist/core/permission/readonly-shell-query.js +66 -7
- package/dist/core/permission/tool-error-code.js +13 -1
- package/dist/core/permission/tool-policy.js +74 -20
- package/dist/core/plugin-lifecycle.js +6 -2
- package/dist/core/relation/pa-team.js +7 -2
- package/dist/core/relation/same-owner-proof.js +131 -0
- package/dist/core/session/session-idle-monitor.js +94 -16
- package/dist/core/session/session-manager.js +69 -16
- package/dist/core/thread/thread-route.js +5 -2
- package/dist/directory/owner-directory-cache.js +690 -99
- package/dist/directory/owner-directory-markdown.js +146 -36
- package/dist/directory/owner-directory-query-operation.js +7 -9
- package/dist/directory/owner-directory-scope.js +12 -0
- package/dist/directory/owner-directory-search.js +5 -1
- package/dist/directory/owner-directory-store.js +28 -0
- package/dist/ecweb/basic-settings-service.js +15 -1
- package/dist/ecweb/message-context-service.js +2 -2
- package/dist/ecweb/providers-service.js +3 -1
- package/dist/ecweb/runtime/lifecycle.js +38 -5
- package/dist/ecweb/runtime/supervisor.js +157 -49
- package/dist/index.js +202 -38
- package/dist/paths.js +2 -1
- package/dist/proxy/manager.js +2 -0
- package/dist/proxy/service-supervisor.js +379 -143
- package/dist/response-system/engines/v1/proactive-flow.js +4 -0
- package/dist/trigger/application-service.js +1 -0
- package/dist/trigger/audit.js +3 -2
- package/dist/trigger/authorization.js +2 -3
- package/dist/trigger/event-source.js +4 -0
- package/dist/trigger/feedback.js +26 -2
- package/dist/trigger/history.js +4 -3
- package/dist/trigger/ipc-service.js +24 -19
- package/dist/trigger/manager.js +3 -5
- package/dist/trigger/parser.js +4 -21
- package/dist/trigger/patch.js +3 -15
- package/dist/trigger/scheduler.js +48 -13
- package/dist/trigger/system-definitions.js +2 -2
- package/dist/trigger/validation.js +4 -13
- package/dist/utils/autostart.js +2 -2
- package/dist/utils/cross-platform.js +36 -8
- package/dist/utils/error-utils.js +8 -0
- package/dist/utils/macos-autostart.js +31 -0
- package/dist/utils/model-prices.jsonl +15 -8
- package/dist/utils/process-introspect.js +21 -1
- package/dist/utils/public-suffix.js +5811 -0
- package/dist/utils/startup-trace.js +7 -1
- package/dist/utils/windows-autostart.js +42 -7
- package/ecagent/dist/harness/compaction/branch-summarization.js +1 -1
- package/ecagent/dist/harness/compaction/compaction.js +4 -4
- package/ecagent/dist/harness/env/nodejs.js +46 -2
- package/kits/docs/aun/ABILITY_CALLING.md +3 -3
- package/kits/docs/channels/aun.md +1 -1
- package/kits/docs/channels/feishu.md +2 -2
- package/kits/docs/context-assembly.md +20 -4
- package/kits/docs/evolcore/INDEX.md +3 -2
- package/kits/docs/evolcore/agent.md +2 -2
- package/kits/docs/evolcore/aid.md +8 -2
- package/kits/docs/evolcore/ctl.md +13 -4
- package/kits/docs/evolcore/directory.md +48 -15
- package/kits/docs/evolcore/file-navigation.md +63 -49
- package/kits/docs/evolcore/group.md +6 -6
- package/kits/docs/evolcore/memory-consolidation.md +1 -1
- package/kits/docs/evolcore/menu-protocol.md +33 -3
- package/kits/docs/evolcore/model.md +5 -3
- package/kits/docs/evolcore/msg.md +28 -27
- package/kits/docs/evolcore/provider.md +39 -5
- package/kits/docs/evolcore/response.md +3 -1
- package/kits/docs/evolcore/thread-chain.md +12 -14
- package/kits/docs/evolcore/tool-authorization.md +21 -1
- package/kits/docs/evolcore/trigger.md +12 -9
- package/kits/docs/identity/ROLE_DETAIL.md +1 -1
- package/kits/docs/prompt-loading-architecture.md +30 -20
- package/kits/eck_manifest.auxiliary.json +5 -5
- package/kits/eck_manifest.json +28 -49
- package/kits/eck_manifest.memory.json +18 -18
- package/kits/rules/01-overview.md +43 -45
- package/kits/rules/02-navigation.md +44 -53
- package/kits/rules/03-identity.md +21 -25
- package/kits/rules/04-relation.md +23 -33
- package/kits/rules/05-venue.md +24 -25
- package/kits/rules/06-channel.md +3 -3
- package/kits/schemas/_meta.json +20 -27
- package/kits/schemas/agent-config.schema.19.json +10 -6
- package/kits/schemas/providers.schema.2.json +74 -0
- package/kits/schemas/relation-config.schema.12.json +2 -2
- package/kits/schemas/role-config.schema.2.json +5 -5
- package/kits/schemas/role-registry.schema.1.json +1 -1
- package/kits/skills/ec-agent-create/SKILL.md +1 -0
- package/kits/skills/ec-service-proxy/SKILL.md +3 -0
- package/kits/skills/ec-trigger/SKILL.md +4 -4
- package/kits/skills/ec-trigger/references/examples.md +1 -1
- package/kits/templates/system-fragments/channel.md +5 -5
- package/kits/templates/system-fragments/commands.md +3 -2
- package/kits/templates/system-fragments/directory-contacts.md +10 -3
- package/kits/templates/system-fragments/identity.md +0 -1
- package/kits/templates/system-fragments/personal-assistant.md +22 -3
- package/kits/templates/system-fragments/reply.md +47 -28
- package/kits/templates/system-fragments/session.md +2 -9
- package/kits/templates/system-fragments/thread.md +5 -5
- package/package.json +17 -13
- package/kits/schemas/agent-config.schema.20.json +0 -925
- package/kits/schemas/relation-config.schema.13.json +0 -289
- package/kits/schemas/role-config.schema.3.json +0 -1038
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** Message Service TTL in seconds; unrelated to Menu execution/client timeouts. */
|
|
2
2
|
export const MENU_MESSAGE_TTL_SECONDS = 60;
|
|
3
|
+
/** Menu is an application control protocol, so it uses the AUN control stream. */
|
|
4
|
+
export const MENU_MESSAGE_CLASS = 'control';
|
|
3
5
|
export const MENU_VOLATILE_SDK_VERSION = '0.5.17';
|
|
4
6
|
function parseSdkVersion(value) {
|
|
5
7
|
if (typeof value !== 'string' || !/^\d+\.\d+\.\d+$/.test(value.trim()))
|
|
@@ -30,22 +32,23 @@ export function menuTransportParams(method, params) {
|
|
|
30
32
|
if (method !== 'message.send' || typeof params.payload?.type !== 'string'
|
|
31
33
|
|| !params.payload.type.startsWith('menu.'))
|
|
32
34
|
return params;
|
|
33
|
-
if (params.payload.type !== 'menu.response' && params.payload.type !== 'menu.event')
|
|
34
|
-
return { ...params, ttl: MENU_MESSAGE_TTL_SECONDS };
|
|
35
|
+
if (params.payload.type !== 'menu.response' && params.payload.type !== 'menu.event') {
|
|
36
|
+
return { ...params, message_class: MENU_MESSAGE_CLASS, ttl: MENU_MESSAGE_TTL_SECONDS };
|
|
37
|
+
}
|
|
35
38
|
const { to_device_id: target, menu_client_sdk_version: sdkVersion, menu_client_volatile_v1: capability, ...rest } = params;
|
|
36
39
|
delete rest.device_id;
|
|
37
40
|
if (!supportsMenuVolatileTransport(sdkVersion ?? params.protected_headers?.sdk_version, capability)) {
|
|
38
41
|
// Evol App versions backed by fastaun < 0.5.17 do not consume the
|
|
39
42
|
// volatile cursor or understand device-targeted Menu responses.
|
|
40
|
-
return rest;
|
|
43
|
+
return { ...rest, message_class: MENU_MESSAGE_CLASS };
|
|
41
44
|
}
|
|
42
45
|
if (target === undefined)
|
|
43
|
-
return { ...rest, ttl: MENU_MESSAGE_TTL_SECONDS };
|
|
46
|
+
return { ...rest, message_class: MENU_MESSAGE_CLASS, ttl: MENU_MESSAGE_TTL_SECONDS };
|
|
44
47
|
const deviceId = menuSenderDeviceId(target);
|
|
45
48
|
if (!deviceId) {
|
|
46
49
|
throw Object.assign(new Error('Invalid Menu reply device'), { code: 'INVALID_MENU_REPLY_DEVICE', retryable: false });
|
|
47
50
|
}
|
|
48
51
|
// device_id takes precedence in the SDK; do not let it override the captured
|
|
49
52
|
// request sender. A rejected target is never retried as an AID broadcast.
|
|
50
|
-
return { ...rest, ttl: MENU_MESSAGE_TTL_SECONDS, to_device_id: deviceId };
|
|
53
|
+
return { ...rest, message_class: MENU_MESSAGE_CLASS, ttl: MENU_MESSAGE_TTL_SECONDS, to_device_id: deviceId };
|
|
51
54
|
}
|
|
@@ -62,6 +62,9 @@ function discoverInstancePort(serviceName, expectedPort) {
|
|
|
62
62
|
&& isProcessAlive(rec.pid)
|
|
63
63
|
&& typeof rec.startedAt === 'number'
|
|
64
64
|
&& Number.isFinite(rec.startedAt)
|
|
65
|
+
&& (raw.owner !== 'evolcore-service-supervisor'
|
|
66
|
+
|| ((raw.state === undefined || raw.state === 'ready')
|
|
67
|
+
&& startTimeMatches(rec.startedAt, getProcessStartTime(rec.pid))))
|
|
65
68
|
&& (serviceName !== 'ecweb' || !('schemaVersion' in rec) || startTimeMatches(rec.startedAt, getProcessStartTime(rec.pid)))
|
|
66
69
|
&& rec.startedAt >= 0
|
|
67
70
|
&& Number.isInteger(rec.port)
|
package/dist/channels/aun.js
CHANGED
|
@@ -4,11 +4,11 @@ import { buildContactRequest, contactIntroductionText, consumeContactIntroductio
|
|
|
4
4
|
import crypto from 'crypto';
|
|
5
5
|
import { performance } from 'node:perf_hooks';
|
|
6
6
|
import fs from 'fs';
|
|
7
|
-
import { ownerResolver } from '../core/ownership/owner-resolver.js';
|
|
7
|
+
import { ownerResolver, OWNERSHIP_CACHE_MAX_AGE_MS } from '../core/ownership/owner-resolver.js';
|
|
8
8
|
import { OWNER_DIRECTORY_APPLY_WAIT_MS, OwnerDirectoryCache, parseOwnerDirectoryGrantAbilityResponse } from '../directory/owner-directory-cache.js';
|
|
9
9
|
import { registerOwnerDirectoryAdmission } from '../directory/owner-directory-admission.js';
|
|
10
10
|
import { OwnerDirectoryAgentMdSync } from '../directory/owner-directory-agentmd-sync.js';
|
|
11
|
-
import { parseNotificationSnapshots } from '../directory/owner-directory-store.js';
|
|
11
|
+
import { parseNotificationSnapshots, parseNotificationPublished } from '../directory/owner-directory-store.js';
|
|
12
12
|
import { OWNER_DIRECTORY_SCOPES } from '../directory/owner-directory-cache.js';
|
|
13
13
|
import path from 'path';
|
|
14
14
|
import os from 'os';
|
|
@@ -44,7 +44,7 @@ import * as outbox from '../aun/outbox.js';
|
|
|
44
44
|
import { aunProtectedHeaders } from '../aun/model-headers.js';
|
|
45
45
|
import { formatSize } from '../utils/media-cache.js';
|
|
46
46
|
import { formatPeerKey, PeerIdentityCache } from '../core/relation/peer-identity.js';
|
|
47
|
-
import {
|
|
47
|
+
import { prepareSameOwnerProof, registerSameOwnerClient, unregisterSameOwnerClient } from '../core/relation/same-owner-proof.js';
|
|
48
48
|
import { isHClassPath } from '../core/permission/protected-paths.js';
|
|
49
49
|
import { consumeAunCausation, registerAunCausation } from '../core/causation/aun-association.js';
|
|
50
50
|
import { deriveCausation, normalizeCausation } from '../core/causation/context.js';
|
|
@@ -1919,13 +1919,16 @@ export class AUNChannel {
|
|
|
1919
1919
|
// ACK 只回传通知自带的 operation_id;旧版通知不带它,也不等 ACK,不能自造一个回过去。
|
|
1920
1920
|
const operationId = typeof record.data.operation_id === 'string' && record.data.operation_id.trim()
|
|
1921
1921
|
? record.data.operation_id : undefined;
|
|
1922
|
+
// `published.<scope>.updated_at_ms`:远端这一版自己声明的修改时间。
|
|
1923
|
+
// 协调者用它丢弃乱序到达的旧通知,并判断已经拉到的东西够不够新。
|
|
1924
|
+
const published = parseNotificationPublished(record.data);
|
|
1922
1925
|
try {
|
|
1923
1926
|
const runtime = await this.getOwnerDirectoryRuntime();
|
|
1924
1927
|
if (!runtime)
|
|
1925
1928
|
return;
|
|
1926
1929
|
// 记标记。真正的网络拉取在 ACK 之后发起(见方法末尾):先拉会把网络耗时
|
|
1927
1930
|
// 压进 App 侧的重试窗口,App 可能因此在拿到 ACK 前再发一次通知。
|
|
1928
|
-
await runtime.cache.handleOwnerChangedEvent(senderAid, Object.keys(digests).length > 0 ? Object.fromEntries(Object.entries(digests).map(([k, v]) => [k, v?.content_digest ?? ''])) : undefined);
|
|
1931
|
+
await runtime.cache.handleOwnerChangedEvent(senderAid, Object.keys(digests).length > 0 ? Object.fromEntries(Object.entries(digests).map(([k, v]) => [k, v?.content_digest ?? ''])) : undefined, published);
|
|
1929
1932
|
// 重试状态只在发通知的那台设备内存里;拿不到它的设备 ID 就不回,
|
|
1930
1933
|
// 广播给 Owner 全部设备既清不掉重试,又会被其它设备当成会话消息展示。
|
|
1931
1934
|
if (operationId && senderDeviceId) {
|
|
@@ -2352,7 +2355,7 @@ export class AUNChannel {
|
|
|
2352
2355
|
this.observerGroupMemberFetches.clear();
|
|
2353
2356
|
// Clean up existing client if any
|
|
2354
2357
|
if (this.client) {
|
|
2355
|
-
|
|
2358
|
+
unregisterSameOwnerClient(this.config.aid, this.client);
|
|
2356
2359
|
ownerResolver.detachClient(this.config.aid, this.client);
|
|
2357
2360
|
this.trace('OUT', 'client.close', { reason: 'initClient' });
|
|
2358
2361
|
try {
|
|
@@ -2394,7 +2397,7 @@ export class AUNChannel {
|
|
|
2394
2397
|
const localConfig = loadAgent(aidName);
|
|
2395
2398
|
ownerResolver.setAgentConfiguredOwners(aidName, configuredOwnerList(localConfig));
|
|
2396
2399
|
ownerResolver.attachClient(aidName, client);
|
|
2397
|
-
|
|
2400
|
+
registerSameOwnerClient(aidName, client, store);
|
|
2398
2401
|
try {
|
|
2399
2402
|
await this.config.onClientReady?.(client);
|
|
2400
2403
|
}
|
|
@@ -3402,7 +3405,7 @@ export class AUNChannel {
|
|
|
3402
3405
|
// 解析对端身份(30天缓存)
|
|
3403
3406
|
const selfAgentDir = path.join(resolvePaths().agentsDir, this.config.aid);
|
|
3404
3407
|
const peerIdentity = await PeerIdentityCache.resolve('aun', fromAid, selfAgentDir, this.store, false, this.config.keystorePath || resolveRoot());
|
|
3405
|
-
await
|
|
3408
|
+
await prepareSameOwnerProof(this.config.aid, fromAid);
|
|
3406
3409
|
const shortAid = this.getShortAid(fromAid);
|
|
3407
3410
|
const displayName = peerIdentity.name || shortAid;
|
|
3408
3411
|
// 详细 dispatch 决策日志:记录消息为何被路由到 agent
|
|
@@ -4599,7 +4602,7 @@ export class AUNChannel {
|
|
|
4599
4602
|
if (!config)
|
|
4600
4603
|
return undefined;
|
|
4601
4604
|
const lifecycle = resolveAgentLifecycle(config);
|
|
4602
|
-
if (lifecycle === null
|
|
4605
|
+
if (lifecycle === null)
|
|
4603
4606
|
return undefined;
|
|
4604
4607
|
return firstConfiguredOwner(config);
|
|
4605
4608
|
}
|
|
@@ -4666,6 +4669,8 @@ export class AUNChannel {
|
|
|
4666
4669
|
return;
|
|
4667
4670
|
// Claim before awaiting submission: an error or lost receipt must not cause automatic resends.
|
|
4668
4671
|
AUNChannel.configuredOwnerBindAttempts.add(attemptKey);
|
|
4672
|
+
logger.info(`${this.logPrefix()} Submitting configured Owner binding invitation: `
|
|
4673
|
+
+ `subject=${subjectAid} owner=${ownerAid} consensus=${current.consensusStatus}`);
|
|
4669
4674
|
await ownerResolver.bind(subjectAid, ownerAid, () => this.isCurrentConfiguredOwnerBind(client, epoch) && this.configuredOwnerAid() === ownerAid
|
|
4670
4675
|
&& !ownerResolver.hasRejectedOwnerBinding(subjectAid, ownerAid));
|
|
4671
4676
|
}
|
|
@@ -4744,7 +4749,7 @@ export class AUNChannel {
|
|
|
4744
4749
|
}
|
|
4745
4750
|
// Force close SDK client,中断它内部的重连循环
|
|
4746
4751
|
if (this.client) {
|
|
4747
|
-
|
|
4752
|
+
unregisterSameOwnerClient(this.config.aid, this.client);
|
|
4748
4753
|
ownerResolver.detachClient(this.config.aid, this.client);
|
|
4749
4754
|
this.trace('OUT', 'client.close', { reason: `takeover_${reason}` });
|
|
4750
4755
|
this.client.close().catch(() => { });
|
|
@@ -4771,7 +4776,7 @@ export class AUNChannel {
|
|
|
4771
4776
|
logger.debug(`${this.logPrefix()} TS-layer reconnect (${reason}) succeeded but generation stale, closing stale client`);
|
|
4772
4777
|
this.stopOwnerDirectoryRefresh();
|
|
4773
4778
|
if (this.client) {
|
|
4774
|
-
|
|
4779
|
+
unregisterSameOwnerClient(this.config.aid, this.client);
|
|
4775
4780
|
ownerResolver.detachClient(this.config.aid, this.client);
|
|
4776
4781
|
this.client.close().catch(() => { });
|
|
4777
4782
|
this.client = null;
|
|
@@ -5296,9 +5301,16 @@ export class AUNChannel {
|
|
|
5296
5301
|
return { status: decision.reason === 'unavailable' ? 'retry' : 'permanent',
|
|
5297
5302
|
code: 'CONTACT_DENIED', error: `联系人准入未通过:${decision.reason}` };
|
|
5298
5303
|
}
|
|
5304
|
+
async prepareAppContactOutbound(channelId, delivery, payload, params) {
|
|
5305
|
+
if (delivery.chatType === 'private' && !this.config.pureIdentity
|
|
5306
|
+
&& !this.hasContactControlPermit(channelId, payload, params)) {
|
|
5307
|
+
await ownerResolver.refresh(this.config.aid, { maxAgeMs: OWNERSHIP_CACHE_MAX_AGE_MS, allowTransient: true });
|
|
5308
|
+
}
|
|
5309
|
+
return this.appContactOutboundBlock(channelId, delivery, payload, params);
|
|
5310
|
+
}
|
|
5299
5311
|
async sendAunPayload(channelId, payload, context, label) {
|
|
5300
5312
|
const delivery = this.requireDelivery(channelId, context);
|
|
5301
|
-
const blocked = this.
|
|
5313
|
+
const blocked = await this.prepareAppContactOutbound(channelId, delivery, payload);
|
|
5302
5314
|
if (blocked)
|
|
5303
5315
|
return { ok: false, ...blocked };
|
|
5304
5316
|
let normalizedPayload;
|
|
@@ -5809,6 +5821,7 @@ export class AUNChannel {
|
|
|
5809
5821
|
/** An unadmitted outbound text becomes an Owner request, never a send to the peer. */
|
|
5810
5822
|
async requestOutboundContact(args) {
|
|
5811
5823
|
const selfAid = this.config.aid;
|
|
5824
|
+
await ownerResolver.refresh(selfAid, { maxAgeMs: OWNERSHIP_CACHE_MAX_AGE_MS, allowTransient: true });
|
|
5812
5825
|
const binding = currentContactBinding(selfAid);
|
|
5813
5826
|
if (!binding) {
|
|
5814
5827
|
return { ok: false, code: 'CONTACT_DIRECTORY_UNAVAILABLE', error: '本端 Owner 关系不可用,未发送申请或原消息' };
|
|
@@ -5891,7 +5904,7 @@ export class AUNChannel {
|
|
|
5891
5904
|
code: 'INVALID_REQUEST_TTL',
|
|
5892
5905
|
};
|
|
5893
5906
|
}
|
|
5894
|
-
const contactBlock = this.
|
|
5907
|
+
const contactBlock = await this.prepareAppContactOutbound(args.to, { chatType: 'private' }, finalPayload, { encrypt: args.encrypt, rawPayload: preserveRawPayload });
|
|
5895
5908
|
if (contactBlock)
|
|
5896
5909
|
return { ok: false, code: contactBlock.code, error: contactBlock.error };
|
|
5897
5910
|
if (preserveRawPayload && jsonUtf8Size(finalPayload) > AUN_MAX_PAYLOAD_SIZE) {
|
|
@@ -5911,7 +5924,7 @@ export class AUNChannel {
|
|
|
5911
5924
|
let peerRole = null;
|
|
5912
5925
|
try {
|
|
5913
5926
|
const { resolvePeerRoleDetail } = await import('../config/peer-role-resolver.js');
|
|
5914
|
-
await
|
|
5927
|
+
await prepareSameOwnerProof(this.config.aid, args.to);
|
|
5915
5928
|
peerRole = resolvePeerRoleDetail({
|
|
5916
5929
|
selfAid: this.config.aid,
|
|
5917
5930
|
channelKey: `aun#${this.config.aid}#main`,
|
|
@@ -6232,7 +6245,7 @@ export class AUNChannel {
|
|
|
6232
6245
|
const delivery = this.requirePersistedDelivery(channelId, entry.delivery);
|
|
6233
6246
|
const context = this.withDelivery(entry.context, delivery);
|
|
6234
6247
|
if (!entry.deliveryReceipt) {
|
|
6235
|
-
const blocked = this.
|
|
6248
|
+
const blocked = await this.prepareAppContactOutbound(channelId, delivery, { type: 'text', text: entry.text });
|
|
6236
6249
|
if (blocked)
|
|
6237
6250
|
return blocked;
|
|
6238
6251
|
}
|
|
@@ -6752,7 +6765,6 @@ export class AUNChannel {
|
|
|
6752
6765
|
if (delivery.chatType === 'group') {
|
|
6753
6766
|
logger.info(`${this.logPrefix()} thought.put ok group=${targetId} task=${taskId} stage=${stage} encrypt=${encrypt} tid=${tid ?? '?'}`);
|
|
6754
6767
|
this.eventBus?.publish?.({ type: 'message:thought-put', agentName: this.config.aid, channelId, taskId, text: thoughtText });
|
|
6755
|
-
this.forwardOutbound(putRes);
|
|
6756
6768
|
if (thoughtText) {
|
|
6757
6769
|
const statsContext = await this.groupStatsContext(channelId);
|
|
6758
6770
|
this.aidStatsCollector?.recordOutbound(this.config.aid, channelId, Buffer.byteLength(thoughtText, 'utf-8'), thoughtText, false, encrypt, context?.metadata?.chatmode ?? 'proactive', 'thought', statsContext);
|
|
@@ -6761,7 +6773,6 @@ export class AUNChannel {
|
|
|
6761
6773
|
else {
|
|
6762
6774
|
logger.info(`${this.logPrefix()} thought.put ok p2p=${this.peerLabel(targetId)} task=${taskId} stage=${stage} encrypt=${encrypt} tid=${tid ?? '?'}`);
|
|
6763
6775
|
this.eventBus?.publish?.({ type: 'message:thought-put', agentName: this.config.aid, channelId, taskId, text: thoughtText });
|
|
6764
|
-
this.forwardOutbound(putRes);
|
|
6765
6776
|
if (thoughtText) {
|
|
6766
6777
|
this.aidStatsCollector?.recordOutbound(this.config.aid, targetId, Buffer.byteLength(thoughtText, 'utf-8'), thoughtText, false, encrypt, context?.metadata?.chatmode ?? 'proactive', 'thought');
|
|
6767
6778
|
}
|
|
@@ -7021,7 +7032,7 @@ export class AUNChannel {
|
|
|
7021
7032
|
}
|
|
7022
7033
|
async deliverImageEntry(entry) {
|
|
7023
7034
|
if (!entry.deliveryReceipt) {
|
|
7024
|
-
const blocked = this.
|
|
7035
|
+
const blocked = await this.prepareAppContactOutbound(entry.channelId, this.requirePersistedDelivery(entry.channelId, entry.delivery), { type: 'image' });
|
|
7025
7036
|
if (blocked)
|
|
7026
7037
|
return blocked;
|
|
7027
7038
|
}
|
|
@@ -7072,7 +7083,7 @@ export class AUNChannel {
|
|
|
7072
7083
|
}
|
|
7073
7084
|
async deliverFileEntry(entry) {
|
|
7074
7085
|
if (!entry.deliveryReceipt) {
|
|
7075
|
-
const blocked = this.
|
|
7086
|
+
const blocked = await this.prepareAppContactOutbound(entry.channelId, this.requirePersistedDelivery(entry.channelId, entry.delivery), { type: 'file' });
|
|
7076
7087
|
if (blocked)
|
|
7077
7088
|
return blocked;
|
|
7078
7089
|
}
|
|
@@ -7479,11 +7490,17 @@ export class AUNChannel {
|
|
|
7479
7490
|
}
|
|
7480
7491
|
await this.sendStructuredOrThrow(channelId, payloadObj, context);
|
|
7481
7492
|
}
|
|
7482
|
-
|
|
7493
|
+
/**
|
|
7494
|
+
* `clientCloseBudgetMs` 只给退出路径用:SDK 的 `close()` 要等 WebSocket 关闭握手
|
|
7495
|
+
* (`transport.js` 里 `ws.on('close')` 后面挂了 3s 兜底),正常也要 2.4s 才返回。
|
|
7496
|
+
* daemon 马上 `exit(0)`,握手等不完的 socket 会随进程消失,为此等满没有意义——
|
|
7497
|
+
* 传入预算时到点就往下走,不再等 SDK。
|
|
7498
|
+
*/
|
|
7499
|
+
async disconnect(clientCloseBudgetMs) {
|
|
7483
7500
|
this.stopOwnerDirectoryRefresh();
|
|
7484
7501
|
this.configuredOwnerBindEpoch++;
|
|
7485
7502
|
if (this.client) {
|
|
7486
|
-
|
|
7503
|
+
unregisterSameOwnerClient(this.config.aid, this.client);
|
|
7487
7504
|
ownerResolver.detachClient(this.config.aid, this.client);
|
|
7488
7505
|
}
|
|
7489
7506
|
this.managedMenuClient.close();
|
|
@@ -7494,8 +7511,25 @@ export class AUNChannel {
|
|
|
7494
7511
|
}
|
|
7495
7512
|
if (this.client) {
|
|
7496
7513
|
this.trace('OUT', 'client.close', { reason: 'disconnect' });
|
|
7514
|
+
// 未等到 close 的 promise 可能稍后 reject(握手被进程退出截断),全程吞掉以免 unhandledRejection。
|
|
7515
|
+
const closing = this.client.close().catch(() => { });
|
|
7497
7516
|
try {
|
|
7498
|
-
|
|
7517
|
+
if (clientCloseBudgetMs === undefined) {
|
|
7518
|
+
await closing;
|
|
7519
|
+
}
|
|
7520
|
+
else {
|
|
7521
|
+
let timer;
|
|
7522
|
+
try {
|
|
7523
|
+
await Promise.race([
|
|
7524
|
+
closing,
|
|
7525
|
+
new Promise(resolve => { timer = setTimeout(resolve, clientCloseBudgetMs); }),
|
|
7526
|
+
]);
|
|
7527
|
+
}
|
|
7528
|
+
finally {
|
|
7529
|
+
if (timer)
|
|
7530
|
+
clearTimeout(timer);
|
|
7531
|
+
}
|
|
7532
|
+
}
|
|
7499
7533
|
this.trace('OUT', 'client.close.ok', { reason: 'disconnect' });
|
|
7500
7534
|
}
|
|
7501
7535
|
catch (e) {
|
|
@@ -8217,7 +8251,7 @@ export class AUNChannelPlugin {
|
|
|
8217
8251
|
policy,
|
|
8218
8252
|
options: { flushDelay: inst.flushDelay ?? DEFAULT_FLUSH_DELAY_SECONDS, fileMarkerPattern: createSendFileMarkerPattern() },
|
|
8219
8253
|
connect: () => channel.connect(),
|
|
8220
|
-
disconnect: () => channel.disconnect(),
|
|
8254
|
+
disconnect: (clientCloseBudgetMs) => channel.disconnect(clientCloseBudgetMs),
|
|
8221
8255
|
onProjectPathRequest: () => Promise.resolve(ctx.defaultProjectPath),
|
|
8222
8256
|
registerBridge(bridge, channelType) {
|
|
8223
8257
|
bridge.register(adapter.channelName, (handler) => channel.onMessage(async (opts) => {
|
package/dist/channels/daemon.js
CHANGED
|
@@ -3,7 +3,7 @@ import { ExecutionTimeoutError } from '../utils/error-utils.js';
|
|
|
3
3
|
import { logger } from '../utils/logger.js';
|
|
4
4
|
import { normalizeExecutionMode } from '../trigger/validation.js';
|
|
5
5
|
import { resolvePeerRoleDetail } from '../config/peer-role-resolver.js';
|
|
6
|
-
import {
|
|
6
|
+
import { prepareSameOwnerProof } from '../core/relation/same-owner-proof.js';
|
|
7
7
|
import { assertSystemSessionLaunchable } from '../core/system-session/registry.js';
|
|
8
8
|
import { sessionTopicThreadId } from '../core/thread/topic-id.js';
|
|
9
9
|
const DEFAULT_WATCHDOG_MS = 11 * 60 * 1000;
|
|
@@ -148,7 +148,7 @@ export class DaemonChannel {
|
|
|
148
148
|
if (ctx.signal?.aborted)
|
|
149
149
|
onAbort();
|
|
150
150
|
if (message.triggerMeta?.originChannelType === 'aun' && message.triggerMeta.originChatType !== 'group') {
|
|
151
|
-
await
|
|
151
|
+
await prepareSameOwnerProof(ctx.trigger.agentAid, message.triggerMeta.originPeerId);
|
|
152
152
|
}
|
|
153
153
|
if (!slot?.terminalClaim) {
|
|
154
154
|
void this.messageQueue.enqueue(ctx.session.id, message, ctx.projectPath, {
|
|
@@ -292,7 +292,7 @@ export class DaemonChannel {
|
|
|
292
292
|
// 反馈目标与触发方式(consolidation.ts 在 normalize 后补挂的字段):
|
|
293
293
|
// 收尾时据此投递反馈,并判断是否该反馈(定时触发不反馈)。
|
|
294
294
|
const { feedbackOrigin, consolidationTriggeredBy } = trigger.execution;
|
|
295
|
-
|
|
295
|
+
const metadata = {
|
|
296
296
|
channelKey: this.channelKey,
|
|
297
297
|
peerId: `trigger:${trigger.id}`,
|
|
298
298
|
peerName: trigger.name,
|
|
@@ -303,7 +303,15 @@ export class DaemonChannel {
|
|
|
303
303
|
...(consolidationMemoryDir ? { consolidationMemoryDir } : {}),
|
|
304
304
|
...(feedbackOrigin ? { feedbackOrigin } : {}),
|
|
305
305
|
...(consolidationTriggeredBy ? { consolidationTriggeredBy } : {}),
|
|
306
|
-
}
|
|
306
|
+
};
|
|
307
|
+
const session = await this.sessionManager.getOrCreateSession(this.channelName, channelId, projectPath, threadId, metadata, trigger.name, undefined, 'private', baseagent, trigger.agentAid, this.channelName, 'system');
|
|
308
|
+
if (session.baseagent === baseagent)
|
|
309
|
+
return session;
|
|
310
|
+
const inheritedSession = await this.sessionManager.getOrCreateSession(this.channelName, channelId, projectPath, `${threadId}:baseagent:${baseagent}`, metadata, trigger.name, undefined, 'private', baseagent, trigger.agentAid, this.channelName, 'system');
|
|
311
|
+
if (inheritedSession.baseagent !== baseagent) {
|
|
312
|
+
throw new Error(`Trigger session baseagent mismatch: expected ${baseagent}, got ${inheritedSession.baseagent}`);
|
|
313
|
+
}
|
|
314
|
+
return inheritedSession;
|
|
307
315
|
}
|
|
308
316
|
executionDeadlineAt(startedAt = Date.now()) {
|
|
309
317
|
return this.totalExecutionMs === undefined
|
|
@@ -82,6 +82,7 @@ function printAgentNewHelp() {
|
|
|
82
82
|
--project <path> 默认: 当前目录
|
|
83
83
|
--baseagent <claude|codex|gemini|ecagent>
|
|
84
84
|
默认: defaults 配置,否则检测本机可用基座
|
|
85
|
+
--provider <id> 指定该 Base Agent 使用的 Provider
|
|
85
86
|
--model <id> 初始化可选;须在主机当前基座的可见模型目录中
|
|
86
87
|
--effort <level> 初始化可选;需同时指定 model,auto 使用默认强度
|
|
87
88
|
--owner <aid> 必填;初始协议 Owner 绑定意图
|
|
@@ -381,6 +382,7 @@ Options:
|
|
|
381
382
|
aid: name,
|
|
382
383
|
project: getArg('--project'),
|
|
383
384
|
baseagent: getArg('--baseagent'),
|
|
385
|
+
provider: getArg('--provider'),
|
|
384
386
|
...ownerOptions,
|
|
385
387
|
...avatarOptions,
|
|
386
388
|
name: getArg('--name'),
|
|
@@ -411,6 +413,8 @@ Options:
|
|
|
411
413
|
console.log(` AID: ${plan.aid}`);
|
|
412
414
|
console.log(` Project: ${plan.project}`);
|
|
413
415
|
console.log(` Baseagent: ${plan.baseagent} (${plan.baseagentSource})`);
|
|
416
|
+
if (plan.provider)
|
|
417
|
+
console.log(` Provider: ${plan.provider}`);
|
|
414
418
|
console.log(` Owner: ${plan.owner || '未设置'} (${plan.ownerSource})`);
|
|
415
419
|
console.log(` Name: ${plan.name} (${plan.nameSource})`);
|
|
416
420
|
if (plan.description)
|
|
@@ -422,6 +426,7 @@ Options:
|
|
|
422
426
|
const result = await agentCreateNonInteractive({
|
|
423
427
|
aid: plan.aid,
|
|
424
428
|
baseagent: plan.baseagent,
|
|
429
|
+
provider: plan.provider,
|
|
425
430
|
project: plan.project,
|
|
426
431
|
owner: plan.owner,
|
|
427
432
|
name: plan.name,
|
package/dist/cli/agent-create.js
CHANGED
|
@@ -24,7 +24,7 @@ import { readTaskRuntimeContextFromEnv } from './task-context.js';
|
|
|
24
24
|
import { logger } from '../utils/logger.js';
|
|
25
25
|
import { creationOwnershipBinding } from '../core/ownership/owner-resolver.js';
|
|
26
26
|
import { getCatalog, getProviderCatalog, resolveCatalogModel, catalogEfforts, assertCatalogSelectable } from '../core/model/model-catalog.js';
|
|
27
|
-
import { resolveProviderServiceForBaseagent } from '../config/providers.js';
|
|
27
|
+
import { resolveProviderId, resolveProviderServiceForBaseagent } from '../config/providers.js';
|
|
28
28
|
import { claimAgentCreation, claimAgentCreationAsync, readAgentCreationClaim, updateAgentCreationClaim } from '../core/agent-creation-claim.js';
|
|
29
29
|
/** Select the creation lifecycle independently of --non-interactive. */
|
|
30
30
|
export function resolveAgentCreateMode(args) {
|
|
@@ -178,7 +178,7 @@ export function resolveAgentCreatePlan(options, projectCwd = process.cwd()) {
|
|
|
178
178
|
const type = requestedType ? (normalizeAgentType(requestedType) ?? requestedType) : DEFAULT_AGENT_TYPE;
|
|
179
179
|
const configExists = isValidAid(aid) && fs.existsSync(path.join(resolvePaths().agentsDir, aid, 'config.json'));
|
|
180
180
|
return {
|
|
181
|
-
aid, project, baseagent, owner, avatarFile: options.avatarFile, avatarUrl: options.avatarUrl,
|
|
181
|
+
aid, project, baseagent, provider: options.provider?.trim() || undefined, owner, avatarFile: options.avatarFile, avatarUrl: options.avatarUrl,
|
|
182
182
|
name, description, type, tags: options.tags,
|
|
183
183
|
force: options.force === true, configExists, baseagentSource, ownerSource,
|
|
184
184
|
nameSource: options.name?.trim() ? 'argument' : metadata.name ? 'package' : 'directory',
|
|
@@ -228,12 +228,22 @@ export function validateAgentCreatePlan(plan) {
|
|
|
228
228
|
if (!detectAvailableBaseagents().includes(plan.baseagent)) {
|
|
229
229
|
return `${plan.baseagent} is not available in the current environment`;
|
|
230
230
|
}
|
|
231
|
+
if (plan.provider !== undefined) {
|
|
232
|
+
if (!plan.provider.trim())
|
|
233
|
+
return 'Provider must be a non-empty string';
|
|
234
|
+
try {
|
|
235
|
+
resolveProviderServiceForBaseagent(plan.provider.trim(), plan.baseagent);
|
|
236
|
+
}
|
|
237
|
+
catch (error) {
|
|
238
|
+
return error instanceof Error ? error.message : String(error);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
231
241
|
return null;
|
|
232
242
|
}
|
|
233
|
-
function saveInitialBehavior(aid, baseagent) {
|
|
243
|
+
function saveInitialBehavior(aid, baseagent, provider) {
|
|
234
244
|
const behavior = {
|
|
235
245
|
active_baseagent: baseagent,
|
|
236
|
-
baseagents: { [baseagent]: {} },
|
|
246
|
+
baseagents: { [baseagent]: provider ? { provider } : {} },
|
|
237
247
|
chatmode: { private: 'interactive', group: 'proactive', nothuman: 'proactive' },
|
|
238
248
|
};
|
|
239
249
|
const sel = { self: aid };
|
|
@@ -550,6 +560,17 @@ export async function agentCreateNonInteractive(opts, runtime = {}) {
|
|
|
550
560
|
return failValidating('ecagent is optional; pass --baseagent ecagent to select it explicitly');
|
|
551
561
|
baseagent = defaultBaseagent;
|
|
552
562
|
}
|
|
563
|
+
const provider = opts.provider?.trim();
|
|
564
|
+
if (opts.provider !== undefined && !provider)
|
|
565
|
+
return failValidating('Provider must be a non-empty string');
|
|
566
|
+
if (provider) {
|
|
567
|
+
try {
|
|
568
|
+
resolveProviderServiceForBaseagent(provider, baseagent);
|
|
569
|
+
}
|
|
570
|
+
catch (error) {
|
|
571
|
+
return failValidating(error instanceof Error ? error.message : String(error));
|
|
572
|
+
}
|
|
573
|
+
}
|
|
553
574
|
if (!path.isAbsolute(opts.project))
|
|
554
575
|
return failValidating(`--project must be absolute: ${opts.project}`);
|
|
555
576
|
if (!fs.existsSync(opts.project)) {
|
|
@@ -609,7 +630,7 @@ export async function agentCreateNonInteractive(opts, runtime = {}) {
|
|
|
609
630
|
opts.onPhase?.('config_saved', 'begin');
|
|
610
631
|
saveAgent({ $schema_version: CONFIG_SCHEMA_VERSION, aid: opts.aid, enabled: true, lifecycle: preservedLifecycle, channels: [], projects: { defaultPath: opts.project } });
|
|
611
632
|
ensureInitialRoleRegistry(opts.aid);
|
|
612
|
-
saveInitialBehavior(opts.aid, baseagent);
|
|
633
|
+
saveInitialBehavior(opts.aid, baseagent, provider);
|
|
613
634
|
ensureAgentDirSkeleton(opts.aid);
|
|
614
635
|
opts.onPhase?.('config_saved', 'done');
|
|
615
636
|
opts.onPhase?.('uploading_agentmd', 'begin');
|
|
@@ -1573,7 +1594,9 @@ export class AgentInitializationService {
|
|
|
1573
1594
|
}
|
|
1574
1595
|
// Omitted fields use the existing defaults/migration selection, just as
|
|
1575
1596
|
// they do on initial creation. Only explicit plan overrides are frozen.
|
|
1576
|
-
if (config && r.plan.provider !== undefined
|
|
1597
|
+
if (config && r.plan.provider !== undefined
|
|
1598
|
+
&& (typeof baseagentConfig?.provider !== 'string'
|
|
1599
|
+
|| resolveProviderId(baseagentConfig.provider) !== resolveProviderId(r.plan.provider)))
|
|
1577
1600
|
failure('INITIALIZE_TARGET_CHANGED');
|
|
1578
1601
|
if (config && r.plan.chatmode !== undefined
|
|
1579
1602
|
&& ['private', 'group', 'nothuman'].some(scope => config.chatmode?.[scope] !== r.plan.chatmode?.[scope])) {
|
|
@@ -1986,7 +2009,7 @@ export function parseInitializationArgs(args) {
|
|
|
1986
2009
|
throw new Error('--bootstrap cannot initialize an agent');
|
|
1987
2010
|
const booleans = new Set(resume ? ['--resume'] : ['--initialize', '--non-interactive', '--dry-run']);
|
|
1988
2011
|
const strings = new Set(resume ? ['--wait', '--format', '--client-request-id'] : [
|
|
1989
|
-
'--project', '--baseagent', '--model', '--effort', '--owner', '--name', '--description', '--tags', '--type', '--avatar-file', '--avatar-url',
|
|
2012
|
+
'--project', '--baseagent', '--provider', '--model', '--effort', '--owner', '--name', '--description', '--tags', '--type', '--avatar-file', '--avatar-url',
|
|
1990
2013
|
'--persona-file', '--persona-text', '--wait', '--format',
|
|
1991
2014
|
]);
|
|
1992
2015
|
const seen = new Set();
|
|
@@ -2035,7 +2058,7 @@ export function resolveInitializationPlan(args, context) {
|
|
|
2035
2058
|
? readInitializationPersona(v['--persona-file'], !!context, context)
|
|
2036
2059
|
: v['--persona-text'];
|
|
2037
2060
|
const p = resolveAgentCreatePlan({
|
|
2038
|
-
aid: parsed.aid, project: v['--project'], baseagent: v['--baseagent'], ...parseAgentOwnerArgs(args),
|
|
2061
|
+
aid: parsed.aid, project: v['--project'], baseagent: v['--baseagent'], provider: v['--provider'], ...parseAgentOwnerArgs(args),
|
|
2039
2062
|
avatarFile: v['--avatar-file'], avatarUrl: v['--avatar-url'],
|
|
2040
2063
|
name: v['--name'], description: v['--description'], tags: parseAgentTags(v['--tags']), type: v['--type'],
|
|
2041
2064
|
}, context?.projectCwd);
|
|
@@ -2043,6 +2066,7 @@ export function resolveInitializationPlan(args, context) {
|
|
|
2043
2066
|
const effort = v['--effort']?.trim();
|
|
2044
2067
|
return {
|
|
2045
2068
|
aid: p.aid, project: p.project, baseagent: p.baseagent ?? '',
|
|
2069
|
+
...(v['--provider']?.trim() ? { provider: v['--provider'].trim() } : {}),
|
|
2046
2070
|
...(model ? { model } : {}),
|
|
2047
2071
|
...(effort && effort !== 'auto' ? { effort } : {}),
|
|
2048
2072
|
ownerAid: p.owner ?? '',
|
package/dist/cli/agent.js
CHANGED
|
@@ -60,13 +60,13 @@ function readAgentMdIdentity(aid) {
|
|
|
60
60
|
if (!fs.existsSync(file))
|
|
61
61
|
return { name: null, description: null };
|
|
62
62
|
const content = fs.readFileSync(file, 'utf8');
|
|
63
|
-
const frontmatter = content.match(/^---\n([\s\S]*?)\n---/);
|
|
63
|
+
const frontmatter = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
64
64
|
if (!frontmatter)
|
|
65
65
|
return { name: null, description: null };
|
|
66
66
|
const body = frontmatter[1];
|
|
67
67
|
return {
|
|
68
|
-
name: body.match(/^name
|
|
69
|
-
description: body.match(/^description
|
|
68
|
+
name: body.match(/^name:[ \t]*["']?(.+?)["']?[ \t]*$/m)?.[1]?.trim() || null,
|
|
69
|
+
description: body.match(/^description:[ \t]*["']?(.+?)["']?[ \t]*$/m)?.[1]?.trim() || null,
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
catch {
|
|
@@ -107,6 +107,12 @@ export async function agentList(registry) {
|
|
|
107
107
|
const result = await ipcQuery(p.socket, { type: 'evolagent.list' });
|
|
108
108
|
if (result && result.ok && result.agents) {
|
|
109
109
|
const agents = result.agents.map((info) => toAgentListItem(info));
|
|
110
|
+
// 显示名以本地 agent.md 为准:daemon 侧是进程内缓存,改名后未必已刷新。
|
|
111
|
+
for (const agent of agents) {
|
|
112
|
+
const identity = readAgentMdIdentity(agent.aid);
|
|
113
|
+
if (identity.name)
|
|
114
|
+
agent.name = identity.name;
|
|
115
|
+
}
|
|
110
116
|
return { ok: true, agents };
|
|
111
117
|
}
|
|
112
118
|
}
|
|
@@ -11,6 +11,7 @@ export async function cmdAidBind(args) {
|
|
|
11
11
|
`${MAIN_CLI_BIN} aid bind status [--refresh] [--subject <subjectAid>] [--format json]`,
|
|
12
12
|
`${MAIN_CLI_BIN} aid bind accept <operationId> [--subject <subjectAid>] [--format json]`,
|
|
13
13
|
`${MAIN_CLI_BIN} aid bind reject <operationId> [--reason <text>] [--subject <subjectAid>] [--format json]`,
|
|
14
|
+
`${MAIN_CLI_BIN} aid bind reject --reset <ownerAid> [--subject <subjectAid>] [--format json]`,
|
|
14
15
|
'宿主 CLI 可显式加 --local-control 选择本地控制,并持有本地控制凭据;TTY 不授予权限。',
|
|
15
16
|
'同一 OS 用户可读取控制凭据,fullaccess 与宿主共用该信任边界。',
|
|
16
17
|
].join('\n'));
|
|
@@ -60,6 +61,8 @@ export async function cmdAidBind(args) {
|
|
|
60
61
|
console.log(`最近已确认关系(历史快照): ${state.relation.consensusStatus} (owner=${state.relation.ownerAid ?? '-'}, version=${state.relation.relationVersion})`);
|
|
61
62
|
}
|
|
62
63
|
console.log(`运行态同步: ${state.synchronization.status}`);
|
|
64
|
+
if (state.rejectionReset)
|
|
65
|
+
console.log(`自动邀约拒绝记录: ${state.rejectionReset.ownerAid} (${state.rejectionReset.cleared ? '已清除' : '不存在'});未提交绑定邀约`);
|
|
63
66
|
if (state.task)
|
|
64
67
|
console.log(`SDK 动作记录(不代表绑定结论): ${state.task.operation_id} (${state.task.status}/${state.task.step})`);
|
|
65
68
|
if (state.decisionTask)
|
package/dist/cli/aun-commands.js
CHANGED
|
@@ -6,6 +6,7 @@ import { normalizeGroupAid } from '../aun/group/index.js';
|
|
|
6
6
|
import { getArgValue, isHelpFlag, wantsHelp } from './help.js';
|
|
7
7
|
import { daemonUnavailableMessage, queryDaemon } from './help.js';
|
|
8
8
|
import { isValidAid as validSendAid } from '../aun/aid/validation.js';
|
|
9
|
+
import { MANAGED_SEND_BOOLEAN_FLAGS, MANAGED_SEND_VALUE_FLAGS } from '../core/message/send-options.js';
|
|
9
10
|
import { AGENT_DELEGATION_TOKEN_ENV, CODEX_SESSION_TOKEN_ENV, readDelegationCredential, } from '../core/auth/agent-delegation.js';
|
|
10
11
|
import { MAIN_CLI_BIN, SELF_AID_ENV, SESSION_ID_ENV } from '../product.js';
|
|
11
12
|
import { isTrustedFullAccessRuntimeContext, readBestTaskRuntimeContext, readVerifiedTaskRuntimeContext, RUNTIME_LOCK_DIR_ENV, SESSION_RUNTIME_DIR_ENV, TASK_RUNTIME_CONTEXT_ENV, } from './task-context.js';
|
|
@@ -508,6 +509,7 @@ Commands:
|
|
|
508
509
|
bind status [--refresh] [--subject <subjectAid>] 核验协议 Owner、任务和同步状态(--refresh 强制重新查询)
|
|
509
510
|
bind accept <operationId> [--subject <subjectAid>] 接受绑定邀约
|
|
510
511
|
bind reject <operationId> [--reason <text>] [--subject <subjectAid>] 拒绝绑定邀约
|
|
512
|
+
bind reject --reset <ownerAid> [--subject <subjectAid>] 清除自动邀约拒绝记录(不发送邀约)
|
|
511
513
|
|
|
512
514
|
Options:
|
|
513
515
|
--format json 输出 JSON 格式
|
|
@@ -1501,8 +1503,8 @@ Options:
|
|
|
1501
1503
|
*
|
|
1502
1504
|
* 使用 `interval` 而非 `delay`:周期触发,由显式
|
|
1503
1505
|
* `ec trigger delete`(结束,不留残留)/ `ec trigger update --every <新时长>`(调整周期)改变状态。
|
|
1504
|
-
* `ec trigger
|
|
1505
|
-
* 不该走
|
|
1506
|
+
* `ec trigger disable` 只停用后续调度,定义仍留在磁盘上,复查这种用完即弃的 Trigger
|
|
1507
|
+
* 不该走 disable,否则会积压大量永不触发的死定义。
|
|
1506
1508
|
* 一次性 Trigger 会静默消失,无法承担「一直跟进直到显式结束」的语义。
|
|
1507
1509
|
*/
|
|
1508
1510
|
export function buildThreadCheckTrigger(input) {
|
|
@@ -3633,8 +3635,8 @@ export function resolveManagedSendArgv(argv, routing) {
|
|
|
3633
3635
|
const booleans = new Set();
|
|
3634
3636
|
const text = [];
|
|
3635
3637
|
const mentions = [];
|
|
3636
|
-
const valueFlags = new Set(
|
|
3637
|
-
const booleanFlags = new Set(
|
|
3638
|
+
const valueFlags = new Set(MANAGED_SEND_VALUE_FLAGS);
|
|
3639
|
+
const booleanFlags = new Set(MANAGED_SEND_BOOLEAN_FLAGS);
|
|
3638
3640
|
for (let index = bodyStart; index < argv.length; index++) {
|
|
3639
3641
|
const flag = argv[index];
|
|
3640
3642
|
if (flag === '--') {
|
|
@@ -3704,7 +3706,12 @@ export function resolveManagedSendArgv(argv, routing) {
|
|
|
3704
3706
|
const to = scope === 'group'
|
|
3705
3707
|
? normalizeGroupAid(argv[3], aid.slice(aid.indexOf('.') + 1))
|
|
3706
3708
|
: hasTo ? argv[3] : inferredTarget;
|
|
3707
|
-
if (!to
|
|
3709
|
+
if (!to)
|
|
3710
|
+
throw new Error('Invalid send target');
|
|
3711
|
+
// 目标形态:普通发送必须是合法 AID。但 `--thread` 指向的目标会话可能属于
|
|
3712
|
+
// 其它渠道(如飞书),那条会话的 `peer` 是原生 ID(`ou_…`),不是 AID。
|
|
3713
|
+
// 此时由话题索引保证目标正确,不再按 AID 校验。
|
|
3714
|
+
if (!thread && !validSendAid(to))
|
|
3708
3715
|
throw new Error('Invalid send target');
|
|
3709
3716
|
const checkEvery = values.get('--check-every');
|
|
3710
3717
|
const triggerPromptExtra = values.get('--trigger-prompt');
|