Add a TypeScript tool
Let an agent propose a Statuspage incident, then approve it before your app posts it.
You need a running Wardrik daemon, Node 22.18+, and a Statuspage page ID and API key.
1. Start an app
Section titled “1. Start an app”mkdir statuspage && cd statuspagenpm init -y && npm pkg set type=module2. Write the tool
Section titled “2. Write the tool”import { Wardrik } from "@wardrik/sdk";import { z } from "zod";
const page = process.env.STATUSPAGE_PAGE_ID;const key = process.env.STATUSPAGE_API_KEY;
const wardrik = new Wardrik({ name: "statuspage" });
wardrik.tool({ name: "post_status", description: "Open an incident on the public status page, with its first update.", input: z.object({ name: z.string().describe("The incident's title, as customers see it"), status: z.enum(["investigating", "identified", "monitoring", "resolved"]), body: z.string().describe("The first update, in plain words"), }), run: async (incident, { signal }) => { const response = await fetch(`https://api.statuspage.io/v1/pages/${page}/incidents`, { method: "POST", headers: { authorization: `OAuth ${key}`, "content-type": "application/json" }, body: JSON.stringify({ incident }), signal, }); if (!response.ok) throw new Error(`Statuspage returned HTTP ${response.status}`);
const { id, shortlink } = await response.json(); return { id, shortlink }; },});
const stop = new AbortController();process.on("SIGTERM", () => stop.abort());process.on("SIGINT", () => stop.abort());
await wardrik.work({ signal: stop.signal });- It isn't
readOnly, so every call needs approval unless a policy allows it. - A thrown error fails the call. The model receives the error message.
3. Connect the tool worker
Section titled “3. Connect the tool worker”Allow the user default/@statuspage to serve tools to the org's agents:
roles: tools: {rules: [{verbs: [serve], kinds: [agent]}]}bindings: - {org: default, role: tools, subjects: [user:default/@statuspage]}systemctl --user restart wardrikwardrik token create statuspage --subject user:default/@statuspageexport STATUSPAGE_PAGE_ID=... STATUSPAGE_API_KEY=...WARDRIK_TOKEN=wdk_... node statuspage.tsThis example uses the default organization, default. The app needs no inbound port, and
the Statuspage key stays in the app.
4. Enable the tool for an agent
Section titled “4. Enable the tool for an agent”---description: Posts to the public status page when asked.tools: [workers/*]policy: ask: workers/post_status: This posts publicly on the status page.---You post incidents on the public status page. Write for customers, in plain words.5. Request and approve a post
Section titled “5. Request and approve a post”wardrik reloadwardrik ask status "Checkout is failing for some customers. Post that we're investigating."wardrik approval lsAGENT CALL TOOL WHYstatus call_7c2e… workers__post_status This posts publicly on the status page.wardrik approval approve status call_7c2e…wardrik approval deny status call_7c2e… --reason "We don't post until it's confirmed."After approval, your app posts the incident and the agent returns its link. The call ID above is illustrative; use the ID from your pending call.
6. Run the tool worker as a service
Section titled “6. Run the tool worker as a service”[Unit]Description=Status page tools for WardrikAfter=wardrik.service
[Service]WorkingDirectory=%h/statuspageEnvironmentFile=%h/.config/statuspage.envExecStart=/usr/bin/node statuspage.tsRestart=on-failure
[Install]WantedBy=default.targetchmod 600 ~/.config/statuspage.env # WARDRIK_TOKEN and the Statuspage keyssystemctl --user daemon-reloadsystemctl --user enable --now statuspageFor other machines or containers, see Host your tools.