apps/agentfield-mock/src/server.ts
Metadata
- Purpose: Source artifact in the anchor-msp system.
- Domain:
applications - Language:
ts - Bytes: 2633
- Lines: 86
- Content hash (short):
9198cea2 - Source (start): apps/agentfield-mock/src/server.ts:1
- Source (end): apps/agentfield-mock/src/server.ts:86
Indexed Symbols
No indexed functions/methods detected in this file.
Markdown Headings (if applicable)
No markdown headings detected.
Source Preview
import Fastify from "fastify";
import { randomUUID, createHmac } from "node:crypto";
const port = Number(process.env.PORT ?? 8081);
const host = process.env.HOST ?? "0.0.0.0";
const callbackUrl = process.env.GATEWAY_WORKFLOW_CALLBACK_URL;
const callbackSecret = process.env.AGENTFIELD_WEBHOOK_SECRET;
const callbackDelayMs = Number(process.env.MOCK_CALLBACK_DELAY_MS ?? 1500);
const app = Fastify({ logger: true });
app.get("/health", async () => {
return {
status: "ok",
service: "agentfield-mock",
timestamp: new Date().toISOString()
};
});
app.post<{ Params: { agent: string; reasoner: string } }>("/api/v1/execute/:agent.:reasoner", async (request, reply) => {
const executionId = randomUUID();
const workspaceId =
(typeof (request.body as Record<string, unknown> | undefined)?.workspaceId === "string"
? (request.body as Record<string, unknown>).workspaceId
: typeof request.headers["x-workspace-id"] === "string"