"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.StreamAgentResponseBody$inboundSchema = exports.StreamAgentData$inboundSchema = exports.StreamAgentRequest$outboundSchema = exports.StreamAgentRequestBody$outboundSchema = exports.StreamAgentMemory$outboundSchema = exports.StreamAgentThread$outboundSchema = exports.StreamAgentContact$outboundSchema = exports.StreamAgentIdentity$outboundSchema = exports.StreamAgentA2AMessage$outboundSchema = exports.StreamAgentPublicMessagePart$outboundSchema = exports.StreamAgentRole$outboundSchema = exports.StreamAgentRoleUserMessage$outboundSchema = exports.StreamAgentRoleToolMessage$outboundSchema = exports.StreamAgentRoleUserMessage = exports.StreamAgentRoleToolMessage = void 0;
exports.streamAgentRoleToJSON = streamAgentRoleToJSON;
exports.streamAgentPublicMessagePartToJSON = streamAgentPublicMessagePartToJSON;
exports.streamAgentA2AMessageToJSON = streamAgentA2AMessageToJSON;
exports.streamAgentIdentityToJSON = streamAgentIdentityToJSON;
exports.streamAgentContactToJSON = streamAgentContactToJSON;
exports.streamAgentThreadToJSON = streamAgentThreadToJSON;
exports.streamAgentMemoryToJSON = streamAgentMemoryToJSON;
exports.streamAgentRequestBodyToJSON = streamAgentRequestBodyToJSON;
exports.streamAgentRequestToJSON = streamAgentRequestToJSON;
exports.streamAgentDataFromJSON = streamAgentDataFromJSON;
exports.streamAgentResponseBodyFromJSON = streamAgentResponseBodyFromJSON;
const z = __importStar(require("zod/v3"));
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.StreamAgentRoleToolMessage = {
    Tool: "tool",
};
/**
 * Message from the end user
 */
exports.StreamAgentRoleUserMessage = {
    User: "user",
};
/** @internal */
exports.StreamAgentRoleToolMessage$outboundSchema = z.nativeEnum(exports.StreamAgentRoleToolMessage);
/** @internal */
exports.StreamAgentRoleUserMessage$outboundSchema = z.nativeEnum(exports.StreamAgentRoleUserMessage);
/** @internal */
exports.StreamAgentRole$outboundSchema = z.union([
    exports.StreamAgentRoleUserMessage$outboundSchema,
    exports.StreamAgentRoleToolMessage$outboundSchema,
]);
function streamAgentRoleToJSON(streamAgentRole) {
    return JSON.stringify(exports.StreamAgentRole$outboundSchema.parse(streamAgentRole));
}
/** @internal */
exports.StreamAgentPublicMessagePart$outboundSchema = z.union([
    components.TextPart$outboundSchema,
    components.FilePart$outboundSchema,
    components.ToolResultPart$outboundSchema,
    components.ErrorPart$outboundSchema,
]);
function streamAgentPublicMessagePartToJSON(streamAgentPublicMessagePart) {
    return JSON.stringify(exports.StreamAgentPublicMessagePart$outboundSchema.parse(streamAgentPublicMessagePart));
}
/** @internal */
exports.StreamAgentA2AMessage$outboundSchema = z.object({
    messageId: z.string().optional(),
    role: z.union([
        exports.StreamAgentRoleUserMessage$outboundSchema,
        exports.StreamAgentRoleToolMessage$outboundSchema,
    ]),
    parts: z.array(z.union([
        components.TextPart$outboundSchema,
        components.FilePart$outboundSchema,
        components.ToolResultPart$outboundSchema,
        components.ErrorPart$outboundSchema,
    ])),
});
function streamAgentA2AMessageToJSON(streamAgentA2AMessage) {
    return JSON.stringify(exports.StreamAgentA2AMessage$outboundSchema.parse(streamAgentA2AMessage));
}
/** @internal */
exports.StreamAgentIdentity$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 streamAgentIdentityToJSON(streamAgentIdentity) {
    return JSON.stringify(exports.StreamAgentIdentity$outboundSchema.parse(streamAgentIdentity));
}
/** @internal */
exports.StreamAgentContact$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 streamAgentContactToJSON(streamAgentContact) {
    return JSON.stringify(exports.StreamAgentContact$outboundSchema.parse(streamAgentContact));
}
/** @internal */
exports.StreamAgentThread$outboundSchema = z.object({
    id: z.string(),
    tags: z.array(z.string()).optional(),
});
function streamAgentThreadToJSON(streamAgentThread) {
    return JSON.stringify(exports.StreamAgentThread$outboundSchema.parse(streamAgentThread));
}
/** @internal */
exports.StreamAgentMemory$outboundSchema = z.object({
    entityId: z.string(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        entityId: "entity_id",
    });
});
function streamAgentMemoryToJSON(streamAgentMemory) {
    return JSON.stringify(exports.StreamAgentMemory$outboundSchema.parse(streamAgentMemory));
}
/** @internal */
exports.StreamAgentRequestBody$outboundSchema = z.object({
    taskId: z.string().optional(),
    message: z.lazy(() => exports.StreamAgentA2AMessage$outboundSchema),
    variables: z.record(z.any()).optional(),
    identity: z.lazy(() => exports.StreamAgentIdentity$outboundSchema).optional(),
    contact: z.lazy(() => exports.StreamAgentContact$outboundSchema).optional(),
    thread: z.lazy(() => exports.StreamAgentThread$outboundSchema).optional(),
    memory: z.lazy(() => exports.StreamAgentMemory$outboundSchema).optional(),
    metadata: z.record(z.any()).optional(),
    streamTimeoutSeconds: z.number().optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        taskId: "task_id",
        streamTimeoutSeconds: "stream_timeout_seconds",
    });
});
function streamAgentRequestBodyToJSON(streamAgentRequestBody) {
    return JSON.stringify(exports.StreamAgentRequestBody$outboundSchema.parse(streamAgentRequestBody));
}
/** @internal */
exports.StreamAgentRequest$outboundSchema = z.object({
    key: z.string(),
    requestBody: z.lazy(() => exports.StreamAgentRequestBody$outboundSchema),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        requestBody: "RequestBody",
    });
});
function streamAgentRequestToJSON(streamAgentRequest) {
    return JSON.stringify(exports.StreamAgentRequest$outboundSchema.parse(streamAgentRequest));
}
/** @internal */
exports.StreamAgentData$inboundSchema = z.union([
    components.AgentExecutionStartedStreamingEvent$inboundSchema,
    components.AgentStartedStreamingEvent$inboundSchema,
    components.AgentThoughtStreamingEvent$inboundSchema,
    components.AgentInactiveStreamingEvent$inboundSchema,
    components.AgentErroredStreamingEvent$inboundSchema,
    components.ActionReviewRequestedStreamingEvent$inboundSchema,
    components.ActionReviewedStreamingEvent$inboundSchema,
    components.ExecutionReviewRequiredStreamingEvent$inboundSchema,
    components.ExecutionReviewedStreamingEvent$inboundSchema,
    components.ExecutionNamedStreamingEvent$inboundSchema,
    components.AgentHandedOffStreamingEvent$inboundSchema,
    components.AgentMessageCreatedStreamingEvent$inboundSchema,
    components.ToolExecutionStartedStreamingEvent$inboundSchema,
    components.ToolExecutionFinishedStreamingEvent$inboundSchema,
    components.ToolExecutionFailedStreamingEvent$inboundSchema,
    components.TimeoutStreamingEvent$inboundSchema,
    components.ErrorStreamingEvent$inboundSchema,
]);
function streamAgentDataFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.StreamAgentData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'StreamAgentData' from JSON`);
}
/** @internal */
exports.StreamAgentResponseBody$inboundSchema = z.object({
    data: z.string().transform((v, ctx) => {
        try {
            return JSON.parse(v);
        }
        catch (err) {
            ctx.addIssue({ code: "custom", message: `malformed json: ${err}` });
            return z.NEVER;
        }
    }).pipe(z.union([
        components.AgentExecutionStartedStreamingEvent$inboundSchema,
        components.AgentStartedStreamingEvent$inboundSchema,
        components.AgentThoughtStreamingEvent$inboundSchema,
        components.AgentInactiveStreamingEvent$inboundSchema,
        components.AgentErroredStreamingEvent$inboundSchema,
        components.ActionReviewRequestedStreamingEvent$inboundSchema,
        components.ActionReviewedStreamingEvent$inboundSchema,
        components.ExecutionReviewRequiredStreamingEvent$inboundSchema,
        components.ExecutionReviewedStreamingEvent$inboundSchema,
        components.ExecutionNamedStreamingEvent$inboundSchema,
        components.AgentHandedOffStreamingEvent$inboundSchema,
        components.AgentMessageCreatedStreamingEvent$inboundSchema,
        components.ToolExecutionStartedStreamingEvent$inboundSchema,
        components.ToolExecutionFinishedStreamingEvent$inboundSchema,
        components.ToolExecutionFailedStreamingEvent$inboundSchema,
        components.TimeoutStreamingEvent$inboundSchema,
        components.ErrorStreamingEvent$inboundSchema,
    ])),
});
function streamAgentResponseBodyFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.StreamAgentResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'StreamAgentResponseBody' from JSON`);
}
//# sourceMappingURL=streamagent.js.map