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,22 +1,29 @@
|
|
|
1
|
+
import { panelResourceVersion } from '../../outputs/panel-cards.js';
|
|
1
2
|
import { memoryHelpEntries } from './memory-slash.js';
|
|
2
3
|
import { executeProviderMenu } from './provider-menu.js';
|
|
4
|
+
import { executePrivateMentionMenu, validatePrivateMentionMenuRequest } from './private-mention-menu.js';
|
|
5
|
+
import { executeContextPolicyMenu, validateContextPolicyMenuRequest } from './context-policy-menu.js';
|
|
3
6
|
import { executeTemplateMenu, executeProviderModelCatalog } from './agent-template-menu.js';
|
|
4
|
-
import { getBaseagentSnapshot, loadedBaseagentIds } from '
|
|
5
|
-
import {
|
|
7
|
+
import { getBaseagentSnapshot, loadedBaseagentIds } from '../baseagent/baseagent-availability.js';
|
|
8
|
+
import { executePluginMenu } from '../plugin/plugin-lifecycle.js';
|
|
9
|
+
import { normalizeBaseagent, resolveBaseagentModelSelection, resolveOpenaiConfig } from '../baseagent/baseagent.js';
|
|
10
|
+
import { buildModelRequestHeaders } from '../inference/request-identity.js';
|
|
6
11
|
import { normalizePeer, writeAgentModelConfig } from '../model/config-scope.js';
|
|
7
12
|
import { formatPeerKey } from '../relation/peer-identity.js';
|
|
8
13
|
import { writeChatmodeConfig } from './chatmode-config.js';
|
|
9
14
|
import { modelMatches, getCatalog, getBaseagentCatalog, resolveCatalogModel, assertCatalogSelectable, CONFIGURABLE_EFFORTS, configurableEfforts } from '../model/model-catalog.js';
|
|
10
15
|
import { constrainResolvedModelForRole, filterModelsForRole, validateModelSelectionForRole } from '../model/model-permission.js';
|
|
11
|
-
import { hasModelSwitcher } from '
|
|
16
|
+
import { hasModelSwitcher } from '../baseagent/runner-types.js';
|
|
12
17
|
import { resolvePaths, getPackageRoot, daemonControlDir, resolveRoot } from '../../paths.js';
|
|
13
18
|
import { buildEnvelope, isDeliveryTarget, isDeliveryTargetForChannel, replyContextFromSession } from '../message/message-utils.js';
|
|
14
19
|
import { isMainSession, isTopicSession, sessionLocalTopicId, sessionTopicThreadId } from '../thread/topic-id.js';
|
|
15
20
|
import path from 'path';
|
|
16
21
|
import fs from 'fs';
|
|
17
22
|
import { parseFileSearchArgs, searchProjectFiles } from './file-search.js';
|
|
23
|
+
import { menuFileFallbackRoots, resolveMenuFilePath } from './menu-file-path.js';
|
|
18
24
|
import os from 'os';
|
|
19
25
|
import { readEffectiveCpuCount } from '../../utils/host-info.js';
|
|
26
|
+
import { readSystemMemoryUsage } from '../../utils/system-memory.js';
|
|
20
27
|
import crypto from 'crypto';
|
|
21
28
|
import { CronExpressionParser } from 'cron-parser';
|
|
22
29
|
import { parseDuration } from '../../trigger/parser.js';
|
|
@@ -29,14 +36,17 @@ import { loadDefaults, loadDaemonConfig } from '../../config-store.js';
|
|
|
29
36
|
import { buildEcwebPairingUrl } from '../../ecweb/pairing.js';
|
|
30
37
|
import { WEB_PACKAGE_NAME, RESTART_REQUEST_ID_ENV, RUNTIME_HOME_ENV, SESSION_ID_ENV } from '../../product.js';
|
|
31
38
|
import { read as cfgRead, resolveEffective, resolveEffectiveFieldWithSource, routeFieldPath, write as cfgWrite, ConfigTarget, } from '../../config/config-manager.js';
|
|
39
|
+
import { fieldSchemaDefault } from '../../config/schema-registry.js';
|
|
32
40
|
import { agentCreateCapabilities, execAgentAction, execAgentQuery, execAgentOptions, execAidAvatar, resolveProjectPath } from './agent-control.js';
|
|
33
41
|
import { readInitialization } from '../../cli/agent-create.js';
|
|
34
42
|
import { agentMdMenuService } from './agentmd-menu.js';
|
|
43
|
+
import { isAgentMdWriteAction } from './agentmd-menu-request.js';
|
|
35
44
|
import { isValidAid } from '../../aun/aid/validation.js';
|
|
36
45
|
import { gatewayList, gatewayUpdate, gatewayDelete, gatewayTest, gatewayModels, gatewaySetPrice } from '../../config/gateway-config.js';
|
|
37
46
|
import { displaySessionTitle } from '../session/session-title.js';
|
|
38
47
|
import { buildTranscriptTurns } from '../session/session-transcript.js';
|
|
39
48
|
import { buildForkHistorySnapshot, pageForkHistory } from '../session/session-manager.js';
|
|
49
|
+
import { openSessionInTerminal, resolveSessionTerminalProjectPath } from '../session/session-terminal.js';
|
|
40
50
|
import { isCapabilityType, listCapabilityOptions, queryCapabilityTypes, resolveCapabilityContext, updateCapabilityPolicy, } from '../capability/capability-manager.js';
|
|
41
51
|
import { normalizeCliArgv, parseCliIntent, parseLegacyCliCommand, validateCliArgv, withDefaultRelationContext } from './cli-intent-parser.js';
|
|
42
52
|
import { auditCommandAuthorization, auditFullAccessEvent, hashArgv } from '../auth/authorization-audit.js';
|
|
@@ -51,7 +61,7 @@ import { chatmodeFieldForPeer, isChatMode, isPrivateChatmodeRoleLocked, resolveC
|
|
|
51
61
|
import { PUBLIC_PERMISSION_MODES } from '../permission/mode.js';
|
|
52
62
|
import { isAgentFullAccessOwner, resolveRuntimePermissionMode, resolveRuntimeStringField, sessionFullAccessStatus, updateRelationSessionFullAccess, validateRuntimeStringFieldOverride, } from '../role/runtime-policy.js';
|
|
53
63
|
import { isManagementRole } from '../../config/builtin-roles.js';
|
|
54
|
-
import { SYSTEM_CONTROL_CHANNEL } from '../system-channels.js';
|
|
64
|
+
import { SYSTEM_CONTROL_CHANNEL } from '../channel/system-channels.js';
|
|
55
65
|
import { logger } from '../../utils/logger.js';
|
|
56
66
|
import { resolveProjectDefaultPath } from '../../utils/project-path.js';
|
|
57
67
|
import { shouldSuppressRealRestart, createRestartRequest, readRestartRequest, updateRestartRequest, removeRestartRequest } from '../../utils/restart-safety.js';
|
|
@@ -277,60 +287,6 @@ async function resolveTopicForkSource(sessionManager, channel, channelId, source
|
|
|
277
287
|
const active = await sessionManager.getActiveSession(channel, channelId);
|
|
278
288
|
return active && isMainSession(active) ? active : undefined;
|
|
279
289
|
}
|
|
280
|
-
/**
|
|
281
|
-
* 解析并校验 menu `name=file` 的目标路径(query/fetch 共用)。
|
|
282
|
-
*
|
|
283
|
-
* 与文本 `/file` 的差异(见设计文档 §6.2):
|
|
284
|
-
* - 接受项目内**绝对路径**(文本 /file 仍拒绝绝对路径)
|
|
285
|
-
* - 项目外文件仅 aid channel owner(identity.role === 'owner')可取
|
|
286
|
-
*
|
|
287
|
-
* 沿用 /file 的安全校验链:拒绝 `..` 穿越、realpathSync 后验证落点。
|
|
288
|
-
* 成功返回 `{ realPath, projectPath, stat }`;失败返回 `{ error, code }`。
|
|
289
|
-
*/
|
|
290
|
-
function resolveMenuFilePath(input, projectPath, role, expectType) {
|
|
291
|
-
if (!projectPath)
|
|
292
|
-
return { error: '无法解析当前 agent projectPath', code: 'NO_PROJECT' };
|
|
293
|
-
const raw = (input ?? '').toString().trim();
|
|
294
|
-
if (!raw)
|
|
295
|
-
return { error: '缺少 path 参数', code: 'MISSING_VALUE' };
|
|
296
|
-
// 拒绝 .. 路径穿越(兼容两种分隔符)
|
|
297
|
-
if (raw.split(path.sep).includes('..') || raw.split('/').includes('..')) {
|
|
298
|
-
return { error: '不支持 .. 路径穿越', code: 'NO_PERMISSION' };
|
|
299
|
-
}
|
|
300
|
-
// 相对路径基于 projectPath 解析;绝对路径原样
|
|
301
|
-
const resolved = path.isAbsolute(raw) ? raw : path.resolve(projectPath, raw);
|
|
302
|
-
if (!fs.existsSync(resolved)) {
|
|
303
|
-
return { error: '文件不存在', code: 'NOT_FOUND' };
|
|
304
|
-
}
|
|
305
|
-
let realPath;
|
|
306
|
-
let realProjectPath;
|
|
307
|
-
try {
|
|
308
|
-
realPath = fs.realpathSync(resolved);
|
|
309
|
-
realProjectPath = fs.realpathSync(projectPath);
|
|
310
|
-
}
|
|
311
|
-
catch {
|
|
312
|
-
return { error: '文件不存在', code: 'NOT_FOUND' };
|
|
313
|
-
}
|
|
314
|
-
const inProject = realPath === realProjectPath || realPath.startsWith(realProjectPath + path.sep);
|
|
315
|
-
// 项目外文件:仅 aid channel owner 可取(§6.2)
|
|
316
|
-
if (!inProject && role !== 'owner') {
|
|
317
|
-
return { error: '无权限:项目外文件仅 owner 可取', code: 'NO_PERMISSION' };
|
|
318
|
-
}
|
|
319
|
-
let stat;
|
|
320
|
-
try {
|
|
321
|
-
stat = fs.statSync(realPath);
|
|
322
|
-
}
|
|
323
|
-
catch {
|
|
324
|
-
return { error: '文件不存在', code: 'NOT_FOUND' };
|
|
325
|
-
}
|
|
326
|
-
if (expectType === 'file' && stat.isDirectory()) {
|
|
327
|
-
return { error: '暂不支持目录', code: 'NOT_SUPPORTED' };
|
|
328
|
-
}
|
|
329
|
-
if (expectType === 'directory' && !stat.isDirectory()) {
|
|
330
|
-
return { error: '不是目录', code: 'NOT_A_DIRECTORY' };
|
|
331
|
-
}
|
|
332
|
-
return { realPath, projectPath: realProjectPath, stat };
|
|
333
|
-
}
|
|
334
290
|
function parseProjectRelativePath(input) {
|
|
335
291
|
if (typeof input !== 'string' || !input.trim()) {
|
|
336
292
|
return { error: '缺少 path 参数', code: 'MISSING_VALUE' };
|
|
@@ -710,7 +666,14 @@ function menuChatmodeField(args, session, explicitChatType) {
|
|
|
710
666
|
}
|
|
711
667
|
return chatmodeFieldForPeer(session?.chatType ?? explicitChatType, session?.metadata?.peerType);
|
|
712
668
|
}
|
|
669
|
+
/**
|
|
670
|
+
* chatmode 未配置时的展示值:优先取 agent-config schema 的 `chatmode.<field>.default`
|
|
671
|
+
* (v22 起三个子字段各自有声明),schema 没声明才回落到内置表。
|
|
672
|
+
*/
|
|
713
673
|
function defaultChatmodeForField(field) {
|
|
674
|
+
const fromSchema = fieldSchemaDefault('agent-config', `chatmode.${field}`);
|
|
675
|
+
if (isChatMode(fromSchema))
|
|
676
|
+
return fromSchema;
|
|
714
677
|
return field === 'private' ? 'interactive' : 'proactive';
|
|
715
678
|
}
|
|
716
679
|
function normalizeMenuPeer(input) {
|
|
@@ -851,7 +814,14 @@ function readMenuMentionMode(target, fallback = null, fallbackSource = null) {
|
|
|
851
814
|
}
|
|
852
815
|
}
|
|
853
816
|
catch { }
|
|
854
|
-
|
|
817
|
+
if (fallback !== null)
|
|
818
|
+
return { value: fallback, source: fallbackSource };
|
|
819
|
+
// 配置链与会话元数据都未设:展示 schema 声明的出厂默认(v22 起 mentionMode 有 default)。
|
|
820
|
+
const fromSchema = fieldSchemaDefault(target.scope === 'agent' ? 'agent-config' : 'relation-config', target.fieldPath);
|
|
821
|
+
if (fromSchema === 'disabled' || fromSchema === 'mention-only' || fromSchema === 'auto') {
|
|
822
|
+
return { value: fromSchema, source: 'builtin' };
|
|
823
|
+
}
|
|
824
|
+
return { value: null, source: null };
|
|
855
825
|
}
|
|
856
826
|
function writeMenuMentionMode(target, value) {
|
|
857
827
|
const route = routeFieldPath(target.fieldPath, target.scope);
|
|
@@ -1051,12 +1021,14 @@ export function isProcessLevelOwner(peerId, owners) {
|
|
|
1051
1021
|
// ── 控制面双轨鉴权(见 docs/.../2026-06-10-control-channel-auth-design.md)──
|
|
1052
1022
|
// 白名单而非黑名单:默认安全,新增进程级 action 需显式加入。
|
|
1053
1023
|
/** /agent 的进程级 action:仅控制 channel 可执行。 */
|
|
1054
|
-
export const PROCESS_LEVEL_AGENT_ACTIONS = new Set(['create', 'initialize', 'delete', 'enable', 'disable']);
|
|
1024
|
+
export const PROCESS_LEVEL_AGENT_ACTIONS = new Set(['create', 'initialize', 'delete', 'enable', 'disable', 'project']);
|
|
1055
1025
|
/** /agent 的「本 agent 自管理」action:agent channel 仅 owner/admin 可对自身 aid 执行;update 另行收紧为 owner。 */
|
|
1056
1026
|
export const SELF_MANAGE_AGENT_ACTIONS = new Set(['update', 'reload']);
|
|
1057
1027
|
/** 判断 (cmdBase, action) 是否为进程级操作(仅控制 channel 可执行)。
|
|
1058
1028
|
* /system 全部进程级;/agent 仅 create/delete/enable/disable 进程级;其余关系级。 */
|
|
1059
1029
|
export function isProcessLevelAction(cmdBase, action) {
|
|
1030
|
+
if (cmdBase === '/plugins')
|
|
1031
|
+
return true;
|
|
1060
1032
|
if (cmdBase === '/provider')
|
|
1061
1033
|
return true;
|
|
1062
1034
|
if (cmdBase === '/baseagent-models')
|
|
@@ -1102,6 +1074,15 @@ function gateControlScope(opts) {
|
|
|
1102
1074
|
function buildMenuIntent(verb, cmdBase, args, action, value, fromControlChannel = false) {
|
|
1103
1075
|
if (cmdBase === '/agent-data-root' || cmdBase === '/relation-data-root')
|
|
1104
1076
|
return null;
|
|
1077
|
+
if (cmdBase === '/context-policy' && (verb === 'query' || verb === 'update'))
|
|
1078
|
+
return {
|
|
1079
|
+
operation: verb === 'update' ? 'contextpolicy.update' : 'contextpolicy.current',
|
|
1080
|
+
scope: 'agent', source: 'menu', args: { ...(args ?? {}), ...(value !== undefined ? { value } : {}) },
|
|
1081
|
+
};
|
|
1082
|
+
if (cmdBase === '/private-mention-mode' && ['query', 'options', 'update'].includes(verb)) {
|
|
1083
|
+
return { operation: `privatementionmode.${verb === 'update' ? 'update' : 'current'}`,
|
|
1084
|
+
scope: 'agent', source: 'menu', args: { ...(args ?? {}), ...(value !== undefined ? { value } : {}) } };
|
|
1085
|
+
}
|
|
1105
1086
|
if (cmdBase === '/file' && args?.rootId !== undefined)
|
|
1106
1087
|
return null;
|
|
1107
1088
|
const payload = { ...(args ?? {}), ...(value !== undefined ? { value } : {}) };
|
|
@@ -1162,6 +1143,8 @@ function buildMenuIntent(verb, cmdBase, args, action, value, fromControlChannel
|
|
|
1162
1143
|
return intent('agent.access.read', 'agent');
|
|
1163
1144
|
return intent(fromControlChannel && !args?.aid ? 'agent.list' : 'agent.show', fromControlChannel ? 'control' : 'agent');
|
|
1164
1145
|
}
|
|
1146
|
+
if (cmdBase === '/connect' && args?.view === 'access')
|
|
1147
|
+
return intent('agent.access.read', 'agent');
|
|
1165
1148
|
if (cmdBase === '/trigger')
|
|
1166
1149
|
return intent(args?.view === 'history' ? 'trigger.history'
|
|
1167
1150
|
: args?.view === 'detail' ? 'trigger.show' : 'trigger.list', 'relation');
|
|
@@ -1173,6 +1156,8 @@ function buildMenuIntent(verb, cmdBase, args, action, value, fromControlChannel
|
|
|
1173
1156
|
return intent('config.read', args?.scope === 'agent' ? 'agent' : 'process');
|
|
1174
1157
|
if (cmdBase === '/agent')
|
|
1175
1158
|
return intent(fromControlChannel ? 'agent.list' : 'agent.show', fromControlChannel ? 'control' : 'agent');
|
|
1159
|
+
if (cmdBase === '/connect')
|
|
1160
|
+
return intent('agent.access.read', 'agent');
|
|
1176
1161
|
if (cmdBase === '/capability')
|
|
1177
1162
|
return intent('capability.read', 'agent');
|
|
1178
1163
|
if (cmdBase === '/trigger')
|
|
@@ -1197,6 +1182,8 @@ function buildMenuIntent(verb, cmdBase, args, action, value, fromControlChannel
|
|
|
1197
1182
|
return intent('permission.current', args?.scope === 'agent' ? 'agent' : 'relation');
|
|
1198
1183
|
}
|
|
1199
1184
|
if (verb === 'update') {
|
|
1185
|
+
if (cmdBase === '/connect')
|
|
1186
|
+
return intent('agent.access.write', 'agent', { action: 'set-access' });
|
|
1200
1187
|
if (cmdBase === '/baseagent')
|
|
1201
1188
|
return intent('agent.baseagent.update', 'agent', { baseagent: value });
|
|
1202
1189
|
// 模型参数只在 Agent 级:写入一律按 agent scope 鉴权(仅 owner/admin)。
|
|
@@ -1220,6 +1207,11 @@ function buildMenuIntent(verb, cmdBase, args, action, value, fromControlChannel
|
|
|
1220
1207
|
return intent('trigger.update', 'relation', { action: 'update' });
|
|
1221
1208
|
}
|
|
1222
1209
|
if (verb === 'action') {
|
|
1210
|
+
if (cmdBase === '/connect' && action === 'set-access')
|
|
1211
|
+
return intent('agent.access.write', 'agent', { action });
|
|
1212
|
+
if ((cmdBase === '/session' || cmdBase === '/s') && action === 'open-terminal') {
|
|
1213
|
+
return intent('session.terminal.open', 'agent');
|
|
1214
|
+
}
|
|
1223
1215
|
if (cmdBase === '/file') {
|
|
1224
1216
|
if (action === 'search')
|
|
1225
1217
|
return intent('file.search', 'filesystem', { filePath: args?.path ?? '.' });
|
|
@@ -1250,6 +1242,8 @@ function buildMenuIntent(verb, cmdBase, args, action, value, fromControlChannel
|
|
|
1250
1242
|
if (cmdBase === '/agent') {
|
|
1251
1243
|
if (action === 'set-access')
|
|
1252
1244
|
return intent('agent.access.write', 'agent', { action });
|
|
1245
|
+
if (action === 'project')
|
|
1246
|
+
return intent('agent.project.' + String(args?.operation ?? ''), 'process', { action });
|
|
1253
1247
|
if (action === 'update' && args?.patch && Object.hasOwn(args.patch, 'avatar')) {
|
|
1254
1248
|
return intent('ec.aid.avatar', 'agent', { action });
|
|
1255
1249
|
}
|
|
@@ -1268,7 +1262,7 @@ function buildMenuIntent(verb, cmdBase, args, action, value, fromControlChannel
|
|
|
1268
1262
|
}
|
|
1269
1263
|
if (cmdBase === '/aid' && action === 'avatar')
|
|
1270
1264
|
return intent('ec.aid.avatar', 'agent', { action });
|
|
1271
|
-
if (cmdBase === '/aid' && action
|
|
1265
|
+
if (cmdBase === '/aid' && isAgentMdWriteAction(action))
|
|
1272
1266
|
return intent('ec.aid.agentmd.put', 'agent', { action });
|
|
1273
1267
|
if (cmdBase === '/trigger') {
|
|
1274
1268
|
if (action === 'create' || action === 'set')
|
|
@@ -1831,7 +1825,7 @@ async function loadMenuTopicSession(sessionManager, channel, channelId, threadId
|
|
|
1831
1825
|
}
|
|
1832
1826
|
/** 动态子菜单:根据 cmd 路径返回选项列表(供 menu.query + cmd 使用) */
|
|
1833
1827
|
export async function getSubMenuItems(cmd, channel, channelId, userId, args, overrideIdentity, explicitChatType, fromControlChannel = false, authSubject, source = 'menu', transportReplyContext) {
|
|
1834
|
-
const session = transportReplyContext?.threadId
|
|
1828
|
+
const session = transportReplyContext?.threadId && cmd.trim().split(' ')[0] !== '/private-mention-mode'
|
|
1835
1829
|
? await loadMenuTopicSession(this.sessionManager, channel, channelId, transportReplyContext.threadId)
|
|
1836
1830
|
: await this.sessionManager.getActiveSession(channel, channelId);
|
|
1837
1831
|
const subject = buildMenuAuthSubject(this, {
|
|
@@ -1860,6 +1854,28 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
1860
1854
|
throw authorized;
|
|
1861
1855
|
return await roleMenuOptions(authorized.context, args);
|
|
1862
1856
|
}
|
|
1857
|
+
// The old Connect root is retained only so existing clients can reopen the
|
|
1858
|
+
// access-settings page. Contact/group/request options remain retired.
|
|
1859
|
+
if (cmdBase0 === '/connect') {
|
|
1860
|
+
const connectOptionsDenied = await authorizeMenuIntent.call(this, {
|
|
1861
|
+
intent: buildMenuIntent('options', cmdBase0, args, undefined, undefined, fromControlChannel),
|
|
1862
|
+
identity: subject.identity,
|
|
1863
|
+
subject,
|
|
1864
|
+
session,
|
|
1865
|
+
explicitChatType,
|
|
1866
|
+
channel,
|
|
1867
|
+
channelId,
|
|
1868
|
+
userId,
|
|
1869
|
+
fromControlChannel,
|
|
1870
|
+
source,
|
|
1871
|
+
});
|
|
1872
|
+
if (connectOptionsDenied)
|
|
1873
|
+
throw { code: connectOptionsDenied.code, message: connectOptionsDenied.error, data: connectOptionsDenied.data };
|
|
1874
|
+
if (args?.option !== undefined && args.option !== 'access') {
|
|
1875
|
+
throw { code: 'NOT_SUPPORTED', message: 'Connect compatibility only supports the access option' };
|
|
1876
|
+
}
|
|
1877
|
+
return [{ value: 'access', label: '访问设置', desc: '设置私聊准入与准入控制消息限额' }];
|
|
1878
|
+
}
|
|
1863
1879
|
if (cmdBase0 === '/group') {
|
|
1864
1880
|
const result = await executeGroupMenu(this, {
|
|
1865
1881
|
kind: 'options', args,
|
|
@@ -1892,6 +1908,9 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
1892
1908
|
});
|
|
1893
1909
|
if (optionsAuthDenied)
|
|
1894
1910
|
throw { code: optionsAuthDenied.code, message: optionsAuthDenied.error, data: optionsAuthDenied.data };
|
|
1911
|
+
if (cmdBase0 === '/private-mention-mode') {
|
|
1912
|
+
return executePrivateMentionMenu('options', subject.selfAid, subject.role, args);
|
|
1913
|
+
}
|
|
1895
1914
|
if (cmdBase0 === '/system') {
|
|
1896
1915
|
if (args?.option !== 'logs')
|
|
1897
1916
|
throw { code: 'NOT_SUPPORTED', message: `Unsupported system option: ${String(args?.option ?? '')}` };
|
|
@@ -1969,12 +1988,14 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
1969
1988
|
// ── 关系级 /trigger list(每个 trigger 一个 MenuItem) ──
|
|
1970
1989
|
if (cmd === '/trigger') {
|
|
1971
1990
|
const triggerScheduler = this.getTriggerSchedulerForChannel?.(channel);
|
|
1972
|
-
|
|
1991
|
+
// 默认列出开与关的全部定义;args.options === 'enabled' 或 args.enabledOnly 只列已启用。
|
|
1992
|
+
// 旧客户端可能传 options='all',语义等同默认,保留兼容。
|
|
1993
|
+
const enabledOnly = args?.options === 'enabled' || args?.enabledOnly === true;
|
|
1973
1994
|
const role = optionsIdentity.role;
|
|
1974
1995
|
const isAdmin = isManagementRole(role) || subject.isDaemonOwner || subject.processRole === 'daemon-service';
|
|
1975
1996
|
if (!triggerScheduler)
|
|
1976
1997
|
return [];
|
|
1977
|
-
const list = triggerScheduler.list({
|
|
1998
|
+
const list = triggerScheduler.list({ enabledOnly })
|
|
1978
1999
|
.filter((definition) => this.canAccessTriggerDefinition(definition, userId ?? '', channel, isAdmin));
|
|
1979
2000
|
return list.map((definition) => {
|
|
1980
2001
|
const view = this.definitionToTriggerView(definition, triggerScheduler);
|
|
@@ -2088,7 +2109,11 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
2088
2109
|
const available = requestedAgent?.name
|
|
2089
2110
|
? (this.getAvailableBaseagentsForOwner?.(requestedAgent.name) ?? [])
|
|
2090
2111
|
: this.getAvailableBaseagents(channel);
|
|
2091
|
-
return available.map((id) => ({
|
|
2112
|
+
return available.map((id) => ({
|
|
2113
|
+
value: id,
|
|
2114
|
+
label: normalizeBaseagent(id).displayName,
|
|
2115
|
+
selected: id === currentAgent,
|
|
2116
|
+
}));
|
|
2092
2117
|
}
|
|
2093
2118
|
if (cmd === '/model') {
|
|
2094
2119
|
const target = resolveMenuModelTarget.call(this, {
|
|
@@ -2256,8 +2281,18 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2256
2281
|
const cmdBase = cmd.trim().split(' ')[0];
|
|
2257
2282
|
if (!cmdBase)
|
|
2258
2283
|
return { error: '缺少命令', code: 'MISSING_CMD' };
|
|
2284
|
+
if (cmdBase === '/private-mention-mode') {
|
|
2285
|
+
const invalid = validatePrivateMentionMenuRequest({ type: 'menu.query', args });
|
|
2286
|
+
if (invalid)
|
|
2287
|
+
return { error: invalid.message, code: invalid.code };
|
|
2288
|
+
}
|
|
2289
|
+
if (cmdBase === '/context-policy') {
|
|
2290
|
+
const invalid = validateContextPolicyMenuRequest({ type: 'menu.query', args });
|
|
2291
|
+
if (invalid)
|
|
2292
|
+
return { error: invalid.message, code: invalid.code };
|
|
2293
|
+
}
|
|
2259
2294
|
if (cmdBase === '/template') {
|
|
2260
|
-
return executeTemplateMenu({ name: 'template', type: 'menu.query', args }, fromControlChannel ? authSubject : undefined, source);
|
|
2295
|
+
return executeTemplateMenu({ name: 'template', type: 'menu.query', id: authSubject?.requestId, args }, fromControlChannel ? authSubject : undefined, source);
|
|
2261
2296
|
}
|
|
2262
2297
|
if (cmdBase === '/model' && args?.scope === 'process' && args?.view === 'catalog') {
|
|
2263
2298
|
return executeProviderModelCatalog({ name: 'model', type: 'menu.query', args }, fromControlChannel ? authSubject : undefined, source);
|
|
@@ -2265,6 +2300,8 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2265
2300
|
if (cmdBase === '/provider') {
|
|
2266
2301
|
return executeProviderMenu({ name: 'provider', cmd, type: 'menu.query', args }, fromControlChannel ? authSubject : undefined, source);
|
|
2267
2302
|
}
|
|
2303
|
+
if (cmdBase === '/plugins')
|
|
2304
|
+
return executePluginMenu({ type: 'menu.query', args }, fromControlChannel ? authSubject : undefined, source);
|
|
2268
2305
|
const isRequesterRoleQuery = cmdBase === '/role' && args?.view === 'requester';
|
|
2269
2306
|
if (isRequesterRoleQuery && Object.keys(args).some(key => key !== 'view')) {
|
|
2270
2307
|
return { error: 'role requester query only accepts args.view', code: 'INVALID_ARGUMENT' };
|
|
@@ -2299,7 +2336,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2299
2336
|
}
|
|
2300
2337
|
}
|
|
2301
2338
|
}
|
|
2302
|
-
if (transportReplyContext?.threadId && !groupResourceSession) {
|
|
2339
|
+
if (transportReplyContext?.threadId && !groupResourceSession && !['/private-mention-mode', '/context-policy'].includes(cmdBase)) {
|
|
2303
2340
|
try {
|
|
2304
2341
|
session = await loadMenuTopicSession(this.sessionManager, channel, channelId, transportReplyContext.threadId);
|
|
2305
2342
|
}
|
|
@@ -2550,6 +2587,17 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2550
2587
|
return menuResultFailure(error);
|
|
2551
2588
|
}
|
|
2552
2589
|
}
|
|
2590
|
+
if (cmdBase === '/connect') {
|
|
2591
|
+
if (args?.view !== 'access')
|
|
2592
|
+
return { error: 'Connect compatibility only supports view=access', code: 'NOT_SUPPORTED' };
|
|
2593
|
+
const authDenied = await authorizeMenuIntent.call(this, {
|
|
2594
|
+
intent: buildMenuIntent('query', cmdBase, args, undefined, undefined, fromControlChannel),
|
|
2595
|
+
identity, subject, session, explicitChatType, channel, channelId, userId, fromControlChannel, source,
|
|
2596
|
+
});
|
|
2597
|
+
if (authDenied)
|
|
2598
|
+
return authDenied;
|
|
2599
|
+
return execAgentQuery({ ...(args ?? {}), aid: args?.aid ?? subject.selfAid, view: 'access' }, this.agentApplicationService, subject, this.runtime);
|
|
2600
|
+
}
|
|
2553
2601
|
if (cmdBase === '/group') {
|
|
2554
2602
|
return await executeGroupMenu(this, {
|
|
2555
2603
|
kind: 'query', args, identity, subject, session,
|
|
@@ -2589,6 +2637,10 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2589
2637
|
const meta = store.getMeta(args.taskId);
|
|
2590
2638
|
if (!meta)
|
|
2591
2639
|
return { error: 'Task not found', code: 'NOT_FOUND' };
|
|
2640
|
+
if (args.view === 'change_summary' && typeof args.threadId === 'string'
|
|
2641
|
+
&& meta.threadId && args.threadId !== meta.threadId) {
|
|
2642
|
+
return { error: 'Task is not available in this session', code: 'FORBIDDEN' };
|
|
2643
|
+
}
|
|
2592
2644
|
const groupId = session.metadata?.groupId || session.channelId;
|
|
2593
2645
|
const sameSession = !(meta.selfAid !== subject.selfAid || meta.sessionId !== session.id
|
|
2594
2646
|
|| meta.channel !== (subject.channelType || channel.split('#')[0])
|
|
@@ -2603,9 +2655,11 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2603
2655
|
}
|
|
2604
2656
|
return { data: args.view === 'activities'
|
|
2605
2657
|
? store.readList(args.taskId, args.offset ?? 0, args.limit ?? 50)
|
|
2606
|
-
: args.view === '
|
|
2607
|
-
? store.
|
|
2608
|
-
:
|
|
2658
|
+
: args.view === 'change_summary'
|
|
2659
|
+
? store.readChangeSummary(args.taskId)
|
|
2660
|
+
: args.view === 'resource'
|
|
2661
|
+
? store.readResource(args.taskId, args.activityId, args.resourceId, args.offset ?? 0)
|
|
2662
|
+
: store.readDetail(args.taskId, args.activityId) };
|
|
2609
2663
|
}
|
|
2610
2664
|
catch (error) {
|
|
2611
2665
|
if (error?.code === 'INVALID_CONTEXT') {
|
|
@@ -2628,6 +2682,22 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2628
2682
|
});
|
|
2629
2683
|
if (authDenied)
|
|
2630
2684
|
return authDenied;
|
|
2685
|
+
if (cmdBase === '/private-mention-mode') {
|
|
2686
|
+
try {
|
|
2687
|
+
return { data: executePrivateMentionMenu('query', subject.selfAid, subject.role, args) };
|
|
2688
|
+
}
|
|
2689
|
+
catch (error) {
|
|
2690
|
+
return menuResultFailure(error);
|
|
2691
|
+
}
|
|
2692
|
+
}
|
|
2693
|
+
if (cmdBase === '/context-policy') {
|
|
2694
|
+
try {
|
|
2695
|
+
return { data: await executeContextPolicyMenu('query', subject.selfAid, subject.role, args) };
|
|
2696
|
+
}
|
|
2697
|
+
catch (error) {
|
|
2698
|
+
return menuResultFailure(error);
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2631
2701
|
if (cmdBase === '/aid' && args?.view === 'agentmd') {
|
|
2632
2702
|
try {
|
|
2633
2703
|
return { data: await agentMdMenuService.query(subject, args) };
|
|
@@ -2688,12 +2758,29 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2688
2758
|
protocolVersion: 1, enabled: peekServiceRouter(root.targetAid)?.enabled
|
|
2689
2759
|
?? loadRouterConfig(agentServicesDir(root.targetAid)).config.enabled,
|
|
2690
2760
|
notifications: this.eventCenter?.get(root.targetAid)?.runtime.nativeOutputAvailable === true,
|
|
2761
|
+
}, panelCards: {
|
|
2762
|
+
protocolVersion: 1, enabled: peekServiceRouter(root.targetAid)?.enabled
|
|
2763
|
+
?? loadRouterConfig(agentServicesDir(root.targetAid)).config.enabled,
|
|
2764
|
+
notifications: this.eventCenter?.get(root.targetAid)?.runtime.nativeOutputAvailable === true,
|
|
2691
2765
|
} } };
|
|
2692
2766
|
}
|
|
2693
2767
|
catch (error) {
|
|
2694
2768
|
return dataRootFailure(error);
|
|
2695
2769
|
}
|
|
2696
2770
|
}
|
|
2771
|
+
if (cmdBase === '/panel-cards-data-root') {
|
|
2772
|
+
if (!args || typeof args.scopeId !== 'string' || !/^[A-Za-z0-9_-]{24}$/.test(args.scopeId) ||
|
|
2773
|
+
Object.keys(args).some(key => key !== 'scopeId')) {
|
|
2774
|
+
return { error: 'panel-cards-data-root requires args.scopeId', code: 'INVALID_ARGUMENT' };
|
|
2775
|
+
}
|
|
2776
|
+
try {
|
|
2777
|
+
const root = dataRootResolver.issuePanelOutputRoot(subject, args.scopeId);
|
|
2778
|
+
return { data: { ...root, scopeId: args.scopeId } };
|
|
2779
|
+
}
|
|
2780
|
+
catch (error) {
|
|
2781
|
+
return dataRootFailure(error);
|
|
2782
|
+
}
|
|
2783
|
+
}
|
|
2697
2784
|
if (cmdBase === '/relation-data-root') {
|
|
2698
2785
|
if (args && Object.keys(args).some(key => key !== 'peerAid')) {
|
|
2699
2786
|
return { error: 'relation-data-root only accepts args.peerAid', code: 'INVALID_ARGUMENT' };
|
|
@@ -2795,6 +2882,10 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2795
2882
|
if ('error' in target)
|
|
2796
2883
|
return target;
|
|
2797
2884
|
const data = queryCapabilityTypes(target.ctx, target.config, type);
|
|
2885
|
+
const inventory = await getBaseagentSnapshot({ config: { ...target.config, aid: target.ctx.aid }, probe: false,
|
|
2886
|
+
runners: { [target.ctx.baseagent]: this.agentMap.get(`${target.ctx.aid}::${target.ctx.baseagent}`) } });
|
|
2887
|
+
data.baseagentCapabilities = inventory.baseagents.find(item => item.id === target.ctx.baseagent)?.capabilities ?? [];
|
|
2888
|
+
data.environment = process.platform;
|
|
2798
2889
|
return { data: sanitizeCapabilityQueryForRole(data, identity.role) };
|
|
2799
2890
|
}
|
|
2800
2891
|
if (cmdBase === '/pwd') {
|
|
@@ -2872,6 +2963,8 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2872
2963
|
config: evolagent.config ?? {},
|
|
2873
2964
|
loaded: this.getAvailableBaseagents(channel),
|
|
2874
2965
|
probe: false,
|
|
2966
|
+
runners: Object.fromEntries([...this.agentMap].filter(([key]) => key.startsWith(`${evolagent.aid}::`))
|
|
2967
|
+
.map(([key, runner]) => [key.slice(evolagent.aid.length + 2), runner])),
|
|
2875
2968
|
}) };
|
|
2876
2969
|
}
|
|
2877
2970
|
if (cmdBase === '/topic') {
|
|
@@ -3238,7 +3331,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
3238
3331
|
osRelease: os.release(),
|
|
3239
3332
|
cpuModel: cpus[0]?.model ?? null,
|
|
3240
3333
|
cpuCount: readEffectiveCpuCount(),
|
|
3241
|
-
memoryTotalBytes:
|
|
3334
|
+
memoryTotalBytes: readSystemMemoryUsage().memTotal,
|
|
3242
3335
|
systemUptime: Math.floor(os.uptime()),
|
|
3243
3336
|
};
|
|
3244
3337
|
// 首屏只读本机基本信息,不定位全局 npm 包,也不等待 CLI 可用性探测。
|
|
@@ -3283,10 +3376,20 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
3283
3376
|
else {
|
|
3284
3377
|
const role = identity.role;
|
|
3285
3378
|
const projectPath = session?.projectPath ?? evolagent?.projectPath ?? this.getOwningAgent?.(channel)?.projectPath;
|
|
3286
|
-
const resolved = resolveMenuFilePath(args?.path, projectPath, role, 'file');
|
|
3379
|
+
const resolved = resolveMenuFilePath(args?.path, projectPath, role, 'file', menuFileFallbackRoots(subject));
|
|
3287
3380
|
if ('error' in resolved)
|
|
3288
3381
|
return resolved;
|
|
3289
3382
|
({ realPath, stat } = resolved);
|
|
3383
|
+
if (role === 'owner') {
|
|
3384
|
+
const denied = await authorizeMenuIntent.call(this, {
|
|
3385
|
+
intent: buildMenuIntent('query', cmdBase, { ...args, path: realPath }),
|
|
3386
|
+
identity, subject, session, explicitChatType, channel, channelId, userId, fromControlChannel, source,
|
|
3387
|
+
});
|
|
3388
|
+
if (denied)
|
|
3389
|
+
return denied;
|
|
3390
|
+
// Pin the subsequent fetch/cache to the file that actually matched.
|
|
3391
|
+
responsePath = realPath;
|
|
3392
|
+
}
|
|
3290
3393
|
}
|
|
3291
3394
|
// sha256 仅对 ≤ 2 MB 文件计算,超过返回 null,客户端降级到 size+mtime(§4、§7 决策 2)
|
|
3292
3395
|
let sha256 = null;
|
|
@@ -3313,6 +3416,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
3313
3416
|
sha256,
|
|
3314
3417
|
size: stat.size,
|
|
3315
3418
|
mtime: stat.mtimeMs,
|
|
3419
|
+
...(dataRoot?.scope === 'panel-output' ? { resourceVersion: panelResourceVersion(stat) } : {}),
|
|
3316
3420
|
},
|
|
3317
3421
|
};
|
|
3318
3422
|
}
|
|
@@ -3323,9 +3427,21 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3323
3427
|
const cmdBase = cmd.trim().split(' ')[0];
|
|
3324
3428
|
if (!cmdBase)
|
|
3325
3429
|
return { error: '缺少命令', code: 'MISSING_CMD' };
|
|
3430
|
+
if (cmdBase === '/private-mention-mode') {
|
|
3431
|
+
const invalid = validatePrivateMentionMenuRequest({ type: 'menu.update', args, value });
|
|
3432
|
+
if (invalid)
|
|
3433
|
+
return { error: invalid.message, code: invalid.code };
|
|
3434
|
+
}
|
|
3435
|
+
if (cmdBase === '/context-policy') {
|
|
3436
|
+
const invalid = validateContextPolicyMenuRequest({ type: 'menu.update', args, value });
|
|
3437
|
+
if (invalid)
|
|
3438
|
+
return { error: invalid.message, code: invalid.code };
|
|
3439
|
+
}
|
|
3326
3440
|
if (cmdBase === '/provider') {
|
|
3327
3441
|
return executeProviderMenu({ name: 'provider', cmd, type: 'menu.update', args, value }, fromControlChannel ? authSubject : undefined, source);
|
|
3328
3442
|
}
|
|
3443
|
+
if (cmdBase === '/plugins')
|
|
3444
|
+
return executePluginMenu({ type: 'menu.update', args, value }, fromControlChannel ? authSubject : undefined, source);
|
|
3329
3445
|
const isEventCenterUpdate = cmdBase === '/events';
|
|
3330
3446
|
const isLoopUpdate = cmdBase === '/session' && args?.resource === 'loop';
|
|
3331
3447
|
const isFullAccessUpdate = cmdBase === '/session' && args?.resource === 'fullaccess';
|
|
@@ -3340,7 +3456,8 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3340
3456
|
return { error: `idleSeconds 必须是 ${MIN_SESSION_LOOP_SECONDS}-${MAX_SESSION_LOOP_SECONDS} 的整数`, code: 'INVALID_ARGUMENT' };
|
|
3341
3457
|
}
|
|
3342
3458
|
}
|
|
3343
|
-
else if (!isFullAccessUpdate && !isEventCenterUpdate &&
|
|
3459
|
+
else if (!isFullAccessUpdate && !isEventCenterUpdate && cmdBase !== '/context-policy'
|
|
3460
|
+
&& cmdBase !== '/provider' && typeof value !== 'string') {
|
|
3344
3461
|
return { error: 'value 必须是字符串', code: 'INVALID_ARGUMENT' };
|
|
3345
3462
|
}
|
|
3346
3463
|
if (isFullAccessUpdate && (typeof value !== 'boolean'
|
|
@@ -3363,7 +3480,7 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3363
3480
|
let session = loadedContext.session;
|
|
3364
3481
|
const evolagent = loadedContext.evolagent;
|
|
3365
3482
|
if (transportReplyContext?.threadId) {
|
|
3366
|
-
const modelAgentScope = (cmdBase === '/model' || cmdBase === '/effort')
|
|
3483
|
+
const modelAgentScope = (cmdBase === '/model' || cmdBase === '/effort' || cmdBase === '/private-mention-mode' || cmdBase === '/context-policy')
|
|
3367
3484
|
&& (menuStringArg(args, 'scope') ?? 'agent') === 'agent';
|
|
3368
3485
|
if (modelAgentScope) {
|
|
3369
3486
|
// Model settings belong to the Agent and can be changed from a locally
|
|
@@ -3502,6 +3619,20 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3502
3619
|
return menuResultFailure(error);
|
|
3503
3620
|
}
|
|
3504
3621
|
}
|
|
3622
|
+
if (cmdBase === '/context-policy') {
|
|
3623
|
+
const denied = await authorizeMenuIntent.call(this, {
|
|
3624
|
+
intent: buildMenuIntent('update', cmdBase, args, undefined, value, fromControlChannel),
|
|
3625
|
+
identity, subject, session, channel, channelId, userId, fromControlChannel, source,
|
|
3626
|
+
});
|
|
3627
|
+
if (denied)
|
|
3628
|
+
return denied;
|
|
3629
|
+
try {
|
|
3630
|
+
return { data: await executeContextPolicyMenu('update', subject.selfAid, subject.role, args, value) };
|
|
3631
|
+
}
|
|
3632
|
+
catch (error) {
|
|
3633
|
+
return menuResultFailure(error);
|
|
3634
|
+
}
|
|
3635
|
+
}
|
|
3505
3636
|
const arg = value.trim();
|
|
3506
3637
|
if (!arg)
|
|
3507
3638
|
return { error: '缺少 value 参数', code: 'MISSING_VALUE' };
|
|
@@ -3519,6 +3650,40 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3519
3650
|
return menuResultFailure(error);
|
|
3520
3651
|
}
|
|
3521
3652
|
}
|
|
3653
|
+
if (cmdBase === '/connect') {
|
|
3654
|
+
const connectUpdateDenied = await authorizeMenuIntent.call(this, {
|
|
3655
|
+
intent: buildMenuIntent('update', cmdBase, args, undefined, arg, fromControlChannel),
|
|
3656
|
+
identity,
|
|
3657
|
+
subject,
|
|
3658
|
+
session,
|
|
3659
|
+
channel,
|
|
3660
|
+
channelId,
|
|
3661
|
+
userId,
|
|
3662
|
+
fromControlChannel,
|
|
3663
|
+
source,
|
|
3664
|
+
});
|
|
3665
|
+
if (connectUpdateDenied)
|
|
3666
|
+
return connectUpdateDenied;
|
|
3667
|
+
const resource = typeof args?.resource === 'string' ? args.resource : '';
|
|
3668
|
+
const accessRevision = typeof args?.expectedAccessRevision === 'string'
|
|
3669
|
+
? args.expectedAccessRevision
|
|
3670
|
+
: typeof args?.accessRevision === 'string' ? args.accessRevision : '';
|
|
3671
|
+
if (!resource || !accessRevision)
|
|
3672
|
+
return { error: 'connect access update requires resource and expectedAccessRevision', code: 'INVALID_ARGUMENT' };
|
|
3673
|
+
let parsed;
|
|
3674
|
+
try {
|
|
3675
|
+
parsed = typeof arg === 'string' ? JSON.parse(arg) : arg;
|
|
3676
|
+
}
|
|
3677
|
+
catch {
|
|
3678
|
+
return { error: 'connect access value must be valid JSON', code: 'INVALID_ARGUMENT' };
|
|
3679
|
+
}
|
|
3680
|
+
const aid = args?.aid ?? subject.selfAid;
|
|
3681
|
+
if (typeof aid !== 'string' || !aid)
|
|
3682
|
+
return { error: '缺少目标 Agent AID', code: 'MISSING_AID' };
|
|
3683
|
+
return execAgentAction('set-access', {
|
|
3684
|
+
aid, resource, value: parsed, accessRevision,
|
|
3685
|
+
}, subject.actorId ?? userId ?? '', this.eventBus, this.agentApplicationService, agentFullAccessMenuSubject(subject, source));
|
|
3686
|
+
}
|
|
3522
3687
|
if (cmdBase === '/group') {
|
|
3523
3688
|
return await executeGroupMenu(this, {
|
|
3524
3689
|
kind: 'update', args, value: arg, identity, subject, session,
|
|
@@ -3538,6 +3703,14 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3538
3703
|
});
|
|
3539
3704
|
if (authDenied)
|
|
3540
3705
|
return authDenied;
|
|
3706
|
+
if (cmdBase === '/private-mention-mode') {
|
|
3707
|
+
try {
|
|
3708
|
+
return { data: executePrivateMentionMenu('update', subject.selfAid, subject.role, args, value) };
|
|
3709
|
+
}
|
|
3710
|
+
catch (error) {
|
|
3711
|
+
return menuResultFailure(error);
|
|
3712
|
+
}
|
|
3713
|
+
}
|
|
3541
3714
|
// ── 进程级 /gateway update(网关配置,value 为 JSON:{scope,type,patch}) ──
|
|
3542
3715
|
if (cmdBase === '/gateway') {
|
|
3543
3716
|
let body;
|
|
@@ -4002,6 +4175,35 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4002
4175
|
return menuResultFailure(error);
|
|
4003
4176
|
}
|
|
4004
4177
|
}
|
|
4178
|
+
if (cmdBase === '/connect') {
|
|
4179
|
+
if (action !== 'set-access')
|
|
4180
|
+
return { error: 'Connect compatibility only supports set-access', code: 'NOT_SUPPORTED' };
|
|
4181
|
+
const connectActionDenied = await authorizeMenuIntent.call(this, {
|
|
4182
|
+
intent: buildMenuIntent('action', cmdBase, args, action, undefined, fromControlChannel),
|
|
4183
|
+
identity: authIdentity,
|
|
4184
|
+
subject,
|
|
4185
|
+
session: authSession,
|
|
4186
|
+
explicitChatType,
|
|
4187
|
+
channel,
|
|
4188
|
+
channelId,
|
|
4189
|
+
userId,
|
|
4190
|
+
fromControlChannel,
|
|
4191
|
+
source,
|
|
4192
|
+
});
|
|
4193
|
+
if (connectActionDenied)
|
|
4194
|
+
return connectActionDenied;
|
|
4195
|
+
const resource = typeof args?.resource === 'string' ? args.resource : '';
|
|
4196
|
+
const accessRevision = typeof args?.expectedAccessRevision === 'string'
|
|
4197
|
+
? args.expectedAccessRevision
|
|
4198
|
+
: typeof args?.accessRevision === 'string' ? args.accessRevision : '';
|
|
4199
|
+
if (!resource || !accessRevision || !Object.hasOwn(args ?? {}, 'value')) {
|
|
4200
|
+
return { error: 'connect set-access requires resource, value and accessRevision', code: 'INVALID_ARGUMENT' };
|
|
4201
|
+
}
|
|
4202
|
+
return execAgentAction('set-access', {
|
|
4203
|
+
aid: args?.aid ?? subject.selfAid,
|
|
4204
|
+
resource, value: args.value, accessRevision,
|
|
4205
|
+
}, subject.actorId ?? userId ?? '', this.eventBus, this.agentApplicationService, agentFullAccessMenuSubject(subject, source));
|
|
4206
|
+
}
|
|
4005
4207
|
if ((cmdBase === '/agent' || cmdBase === '/aid') && !args?.aid) {
|
|
4006
4208
|
const selfAid = this.getOwningAgent?.(channel)?.aid;
|
|
4007
4209
|
if (selfAid)
|
|
@@ -4048,9 +4250,9 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4048
4250
|
// ── /aid AgentMD and avatar ──
|
|
4049
4251
|
// Canonical avatar action; legacy agent/update patch.avatar reuses the same uploader.
|
|
4050
4252
|
if (cmdBase === '/aid') {
|
|
4051
|
-
if (action
|
|
4253
|
+
if (isAgentMdWriteAction(action)) {
|
|
4052
4254
|
try {
|
|
4053
|
-
const data = await agentMdMenuService.publish(subject, args ?? {});
|
|
4255
|
+
const data = await agentMdMenuService.publish(subject, args ?? {}, action);
|
|
4054
4256
|
this.eventBus?.publish({
|
|
4055
4257
|
type: 'agent:updated', aid: data.aid, nameChanged: data.nameChanged, timestamp: Date.now(),
|
|
4056
4258
|
});
|
|
@@ -4110,6 +4312,9 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4110
4312
|
args = { ...(args ?? {}), aid: selfAid };
|
|
4111
4313
|
}
|
|
4112
4314
|
const a = { ...(args ?? {}) };
|
|
4315
|
+
if (action === 'project') {
|
|
4316
|
+
return execAgentAction(action, a, userId ?? '', this.eventBus, this.agentApplicationService, agentFullAccessMenuSubject(subject, source));
|
|
4317
|
+
}
|
|
4113
4318
|
if (action === 'create' && a.resume !== true && a.cancel !== true) {
|
|
4114
4319
|
if (a.project !== undefined && typeof a.project !== 'string')
|
|
4115
4320
|
return { error: 'project 必须是字符串', code: 'INVALID_ARGS' };
|
|
@@ -4218,10 +4423,6 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4218
4423
|
if (!result.ok)
|
|
4219
4424
|
return { error: result.error, code: result.code || 'INTERNAL' };
|
|
4220
4425
|
this.eventBus.publish({ type: 'agent:stopped', aid: a.aid, timestamp: Date.now() });
|
|
4221
|
-
// 中断该 agent 正在执行的大模型调用
|
|
4222
|
-
const handle = this.agentRegistry?.get(a.aid);
|
|
4223
|
-
if (handle)
|
|
4224
|
-
this.messageQueue.interruptByAgent(handle.name);
|
|
4225
4426
|
}
|
|
4226
4427
|
else {
|
|
4227
4428
|
const result = this.agentApplicationService
|
|
@@ -4307,6 +4508,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4307
4508
|
executionTimeoutMs: args.executionTimeoutMs,
|
|
4308
4509
|
effort: args.effort,
|
|
4309
4510
|
permissionMode: args.permissionMode,
|
|
4511
|
+
enabled: args.enabled,
|
|
4310
4512
|
triggerThread,
|
|
4311
4513
|
};
|
|
4312
4514
|
const r = await this.registerTriggerFromParsed(parsed, channel, channelId, userId ?? '', undefined, this.resolveMenuChatType(channel, channelId, explicitChatType), undefined, isAdmin, subject.isDaemonOwner, subject.canApprovePersistentFullAccess);
|
|
@@ -4318,7 +4520,13 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4318
4520
|
: 'INVALID_ARGS';
|
|
4319
4521
|
return { error: r.error, code };
|
|
4320
4522
|
}
|
|
4321
|
-
return { data: {
|
|
4523
|
+
return { data: {
|
|
4524
|
+
id: r.trigger.id,
|
|
4525
|
+
name: r.trigger.name,
|
|
4526
|
+
enabled: r.trigger.enabled,
|
|
4527
|
+
nextFireAt: r.trigger.nextFireAt,
|
|
4528
|
+
...(r.trigger.enabled ? {} : { enableHint: `/trigger enable ${r.trigger.id}` }),
|
|
4529
|
+
} };
|
|
4322
4530
|
}
|
|
4323
4531
|
if (action === 'cancel') {
|
|
4324
4532
|
const nameOrId = args?.nameOrId;
|
|
@@ -4527,7 +4735,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4527
4735
|
}
|
|
4528
4736
|
const actualSourceMessageId = sourceAssistantMessageId;
|
|
4529
4737
|
const historySnapshot = buildForkHistorySnapshot(messages, actualSourceMessageId);
|
|
4530
|
-
const forkedAgentSessionId = await currentAgent.forkSessionAt(current.agentSessionId, current.projectPath, actualSourceMessageId, name || undefined, { sessionId: current.id, permissionMode: subject.permissionMode, role: subject.role });
|
|
4738
|
+
const forkedAgentSessionId = await currentAgent.forkSessionAt(current.agentSessionId, current.projectPath, actualSourceMessageId, name || undefined, { sessionId: current.id, permissionMode: subject.permissionMode, role: subject.role, authorization: subject });
|
|
4531
4739
|
const topic = await this.sessionManager.createForkedThreadSession(current, forkedAgentSessionId, targetThreadId, {
|
|
4532
4740
|
name: name || undefined,
|
|
4533
4741
|
creatorPeerId: userId,
|
|
@@ -4536,6 +4744,9 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4536
4744
|
historySnapshot,
|
|
4537
4745
|
requestId,
|
|
4538
4746
|
});
|
|
4747
|
+
await currentAgent.commitSessionFork?.(forkedAgentSessionId, topic, {
|
|
4748
|
+
sessionId: current.id, authorization: subject,
|
|
4749
|
+
}).catch(async (error) => { await this.sessionManager.unbindSession(topic.id); throw error; });
|
|
4539
4750
|
await currentAgent.updateSessionMetadata?.(forkedAgentSessionId, {
|
|
4540
4751
|
evolcoreSessionId: topic.id,
|
|
4541
4752
|
sourceSessionId: current.id,
|
|
@@ -4767,6 +4978,55 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4767
4978
|
}
|
|
4768
4979
|
// ── /session 系列 ──
|
|
4769
4980
|
if (cmdBase === '/session' || cmdBase === '/s') {
|
|
4981
|
+
if (action === 'open-terminal') {
|
|
4982
|
+
if (fromControlChannel || channel.split('#', 1)[0] !== 'aun' || subject.chatType !== 'private') {
|
|
4983
|
+
return { error: '打开 Base Agent 终端仅支持 Agent AID 的 AUN 私聊请求', code: 'NOT_SUPPORTED' };
|
|
4984
|
+
}
|
|
4985
|
+
const sessionId = typeof args?.sessionId === 'string' ? args.sessionId.trim() : '';
|
|
4986
|
+
if (!sessionId)
|
|
4987
|
+
return { error: '缺少 args.sessionId', code: 'MISSING_VALUE' };
|
|
4988
|
+
const baseagent = evolagent?.baseagent;
|
|
4989
|
+
if (baseagent !== 'claude' && baseagent !== 'codex') {
|
|
4990
|
+
return { error: `当前 Agent 的 Base Agent 不支持终端恢复: ${baseagent || 'unknown'}`, code: 'NOT_SUPPORTED' };
|
|
4991
|
+
}
|
|
4992
|
+
const selfAid = evolagent?.aid ?? this.getOwningAgent?.(channel)?.aid;
|
|
4993
|
+
if (!selfAid)
|
|
4994
|
+
return { error: '当前 channel 无绑定 Agent', code: 'MISSING_AID' };
|
|
4995
|
+
const targetSession = this.sessionManager.findBoundSessionByAgentSessionId?.(sessionId, baseagent, selfAid);
|
|
4996
|
+
if (!targetSession)
|
|
4997
|
+
return { error: '找不到绑定到当前 Agent 的 Base Agent 会话', code: 'NOT_FOUND' };
|
|
4998
|
+
let currentProjectPath;
|
|
4999
|
+
try {
|
|
5000
|
+
currentProjectPath = resolveSessionTerminalProjectPath(session?.projectPath, targetSession.projectPath);
|
|
5001
|
+
}
|
|
5002
|
+
catch (error) {
|
|
5003
|
+
return { error: error instanceof Error ? error.message : String(error), code: 'PROJECT_MISMATCH' };
|
|
5004
|
+
}
|
|
5005
|
+
if (!this.sessionManager.checkSessionFileExists(currentProjectPath, sessionId, baseagent, selfAid)) {
|
|
5006
|
+
return { error: 'Base Agent 会话历史文件不存在', code: 'NOT_FOUND' };
|
|
5007
|
+
}
|
|
5008
|
+
try {
|
|
5009
|
+
const codexConfig = baseagent === 'codex'
|
|
5010
|
+
? resolveEffective({ self: selfAid }, { cache: false }).baseagents?.codex
|
|
5011
|
+
: undefined;
|
|
5012
|
+
const connection = codexConfig?.provider
|
|
5013
|
+
? resolveOpenaiConfig({ agents: { codex: codexConfig } })
|
|
5014
|
+
: undefined;
|
|
5015
|
+
const codexProvider = connection?.providerId ? {
|
|
5016
|
+
providerId: connection.providerId,
|
|
5017
|
+
apiKey: connection.apiKey,
|
|
5018
|
+
baseUrl: connection.baseUrl,
|
|
5019
|
+
headers: buildModelRequestHeaders({ baseagent: 'codex', baseUrl: connection.baseUrl,
|
|
5020
|
+
agentAid: selfAid, configuredHeaders: connection.headers }),
|
|
5021
|
+
queryParams: connection.queryParams,
|
|
5022
|
+
} : undefined;
|
|
5023
|
+
await openSessionInTerminal({ baseagent, sessionId, cwd: currentProjectPath, codexProvider });
|
|
5024
|
+
return { data: { action: 'open-terminal', success: true, baseagent, sessionId } };
|
|
5025
|
+
}
|
|
5026
|
+
catch (error) {
|
|
5027
|
+
return { error: error instanceof Error ? error.message : String(error), code: 'TERMINAL_OPEN_FAILED' };
|
|
5028
|
+
}
|
|
5029
|
+
}
|
|
4770
5030
|
if (action === 'stop') {
|
|
4771
5031
|
if (!session)
|
|
4772
5032
|
return { error: '当前无活跃会话', code: 'NO_ACTIVE_SESSION' };
|
|
@@ -4947,7 +5207,8 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4947
5207
|
isPendingInRegistry: () => hasLiveRestartMonitor({ requestId }),
|
|
4948
5208
|
});
|
|
4949
5209
|
if (!restartLaunch.ok) {
|
|
4950
|
-
|
|
5210
|
+
const pending = readRestartRequest(pendingFile, requestId);
|
|
5211
|
+
if (restartLaunch.pending || (pending?.backend === 'systemd' && ['requested', 'accepted'].includes(pending.status))) {
|
|
4951
5212
|
logger.error(`[System] Restart ownership is still unconfirmed (requestId=${restartRequestId}, PID=${restartLaunch.pid ?? 'unknown'})`);
|
|
4952
5213
|
return {
|
|
4953
5214
|
error: `重启请求状态暂不可确认(requestId=${restartRequestId})。启动链仍在运行,可能继续执行;请勿立即重复发起。诊断日志:${logFilePath},monitor 记录见 restart.log。`,
|
|
@@ -4961,13 +5222,14 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4961
5222
|
},
|
|
4962
5223
|
};
|
|
4963
5224
|
}
|
|
4964
|
-
|
|
5225
|
+
if (pending?.backend !== 'systemd')
|
|
5226
|
+
removeRestartRequest(pendingFile, requestId);
|
|
4965
5227
|
logger.error(`[System] Refusing menu restart: restart-monitor did not take ownership (${restartLaunch.reason})`);
|
|
4966
5228
|
for (const line of (restartLaunch.stderrTail ?? '').split(/\r?\n/).filter(Boolean).slice(-8)) {
|
|
4967
5229
|
logger.error(`[System] | ${line}`);
|
|
4968
5230
|
}
|
|
4969
5231
|
return {
|
|
4970
|
-
error:
|
|
5232
|
+
error: `重启未确认完成:${pending?.reason ?? restartLaunch.reason}。请检查重启日志和所属服务状态。`,
|
|
4971
5233
|
code: 'RESTART_MONITOR_DEAD',
|
|
4972
5234
|
data: {
|
|
4973
5235
|
reasonCode: 'RESTART_MONITOR_DEAD',
|
|
@@ -4977,7 +5239,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4977
5239
|
},
|
|
4978
5240
|
};
|
|
4979
5241
|
}
|
|
4980
|
-
logger.info(`[System] Restart
|
|
5242
|
+
logger.info(`[System] Restart lifecycle accepted request ${restartRequestId} (PID ${restartLaunch.pid ?? 'unknown'})`);
|
|
4981
5243
|
}
|
|
4982
5244
|
else {
|
|
4983
5245
|
logger.info('[System] Suppressed real menu restart in test runtime');
|
|
@@ -5386,10 +5648,31 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
5386
5648
|
}
|
|
5387
5649
|
else {
|
|
5388
5650
|
const projectPath = session?.projectPath ?? evolagent?.projectPath ?? this.getOwningAgent?.(channel)?.projectPath;
|
|
5389
|
-
const resolved = resolveMenuFilePath(args?.path, projectPath, identity.role, 'file');
|
|
5651
|
+
const resolved = resolveMenuFilePath(args?.path, projectPath, identity.role, 'file', menuFileFallbackRoots(subject));
|
|
5390
5652
|
if ('error' in resolved)
|
|
5391
5653
|
return resolved;
|
|
5392
5654
|
({ realPath, stat } = resolved);
|
|
5655
|
+
if (identity.role === 'owner') {
|
|
5656
|
+
const denied = await authorizeMenuIntent.call(this, {
|
|
5657
|
+
intent: buildMenuIntent('action', cmdBase, { ...args, path: realPath }, 'fetch'),
|
|
5658
|
+
identity: authIdentity, subject, session: authSession, explicitChatType,
|
|
5659
|
+
channel, channelId, userId, fromControlChannel, source,
|
|
5660
|
+
});
|
|
5661
|
+
if (denied)
|
|
5662
|
+
return denied;
|
|
5663
|
+
}
|
|
5664
|
+
}
|
|
5665
|
+
if (args?.resourceVersion !== undefined || args?.maxBytes !== undefined) {
|
|
5666
|
+
if (dataRoot?.scope !== 'panel-output' || typeof args?.resourceVersion !== 'string'
|
|
5667
|
+
|| !/^[a-f0-9]{24}$/.test(args.resourceVersion)
|
|
5668
|
+
|| !Number.isSafeInteger(args.maxBytes) || args.maxBytes < 1 || args.maxBytes > FILE_FETCH_MAX_SIZE) {
|
|
5669
|
+
return { error: 'Invalid panel resource fetch parameters', code: 'INVALID_ARGUMENT' };
|
|
5670
|
+
}
|
|
5671
|
+
if (panelResourceVersion(stat) !== args.resourceVersion) {
|
|
5672
|
+
return { error: 'Panel resource changed', code: 'RESOURCE_EXPIRED' };
|
|
5673
|
+
}
|
|
5674
|
+
if (stat.size > args.maxBytes)
|
|
5675
|
+
return { error: 'Panel resource exceeds its size limit', code: 'FILE_TOO_LARGE' };
|
|
5393
5676
|
}
|
|
5394
5677
|
if (stat.size > FILE_FETCH_MAX_SIZE) {
|
|
5395
5678
|
return { error: `文件过大: ${(stat.size / 1024 / 1024).toFixed(1)} MB (限制 ${FILE_FETCH_MAX_SIZE / 1024 / 1024} MB)`, code: 'FILE_TOO_LARGE' };
|
|
@@ -5400,7 +5683,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
5400
5683
|
if (!adapter.capabilities?.file)
|
|
5401
5684
|
return { error: '通道不支持文件发送', code: 'NOT_SUPPORTED' };
|
|
5402
5685
|
const sessionReplyContext = session ? replyContextFromSession(session, this.getReplyContext(session)) : undefined;
|
|
5403
|
-
|
|
5686
|
+
let replyCtx = transportReplyContext
|
|
5404
5687
|
? {
|
|
5405
5688
|
...(sessionReplyContext ?? {}),
|
|
5406
5689
|
...transportReplyContext,
|
|
@@ -5410,7 +5693,16 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
5410
5693
|
},
|
|
5411
5694
|
}
|
|
5412
5695
|
: sessionReplyContext;
|
|
5696
|
+
if (dataRoot?.scope === 'panel-output') {
|
|
5697
|
+
replyCtx = { ...replyCtx, metadata: { ...replyCtx?.metadata, encrypted: true } };
|
|
5698
|
+
}
|
|
5413
5699
|
const sendFile = async () => {
|
|
5700
|
+
if (dataRoot?.scope === 'panel-output') {
|
|
5701
|
+
const current = dataRootResolver.resolvePath(args?.rootId, subject, args?.path, 'file');
|
|
5702
|
+
if (current.realPath !== realPath || panelResourceVersion(current.stat) !== panelResourceVersion(stat)) {
|
|
5703
|
+
throw new DataRootError('RESOURCE_EXPIRED', 'Panel resource changed');
|
|
5704
|
+
}
|
|
5705
|
+
}
|
|
5414
5706
|
const receipt = await adapter.send(buildEnvelope({ channel: adapter.channelName, channelId, replyContext: replyCtx }), { kind: 'result.file', filePath: realPath, correlationId: requestId });
|
|
5415
5707
|
if (receipt && typeof receipt === 'object' && receipt.status === 'failed') {
|
|
5416
5708
|
throw Object.assign(new Error(receipt.error || '文件发送失败'), {
|
|
@@ -5482,6 +5774,8 @@ function menuCommandToken(cmd) {
|
|
|
5482
5774
|
}
|
|
5483
5775
|
function isProcessLevelMenu(name, cmd) {
|
|
5484
5776
|
const cmdToken = menuCommandToken(cmd);
|
|
5777
|
+
if (name === 'plugins' || cmdToken === '/plugins')
|
|
5778
|
+
return true;
|
|
5485
5779
|
return name === 'provider' || cmdToken === '/provider' || name === 'system' || name === 'agent' || name === 'gateway' || name === 'config' || name === 'baseagent-models' || name === 'baseagents'
|
|
5486
5780
|
|| cmdToken === '/system' || cmdToken === '/agent' || cmdToken === '/gateway' || cmdToken === '/config' || cmdToken === '/baseagent-models' || cmdToken === '/baseagents';
|
|
5487
5781
|
}
|
|
@@ -5511,8 +5805,10 @@ async function execMenuForSystemControl(payload, context) {
|
|
|
5511
5805
|
const isDataRootQuery = payload?.type === 'menu.query'
|
|
5512
5806
|
&& (name === 'agent-data-root'
|
|
5513
5807
|
|| name === 'relation-data-root'
|
|
5808
|
+
|| name === 'panel-cards-data-root'
|
|
5514
5809
|
|| compatCmd === '/agent-data-root'
|
|
5515
|
-
|| compatCmd === '/relation-data-root'
|
|
5810
|
+
|| compatCmd === '/relation-data-root'
|
|
5811
|
+
|| compatCmd === '/panel-cards-data-root');
|
|
5516
5812
|
const isRootedFile = (name === 'file' || compatCmd === '/file')
|
|
5517
5813
|
&& typeof payload?.args?.rootId === 'string';
|
|
5518
5814
|
if (isFileFetch || isDataRootQuery || isRootedFile || isAgentStorageMenuRequest(payload ?? {})) {
|
|
@@ -5533,9 +5829,9 @@ async function execMenuForSystemControl(payload, context) {
|
|
|
5533
5829
|
const isConnectRequest = name === 'connect' || compatCmd === '/connect';
|
|
5534
5830
|
const requiresAgentTarget = (name === 'menu' && payload?.type === 'menu.query' && payload?.args?.view === 'queries')
|
|
5535
5831
|
|| isRoleRequest || isConnectRequest || [
|
|
5536
|
-
'observable', 'baseagent', 'model', 'effort', 'trigger', 'capability', 'group', 'aid', 'team-workspace', 'slash-commands', 'events',
|
|
5832
|
+
'observable', 'baseagent', 'model', 'effort', 'trigger', 'capability', 'group', 'aid', 'team-workspace', 'slash-commands', 'events', 'private-mention-mode', 'context-policy',
|
|
5537
5833
|
].includes(name)
|
|
5538
|
-
|| ['/observable', '/baseagent', '/model', '/effort', '/trigger', '/capability', '/group', '/aid', '/team-workspace', '/evolhelp', '/events'].includes(compatCmd ?? '')
|
|
5834
|
+
|| ['/observable', '/baseagent', '/model', '/effort', '/trigger', '/capability', '/group', '/aid', '/team-workspace', '/evolhelp', '/events', '/private-mention-mode', '/context-policy'].includes(compatCmd ?? '')
|
|
5539
5835
|
|| (!isProcessLevel && requestedContextKind !== undefined && requestedContextKind !== 'process');
|
|
5540
5836
|
const target = isProcessLevel
|
|
5541
5837
|
? { channel: SYSTEM_CONTROL_CHANNEL }
|
|
@@ -5720,9 +6016,12 @@ async function execMenuForSystemControl(payload, context) {
|
|
|
5720
6016
|
channelId: targetChannel,
|
|
5721
6017
|
args: payload.args,
|
|
5722
6018
|
});
|
|
6019
|
+
const actionArgs = payload.action === 'create' && (name === 'provider' || menuCommandToken(payload.cmd) === '/provider') && payload.value !== undefined
|
|
6020
|
+
? { ...(execution.args ?? {}), provider: payload.value }
|
|
6021
|
+
: execution.args;
|
|
5723
6022
|
const r = hasExplicitContext
|
|
5724
|
-
? await this.execMenuAction(cmd, payload.action,
|
|
5725
|
-
: await this.execMenuAction(cmd, payload.action,
|
|
6023
|
+
? await this.execMenuAction(cmd, payload.action, actionArgs, targetChannel, execution.channelId, execution.subject.actorId, execution.subject.identity, execution.subject.chatType, id, true, execution.subject, context.source)
|
|
6024
|
+
: await this.execMenuAction(cmd, payload.action, actionArgs, targetChannel, targetChannel, context.actorAid, trustedIdentity, undefined, id, true, trustedSubject, context.source);
|
|
5726
6025
|
return ecwebResp(id, name, r);
|
|
5727
6026
|
}
|
|
5728
6027
|
default:
|