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 const lastAssistant = messagesSnapshot
.slice() .slice()
.toReversed() .toReversed()
.find((m) => (m as AgentMessage)?.role === "assistant") as AssistantMessage | undefined; .find((m) => m?.role === "assistant") as AssistantMessage | undefined;
const toolMetasNormalized = toolMetas const toolMetasNormalized = toolMetas
.filter( .filter(

View File

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

View File

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

View File

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

View File

@@ -634,7 +634,7 @@ export async function runNodeHost(opts: NodeHostRunOptions): Promise<void> {
}); });
const skillBins = new SkillBinsCache(async () => { 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)) : []; const bins = Array.isArray(res?.bins) ? res.bins.map((bin) => String(bin)) : [];
return bins; return bins;
}); });