/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Status, Status$inboundSchema, Status$outboundSchema, } from "./status.js"; /** * Whether the command exited normally or timed out. */ export const ShellCallOutputType = { Exit: "exit", Timeout: "timeout", } as const; /** * Whether the command exited normally or timed out. */ export type ShellCallOutputType = ClosedEnum; export type Outcome = { /** * Whether the command exited normally or timed out. */ type: ShellCallOutputType; /** * Exit code of the command, or null if timed out. */ exitCode: number | null; }; /** * Result of the executed command. */ export type Output = { /** * Standard output from the command. */ stdout: string; /** * Standard error from the command. */ stderr: string; outcome: Outcome; }; /** * Shell call output item: The captured output from a hosted-container shell tool call. */ export type ShellCallOutput = { type: "shell_call_output"; id: string; callId: string; /** * Result of the executed command. */ output: Output; /** * The processing status of an individual item. 'in_progress' means currently processing, 'completed' means finished successfully, 'incomplete' means processing stopped before completion. */ status?: Status | undefined; }; /** @internal */ export const ShellCallOutputType$inboundSchema: z.ZodNativeEnum< typeof ShellCallOutputType > = z.nativeEnum(ShellCallOutputType); /** @internal */ export const ShellCallOutputType$outboundSchema: z.ZodNativeEnum< typeof ShellCallOutputType > = ShellCallOutputType$inboundSchema; /** @internal */ export const Outcome$inboundSchema: z.ZodType = z.object({ type: ShellCallOutputType$inboundSchema, exit_code: z.nullable(z.number().int()), }).transform((v) => { return remap$(v, { "exit_code": "exitCode", }); }); /** @internal */ export type Outcome$Outbound = { type: string; exit_code: number | null; }; /** @internal */ export const Outcome$outboundSchema: z.ZodType< Outcome$Outbound, z.ZodTypeDef, Outcome > = z.object({ type: ShellCallOutputType$outboundSchema, exitCode: z.nullable(z.number().int()), }).transform((v) => { return remap$(v, { exitCode: "exit_code", }); }); export function outcomeToJSON(outcome: Outcome): string { return JSON.stringify(Outcome$outboundSchema.parse(outcome)); } export function outcomeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Outcome$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Outcome' from JSON`, ); } /** @internal */ export const Output$inboundSchema: z.ZodType = z .object({ stdout: z.string(), stderr: z.string(), outcome: z.lazy(() => Outcome$inboundSchema), }); /** @internal */ export type Output$Outbound = { stdout: string; stderr: string; outcome: Outcome$Outbound; }; /** @internal */ export const Output$outboundSchema: z.ZodType< Output$Outbound, z.ZodTypeDef, Output > = z.object({ stdout: z.string(), stderr: z.string(), outcome: z.lazy(() => Outcome$outboundSchema), }); export function outputToJSON(output: Output): string { return JSON.stringify(Output$outboundSchema.parse(output)); } export function outputFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Output$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Output' from JSON`, ); } /** @internal */ export const ShellCallOutput$inboundSchema: z.ZodType< ShellCallOutput, z.ZodTypeDef, unknown > = z.object({ type: z.literal("shell_call_output"), id: z.string(), call_id: z.string(), output: z.lazy(() => Output$inboundSchema), status: Status$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "call_id": "callId", }); }); /** @internal */ export type ShellCallOutput$Outbound = { type: "shell_call_output"; id: string; call_id: string; output: Output$Outbound; status?: string | undefined; }; /** @internal */ export const ShellCallOutput$outboundSchema: z.ZodType< ShellCallOutput$Outbound, z.ZodTypeDef, ShellCallOutput > = z.object({ type: z.literal("shell_call_output"), id: z.string(), callId: z.string(), output: z.lazy(() => Output$outboundSchema), status: Status$outboundSchema.optional(), }).transform((v) => { return remap$(v, { callId: "call_id", }); }); export function shellCallOutputToJSON( shellCallOutput: ShellCallOutput, ): string { return JSON.stringify(ShellCallOutput$outboundSchema.parse(shellCallOutput)); } export function shellCallOutputFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ShellCallOutput$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ShellCallOutput' from JSON`, ); }