fix: sync protocol outputs

This commit is contained in:
Peter Steinberger
2026-01-18 08:58:41 +00:00
parent 4de3c3a028
commit b015c7e5ad
9 changed files with 85 additions and 29 deletions

View File

@@ -1632,6 +1632,51 @@ public struct LogsTailResult: Codable, Sendable {
} }
} }
public struct ExecApprovalsGetParams: Codable, Sendable {
}
public struct ExecApprovalsSetParams: Codable, Sendable {
public let file: [String: AnyCodable]
public let basehash: String?
public init(
file: [String: AnyCodable],
basehash: String?
) {
self.file = file
self.basehash = basehash
}
private enum CodingKeys: String, CodingKey {
case file
case basehash = "baseHash"
}
}
public struct ExecApprovalsSnapshot: Codable, Sendable {
public let path: String
public let exists: Bool
public let hash: String
public let file: [String: AnyCodable]
public init(
path: String,
exists: Bool,
hash: String,
file: [String: AnyCodable]
) {
self.path = path
self.exists = exists
self.hash = hash
self.file = file
}
private enum CodingKeys: String, CodingKey {
case path
case exists
case hash
case file
}
}
public struct ChatHistoryParams: Codable, Sendable { public struct ChatHistoryParams: Codable, Sendable {
public let sessionkey: String public let sessionkey: String
public let limit: Int? public let limit: Int?

View File

@@ -56,9 +56,8 @@ const buildAssistantErrorMessage = (model: { api: string; provider: string; id:
const mockPiAi = () => { const mockPiAi = () => {
vi.doMock("@mariozechner/pi-ai", async () => { vi.doMock("@mariozechner/pi-ai", async () => {
const actual = await vi.importActual<typeof import("@mariozechner/pi-ai")>( const actual =
"@mariozechner/pi-ai", await vi.importActual<typeof import("@mariozechner/pi-ai")>("@mariozechner/pi-ai");
);
return { return {
...actual, ...actual,
complete: async (model: { api: string; provider: string; id: string }) => { complete: async (model: { api: string; provider: string; id: string }) => {

View File

@@ -352,7 +352,11 @@ const emptyRegistry = createRegistry([]);
const defaultRegistry = createTestRegistry([ const defaultRegistry = createTestRegistry([
{ {
pluginId: "discord", pluginId: "discord",
plugin: createOutboundTestPlugin({ id: "discord", outbound: discordOutbound, label: "Discord" }), plugin: createOutboundTestPlugin({
id: "discord",
outbound: discordOutbound,
label: "Discord",
}),
source: "test", source: "test",
}, },
{ {

View File

@@ -130,9 +130,7 @@ export const execApprovalsHandlers: GatewayRequestHandlers = {
const currentSocketPath = snapshot.file.socket?.path?.trim(); const currentSocketPath = snapshot.file.socket?.path?.trim();
const currentToken = snapshot.file.socket?.token?.trim(); const currentToken = snapshot.file.socket?.token?.trim();
const socketPath = const socketPath =
normalized.socket?.path?.trim() ?? normalized.socket?.path?.trim() ?? currentSocketPath ?? resolveExecApprovalsSocketPath();
currentSocketPath ??
resolveExecApprovalsSocketPath();
const token = normalized.socket?.token?.trim() ?? currentToken ?? ""; const token = normalized.socket?.token?.trim() ?? currentToken ?? "";
const next: ExecApprovalsFile = { const next: ExecApprovalsFile = {
...normalized, ...normalized,

View File

@@ -9,9 +9,8 @@ const mocks = vi.hoisted(() => ({
})); }));
vi.mock("../../config/config.js", async () => { vi.mock("../../config/config.js", async () => {
const actual = await vi.importActual<typeof import("../../config/config.js")>( const actual =
"../../config/config.js", await vi.importActual<typeof import("../../config/config.js")>("../../config/config.js");
);
return { return {
...actual, ...actual,
loadConfig: () => ({}), loadConfig: () => ({}),

View File

@@ -212,11 +212,11 @@ export {
resolveDiscordAccount, resolveDiscordAccount,
type ResolvedDiscordAccount, type ResolvedDiscordAccount,
} from "../discord/accounts.js"; } from "../discord/accounts.js";
export { auditDiscordChannelPermissions, collectDiscordAuditChannelIds } from "../discord/audit.js";
export { export {
auditDiscordChannelPermissions, listDiscordDirectoryGroupsLive,
collectDiscordAuditChannelIds, listDiscordDirectoryPeersLive,
} from "../discord/audit.js"; } from "../discord/directory-live.js";
export { listDiscordDirectoryGroupsLive, listDiscordDirectoryPeersLive } from "../discord/directory-live.js";
export { probeDiscord } from "../discord/probe.js"; export { probeDiscord } from "../discord/probe.js";
export { resolveDiscordChannelAllowlist } from "../discord/resolve-channels.js"; export { resolveDiscordChannelAllowlist } from "../discord/resolve-channels.js";
export { resolveDiscordUserAllowlist } from "../discord/resolve-users.js"; export { resolveDiscordUserAllowlist } from "../discord/resolve-users.js";
@@ -238,7 +238,10 @@ export {
resolveSlackAccount, resolveSlackAccount,
type ResolvedSlackAccount, type ResolvedSlackAccount,
} from "../slack/accounts.js"; } from "../slack/accounts.js";
export { listSlackDirectoryGroupsLive, listSlackDirectoryPeersLive } from "../slack/directory-live.js"; export {
listSlackDirectoryGroupsLive,
listSlackDirectoryPeersLive,
} from "../slack/directory-live.js";
export { probeSlack } from "../slack/probe.js"; export { probeSlack } from "../slack/probe.js";
export { resolveSlackChannelAllowlist } from "../slack/resolve-channels.js"; export { resolveSlackChannelAllowlist } from "../slack/resolve-channels.js";
export { resolveSlackUserAllowlist } from "../slack/resolve-users.js"; export { resolveSlackUserAllowlist } from "../slack/resolve-users.js";

View File

@@ -46,13 +46,7 @@ const registryCache = new Map<string, PluginRegistry>();
const defaultLogger = () => createSubsystemLogger("plugins"); const defaultLogger = () => createSubsystemLogger("plugins");
const BUNDLED_ENABLED_BY_DEFAULT = new Set([ const BUNDLED_ENABLED_BY_DEFAULT = new Set(["telegram", "whatsapp", "discord", "slack", "signal"]);
"telegram",
"whatsapp",
"discord",
"slack",
"signal",
]);
const normalizeList = (value: unknown): string[] => { const normalizeList = (value: unknown): string[] => {
if (!Array.isArray(value)) return []; if (!Array.isArray(value)) return [];

View File

@@ -8,9 +8,7 @@ import type {
import type { PluginRegistry } from "../plugins/registry.js"; import type { PluginRegistry } from "../plugins/registry.js";
import { normalizeIMessageHandle } from "../imessage/targets.js"; import { normalizeIMessageHandle } from "../imessage/targets.js";
export const createTestRegistry = ( export const createTestRegistry = (channels: PluginRegistry["channels"] = []): PluginRegistry => ({
channels: PluginRegistry["channels"] = [],
): PluginRegistry => ({
plugins: [], plugins: [],
tools: [], tools: [],
hooks: [], hooks: [],

View File

@@ -1,6 +1,10 @@
import { afterEach, beforeEach, vi } from "vitest"; import { afterEach, beforeEach, vi } from "vitest";
import type { ChannelId, ChannelOutboundAdapter, ChannelPlugin } from "../src/channels/plugins/types.js"; import type {
ChannelId,
ChannelOutboundAdapter,
ChannelPlugin,
} from "../src/channels/plugins/types.js";
import type { ClawdbotConfig } from "../src/config/config.js"; import type { ClawdbotConfig } from "../src/config/config.js";
import type { OutboundSendDeps } from "../src/infra/outbound/deliver.js"; import type { OutboundSendDeps } from "../src/infra/outbound/deliver.js";
import { setActivePluginRegistry } from "../src/plugins/runtime.js"; import { setActivePluginRegistry } from "../src/plugins/runtime.js";
@@ -97,8 +101,16 @@ const createStubPlugin = (params: {
const createDefaultRegistry = () => const createDefaultRegistry = () =>
createTestRegistry([ createTestRegistry([
{ pluginId: "discord", plugin: createStubPlugin({ id: "discord", label: "Discord" }), source: "test" }, {
{ pluginId: "slack", plugin: createStubPlugin({ id: "slack", label: "Slack" }), source: "test" }, pluginId: "discord",
plugin: createStubPlugin({ id: "discord", label: "Discord" }),
source: "test",
},
{
pluginId: "slack",
plugin: createStubPlugin({ id: "slack", label: "Slack" }),
source: "test",
},
{ {
pluginId: "telegram", pluginId: "telegram",
plugin: { plugin: {
@@ -122,7 +134,11 @@ const createDefaultRegistry = () =>
}), }),
source: "test", source: "test",
}, },
{ pluginId: "signal", plugin: createStubPlugin({ id: "signal", label: "Signal" }), source: "test" }, {
pluginId: "signal",
plugin: createStubPlugin({ id: "signal", label: "Signal" }),
source: "test",
},
{ {
pluginId: "imessage", pluginId: "imessage",
plugin: createStubPlugin({ id: "imessage", label: "iMessage", aliases: ["imsg"] }), plugin: createStubPlugin({ id: "imessage", label: "iMessage", aliases: ["imsg"] }),