import { getLogger as getLogger$1 } from "../../../logger.js";
import { queueDatasetRunItems } from "../services/datasetRun.js";
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
import { TenantProjectParamsSchema, TriggerDatasetRunSchema } from "@inkeep/agents-core";

//#region src/domains/evals/routes/datasetTriggers.ts
const app = new OpenAPIHono();
const logger = getLogger$1("workflow-triggers");
app.openapi(createRoute({
	method: "post",
	path: "/run-dataset-items",
	summary: "Run dataset items",
	description: "Runs dataset items for processing through the chat API",
	operationId: "run-dataset-items",
	tags: ["Workflows"],
	request: {
		params: TenantProjectParamsSchema,
		body: { content: { "application/json": { schema: TriggerDatasetRunSchema } } }
	},
	responses: {
		202: {
			description: "Workflows queued successfully",
			content: { "application/json": { schema: z.object({
				queued: z.number(),
				failed: z.number(),
				datasetRunId: z.string()
			}) } }
		},
		400: { description: "Invalid request" },
		500: { description: "Internal server error" }
	}
}), async (c) => {
	const { tenantId, projectId } = c.req.valid("param");
	const { datasetRunId, items, evaluatorIds, evaluationRunId } = c.req.valid("json");
	logger.info({
		tenantId,
		projectId,
		datasetRunId,
		itemCount: items.length
	}, "Triggering dataset run workflow");
	const { queued, failed } = await queueDatasetRunItems({
		tenantId,
		projectId,
		datasetRunId,
		items,
		evaluatorIds,
		evaluationRunId
	});
	logger.info({
		tenantId,
		projectId,
		datasetRunId,
		queued,
		failed
	}, "Dataset run workflow trigger complete");
	return c.json({
		queued,
		failed,
		datasetRunId
	}, 202);
});
var datasetTriggers_default = app;

//#endregion
export { datasetTriggers_default as default };