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,15 +1,15 @@
|
|
|
1
1
|
import { parsePermissionApprovalDecision } from '../permission/approval-gateway.js';
|
|
2
|
-
import { hasModelSwitcher, hasPermissionController } from '
|
|
3
|
-
import { normalizeBaseagent, resolveBaseagentModelSelection } from '
|
|
2
|
+
import { hasModelSwitcher, hasPermissionController } from '../baseagent/runner-types.js';
|
|
3
|
+
import { normalizeBaseagent, resolveBaseagentModelSelection } from '../baseagent/baseagent.js';
|
|
4
4
|
import { buildEnvelope, isDeliveryTargetForChannel } from '../message/message-utils.js';
|
|
5
5
|
import { resolvePaths, getPackageRoot, daemonControlDir } from '../../paths.js';
|
|
6
6
|
import { logger } from '../../utils/logger.js';
|
|
7
|
-
import { shouldSuppressRealRestart, createRestartRequest, updateRestartRequest, removeRestartRequest } from '../../utils/restart-safety.js';
|
|
8
|
-
import { RESTART_REQUEST_ID_ENV } from '../../product.js';
|
|
7
|
+
import { shouldSuppressRealRestart, createRestartRequest, readRestartRequest, updateRestartRequest, removeRestartRequest } from '../../utils/restart-safety.js';
|
|
8
|
+
import { RESTART_REQUEST_ID_ENV, RUNTIME_HOME_ENV, SESSION_ID_ENV } from '../../product.js';
|
|
9
|
+
import { AGENT_DELEGATION_TOKEN_ENV } from '../auth/agent-delegation.js';
|
|
9
10
|
import crypto from 'crypto';
|
|
10
11
|
import path from 'path';
|
|
11
12
|
import fs from 'fs';
|
|
12
|
-
import { ensureFreshPackageVersionInfo } from '../../utils/package-version-info.js';
|
|
13
13
|
import { executeUpgradeAction, formatUpgradeResult, subscribeUpgradeJob } from '../../utils/upgrade-jobs.js';
|
|
14
14
|
import { loadDaemonConfig } from '../../config-store.js';
|
|
15
15
|
import { formatPairingCodeMessage } from '../../ecweb/pairing.js';
|
|
@@ -36,24 +36,26 @@ import { displaySessionTitle } from '../session/session-title.js';
|
|
|
36
36
|
import { chatmodeFieldForPeer, isChatMode, isPrivateChatmodeRoleLocked, resolveChatModeForField } from '../message/peer-mode.js';
|
|
37
37
|
import { normalizePermissionMode as normalizePermissionModeContract, PUBLIC_PERMISSION_MODES } from '../permission/mode.js';
|
|
38
38
|
import { isManagementRole } from '../../config/builtin-roles.js';
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
39
|
+
import { assertDeclaredBaseagentCapability } from '../baseagent/baseagent-capability-adapter.js';
|
|
40
|
+
import { isSystemControlChannel } from '../channel/system-channels.js';
|
|
41
|
+
import { resolveCliEntry, launchMonitorAndConfirm, isProcessRunning } from '../../utils/cross-platform.js';
|
|
41
42
|
import { hasLiveRestartMonitor } from '../../utils/instance-registry.js';
|
|
42
43
|
import { guardIdleCommand, guardGroupSlashCommand, guardKnownCommand, guardRoleCommand, guardThreadCommand, isRecognizedSlashCommand, normalizeSlashContent, parseFullAccessCommand, probeSessionActivity, } from './slash-gate.js';
|
|
43
44
|
import { MAX_AUN_ATTACHMENT_SIZE } from '../../aun/msg/upload.js';
|
|
45
|
+
import { formatCompactingNotice, readLastModelCallContextUsage } from '../../stats/context-usage.js';
|
|
44
46
|
import { DEFAULT_SESSION_LOOP_SECONDS, MAX_SESSION_LOOP_PROMPT_LENGTH, MAX_SESSION_LOOP_SECONDS, MIN_SESSION_LOOP_SECONDS, refreshSessionLoopTarget, resolveCurrentSessionLoopTarget, resolveSessionLoopTarget, sessionLoopPayload, validateIdleSeconds, writeSessionLoopConfig, } from '../session/session-idle-monitor.js';
|
|
45
47
|
const allEfforts = CONFIGURABLE_EFFORTS;
|
|
46
48
|
const PERMISSION_MODE_KEYS = PUBLIC_PERMISSION_MODES;
|
|
47
|
-
function formatSessionPolicyStatus(name, scope, enabled
|
|
48
|
-
return `${
|
|
49
|
+
function formatSessionPolicyStatus(name, scope, enabled) {
|
|
50
|
+
return `${name} 当前生效:${enabled ? '开启' : '关闭'}(${scope})`;
|
|
49
51
|
}
|
|
50
52
|
function formatUpgradeEvent(event) {
|
|
51
53
|
if (event.event === 'upgrade.progress')
|
|
52
|
-
return
|
|
54
|
+
return event.message;
|
|
53
55
|
if (event.status === 'no-update')
|
|
54
|
-
return '
|
|
56
|
+
return '当前 EvolCore 已是最新版本';
|
|
55
57
|
if (event.status === 'restart-started')
|
|
56
|
-
return '
|
|
58
|
+
return '升级包已准备完成,服务正在重启';
|
|
57
59
|
if (event.status === 'timeout')
|
|
58
60
|
return `❌ 升级超时:${event.reason ?? event.message}`;
|
|
59
61
|
if (event.status === 'failed')
|
|
@@ -387,7 +389,7 @@ async function getGitWorkingDirInfo(projectPath) {
|
|
|
387
389
|
return null; // git 命令失败时静默返回 null
|
|
388
390
|
}
|
|
389
391
|
}
|
|
390
|
-
export async function handleSlashCommand(content, channel, channelId, sendMessage, userId, threadId, chatType, source, messageId, selfAID, overrideIdentity, overrideSubject, replyContext, applyGroupSlashPolicy = false) {
|
|
392
|
+
export async function handleSlashCommand(content, channel, channelId, sendMessage, userId, threadId, chatType, source, messageId, selfAID, overrideIdentity, overrideSubject, replyContext, applyGroupSlashPolicy = false, submitLoopPrompt) {
|
|
391
393
|
// 卡片回调的 chatType 不可靠(飞书 bot 单聊 chatId 也是 oc_ 前缀),
|
|
392
394
|
// 不应覆盖 session 中已有的正确值
|
|
393
395
|
if (source === 'card-trigger')
|
|
@@ -637,9 +639,52 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
637
639
|
return { kind: 'command.error', text: `❌ 秒数必须是 ${MIN_SESSION_LOOP_SECONDS}-${MAX_SESSION_LOOP_SECONDS} 的整数` };
|
|
638
640
|
next = { enabled: true, idleSeconds: seconds };
|
|
639
641
|
}
|
|
642
|
+
const writeLoop = (current) => {
|
|
643
|
+
if (next.enabled)
|
|
644
|
+
this.assertSessionLoopTrigger(current.session);
|
|
645
|
+
const updated = writeSessionLoopConfig(this.sessionManager, current, next);
|
|
646
|
+
if (!next.enabled)
|
|
647
|
+
this.sessionManager.consumeSessionLoopOnce(updated.session.id);
|
|
648
|
+
const payload = sessionLoopPayload(updated);
|
|
649
|
+
return {
|
|
650
|
+
kind: 'system.notice',
|
|
651
|
+
text: formatSessionPolicyStatus('idle 触发', updated.level, payload.value === true)
|
|
652
|
+
+ (payload.value ? `(${payload.idleSeconds} 秒)` : ';已取消待执行的单次触发'),
|
|
653
|
+
subtype: 'session.loop.updated',
|
|
654
|
+
};
|
|
655
|
+
};
|
|
640
656
|
try {
|
|
641
657
|
const latest = await refreshSessionLoopTarget(this.sessionManager, route, target);
|
|
642
658
|
if (oncePrompt) {
|
|
659
|
+
const sessionId = latest.session.id;
|
|
660
|
+
const idle = submitLoopPrompt && probeSessionActivity(this.messageQueue.getSessionSnapshot(sessionId), {
|
|
661
|
+
paused: () => this.processor?.isPauseRequested?.(sessionId) ?? false,
|
|
662
|
+
activeStream: () => {
|
|
663
|
+
const runner = this.getLoadedAgent(channel, latest.session.baseagent);
|
|
664
|
+
return runner?.hasActiveStream(sessionId) || runner?.hasActiveOperation?.(sessionId) === true
|
|
665
|
+
|| runner?.getExecutionState?.(sessionId) === 'interrupting';
|
|
666
|
+
},
|
|
667
|
+
pendingInteraction: () => (this.interactionRouter?.getPending(sessionId).length ?? 0) > 0,
|
|
668
|
+
}) === 'idle';
|
|
669
|
+
if (submitLoopPrompt && idle) {
|
|
670
|
+
submitLoopPrompt({
|
|
671
|
+
prompt: oncePrompt,
|
|
672
|
+
sessionId,
|
|
673
|
+
enableLoop: async () => {
|
|
674
|
+
try {
|
|
675
|
+
const current = await refreshSessionLoopTarget(this.sessionManager, route, latest);
|
|
676
|
+
return writeLoop(current);
|
|
677
|
+
}
|
|
678
|
+
catch (error) {
|
|
679
|
+
return {
|
|
680
|
+
kind: 'command.error',
|
|
681
|
+
text: `指令已提交,开启 loop 失败:${error instanceof Error ? error.message : String(error)}`,
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
},
|
|
685
|
+
});
|
|
686
|
+
return null;
|
|
687
|
+
}
|
|
643
688
|
this.assertSessionLoopTrigger(latest.session, true);
|
|
644
689
|
this.sessionManager.updateSessionLoopOnce(latest.session.id, {
|
|
645
690
|
idleSeconds: DEFAULT_SESSION_LOOP_SECONDS,
|
|
@@ -650,24 +695,14 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
650
695
|
return null;
|
|
651
696
|
return {
|
|
652
697
|
kind: 'system.notice',
|
|
653
|
-
text:
|
|
698
|
+
text: `单次 idle 触发(${latest.level})已安排;闲置时长:${DEFAULT_SESSION_LOOP_SECONDS} 秒;提示词:${oncePrompt.replace(/\s+/g, ' ').slice(0, 120)}`,
|
|
654
699
|
subtype: 'session.loop.once.updated',
|
|
655
700
|
};
|
|
656
701
|
}
|
|
657
|
-
|
|
658
|
-
this.assertSessionLoopTrigger(latest.session);
|
|
659
|
-
const updated = writeSessionLoopConfig(this.sessionManager, latest, next);
|
|
660
|
-
if (!next.enabled)
|
|
661
|
-
this.sessionManager.consumeSessionLoopOnce(updated.session.id);
|
|
662
|
-
const payload = sessionLoopPayload(updated);
|
|
702
|
+
const result = writeLoop(latest);
|
|
663
703
|
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
664
704
|
return null;
|
|
665
|
-
return
|
|
666
|
-
kind: 'system.notice',
|
|
667
|
-
text: formatSessionPolicyStatus('idle 触发', updated.level, payload.value === true, true)
|
|
668
|
-
+ (payload.value ? `(${payload.idleSeconds} 秒)` : ';已取消待执行的单次触发'),
|
|
669
|
-
subtype: 'session.loop.updated',
|
|
670
|
-
};
|
|
705
|
+
return result;
|
|
671
706
|
}
|
|
672
707
|
catch (error) {
|
|
673
708
|
return { kind: 'command.error', text: `❌ ${error instanceof Error ? error.message : String(error)}` };
|
|
@@ -691,7 +726,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
691
726
|
return { kind: 'command.error', text: '❌ /fa 需要同一身份同时具备 Agent Owner 和 daemon Owner 权限' };
|
|
692
727
|
}
|
|
693
728
|
const status = sessionFullAccessStatus(commandSession, principalId);
|
|
694
|
-
const formatStatus = (current
|
|
729
|
+
const formatStatus = (current) => formatSessionPolicyStatus('fullaccess', current.scope, current.effective)
|
|
695
730
|
+ ';Agent 全局:' + (current.globalEnabled ? '开启' : '关闭')
|
|
696
731
|
+ ';作用域设置:' + (current.localEnabled ? '开启' : '关闭')
|
|
697
732
|
+ (current.globalEnabled ? '(被全局覆盖)' : '');
|
|
@@ -742,7 +777,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
742
777
|
});
|
|
743
778
|
return {
|
|
744
779
|
kind: 'system.notice',
|
|
745
|
-
text: formatStatus(sessionFullAccessStatus(updatedSession, principalId)
|
|
780
|
+
text: formatStatus(sessionFullAccessStatus(updatedSession, principalId)),
|
|
746
781
|
subtype: 'session.fullaccess.updated',
|
|
747
782
|
};
|
|
748
783
|
}
|
|
@@ -873,7 +908,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
873
908
|
' /baseagent - 查看 Agent 后端',
|
|
874
909
|
' /perm - 查看权限模式',
|
|
875
910
|
' /mention - 查看群聊 @ 处理模式',
|
|
876
|
-
...(canReadLoop ? [` /loop${canUpdateLoop ? ' [on [seconds]|off|<提示词>]' : ''} - 查看${canUpdateLoop ? '或设置' : ''}
|
|
911
|
+
...(canReadLoop ? [` /loop${canUpdateLoop ? ' [on [seconds]|off|<提示词>]' : ''} - 查看${canUpdateLoop ? '或设置' : ''}当前会话的闲置触发`] : []),
|
|
877
912
|
' /ask <选项> - 回答待处理问题',
|
|
878
913
|
' /pause - 在下一次工具调用前暂停任务',
|
|
879
914
|
' /resume - 继续已暂停的任务',
|
|
@@ -905,7 +940,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
905
940
|
const appendProcessCommands = (lines) => {
|
|
906
941
|
if (!isDaemonOwner)
|
|
907
942
|
return;
|
|
908
|
-
lines.push('', '
|
|
943
|
+
lines.push('', '进程级运维:', ' /restart - 重启服务', ' /upgrade - 检查版本更新', ' /update [status] - 执行版本升级或查询当前升级状态', ' /reload [aid] - 热重载 Agent 配置', ' /fa [on|off|<任务信息>] - 查看/切换会话 fullaccess,或单次执行任务', ' /pair - 获取远程控制配对码', ' /diag <问题描述> - 邀请或追加远程诊断;/diag stop 撤销授权');
|
|
909
944
|
};
|
|
910
945
|
if (!isAdmin && activeChatType === 'group') {
|
|
911
946
|
const lines = [
|
|
@@ -920,12 +955,12 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
920
955
|
'',
|
|
921
956
|
'💬 聊天设置:',
|
|
922
957
|
...(canReadChatmode || canSetChatmode ? [` /chatmode${canSetChatmode ? ` [${chatmodeChoices}]` : ''} - 查看${canSetChatmode ? '或切换' : ''}会话模式`] : []),
|
|
923
|
-
...(canReadLoop ? [` /loop${canUpdateLoop ? ' [on [seconds]|off|<提示词>]' : ''} - 查看${canUpdateLoop ? '或设置' : ''}
|
|
958
|
+
...(canReadLoop ? [` /loop${canUpdateLoop ? ' [on [seconds]|off|<提示词>]' : ''} - 查看${canUpdateLoop ? '或设置' : ''}当前会话的闲置触发`] : []),
|
|
924
959
|
...(canReadMentionmode || canSetMentionmode ? [` /mention${canSetMentionmode ? ' [mention-only|disabled]' : ''} - 查看${canSetMentionmode ? '或切换' : ''}群聊 @ 处理模式`] : []),
|
|
925
960
|
] : []),
|
|
926
961
|
...(canReadPermission || canAnswerPermission ? [
|
|
927
962
|
'',
|
|
928
|
-
'
|
|
963
|
+
'权限管理:',
|
|
929
964
|
...(canReadPermission ? [' /perm - 查看当前权限模式'] : []),
|
|
930
965
|
...(canAnswerPermission ? [' /perm <动作> - 审批权限请求(按授权卡选项)'] : []),
|
|
931
966
|
] : []),
|
|
@@ -943,7 +978,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
943
978
|
const lines = [
|
|
944
979
|
'可用命令:',
|
|
945
980
|
'',
|
|
946
|
-
'
|
|
981
|
+
'会话管理:',
|
|
947
982
|
' /new [名称] - 创建新会话(清空历史请用此命令,可选命名)',
|
|
948
983
|
' /s [cli|名称|序号|uuid] - 列出或切换会话(cli 查看未导入的 CLI 会话)',
|
|
949
984
|
' /name <新名称> - 重命名当前会话',
|
|
@@ -965,10 +1000,10 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
965
1000
|
'💬 聊天设置:',
|
|
966
1001
|
` /chatmode${canSetChatmode ? ` [${chatmodeChoices}]` : ''} - 查看${canSetChatmode ? '或切换' : ''}会话模式`,
|
|
967
1002
|
] : []),
|
|
968
|
-
...(canReadLoop ? ['', ` /loop${canUpdateLoop ? ' [on [seconds]|off|<提示词>]' : ''} - 查看${canUpdateLoop ? '或设置' : ''}
|
|
1003
|
+
...(canReadLoop ? ['', ` /loop${canUpdateLoop ? ' [on [seconds]|off|<提示词>]' : ''} - 查看${canUpdateLoop ? '或设置' : ''}当前会话的闲置触发`] : []),
|
|
969
1004
|
...(canReadPermission || canAnswerPermission ? [
|
|
970
1005
|
'',
|
|
971
|
-
'
|
|
1006
|
+
'权限管理:',
|
|
972
1007
|
...(canReadPermission ? [' /perm - 查看当前权限模式'] : []),
|
|
973
1008
|
...(canAnswerPermission ? [' /perm <动作> - 审批权限请求(按授权卡选项)'] : []),
|
|
974
1009
|
] : []),
|
|
@@ -988,10 +1023,10 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
988
1023
|
const lines = [
|
|
989
1024
|
'可用命令:',
|
|
990
1025
|
'',
|
|
991
|
-
'
|
|
1026
|
+
'项目:',
|
|
992
1027
|
' /pwd - 显示当前项目路径',
|
|
993
1028
|
'',
|
|
994
|
-
'
|
|
1029
|
+
'会话管理:',
|
|
995
1030
|
' /new [名称] - 创建新会话(清空历史请用此命令,可选命名)',
|
|
996
1031
|
' /s [cli|名称|序号|uuid] - 列出或切换会话(cli 查看未导入的 CLI 会话)',
|
|
997
1032
|
' /name <新名称> - 重命名当前会话',
|
|
@@ -1013,19 +1048,19 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1013
1048
|
' /activity [all|text|none] - 查看/控制中间输出显示模式',
|
|
1014
1049
|
...(canReadChatmode || canSetChatmode ? [` /chatmode${canSetChatmode ? ` [${chatmodeChoices}]` : ''} - 查看${canSetChatmode ? '/切换' : ''}会话模式(被动响应或主动推进)`] : []),
|
|
1015
1050
|
...(canReadMentionmode || canSetMentionmode ? [` /mention${canSetMentionmode ? ' [mention-only|disabled]' : ''} - 查看${canSetMentionmode ? '/切换' : ''}群聊 @ 处理模式`] : []),
|
|
1016
|
-
...(canReadLoop ? [` /loop${canUpdateLoop ? ' [on [seconds]|off|<提示词>]' : ''} - 查看${canUpdateLoop ? '或设置' : ''}
|
|
1051
|
+
...(canReadLoop ? [` /loop${canUpdateLoop ? ' [on [seconds]|off|<提示词>]' : ''} - 查看${canUpdateLoop ? '或设置' : ''}当前会话的闲置触发`] : []),
|
|
1017
1052
|
'',
|
|
1018
|
-
'
|
|
1053
|
+
'上下文:',
|
|
1019
1054
|
' /memory - 记忆概览与维护',
|
|
1020
1055
|
' /skill - 技能列表与索引刷新',
|
|
1021
1056
|
' /thread - 话题列表、更名与 summary',
|
|
1022
1057
|
'',
|
|
1023
|
-
'
|
|
1058
|
+
'权限管理:',
|
|
1024
1059
|
...(canReadPermission ? [' /perm - 查看当前权限模式'] : []),
|
|
1025
1060
|
...(canReadPermission ? [' 权限模式请通过角色策略编辑器修改'] : []),
|
|
1026
1061
|
...(canAnswerPermission ? [' /perm <动作> - 审批权限请求(按授权卡选项)'] : []),
|
|
1027
1062
|
'',
|
|
1028
|
-
'
|
|
1063
|
+
'运维:',
|
|
1029
1064
|
' /status - 显示会话状态',
|
|
1030
1065
|
' /pause - 在下一次工具调用前暂停当前任务',
|
|
1031
1066
|
' /resume - 继续暂停或异常中断的当前任务',
|
|
@@ -1097,7 +1132,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1097
1132
|
const loopHelp = canReadLoop || canUpdateLoop ? [{
|
|
1098
1133
|
command: '/loop',
|
|
1099
1134
|
...(canUpdateLoop ? { args: '[on [seconds]|off|<提示词>]' } : {}),
|
|
1100
|
-
description: '
|
|
1135
|
+
description: '查看或设置闲置触发。带提示词时,空闲会话先提交提示词再开启 loop,忙碌会话闲置 300 秒后执行一次',
|
|
1101
1136
|
category: '聊天设置',
|
|
1102
1137
|
roles: [identity.role],
|
|
1103
1138
|
}] : [];
|
|
@@ -1236,12 +1271,12 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1236
1271
|
if (normalizedContent.startsWith('/perm')) {
|
|
1237
1272
|
const args = normalizedContent.slice(5).trim();
|
|
1238
1273
|
const permissionDecisionLabels = {
|
|
1239
|
-
allow: '
|
|
1240
|
-
always: '
|
|
1241
|
-
file_60m: '
|
|
1242
|
-
directory_60m: '
|
|
1243
|
-
all_directories_60m: '
|
|
1244
|
-
deny: '
|
|
1274
|
+
allow: '已授权(本次),继续执行……',
|
|
1275
|
+
always: '已授权(当前会话临时授权 30 分钟),继续执行……',
|
|
1276
|
+
file_60m: '已授权(同文件 60 分钟),继续执行……',
|
|
1277
|
+
directory_60m: '已授权(当前目录及子目录 60 分钟),继续执行……',
|
|
1278
|
+
all_directories_60m: '已授权(当前会话所有普通目录 60 分钟),继续执行……',
|
|
1279
|
+
deny: '已拒绝',
|
|
1245
1280
|
};
|
|
1246
1281
|
// Explicit request IDs are globally unique and already bound to an exact
|
|
1247
1282
|
// authenticated approver in PermissionGateway. Handle this before session
|
|
@@ -1385,7 +1420,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1385
1420
|
return { kind: 'command.error', text: '❌ 当前没有待回答的问题' };
|
|
1386
1421
|
const fb = await this.handleInteractionFallback('ask', args, askSession.id, userId, this.getAdapter(channel)?.channelKey);
|
|
1387
1422
|
if (fb.matched)
|
|
1388
|
-
return { kind: 'command.result', text: fb.result ?? '
|
|
1423
|
+
return { kind: 'command.result', text: fb.result ?? '已回答' };
|
|
1389
1424
|
return { kind: 'command.error', text: '❌ 当前没有待回答的问题' };
|
|
1390
1425
|
}
|
|
1391
1426
|
// /pause gates the next tool; /resume also recovers a failed backend turn.
|
|
@@ -1398,6 +1433,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1398
1433
|
return { kind: 'system.notice', text: '当前没有活跃会话', subtype: 'session.pause.idle' };
|
|
1399
1434
|
}
|
|
1400
1435
|
const pauseAgent = await this.ensureAgent(channel, pauseSession.baseagent);
|
|
1436
|
+
assertDeclaredBaseagentCapability(pauseSession.baseagent, 'X01');
|
|
1401
1437
|
const hasActiveTask = pauseAgent.hasActiveStream(pauseSession.id)
|
|
1402
1438
|
|| this.messageQueue.isProcessing(pauseSession.id);
|
|
1403
1439
|
if (!hasActiveTask) {
|
|
@@ -1407,7 +1443,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1407
1443
|
return {
|
|
1408
1444
|
kind: 'system.notice',
|
|
1409
1445
|
text: requested
|
|
1410
|
-
? '
|
|
1446
|
+
? '已请求暂停,任务将在下一次工具调用前暂停'
|
|
1411
1447
|
: '当前任务已请求暂停或正在暂停',
|
|
1412
1448
|
subtype: 'session.pause.requested',
|
|
1413
1449
|
};
|
|
@@ -1497,7 +1533,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1497
1533
|
this.eventBus.publish({ type: 'agent:baseagent-changed', aid: owningAgent.aid, baseagent: args, previousBaseagent, scope: 'agent', timestamp: Date.now() });
|
|
1498
1534
|
return {
|
|
1499
1535
|
kind: 'command.result',
|
|
1500
|
-
text:
|
|
1536
|
+
text: `新会话默认 Baseagent: ${previousBaseagent} → ${args}`
|
|
1501
1537
|
+ (currentSession ? `\n当前会话继续使用 ${currentSession.baseagent}。` : ''),
|
|
1502
1538
|
};
|
|
1503
1539
|
}
|
|
@@ -1592,7 +1628,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1592
1628
|
});
|
|
1593
1629
|
return {
|
|
1594
1630
|
kind: 'command.result',
|
|
1595
|
-
text: '
|
|
1631
|
+
text: '已清除当前 Agent 的模型和推理强度设置',
|
|
1596
1632
|
structured: { ok: true, scope: 'agent', self: selfAID ?? this.resolveSelfAID(channel) },
|
|
1597
1633
|
};
|
|
1598
1634
|
}
|
|
@@ -1873,7 +1909,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1873
1909
|
});
|
|
1874
1910
|
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
1875
1911
|
return null;
|
|
1876
|
-
return { kind: 'command.result', text:
|
|
1912
|
+
return { kind: 'command.result', text: `已切换\n ${changes.join('\n ')}` };
|
|
1877
1913
|
}
|
|
1878
1914
|
// /effort 命令:查看或切换推理强度
|
|
1879
1915
|
if (normalizedContent.startsWith('/effort')) {
|
|
@@ -2007,7 +2043,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2007
2043
|
});
|
|
2008
2044
|
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
2009
2045
|
return null;
|
|
2010
|
-
return { kind: 'command.result', text: '
|
|
2046
|
+
return { kind: 'command.result', text: '已清除 Agent 级推理强度,使用默认配置' };
|
|
2011
2047
|
}
|
|
2012
2048
|
// /effort <level>:切换推理强度
|
|
2013
2049
|
if (!efforts.includes(args)) {
|
|
@@ -2034,7 +2070,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2034
2070
|
});
|
|
2035
2071
|
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
2036
2072
|
return null;
|
|
2037
|
-
return { kind: 'command.result', text:
|
|
2073
|
+
return { kind: 'command.result', text: `推理强度: ${newEffort}` };
|
|
2038
2074
|
}
|
|
2039
2075
|
// /reload [aid] — 热重载 agent 配置
|
|
2040
2076
|
// daemon owner:可 reload 任意 aid(无参则 reload 自身所在 agent)
|
|
@@ -2083,7 +2119,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2083
2119
|
return { kind: 'command.error', text: `❌ reload 失败:${res.error}` };
|
|
2084
2120
|
return {
|
|
2085
2121
|
kind: 'system.notice',
|
|
2086
|
-
text:
|
|
2122
|
+
text: `Agent ${targetAid} 配置已重载`,
|
|
2087
2123
|
subtype: 'agent.reloaded',
|
|
2088
2124
|
};
|
|
2089
2125
|
}
|
|
@@ -2112,7 +2148,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2112
2148
|
return { kind: 'command.error', text: `❌ ${result.error}` };
|
|
2113
2149
|
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
2114
2150
|
return null;
|
|
2115
|
-
return { kind: 'command.result', text:
|
|
2151
|
+
return { kind: 'command.result', text: `观察者模式: ${result.data.observable ? 'true' : 'false'}` };
|
|
2116
2152
|
}
|
|
2117
2153
|
if (normalizedContent === '/activity' || normalizedContent.startsWith('/activity ')) {
|
|
2118
2154
|
const activityArg = normalizedContent.slice(9).trim();
|
|
@@ -2144,7 +2180,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2144
2180
|
initiatorId: userId,
|
|
2145
2181
|
kind: {
|
|
2146
2182
|
kind: 'command-card',
|
|
2147
|
-
title: '
|
|
2183
|
+
title: '中间输出模式',
|
|
2148
2184
|
body: modeDescriptions.map(m => `${m.configVal === currentMode ? '✓' : '•'} **${m.key}** (${m.label})`).join('\n'),
|
|
2149
2185
|
buttons: modeDescriptions.map(m => ({
|
|
2150
2186
|
label: m.configVal === currentMode ? `✓ ${m.key}` : m.key,
|
|
@@ -2179,7 +2215,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2179
2215
|
}
|
|
2180
2216
|
const label = modeDescriptions.find(m => m.configVal === newMode)?.label || newMode;
|
|
2181
2217
|
if (newMode === currentMode) {
|
|
2182
|
-
return { kind: 'command.result', text:
|
|
2218
|
+
return { kind: 'command.result', text: `中间输出模式已是 ${activityArg}(${label})` };
|
|
2183
2219
|
}
|
|
2184
2220
|
// 切换操作仅 owner
|
|
2185
2221
|
if (!isOwner)
|
|
@@ -2192,7 +2228,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2192
2228
|
}
|
|
2193
2229
|
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
2194
2230
|
return null;
|
|
2195
|
-
return { kind: 'command.result', text:
|
|
2231
|
+
return { kind: 'command.result', text: `中间输出模式: ${activityArg}(${label})` };
|
|
2196
2232
|
}
|
|
2197
2233
|
// /chatmode 命令:私聊提供 interactive/proactive,群聊固定 proactive
|
|
2198
2234
|
// - 查看:所有人可用
|
|
@@ -2216,7 +2252,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2216
2252
|
initiatorId: userId,
|
|
2217
2253
|
kind: {
|
|
2218
2254
|
kind: 'command-card',
|
|
2219
|
-
title: '
|
|
2255
|
+
title: '会话模式',
|
|
2220
2256
|
body: modes.map(m => `${m.key === currentMode ? '✓' : '•'} **${m.key}** (${m.name}) - ${m.desc}`).join('\n'),
|
|
2221
2257
|
buttons: modes.map(m => ({
|
|
2222
2258
|
label: m.key === currentMode ? `✓ ${m.key}` : m.key,
|
|
@@ -2267,7 +2303,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2267
2303
|
return { kind: 'command.error', text: '❌ 群聊仅支持 proactive 模式' };
|
|
2268
2304
|
}
|
|
2269
2305
|
if (arg === currentMode) {
|
|
2270
|
-
return { kind: 'command.result', text:
|
|
2306
|
+
return { kind: 'command.result', text: `当前会话模式已是 ${arg}` };
|
|
2271
2307
|
}
|
|
2272
2308
|
if (arg === 'interactive' && isPrivateChatmodeRoleLocked(target.field, target.role)) {
|
|
2273
2309
|
return { kind: 'command.error', text: '❌ 私聊交互模式仅限 owner/admin,当前角色固定为 proactive' };
|
|
@@ -2316,7 +2352,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2316
2352
|
}
|
|
2317
2353
|
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
2318
2354
|
return null;
|
|
2319
|
-
return { kind: 'command.result', text:
|
|
2355
|
+
return { kind: 'command.result', text: `会话模式已切换: ${arg}` };
|
|
2320
2356
|
}
|
|
2321
2357
|
// /mention 命令:查看/切换群聊 @ 处理模式(mention-only | disabled | auto)
|
|
2322
2358
|
// 写入层级按会话类型自动选择:群聊 → relation 级(当前群),私聊 → agent 级(Agent 全局默认)
|
|
@@ -2408,7 +2444,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2408
2444
|
writeSlashMentionMode(mentionTarget, null);
|
|
2409
2445
|
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
2410
2446
|
return null;
|
|
2411
|
-
return { kind: 'command.result', text:
|
|
2447
|
+
return { kind: 'command.result', text: `已清除${scopeLabel}覆盖,将跟随上级设置` };
|
|
2412
2448
|
}
|
|
2413
2449
|
if (arg === currentMode) {
|
|
2414
2450
|
return { kind: 'command.result', text: `当前已是 ${arg}` };
|
|
@@ -2416,7 +2452,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2416
2452
|
writeSlashMentionMode(mentionTarget, arg);
|
|
2417
2453
|
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
2418
2454
|
return null;
|
|
2419
|
-
return { kind: 'command.result', text:
|
|
2455
|
+
return { kind: 'command.result', text: `@ 处理模式(${scopeLabel})已切换: ${currentMode ?? '未设置'} → ${arg}` };
|
|
2420
2456
|
}
|
|
2421
2457
|
// /stop 命令:中断当前任务
|
|
2422
2458
|
if (normalizedContent.startsWith('/stop ')) {
|
|
@@ -2450,15 +2486,10 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2450
2486
|
await this.processor.interruptSession(sessionKey, 'stop');
|
|
2451
2487
|
return {
|
|
2452
2488
|
kind: 'system.notice',
|
|
2453
|
-
text: '
|
|
2489
|
+
text: '已发送中断信号,任务将尽快停止',
|
|
2454
2490
|
subtype: 'session.stopped',
|
|
2455
2491
|
};
|
|
2456
2492
|
}
|
|
2457
|
-
// /clear 已移除:Claude/Codex/Gemini 对“清空当前 backend 历史”的语义不一致。
|
|
2458
|
-
// 统一使用 /new 创建新会话来开始全新上下文。
|
|
2459
|
-
if (normalizedContent === '/clear') {
|
|
2460
|
-
return { kind: 'command.error', text: '⚠️ /clear 已移除\n\n请使用 /new [名称] 创建新会话来开始全新上下文。旧会话会保留,可通过 /s 查看或切换。' };
|
|
2461
|
-
}
|
|
2462
2493
|
// /renew:只支持话题会话。它废止当前 backend 绑定;下一条普通消息
|
|
2463
2494
|
// 才会在新的 TurnLease 中懒创建并绑定新 backend。
|
|
2464
2495
|
if (normalizedContent === '/renew' || /^\/renew\s/.test(normalizedContent)) {
|
|
@@ -2538,7 +2569,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2538
2569
|
return { kind: 'system.error', text: '❌ 当前渠道无法安全记录该请求,未执行 backend 轮换', subtype: 'session.renew.claim_failed', recoverable: true };
|
|
2539
2570
|
}
|
|
2540
2571
|
if (outcome.kind === 'duplicate') {
|
|
2541
|
-
return { kind: 'system.notice', text: '
|
|
2572
|
+
return { kind: 'system.notice', text: '该请求已接收过,不再重复执行', subtype: 'session.renew.duplicate' };
|
|
2542
2573
|
}
|
|
2543
2574
|
if (outcome.kind === 'busy' || outcome.kind === 'unknown') {
|
|
2544
2575
|
return {
|
|
@@ -2586,7 +2617,8 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2586
2617
|
return { kind: 'command.error', text: `❌ 当前 Agent (${currentSessionAgent.name}) 不支持 /compact` };
|
|
2587
2618
|
}
|
|
2588
2619
|
if (sendMessage) {
|
|
2589
|
-
const
|
|
2620
|
+
const contextUsage = await readLastModelCallContextUsage(session.id, session.agentSessionId);
|
|
2621
|
+
const text = formatCompactingNotice(contextUsage?.totalTokens);
|
|
2590
2622
|
await sendMessage(channelId, text, this.getReplyContext(session), {
|
|
2591
2623
|
kind: 'system.notice',
|
|
2592
2624
|
text,
|
|
@@ -2808,7 +2840,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2808
2840
|
await interruptPausedSessionBeforeReplacement(session || activeSession);
|
|
2809
2841
|
const projectPath = this.getEffectiveDefaultPath(channel);
|
|
2810
2842
|
if (sendMessage && session) {
|
|
2811
|
-
const creatingText =
|
|
2843
|
+
const creatingText = `正在创建新会话${sessionName ? `: ${sessionName}` : ''}...`;
|
|
2812
2844
|
await sendMessage(channelId, creatingText, this.getReplyContext(session), { kind: 'system.notice', text: creatingText, subtype: 'session.creating' });
|
|
2813
2845
|
}
|
|
2814
2846
|
const newSessionBaseagent = this.agentRegistry?.resolveByChannel(channel)?.baseagent || this.parseDefaultBaseagent();
|
|
@@ -2859,11 +2891,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2859
2891
|
}
|
|
2860
2892
|
const previousAgent = getActiveAgentIfAvailable();
|
|
2861
2893
|
if (session && previousAgent) {
|
|
2862
|
-
//
|
|
2863
|
-
// session starts with a fresh conversation history
|
|
2864
|
-
// Clearing is a pure backend lifecycle operation; model selection is
|
|
2865
|
-
// resolved only when the new session performs its next turn.
|
|
2866
|
-
await previousAgent.clearSession(session.id, session.agentSessionId || '', session.projectPath);
|
|
2894
|
+
// Release runtime resources while preserving the previous backend history.
|
|
2867
2895
|
await previousAgent.closeSession(session.id);
|
|
2868
2896
|
}
|
|
2869
2897
|
const newAgent = this.agentRegistry?.resolveByChannel(channel);
|
|
@@ -2895,7 +2923,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2895
2923
|
const backendBits = [newBaseagent, backendModel, backendEffort].filter(Boolean).join(' · ');
|
|
2896
2924
|
return {
|
|
2897
2925
|
kind: 'system.notice',
|
|
2898
|
-
text:
|
|
2926
|
+
text: `已创建新会话${sessionName ? `: ${sessionName}` : ''} : ${backendBits}${handoffDiscardWarning ? `\n${handoffDiscardWarning}` : ''}`,
|
|
2899
2927
|
subtype: 'session.created',
|
|
2900
2928
|
};
|
|
2901
2929
|
}
|
|
@@ -2942,10 +2970,10 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2942
2970
|
let status;
|
|
2943
2971
|
if (ch?.getStatus) {
|
|
2944
2972
|
const s = ch.getStatus();
|
|
2945
|
-
status = s.connected ? '
|
|
2973
|
+
status = s.connected ? '已连接' : '重连中';
|
|
2946
2974
|
}
|
|
2947
2975
|
else {
|
|
2948
|
-
status = '
|
|
2976
|
+
status = '已注册';
|
|
2949
2977
|
}
|
|
2950
2978
|
if (!groups.has(type))
|
|
2951
2979
|
groups.set(type, []);
|
|
@@ -2957,7 +2985,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2957
2985
|
if (!isAdmin && !isDaemonOwner && !isGlobalCheckChannel) {
|
|
2958
2986
|
// visitor/member: 仅显示实例通道摘要
|
|
2959
2987
|
const total = [...groups.values()].flat().length;
|
|
2960
|
-
const healthy = [...groups.values()].flat().filter(i => i.status.
|
|
2988
|
+
const healthy = [...groups.values()].flat().filter(i => i.status === '已连接' || i.status === '已注册').length;
|
|
2961
2989
|
lines.push(` ${healthy}/${total} 渠道正常`);
|
|
2962
2990
|
return { kind: 'command.result', text: lines.join('\n') };
|
|
2963
2991
|
}
|
|
@@ -2969,7 +2997,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2969
2997
|
const parts = instances.map(i => {
|
|
2970
2998
|
const seg = i.name.split('#');
|
|
2971
2999
|
const instName = seg.length >= 3 ? seg.slice(2).join('#') : i.name;
|
|
2972
|
-
return `${i.status
|
|
3000
|
+
return `${i.status} ${instName}`;
|
|
2973
3001
|
});
|
|
2974
3002
|
lines.push(` ${type}: ${parts.join(', ')}`);
|
|
2975
3003
|
}
|
|
@@ -3202,12 +3230,6 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3202
3230
|
autoUpgrade = false;
|
|
3203
3231
|
}
|
|
3204
3232
|
}
|
|
3205
|
-
if (!suppressRealRestart && autoUpgrade) {
|
|
3206
|
-
await ensureFreshPackageVersionInfo(undefined, {
|
|
3207
|
-
source: 'slash-restart',
|
|
3208
|
-
log: message => logger.info(`[System] ${message}`),
|
|
3209
|
-
});
|
|
3210
|
-
}
|
|
3211
3233
|
const restartInfo = {
|
|
3212
3234
|
channel,
|
|
3213
3235
|
channelId,
|
|
@@ -3220,12 +3242,9 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3220
3242
|
...(restartReplyContext?.replyToMessageId ? { rootId: restartReplyContext.replyToMessageId } : {}),
|
|
3221
3243
|
};
|
|
3222
3244
|
if (!suppressRealRestart) {
|
|
3223
|
-
//
|
|
3224
|
-
//
|
|
3225
|
-
|
|
3226
|
-
const monitorEntry = resolveMonitorLaunch(getPackageRoot(), path.join(resolvePaths().root, 'data', 'monitor-stage'));
|
|
3227
|
-
if (monitorEntry.note)
|
|
3228
|
-
logger.info(`[System] ${monitorEntry.note}`);
|
|
3245
|
+
// CLI owns backend selection for Menu and slash alike. In particular,
|
|
3246
|
+
// a detached monitor cannot survive shutdown of its owning systemd unit.
|
|
3247
|
+
const monitorEntry = resolveCliEntry(getPackageRoot());
|
|
3229
3248
|
if (!fs.existsSync(monitorEntry.entry)) {
|
|
3230
3249
|
logger.error(`[System] Refusing restart: restart-monitor entry not found: ${monitorEntry.entry}`);
|
|
3231
3250
|
return { code: 'RESTART_ENTRY_MISSING', entry: monitorEntry.entry };
|
|
@@ -3235,18 +3254,20 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3235
3254
|
const pendingFile = path.join(controlDir, 'restart-pending.json');
|
|
3236
3255
|
if (await hasLiveRestartMonitor()
|
|
3237
3256
|
|| !createRestartRequest(pendingFile, restartInfo, isProcessRunning)) {
|
|
3238
|
-
if (monitorEntry.stageDir)
|
|
3239
|
-
cleanupMonitorStage(monitorEntry.stageDir);
|
|
3240
3257
|
return { code: 'RESTART_PENDING_CONFIRMATION', reason: '已有重启请求正在处理', requestId: restartInfo.requestId };
|
|
3241
3258
|
}
|
|
3242
|
-
const confirmation = await launchMonitorAndConfirm([...monitorEntry.args, 'restart
|
|
3259
|
+
const confirmation = await launchMonitorAndConfirm([...monitorEntry.args, 'restart', autoUpgrade ? '--apply-package-upgrades' : '--skip-package-upgrades'], {
|
|
3260
|
+
[RUNTIME_HOME_ENV]: resolvePaths().root, [RESTART_REQUEST_ID_ENV]: restartInfo.requestId,
|
|
3261
|
+
[SESSION_ID_ENV]: '', [AGENT_DELEGATION_TOKEN_ENV]: '',
|
|
3262
|
+
}, () => ['accepted', 'ready'].includes(readRestartRequest(pendingFile, restartInfo.requestId)?.status ?? ''), pid => hasLiveRestartMonitor({ excludePid: pid, requestId: restartInfo.requestId, phase: 'accepted' }), {
|
|
3243
3263
|
requestId: restartInfo.requestId,
|
|
3244
3264
|
logFilePath: path.join(resolvePaths().logs, `restart-launch-${restartInfo.requestId}.log`),
|
|
3245
3265
|
onSpawn: pid => { updateRestartRequest(pendingFile, restartInfo.requestId, { launcherPid: pid }); },
|
|
3246
3266
|
isPendingInRegistry: () => hasLiveRestartMonitor({ requestId: restartInfo.requestId }),
|
|
3247
3267
|
});
|
|
3248
3268
|
if (!confirmation.ok) {
|
|
3249
|
-
|
|
3269
|
+
const pending = readRestartRequest(pendingFile, restartInfo.requestId);
|
|
3270
|
+
if (confirmation.pending || (pending?.backend === 'systemd' && ['requested', 'accepted'].includes(pending.status))) {
|
|
3250
3271
|
logger.warn(`[System] Restart ownership remains unconfirmed (requestId=${restartInfo.requestId}, PID=${confirmation.pid ?? 'unknown'})`);
|
|
3251
3272
|
return {
|
|
3252
3273
|
code: 'RESTART_PENDING_CONFIRMATION',
|
|
@@ -3255,15 +3276,13 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3255
3276
|
...(confirmation.pid ? { pid: confirmation.pid } : {}),
|
|
3256
3277
|
};
|
|
3257
3278
|
}
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
cleanupMonitorStage(monitorEntry.stageDir);
|
|
3261
|
-
removeRestartRequest(pendingFile, restartInfo.requestId);
|
|
3279
|
+
if (pending?.backend !== 'systemd')
|
|
3280
|
+
removeRestartRequest(pendingFile, restartInfo.requestId);
|
|
3262
3281
|
logger.error(`[System] Refusing restart: restart-monitor did not come up (${confirmation.reason})`);
|
|
3263
3282
|
for (const line of (confirmation.stderrTail ?? '').split(/\r?\n/).filter(Boolean).slice(-8)) {
|
|
3264
3283
|
logger.error(`[System] | ${line}`);
|
|
3265
3284
|
}
|
|
3266
|
-
return { code: 'RESTART_MONITOR_DEAD', reason: confirmation.reason ?? 'unknown' };
|
|
3285
|
+
return { code: 'RESTART_MONITOR_DEAD', reason: pending?.reason ?? confirmation.reason ?? 'unknown' };
|
|
3267
3286
|
}
|
|
3268
3287
|
}
|
|
3269
3288
|
else {
|
|
@@ -3301,7 +3320,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3301
3320
|
});
|
|
3302
3321
|
await adapter.send(envelope, {
|
|
3303
3322
|
kind: 'system.notice',
|
|
3304
|
-
text: '
|
|
3323
|
+
text: '服务正在重启...',
|
|
3305
3324
|
subtype: 'system.restart.pending',
|
|
3306
3325
|
});
|
|
3307
3326
|
// 等待消息发送完成后再延迟 kill
|
|
@@ -3552,8 +3571,8 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3552
3571
|
return {
|
|
3553
3572
|
kind: 'system.notice',
|
|
3554
3573
|
text: isCrossChannel
|
|
3555
|
-
?
|
|
3556
|
-
:
|
|
3574
|
+
? `文件已通过 ${targetLabel} 发送: ${filePath} (${sizeStr})`
|
|
3575
|
+
: `已发送: ${filePath} (${sizeStr})`,
|
|
3557
3576
|
subtype: 'file.sent',
|
|
3558
3577
|
};
|
|
3559
3578
|
}
|
|
@@ -3603,7 +3622,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3603
3622
|
initiatorId: userId,
|
|
3604
3623
|
kind: {
|
|
3605
3624
|
kind: 'command-card',
|
|
3606
|
-
title:
|
|
3625
|
+
title: `${path.basename(session.projectPath)} CLI 会话 (${cliDisplayItems.length})`,
|
|
3607
3626
|
body: bodyLines.join('\n'),
|
|
3608
3627
|
buttons: cliDisplayItems.map((item) => ({
|
|
3609
3628
|
label: item.uuid,
|
|
@@ -3687,7 +3706,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3687
3706
|
initiatorId: userId,
|
|
3688
3707
|
kind: {
|
|
3689
3708
|
kind: 'command-card',
|
|
3690
|
-
title:
|
|
3709
|
+
title: `${path.basename(session.projectPath)} 会话列表`,
|
|
3691
3710
|
body: bodyLines.join('\n'),
|
|
3692
3711
|
buttons: displaySessions.map(ds => {
|
|
3693
3712
|
const shortId = ds.session.agentSessionId ? ds.session.agentSessionId.substring(0, 8) : ds.name;
|
|
@@ -3792,7 +3811,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3792
3811
|
const imported = await this.sessionManager.importCliSession(channel, channelId, projectPath, cliSession.uuid, currentBaseagent, selfAID ?? session?.selfAID);
|
|
3793
3812
|
this.eventBus.publish({ type: 'session:imported', sessionId: imported.id, agentSessionId: cliSession.uuid, projectPath });
|
|
3794
3813
|
const projectName = this.getProjectName(projectPath);
|
|
3795
|
-
return { kind: 'command.result', text:
|
|
3814
|
+
return { kind: 'command.result', text: `已导入 CLI 会话: ${displaySessionTitle(imported.name, '(未命名)')}\n 项目: ${projectName}\n 将继续之前的对话历史` };
|
|
3796
3815
|
}
|
|
3797
3816
|
}
|
|
3798
3817
|
}
|
|
@@ -3815,7 +3834,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3815
3834
|
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
3816
3835
|
return null;
|
|
3817
3836
|
const { lastInputLine } = await readLastInput();
|
|
3818
|
-
return { kind: 'command.result', text:
|
|
3837
|
+
return { kind: 'command.result', text: `已切换到会话: ${displaySessionTitle(targetSession.name, sessionName)}\n 项目: ${path.basename(targetSession.projectPath)}${lastInputLine}` };
|
|
3819
3838
|
}
|
|
3820
3839
|
if (targetSession.id === session.id) {
|
|
3821
3840
|
return { kind: 'command.result', text: `当前已在会话: ${displaySessionTitle(targetSession.name, sessionName)}` };
|
|
@@ -3836,7 +3855,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3836
3855
|
return null;
|
|
3837
3856
|
const { lastInput, lastInputLine } = await readLastInput();
|
|
3838
3857
|
const continueHint = lastInput ? '\n 将继续之前的对话历史' : '\n 当前会话未有发言';
|
|
3839
|
-
return { kind: 'command.result', text:
|
|
3858
|
+
return { kind: 'command.result', text: `已切换到会话: ${displaySessionTitle(targetSession.name, sessionName)}${continueHint}${lastInputLine}` };
|
|
3840
3859
|
}
|
|
3841
3860
|
// /rename 或 /name 命令:重命名当前会话
|
|
3842
3861
|
if (normalizedContent === '/rename' || normalizedContent === '/name') {
|
|
@@ -3888,7 +3907,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3888
3907
|
this.eventBus.publish({ type: 'session:renamed', sessionId: session.id, oldName, newName });
|
|
3889
3908
|
return {
|
|
3890
3909
|
kind: 'system.notice',
|
|
3891
|
-
text:
|
|
3910
|
+
text: `已将当前会话重命名为: ${newName}`,
|
|
3892
3911
|
subtype: 'session.renamed',
|
|
3893
3912
|
};
|
|
3894
3913
|
}
|
|
@@ -3937,7 +3956,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3937
3956
|
const targetAgent = this.getLoadedAgent(channel, targetSession.baseagent);
|
|
3938
3957
|
this.processor?.clearPauseSession?.(targetSession.id);
|
|
3939
3958
|
await targetAgent?.closeSession(targetSession.id);
|
|
3940
|
-
return { kind: 'command.result', text:
|
|
3959
|
+
return { kind: 'command.result', text: `已删除会话: ${displaySessionTitle(targetSession.name, sessionName)}\n会话文件已保留,可通过 CLI 访问` };
|
|
3941
3960
|
}
|
|
3942
3961
|
// /fork 命令:分支当前会话
|
|
3943
3962
|
if (normalizedContent === '/fork' || normalizedContent.startsWith('/fork ')) {
|
|
@@ -3955,9 +3974,12 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3955
3974
|
await interruptPausedSessionBeforeReplacement(session);
|
|
3956
3975
|
try {
|
|
3957
3976
|
const forkedSessionId = await forkAgent.forkSession(session.agentSessionId, session.projectPath, forkName, {
|
|
3958
|
-
sessionId: session.id, permissionMode: authSubject.permissionMode, role: authSubject.role,
|
|
3977
|
+
sessionId: session.id, permissionMode: authSubject.permissionMode, role: authSubject.role, authorization: authSubject,
|
|
3959
3978
|
});
|
|
3960
3979
|
const newSession = await this.sessionManager.createForkedSession(session, forkedSessionId, forkName);
|
|
3980
|
+
await forkAgent.commitSessionFork?.(forkedSessionId, newSession, {
|
|
3981
|
+
sessionId: session.id, authorization: authSubject,
|
|
3982
|
+
}).catch(async (error) => { await this.sessionManager.unbindSession(newSession.id); throw error; });
|
|
3961
3983
|
await forkAgent.updateSessionMetadata?.(forkedSessionId, {
|
|
3962
3984
|
gitInfo: {
|
|
3963
3985
|
branch: null,
|
|
@@ -3970,7 +3992,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3970
3992
|
logger.debug('[CommandHandler] Backend fork metadata sync failed:', error);
|
|
3971
3993
|
});
|
|
3972
3994
|
this.eventBus.publish({ type: 'session:forked', sessionId: newSession.id, sourceSessionId: session.id, name: forkName });
|
|
3973
|
-
return { kind: 'command.result', text:
|
|
3995
|
+
return { kind: 'command.result', text: `会话已分支: ${displaySessionTitle(newSession.name, '(未命名)')}\n新会话已激活,可以继续对话\n\n使用 /s 查看所有会话,/s <名称> 切换回原会话` };
|
|
3974
3996
|
}
|
|
3975
3997
|
catch (error) {
|
|
3976
3998
|
logger.error('[CommandHandler] Fork session failed:', error);
|
|
@@ -4072,14 +4094,14 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
4072
4094
|
try {
|
|
4073
4095
|
if (!repairSession.agentSessionId) {
|
|
4074
4096
|
await this.sessionManager.resetHealthStatus(repairSession.id);
|
|
4075
|
-
return { kind: 'command.result', text:
|
|
4097
|
+
return { kind: 'command.result', text: `修复完成\n\n修复内容:\n- 未发现问题(新会话)\n- 已重置异常计数器` };
|
|
4076
4098
|
}
|
|
4077
4099
|
// 通过 agent 定位 session 文件
|
|
4078
4100
|
const sessionFile = repairAgent.resolveSessionFile?.(repairSession.agentSessionId, repairSession.projectPath) ?? null;
|
|
4079
4101
|
if (!sessionFile) {
|
|
4080
4102
|
// 文件不存在(已被删除或从未创建),直接重置
|
|
4081
4103
|
await this.sessionManager.resetHealthStatus(repairSession.id);
|
|
4082
|
-
return { kind: 'command.result', text:
|
|
4104
|
+
return { kind: 'command.result', text: `修复完成\n\n修复内容:\n- 会话文件不存在(可能已被清理)\n- 已重置异常计数器` };
|
|
4083
4105
|
}
|
|
4084
4106
|
const healthCheck = await checkSessionFile(sessionFile);
|
|
4085
4107
|
if (healthCheck.corrupt) {
|
|
@@ -4094,14 +4116,14 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
4094
4116
|
}
|
|
4095
4117
|
repairAgent.updateSessionId(repairSession.id, '');
|
|
4096
4118
|
await this.sessionManager.resetHealthStatus(repairSession.id);
|
|
4097
|
-
return { kind: 'command.result', text:
|
|
4119
|
+
return { kind: 'command.result', text: `修复完成\n\n检测到问题:\n${healthCheck.issues.map((i) => `- ${i}`).join('\n')}\n\n修复操作:\n- 已备份损坏文件\n- 已删除损坏文件\n- 已重置异常计数器\n\n备份位置:${backupPath}` };
|
|
4098
4120
|
}
|
|
4099
4121
|
if (healthCheck.issues.length > 0) {
|
|
4100
4122
|
await this.sessionManager.resetHealthStatus(repairSession.id);
|
|
4101
4123
|
return { kind: 'command.error', text: `⚠️ 检测到问题:\n${healthCheck.issues.map((i) => `- ${i}`).join('\n')}\n\n建议使用 /new 创建新会话\n\n已重置异常计数器,可继续使用当前会话。` };
|
|
4102
4124
|
}
|
|
4103
4125
|
await this.sessionManager.resetHealthStatus(repairSession.id);
|
|
4104
|
-
return { kind: 'command.result', text:
|
|
4126
|
+
return { kind: 'command.result', text: `修复完成\n\n修复内容:\n- 未发现问题\n- 已重置异常计数器` };
|
|
4105
4127
|
}
|
|
4106
4128
|
catch (error) {
|
|
4107
4129
|
logger.error('[Repair] Failed:', error);
|