@ai2web/server
v0.2.0
Published
AI2Web server - framework-agnostic /ai2w route handler + adapters (Node http, Express, Hono, Next).
Maintainers
Readme
@ai2web/server
A framework-agnostic route handler that serves an AI2Web site: the required /.well-known/ai2w discovery anchor, the canonical /ai2w manifest, capability negotiation, and your module/action routes. Ships Node and Cloudflare Workers adapters.
Install
npm install @ai2web/server @ai2web/coreUse
import { nodeListener, cloudflareHandler } from "@ai2web/server";
import { ai2web } from "@ai2web/core";
const manifest = ai2web({ name: "Acme", url: "https://acme.example", type: "ecommerce" })
.capability("content")
.build();
const options = {
manifest,
modules: { content: (req) => ({ items: [] }) },
actions: { check_stock: (req) => ({ in_stock: true }) },
};
// Node
import { createServer } from "node:http";
createServer(nodeListener(options)).listen(8787);
// Cloudflare Workers
export default cloudflareHandler(options);createAi2wHandler(options) is also exported for use with any other runtime.
Request validation
By default the server validates each action's request body against the input_schema that action declares in the manifest, returning a 400 invalid_request before your handler runs. So schema compliance on every request is built in, not something you wire yourself. Opt out with validateInput: false in the options.
Part of AI2Web.
