refactor(agent-tools): reuse gateway option parsing

This commit is contained in:
Peter Steinberger
2026-02-17 00:29:30 +00:00
parent 37c97964af
commit 10b060dbd3
3 changed files with 13 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
import { loadConfig, resolveGatewayPort } from "../../config/config.js";
import { callGateway } from "../../gateway/call.js";
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../../utils/message-channel.js";
import { readStringParam } from "./common.js";
export const DEFAULT_GATEWAY_URL = "ws://127.0.0.1:18789";
@@ -10,6 +11,14 @@ export type GatewayCallOptions = {
timeoutMs?: number;
};
export function readGatewayCallOptions(params: Record<string, unknown>): GatewayCallOptions {
return {
gatewayUrl: readStringParam(params, "gatewayUrl", { trim: false }),
gatewayToken: readStringParam(params, "gatewayToken", { trim: false }),
timeoutMs: typeof params.timeoutMs === "number" ? params.timeoutMs : undefined,
};
}
function canonicalizeToolGatewayWsUrl(raw: string): { origin: string; key: string } {
const input = raw.trim();
let url: URL;