* Register an externally-created AgentSession so that WorkspaceService * operations (sendMessage, resumeStream, remove, etc.) reuse it instead of * creating a duplicate. Used by `mux run` CLI to keep a single session * instance for the parent workspace.
(workspaceId: string, session: AgentSession)
| 2805 | * instance for the parent workspace. |
| 2806 | */ |
| 2807 | public registerSession(workspaceId: string, session: AgentSession): void { |
| 2808 | workspaceId = workspaceId.trim(); |
| 2809 | assert(workspaceId.length > 0, "workspaceId must not be empty"); |
| 2810 | assert(!this.sessions.has(workspaceId), `session already registered for ${workspaceId}`); |
| 2811 | if (this.transientStartupRecoverySessions.get(workspaceId) === session) { |
| 2812 | this.transientStartupRecoverySessions.delete(workspaceId); |
| 2813 | } |
| 2814 | |
| 2815 | this.sessions.set(workspaceId, session); |
| 2816 | this.attachSessionSubscriptions(workspaceId, session); |
| 2817 | } |
| 2818 | |
| 2819 | public emitChatEvent(workspaceId: string, message: WorkspaceChatMessage): void { |
| 2820 | const trimmed = workspaceId.trim(); |