Secrets: harden SecretRef-safe models.json persistence (#38955)

This commit is contained in:
Josh Avant
2026-03-07 11:28:39 -06:00
committed by GitHub
parent b08337b902
commit 8e20dd22d8
66 changed files with 2713 additions and 299 deletions

View File

@@ -150,10 +150,14 @@ function createMessage(params: {
id: string;
channelId: string;
content: string;
author: import("@buape/carbon").Message["author"];
author: {
id: string;
bot: boolean;
username?: string;
};
mentionedUsers?: Array<{ id: string }>;
mentionedEveryone?: boolean;
attachments?: import("@buape/carbon").Message["attachments"];
attachments?: Array<Record<string, unknown>>;
}): import("@buape/carbon").Message {
return {
id: params.id,

View File

@@ -7,6 +7,7 @@ import {
const preflightDiscordMessageMock = vi.hoisted(() => vi.fn());
const processDiscordMessageMock = vi.hoisted(() => vi.fn());
const eventualReplyDeliveredMock = vi.hoisted(() => vi.fn());
type SetStatusFn = (patch: Record<string, unknown>) => void;
vi.mock("./message-handler.preflight.js", () => ({
preflightDiscordMessage: preflightDiscordMessageMock,
@@ -45,7 +46,7 @@ function createPreflightContext(channelId = "ch-1") {
}
async function createLifecycleStopScenario(params: {
createHandler: (status: ReturnType<typeof vi.fn>) => {
createHandler: (status: SetStatusFn) => {
handler: (data: never, opts: never) => Promise<void>;
stop: () => void;
};
@@ -59,7 +60,7 @@ async function createLifecycleStopScenario(params: {
createPreflightContext(contextParams.data.channel_id),
);
const setStatus = vi.fn();
const setStatus = vi.fn<SetStatusFn>();
const { handler, stop } = params.createHandler(setStatus);
await expect(handler(createMessageData("m-1") as never, {} as never)).resolves.toBeUndefined();

View File

@@ -1,5 +1,6 @@
import { vi } from "vitest";
import type { OpenClawConfig } from "../../config/types.js";
import type { createDiscordMessageHandler } from "./message-handler.js";
import { createNoopThreadBindingManager } from "./thread-bindings.js";
export const DEFAULT_DISCORD_BOT_USER_ID = "bot-123";
@@ -9,7 +10,7 @@ export function createDiscordHandlerParams(overrides?: {
setStatus?: (patch: Record<string, unknown>) => void;
abortSignal?: AbortSignal;
workerRunTimeoutMs?: number;
}) {
}): Parameters<typeof createDiscordMessageHandler>[0] {
const cfg: OpenClawConfig = {
channels: {
discord: {