mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 11:15:00 +00:00
chore: Fix TypeScript errors 2/n.
This commit is contained in:
@@ -2,7 +2,7 @@ import fs from "node:fs/promises";
|
|||||||
import os from "node:os";
|
import os from "node:os";
|
||||||
|
|
||||||
import type { AgentMessage } from "@mariozechner/pi-agent-core";
|
import type { AgentMessage } from "@mariozechner/pi-agent-core";
|
||||||
import type { AssistantMessage, ImageContent } from "@mariozechner/pi-ai";
|
import type { ImageContent } from "@mariozechner/pi-ai";
|
||||||
import { streamSimple } from "@mariozechner/pi-ai";
|
import { streamSimple } from "@mariozechner/pi-ai";
|
||||||
import {
|
import {
|
||||||
createAgentSession,
|
createAgentSession,
|
||||||
@@ -869,7 +869,7 @@ export async function runEmbeddedAttempt(
|
|||||||
const lastAssistant = messagesSnapshot
|
const lastAssistant = messagesSnapshot
|
||||||
.slice()
|
.slice()
|
||||||
.toReversed()
|
.toReversed()
|
||||||
.find((m) => m?.role === "assistant") as AssistantMessage | undefined;
|
.find((m) => m?.role === "assistant");
|
||||||
|
|
||||||
const toolMetasNormalized = toolMetas
|
const toolMetasNormalized = toolMetas
|
||||||
.filter(
|
.filter(
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/ind
|
|||||||
import { callGateway } from "../../gateway/call.js";
|
import { callGateway } from "../../gateway/call.js";
|
||||||
import type { AnnounceTarget } from "./sessions-send-helpers.js";
|
import type { AnnounceTarget } from "./sessions-send-helpers.js";
|
||||||
import { resolveAnnounceTargetFromKey } from "./sessions-send-helpers.js";
|
import { resolveAnnounceTargetFromKey } from "./sessions-send-helpers.js";
|
||||||
|
import { SessionListRow } from "./sessions-helpers.js";
|
||||||
|
|
||||||
export async function resolveAnnounceTarget(params: {
|
export async function resolveAnnounceTarget(params: {
|
||||||
sessionKey: string;
|
sessionKey: string;
|
||||||
@@ -20,7 +21,7 @@ export async function resolveAnnounceTarget(params: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const list = await callGateway({
|
const list = await callGateway<{ sessions: Array<SessionListRow> }>({
|
||||||
method: "sessions.list",
|
method: "sessions.list",
|
||||||
params: {
|
params: {
|
||||||
includeGlobal: true,
|
includeGlobal: true,
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ async function resolveSessionKeyFromSessionId(params: {
|
|||||||
}): Promise<SessionReferenceResolution> {
|
}): Promise<SessionReferenceResolution> {
|
||||||
try {
|
try {
|
||||||
// Resolve via gateway so we respect store routing and visibility rules.
|
// Resolve via gateway so we respect store routing and visibility rules.
|
||||||
const result = await callGateway({
|
const result = await callGateway<{ key?: string }>({
|
||||||
method: "sessions.resolve",
|
method: "sessions.resolve",
|
||||||
params: {
|
params: {
|
||||||
sessionId: params.sessionId,
|
sessionId: params.sessionId,
|
||||||
@@ -220,7 +220,7 @@ async function resolveSessionKeyFromKey(params: {
|
|||||||
}): Promise<SessionReferenceResolution | null> {
|
}): Promise<SessionReferenceResolution | null> {
|
||||||
try {
|
try {
|
||||||
// Try key-based resolution first so non-standard keys keep working.
|
// Try key-based resolution first so non-standard keys keep working.
|
||||||
const result = await callGateway({
|
const result = await callGateway<{ key?: string }>({
|
||||||
method: "sessions.resolve",
|
method: "sessions.resolve",
|
||||||
params: {
|
params: {
|
||||||
key: params.key,
|
key: params.key,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
resolveSessionReference,
|
resolveSessionReference,
|
||||||
resolveMainSessionAlias,
|
resolveMainSessionAlias,
|
||||||
resolveInternalSessionKey,
|
resolveInternalSessionKey,
|
||||||
|
SessionListRow,
|
||||||
stripToolMessages,
|
stripToolMessages,
|
||||||
} from "./sessions-helpers.js";
|
} from "./sessions-helpers.js";
|
||||||
|
|
||||||
@@ -28,7 +29,7 @@ async function isSpawnedSessionAllowed(params: {
|
|||||||
targetSessionKey: string;
|
targetSessionKey: string;
|
||||||
}): Promise<boolean> {
|
}): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
const list = await callGateway({
|
const list = await callGateway<{ sessions: Array<SessionListRow> }>({
|
||||||
method: "sessions.list",
|
method: "sessions.list",
|
||||||
params: {
|
params: {
|
||||||
includeGlobal: false,
|
includeGlobal: false,
|
||||||
@@ -126,7 +127,7 @@ export function createSessionsHistoryTool(opts?: {
|
|||||||
? Math.max(1, Math.floor(params.limit))
|
? Math.max(1, Math.floor(params.limit))
|
||||||
: undefined;
|
: undefined;
|
||||||
const includeTools = Boolean(params.includeTools);
|
const includeTools = Boolean(params.includeTools);
|
||||||
const result = await callGateway({
|
const result = await callGateway<{ messages: Array<unknown> }>({
|
||||||
method: "chat.history",
|
method: "chat.history",
|
||||||
params: { sessionKey: resolvedKey, limit },
|
params: { sessionKey: resolvedKey, limit },
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ export function createSessionsListTool(opts?: {
|
|||||||
: 0;
|
: 0;
|
||||||
const messageLimit = Math.min(messageLimitRaw, 20);
|
const messageLimit = Math.min(messageLimitRaw, 20);
|
||||||
|
|
||||||
const list = await callGateway({
|
const list = await callGateway<{ sessions: Array<SessionListRow>; path: string }>({
|
||||||
method: "sessions.list",
|
method: "sessions.list",
|
||||||
params: {
|
params: {
|
||||||
limit,
|
limit,
|
||||||
@@ -196,7 +196,7 @@ export function createSessionsListTool(opts?: {
|
|||||||
alias,
|
alias,
|
||||||
mainKey,
|
mainKey,
|
||||||
});
|
});
|
||||||
const history = await callGateway({
|
const history = await callGateway<{ messages: Array<unknown> }>({
|
||||||
method: "chat.history",
|
method: "chat.history",
|
||||||
params: { sessionKey: resolvedKey, limit: messageLimit },
|
params: { sessionKey: resolvedKey, limit: messageLimit },
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export async function runSessionsSendA2AFlow(params: {
|
|||||||
let latestReply = params.roundOneReply;
|
let latestReply = params.roundOneReply;
|
||||||
if (!primaryReply && params.waitRunId) {
|
if (!primaryReply && params.waitRunId) {
|
||||||
const waitMs = Math.min(params.announceTimeoutMs, 60_000);
|
const waitMs = Math.min(params.announceTimeoutMs, 60_000);
|
||||||
const wait = await callGateway({
|
const wait = await callGateway<{ status: string }>({
|
||||||
method: "agent.wait",
|
method: "agent.wait",
|
||||||
params: {
|
params: {
|
||||||
runId: params.waitRunId,
|
runId: params.waitRunId,
|
||||||
|
|||||||
@@ -338,7 +338,7 @@ export const handleSubagentsCommand: CommandHandler = async (params, allowTextCo
|
|||||||
reply: { text: `⚠️ ${resolved.error ?? "Unknown subagent."}` },
|
reply: { text: `⚠️ ${resolved.error ?? "Unknown subagent."}` },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const history = await callGateway({
|
const history = await callGateway<{ messages: Array<unknown> }>({
|
||||||
method: "chat.history",
|
method: "chat.history",
|
||||||
params: { sessionKey: resolved.entry.childSessionKey, limit },
|
params: { sessionKey: resolved.entry.childSessionKey, limit },
|
||||||
});
|
});
|
||||||
@@ -371,7 +371,7 @@ export const handleSubagentsCommand: CommandHandler = async (params, allowTextCo
|
|||||||
const idempotencyKey = crypto.randomUUID();
|
const idempotencyKey = crypto.randomUUID();
|
||||||
let runId: string = idempotencyKey;
|
let runId: string = idempotencyKey;
|
||||||
try {
|
try {
|
||||||
const response = await callGateway({
|
const response = await callGateway<{ runId: string }>({
|
||||||
method: "agent",
|
method: "agent",
|
||||||
params: {
|
params: {
|
||||||
message,
|
message,
|
||||||
@@ -393,7 +393,7 @@ export const handleSubagentsCommand: CommandHandler = async (params, allowTextCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
const waitMs = 30_000;
|
const waitMs = 30_000;
|
||||||
const wait = await callGateway({
|
const wait = await callGateway<{ status?: string; error?: string }>({
|
||||||
method: "agent.wait",
|
method: "agent.wait",
|
||||||
params: { runId, timeoutMs: waitMs },
|
params: { runId, timeoutMs: waitMs },
|
||||||
timeoutMs: waitMs + 2000,
|
timeoutMs: waitMs + 2000,
|
||||||
@@ -413,7 +413,7 @@ export const handleSubagentsCommand: CommandHandler = async (params, allowTextCo
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const history = await callGateway({
|
const history = await callGateway<{ messages: Array<unknown> }>({
|
||||||
method: "chat.history",
|
method: "chat.history",
|
||||||
params: { sessionKey: resolved.entry.childSessionKey, limit: 50 },
|
params: { sessionKey: resolved.entry.childSessionKey, limit: 50 },
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { normalizeGatewayTokenInput, randomToken } from "../commands/onboard-helpers.js";
|
import { normalizeGatewayTokenInput, randomToken } from "../commands/onboard-helpers.js";
|
||||||
import type { GatewayAuthChoice } from "../commands/onboard-types.js";
|
import type { GatewayAuthChoice } from "../commands/onboard-types.js";
|
||||||
import type { OpenClawConfig } from "../config/config.js";
|
import type { GatewayBindMode, GatewayTailscaleMode, OpenClawConfig } from "../config/config.js";
|
||||||
import { findTailscaleBinary } from "../infra/tailscale.js";
|
import { findTailscaleBinary } from "../infra/tailscale.js";
|
||||||
import type { RuntimeEnv } from "../runtime.js";
|
import type { RuntimeEnv } from "../runtime.js";
|
||||||
import type {
|
import type {
|
||||||
@@ -226,11 +226,11 @@ export async function configureGatewayForOnboarding(
|
|||||||
gateway: {
|
gateway: {
|
||||||
...nextConfig.gateway,
|
...nextConfig.gateway,
|
||||||
port,
|
port,
|
||||||
bind,
|
bind: bind as GatewayBindMode,
|
||||||
...(bind === "custom" && customBindHost ? { customBindHost } : {}),
|
...(bind === "custom" && customBindHost ? { customBindHost } : {}),
|
||||||
tailscale: {
|
tailscale: {
|
||||||
...nextConfig.gateway?.tailscale,
|
...nextConfig.gateway?.tailscale,
|
||||||
mode: tailscaleMode,
|
mode: tailscaleMode as GatewayTailscaleMode,
|
||||||
resetOnExit: tailscaleResetOnExit,
|
resetOnExit: tailscaleResetOnExit,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -240,11 +240,11 @@ export async function configureGatewayForOnboarding(
|
|||||||
nextConfig,
|
nextConfig,
|
||||||
settings: {
|
settings: {
|
||||||
port,
|
port,
|
||||||
bind,
|
bind: bind as GatewayBindMode,
|
||||||
customBindHost: bind === "custom" ? customBindHost : undefined,
|
customBindHost: bind === "custom" ? customBindHost : undefined,
|
||||||
authMode,
|
authMode,
|
||||||
gatewayToken,
|
gatewayToken,
|
||||||
tailscaleMode,
|
tailscaleMode: tailscaleMode as GatewayTailscaleMode,
|
||||||
tailscaleResetOnExit,
|
tailscaleResetOnExit,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user