refactor(server): remove unnecessary String() conversions from type-aware lint fixes (#695)
This commit is contained in:
@@ -398,7 +398,7 @@ export class MockLoadTestAgentClient implements AgentClient {
|
|||||||
const metadata = (handle.metadata ?? {}) as Partial<AgentSessionConfig>;
|
const metadata = (handle.metadata ?? {}) as Partial<AgentSessionConfig>;
|
||||||
return new MockLoadTestAgentSession({
|
return new MockLoadTestAgentSession({
|
||||||
config: {
|
config: {
|
||||||
cwd: String(metadata.cwd ?? overrides?.cwd ?? process.cwd()),
|
cwd: metadata.cwd ?? overrides?.cwd ?? process.cwd(),
|
||||||
...metadata,
|
...metadata,
|
||||||
...overrides,
|
...overrides,
|
||||||
provider: MOCK_LOAD_TEST_PROVIDER_ID,
|
provider: MOCK_LOAD_TEST_PROVIDER_ID,
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ type SessionMessage<T extends SessionOutboundMessage["type"]> = Extract<
|
|||||||
function makeTranscriptionHandler(resolve: (value: string) => void) {
|
function makeTranscriptionHandler(resolve: (value: string) => void) {
|
||||||
return (msg: SessionMessage<"transcription_result">) => {
|
return (msg: SessionMessage<"transcription_result">) => {
|
||||||
if (msg.type !== "transcription_result") return;
|
if (msg.type !== "transcription_result") return;
|
||||||
const text = String(msg.payload.text ?? "").trim();
|
const text = (msg.payload.text ?? "").trim();
|
||||||
if (!text) return;
|
if (!text) return;
|
||||||
resolve(text);
|
resolve(text);
|
||||||
};
|
};
|
||||||
@@ -27,7 +27,7 @@ function makeErrorHandler(reject: (error: Error) => void) {
|
|||||||
return (msg: SessionMessage<"activity_log">) => {
|
return (msg: SessionMessage<"activity_log">) => {
|
||||||
if (msg.type !== "activity_log") return;
|
if (msg.type !== "activity_log") return;
|
||||||
if (msg.payload.type !== "error") return;
|
if (msg.payload.type !== "error") return;
|
||||||
reject(new Error(String(msg.payload.content)));
|
reject(new Error(msg.payload.content));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ function makeSpeakToolHandler(resolve: (value: string) => void) {
|
|||||||
if (msg.payload.event.type !== "timeline") return;
|
if (msg.payload.event.type !== "timeline") return;
|
||||||
const item = msg.payload.event.item;
|
const item = msg.payload.event.item;
|
||||||
if (item.type !== "tool_call") return;
|
if (item.type !== "tool_call") return;
|
||||||
const name = String(item.name ?? "");
|
const name = item.name ?? "";
|
||||||
if (!name.toLowerCase().includes("speak")) return;
|
if (!name.toLowerCase().includes("speak")) return;
|
||||||
resolve(name);
|
resolve(name);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ function makeTranscriptionHandler(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
resolve({
|
resolve({
|
||||||
text: String(message.payload.text ?? ""),
|
text: message.payload.text ?? "",
|
||||||
isLowConfidence: Boolean(message.payload.isLowConfidence),
|
isLowConfidence: Boolean(message.payload.isLowConfidence),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -83,7 +83,7 @@ function makeActivityErrorHandler(reject: (error: Error) => void) {
|
|||||||
if (message.payload.type !== "error") {
|
if (message.payload.type !== "error") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
reject(new Error(String(message.payload.content)));
|
reject(new Error(message.payload.content));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,7 +237,7 @@ for (const targetProvider of [
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
timelineToolAgentIds.add(message.payload.agentId);
|
timelineToolAgentIds.add(message.payload.agentId);
|
||||||
timelineTools.push(String(item.name ?? ""));
|
timelineTools.push(item.name ?? "");
|
||||||
});
|
});
|
||||||
const offErrors = ctx.client.on("activity_log", (message) => {
|
const offErrors = ctx.client.on("activity_log", (message) => {
|
||||||
if (message.type !== "activity_log") {
|
if (message.type !== "activity_log") {
|
||||||
@@ -246,7 +246,7 @@ for (const targetProvider of [
|
|||||||
if (message.payload.type !== "error") {
|
if (message.payload.type !== "error") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
activityErrors.push(String(message.payload.content ?? ""));
|
activityErrors.push(message.payload.content ?? "");
|
||||||
});
|
});
|
||||||
|
|
||||||
const inputSpeech = await withTimeout(
|
const inputSpeech = await withTimeout(
|
||||||
|
|||||||
@@ -259,14 +259,14 @@ export class WorkspaceDirectory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (filter.idPrefix && filter.idPrefix.trim().length > 0) {
|
if (filter.idPrefix && filter.idPrefix.trim().length > 0) {
|
||||||
if (!String(workspace.id).startsWith(filter.idPrefix.trim())) {
|
if (!workspace.id.startsWith(filter.idPrefix.trim())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter.query && filter.query.trim().length > 0) {
|
if (filter.query && filter.query.trim().length > 0) {
|
||||||
const query = filter.query.trim().toLocaleLowerCase();
|
const query = filter.query.trim().toLocaleLowerCase();
|
||||||
const haystacks = [workspace.name, String(workspace.projectId), String(workspace.id)];
|
const haystacks = [workspace.name, workspace.projectId, workspace.id];
|
||||||
if (!haystacks.some((value) => value.toLocaleLowerCase().includes(query))) {
|
if (!haystacks.some((value) => value.toLocaleLowerCase().includes(query))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user