mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 07:11:25 +00:00
style: run oxfmt and fix gate failures
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { resolveUserTimezone } from "../../agents/date-time.js";
|
||||
import type { OpenClawConfig } from "../../config/types.js";
|
||||
import { resolveUserTimezone } from "../../agents/date-time.js";
|
||||
import { formatZonedTimestamp } from "../../infra/format-time/format-datetime.ts";
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import type { GatewayRequestContext } from "./types.js";
|
||||
import { BARE_SESSION_RESET_PROMPT } from "../../auto-reply/reply/session-reset-prompt.js";
|
||||
import { agentHandlers } from "./agent.js";
|
||||
import type { GatewayRequestContext } from "./types.js";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
loadSessionEntry: vi.fn(),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import type { GatewayRequestHandlerOptions, GatewayRequestHandlers } from "./types.js";
|
||||
import { listAgentIds } from "../../agents/agent-scope.js";
|
||||
import { BARE_SESSION_RESET_PROMPT } from "../../auto-reply/reply/session-reset-prompt.js";
|
||||
import { agentCommand } from "../../commands/agent.js";
|
||||
@@ -49,7 +50,6 @@ import { waitForAgentJob } from "./agent-job.js";
|
||||
import { injectTimestamp, timestampOptsFromConfig } from "./agent-timestamp.js";
|
||||
import { normalizeRpcAttachmentsToChatAttachments } from "./attachment-normalize.js";
|
||||
import { sessionsHandlers } from "./sessions.js";
|
||||
import type { GatewayRequestHandlerOptions, GatewayRequestHandlers } from "./types.js";
|
||||
|
||||
const RESET_COMMAND_RE = /^\/(new|reset)(?:\s+([\s\S]*))?$/i;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import type { GatewayRequestHandlers, RespondFn } from "./types.js";
|
||||
import {
|
||||
listAgentIds,
|
||||
resolveAgentDir,
|
||||
@@ -42,7 +43,6 @@ import {
|
||||
validateAgentsUpdateParams,
|
||||
} from "../protocol/index.js";
|
||||
import { listAgentsForGateway } from "../session-utils.js";
|
||||
import type { GatewayRequestHandlers, RespondFn } from "./types.js";
|
||||
|
||||
const BOOTSTRAP_FILE_NAMES = [
|
||||
DEFAULT_AGENTS_FILENAME,
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import crypto from "node:crypto";
|
||||
import type { NodeSession } from "../node-registry.js";
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
import {
|
||||
createBrowserControlContext,
|
||||
startBrowserControlServiceFromConfig,
|
||||
@@ -7,10 +9,8 @@ import { applyBrowserProxyPaths, persistBrowserProxyFiles } from "../../browser/
|
||||
import { createBrowserRouteDispatcher } from "../../browser/routes/dispatcher.js";
|
||||
import { loadConfig } from "../../config/config.js";
|
||||
import { isNodeCommandAllowed, resolveNodeCommandAllowlist } from "../node-command-policy.js";
|
||||
import type { NodeSession } from "../node-registry.js";
|
||||
import { ErrorCodes, errorShape } from "../protocol/index.js";
|
||||
import { respondUnavailableOnNodeInvokeError, safeParseJson } from "./nodes.helpers.js";
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
|
||||
type BrowserRequestParams = {
|
||||
method?: string;
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import type { ChannelAccountSnapshot, ChannelPlugin } from "../../channels/plugins/types.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import type { GatewayRequestContext, GatewayRequestHandlers } from "./types.js";
|
||||
import { buildChannelUiCatalog } from "../../channels/plugins/catalog.js";
|
||||
import { resolveChannelDefaultAccountId } from "../../channels/plugins/helpers.js";
|
||||
import {
|
||||
@@ -7,8 +10,6 @@ import {
|
||||
normalizeChannelId,
|
||||
} from "../../channels/plugins/index.js";
|
||||
import { buildChannelAccountSnapshot } from "../../channels/plugins/status.js";
|
||||
import type { ChannelAccountSnapshot, ChannelPlugin } from "../../channels/plugins/types.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { loadConfig, readConfigFileSnapshot } from "../../config/config.js";
|
||||
import { getChannelActivity } from "../../infra/channel-activity.js";
|
||||
import { DEFAULT_ACCOUNT_ID } from "../../routing/session-key.js";
|
||||
@@ -21,7 +22,6 @@ import {
|
||||
validateChannelsStatusParams,
|
||||
} from "../protocol/index.js";
|
||||
import { formatForLog } from "../ws-log.js";
|
||||
import type { GatewayRequestContext, GatewayRequestHandlers } from "./types.js";
|
||||
|
||||
type ChannelLogoutPayload = {
|
||||
channel: ChannelId;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CURRENT_SESSION_VERSION } from "@mariozechner/pi-coding-agent";
|
||||
import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { CURRENT_SESSION_VERSION } from "@mariozechner/pi-coding-agent";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
type TranscriptLine = {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CURRENT_SESSION_VERSION } from "@mariozechner/pi-coding-agent";
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { CURRENT_SESSION_VERSION } from "@mariozechner/pi-coding-agent";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import type { GatewayRequestContext } from "./types.js";
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { CURRENT_SESSION_VERSION, SessionManager } from "@mariozechner/pi-coding-agent";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { CURRENT_SESSION_VERSION, SessionManager } from "@mariozechner/pi-coding-agent";
|
||||
import type { MsgContext } from "../../auto-reply/templating.js";
|
||||
import type { GatewayRequestContext, GatewayRequestHandlers } from "./types.js";
|
||||
import { resolveSessionAgentId } from "../../agents/agent-scope.js";
|
||||
import { resolveThinkingDefault } from "../../agents/model-selection.js";
|
||||
import { resolveAgentTimeoutMs } from "../../agents/timeout.js";
|
||||
import { dispatchInboundMessage } from "../../auto-reply/dispatch.js";
|
||||
import { createReplyDispatcher } from "../../auto-reply/reply/reply-dispatcher.js";
|
||||
import type { MsgContext } from "../../auto-reply/templating.js";
|
||||
import { createReplyPrefixOptions } from "../../channels/reply-prefix.js";
|
||||
import { resolveSessionFilePath } from "../../config/sessions.js";
|
||||
import { resolveSendPolicy } from "../../sessions/send-policy.js";
|
||||
@@ -41,7 +42,6 @@ import {
|
||||
import { formatForLog } from "../ws-log.js";
|
||||
import { injectTimestamp, timestampOptsFromConfig } from "./agent-timestamp.js";
|
||||
import { normalizeRpcAttachmentsToChatAttachments } from "./attachment-normalize.js";
|
||||
import type { GatewayRequestContext, GatewayRequestHandlers } from "./types.js";
|
||||
|
||||
type TranscriptAppendResult = {
|
||||
ok: boolean;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { OpenClawConfig } from "../../config/types.openclaw.js";
|
||||
import type { GatewayRequestHandlers, RespondFn } from "./types.js";
|
||||
import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../../agents/agent-scope.js";
|
||||
import { listChannelPlugins } from "../../channels/plugins/index.js";
|
||||
import {
|
||||
@@ -19,7 +21,6 @@ import {
|
||||
} from "../../config/redact-snapshot.js";
|
||||
import { buildConfigSchema, type ConfigSchemaResponse } from "../../config/schema.js";
|
||||
import { extractDeliveryInfo } from "../../config/sessions.js";
|
||||
import type { OpenClawConfig } from "../../config/types.openclaw.js";
|
||||
import {
|
||||
formatDoctorNonInteractiveHint,
|
||||
type RestartSentinelPayload,
|
||||
@@ -38,7 +39,6 @@ import {
|
||||
} from "../protocol/index.js";
|
||||
import { resolveBaseHashParam } from "./base-hash.js";
|
||||
import { parseRestartRequestParams } from "./restart-request.js";
|
||||
import type { GatewayRequestHandlers, RespondFn } from "./types.js";
|
||||
import { assertValidParams } from "./validation.js";
|
||||
|
||||
function requireConfigBaseHash(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ErrorCodes, errorShape } from "../protocol/index.js";
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
import { ErrorCodes, errorShape } from "../protocol/index.js";
|
||||
|
||||
export const connectHandlers: GatewayRequestHandlers = {
|
||||
connect: ({ respond }) => {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { CronJobCreate, CronJobPatch } from "../../cron/types.js";
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
import { normalizeCronJobCreate, normalizeCronJobPatch } from "../../cron/normalize.js";
|
||||
import { readCronRunLogEntries, resolveCronRunLogPath } from "../../cron/run-log.js";
|
||||
import type { CronJobCreate, CronJobPatch } from "../../cron/types.js";
|
||||
import { validateScheduleTimestamp } from "../../cron/validate-timestamp.js";
|
||||
import {
|
||||
ErrorCodes,
|
||||
@@ -15,7 +16,6 @@ import {
|
||||
validateCronUpdateParams,
|
||||
validateWakeParams,
|
||||
} from "../protocol/index.js";
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
|
||||
export const cronHandlers: GatewayRequestHandlers = {
|
||||
wake: ({ params, respond, context }) => {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
import {
|
||||
approveDevicePairing,
|
||||
listDevicePairing,
|
||||
@@ -17,7 +18,6 @@ import {
|
||||
validateDeviceTokenRevokeParams,
|
||||
validateDeviceTokenRotateParams,
|
||||
} from "../protocol/index.js";
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
|
||||
function redactPairedDevice(
|
||||
device: { tokens?: Record<string, DeviceAuthToken> } & Record<string, unknown>,
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import type { ExecApprovalForwarder } from "../../infra/exec-approval-forwarder.js";
|
||||
import type { ExecApprovalManager } from "../exec-approval-manager.js";
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
import {
|
||||
DEFAULT_EXEC_APPROVAL_TIMEOUT_MS,
|
||||
type ExecApprovalDecision,
|
||||
} from "../../infra/exec-approvals.js";
|
||||
import type { ExecApprovalManager } from "../exec-approval-manager.js";
|
||||
import {
|
||||
ErrorCodes,
|
||||
errorShape,
|
||||
@@ -11,7 +12,6 @@ import {
|
||||
validateExecApprovalRequestParams,
|
||||
validateExecApprovalResolveParams,
|
||||
} from "../protocol/index.js";
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
|
||||
export function createExecApprovalHandlers(
|
||||
manager: ExecApprovalManager,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { GatewayRequestHandlers, RespondFn } from "./types.js";
|
||||
import {
|
||||
ensureExecApprovals,
|
||||
mergeExecApprovalsSocketDefaults,
|
||||
@@ -21,7 +22,6 @@ import {
|
||||
respondUnavailableOnThrow,
|
||||
safeParseJson,
|
||||
} from "./nodes.helpers.js";
|
||||
import type { GatewayRequestHandlers, RespondFn } from "./types.js";
|
||||
import { assertValidParams } from "./validation.js";
|
||||
|
||||
function requireApprovalsBaseHash(
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
import { getStatusSummary } from "../../commands/status.js";
|
||||
import { ErrorCodes, errorShape } from "../protocol/index.js";
|
||||
import { HEALTH_REFRESH_INTERVAL_MS } from "../server-constants.js";
|
||||
import { formatError } from "../server-utils.js";
|
||||
import { formatForLog } from "../ws-log.js";
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
|
||||
const ADMIN_SCOPE = "operator.admin";
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
import { getResolvedLoggerSettings } from "../../logging.js";
|
||||
import { clamp } from "../../utils.js";
|
||||
import {
|
||||
@@ -8,7 +9,6 @@ import {
|
||||
formatValidationErrors,
|
||||
validateLogsTailParams,
|
||||
} from "../protocol/index.js";
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
|
||||
const DEFAULT_LIMIT = 500;
|
||||
const DEFAULT_MAX_BYTES = 250_000;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
import {
|
||||
ErrorCodes,
|
||||
errorShape,
|
||||
formatValidationErrors,
|
||||
validateModelsListParams,
|
||||
} from "../protocol/index.js";
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
|
||||
export const modelsHandlers: GatewayRequestHandlers = {
|
||||
"models.list": async ({ params, respond, context }) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { GatewayRequestHandler } from "./types.js";
|
||||
import { ErrorCodes, errorShape, validateNodeInvokeResultParams } from "../protocol/index.js";
|
||||
import { respondInvalidParams } from "./nodes.helpers.js";
|
||||
import type { GatewayRequestHandler } from "./types.js";
|
||||
|
||||
function normalizeNodeInvokeResultParams(params: unknown): unknown {
|
||||
if (!params || typeof params !== "object") {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { ErrorObject } from "ajv";
|
||||
import type { RespondFn } from "./types.js";
|
||||
import { ErrorCodes, errorShape, formatValidationErrors } from "../protocol/index.js";
|
||||
import { formatForLog } from "../ws-log.js";
|
||||
import type { RespondFn } from "./types.js";
|
||||
|
||||
type ValidatorFn = ((value: unknown) => boolean) & {
|
||||
errors?: ErrorObject[] | null;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
import { loadConfig } from "../../config/config.js";
|
||||
import { listDevicePairing } from "../../infra/device-pairing.js";
|
||||
import {
|
||||
@@ -32,7 +33,6 @@ import {
|
||||
safeParseJson,
|
||||
uniqueSortedStrings,
|
||||
} from "./nodes.helpers.js";
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
|
||||
function isNodeEntry(entry: { role?: string; roles?: string[] }) {
|
||||
if (entry.role === "node") {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { sendHandlers } from "./send.js";
|
||||
import type { GatewayRequestContext } from "./types.js";
|
||||
import { sendHandlers } from "./send.js";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
deliverOutboundPayloads: vi.fn(),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { GatewayRequestContext, GatewayRequestHandlers } from "./types.js";
|
||||
import { resolveSessionAgentId } from "../../agents/agent-scope.js";
|
||||
import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js";
|
||||
import { DEFAULT_CHAT_CHANNEL } from "../../channels/registry.js";
|
||||
@@ -19,7 +20,6 @@ import {
|
||||
validateSendParams,
|
||||
} from "../protocol/index.js";
|
||||
import { formatForLog } from "../ws-log.js";
|
||||
import type { GatewayRequestContext, GatewayRequestHandlers } from "./types.js";
|
||||
|
||||
type InflightResult = {
|
||||
ok: boolean;
|
||||
|
||||
@@ -20,10 +20,6 @@ vi.mock("../../commands/status.js", () => ({
|
||||
getStatusSummary: vi.fn().mockResolvedValue({ ok: true }),
|
||||
}));
|
||||
|
||||
type HealthStatusHandlerParams = Parameters<
|
||||
(typeof import("./health.js"))["healthHandlers"]["status"]
|
||||
>[0];
|
||||
|
||||
describe("waitForAgentJob", () => {
|
||||
it("maps lifecycle end events with aborted=true to timeout", async () => {
|
||||
const runId = `run-timeout-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
||||
@@ -240,7 +236,7 @@ describe("gateway chat transcript writes (guardrail)", () => {
|
||||
});
|
||||
|
||||
describe("exec approval handlers", () => {
|
||||
const execApprovalNoop = () => {};
|
||||
const execApprovalNoop = () => false;
|
||||
type ExecApprovalHandlers = ReturnType<typeof createExecApprovalHandlers>;
|
||||
type ExecApprovalRequestArgs = Parameters<ExecApprovalHandlers["exec.approval.request"]>[0];
|
||||
type ExecApprovalResolveArgs = Parameters<ExecApprovalHandlers["exec.approval.resolve"]>[0];
|
||||
@@ -276,7 +272,7 @@ describe("exec approval handlers", () => {
|
||||
} as unknown as ExecApprovalRequestArgs["params"];
|
||||
return params.handlers["exec.approval.request"]({
|
||||
params: requestParams,
|
||||
respond: params.respond,
|
||||
respond: params.respond as unknown as ExecApprovalRequestArgs["respond"],
|
||||
context: toExecApprovalRequestContext(params.context),
|
||||
client: null,
|
||||
req: { id: "req-1", type: "req", method: "exec.approval.request" },
|
||||
@@ -292,9 +288,9 @@ describe("exec approval handlers", () => {
|
||||
}) {
|
||||
return params.handlers["exec.approval.resolve"]({
|
||||
params: { id: params.id, decision: "allow-once" } as ExecApprovalResolveArgs["params"],
|
||||
respond: params.respond,
|
||||
respond: params.respond as unknown as ExecApprovalResolveArgs["respond"],
|
||||
context: toExecApprovalResolveContext(params.context),
|
||||
client: { connect: { client: { id: "cli", displayName: "CLI" } } },
|
||||
client: null,
|
||||
req: { id: "req-2", type: "req", method: "exec.approval.resolve" },
|
||||
isWebchatConnect: execApprovalNoop,
|
||||
});
|
||||
@@ -477,9 +473,13 @@ describe("gateway healthHandlers.status scope handling", () => {
|
||||
const { healthHandlers } = await import("./health.js");
|
||||
|
||||
await healthHandlers.status({
|
||||
respond,
|
||||
client: { connect: { role: "operator", scopes: ["operator.read"] } },
|
||||
} as HealthStatusHandlerParams);
|
||||
req: {} as never,
|
||||
params: {} as never,
|
||||
respond: respond as never,
|
||||
context: {} as never,
|
||||
client: { connect: { role: "operator", scopes: ["operator.read"] } } as never,
|
||||
isWebchatConnect: () => false,
|
||||
});
|
||||
|
||||
expect(vi.mocked(status.getStatusSummary)).toHaveBeenCalledWith({ includeSensitive: false });
|
||||
expect(respond).toHaveBeenCalledWith(true, { ok: true }, undefined);
|
||||
@@ -491,9 +491,13 @@ describe("gateway healthHandlers.status scope handling", () => {
|
||||
const { healthHandlers } = await import("./health.js");
|
||||
|
||||
await healthHandlers.status({
|
||||
respond,
|
||||
client: { connect: { role: "operator", scopes: ["operator.admin"] } },
|
||||
} as HealthStatusHandlerParams);
|
||||
req: {} as never,
|
||||
params: {} as never,
|
||||
respond: respond as never,
|
||||
context: {} as never,
|
||||
client: { connect: { role: "operator", scopes: ["operator.admin"] } } as never,
|
||||
isWebchatConnect: () => false,
|
||||
});
|
||||
|
||||
expect(vi.mocked(status.getStatusSummary)).toHaveBeenCalledWith({ includeSensitive: true });
|
||||
expect(respond).toHaveBeenCalledWith(true, { ok: true }, undefined);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import type { GatewayRequestHandlers, RespondFn } from "./types.js";
|
||||
import { resolveDefaultAgentId } from "../../agents/agent-scope.js";
|
||||
import { abortEmbeddedPiRun, waitForEmbeddedPiRunEnd } from "../../agents/pi-embedded.js";
|
||||
import { stopSubagentsForRequester } from "../../auto-reply/reply/abort.js";
|
||||
@@ -42,7 +43,6 @@ import {
|
||||
} from "../session-utils.js";
|
||||
import { applySessionsPatchToStore } from "../sessions-patch.js";
|
||||
import { resolveSessionKeyFromResolveParams } from "../sessions-resolve.js";
|
||||
import type { GatewayRequestHandlers, RespondFn } from "./types.js";
|
||||
import { assertValidParams } from "./validation.js";
|
||||
|
||||
function requireSessionKey(key: unknown, respond: RespondFn): string | null {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
import {
|
||||
listAgentIds,
|
||||
resolveAgentWorkspaceDir,
|
||||
@@ -7,7 +9,6 @@ import { installSkill } from "../../agents/skills-install.js";
|
||||
import { buildWorkspaceSkillStatus } from "../../agents/skills-status.js";
|
||||
import { loadWorkspaceSkillEntries, type SkillEntry } from "../../agents/skills.js";
|
||||
import { listAgentWorkspaceDirs } from "../../agents/workspace-dirs.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { loadConfig, writeConfigFile } from "../../config/config.js";
|
||||
import { getRemoteSkillEligibility } from "../../infra/skills-remote.js";
|
||||
import { normalizeAgentId } from "../../routing/session-key.js";
|
||||
@@ -21,7 +22,6 @@ import {
|
||||
validateSkillsStatusParams,
|
||||
validateSkillsUpdateParams,
|
||||
} from "../protocol/index.js";
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
|
||||
function collectSkillBins(entries: SkillEntry[]): string[] {
|
||||
const bins = new Set<string>();
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
import { resolveMainSessionKeyFromConfig } from "../../config/sessions.js";
|
||||
import { getLastHeartbeatEvent } from "../../infra/heartbeat-events.js";
|
||||
import { setHeartbeatsEnabled } from "../../infra/heartbeat-runner.js";
|
||||
import { enqueueSystemEvent, isSystemEventContextChanged } from "../../infra/system-events.js";
|
||||
import { listSystemPresence, updateSystemPresence } from "../../infra/system-presence.js";
|
||||
import { ErrorCodes, errorShape } from "../protocol/index.js";
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
|
||||
export const systemHandlers: GatewayRequestHandlers = {
|
||||
"last-heartbeat": ({ respond }) => {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
import { readConfigFileSnapshot } from "../../config/config.js";
|
||||
import { redactConfigObject } from "../../config/redact-snapshot.js";
|
||||
import {
|
||||
@@ -7,7 +8,6 @@ import {
|
||||
validateTalkConfigParams,
|
||||
validateTalkModeParams,
|
||||
} from "../protocol/index.js";
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
|
||||
const ADMIN_SCOPE = "operator.admin";
|
||||
const TALK_SECRETS_SCOPE = "operator.talk.secrets";
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
import { loadConfig } from "../../config/config.js";
|
||||
import {
|
||||
OPENAI_TTS_MODELS,
|
||||
@@ -16,7 +17,6 @@ import {
|
||||
} from "../../tts/tts.js";
|
||||
import { ErrorCodes, errorShape } from "../protocol/index.js";
|
||||
import { formatForLog } from "../ws-log.js";
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
|
||||
export const ttsHandlers: GatewayRequestHandlers = {
|
||||
"tts.status": async ({ respond }) => {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
import { loadConfig } from "../../config/config.js";
|
||||
import { extractDeliveryInfo } from "../../config/sessions.js";
|
||||
import { resolveOpenClawPackageRoot } from "../../infra/openclaw-root.js";
|
||||
@@ -11,7 +12,6 @@ import { normalizeUpdateChannel } from "../../infra/update-channels.js";
|
||||
import { runGatewayUpdate } from "../../infra/update-runner.js";
|
||||
import { validateUpdateRunParams } from "../protocol/index.js";
|
||||
import { parseRestartRequestParams } from "./restart-request.js";
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
import { assertValidParams } from "./validation.js";
|
||||
|
||||
export const updateHandlers: GatewayRequestHandlers = {
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
import fs from "node:fs";
|
||||
import { loadConfig } from "../../config/config.js";
|
||||
import {
|
||||
resolveSessionFilePath,
|
||||
resolveSessionFilePathOptions,
|
||||
} from "../../config/sessions/paths.js";
|
||||
import type { SessionEntry, SessionSystemPromptReport } from "../../config/sessions/types.js";
|
||||
import { loadProviderUsageSummary } from "../../infra/provider-usage.js";
|
||||
import type {
|
||||
CostUsageSummary,
|
||||
SessionCostSummary,
|
||||
@@ -16,6 +10,13 @@ import type {
|
||||
SessionModelUsage,
|
||||
SessionToolUsage,
|
||||
} from "../../infra/session-cost-usage.js";
|
||||
import type { GatewayRequestHandlers, RespondFn } from "./types.js";
|
||||
import { loadConfig } from "../../config/config.js";
|
||||
import {
|
||||
resolveSessionFilePath,
|
||||
resolveSessionFilePathOptions,
|
||||
} from "../../config/sessions/paths.js";
|
||||
import { loadProviderUsageSummary } from "../../infra/provider-usage.js";
|
||||
import {
|
||||
loadCostUsageSummary,
|
||||
loadSessionCostSummary,
|
||||
@@ -36,7 +37,6 @@ import {
|
||||
loadCombinedSessionStoreForGateway,
|
||||
loadSessionEntry,
|
||||
} from "../session-utils.js";
|
||||
import type { GatewayRequestHandlers, RespondFn } from "./types.js";
|
||||
|
||||
const COST_USAGE_CACHE_TTL_MS = 30_000;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ErrorObject } from "ajv";
|
||||
import { ErrorCodes, errorShape, formatValidationErrors } from "../protocol/index.js";
|
||||
import type { RespondFn } from "./types.js";
|
||||
import { ErrorCodes, errorShape, formatValidationErrors } from "../protocol/index.js";
|
||||
|
||||
export type Validator<T> = ((params: unknown) => params is T) & {
|
||||
errors?: ErrorObject[] | null;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
import { loadVoiceWakeConfig, setVoiceWakeTriggers } from "../../infra/voicewake.js";
|
||||
import { ErrorCodes, errorShape } from "../protocol/index.js";
|
||||
import { normalizeVoiceWakeTriggers } from "../server-utils.js";
|
||||
import { formatForLog } from "../ws-log.js";
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
|
||||
export const voicewakeHandlers: GatewayRequestHandlers = {
|
||||
"voicewake.get": async ({ respond }) => {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { GatewayRequestHandlers, RespondFn } from "./types.js";
|
||||
import { listChannelPlugins } from "../../channels/plugins/index.js";
|
||||
import {
|
||||
ErrorCodes,
|
||||
@@ -7,7 +8,6 @@ import {
|
||||
validateWebLoginWaitParams,
|
||||
} from "../protocol/index.js";
|
||||
import { formatForLog } from "../ws-log.js";
|
||||
import type { GatewayRequestHandlers, RespondFn } from "./types.js";
|
||||
|
||||
const WEB_LOGIN_METHODS = new Set(["web.login.start", "web.login.wait"]);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import type { GatewayRequestContext, GatewayRequestHandlers, RespondFn } from "./types.js";
|
||||
import { defaultRuntime } from "../../runtime.js";
|
||||
import { WizardSession } from "../../wizard/session.js";
|
||||
import {
|
||||
@@ -10,7 +11,6 @@ import {
|
||||
validateWizardStatusParams,
|
||||
} from "../protocol/index.js";
|
||||
import { formatForLog } from "../ws-log.js";
|
||||
import type { GatewayRequestContext, GatewayRequestHandlers, RespondFn } from "./types.js";
|
||||
import { assertValidParams } from "./validation.js";
|
||||
|
||||
function readWizardStatus(session: WizardSession) {
|
||||
|
||||
Reference in New Issue
Block a user