/* * 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 ShellCallOutputWithIdType = { Exit: "exit", Timeout: "timeout", } as const; /** * Whether the command exited normally or timed out. */ export type ShellCallOutputWithIdType = ClosedEnum< typeof ShellCallOutputWithIdType >; export type ShellCallOutputWithIdOutcome = { /** * Whether the command exited normally or timed out. */ type: ShellCallOutputWithIdType; /** * Exit code of the command, or null if timed out. */ exitCode: number | null; }; /** * Result of the executed command. */ export type ShellCallOutputWithIdOutput = { /** * Standard output from the command. */ stdout: string; /** * Standard error from the command. */ stderr: string; outcome: ShellCallOutputWithIdOutcome; }; /** * Shell call output item: The captured output from a hosted-container shell tool call. */ export type ShellCallOutputWithId = { type: "shell_call_output"; /** * The unique ID of the message. */ id: string; callId: string; /** * Result of the executed command. */ output: ShellCallOutputWithIdOutput; /** * 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; /** * The ID of the response that created this item, if any. */ responseId?: string | null | undefined; /** * Metadata from the response that created this item, if any. */ metadata?: { [k: string]: string } | null | undefined; }; /** @internal */ export const ShellCallOutputWithIdType$inboundSchema: z.ZodNativeEnum< typeof ShellCallOutputWithIdType > = z.nativeEnum(ShellCallOutputWithIdType); /** @internal */ export const ShellCallOutputWithIdType$outboundSchema: z.ZodNativeEnum< typeof ShellCallOutputWithIdType > = ShellCallOutputWithIdType$inboundSchema; /** @internal */ export const ShellCallOutputWithIdOutcome$inboundSchema: z.ZodType< ShellCallOutputWithIdOutcome, z.ZodTypeDef, unknown > = z.object({ type: ShellCallOutputWithIdType$inboundSchema, exit_code: z.nullable(z.number().int()), }).transform((v) => { return remap$(v, { "exit_code": "exitCode", }); }); /** @internal */ export type ShellCallOutputWithIdOutcome$Outbound = { type: string; exit_code: number | null; }; /** @internal */ export const ShellCallOutputWithIdOutcome$outboundSchema: z.ZodType< ShellCallOutputWithIdOutcome$Outbound, z.ZodTypeDef, ShellCallOutputWithIdOutcome > = z.object({ type: ShellCallOutputWithIdType$outboundSchema, exitCode: z.nullable(z.number().int()), }).transform((v) => { return remap$(v, { exitCode: "exit_code", }); }); export function shellCallOutputWithIdOutcomeToJSON( shellCallOutputWithIdOutcome: ShellCallOutputWithIdOutcome, ): string { return JSON.stringify( ShellCallOutputWithIdOutcome$outboundSchema.parse( shellCallOutputWithIdOutcome, ), ); } export function shellCallOutputWithIdOutcomeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ShellCallOutputWithIdOutcome$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ShellCallOutputWithIdOutcome' from JSON`, ); } /** @internal */ export const ShellCallOutputWithIdOutput$inboundSchema: z.ZodType< ShellCallOutputWithIdOutput, z.ZodTypeDef, unknown > = z.object({ stdout: z.string(), stderr: z.string(), outcome: z.lazy(() => ShellCallOutputWithIdOutcome$inboundSchema), }); /** @internal */ export type ShellCallOutputWithIdOutput$Outbound = { stdout: string; stderr: string; outcome: ShellCallOutputWithIdOutcome$Outbound; }; /** @internal */ export const ShellCallOutputWithIdOutput$outboundSchema: z.ZodType< ShellCallOutputWithIdOutput$Outbound, z.ZodTypeDef, ShellCallOutputWithIdOutput > = z.object({ stdout: z.string(), stderr: z.string(), outcome: z.lazy(() => ShellCallOutputWithIdOutcome$outboundSchema), }); export function shellCallOutputWithIdOutputToJSON( shellCallOutputWithIdOutput: ShellCallOutputWithIdOutput, ): string { return JSON.stringify( ShellCallOutputWithIdOutput$outboundSchema.parse( shellCallOutputWithIdOutput, ), ); } export function shellCallOutputWithIdOutputFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ShellCallOutputWithIdOutput$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ShellCallOutputWithIdOutput' from JSON`, ); } /** @internal */ export const ShellCallOutputWithId$inboundSchema: z.ZodType< ShellCallOutputWithId, z.ZodTypeDef, unknown > = z.object({ type: z.literal("shell_call_output"), id: z.string(), call_id: z.string(), output: z.lazy(() => ShellCallOutputWithIdOutput$inboundSchema), status: Status$inboundSchema.optional(), response_id: z.nullable(z.string()).optional(), metadata: z.nullable(z.record(z.string())).optional(), }).transform((v) => { return remap$(v, { "call_id": "callId", "response_id": "responseId", }); }); /** @internal */ export type ShellCallOutputWithId$Outbound = { type: "shell_call_output"; id: string; call_id: string; output: ShellCallOutputWithIdOutput$Outbound; status?: string | undefined; response_id?: string | null | undefined; metadata?: { [k: string]: string } | null | undefined; }; /** @internal */ export const ShellCallOutputWithId$outboundSchema: z.ZodType< ShellCallOutputWithId$Outbound, z.ZodTypeDef, ShellCallOutputWithId > = z.object({ type: z.literal("shell_call_output"), id: z.string(), callId: z.string(), output: z.lazy(() => ShellCallOutputWithIdOutput$outboundSchema), status: Status$outboundSchema.optional(), responseId: z.nullable(z.string()).optional(), metadata: z.nullable(z.record(z.string())).optional(), }).transform((v) => { return remap$(v, { callId: "call_id", responseId: "response_id", }); }); export function shellCallOutputWithIdToJSON( shellCallOutputWithId: ShellCallOutputWithId, ): string { return JSON.stringify( ShellCallOutputWithId$outboundSchema.parse(shellCallOutputWithId), ); } export function shellCallOutputWithIdFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ShellCallOutputWithId$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ShellCallOutputWithId' from JSON`, ); }