MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / toBatchItemResult

Function toBatchItemResult

server/src/utils/batch.ts:190–216  ·  view source on GitHub ↗

* Convert an SDK batch result entry to our BatchItemResult.

(entry: MessageBatchIndividualResponse)

Source from the content-addressed store, hash-verified

188 * Convert an SDK batch result entry to our BatchItemResult.
189 */
190function toBatchItemResult(entry: MessageBatchIndividualResponse): BatchItemResult {
191 const { custom_id, result } = entry;
192
193 if (result.type === 'succeeded') {
194 return {
195 customId: custom_id,
196 status: 'succeeded',
197 message: (result as MessageBatchSucceededResult).message,
198 };
199 }
200
201 if (result.type === 'errored') {
202 const errResult = result as MessageBatchErroredResult;
203 // ErrorResponse.error is the ErrorObject containing type + message
204 const { type, message } = errResult.error.error;
205 return {
206 customId: custom_id,
207 status: 'errored',
208 error: { type, message },
209 };
210 }
211
212 return {
213 customId: custom_id,
214 status: result.type as 'canceled' | 'expired',
215 };
216}
217
218/**
219 * Extract the text content from a succeeded batch result.

Callers 1

collectResultsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected