(event: EventMessagePartDelta)
| 152 | } |
| 153 | |
| 154 | private async handlePartDelta(event: EventMessagePartDelta) { |
| 155 | const props = event.properties |
| 156 | const session = await Effect.runPromise(this.input.session.tryGet(props.sessionID)) |
| 157 | if (!session) return |
| 158 | |
| 159 | const known = await Effect.runPromise( |
| 160 | this.input.session.tryGetPartMetadata({ |
| 161 | sessionId: session.id, |
| 162 | messageId: props.messageID, |
| 163 | partId: props.partID, |
| 164 | }), |
| 165 | ) |
| 166 | const metadata = |
| 167 | known?.role && known.partType |
| 168 | ? known |
| 169 | : await this.fetchPartMetadata(session.id, session.cwd, props.messageID, props.partID) |
| 170 | if (metadata?.role !== "assistant") return |
| 171 | if (metadata.partType === "text" && props.field === "text" && metadata.ignored !== true) { |
| 172 | await this.input.connection.sessionUpdate({ |
| 173 | sessionId: session.id, |
| 174 | update: { |
| 175 | sessionUpdate: "agent_message_chunk", |
| 176 | messageId: props.messageID, |
| 177 | content: { |
| 178 | type: "text", |
| 179 | text: props.delta, |
| 180 | }, |
| 181 | }, |
| 182 | }) |
| 183 | return |
| 184 | } |
| 185 | |
| 186 | if (metadata.partType === "reasoning" && props.field === "text") { |
| 187 | await this.input.connection.sessionUpdate({ |
| 188 | sessionId: session.id, |
| 189 | update: { |
| 190 | sessionUpdate: "agent_thought_chunk", |
| 191 | messageId: props.messageID, |
| 192 | content: { |
| 193 | type: "text", |
| 194 | text: props.delta, |
| 195 | }, |
| 196 | }, |
| 197 | }) |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | private async fetchPartMetadata(sessionId: string, cwd: string, messageId: string, partId: string) { |
| 202 | const message = await this.input.sdk.session |
no test coverage detected