chore: Fix TypeScript errors 1/n.

This commit is contained in:
cpojer
2026-01-31 16:38:03 +09:00
parent 2957d4306d
commit e5eb9610dc
5 changed files with 19 additions and 11 deletions

View File

@@ -869,7 +869,7 @@ export async function runEmbeddedAttempt(
const lastAssistant = messagesSnapshot
.slice()
.toReversed()
.find((m) => (m as AgentMessage)?.role === "assistant") as AssistantMessage | undefined;
.find((m) => m?.role === "assistant") as AssistantMessage | undefined;
const toolMetasNormalized = toolMetas
.filter(

View File

@@ -81,7 +81,7 @@ export function createSessionsSendTool(opts?: {
}
const listSessions = async (listParams: Record<string, unknown>) => {
const result = await callGateway({
const result = await callGateway<{ sessions: Array<{ key: string }> }>({
method: "sessions.list",
params: listParams,
timeoutMs: 10_000,
@@ -136,7 +136,7 @@ export function createSessionsSendTool(opts?: {
};
let resolvedKey = "";
try {
const resolved = await callGateway({
const resolved = await callGateway<{ key: string }>({
method: "sessions.resolve",
params: resolveParams,
timeoutMs: 10_000,
@@ -283,7 +283,7 @@ export function createSessionsSendTool(opts?: {
if (timeoutSeconds === 0) {
try {
const response = await callGateway({
const response = await callGateway<{ runId: string }>({
method: "agent",
params: sendParams,
timeoutMs: 10_000,
@@ -311,7 +311,7 @@ export function createSessionsSendTool(opts?: {
}
try {
const response = await callGateway({
const response = await callGateway<{ runId: string }>({
method: "agent",
params: sendParams,
timeoutMs: 10_000,
@@ -333,7 +333,7 @@ export function createSessionsSendTool(opts?: {
let waitStatus: string | undefined;
let waitError: string | undefined;
try {
const wait = await callGateway({
const wait = await callGateway<{ status?: string; error?: string }>({
method: "agent.wait",
params: {
runId,
@@ -371,7 +371,7 @@ export function createSessionsSendTool(opts?: {
});
}
const history = await callGateway({
const history = await callGateway<{ messages: Array<unknown> }>({
method: "chat.history",
params: { sessionKey: resolvedKey, limit: 50 },
});

View File

@@ -221,7 +221,7 @@ export function createSessionsSpawnTool(opts?: {
const childIdem = crypto.randomUUID();
let childRunId: string = childIdem;
try {
const response = await callGateway({
const response = await callGateway<{ runId: string }>({
method: "agent",
params: {
message: task,

View File

@@ -83,7 +83,11 @@ async function listGuildChannels(
fetcher: typeof fetch,
guildId: string,
): Promise<DiscordChannelSummary[]> {
const raw = await fetchDiscord(`/guilds/${guildId}/channels`, token, fetcher);
const raw = await fetchDiscord<Array<DiscordChannelSummary>>(
`/guilds/${guildId}/channels`,
token,
fetcher,
);
return raw
.filter((channel) => Boolean(channel.id) && "name" in channel)
.map((channel) => {
@@ -107,7 +111,11 @@ async function fetchChannel(
fetcher: typeof fetch,
channelId: string,
): Promise<DiscordChannelSummary | null> {
const raw = await fetchDiscord(`/channels/${channelId}`, token, fetcher);
const raw = await fetchDiscord<DiscordChannelSummary & { guild_id: string }>(
`/channels/${channelId}`,
token,
fetcher,
);
if (!raw || !("guild_id" in raw)) {
return null;
}

View File

@@ -634,7 +634,7 @@ export async function runNodeHost(opts: NodeHostRunOptions): Promise<void> {
});
const skillBins = new SkillBinsCache(async () => {
const res = await client.request("skills.bins", {});
const res = await client.request<{ bins: Array<unknown> }>("skills.bins", {});
const bins = Array.isArray(res?.bins) ? res.bins.map((bin) => String(bin)) : [];
return bins;
});