chore: migrate to oxlint and oxfmt
Co-authored-by: Christoph Nakazawa <christoph.pojer@gmail.com>
This commit is contained in:
@@ -99,26 +99,19 @@ export function createNodesTool(): AnyAgentTool {
|
||||
const gatewayOpts: GatewayCallOptions = {
|
||||
gatewayUrl: readStringParam(params, "gatewayUrl", { trim: false }),
|
||||
gatewayToken: readStringParam(params, "gatewayToken", { trim: false }),
|
||||
timeoutMs:
|
||||
typeof params.timeoutMs === "number" ? params.timeoutMs : undefined,
|
||||
timeoutMs: typeof params.timeoutMs === "number" ? params.timeoutMs : undefined,
|
||||
};
|
||||
|
||||
switch (action) {
|
||||
case "status":
|
||||
return jsonResult(
|
||||
await callGatewayTool("node.list", gatewayOpts, {}),
|
||||
);
|
||||
return jsonResult(await callGatewayTool("node.list", gatewayOpts, {}));
|
||||
case "describe": {
|
||||
const node = readStringParam(params, "node", { required: true });
|
||||
const nodeId = await resolveNodeId(gatewayOpts, node);
|
||||
return jsonResult(
|
||||
await callGatewayTool("node.describe", gatewayOpts, { nodeId }),
|
||||
);
|
||||
return jsonResult(await callGatewayTool("node.describe", gatewayOpts, { nodeId }));
|
||||
}
|
||||
case "pending":
|
||||
return jsonResult(
|
||||
await callGatewayTool("node.pair.list", gatewayOpts, {}),
|
||||
);
|
||||
return jsonResult(await callGatewayTool("node.pair.list", gatewayOpts, {}));
|
||||
case "approve": {
|
||||
const requestId = readStringParam(params, "requestId", {
|
||||
required: true,
|
||||
@@ -153,16 +146,9 @@ export function createNodesTool(): AnyAgentTool {
|
||||
params: {
|
||||
title: title.trim() || undefined,
|
||||
body: body.trim() || undefined,
|
||||
sound:
|
||||
typeof params.sound === "string" ? params.sound : undefined,
|
||||
priority:
|
||||
typeof params.priority === "string"
|
||||
? params.priority
|
||||
: undefined,
|
||||
delivery:
|
||||
typeof params.delivery === "string"
|
||||
? params.delivery
|
||||
: undefined,
|
||||
sound: typeof params.sound === "string" ? params.sound : undefined,
|
||||
priority: typeof params.priority === "string" ? params.priority : undefined,
|
||||
delivery: typeof params.delivery === "string" ? params.delivery : undefined,
|
||||
},
|
||||
idempotencyKey: crypto.randomUUID(),
|
||||
});
|
||||
@@ -172,9 +158,7 @@ export function createNodesTool(): AnyAgentTool {
|
||||
const node = readStringParam(params, "node", { required: true });
|
||||
const nodeId = await resolveNodeId(gatewayOpts, node);
|
||||
const facingRaw =
|
||||
typeof params.facing === "string"
|
||||
? params.facing.toLowerCase()
|
||||
: "both";
|
||||
typeof params.facing === "string" ? params.facing.toLowerCase() : "both";
|
||||
const facings: CameraFacing[] =
|
||||
facingRaw === "both"
|
||||
? ["front", "back"]
|
||||
@@ -184,18 +168,15 @@ export function createNodesTool(): AnyAgentTool {
|
||||
throw new Error("invalid facing (front|back|both)");
|
||||
})();
|
||||
const maxWidth =
|
||||
typeof params.maxWidth === "number" &&
|
||||
Number.isFinite(params.maxWidth)
|
||||
typeof params.maxWidth === "number" && Number.isFinite(params.maxWidth)
|
||||
? params.maxWidth
|
||||
: undefined;
|
||||
const quality =
|
||||
typeof params.quality === "number" &&
|
||||
Number.isFinite(params.quality)
|
||||
typeof params.quality === "number" && Number.isFinite(params.quality)
|
||||
? params.quality
|
||||
: undefined;
|
||||
const delayMs =
|
||||
typeof params.delayMs === "number" &&
|
||||
Number.isFinite(params.delayMs)
|
||||
typeof params.delayMs === "number" && Number.isFinite(params.delayMs)
|
||||
? params.delayMs
|
||||
: undefined;
|
||||
const deviceId =
|
||||
@@ -227,13 +208,10 @@ export function createNodesTool(): AnyAgentTool {
|
||||
normalizedFormat !== "jpeg" &&
|
||||
normalizedFormat !== "png"
|
||||
) {
|
||||
throw new Error(
|
||||
`unsupported camera.snap format: ${payload.format}`,
|
||||
);
|
||||
throw new Error(`unsupported camera.snap format: ${payload.format}`);
|
||||
}
|
||||
|
||||
const isJpeg =
|
||||
normalizedFormat === "jpg" || normalizedFormat === "jpeg";
|
||||
const isJpeg = normalizedFormat === "jpg" || normalizedFormat === "jpeg";
|
||||
const filePath = cameraTempPath({
|
||||
kind: "snap",
|
||||
facing,
|
||||
@@ -245,8 +223,7 @@ export function createNodesTool(): AnyAgentTool {
|
||||
type: "image",
|
||||
data: payload.base64,
|
||||
mimeType:
|
||||
imageMimeFromFormat(payload.format) ??
|
||||
(isJpeg ? "image/jpeg" : "image/png"),
|
||||
imageMimeFromFormat(payload.format) ?? (isJpeg ? "image/jpeg" : "image/png"),
|
||||
});
|
||||
details.push({
|
||||
facing,
|
||||
@@ -269,32 +246,24 @@ export function createNodesTool(): AnyAgentTool {
|
||||
idempotencyKey: crypto.randomUUID(),
|
||||
})) as { payload?: unknown };
|
||||
const payload =
|
||||
raw && typeof raw.payload === "object" && raw.payload !== null
|
||||
? raw.payload
|
||||
: {};
|
||||
raw && typeof raw.payload === "object" && raw.payload !== null ? raw.payload : {};
|
||||
return jsonResult(payload);
|
||||
}
|
||||
case "camera_clip": {
|
||||
const node = readStringParam(params, "node", { required: true });
|
||||
const nodeId = await resolveNodeId(gatewayOpts, node);
|
||||
const facing =
|
||||
typeof params.facing === "string"
|
||||
? params.facing.toLowerCase()
|
||||
: "front";
|
||||
const facing = typeof params.facing === "string" ? params.facing.toLowerCase() : "front";
|
||||
if (facing !== "front" && facing !== "back") {
|
||||
throw new Error("invalid facing (front|back)");
|
||||
}
|
||||
const durationMs =
|
||||
typeof params.durationMs === "number" &&
|
||||
Number.isFinite(params.durationMs)
|
||||
typeof params.durationMs === "number" && Number.isFinite(params.durationMs)
|
||||
? params.durationMs
|
||||
: typeof params.duration === "string"
|
||||
? parseDurationMs(params.duration)
|
||||
: 3000;
|
||||
const includeAudio =
|
||||
typeof params.includeAudio === "boolean"
|
||||
? params.includeAudio
|
||||
: true;
|
||||
typeof params.includeAudio === "boolean" ? params.includeAudio : true;
|
||||
const deviceId =
|
||||
typeof params.deviceId === "string" && params.deviceId.trim()
|
||||
? params.deviceId.trim()
|
||||
@@ -332,25 +301,19 @@ export function createNodesTool(): AnyAgentTool {
|
||||
const node = readStringParam(params, "node", { required: true });
|
||||
const nodeId = await resolveNodeId(gatewayOpts, node);
|
||||
const durationMs =
|
||||
typeof params.durationMs === "number" &&
|
||||
Number.isFinite(params.durationMs)
|
||||
typeof params.durationMs === "number" && Number.isFinite(params.durationMs)
|
||||
? params.durationMs
|
||||
: typeof params.duration === "string"
|
||||
? parseDurationMs(params.duration)
|
||||
: 10_000;
|
||||
const fps =
|
||||
typeof params.fps === "number" && Number.isFinite(params.fps)
|
||||
? params.fps
|
||||
: 10;
|
||||
typeof params.fps === "number" && Number.isFinite(params.fps) ? params.fps : 10;
|
||||
const screenIndex =
|
||||
typeof params.screenIndex === "number" &&
|
||||
Number.isFinite(params.screenIndex)
|
||||
typeof params.screenIndex === "number" && Number.isFinite(params.screenIndex)
|
||||
? params.screenIndex
|
||||
: 0;
|
||||
const includeAudio =
|
||||
typeof params.includeAudio === "boolean"
|
||||
? params.includeAudio
|
||||
: true;
|
||||
typeof params.includeAudio === "boolean" ? params.includeAudio : true;
|
||||
const raw = (await callGatewayTool("node.invoke", gatewayOpts, {
|
||||
nodeId,
|
||||
command: "screen.record",
|
||||
@@ -368,10 +331,7 @@ export function createNodesTool(): AnyAgentTool {
|
||||
typeof params.outPath === "string" && params.outPath.trim()
|
||||
? params.outPath.trim()
|
||||
: screenRecordTempPath({ ext: payload.format || "mp4" });
|
||||
const written = await writeScreenRecordToFile(
|
||||
filePath,
|
||||
payload.base64,
|
||||
);
|
||||
const written = await writeScreenRecordToFile(filePath, payload.base64);
|
||||
return {
|
||||
content: [{ type: "text", text: `FILE:${written.path}` }],
|
||||
details: {
|
||||
@@ -387,8 +347,7 @@ export function createNodesTool(): AnyAgentTool {
|
||||
const node = readStringParam(params, "node", { required: true });
|
||||
const nodeId = await resolveNodeId(gatewayOpts, node);
|
||||
const maxAgeMs =
|
||||
typeof params.maxAgeMs === "number" &&
|
||||
Number.isFinite(params.maxAgeMs)
|
||||
typeof params.maxAgeMs === "number" && Number.isFinite(params.maxAgeMs)
|
||||
? params.maxAgeMs
|
||||
: undefined;
|
||||
const desiredAccuracy =
|
||||
@@ -419,23 +378,17 @@ export function createNodesTool(): AnyAgentTool {
|
||||
const nodeId = await resolveNodeId(gatewayOpts, node);
|
||||
const commandRaw = params.command;
|
||||
if (!commandRaw) {
|
||||
throw new Error(
|
||||
"command required (argv array, e.g. ['echo', 'Hello'])",
|
||||
);
|
||||
throw new Error("command required (argv array, e.g. ['echo', 'Hello'])");
|
||||
}
|
||||
if (!Array.isArray(commandRaw)) {
|
||||
throw new Error(
|
||||
"command must be an array of strings (argv), e.g. ['echo', 'Hello']",
|
||||
);
|
||||
throw new Error("command must be an array of strings (argv), e.g. ['echo', 'Hello']");
|
||||
}
|
||||
const command = commandRaw.map((c) => String(c));
|
||||
if (command.length === 0) {
|
||||
throw new Error("command must not be empty");
|
||||
}
|
||||
const cwd =
|
||||
typeof params.cwd === "string" && params.cwd.trim()
|
||||
? params.cwd.trim()
|
||||
: undefined;
|
||||
typeof params.cwd === "string" && params.cwd.trim() ? params.cwd.trim() : undefined;
|
||||
const env = parseEnvPairs(params.env);
|
||||
const commandTimeoutMs = parseTimeoutMs(params.commandTimeoutMs);
|
||||
const invokeTimeoutMs = parseTimeoutMs(params.invokeTimeoutMs);
|
||||
|
||||
Reference in New Issue
Block a user