Monorepo for Aesthetic.Computer
aesthetic.computer
1// Tool: publish_clock
2// Publish a clock melody to aesthetic.computer
3
4export const publishClockTool = {
5 name: "publish_clock",
6 description: "Publish a clock melody to aesthetic.computer. Returns a pronounceable short code.",
7 inputSchema: {
8 type: "object" as const,
9 properties: {
10 source: {
11 type: "string",
12 description: "Clock melody string (e.g., 'c4 e4 g4 c5'). Max 10,000 characters.",
13 },
14 },
15 required: ["source"],
16 },
17};
18
19export async function publishClock(args: { source: string }, token?: string) {
20 const headers: Record<string, string> = {
21 "Content-Type": "application/json",
22 };
23
24 if (token) {
25 headers["Authorization"] = `Bearer ${token}`;
26 }
27
28 const response = await fetch("https://aesthetic.computer/api/store-clock", {
29 method: "POST",
30 headers,
31 body: JSON.stringify({
32 source: args.source,
33 }),
34 });
35
36 if (!response.ok) {
37 const error: any = await response.json().catch(() => ({ error: response.statusText }));
38 throw new Error(`Failed to publish clock: ${error.error || response.statusText}`);
39 }
40
41 const result: any = await response.json();
42 return {
43 code: result.code,
44 url: `https://aesthetic.computer/clock~${result.code}`,
45 cached: result.cached,
46 };
47}