mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-29 01:52:04 +00:00
refactor(gateway): type inline tool auth helpers
This commit is contained in:
@@ -79,8 +79,7 @@ export type InlineActionResult =
|
||||
abortedLastRun: boolean;
|
||||
};
|
||||
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
function extractTextFromToolResult(result: any): string | null {
|
||||
function extractTextFromToolResult(result: unknown): string | null {
|
||||
if (!result || typeof result !== "object") {
|
||||
return null;
|
||||
}
|
||||
@@ -246,12 +245,12 @@ export async function handleInlineActions(params: {
|
||||
|
||||
const toolCallId = `cmd_${generateSecureToken(8)}`;
|
||||
try {
|
||||
const result = await tool.execute(toolCallId, {
|
||||
const toolArgs: Parameters<NonNullable<typeof tool.execute>>[1] = {
|
||||
command: rawArgs,
|
||||
commandName: skillInvocation.command.name,
|
||||
skillName: skillInvocation.command.skillName,
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
} as any);
|
||||
};
|
||||
const result = await tool.execute(toolCallId, toolArgs);
|
||||
const text = extractTextFromToolResult(result) ?? "✅ Done.";
|
||||
typing.cleanup();
|
||||
return { kind: "reply", reply: { text } };
|
||||
|
||||
@@ -244,7 +244,7 @@ async function configureTrustedProxyControlUiAuth() {
|
||||
|
||||
async function writeTrustedProxyControlUiConfig(params?: { allowInsecureAuth?: boolean }) {
|
||||
const { writeConfigFile } = await import("../config/config.js");
|
||||
await writeConfigFile({
|
||||
const nextConfig: Parameters<typeof writeConfigFile>[0] = {
|
||||
gateway: {
|
||||
trustedProxies: ["127.0.0.1"],
|
||||
controlUi: {
|
||||
@@ -252,8 +252,8 @@ async function writeTrustedProxyControlUiConfig(params?: { allowInsecureAuth?: b
|
||||
...(params?.allowInsecureAuth ? { allowInsecureAuth: true } : {}),
|
||||
},
|
||||
},
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
} as any);
|
||||
};
|
||||
await writeConfigFile(nextConfig);
|
||||
}
|
||||
|
||||
function isConnectResMessage(id: string) {
|
||||
@@ -325,8 +325,7 @@ async function startRateLimitedTokenServerWithPairedDeviceToken() {
|
||||
mode: "token",
|
||||
token: "secret",
|
||||
rateLimit: { maxAttempts: 1, windowMs: 60_000, lockoutMs: 60_000, exemptLoopback: false },
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
} as any;
|
||||
} satisfies Record<string, unknown>;
|
||||
|
||||
const { server, ws, port, prevToken } = await startServerWithClient(undefined, {
|
||||
controlUiEnabled: true,
|
||||
|
||||
Reference in New Issue
Block a user