dsh-eval-guard 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/index.js +32 -0
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -1968,6 +1968,36 @@ var TaskService = class {
1968
1968
  definition(taskId) {
1969
1969
  return TASK_DEFINITIONS[taskId];
1970
1970
  }
1971
+ /** Extract a setup task's workspace.zip into the workspace root. */
1972
+ extractMaterial(workspacePath) {
1973
+ const zip = path.join(workspacePath, "workspace.zip");
1974
+ if (!fs.existsSync(zip)) throw new Error("workspace.zip is missing");
1975
+ const temp = fs.mkdtempSync(path.join(guardRoot(), "extract-"));
1976
+ try {
1977
+ execFileSync("unzip", [
1978
+ "-q",
1979
+ zip,
1980
+ "-d",
1981
+ temp
1982
+ ], { stdio: "pipe" });
1983
+ const inner = path.join(temp, "workspace");
1984
+ const source = fs.existsSync(inner) ? inner : temp;
1985
+ for (const entry of fs.readdirSync(source)) {
1986
+ const destination = path.join(workspacePath, entry);
1987
+ if (fs.existsSync(destination)) fs.rmSync(destination, {
1988
+ recursive: true,
1989
+ force: true
1990
+ });
1991
+ fs.renameSync(path.join(source, entry), destination);
1992
+ }
1993
+ fs.rmSync(zip, { force: true });
1994
+ } finally {
1995
+ fs.rmSync(temp, {
1996
+ recursive: true,
1997
+ force: true
1998
+ });
1999
+ }
2000
+ }
1971
2001
  /** Start a non-blocking install. The settings page polls the returned job. */
1972
2002
  startInstall(workspaceId, taskId, options = {}) {
1973
2003
  const definition = TASK_DEFINITIONS[taskId];
@@ -1990,6 +2020,7 @@ var TaskService = class {
1990
2020
  };
1991
2021
  try {
1992
2022
  fs.copyFileSync(this.materialZip(taskId), path.join(checked.path, "workspace.zip"));
2023
+ if (definition.needsSetup) this.extractMaterial(checked.path);
1993
2024
  } catch (error) {
1994
2025
  return {
1995
2026
  ok: false,
@@ -2126,6 +2157,7 @@ var TaskService = class {
2126
2157
  };
2127
2158
  try {
2128
2159
  fs.copyFileSync(this.materialZip(taskId), path.join(checked.path, "workspace.zip"));
2160
+ if (definition.needsSetup) this.extractMaterial(checked.path);
2129
2161
  if (definition.prepare !== void 0) definition.prepare(checked.path);
2130
2162
  } catch (error) {
2131
2163
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-eval-guard",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "type": "module",
5
5
  "description": "Evaluation guard for DSH: workspace-only filesystem, no network/subagents, wall-clock limits, and task installation for the meow-ai-arena tank task.",
6
6
  "license": "MIT",