"use strict";
/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.CreateAgentResponseRequestResponse$inboundSchema = exports.CreateAgentResponseRequestResponseBody$inboundSchema = exports.CreateAgentResponseRequestRequest$outboundSchema = exports.CreateAgentResponseRequestRequestBody$outboundSchema = exports.Conversation$outboundSchema = exports.Memory$outboundSchema = exports.CreateAgentResponseRequestThread$outboundSchema = exports.Contact$outboundSchema = exports.Identity$outboundSchema = exports.A2AMessage$outboundSchema = exports.PublicMessagePart$outboundSchema = exports.CreateAgentResponseRequestRole$outboundSchema = exports.RoleUserMessage$outboundSchema = exports.RoleToolMessage$outboundSchema = exports.RoleUserMessage = exports.RoleToolMessage = void 0;
exports.createAgentResponseRequestRoleToJSON = createAgentResponseRequestRoleToJSON;
exports.publicMessagePartToJSON = publicMessagePartToJSON;
exports.a2AMessageToJSON = a2AMessageToJSON;
exports.identityToJSON = identityToJSON;
exports.contactToJSON = contactToJSON;
exports.createAgentResponseRequestThreadToJSON = createAgentResponseRequestThreadToJSON;
exports.memoryToJSON = memoryToJSON;
exports.conversationToJSON = conversationToJSON;
exports.createAgentResponseRequestRequestBodyToJSON = createAgentResponseRequestRequestBodyToJSON;
exports.createAgentResponseRequestRequestToJSON = createAgentResponseRequestRequestToJSON;
exports.createAgentResponseRequestResponseBodyFromJSON = createAgentResponseRequestResponseBodyFromJSON;
exports.createAgentResponseRequestResponseFromJSON = createAgentResponseRequestResponseFromJSON;
const z = __importStar(require("zod/v3"));
const event_streams_js_1 = require("../../lib/event-streams.js");
const primitives_js_1 = require("../../lib/primitives.js");
const schemas_js_1 = require("../../lib/schemas.js");
const components = __importStar(require("../components/index.js"));
/**
 * Message containing tool execution results
 */
exports.RoleToolMessage = {
    Tool: "tool",
};
/**
 * Message from the end user
 */
exports.RoleUserMessage = {
    User: "user",
};
/** @internal */
exports.RoleToolMessage$outboundSchema = z.nativeEnum(exports.RoleToolMessage);
/** @internal */
exports.RoleUserMessage$outboundSchema = z.nativeEnum(exports.RoleUserMessage);
/** @internal */
exports.CreateAgentResponseRequestRole$outboundSchema = z.union([exports.RoleUserMessage$outboundSchema, exports.RoleToolMessage$outboundSchema]);
function createAgentResponseRequestRoleToJSON(createAgentResponseRequestRole) {
    return JSON.stringify(exports.CreateAgentResponseRequestRole$outboundSchema.parse(createAgentResponseRequestRole));
}
/** @internal */
exports.PublicMessagePart$outboundSchema = z.union([
    components.TextPart$outboundSchema,
    components.FilePart$outboundSchema,
    components.ToolResultPart$outboundSchema,
    components.ErrorPart$outboundSchema,
]);
function publicMessagePartToJSON(publicMessagePart) {
    return JSON.stringify(exports.PublicMessagePart$outboundSchema.parse(publicMessagePart));
}
/** @internal */
exports.A2AMessage$outboundSchema = z.object({
    messageId: z.string().optional(),
    role: z.union([
        exports.RoleUserMessage$outboundSchema,
        exports.RoleToolMessage$outboundSchema,
    ]),
    parts: z.array(z.union([
        components.TextPart$outboundSchema,
        components.FilePart$outboundSchema,
        components.ToolResultPart$outboundSchema,
        components.ErrorPart$outboundSchema,
    ])),
});
function a2AMessageToJSON(a2AMessage) {
    return JSON.stringify(exports.A2AMessage$outboundSchema.parse(a2AMessage));
}
/** @internal */
exports.Identity$outboundSchema = z.object({
    id: z.string(),
    displayName: z.string().optional(),
    email: z.string().optional(),
    metadata: z.array(z.record(z.any())).optional(),
    logoUrl: z.string().optional(),
    tags: z.array(z.string()).optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        displayName: "display_name",
        logoUrl: "logo_url",
    });
});
function identityToJSON(identity) {
    return JSON.stringify(exports.Identity$outboundSchema.parse(identity));
}
/** @internal */
exports.Contact$outboundSchema = z.object({
    id: z.string(),
    displayName: z.string().optional(),
    email: z.string().optional(),
    metadata: z.array(z.record(z.any())).optional(),
    logoUrl: z.string().optional(),
    tags: z.array(z.string()).optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        displayName: "display_name",
        logoUrl: "logo_url",
    });
});
function contactToJSON(contact) {
    return JSON.stringify(exports.Contact$outboundSchema.parse(contact));
}
/** @internal */
exports.CreateAgentResponseRequestThread$outboundSchema = z.object({
    id: z.string(),
    tags: z.array(z.string()).optional(),
});
function createAgentResponseRequestThreadToJSON(createAgentResponseRequestThread) {
    return JSON.stringify(exports.CreateAgentResponseRequestThread$outboundSchema.parse(createAgentResponseRequestThread));
}
/** @internal */
exports.Memory$outboundSchema = z.object({
    entityId: z.string(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        entityId: "entity_id",
    });
});
function memoryToJSON(memory) {
    return JSON.stringify(exports.Memory$outboundSchema.parse(memory));
}
/** @internal */
exports.Conversation$outboundSchema = z.object({
    id: z.string(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        id: "_id",
    });
});
function conversationToJSON(conversation) {
    return JSON.stringify(exports.Conversation$outboundSchema.parse(conversation));
}
/** @internal */
exports.CreateAgentResponseRequestRequestBody$outboundSchema = z.object({
    taskId: z.string().optional(),
    message: z.lazy(() => exports.A2AMessage$outboundSchema),
    variables: z.record(z.any()).optional(),
    identity: z.lazy(() => exports.Identity$outboundSchema).optional(),
    contact: z.lazy(() => exports.Contact$outboundSchema).optional(),
    thread: z.lazy(() => exports.CreateAgentResponseRequestThread$outboundSchema)
        .optional(),
    memory: z.lazy(() => exports.Memory$outboundSchema).optional(),
    metadata: z.record(z.any()).optional(),
    background: z.boolean().default(false),
    stream: z.boolean().default(false),
    conversation: z.lazy(() => exports.Conversation$outboundSchema).optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        taskId: "task_id",
    });
});
function createAgentResponseRequestRequestBodyToJSON(createAgentResponseRequestRequestBody) {
    return JSON.stringify(exports.CreateAgentResponseRequestRequestBody$outboundSchema.parse(createAgentResponseRequestRequestBody));
}
/** @internal */
exports.CreateAgentResponseRequestRequest$outboundSchema = z.object({
    agentKey: z.string(),
    requestBody: z.lazy(() => exports.CreateAgentResponseRequestRequestBody$outboundSchema),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        agentKey: "agent_key",
        requestBody: "RequestBody",
    });
});
function createAgentResponseRequestRequestToJSON(createAgentResponseRequestRequest) {
    return JSON.stringify(exports.CreateAgentResponseRequestRequest$outboundSchema.parse(createAgentResponseRequestRequest));
}
/** @internal */
exports.CreateAgentResponseRequestResponseBody$inboundSchema = z.object({
    data: z.string().optional().transform((v, ctx) => {
        if (v === undefined)
            return undefined;
        try {
            return JSON.parse(v);
        }
        catch (err) {
            ctx.addIssue({ code: "custom", message: `malformed json: ${err}` });
            return z.NEVER;
        }
    }).pipe(components.ResponseStreamingEvent$inboundSchema.optional()),
});
function createAgentResponseRequestResponseBodyFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.CreateAgentResponseRequestResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateAgentResponseRequestResponseBody' from JSON`);
}
/** @internal */
exports.CreateAgentResponseRequestResponse$inboundSchema = z.union([
    components.CreateAgentResponse$inboundSchema,
    z.instanceof((ReadableStream))
        .transform(stream => {
        return new event_streams_js_1.EventStream(stream, rawEvent => {
            if (rawEvent.data === "[DONE]")
                return { done: true };
            return {
                value: z.lazy(() => exports.CreateAgentResponseRequestResponseBody$inboundSchema).parse(rawEvent),
            };
        });
    }),
]);
function createAgentResponseRequestResponseFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.CreateAgentResponseRequestResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateAgentResponseRequestResponse' from JSON`);
}
//# sourceMappingURL=createagentresponserequest.js.map