From d2bfcd70e7fe1d1eadcbe2f2c2a49fd0284c97bd Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 24 Jan 2026 00:25:47 +0000 Subject: [PATCH] fix: stabilize tests and sync protocol models --- .../ClawdbotProtocol/GatewayModels.swift | 28 +++++++++---------- .../ClawdbotProtocol/GatewayModels.swift | 28 +++++++++---------- src/agents/pi-embedded-runner.test.ts | 4 +-- src/auto-reply/reply/commands.test.ts | 19 +++++++++++-- 4 files changed, 47 insertions(+), 32 deletions(-) diff --git a/apps/macos/Sources/ClawdbotProtocol/GatewayModels.swift b/apps/macos/Sources/ClawdbotProtocol/GatewayModels.swift index 4b80bf3f6..3f66b79fc 100644 --- a/apps/macos/Sources/ClawdbotProtocol/GatewayModels.swift +++ b/apps/macos/Sources/ClawdbotProtocol/GatewayModels.swift @@ -1973,25 +1973,25 @@ public struct ExecApprovalsSnapshot: Codable, Sendable { public struct ExecApprovalRequestParams: Codable, Sendable { public let id: String? public let command: String - public let cwd: String? - public let host: String? - public let security: String? - public let ask: String? - public let agentid: String? - public let resolvedpath: String? - public let sessionkey: String? + public let cwd: AnyCodable? + public let host: AnyCodable? + public let security: AnyCodable? + public let ask: AnyCodable? + public let agentid: AnyCodable? + public let resolvedpath: AnyCodable? + public let sessionkey: AnyCodable? public let timeoutms: Int? public init( id: String?, command: String, - cwd: String?, - host: String?, - security: String?, - ask: String?, - agentid: String?, - resolvedpath: String?, - sessionkey: String?, + cwd: AnyCodable?, + host: AnyCodable?, + security: AnyCodable?, + ask: AnyCodable?, + agentid: AnyCodable?, + resolvedpath: AnyCodable?, + sessionkey: AnyCodable?, timeoutms: Int? ) { self.id = id diff --git a/apps/shared/ClawdbotKit/Sources/ClawdbotProtocol/GatewayModels.swift b/apps/shared/ClawdbotKit/Sources/ClawdbotProtocol/GatewayModels.swift index 4b80bf3f6..3f66b79fc 100644 --- a/apps/shared/ClawdbotKit/Sources/ClawdbotProtocol/GatewayModels.swift +++ b/apps/shared/ClawdbotKit/Sources/ClawdbotProtocol/GatewayModels.swift @@ -1973,25 +1973,25 @@ public struct ExecApprovalsSnapshot: Codable, Sendable { public struct ExecApprovalRequestParams: Codable, Sendable { public let id: String? public let command: String - public let cwd: String? - public let host: String? - public let security: String? - public let ask: String? - public let agentid: String? - public let resolvedpath: String? - public let sessionkey: String? + public let cwd: AnyCodable? + public let host: AnyCodable? + public let security: AnyCodable? + public let ask: AnyCodable? + public let agentid: AnyCodable? + public let resolvedpath: AnyCodable? + public let sessionkey: AnyCodable? public let timeoutms: Int? public init( id: String?, command: String, - cwd: String?, - host: String?, - security: String?, - ask: String?, - agentid: String?, - resolvedpath: String?, - sessionkey: String?, + cwd: AnyCodable?, + host: AnyCodable?, + security: AnyCodable?, + ask: AnyCodable?, + agentid: AnyCodable?, + resolvedpath: AnyCodable?, + sessionkey: AnyCodable?, timeoutms: Int? ) { self.id = id diff --git a/src/agents/pi-embedded-runner.test.ts b/src/agents/pi-embedded-runner.test.ts index 8ab12c6c1..59bf617dd 100644 --- a/src/agents/pi-embedded-runner.test.ts +++ b/src/agents/pi-embedded-runner.test.ts @@ -70,7 +70,7 @@ vi.mock("@mariozechner/pi-ai", async () => { }, streamSimple: (model: { api: string; provider: string; id: string }) => { const stream = new actual.AssistantMessageEventStream(); - queueMicrotask(() => { + setTimeout(() => { stream.push({ type: "done", reason: "stop", @@ -80,7 +80,7 @@ vi.mock("@mariozechner/pi-ai", async () => { : buildAssistantMessage(model), }); stream.end(); - }); + }, 0); return stream; }, }; diff --git a/src/auto-reply/reply/commands.test.ts b/src/auto-reply/reply/commands.test.ts index cf383ed86..c7983ae0c 100644 --- a/src/auto-reply/reply/commands.test.ts +++ b/src/auto-reply/reply/commands.test.ts @@ -1,4 +1,8 @@ -import { describe, expect, it, vi } from "vitest"; +import fs from "node:fs/promises"; +import os from "node:os"; +import path from "node:path"; + +import { afterAll, beforeAll, describe, expect, it, vi } from "vitest"; import { addSubagentRunForTests, @@ -11,6 +15,17 @@ import { resetBashChatCommandForTests } from "./bash-command.js"; import { buildCommandContext, handleCommands } from "./commands.js"; import { parseInlineDirectives } from "./directive-handling.js"; +let testWorkspaceDir = os.tmpdir(); + +beforeAll(async () => { + testWorkspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-commands-")); + await fs.writeFile(path.join(testWorkspaceDir, "AGENTS.md"), "# Agents\n", "utf-8"); +}); + +afterAll(async () => { + await fs.rm(testWorkspaceDir, { recursive: true, force: true }); +}); + function buildParams(commandBody: string, cfg: ClawdbotConfig, ctxOverrides?: Partial) { const ctx = { Body: commandBody, @@ -37,7 +52,7 @@ function buildParams(commandBody: string, cfg: ClawdbotConfig, ctxOverrides?: Pa directives: parseInlineDirectives(commandBody), elevated: { enabled: true, allowed: true, failures: [] }, sessionKey: "agent:main:main", - workspaceDir: "/tmp", + workspaceDir: testWorkspaceDir, defaultGroupActivation: () => "mention", resolvedVerboseLevel: "off" as const, resolvedReasoningLevel: "off" as const,