Mirrors AbstractAgent.addMessage: mutate the messages array in place and * notify with the SAME array reference (no reassignment).
(message: Message)
| 86 | /** Mirrors AbstractAgent.addMessage: mutate the messages array in place and |
| 87 | * notify with the SAME array reference (no reassignment). */ |
| 88 | pushMessageInPlace(message: Message) { |
| 89 | this.messages.push(message); |
| 90 | for (const s of this.subscribers) { |
| 91 | s.onMessagesChanged?.({ |
| 92 | messages: this.messages, |
| 93 | state: this.state, |
| 94 | agent: this, |
| 95 | }); |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | emitState(state: State) { |
| 100 | this.state = state; |