@endpointcontext/core
v0.1.0
Published
Core request negotiation helpers for the Endpoint Context Protocol.
Downloads
19
Maintainers
Readme
@endpointcontext/core
Small, framework-agnostic helpers for the Endpoint Context Protocol.
What It Does
It answers the core routing question:
- browser-like request -> keep normal HTML flow
- non-browser request -> serve semantic content
Example
import { createFetchHandler } from '@endpointcontext/core';
const handleEcp = createFetchHandler({
getAgentContent: async ({ request }) => {
const pathname = new URL(request.url).pathname;
if (pathname === '/docs') {
return '# Architectural Reference\n\nSemantic markdown goes here.';
}
return null;
},
});
export default {
async fetch(request) {
const ecpResponse = await handleEcp({ request });
if (ecpResponse) return ecpResponse;
return new Response('<h1>HTML site</h1>', {
headers: { 'content-type': 'text/html; charset=utf-8' },
});
},
};