Skip to content

Commit cdadbdc

Browse files
author
Shaw
committed
chore: format integration routes
1 parent 4f6bd53 commit cdadbdc

6 files changed

Lines changed: 95 additions & 33 deletions

File tree

packages/cloud-api/compat/agents/[id]/logs/route.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { Hono } from "hono";
2-
import type { RouteContext } from "@/lib/api/hono-next-style-params";
32
/**
43
* GET /api/compat/agents/[id]/logs — container logs for thin clients
54
*
65
* Fetches logs from the bridge URL if the agent is running,
76
* or returns a descriptive status message otherwise.
87
*/
98
import { envelope, errorEnvelope } from "@/lib/api/compat-envelope";
9+
import type { RouteContext } from "@/lib/api/hono-next-style-params";
1010
import { assertSafeOutboundUrl } from "@/lib/security/outbound-url";
1111
import { elizaSandboxService } from "@/lib/services/eliza-sandbox";
1212
import { logger } from "@/lib/utils/logger";
@@ -17,12 +17,18 @@ import { handleCompatError } from "../../../_lib/error-handler";
1717

1818
const CORS_METHODS = "GET, OPTIONS";
1919

20-
async function __hono_GET(request: Request, { params }: RouteContext<{ id: string }>) {
20+
async function __hono_GET(
21+
request: Request,
22+
{ params }: RouteContext<{ id: string }>,
23+
) {
2124
try {
2225
const { user } = await requireCompatAuth(request);
2326
const { id: agentId } = await params;
2427

25-
const agent = await elizaSandboxService.getAgent(agentId, user.organization_id);
28+
const agent = await elizaSandboxService.getAgent(
29+
agentId,
30+
user.organization_id,
31+
);
2632
if (!agent) {
2733
return withCompatCors(
2834
Response.json(errorEnvelope("Agent not found"), { status: 404 }),
@@ -32,7 +38,10 @@ async function __hono_GET(request: Request, { params }: RouteContext<{ id: strin
3238

3339
const url = new URL(request.url);
3440
const rawTail = parseInt(url.searchParams.get("tail") ?? "100", 10);
35-
const tail = Math.max(1, Math.min(Number.isFinite(rawTail) ? rawTail : 100, 5000));
41+
const tail = Math.max(
42+
1,
43+
Math.min(Number.isFinite(rawTail) ? rawTail : 100, 5000),
44+
);
3645

3746
// Try bridge logs if agent is running
3847
if (agent.bridge_url && agent.status === "running") {
@@ -50,7 +59,8 @@ async function __hono_GET(request: Request, { params }: RouteContext<{ id: strin
5059
} catch (fetchErr) {
5160
logger.warn("[compat] Failed to fetch logs from bridge", {
5261
agentId,
53-
error: fetchErr instanceof Error ? fetchErr.message : String(fetchErr),
62+
error:
63+
fetchErr instanceof Error ? fetchErr.message : String(fetchErr),
5464
});
5565
}
5666
}
@@ -66,7 +76,9 @@ async function __hono_GET(request: Request, { params }: RouteContext<{ id: strin
6676
};
6777

6878
return withCompatCors(
69-
Response.json(envelope(statusMsg[agent.status] ?? `Agent status: ${agent.status}`)),
79+
Response.json(
80+
envelope(statusMsg[agent.status] ?? `Agent status: ${agent.status}`),
81+
),
7082
CORS_METHODS,
7183
);
7284
} catch (err) {
@@ -77,6 +89,8 @@ async function __hono_GET(request: Request, { params }: RouteContext<{ id: strin
7789
const __hono_app = new Hono<AppEnv>();
7890
__hono_app.options("/", () => handleCompatCorsOptions(CORS_METHODS));
7991
__hono_app.get("/", async (c) =>
80-
__hono_GET(c.req.raw, { params: Promise.resolve({ id: c.req.param("id")! }) }),
92+
__hono_GET(c.req.raw, {
93+
params: Promise.resolve({ id: c.req.param("id")! }),
94+
}),
8195
);
8296
export default __hono_app;

packages/cloud-api/v1/agents/[agentId]/logs/route.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,37 @@ app.get("/", async (c) => {
2222
try {
2323
const identity = await requireServiceKey(c);
2424
const agentId = c.req.param("agentId") ?? "";
25-
const agent = await elizaSandboxService.getAgent(agentId, identity.organizationId);
25+
const agent = await elizaSandboxService.getAgent(
26+
agentId,
27+
identity.organizationId,
28+
);
2629

2730
if (!agent) {
2831
return c.json({ error: "Agent not found" }, 404);
2932
}
3033

3134
const rawTail = parseInt(c.req.query("tail") ?? "100", 10);
32-
const tail = Math.max(1, Math.min(Number.isFinite(rawTail) ? rawTail : 100, 5000));
35+
const tail = Math.max(
36+
1,
37+
Math.min(Number.isFinite(rawTail) ? rawTail : 100, 5000),
38+
);
3339

3440
if (agent.bridge_url && agent.status === "running") {
3541
try {
3642
const logsUrl = `${agent.bridge_url}/logs?tail=${tail}`;
3743
await assertSafeOutboundUrl(logsUrl);
38-
const res = await fetch(logsUrl, { signal: AbortSignal.timeout(10_000) });
44+
const res = await fetch(logsUrl, {
45+
signal: AbortSignal.timeout(10_000),
46+
});
3947
if (res.ok) {
4048
const logs = await res.text();
4149
return c.json({ logs, status: agent.status });
4250
}
4351
} catch (fetchErr) {
4452
logger.warn("[service-api] Failed to fetch logs from bridge", {
4553
agentId,
46-
error: fetchErr instanceof Error ? fetchErr.message : String(fetchErr),
54+
error:
55+
fetchErr instanceof Error ? fetchErr.message : String(fetchErr),
4756
});
4857
}
4958
}

packages/cloud-api/v1/containers/[id]/logs/route.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77
*/
88

99
import { Hono } from "hono";
10-
11-
import { forwardToContainerControlPlane } from "../../../_container-control-plane-forward";
1210
import { failureResponse } from "@/lib/api/cloud-worker-errors";
1311
import { requireUserOrApiKeyWithOrg } from "@/lib/auth/workers-hono-auth";
1412
import { logger } from "@/lib/utils/logger";
1513
import type { AppEnv } from "@/types/cloud-worker-env";
14+
import { forwardToContainerControlPlane } from "../../../_container-control-plane-forward";
1615

1716
const app = new Hono<AppEnv>();
1817

packages/cloud-api/v1/containers/[id]/logs/stream/route.ts

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,28 @@ import { logger } from "@/lib/utils/logger";
3434

3535
const HEARTBEAT_INTERVAL_MS = 25_000;
3636

37-
async function __hono_GET(request: Request, { params }: { params: Promise<{ id: string }> }) {
37+
async function __hono_GET(
38+
request: Request,
39+
{ params }: { params: Promise<{ id: string }> },
40+
) {
3841
let user: { organization_id: string | null };
3942
try {
4043
({ user } = await requireAuthOrApiKeyWithOrg(request));
4144
} catch (err) {
4245
return Response.json(
43-
{ success: false, error: err instanceof Error ? err.message : "Unauthorized" },
46+
{
47+
success: false,
48+
error: err instanceof Error ? err.message : "Unauthorized",
49+
},
4450
{ status: 401 },
4551
);
4652
}
4753
if (!user.organization_id) {
4854
return Response.json(
49-
{ success: false, error: "Caller is not associated with an organization" },
55+
{
56+
success: false,
57+
error: "Caller is not associated with an organization",
58+
},
5059
{ status: 403 },
5160
);
5261
}
@@ -68,15 +77,21 @@ async function __hono_GET(request: Request, { params }: { params: Promise<{ id:
6877
if (request.signal.aborted) {
6978
ac.abort();
7079
} else {
71-
request.signal.addEventListener("abort", () => ac.abort(), { once: true });
80+
request.signal.addEventListener("abort", () => ac.abort(), {
81+
once: true,
82+
});
7283
}
7384
}
7485

7586
const stream = new ReadableStream<Uint8Array>({
7687
async start(controller) {
7788
const send = (event: string, data: unknown) => {
7889
try {
79-
controller.enqueue(encoder.encode(`event: ${event}\ndata: ${JSON.stringify(data)}\n\n`));
90+
controller.enqueue(
91+
encoder.encode(
92+
`event: ${event}\ndata: ${JSON.stringify(data)}\n\n`,
93+
),
94+
);
8095
} catch {
8196
// Controller already closed — ignore.
8297
}
@@ -91,15 +106,22 @@ async function __hono_GET(request: Request, { params }: { params: Promise<{ id:
91106

92107
send("open", { containerId, tailLines });
93108

94-
const heartbeat = setInterval(() => sendComment("keep-alive"), HEARTBEAT_INTERVAL_MS);
109+
const heartbeat = setInterval(
110+
() => sendComment("keep-alive"),
111+
HEARTBEAT_INTERVAL_MS,
112+
);
95113

96114
try {
97-
await getHetznerContainersClient().streamLogs(containerId, user.organization_id!, {
98-
tailLines,
99-
signal: ac.signal,
100-
onStdout: (chunk) => send("log", { chunk, stream: "stdout" }),
101-
onStderr: (chunk) => send("log", { chunk, stream: "stderr" }),
102-
});
115+
await getHetznerContainersClient().streamLogs(
116+
containerId,
117+
user.organization_id!,
118+
{
119+
tailLines,
120+
signal: ac.signal,
121+
onStdout: (chunk) => send("log", { chunk, stream: "stdout" }),
122+
onStderr: (chunk) => send("log", { chunk, stream: "stderr" }),
123+
},
124+
);
103125
send("close", { reason: "remote_exit" });
104126
} catch (err) {
105127
if (err instanceof HetznerClientError) {
@@ -141,6 +163,8 @@ async function __hono_GET(request: Request, { params }: { params: Promise<{ id:
141163

142164
const __hono_app = new Hono<AppEnv>();
143165
__hono_app.get("/", async (c) =>
144-
__hono_GET(c.req.raw, { params: Promise.resolve({ id: c.req.param("id")! }) }),
166+
__hono_GET(c.req.raw, {
167+
params: Promise.resolve({ id: c.req.param("id")! }),
168+
}),
145169
);
146170
export default __hono_app;

packages/cloud-api/v1/reports/bug/route.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
import { Hono } from "hono";
88
import { z } from "zod";
99
import { failureResponse } from "@/lib/api/cloud-worker-errors";
10-
import { RateLimitPresets, rateLimit } from "@/lib/middleware/rate-limit-hono-cloudflare";
10+
import {
11+
RateLimitPresets,
12+
rateLimit,
13+
} from "@/lib/middleware/rate-limit-hono-cloudflare";
1114
import { emailService } from "@/lib/services/email";
1215
import { logger } from "@/lib/utils/logger";
1316
import type { AppEnv } from "@/types/cloud-worker-env";
@@ -67,8 +70,12 @@ app.post("/", async (c) => {
6770

6871
const reportId = `rpt_${crypto.randomUUID()}`;
6972
const receivedAt = new Date().toISOString();
70-
const env = c.env as { BUG_REPORT_EMAIL_TO?: string; SUPPORT_EMAIL?: string };
71-
const recipient = env.BUG_REPORT_EMAIL_TO ?? env.SUPPORT_EMAIL ?? "developer@elizalabs.ai";
73+
const env = c.env as {
74+
BUG_REPORT_EMAIL_TO?: string;
75+
SUPPORT_EMAIL?: string;
76+
};
77+
const recipient =
78+
env.BUG_REPORT_EMAIL_TO ?? env.SUPPORT_EMAIL ?? "developer@elizalabs.ai";
7279

7380
const startupSummary = validated.startup
7481
? JSON.stringify(validated.startup, null, 2)
@@ -120,8 +127,12 @@ app.post("/", async (c) => {
120127
"",
121128
"Steps to Reproduce:",
122129
validated.stepsToReproduce,
123-
validated.expectedBehavior ? `\nExpected Behavior:\n${validated.expectedBehavior}` : "",
124-
validated.actualBehavior ? `\nActual Behavior:\n${validated.actualBehavior}` : "",
130+
validated.expectedBehavior
131+
? `\nExpected Behavior:\n${validated.expectedBehavior}`
132+
: "",
133+
validated.actualBehavior
134+
? `\nActual Behavior:\n${validated.actualBehavior}`
135+
: "",
125136
startupSummary ? `\nStartup Context:\n${startupSummary}` : "",
126137
validated.logs ? `\nLogs:\n${validated.logs}` : "",
127138
]
@@ -141,7 +152,10 @@ app.post("/", async (c) => {
141152
source: validated.source,
142153
category: validated.category,
143154
});
144-
return c.json({ accepted: false, error: "Email service unavailable" }, 503);
155+
return c.json(
156+
{ accepted: false, error: "Email service unavailable" },
157+
503,
158+
);
145159
}
146160

147161
logger.info("[BugReport] Structured bug report accepted", {

plugins/plugin-local-inference/src/services/dflash-catalog-disable.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ describe("DflashLlamaServer catalog disable reason", () => {
175175
});
176176

177177
it("omits drafter startup flags when launched target-only", async () => {
178-
const root = fs.mkdtempSync(path.join(os.tmpdir(), "eliza-dflash-disable-"));
178+
const root = fs.mkdtempSync(
179+
path.join(os.tmpdir(), "eliza-dflash-disable-"),
180+
);
179181
const binary = path.join(root, "llama-server");
180182
const argsFile = path.join(root, "args.txt");
181183
fs.writeFileSync(

0 commit comments

Comments
 (0)