Skip to main content

apps/gateway/src/routes/execute.ts

Metadata

Indexed Symbols

No indexed functions/methods detected in this file.

Markdown Headings (if applicable)

No markdown headings detected.

Source Preview

import type { FastifyPluginAsync } from "fastify";
import { createHmac, randomUUID, timingSafeEqual } from "node:crypto";
import { executeAgentRequestSchema, workflowControlRequestSchema } from "@anchor/contracts";
import { env } from "../config/env.js";
import { enqueueAgentExecution } from "../services/agentfield-client.js";
import { buildAuditCredential } from "../services/audit.js";
import { getEffectivePlatformSettings, resolveSecretValue } from "../services/runtime-config.js";
import { recordWebhookReceipt } from "../services/webhook-repository.js";
import {
cancelWorkflowExecution,
getWorkflowExecutionById,
listWorkflowCallbacks,
listAuditCredentials,
listWorkflowExecutions,
persistAuditCredential,
persistWorkflowCompletion,
persistWorkflowExecution
} from "../services/workflow-repository.js";
import { getIdempotencyKey, getIdempotencyRouteScope } from "../utils/idempotency.js";
import { getWorkspaceIdFromHeaders } from "../utils/workspace.js";
import { ensureRoles } from "../utils/authorization.js";

export const executionRoutes: FastifyPluginAsync = async (app) => {
app.get("/api/v1/workflow-executions", async (request, reply) => {
if (!ensureRoles(request, reply, ["msp_admin", "ops_engineer", "viewer", "automation_operator"])) {