evolcore 0.0.41-test.0 → 0.0.41-test.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -0
- package/dist/agents/baseagent-availability.js +1 -1
- package/dist/agents/baseagent.js +88 -49
- package/dist/agents/claude-runner.js +177 -92
- package/dist/agents/codex-runner.js +146 -71
- package/dist/agents/ecagent-runner.js +1 -1
- package/dist/agents/gemini-runner.js +1 -1
- package/dist/aun/aid/agentmd.js +98 -11
- package/dist/aun/aid/client.js +1 -1
- package/dist/aun/aid/control-aid.js +26 -2
- package/dist/aun/aid/identity.js +91 -0
- package/dist/aun/aid/index.js +1 -1
- package/dist/aun/aid/managed-operation.js +1 -1
- package/dist/aun/aid/ownership-operation.js +23 -22
- package/dist/aun/group/fs-download.js +39 -0
- package/dist/aun/group/identity.js +36 -21
- package/dist/aun/group/operations.js +5 -0
- package/dist/aun/menu/client.js +27 -0
- package/dist/aun/msg/managed-operation.js +68 -7
- package/dist/aun/msg/p2p.js +8 -8
- package/dist/aun/service-proxy.js +53 -12
- package/dist/channels/aun.js +633 -32
- package/dist/channels/daemon.js +15 -1
- package/dist/cli/agent-command.js +5 -2
- package/dist/cli/agent-create.js +991 -233
- package/dist/cli/agent.js +49 -10
- package/dist/cli/aid-bind-command.js +48 -19
- package/dist/cli/aun-commands.js +48 -36
- package/dist/cli/daemon-commands.js +679 -697
- package/dist/cli/fs-command.js +64 -2
- package/dist/cli/index.js +72 -5
- package/dist/cli/init-channel.js +1 -1
- package/dist/cli/init.js +75 -1
- package/dist/cli/managed-command-guard.js +17 -1
- package/dist/cli/model.js +40 -40
- package/dist/cli/provider-command.js +57 -0
- package/dist/cli/proxy-command.js +92 -0
- package/dist/cli/restart-monitor.js +4 -2
- package/dist/cli/role.js +85 -0
- package/dist/cli/stats.js +10 -3
- package/dist/cli/task-context.js +19 -0
- package/dist/config/access-policy.js +7 -2
- package/dist/config/boot-log.js +39 -1
- package/dist/config/config-field-policy.js +17 -39
- package/dist/config/config-manager.js +183 -44
- package/dist/config/config-operation-service.js +5 -19
- package/dist/config/contact-book-store.js +47 -21
- package/dist/config/contact-book.js +18 -12
- package/dist/config/contact-operation-service.js +3 -4
- package/dist/config/contact-request-service.js +11 -0
- package/dist/config/daemon-services.js +11 -0
- package/dist/config/gateway-config.js +88 -594
- package/dist/config/owner-config.js +2 -2
- package/dist/config/peer-role-resolver.js +15 -12
- package/dist/config/provider-ipc-service.js +132 -0
- package/dist/config/provider-menu-request.js +58 -0
- package/dist/config/providers-config.js +12 -7
- package/dist/config/providers-import.js +3 -21
- package/dist/config/providers-management.js +78 -5
- package/dist/config/resolved-config-op.js +11 -1
- package/dist/config/role-command-service.js +166 -0
- package/dist/config/role-request-service.js +193 -0
- package/dist/config/schema-migration.js +1000 -25
- package/dist/config-store.js +89 -4
- package/dist/contracts/ecweb-instance.js +41 -0
- package/dist/contracts/ecweb-service-protocol.js +4 -1
- package/dist/core/agent-application-service.js +60 -11
- package/dist/core/agent-create-status.js +203 -0
- package/dist/core/agent-creation-claim.js +177 -0
- package/dist/core/agent-ipc-registration.js +39 -18
- package/dist/core/agent-runtime.js +194 -24
- package/dist/core/auth/agent-delegation.js +6 -3
- package/dist/core/auth/auth-gateway.js +67 -2
- package/dist/core/auth/authorization-audit.js +58 -11
- package/dist/core/auth/delegation-authorization.js +5 -2
- package/dist/core/auth/operation-authorizer.js +43 -6
- package/dist/core/auth/operation-catalog.js +45 -7
- package/dist/core/channel-loader.js +2 -0
- package/dist/core/command/agent-control.js +260 -21
- package/dist/core/command/agent-storage-menu.js +5 -3
- package/dist/core/command/cli-intent-parser.js +8 -3
- package/dist/core/command/command-handler.js +112 -154
- package/dist/core/command/connect-menu.js +11 -3
- package/dist/core/command/data-root-resolver.js +5 -4
- package/dist/core/command/memory-slash.js +16 -8
- package/dist/core/command/menu-catalog.js +10 -6
- package/dist/core/command/menu-handler.js +106 -73
- package/dist/core/command/menu-protocol.js +15 -1
- package/dist/core/command/provider-menu.js +46 -0
- package/dist/core/command/role-menu.js +147 -30
- package/dist/core/command/slash-handler.js +125 -255
- package/dist/core/daemon-control.js +26 -27
- package/dist/core/event-catalog.js +10 -0
- package/dist/core/evolagent-registry.js +7 -5
- package/dist/core/evolagent.js +10 -8
- package/dist/core/file-integrity/store.js +11 -0
- package/dist/core/handoff/ipc-registration.js +3 -0
- package/dist/core/inference/text-inference.js +31 -40
- package/dist/core/initialization/service.js +491 -0
- package/dist/core/ipc-registration.js +40 -24
- package/dist/core/memory/consolidation-context.js +51 -5
- package/dist/core/memory/consolidation-ops-records.js +96 -1
- package/dist/core/memory/consolidation-trigger.js +208 -191
- package/dist/core/memory/consolidation.js +333 -35
- package/dist/core/memory/index-manager.js +27 -5
- package/dist/core/memory/memory-admin.js +45 -5
- package/dist/core/memory/memory-writer.js +163 -18
- package/dist/core/memory/relation-idle-monitor.js +119 -58
- package/dist/core/memory/relation-sweep.js +55 -45
- package/dist/core/message/aun-ipc-sender.js +81 -69
- package/dist/core/message/im-renderer.js +25 -4
- package/dist/core/message/message-admission.js +89 -4
- package/dist/core/message/message-bridge.js +66 -21
- package/dist/core/message/response-engine.js +108 -35
- package/dist/core/model/catalog-service.js +5 -3
- package/dist/core/model/config-scope.js +29 -71
- package/dist/core/model/field-scope.js +1 -1
- package/dist/core/model/model-catalog.js +30 -41
- package/dist/core/model/model-diagnostics.js +4 -3
- package/dist/core/model/model-fallback.js +10 -7
- package/dist/core/model/model-permission.js +3 -2
- package/dist/core/ownership/owner-resolver.js +772 -158
- package/dist/core/permission/approval-gateway.js +103 -403
- package/dist/core/permission/ec-command-parser.js +62 -6
- package/dist/core/permission/index.js +1 -0
- package/dist/core/permission/permission-result.js +78 -0
- package/dist/core/permission/sandbox-runtime.js +18 -1
- package/dist/core/permission/tool-policy.js +21 -46
- package/dist/core/relation/peer-identity.js +64 -1
- package/dist/core/role/runtime-policy.js +72 -13
- package/dist/core/session/session-capsule.js +1 -1
- package/dist/core/session/session-idle-monitor.js +1 -1
- package/dist/core/session/session-manager.js +20 -0
- package/dist/core/session/session-renew.js +3 -3
- package/dist/core/skill/index-generator.js +15 -5
- package/dist/core/system-session/memory.js +43 -8
- package/dist/core/thread/thread-service.js +19 -6
- package/dist/directory/owner-directory-admission.js +95 -0
- package/dist/directory/owner-directory-authorization.js +309 -0
- package/dist/directory/owner-directory-cache.js +635 -0
- package/dist/eck/kit-renderer.js +2 -2
- package/dist/ecweb/basic-settings-service.js +33 -40
- package/dist/ecweb/init-menu.js +32 -0
- package/dist/ecweb/message-context-service.js +110 -0
- package/dist/index.js +93 -19
- package/dist/ipc.js +247 -29
- package/dist/paths.js +7 -0
- package/dist/proxy/command.js +122 -0
- package/dist/proxy/ipc-service.js +68 -0
- package/dist/proxy/manager.js +484 -0
- package/dist/proxy/service-supervisor.js +603 -0
- package/dist/response-system/engines/v1/proactive-flow.js +16 -6
- package/dist/trigger/authorization.js +27 -17
- package/dist/trigger/feedback.js +2 -3
- package/dist/trigger/ipc-service.js +105 -78
- package/dist/trigger/local-files.js +2 -1
- package/dist/trigger/manager.js +5 -3
- package/dist/trigger/scheduler.js +88 -6
- package/dist/utils/atomic-write.js +28 -0
- package/dist/utils/cross-platform.js +14 -0
- package/dist/utils/ecweb-supervisor.js +258 -83
- package/dist/utils/error-utils.js +26 -2
- package/dist/utils/logger.js +92 -6
- package/dist/utils/package-version-info.js +4 -2
- package/dist/utils/welcome.js +1 -1
- package/kits/docs/INDEX.md +1 -0
- package/kits/docs/aun/SDK.md +4 -1
- package/kits/docs/channels/aun.md +9 -0
- package/kits/docs/evolcore/INDEX.md +1 -0
- package/kits/docs/evolcore/agent.md +8 -1
- package/kits/docs/evolcore/aid.md +67 -17
- package/kits/docs/evolcore/config.md +28 -7
- package/kits/docs/evolcore/contact.md +3 -0
- package/kits/docs/evolcore/fs.md +11 -0
- package/kits/docs/evolcore/group.md +1 -1
- package/kits/docs/evolcore/memory-architecture.md +2 -2
- package/kits/docs/evolcore/memory-consolidation.md +32 -8
- package/kits/docs/evolcore/memory.md +1 -1
- package/kits/docs/evolcore/menu-protocol.md +4 -0
- package/kits/docs/evolcore/model.md +23 -20
- package/kits/docs/evolcore/msg.md +4 -7
- package/kits/docs/evolcore/provider.md +50 -0
- package/kits/docs/identity/AID_PROFILE_SPEC.md +52 -17
- package/kits/migrations/migrate-contact-book-v2.mjs +30 -11
- package/kits/rules/01-overview.md +3 -0
- package/kits/rules/04-relation.md +1 -1
- package/kits/schemas/_meta.json +37 -4
- package/kits/schemas/agent-config.schema.13.json +8 -3
- package/kits/schemas/agent-config.schema.16.json +891 -0
- package/kits/schemas/daemon.schema.9.json +366 -0
- package/kits/schemas/defaults.schema.5.json +406 -127
- package/kits/schemas/relation-config.schema.11.json +277 -0
- package/kits/schemas/role-config.schema.1.json +7 -7
- package/kits/skills/.switches.json +4 -0
- package/kits/skills/ec-agent-create/SKILL.md +3 -0
- package/kits/skills/ec-identity/SKILL.md +2 -2
- package/kits/skills/ec-service-proxy/SKILL.md +118 -0
- package/kits/skills/ec-skill/scripts/skill.mjs +6 -0
- package/kits/skills/personal-assistant/SKILL.md +176 -0
- package/kits/skills/personal-assistant/references/01-workspace-spec.md +333 -0
- package/kits/skills/personal-assistant/references/02-bootstrap.md +205 -0
- package/kits/skills/personal-assistant/references/03-data-flow-and-gaps.md +177 -0
- package/kits/skills/personal-assistant/references/04-frontend-contract.md +439 -0
- package/kits/skills/personal-assistant/references/05-directory-reference.md +292 -0
- package/kits/skills/personal-assistant/references/06-render-config.md +350 -0
- package/kits/skills/personal-assistant/schema/workspace.schema.json +85 -0
- package/kits/skills/personal-assistant/schema/workspace.v1.json +66 -0
- package/kits/skills/personal-assistant/scripts/archive.mjs +154 -0
- package/kits/skills/personal-assistant/scripts/check.mjs +114 -0
- package/kits/skills/personal-assistant/scripts/index-rebuild.mjs +252 -0
- package/kits/skills/personal-assistant/scripts/ingest.mjs +344 -0
- package/kits/skills/personal-assistant/scripts/init.mjs +270 -0
- package/kits/skills/personal-assistant/scripts/lib/apply.mjs +92 -0
- package/kits/skills/personal-assistant/scripts/lib/schema.mjs +96 -0
- package/kits/skills/personal-assistant/scripts/lib/time.mjs +28 -0
- package/kits/skills/personal-assistant/scripts/migrate.mjs +172 -0
- package/kits/skills/personal-assistant/scripts/search.mjs +172 -0
- package/kits/skills/personal-assistant/scripts/verify.mjs +196 -0
- package/kits/skills/personal-assistant/templates/INDEX.md.tpl +24 -0
- package/kits/skills/personal-assistant/templates/README.md.tpl +108 -0
- package/kits/skills/personal-assistant/triggers/ingest-daily.json +23 -0
- package/kits/skills/personal-assistant/triggers/memory-consolidate.json +23 -0
- package/kits/skills/personal-assistant/triggers/report-daily.json +23 -0
- package/kits/skills/personal-assistant/triggers/report-weekly.json +23 -0
- package/kits/skills/thread-ops/SKILL.md +5 -0
- package/kits/templates/memory-consolidation/forget.md +19 -6
- package/kits/templates/memory-consolidation/notes.md +1 -1
- package/kits/templates/memory-consolidation/profile.md +2 -2
- package/kits/templates/memory-consolidation/promote.md +20 -3
- package/kits/templates/roles/member.json +8 -1
- package/kits/templates/system-fragments/baseagent.md +2 -2
- package/kits/templates/system-fragments/memory.md +4 -4
- package/kits/templates/system-fragments/venue.md +1 -1
- package/package.json +7 -3
- package/dist/core/message/create-status.js +0 -96
package/dist/cli/agent.js
CHANGED
|
@@ -4,7 +4,7 @@ import path from 'path';
|
|
|
4
4
|
import { SESSION_ID_ENV } from '../product.js';
|
|
5
5
|
import { resolvePaths, agentMdPath as getAgentMdPathFromPaths, agentPersonalDir, agentWelcomePath, aunPath as defaultAunPath } from '../paths.js';
|
|
6
6
|
import { loadDefaults, loadAllAgents, loadAgent, saveAgent, ensureAgentDirSkeleton } from '../config-store.js';
|
|
7
|
-
import { initConfigManager } from '../config/config-manager.js';
|
|
7
|
+
import { assertAgentAidAvailable, assertAgentModelConfigured, initConfigManager } from '../config/config-manager.js';
|
|
8
8
|
import { resolveConfigCommand } from '../config/resolved-config-op.js';
|
|
9
9
|
import { executeResolvedConfigCommandAsync } from '../config/config-operation-service.js';
|
|
10
10
|
import { ipcQuery, IpcTransportError } from '../ipc.js';
|
|
@@ -21,6 +21,7 @@ import { resolveAgentLifecycle } from '../config/lifecycle.js';
|
|
|
21
21
|
import { initializationSummary } from './agent-create.js';
|
|
22
22
|
import { parseAgentWelcomeMetadata, readAgentWelcomeTemplate, renderPostBootstrapWelcomeMessage, saveAgentWelcomeTemplate, validateWelcomeTemplate } from '../utils/welcome.js';
|
|
23
23
|
import { RUNTIME_ENVIRONMENT_NAMES } from '../config/runtime-env.js';
|
|
24
|
+
import { removeAgentFiles } from '../core/agent-create-status.js';
|
|
24
25
|
export { agentCreateInteractive, agentCreateNonInteractive, parseAgentOwnerArgs, resolveAgentCreatePlan, validateAgentCreatePlan, validateAgentOwnerOptions, } from './agent-create.js';
|
|
25
26
|
/** Route agent lifecycle commands from a managed task through daemon IPC. */
|
|
26
27
|
export async function runManagedAgentOperation(argv, timeoutMs = 60_000) {
|
|
@@ -364,6 +365,14 @@ export async function agentDisable(aid, options = {}) {
|
|
|
364
365
|
return agentSetEnabled(aid, false, options);
|
|
365
366
|
}
|
|
366
367
|
async function agentSetEnabled(aid, enabled, options = {}) {
|
|
368
|
+
if (enabled) {
|
|
369
|
+
try {
|
|
370
|
+
assertAgentAidAvailable(aid);
|
|
371
|
+
}
|
|
372
|
+
catch (error) {
|
|
373
|
+
return { ok: false, code: 'CONTROL_AID_RESERVED', error: error.message };
|
|
374
|
+
}
|
|
375
|
+
}
|
|
367
376
|
const p = resolvePaths();
|
|
368
377
|
let config;
|
|
369
378
|
try {
|
|
@@ -375,6 +384,14 @@ async function agentSetEnabled(aid, enabled, options = {}) {
|
|
|
375
384
|
if (!config) {
|
|
376
385
|
return { ok: false, error: `Agent "${aid}" not found` };
|
|
377
386
|
}
|
|
387
|
+
if (enabled) {
|
|
388
|
+
try {
|
|
389
|
+
assertAgentModelConfigured(aid);
|
|
390
|
+
}
|
|
391
|
+
catch (error) {
|
|
392
|
+
return { ok: false, code: error.code ?? 'CONFIG_ERROR', error: error.message ?? String(error) };
|
|
393
|
+
}
|
|
394
|
+
}
|
|
378
395
|
const previousEnabled = config.enabled;
|
|
379
396
|
config.enabled = enabled;
|
|
380
397
|
saveAgent(config);
|
|
@@ -516,6 +533,12 @@ function readPersonaSource(file) {
|
|
|
516
533
|
}
|
|
517
534
|
/** Read or replace the current Agent's personal/persona.md. */
|
|
518
535
|
export async function agentPersona(aid, options = {}) {
|
|
536
|
+
try {
|
|
537
|
+
assertAgentAidAvailable(aid);
|
|
538
|
+
}
|
|
539
|
+
catch (error) {
|
|
540
|
+
return { ok: false, code: 'CONTROL_AID_RESERVED', error: error.message };
|
|
541
|
+
}
|
|
519
542
|
if (options.text !== undefined && options.file !== undefined)
|
|
520
543
|
return { ok: false, code: 'INVALID_ARGS', error: '--text 与 --file 不能同时使用' };
|
|
521
544
|
const managedSession = !!process.env.EVOLCORE_SESSION_ID && !options.trustedLocal;
|
|
@@ -562,6 +585,12 @@ export async function agentPersona(aid, options = {}) {
|
|
|
562
585
|
}
|
|
563
586
|
/** Read or replace the current Agent's self-prepared Bootstrap welcome template. */
|
|
564
587
|
export async function agentWelcome(aid, options = {}) {
|
|
588
|
+
try {
|
|
589
|
+
assertAgentAidAvailable(aid);
|
|
590
|
+
}
|
|
591
|
+
catch (error) {
|
|
592
|
+
return { ok: false, code: 'CONTROL_AID_RESERVED', error: error.message };
|
|
593
|
+
}
|
|
565
594
|
if (!isValidAid(aid))
|
|
566
595
|
return { ok: false, code: 'INVALID_ARGS', error: 'Invalid Agent AID' };
|
|
567
596
|
if (options.text !== undefined) {
|
|
@@ -645,6 +674,12 @@ export async function agentWelcome(aid, options = {}) {
|
|
|
645
674
|
* running or reload fails, returns reloaded:false (no error).
|
|
646
675
|
*/
|
|
647
676
|
export async function agentChannelUpsert(opts) {
|
|
677
|
+
try {
|
|
678
|
+
assertAgentAidAvailable(opts.aid);
|
|
679
|
+
}
|
|
680
|
+
catch (error) {
|
|
681
|
+
return { ok: false, code: 'CONTROL_AID_RESERVED', error: error.message };
|
|
682
|
+
}
|
|
648
683
|
const p = resolvePaths();
|
|
649
684
|
const SUPPORTED_TYPES = new Set(['feishu', 'wechat', 'dingtalk', 'qqbot', 'wecom']);
|
|
650
685
|
if (opts.channel.type === 'aun') {
|
|
@@ -710,15 +745,7 @@ export async function agentDelete(aid, purge = false) {
|
|
|
710
745
|
stopped = !!result?.ok;
|
|
711
746
|
}
|
|
712
747
|
catch { }
|
|
713
|
-
|
|
714
|
-
fs.rmSync(agentDir, { recursive: true, force: true });
|
|
715
|
-
}
|
|
716
|
-
else {
|
|
717
|
-
fs.unlinkSync(configPath);
|
|
718
|
-
// 清理构建进度文件(非 purge 删除只移除 config.json,需显式清理 create-status.json)
|
|
719
|
-
const { removeCreateStatus } = await import('../core/message/create-status.js');
|
|
720
|
-
removeCreateStatus(agentDir);
|
|
721
|
-
}
|
|
748
|
+
await removeAgentFiles(aid, purge);
|
|
722
749
|
// Trigger resync so daemon drops the agent
|
|
723
750
|
try {
|
|
724
751
|
await ipcQuery(p.socket, { type: 'evolagent.resync' });
|
|
@@ -728,6 +755,12 @@ export async function agentDelete(aid, purge = false) {
|
|
|
728
755
|
}
|
|
729
756
|
// ==================== agentRename ====================
|
|
730
757
|
export async function agentRename(aid, name) {
|
|
758
|
+
try {
|
|
759
|
+
assertAgentAidAvailable(aid);
|
|
760
|
+
}
|
|
761
|
+
catch (error) {
|
|
762
|
+
return { ok: false, code: 'CONTROL_AID_RESERVED', error: error.message };
|
|
763
|
+
}
|
|
731
764
|
const config = loadAgent(aid);
|
|
732
765
|
if (!config) {
|
|
733
766
|
return { ok: false, error: `Agent "${aid}" not found` };
|
|
@@ -757,6 +790,12 @@ export async function agentRename(aid, name) {
|
|
|
757
790
|
}
|
|
758
791
|
// ==================== agentReady ====================
|
|
759
792
|
export async function agentReady(aid, commandArgs) {
|
|
793
|
+
try {
|
|
794
|
+
assertAgentAidAvailable(aid);
|
|
795
|
+
}
|
|
796
|
+
catch (error) {
|
|
797
|
+
return { ok: false, code: 'CONTROL_AID_RESERVED', error: error.message };
|
|
798
|
+
}
|
|
760
799
|
const managedSessionId = process.env.EVOLCORE_SESSION_ID;
|
|
761
800
|
const taskSelfAid = managedSessionId ? readTaskRuntimeContextFromEnv()?.selfAid : undefined;
|
|
762
801
|
if (taskSelfAid && taskSelfAid.replace(/^@/, '') !== aid.replace(/^@/, '')) {
|
|
@@ -1,29 +1,48 @@
|
|
|
1
|
-
import { ipcQuery } from '../ipc.js';
|
|
1
|
+
import { ipcHostQuery, ipcQuery } from '../ipc.js';
|
|
2
2
|
import { resolvePaths } from '../paths.js';
|
|
3
3
|
import { parseOwnershipCommand, ownershipFailure } from '../aun/aid/ownership-operation.js';
|
|
4
|
-
import { readDelegationCredential } from '../core/auth/agent-delegation.js';
|
|
5
|
-
import { MAIN_CLI_BIN } from '../product.js';
|
|
4
|
+
import { AGENT_DELEGATION_TOKEN_ENV, CODEX_SESSION_TOKEN_ENV, readDelegationCredential } from '../core/auth/agent-delegation.js';
|
|
5
|
+
import { MAIN_CLI_BIN, SESSION_ID_ENV } from '../product.js';
|
|
6
6
|
export async function cmdAidBind(args) {
|
|
7
7
|
if (args.includes('--help') || args.includes('-h')) {
|
|
8
8
|
console.log([
|
|
9
9
|
`用法: ${MAIN_CLI_BIN} aid bind <ownerAid> [--subject <subjectAid>] [--format json]`,
|
|
10
|
-
|
|
10
|
+
`用法: ${MAIN_CLI_BIN} aid transfer <subAid> <newOwnerAid> --subject <currentOwnerAid> [--format json]`,
|
|
11
|
+
`${MAIN_CLI_BIN} aid bind status [--refresh] [--subject <subjectAid>] [--format json]`,
|
|
11
12
|
`${MAIN_CLI_BIN} aid bind accept <operationId> [--subject <subjectAid>] [--format json]`,
|
|
12
13
|
`${MAIN_CLI_BIN} aid bind reject <operationId> [--reason <text>] [--subject <subjectAid>] [--format json]`,
|
|
14
|
+
'宿主 CLI 可显式加 --local-control 选择本地控制,并持有本地控制凭据;TTY 不授予权限。',
|
|
15
|
+
'同一 OS 用户可读取控制凭据,fullaccess 与宿主共用该信任边界。',
|
|
13
16
|
].join('\n'));
|
|
14
17
|
return;
|
|
15
18
|
}
|
|
16
19
|
const formatJson = args.includes('--format') && args[args.indexOf('--format') + 1] === 'json';
|
|
17
20
|
try {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
const requestedLocalControl = args.includes('--local-control');
|
|
22
|
+
if (args.filter(arg => arg === '--local-control').length > 1) {
|
|
23
|
+
throw Object.assign(new Error('Duplicate --local-control option'), { code: 'INVALID_ARGUMENT' });
|
|
24
|
+
}
|
|
25
|
+
const commandArgs = args.filter(arg => arg !== '--local-control');
|
|
26
|
+
const ownershipArgv = commandArgs[0] === 'transfer' ? commandArgs : ['bind', ...commandArgs];
|
|
27
|
+
const command = parseOwnershipCommand(ownershipArgv);
|
|
28
|
+
const sessionId = process.env[SESSION_ID_ENV];
|
|
29
|
+
const delegationToken = readDelegationCredential();
|
|
30
|
+
const managedContext = [SESSION_ID_ENV, AGENT_DELEGATION_TOKEN_ENV, CODEX_SESSION_TOKEN_ENV]
|
|
31
|
+
.some(key => process.env[key] !== undefined);
|
|
32
|
+
if (requestedLocalControl && managedContext) {
|
|
33
|
+
throw Object.assign(new Error('Task delegation cannot select host control authentication'), { code: 'INVALID_DELEGATION' });
|
|
34
|
+
}
|
|
35
|
+
// A clean standalone CLI keeps the historical syntax. Any managed marker,
|
|
36
|
+
// including a delegation token after session tampering, forces delegation.
|
|
37
|
+
const localControl = requestedLocalControl || !managedContext;
|
|
38
|
+
if (!localControl && (!sessionId?.trim() || !delegationToken)) {
|
|
39
|
+
throw Object.assign(new Error('Valid task delegation is required; host CLI must explicitly use --local-control'), { code: 'DELEGATION_REQUIRED' });
|
|
40
|
+
}
|
|
41
|
+
const isDecision = command.action === 'accept' || command.action === 'reject';
|
|
42
|
+
const query = localControl ? ipcHostQuery : ipcQuery;
|
|
43
|
+
const response = await query(resolvePaths().socket, {
|
|
44
|
+
type: 'aid.ownership', argv: ['aid', ...ownershipArgv],
|
|
45
|
+
...(localControl ? { authMode: 'local-control' } : { sessionId, delegationToken }),
|
|
27
46
|
}, isDecision ? 150_000 : 30_000);
|
|
28
47
|
if (!response?.ok)
|
|
29
48
|
throw Object.assign(new Error(response?.error ?? 'daemon 未运行或 IPC 不可用'), { code: response?.code, retryable: response?.retryable });
|
|
@@ -32,17 +51,27 @@ export async function cmdAidBind(args) {
|
|
|
32
51
|
else {
|
|
33
52
|
const state = response.state;
|
|
34
53
|
console.log(`主体 AID: ${state.subjectAid}`);
|
|
35
|
-
console.log(
|
|
36
|
-
console.log(
|
|
37
|
-
if (state.consensus)
|
|
38
|
-
console.log(
|
|
54
|
+
console.log(`当前协议 Owner: ${state.ownerAid ?? '未确认'}`);
|
|
55
|
+
console.log(`当前共识状态: ${state.consensusStatus}`);
|
|
56
|
+
if (state.consensus && state.consensusStatus !== 'unavailable') {
|
|
57
|
+
console.log(`当前观察关系版本: ${state.consensus.relation_version}`);
|
|
58
|
+
}
|
|
59
|
+
if (state.relation && !state.relation.isCurrent) {
|
|
60
|
+
console.log(`最近已确认关系(历史快照): ${state.relation.consensusStatus} (owner=${state.relation.ownerAid ?? '-'}, version=${state.relation.relationVersion})`);
|
|
61
|
+
}
|
|
39
62
|
console.log(`运行态同步: ${state.synchronization.status}`);
|
|
40
63
|
if (state.task)
|
|
41
|
-
console.log(
|
|
64
|
+
console.log(`SDK 动作记录(不代表绑定结论): ${state.task.operation_id} (${state.task.status}/${state.task.step})`);
|
|
42
65
|
if (state.decisionTask)
|
|
43
|
-
console.log(
|
|
66
|
+
console.log(`审批 SDK 动作记录(不代表关系已成立): ${state.decisionTask.operation_id} (${state.decisionTask.status}/${state.decisionTask.step})`);
|
|
44
67
|
if (state.decisionConsensus)
|
|
45
68
|
console.log(`审批目标共识: ${state.decisionConsensus.status} (owner=${state.decisionConsensus.owner_aid ?? '-'}, version=${state.decisionConsensus.relation_version}, lock=${state.decisionConsensus.lock})`);
|
|
69
|
+
if (state.targetConsensus)
|
|
70
|
+
console.log(`转让目标共识: ${state.targetConsensus.status} (sub=${state.targetConsensus.sub_aid}, owner=${state.targetConsensus.owner_aid ?? '-'}, version=${state.targetConsensus.relation_version}, lock=${state.targetConsensus.lock})`);
|
|
71
|
+
for (const transfer of state.transfers ?? []) {
|
|
72
|
+
const consensus = transfer.consensus;
|
|
73
|
+
console.log(`Owner 转让: sub=${transfer.task.sub_aid}, newOwner=${transfer.task.new_owner_aid}, operation=${transfer.task.operation_id} (${transfer.task.status}/${transfer.task.step})${consensus ? `, 共识=${consensus.status}/${consensus.relation_version}/${consensus.lock}` : ''}`);
|
|
74
|
+
}
|
|
46
75
|
for (const request of state.requests ?? []) {
|
|
47
76
|
console.log(`待确认邀约: ${request.operation_id} (sub=${request.sub_aid}, owner=${request.owner_aid}, 本端=${request.local_role})`);
|
|
48
77
|
}
|
package/dist/cli/aun-commands.js
CHANGED
|
@@ -2,7 +2,7 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import crypto from 'crypto';
|
|
4
4
|
import { agentMdPath, resolvePaths, resolveRoot } from '../paths.js';
|
|
5
|
-
import {
|
|
5
|
+
import { normalizeGroupAid, sameGroupAid } 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';
|
|
@@ -472,7 +472,8 @@ Commands:
|
|
|
472
472
|
agentmd set <aid> <field> <value> 修改一个字段并签名上传
|
|
473
473
|
avatar <aid> --file <path> | --url <https-url> 上传头像并更新 agent.md
|
|
474
474
|
bind <ownerAid> [--subject <subjectAid>] 发起 Ownership 2.1 绑定
|
|
475
|
-
|
|
475
|
+
transfer <subAid> <newOwnerAid> --subject <currentOwnerAid> 发起 Ownership 2.1 转让
|
|
476
|
+
bind status [--refresh] [--subject <subjectAid>] 核验协议 Owner、任务和同步状态(--refresh 强制重新查询)
|
|
476
477
|
bind accept <operationId> [--subject <subjectAid>] 接受绑定邀约
|
|
477
478
|
bind reject <operationId> [--reason <text>] [--subject <subjectAid>] 拒绝绑定邀约
|
|
478
479
|
|
|
@@ -495,9 +496,9 @@ Options:
|
|
|
495
496
|
ec aid agentmd set mybot.agentid.pub description "A helpful agent"`);
|
|
496
497
|
return;
|
|
497
498
|
}
|
|
498
|
-
if (sub === 'bind') {
|
|
499
|
+
if (sub === 'bind' || sub === 'transfer') {
|
|
499
500
|
const { cmdAidBind } = await import('./aid-bind-command.js');
|
|
500
|
-
await cmdAidBind(args.slice(1));
|
|
501
|
+
await cmdAidBind(args.slice(sub === 'bind' ? 1 : 0));
|
|
501
502
|
return;
|
|
502
503
|
}
|
|
503
504
|
const isAgentmdHelp = sub === 'agentmd' && (!args[1] || isHelpFlag(args[1]));
|
|
@@ -885,9 +886,9 @@ Options:
|
|
|
885
886
|
if (verb === 'set') {
|
|
886
887
|
const field = args[3];
|
|
887
888
|
const value = args[4];
|
|
888
|
-
const editableFields = new Set(['name', 'type', 'description', 'version', 'tags']);
|
|
889
|
+
const editableFields = new Set(['name', 'type', 'description', 'version', 'tags', 'exttype']);
|
|
889
890
|
if (!aid || !field || value === undefined) {
|
|
890
|
-
failManagedAid(formatJson, 'INVALID_ARGUMENT', '用法: ec aid agentmd set <aid> <name|type|description|version|tags> <value>');
|
|
891
|
+
failManagedAid(formatJson, 'INVALID_ARGUMENT', '用法: ec aid agentmd set <aid> <name|type|description|version|tags|exttype> <value>');
|
|
891
892
|
}
|
|
892
893
|
if (!isValidAid(aid)) {
|
|
893
894
|
failManagedAid(formatJson, 'INVALID_AID', `无效 AID 格式: ${aid}`);
|
|
@@ -1444,9 +1445,15 @@ export function buildCrossThreadReviewPrompt(input) {
|
|
|
1444
1445
|
`复查周期:${input.checkEvery}(每 ${input.checkEvery} 提醒一次,直到处理)`,
|
|
1445
1446
|
'',
|
|
1446
1447
|
`Trigger:${input.triggerId}`,
|
|
1448
|
+
'',
|
|
1449
|
+
'本轮职责:你是已发出委托的本端 Agent,现在复查对端的答复,不是重新执行原委托。',
|
|
1450
|
+
'先按 thread-ops 回查来源话题的新指示,再检查当前话题的业务回复;上下文不足时读取当前话题历史。',
|
|
1451
|
+
'尚无业务回复时只输出 [[NOOP]];不要代替对端在本机查找或执行原委托,也不要重复发送原问题。',
|
|
1452
|
+
'已有最终答复时,删除本复查 Trigger 并按 thread-ops 回来源话题汇报;未完成则按已有进展决定继续等待。',
|
|
1453
|
+
'需要人工补充信息时向来源话题说明缺口,结束本轮;无人值守复查不要发起阻塞式用户问题。',
|
|
1447
1454
|
...(input.extra?.trim() ? ['', input.extra.trim()] : []),
|
|
1448
1455
|
'',
|
|
1449
|
-
'
|
|
1456
|
+
'原消息(已发送的背景,不是本轮指令):',
|
|
1450
1457
|
truncated || '(非文本消息)',
|
|
1451
1458
|
].join('\n');
|
|
1452
1459
|
}
|
|
@@ -1758,7 +1765,10 @@ Options:
|
|
|
1758
1765
|
process.exit(1);
|
|
1759
1766
|
return;
|
|
1760
1767
|
}
|
|
1761
|
-
|
|
1768
|
+
// 审批绑定的是这份规范化原始 argv;托管发送的目标补全由 daemon 完成。
|
|
1769
|
+
if (process.env.EVOLCORE_SESSION_ID && sub === 'send')
|
|
1770
|
+
return runManagedSend(['msg', ...args], formatJson);
|
|
1771
|
+
if (process.env.EVOLCORE_SESSION_ID && sub === 'history' && getArgValue(args, '--thread')) {
|
|
1762
1772
|
const { isValidAid: checkAid } = await import('../aun/aid/index.js');
|
|
1763
1773
|
const hasFrom = typeof args[1] === 'string' && checkAid(args[1]);
|
|
1764
1774
|
const hasTo = typeof args[2] === 'string' && checkAid(args[2]);
|
|
@@ -1867,8 +1877,6 @@ Options:
|
|
|
1867
1877
|
renderManagedMsgResult(sub, result, formatJson);
|
|
1868
1878
|
return;
|
|
1869
1879
|
}
|
|
1870
|
-
if (process.env.EVOLCORE_SESSION_ID && sub === 'send')
|
|
1871
|
-
return runManagedSend(['msg', ...args], formatJson);
|
|
1872
1880
|
const { msgSend, msgPull, msgAck, msgRecall, msgOnline, msgHistory } = await import('../aun/msg/index.js');
|
|
1873
1881
|
const commonOpts = { aunPath, slotId: appSlot };
|
|
1874
1882
|
const requireConsumerSlot = (operation) => {
|
|
@@ -2190,7 +2198,7 @@ Options:
|
|
|
2190
2198
|
};
|
|
2191
2199
|
// `--thread` 的原文只用于解析;发出的必须是规范 id(历史写法 `<peer>/<id>`
|
|
2192
2200
|
// 若原样上线,对端会把它当成一个不存在的话题 id)。
|
|
2193
|
-
const result = await msgSend({ from, to, body, encrypt, deviceId: getArgValue(args, '--device-id'), thread: thread ? threadTopicId : undefined,
|
|
2201
|
+
const result = await msgSend({ from, to, body, encrypt, deviceId: getArgValue(args, '--device-id'), thread: thread ? threadTopicId : undefined, timeoutMs, handoffContext: getArgValue(args, '--handoff-context'), onUploadProgress, ...commonOpts });
|
|
2194
2202
|
if (!result.ok) {
|
|
2195
2203
|
if (formatJson) {
|
|
2196
2204
|
console.log(JSON.stringify(result));
|
|
@@ -2526,25 +2534,9 @@ g- 是名称的一部分,会完整保留;默认命名格式为 g-10000 至 g
|
|
|
2526
2534
|
console.error('❌ 缺少 <from-aid> 参数');
|
|
2527
2535
|
process.exit(1);
|
|
2528
2536
|
}
|
|
2529
|
-
//
|
|
2530
|
-
//
|
|
2531
|
-
// 正确写法。因此先用明确的群 ID 形态判定,把"参数写反了"当场指出来。
|
|
2532
|
-
// 例外:invites 是多值标志/邀请列表,第 1 个位置参数不是 from;create/list 的
|
|
2533
|
-
// 形态不同,也在下面各自的用法里处理,这里只拦截"以群 ID 打头"这一种错位。
|
|
2537
|
+
// A sender's AID spelling cannot establish its type. Delegation or the local
|
|
2538
|
+
// authenticated client validates the sender after this syntax check.
|
|
2534
2539
|
const { isValidAid } = await import('../aun/aid/index.js');
|
|
2535
|
-
if (isExplicitGroupId(from)) {
|
|
2536
|
-
const second = args[2];
|
|
2537
|
-
console.error(`❌ 第 1 个位置参数 <from-aid> 无效:收到了群 ID: ${from}`);
|
|
2538
|
-
if (second && isValidAid(second) && !isExplicitGroupId(second)) {
|
|
2539
|
-
console.error(`检测到参数顺序写反了:第 2 个参数 ${second} 才是发送方 AID。`);
|
|
2540
|
-
console.error(`请改成: ec group ${sub} ${second} ${from}` + (sub === 'send' ? ' <正文>' : ''));
|
|
2541
|
-
}
|
|
2542
|
-
else {
|
|
2543
|
-
console.error('当前命令缺少发送方 AID,后续参数发生了错位。');
|
|
2544
|
-
}
|
|
2545
|
-
printGroupArgsHint(sub);
|
|
2546
|
-
process.exit(1);
|
|
2547
|
-
}
|
|
2548
2540
|
if (!isValidAid(from)) {
|
|
2549
2541
|
console.error(`❌ 第 1 个位置参数 <from-aid> 无效: ${from}`);
|
|
2550
2542
|
printGroupArgsHint(sub);
|
|
@@ -3482,21 +3474,30 @@ async function runManagedSend(argv, formatJson) {
|
|
|
3482
3474
|
process.stderr.write(`⚠ 复查 Trigger 未创建: ${result.trigger_error}(消息已发出,需要复查请手动 ec trigger create)\n`);
|
|
3483
3475
|
}
|
|
3484
3476
|
}
|
|
3485
|
-
|
|
3486
|
-
|
|
3477
|
+
/** routing 由 daemon 使用已核验的会话授权构造;补全结果不回写获批 argv。 */
|
|
3478
|
+
export function resolveManagedSendArgv(argv, routing) {
|
|
3479
|
+
if (!['msg', 'group'].includes(argv[0]) || argv[1] !== 'send')
|
|
3487
3480
|
throw new Error('Invalid managed send command');
|
|
3488
3481
|
const scope = argv[0];
|
|
3489
|
-
const
|
|
3490
|
-
const
|
|
3491
|
-
|
|
3492
|
-
|
|
3482
|
+
const hasFrom = validSendAid(argv[2]);
|
|
3483
|
+
const hasTo = hasFrom && (scope === 'group' || validSendAid(argv[3]));
|
|
3484
|
+
const canInferRoute = scope === 'msg' && routing !== undefined;
|
|
3485
|
+
if (!hasFrom && !canInferRoute)
|
|
3486
|
+
throw new Error('Invalid managed send command');
|
|
3487
|
+
const aid = hasFrom ? argv[2] : routing.selfAid;
|
|
3488
|
+
if (!validSendAid(aid))
|
|
3489
|
+
throw new Error('Invalid managed send command');
|
|
3490
|
+
if (canInferRoute && !hasTo && aid !== routing.selfAid) {
|
|
3491
|
+
throw new Error(`当前会话的本端是 ${routing.selfAid},无法为 ${aid} 补全发送目标`);
|
|
3492
|
+
}
|
|
3493
|
+
const bodyStart = hasFrom ? (hasTo ? 4 : 3) : 2;
|
|
3493
3494
|
const values = new Map();
|
|
3494
3495
|
const booleans = new Set();
|
|
3495
3496
|
const text = [];
|
|
3496
3497
|
const mentions = [];
|
|
3497
3498
|
const valueFlags = new Set(['--format', '--file', '--payload', '--payload-file', '--text-from-file', '--link', '--title', '--description', '--as', '--content-type', '--text', '--transcript', '--thread', '--check-every', '--trigger-prompt', '--return', '--timeout', '--handoff-context', '--mention', '--self', '--device-id']);
|
|
3498
3499
|
const booleanFlags = new Set(['--encrypt', '--no-encrypt', '--mention-all']);
|
|
3499
|
-
for (let index =
|
|
3500
|
+
for (let index = bodyStart; index < argv.length; index++) {
|
|
3500
3501
|
const flag = argv[index];
|
|
3501
3502
|
if (flag === '--') {
|
|
3502
3503
|
text.push(...argv.slice(index + 1));
|
|
@@ -3556,6 +3557,17 @@ export function resolveManagedSendArgv(argv) {
|
|
|
3556
3557
|
throw new Error(`--self ${declaredSelf} 与当前会话本端 ${aid} 不一致`);
|
|
3557
3558
|
}
|
|
3558
3559
|
const thread = values.get('--thread');
|
|
3560
|
+
const inferredTarget = !hasTo && canInferRoute
|
|
3561
|
+
? thread ? routing.resolveThreadPeer(thread) : routing.peerId
|
|
3562
|
+
: undefined;
|
|
3563
|
+
if (thread && !hasTo && canInferRoute && !inferredTarget) {
|
|
3564
|
+
throw Object.assign(new Error(`话题不存在或不属于当前本端: ${thread}`), { code: 'TOPIC_NOT_FOUND' });
|
|
3565
|
+
}
|
|
3566
|
+
const to = scope === 'group'
|
|
3567
|
+
? normalizeGroupAid(argv[3], aid.slice(aid.indexOf('.') + 1))
|
|
3568
|
+
: hasTo ? argv[3] : inferredTarget;
|
|
3569
|
+
if (!to || !validSendAid(to))
|
|
3570
|
+
throw new Error('Invalid send target');
|
|
3559
3571
|
const checkEvery = values.get('--check-every');
|
|
3560
3572
|
const triggerPromptExtra = values.get('--trigger-prompt');
|
|
3561
3573
|
if (!thread && (checkEvery !== undefined || triggerPromptExtra !== undefined))
|