* Handles a systemMessage.transform request from the runtime. * Dispatches each section to its registered transform callback. * * @param sections - Map of section IDs to their current rendered content * @returns A promise that resolves with the transformed sections * @intern
(
sections: Record<string, { content: string }>
)
| 1152 | * @internal This method is for internal use by the SDK. |
| 1153 | */ |
| 1154 | async _handleSystemMessageTransform( |
| 1155 | sections: Record<string, { content: string }> |
| 1156 | ): Promise<{ sections: Record<string, { content: string }> }> { |
| 1157 | const result: Record<string, { content: string }> = {}; |
| 1158 | |
| 1159 | for (const [sectionId, { content }] of Object.entries(sections)) { |
| 1160 | const callback = this.transformCallbacks?.get(sectionId); |
| 1161 | if (callback) { |
| 1162 | try { |
| 1163 | const transformed = await callback(content); |
| 1164 | result[sectionId] = { content: transformed }; |
| 1165 | } catch (_error) { |
| 1166 | // Callback failed — return original content |
| 1167 | result[sectionId] = { content }; |
| 1168 | } |
| 1169 | } else { |
| 1170 | // No callback for this section — pass through unchanged |
| 1171 | result[sectionId] = { content }; |
| 1172 | } |
| 1173 | } |
| 1174 | |
| 1175 | return { sections: result }; |
| 1176 | } |
| 1177 | |
| 1178 | /** |
| 1179 | * Handles a user input request from the Copilot CLI. |
no test coverage detected