Skip to content

Commit 63c3f2d

Browse files
committed
chore: fmt
1 parent 8a41ab7 commit 63c3f2d

2 files changed

Lines changed: 48 additions & 131 deletions

File tree

examples/agent-deploy/lib/auth.ts

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ const capabilities: Capability[] = [
5656
},
5757
{
5858
name: "sites.get",
59-
description:
60-
"Get details of a specific deployed site including its HTML content",
59+
description: "Get details of a specific deployed site including its HTML content",
6160
input: {
6261
type: "object",
6362
properties: {
@@ -167,9 +166,7 @@ const AUTONOMOUS_CAPABILITIES = [
167166

168167
function siteUrl(slug: string): string {
169168
const base =
170-
process.env.NEXT_PUBLIC_APP_URL ||
171-
process.env.BETTER_AUTH_URL ||
172-
"http://localhost:3100";
169+
process.env.NEXT_PUBLIC_APP_URL || process.env.BETTER_AUTH_URL || "http://localhost:3100";
173170
return `${base}/sites/${slug}`;
174171
}
175172

@@ -190,9 +187,7 @@ export const auth = betterAuth({
190187
"A deployment platform for HTML sites. AI agents can create, update, and manage static HTML deployments through capability-based authentication.",
191188
capabilities,
192189
defaultHostCapabilities: ({ mode }) =>
193-
mode === "autonomous"
194-
? AUTONOMOUS_CAPABILITIES
195-
: READ_ONLY_CAPABILITIES,
190+
mode === "autonomous" ? AUTONOMOUS_CAPABILITIES : READ_ONLY_CAPABILITIES,
196191
modes: ["delegated", "autonomous"],
197192
approvalMethods: ["ciba", "device_authorization"],
198193
resolveApprovalMethod: ({ preferredMethod, supportedMethods }) => {
@@ -209,10 +204,7 @@ export const auth = betterAuth({
209204
const autonomousUserId = `autonomous_${hostId}`;
210205
const sites = await listSites(autonomousUserId);
211206
for (const s of sites) {
212-
await db
213-
.update(schema.site)
214-
.set({ userId })
215-
.where(eq(schema.site.id, s.id));
207+
await db.update(schema.site).set({ userId }).where(eq(schema.site.id, s.id));
216208
}
217209
},
218210
onExecute: async ({ capability, arguments: args, agentSession }) => {
@@ -221,9 +213,7 @@ export const auth = betterAuth({
221213
switch (capability) {
222214
case "sites.list": {
223215
const sites = await listSites(userId);
224-
const limited = args?.limit
225-
? sites.slice(0, Number(args.limit))
226-
: sites;
216+
const limited = args?.limit ? sites.slice(0, Number(args.limit)) : sites;
227217
return {
228218
sites: limited.map((s) => ({
229219
id: s.id,
@@ -262,9 +252,7 @@ export const auth = betterAuth({
262252
}
263253
const html = String(args.html);
264254
if (html.length > MAX_HTML_SIZE) {
265-
throw new Error(
266-
`HTML content exceeds ${MAX_HTML_SIZE / 1024 / 1024} MB limit`,
267-
);
255+
throw new Error(`HTML content exceeds ${MAX_HTML_SIZE / 1024 / 1024} MB limit`);
268256
}
269257
const site = await createSite({
270258
name: String(args.name).slice(0, MAX_NAME_LENGTH),
@@ -287,23 +275,18 @@ export const auth = betterAuth({
287275
if (!args?.id) throw new Error("Missing required argument: id");
288276
const updateHtml = args.html ? String(args.html) : undefined;
289277
if (updateHtml && updateHtml.length > MAX_HTML_SIZE) {
290-
throw new Error(
291-
`HTML content exceeds ${MAX_HTML_SIZE / 1024 / 1024} MB limit`,
292-
);
278+
throw new Error(`HTML content exceeds ${MAX_HTML_SIZE / 1024 / 1024} MB limit`);
293279
}
294280
const updated = await updateSite({
295281
id: String(args.id),
296282
userId,
297-
name: args.name
298-
? String(args.name).slice(0, MAX_NAME_LENGTH)
299-
: undefined,
283+
name: args.name ? String(args.name).slice(0, MAX_NAME_LENGTH) : undefined,
300284
html: updateHtml,
301285
description: args.description
302286
? String(args.description).slice(0, MAX_DESC_LENGTH)
303287
: undefined,
304288
});
305-
if (!updated)
306-
throw new Error("Site not found or not owned by user");
289+
if (!updated) throw new Error("Site not found or not owned by user");
307290
return {
308291
id: updated.id,
309292
name: updated.name,
@@ -316,8 +299,7 @@ export const auth = betterAuth({
316299
case "sites.delete": {
317300
if (!args?.id) throw new Error("Missing required argument: id");
318301
const success = await deleteSite(String(args.id), userId);
319-
if (!success)
320-
throw new Error("Site not found or not owned by user");
302+
if (!success) throw new Error("Site not found or not owned by user");
321303
return { success: true, deletedId: String(args.id) };
322304
}
323305

0 commit comments

Comments
 (0)