dsh-tavern-bundle 0.1.0
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/LICENSE +21 -0
- package/README.md +216 -0
- package/cordis.patch.yml +14 -0
- package/lib/adapters/model-gateway.d.ts +4 -0
- package/lib/adapters/model-gateway.d.ts.map +1 -0
- package/lib/adapters/model-gateway.js +3 -0
- package/lib/adapters/model-gateway.js.map +1 -0
- package/lib/adapters/prestep-spike.d.ts +16 -0
- package/lib/adapters/prestep-spike.d.ts.map +1 -0
- package/lib/adapters/prestep-spike.js +114 -0
- package/lib/adapters/prestep-spike.js.map +1 -0
- package/lib/adapters/runtime-probe.d.ts +67 -0
- package/lib/adapters/runtime-probe.d.ts.map +1 -0
- package/lib/adapters/runtime-probe.js +106 -0
- package/lib/adapters/runtime-probe.js.map +1 -0
- package/lib/adapters/session-agent-provider.d.ts +3 -0
- package/lib/adapters/session-agent-provider.d.ts.map +1 -0
- package/lib/adapters/session-agent-provider.js +3 -0
- package/lib/adapters/session-agent-provider.js.map +1 -0
- package/lib/adapters/subagent-gateway.d.ts +3 -0
- package/lib/adapters/subagent-gateway.d.ts.map +1 -0
- package/lib/adapters/subagent-gateway.js +3 -0
- package/lib/adapters/subagent-gateway.js.map +1 -0
- package/lib/application/chat/chat-application-service.d.ts +94 -0
- package/lib/application/chat/chat-application-service.d.ts.map +1 -0
- package/lib/application/chat/chat-application-service.js +291 -0
- package/lib/application/chat/chat-application-service.js.map +1 -0
- package/lib/application/companion/agent-orchestrator.d.ts +91 -0
- package/lib/application/companion/agent-orchestrator.d.ts.map +1 -0
- package/lib/application/companion/agent-orchestrator.js +298 -0
- package/lib/application/companion/agent-orchestrator.js.map +1 -0
- package/lib/application/companion/companion-child-service.d.ts +47 -0
- package/lib/application/companion/companion-child-service.d.ts.map +1 -0
- package/lib/application/companion/companion-child-service.js +30 -0
- package/lib/application/companion/companion-child-service.js.map +1 -0
- package/lib/application/companion/companion-invocation-service.d.ts +42 -0
- package/lib/application/companion/companion-invocation-service.d.ts.map +1 -0
- package/lib/application/companion/companion-invocation-service.js +50 -0
- package/lib/application/companion/companion-invocation-service.js.map +1 -0
- package/lib/application/companion/companion-profile-service.d.ts +32 -0
- package/lib/application/companion/companion-profile-service.d.ts.map +1 -0
- package/lib/application/companion/companion-profile-service.js +112 -0
- package/lib/application/companion/companion-profile-service.js.map +1 -0
- package/lib/application/companion/companion-promotion-service.d.ts +69 -0
- package/lib/application/companion/companion-promotion-service.d.ts.map +1 -0
- package/lib/application/companion/companion-promotion-service.js +129 -0
- package/lib/application/companion/companion-promotion-service.js.map +1 -0
- package/lib/application/group-chat/group-chat-execution-service.d.ts +22 -0
- package/lib/application/group-chat/group-chat-execution-service.d.ts.map +1 -0
- package/lib/application/group-chat/group-chat-execution-service.js +110 -0
- package/lib/application/group-chat/group-chat-execution-service.js.map +1 -0
- package/lib/application/group-chat/group-chat-orchestrator.d.ts +51 -0
- package/lib/application/group-chat/group-chat-orchestrator.d.ts.map +1 -0
- package/lib/application/group-chat/group-chat-orchestrator.js +57 -0
- package/lib/application/group-chat/group-chat-orchestrator.js.map +1 -0
- package/lib/application/memory/memory-retriever.d.ts +37 -0
- package/lib/application/memory/memory-retriever.d.ts.map +1 -0
- package/lib/application/memory/memory-retriever.js +91 -0
- package/lib/application/memory/memory-retriever.js.map +1 -0
- package/lib/application/memory/memory-service.d.ts +128 -0
- package/lib/application/memory/memory-service.d.ts.map +1 -0
- package/lib/application/memory/memory-service.js +346 -0
- package/lib/application/memory/memory-service.js.map +1 -0
- package/lib/application/ports/companion-runtime-port.d.ts +72 -0
- package/lib/application/ports/companion-runtime-port.d.ts.map +1 -0
- package/lib/application/ports/companion-runtime-port.js +2 -0
- package/lib/application/ports/companion-runtime-port.js.map +1 -0
- package/lib/application/ports/llm-port.d.ts +7 -0
- package/lib/application/ports/llm-port.d.ts.map +1 -0
- package/lib/application/ports/llm-port.js +2 -0
- package/lib/application/ports/llm-port.js.map +1 -0
- package/lib/application/ports/message-source.d.ts +4 -0
- package/lib/application/ports/message-source.d.ts.map +1 -0
- package/lib/application/ports/message-source.js +5 -0
- package/lib/application/ports/message-source.js.map +1 -0
- package/lib/application/ports/session-context-port.d.ts +13 -0
- package/lib/application/ports/session-context-port.d.ts.map +1 -0
- package/lib/application/ports/session-context-port.js +2 -0
- package/lib/application/ports/session-context-port.js.map +1 -0
- package/lib/application/ports/subagent-port.d.ts +31 -0
- package/lib/application/ports/subagent-port.d.ts.map +1 -0
- package/lib/application/ports/subagent-port.js +2 -0
- package/lib/application/ports/subagent-port.js.map +1 -0
- package/lib/application/ports/user-resolver-port.d.ts +5 -0
- package/lib/application/ports/user-resolver-port.d.ts.map +1 -0
- package/lib/application/ports/user-resolver-port.js +2 -0
- package/lib/application/ports/user-resolver-port.js.map +1 -0
- package/lib/application/relationship/relationship-event-service.d.ts +31 -0
- package/lib/application/relationship/relationship-event-service.d.ts.map +1 -0
- package/lib/application/relationship/relationship-event-service.js +43 -0
- package/lib/application/relationship/relationship-event-service.js.map +1 -0
- package/lib/application/relationship/relationship-policy.d.ts +20 -0
- package/lib/application/relationship/relationship-policy.d.ts.map +1 -0
- package/lib/application/relationship/relationship-policy.js +24 -0
- package/lib/application/relationship/relationship-policy.js.map +1 -0
- package/lib/application/relationship/relationship-projection.d.ts +14 -0
- package/lib/application/relationship/relationship-projection.d.ts.map +1 -0
- package/lib/application/relationship/relationship-projection.js +25 -0
- package/lib/application/relationship/relationship-projection.js.map +1 -0
- package/lib/application/relationship/relationship-service.d.ts +95 -0
- package/lib/application/relationship/relationship-service.d.ts.map +1 -0
- package/lib/application/relationship/relationship-service.js +254 -0
- package/lib/application/relationship/relationship-service.js.map +1 -0
- package/lib/application/workspace/workspace-service.d.ts +106 -0
- package/lib/application/workspace/workspace-service.d.ts.map +1 -0
- package/lib/application/workspace/workspace-service.js +44 -0
- package/lib/application/workspace/workspace-service.js.map +1 -0
- package/lib/bootstrap/create-domain.d.ts +5 -0
- package/lib/bootstrap/create-domain.d.ts.map +1 -0
- package/lib/bootstrap/create-domain.js +14 -0
- package/lib/bootstrap/create-domain.js.map +1 -0
- package/lib/bootstrap/create-repositories.d.ts +403 -0
- package/lib/bootstrap/create-repositories.d.ts.map +1 -0
- package/lib/bootstrap/create-repositories.js +39 -0
- package/lib/bootstrap/create-repositories.js.map +1 -0
- package/lib/bootstrap/create-runtime.d.ts +8 -0
- package/lib/bootstrap/create-runtime.d.ts.map +1 -0
- package/lib/bootstrap/create-runtime.js +10 -0
- package/lib/bootstrap/create-runtime.js.map +1 -0
- package/lib/bootstrap/create-services.d.ts +52 -0
- package/lib/bootstrap/create-services.d.ts.map +1 -0
- package/lib/bootstrap/create-services.js +79 -0
- package/lib/bootstrap/create-services.js.map +1 -0
- package/lib/bootstrap/install-commands.d.ts +4 -0
- package/lib/bootstrap/install-commands.d.ts.map +1 -0
- package/lib/bootstrap/install-commands.js +322 -0
- package/lib/bootstrap/install-commands.js.map +1 -0
- package/lib/bootstrap/install-http.d.ts +7 -0
- package/lib/bootstrap/install-http.d.ts.map +1 -0
- package/lib/bootstrap/install-http.js +265 -0
- package/lib/bootstrap/install-http.js.map +1 -0
- package/lib/bootstrap/lifecycle.d.ts +14 -0
- package/lib/bootstrap/lifecycle.d.ts.map +1 -0
- package/lib/bootstrap/lifecycle.js +56 -0
- package/lib/bootstrap/lifecycle.js.map +1 -0
- package/lib/bootstrap/types.d.ts +9 -0
- package/lib/bootstrap/types.d.ts.map +1 -0
- package/lib/bootstrap/types.js +2 -0
- package/lib/bootstrap/types.js.map +1 -0
- package/lib/client.js +6 -0
- package/lib/client.js.map +1 -0
- package/lib/core/audit-service.d.ts +43 -0
- package/lib/core/audit-service.d.ts.map +1 -0
- package/lib/core/audit-service.js +75 -0
- package/lib/core/audit-service.js.map +1 -0
- package/lib/core/candidate-extractor.d.ts +31 -0
- package/lib/core/candidate-extractor.d.ts.map +1 -0
- package/lib/core/candidate-extractor.js +83 -0
- package/lib/core/candidate-extractor.js.map +1 -0
- package/lib/core/candidate-service.d.ts +72 -0
- package/lib/core/candidate-service.d.ts.map +1 -0
- package/lib/core/candidate-service.js +283 -0
- package/lib/core/candidate-service.js.map +1 -0
- package/lib/core/character-service.d.ts +26 -0
- package/lib/core/character-service.d.ts.map +1 -0
- package/lib/core/character-service.js +68 -0
- package/lib/core/character-service.js.map +1 -0
- package/lib/core/chat-file-io.d.ts +28 -0
- package/lib/core/chat-file-io.d.ts.map +1 -0
- package/lib/core/chat-file-io.js +114 -0
- package/lib/core/chat-file-io.js.map +1 -0
- package/lib/core/chat-service.d.ts +4 -0
- package/lib/core/chat-service.d.ts.map +1 -0
- package/lib/core/chat-service.js +3 -0
- package/lib/core/chat-service.js.map +1 -0
- package/lib/core/command-arguments.d.ts +2 -0
- package/lib/core/command-arguments.d.ts.map +1 -0
- package/lib/core/command-arguments.js +42 -0
- package/lib/core/command-arguments.js.map +1 -0
- package/lib/core/companion-child-agent-service.d.ts +3 -0
- package/lib/core/companion-child-agent-service.d.ts.map +1 -0
- package/lib/core/companion-child-agent-service.js +3 -0
- package/lib/core/companion-child-agent-service.js.map +1 -0
- package/lib/core/companion-invocation-service.d.ts +3 -0
- package/lib/core/companion-invocation-service.d.ts.map +1 -0
- package/lib/core/companion-invocation-service.js +3 -0
- package/lib/core/companion-invocation-service.js.map +1 -0
- package/lib/core/companion-profile-service.d.ts +3 -0
- package/lib/core/companion-profile-service.d.ts.map +1 -0
- package/lib/core/companion-profile-service.js +3 -0
- package/lib/core/companion-profile-service.js.map +1 -0
- package/lib/core/companion-promotion-service.d.ts +3 -0
- package/lib/core/companion-promotion-service.d.ts.map +1 -0
- package/lib/core/companion-promotion-service.js +3 -0
- package/lib/core/companion-promotion-service.js.map +1 -0
- package/lib/core/context-assembler.d.ts +92 -0
- package/lib/core/context-assembler.d.ts.map +1 -0
- package/lib/core/context-assembler.js +185 -0
- package/lib/core/context-assembler.js.map +1 -0
- package/lib/core/conversation-repository.d.ts +42 -0
- package/lib/core/conversation-repository.d.ts.map +1 -0
- package/lib/core/conversation-repository.js +94 -0
- package/lib/core/conversation-repository.js.map +1 -0
- package/lib/core/group-chat-execution-service.d.ts +3 -0
- package/lib/core/group-chat-execution-service.d.ts.map +1 -0
- package/lib/core/group-chat-execution-service.js +3 -0
- package/lib/core/group-chat-execution-service.js.map +1 -0
- package/lib/core/group-chat-orchestrator.d.ts +3 -0
- package/lib/core/group-chat-orchestrator.d.ts.map +1 -0
- package/lib/core/group-chat-orchestrator.js +3 -0
- package/lib/core/group-chat-orchestrator.js.map +1 -0
- package/lib/core/memory-retriever.d.ts +3 -0
- package/lib/core/memory-retriever.d.ts.map +1 -0
- package/lib/core/memory-retriever.js +3 -0
- package/lib/core/memory-retriever.js.map +1 -0
- package/lib/core/memory-service.d.ts +3 -0
- package/lib/core/memory-service.d.ts.map +1 -0
- package/lib/core/memory-service.js +3 -0
- package/lib/core/memory-service.js.map +1 -0
- package/lib/core/personality-candidate-service.d.ts +46 -0
- package/lib/core/personality-candidate-service.d.ts.map +1 -0
- package/lib/core/personality-candidate-service.js +65 -0
- package/lib/core/personality-candidate-service.js.map +1 -0
- package/lib/core/prompt-assembler.d.ts +43 -0
- package/lib/core/prompt-assembler.d.ts.map +1 -0
- package/lib/core/prompt-assembler.js +67 -0
- package/lib/core/prompt-assembler.js.map +1 -0
- package/lib/core/relationship-event-service.d.ts +3 -0
- package/lib/core/relationship-event-service.d.ts.map +1 -0
- package/lib/core/relationship-event-service.js +3 -0
- package/lib/core/relationship-event-service.js.map +1 -0
- package/lib/core/relationship-policy.d.ts +3 -0
- package/lib/core/relationship-policy.d.ts.map +1 -0
- package/lib/core/relationship-policy.js +3 -0
- package/lib/core/relationship-policy.js.map +1 -0
- package/lib/core/relationship-projection.d.ts +3 -0
- package/lib/core/relationship-projection.d.ts.map +1 -0
- package/lib/core/relationship-projection.js +3 -0
- package/lib/core/relationship-projection.js.map +1 -0
- package/lib/core/relationship-service.d.ts +3 -0
- package/lib/core/relationship-service.d.ts.map +1 -0
- package/lib/core/relationship-service.js +3 -0
- package/lib/core/relationship-service.js.map +1 -0
- package/lib/core/roleplay-contract.d.ts +11 -0
- package/lib/core/roleplay-contract.d.ts.map +1 -0
- package/lib/core/roleplay-contract.js +27 -0
- package/lib/core/roleplay-contract.js.map +1 -0
- package/lib/core/runtime-binding-service.d.ts +19 -0
- package/lib/core/runtime-binding-service.d.ts.map +1 -0
- package/lib/core/runtime-binding-service.js +66 -0
- package/lib/core/runtime-binding-service.js.map +1 -0
- package/lib/core/scene-service.d.ts +60 -0
- package/lib/core/scene-service.d.ts.map +1 -0
- package/lib/core/scene-service.js +212 -0
- package/lib/core/scene-service.js.map +1 -0
- package/lib/core/session-binding-service.d.ts +51 -0
- package/lib/core/session-binding-service.d.ts.map +1 -0
- package/lib/core/session-binding-service.js +106 -0
- package/lib/core/session-binding-service.js.map +1 -0
- package/lib/core/skill-service.d.ts +82 -0
- package/lib/core/skill-service.d.ts.map +1 -0
- package/lib/core/skill-service.js +45 -0
- package/lib/core/skill-service.js.map +1 -0
- package/lib/core/tavern-session-bridge.d.ts +3 -0
- package/lib/core/tavern-session-bridge.d.ts.map +1 -0
- package/lib/core/tavern-session-bridge.js +3 -0
- package/lib/core/tavern-session-bridge.js.map +1 -0
- package/lib/core/user-resolver.d.ts +15 -0
- package/lib/core/user-resolver.d.ts.map +1 -0
- package/lib/core/user-resolver.js +17 -0
- package/lib/core/user-resolver.js.map +1 -0
- package/lib/core/workspace-service.d.ts +3 -0
- package/lib/core/workspace-service.d.ts.map +1 -0
- package/lib/core/workspace-service.js +3 -0
- package/lib/core/workspace-service.js.map +1 -0
- package/lib/core/workspace-session-service.d.ts +11 -0
- package/lib/core/workspace-session-service.d.ts.map +1 -0
- package/lib/core/workspace-session-service.js +14 -0
- package/lib/core/workspace-session-service.js.map +1 -0
- package/lib/domain/schemas.d.ts +1173 -0
- package/lib/domain/schemas.d.ts.map +1 -0
- package/lib/domain/schemas.js +590 -0
- package/lib/domain/schemas.js.map +1 -0
- package/lib/domain/spec.d.ts +494 -0
- package/lib/domain/spec.d.ts.map +1 -0
- package/lib/domain/spec.js +63 -0
- package/lib/domain/spec.js.map +1 -0
- package/lib/import/artifact-service.d.ts +33 -0
- package/lib/import/artifact-service.d.ts.map +1 -0
- package/lib/import/artifact-service.js +67 -0
- package/lib/import/artifact-service.js.map +1 -0
- package/lib/import/import-service.d.ts +30 -0
- package/lib/import/import-service.d.ts.map +1 -0
- package/lib/import/import-service.js +154 -0
- package/lib/import/import-service.js.map +1 -0
- package/lib/import/parser.d.ts +81 -0
- package/lib/import/parser.d.ts.map +1 -0
- package/lib/import/parser.js +423 -0
- package/lib/import/parser.js.map +1 -0
- package/lib/index.d.ts +60 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +111 -0
- package/lib/index.js.map +1 -0
- package/lib/infrastructure/dsh/llm/llm-port.d.ts +3 -0
- package/lib/infrastructure/dsh/llm/llm-port.d.ts.map +1 -0
- package/lib/infrastructure/dsh/llm/llm-port.js +2 -0
- package/lib/infrastructure/dsh/llm/llm-port.js.map +1 -0
- package/lib/infrastructure/dsh/llm/model-gateway.d.ts +10 -0
- package/lib/infrastructure/dsh/llm/model-gateway.d.ts.map +1 -0
- package/lib/infrastructure/dsh/llm/model-gateway.js +21 -0
- package/lib/infrastructure/dsh/llm/model-gateway.js.map +1 -0
- package/lib/infrastructure/dsh/session/session-agent-provider.d.ts +28 -0
- package/lib/infrastructure/dsh/session/session-agent-provider.d.ts.map +1 -0
- package/lib/infrastructure/dsh/session/session-agent-provider.js +40 -0
- package/lib/infrastructure/dsh/session/session-agent-provider.js.map +1 -0
- package/lib/infrastructure/dsh/session/tavern-session-bridge.d.ts +142 -0
- package/lib/infrastructure/dsh/session/tavern-session-bridge.d.ts.map +1 -0
- package/lib/infrastructure/dsh/session/tavern-session-bridge.js +544 -0
- package/lib/infrastructure/dsh/session/tavern-session-bridge.js.map +1 -0
- package/lib/infrastructure/dsh/subagent/subagent-gateway.d.ts +63 -0
- package/lib/infrastructure/dsh/subagent/subagent-gateway.d.ts.map +1 -0
- package/lib/infrastructure/dsh/subagent/subagent-gateway.js +70 -0
- package/lib/infrastructure/dsh/subagent/subagent-gateway.js.map +1 -0
- package/lib/infrastructure/runtime/companion-runtime.d.ts +128 -0
- package/lib/infrastructure/runtime/companion-runtime.d.ts.map +1 -0
- package/lib/infrastructure/runtime/companion-runtime.js +127 -0
- package/lib/infrastructure/runtime/companion-runtime.js.map +1 -0
- package/lib/infrastructure/runtime/runtime-factory.d.ts +10 -0
- package/lib/infrastructure/runtime/runtime-factory.d.ts.map +1 -0
- package/lib/infrastructure/runtime/runtime-factory.js +14 -0
- package/lib/infrastructure/runtime/runtime-factory.js.map +1 -0
- package/lib/interfaces/http/chat/chat-http.d.ts +23 -0
- package/lib/interfaces/http/chat/chat-http.d.ts.map +1 -0
- package/lib/interfaces/http/chat/chat-http.js +310 -0
- package/lib/interfaces/http/chat/chat-http.js.map +1 -0
- package/lib/interfaces/http/companion/companion-http.d.ts +8 -0
- package/lib/interfaces/http/companion/companion-http.d.ts.map +1 -0
- package/lib/interfaces/http/companion/companion-http.js +76 -0
- package/lib/interfaces/http/companion/companion-http.js.map +1 -0
- package/lib/interfaces/http/companion/promotion-http.d.ts +6 -0
- package/lib/interfaces/http/companion/promotion-http.d.ts.map +1 -0
- package/lib/interfaces/http/companion/promotion-http.js +25 -0
- package/lib/interfaces/http/companion/promotion-http.js.map +1 -0
- package/lib/interfaces/http/companion/runtime-http.d.ts +13 -0
- package/lib/interfaces/http/companion/runtime-http.d.ts.map +1 -0
- package/lib/interfaces/http/companion/runtime-http.js +51 -0
- package/lib/interfaces/http/companion/runtime-http.js.map +1 -0
- package/lib/interfaces/http/companion/stage4-companion-http.d.ts +30 -0
- package/lib/interfaces/http/companion/stage4-companion-http.d.ts.map +1 -0
- package/lib/interfaces/http/companion/stage4-companion-http.js +149 -0
- package/lib/interfaces/http/companion/stage4-companion-http.js.map +1 -0
- package/lib/interfaces/http/group/group-http.d.ts +11 -0
- package/lib/interfaces/http/group/group-http.d.ts.map +1 -0
- package/lib/interfaces/http/group/group-http.js +77 -0
- package/lib/interfaces/http/group/group-http.js.map +1 -0
- package/lib/interfaces/http/memory/candidate-http.d.ts +8 -0
- package/lib/interfaces/http/memory/candidate-http.d.ts.map +1 -0
- package/lib/interfaces/http/memory/candidate-http.js +86 -0
- package/lib/interfaces/http/memory/candidate-http.js.map +1 -0
- package/lib/interfaces/http/relationship/companion-relationship-http.d.ts +7 -0
- package/lib/interfaces/http/relationship/companion-relationship-http.d.ts.map +1 -0
- package/lib/interfaces/http/relationship/companion-relationship-http.js +30 -0
- package/lib/interfaces/http/relationship/companion-relationship-http.js.map +1 -0
- package/lib/interfaces/http/workspace/workspace-http.d.ts +19 -0
- package/lib/interfaces/http/workspace/workspace-http.d.ts.map +1 -0
- package/lib/interfaces/http/workspace/workspace-http.js +78 -0
- package/lib/interfaces/http/workspace/workspace-http.js.map +1 -0
- package/lib/interfaces/read-model/tavern-read-api.d.ts +44 -0
- package/lib/interfaces/read-model/tavern-read-api.d.ts.map +1 -0
- package/lib/interfaces/read-model/tavern-read-api.js +189 -0
- package/lib/interfaces/read-model/tavern-read-api.js.map +1 -0
- package/lib/remote/candidate-api.d.ts +3 -0
- package/lib/remote/candidate-api.d.ts.map +1 -0
- package/lib/remote/candidate-api.js +3 -0
- package/lib/remote/candidate-api.js.map +1 -0
- package/lib/remote/chat-api.d.ts +3 -0
- package/lib/remote/chat-api.d.ts.map +1 -0
- package/lib/remote/chat-api.js +3 -0
- package/lib/remote/chat-api.js.map +1 -0
- package/lib/remote/companion-api.d.ts +3 -0
- package/lib/remote/companion-api.d.ts.map +1 -0
- package/lib/remote/companion-api.js +3 -0
- package/lib/remote/companion-api.js.map +1 -0
- package/lib/remote/companion-promotion-api.d.ts +3 -0
- package/lib/remote/companion-promotion-api.d.ts.map +1 -0
- package/lib/remote/companion-promotion-api.js +3 -0
- package/lib/remote/companion-promotion-api.js.map +1 -0
- package/lib/remote/import-http.d.ts +29 -0
- package/lib/remote/import-http.d.ts.map +1 -0
- package/lib/remote/import-http.js +106 -0
- package/lib/remote/import-http.js.map +1 -0
- package/lib/remote/stage4-api.d.ts +6 -0
- package/lib/remote/stage4-api.d.ts.map +1 -0
- package/lib/remote/stage4-api.js +4 -0
- package/lib/remote/stage4-api.js.map +1 -0
- package/lib/remote/stage5-runtime-api.d.ts +4 -0
- package/lib/remote/stage5-runtime-api.d.ts.map +1 -0
- package/lib/remote/stage5-runtime-api.js +2 -0
- package/lib/remote/stage5-runtime-api.js.map +1 -0
- package/lib/remote/stage6-group-api.d.ts +4 -0
- package/lib/remote/stage6-group-api.d.ts.map +1 -0
- package/lib/remote/stage6-group-api.js +2 -0
- package/lib/remote/stage6-group-api.js.map +1 -0
- package/lib/remote/tavern-api.d.ts +3 -0
- package/lib/remote/tavern-api.d.ts.map +1 -0
- package/lib/remote/tavern-api.js +3 -0
- package/lib/remote/tavern-api.js.map +1 -0
- package/lib/runtime/agent-orchestrator.d.ts +3 -0
- package/lib/runtime/agent-orchestrator.d.ts.map +1 -0
- package/lib/runtime/agent-orchestrator.js +3 -0
- package/lib/runtime/agent-orchestrator.js.map +1 -0
- package/lib/runtime/companion-runtime.d.ts +3 -0
- package/lib/runtime/companion-runtime.d.ts.map +1 -0
- package/lib/runtime/companion-runtime.js +3 -0
- package/lib/runtime/companion-runtime.js.map +1 -0
- package/lib/runtime/langgraph-graph.d.ts +32 -0
- package/lib/runtime/langgraph-graph.d.ts.map +1 -0
- package/lib/runtime/langgraph-graph.js +32 -0
- package/lib/runtime/langgraph-graph.js.map +1 -0
- package/lib/runtime/state.d.ts +38 -0
- package/lib/runtime/state.d.ts.map +1 -0
- package/lib/runtime/state.js +16 -0
- package/lib/runtime/state.js.map +1 -0
- package/lib/seed/elaine.d.ts +9 -0
- package/lib/seed/elaine.d.ts.map +1 -0
- package/lib/seed/elaine.js +27 -0
- package/lib/seed/elaine.js.map +1 -0
- package/lib/tools/import-character.d.ts +16 -0
- package/lib/tools/import-character.d.ts.map +1 -0
- package/lib/tools/import-character.js +98 -0
- package/lib/tools/import-character.js.map +1 -0
- package/package.json +108 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { createAssistantMessage } from '@deepseek-ai/dsh-llm';
|
|
3
|
+
import { ChatFileIO } from '../core/chat-file-io.js';
|
|
4
|
+
import { CandidateExtractor } from '../core/candidate-extractor.js';
|
|
5
|
+
import { CandidateService } from '../core/candidate-service.js';
|
|
6
|
+
import { ChatApplicationService } from '../application/chat/chat-application-service.js';
|
|
7
|
+
import { KvTableConversationRepository } from '../core/conversation-repository.js';
|
|
8
|
+
import { PromptAssembler } from '../core/prompt-assembler.js';
|
|
9
|
+
import { KvTableSessionBindingService } from '../core/session-binding-service.js';
|
|
10
|
+
import { TavernSessionBridge } from '../infrastructure/dsh/session/tavern-session-bridge.js';
|
|
11
|
+
import { LocalUserResolver } from '../core/user-resolver.js';
|
|
12
|
+
import { ModelGateway } from '../infrastructure/dsh/llm/model-gateway.js';
|
|
13
|
+
import { CompanionPromotionService } from '../application/companion/companion-promotion-service.js';
|
|
14
|
+
import { PersonalityCandidateService } from '../core/personality-candidate-service.js';
|
|
15
|
+
import { installTavernImportHttp } from '../remote/import-http.js';
|
|
16
|
+
import { installTavernApiHttp } from '../interfaces/read-model/tavern-read-api.js';
|
|
17
|
+
import { registerChatAPI } from '../interfaces/http/chat/chat-http.js';
|
|
18
|
+
import { registerCandidateApi } from '../interfaces/http/memory/candidate-http.js';
|
|
19
|
+
import { registerCompanionApi } from '../interfaces/http/companion/companion-http.js';
|
|
20
|
+
import { registerCompanionPromotionApi } from '../interfaces/http/companion/promotion-http.js';
|
|
21
|
+
import { registerCompanionStage4Http } from '../interfaces/http/companion/stage4-companion-http.js';
|
|
22
|
+
import { registerWorkspaceHttp } from '../interfaces/http/workspace/workspace-http.js';
|
|
23
|
+
import { registerCompanionRelationshipApi } from '../interfaces/http/relationship/companion-relationship-http.js';
|
|
24
|
+
import { registerCompanionRuntimeHttp } from '../interfaces/http/companion/runtime-http.js';
|
|
25
|
+
import { registerGroupHttp } from '../interfaces/http/group/group-http.js';
|
|
26
|
+
import { parseCommandArguments } from '../core/command-arguments.js';
|
|
27
|
+
function parseJsonPayload(raw) {
|
|
28
|
+
const text = raw.trim();
|
|
29
|
+
if (text === '')
|
|
30
|
+
return {};
|
|
31
|
+
return JSON.parse(text);
|
|
32
|
+
}
|
|
33
|
+
function errorResult(text) {
|
|
34
|
+
return { kind: 'error', text };
|
|
35
|
+
}
|
|
36
|
+
export function installTavernHttp(ctx, services, repositories, tavernService, workspacePath, config, lifecycle) {
|
|
37
|
+
const { characterService, importService, auditService, relationshipService, relationshipEventService, memoryService, companionProfiles, sceneService, skillService, workspaceService, runtimeBindings, workspaceSessions, companionInvocation, groupOrchestrator, groupExecution, contextAssembler, logger, relationshipProjection } = services;
|
|
38
|
+
const findCompanionByName = (ownerUserId, displayName) => {
|
|
39
|
+
const normalized = displayName.trim().toLocaleLowerCase();
|
|
40
|
+
const matches = companionProfiles.listForUser(ownerUserId).filter(profile => profile.status === 'active' && (profile.displayName ?? profile.identitySummary ?? '').trim().toLocaleLowerCase() === normalized);
|
|
41
|
+
if (matches.length === 0)
|
|
42
|
+
throw new Error(`[Tavern] 没有找到名为“${displayName}”的活跃伙伴`);
|
|
43
|
+
if (matches.length > 1)
|
|
44
|
+
throw new Error(`[Tavern] 有多个名为“${displayName}”的伙伴,请先设置唯一名称`);
|
|
45
|
+
return matches[0];
|
|
46
|
+
};
|
|
47
|
+
// 浏览器 HTTP 面(仅 web profile 有 webServer;probe 无此服务则跳过)。
|
|
48
|
+
// 注意:0.1.0-rc.6 的服务名是 webServer(dsh-host-webserver 提供,非旧版 httpServer);
|
|
49
|
+
// llm 由 dsh-llm 提供(阶段 1 普通聊天 ChatService 依赖,ADR-002);
|
|
50
|
+
// agents 由 dsh-agent 提供(阶段 2 DSH 原生会话绑定,ADR-008)。
|
|
51
|
+
ctx.inject(['webServer', 'llm', 'agents'], webCtx => {
|
|
52
|
+
const server = webCtx.get('webServer');
|
|
53
|
+
if (server === undefined)
|
|
54
|
+
return;
|
|
55
|
+
installTavernImportHttp(webCtx, importService, server);
|
|
56
|
+
// 阶段 5.5:UI 数据面(场景/角色/记忆/关系/审计,只读 + 当前场景指针)。
|
|
57
|
+
installTavernApiHttp(webCtx, {
|
|
58
|
+
scenes: sceneService,
|
|
59
|
+
memory: memoryService,
|
|
60
|
+
relationships: relationshipService,
|
|
61
|
+
audit: auditService,
|
|
62
|
+
relationshipEvents: relationshipEventService,
|
|
63
|
+
users: new LocalUserResolver(),
|
|
64
|
+
tavern: tavernService,
|
|
65
|
+
characters: characterService,
|
|
66
|
+
workspacePath: workspacePath,
|
|
67
|
+
}, server);
|
|
68
|
+
// 阶段 1:普通聊天旁路(非 Agent 模型调用,ADR-002/003)。
|
|
69
|
+
const llm = webCtx.get('llm');
|
|
70
|
+
if (llm === undefined)
|
|
71
|
+
return;
|
|
72
|
+
const conversationRepo = new KvTableConversationRepository(repositories.conversations, repositories.conversationMessages);
|
|
73
|
+
const promptAssembler = new PromptAssembler(characterService, contextAssembler, conversationRepo);
|
|
74
|
+
const modelGateway = new ModelGateway(llm);
|
|
75
|
+
const modelSelection = () => {
|
|
76
|
+
const defaultModel = webCtx.get('agentDefaultModel');
|
|
77
|
+
const selection = defaultModel?.currentSelection();
|
|
78
|
+
if (selection === undefined || selection.provider.trim() === '' || selection.model.trim() === '')
|
|
79
|
+
throw new Error('[Tavern] DSH 当前未配置可用模型,请先在 DSH 中配置模型提供方');
|
|
80
|
+
return selection;
|
|
81
|
+
};
|
|
82
|
+
const userResolver = new LocalUserResolver();
|
|
83
|
+
const candidateService = new CandidateService(repositories.insightCandidates, conversationRepo, memoryService, auditService, relationshipEventService, relationshipProjection);
|
|
84
|
+
const candidateExtractor = new CandidateExtractor(conversationRepo, candidateService, modelGateway, modelSelection);
|
|
85
|
+
const chatService = new ChatApplicationService(userResolver, characterService, conversationRepo, promptAssembler, modelGateway, modelSelection, (ownerUserId, conversationId) => candidateExtractor.extract(ownerUserId, conversationId).then(() => undefined), (ownerUserId, conversationId) => candidateService.reconcileConversationEvidence(ownerUserId, conversationId).then(() => undefined));
|
|
86
|
+
// 阶段 2:DSH 原生会话绑定桥(ADR-008;呈现方案 v2:角色=会话容器)。
|
|
87
|
+
const bindingService = new KvTableSessionBindingService(repositories.sessionBindings);
|
|
88
|
+
const sessionBridge = new TavernSessionBridge(new LocalUserResolver(), characterService, bindingService, chatService, modelSelection, workspacePath, companionProfiles);
|
|
89
|
+
// M3:聊天文件导入导出(SillyTavern jsonl)。
|
|
90
|
+
const chatFileIO = new ChatFileIO(characterService, chatService, conversationRepo);
|
|
91
|
+
registerChatAPI(webCtx, chatService, server, sessionBridge, chatFileIO, characterService, companionProfiles);
|
|
92
|
+
registerCandidateApi(webCtx, server, candidateService, candidateExtractor, userResolver);
|
|
93
|
+
const promotionService = new CompanionPromotionService(conversationRepo, characterService, modelGateway, modelSelection);
|
|
94
|
+
registerCompanionPromotionApi(webCtx, server, userResolver, promotionService);
|
|
95
|
+
// 升格后继续沉淀共同经历:/companion-remember 伙伴名 [conversationId]
|
|
96
|
+
ctx.effect(() => webCtx.commands.register({
|
|
97
|
+
name: 'companion-remember',
|
|
98
|
+
description: '把一次聊天归纳成新的共同经历事件,写入伙伴档案。用法:/companion-remember 伙伴名 可选conversationId',
|
|
99
|
+
input: { hint: '伙伴名 可选conversationId' },
|
|
100
|
+
recordInput: false,
|
|
101
|
+
handler: async (invocation) => {
|
|
102
|
+
const raw = invocation.rawInput.trim();
|
|
103
|
+
if (!raw)
|
|
104
|
+
return errorResult('[Tavern] 用法:/companion-remember "伙伴名" 可选conversationId');
|
|
105
|
+
let args;
|
|
106
|
+
try {
|
|
107
|
+
args = parseCommandArguments(raw);
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
return errorResult(error instanceof Error ? error.message : String(error));
|
|
111
|
+
}
|
|
112
|
+
const [displayName, ...rest] = args;
|
|
113
|
+
const owner = await new LocalUserResolver().getCurrentUserId();
|
|
114
|
+
let profile;
|
|
115
|
+
try {
|
|
116
|
+
profile = findCompanionByName(owner, displayName);
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
return errorResult(error instanceof Error ? error.message : String(error));
|
|
120
|
+
}
|
|
121
|
+
const conversationId = rest[0] ?? (await chatService.listConversations()).filter(item => item.characterId === profile.characterId && item.status === 'active').sort((a, b) => b.updatedAt.localeCompare(a.updatedAt))[0]?.id;
|
|
122
|
+
if (conversationId === undefined)
|
|
123
|
+
return errorResult('[Tavern] 没有找到可归纳的活跃聊天文件;请先在角色卡或伙伴 Agent 会话中聊天');
|
|
124
|
+
const events = await promotionService.summarizeSharedHistory(owner, profile.characterId, conversationId);
|
|
125
|
+
if (events.length === 0)
|
|
126
|
+
return errorResult('[Tavern] 模型没有归纳出新的共同经历事件');
|
|
127
|
+
for (const event of events) {
|
|
128
|
+
const stable = `shared-history:${profile.id}:${conversationId}:${createHash('sha256').update(`${conversationId}|${event.content}|${event.evidenceMessageIds.slice().sort().join(',')}`).digest('hex').slice(0, 24)}`;
|
|
129
|
+
await memoryService.remember({ id: stable, characterId: profile.characterId, ownerUserId: owner, fact: event.content, category: 'shared-experience', source: 'user', sourceMessageIds: event.evidenceMessageIds, confidence: 0.8, salience: 0.7, sourceEventId: `shared-history:${profile.id}:${conversationId}` });
|
|
130
|
+
}
|
|
131
|
+
return { kind: 'success', text: `✅ 已为 ${profile.displayName ?? profile.characterId} 归纳 ${events.length} 条新的共同经历:\n${events.map((event, index) => `${index + 1}. ${event.content}`).join('\n')}` };
|
|
132
|
+
},
|
|
133
|
+
}), 'tavern: register /companion-remember');
|
|
134
|
+
const personalityCandidates = new PersonalityCandidateService(repositories.personalityCandidates, repositories.companionProfiles, conversationRepo, auditService);
|
|
135
|
+
registerCompanionApi(webCtx, server, companionProfiles, personalityCandidates, characterService, userResolver);
|
|
136
|
+
registerWorkspaceHttp(webCtx, server, { users: userResolver, workspaces: workspaceService, profiles: companionProfiles, sessionBridge, openGroupSession: async (owner, workspaceId, sceneId) => {
|
|
137
|
+
const thread = await groupOrchestrator.createThread(owner, workspaceId, sceneId);
|
|
138
|
+
const opened = await sessionBridge.openEntertainmentSpace(webCtx, workspaceService.getForOwner(owner, workspaceId).name, `${owner}:${thread.id}`, async (session, payload) => {
|
|
139
|
+
const user = payload.messages[0];
|
|
140
|
+
if (user)
|
|
141
|
+
session.append('user/message', user, { surfaceOp: 'append' });
|
|
142
|
+
const text = user?.content.filter(block => block.type === 'text').map(block => block.text).join('') ?? '';
|
|
143
|
+
const posted = await groupOrchestrator.postUserMessage(owner, thread.id, text);
|
|
144
|
+
const result = await groupExecution.runBatch({ ownerUserId: owner, batchId: posted.batch.id, directParentSessionId: payload.agent.session.id });
|
|
145
|
+
let step = payload.step;
|
|
146
|
+
for (const reply of result.messages) {
|
|
147
|
+
session.append('assistant/message', { turn: payload.turn, step: step++, message: createAssistantMessage({ content: [{ type: 'text', text: reply.content }], source: { provider: modelSelection().provider, model: modelSelection().model } }) }, { surfaceOp: 'append' });
|
|
148
|
+
}
|
|
149
|
+
return { kind: 'reject' };
|
|
150
|
+
});
|
|
151
|
+
await workspaceSessions.create({ ownerUserId: owner, workspaceId, sceneId, threadId: thread.id, sessionId: opened.sessionId });
|
|
152
|
+
return { sessionId: opened.sessionId, threadId: thread.id };
|
|
153
|
+
} });
|
|
154
|
+
registerCompanionStage4Http(webCtx, server, { users: userResolver, characters: characterService, profiles: companionProfiles, personalities: personalityCandidates, workspaces: workspaceService, skills: skillService, relationships: relationshipService, memory: memoryService, conversations: conversationRepo, sessionBridge, openGroupSession: async (owner, workspaceId, sceneId) => {
|
|
155
|
+
const thread = await groupOrchestrator.createThread(owner, workspaceId, sceneId);
|
|
156
|
+
const opened = await sessionBridge.openEntertainmentSpace(webCtx, workspaceService.getForOwner(owner, workspaceId).name, `${owner}:${thread.id}`, async (session, payload) => {
|
|
157
|
+
const user = payload.messages[0];
|
|
158
|
+
if (user)
|
|
159
|
+
session.append('user/message', user, { surfaceOp: 'append' });
|
|
160
|
+
const text = user?.content.filter(block => block.type === 'text').map(block => block.text).join('') ?? '';
|
|
161
|
+
const posted = await groupOrchestrator.postUserMessage(owner, thread.id, text);
|
|
162
|
+
const result = await groupExecution.runBatch({ ownerUserId: owner, batchId: posted.batch.id, directParentSessionId: payload.agent.session.id });
|
|
163
|
+
let step = payload.step;
|
|
164
|
+
for (const reply of result.messages) {
|
|
165
|
+
session.append('assistant/message', { turn: payload.turn, step: step++, message: createAssistantMessage({ content: [{ type: 'text', text: reply.content }], source: { provider: modelSelection().provider, model: modelSelection().model } }) }, { surfaceOp: 'append' });
|
|
166
|
+
}
|
|
167
|
+
return { kind: 'reject' };
|
|
168
|
+
});
|
|
169
|
+
await workspaceSessions.create({ ownerUserId: owner, workspaceId, sceneId, threadId: thread.id, sessionId: opened.sessionId });
|
|
170
|
+
return { sessionId: opened.sessionId, threadId: thread.id };
|
|
171
|
+
} });
|
|
172
|
+
registerGroupHttp(webCtx, server, userResolver, groupOrchestrator, groupExecution, companionProfiles, { resolveDirectParentSession: async (owner, workspaceId) => {
|
|
173
|
+
const workspace = workspaceService.getForOwner(owner, workspaceId);
|
|
174
|
+
if (!workspace || workspace.status !== 'active')
|
|
175
|
+
throw new Error('[Tavern] Workspace 不存在或不可用');
|
|
176
|
+
const opened = await sessionBridge.openEntertainmentSpace(webCtx, workspace.name, `${owner}:${workspace.id}`);
|
|
177
|
+
if (opened.workspace.status !== 'attached')
|
|
178
|
+
throw new Error(`[Tavern] 娱乐空间 Host 会话未能挂载:${opened.workspace.error}`);
|
|
179
|
+
return opened.sessionId;
|
|
180
|
+
} });
|
|
181
|
+
registerCompanionRelationshipApi(webCtx, server, userResolver, companionProfiles);
|
|
182
|
+
registerCompanionRuntimeHttp(webCtx, server, { users: userResolver, invocation: companionInvocation, bindings: runtimeBindings });
|
|
183
|
+
// 存量迁移:旧角色会话容器行转为其当时 active 聊天文件的一对一 binding。
|
|
184
|
+
// 其它聊天文件保留在 Tavern 存储中,用户可从设置页按需重新打开。
|
|
185
|
+
void bindingService.migrateLegacyToConversation().then(summary => {
|
|
186
|
+
if (summary.migrated > 0)
|
|
187
|
+
logger.info(`[Tavern] 聊天文件会话 binding 迁移:${summary.migrated} 行`);
|
|
188
|
+
}).catch(error => {
|
|
189
|
+
logger.warn(`[Tavern] binding 迁移异常:${error instanceof Error ? error.message : String(error)}`);
|
|
190
|
+
});
|
|
191
|
+
// 阶段 2:DSH 原生会话恢复——binding 表全部 resume + 重挂 pre-step 拦截器。
|
|
192
|
+
// 延迟执行:dsh-agent-loop 的恢复协调器同一时刻只允许一个 resume 交易,
|
|
193
|
+
// 与宿主(含 smoke harness 的 parent/child 恢复)并发会抛
|
|
194
|
+
// "cannot prepare session while it is live"。等宿主恢复窗口过后再批量恢复。
|
|
195
|
+
const restoreBindings = () => {
|
|
196
|
+
void sessionBridge.resumeAll(webCtx).then(summary => {
|
|
197
|
+
logger.info(`[Tavern] DSH 原生会话恢复:${summary.restored} 个保留、${summary.rebuilt} 个重建、${summary.created} 个补建,${summary.failed.length} 个失败`);
|
|
198
|
+
if (summary.failed.length > 0) {
|
|
199
|
+
logger.warn(`[Tavern] 恢复失败详情:${summary.failed.join(';')}`);
|
|
200
|
+
}
|
|
201
|
+
}).catch(error => {
|
|
202
|
+
logger.warn(`[Tavern] 恢复过程异常:${error instanceof Error ? error.message : String(error)}`);
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
// 首次尝试:3 秒后(宿主恢复窗口过后);若仍被占用,5 秒后再试一次。
|
|
206
|
+
lifecycle.setTimeout(restoreBindings, 3000);
|
|
207
|
+
lifecycle.setTimeout(restoreBindings, 8000);
|
|
208
|
+
// attach 补挂:workspaceRegistry 可能晚于 reconcile 就绪(依赖 sessionPersistence 初始化)——
|
|
209
|
+
// 启动 15s/30s 后重试 pendingAttach,确保角色会话最终归入 Tavern 工作区。
|
|
210
|
+
const retryAttach = () => {
|
|
211
|
+
void sessionBridge.retryPendingAttach(webCtx).then(attached => {
|
|
212
|
+
if (attached > 0)
|
|
213
|
+
logger.info(`[Tavern] 工作区补挂成功:${attached} 个会话`);
|
|
214
|
+
}).catch(error => {
|
|
215
|
+
logger.warn(`[Tavern] 工作区补挂异常:${error instanceof Error ? error.message : String(error)}`);
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
lifecycle.setTimeout(retryAttach, 15000);
|
|
219
|
+
lifecycle.setTimeout(retryAttach, 30000);
|
|
220
|
+
// 阶段 1:普通聊天命令入口(非 Agent;经 ChatService,不创建子 Agent)。
|
|
221
|
+
ctx.effect(() => webCtx.commands.register({
|
|
222
|
+
name: 'tavern-chat',
|
|
223
|
+
description: '普通角色卡聊天(非 Agent 模型调用);参数为 JSON:{"characterId":"elaine","message":"你好","conversationId":"可选","sceneId":"可选"}',
|
|
224
|
+
input: { hint: '{"characterId":"elaine","message":"你好"}' },
|
|
225
|
+
recordInput: false,
|
|
226
|
+
handler: async (invocation) => {
|
|
227
|
+
let payload;
|
|
228
|
+
try {
|
|
229
|
+
payload = parseJsonPayload(invocation.rawInput);
|
|
230
|
+
}
|
|
231
|
+
catch {
|
|
232
|
+
return errorResult('[Tavern] tavern-chat 参数必须是 JSON 对象');
|
|
233
|
+
}
|
|
234
|
+
const record = typeof payload === 'object' && payload !== null
|
|
235
|
+
? payload
|
|
236
|
+
: {};
|
|
237
|
+
if (typeof record.characterId !== 'string' || record.characterId === '') {
|
|
238
|
+
return errorResult('[Tavern] tavern-chat 需要字符串参数 characterId');
|
|
239
|
+
}
|
|
240
|
+
if (typeof record.message !== 'string' || record.message === '') {
|
|
241
|
+
return errorResult('[Tavern] tavern-chat 需要非空字符串参数 message');
|
|
242
|
+
}
|
|
243
|
+
const result = await chatService.stream({
|
|
244
|
+
characterId: record.characterId,
|
|
245
|
+
message: record.message,
|
|
246
|
+
...(typeof record.conversationId === 'string' ? { conversationId: record.conversationId } : {}),
|
|
247
|
+
...(typeof record.sceneId === 'string' ? { sceneId: record.sceneId } : {}),
|
|
248
|
+
});
|
|
249
|
+
let reply = '';
|
|
250
|
+
for await (const delta of result.stream)
|
|
251
|
+
reply += delta;
|
|
252
|
+
return {
|
|
253
|
+
kind: 'success',
|
|
254
|
+
text: `✅ 已回复(普通聊天,非 Agent)\n${reply}\n---JSON---\n`
|
|
255
|
+
+ JSON.stringify({ conversationId: result.conversationId, messageId: result.messageId, reply }),
|
|
256
|
+
};
|
|
257
|
+
},
|
|
258
|
+
}), 'tavern: register /tavern-chat');
|
|
259
|
+
if (config.probe === true) {
|
|
260
|
+
const web = webCtx.get('webServer');
|
|
261
|
+
console.log(`[Tavern-PROBE] webServer inject ok; port=${web?.port ?? 'n/a'};chat API registered;/tavern-chat registered`);
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=install-http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install-http.js","sourceRoot":"","sources":["../../src/bootstrap/install-http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,iDAAiD,CAAA;AACxF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAA;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAA;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,wDAAwD,CAAA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AK,GAAG,EAAE,CAAA;gBACd,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM;oBAAE,KAAK,IAAI,KAAK,CAAA;gBACvD,OAAO;oBACL,IAAI,EAAE,SAAS;oBACf,IAAI,EAAE,wBAAwB,KAAK,gBAAgB;0BAC/C,IAAI,CAAC,SAAS,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,cAAc,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,CAAC;iBAClG,CAAA;YACH,CAAC;SACF,CAAC,EAAE,+BAA+B,CAAC,CAAA;QAEpC,IAAI,MAAM,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YAC1B,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,WAAW,CAAkC,CAAA;YACpE,OAAO,CAAC,GAAG,CAAC,4CAA4C,GAAG,EAAE,IAAI,IAAI,KAAK,8CAA8C,CAAC,CAAA;QAC3H,CAAC;IACH,CAAC,CAAC,CAAA;AAEF,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tavern bootstrap 生命周期管理。
|
|
3
|
+
*
|
|
4
|
+
* 所有由 Tavern 主动创建的长期定时任务都必须通过本对象注册,避免插件
|
|
5
|
+
* 更新/卸载后遗留旧 timer 继续执行。Host 的 ctx.effect 负责触发 dispose。
|
|
6
|
+
*/
|
|
7
|
+
export interface TavernLifecycle {
|
|
8
|
+
setTimeout(callback: () => void, delayMs: number): ReturnType<typeof setTimeout> | undefined;
|
|
9
|
+
setInterval(callback: () => void, delayMs: number): ReturnType<typeof setInterval> | undefined;
|
|
10
|
+
track(disposer: () => void): void;
|
|
11
|
+
dispose(): void;
|
|
12
|
+
}
|
|
13
|
+
export declare function createTavernLifecycle(): TavernLifecycle;
|
|
14
|
+
//# sourceMappingURL=lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../src/bootstrap/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,SAAS,CAAA;IAC5F,WAAW,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,GAAG,SAAS,CAAA;IAC9F,KAAK,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAA;IACjC,OAAO,IAAI,IAAI,CAAA;CAChB;AAED,wBAAgB,qBAAqB,IAAI,eAAe,CAgDvD"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export function createTavernLifecycle() {
|
|
2
|
+
const timers = new Set();
|
|
3
|
+
const disposers = new Set();
|
|
4
|
+
let disposed = false;
|
|
5
|
+
const removeTimer = (timer) => {
|
|
6
|
+
timers.delete(timer);
|
|
7
|
+
};
|
|
8
|
+
return {
|
|
9
|
+
setTimeout(callback, delayMs) {
|
|
10
|
+
if (disposed)
|
|
11
|
+
return undefined;
|
|
12
|
+
const timer = setTimeout(() => {
|
|
13
|
+
removeTimer(timer);
|
|
14
|
+
if (!disposed)
|
|
15
|
+
callback();
|
|
16
|
+
}, delayMs);
|
|
17
|
+
timers.add(timer);
|
|
18
|
+
return timer;
|
|
19
|
+
},
|
|
20
|
+
setInterval(callback, delayMs) {
|
|
21
|
+
if (disposed)
|
|
22
|
+
return undefined;
|
|
23
|
+
const timer = setInterval(() => {
|
|
24
|
+
if (!disposed)
|
|
25
|
+
callback();
|
|
26
|
+
}, delayMs);
|
|
27
|
+
timers.add(timer);
|
|
28
|
+
return timer;
|
|
29
|
+
},
|
|
30
|
+
track(disposer) {
|
|
31
|
+
if (disposed) {
|
|
32
|
+
disposer();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
disposers.add(disposer);
|
|
36
|
+
},
|
|
37
|
+
dispose() {
|
|
38
|
+
if (disposed)
|
|
39
|
+
return;
|
|
40
|
+
disposed = true;
|
|
41
|
+
for (const timer of timers) {
|
|
42
|
+
clearTimeout(timer);
|
|
43
|
+
clearInterval(timer);
|
|
44
|
+
}
|
|
45
|
+
timers.clear();
|
|
46
|
+
for (const disposer of disposers) {
|
|
47
|
+
try {
|
|
48
|
+
disposer();
|
|
49
|
+
}
|
|
50
|
+
catch { /* cleanup must continue */ }
|
|
51
|
+
}
|
|
52
|
+
disposers.clear();
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=lifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../src/bootstrap/lifecycle.ts"],"names":[],"mappings":"AAaA,MAAM,UAAU,qBAAqB;IACnC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkE,CAAA;IACxF,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAA;IACvC,IAAI,QAAQ,GAAG,KAAK,CAAA;IAEpB,MAAM,WAAW,GAAG,CAAC,KAAqE,EAAE,EAAE;QAC5F,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACtB,CAAC,CAAA;IAED,OAAO;QACL,UAAU,CAAC,QAAQ,EAAE,OAAO;YAC1B,IAAI,QAAQ;gBAAE,OAAO,SAAS,CAAA;YAC9B,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;gBAC5B,WAAW,CAAC,KAAK,CAAC,CAAA;gBAClB,IAAI,CAAC,QAAQ;oBAAE,QAAQ,EAAE,CAAA;YAC3B,CAAC,EAAE,OAAO,CAAC,CAAA;YACX,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;YACjB,OAAO,KAAK,CAAA;QACd,CAAC;QACD,WAAW,CAAC,QAAQ,EAAE,OAAO;YAC3B,IAAI,QAAQ;gBAAE,OAAO,SAAS,CAAA;YAC9B,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;gBAC7B,IAAI,CAAC,QAAQ;oBAAE,QAAQ,EAAE,CAAA;YAC3B,CAAC,EAAE,OAAO,CAAC,CAAA;YACX,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;YACjB,OAAO,KAAK,CAAA;QACd,CAAC;QACD,KAAK,CAAC,QAAQ;YACZ,IAAI,QAAQ,EAAE,CAAC;gBACb,QAAQ,EAAE,CAAA;gBACV,OAAM;YACR,CAAC;YACD,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QACzB,CAAC;QACD,OAAO;YACL,IAAI,QAAQ;gBAAE,OAAM;YACpB,QAAQ,GAAG,IAAI,CAAA;YACf,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;gBAC3B,YAAY,CAAC,KAAK,CAAC,CAAA;gBACnB,aAAa,CAAC,KAAK,CAAC,CAAA;YACtB,CAAC;YACD,MAAM,CAAC,KAAK,EAAE,CAAA;YACd,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;gBACjC,IAAI,CAAC;oBAAC,QAAQ,EAAE,CAAA;gBAAC,CAAC;gBAAC,MAAM,CAAC,CAAC,2BAA2B,CAAC,CAAC;YAC1D,CAAC;YACD,SAAS,CAAC,KAAK,EAAE,CAAA;QACnB,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Domain } from '@deepseek-ai/dsh-storage-domain';
|
|
2
|
+
import type { tavernDomainSpec } from '../domain/spec.js';
|
|
3
|
+
export type TavernDomain = Domain<typeof tavernDomainSpec>;
|
|
4
|
+
/** Resources created by the composition root, kept together for later installers. */
|
|
5
|
+
export interface TavernBootstrapResources {
|
|
6
|
+
readonly domain: TavernDomain;
|
|
7
|
+
readonly workspacePath: string;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/bootstrap/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAA;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAEzD,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAE1D,qFAAqF;AACrF,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAA;IAC7B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;CAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/bootstrap/types.ts"],"names":[],"mappings":""}
|
package/lib/client.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({id:`dsh-tavern-bundle`,factory:e=>{var t={exports:{}},n=t.exports;Object.defineProperty(n,Symbol.toStringTag,{value:`Module`});let r=e("react"),i=e("react/jsx-runtime");async function a(e){let t=await fetch(e,{headers:{accept:`application/json`}}),n=await t.json();if(!t.ok)throw Error(n.error??`请求失败(${t.status})`);return n}async function o(){return[...(await a(`/api/tavern/characters`)).characters]}async function s(){return[...(await a(`/api/chat/conversations`)).conversations]}async function c(e){return[...(await a(`/api/chat/messages?conversationId=${encodeURIComponent(e)}`)).messages]}async function l(e){return[...(await a(`/api/chat/greetings?characterId=${encodeURIComponent(e)}`)).greetings]}async function u(e){let t=await fetch(`/api/chat/characters/trash`,{method:`POST`,headers:{accept:`application/json`,"content-type":`application/json`},body:JSON.stringify({characterId:e})});if(!t.ok){let e=await t.json();throw Error(e.error??`删除角色失败(${t.status})`)}}async function d(){return[...(await a(`/api/chat/characters/trashed`)).characters]}async function f(e){let t=await fetch(`/api/chat/characters/restore`,{method:`POST`,headers:{accept:`application/json`,"content-type":`application/json`},body:JSON.stringify({characterId:e})});if(!t.ok){let e=await t.json();throw Error(e.error??`恢复角色失败(${t.status})`)}}async function p(e,t){let n=await fetch(`/api/chat/rename`,{method:`POST`,headers:{accept:`application/json`,"content-type":`application/json`},body:JSON.stringify({conversationId:e,title:t})});if(!n.ok){let e=await n.json();throw Error(e.error??`重命名失败(${n.status})`)}}async function m(e){let t=await fetch(`/api/chat/trash`,{method:`POST`,headers:{accept:`application/json`,"content-type":`application/json`},body:JSON.stringify({conversationId:e})});if(!t.ok){let e=await t.json();throw Error(e.error??`删除聊天失败(${t.status})`)}}async function h(e){let t=await fetch(`/api/chat/open`,{method:`POST`,headers:{accept:`application/json`,"content-type":`application/json`},body:JSON.stringify({conversationId:e})}),n=await t.json();if(!t.ok||typeof n.sessionId!=`string`||typeof n.conversationId!=`string`)throw Error(n.error??`打开聊天失败(${t.status})`);return{sessionId:n.sessionId,conversationId:n.conversationId}}async function g(e){let t=await fetch(`/api/tavern/import?filename=${encodeURIComponent(e.name)}`,{method:`POST`,headers:{accept:`application/json`},body:e}),n=await t.json();if(!t.ok||typeof n.characterId!=`string`)throw Error(n.error??`导入角色卡失败(${t.status})`);return n}async function _(e){return(await a(`/api/chat/export?conversationId=${encodeURIComponent(e)}`)).jsonl}async function v(e,t,n){let r=await fetch(`/api/chat/import`,{method:`POST`,headers:{accept:`application/json`,"content-type":`application/json`},body:JSON.stringify({characterId:e,content:t,...n===void 0?{}:{title:n}})}),i=await r.json();if(!r.ok||typeof i.conversationId!=`string`)throw Error(i.error??`导入失败(${r.status})`);return i.conversationId}async function y(e,t){let n=await fetch(`/api/chat/bind`,{method:`POST`,headers:{accept:`application/json`,"content-type":`application/json`},body:JSON.stringify({characterId:e,...t?.greetingIndex===void 0?{}:{greetingIndex:t.greetingIndex},...t?.sceneId===void 0?{}:{sceneId:t.sceneId}})}),r=await n.json();if(!n.ok||typeof r.sessionId!=`string`||typeof r.conversationId!=`string`)throw Error(r.error??`绑定会话失败(${n.status})`);return{sessionId:r.sessionId,conversationId:r.conversationId}}async function b(e){let t=await fetch(`/api/chat/bind-companion-agent`,{method:`POST`,headers:{accept:`application/json`,"content-type":`application/json`},body:JSON.stringify({companionProfileId:e})}),n=await t.json();if(!t.ok||typeof n.sessionId!=`string`||typeof n.conversationId!=`string`||typeof n.restored!=`boolean`)throw Error(n.error??`打开伙伴 Agent 会话失败(${t.status})`);return{sessionId:n.sessionId,conversationId:n.conversationId,restored:n.restored}}async function x(e=`pending`){return[...(await a(`/api/tavern/candidates?status=${encodeURIComponent(e)}`)).candidates]}async function S(e){return[...(await a(`/api/tavern/candidates/${encodeURIComponent(e)}/evidence`)).messages]}var C=class extends Error{conflicts;constructor(e){super(`candidate-conflict`),this.conflicts=e}};async function w(e,t,n,r){let i=await fetch(`/api/tavern/candidates/${encodeURIComponent(e)}/${t?`accept`:`reject`}`,{method:`POST`,headers:{accept:`application/json`,"content-type":`application/json`},...t&&(n!==void 0||r!==void 0)?{body:JSON.stringify({...n===void 0?{}:{content:n},...r===void 0?{}:{supersedeMemoryId:r}})}:{}});if(!i.ok){let e=await i.json();throw i.status===409&&Array.isArray(e.conflicts)?new C(e.conflicts):Error(e.error??`审阅失败(${i.status})`)}}async function T(e,t){let n=await fetch(`/api/tavern/candidates/${encodeURIComponent(e)}/mark-sensitive`,{method:`POST`,headers:{accept:`application/json`,"content-type":`application/json`},body:JSON.stringify({sensitivity:t})});if(!n.ok){let e=await n.json();throw Error(e.error??`标记敏感失败(${n.status})`)}}async function E(e,t){let n=await fetch(`/api/tavern/candidates/${encodeURIComponent(e)}/supersede`,{method:`POST`,headers:{accept:`application/json`,"content-type":`application/json`},body:JSON.stringify({newContent:t})});if(!n.ok){let e=await n.json();throw Error(e.error??`更正候选失败(${n.status})`)}}async function D(e){let t=await fetch(`/api/tavern/candidates/extract`,{method:`POST`,headers:{accept:`application/json`,"content-type":`application/json`},body:JSON.stringify({conversationId:e})});if(!t.ok){let e=await t.json();throw Error(e.error??`提取失败(${t.status})`)}}async function O(e,t){let n=await fetch(`/api/tavern/stage4${e}`,{method:`POST`,headers:{accept:`application/json`,"content-type":`application/json`},body:JSON.stringify(t)}),r=await n.json();if(!n.ok)throw Error(r.error??`请求失败(${n.status})`);return r}async function k(){return(await a(`/api/tavern/stage4/companions`)).profiles}async function A(e,t){return(await O(`/promotions/preview`,{characterId:e,conversationId:t})).candidate}async function j(e){return(await O(`/companions/promote`,e)).profile}async function M(){return(await a(`/api/tavern/stage5/runtime/bindings`)).bindings}async function N(e){return a(`/api/tavern/stage4/companions/${encodeURIComponent(e)}`)}async function P(e,t){await O(`/companions/${encodeURIComponent(e)}/skills`,t)}async function ee(e,t){await O(`/skills/${encodeURIComponent(e)}/${t?`enable`:`disable`}`,{})}async function F(e,t){return(await O(`/companions/${encodeURIComponent(e)}/name`,{displayName:t})).profile}async function te(e,t){return(await O(`/companions/${encodeURIComponent(e)}/status`,{status:t})).profile}async function I(e,t){let n=t===void 0?``:`?sceneId=${encodeURIComponent(t)}`;return(await a(`/api/companions/${encodeURIComponent(e)}/relationships${n}`)).relationships}async function L(e,t){let n=await fetch(`/api/tavern/personality-candidates/${encodeURIComponent(e)}/${t?`accept`:`reject`}`,{method:`POST`,headers:{accept:`application/json`,"content-type":`application/json`},body:JSON.stringify({})});if(!n.ok){let e=await n.json();throw Error(e.error??`性格审阅失败(${n.status})`)}}async function R(){return(await a(`/api/tavern/stage4/workspaces`)).workspaces}async function z(e){let t=await O(`/workspaces`,{name:e,createDefaultScene:!0});return{...t.workspace,sceneIds:t.sceneId?[t.sceneId]:[]}}async function ne(e,t,n){await O(`/workspaces/members`,{workspaceId:e,companionProfileId:t,sceneId:n})}async function re(e){return a(`/api/tavern/stage4/workspaces/${encodeURIComponent(e)}/details`)}async function B(e,t){await O(`/workspaces/members/remove`,{workspaceId:e,companionProfileId:t})}async function ie(e){return O(`/workspaces/${encodeURIComponent(e)}/open-session`,{})}async function ae(e){return(await a(`/api/tavern/stage6/groups/threads?workspaceId=${encodeURIComponent(e)}`)).threads}async function oe(e,t,n=[]){let r=await fetch(`/api/tavern/stage6/groups/threads/${encodeURIComponent(e)}/messages`,{method:`POST`,headers:{accept:`application/json`,"content-type":`application/json`},body:JSON.stringify({content:t,mentions:n})}),i=await r.json();if(!r.ok||!i.message||!i.batch)throw Error(i.error??`发送群聊消息失败(${r.status})`);return{message:i.message,batch:i.batch,deliveries:i.deliveries??[]}}async function se(e){return(await a(`/api/tavern/stage6/groups/threads/${encodeURIComponent(e)}/messages`)).messages}async function ce(e){return a(`/api/tavern/stage6/groups/batches/${encodeURIComponent(e)}`)}var V={ink:`#f2eee7`,muted:`#a69f96`,line:`rgba(242,238,231,.12)`,panel:`rgba(31,34,39,.72)`,panelStrong:`rgba(42,45,51,.9)`,accent:`#d8a46c`,green:`#9dc7a0`,red:`#e59a91`,blue:`#9fb8d8`},H={border:`1px solid ${V.line}`,background:`transparent`,color:V.ink,borderRadius:6,padding:`7px 11px`,cursor:`pointer`,fontSize:12},le={...H,background:V.accent,color:`#211b16`,borderColor:V.accent,fontWeight:700},U={width:`100%`,boxSizing:`border-box`,border:`1px solid ${V.line}`,background:`rgba(0,0,0,.18)`,color:V.ink,borderRadius:5,padding:`9px 10px`,fontSize:13},W={background:V.panel,border:`1px solid ${V.line}`,borderRadius:8,padding:16};function ue({children:e,tone:t=V.muted}){return(0,i.jsx)(`span`,{style:{color:t,fontSize:11,border:`1px solid ${t}66`,borderRadius:999,padding:`3px 7px`},children:e})}function G({children:e}){return(0,i.jsx)(`div`,{style:{color:V.muted,fontSize:13,padding:`25px 0`,textAlign:`center`},children:e})}function K({onOpenProfile:e}){let[t,n]=(0,r.useState)([]),[a,o]=(0,r.useState)(null);return(0,r.useEffect)(()=>{k().then(e=>n(e.filter(e=>e.status!==`retired`))).catch(e=>o(e instanceof Error?e.message:String(e)))},[]),(0,i.jsxs)(`div`,{children:[(0,i.jsxs)(`div`,{style:{marginBottom:22},children:[(0,i.jsx)(`div`,{style:{color:V.accent,fontSize:12,letterSpacing:1.5,textTransform:`uppercase`},children:`Long-term companions`}),(0,i.jsx)(`h2`,{style:{margin:`6px 0`,fontSize:25},children:`我的长期伙伴`}),(0,i.jsx)(`p`,{style:{color:V.muted,margin:0,fontSize:13},children:`角色卡是起点。这里保存那些经过共同经历、记忆和确认后,可以继续回来的角色。`})]}),a&&(0,i.jsx)(`div`,{style:{color:V.red,marginBottom:12},children:a}),t.length===0?(0,i.jsx)(G,{children:`还没有长期伙伴。先在“角色与聊天”中选择一张角色卡升格。`}):(0,i.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(260px, 1fr))`,gap:12},children:t.map(t=>(0,i.jsxs)(`div`,{style:W,children:[(0,i.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`start`,gap:8},children:[(0,i.jsxs)(`div`,{children:[(0,i.jsx)(`div`,{style:{fontSize:19,fontWeight:700},children:t.displayName||t.identitySummary||`未命名伙伴`}),(0,i.jsxs)(`div`,{style:{color:V.muted,fontSize:12,marginTop:4},children:[`角色卡 `,t.characterRevision?`v${t.characterRevision}`:``]})]}),(0,i.jsx)(ue,{tone:t.status===`active`?V.green:V.muted,children:t.status===`active`?`活跃`:t.status})]}),(0,i.jsx)(`p`,{style:{color:V.muted,fontSize:13,lineHeight:1.55,minHeight:42},children:t.personalitySummary||`性格还在形成中,完成几次聊天后可以进行确认。`}),(0,i.jsx)(`div`,{style:{display:`flex`,gap:7,flexWrap:`wrap`},children:(0,i.jsx)(`button`,{type:`button`,style:le,onClick:()=>e(t.id),children:`打开伙伴档案`})})]},t.id))})]})}function de({profileId:e,onBack:t,onContinue:n}){let[a,o]=(0,r.useState)(null),[s,c]=(0,r.useState)([]),[l,u]=(0,r.useState)([]),[d,f]=(0,r.useState)(null),[p,m]=(0,r.useState)(!1),[h,g]=(0,r.useState)(``),[_,v]=(0,r.useState)(``),[y,x]=(0,r.useState)(``),[S,C]=(0,r.useState)(!1),[w,T]=(0,r.useState)(``),[E,D]=(0,r.useState)([]),[O,A]=(0,r.useState)(null),j=(0,r.useCallback)(()=>{Promise.all([N(e),I(e)]).then(([e,t])=>{o(e),c(t),f(null)}).catch(e=>f(e instanceof Error?e.message:String(e)))},[e]);if((0,r.useEffect)(j,[j]),(0,r.useEffect)(()=>{Promise.all([k(),M()]).then(([t,n])=>{u(t),D(n.filter(t=>t.companionProfileId===e))}).catch(()=>{})},[e]),d)return(0,i.jsx)(`div`,{style:{color:V.red},children:d});if(!a)return(0,i.jsx)(G,{children:`正在读取伙伴档案…`});let L=a.profile,R=L.displayName||L.identitySummary||L.id,z=async()=>{try{let t=await b(e);A(t.restored?`已恢复伙伴 Agent 会话。`:`已创建伙伴 Agent 会话。`),n(t.sessionId)}catch(e){f(e instanceof Error?e.message:String(e))}},ne=async()=>{if(window.confirm(`解散“${R}”?这不会删除聊天记录、记忆或审计历史,之后可以从新的聊天文件重新升格。`))try{await te(e,`retired`),A(`伙伴已解散。原聊天与记忆仍然保留。`),j()}catch(e){f(e instanceof Error?e.message:String(e))}};return(0,i.jsxs)(`div`,{children:[(0,i.jsx)(`button`,{type:`button`,style:{...H,marginBottom:18},onClick:t,children:`← 返回伙伴列表`}),(0,i.jsxs)(`div`,{style:{...W,background:`linear-gradient(135deg, rgba(122,91,64,.38), rgba(31,34,39,.85))`,marginBottom:12},children:[(0,i.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`start`},children:[(0,i.jsxs)(`div`,{children:[(0,i.jsx)(`div`,{style:{color:V.accent,fontSize:12,letterSpacing:1},children:`COMPANION PROFILE`}),S?(0,i.jsxs)(`div`,{style:{display:`flex`,gap:7,margin:`7px 0`},children:[(0,i.jsx)(`input`,{autoFocus:!0,style:{...U,maxWidth:280},value:w,onChange:e=>T(e.target.value),onKeyDown:t=>{t.key===`Enter`&&w.trim()&&F(e,w).then(()=>{C(!1),j()}).catch(e=>f(e instanceof Error?e.message:String(e)))}}),(0,i.jsx)(`button`,{type:`button`,style:le,disabled:!w.trim(),onClick:t=>{t.preventDefault(),t.stopPropagation(),F(e,w).then(()=>{C(!1),j()}).catch(e=>f(e instanceof Error?e.message:String(e)))},children:`保存`}),(0,i.jsx)(`button`,{type:`button`,style:H,onClick:()=>C(!1),children:`取消`})]}):(0,i.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,i.jsx)(`h2`,{style:{margin:`7px 0 3px`,fontSize:28},children:L.displayName||L.identitySummary||`长期伙伴`}),(0,i.jsx)(`button`,{type:`button`,style:{...H,padding:`4px 7px`},title:`修改伙伴名称`,onClick:()=>{T(R),C(!0)},children:`改名`})]}),(0,i.jsx)(`div`,{style:{color:V.muted,fontSize:13},children:L.status===`active`?`可以在 DSH 会话中以角色身份陪你聊天,也可以加入娱乐空间。`:`当前不会创建新的运行实例。`})]}),(0,i.jsx)(ue,{tone:L.status===`active`?V.green:V.muted,children:L.status})]}),L.status===`active`&&(0,i.jsxs)(`div`,{style:{marginTop:15,display:`grid`,gap:8},children:[(0,i.jsx)(`button`,{type:`button`,style:le,onClick:e=>{e.preventDefault(),e.stopPropagation(),z()},children:`和升格的 Agent 聊天`}),O&&(0,i.jsx)(`div`,{style:{color:V.green,fontSize:12},children:O}),(0,i.jsxs)(`div`,{style:{color:V.muted,fontSize:12},children:[`或在任意个人 Agent 会话中输入`,(0,i.jsxs)(`div`,{style:{...U,marginTop:6,color:V.ink,userSelect:`all`},children:[`/companion-summon "`,R.replaceAll(`"`,`"`),`" 请陪我聊聊天`]})]})]})]}),(0,i.jsxs)(`div`,{style:{...W,marginBottom:12,display:`flex`,justifyContent:`space-between`,alignItems:`center`,gap:12},children:[(0,i.jsx)(`div`,{style:{color:V.muted,fontSize:12},children:`解散只结束伙伴身份,不会删除原聊天、记忆或关系历史。`}),(0,i.jsx)(`button`,{type:`button`,style:{...H,color:V.red},onClick:e=>{e.preventDefault(),e.stopPropagation(),ne()},children:L.status===`retired`?`伙伴已解散`:`解散伙伴`})]}),(0,i.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(250px, 1fr))`,gap:12},children:[(0,i.jsxs)(`section`,{style:W,children:[(0,i.jsx)(`h3`,{style:{marginTop:0},children:`她的性格`}),(0,i.jsx)(`p`,{style:{color:V.muted,lineHeight:1.55},children:L.personalitySummary||`尚未确认长期性格。`}),(L.personalityTraits??[]).map(e=>(0,i.jsxs)(`div`,{style:{borderTop:`1px solid ${V.line}`,padding:`9px 0`,fontSize:13},children:[(0,i.jsx)(`b`,{children:e.name}),(0,i.jsxs)(`span`,{style:{float:`right`,color:V.accent},children:[Math.round(e.strength*100),`%`]}),(0,i.jsx)(`div`,{style:{color:V.muted,marginTop:4},children:e.description})]},e.id))]}),(0,i.jsxs)(`section`,{style:W,children:[(0,i.jsx)(`h3`,{style:{marginTop:0},children:`身份与背景`}),(0,i.jsx)(`p`,{style:{color:V.muted,lineHeight:1.55},children:L.identitySummary||`升格时没有总结到身份与背景;可以重新升格,或在伙伴档案中补充。`})]}),(0,i.jsxs)(`section`,{style:W,children:[(0,i.jsx)(`h3`,{style:{marginTop:0},children:`你们的关系`}),(0,i.jsx)(`p`,{style:{color:V.muted,lineHeight:1.55},children:L.userRelationshipSummary||`升格时没有总结到你们的关系;可以重新升格,或在伙伴档案中补充。`})]}),(0,i.jsxs)(`section`,{style:W,children:[(0,i.jsx)(`h3`,{style:{marginTop:0},children:`共同经历`}),(0,i.jsx)(`div`,{style:{fontSize:28,color:V.accent},children:a.memories.filter(e=>e.category===`shared-experience`).length}),(0,i.jsx)(`div`,{style:{color:V.muted,fontSize:12},children:`条共同经历事件`}),a.memories.filter(e=>e.category===`shared-experience`).length===0?(0,i.jsx)(G,{children:`还没有共同经历事件。升格时会从聊天中归纳,之后也可以用 /companion-remember 继续沉淀。`}):a.memories.filter(e=>e.category===`shared-experience`).map(e=>(0,i.jsx)(`div`,{style:{borderTop:`1px solid ${V.line}`,padding:`9px 0`,fontSize:13},children:e.fact},e.id))]}),(0,i.jsxs)(`section`,{style:W,children:[(0,i.jsx)(`h3`,{style:{marginTop:0},children:`她认识谁`}),s.length===0?(0,i.jsx)(G,{children:`尚未认识其他伙伴`}):s.map((e,t)=>(0,i.jsxs)(`div`,{style:{borderTop:`1px solid ${V.line}`,padding:`9px 0`,fontSize:13},children:[(0,i.jsx)(`b`,{children:e.type}),(0,i.jsx)(`span`,{style:{float:`right`,color:V.accent},children:e.value}),(0,i.jsxs)(`div`,{style:{color:V.muted,marginTop:4},children:[l.find(t=>`companion:${t.id}`===e.fromNodeId)?.displayName||l.find(t=>`companion:${t.id}`===e.fromNodeId)?.identitySummary||`当前伙伴`,` → `,l.find(t=>`companion:${t.id}`===e.toNodeId)?.displayName||l.find(t=>`companion:${t.id}`===e.toNodeId)?.identitySummary||`另一位伙伴`]})]},t))]}),(0,i.jsxs)(`section`,{style:W,children:[(0,i.jsx)(`h3`,{style:{marginTop:0},children:`运行状态`}),(0,i.jsx)(`p`,{style:{color:V.muted,fontSize:12,lineHeight:1.5},children:`伙伴聊天和召唤都会使用当前 DSH 会话的模型;Tavern 不保存模型或 API Key。`}),(0,i.jsx)(`div`,{style:{borderTop:`1px solid ${V.line}`,marginTop:12,paddingTop:10},children:E.length===0?(0,i.jsx)(`div`,{style:{color:V.muted,fontSize:12},children:`暂无运行中的伙伴。她会以角色身份回应,不会把内部运行过程带入聊天。`}):(0,i.jsx)(`div`,{style:{display:`grid`,gap:5},children:E.slice(0,4).map(e=>(0,i.jsxs)(`div`,{style:{fontSize:12,display:`flex`,justifyContent:`space-between`,gap:8},children:[(0,i.jsx)(`span`,{style:{color:e.runtimeType===`dsh-child`?V.blue:V.muted},children:e.runtimeType===`dsh-child`?`DSH 子代理`:e.purpose}),(0,i.jsx)(ue,{tone:e.status===`active`?V.green:e.status===`orphaned`?V.red:V.muted,children:e.status})]},e.id))})})]})]}),(0,i.jsxs)(`section`,{style:{...W,marginTop:12},children:[(0,i.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,i.jsxs)(`div`,{children:[(0,i.jsx)(`h3`,{style:{margin:0},children:`她的 Skills`}),(0,i.jsx)(`div`,{style:{color:V.muted,fontSize:12,marginTop:4},children:`Skill 决定她如何工作。`})]}),(0,i.jsx)(`button`,{type:`button`,style:H,onClick:()=>m(e=>!e),children:`+ 新建 Skill`})]}),p&&(0,i.jsxs)(`div`,{style:{marginTop:14,padding:14,background:`rgba(0,0,0,.16)`,borderRadius:6,display:`grid`,gap:8},children:[(0,i.jsx)(`input`,{style:U,placeholder:`Skill 名称,例如:项目架构顾问`,value:h,onChange:e=>g(e.target.value)}),(0,i.jsx)(`input`,{style:U,placeholder:`一句话说明`,value:_,onChange:e=>v(e.target.value)}),(0,i.jsx)(`textarea`,{style:{...U,minHeight:80},placeholder:`工作步骤和行为边界`,value:y,onChange:e=>x(e.target.value)}),(0,i.jsx)(`div`,{children:(0,i.jsx)(`button`,{type:`button`,style:le,disabled:!h||!y,onClick:()=>void P(e,{name:h,description:_,instructions:y,workflowId:`analysis`}).then(()=>{m(!1),g(``),v(``),x(``),j()}).catch(e=>f(e instanceof Error?e.message:String(e))),children:`保存 Skill`})})]}),a.skills.length===0?(0,i.jsx)(G,{children:`还没有 Skill。为她添加一种更擅长帮助你的工作方式。`}):a.skills.map(e=>(0,i.jsxs)(`div`,{style:{borderTop:`1px solid ${V.line}`,padding:`11px 0`,display:`flex`,justifyContent:`space-between`,gap:12},children:[(0,i.jsxs)(`div`,{children:[(0,i.jsx)(`b`,{children:e.name}),(0,i.jsxs)(`span`,{style:{color:V.muted,fontSize:11,marginLeft:8},children:[`v`,e.version]}),(0,i.jsx)(`div`,{style:{color:V.muted,fontSize:12,marginTop:4},children:e.description})]}),(0,i.jsx)(`button`,{type:`button`,style:H,onClick:()=>void ee(e.id,e.status===`disabled`).then(j),children:e.status===`active`?`停用`:`启用`})]},e.id))]})]})}function fe({onBack:e,onOpenSession:t}){let[n,a]=(0,r.useState)([]),[o,s]=(0,r.useState)([]),[c,l]=(0,r.useState)(``),[u,d]=(0,r.useState)(new Set),[f,p]=(0,r.useState)(new Set),[m,h]=(0,r.useState)(new Set),[g,_]=(0,r.useState)([]),[v,y]=(0,r.useState)([]),[b,x]=(0,r.useState)(``),[S,C]=(0,r.useState)(``),[w,T]=(0,r.useState)(``),[E,D]=(0,r.useState)([]),[O,A]=(0,r.useState)(``),[j,M]=(0,r.useState)(``),[N,P]=(0,r.useState)(null),[ee,F]=(0,r.useState)([]),[te,I]=(0,r.useState)(null),[L,K]=(0,r.useState)(!1),[de,fe]=(0,r.useState)(null),pe=(0,r.useCallback)(async()=>{fe(null);try{let[e,t]=await Promise.all([R(),k()]);a(e),s(t),e.length===1&&c===``&&l(e[0].id)}catch(e){fe(e instanceof Error?e.message:String(e))}},[c]);(0,r.useEffect)(()=>{pe()},[pe]),(0,r.useEffect)(()=>{if(!c){_([]),y([]),d(new Set);return}Promise.all([re(c),ae(c)]).then(([e,t])=>{_(e.scenes),y(t),d(new Set(e.members.map(e=>e.entityId))),p(new Set(e.members.map(e=>e.entityId))),T(e.scenes.find(e=>e.status===`active`)?.id??``)}).catch(e=>I(e instanceof Error?e.message:String(e)))},[c]);let q=(0,r.useMemo)(()=>o.filter(e=>u.has(e.id)),[o,u]),J=(e,t)=>e(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}),Y=async()=>{if(b.trim()){K(!0);try{let e=await z(b.trim());a(t=>[...t,e]),l(e.id),x(``)}catch(e){I(e instanceof Error?e.message:String(e))}finally{K(!1)}}},me=async()=>{if(!(!c||!w||!q.length)){K(!0);try{for(let e of o)u.has(e.id)?await ne(c,e.id,w):f.has(e.id)&&await B(c,e.id);let e=await ie(c);I(`群聊会话已创建,正在打开 DSH 原生会话。`),t?.(e.sessionId)}catch(e){I(e instanceof Error?e.message:String(e))}finally{K(!1)}}},X=async(e,n)=>{if(c){K(!0);try{let e=await ie(c);I(`正在打开新的 DSH 原生聚会会话。`),t?.(e.sessionId)}catch(e){I(e instanceof Error?e.message:String(e))}finally{K(!1)}}},he=async()=>{if(!(!S||!O.trim())){K(!0);try{let e=await oe(S,O,[...m]);D(t=>[...t,e.message]),M(e.batch.id),P(`queued`),F(e.deliveries),A(``),h(new Set),I(null)}catch(e){I(e instanceof Error?e.message:String(e))}finally{K(!1)}}},Z=(0,r.useCallback)(async()=>{if(!j||!S)return;let[e,t]=await Promise.all([se(S),ce(j)]);D(e),P(t.batch.status),F(t.deliveries),I(null)},[j,S]);return(0,r.useEffect)(()=>{if(!j||!S||N&&[`completed`,`partial`,`failed`].includes(N))return;let e=()=>{document.hidden||Z().catch(e=>I(e instanceof Error?e.message:String(e)))},t=window.setInterval(e,3e3);return e(),()=>window.clearInterval(t)},[j,S,N,Z]),(0,i.jsxs)(`div`,{children:[(0,i.jsxs)(`button`,{type:`button`,style:{...H,marginBottom:18},onClick:S?()=>{C(``),D([]),M(``)}:e,children:[`← `,S?`返回空间`:`返回工作台`]}),(0,i.jsxs)(`div`,{style:{marginBottom:20},children:[(0,i.jsx)(`div`,{style:{color:V.accent,fontSize:12},children:`ENTERTAINMENT SPACE`}),(0,i.jsx)(`h2`,{style:{margin:`6px 0`},children:`娱乐空间`}),(0,i.jsx)(`p`,{style:{color:V.muted,margin:0,fontSize:13},children:`让长期伙伴在同一个场景里相遇,或继续之前的聚会。`})]}),S?(0,i.jsxs)(`div`,{style:{...W,maxWidth:840},children:[(0,i.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,gap:12,color:V.muted,fontSize:12,marginBottom:12},children:[(0,i.jsx)(`span`,{children:g.find(e=>e.id===w)?.title||`娱乐空间`}),(0,i.jsx)(`span`,{children:q.map(e=>e.displayName||e.identitySummary||e.id).join(` · `)})]}),(0,i.jsx)(`div`,{style:{minHeight:260,maxHeight:430,overflow:`auto`},children:E.length===0?(0,i.jsx)(G,{children:`聚会刚刚开始,等待你的第一句话。`}):E.map(e=>(0,i.jsxs)(`div`,{style:{padding:`11px 0`,borderTop:`1px solid ${V.line}`},children:[(0,i.jsx)(`div`,{style:{color:e.senderKind===`user`?V.accent:V.blue,fontSize:12,marginBottom:4},children:e.senderKind===`user`?`你`:e.senderName??o.find(t=>t.id===e.senderId)?.displayName??e.senderId}),(0,i.jsx)(`div`,{style:{whiteSpace:`pre-wrap`,lineHeight:1.55},children:e.content})]},e.id))}),j&&(0,i.jsxs)(`div`,{style:{padding:10,borderRadius:6,background:`rgba(216,164,108,.1)`,fontSize:12,marginTop:10},children:[(0,i.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,gap:8,alignItems:`center`},children:[(0,i.jsx)(`b`,{children:N===`completed`?`本轮已完成`:N===`partial`?`本轮部分完成`:N===`failed`?`本轮执行失败`:N===`running`?`伙伴正在回应`:`本轮等待执行`}),N&&(0,i.jsx)(ue,{tone:N===`completed`?V.green:N===`failed`?V.red:V.accent,children:N})]}),(0,i.jsx)(`div`,{style:{display:`grid`,gap:5,marginTop:8},children:ee.map(e=>(0,i.jsxs)(`div`,{style:{color:e.status===`failed`?V.red:e.status===`completed`?V.green:V.blue},children:[e.companionName||o.find(t=>t.id===e.companionProfileId)?.displayName||o.find(t=>t.id===e.companionProfileId)?.identitySummary||`未命名伙伴`,` · `,e.status,e.error&&(0,i.jsx)(`div`,{style:{color:V.red,marginTop:2,overflowWrap:`anywhere`},children:e.error})]},e.id))}),N!==`completed`&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`div`,{style:{marginTop:8},children:N===`partial`||N===`failed`?`在当前 DSH 会话再次运行以重试失败项:`:`请在当前 DSH 会话运行:`}),(0,i.jsxs)(`div`,{style:{...U,marginTop:6,color:V.ink,userSelect:`all`,overflowWrap:`anywhere`},children:[`/space-run `,j]})]}),(0,i.jsx)(`button`,{type:`button`,style:{...H,marginTop:8},onClick:()=>void Z().catch(e=>I(e instanceof Error?e.message:String(e))),children:`刷新状态`})]}),(0,i.jsx)(`div`,{style:{display:`flex`,gap:6,flexWrap:`wrap`,marginTop:12},children:q.map(e=>(0,i.jsxs)(`button`,{type:`button`,style:{...H,borderColor:m.has(e.id)?V.accent:V.line},onClick:()=>J(h,e.id),children:[`@`,e.displayName||e.identitySummary||e.id]},e.id))}),(0,i.jsxs)(`div`,{style:{display:`flex`,gap:8,marginTop:8},children:[(0,i.jsx)(`input`,{style:U,value:O,placeholder:m.size?`只投递给点名伙伴`:`未点名时自动选择至多两位伙伴`,onChange:e=>A(e.target.value),onKeyDown:e=>{e.key===`Enter`&&he()}}),(0,i.jsx)(`button`,{type:`button`,style:le,disabled:L||!O.trim(),onClick:()=>void he(),children:L?`处理中…`:`发送`})]})]}):(0,i.jsxs)(`div`,{style:{...W,maxWidth:760,display:`grid`,gap:12},children:[(0,i.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,gap:8},children:[(0,i.jsxs)(`label`,{style:{flex:1,fontSize:12,color:V.muted},children:[`选择已有工作区`,(0,i.jsxs)(`select`,{style:{...U,marginTop:5},value:c,onChange:e=>l(e.target.value),children:[(0,i.jsx)(`option`,{value:``,children:`请选择工作区`}),n.map(e=>(0,i.jsxs)(`option`,{value:e.id,children:[e.name,e.status===`active`?``:`(`+e.status+`)`]},e.id))]})]}),(0,i.jsx)(`button`,{type:`button`,style:{...H,marginTop:18},disabled:L,onClick:e=>{e.preventDefault(),e.stopPropagation(),pe()},children:`刷新`})]}),de&&(0,i.jsxs)(`div`,{style:{color:V.red,fontSize:12},children:[`读取工作区失败:`,de]}),n.length===0&&!de&&(0,i.jsx)(`div`,{style:{color:V.muted,fontSize:12},children:`没有读取到工作区。可在下方创建一个新工作区;如果已有工作区未出现,请点击刷新。`}),(0,i.jsxs)(`div`,{style:{display:`flex`,gap:7},children:[(0,i.jsx)(`input`,{style:U,placeholder:`新建工作区名称`,value:b,onChange:e=>x(e.target.value)}),(0,i.jsx)(`button`,{type:`button`,style:H,disabled:L||!b.trim(),onClick:()=>void Y(),children:`创建工作区`})]}),c&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(`label`,{style:{fontSize:12,color:V.muted},children:[`场景`,(0,i.jsx)(`select`,{style:{...U,marginTop:5},value:w,onChange:e=>T(e.target.value),children:g.filter(e=>e.status===`active`).map(e=>(0,i.jsx)(`option`,{value:e.id,children:e.title||`未命名场景`},e.id))})]}),(0,i.jsxs)(`div`,{children:[(0,i.jsx)(`div`,{style:{color:V.muted,fontSize:12,marginBottom:7},children:`空间成员`}),(0,i.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit,minmax(180px,1fr))`,gap:6},children:o.filter(e=>e.status===`active`).length===0?(0,i.jsx)(`div`,{style:{color:V.muted,fontSize:12},children:`还没有可加入的活跃伙伴。请先从角色与聊天中升格伙伴。`}):o.filter(e=>e.status===`active`).map(e=>(0,i.jsxs)(`label`,{style:{display:`flex`,gap:7,alignItems:`center`,padding:7,border:`1px solid `+(u.has(e.id)?V.accent:V.line),borderRadius:6},children:[(0,i.jsx)(`input`,{type:`checkbox`,checked:u.has(e.id),onChange:()=>J(d,e.id)}),e.displayName||e.identitySummary||e.id]},e.id))})]}),(0,i.jsx)(`button`,{type:`button`,style:le,disabled:!w||!q.length||L,onClick:()=>void me(),children:`开始新聚会`}),v.length>0&&(0,i.jsxs)(`div`,{children:[(0,i.jsx)(`div`,{style:{color:V.muted,fontSize:12,marginBottom:7},children:`之前的聚会`}),v.map(e=>(0,i.jsxs)(`button`,{type:`button`,style:{...H,width:`100%`,textAlign:`left`,marginBottom:6},onClick:()=>void X(e.id,e.sceneId),children:[`继续 `,g.find(t=>t.id===e.sceneId)?.title||`聚会`,(0,i.jsx)(`span`,{style:{float:`right`,color:V.muted},children:e.status})]},e.id))]})]})]}),te&&(0,i.jsx)(`div`,{style:{color:V.red,marginTop:12},children:te})]})}var pe=`#f2eee7`,q=`#a69f96`,J=`rgba(242,238,231,.14)`,Y=`#d8a46c`,me={background:`rgba(31,34,39,.9)`,border:`1px solid ${J}`,borderRadius:10,padding:18},X={border:`1px solid ${J}`,background:`transparent`,color:pe,borderRadius:7,padding:`8px 12px`,cursor:`pointer`,fontSize:13},he={...X,background:Y,borderColor:Y,color:`#211b16`,fontWeight:700},Z={width:`100%`,boxSizing:`border-box`,padding:`9px 10px`,borderRadius:6,border:`1px solid ${J}`,background:`rgba(0,0,0,.2)`,color:pe};function ge({candidate:e,selectedMemories:t,selectedPersonality:n,selectedHistory:r,onToggleMemory:a,onTogglePersonality:o,onToggleHistory:s,onShowEvidence:c}){return(0,i.jsxs)(`div`,{style:{display:`grid`,gap:9,marginBottom:14,fontSize:12},children:[(0,i.jsxs)(`div`,{children:[(0,i.jsxs)(`b`,{children:[`共同经历事件(`,e.sharedHistory.events.length,`)`]}),e.sharedHistory.events.length===0?(0,i.jsx)(`div`,{style:{color:q},children:`模型没有从这次聊天中归纳出共同经历事件。`}):e.sharedHistory.events.map((e,t)=>(0,i.jsxs)(`div`,{style:{padding:`7px 0`,borderTop:`1px solid ${J}`},children:[(0,i.jsx)(`input`,{type:`checkbox`,checked:r.has(t),onChange:()=>s(t)}),` `,e.content,(0,i.jsxs)(`span`,{style:{color:q},children:[` · 证据 `,e.evidenceMessageIds.length,` 条`]}),` `,(0,i.jsx)(`button`,{type:`button`,style:{...X,padding:`2px 6px`,fontSize:11},onClick:()=>c(e.evidenceMessageIds),children:`查看原文`})]},t))]}),(0,i.jsxs)(`div`,{children:[(0,i.jsxs)(`b`,{children:[`建议保留的记忆(`,e.memories.length,`)`]}),e.memories.map((e,n)=>(0,i.jsxs)(`div`,{style:{padding:`7px 0`,borderTop:`1px solid ${J}`},children:[(0,i.jsx)(`input`,{type:`checkbox`,checked:t.has(n),onChange:()=>a(n)}),` `,e.content,(0,i.jsxs)(`span`,{style:{color:q},children:[` · `,e.category,` · 证据 `,e.evidenceMessageIds.length,` 条`]}),` `,(0,i.jsx)(`button`,{type:`button`,style:{...X,padding:`2px 6px`,fontSize:11},onClick:()=>c(e.evidenceMessageIds),children:`查看原文`})]},n))]}),(0,i.jsxs)(`div`,{children:[(0,i.jsxs)(`b`,{children:[`归纳出的性格(`,e.personality.length,`)`]}),e.personality.map((e,t)=>(0,i.jsxs)(`div`,{style:{padding:`7px 0`,borderTop:`1px solid ${J}`},children:[(0,i.jsx)(`input`,{type:`checkbox`,checked:n.has(t),onChange:()=>o(t)}),` `,e.name,`:`,e.description,(0,i.jsxs)(`span`,{style:{color:q},children:[` · 置信度 `,Math.round(e.confidence*100),`% · 证据 `,e.evidenceMessageIds.length,` 条`]}),` `,(0,i.jsx)(`button`,{type:`button`,style:{...X,padding:`2px 6px`,fontSize:11},onClick:()=>c(e.evidenceMessageIds),children:`查看原文`})]},t))]})]})}function _e({character:e,conversations:t,busy:n,onCancel:a,onConfirm:o}){let s=(0,r.useMemo)(()=>t.filter(t=>t.characterId===e.id&&t.status===`active`),[e.id,t]),[l,u]=(0,r.useState)(0),[d,f]=(0,r.useState)(s[0]?.id??``),[p,m]=(0,r.useState)(null),[h,g]=(0,r.useState)(!1),[_,v]=(0,r.useState)(null),[y,b]=(0,r.useState)(new Set),[x,S]=(0,r.useState)(new Set),[C,w]=(0,r.useState)(new Set),[T,E]=(0,r.useState)([]),[D,O]=(0,r.useState)(!1),[k,j]=(0,r.useState)(e.name),[M,N]=(0,r.useState)(`源自角色卡「${e.name}」的长期伙伴。`),[P,ee]=(0,r.useState)(``),[F,te]=(0,r.useState)(``),[I,L]=(0,r.useState)(``),[R,z]=(0,r.useState)(`不假装记得未确认的事情;涉及外部操作时先征得同意。`),ne=s.find(e=>e.id===d),re=async()=>{if(d){g(!0),v(null);try{let t=await A(e.id,d);m(t),b(new Set(t.memories.map((e,t)=>e.recommendation===`keep`?t:-1).filter(e=>e>=0))),S(new Set(t.personality.map((e,t)=>e.recommendation===`keep`?t:-1).filter(e=>e>=0))),w(new Set(t.sharedHistory.events.map((e,t)=>t))),j(t.identity.suggestedDisplayName),N(t.identity.identitySummary),ee(t.relationship.summary),te(t.sharedHistory.summary||t.sharedHistory.events.map(e=>e.content).join(`;`)),L(t.goals.join(`
|
|
2
|
+
`)),z(t.boundaries.join(`
|
|
3
|
+
`)||R),u(1)}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(!1)}}},B=async e=>{O(!0);try{let t=await c(d);E(t.filter(t=>e.includes(t.id)))}catch(e){v(e instanceof Error?e.message:String(e))}finally{O(!1)}},ie=(e,t,n)=>{let r=new Set(e);r.has(t)?r.delete(t):r.add(t),n(r)},ae=e=>ie(C,e,w),oe=()=>o({characterId:e.id,displayName:k.trim(),identitySummary:M,userRelationshipSummary:P,sharedHistorySummary:F,...p===null?{}:{communicationPreferences:[...p.roleplay.speakingStyle,...p.roleplay.preferredPatterns.map(e=>`偏好:${e}`),...p.roleplay.avoidPatterns.map(e=>`避免:${e}`)].join(`;`)},goals:I.split(`
|
|
4
|
+
`).map(e=>e.trim()).filter(Boolean),boundaries:R.split(`
|
|
5
|
+
`).map(e=>e.trim()).filter(Boolean),sourceConversationId:d,confirmedMemories:(p?.memories??[]).filter((e,t)=>y.has(t)).map(e=>({content:e.content,category:e.category,confidence:e.confidence,evidenceMessageIds:e.evidenceMessageIds})),confirmedSharedHistory:(p?.sharedHistory.events??[]).filter((e,t)=>C.has(t)).map(e=>({content:e.content,evidenceMessageIds:e.evidenceMessageIds})),confirmedPersonality:(p?.personality??[]).filter((e,t)=>x.has(t)).map(e=>({name:e.name,description:e.description,strength:e.strength,confidence:e.confidence,evidenceMessageIds:e.evidenceMessageIds}))});return(0,i.jsxs)(`div`,{style:{maxWidth:760},children:[(0,i.jsx)(`button`,{type:`button`,style:{...X,marginBottom:15},onClick:a,children:`← 返回角色`}),(0,i.jsxs)(`div`,{style:{marginBottom:16},children:[(0,i.jsx)(`div`,{style:{color:Y,fontSize:12,letterSpacing:1.3},children:`PROMOTE A COMPANION`}),(0,i.jsxs)(`h2`,{style:{margin:`5px 0`},children:[`让 `,e.name,` 成为长期伙伴`]}),(0,i.jsx)(`p`,{style:{color:q,margin:0,lineHeight:1.55},children:`角色卡提供基础设定;模型只会根据你选择的聊天文件归纳候选。确认前,任何结论都不会写入长期档案。`})]}),(0,i.jsxs)(`div`,{style:{display:`flex`,gap:10,marginBottom:14,color:q,fontSize:12},children:[(0,i.jsx)(`span`,{style:{color:l===0?Y:pe},children:`1. 聊天依据`}),(0,i.jsx)(`span`,{style:{color:l===1?Y:l>1?pe:q},children:`2. 候选档案`}),(0,i.jsx)(`span`,{style:{color:l===2?Y:q},children:`3. 确认升格`})]}),_&&(0,i.jsx)(`div`,{style:{color:`#e59a91`,marginBottom:10},children:_}),(0,i.jsxs)(`section`,{style:me,children:[l===0&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`h3`,{style:{marginTop:0},children:`选择一份聊天历史`}),(0,i.jsx)(`p`,{style:{color:q,fontSize:13,lineHeight:1.55},children:`生成时使用当前 DSH 已配置的模型和凭据,不会要求填写 API Key。每条候选都会附带来源消息。`}),s.length===0?(0,i.jsx)(`div`,{style:{color:`#e59a91`},children:`还没有可用于升格的聊天文件。`}):(0,i.jsx)(`div`,{style:{display:`grid`,gap:8},children:s.map(e=>(0,i.jsxs)(`label`,{style:{border:`1px solid ${d===e.id?Y:J}`,borderRadius:7,padding:11,cursor:`pointer`},children:[(0,i.jsx)(`input`,{type:`radio`,checked:d===e.id,onChange:()=>f(e.id)}),` `,(0,i.jsx)(`b`,{children:e.title??`聊天 · ${new Date(e.createdAt).toLocaleDateString()}`}),(0,i.jsxs)(`span`,{style:{color:q,fontSize:12},children:[` · 最后更新 `,new Date(e.updatedAt).toLocaleString()]})]},e.id))})]}),l===1&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`h3`,{style:{marginTop:0},children:`审阅模型生成的候选档案`}),(0,i.jsxs)(`div`,{style:{padding:`9px 11px`,borderRadius:6,background:`rgba(216,164,108,.1)`,color:`#e9c79e`,fontSize:12,marginBottom:13},children:[`聊天依据:`,ne?.title??`未选择`,` · 模型:`,p?.source.provider,` / `,p?.source.model,`。请检查候选内容;最终仍以你编辑后的值为准。`]}),p&&(0,i.jsx)(ge,{candidate:p,selectedMemories:y,selectedPersonality:x,selectedHistory:C,onToggleMemory:e=>ie(y,e,b),onTogglePersonality:e=>ie(x,e,S),onToggleHistory:ae,onShowEvidence:e=>void B(e)}),(D||T.length>0)&&(0,i.jsxs)(`div`,{style:{marginBottom:12,padding:11,borderRadius:7,background:`rgba(255,255,255,.04)`},children:[(0,i.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,fontSize:12,marginBottom:7},children:[(0,i.jsx)(`b`,{children:`来源消息`}),(0,i.jsx)(`button`,{type:`button`,style:{...X,padding:`2px 6px`},onClick:()=>E([]),children:`关闭`})]}),D?`正在读取原文…`:T.map(e=>(0,i.jsxs)(`div`,{style:{borderTop:`1px solid ${J}`,padding:`7px 0`,fontSize:12,whiteSpace:`pre-wrap`},children:[(0,i.jsxs)(`b`,{children:[e.role===`user`?`你`:e.role===`assistant`?`角色`:`系统`,`:`]}),e.content]},e.id))]}),(0,i.jsxs)(`label`,{children:[`伙伴名称`,(0,i.jsx)(`input`,{style:{...Z,marginTop:5},value:k,onChange:e=>j(e.target.value)})]}),(0,i.jsxs)(`label`,{style:{display:`block`,marginTop:10},children:[`身份简介`,(0,i.jsx)(`textarea`,{style:{...Z,marginTop:5,minHeight:60},value:M,onChange:e=>N(e.target.value)})]}),(0,i.jsxs)(`label`,{style:{display:`block`,marginTop:10},children:[`你们的关系`,(0,i.jsx)(`textarea`,{style:{...Z,marginTop:5,minHeight:58},value:P,onChange:e=>ee(e.target.value)})]}),(0,i.jsxs)(`label`,{style:{display:`block`,marginTop:10},children:[`共同经历摘要`,(0,i.jsx)(`textarea`,{style:{...Z,marginTop:5,minHeight:58},value:F,onChange:e=>te(e.target.value)})]})]}),l===2&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`h3`,{style:{marginTop:0},children:`确认边界与初始策略`}),(0,i.jsx)(`p`,{style:{color:q,fontSize:13},children:`伙伴将跟随当前 DSH 会话模型;长期身份、记忆与行为边界由档案保存。`}),(0,i.jsxs)(`div`,{style:{padding:`10px 12px`,borderRadius:7,background:`rgba(255,255,255,.05)`,fontSize:12,marginBottom:12},children:[(0,i.jsxs)(`div`,{style:{marginBottom:6},children:[(0,i.jsx)(`b`,{children:`身份简介:`}),M]}),(0,i.jsxs)(`div`,{style:{marginBottom:6},children:[(0,i.jsx)(`b`,{children:`你们的关系:`}),P||`(未填写)`]}),(0,i.jsxs)(`div`,{style:{marginBottom:6},children:[(0,i.jsx)(`b`,{children:`共同经历摘要:`}),F||`(未填写)`]}),(0,i.jsxs)(`div`,{style:{marginBottom:6},children:[(0,i.jsx)(`b`,{children:`共同经历事件:`}),p?.sharedHistory.events.filter((e,t)=>C.has(t)).map(e=>e.content).join(`;`)||`(未选择)`]}),(0,i.jsxs)(`div`,{style:{marginBottom:6},children:[(0,i.jsx)(`b`,{children:`已确认性格:`}),p?.personality.filter((e,t)=>x.has(t)).map(e=>`${e.name}:${e.description}`).join(`;`)||`(未选择)`]}),(0,i.jsxs)(`div`,{children:[(0,i.jsx)(`b`,{children:`将写入记忆:`}),p?.memories.filter((e,t)=>y.has(t)).length??0,` 条`]})]}),(0,i.jsxs)(`label`,{children:[`长期目标`,(0,i.jsx)(`textarea`,{style:{...Z,marginTop:5,minHeight:58},value:I,onChange:e=>L(e.target.value)})]}),(0,i.jsxs)(`label`,{style:{display:`block`,marginTop:10},children:[`边界`,(0,i.jsx)(`textarea`,{style:{...Z,marginTop:5,minHeight:58},value:R,onChange:e=>z(e.target.value)})]})]}),(0,i.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,marginTop:18},children:[(0,i.jsx)(`button`,{type:`button`,style:X,disabled:l===0||n||h,onClick:()=>u(e=>e-1),children:`上一步`}),l===0?(0,i.jsx)(`button`,{type:`button`,style:he,disabled:!d||h,onClick:()=>void re(),children:h?`正在总结聊天历史…`:`生成候选档案`}):l===1?(0,i.jsx)(`button`,{type:`button`,style:he,disabled:!k.trim(),onClick:()=>u(2),children:`确认这些内容`}):(0,i.jsx)(`button`,{type:`button`,style:he,disabled:n||!k.trim(),onClick:oe,children:n?`正在升格…`:`确认成为长期伙伴`})]})]})]})}var Q=(e=!1)=>({padding:`4px 10px`,borderRadius:7,cursor:`pointer`,fontSize:12,border:`1px solid rgba(255,255,255,.16)`,background:e?`rgba(120,160,255,.25)`:`transparent`,color:`inherit`}),$={padding:`7px 0`,borderBottom:`1px solid rgba(255,255,255,.08)`};function ve(){let[e,t]=(0,r.useState)([]),[n,a]=(0,r.useState)({}),[o,s]=(0,r.useState)(null),[c,l]=(0,r.useState)(null),[u,d]=(0,r.useState)(null),[f,p]=(0,r.useState)(null),m=(0,r.useCallback)(()=>{l(null),Promise.all([x(`pending`),x(`evidence-invalid`)]).then(([e,n])=>t([...e,...n])).catch(e=>l(e instanceof Error?e.message:String(e)))},[]);(0,r.useEffect)(m,[m]);let h=(0,r.useCallback)(async e=>{if(o===e){s(null);return}if(s(e),n[e]===void 0){d(e);try{let t=await S(e);a(n=>({...n,[e]:t}))}catch(e){l(e instanceof Error?e.message:String(e))}finally{d(null)}}},[n,o]),g=(0,r.useCallback)(async(e,t,n)=>{let r;if(t){let t=window.prompt(`确认或修改这条长期记忆:`,e.proposedContent);if(t===null)return;r=t}if(!(t&&e.sensitivity===`high`&&!window.confirm(`此候选标记为高敏感信息。确认写入长期记忆吗?`))){d(e.id);try{await w(e.id,t,r,n),p(null),m()}catch(t){t instanceof C?p({candidateId:e.id,content:r??e.proposedContent,conflicts:t.conflicts}):l(t instanceof Error?t.message:String(t))}finally{d(null)}}},[m]),_=(0,r.useCallback)(async e=>{d(e.id);try{await T(e.id,e.sensitivity===`high`?`low`:`high`),m()}catch(e){l(e instanceof Error?e.message:String(e))}finally{d(null)}},[m]),v=(0,r.useCallback)(async e=>{let t=window.prompt(`输入更正后的记忆内容:`,e.proposedContent);if(t!==null&&t.trim()!==``){d(e.id);try{await E(e.id,t),m()}catch(e){l(e instanceof Error?e.message:String(e))}finally{d(null)}}},[m]);return(0,i.jsxs)(`div`,{style:{marginTop:18,borderTop:`1px solid rgba(255,255,255,.1)`,paddingTop:10},children:[(0,i.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:7},children:[(0,i.jsx)(`strong`,{style:{fontSize:13},children:`🧠 待审阅记忆`}),(0,i.jsx)(`button`,{type:`button`,style:Q(),disabled:u!==null,onClick:m,children:`刷新候选`})]}),(0,i.jsx)(`div`,{style:{opacity:.6,fontSize:11,margin:`4px 0 7px`},children:`模型只能提出候选;接受后才写入长期记忆。候选附带聊天消息证据并由 Host 校验归属。`}),c!==null&&(0,i.jsx)(`div`,{style:{color:`#ff8a8a`,fontSize:12},children:c}),e.map(e=>{let t=n[e.id],r=o===e.id;return(0,i.jsxs)(`div`,{style:{...$,padding:`8px 0`},children:[(0,i.jsxs)(`div`,{children:[(0,i.jsx)(`strong`,{style:{fontSize:12},children:e.proposedContent}),(0,i.jsxs)(`span`,{style:{opacity:.55,fontSize:11,marginLeft:7},children:[e.kind,` · 置信 `,Math.round(e.confidence*100),`% · `,e.sensitivity,` · `,e.status]})]}),e.status===`evidence-invalid`&&(0,i.jsx)(`div`,{style:{color:`#ffca75`,fontSize:11,marginTop:3},children:`⚠ 来源消息已编辑、删除或不在当前聊天分支,不能再接受。可查看原文后重新提取。`}),e.rationale!==void 0&&(0,i.jsxs)(`div`,{style:{opacity:.6,fontSize:11,margin:`3px 0`},children:[`原因:`,e.rationale]}),(0,i.jsx)(`button`,{type:`button`,style:{...Q(),marginTop:4},disabled:u!==null,onClick:()=>void h(e.id),children:r?`收起证据`:`查看消息证据(${e.sourceMessageIds.length})`}),r&&(0,i.jsx)(`div`,{style:{marginTop:6,padding:`6px 8px`,borderRadius:6,background:`rgba(255,255,255,.04)`},children:t===void 0?(0,i.jsx)(`div`,{style:{opacity:.55,fontSize:11},children:`正在加载证据原文…`}):t.map(e=>(0,i.jsxs)(`div`,{style:{marginBottom:6,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,fontSize:12},children:[(0,i.jsxs)(`strong`,{style:{opacity:.7},children:[e.role===`user`?`用户`:e.role===`assistant`?`角色`:`系统`,`:`]}),e.content]},e.id))}),e.status===`pending`&&(0,i.jsxs)(`div`,{style:{display:`flex`,gap:5,marginTop:5},children:[(0,i.jsx)(`button`,{type:`button`,style:Q(),disabled:u!==null,onClick:()=>void g(e,!0),children:`接受 / 修改`}),(0,i.jsx)(`button`,{type:`button`,style:{...Q(),color:`#ffadad`},disabled:u!==null,onClick:()=>void g(e,!1),children:`拒绝`}),(0,i.jsx)(`button`,{type:`button`,style:Q(),disabled:u!==null,onClick:()=>void _(e),children:e.sensitivity===`high`?`取消高敏感`:`标记高敏感`}),(0,i.jsx)(`button`,{type:`button`,style:Q(),disabled:u!==null,onClick:()=>void v(e),children:`更正`})]}),f?.candidateId===e.id&&(0,i.jsxs)(`div`,{style:{marginTop:6,padding:`6px 8px`,borderRadius:6,background:`rgba(255,180,120,.08)`},children:[(0,i.jsx)(`div`,{style:{color:`#ffca75`,fontSize:12,marginBottom:4},children:`检测到与已有记忆冲突,请选择要替换的旧记忆:`}),f.conflicts.map(t=>(0,i.jsxs)(`div`,{style:{display:`flex`,gap:6,alignItems:`center`,marginBottom:4},children:[(0,i.jsx)(`span`,{style:{flex:1,fontSize:12,opacity:.8},children:t.fact}),(0,i.jsx)(`button`,{type:`button`,style:Q(),disabled:u!==null,onClick:()=>void g(e,!0,t.id),children:`替换并接受`})]},t.id))]})]},e.id)}),e.length===0&&(0,i.jsx)(`div`,{style:{opacity:.55,fontSize:12},children:`没有待审阅候选。每次正常聊天完成后会尝试后台提取;也可在聊天文件菜单中手动重跑。`})]})}function ye({profileId:e,onClose:t}){let[n,a]=(0,r.useState)(null),[o,s]=(0,r.useState)([]),[c,l]=(0,r.useState)(null),u=(0,r.useCallback)(()=>{Promise.all([N(e),I(e)]).then(([e,t])=>{a(e),s(t),l(null)}).catch(e=>l(e instanceof Error?e.message:String(e)))},[e]);if((0,r.useEffect)(u,[u]),c)return(0,i.jsxs)(`div`,{children:[(0,i.jsx)(`button`,{type:`button`,style:Q(),onClick:t,children:`← 返回角色`}),(0,i.jsx)(`div`,{style:{color:`#ff8a8a`,marginTop:8},children:c})]});if(!n)return(0,i.jsx)(`div`,{children:`正在加载伙伴档案…`});let d=n.profile;return(0,i.jsxs)(`div`,{children:[(0,i.jsxs)(`div`,{style:{display:`flex`,gap:7,alignItems:`center`},children:[(0,i.jsx)(`button`,{type:`button`,style:Q(),onClick:t,children:`← 返回角色`}),(0,i.jsxs)(`strong`,{children:[`伙伴档案 · `,d.status]})]}),(0,i.jsxs)(`section`,{style:{...$,marginTop:10},children:[(0,i.jsx)(`strong`,{children:`她是谁 / 性格`}),(0,i.jsx)(`div`,{style:{marginTop:4},children:d.personalitySummary??`待用户确认:尚未确认长期性格。`}),(d.personalityTraits??[]).map(e=>(0,i.jsxs)(`div`,{style:{fontSize:12,opacity:.8,marginTop:4},children:[e.name,` · 强度 `,Math.round(e.strength*100),`% · 置信 `,Math.round(e.confidence*100),`% · `,e.source,(0,i.jsx)(`br`,{}),e.description]},e.id))]}),(0,i.jsxs)(`section`,{style:$,children:[(0,i.jsx)(`strong`,{children:`待确认性格`}),n.personalityCandidates.filter(e=>e.status===`pending`).length===0?(0,i.jsx)(`div`,{style:{opacity:.6},children:`没有待确认的性格候选`}):n.personalityCandidates.filter(e=>e.status===`pending`).map(e=>(0,i.jsxs)(`div`,{style:{marginTop:5},children:[(0,i.jsx)(`b`,{children:e.traitName}),` · 置信 `,Math.round(e.confidence*100),`%`,(0,i.jsx)(`div`,{style:{fontSize:12,opacity:.7},children:e.description}),(0,i.jsx)(`button`,{type:`button`,style:Q(),onClick:()=>void L(e.id,!0).then(u),children:`确认`}),(0,i.jsx)(`button`,{type:`button`,style:{...Q(),color:`#ffadad`},onClick:()=>void L(e.id,!1).then(u),children:`拒绝`})]},e.id))]}),(0,i.jsxs)(`section`,{style:$,children:[(0,i.jsx)(`strong`,{children:`已沉淀记忆`}),n.memories.length===0?(0,i.jsx)(`div`,{style:{opacity:.6},children:`暂无已确认记忆`}):n.memories.map(e=>(0,i.jsxs)(`div`,{style:{fontSize:12,marginTop:4},children:[e.fact,` `,(0,i.jsxs)(`span`,{style:{opacity:.5},children:[`· `,e.category]})]},e.id))]}),(0,i.jsxs)(`section`,{style:$,children:[(0,i.jsx)(`strong`,{children:`Skills`}),n.skills.length===0?(0,i.jsx)(`div`,{style:{opacity:.6},children:`暂无 Skill`}):n.skills.map(e=>(0,i.jsxs)(`div`,{style:{marginTop:5},children:[(0,i.jsx)(`b`,{children:e.name}),` · v`,e.version,` · `,e.status,(0,i.jsx)(`div`,{style:{fontSize:12,opacity:.7},children:e.description}),(0,i.jsxs)(`button`,{type:`button`,style:Q(),onClick:()=>void ee(e.id,e.status===`disabled`).then(u),children:[` `,e.status===`active`?`禁用`:`启用`,` `]})]},e.id))]}),(0,i.jsxs)(`section`,{style:$,children:[(0,i.jsx)(`strong`,{children:`工作区`}),n.workspaces.length===0?(0,i.jsx)(`div`,{style:{opacity:.6},children:`尚未加入工作区`}):n.workspaces.map(e=>(0,i.jsxs)(`div`,{children:[e.workspace.name,` · Scene:`,e.sceneIds.join(`, `)||`无`]},e.workspace.id))]}),(0,i.jsxs)(`section`,{style:$,children:[(0,i.jsx)(`strong`,{children:`她认识谁`}),o.length===0?(0,i.jsx)(`div`,{style:{opacity:.6},children:`尚未认识任何伙伴`}):o.map((e,t)=>(0,i.jsxs)(`div`,{children:[e.fromNodeId,` → `,e.toNodeId,` · `,e.type,` `,e.value]},t))]})]})}function be(e){let[t,n]=(0,r.useState)([]),[a,c]=(0,r.useState)([]),[b,x]=(0,r.useState)(null),[S,C]=(0,r.useState)(null),[w,T]=(0,r.useState)([]),[E,O]=(0,r.useState)(null),[A,M]=(0,r.useState)(!1),[N,P]=(0,r.useState)([]),[ee,F]=(0,r.useState)(null),[te,I]=(0,r.useState)(null),[L,R]=(0,r.useState)([]),z=(0,r.useRef)(null),ne=(0,r.useRef)(null),re=(0,r.useRef)(null),B=(0,r.useCallback)(()=>{Promise.all([o(),s(),k()]).then(([e,t,r])=>{n(e),c(t),R(r),O(null)}).catch(e=>O(e instanceof Error?e.message:String(e)))},[]);(0,r.useEffect)(B,[B,e.refreshToken]),(0,r.useEffect)(()=>{d().then(P).catch(()=>{})},[e.refreshToken,t.length]);let ie=(0,r.useCallback)(async t=>{M(!0);try{let n=await h(t);e.openSession(n.sessionId),B()}catch(e){O(e instanceof Error?e.message:String(e))}finally{M(!1)}},[e,B]),ae=(0,r.useCallback)(async(t,n)=>{M(!0);try{let r=await y(t,n===void 0?void 0:{greetingIndex:n});C(null),e.createSession(r.sessionId),B()}catch(e){O(e instanceof Error?e.message:String(e))}finally{M(!1)}},[e,B]),oe=(0,r.useCallback)(async e=>{try{C(e),T(await l(e))}catch(e){O(e instanceof Error?e.message:String(e))}},[]),se=(0,r.useCallback)(async e=>{M(!0);try{let t=await g(e);O(`✅ ${t.deduplicated?`角色卡已存在`:`已导入角色卡`}:${t.name}`),B()}catch(e){O(e instanceof Error?e.message:String(e))}finally{M(!1),z.current&&(z.current.value=``)}},[B]),ce=(0,r.useCallback)(async e=>{let t=re.current;if(t!==null){M(!0);try{await v(t,await e.text(),e.name.replace(/\.[^.]+$/,``)),B()}catch(e){O(e instanceof Error?e.message:String(e))}finally{M(!1),re.current=null,ne.current&&(ne.current.value=``)}}},[B]),V=(0,r.useCallback)(async e=>{M(!0);try{let t=await j(e);I(null),O(`✅ ${t.displayName??e.displayName??`伙伴`} 已成为长期伙伴`),B()}catch(e){O(e instanceof Error?e.message:String(e))}finally{M(!1)}},[B]),H=(0,r.useCallback)(async e=>{if(window.confirm(`将“${e.name}”及其全部聊天文件移入 Tavern 回收站。聊天记录不会立即删除,可以随后恢复。确定继续吗?`)){M(!0);try{await u(e.id),x(null),B()}catch(e){O(e instanceof Error?e.message:String(e))}finally{M(!1)}}},[B]),le=(0,r.useCallback)(async e=>{M(!0);try{await f(e),await Promise.all([B(),d().then(P)])}catch(e){O(e instanceof Error?e.message:String(e))}finally{M(!1)}},[B]),U=(0,r.useCallback)(async e=>{let t=window.prompt(`聊天文件名称(留空可恢复日期名称)`,e.title??``);if(t!==null){M(!0);try{await p(e.id,t),B()}catch(e){O(e instanceof Error?e.message:String(e))}finally{M(!1)}}},[B]),W=(0,r.useCallback)(async e=>{M(!0);try{await D(e),O(`✅ 已请求提取候选,稍后可在“待审阅记忆”查看`)}catch(e){O(e instanceof Error?e.message:String(e))}finally{M(!1)}},[]),ue=(0,r.useCallback)(async e=>{if(window.confirm(`将聊天文件“${e.title??`未命名聊天`}”移入 Tavern 回收站?消息历史会保留,可恢复。`)){M(!0);try{await m(e.id),B()}catch(e){O(e instanceof Error?e.message:String(e))}finally{M(!1)}}},[B]),G=(0,r.useCallback)(async(e,t)=>{try{let n=new Blob([await _(e)],{type:`application/x-ndjson;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${t}-chat.jsonl`,i.click(),URL.revokeObjectURL(r)}catch(e){O(e instanceof Error?e.message:String(e))}},[]);return te===null?ee===null?(0,i.jsxs)(`div`,{children:[(0,i.jsx)(`p`,{style:{opacity:.7,marginTop:0,fontSize:12},children:`角色卡与聊天文件只在这里管理。打开聊天后,后续输入、归档和会话操作全部使用 DSH 原生界面。`}),(0,i.jsxs)(`div`,{style:{marginBottom:10},children:[(0,i.jsx)(`button`,{type:`button`,style:Q(),disabled:A,onClick:()=>z.current?.click(),children:`📥 导入角色卡`}),(0,i.jsx)(`input`,{ref:z,type:`file`,accept:`.json,.png,.charx`,style:{display:`none`},onChange:e=>{let t=e.target.files?.[0];t&&se(t)}})]}),E&&(0,i.jsx)(`div`,{style:{color:E.startsWith(`✅`)?`#8fda9b`:`#ff8a8a`,fontSize:12,marginBottom:8},children:E}),t.map(e=>{let t=a.filter(t=>t.characterId===e.id&&t.status===`active`),n=b===e.id;return(0,i.jsxs)(`div`,{style:{...$,padding:`9px 0`},children:[(0,i.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:7},children:[(0,i.jsxs)(`button`,{type:`button`,style:{...Q(n),flex:1,textAlign:`left`},onClick:()=>x(n?null:e.id),children:[`🎭 `,e.name,(0,i.jsxs)(`span`,{style:{opacity:.55,marginLeft:8},children:[t.length,` 个聊天文件`]})]}),(0,i.jsx)(`button`,{type:`button`,style:Q(),disabled:A,onClick:()=>void oe(e.id),children:`➕ 新建聊天`}),L.some(t=>t.characterId===e.id&&t.status===`active`)?(0,i.jsx)(`button`,{type:`button`,style:Q(),onClick:()=>F(L.find(t=>t.characterId===e.id&&t.status===`active`).id),children:`伙伴档案`}):(0,i.jsx)(`button`,{type:`button`,style:Q(),disabled:A,onClick:()=>I(e),children:`✨ 升格为长期伙伴`}),(0,i.jsx)(`button`,{type:`button`,style:Q(),disabled:A,onClick:()=>{re.current=e.id,ne.current?.click()},children:`📥 导入聊天`}),(0,i.jsx)(`button`,{type:`button`,style:{...Q(),color:`#ffadad`},disabled:A,onClick:()=>void H(e),children:`删除角色`})]}),S===e.id&&(0,i.jsxs)(`div`,{style:{padding:`7px 0 2px 14px`,display:`flex`,gap:5,flexWrap:`wrap`},children:[(0,i.jsx)(`span`,{style:{opacity:.65,fontSize:11,alignSelf:`center`},children:`选择开场白:`}),w.map((t,n)=>(0,i.jsxs)(`button`,{type:`button`,title:t,style:Q(),onClick:()=>void ae(e.id,n),children:[t.slice(0,18),t.length>18?`…`:``]},n)),(0,i.jsx)(`button`,{type:`button`,style:Q(),onClick:()=>void ae(e.id),children:`不带开场白`})]}),n&&(0,i.jsxs)(`div`,{style:{padding:`7px 0 0 14px`},children:[t.map(t=>(0,i.jsxs)(`div`,{style:{...$,display:`flex`,alignItems:`center`,gap:6},children:[(0,i.jsxs)(`div`,{style:{flex:1},children:[(0,i.jsx)(`strong`,{style:{fontSize:13},children:t.title??`聊天 · ${new Date(t.createdAt).toLocaleDateString()}`}),(0,i.jsx)(`div`,{style:{opacity:.55,fontSize:11},children:new Date(t.updatedAt).toLocaleString()})]}),(0,i.jsx)(`button`,{type:`button`,style:Q(),disabled:A,onClick:()=>void ie(t.id),children:`打开`}),(0,i.jsx)(`button`,{type:`button`,style:Q(),disabled:A,onClick:()=>void U(t),children:`改名`}),(0,i.jsx)(`button`,{type:`button`,style:Q(),onClick:()=>void G(t.id,e.name),children:`导出`}),(0,i.jsx)(`button`,{type:`button`,style:Q(),disabled:A,onClick:()=>void W(t.id),children:`提取记忆`}),(0,i.jsx)(`button`,{type:`button`,style:{...Q(),color:`#ffadad`},disabled:A,onClick:()=>void ue(t),children:`删除`})]},t.id)),t.length===0&&(0,i.jsx)(`div`,{style:{opacity:.55,fontSize:12},children:`暂无聊天文件。新建或导入一份聊天开始。`})]})]},e.id)}),t.length===0&&(0,i.jsx)(`div`,{style:{opacity:.55,fontSize:12},children:`暂无角色卡,请使用上方“导入角色卡”选择文件。`}),N.length>0&&(0,i.jsxs)(`div`,{style:{marginTop:16,borderTop:`1px solid rgba(255,255,255,.1)`,paddingTop:9},children:[(0,i.jsx)(`strong`,{style:{fontSize:13},children:`🗑 Tavern 回收站`}),(0,i.jsx)(`div`,{style:{opacity:.6,fontSize:11,margin:`4px 0`},children:`恢复角色会同时恢复其聊天文件;不会自动重新打开原生会话。`}),N.map(e=>(0,i.jsxs)(`div`,{style:{...$,display:`flex`,alignItems:`center`,gap:8},children:[(0,i.jsxs)(`span`,{style:{flex:1,opacity:.75},children:[`🎭 `,e.name]}),(0,i.jsx)(`button`,{type:`button`,style:Q(),disabled:A,onClick:()=>void le(e.id),children:`恢复`})]},e.id))]}),(0,i.jsx)(ve,{}),(0,i.jsx)(`input`,{ref:ne,type:`file`,accept:`.jsonl,.json,.txt`,style:{display:`none`},onChange:e=>{let t=e.target.files?.[0];t&&ce(t)}})]}):(0,i.jsx)(ye,{profileId:ee,onClose:()=>F(null)}):(0,i.jsx)(_e,{character:te,conversations:a,busy:A,onCancel:()=>I(null),onConfirm:e=>void V(e)})}function xe(e){let t={openSession:e.openSession??(()=>{}),createSession:e.createSession??(()=>{})},[n,a]=(0,r.useState)(`chat`),[o,s]=(0,r.useState)(null),[c,l]=(0,r.useState)(0),u=e=>{s(null),a(e),l(e=>e+1)};return(0,i.jsxs)(`div`,{style:{color:`#f2eee7`,maxWidth:1020,padding:`8px 2px 28px`},children:[(0,i.jsxs)(`header`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`end`,gap:16,marginBottom:16},children:[(0,i.jsxs)(`div`,{children:[(0,i.jsx)(`div`,{style:{fontSize:11,letterSpacing:2,color:`#d8a46c`,textTransform:`uppercase`},children:`DSH · TAVERN`}),(0,i.jsx)(`h1`,{style:{margin:`5px 0 0`,fontSize:26},children:n===`chat`?`角色与聊天`:n===`companions`?`我的伙伴`:`娱乐空间`})]}),(0,i.jsx)(`div`,{style:{color:`rgba(242,238,231,.55)`,fontSize:12},children:`角色扮演 · 长期伙伴 · 子代理`})]}),(0,i.jsx)(`nav`,{style:{display:`flex`,gap:6,borderBottom:`1px solid rgba(242,238,231,.12)`,paddingBottom:10,marginBottom:20,overflowX:`auto`},children:[[`chat`,`角色与聊天`],[`companions`,`我的伙伴`],[`spaces`,`娱乐空间`]].map(([e,t])=>(0,i.jsx)(`button`,{type:`button`,onClick:()=>u(e),style:{border:`0`,borderBottom:n===e?`2px solid #d8a46c`:`2px solid transparent`,background:`transparent`,color:n===e?`#f2eee7`:`rgba(242,238,231,.55)`,padding:`8px 10px`,cursor:`pointer`,whiteSpace:`nowrap`,fontSize:13},children:t},e))}),n===`chat`&&(0,i.jsx)(be,{...t,refreshToken:c}),n===`companions`&&(o===null?(0,i.jsx)(K,{onOpenProfile:s}):(0,i.jsx)(de,{profileId:o,onBack:()=>s(null),onContinue:t.openSession})),n===`spaces`&&(0,i.jsx)(fe,{onBack:()=>u(`companions`),onOpenSession:t.openSession})]})}var Se=[`slots`,`sessions`,`workspaces`];async function Ce(e,t){let n=t;for(let t=0;t<50;t+=1){if(e.sessions.list.getSnapshot().ids.includes(n)){e.sessions.open(n);return}await new Promise(e=>setTimeout(e,100))}e.sessions.open(n)}function we(e){e.slots.inject(`settings.section`,()=>e.slots.register({name:`settings.section`,id:`tavern-dashboard`,order:200,label:`Tavern`},t=>(0,i.jsx)(xe,{...t,openSession:t=>{Ce(e,t)},createSession:async t=>{await Ce(e,t)}})))}return n.apply=we,n.inject=Se,t.exports}});
|
|
6
|
+
//# sourceMappingURL=client.js.map
|