MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / unwrapInvocation

Function unwrapInvocation

packages/plugins/openapi/src/testing/index.ts:716–743  ·  view source on GitHub ↗
(
  raw: unknown,
)

Source from the content-addressed store, hash-verified

714}
715
716export const unwrapInvocation = <TData = Record<string, unknown> | null>(
717 raw: unknown,
718): OpenApiInvocationResult<TData> => {
719 if (!isToolResult(raw)) {
720 return {
721 status: null,
722 headers: null,
723 data: raw as TData,
724 error: null,
725 };
726 }
727 if (raw.ok) {
728 // Payload-first: `data` is the upstream body; transport status/headers
729 // ride in the `http` side channel.
730 return {
731 status: raw.http?.status ?? null,
732 headers: raw.http?.headers ?? null,
733 data: raw.data as TData,
734 error: null,
735 };
736 }
737 return {
738 status: raw.error.status ?? null,
739 headers: null,
740 data: null as TData,
741 error: raw.error.details ?? raw.error,
742 };
743};

Calls 1

isToolResultFunction · 0.90

Tested by

no test coverage detected