fix: stabilize tests and sync protocol models
This commit is contained in:
@@ -1973,25 +1973,25 @@ public struct ExecApprovalsSnapshot: Codable, Sendable {
|
|||||||
public struct ExecApprovalRequestParams: Codable, Sendable {
|
public struct ExecApprovalRequestParams: Codable, Sendable {
|
||||||
public let id: String?
|
public let id: String?
|
||||||
public let command: String
|
public let command: String
|
||||||
public let cwd: String?
|
public let cwd: AnyCodable?
|
||||||
public let host: String?
|
public let host: AnyCodable?
|
||||||
public let security: String?
|
public let security: AnyCodable?
|
||||||
public let ask: String?
|
public let ask: AnyCodable?
|
||||||
public let agentid: String?
|
public let agentid: AnyCodable?
|
||||||
public let resolvedpath: String?
|
public let resolvedpath: AnyCodable?
|
||||||
public let sessionkey: String?
|
public let sessionkey: AnyCodable?
|
||||||
public let timeoutms: Int?
|
public let timeoutms: Int?
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
id: String?,
|
id: String?,
|
||||||
command: String,
|
command: String,
|
||||||
cwd: String?,
|
cwd: AnyCodable?,
|
||||||
host: String?,
|
host: AnyCodable?,
|
||||||
security: String?,
|
security: AnyCodable?,
|
||||||
ask: String?,
|
ask: AnyCodable?,
|
||||||
agentid: String?,
|
agentid: AnyCodable?,
|
||||||
resolvedpath: String?,
|
resolvedpath: AnyCodable?,
|
||||||
sessionkey: String?,
|
sessionkey: AnyCodable?,
|
||||||
timeoutms: Int?
|
timeoutms: Int?
|
||||||
) {
|
) {
|
||||||
self.id = id
|
self.id = id
|
||||||
|
|||||||
@@ -1973,25 +1973,25 @@ public struct ExecApprovalsSnapshot: Codable, Sendable {
|
|||||||
public struct ExecApprovalRequestParams: Codable, Sendable {
|
public struct ExecApprovalRequestParams: Codable, Sendable {
|
||||||
public let id: String?
|
public let id: String?
|
||||||
public let command: String
|
public let command: String
|
||||||
public let cwd: String?
|
public let cwd: AnyCodable?
|
||||||
public let host: String?
|
public let host: AnyCodable?
|
||||||
public let security: String?
|
public let security: AnyCodable?
|
||||||
public let ask: String?
|
public let ask: AnyCodable?
|
||||||
public let agentid: String?
|
public let agentid: AnyCodable?
|
||||||
public let resolvedpath: String?
|
public let resolvedpath: AnyCodable?
|
||||||
public let sessionkey: String?
|
public let sessionkey: AnyCodable?
|
||||||
public let timeoutms: Int?
|
public let timeoutms: Int?
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
id: String?,
|
id: String?,
|
||||||
command: String,
|
command: String,
|
||||||
cwd: String?,
|
cwd: AnyCodable?,
|
||||||
host: String?,
|
host: AnyCodable?,
|
||||||
security: String?,
|
security: AnyCodable?,
|
||||||
ask: String?,
|
ask: AnyCodable?,
|
||||||
agentid: String?,
|
agentid: AnyCodable?,
|
||||||
resolvedpath: String?,
|
resolvedpath: AnyCodable?,
|
||||||
sessionkey: String?,
|
sessionkey: AnyCodable?,
|
||||||
timeoutms: Int?
|
timeoutms: Int?
|
||||||
) {
|
) {
|
||||||
self.id = id
|
self.id = id
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ vi.mock("@mariozechner/pi-ai", async () => {
|
|||||||
},
|
},
|
||||||
streamSimple: (model: { api: string; provider: string; id: string }) => {
|
streamSimple: (model: { api: string; provider: string; id: string }) => {
|
||||||
const stream = new actual.AssistantMessageEventStream();
|
const stream = new actual.AssistantMessageEventStream();
|
||||||
queueMicrotask(() => {
|
setTimeout(() => {
|
||||||
stream.push({
|
stream.push({
|
||||||
type: "done",
|
type: "done",
|
||||||
reason: "stop",
|
reason: "stop",
|
||||||
@@ -80,7 +80,7 @@ vi.mock("@mariozechner/pi-ai", async () => {
|
|||||||
: buildAssistantMessage(model),
|
: buildAssistantMessage(model),
|
||||||
});
|
});
|
||||||
stream.end();
|
stream.end();
|
||||||
});
|
}, 0);
|
||||||
return stream;
|
return stream;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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 {
|
import {
|
||||||
addSubagentRunForTests,
|
addSubagentRunForTests,
|
||||||
@@ -11,6 +15,17 @@ import { resetBashChatCommandForTests } from "./bash-command.js";
|
|||||||
import { buildCommandContext, handleCommands } from "./commands.js";
|
import { buildCommandContext, handleCommands } from "./commands.js";
|
||||||
import { parseInlineDirectives } from "./directive-handling.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<MsgContext>) {
|
function buildParams(commandBody: string, cfg: ClawdbotConfig, ctxOverrides?: Partial<MsgContext>) {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
Body: commandBody,
|
Body: commandBody,
|
||||||
@@ -37,7 +52,7 @@ function buildParams(commandBody: string, cfg: ClawdbotConfig, ctxOverrides?: Pa
|
|||||||
directives: parseInlineDirectives(commandBody),
|
directives: parseInlineDirectives(commandBody),
|
||||||
elevated: { enabled: true, allowed: true, failures: [] },
|
elevated: { enabled: true, allowed: true, failures: [] },
|
||||||
sessionKey: "agent:main:main",
|
sessionKey: "agent:main:main",
|
||||||
workspaceDir: "/tmp",
|
workspaceDir: testWorkspaceDir,
|
||||||
defaultGroupActivation: () => "mention",
|
defaultGroupActivation: () => "mention",
|
||||||
resolvedVerboseLevel: "off" as const,
|
resolvedVerboseLevel: "off" as const,
|
||||||
resolvedReasoningLevel: "off" as const,
|
resolvedReasoningLevel: "off" as const,
|
||||||
|
|||||||
Reference in New Issue
Block a user