first commit

This commit is contained in:
Nermin Karic
2026-11-22 21:49:17 +01:00
commit f5e2fcbf98
693 changed files with 82975 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
import { handleMcpRequest } from "@lib/ucp/mcp"
export const POST = (request: Request) => handleMcpRequest(request)
export const GET = () =>
new Response("Method Not Allowed", { status: 405, headers: { Allow: "POST" } })

View File

@@ -0,0 +1,15 @@
import { cancelCart, getCart, updateCart } from "@lib/ucp/operations"
import { readJsonBody, toResponse } from "@lib/ucp/ucp"
type Context = { params: Promise<{ cartId: string }> }
export const GET = async (request: Request, { params }: Context) =>
toResponse(await getCart(request, (await params).cartId))
export const PUT = async (request: Request, { params }: Context) =>
toResponse(
await updateCart(request, (await params).cartId, (await readJsonBody(request)) ?? {})
)
export const DELETE = async (request: Request, { params }: Context) =>
toResponse(await cancelCart(request, (await params).cartId))

View File

@@ -0,0 +1,11 @@
import { createCart } from "@lib/ucp/operations"
import { readJsonBody, toResponse } from "@lib/ucp/ucp"
export const POST = async (request: Request) =>
toResponse(
await createCart(
request,
(await readJsonBody(request)) ?? {},
request.headers.get("idempotency-key")
)
)

View File

@@ -0,0 +1,5 @@
import { lookupCatalog } from "@lib/ucp/operations"
import { readJsonBody, toResponse } from "@lib/ucp/ucp"
export const POST = async (request: Request) =>
toResponse(await lookupCatalog(request, (await readJsonBody(request)) ?? {}))

View File

@@ -0,0 +1,5 @@
import { searchCatalog } from "@lib/ucp/operations"
import { readJsonBody, toResponse } from "@lib/ucp/ucp"
export const POST = async (request: Request) =>
toResponse(await searchCatalog(request, (await readJsonBody(request)) ?? {}))

View File

@@ -0,0 +1,7 @@
import { cancelCheckout } from "@lib/ucp/operations"
import { toResponse } from "@lib/ucp/ucp"
export const POST = async (
request: Request,
{ params }: { params: Promise<{ id: string }> }
) => toResponse(await cancelCheckout(request, (await params).id))

View File

@@ -0,0 +1,7 @@
import { completeCheckout } from "@lib/ucp/operations"
import { toResponse } from "@lib/ucp/ucp"
export const POST = async (
request: Request,
{ params }: { params: Promise<{ id: string }> }
) => toResponse(await completeCheckout(request, (await params).id))

View File

@@ -0,0 +1,12 @@
import { getCheckout, updateCheckout } from "@lib/ucp/operations"
import { readJsonBody, toResponse } from "@lib/ucp/ucp"
type Context = { params: Promise<{ id: string }> }
export const GET = async (request: Request, { params }: Context) =>
toResponse(await getCheckout(request, (await params).id))
export const PUT = async (request: Request, { params }: Context) =>
toResponse(
await updateCheckout(request, (await params).id, (await readJsonBody(request)) ?? {})
)

View File

@@ -0,0 +1,11 @@
import { createCheckout } from "@lib/ucp/operations"
import { readJsonBody, toResponse } from "@lib/ucp/ucp"
export const POST = async (request: Request) =>
toResponse(
await createCheckout(
request,
(await readJsonBody(request)) ?? {},
request.headers.get("idempotency-key")
)
)

View File

@@ -0,0 +1,26 @@
import { handleMcpRequest } from "@lib/ucp/mcp"
import { UCP_MCP_PATH, UCP_REST_BASE_PATH, UCP_VERSION } from "@lib/ucp/ucp"
import { getRequestOrigin } from "@lib/util/site"
export const GET = (request: Request) => {
const origin = getRequestOrigin(request)
const base = `${origin}${UCP_REST_BASE_PATH}`
return Response.json({
ucp: { version: UCP_VERSION },
profile: `${origin}/.well-known/ucp`,
mcp: `${origin}${UCP_MCP_PATH}`,
operations: [
`POST ${base}/catalog/search`,
`POST ${base}/catalog/lookup`,
`POST ${base}/cart`,
`GET|PUT|DELETE ${base}/cart/{id}`,
`POST ${base}/checkout-sessions`,
`GET|PUT ${base}/checkout-sessions/{id}`,
`POST ${base}/checkout-sessions/{id}/complete`,
`POST ${base}/checkout-sessions/{id}/cancel`,
],
})
}
// Agents that only know the service URL may probe it with MCP JSON-RPC.
export const POST = (request: Request) => handleMcpRequest(request)