// src/manifest.ts of @absolutejs/dispatch
import { Type } from "@sinclair/typebox";
import { defineManifest, toolFactory } from "@absolutejs/manifest";
import type { Dispatcher, DispatcherOptions } from "./types";
const tool = toolFactory<Dispatcher>();
export const manifest = defineManifest<DispatcherOptions, Dispatcher>()({
contract: 2,
identity: {
category: "messaging",
name: "@absolutejs/dispatch",
tagline: "Send email, texts, and push notifications from your site.",
},
settings: Type.Object({
defaultFrom: Type.Optional(
Type.Object(
{ email: Type.Optional(Type.String({ format: "email" })) },
{ title: "Default sender" },
),
),
}),
slots: {
email: {
configPath: "email",
contract: "dispatch/email-adapter",
description: "Email transport",
known: ["@absolutejs/dispatch-resend", "@absolutejs/dispatch-postmark"],
},
},
tools: {
send_email: tool.runtime({
annotations: { openWorldHint: true },
authorization: {
approval: "policy",
audience: "owner",
destinationFields: ["to"],
effects: ["send", "external-network"],
idempotency: { mode: "host" },
requiredScopes: ["email:send"],
reversible: false,
},
description: "Send a transactional email through the configured adapter.",
handler: async (input, dispatcher) => {
const result = await dispatcher.email(input);
return `sent via ${result.provider}`;
},
input: Type.Object({
subject: Type.String(),
text: Type.String(),
to: Type.String({ format: "email" }),
}),
}),
},
wiring: [
{
id: "default",
server: {
code: "const dispatcher = createDispatcher({ email: ${slot.email}, ...${settings} });",
imports: [
{ from: "@absolutejs/dispatch", names: ["createDispatcher"] },
],
placement: "module-scope",
},
title: "Create the dispatcher",
},
],
});