@qwen-code/qwen-harness 0.1.16 → 0.1.17

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.
@@ -15,36 +15,36 @@ var __export = (target, all) => {
15
15
  };
16
16
 
17
17
  // src/utils/settings.ts
18
- function record(value, path35) {
18
+ function record(value, path34) {
19
19
  if (value === void 0) return {};
20
20
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
21
- throw new Error(`${path35} must be a JSON object`);
21
+ throw new Error(`${path34} must be a JSON object`);
22
22
  }
23
23
  return value;
24
24
  }
25
- function assertKnownKeys(value, path35, allowedKeys) {
25
+ function assertKnownKeys(value, path34, allowedKeys) {
26
26
  const allowed = new Set(allowedKeys);
27
27
  const unknownKeys = Object.keys(value).filter((key) => !allowed.has(key));
28
28
  if (unknownKeys.length === 0) return;
29
- throw new Error(`${path35} contains unknown field${unknownKeys.length === 1 ? "" : "s"}: ${unknownKeys.join(", ")}`);
29
+ throw new Error(`${path34} contains unknown field${unknownKeys.length === 1 ? "" : "s"}: ${unknownKeys.join(", ")}`);
30
30
  }
31
- function optionalString(value, path35) {
31
+ function optionalString(value, path34) {
32
32
  if (value === void 0) return void 0;
33
33
  if (typeof value !== "string" || value.trim().length === 0) {
34
- throw new Error(`${path35} must be a non-empty string`);
34
+ throw new Error(`${path34} must be a non-empty string`);
35
35
  }
36
36
  return value.trim();
37
37
  }
38
- function optionalNonNegativeInteger(value, path35) {
38
+ function optionalNonNegativeInteger(value, path34) {
39
39
  if (value === void 0) return void 0;
40
40
  if (!Number.isSafeInteger(value) || Number(value) < 0) {
41
- throw new Error(`${path35} must be a non-negative integer`);
41
+ throw new Error(`${path34} must be a non-negative integer`);
42
42
  }
43
43
  return Number(value);
44
44
  }
45
- function optionalPositiveInteger(value, path35) {
46
- const parsed = optionalNonNegativeInteger(value, path35);
47
- if (parsed === 0) throw new Error(`${path35} must be a positive integer`);
45
+ function optionalPositiveInteger(value, path34) {
46
+ const parsed = optionalNonNegativeInteger(value, path34);
47
+ if (parsed === 0) throw new Error(`${path34} must be a positive integer`);
48
48
  return parsed;
49
49
  }
50
50
  function withoutUndefined(value) {
@@ -4617,70 +4617,12 @@ var init_codemode = __esm({
4617
4617
  }
4618
4618
  });
4619
4619
 
4620
- // src/harnesses/scaling/planning-test-sandbox.ts
4621
- import { constants as constants2 } from "node:fs";
4622
- import { access, mkdtemp as mkdtemp3, realpath as realpath2, rm as rm5 } from "node:fs/promises";
4623
- import { tmpdir as tmpdir4 } from "node:os";
4624
- import path18 from "node:path";
4625
- function quoteShellArg(value) {
4626
- return "'" + value.replaceAll("'", "'\\''") + "'";
4627
- }
4628
- async function runPlanningTest(command, run) {
4629
- const mac = process.platform === "darwin";
4630
- const binary = mac ? "/usr/bin/sandbox-exec" : process.platform === "linux" ? "/usr/bin/bwrap" : void 0;
4631
- if (!binary) throw new Error("Planning tests require a read-only sandbox. Run this test after submitting the plan.");
4632
- try {
4633
- await access(binary, constants2.X_OK);
4634
- } catch {
4635
- throw new Error(`Planning tests require ${binary}. Run this test after submitting the plan.`);
4636
- }
4637
- const directory = await mkdtemp3(path18.join(tmpdir4(), "pi-planning-test-"));
4638
- try {
4639
- const scratch = await realpath2(directory);
4640
- const sandbox = mac ? [
4641
- binary,
4642
- "-p",
4643
- `(version 1) (allow default) (deny file-write*) (allow file-write* (subpath ${JSON.stringify(scratch)}) (literal "/dev/null"))`
4644
- ] : [
4645
- binary,
4646
- "--die-with-parent",
4647
- "--unshare-pid",
4648
- "--ro-bind",
4649
- "/",
4650
- "/",
4651
- "--dev",
4652
- "/dev",
4653
- "--proc",
4654
- "/proc",
4655
- "--bind",
4656
- scratch,
4657
- scratch,
4658
- "--"
4659
- ];
4660
- const env = [
4661
- "TMPDIR",
4662
- "TMP",
4663
- "TEMP",
4664
- "XDG_CACHE_HOME",
4665
- "PYTHONPYCACHEPREFIX",
4666
- "npm_config_cache",
4667
- "CARGO_TARGET_DIR",
4668
- "GOCACHE"
4669
- ].map((name) => `${name}=${scratch}`);
4670
- return await run(`${[...sandbox, "/usr/bin/env", ...env].map(quoteShellArg).join(" ")} ${command}`);
4671
- } finally {
4672
- await rm5(directory, { recursive: true, force: true });
4673
- }
4674
- }
4675
- var init_planning_test_sandbox = __esm({
4676
- "src/harnesses/scaling/planning-test-sandbox.ts"() {
4677
- "use strict";
4678
- }
4679
- });
4680
-
4681
4620
  // src/harnesses/scaling/planning.ts
4682
4621
  import { defineTool as defineTool29 } from "@earendil-works/pi-coding-agent";
4683
4622
  import { Type as Type28 } from "typebox";
4623
+ function quoteShellArg(value) {
4624
+ return "'" + value.replaceAll("'", "'\\''") + "'";
4625
+ }
4684
4626
  function isTestCommand([name, option, subcommand]) {
4685
4627
  return name === "pytest" || (name === "python" || name === "python3") && option === "-m" && subcommand === "pytest" || name === "node" && option === "--test" || name === "npm" && (option === "test" || option === "run" && subcommand === "test") || (name === "cargo" || name === "go") && option === "test";
4686
4628
  }
@@ -4763,7 +4705,6 @@ var READ_ONLY_TOOLS, FIND_OPTIONS, PlanningWorkflow;
4763
4705
  var init_planning = __esm({
4764
4706
  "src/harnesses/scaling/planning.ts"() {
4765
4707
  "use strict";
4766
- init_planning_test_sandbox();
4767
4708
  init_tools();
4768
4709
  READ_ONLY_TOOLS = /* @__PURE__ */ new Set([
4769
4710
  "read_file",
@@ -4845,9 +4786,8 @@ var init_planning = __esm({
4845
4786
  if (name === "bash") {
4846
4787
  const input = args;
4847
4788
  const parsed = planningShell(input.command);
4848
- if (!parsed.test) return execute2({ ...input, command: parsed.command });
4849
- if (input.background) throw new Error("Run planning tests in the foreground");
4850
- return runPlanningTest(parsed.command, (command) => execute2({ ...input, command }));
4789
+ if (parsed.test && input.background) throw new Error("Run planning tests in the foreground");
4790
+ return execute2({ ...input, command: parsed.command });
4851
4791
  }
4852
4792
  if (!READ_ONLY_TOOLS.has(name))
4853
4793
  throw new Error(
@@ -5348,7 +5288,11 @@ function mechanismPrompt(config) {
5348
5288
  );
5349
5289
  if (config.W === "W2")
5350
5290
  pieces.push(
5351
- "Begin in the planning phase: gather information with read-only tools and Shell queries, including read-only find and which. Supported test commands such as pytest, node --test, and npm test can run in the foreground with a read-only filesystem and temporary caches when a test sandbox is available. Do not modify project files or run implementation commands. Submit an actionable plan and verification steps with submit_plan. The host automatically enters execution in the next model turn; no user approval is needed for that transition."
5291
+ [
5292
+ "Begin in the planning phase. Inspect the workspace and run existing tests as needed to understand the task and form a plan. Tests may produce temporary files, caches, and build artifacts.",
5293
+ "During planning, do not edit project files or run implementation commands.",
5294
+ "When ready, submit an actionable plan and verification steps with submit_plan. Execution begins automatically on the next model turn. Once the plan is accepted, implement it, verify the result, and finish the task."
5295
+ ].join("\n\n")
5352
5296
  );
5353
5297
  if (config.W === "W3")
5354
5298
  pieces.push(
@@ -5464,7 +5408,7 @@ var init_send_message = __esm({
5464
5408
 
5465
5409
  // src/utils/storage/json_store.ts
5466
5410
  import { mkdir as mkdir8, readFile as readFile8, writeFile as writeFile8, rename as rename2, unlink } from "node:fs/promises";
5467
- import path19 from "node:path";
5411
+ import path18 from "node:path";
5468
5412
  import { randomUUID as randomUUID5 } from "node:crypto";
5469
5413
  var JsonStore;
5470
5414
  var init_json_store = __esm({
@@ -5496,7 +5440,7 @@ var init_json_store = __esm({
5496
5440
  }).then(async () => {
5497
5441
  const state = await this.load();
5498
5442
  const result = await change(state);
5499
- await mkdir8(path19.dirname(this.file), { recursive: true });
5443
+ await mkdir8(path18.dirname(this.file), { recursive: true });
5500
5444
  const temporary = this.file + "." + randomUUID5();
5501
5445
  try {
5502
5446
  await writeFile8(temporary, JSON.stringify(state, null, 2) + "\n", { mode: 384, flag: "wx" });
@@ -5765,7 +5709,7 @@ var init_agent_manager = __esm({
5765
5709
 
5766
5710
  // src/utils/filesystem/apply_patch.ts
5767
5711
  import { mkdir as mkdir9, readFile as readFile9, stat, unlink as unlink2, writeFile as writeFile9 } from "node:fs/promises";
5768
- import path20 from "node:path";
5712
+ import path19 from "node:path";
5769
5713
  function patchError(message) {
5770
5714
  return new Error(`Invalid patch: ${message}`);
5771
5715
  }
@@ -6108,7 +6052,7 @@ function throwIfAborted(signal) {
6108
6052
  }
6109
6053
  async function writeWithParents(target, contents, signal) {
6110
6054
  throwIfAborted(signal);
6111
- await mkdir9(path20.dirname(target), { recursive: true });
6055
+ await mkdir9(path19.dirname(target), { recursive: true });
6112
6056
  await writeFile9(target, contents, { encoding: "utf8", signal });
6113
6057
  }
6114
6058
  function formatApplyPatchSummary(paths) {
@@ -6729,9 +6673,9 @@ var init_read_mcp_resource = __esm({
6729
6673
  // src/utils/execution/process_manager.ts
6730
6674
  import { spawn as spawn5 } from "node:child_process";
6731
6675
  import { closeSync, mkdtempSync, openSync, writeSync } from "node:fs";
6732
- import { open as open2, rm as rm6 } from "node:fs/promises";
6733
- import { tmpdir as tmpdir5 } from "node:os";
6734
- import path21 from "node:path";
6676
+ import { open as open2, rm as rm5 } from "node:fs/promises";
6677
+ import { tmpdir as tmpdir4 } from "node:os";
6678
+ import path20 from "node:path";
6735
6679
  import { randomUUID as randomUUID9 } from "node:crypto";
6736
6680
  import { setTimeout as delay3 } from "node:timers/promises";
6737
6681
  import { getShellConfig as getShellConfig3 } from "@earendil-works/pi-coding-agent";
@@ -6751,9 +6695,9 @@ var init_process_manager = __esm({
6751
6695
  if (this.disposed) throw new Error("Process manager is closed");
6752
6696
  if ([...this.processes.values()].filter((p) => p.running).length >= 32)
6753
6697
  throw new Error("At most 32 background processes may run at once");
6754
- this.directory ??= mkdtempSync(path21.join(tmpdir5(), "scaling-processes-"));
6698
+ this.directory ??= mkdtempSync(path20.join(tmpdir4(), "scaling-processes-"));
6755
6699
  const id = randomUUID9();
6756
- const outputPath = path21.join(this.directory, id + ".log");
6700
+ const outputPath = path20.join(this.directory, id + ".log");
6757
6701
  const fd = openSync(outputPath, "wx", 384);
6758
6702
  const shell = getShellConfig3();
6759
6703
  let child;
@@ -6917,7 +6861,7 @@ var init_process_manager = __esm({
6917
6861
  async dispose() {
6918
6862
  this.disposed = true;
6919
6863
  await Promise.all([...this.processes.keys()].map((id) => this.stop(id)));
6920
- if (this.directory) await rm6(this.directory, { recursive: true, force: true });
6864
+ if (this.directory) await rm5(this.directory, { recursive: true, force: true });
6921
6865
  }
6922
6866
  };
6923
6867
  }
@@ -7053,8 +6997,8 @@ var init_memory_store = __esm({
7053
6997
  });
7054
6998
 
7055
6999
  // src/utils/skills/skill_store.ts
7056
- import { readFile as readFile11, mkdir as mkdir10, writeFile as writeFile11, rm as rm7, realpath as realpath3 } from "node:fs/promises";
7057
- import path22 from "node:path";
7000
+ import { readFile as readFile11, mkdir as mkdir10, writeFile as writeFile11, rm as rm6, realpath as realpath2 } from "node:fs/promises";
7001
+ import path21 from "node:path";
7058
7002
  import { loadSkills } from "@earendil-works/pi-coding-agent";
7059
7003
  var SkillStore;
7060
7004
  var init_skill_store = __esm({
@@ -7069,7 +7013,7 @@ var init_skill_store = __esm({
7069
7013
  constructor(cwd, managedRoot, roots = []) {
7070
7014
  this.cwd = cwd;
7071
7015
  this.managedRoot = managedRoot;
7072
- this.roots = roots.map((root) => path22.resolve(cwd, root));
7016
+ this.roots = roots.map((root) => path21.resolve(cwd, root));
7073
7017
  }
7074
7018
  list() {
7075
7019
  return loadSkills({
@@ -7097,29 +7041,29 @@ var init_skill_store = __esm({
7097
7041
  throw new Error("content must contain a complete SKILL.md with name and description frontmatter");
7098
7042
  await mkdir10(directory);
7099
7043
  try {
7100
- await writeFile11(path22.join(directory, "SKILL.md"), input.content, { flag: "wx" });
7044
+ await writeFile11(path21.join(directory, "SKILL.md"), input.content, { flag: "wx" });
7101
7045
  const skill = this.list().skills.find((s) => s.name === input.name);
7102
- if (!skill || await realpath3(skill.baseDir) !== directory)
7046
+ if (!skill || await realpath2(skill.baseDir) !== directory)
7103
7047
  throw new Error("Invalid SKILL.md frontmatter, or name does not match the requested skill");
7104
7048
  } catch (error) {
7105
- await rm7(directory, { recursive: true, force: true });
7049
+ await rm6(directory, { recursive: true, force: true });
7106
7050
  throw error;
7107
7051
  }
7108
7052
  } else {
7109
7053
  const skill = this.find(input.name);
7110
- if (await realpath3(skill.baseDir) !== directory)
7054
+ if (await realpath2(skill.baseDir) !== directory)
7111
7055
  throw new Error("Only run-owned skills can be modified; source skills are read-only");
7112
- if (input.action === "delete") await rm7(directory, { recursive: true });
7056
+ if (input.action === "delete") await rm6(directory, { recursive: true });
7113
7057
  else {
7114
7058
  const target = await resolveWorkspacePath(directory, input.path ?? "SKILL.md");
7115
- const isSkillFile = target === path22.join(directory, "SKILL.md");
7059
+ const isSkillFile = target === path21.join(directory, "SKILL.md");
7116
7060
  if (input.action === "remove_file") {
7117
7061
  if (isSkillFile) throw new Error("Use delete to remove the whole skill");
7118
- await rm7(target);
7062
+ await rm6(target);
7119
7063
  } else if (input.action === "write_file") {
7120
7064
  if (input.content === void 0) throw new Error("content is required");
7121
7065
  if (isSkillFile) throw new Error("Use patch to update SKILL.md");
7122
- await mkdir10(path22.dirname(target), { recursive: true });
7066
+ await mkdir10(path21.dirname(target), { recursive: true });
7123
7067
  await writeFile11(target, input.content);
7124
7068
  } else {
7125
7069
  if (!input.old_string || input.new_string === void 0)
@@ -7145,7 +7089,7 @@ import { execFile } from "node:child_process";
7145
7089
  import { promisify as promisify2 } from "node:util";
7146
7090
  import { mkdir as mkdir11 } from "node:fs/promises";
7147
7091
  import { randomUUID as randomUUID11 } from "node:crypto";
7148
- import path23 from "node:path";
7092
+ import path22 from "node:path";
7149
7093
  var execute, WorktreeManager;
7150
7094
  var init_worktree_manager = __esm({
7151
7095
  "src/utils/filesystem/worktree_manager.ts"() {
@@ -7167,8 +7111,8 @@ var init_worktree_manager = __esm({
7167
7111
  throw new Error("Worktree name must be a slug of at most 64 characters");
7168
7112
  const { stdout } = await execute("git", ["rev-parse", "--show-toplevel"], { cwd: this.cwd, signal });
7169
7113
  const root = stdout.trim();
7170
- const directory = await resolveWorkspacePath(root, path23.join(".pi", "worktrees", slug));
7171
- await mkdir11(path23.dirname(directory), { recursive: true });
7114
+ const directory = await resolveWorkspacePath(root, path22.join(".pi", "worktrees", slug));
7115
+ await mkdir11(path22.dirname(directory), { recursive: true });
7172
7116
  const branch = "dragon/" + slug;
7173
7117
  await execute("git", ["worktree", "add", "-b", branch, directory, "HEAD"], { cwd: root, signal });
7174
7118
  const worktree = { id: randomUUID11(), path: directory, branch, status: "active" };
@@ -7197,7 +7141,7 @@ var init_worktree_manager = __esm({
7197
7141
  // src/utils/secrets/secret_vault.ts
7198
7142
  import { randomBytes, createCipheriv, createDecipheriv } from "node:crypto";
7199
7143
  import { mkdir as mkdir12, readFile as readFile12, writeFile as writeFile12 } from "node:fs/promises";
7200
- import path24 from "node:path";
7144
+ import path23 from "node:path";
7201
7145
  var SecretVault;
7202
7146
  var init_secret_vault = __esm({
7203
7147
  "src/utils/secrets/secret_vault.ts"() {
@@ -7210,14 +7154,14 @@ var init_secret_vault = __esm({
7210
7154
  constructor(root, parent) {
7211
7155
  this.root = root;
7212
7156
  this.parent = parent;
7213
- this.store = new JsonStore(path24.join(root, "vault.json"), { entries: [] });
7157
+ this.store = new JsonStore(path23.join(root, "vault.json"), { entries: [] });
7214
7158
  }
7215
7159
  name(name) {
7216
7160
  if (!/^[A-Za-z0-9_-]{1,128}$/u.test(name)) throw new Error("Secret name must be an identifier");
7217
7161
  return name;
7218
7162
  }
7219
7163
  async key() {
7220
- const file = path24.join(this.root, "key");
7164
+ const file = path23.join(this.root, "key");
7221
7165
  await mkdir12(this.root, { recursive: true, mode: 448 });
7222
7166
  let key;
7223
7167
  try {
@@ -7291,12 +7235,12 @@ var init_secret_vault = __esm({
7291
7235
  });
7292
7236
 
7293
7237
  // src/capabilities/task-tool-space.ts
7294
- import path25 from "node:path";
7238
+ import path24 from "node:path";
7295
7239
  function createBaseTaskToolSpace(options) {
7296
7240
  const { cwd, stateDirectory } = options;
7297
7241
  const settings = options.settings ?? loadCapabilitySettings(cwd);
7298
7242
  const processes = new ProcessManager(cwd);
7299
- const secrets = new SecretVault(path25.join(stateDirectory, "secrets"), options.parentSecrets);
7243
+ const secrets = new SecretVault(path24.join(stateDirectory, "secrets"), options.parentSecrets);
7300
7244
  const resolveRecord = async (value) => value ? Object.fromEntries(
7301
7245
  await Promise.all(Object.entries(value).map(async ([key, text2]) => [key, await secrets.interpolate(text2)]))
7302
7246
  ) : void 0;
@@ -7309,15 +7253,15 @@ function createBaseTaskToolSpace(options) {
7309
7253
  ...resolved,
7310
7254
  options: {
7311
7255
  ...resolved.options,
7312
- cwd: path25.resolve(cwd, resolved.options.cwd ?? "."),
7256
+ cwd: path24.resolve(cwd, resolved.options.cwd ?? "."),
7313
7257
  env: await resolveRecord(resolved.options.env)
7314
7258
  }
7315
7259
  };
7316
7260
  }
7317
7261
  });
7318
- const memory = new MemoryStore(path25.join(stateDirectory, "memory.json"), options.initialMemory);
7319
- const skills = new SkillStore(cwd, path25.join(stateDirectory, "skills"), options.skillPaths);
7320
- const worktrees = new WorktreeManager(cwd, path25.join(stateDirectory, "worktrees.json"));
7262
+ const memory = new MemoryStore(path24.join(stateDirectory, "memory.json"), options.initialMemory);
7263
+ const skills = new SkillStore(cwd, path24.join(stateDirectory, "skills"), options.skillPaths);
7264
+ const worktrees = new WorktreeManager(cwd, path24.join(stateDirectory, "worktrees.json"));
7321
7265
  const tools = [
7322
7266
  createReadFileTool(cwd),
7323
7267
  createApplyPatchTool(cwd),
@@ -7395,7 +7339,7 @@ var init_task_tool_space = __esm({
7395
7339
 
7396
7340
  // src/utils/clients/media/video_jobs.ts
7397
7341
  import { mkdir as mkdir13, writeFile as writeFile13 } from "node:fs/promises";
7398
- import path26 from "node:path";
7342
+ import path25 from "node:path";
7399
7343
  var VideoJobs;
7400
7344
  var init_video_jobs = __esm({
7401
7345
  "src/utils/clients/media/video_jobs.ts"() {
@@ -7466,7 +7410,7 @@ var init_video_jobs = __esm({
7466
7410
  if (!response.ok) throw new Error(`Video download failed: ${response.status}`);
7467
7411
  const bytes = await responseBytes2(response, 200 * 1024 * 1024);
7468
7412
  signal?.throwIfAborted();
7469
- await mkdir13(path26.dirname(target), { recursive: true });
7413
+ await mkdir13(path25.dirname(target), { recursive: true });
7470
7414
  await writeFile13(target, bytes, { signal });
7471
7415
  }
7472
7416
  return { task_id: taskId, status, video_url: url, file_path: filePath, usage: payload.usage };
@@ -7612,7 +7556,7 @@ var init_scheduler = __esm({
7612
7556
  // src/utils/lsp/lsp_manager.ts
7613
7557
  import { spawn as spawn6 } from "node:child_process";
7614
7558
  import { readFile as readFile13 } from "node:fs/promises";
7615
- import path27 from "node:path";
7559
+ import path26 from "node:path";
7616
7560
  import { pathToFileURL as pathToFileURL2 } from "node:url";
7617
7561
  import {
7618
7562
  createMessageConnection,
@@ -7755,8 +7699,8 @@ var init_lsp_manager = __esm({
7755
7699
  }
7756
7700
  async query(input, signal) {
7757
7701
  const file = await resolveWorkspacePath(this.cwd, input.file_path);
7758
- const name = input.server ?? Object.keys(this.configs).find((name2) => this.configs[name2].extensions.includes(path27.extname(file)));
7759
- if (!name) throw new Error(`No LSP server configured for ${path27.extname(file)}`);
7702
+ const name = input.server ?? Object.keys(this.configs).find((name2) => this.configs[name2].extensions.includes(path26.extname(file)));
7703
+ if (!name) throw new Error(`No LSP server configured for ${path26.extname(file)}`);
7760
7704
  const server2 = await this.server(name, signal);
7761
7705
  const uri = pathToFileURL2(file).href;
7762
7706
  await this.synchronize(name, server2, file, uri, signal);
@@ -8060,7 +8004,7 @@ var init_artifact_store = __esm({
8060
8004
 
8061
8005
  // src/utils/sessions/session_catalog.ts
8062
8006
  import { SessionManager } from "@earendil-works/pi-coding-agent";
8063
- import path28 from "node:path";
8007
+ import path27 from "node:path";
8064
8008
  var SessionCatalog;
8065
8009
  var init_session_catalog = __esm({
8066
8010
  "src/utils/sessions/session_catalog.ts"() {
@@ -8074,7 +8018,7 @@ var init_session_catalog = __esm({
8074
8018
  current;
8075
8019
  constructor(cwd, directory, stateFile, current) {
8076
8020
  this.cwd = cwd;
8077
- this.directory = path28.resolve(cwd, directory);
8021
+ this.directory = path27.resolve(cwd, directory);
8078
8022
  this.metadata = new JsonStore(stateFile, {});
8079
8023
  this.current = current;
8080
8024
  }
@@ -8235,7 +8179,7 @@ var init_connection_manager = __esm({
8235
8179
 
8236
8180
  // src/utils/plugins/plugin_manager.ts
8237
8181
  import { mkdir as mkdir14 } from "node:fs/promises";
8238
- import path29 from "node:path";
8182
+ import path28 from "node:path";
8239
8183
  import { DefaultPackageManager, SettingsManager as SettingsManager5 } from "@earendil-works/pi-coding-agent";
8240
8184
  var PluginManager;
8241
8185
  var init_plugin_manager = __esm({
@@ -8249,15 +8193,15 @@ var init_plugin_manager = __esm({
8249
8193
  settings;
8250
8194
  constructor(root) {
8251
8195
  this.root = root;
8252
- this.store = new JsonStore(path29.join(root, "catalog.json"), { plugins: [] });
8196
+ this.store = new JsonStore(path28.join(root, "catalog.json"), { plugins: [] });
8253
8197
  }
8254
8198
  async manager() {
8255
8199
  if (!this.packageManager) {
8256
8200
  await mkdir14(this.root, { recursive: true });
8257
- this.settings = SettingsManager5.create(this.root, path29.join(this.root, "agent"), { projectTrusted: true });
8201
+ this.settings = SettingsManager5.create(this.root, path28.join(this.root, "agent"), { projectTrusted: true });
8258
8202
  this.packageManager = new DefaultPackageManager({
8259
8203
  cwd: this.root,
8260
- agentDir: path29.join(this.root, "agent"),
8204
+ agentDir: path28.join(this.root, "agent"),
8261
8205
  settingsManager: this.settings
8262
8206
  });
8263
8207
  }
@@ -10182,10 +10126,10 @@ var init_workflow = __esm({
10182
10126
  });
10183
10127
 
10184
10128
  // src/capabilities/expanded-task-tool-space.ts
10185
- import path30 from "node:path";
10129
+ import path29 from "node:path";
10186
10130
  function createExpandedTaskToolSpace(options) {
10187
10131
  const base = createBaseTaskToolSpace(options);
10188
- const file = (name) => path30.join(options.stateDirectory, name);
10132
+ const file = (name) => path29.join(options.stateDirectory, name);
10189
10133
  const tasks = new TaskStore(file("tasks.json"));
10190
10134
  const goals = new GoalStore(file("goal.json"), options.goalUsage);
10191
10135
  const scheduler = new Scheduler(file("schedules.json"), options.wake);
@@ -10386,7 +10330,7 @@ var child_exports = {};
10386
10330
  __export(child_exports, {
10387
10331
  runScalingChild: () => runScalingChild
10388
10332
  });
10389
- import path31 from "node:path";
10333
+ import path30 from "node:path";
10390
10334
  import { InMemoryCredentialStore } from "@earendil-works/pi-ai";
10391
10335
  import {
10392
10336
  createAgentSession,
@@ -10446,7 +10390,7 @@ async function runScalingChild(task, parent, signal, config, limits, budget, par
10446
10390
  await loader.reload();
10447
10391
  const manager = SessionManager2.create(
10448
10392
  parent.cwd,
10449
- path31.join(parent.sessionManager.getSessionDir(), "scaling-children"),
10393
+ path30.join(parent.sessionManager.getSessionDir(), "scaling-children"),
10450
10394
  { parentSession: parent.sessionManager.getSessionFile() }
10451
10395
  );
10452
10396
  const { session } = await createAgentSession({
@@ -10524,8 +10468,8 @@ var init_child = __esm({
10524
10468
  });
10525
10469
 
10526
10470
  // src/harnesses/scaling/runtime.ts
10527
- import path32 from "node:path";
10528
- import { tmpdir as tmpdir6 } from "node:os";
10471
+ import path31 from "node:path";
10472
+ import { tmpdir as tmpdir5 } from "node:os";
10529
10473
  import { randomUUID as randomUUID19 } from "node:crypto";
10530
10474
  import {
10531
10475
  SettingsManager as SettingsManager7,
@@ -10555,7 +10499,7 @@ function createScalingRuntime(input, options = {}) {
10555
10499
  let turn = 0;
10556
10500
  let disposing;
10557
10501
  let initialized = false;
10558
- let stateDirectory = path32.join(tmpdir6(), "scaling-pending-" + randomUUID19());
10502
+ let stateDirectory = path31.join(tmpdir5(), "scaling-pending-" + randomUUID19());
10559
10503
  const toolName = (name) => visibleToolName(config.TS, name);
10560
10504
  const makeToolSpace = (directory) => {
10561
10505
  const common = { ...options.toolServices, cwd, stateDirectory: directory, parentSecrets: options.parentSecrets };
@@ -10828,9 +10772,9 @@ function createScalingRuntime(input, options = {}) {
10828
10772
  budget.onChange = (state) => pi.appendEntry("scaling-budget", state);
10829
10773
  }
10830
10774
  boundContext = ctx;
10831
- const root = options.toolServices?.stateRoot ? path32.resolve(cwd, options.toolServices.stateRoot) : path32.join(ctx.sessionManager.getSessionDir(), "scaling-tools");
10832
- const directory = path32.join(root, ctx.sessionManager.getSessionId());
10833
- if (savedConfig?.toolStateDirectory && path32.resolve(savedConfig.toolStateDirectory) !== path32.resolve(directory))
10775
+ const root = options.toolServices?.stateRoot ? path31.resolve(cwd, options.toolServices.stateRoot) : path31.join(ctx.sessionManager.getSessionDir(), "scaling-tools");
10776
+ const directory = path31.join(root, ctx.sessionManager.getSessionId());
10777
+ if (savedConfig?.toolStateDirectory && path31.resolve(savedConfig.toolStateDirectory) !== path31.resolve(directory))
10834
10778
  fail(
10835
10779
  new Error(
10836
10780
  "This session used a different task-tool state root; restore its service configuration or start a new session"
@@ -10848,7 +10792,7 @@ function createScalingRuntime(input, options = {}) {
10848
10792
  if ("initialize" in toolSpace) await toolSpace.initialize();
10849
10793
  initialized = true;
10850
10794
  }
10851
- await agents?.bind(path32.join(stateDirectory, "agents.json"));
10795
+ await agents?.bind(path31.join(stateDirectory, "agents.json"));
10852
10796
  if (!previous)
10853
10797
  pi.appendEntry("scaling-config", {
10854
10798
  version: SCALING_RUNTIME_VERSION,
@@ -11098,11 +11042,11 @@ function createAgentArenaEditFileTool(cwd) {
11098
11042
  promptSnippet: "Edit files with exact text replacement",
11099
11043
  parameters: agentArenaSchema,
11100
11044
  async execute(toolCallId, params, signal, _onUpdate, context) {
11101
- const path35 = await resolveWorkspacePath(cwd, params.path);
11045
+ const path34 = await resolveWorkspacePath(cwd, params.path);
11102
11046
  const nativeEdit = createEditToolDefinition(cwd);
11103
11047
  await nativeEdit.execute(
11104
11048
  toolCallId,
11105
- { path: path35, edits: [{ oldText: params.old_text, newText: params.new_text }] },
11049
+ { path: path34, edits: [{ oldText: params.old_text, newText: params.new_text }] },
11106
11050
  signal,
11107
11051
  void 0,
11108
11052
  context
@@ -11119,11 +11063,11 @@ function createCodeEditFileTool(cwd) {
11119
11063
  promptSnippet: "Edit project files",
11120
11064
  parameters: codeSchema,
11121
11065
  async execute(toolCallId, params, signal, _onUpdate, context) {
11122
- const path35 = await resolveWorkspacePath(cwd, params.path);
11066
+ const path34 = await resolveWorkspacePath(cwd, params.path);
11123
11067
  const nativeEdit = createEditToolDefinition(cwd);
11124
11068
  await nativeEdit.execute(
11125
11069
  toolCallId,
11126
- { path: path35, edits: [{ oldText: params.context, newText: params.replacement }] },
11070
+ { path: path34, edits: [{ oldText: params.context, newText: params.replacement }] },
11127
11071
  signal,
11128
11072
  void 0,
11129
11073
  context
@@ -11152,9 +11096,9 @@ function createWriteFileTool(cwd) {
11152
11096
  promptSnippet: "Create or overwrite workspace files",
11153
11097
  parameters: schema,
11154
11098
  async execute(toolCallId, params, signal, _onUpdate, context) {
11155
- const path35 = await resolveWorkspacePath(cwd, params.path);
11099
+ const path34 = await resolveWorkspacePath(cwd, params.path);
11156
11100
  const nativeWrite = createWriteToolDefinition(cwd);
11157
- await nativeWrite.execute(toolCallId, { path: path35, content: params.content }, signal, void 0, context);
11101
+ await nativeWrite.execute(toolCallId, { path: path34, content: params.content }, signal, void 0, context);
11158
11102
  return jsonToolResult({ status: "success" });
11159
11103
  }
11160
11104
  });
@@ -12051,9 +11995,9 @@ function createCreateFileTool(cwd) {
12051
11995
  promptSnippet: "Create project files",
12052
11996
  parameters: schema8,
12053
11997
  async execute(toolCallId, params, signal, _onUpdate, context) {
12054
- const path35 = await resolveWorkspacePath(cwd, params.path);
11998
+ const path34 = await resolveWorkspacePath(cwd, params.path);
12055
11999
  const nativeWrite = createWriteToolDefinition2(cwd);
12056
- await nativeWrite.execute(toolCallId, { path: path35, content: params.content }, signal, void 0, context);
12000
+ await nativeWrite.execute(toolCallId, { path: path34, content: params.content }, signal, void 0, context);
12057
12001
  return jsonToolResult({ status: "success", message: `Created ${params.path}.` });
12058
12002
  }
12059
12003
  });
@@ -12076,8 +12020,8 @@ function createDeleteFileTool(cwd) {
12076
12020
  promptSnippet: "Delete project files",
12077
12021
  parameters: schema9,
12078
12022
  async execute(_toolCallId, params) {
12079
- const path35 = await resolveWorkspacePath(cwd, params.path);
12080
- await rm3(path35, { recursive: true, force: true });
12023
+ const path34 = await resolveWorkspacePath(cwd, params.path);
12024
+ await rm3(path34, { recursive: true, force: true });
12081
12025
  return jsonToolResult({ status: "success" });
12082
12026
  }
12083
12027
  });
@@ -12180,7 +12124,7 @@ function createGrepFilesTool(cwd) {
12180
12124
  return jsonToolResult({
12181
12125
  status: "success",
12182
12126
  mode: outputMode,
12183
- counts: [...counts].map(([path35, count]) => ({ path: path35, count })),
12127
+ counts: [...counts].map(([path34, count]) => ({ path: path34, count })),
12184
12128
  totalMatches: lines.length
12185
12129
  });
12186
12130
  }
@@ -12216,7 +12160,7 @@ function createListFilesTool(cwd) {
12216
12160
  const text2 = result.content.find((part) => part.type === "text")?.text || "";
12217
12161
  return jsonToolResult({
12218
12162
  status: "success",
12219
- files: text2.split("\n").filter((line) => line && !line.startsWith("[")).map((path35) => ({ path: path35 }))
12163
+ files: text2.split("\n").filter((line) => line && !line.startsWith("[")).map((path34) => ({ path: path34 }))
12220
12164
  });
12221
12165
  }
12222
12166
  });
@@ -13192,7 +13136,7 @@ import { Type as Type94 } from "typebox";
13192
13136
  // src/utils/filesystem/str_replace_editor.ts
13193
13137
  init_workspace();
13194
13138
  import { readFile as readFile16, readdir as readdir3, stat as stat4, writeFile as writeFile14 } from "node:fs/promises";
13195
- import path33 from "node:path";
13139
+ import path32 from "node:path";
13196
13140
  var STR_REPLACE_EDITOR_DEFAULT_MAX_OUTPUT_CHARS = 16e3;
13197
13141
  var TRUNCATED_MESSAGE = "<response clipped><NOTE>To save on context only part of this file has been shown to you. You should retry this tool after you have searched inside the file with `grep -n` in order to find the line numbers of what you are looking for.</NOTE>";
13198
13142
  function throwIfAborted2(signal) {
@@ -13212,7 +13156,7 @@ function requiredForCommand(value, parameter, command, allowEmpty = true) {
13212
13156
  }
13213
13157
  async function resolveAbsoluteWorkspacePath(cwd, rawPath) {
13214
13158
  if (!rawPath.trim()) throw new Error("path must be a non-empty string");
13215
- if (!path33.isAbsolute(rawPath)) {
13159
+ if (!path32.isAbsolute(rawPath)) {
13216
13160
  throw new Error(
13217
13161
  `The path ${rawPath} is not an absolute path, it should start with \`/\`. Maybe you meant /${rawPath}?`
13218
13162
  );
@@ -13285,8 +13229,8 @@ async function listDirectory(target, displayTarget, maxOutputChars, signal) {
13285
13229
  const rows2 = [];
13286
13230
  for (const entry of entries) {
13287
13231
  if (entry.name.startsWith(".") || entry.name === "node_modules" || entry.name === "__pycache__") continue;
13288
- const child = path33.join(directory, entry.name);
13289
- const displayChild = path33.join(displayDirectory, entry.name);
13232
+ const child = path32.join(directory, entry.name);
13233
+ const displayChild = path32.join(displayDirectory, entry.name);
13290
13234
  const type = entry.isDirectory() ? "d" : entry.isFile() ? "f" : "?";
13291
13235
  rows2.push(`${type} ${displayChild}`);
13292
13236
  if (entry.isDirectory() && depth < 2) {
@@ -13330,7 +13274,7 @@ function lineNumbersAt(content, offsets) {
13330
13274
  }
13331
13275
  async function viewPath(cwd, request, maxOutputChars, signal) {
13332
13276
  const target = await resolveAbsoluteWorkspacePath(cwd, request.path);
13333
- const displayTarget = path33.resolve(request.path);
13277
+ const displayTarget = path32.resolve(request.path);
13334
13278
  const type = await requireExisting(target, displayTarget, "view");
13335
13279
  if (type === "directory") {
13336
13280
  if (request.view_range !== void 0) {
@@ -13347,7 +13291,7 @@ async function viewPath(cwd, request, maxOutputChars, signal) {
13347
13291
  async function createFile(cwd, request, signal) {
13348
13292
  const content = requiredForCommand(request.file_text, "file_text", "create");
13349
13293
  const target = await resolveAbsoluteWorkspacePath(cwd, request.path);
13350
- const displayTarget = path33.resolve(request.path);
13294
+ const displayTarget = path32.resolve(request.path);
13351
13295
  throwIfAborted2(signal);
13352
13296
  try {
13353
13297
  await writeFile14(target, content, { encoding: "utf8", flag: "wx", signal });
@@ -13365,7 +13309,7 @@ async function replaceInFile(cwd, request, signal) {
13365
13309
  const oldValue = requiredForCommand(request.old_str, "old_str", "str_replace", false);
13366
13310
  const newValue = request.new_str ?? "";
13367
13311
  const target = await resolveAbsoluteWorkspacePath(cwd, request.path);
13368
- const displayTarget = path33.resolve(request.path);
13312
+ const displayTarget = path32.resolve(request.path);
13369
13313
  const type = await requireExisting(target, displayTarget, "str_replace");
13370
13314
  if (type !== "file") throw new Error(`cannot edit "${displayTarget}": not a regular file`);
13371
13315
  const before = await readFile16(target, { encoding: "utf8", signal });
@@ -13392,7 +13336,7 @@ async function insertInFile(cwd, request, signal) {
13392
13336
  }
13393
13337
  const value = requiredForCommand(request.new_str, "new_str", "insert");
13394
13338
  const target = await resolveAbsoluteWorkspacePath(cwd, request.path);
13395
- const displayTarget = path33.resolve(request.path);
13339
+ const displayTarget = path32.resolve(request.path);
13396
13340
  const type = await requireExisting(target, displayTarget, "insert");
13397
13341
  if (type !== "file") throw new Error(`cannot insert into "${displayTarget}": not a regular file`);
13398
13342
  const before = await readFile16(target, { encoding: "utf8", signal });
@@ -13631,25 +13575,25 @@ function parseHarnessInvocation(args) {
13631
13575
  // src/runtime/subagent-runtime.ts
13632
13576
  import {
13633
13577
  accessSync,
13634
- constants as constants3,
13578
+ constants as constants2,
13635
13579
  readFileSync,
13636
13580
  realpathSync
13637
13581
  } from "node:fs";
13638
- import path34 from "node:path";
13582
+ import path33 from "node:path";
13639
13583
  import { fileURLToPath as fileURLToPath4 } from "node:url";
13640
13584
  var SUBAGENT_PI_BINARY_ENV = "PI_SUBAGENT_PI_BINARY";
13641
13585
  function resolvePackagedHarnessEntrypoint(candidate) {
13642
13586
  try {
13643
13587
  const entrypoint = realpathSync(candidate);
13644
- if (path34.basename(entrypoint) !== "entrypoint.js" || path34.basename(path34.dirname(entrypoint)) !== "dist") {
13588
+ if (path33.basename(entrypoint) !== "entrypoint.js" || path33.basename(path33.dirname(entrypoint)) !== "dist") {
13645
13589
  return void 0;
13646
13590
  }
13647
- const packageRoot = path34.dirname(path34.dirname(entrypoint));
13591
+ const packageRoot = path33.dirname(path33.dirname(entrypoint));
13648
13592
  const packageJson = JSON.parse(
13649
- readFileSync(path34.join(packageRoot, "package.json"), "utf8")
13593
+ readFileSync(path33.join(packageRoot, "package.json"), "utf8")
13650
13594
  );
13651
13595
  if (packageJson.name !== "@qwen-code/qwen-harness") return void 0;
13652
- if (process.platform !== "win32") accessSync(entrypoint, constants3.X_OK);
13596
+ if (process.platform !== "win32") accessSync(entrypoint, constants2.X_OK);
13653
13597
  return entrypoint;
13654
13598
  } catch {
13655
13599
  return void 0;