MCPcopy Index your code
hub / github.com/getsentry/XcodeBuildMCP / toStructuredEnvelope

Function toStructuredEnvelope

src/utils/structured-output-envelope.ts:382–408  ·  view source on GitHub ↗
(
  result: TResult,
  schema: string,
  schemaVersion: string,
  options: StructuredEnvelopeOptions = {},
)

Source from the content-addressed store, hash-verified

380}
381
382export function toStructuredEnvelope<TResult extends ToolDomainResult>(
383 result: TResult,
384 schema: string,
385 schemaVersion: string,
386 options: StructuredEnvelopeOptions = {},
387): StructuredOutputEnvelope<unknown> {
388 const { nextSteps, nextStepRuntime = 'cli', outputStyle = 'normal' } = options;
389 const { kind: neverKind, didError, error, ...data } = result;
390 const projectedData = projectRuntimeSnapshotData(data as DomainResultData<TResult>, options);
391 const serializedNextSteps =
392 schema === 'xcodebuildmcp.output.error'
393 ? undefined
394 : serializeNextSteps(nextSteps, {
395 runtime: nextStepRuntime,
396 });
397
398 const envelope: StructuredOutputEnvelope<unknown> = {
399 schema,
400 schemaVersion,
401 didError,
402 error,
403 data: isRecord(projectedData) && Object.keys(projectedData).length === 0 ? null : projectedData,
404 ...(serializedNextSteps ? { nextSteps: serializedNextSteps } : {}),
405 };
406
407 return applyStructuredOutputStyle(envelope, outputStyle);
408}

Calls 4

serializeNextStepsFunction · 0.90
isRecordFunction · 0.70

Tested by

no test coverage detected