evolcore 0.0.49 → 0.0.51
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 +103 -3
- package/bin/ec-build.mjs +60 -0
- package/bin/ecmsg.js +64 -57
- package/dist/ability/caller/authorization.js +21 -0
- package/dist/ability/caller/command.js +173 -0
- package/dist/ability/caller/contract.js +117 -0
- package/dist/ability/caller/credential-files.js +132 -0
- package/dist/ability/caller/daemon.js +183 -0
- package/dist/ability/caller/schema-view.js +157 -0
- package/dist/ability/caller/service.js +519 -0
- package/dist/ability/command-contract.js +5 -0
- package/dist/ability/daemon.js +5 -1
- package/dist/ability/interop-v1.js +156 -106
- package/dist/ability/management.js +1 -0
- package/dist/agent-template/jobs.js +79 -3
- package/dist/agent-template/runtime.js +459 -47
- package/dist/agent-template/service.js +1242 -198
- package/dist/agent-template/share.js +103 -0
- package/dist/agent-template/tool-runner.js +25 -0
- package/dist/agent-template/types.js +10 -2
- package/dist/agents/claude/availability.js +94 -0
- package/dist/agents/claude/capability-provider.js +154 -0
- package/dist/agents/claude/index.js +145 -0
- package/dist/agents/{claude-runner.js → claude/runner.js} +78 -166
- package/dist/agents/claude/session-file-adapter.js +246 -0
- package/dist/agents/codex/app-server-client.js +90 -10
- package/dist/agents/codex/availability.js +164 -0
- package/dist/agents/codex/capability-provider.js +138 -0
- package/dist/agents/codex/cli.js +38 -0
- package/dist/agents/codex/index.js +345 -0
- package/dist/agents/codex/mcp-elicitation.js +135 -0
- package/dist/agents/{codex-runner.js → codex/runner.js} +652 -383
- package/dist/agents/codex/session-file-adapter.js +834 -0
- package/dist/agents/dsh/availability.js +28 -0
- package/dist/agents/dsh/capability-provider.js +56 -0
- package/dist/agents/dsh/desktop-locations.ps1 +66 -0
- package/dist/agents/dsh/desktop-probe.cjs +37 -0
- package/dist/agents/dsh/index.js +98 -0
- package/dist/agents/dsh/installation.js +400 -0
- package/dist/agents/dsh/resources.js +755 -0
- package/dist/agents/dsh/runner.js +1183 -0
- package/dist/agents/dsh/runtime/README.md +243 -0
- package/dist/agents/dsh/runtime/authorization.js +23 -0
- package/dist/agents/dsh/runtime/bridge.js +837 -0
- package/dist/agents/dsh/runtime/config.js +271 -0
- package/dist/agents/dsh/runtime/entry.js +229 -0
- package/dist/agents/dsh/runtime/session-inspector.js +340 -0
- package/dist/agents/dsh/runtime/tool-policy.js +49 -0
- package/dist/agents/dsh/session-file-adapter.js +145 -0
- package/dist/agents/ecagent/index.js +215 -0
- package/dist/agents/{ecagent-runner.js → ecagent/runner.js} +592 -106
- package/dist/agents/ecagent/session-file-adapter.js +134 -0
- package/dist/agents/gemini/index.js +96 -0
- package/dist/agents/{gemini-runner.js → gemini/runner.js} +18 -23
- package/dist/{core/session/adapters/gemini-session-file-adapter.js → agents/gemini/session-file-adapter.js} +2 -2
- package/dist/aun/ability-device-routing.js +11 -17
- package/dist/aun/aid/agentmd.js +27 -1
- package/dist/aun/aid/control-aid.js +52 -32
- package/dist/aun/aid/managed-operation.js +6 -4
- package/dist/aun/group/invite-service.js +7 -37
- package/dist/aun/group/operations.js +6 -0
- package/dist/aun/menu/client.js +1 -1
- package/dist/aun/msg/history.js +1 -1
- package/dist/aun/msg/managed-operation.js +93 -21
- package/dist/aun/msg/mention-schema.js +1 -1
- package/dist/aun/msg/p2p.js +32 -4
- package/dist/aun/msg/upload.js +126 -3
- package/dist/aun/service-proxy.js +1 -1
- package/dist/aun/storage/index.js +242 -0
- package/dist/build-identity.json +1 -1
- package/dist/channels/aun.js +698 -213
- package/dist/channels/daemon.js +3 -2
- package/dist/channels/dingtalk.js +1 -1
- package/dist/channels/feishu.js +9 -9
- package/dist/channels/qqbot.js +1 -1
- package/dist/channels/wechat.js +2 -2
- package/dist/channels/wecom.js +1 -1
- package/dist/claude-gateway/agent-registration.js +389 -0
- package/dist/claude-gateway/binding.js +96 -0
- package/dist/claude-gateway/inbox.js +138 -0
- package/dist/claude-gateway/index.js +125 -0
- package/dist/claude-gateway/listing.js +330 -0
- package/dist/claude-gateway/router.js +328 -0
- package/dist/claude-gateway/sessions.js +128 -0
- package/dist/claude-gateway/terminal.js +250 -0
- package/dist/claude-gateway/transcript.js +272 -0
- package/dist/claude-gateway/types.js +14 -0
- package/dist/cli/ability-command.js +45 -0
- package/dist/cli/ability-output.js +182 -0
- package/dist/cli/agent-command.js +21 -2
- package/dist/cli/agent-create.js +197 -56
- package/dist/cli/agent-template.js +400 -27
- package/dist/cli/agent.js +105 -11
- package/dist/cli/aun-commands.js +237 -123
- package/dist/cli/bench.js +5 -2
- package/dist/cli/config.js +22 -6
- package/dist/cli/daemon-commands.js +283 -109
- package/dist/cli/data-command.js +1 -1
- package/dist/cli/debug-mode.js +9 -0
- package/dist/cli/directory.js +1 -2
- package/dist/cli/ecmsg-gateway.js +64 -26
- package/dist/cli/fs-command.js +67 -39
- package/dist/cli/index.js +45 -12
- package/dist/cli/init.js +161 -90
- package/dist/cli/managed-command-guard.js +3 -0
- package/dist/cli/menu-client.js +32 -7
- package/dist/cli/model.js +1 -1
- package/dist/cli/pay-command.js +30 -0
- package/dist/cli/provider-command.js +6 -2
- package/dist/cli/restart-monitor.js +4 -4
- package/dist/cli/services-command.js +35 -10
- package/dist/cli/skill-command.js +4 -4
- package/dist/cli/task-context.js +24 -14
- package/dist/cli/team-workspace-command.js +50 -52
- package/dist/cli/thread-command.js +81 -14
- package/dist/cli/trigger-command.js +47 -12
- package/dist/cli/watch-logs.js +2 -1
- package/dist/config/access-policy.js +16 -3
- package/dist/config/boot-log.js +3 -0
- package/dist/config/builtin-role-templates.js +1 -1
- package/dist/config/config-field-policy.js +26 -13
- package/dist/config/config-manager.js +113 -52
- package/dist/config/config-operation-service.js +22 -1
- package/dist/config/gateway-config.js +29 -44
- package/dist/config/invoke-ipc-service.js +1 -1
- package/dist/config/owner-config.js +5 -19
- package/dist/config/peer-book-store.js +2 -3
- package/dist/config/peer-book.js +2 -2
- package/dist/config/peer-role-resolver.js +3 -9
- package/dist/config/provider-identity-migration.js +24 -105
- package/dist/config/provider-ipc-service.js +13 -3
- package/dist/config/provider-local-sync.js +4 -1
- package/dist/config/provider-menu-request.js +21 -3
- package/dist/config/provider-templates.js +1 -1
- package/dist/config/providers-config.js +138 -31
- package/dist/config/providers-import.js +3 -3
- package/dist/config/providers-management.js +109 -118
- package/dist/config/resolved-config-op.js +1 -42
- package/dist/config/schema-migration.js +254 -15
- package/dist/config/schema-registry.js +53 -8
- package/dist/config-store.js +1343 -63
- package/dist/core/{agent-application-service.js → agent/agent-application-service.js} +228 -9
- package/dist/core/{agent-create-status.js → agent/agent-create-status.js} +112 -4
- package/dist/core/{agent-creation-claim.js → agent/agent-creation-claim.js} +3 -3
- package/dist/core/{agent-ipc-registration.js → agent/agent-ipc-registration.js} +119 -25
- package/dist/core/{agent-reload-coordinator.js → agent/agent-reload-coordinator.js} +65 -0
- package/dist/core/{agent-runtime.js → agent/agent-runtime.js} +249 -79
- package/dist/core/{evolagent-registry.js → agent/evolagent-registry.js} +23 -18
- package/dist/core/{evolagent.js → agent/evolagent.js} +11 -11
- package/dist/core/auth/agent-delegation.js +15 -8
- package/dist/core/auth/delegation-authorization.js +28 -0
- package/dist/core/auth/operation-authorizer.js +20 -2
- package/dist/core/auth/operation-catalog.js +80 -8
- package/dist/core/baseagent/baseagent-availability.js +197 -0
- package/dist/core/baseagent/baseagent-capability-adapter.js +288 -0
- package/dist/core/baseagent/baseagent-config-shared.js +56 -0
- package/dist/core/baseagent/baseagent-identity.js +68 -0
- package/dist/core/{baseagent-loader.js → baseagent/baseagent-loader.js} +89 -6
- package/dist/core/baseagent/baseagent-model-defaults.js +26 -0
- package/dist/core/baseagent/baseagent-plugin-descriptor.js +357 -0
- package/dist/core/baseagent/baseagent-plugin-loader.js +367 -0
- package/dist/core/baseagent/baseagent.js +157 -0
- package/dist/{agents → core/baseagent}/runner-types.js +36 -4
- package/dist/core/capability/capability-manager.js +91 -33
- package/dist/core/capability/providers/claude-capability-provider.js +2 -154
- package/dist/core/capability/providers/codex-capability-provider.js +2 -136
- package/dist/core/{channel-loader.js → channel/channel-loader.js} +226 -38
- package/dist/core/{channel-runtime.js → channel/channel-runtime.js} +21 -19
- package/dist/core/command/agent-control.js +80 -17
- package/dist/core/command/agent-template-menu.js +23 -10
- package/dist/core/command/agentmd-menu-request.js +19 -8
- package/dist/core/command/agentmd-menu.js +14 -5
- package/dist/core/command/cli-intent-parser.js +15 -0
- package/dist/core/command/command-handler.js +127 -57
- package/dist/core/command/context-policy-menu.js +122 -0
- package/dist/core/command/data-root-resolver.js +157 -20
- package/dist/core/command/memory-slash.js +6 -6
- package/dist/core/command/menu-catalog.js +95 -19
- package/dist/core/command/menu-file-path.js +70 -0
- package/dist/core/command/menu-handler.js +392 -93
- package/dist/core/command/menu-protocol.js +47 -8
- package/dist/core/command/menu-query-batch.js +9 -5
- package/dist/core/command/private-mention-menu.js +71 -0
- package/dist/core/command/provider-menu.js +7 -11
- package/dist/core/command/role-menu.js +1 -1
- package/dist/core/command/skill-slash.js +17 -5
- package/dist/core/command/slash-gate.js +2 -4
- package/dist/core/command/slash-handler.js +143 -121
- package/dist/core/command/team-workspace-bootstrap.js +2 -1
- package/dist/core/command/team-workspace-team.js +3 -3
- package/dist/core/command/topic-slash.js +16 -10
- package/dist/core/{daemon-bootstrap.js → daemon/daemon-bootstrap.js} +14 -18
- package/dist/core/{daemon-control.js → daemon/daemon-control.js} +48 -21
- package/dist/core/{daemon-lifecycle.js → daemon/daemon-lifecycle.js} +28 -20
- package/dist/core/{host-snapshot.js → daemon/host-snapshot.js} +10 -5
- package/dist/core/{ipc-registration.js → daemon/ipc-registration.js} +101 -37
- package/dist/core/{lifecycle-notice.js → daemon/lifecycle-notice.js} +4 -5
- package/dist/core/file-integrity/store.js +1 -1
- package/dist/core/handoff/ipc-registration.js +3 -3
- package/dist/core/handoff/runtime.js +2 -2
- package/dist/{agents → core/inference}/request-identity.js +2 -2
- package/dist/core/inference/text-inference.js +4 -4
- package/dist/core/{bootstrap-messages.js → initialization/bootstrap-messages.js} +10 -10
- package/dist/core/{bootstrap-service.js → initialization/bootstrap-service.js} +24 -23
- package/dist/core/initialization/service.js +57 -9
- package/dist/core/invoke/executors/media.js +1 -1
- package/dist/core/invoke/executors/text.js +1 -1
- package/dist/core/memory/consolidation-context.js +3 -2
- package/dist/core/memory/consolidation-trigger.js +9 -3
- package/dist/core/memory/consolidation.js +39 -68
- package/dist/core/memory/memory-admin.js +6 -6
- package/dist/core/memory/memory-writer.js +1 -1
- package/dist/core/memory/relation-idle-monitor.js +1 -1
- package/dist/core/message/aun-ipc-sender.js +204 -88
- package/dist/core/message/aun-request-registry.js +44 -5
- package/dist/core/message/auto-mention-gate.js +1 -1
- package/dist/core/message/contact-admission.js +1 -1
- package/dist/core/message/im-renderer.js +19 -0
- package/dist/core/{interaction-router.js → message/interaction-router.js} +131 -1
- package/dist/core/message/items-formatter.js +5 -5
- package/dist/core/message/message-admission.js +1 -1
- package/dist/core/message/message-bridge.js +239 -59
- package/dist/core/message/message-log.js +8 -0
- package/dist/core/message/message-queue.js +88 -7
- package/dist/core/message/message-utils.js +1 -1
- package/dist/core/message/peer-mode.js +16 -5
- package/dist/core/message/response-engine.js +351 -152
- package/dist/core/message/send-options.js +44 -7
- package/dist/core/message/send-routing.js +55 -115
- package/dist/core/message/stream-idle-monitor.js +1 -1
- package/dist/core/{data-migration.js → migration/data-migration.js} +29 -1
- package/dist/core/model/catalog-service.js +29 -8
- package/dist/core/model/model-capabilities.js +88 -0
- package/dist/core/model/model-catalog.js +18 -7
- package/dist/core/model/model-diagnostics.js +4 -4
- package/dist/core/ownership/owner-resolver.js +107 -101
- package/dist/core/{pack-auth.js → pack/pack-auth.js} +34 -3
- package/dist/core/{pack-install.js → pack/pack-install.js} +95 -17
- package/dist/core/permission/approval-gateway.js +9 -18
- package/dist/core/permission/ec-command-parser.js +242 -82
- package/dist/core/permission/managed-file.js +234 -0
- package/dist/core/permission/protected-paths.js +120 -9
- package/dist/core/permission/sandbox-runtime.js +267 -3
- package/dist/core/permission/services-path-acl.js +9 -2
- package/dist/core/permission/session-path-grants.js +1 -1
- package/dist/core/permission/shell-environment.js +15 -1
- package/dist/core/permission/tool-policy.js +21 -9
- package/dist/core/plugin/plugin-lifecycle.js +442 -0
- package/dist/core/session/adapters/claude-session-file-adapter.js +2 -242
- package/dist/core/session/adapters/codex-session-file-adapter.js +2 -562
- package/dist/core/session/adapters/ecagent-session-file-adapter.js +2 -134
- package/dist/core/{background-session → session/background}/session-cleanup.js +2 -2
- package/dist/core/{background-session → session/background}/types.js +1 -1
- package/dist/core/session/session-file-health.js +2 -272
- package/dist/core/session/session-idle-monitor.js +1 -1
- package/dist/core/session/session-manager.js +76 -12
- package/dist/core/session/session-mapper.js +16 -0
- package/dist/core/session/session-terminal.js +185 -0
- package/dist/core/session/session-title.js +8 -11
- package/dist/core/{system-session → session/system}/memory.js +43 -9
- package/dist/core/{system-session → session/system}/registry.js +1 -1
- package/dist/core/{system-session → session/system}/types.js +1 -1
- package/dist/core/skill/index-generator.js +3 -3
- package/dist/core/skill/switch-resolver.js +3 -0
- package/dist/core/task/task-activity-store.js +112 -0
- package/dist/core/task/task-recovery-service.js +2 -2
- package/dist/core/thread/command-parser.js +4 -1
- package/dist/core/thread/ipc-operation.js +6 -4
- package/dist/core/thread/thread-operation.js +27 -11
- package/dist/core/thread/thread-route.js +5 -3
- package/dist/core/thread/thread-service.js +307 -58
- package/dist/core/thread/topic-id.js +52 -2
- package/dist/core/thread/types.js +15 -1
- package/dist/directory/{owner-directory-admission.js → admission.js} +3 -3
- package/dist/directory/{owner-directory-cache.js → cache.js} +90 -8
- package/dist/directory/{owner-directory-markdown.js → markdown.js} +2 -2
- package/dist/directory/{owner-directory-query-operation.js → query-operation.js} +83 -9
- package/dist/directory/{owner-directory-search.js → search.js} +50 -2
- package/dist/directory/{owner-directory-store.js → store.js} +2 -2
- package/dist/eck/kit-renderer.js +3 -2
- package/dist/eck/manifest-engine.js +64 -2
- package/dist/eck/message-renderer.js +35 -0
- package/dist/ecweb/basic-settings-service.js +12 -10
- package/dist/{contracts → ecweb/contracts}/ecweb-service-protocol.js +2 -1
- package/dist/ecweb/dsh-native-service.js +413 -0
- package/dist/ecweb/providers-service.js +5 -3
- package/dist/ecweb/runtime/lifecycle.js +1 -1
- package/dist/ecweb/runtime/supervisor.js +1 -1
- package/dist/event-center/center-config.js +2 -2
- package/dist/event-center/dispatcher.js +1 -1
- package/dist/event-center/ipc-operation.js +12 -3
- package/dist/event-center/pack-loader.js +2 -2
- package/dist/event-center/registry.js +6 -6
- package/dist/event-center/runtime.js +2 -2
- package/dist/index.js +181 -77
- package/dist/ipc.js +161 -12
- package/dist/outputs/authorization.js +27 -0
- package/dist/outputs/events.js +10 -1
- package/dist/outputs/panel-cards.js +960 -0
- package/dist/paths.js +60 -1
- package/dist/pay/command.js +38 -0
- package/dist/pay/protocol.js +136 -0
- package/dist/pay/runtime.js +196 -0
- package/dist/pay/service.js +384 -0
- package/dist/pay/store.js +81 -0
- package/dist/response-system/engines/v1/proactive-flow.js +30 -3
- package/dist/services/dispatcher.js +25 -7
- package/dist/services/host/main.js +397 -0
- package/dist/services/host/protocol.js +125 -0
- package/dist/services/host/resident.js +347 -0
- package/dist/services/host-client.js +398 -0
- package/dist/services/host-deploy.js +180 -0
- package/dist/services/host-launch.js +117 -0
- package/dist/services/host-recycle.js +208 -0
- package/dist/services/host-runtime.js +841 -0
- package/dist/services/idempotency.js +44 -86
- package/dist/services/index-generator.js +4 -3
- package/dist/services/index.js +258 -36
- package/dist/services/ipc-operation.js +503 -78
- package/dist/services/pack-manager.js +2 -2
- package/dist/services/router.js +43 -3
- package/dist/services/script-runner.js +541 -100
- package/dist/services/service-payload.js +28 -1
- package/dist/services/validation.js +136 -5
- package/dist/stats/context-usage.js +110 -0
- package/dist/stats/model-resolver.js +103 -17
- package/dist/stats/query.js +5 -0
- package/dist/trigger/application-service.js +9 -6
- package/dist/trigger/authorization.js +36 -33
- package/dist/trigger/ipc-service.js +4 -4
- package/dist/trigger/local-files.js +8 -166
- package/dist/trigger/manager.js +2 -2
- package/dist/trigger/parser.js +48 -0
- package/dist/trigger/scheduler.js +35 -13
- package/dist/trigger/script-executor.js +21 -0
- package/dist/trigger/script-sandbox.js +77 -232
- package/dist/trigger/system-definitions.js +25 -0
- package/dist/trigger/validation.js +1 -1
- package/dist/utils/aid-bind.js +3 -0
- package/dist/utils/atomic-write.js +88 -1
- package/dist/utils/cross-platform.js +4 -42
- package/dist/utils/error-dict.json +22 -1
- package/dist/utils/error-utils.js +193 -6
- package/dist/utils/evolcore-version.js +2 -2
- package/dist/utils/host-info.js +74 -1
- package/dist/utils/logger.js +5 -3
- package/dist/utils/media-cache.js +284 -42
- package/dist/utils/restart-safety.js +14 -1
- package/dist/utils/startup-trace.js +20 -4
- package/dist/utils/system-memory.js +113 -25
- package/dist/utils/systemd-lifecycle.js +154 -0
- package/dist/utils/welcome.js +64 -20
- package/dist/utils/windows-shell-trust.js +7 -3
- package/ecagent/README.md +35 -0
- package/ecagent/dist/agent-loop.js +80 -30
- package/ecagent/dist/harness/env/nodejs.d.ts +16 -0
- package/ecagent/dist/harness/env/nodejs.js +49 -20
- package/ecagent/dist/harness/messages.js +3 -2
- package/ecagent/dist/harness/types.d.ts +1 -0
- package/ecagent/dist/runtime/types.d.ts +2 -0
- package/ecagent/dist/runtime/utils/validation.d.ts +7 -1
- package/ecagent/dist/runtime/utils/validation.js +42 -0
- package/ecagent/dist/types.d.ts +2 -0
- package/kits/docs/INDEX.md +3 -2
- package/kits/docs/aun/AUN/346/266/210/346/201/257/347/261/273/345/236/213/344/270/216/345/261/236/346/200/247.md +1 -0
- package/kits/docs/channels/aun.md +1 -1
- package/kits/docs/channels/feishu.md +1 -1
- package/kits/docs/evolcore/INDEX.md +13 -9
- package/kits/docs/evolcore/agent-create.md +2 -0
- package/kits/docs/evolcore/agent.md +133 -11
- package/kits/docs/evolcore/aid.md +39 -6
- package/kits/docs/evolcore/config.md +95 -1
- package/kits/docs/evolcore/ctl.md +2 -1
- package/kits/docs/evolcore/ec-capabilities.md +7 -10
- package/kits/docs/evolcore/ecweb-lifecycle.md +5 -1
- package/kits/docs/evolcore/event.md +1 -1
- package/kits/docs/evolcore/fs.md +49 -3
- package/kits/docs/evolcore/group.md +5 -4
- package/kits/docs/evolcore/memory-consolidation.md +1 -1
- package/kits/docs/evolcore/memory-tags.md +2 -0
- package/kits/docs/evolcore/menu-client.md +3 -3
- package/kits/docs/evolcore/menu-protocol.md +31 -2
- package/kits/docs/evolcore/model.md +12 -1
- package/kits/docs/evolcore/msg.md +96 -36
- package/kits/docs/evolcore/pay.md +22 -0
- package/kits/docs/evolcore/plugin.md +74 -0
- package/kits/docs/evolcore/provider.md +29 -2
- package/kits/docs/evolcore/rpc.md +2 -2
- package/kits/docs/evolcore/services.md +46 -18
- package/kits/docs/evolcore/skill.md +17 -1
- package/kits/docs/evolcore/stats.md +5 -0
- package/kits/docs/evolcore/storage.md +22 -0
- package/kits/docs/evolcore/thread-chain.md +20 -9
- package/kits/docs/evolcore/tool-authorization.md +14 -0
- package/kits/docs/evolcore/trigger.md +89 -13
- package/kits/docs/identity/AID_PROFILE_SPEC.md +1 -1
- package/kits/docs/venues/feishu-group.md +3 -2
- package/kits/docs/venues/feishu-private.md +3 -2
- package/kits/rules/01-overview.md +11 -32
- package/kits/rules/02-navigation.md +20 -6
- package/kits/rules/06-channel.md +20 -4
- package/kits/schemas/_meta.json +42 -5
- package/kits/schemas/agent-config.schema.21.json +974 -0
- package/kits/schemas/agent-config.schema.22.json +977 -0
- package/kits/schemas/agent-config.schema.23.json +974 -0
- package/kits/schemas/agent-config.schema.24.json +986 -0
- package/kits/schemas/agent-config.schema.25.json +986 -0
- package/kits/schemas/daemon.schema.10.json +373 -0
- package/kits/schemas/daemon.schema.11.json +487 -0
- package/kits/schemas/daemon.schema.12.json +505 -0
- package/kits/schemas/daemon.schema.9.json +12 -0
- package/kits/schemas/defaults.schema.7.json +472 -0
- package/kits/schemas/defaults.schema.8.json +484 -0
- package/kits/schemas/providers.schema.1.json +1 -1
- package/kits/schemas/providers.schema.2.json +1 -1
- package/kits/schemas/providers.schema.3.json +26 -4
- package/kits/schemas/relation-config.schema.13.json +289 -0
- package/kits/skills/.switches.json +17 -1
- package/kits/skills/ability/SKILL.md +395 -33
- package/kits/skills/ability/STRUCTURE.md +338 -0
- package/kits/skills/ability/references/cli.md +208 -0
- package/kits/skills/ability/references/development.md +107 -37
- package/kits/skills/ability/references/management.md +106 -46
- package/kits/skills/ability/references/runtime-protocol.md +65 -63
- package/kits/skills/agent-output-cards/SKILL.md +80 -37
- package/kits/skills/agent-output-cards/examples/html-surface.json +11 -0
- package/kits/skills/agent-output-cards/examples/meeting-followups.json +16 -0
- package/kits/skills/agent-output-cards/examples/meeting-latest.json +24 -0
- package/kits/skills/agent-output-cards/examples/project-metrics.json +16 -0
- package/kits/skills/agent-output-cards/examples/quick-links.json +18 -0
- package/kits/skills/agent-output-cards/examples/surface.html +8 -0
- package/kits/skills/agent-template-project/SKILL.md +51 -0
- package/kits/skills/agent-template-project/references/01-collect-and-pack.md +174 -0
- package/kits/skills/agent-template-project/references/02-upload-and-share.md +109 -0
- package/kits/skills/agent-template-project/references/03-download-and-install.md +189 -0
- package/kits/skills/agent-template-project/references/04-upgrade-and-recovery.md +74 -0
- package/kits/skills/agent-template-project/references/05-publish-to-platform.md +62 -0
- package/kits/skills/ec-group/SKILL.md +8 -6
- package/kits/skills/ec-group/TASK.md +186 -0
- package/kits/skills/ec-group/WORKLOG.md +180 -0
- package/kits/skills/ec-group-collaboration/SKILL.md +5 -5
- package/kits/skills/ec-identity/SKILL.md +9 -6
- package/kits/skills/ec-pay/SKILL.md +223 -0
- package/kits/skills/ec-provider/SKILL.md +6 -6
- package/kits/skills/{ec-service-proxy → ec-proxy}/SKILL.md +8 -5
- package/kits/skills/ec-service-call/SKILL.md +138 -0
- package/kits/skills/ec-service-pack/SKILL.md +277 -0
- package/kits/skills/ec-skill/SKILL.md +25 -9
- package/kits/skills/ec-skill/scripts/cli.mjs +7 -7
- package/kits/skills/ec-skill/scripts/skill.mjs +55 -41
- package/kits/skills/ec-skill/scripts/template/SKILL.md.tmpl +9 -0
- package/kits/skills/ec-trigger/SKILL.md +3 -3
- package/kits/skills/personal-assistant/SKILL.md +22 -22
- package/kits/skills/personal-assistant/references/03-data-flow-and-gaps.md +1 -1
- package/kits/skills/scrapling-article-fetch/SKILL.md +5 -5
- package/kits/skills/thread-ops/SKILL.md +19 -9
- package/kits/skills/wechat-article-media-download/SKILL.md +2 -2
- package/kits/skills/wechat-article-reader/SKILL.md +2 -2
- package/kits/templates/memory-consolidation/notes.md +2 -2
- package/kits/templates/memory-consolidation/workflow.md +46 -0
- package/kits/templates/system-fragments/channel.md +13 -4
- package/kits/templates/system-fragments/commands.md +5 -4
- package/kits/templates/system-fragments/personal-assistant.md +2 -2
- package/kits/templates/system-fragments/reply.md +15 -9
- package/kits/templates/system-fragments/session.md +2 -2
- package/kits/templates/system-fragments/thread.md +30 -127
- package/kits/templates/system-fragments/venue.md +16 -0
- package/package.json +7 -7
- package/scripts/agent-template/index.mjs +7 -1
- package/scripts/agent-template/inspect.mjs +99 -39
- package/scripts/agent-template/overlay.mjs +126 -2
- package/scripts/agent-template/shared/common.mjs +49 -5
- package/scripts/agent-template/shared/plan.mjs +4 -2
- package/scripts/agent-template/shared/service-packs.mjs +104 -0
- package/scripts/agent-template/shared/team-schema.json +468 -39
- package/scripts/agent-template/shared/template-contract.mjs +93 -51
- package/scripts/agent-template/shared/template-package.mjs +225 -44
- package/scripts/agent-template/shared/template-runtime.mjs +137 -15
- package/scripts/agent-template/shared/template.mjs +31 -8
- package/scripts/agent-template/team-pack.mjs +528 -56
- package/scripts/agent-template/team-preview.mjs +102 -9
- package/scripts/aid-batch/identity-batch.mjs +1 -1
- package/dist/agents/baseagent-availability.js +0 -152
- package/dist/agents/baseagent.js +0 -750
- package/dist/agents/codex/catalog.js +0 -80
- package/dist/agents/ecagent-plugin-lazy.js +0 -41
- package/dist/agents/tool-time-context.js +0 -55
- package/dist/core/legacy-rename.js +0 -41
- package/dist/core/plugin-lifecycle.js +0 -137
- package/dist/core/rate-window.js +0 -53
- package/dist/core/runner-reload-transaction.js +0 -60
- package/dist/core/runtime-lock.js +0 -90
- package/dist/core/soul.js +0 -66
- package/dist/core/system-session/grants.js +0 -40
- package/dist/directory/owner-directory-agentmd-sync.js +0 -89
- package/dist/directory/owner-directory-request-operation.js +0 -79
- package/dist/directory/owner-directory-text.js +0 -60
- package/kits/docs/aun/ABILITY_CALLING.md +0 -280
- package/kits/docs/evolcore/ability.md +0 -185
- package/kits/skills/ability/references/calling.md +0 -56
- package/kits/skills/ability/references/contract-checklist.md +0 -37
- package/kits/skills/ability/references/recovery.md +0 -27
- /package/dist/{core/capability/providers/gemini-capability-provider.js → agents/gemini/capability-provider.js} +0 -0
- /package/dist/core/{system-channels.js → channel/system-channels.js} +0 -0
- /package/dist/core/{daemon-file-cache.js → daemon/daemon-file-cache.js} +0 -0
- /package/dist/core/{event-bus.js → event/event-bus.js} +0 -0
- /package/dist/core/{event-catalog.js → event/event-catalog.js} +0 -0
- /package/dist/core/{pack-ledger.js → pack/pack-ledger.js} +0 -0
- /package/dist/directory/{owner-directory-identity.js → identity.js} +0 -0
- /package/dist/directory/{owner-directory-policy.js → policy.js} +0 -0
- /package/dist/directory/{owner-directory-remarks.js → remarks.js} +0 -0
- /package/dist/directory/{owner-directory-scope.js → scope.js} +0 -0
- /package/dist/{contracts → ecweb/contracts}/ecweb-instance.js +0 -0
- /package/kits/templates/{bootstrap-welcome.md → bootstrap-intro.md} +0 -0
package/dist/cli/aun-commands.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import crypto from 'crypto';
|
|
4
|
-
import { agentMdPath, resolvePaths, resolveRoot } from '../paths.js';
|
|
4
|
+
import { agentDir, agentMdPath, resolvePaths, resolveRoot } from '../paths.js';
|
|
5
5
|
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 {
|
|
9
|
+
import { AGENTMD_EDITABLE_FIELDS, AGENTMD_VISIBILITY_ERROR, isAgentMdEditableField, isAgentMdVisibility, } from '../aun/aid/agentmd.js';
|
|
10
|
+
import { isValidEncryptMode, MANAGED_SEND_BOOLEAN_FLAGS, MANAGED_SEND_TRISTATE_FLAGS, MANAGED_SEND_VALUE_FLAGS, resolveEncryptFlagValue, } from '../core/message/send-options.js';
|
|
10
11
|
import { AGENT_DELEGATION_TOKEN_ENV, CODEX_SESSION_TOKEN_ENV, readDelegationCredential, } from '../core/auth/agent-delegation.js';
|
|
11
12
|
import { MAIN_CLI_BIN, SELF_AID_ENV, SESSION_ID_ENV } from '../product.js';
|
|
12
13
|
import { isTrustedFullAccessRuntimeContext, readBestTaskRuntimeContext, readVerifiedTaskRuntimeContext, RUNTIME_LOCK_DIR_ENV, SESSION_RUNTIME_DIR_ENV, TASK_RUNTIME_CONTEXT_ENV, } from './task-context.js';
|
|
13
14
|
import { assertEcSingleLine, parseTimeArg, TIME_ARG_FORMATS } from './cli-argv.js';
|
|
14
15
|
import { canonicalizeEvolcoreCommandArgv } from '../core/permission/ec-command-parser.js';
|
|
16
|
+
import { DEBUG_SESSION_ENV } from './debug-mode.js';
|
|
15
17
|
import { ManagedGroupOperationError } from '../aun/msg/managed-operation.js';
|
|
16
18
|
import { parseDuration } from '../trigger/parser.js';
|
|
17
19
|
import { isTopicThreadId, safeFormatMainTopicId } from '../core/thread/topic-id.js';
|
|
@@ -1015,22 +1017,25 @@ Options:
|
|
|
1015
1017
|
put <aid> 读本地 agent.md → 用本地私钥签名 → 上传到 PKI
|
|
1016
1018
|
get <aid> 从 PKI 下载 agent.md → 验签 → 持久化到本地
|
|
1017
1019
|
set <aid> <field> <value>
|
|
1018
|
-
修改
|
|
1019
|
-
tags 的 value 必须是 JSON 字符串数组,例如 ["coding","tools","aun"]
|
|
1020
|
+
修改 ${AGENTMD_EDITABLE_FIELDS.join('/')} 中的一个字段,签名后上传
|
|
1021
|
+
tags 的 value 必须是 JSON 字符串数组,例如 ["coding","tools","aun"]
|
|
1022
|
+
visibility 的 value 必须是 public、unlisted 或 private`);
|
|
1020
1023
|
return;
|
|
1021
1024
|
}
|
|
1022
1025
|
if (verb === 'set') {
|
|
1023
1026
|
const field = args[3];
|
|
1024
1027
|
const value = args[4];
|
|
1025
|
-
const editableFields = new Set(['name', 'type', 'description', 'version', 'tags', 'exttype']);
|
|
1026
1028
|
if (!aid || !field || value === undefined) {
|
|
1027
|
-
failManagedAid(formatJson, 'INVALID_ARGUMENT',
|
|
1029
|
+
failManagedAid(formatJson, 'INVALID_ARGUMENT', `用法: ec aid agentmd set <aid> <${AGENTMD_EDITABLE_FIELDS.join('|')}> <value>`);
|
|
1028
1030
|
}
|
|
1029
1031
|
if (!isValidAid(aid)) {
|
|
1030
1032
|
failManagedAid(formatJson, 'INVALID_AID', `无效 AID 格式: ${aid}`);
|
|
1031
1033
|
}
|
|
1032
|
-
if (!
|
|
1033
|
-
failManagedAid(formatJson, 'INVALID_ARGUMENT', `agentmd set field must be one of ${
|
|
1034
|
+
if (!isAgentMdEditableField(field)) {
|
|
1035
|
+
failManagedAid(formatJson, 'INVALID_ARGUMENT', `agentmd set field must be one of ${AGENTMD_EDITABLE_FIELDS.join(', ')}`);
|
|
1036
|
+
}
|
|
1037
|
+
if (field === 'visibility' && !isAgentMdVisibility(value)) {
|
|
1038
|
+
failManagedAid(formatJson, 'INVALID_ARGUMENT', AGENTMD_VISIBILITY_ERROR);
|
|
1034
1039
|
}
|
|
1035
1040
|
let parsedValue = value;
|
|
1036
1041
|
if (field === 'tags') {
|
|
@@ -1258,6 +1263,7 @@ Commands:
|
|
|
1258
1263
|
upload <aid> <local-file> <remote-path> [--public] 上传文件(默认私有)
|
|
1259
1264
|
download <aid> <url> [local-path] 下载文件
|
|
1260
1265
|
get-by-share <aid> <share-id> [local-path] 通过分享短码下载文件
|
|
1266
|
+
share <aid> --input-file FILE [--format json] 创建/查询/撤销私有分享,JSON内action=create|list|revoke|status
|
|
1261
1267
|
ls <aid> [prefix] 列文件
|
|
1262
1268
|
rm <aid> <remote-path> 删文件
|
|
1263
1269
|
quota <aid> 查配额
|
|
@@ -1291,7 +1297,7 @@ Options:
|
|
|
1291
1297
|
process.exit(1);
|
|
1292
1298
|
}
|
|
1293
1299
|
if (process.env.EVOLCORE_SESSION_ID) {
|
|
1294
|
-
const operation = { ls: 'storage.list', quota: 'storage.quota', upload: 'storage.upload', download: 'storage.download', rm: 'storage.delete', 'get-by-share': 'storage.get_by_share' }[sub];
|
|
1300
|
+
const operation = { ls: 'storage.list', quota: 'storage.quota', upload: 'storage.upload', download: 'storage.download', rm: 'storage.delete', 'get-by-share': 'storage.get_by_share', share: 'storage.share' }[sub];
|
|
1295
1301
|
if (!operation)
|
|
1296
1302
|
failManagedGroup(formatJson, 'NOT_ALLOWED', `unsupported managed storage command: ${sub}`);
|
|
1297
1303
|
const delegationToken = readDelegationCredential();
|
|
@@ -1339,7 +1345,12 @@ Options:
|
|
|
1339
1345
|
}
|
|
1340
1346
|
if (!authorization.ok)
|
|
1341
1347
|
failManagedGroup(formatJson, authorization.code || 'STORAGE_AUTH_FAILED', authorization.error || 'Storage operation denied');
|
|
1342
|
-
if (sub === '
|
|
1348
|
+
if (sub === 'share') {
|
|
1349
|
+
console.log(JSON.stringify(authorization.result, null, 2));
|
|
1350
|
+
if (authorization.result?.state !== 'succeeded')
|
|
1351
|
+
process.exitCode = 3;
|
|
1352
|
+
}
|
|
1353
|
+
else if (sub === 'ls') {
|
|
1343
1354
|
const objects = authorization.result?.objects ?? authorization.result ?? [];
|
|
1344
1355
|
console.log(Array.isArray(objects) && !objects.length ? '(空)' : JSON.stringify(objects, null, 2));
|
|
1345
1356
|
}
|
|
@@ -1356,6 +1367,22 @@ Options:
|
|
|
1356
1367
|
return;
|
|
1357
1368
|
}
|
|
1358
1369
|
const { storageUpload, storageDownload, storageGetByShare, storageLs, storageRm, storageQuota } = await import('../aun/storage/index.js');
|
|
1370
|
+
if (sub === 'share') {
|
|
1371
|
+
const { resolveStorageCommandArgv, executeStorageShare } = await import('../aun/storage/index.js');
|
|
1372
|
+
const { createShortConnection } = await import('../aun/rpc/index.js');
|
|
1373
|
+
const command = resolveStorageCommandArgv(['storage', ...args]);
|
|
1374
|
+
const client = await createShortConnection(aid, { aunPath });
|
|
1375
|
+
try {
|
|
1376
|
+
const result = await executeStorageShare(client, aid, command.share, path.join(resolvePaths().root, 'data', 'storage-shares'));
|
|
1377
|
+
console.log(JSON.stringify(result, null, 2));
|
|
1378
|
+
if (result.state !== 'succeeded')
|
|
1379
|
+
process.exitCode = 3;
|
|
1380
|
+
}
|
|
1381
|
+
finally {
|
|
1382
|
+
await client.close();
|
|
1383
|
+
}
|
|
1384
|
+
return;
|
|
1385
|
+
}
|
|
1359
1386
|
if (sub === 'upload') {
|
|
1360
1387
|
const localFile = args[2];
|
|
1361
1388
|
const remotePath = args[3];
|
|
@@ -1499,7 +1526,7 @@ Options:
|
|
|
1499
1526
|
/**
|
|
1500
1527
|
* 构造跨话题复查 Trigger 的定义。
|
|
1501
1528
|
*
|
|
1502
|
-
* `
|
|
1529
|
+
* `ecmsg send --thread T2 --check-every 5m` 发送成功后自动创建。
|
|
1503
1530
|
*
|
|
1504
1531
|
* 使用 `interval` 而非 `delay`:周期触发,由显式
|
|
1505
1532
|
* `ec trigger delete`(结束,不留残留)/ `ec trigger update --every <新时长>`(调整周期)改变状态。
|
|
@@ -1581,7 +1608,7 @@ export function buildCrossThreadReviewPrompt(input) {
|
|
|
1581
1608
|
`当前话题:${input.targetThreadName}(对端 ${input.targetPeerName})`,
|
|
1582
1609
|
`发送于:{{trigger.labels.firstSentAtTime}}`,
|
|
1583
1610
|
`已过:{{run.elapsed}}`,
|
|
1584
|
-
|
|
1611
|
+
`复查周期:{{run.every}}(每 {{run.every}} 提醒一次,直到处理)`,
|
|
1585
1612
|
'',
|
|
1586
1613
|
`Trigger:${input.triggerId}`,
|
|
1587
1614
|
'',
|
|
@@ -1621,7 +1648,7 @@ function parseCheckEveryArgs(checkEveryRaw, hasCheckEvery) {
|
|
|
1621
1648
|
/**
|
|
1622
1649
|
* 跨话题发送成功后的统一收尾:创建周期复查 Trigger + 写入本端 thread-inbox。
|
|
1623
1650
|
*
|
|
1624
|
-
*
|
|
1651
|
+
* 私聊与群聊的跨话题发送(`ecmsg send --thread`)共用,
|
|
1625
1652
|
* 保证两条路径行为一致(M2 修复前群聊路径完全不做这两件事)。
|
|
1626
1653
|
*
|
|
1627
1654
|
* 设计见 `docs/thread-chain/thread-context-mechanism.md` §十、`thread-cli-spec-v2.md` §3.4。
|
|
@@ -1653,12 +1680,22 @@ async function applyCrossThreadSendEffects(input) {
|
|
|
1653
1680
|
let originPeerName = originPeer;
|
|
1654
1681
|
let targetThreadName = input.targetThreadId;
|
|
1655
1682
|
let targetPeerName = input.targetChannelId;
|
|
1656
|
-
//
|
|
1657
|
-
// 伪对端(trigger: / bg
|
|
1658
|
-
const originPeerType = (() => {
|
|
1683
|
+
// 来源话题对端的主体类型(话题索引不存 type):身份缓存优先,运行时取值兜底。
|
|
1684
|
+
// 伪对端(trigger: / bg:)与 'system' 都不是主体,不能写进信封。
|
|
1685
|
+
const originPeerType = await (async () => {
|
|
1686
|
+
// 类型以身份缓存(agent.md 快照)为准,按来源对端 AID 查;复查唤醒的会话里运行时 peerType 可能是 'system',不能当对端类型。
|
|
1687
|
+
try {
|
|
1688
|
+
const { PeerIdentityCache } = await import('../core/relation/peer-identity.js');
|
|
1689
|
+
const cached = PeerIdentityCache.get('aun', originPeer, agentDir(input.selfAid));
|
|
1690
|
+
if (cached && cached.source !== 'unknown' && cached.type)
|
|
1691
|
+
return cached.type;
|
|
1692
|
+
}
|
|
1693
|
+
catch {
|
|
1694
|
+
// 缓存不可读时退回运行时取值
|
|
1695
|
+
}
|
|
1659
1696
|
const type = String(runtime?.peerType ?? '').trim();
|
|
1660
1697
|
const peerId = String(runtime?.peerId ?? '');
|
|
1661
|
-
if (!type || peerId.startsWith('trigger:') || peerId.startsWith('bg:'))
|
|
1698
|
+
if (!type || type === 'system' || peerId.startsWith('trigger:') || peerId.startsWith('bg:'))
|
|
1662
1699
|
return undefined;
|
|
1663
1700
|
return type;
|
|
1664
1701
|
})();
|
|
@@ -1712,7 +1749,7 @@ async function applyCrossThreadSendEffects(input) {
|
|
|
1712
1749
|
// `--check-every none`:跳过 Trigger,只保留 inbox(「我发过」是事实,定时唤醒是可选项)。
|
|
1713
1750
|
if (input.durationMs !== undefined) {
|
|
1714
1751
|
try {
|
|
1715
|
-
const { formatChannelKey } = await import('../core/channel-loader.js');
|
|
1752
|
+
const { formatChannelKey } = await import('../core/channel/channel-loader.js');
|
|
1716
1753
|
const triggerDef = buildThreadCheckTrigger({
|
|
1717
1754
|
agentAid: input.selfAid,
|
|
1718
1755
|
id: triggerId,
|
|
@@ -1780,16 +1817,34 @@ export async function cmdMsg(args) {
|
|
|
1780
1817
|
const aunPath = resolveAunPath(args);
|
|
1781
1818
|
const formatJson = getArgValue(args, '--format') === 'json';
|
|
1782
1819
|
const appSlot = getArgValue(args, '--app');
|
|
1820
|
+
// `ec msg send --help` 要的是发送用法,不是查询子命令清单——后者一个发送参数都没有,
|
|
1821
|
+
// 照着查 --file / --link 只会查不到。发送正文集中在 ecmsg,这里给要点并指向它。
|
|
1822
|
+
if (sub === 'send' && wantsHelp(args)) {
|
|
1823
|
+
console.log(`用法: ecmsg send '<正文>' [选项]
|
|
1824
|
+
ecmsg send '<正文>' --thread <话题id>
|
|
1825
|
+
ecmsg send '<正文>' --thread <话题id> --selfmode
|
|
1826
|
+
|
|
1827
|
+
发送一律用 ecmsg(托管会话本端恒等于会话本端,接收方由话题和模式推出)。
|
|
1828
|
+
|
|
1829
|
+
正文来源(互斥,选一种):
|
|
1830
|
+
'<正文>' 位置参数
|
|
1831
|
+
--file <path> 附件;配 --as image|video|voice|file|widget_card、--text '<说明>'
|
|
1832
|
+
--link <url> 链接卡片;配 --title
|
|
1833
|
+
--payload '<json>' 自定义 payload
|
|
1834
|
+
--payload-file <path> 从文件读 payload
|
|
1835
|
+
--text-from-file <path> 从文件读正文
|
|
1836
|
+
|
|
1837
|
+
参数: ${MANAGED_SEND_VALUE_FLAGS.join(' ')} ${MANAGED_SEND_TRISTATE_FLAGS.join(' ')}
|
|
1838
|
+
|
|
1839
|
+
完整用法与各参数语义: ecmsg --help`);
|
|
1840
|
+
return;
|
|
1841
|
+
}
|
|
1783
1842
|
if (!sub || isHelpFlag(sub) || (wantsHelp(args) && sub !== 'history')) {
|
|
1784
1843
|
console.log(`用法: ec msg <command> <from-aid> [args...] [options]
|
|
1785
1844
|
|
|
1845
|
+
发送统一用 ecmsg send(见 ecmsg --help)。
|
|
1846
|
+
|
|
1786
1847
|
Commands:
|
|
1787
|
-
send <from> <to> <text> 发送文本
|
|
1788
|
-
send <from> <to> --text-from-file <path> 从文件读取文本内容
|
|
1789
|
-
send <from> <to> --file <path> [--as <type>] 发送文件(image|video|voice|file)
|
|
1790
|
-
send <from> <to> --link <url> [--title T] 发送链接卡片
|
|
1791
|
-
send <from> <to> --payload <json> 发送自定义 payload
|
|
1792
|
-
send <from> <to> --payload-file <path> 从 UTF-8 文件读取自定义 payload
|
|
1793
1848
|
request get <self-aid> <request-id> 查询已登记请求状态
|
|
1794
1849
|
pull <from> [--after-seq N] [--limit N] --app <name> 拉取收件箱(必须使用独立 slot)
|
|
1795
1850
|
ack <from> <seq> [--app <name>] 确认已读
|
|
@@ -1797,25 +1852,22 @@ Commands:
|
|
|
1797
1852
|
online <from> <target-aid> [<target-aid>...] 查询在线状态
|
|
1798
1853
|
history <from> [<target-aid>|selector] [筛选选项] 查询本地消息历史
|
|
1799
1854
|
|
|
1800
|
-
|
|
1801
|
-
send <text> --thread <id> from/to 从运行时上下文与话题索引自动推断
|
|
1802
|
-
send <text> 发送到当前会话对端
|
|
1803
|
-
ecmsg send '<text>' [--thread <id>|--to <对端ID>] 统一入口,跨话题自动建复查
|
|
1855
|
+
托管会话(EVOLCORE_SESSION_ID 已设时):发送一律走 ecmsg,本命令只提供查询类子命令。
|
|
1804
1856
|
|
|
1805
1857
|
Options:
|
|
1806
|
-
--text-from-file <path> 从文件读取文本(UTF-8),用于超长消息或避免 Shell 转义
|
|
1807
|
-
--handoff-context <text> 仅托管会话:为目标会话补充本地上下文,不发给对端
|
|
1808
1858
|
--app <name> 指定应用 slot(独立消费通道,不影响 daemon)
|
|
1809
1859
|
--aun-path <path> 指定 AUN keystore 根
|
|
1810
1860
|
--format json 输出 JSON 格式
|
|
1811
1861
|
--payload '<json>' 发送任意 JSON payload,不添加聊天字段
|
|
1812
1862
|
--payload-file <path> 从 UTF-8 文件读取 JSON payload(与 --payload 互斥)
|
|
1813
1863
|
--return none|required 是否等待关联响应(required 建立请求记录)
|
|
1814
|
-
--device-id <id>
|
|
1864
|
+
--device-id <id> 可选,定向到能力目录中的一台设备;不指定时业务 Ability 收到首个最终回包即返回(protocol/discover 不指定,不写入 payload)
|
|
1815
1865
|
--timeout <duration> required 的等待期限和 AUN volatile TTL,如 30s、60s、2m(默认 60s,最大 3600s)
|
|
1816
|
-
--encrypt
|
|
1817
|
-
|
|
1866
|
+
--encrypt yes|no|auto 加密三态:yes 强制加密 / no 强制明文 / auto 跟随入站消息
|
|
1867
|
+
不带此参数时默认 auto
|
|
1818
1868
|
--thread <id> 指定目标话题 ID(话题必须存在于本端索引;from/to 可省略)
|
|
1869
|
+
--after-seq <N> pull 的起始序号
|
|
1870
|
+
--limit <N> 返回最新 N 条(默认 50,最大 500)
|
|
1819
1871
|
--session <latest|all|id> 按 EvolCore 逻辑会话过滤历史(默认 latest)
|
|
1820
1872
|
--before <time> 只返回该时间之前的历史
|
|
1821
1873
|
--after <time> 只返回该时间之后的历史
|
|
@@ -1824,28 +1876,8 @@ Options:
|
|
|
1824
1876
|
--channel-name <name> 历史渠道实例名(非 AUN 渠道必须匹配 Agent 配置)
|
|
1825
1877
|
--channel-key <key> 非 AUN 已落盘渠道的完整实例键(与 --peer-id 成对)
|
|
1826
1878
|
--peer-id <id> 非 AUN 渠道的原生对端 ID(与 --channel-key 成对)
|
|
1827
|
-
--check-every <duration|none> 跨话题发送后自动创建**跨话题复查**(如 5m/30m/2h),跨话题时**必填**;none = 不建复查
|
|
1828
|
-
每 duration 向**目标话题**投递一条【跨话题复查】通知(不新建会话),
|
|
1829
|
-
由目标话题侧的 agent 在自己的上下文里决定结束/调整周期/继续
|
|
1830
|
-
Trigger 名:check-<目标threadId>-from-<来源threadId>-<唯一后缀>
|
|
1831
|
-
结束/调整用返回的 trigger_id(trig_…),show/update/delete 只认 id
|
|
1832
|
-
--content-type <mime> 显式覆盖 MIME(仅 --file 模式)
|
|
1833
|
-
--as <type> 附件类型:image|video|voice|file(仅 --file 模式)
|
|
1834
|
-
--text <说明> 附件说明文字(仅 --file 模式)
|
|
1835
|
-
--transcript <text> 语音转写(仅 --as voice)
|
|
1836
|
-
--title <text> 链接标题(仅 --link 模式)
|
|
1837
|
-
--description <text> 链接描述(仅 --link 模式)
|
|
1838
|
-
-- end-of-options:其后所有参数按正文处理
|
|
1839
|
-
(用于发送恰好等于某 flag 的文本,如 send a b -- --encrypt)
|
|
1840
1879
|
|
|
1841
1880
|
示例:
|
|
1842
|
-
ec msg send alice.agentid.pub bob.agentid.pub "hello"
|
|
1843
|
-
ec msg send alice.agentid.pub bob.agentid.pub --text-from-file long-message.txt
|
|
1844
|
-
ec msg send alice.agentid.pub bob.agentid.pub "讨论项目A" --thread "thread-xxx"
|
|
1845
|
-
ec msg send alice.agentid.pub bob.agentid.pub --file ./pic.png
|
|
1846
|
-
ec msg send alice.agentid.pub bob.agentid.pub --file ./demo.mp4 --as video
|
|
1847
|
-
ec msg send alice.agentid.pub bob.agentid.pub --link https://example.com --title "AUN"
|
|
1848
|
-
ec msg send alice.agentid.pub bob.agentid.pub --payload '{"type":"query"}' --return required --timeout 60s --format json
|
|
1849
1881
|
ec msg request get alice.agentid.pub request-123 --format json
|
|
1850
1882
|
ec msg pull alice.agentid.pub --app my-bot
|
|
1851
1883
|
ec msg ack alice.agentid.pub 42 --app my-bot
|
|
@@ -1929,9 +1961,20 @@ Options:
|
|
|
1929
1961
|
process.exit(1);
|
|
1930
1962
|
return;
|
|
1931
1963
|
}
|
|
1932
|
-
//
|
|
1933
|
-
|
|
1964
|
+
// 托管会话的发消息入口只有一个:ecmsg send。`ec msg send` 在这里直接禁用,
|
|
1965
|
+
// 不再转发给 daemon——否则同一件事会有两条写法,模型与文档永远对不齐。
|
|
1966
|
+
// 唯一例外是 `--as-session` 调试身份:宿主终端要代表某个 agent 发消息,
|
|
1967
|
+
// 而 ecmsg 不支持 --as-session,只能走这条。该标记只有 debug-mode 会注入。
|
|
1968
|
+
if (process.env.EVOLCORE_SESSION_ID && sub === 'send' && !process.env[DEBUG_SESSION_ENV]) {
|
|
1969
|
+
console.error("❌ 托管会话发送消息请用: ecmsg send '<正文>' [--thread <话题id> [--selfmode]](见 ecmsg --help)");
|
|
1970
|
+
process.exit(1);
|
|
1971
|
+
return;
|
|
1972
|
+
}
|
|
1973
|
+
// 调试身份:走 daemon 的托管通道(审批与授权仍由 daemon 校验),
|
|
1974
|
+
// 不能落到下面的宿主终端分支——那条没有委托校验。
|
|
1975
|
+
if (process.env.EVOLCORE_SESSION_ID && sub === 'send') {
|
|
1934
1976
|
return runManagedSend(['msg', ...args], formatJson);
|
|
1977
|
+
}
|
|
1935
1978
|
if (process.env.EVOLCORE_SESSION_ID && sub === 'history' && getArgValue(args, '--thread')) {
|
|
1936
1979
|
const { isValidAid: checkAid } = await import('../aun/aid/index.js');
|
|
1937
1980
|
const hasFrom = typeof args[1] === 'string' && checkAid(args[1]);
|
|
@@ -1984,7 +2027,7 @@ Options:
|
|
|
1984
2027
|
}
|
|
1985
2028
|
}
|
|
1986
2029
|
}
|
|
1987
|
-
// 宿主终端的简化式:`
|
|
2030
|
+
// 宿主终端的简化式:`ec msg send '<正文>' --self <selfAid> --thread <ref>`
|
|
1988
2031
|
// 没有托管会话上下文,本端只能由 --self 给出;对端由话题引用推导。
|
|
1989
2032
|
// 这和托管会话里的简化式是同一语义,只是本端来源不同。
|
|
1990
2033
|
if (sub === 'send' && !process.env.EVOLCORE_SESSION_ID) {
|
|
@@ -2032,7 +2075,7 @@ Options:
|
|
|
2032
2075
|
if (!isValidAid(from)) {
|
|
2033
2076
|
console.error(`❌ 无效 AID 格式: ${from}`);
|
|
2034
2077
|
if (sub === 'send') {
|
|
2035
|
-
console.error('
|
|
2078
|
+
console.error('提示:宿主终端写法为 ec msg send <本端AID> <对端AID> <正文>,或用 --self <本端AID> --thread <话题id> 由话题推导对端');
|
|
2036
2079
|
}
|
|
2037
2080
|
process.exit(1);
|
|
2038
2081
|
}
|
|
@@ -2185,9 +2228,16 @@ Options:
|
|
|
2185
2228
|
return;
|
|
2186
2229
|
}
|
|
2187
2230
|
if (sub === 'send') {
|
|
2231
|
+
// 发送统一入口是 ecmsg:提示直接给托管写法,避免模型照抄位置参数式。
|
|
2232
|
+
if (process.env.EVOLCORE_SESSION_ID) {
|
|
2233
|
+
console.error('托管会话的发送用: ecmsg send \'<正文>\' [--thread <话题id> [--selfmode]](见 ecmsg --help)');
|
|
2234
|
+
process.exit(1);
|
|
2235
|
+
}
|
|
2188
2236
|
const to = args[2];
|
|
2189
2237
|
if (!to) {
|
|
2190
|
-
|
|
2238
|
+
// 只有宿主终端会走到这里(托管会话在入口处已被拒),而宿主终端的 ecmsg
|
|
2239
|
+
// 只放行跨话题自派,发给对端只能用本命令,所以这里给本命令自己的用法。
|
|
2240
|
+
console.error('用法(宿主终端): ec msg send <本端AID> <对端AID> <正文|--file …|--link …|--payload …>');
|
|
2191
2241
|
process.exit(1);
|
|
2192
2242
|
}
|
|
2193
2243
|
if (!isValidAid(to)) {
|
|
@@ -2221,6 +2271,7 @@ Options:
|
|
|
2221
2271
|
contentType: getArgValue(args, '--content-type'),
|
|
2222
2272
|
text: getArgValue(args, '--text'),
|
|
2223
2273
|
transcript: getArgValue(args, '--transcript'),
|
|
2274
|
+
title: getArgValue(args, '--title'),
|
|
2224
2275
|
};
|
|
2225
2276
|
}
|
|
2226
2277
|
else if (textFromFileVal) {
|
|
@@ -2282,10 +2333,6 @@ Options:
|
|
|
2282
2333
|
}
|
|
2283
2334
|
body = { mode: 'text', text };
|
|
2284
2335
|
}
|
|
2285
|
-
// 显式 flag 覆盖 daemon 默认值;未指定时保留 undefined。
|
|
2286
|
-
const encrypt = args.includes('--no-encrypt')
|
|
2287
|
-
? false
|
|
2288
|
-
: args.includes('--encrypt') ? true : undefined;
|
|
2289
2336
|
const thread = getArgValue(args, '--thread');
|
|
2290
2337
|
// P1b.6.5: 话题存在性校验 — 引用必须能解析成本端已存在的话题
|
|
2291
2338
|
let threadEntry;
|
|
@@ -2330,6 +2377,8 @@ Options:
|
|
|
2330
2377
|
const triggerPromptExtra = getArgValue(args, '--trigger-prompt');
|
|
2331
2378
|
let checkEveryDurationMs;
|
|
2332
2379
|
const runtime = await readBestTaskRuntimeContext();
|
|
2380
|
+
// 三态加密:不写 `--encrypt` 就是默认 auto,auto 需要本轮的入站加密态来解析。
|
|
2381
|
+
const encrypt = readTristateEncrypt(args, runtime?.inboundEncrypted);
|
|
2333
2382
|
if (thread && runtime?.sessionId) {
|
|
2334
2383
|
const parsedCheck = parseCheckEveryArgs(checkEveryRaw, hasCheckEvery);
|
|
2335
2384
|
if ('error' in parsedCheck) {
|
|
@@ -2546,19 +2595,26 @@ Options:
|
|
|
2546
2595
|
}
|
|
2547
2596
|
return;
|
|
2548
2597
|
}
|
|
2549
|
-
console.error(`未知子命令: ${sub}\n用法: ec msg [
|
|
2598
|
+
console.error(`未知子命令: ${sub}\n用法: ec msg [request|pull|ack|recall|online|history](发送用 ecmsg send)`);
|
|
2550
2599
|
process.exit(1);
|
|
2551
2600
|
}
|
|
2552
2601
|
// ==================== Group ====================
|
|
2553
2602
|
const GROUP_FROM_AID_FORMAT_EXAMPLE = 'sender.example.invalid';
|
|
2554
2603
|
const GROUP_AID_FORMAT_EXAMPLE = '12345.example.invalid';
|
|
2555
2604
|
function printGroupArgsHint(sub) {
|
|
2556
|
-
|
|
2557
|
-
|
|
2605
|
+
// 托管会话只教 ecmsg;宿主终端的 ecmsg 发不了群(只放行跨话题自派),
|
|
2606
|
+
// 那边给本命令自己的用法。
|
|
2607
|
+
if (sub === 'send' && process.env.EVOLCORE_SESSION_ID) {
|
|
2608
|
+
console.error("正确格式: ecmsg send '<正文>' [--file <path> --as <type>](当前群会话直接发送;跨群用 --thread <群主话题id>)");
|
|
2609
|
+
console.error('查询真实群 AID: ec group list <发送方AID>');
|
|
2610
|
+
return;
|
|
2558
2611
|
}
|
|
2559
|
-
|
|
2560
|
-
console.error(
|
|
2612
|
+
if (sub === 'send') {
|
|
2613
|
+
console.error('正确格式(宿主终端): ec group send <发送方AID> <真实群AID> <正文或文件参数>');
|
|
2614
|
+
console.error('查询真实群 AID: ec group list <发送方AID>');
|
|
2615
|
+
return;
|
|
2561
2616
|
}
|
|
2617
|
+
console.error(`正确格式: ec group ${sub} <发送方AID> <真实群AID> [选项]`);
|
|
2562
2618
|
console.error(`仅格式示例(.example.invalid 是保留的虚构域,不是真实 AID): ec group ${sub} ${GROUP_FROM_AID_FORMAT_EXAMPLE} ${GROUP_AID_FORMAT_EXAMPLE}`);
|
|
2563
2619
|
console.error('顺序固定为「先发送方 AID,后群 AID」;查询真实群 AID: ec group list <发送方AID>');
|
|
2564
2620
|
}
|
|
@@ -2610,10 +2666,7 @@ visitor 不开放历史;群权限仍由托管会话校验。`);
|
|
|
2610
2666
|
console.log(`用法: ec group <command> <from-aid> [args...] [options]
|
|
2611
2667
|
|
|
2612
2668
|
消息:
|
|
2613
|
-
send
|
|
2614
|
-
send <from> <group-id> --file <path> [--as <type>] 发送群文件
|
|
2615
|
-
send <from> <group-id> --payload <json> 发送自定义 payload
|
|
2616
|
-
(托管会话发消息统一用 ecmsg send '<text>' --to <群ID>,见 ecmsg --help)
|
|
2669
|
+
发送群消息统一用 ecmsg send(当前群会话直接发;跨群用 --thread <群主话题id>,见 ecmsg --help)
|
|
2617
2670
|
pull <from> <group-id> [--after-seq N] [--limit N] --app <name> 拉取群消息(必须使用独立 slot)
|
|
2618
2671
|
ack <from> <group-id> <seq> [--app <name>] 确认已读
|
|
2619
2672
|
history <from> <group-id> [options] 查询本地群消息历史(只读)
|
|
@@ -2659,32 +2712,12 @@ Options:
|
|
|
2659
2712
|
--app <name> 指定应用 slot(独立消费通道,不影响 daemon)
|
|
2660
2713
|
--aun-path <path> 指定 AUN keystore 根
|
|
2661
2714
|
--format json 输出 JSON 格式
|
|
2662
|
-
--encrypt 强制端到端加密(未指定时使用 daemon 默认值;仅 send)
|
|
2663
|
-
--no-encrypt 强制明文发送(优先于 --encrypt;仅 send)
|
|
2664
|
-
--thread <id> 指定话题 ID(仅 send;话题必须存在于本端索引)
|
|
2665
|
-
--check-every <时长|none> 跨话题发送(带 --thread)时**必填**,创建跨话题复查(如 5m/30m/2h);none = 不建复查
|
|
2666
|
-
到期向**目标话题**投递【跨话题复查】通知,不新建会话
|
|
2667
|
-
无值时默认 5m;Trigger 名:check-<目标threadId>-from-<来源threadId>-<唯一后缀>
|
|
2668
|
-
结束/调整用返回的 trigger_id(trig_…),show/update/delete 只认 id
|
|
2669
|
-
--trigger-prompt <text> 追加到复查通知正文里的补充说明(仅 --check-every)
|
|
2670
|
-
--mention <...> 发送时 @ 某个成员。单引号包住、逗号分隔多个 aid
|
|
2671
|
-
(如 --mention 'alice.agentid.pub,bob.agentid.pub'),可多次传入
|
|
2672
|
-
--mention-all 发送时 @ 所有人
|
|
2673
|
-
--content-type <mime> 显式覆盖 MIME(仅 --file 模式)
|
|
2674
|
-
--as <type> 附件类型:image|video|voice|file(仅 --file 模式)
|
|
2675
|
-
--text <说明> 附件说明文字(仅 --file 模式)
|
|
2676
|
-
--transcript <text> 语音转写(仅 --as voice)
|
|
2677
2715
|
--group-id <aid> 指定自定义群 AID(仅 create);省略时生成 g- 加五位随机数字
|
|
2678
2716
|
--member-type <type> 定向邀请成员类型:human|agent(仅 invite)
|
|
2679
|
-
--
|
|
2680
|
-
(用于发送恰好等于某 flag 的文本,如 send a g -- --encrypt)
|
|
2717
|
+
history 的筛选选项见 ec group history --help
|
|
2681
2718
|
|
|
2682
2719
|
格式示例(.example.invalid 是保留的虚构域,以下 AID 均不是真实地址):
|
|
2683
2720
|
ec group create sender.example.invalid "Dev Team" --visibility private
|
|
2684
|
-
ec group send sender.example.invalid 12345.example.invalid "hello team"
|
|
2685
|
-
ec group send sender.example.invalid 12345.example.invalid '@member 看下 PR' --mention 'member.example.invalid'
|
|
2686
|
-
ec group send sender.example.invalid 12345.example.invalid --file ./arch.png
|
|
2687
|
-
ec group send sender.example.invalid g-12345.example.invalid "进度?" --thread thread-xxx --check-every 30m
|
|
2688
2721
|
ec group rules sender.example.invalid 12345.example.invalid set ./rules.md
|
|
2689
2722
|
ec group invite sender.example.invalid 12345.example.invalid member.example.invalid
|
|
2690
2723
|
ec group members sender.example.invalid 12345.example.invalid
|
|
@@ -2715,13 +2748,17 @@ g- 是名称的一部分,会完整保留;默认命名格式为 g-10000 至 g
|
|
|
2715
2748
|
renderManagedGroupResult(args, result, formatJson);
|
|
2716
2749
|
return;
|
|
2717
2750
|
}
|
|
2751
|
+
// 同 ec msg send:托管会话的群发只走 ecmsg send(当前群会话省略 --thread,
|
|
2752
|
+
// 跨群用 --thread <群主话题id>);`--as-session` 调试身份例外,理由见 cmdMsg 里同一处判断。
|
|
2753
|
+
if (process.env.EVOLCORE_SESSION_ID && sub === 'send' && !process.env[DEBUG_SESSION_ENV]) {
|
|
2754
|
+
return failManagedGroup(formatJson, 'NOT_ALLOWED', "托管会话发送群消息请用: ecmsg send '<正文>'(当前群会话直接发;跨群用 --thread <群主话题id>,见 ecmsg --help)");
|
|
2755
|
+
}
|
|
2718
2756
|
if (process.env.EVOLCORE_SESSION_ID && sub === 'send') {
|
|
2719
2757
|
if (args.includes('--aun-path') || args.includes('--app')) {
|
|
2720
2758
|
failManagedGroup(formatJson, 'NOT_ALLOWED', '--aun-path and --app are not allowed in a managed task');
|
|
2721
2759
|
}
|
|
2722
|
-
let groupId;
|
|
2723
2760
|
try {
|
|
2724
|
-
|
|
2761
|
+
normalizeGroupAid(args[2] ?? '', from.slice(from.indexOf('.') + 1));
|
|
2725
2762
|
}
|
|
2726
2763
|
catch (error) {
|
|
2727
2764
|
failManagedGroup(formatJson, 'INVALID_ARGUMENT', `Invalid group AID: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -2931,9 +2968,6 @@ g- 是名称的一部分,会完整保留;默认命名格式为 g-10000 至 g
|
|
|
2931
2968
|
index++;
|
|
2932
2969
|
}
|
|
2933
2970
|
}
|
|
2934
|
-
if (optionArgs.includes('--encrypt') && optionArgs.includes('--no-encrypt')) {
|
|
2935
|
-
failManagedGroup(formatJson, 'INVALID_ARGUMENT', '--encrypt 与 --no-encrypt 不能同时使用');
|
|
2936
|
-
}
|
|
2937
2971
|
if ([fileVal, payloadVal, payloadFileVal].filter(Boolean).length > 1) {
|
|
2938
2972
|
failManagedGroup(formatJson, 'INVALID_ARGUMENT', '--file, --payload and --payload-file are mutually exclusive');
|
|
2939
2973
|
}
|
|
@@ -2946,8 +2980,8 @@ g- 是名称的一部分,会完整保留;默认命名格式为 g-10000 至 g
|
|
|
2946
2980
|
let body;
|
|
2947
2981
|
if (fileVal) {
|
|
2948
2982
|
const attachmentType = getSendArgValue('--as');
|
|
2949
|
-
if (attachmentType && !['image', 'video', 'voice', 'file'].includes(attachmentType)) {
|
|
2950
|
-
failManagedGroup(formatJson, 'INVALID_ARGUMENT', `--as 仅支持 image|video|voice|file: ${attachmentType}`);
|
|
2983
|
+
if (attachmentType && !['image', 'video', 'voice', 'file', 'widget_card'].includes(attachmentType)) {
|
|
2984
|
+
failManagedGroup(formatJson, 'INVALID_ARGUMENT', `--as 仅支持 image|video|voice|file|widget_card: ${attachmentType}`);
|
|
2951
2985
|
}
|
|
2952
2986
|
const transcript = getSendArgValue('--transcript');
|
|
2953
2987
|
if (transcript !== undefined && attachmentType !== 'voice') {
|
|
@@ -2960,6 +2994,7 @@ g- 是名称的一部分,会完整保留;默认命名格式为 g-10000 至 g
|
|
|
2960
2994
|
contentType: getSendArgValue('--content-type'),
|
|
2961
2995
|
text: getSendArgValue('--text'),
|
|
2962
2996
|
transcript,
|
|
2997
|
+
title: getSendArgValue('--title'),
|
|
2963
2998
|
};
|
|
2964
2999
|
}
|
|
2965
3000
|
else if (payloadVal) {
|
|
@@ -2990,10 +3025,9 @@ g- 是名称的一部分,会完整保留;默认命名格式为 g-10000 至 g
|
|
|
2990
3025
|
body = { mode: 'text', text };
|
|
2991
3026
|
}
|
|
2992
3027
|
const mentions = collectMentions();
|
|
2993
|
-
//
|
|
2994
|
-
const
|
|
2995
|
-
|
|
2996
|
-
: args.includes('--encrypt') ? true : undefined;
|
|
3028
|
+
// 三态加密:不写 `--encrypt` 就是默认 auto,auto 需要本轮的入站加密态来解析。
|
|
3029
|
+
const groupRuntime = await readBestTaskRuntimeContext();
|
|
3030
|
+
const encryptGroup = readTristateEncrypt(args, groupRuntime?.inboundEncrypted);
|
|
2997
3031
|
const thread = getSendArgValue('--thread');
|
|
2998
3032
|
// M2: 群话题跨话题发送与私聊同样必须指定 --check-every,并同样创建复查 Trigger + 写 inbox。
|
|
2999
3033
|
const groupCheckEveryRaw = getSendArgValue('--check-every');
|
|
@@ -3577,10 +3611,17 @@ g- 是名称的一部分,会完整保留;默认命名格式为 g-10000 至 g
|
|
|
3577
3611
|
}
|
|
3578
3612
|
return;
|
|
3579
3613
|
}
|
|
3580
|
-
console.error(`未知子命令: ${sub}\n用法: ec group [
|
|
3614
|
+
console.error(`未知子命令: ${sub}\n用法: ec group [pull|ack|history|create|list|info|update|dissolve|suspend|resume|rules|mention|join|leave|invite|invites|accept-invite|reject-invite|revoke-invite|kick|members|online|role|owner|ban|unban|block|unblock|blocklist|report-status|member-statuses](发送用 ecmsg send)`);
|
|
3581
3615
|
process.exit(1);
|
|
3582
3616
|
}
|
|
3583
3617
|
// ==================== Main ====================
|
|
3618
|
+
/**
|
|
3619
|
+
* 把发送 argv 交给 daemon 的托管通道(`aun-msg-send`)。
|
|
3620
|
+
*
|
|
3621
|
+
* 只由 `--as-session` 调试身份使用:普通托管会话被入口处挡住、只走 ecmsg,
|
|
3622
|
+
* 而宿主终端没有委托凭证。调试身份两者都有,正好用这条——委托校验与审批
|
|
3623
|
+
* 仍在 daemon 侧完成,调试身份并不绕过任何授权。
|
|
3624
|
+
*/
|
|
3584
3625
|
async function runManagedSend(argv, formatJson) {
|
|
3585
3626
|
const delegationToken = readDelegationCredential();
|
|
3586
3627
|
if (!delegationToken)
|
|
@@ -3615,17 +3656,19 @@ async function runManagedSend(argv, formatJson) {
|
|
|
3615
3656
|
process.stderr.write(`⚠ 复查 Trigger 未创建: ${result.trigger_error}(消息已发出,需要复查请手动 ec trigger create)\n`);
|
|
3616
3657
|
}
|
|
3617
3658
|
}
|
|
3659
|
+
// 这些示例直接进模型上下文(门禁与 CLI 的拒绝提示都会引用),统一给
|
|
3660
|
+
// `ecmsg send` 写法:本端恒为会话本端,接收方由话题和模式推出。
|
|
3618
3661
|
const SEND_BODY_MODE_USAGE = {
|
|
3619
3662
|
msg: {
|
|
3620
|
-
'--file': "
|
|
3621
|
-
'--text-from-file': '
|
|
3622
|
-
'--link': "
|
|
3623
|
-
'--payload': "
|
|
3624
|
-
'--payload-file': '
|
|
3663
|
+
'--file': "ecmsg send --file <path> [--as <type>] [--text '<说明>']",
|
|
3664
|
+
'--text-from-file': 'ecmsg send --text-from-file <path>',
|
|
3665
|
+
'--link': "ecmsg send --link <url> [--title '<title>'] [--description '<desc>']",
|
|
3666
|
+
'--payload': "ecmsg send --payload '<json>'",
|
|
3667
|
+
'--payload-file': 'ecmsg send --payload-file <path>',
|
|
3625
3668
|
},
|
|
3626
3669
|
group: {
|
|
3627
|
-
'--file': "
|
|
3628
|
-
'--payload': "
|
|
3670
|
+
'--file': "ecmsg send --file <path> [--as <type>] [--text '<说明>'] --thread <群主话题id>",
|
|
3671
|
+
'--payload': "ecmsg send --payload '<json>' --thread <群主话题id>",
|
|
3629
3672
|
},
|
|
3630
3673
|
};
|
|
3631
3674
|
function sendBodyModeConflict(scope, modes, hasPositionText) {
|
|
@@ -3668,20 +3711,44 @@ export function resolveManagedSendArgv(argv, routing) {
|
|
|
3668
3711
|
const mentions = [];
|
|
3669
3712
|
const valueFlags = new Set(MANAGED_SEND_VALUE_FLAGS);
|
|
3670
3713
|
const booleanFlags = new Set(MANAGED_SEND_BOOLEAN_FLAGS);
|
|
3714
|
+
const tristateFlags = new Set(MANAGED_SEND_TRISTATE_FLAGS);
|
|
3715
|
+
let encrypt;
|
|
3671
3716
|
for (let index = bodyStart; index < argv.length; index++) {
|
|
3672
3717
|
const flag = argv[index];
|
|
3673
3718
|
if (flag === '--') {
|
|
3674
3719
|
text.push(...argv.slice(index + 1));
|
|
3675
3720
|
break;
|
|
3676
3721
|
}
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3722
|
+
if (tristateFlags.has(flag)) {
|
|
3723
|
+
// 三态取值,必须带 yes|no|auto;裸写是参数错误。
|
|
3724
|
+
const mode = argv[++index];
|
|
3725
|
+
if (!isValidEncryptMode(mode)) {
|
|
3726
|
+
throw new Error(`--encrypt 只接受 yes|no|auto${mode === undefined ? '' : `,收到 ${mode}`}`);
|
|
3727
|
+
}
|
|
3728
|
+
encrypt = mode === 'auto' ? 'auto' : resolveEncryptFlagValue(mode);
|
|
3729
|
+
continue;
|
|
3730
|
+
}
|
|
3731
|
+
// `--to` / `--from` 是**网关**选项。它们不在取值表里,落到下面就会进 text ——
|
|
3732
|
+
// 正文会变成「--to x.agentid.cn 你好」,消息照常送达,于是没人发现发错了。
|
|
3733
|
+
// 这里明确拒绝。
|
|
3734
|
+
//
|
|
3735
|
+
// 提示只教 `ecmsg`:托管会话的唯一发送入口就是它(见 `cmdMsg` 里对
|
|
3736
|
+
// `ec msg send` 的禁用)。绝不能在这里推荐 `ec msg send <from> <to>` 的
|
|
3737
|
+
// 位置参数式——那是内部通道,把模型教过去就等于制造第二套写法,
|
|
3738
|
+
// 模型和文档会永远对不齐。
|
|
3680
3739
|
if (flag === '--to' || flag === '--from') {
|
|
3681
|
-
|
|
3740
|
+
const advice = flag === '--to'
|
|
3741
|
+
? '接收方不再用 --to:当前话题直接省略,跨话题用 `--thread <话题id>`,'
|
|
3742
|
+
+ '自派再加 `--selfmode`'
|
|
3743
|
+
: '托管会话里本端恒等于会话本端,禁止写 `--from`';
|
|
3744
|
+
throw new Error(`${flag} 不是 ec msg send 的参数(它是网关选项)。${advice}`);
|
|
3682
3745
|
}
|
|
3683
3746
|
if (flag === '--app' || flag === '--aun-path')
|
|
3684
3747
|
throw new Error(`${flag} is not allowed for managed sends`);
|
|
3748
|
+
// 未知 `--flag` 会落到下面的 text.push,进而把整串参数当成正文静默发出去。
|
|
3749
|
+
if (flag.startsWith('--') && !valueFlags.has(flag) && !booleanFlags.has(flag) && !tristateFlags.has(flag)) {
|
|
3750
|
+
throw new Error(`未知发送参数:${flag}`);
|
|
3751
|
+
}
|
|
3685
3752
|
if (booleanFlags.has(flag))
|
|
3686
3753
|
booleans.add(flag);
|
|
3687
3754
|
else if (valueFlags.has(flag)) {
|
|
@@ -3704,8 +3771,6 @@ export function resolveManagedSendArgv(argv, routing) {
|
|
|
3704
3771
|
else
|
|
3705
3772
|
text.push(flag);
|
|
3706
3773
|
}
|
|
3707
|
-
if (booleans.has('--encrypt') && booleans.has('--no-encrypt'))
|
|
3708
|
-
throw new Error('Encryption options are mutually exclusive');
|
|
3709
3774
|
if (values.has('--format') && values.get('--format') !== 'json')
|
|
3710
3775
|
throw new Error('--format only supports json');
|
|
3711
3776
|
const returnPolicy = values.get('--return');
|
|
@@ -3752,10 +3817,20 @@ export function resolveManagedSendArgv(argv, routing) {
|
|
|
3752
3817
|
throw new Error('Invalid send target');
|
|
3753
3818
|
const checkEvery = values.get('--check-every');
|
|
3754
3819
|
const triggerPromptExtra = values.get('--trigger-prompt');
|
|
3820
|
+
const selfMode = booleans.has('--selfmode');
|
|
3821
|
+
if (selfMode && !thread)
|
|
3822
|
+
throw new Error('--selfmode requires --thread');
|
|
3823
|
+
if (selfMode && scope === 'group')
|
|
3824
|
+
throw new Error('--selfmode sends the local AID, not a group message');
|
|
3755
3825
|
if (!thread && (checkEvery !== undefined || triggerPromptExtra !== undefined))
|
|
3756
3826
|
throw new Error('Cross-thread options require --thread');
|
|
3827
|
+
// 自派不建复查:不写 thread-inbox、不建 Trigger,周期参数对它没有意义。
|
|
3828
|
+
if (selfMode && (checkEvery !== undefined || triggerPromptExtra !== undefined)) {
|
|
3829
|
+
throw new Error('--selfmode does not create a review trigger; --check-every/--trigger-prompt are not allowed');
|
|
3830
|
+
}
|
|
3757
3831
|
let checkEveryMs;
|
|
3758
|
-
if (thread) {
|
|
3832
|
+
if (thread && !selfMode) {
|
|
3833
|
+
// 委托必须给出复查周期(网关会先补默认 20m);自派没有复查,跳过。
|
|
3759
3834
|
if (checkEvery === undefined)
|
|
3760
3835
|
throw new Error('Cross-thread sends require --check-every (or "none")');
|
|
3761
3836
|
// `none` = 跨话题发送但不建复查 Trigger;checkEveryMs 保持 undefined,下游据此跳过建 Trigger。
|
|
@@ -3783,11 +3858,13 @@ export function resolveManagedSendArgv(argv, routing) {
|
|
|
3783
3858
|
const payloadFile = values.get('--payload-file');
|
|
3784
3859
|
if (values.has('--file')) {
|
|
3785
3860
|
const as = values.get('--as');
|
|
3786
|
-
if (as && !['image', 'video', 'voice', 'file'].includes(as))
|
|
3861
|
+
if (as && !['image', 'video', 'voice', 'file', 'widget_card'].includes(as))
|
|
3787
3862
|
throw new Error('Invalid attachment type');
|
|
3788
3863
|
if (values.has('--transcript') && as !== 'voice')
|
|
3789
3864
|
throw new Error('--transcript requires --as voice');
|
|
3790
|
-
file = { filePath: values.get('--file'), as, contentType: values.get('--content-type'), text: values.get('--text'), transcript: values.get('--transcript') };
|
|
3865
|
+
file = { filePath: values.get('--file'), as, contentType: values.get('--content-type'), text: values.get('--text'), transcript: values.get('--transcript'), title: values.get('--title') };
|
|
3866
|
+
if (as === 'widget_card' && returnPolicy === 'required')
|
|
3867
|
+
throw new Error('WidgetCard replies use widget_card_reply, not --return required');
|
|
3791
3868
|
}
|
|
3792
3869
|
else if (values.has('--payload')) {
|
|
3793
3870
|
payload = parseJsonObjectArgument(values.get('--payload'));
|
|
@@ -3809,8 +3886,8 @@ export function resolveManagedSendArgv(argv, routing) {
|
|
|
3809
3886
|
const deviceId = resolveAunSendDevice(values.get('--device-id'), scope, payload);
|
|
3810
3887
|
return { aid, to, scope, payload, rawPayload: values.has('--payload') || values.has('--payload-file'), file, textFile: values.get('--text-from-file'), payloadFile,
|
|
3811
3888
|
deviceId,
|
|
3812
|
-
encrypt
|
|
3813
|
-
thread, checkEvery, checkEveryMs: checkEveryMs ?? undefined, triggerPromptExtra, returnPolicy: returnPolicy, timeoutMs, handoffContext,
|
|
3889
|
+
encrypt,
|
|
3890
|
+
thread, selfMode: selfMode || undefined, checkEvery, checkEveryMs: checkEveryMs ?? undefined, triggerPromptExtra, returnPolicy: returnPolicy, timeoutMs, handoffContext,
|
|
3814
3891
|
mentions: mentions.length ? mentions : undefined };
|
|
3815
3892
|
}
|
|
3816
3893
|
/**
|
|
@@ -3838,8 +3915,40 @@ const VALUE_FLAGS = new Set([
|
|
|
3838
3915
|
'--check-every', '--trigger-prompt',
|
|
3839
3916
|
]);
|
|
3840
3917
|
const BOOLEAN_FLAGS = new Set([
|
|
3841
|
-
'--
|
|
3918
|
+
'--mention-all', '--clear',
|
|
3842
3919
|
]);
|
|
3920
|
+
/** 三态取值选项:取值必须显式给出,随 flag 一起跳过。 */
|
|
3921
|
+
const TRISTATE_FLAGS = new Set(['--encrypt']);
|
|
3922
|
+
/**
|
|
3923
|
+
* 从 argv 读取 `--encrypt yes|no|auto`。
|
|
3924
|
+
*
|
|
3925
|
+
* 只有三态:裸写是参数错误。不写 `--encrypt` 时返回 undefined,
|
|
3926
|
+
* 语义就是默认值 `auto`——由调用方按「本轮是否被对端消息触发」解析,
|
|
3927
|
+
* 不能当成明文,更不能当成 `yes`。
|
|
3928
|
+
*/
|
|
3929
|
+
function readTristateEncrypt(args, inboundEncrypted) {
|
|
3930
|
+
for (let index = 0; index < args.length; index++) {
|
|
3931
|
+
if (args[index] === '--')
|
|
3932
|
+
break;
|
|
3933
|
+
if (args[index] !== '--encrypt')
|
|
3934
|
+
continue;
|
|
3935
|
+
const mode = args[++index];
|
|
3936
|
+
if (!isValidEncryptMode(mode)) {
|
|
3937
|
+
throw new Error(`--encrypt 只接受 yes|no|auto${mode === undefined ? '' : `,收到 ${mode}`}`);
|
|
3938
|
+
}
|
|
3939
|
+
return mode === 'auto' ? resolveAutoEncrypt(inboundEncrypted) : resolveEncryptFlagValue(mode);
|
|
3940
|
+
}
|
|
3941
|
+
// 完全没写 --encrypt:默认 auto。
|
|
3942
|
+
return resolveAutoEncrypt(inboundEncrypted);
|
|
3943
|
+
}
|
|
3944
|
+
/**
|
|
3945
|
+
* `auto` 的解析:被对端消息触发时沿用该消息的加密状态,否则明文。
|
|
3946
|
+
*
|
|
3947
|
+
* 与 `resolveSendRoute` 的 auto 语义一致;这里只服务不走网关的老命令。
|
|
3948
|
+
*/
|
|
3949
|
+
function resolveAutoEncrypt(inboundEncrypted) {
|
|
3950
|
+
return inboundEncrypted === true;
|
|
3951
|
+
}
|
|
3843
3952
|
function collectPositional(args, startIdx, extraValueFlags) {
|
|
3844
3953
|
const out = [];
|
|
3845
3954
|
let endOfFlags = false;
|
|
@@ -3857,6 +3966,11 @@ function collectPositional(args, startIdx, extraValueFlags) {
|
|
|
3857
3966
|
i++;
|
|
3858
3967
|
continue;
|
|
3859
3968
|
} // 精确匹配取值 flag:跳过其值
|
|
3969
|
+
if (TRISTATE_FLAGS.has(a)) { // 三态 flag:其取值既不是正文,也不参与位置参数
|
|
3970
|
+
if (isValidEncryptMode(args[i + 1]))
|
|
3971
|
+
i++;
|
|
3972
|
+
continue;
|
|
3973
|
+
}
|
|
3860
3974
|
if (BOOLEAN_FLAGS.has(a)) {
|
|
3861
3975
|
continue;
|
|
3862
3976
|
} // 精确匹配开关 flag:仅跳过自身
|