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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import {
|
|
3
|
+
import { requireTrustedWindowsShellExecutable, WindowsShellTrustError } from '../../utils/windows-shell-trust.js';
|
|
4
|
+
import { parseRemoteCommand } from '../../ability/caller/command.js';
|
|
4
5
|
export function parseJsonObjectArgument(raw, optionName = '--payload') {
|
|
5
6
|
let parsed;
|
|
6
7
|
try {
|
|
@@ -371,7 +372,7 @@ const EVOLCORE_EXECUTABLE_ALIASES = new Set(['ec', 'ec.cmd', 'ec.exe', 'ec.ps1']
|
|
|
371
372
|
* 轻量发送入口 `ecmsg` 的前缀映射:`ecmsg <args...>` 等价于 `ec msg <args...>`。
|
|
372
373
|
*
|
|
373
374
|
* 必须在这里归一,不能只做一个独立脚本——委托审批是按规范化 argv 的哈希
|
|
374
|
-
* arm 的(
|
|
375
|
+
* arm 的(Codex runner 的 armApprovedDelegationCommand)。若 `ecmsg` 不归一到
|
|
375
376
|
* `['ec','msg',...]`,策略层会把它当普通命令(kind: 'none'),既不 arm 审批,
|
|
376
377
|
* daemon 侧也算不出匹配的哈希,最终必然 INVALID_DELEGATION;更糟的是它会绕过
|
|
377
378
|
* ec_shell_composite_command 与会话身份绑定,成为冒充发送的后门。
|
|
@@ -391,12 +392,13 @@ const EVOLCORE_SUBCOMMANDS = new Set([
|
|
|
391
392
|
'mode', 'model', 'msg', 'mv', 'net', 'queue', 'response', 'restart',
|
|
392
393
|
'restart-monitor', 'rpc', 'start', 'stats', 'status', 'stop', 'storage', 'task',
|
|
393
394
|
'trigger', 'proxy', 'version', 'watch', 'session', 'team', 'upgrade', 'update',
|
|
394
|
-
'directory', 'getmeta', 'integrity', 'invoke', 'memory', 'provider', 'role', 'skill', 'thread',
|
|
395
|
+
'directory', 'getmeta', 'integrity', 'invoke', 'memory', 'provider', 'plugin', 'role', 'skill', 'thread', 'pay',
|
|
395
396
|
]);
|
|
396
397
|
// Development/install entrypoints that are part of this repository's CLI.
|
|
397
398
|
// Only these exact relative paths are canonicalized; arbitrary Node scripts
|
|
398
399
|
// must never become an EC command merely because their filename is similar.
|
|
399
|
-
const EVOLCORE_NODE_WRAPPER_PATHS = new Set(['bin/ec.js', 'dist/cli/index.js']);
|
|
400
|
+
const EVOLCORE_NODE_WRAPPER_PATHS = new Set(['bin/ec.js', 'dist/cli/index.js', 'bin/ecmsg.js']);
|
|
401
|
+
const ECMSG_NODE_PREFIX = /^node(?:\.exe)?[ \t]+(['"]?)(?:\.[\\/])?bin[\\/]ecmsg\.js\1(?=$|\s|[;&|`()<>])/i;
|
|
400
402
|
const SHELL_UNQUOTED_META = new Set([
|
|
401
403
|
';', '&', '|', '`', '<', '>', '$', '(', ')', '*', '?', '[', ']', '{', '}', '#',
|
|
402
404
|
]);
|
|
@@ -448,15 +450,18 @@ function stripHeredocBodies(command) {
|
|
|
448
450
|
// never establish an EC invocation.
|
|
449
451
|
const POWERSHELL_ASSIGNMENT_PREFIX = /^\$(?:[A-Za-z_][\w:]*|\{[^{}\r\n]+\})\s*=(?!=)/u;
|
|
450
452
|
function hasEcCommandPrefix(command, dialect = 'posix') {
|
|
453
|
+
const posix = dialect === 'posix';
|
|
451
454
|
let quote = null;
|
|
452
455
|
let escaped = false;
|
|
453
456
|
let boundary = true;
|
|
457
|
+
let wordBoundary = true;
|
|
454
458
|
const powerShell = dialect === 'powershell';
|
|
455
459
|
for (let index = 0; index < command.length; index++) {
|
|
456
460
|
const char = command[index];
|
|
457
461
|
if (escaped) {
|
|
458
462
|
escaped = false;
|
|
459
463
|
boundary = false;
|
|
464
|
+
wordBoundary = false;
|
|
460
465
|
continue;
|
|
461
466
|
}
|
|
462
467
|
if (quote === 'single') {
|
|
@@ -477,6 +482,15 @@ function hasEcCommandPrefix(command, dialect = 'posix') {
|
|
|
477
482
|
quote = null;
|
|
478
483
|
continue;
|
|
479
484
|
}
|
|
485
|
+
if (posix && char === '\\') {
|
|
486
|
+
// A continued line does not end a command or word. Other escaped
|
|
487
|
+
// characters are word data, including whitespace and separators.
|
|
488
|
+
if (command[index + 1] === '\n')
|
|
489
|
+
index++;
|
|
490
|
+
else
|
|
491
|
+
escaped = true;
|
|
492
|
+
continue;
|
|
493
|
+
}
|
|
480
494
|
if (powerShell && char === '`') {
|
|
481
495
|
escaped = true;
|
|
482
496
|
continue;
|
|
@@ -488,7 +502,8 @@ function hasEcCommandPrefix(command, dialect = 'posix') {
|
|
|
488
502
|
index = end + 1;
|
|
489
503
|
continue;
|
|
490
504
|
}
|
|
491
|
-
if (
|
|
505
|
+
if (char === '#' && (posix && wordBoundary
|
|
506
|
+
|| powerShell && (index === 0 || /\s/.test(command[index - 1])))) {
|
|
492
507
|
const end = command.indexOf('\n', index);
|
|
493
508
|
if (end < 0)
|
|
494
509
|
return false;
|
|
@@ -507,23 +522,28 @@ function hasEcCommandPrefix(command, dialect = 'posix') {
|
|
|
507
522
|
if (powerShell ? isPowerShellSingleQuote(char) : char === "'") {
|
|
508
523
|
quote = 'single';
|
|
509
524
|
boundary = false;
|
|
525
|
+
wordBoundary = false;
|
|
510
526
|
continue;
|
|
511
527
|
}
|
|
512
528
|
if (powerShell ? isPowerShellDoubleQuote(char) : char === '"') {
|
|
513
529
|
quote = 'double';
|
|
514
530
|
boundary = false;
|
|
531
|
+
wordBoundary = false;
|
|
515
532
|
continue;
|
|
516
533
|
}
|
|
517
534
|
if (powerShell && /[{}\r\n]/.test(char)) {
|
|
518
535
|
boundary = true;
|
|
519
536
|
continue;
|
|
520
537
|
}
|
|
521
|
-
if (/[;&|`()<>]/.test(char)) {
|
|
538
|
+
if (posix && char === '\n' || /[;&|`()<>]/.test(char)) {
|
|
522
539
|
boundary = true;
|
|
540
|
+
wordBoundary = true;
|
|
523
541
|
continue;
|
|
524
542
|
}
|
|
525
|
-
if (
|
|
543
|
+
if (/\s/.test(char)) {
|
|
544
|
+
wordBoundary = !posix || char === ' ' || char === '\t';
|
|
526
545
|
continue;
|
|
546
|
+
}
|
|
527
547
|
if (boundary && powerShell && char === '$') {
|
|
528
548
|
const assignment = POWERSHELL_ASSIGNMENT_PREFIX.exec(command.slice(index));
|
|
529
549
|
if (assignment) {
|
|
@@ -537,7 +557,10 @@ function hasEcCommandPrefix(command, dialect = 'posix') {
|
|
|
537
557
|
// `ecmsg ... && rm -rf /` 会落成 kind:'none',绕过复合命令拦截。
|
|
538
558
|
if (boundary && /^ecmsg(?:\.cmd|\.exe|\.ps1)?(?=$|\s|[;&|`()<>])/i.test(command.slice(index)))
|
|
539
559
|
return true;
|
|
560
|
+
if (boundary && ECMSG_NODE_PREFIX.test(command.slice(index)))
|
|
561
|
+
return true;
|
|
540
562
|
boundary = false;
|
|
563
|
+
wordBoundary = false;
|
|
541
564
|
}
|
|
542
565
|
return false;
|
|
543
566
|
}
|
|
@@ -843,9 +866,12 @@ export function normalizeEvolcoreCommandArgv(argv) {
|
|
|
843
866
|
if (entryAlias && EVOLCORE_MSG_ENTRY_ALIASES.has(entryAlias)) {
|
|
844
867
|
return ['ec', 'msg', ...materialized.slice(1)];
|
|
845
868
|
}
|
|
846
|
-
if (typeof executable === 'string' && isNodeExecutable(executable) && materialized
|
|
847
|
-
|
|
848
|
-
|
|
869
|
+
if (typeof executable === 'string' && isNodeExecutable(executable) && typeof materialized[1] === 'string') {
|
|
870
|
+
const wrapper = normalizeNodeWrapperPath(materialized[1]);
|
|
871
|
+
if (wrapper === 'bin/ecmsg.js')
|
|
872
|
+
return ['ec', 'msg', ...materialized.slice(2)];
|
|
873
|
+
if (wrapper)
|
|
874
|
+
return ['ec', ...materialized.slice(2)];
|
|
849
875
|
}
|
|
850
876
|
return materialized;
|
|
851
877
|
}
|
|
@@ -917,7 +943,7 @@ const INLINE_TEXT_FLAGS = {
|
|
|
917
943
|
const MESSAGE_POSITIONAL_FLAGS = new Set([
|
|
918
944
|
'--file', '--payload', '--payload-file', '--as', '--content-type', '--text', '--transcript',
|
|
919
945
|
'--thread', '--title', '--description', '--text-from-file',
|
|
920
|
-
'--handoff-context', '--aun-path', '--app', '--format', '--encrypt',
|
|
946
|
+
'--handoff-context', '--aun-path', '--app', '--format', '--encrypt',
|
|
921
947
|
'--return', '--timeout',
|
|
922
948
|
]);
|
|
923
949
|
/** Decode the EC inline text contract exactly once, after shell parsing. */
|
|
@@ -1039,7 +1065,7 @@ function canonicalizeCommaOnlyFlags(argv, flags) {
|
|
|
1039
1065
|
index++;
|
|
1040
1066
|
}
|
|
1041
1067
|
}
|
|
1042
|
-
const LOCAL_FILE_VALUE_FLAGS = new Set(['--file', '--text-from-file', '--payload-file']);
|
|
1068
|
+
const LOCAL_FILE_VALUE_FLAGS = new Set(['--file', '--text-from-file', '--payload-file', '--params-file']);
|
|
1043
1069
|
function normalizeWindowsFilePath(value) {
|
|
1044
1070
|
if (process.platform !== 'win32' || !/^[A-Za-z]:[\\/]/u.test(value))
|
|
1045
1071
|
return value;
|
|
@@ -1049,7 +1075,7 @@ function canonicalizeLocalFilePathFlags(argv) {
|
|
|
1049
1075
|
for (let index = 2; index < argv.length; index++) {
|
|
1050
1076
|
if (argv[index] === '--')
|
|
1051
1077
|
break;
|
|
1052
|
-
const inline = argv[index].match(/^(--(?:file|text-from-file|payload-file))=(.*)$/u);
|
|
1078
|
+
const inline = argv[index].match(/^(--(?:file|text-from-file|payload-file|params-file))=(.*)$/u);
|
|
1053
1079
|
if (inline) {
|
|
1054
1080
|
argv[index] = `${inline[1]}=${normalizeWindowsFilePath(inline[2])}`;
|
|
1055
1081
|
continue;
|
|
@@ -1218,12 +1244,20 @@ function unwrapPowerShellCredentialPrefix(command) {
|
|
|
1218
1244
|
}
|
|
1219
1245
|
export function parseCodexCarrierCommand(carrier, options = {}) {
|
|
1220
1246
|
if (options.verifyShellExecutable) {
|
|
1221
|
-
if (!carrier.executable) {
|
|
1222
|
-
return parseFailure('untrusted-shell', carrier.command, 0, 0, carrier.dialect);
|
|
1223
|
-
}
|
|
1224
1247
|
const kind = carrier.dialect === 'posix' ? 'bash' : carrier.dialect;
|
|
1225
|
-
|
|
1226
|
-
|
|
1248
|
+
try {
|
|
1249
|
+
if (!carrier.executable) {
|
|
1250
|
+
throw new WindowsShellTrustError('SHELL_PATH_UNRESOLVED', 'Shell carrier 缺少可执行文件路径');
|
|
1251
|
+
}
|
|
1252
|
+
requireTrustedWindowsShellExecutable(carrier.executable, kind);
|
|
1253
|
+
}
|
|
1254
|
+
catch (error) {
|
|
1255
|
+
const failure = error instanceof WindowsShellTrustError ? error
|
|
1256
|
+
: new WindowsShellTrustError('SHELL_TRUST_CHECK_FAILED', error instanceof Error ? error.message : String(error), { path: carrier.executable }, error);
|
|
1257
|
+
return {
|
|
1258
|
+
...parseFailure('untrusted-shell', carrier.command, 0, 0, carrier.dialect),
|
|
1259
|
+
shellTrustFailure: { reason: failure.reason, message: failure.message, diagnostics: failure.diagnostics },
|
|
1260
|
+
};
|
|
1227
1261
|
}
|
|
1228
1262
|
}
|
|
1229
1263
|
if (carrier.parseFailure)
|
|
@@ -1291,7 +1325,8 @@ export function parseCodexCarrierCommand(carrier, options = {}) {
|
|
|
1291
1325
|
: parsed;
|
|
1292
1326
|
}
|
|
1293
1327
|
export function literalShellParseRemedy(failure) {
|
|
1294
|
-
if (failure.issue === 'shell-composition'
|
|
1328
|
+
if (failure.issue === 'shell-composition'
|
|
1329
|
+
|| failure.issue === 'structural-newline' && failure.dialect === 'posix') {
|
|
1295
1330
|
return '一次调用只执行一条完整命令;查询和操作请拆成独立工具调用,不要拼接管道、重定向、分号或子表达式。';
|
|
1296
1331
|
}
|
|
1297
1332
|
if (failure.dialect === 'posix' && failure.issue === 'unsupported-escape') {
|
|
@@ -2985,13 +3020,13 @@ export function parseBoundedOutputShellCommand(command, options = {}) {
|
|
|
2985
3020
|
// 所以两种情况都切在 operators[0].start,绝不能按 end 切——那会把 `2>&1` 混进 argv。
|
|
2986
3021
|
const first = operators[0];
|
|
2987
3022
|
const sourceText = trimShellSpacing(input.slice(0, first.start));
|
|
3023
|
+
// 源命令允许 `$TMPDIR` 作**参数**(`--spec-file $TMPDIR/x.json`):
|
|
3024
|
+
// 它已被换成哨兵串,不会在 spawn 时被再次展开,最终路径由 policy 层
|
|
3025
|
+
// 用本会话 TMPDIR 还原并校验。限制只针对重定向目标——那是替另一条命令
|
|
3026
|
+
// 指定写入位置,不能借 `$TMPDIR` 表达(见下面 redirect 分支)。
|
|
2988
3027
|
const argv = parseLiteralShellArgv(sourceText, literalOptions);
|
|
2989
3028
|
if (!argv)
|
|
2990
3029
|
return null;
|
|
2991
|
-
// `$TMPDIR` is a transport-level path reference, never an argument
|
|
2992
|
-
// expansion for the privileged command itself.
|
|
2993
|
-
if (argv.some(value => value.includes(MANAGED_TMPDIR_TOKEN)))
|
|
2994
|
-
return null;
|
|
2995
3030
|
const filterChain = [];
|
|
2996
3031
|
let outputPath;
|
|
2997
3032
|
let discardStdout = false;
|
|
@@ -3042,8 +3077,18 @@ export function parseBoundedOutputShellCommand(command, options = {}) {
|
|
|
3042
3077
|
prevEnd = segmentEnd;
|
|
3043
3078
|
cursor++;
|
|
3044
3079
|
}
|
|
3080
|
+
// 源命令参数里的 `$TMPDIR` 已在 tokenize 阶段换成哨兵串(literalOptions
|
|
3081
|
+
// 关掉了 allowManagedTmpDir,避免它被当成展开放行)。这里必须显式还原成
|
|
3082
|
+
// 本会话的真实 TMPDIR,否则下游 spawn 会拿到字面量哨兵。
|
|
3083
|
+
// 没有 managedTempDir 就无从还原 → 拒绝,不能让 `$TMPDIR` 逃进 argv。
|
|
3084
|
+
const needsRestore = argv.some(value => value.includes(MANAGED_TMPDIR_TOKEN));
|
|
3085
|
+
if (needsRestore && !options.managedTempDir)
|
|
3086
|
+
return null;
|
|
3087
|
+
const restoredArgv = needsRestore
|
|
3088
|
+
? argv.map(value => restoreManagedTmpDirToken(value, options.managedTempDir))
|
|
3089
|
+
: argv;
|
|
3045
3090
|
return {
|
|
3046
|
-
argv,
|
|
3091
|
+
argv: restoredArgv,
|
|
3047
3092
|
mergeStderr,
|
|
3048
3093
|
...(discardStdout ? { discardStdout } : {}),
|
|
3049
3094
|
...(discardStderr ? { discardStderr } : {}),
|
|
@@ -3214,7 +3259,10 @@ export function classifyEvolcoreShellCommand(command, options = {}) {
|
|
|
3214
3259
|
return { kind: 'literal' };
|
|
3215
3260
|
if (!nested.ok && (hasCarrierEcCommandPrefix(stringCarrier.command, stringCarrier.dialect)
|
|
3216
3261
|
|| (stringCarrier.dialect === 'powershell' && hasPowerShellCredentialAssignment(stringCarrier.command)))) {
|
|
3217
|
-
return {
|
|
3262
|
+
return {
|
|
3263
|
+
kind: 'composite', issue: nested.issue,
|
|
3264
|
+
...(nested.shellTrustFailure ? { shellTrustFailure: nested.shellTrustFailure } : {}),
|
|
3265
|
+
};
|
|
3218
3266
|
}
|
|
3219
3267
|
return { kind: 'none' };
|
|
3220
3268
|
}
|
|
@@ -3234,7 +3282,10 @@ export function classifyEvolcoreShellCommand(command, options = {}) {
|
|
|
3234
3282
|
return { kind: 'literal' };
|
|
3235
3283
|
if (!nested.ok && (hasCarrierEcCommandPrefix(carrier.command, carrier.dialect)
|
|
3236
3284
|
|| (carrier.dialect === 'powershell' && hasPowerShellCredentialAssignment(carrier.command)))) {
|
|
3237
|
-
return {
|
|
3285
|
+
return {
|
|
3286
|
+
kind: 'composite', issue: nested.issue,
|
|
3287
|
+
...(nested.shellTrustFailure ? { shellTrustFailure: nested.shellTrustFailure } : {}),
|
|
3288
|
+
};
|
|
3238
3289
|
}
|
|
3239
3290
|
}
|
|
3240
3291
|
const malformedCmdBody = extractCodexCmdCarrierBody(stripped);
|
|
@@ -3316,7 +3367,23 @@ export function resolveCanonicalEvolcoreToolInput(input, options = {}) {
|
|
|
3316
3367
|
...(dialect ? { dialect } : {}),
|
|
3317
3368
|
...(carrier?.posixShell ? { posixShell: carrier.posixShell } : {}),
|
|
3318
3369
|
};
|
|
3319
|
-
const
|
|
3370
|
+
const intent = classifyEvolcoreShellCommand(command, { ...parseOptions, verifyShellExecutable: false });
|
|
3371
|
+
// Ordinary shell commands do not request the privileged EC path. Their
|
|
3372
|
+
// approval and filesystem rules must not depend on EC carrier signatures.
|
|
3373
|
+
const ecParseOptions = {
|
|
3374
|
+
...parseOptions,
|
|
3375
|
+
verifyShellExecutable: options.verifyShellExecutable === true
|
|
3376
|
+
&& (intent.kind !== 'none'
|
|
3377
|
+
|| carrier?.dialect === 'powershell' && hasPowerShellCredentialAssignment(command)),
|
|
3378
|
+
};
|
|
3379
|
+
const classification = ecParseOptions.verifyShellExecutable
|
|
3380
|
+
? classifyEvolcoreShellCommand(command, ecParseOptions) : intent;
|
|
3381
|
+
const parsed = carrier
|
|
3382
|
+
? parseCodexCarrierCommand(carrier, ecParseOptions)
|
|
3383
|
+
: parseCodexToolCommand(input, ecParseOptions);
|
|
3384
|
+
// Validate the outer carrier before accepting a bounded-output rewrite too.
|
|
3385
|
+
if (!parsed.ok && parsed.issue === 'untrusted-shell')
|
|
3386
|
+
return { kind: 'invalid', failure: parsed };
|
|
3320
3387
|
if (!carrier?.parseFailure
|
|
3321
3388
|
&& (classification.kind === 'bounded-output' || classification.kind === 'cd-prefixed')) {
|
|
3322
3389
|
if (normalizeEvolcoreCommandArgv(classification.command.argv)[0] !== 'ec')
|
|
@@ -3330,9 +3397,6 @@ export function resolveCanonicalEvolcoreToolInput(input, options = {}) {
|
|
|
3330
3397
|
});
|
|
3331
3398
|
return { kind: 'ec', spec };
|
|
3332
3399
|
}
|
|
3333
|
-
const parsed = carrier
|
|
3334
|
-
? parseCodexCarrierCommand(carrier, parseOptions)
|
|
3335
|
-
: parseCodexToolCommand(input, parseOptions);
|
|
3336
3400
|
if (parsed.ok && normalizeEvolcoreCommandArgv(parsed.argv)[0] === 'ec') {
|
|
3337
3401
|
const spec = buildCanonicalEvolcoreExecutionSpec({
|
|
3338
3402
|
argv: parsed.argv,
|
|
@@ -3351,8 +3415,12 @@ export function resolveCanonicalEvolcoreToolInput(input, options = {}) {
|
|
|
3351
3415
|
? parseFailure(classification.issue, command, 0, 0, dialect ?? 'posix')
|
|
3352
3416
|
: parsed,
|
|
3353
3417
|
};
|
|
3354
|
-
|
|
3418
|
+
// Match the classifier's treatment of heredoc data in this fallback too.
|
|
3419
|
+
const prefixCommand = !dialect || dialect === 'posix' ? stripHeredocBodies(command) : command;
|
|
3420
|
+
if (!parsed.ok && (hasEcCommandPrefix(prefixCommand, dialect)
|
|
3421
|
+
|| carrier?.dialect === 'powershell' && hasPowerShellCredentialAssignment(command))) {
|
|
3355
3422
|
return { kind: 'invalid', failure: parsed };
|
|
3423
|
+
}
|
|
3356
3424
|
return { kind: 'not-ec' };
|
|
3357
3425
|
}
|
|
3358
3426
|
function isDeterministicFilePath(value) {
|
|
@@ -3395,8 +3463,20 @@ const PROACTIVE_SEND_VALUE_FLAGS = new Set([
|
|
|
3395
3463
|
'--check-every', '--trigger-prompt', '--return', '--timeout',
|
|
3396
3464
|
]);
|
|
3397
3465
|
const PROACTIVE_SEND_BOOLEAN_FLAGS = new Set([
|
|
3398
|
-
'--
|
|
3466
|
+
'--mention-all', '--selfmode',
|
|
3467
|
+
]);
|
|
3468
|
+
/**
|
|
3469
|
+
* 三态取值选项:`--encrypt yes|no|auto`,必须带取值;不写该参数才是默认 `auto`。
|
|
3470
|
+
*
|
|
3471
|
+
* 必须单独成一类而不是并进取值表:并进取值表会让裸 `--encrypt` 因缺值被判失败,
|
|
3472
|
+
* 并进布尔表则会把 `--encrypt yes` 的 `yes` 读成正文,和 `--payload-file`
|
|
3473
|
+
* 撞成正文冲突——那正是文档示例被判违规、重试后触发熔断的原因。
|
|
3474
|
+
*/
|
|
3475
|
+
const PROACTIVE_SEND_TRISTATE_FLAGS = new Set([
|
|
3476
|
+
'--encrypt',
|
|
3399
3477
|
]);
|
|
3478
|
+
/** `--encrypt` 的合法取值,与 send-options 的 ENCRYPT_MODES 同口径。 */
|
|
3479
|
+
const PROACTIVE_ENCRYPT_MODES = new Set(['yes', 'no', 'auto']);
|
|
3400
3480
|
const SEND_CONTENT_VALUE_FLAGS = new Set([
|
|
3401
3481
|
'--payload', '--title', '--description', '--text', '--transcript', '--handoff-context',
|
|
3402
3482
|
]);
|
|
@@ -3457,6 +3537,13 @@ export function containsLiteralManagedTmpDirOutsideSendContent(argv) {
|
|
|
3457
3537
|
endOfOptions = true;
|
|
3458
3538
|
continue;
|
|
3459
3539
|
}
|
|
3540
|
+
if (PROACTIVE_SEND_TRISTATE_FLAGS.has(value)) {
|
|
3541
|
+
// 三态选项的取值不是正文:`--encrypt yes` 的 `yes` 必须和 flag 一起跳过。
|
|
3542
|
+
const next = argv[index + 1];
|
|
3543
|
+
if (next !== undefined && PROACTIVE_ENCRYPT_MODES.has(next))
|
|
3544
|
+
index++;
|
|
3545
|
+
continue;
|
|
3546
|
+
}
|
|
3460
3547
|
if (PROACTIVE_SEND_BOOLEAN_FLAGS.has(value))
|
|
3461
3548
|
continue;
|
|
3462
3549
|
if (PROACTIVE_SEND_VALUE_FLAGS.has(value)) {
|
|
@@ -3498,6 +3585,15 @@ export function isReadOnlyEcCommand(toolName, input) {
|
|
|
3498
3585
|
return false;
|
|
3499
3586
|
if (argv.includes('--help') || argv.includes('-h'))
|
|
3500
3587
|
return true;
|
|
3588
|
+
if (argv[1] === 'ability' && argv[2] === 'remote') {
|
|
3589
|
+
try {
|
|
3590
|
+
const command = parseRemoteCommand(argv.slice(1));
|
|
3591
|
+
return ['list', 'info', 'devices', 'result'].includes(command.action) || command.action === 'call' && command.options['dry-run'] === 'true';
|
|
3592
|
+
}
|
|
3593
|
+
catch {
|
|
3594
|
+
return false;
|
|
3595
|
+
}
|
|
3596
|
+
}
|
|
3501
3597
|
const head = `${argv[1] ?? ''}.${argv[2] ?? ''}`;
|
|
3502
3598
|
return READ_ONLY_SUBCOMMANDS.has(head);
|
|
3503
3599
|
}
|
|
@@ -3505,9 +3601,9 @@ export function isReadOnlyEcCommand(toolName, input) {
|
|
|
3505
3601
|
export function containsUnresolvedManagedTmpDirReference(argv) {
|
|
3506
3602
|
return argv.some(value => /(?:\\\$TMPDIR|\\\$\{TMPDIR\})/i.test(value));
|
|
3507
3603
|
}
|
|
3508
|
-
function
|
|
3604
|
+
function diagnoseProactiveSendPayload(argv, scope, bodyStart = 5, options = {}) {
|
|
3509
3605
|
if (!argv || argv[0] !== 'ec' || argv[1] !== scope || argv[2] !== 'send')
|
|
3510
|
-
return false;
|
|
3606
|
+
return { ok: false, problem: 'not_send_command' };
|
|
3511
3607
|
const positionals = [];
|
|
3512
3608
|
const modes = new Map();
|
|
3513
3609
|
let endOfOptions = false;
|
|
@@ -3521,6 +3617,16 @@ function hasExecutableProactiveSendPayload(argv, scope, bodyStart = 5, options =
|
|
|
3521
3617
|
endOfOptions = true;
|
|
3522
3618
|
continue;
|
|
3523
3619
|
}
|
|
3620
|
+
if (PROACTIVE_SEND_TRISTATE_FLAGS.has(value)) {
|
|
3621
|
+
// 三态取值:必须紧跟 yes|no|auto。裸写是参数错误,不能落到下面的
|
|
3622
|
+
// 「未知 --flag」分支——那里会把下一个词当正文吞掉,判定就失真了。
|
|
3623
|
+
const next = argv[index + 1];
|
|
3624
|
+
if (next === undefined || !PROACTIVE_ENCRYPT_MODES.has(next)) {
|
|
3625
|
+
return { ok: false, problem: 'encrypt_mode_invalid', detail: value };
|
|
3626
|
+
}
|
|
3627
|
+
index++;
|
|
3628
|
+
continue;
|
|
3629
|
+
}
|
|
3524
3630
|
if (PROACTIVE_SEND_BOOLEAN_FLAGS.has(value))
|
|
3525
3631
|
continue;
|
|
3526
3632
|
if (!PROACTIVE_SEND_VALUE_FLAGS.has(value)) {
|
|
@@ -3536,68 +3642,120 @@ function hasExecutableProactiveSendPayload(argv, scope, bodyStart = 5, options =
|
|
|
3536
3642
|
}
|
|
3537
3643
|
const operand = argv[++index];
|
|
3538
3644
|
if (operand === undefined || operand.startsWith('--'))
|
|
3539
|
-
return false;
|
|
3645
|
+
return { ok: false, problem: 'missing_operand', detail: value };
|
|
3540
3646
|
if (value === '--file' || value === '--text-from-file') {
|
|
3541
3647
|
// 文件附件同样是向对端的意图表达:它和正文一起出现时不改变语义,
|
|
3542
3648
|
// 单独出现时也把内容真实投递给了对端。只保留路径的确定性校验。
|
|
3543
|
-
if (!options.allowAttachment
|
|
3544
|
-
return false;
|
|
3649
|
+
if (!options.allowAttachment)
|
|
3650
|
+
return { ok: false, problem: 'attachment_not_allowed', detail: value };
|
|
3651
|
+
if (!isDeterministicFilePath(operand))
|
|
3652
|
+
return { ok: false, problem: 'file_path_uncertain', detail: operand };
|
|
3545
3653
|
if (modes.has('file'))
|
|
3546
|
-
return false;
|
|
3654
|
+
return { ok: false, problem: 'duplicate_file', detail: value };
|
|
3547
3655
|
modes.set('file', operand);
|
|
3548
3656
|
continue;
|
|
3549
3657
|
}
|
|
3550
|
-
if (value === '--app'
|
|
3551
|
-
return false;
|
|
3658
|
+
if (value === '--app')
|
|
3659
|
+
return { ok: false, problem: 'unsupported_app_option', detail: value };
|
|
3660
|
+
if (value === '--aun-path')
|
|
3661
|
+
return { ok: false, problem: 'unsupported_aun_path_option', detail: value };
|
|
3552
3662
|
if (value === '--format' && operand !== 'json')
|
|
3553
|
-
return false;
|
|
3663
|
+
return { ok: false, problem: 'format_not_json', detail: operand };
|
|
3554
3664
|
if (value === '--link') {
|
|
3555
|
-
if (scope !== 'msg'
|
|
3556
|
-
return false;
|
|
3665
|
+
if (scope !== 'msg')
|
|
3666
|
+
return { ok: false, problem: 'link_not_private', detail: value };
|
|
3667
|
+
if (modes.has('link'))
|
|
3668
|
+
return { ok: false, problem: 'duplicate_link', detail: value };
|
|
3557
3669
|
modes.set('link', operand);
|
|
3558
3670
|
}
|
|
3559
3671
|
if (value === '--payload') {
|
|
3560
3672
|
if (modes.has('payload'))
|
|
3561
|
-
return false;
|
|
3673
|
+
return { ok: false, problem: 'duplicate_payload', detail: value };
|
|
3562
3674
|
modes.set('payload', operand);
|
|
3563
3675
|
}
|
|
3564
3676
|
if (value === '--payload-file') {
|
|
3565
|
-
if (scope !== 'msg'
|
|
3566
|
-
return false;
|
|
3677
|
+
if (scope !== 'msg')
|
|
3678
|
+
return { ok: false, problem: 'payload_file_not_private', detail: value };
|
|
3679
|
+
if (modes.has('payload-file'))
|
|
3680
|
+
return { ok: false, problem: 'duplicate_payload_file', detail: value };
|
|
3681
|
+
if (!isManagedPayloadFilePath(operand))
|
|
3682
|
+
return { ok: false, problem: 'payload_file_path_uncertain', detail: operand };
|
|
3567
3683
|
modes.set('payload-file', operand);
|
|
3568
3684
|
}
|
|
3569
3685
|
}
|
|
3570
3686
|
// 正文、链接、payload、payload-file 之间互斥;文件附件允许和正文一起出现。
|
|
3571
3687
|
const contentModes = [...modes.keys()].filter(key => key !== 'file');
|
|
3572
3688
|
if (contentModes.length > 1)
|
|
3573
|
-
return false;
|
|
3574
|
-
if (contentModes.length > 0 && positionals.length > 0)
|
|
3575
|
-
return false;
|
|
3576
|
-
|
|
3577
|
-
|
|
3689
|
+
return { ok: false, problem: 'mode_conflict', detail: contentModes.map(key => `--${key}`).join(' + ') };
|
|
3690
|
+
if (contentModes.length > 0 && positionals.length > 0) {
|
|
3691
|
+
return { ok: false, problem: 'body_with_content_mode', detail: `--${contentModes[0]} + 位置正文 "${positionals.join(' ')}"` };
|
|
3692
|
+
}
|
|
3693
|
+
if (contentModes.length > 0 && modes.has('file')) {
|
|
3694
|
+
return { ok: false, problem: 'file_with_content_mode', detail: `--${contentModes[0]} + --file` };
|
|
3695
|
+
}
|
|
3578
3696
|
if (modes.has('link')) {
|
|
3579
3697
|
try {
|
|
3580
3698
|
const url = new URL(modes.get('link'));
|
|
3581
|
-
return url.protocol === 'http:' || url.protocol === 'https:'
|
|
3699
|
+
return url.protocol === 'http:' || url.protocol === 'https:'
|
|
3700
|
+
? { ok: true }
|
|
3701
|
+
: { ok: false, problem: 'link_not_http', detail: modes.get('link') };
|
|
3582
3702
|
}
|
|
3583
3703
|
catch {
|
|
3584
|
-
return false;
|
|
3704
|
+
return { ok: false, problem: 'link_not_http', detail: modes.get('link') };
|
|
3585
3705
|
}
|
|
3586
3706
|
}
|
|
3587
3707
|
if (modes.has('payload')) {
|
|
3588
3708
|
try {
|
|
3589
3709
|
parseJsonObjectArgument(modes.get('payload'));
|
|
3590
|
-
return true;
|
|
3710
|
+
return { ok: true };
|
|
3591
3711
|
}
|
|
3592
3712
|
catch {
|
|
3593
|
-
return false;
|
|
3713
|
+
return { ok: false, problem: 'payload_not_object', detail: modes.get('payload') };
|
|
3594
3714
|
}
|
|
3595
3715
|
}
|
|
3596
3716
|
if (modes.has('payload-file'))
|
|
3597
|
-
return true;
|
|
3717
|
+
return { ok: true };
|
|
3598
3718
|
if (modes.has('file'))
|
|
3599
|
-
return true;
|
|
3600
|
-
return positionals.join(' ').length > 0;
|
|
3719
|
+
return { ok: true };
|
|
3720
|
+
return positionals.join(' ').length > 0 ? { ok: true } : { ok: false, problem: 'empty_body' };
|
|
3721
|
+
}
|
|
3722
|
+
function hasExecutableProactiveSendPayload(argv, scope, bodyStart = 5, options = {}) {
|
|
3723
|
+
return diagnoseProactiveSendPayload(argv, scope, bodyStart, options).ok;
|
|
3724
|
+
}
|
|
3725
|
+
/** 发送内容的合法写法清单;简化式与完整式诊断共用,避免两处枚举漂移。 */
|
|
3726
|
+
const SEND_CONTENT_FORMS_HINT = '正文不能为空(可用位置正文、--file、--text-from-file、--payload 或 --payload-file 之一);'
|
|
3727
|
+
+ '--link 的值必须是 http(s) URL;--payload 的值必须是 JSON 对象;'
|
|
3728
|
+
+ '--payload-file 的值必须是 $TMPDIR 或项目目录下的确定文件路径;'
|
|
3729
|
+
+ '--file/--text-from-file 的值必须是确定的文件路径。';
|
|
3730
|
+
const SEND_PAYLOAD_PROBLEM_HINTS = {
|
|
3731
|
+
not_send_command: '不是发送命令。',
|
|
3732
|
+
missing_operand: '参数缺少取值:{detail} 后面必须紧跟一个值。',
|
|
3733
|
+
attachment_not_allowed: '当前发送场景不允许带附件:{detail}。',
|
|
3734
|
+
file_path_uncertain: '附件路径不确定或缺少引号:{detail}。请用引号包裹完整路径。',
|
|
3735
|
+
duplicate_file: '一次只能带一个附件,--file/--text-from-file 重复出现:{detail}。',
|
|
3736
|
+
unsupported_app_option: '发送时不能用 --app(非托管拉取入口):{detail}。',
|
|
3737
|
+
unsupported_aun_path_option: '发送时不能用 --aun-path:{detail}。',
|
|
3738
|
+
format_not_json: '--format 只接受 json,收到:{detail}。',
|
|
3739
|
+
link_not_private: '--link 只能用于私聊发送:{detail}。',
|
|
3740
|
+
duplicate_link: '一次只能带一个 --link:{detail}。',
|
|
3741
|
+
duplicate_payload: '一次只能带一个 --payload:{detail}。',
|
|
3742
|
+
payload_file_not_private: '--payload-file 只用于私聊发送:{detail}。',
|
|
3743
|
+
duplicate_payload_file: '一次只能带一个 --payload-file:{detail}。',
|
|
3744
|
+
payload_file_path_uncertain: '--payload-file 的路径不确定:{detail}。必须是 $TMPDIR 或项目目录下的确定文件路径,不能包含未解析的变量或通配符。',
|
|
3745
|
+
mode_conflict: '发送内容写法互相冲突:{detail}。正文、--link、--payload、--payload-file 只能选一种。',
|
|
3746
|
+
body_with_content_mode: '位置正文和内容参数不能同时使用:{detail}。去掉位置正文,或改用其中一种。',
|
|
3747
|
+
file_with_content_mode: '附件和内容参数不能同时使用:{detail}。正文或 payload 与 --file 只能选一种。',
|
|
3748
|
+
link_not_http: '--link 必须是 http(s) URL,收到:{detail}。',
|
|
3749
|
+
payload_not_object: '--payload 的值必须是 JSON 对象,收到:{detail}。',
|
|
3750
|
+
empty_body: '没有可发送的内容:正文为空,也没有给出 --file/--text-from-file/--payload/--payload-file/--link。',
|
|
3751
|
+
encrypt_mode_invalid: '--encrypt 只接受 yes|no|auto,必须带取值。',
|
|
3752
|
+
};
|
|
3753
|
+
function describeSendPayloadProblem(diagnosis) {
|
|
3754
|
+
if (diagnosis.problem) {
|
|
3755
|
+
const template = SEND_PAYLOAD_PROBLEM_HINTS[diagnosis.problem];
|
|
3756
|
+
return `发送命令被拒:${template.replace('{detail}', diagnosis.detail ?? '')}`;
|
|
3757
|
+
}
|
|
3758
|
+
return `发送命令被拒:${SEND_CONTENT_FORMS_HINT}`;
|
|
3601
3759
|
}
|
|
3602
3760
|
function parseEvolcoreSendArgv(argv) {
|
|
3603
3761
|
if (!argv || argv[0] !== 'ec')
|
|
@@ -3706,8 +3864,8 @@ export function describeProactiveSendCommandFailure(toolName, input, session) {
|
|
|
3706
3864
|
return undefined;
|
|
3707
3865
|
const commandText = [input.command, input.input, ...(Array.isArray(input.commandArgv) ? input.commandArgv : [])]
|
|
3708
3866
|
.filter((value) => typeof value === 'string').join(' ');
|
|
3709
|
-
// `ecmsg send`
|
|
3710
|
-
//
|
|
3867
|
+
// 诊断同时认 `ecmsg send` 与它规范化后的内部形态(`ec msg|group send`),否则
|
|
3868
|
+
// ecmsg 写法被拒时只会掉进"上一轮未包含意图表达"的笼统提示,模型拿不到可操作原因。
|
|
3711
3869
|
if (!/\bec(?:\.cmd|\.exe)?\s+(?:group|msg)\s+send\b|\becmsg(?:\.cmd|\.exe|\.ps1)?\s+send\b/i.test(commandText)) {
|
|
3712
3870
|
return undefined;
|
|
3713
3871
|
}
|
|
@@ -3718,7 +3876,7 @@ export function describeProactiveSendCommandFailure(toolName, input, session) {
|
|
|
3718
3876
|
return `当前汇报命令未通过规范解析(${result.issue},${result.dialect},位置 ${result.offset});`
|
|
3719
3877
|
+ '请检查引号和转义,并将发送作为一条独立命令。';
|
|
3720
3878
|
}
|
|
3721
|
-
//
|
|
3879
|
+
// 正文里只是提到发送命令的其它命令(如 ec memory note "ecmsg send …")不是发送调用。
|
|
3722
3880
|
const argv = result.argv;
|
|
3723
3881
|
if (argv[0] !== 'ec' || (argv[1] !== 'msg' && argv[1] !== 'group') || argv[2] !== 'send')
|
|
3724
3882
|
return undefined;
|
|
@@ -3728,33 +3886,33 @@ export function describeProactiveSendCommandFailure(toolName, input, session) {
|
|
|
3728
3886
|
// 托管简化式(`ecmsg send '<正文>'`):from/to 由当前会话推断,
|
|
3729
3887
|
// 不应再按"缺少发送者与目标"给建议,只可能是发送内容或参数无效。
|
|
3730
3888
|
if (isManagedSimplifiedSend(argv)) {
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3889
|
+
const diagnosis = diagnoseProactiveSendPayload(argv, argv[1], 3, { allowAttachment: true });
|
|
3890
|
+
// 诊断通过说明内容本身合法,被拒的原因不在这一层,交给调用方按缺省处理。
|
|
3891
|
+
return diagnosis.ok ? undefined : describeSendPayloadProblem(diagnosis);
|
|
3734
3892
|
}
|
|
3735
3893
|
const scope = argv[1];
|
|
3736
3894
|
const prefix = '发送命令被拒:';
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
// 带 --thread
|
|
3895
|
+
// 面向模型的写法统一是 `ecmsg send`:本端恒为会话本端,不写 from;
|
|
3896
|
+
// 接收方由话题和模式推出,不用 --to。
|
|
3897
|
+
const expectedForm = 'ecmsg send "<正文>"';
|
|
3898
|
+
// 带 --thread 的发送走话题路由校验;走到这里说明话题本身没解析通过。
|
|
3741
3899
|
if (sendOptionValue(argv, '--thread')) {
|
|
3742
|
-
return `${prefix}带 --thread
|
|
3743
|
-
+
|
|
3744
|
-
+
|
|
3900
|
+
return `${prefix}带 --thread 的跨话题发送未通过校验——话题必须已存在于本端,且不能是当前话题:`
|
|
3901
|
+
+ `独立话题写 thread-…,主话题写 main:<aidA>:<aidB>(两端之一必须是本端)。`
|
|
3902
|
+
+ `跨话题默认是委托(收件人为该话题对端);要发给自己加 --selfmode。`
|
|
3745
3903
|
+ `主话题 id 只在本端之间有效,不要转发给别人使用。可用 ec thread list <对方AID> 取得可用值。`;
|
|
3746
3904
|
}
|
|
3747
3905
|
// 私聊/群聊用错了 scope。
|
|
3748
3906
|
if (session?.chatType && (session.chatType === 'group') !== (scope === 'group')) {
|
|
3749
3907
|
return session.chatType === 'group'
|
|
3750
|
-
? `${prefix}
|
|
3751
|
-
+
|
|
3752
|
-
: `${prefix}当前是私聊会话,回复用 ${expectedForm}
|
|
3908
|
+
? `${prefix}当前是群聊会话,公开回复直接写 ecmsg send "<正文>"(群会话里即群内公开发送);`
|
|
3909
|
+
+ `要私下联系本条消息的发送者,用 --thread <与对方的私聊话题>。`
|
|
3910
|
+
: `${prefix}当前是私聊会话,回复用 ${expectedForm};群回复在群会话里同样用 ecmsg send。`;
|
|
3753
3911
|
}
|
|
3754
3912
|
const from = argv[3];
|
|
3755
3913
|
const to = argv[4];
|
|
3756
3914
|
const fullFormHint = `${prefix}缺少发送者与目标。完整形式为 ${expectedForm};`
|
|
3757
|
-
+
|
|
3915
|
+
+ `普通回复直接写 ecmsg send '<正文>'(省略 from/to 即发往当前会话对端);跨话题发送才需要 --thread。`;
|
|
3758
3916
|
if (!from || from.startsWith('--')) {
|
|
3759
3917
|
return fullFormHint;
|
|
3760
3918
|
}
|
|
@@ -3762,7 +3920,7 @@ export function describeProactiveSendCommandFailure(toolName, input, session) {
|
|
|
3762
3920
|
return looksLikeAid(from)
|
|
3763
3921
|
? fullFormHint
|
|
3764
3922
|
: `${prefix}缺少发送者与目标("${from}" 是正文而非 AID)。完整形式为 ${expectedForm};`
|
|
3765
|
-
+
|
|
3923
|
+
+ `普通回复直接写 ecmsg send '<正文>'(省略 from/to 即发往当前会话对端);跨话题发送才需要 --thread。`;
|
|
3766
3924
|
}
|
|
3767
3925
|
if (!looksLikeAid(from) || !looksLikeAid(to)) {
|
|
3768
3926
|
return `${prefix}发送者/目标不是合法 AID(收到 from="${from}" to="${to}")。完整形式为 ${expectedForm}。`;
|
|
@@ -3772,11 +3930,12 @@ export function describeProactiveSendCommandFailure(toolName, input, session) {
|
|
|
3772
3930
|
}
|
|
3773
3931
|
if (session?.channelId && to !== session.channelId) {
|
|
3774
3932
|
return `${prefix}目标必须是当前会话${scope === 'group' ? '群' : '对端'} ${session.channelId},命令里写的是 ${to};`
|
|
3775
|
-
+ `要联系其他对象请走 --thread
|
|
3933
|
+
+ `要联系其他对象请走 --thread 跨话题发送(先用 ec thread list <对方AID> 选话题,或直接写主话题 main:<本端AID>:<对方AID>)。`;
|
|
3776
3934
|
}
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3935
|
+
const payloadDiagnosis = diagnoseProactiveSendPayload(argv, scope, 5, { allowAttachment: true });
|
|
3936
|
+
if (payloadDiagnosis.ok)
|
|
3937
|
+
return undefined;
|
|
3938
|
+
return `${prefix}发送者与目标正确,但${describeSendPayloadProblem(payloadDiagnosis).replace(/^发送命令被拒:/, '')}`;
|
|
3780
3939
|
}
|
|
3781
3940
|
/** 与 CLI `isValidAid` 同一规则;parser 不依赖 AID 模块,避免引入身份存储副作用。 */
|
|
3782
3941
|
function looksLikeAid(value) {
|
|
@@ -3799,8 +3958,9 @@ function sendOptionValue(argv, flag) {
|
|
|
3799
3958
|
/**
|
|
3800
3959
|
* 带 `--thread` 的跨话题发送:目标由话题推断,不受「只能发给当前对端/群」限制。
|
|
3801
3960
|
*
|
|
3802
|
-
*
|
|
3803
|
-
*
|
|
3961
|
+
* 入参是规范化后的 argv:`ecmsg send "<text>" --thread <id>` 归一为内部形态
|
|
3962
|
+
* `ec msg send "<text>" --thread <id>`(目标取话题 peer);带显式 self/target 的
|
|
3963
|
+
* 内部完整形式 `ec msg|group send <self> <target> ... --thread <id>` 同样支持。
|
|
3804
3964
|
* `resolveThread` 必须校验话题存在于本端索引、scope 与话题类型一致,且给出
|
|
3805
3965
|
* target 时与话题 peer 相同;这里只做语法与发送者校验。
|
|
3806
3966
|
*/
|