evolcore 0.0.50 → 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 +39 -2
- package/bin/ec-build.mjs +60 -0
- package/bin/ecmsg.js +65 -63
- package/dist/ability/caller/command.js +24 -15
- package/dist/ability/caller/contract.js +24 -9
- package/dist/ability/caller/credential-files.js +132 -0
- package/dist/ability/caller/daemon.js +32 -7
- package/dist/ability/caller/schema-view.js +157 -0
- package/dist/ability/caller/service.js +202 -63
- package/dist/ability/interop-v1.js +156 -113
- package/dist/agent-template/jobs.js +14 -110
- package/dist/agent-template/runtime.js +331 -193
- package/dist/agent-template/service.js +1029 -1104
- package/dist/agent-template/share.js +103 -0
- package/dist/agent-template/tool-runner.js +25 -0
- package/dist/agent-template/types.js +10 -3
- 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} +74 -158
- 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} +648 -382
- 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 +55 -10
- package/dist/agents/gemini/{gemini-runner.js → runner.js} +4 -9
- package/dist/aun/ability-device-routing.js +11 -17
- package/dist/aun/aid/agentmd.js +27 -1
- package/dist/aun/aid/managed-operation.js +6 -4
- package/dist/aun/group/invite-service.js +1 -1
- 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/p2p.js +6 -6
- 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 +180 -43
- 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/{agents/claude-gateway → claude-gateway}/agent-registration.js +13 -13
- package/dist/{agents/claude-gateway → claude-gateway}/binding.js +3 -3
- package/dist/{agents/claude-gateway → claude-gateway}/inbox.js +1 -1
- package/dist/{agents/claude-gateway → claude-gateway}/index.js +2 -2
- package/dist/{agents/claude-gateway → claude-gateway}/listing.js +3 -3
- package/dist/{agents/claude-gateway → claude-gateway}/router.js +4 -4
- package/dist/{agents/claude-gateway → claude-gateway}/sessions.js +2 -2
- package/dist/{agents/claude-gateway → claude-gateway}/terminal.js +1 -1
- package/dist/{agents/claude-gateway → claude-gateway}/transcript.js +1 -1
- package/dist/cli/ability-command.js +8 -5
- package/dist/cli/ability-output.js +182 -0
- package/dist/cli/agent-command.js +1 -1
- package/dist/cli/agent-create.js +123 -42
- package/dist/cli/agent-template.js +400 -29
- package/dist/cli/agent.js +14 -11
- package/dist/cli/aun-commands.js +167 -111
- package/dist/cli/daemon-commands.js +38 -8
- 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 +55 -19
- package/dist/cli/fs-command.js +67 -39
- package/dist/cli/index.js +25 -11
- package/dist/cli/init.js +124 -29
- package/dist/cli/managed-command-guard.js +2 -0
- package/dist/cli/model.js +1 -1
- package/dist/cli/restart-monitor.js +2 -2
- package/dist/cli/services-command.js +24 -1
- 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 +3 -2
- package/dist/cli/trigger-command.js +47 -12
- package/dist/cli/watch-logs.js +2 -1
- package/dist/config/boot-log.js +3 -0
- package/dist/config/builtin-role-templates.js +1 -1
- package/dist/config/config-field-policy.js +10 -6
- package/dist/config/config-manager.js +33 -12
- package/dist/config/gateway-config.js +21 -37
- package/dist/config/invoke-ipc-service.js +1 -1
- package/dist/config/owner-config.js +5 -3
- package/dist/config/peer-book-store.js +2 -3
- package/dist/config/peer-book.js +2 -2
- package/dist/config/peer-role-resolver.js +2 -2
- 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 +39 -15
- package/dist/config/providers-import.js +3 -3
- package/dist/config/providers-management.js +74 -99
- package/dist/config/schema-migration.js +177 -11
- package/dist/config/schema-registry.js +1 -1
- package/dist/config-store.js +38 -50
- package/dist/core/{agent-application-service.js → agent/agent-application-service.js} +9 -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} +102 -25
- package/dist/core/{agent-reload-coordinator.js → agent/agent-reload-coordinator.js} +61 -1
- package/dist/core/{agent-runtime.js → agent/agent-runtime.js} +53 -27
- package/dist/core/{evolagent-registry.js → agent/evolagent-registry.js} +12 -12
- package/dist/core/{evolagent.js → agent/evolagent.js} +11 -11
- package/dist/core/auth/agent-delegation.js +1 -8
- package/dist/core/auth/delegation-authorization.js +28 -0
- package/dist/core/auth/operation-authorizer.js +7 -4
- package/dist/core/auth/operation-catalog.js +34 -5
- 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} +62 -6
- package/dist/core/baseagent/baseagent-model-defaults.js +26 -0
- package/dist/{agents → core/baseagent}/baseagent-plugin-descriptor.js +107 -24
- 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 +79 -30
- 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} +18 -18
- package/dist/core/command/agent-control.js +60 -15
- package/dist/core/command/agent-template-menu.js +21 -9
- package/dist/core/command/agentmd-menu-request.js +19 -8
- package/dist/core/command/agentmd-menu.js +14 -5
- 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 +80 -20
- package/dist/core/command/menu-handler.js +305 -25
- package/dist/core/command/menu-protocol.js +42 -8
- package/dist/core/command/menu-query-batch.js +9 -5
- 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 +127 -96
- package/dist/core/command/team-workspace-team.js +3 -3
- package/dist/core/command/topic-slash.js +10 -10
- package/dist/core/{daemon-bootstrap.js → daemon/daemon-bootstrap.js} +14 -14
- package/dist/core/{daemon-control.js → daemon/daemon-control.js} +46 -20
- package/dist/core/{daemon-lifecycle.js → daemon/daemon-lifecycle.js} +15 -15
- package/dist/core/{host-snapshot.js → daemon/host-snapshot.js} +3 -3
- package/dist/core/{ipc-registration.js → daemon/ipc-registration.js} +98 -38
- 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 +1 -1
- 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 +54 -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 +1 -1
- package/dist/core/memory/consolidation-trigger.js +9 -3
- package/dist/core/memory/consolidation.js +4 -4
- 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 +114 -75
- package/dist/core/message/aun-request-registry.js +13 -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} +4 -4
- 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 +135 -54
- package/dist/core/message/message-queue.js +83 -4
- package/dist/core/message/message-utils.js +1 -1
- package/dist/core/message/peer-mode.js +1 -1
- package/dist/core/message/response-engine.js +347 -163
- package/dist/core/message/send-options.js +9 -6
- package/dist/core/message/send-routing.js +45 -109
- 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 +14 -3
- package/dist/core/model/model-diagnostics.js +4 -4
- package/dist/core/ownership/owner-resolver.js +95 -15
- package/dist/core/{pack-auth.js → pack/pack-auth.js} +30 -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 +70 -34
- package/dist/core/permission/managed-file.js +234 -0
- package/dist/core/permission/protected-paths.js +56 -0
- package/dist/core/permission/sandbox-runtime.js +267 -3
- package/dist/core/permission/session-path-grants.js +1 -1
- package/dist/core/permission/shell-environment.js +15 -1
- package/dist/core/plugin/plugin-lifecycle.js +442 -0
- package/dist/core/session/adapters/claude-session-file-adapter.js +2 -246
- package/dist/core/session/adapters/codex-session-file-adapter.js +2 -566
- 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 +29 -2
- 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 +1 -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/ipc-operation.js +2 -2
- package/dist/core/thread/thread-operation.js +2 -1
- package/dist/core/thread/thread-route.js +5 -3
- package/dist/core/thread/thread-service.js +14 -4
- 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 +1 -1
- package/dist/eck/manifest-engine.js +64 -2
- package/dist/eck/message-renderer.js +35 -0
- package/dist/ecweb/basic-settings-service.js +9 -3
- 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 +1 -1
- 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 +71 -42
- package/dist/ipc.js +103 -10
- 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 +12 -0
- package/dist/pay/command.js +1 -1
- package/dist/pay/runtime.js +18 -10
- package/dist/response-system/engines/v1/proactive-flow.js +1 -1
- package/dist/services/dispatcher.js +2 -2
- package/dist/services/host/main.js +10 -1
- package/dist/services/host/protocol.js +9 -2
- package/dist/services/host/resident.js +37 -0
- package/dist/services/host-client.js +12 -0
- package/dist/services/host-recycle.js +8 -3
- package/dist/services/host-runtime.js +54 -15
- package/dist/services/index.js +83 -19
- package/dist/services/ipc-operation.js +303 -38
- package/dist/services/pack-manager.js +2 -2
- package/dist/services/router.js +43 -3
- package/dist/services/script-runner.js +34 -25
- package/dist/services/service-payload.js +28 -1
- package/dist/services/validation.js +28 -2
- 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 +3 -2
- package/dist/trigger/authorization.js +36 -33
- package/dist/trigger/ipc-service.js +4 -4
- package/dist/trigger/local-files.js +8 -176
- package/dist/trigger/manager.js +2 -2
- package/dist/trigger/parser.js +48 -0
- package/dist/trigger/scheduler.js +14 -2
- package/dist/trigger/script-executor.js +21 -0
- package/dist/trigger/script-sandbox.js +57 -243
- package/dist/trigger/system-definitions.js +25 -0
- package/dist/trigger/validation.js +1 -1
- 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 +1 -1
- package/dist/utils/logger.js +3 -1
- package/dist/utils/media-cache.js +99 -4
- package/dist/utils/startup-trace.js +20 -4
- package/dist/utils/welcome.js +64 -20
- 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 +1 -1
- package/kits/docs/channels/feishu.md +1 -1
- package/kits/docs/evolcore/INDEX.md +10 -7
- package/kits/docs/evolcore/agent-create.md +2 -0
- package/kits/docs/evolcore/agent.md +100 -13
- package/kits/docs/evolcore/aid.md +19 -3
- package/kits/docs/evolcore/config.md +94 -0
- 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 +3 -3
- package/kits/docs/evolcore/memory-consolidation.md +1 -1
- package/kits/docs/evolcore/menu-protocol.md +24 -2
- package/kits/docs/evolcore/model.md +9 -1
- package/kits/docs/evolcore/msg.md +30 -28
- package/kits/docs/evolcore/pay.md +8 -20
- package/kits/docs/evolcore/plugin.md +74 -0
- package/kits/docs/evolcore/provider.md +8 -2
- package/kits/docs/evolcore/rpc.md +2 -2
- 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 +19 -10
- package/kits/docs/evolcore/tool-authorization.md +4 -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/02-navigation.md +20 -13
- package/kits/rules/06-channel.md +18 -2
- package/kits/schemas/_meta.json +8 -4
- package/kits/schemas/agent-config.schema.23.json +19 -3
- 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.11.json +487 -0
- package/kits/schemas/daemon.schema.12.json +505 -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 +8 -2
- package/kits/skills/.switches.json +4 -0
- package/kits/skills/ability/SKILL.md +194 -27
- package/kits/skills/ability/STRUCTURE.md +5 -0
- package/kits/skills/agent-output-cards/SKILL.md +90 -54
- 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 +3 -3
- package/kits/skills/ec-group-collaboration/SKILL.md +4 -4
- package/kits/skills/ec-identity/SKILL.md +9 -6
- package/kits/skills/ec-pay/SKILL.md +163 -41
- package/kits/skills/ec-provider/SKILL.md +5 -5
- package/kits/skills/ec-service-call/SKILL.md +3 -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 +2 -2
- 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/system-fragments/commands.md +1 -1
- package/kits/templates/system-fragments/personal-assistant.md +2 -2
- package/kits/templates/system-fragments/reply.md +14 -9
- package/kits/templates/system-fragments/session.md +1 -1
- package/kits/templates/system-fragments/thread.md +10 -5
- package/package.json +6 -5
- package/scripts/agent-template/index.mjs +7 -1
- package/scripts/agent-template/inspect.mjs +81 -35
- package/scripts/agent-template/overlay.mjs +110 -4
- package/scripts/agent-template/shared/common.mjs +36 -4
- 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 +467 -54
- package/scripts/agent-template/shared/template-contract.mjs +70 -68
- package/scripts/agent-template/shared/template-package.mjs +153 -36
- package/scripts/agent-template/shared/template-runtime.mjs +76 -64
- package/scripts/agent-template/shared/template.mjs +11 -46
- package/scripts/agent-template/team-pack.mjs +451 -35
- package/scripts/agent-template/team-preview.mjs +75 -226
- package/scripts/aid-batch/identity-batch.mjs +1 -1
- package/dist/agents/baseagent-availability.js +0 -176
- package/dist/agents/baseagent-capability-adapter.js +0 -102
- package/dist/agents/baseagent-plugin-loader.js +0 -145
- package/dist/agents/baseagent.js +0 -816
- 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/skills/ec-pay/references/pay-cli.md +0 -110
- /package/dist/agents/gemini/{gemini-capability-provider.js → capability-provider.js} +0 -0
- /package/dist/agents/gemini/{gemini-session-file-adapter.js → session-file-adapter.js} +0 -0
- /package/dist/{agents/claude-gateway → claude-gateway}/types.js +0 -0
- /package/dist/core/{system-channels.js → channel/system-channels.js} +0 -0
- /package/dist/core/{daemon-file-cache.js → daemon/daemon-file-cache.js} +0 -0
- /package/dist/core/{event-bus.js → event/event-bus.js} +0 -0
- /package/dist/core/{event-catalog.js → event/event-catalog.js} +0 -0
- /package/dist/core/{pack-ledger.js → pack/pack-ledger.js} +0 -0
- /package/dist/directory/{owner-directory-identity.js → identity.js} +0 -0
- /package/dist/directory/{owner-directory-policy.js → policy.js} +0 -0
- /package/dist/directory/{owner-directory-remarks.js → remarks.js} +0 -0
- /package/dist/directory/{owner-directory-scope.js → scope.js} +0 -0
- /package/dist/{contracts → ecweb/contracts}/ecweb-instance.js +0 -0
- /package/kits/templates/{bootstrap-welcome.md → bootstrap-intro.md} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
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';
|
|
@@ -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 {
|
|
39
|
+
import { assertDeclaredBaseagentCapability } from '../baseagent/baseagent-capability-adapter.js';
|
|
40
|
+
import { isSystemControlChannel } from '../channel/system-channels.js';
|
|
40
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
|
}
|
|
@@ -3292,7 +3320,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3292
3320
|
});
|
|
3293
3321
|
await adapter.send(envelope, {
|
|
3294
3322
|
kind: 'system.notice',
|
|
3295
|
-
text: '
|
|
3323
|
+
text: '服务正在重启...',
|
|
3296
3324
|
subtype: 'system.restart.pending',
|
|
3297
3325
|
});
|
|
3298
3326
|
// 等待消息发送完成后再延迟 kill
|
|
@@ -3543,8 +3571,8 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3543
3571
|
return {
|
|
3544
3572
|
kind: 'system.notice',
|
|
3545
3573
|
text: isCrossChannel
|
|
3546
|
-
?
|
|
3547
|
-
:
|
|
3574
|
+
? `文件已通过 ${targetLabel} 发送: ${filePath} (${sizeStr})`
|
|
3575
|
+
: `已发送: ${filePath} (${sizeStr})`,
|
|
3548
3576
|
subtype: 'file.sent',
|
|
3549
3577
|
};
|
|
3550
3578
|
}
|
|
@@ -3594,7 +3622,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3594
3622
|
initiatorId: userId,
|
|
3595
3623
|
kind: {
|
|
3596
3624
|
kind: 'command-card',
|
|
3597
|
-
title:
|
|
3625
|
+
title: `${path.basename(session.projectPath)} CLI 会话 (${cliDisplayItems.length})`,
|
|
3598
3626
|
body: bodyLines.join('\n'),
|
|
3599
3627
|
buttons: cliDisplayItems.map((item) => ({
|
|
3600
3628
|
label: item.uuid,
|
|
@@ -3678,7 +3706,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3678
3706
|
initiatorId: userId,
|
|
3679
3707
|
kind: {
|
|
3680
3708
|
kind: 'command-card',
|
|
3681
|
-
title:
|
|
3709
|
+
title: `${path.basename(session.projectPath)} 会话列表`,
|
|
3682
3710
|
body: bodyLines.join('\n'),
|
|
3683
3711
|
buttons: displaySessions.map(ds => {
|
|
3684
3712
|
const shortId = ds.session.agentSessionId ? ds.session.agentSessionId.substring(0, 8) : ds.name;
|
|
@@ -3783,7 +3811,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3783
3811
|
const imported = await this.sessionManager.importCliSession(channel, channelId, projectPath, cliSession.uuid, currentBaseagent, selfAID ?? session?.selfAID);
|
|
3784
3812
|
this.eventBus.publish({ type: 'session:imported', sessionId: imported.id, agentSessionId: cliSession.uuid, projectPath });
|
|
3785
3813
|
const projectName = this.getProjectName(projectPath);
|
|
3786
|
-
return { kind: 'command.result', text:
|
|
3814
|
+
return { kind: 'command.result', text: `已导入 CLI 会话: ${displaySessionTitle(imported.name, '(未命名)')}\n 项目: ${projectName}\n 将继续之前的对话历史` };
|
|
3787
3815
|
}
|
|
3788
3816
|
}
|
|
3789
3817
|
}
|
|
@@ -3806,7 +3834,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3806
3834
|
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
3807
3835
|
return null;
|
|
3808
3836
|
const { lastInputLine } = await readLastInput();
|
|
3809
|
-
return { kind: 'command.result', text:
|
|
3837
|
+
return { kind: 'command.result', text: `已切换到会话: ${displaySessionTitle(targetSession.name, sessionName)}\n 项目: ${path.basename(targetSession.projectPath)}${lastInputLine}` };
|
|
3810
3838
|
}
|
|
3811
3839
|
if (targetSession.id === session.id) {
|
|
3812
3840
|
return { kind: 'command.result', text: `当前已在会话: ${displaySessionTitle(targetSession.name, sessionName)}` };
|
|
@@ -3827,7 +3855,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3827
3855
|
return null;
|
|
3828
3856
|
const { lastInput, lastInputLine } = await readLastInput();
|
|
3829
3857
|
const continueHint = lastInput ? '\n 将继续之前的对话历史' : '\n 当前会话未有发言';
|
|
3830
|
-
return { kind: 'command.result', text:
|
|
3858
|
+
return { kind: 'command.result', text: `已切换到会话: ${displaySessionTitle(targetSession.name, sessionName)}${continueHint}${lastInputLine}` };
|
|
3831
3859
|
}
|
|
3832
3860
|
// /rename 或 /name 命令:重命名当前会话
|
|
3833
3861
|
if (normalizedContent === '/rename' || normalizedContent === '/name') {
|
|
@@ -3879,7 +3907,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3879
3907
|
this.eventBus.publish({ type: 'session:renamed', sessionId: session.id, oldName, newName });
|
|
3880
3908
|
return {
|
|
3881
3909
|
kind: 'system.notice',
|
|
3882
|
-
text:
|
|
3910
|
+
text: `已将当前会话重命名为: ${newName}`,
|
|
3883
3911
|
subtype: 'session.renamed',
|
|
3884
3912
|
};
|
|
3885
3913
|
}
|
|
@@ -3928,7 +3956,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3928
3956
|
const targetAgent = this.getLoadedAgent(channel, targetSession.baseagent);
|
|
3929
3957
|
this.processor?.clearPauseSession?.(targetSession.id);
|
|
3930
3958
|
await targetAgent?.closeSession(targetSession.id);
|
|
3931
|
-
return { kind: 'command.result', text:
|
|
3959
|
+
return { kind: 'command.result', text: `已删除会话: ${displaySessionTitle(targetSession.name, sessionName)}\n会话文件已保留,可通过 CLI 访问` };
|
|
3932
3960
|
}
|
|
3933
3961
|
// /fork 命令:分支当前会话
|
|
3934
3962
|
if (normalizedContent === '/fork' || normalizedContent.startsWith('/fork ')) {
|
|
@@ -3946,9 +3974,12 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3946
3974
|
await interruptPausedSessionBeforeReplacement(session);
|
|
3947
3975
|
try {
|
|
3948
3976
|
const forkedSessionId = await forkAgent.forkSession(session.agentSessionId, session.projectPath, forkName, {
|
|
3949
|
-
sessionId: session.id, permissionMode: authSubject.permissionMode, role: authSubject.role,
|
|
3977
|
+
sessionId: session.id, permissionMode: authSubject.permissionMode, role: authSubject.role, authorization: authSubject,
|
|
3950
3978
|
});
|
|
3951
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; });
|
|
3952
3983
|
await forkAgent.updateSessionMetadata?.(forkedSessionId, {
|
|
3953
3984
|
gitInfo: {
|
|
3954
3985
|
branch: null,
|
|
@@ -3961,7 +3992,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3961
3992
|
logger.debug('[CommandHandler] Backend fork metadata sync failed:', error);
|
|
3962
3993
|
});
|
|
3963
3994
|
this.eventBus.publish({ type: 'session:forked', sessionId: newSession.id, sourceSessionId: session.id, name: forkName });
|
|
3964
|
-
return { kind: 'command.result', text:
|
|
3995
|
+
return { kind: 'command.result', text: `会话已分支: ${displaySessionTitle(newSession.name, '(未命名)')}\n新会话已激活,可以继续对话\n\n使用 /s 查看所有会话,/s <名称> 切换回原会话` };
|
|
3965
3996
|
}
|
|
3966
3997
|
catch (error) {
|
|
3967
3998
|
logger.error('[CommandHandler] Fork session failed:', error);
|
|
@@ -4063,14 +4094,14 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
4063
4094
|
try {
|
|
4064
4095
|
if (!repairSession.agentSessionId) {
|
|
4065
4096
|
await this.sessionManager.resetHealthStatus(repairSession.id);
|
|
4066
|
-
return { kind: 'command.result', text:
|
|
4097
|
+
return { kind: 'command.result', text: `修复完成\n\n修复内容:\n- 未发现问题(新会话)\n- 已重置异常计数器` };
|
|
4067
4098
|
}
|
|
4068
4099
|
// 通过 agent 定位 session 文件
|
|
4069
4100
|
const sessionFile = repairAgent.resolveSessionFile?.(repairSession.agentSessionId, repairSession.projectPath) ?? null;
|
|
4070
4101
|
if (!sessionFile) {
|
|
4071
4102
|
// 文件不存在(已被删除或从未创建),直接重置
|
|
4072
4103
|
await this.sessionManager.resetHealthStatus(repairSession.id);
|
|
4073
|
-
return { kind: 'command.result', text:
|
|
4104
|
+
return { kind: 'command.result', text: `修复完成\n\n修复内容:\n- 会话文件不存在(可能已被清理)\n- 已重置异常计数器` };
|
|
4074
4105
|
}
|
|
4075
4106
|
const healthCheck = await checkSessionFile(sessionFile);
|
|
4076
4107
|
if (healthCheck.corrupt) {
|
|
@@ -4085,14 +4116,14 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
4085
4116
|
}
|
|
4086
4117
|
repairAgent.updateSessionId(repairSession.id, '');
|
|
4087
4118
|
await this.sessionManager.resetHealthStatus(repairSession.id);
|
|
4088
|
-
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}` };
|
|
4089
4120
|
}
|
|
4090
4121
|
if (healthCheck.issues.length > 0) {
|
|
4091
4122
|
await this.sessionManager.resetHealthStatus(repairSession.id);
|
|
4092
4123
|
return { kind: 'command.error', text: `⚠️ 检测到问题:\n${healthCheck.issues.map((i) => `- ${i}`).join('\n')}\n\n建议使用 /new 创建新会话\n\n已重置异常计数器,可继续使用当前会话。` };
|
|
4093
4124
|
}
|
|
4094
4125
|
await this.sessionManager.resetHealthStatus(repairSession.id);
|
|
4095
|
-
return { kind: 'command.result', text:
|
|
4126
|
+
return { kind: 'command.result', text: `修复完成\n\n修复内容:\n- 未发现问题\n- 已重置异常计数器` };
|
|
4096
4127
|
}
|
|
4097
4128
|
catch (error) {
|
|
4098
4129
|
logger.error('[Repair] Failed:', error);
|