Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

DeepSeek Harness: the approval plugin gets the data folder's real path

milind-soni96b76a4f7e57
diff --git a/server/drivers/acp/deepseek.test.ts b/server/drivers/acp/deepseek.test.ts
index 6fe16f6c49..34313af9b3 100644
--- a/server/drivers/acp/deepseek.test.ts
+++ b/server/drivers/acp/deepseek.test.ts
@@ -1,4 +1,4 @@
-import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
+import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, realpathSync, statSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { delimiter, join } from "node:path";
import { fileURLToPath } from "node:url";
@@ -206,7 +206,8 @@ describe("DeepSeek approval patch", () => {
function expectApprovalFiles(patch: string, review: boolean) {
expect(readFileSync(plugin, "utf8")).toBe(DSH_APPROVAL_PLUGIN);
expect(parse(readFileSync(patch, "utf8"))).toEqual([{ insert: [
- { id: "openmausbot-approval-preset", name: plugin, config: { review, dataDir: DATA_DIR } },
+ // The real path, as a conversation's folder is named under it (the test data folder may sit behind /tmp's link).
+ { id: "openmausbot-approval-preset", name: plugin, config: { review, dataDir: realpathSync(DATA_DIR) } },
] }]);
}
diff --git a/server/drivers/acp/deepseek.ts b/server/drivers/acp/deepseek.ts
index 296b78e1d8..40a11dc900 100644
--- a/server/drivers/acp/deepseek.ts
+++ b/server/drivers/acp/deepseek.ts
@@ -27,7 +27,7 @@
// Picker ids are `<provider>/<model>` so bot settings, badges and config.json
// stay readable; resolveTurnModel turns them into dsh's wire pair just before
// the core selects the model.
-import { mkdirSync, readFileSync } from "node:fs";
+import { mkdirSync, readFileSync, realpathSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
import { parse as parseYaml, stringify } from "yaml";
@@ -321,12 +321,17 @@ const approvalPlugin = join(approvalDir, "approval-preset.mjs");
const reviewPatch = join(approvalDir, "approval-review.patch.yml");
const sandboxPatch = join(approvalDir, "approval-sandbox.patch.yml");
+/** The data folder as a conversation's folder is named (its real path), so the plugin finds the bot's memory from it. */
+function approvalDataDir(): string {
+ try { return realpathSync(DATA_DIR); } catch { return DATA_DIR; }
+}
+
function approvalPatch(review: boolean): string {
const patch = review ? reviewPatch : sandboxPatch;
mkdirSync(approvalDir, { recursive: true });
writeFileAtomicIfChanged(approvalPlugin, DSH_APPROVAL_PLUGIN);
writeFileAtomicIfChanged(patch, stringify([{ insert: [
- { id: "openmausbot-approval-preset", name: approvalPlugin, config: { review, dataDir: DATA_DIR } },
+ { id: "openmausbot-approval-preset", name: approvalPlugin, config: { review, dataDir: approvalDataDir() } },
] }]));
return patch;
}