agentv 0.18.0 → 0.20.0

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.
@@ -145,17 +145,17 @@ import { readFileSync as readFileSync2 } from "node:fs";
145
145
  import { Command } from "commander";
146
146
 
147
147
  // src/commands/eval/index.ts
148
- import { stat as stat3 } from "node:fs/promises";
148
+ import { stat as stat4 } from "node:fs/promises";
149
149
  import path19 from "node:path";
150
150
  import fg from "fast-glob";
151
151
 
152
152
  // src/commands/eval/run-eval.ts
153
153
  import { constants as constants6 } from "node:fs";
154
- import { access as access6, mkdir as mkdir6 } from "node:fs/promises";
154
+ import { access as access6, mkdir as mkdir7 } from "node:fs/promises";
155
155
  import path18 from "node:path";
156
156
  import { pathToFileURL } from "node:url";
157
157
 
158
- // ../../packages/core/dist/chunk-QHEZJRTU.js
158
+ // ../../packages/core/dist/chunk-SVY324GN.js
159
159
  import { constants } from "node:fs";
160
160
  import { access, readFile } from "node:fs/promises";
161
161
  import path from "node:path";
@@ -4201,7 +4201,7 @@ var coerce = {
4201
4201
  };
4202
4202
  var NEVER = INVALID;
4203
4203
 
4204
- // ../../packages/core/dist/chunk-QHEZJRTU.js
4204
+ // ../../packages/core/dist/chunk-SVY324GN.js
4205
4205
  async function fileExists(filePath) {
4206
4206
  try {
4207
4207
  await access(filePath, constants.F_OK);
@@ -4874,18 +4874,18 @@ function isAgentProvider(provider) {
4874
4874
  import { readFile as readFile5 } from "node:fs/promises";
4875
4875
  import path62 from "node:path";
4876
4876
  import { parse as parse22 } from "yaml";
4877
- import { readFile as readFile3 } from "node:fs/promises";
4877
+ import { readFile as readFile6 } from "node:fs/promises";
4878
4878
  import path22 from "node:path";
4879
4879
  import micromatch from "micromatch";
4880
4880
  import { parse as parse5 } from "yaml";
4881
4881
  import { constants as constants3 } from "node:fs";
4882
4882
  import { access as access3 } from "node:fs/promises";
4883
- import path8 from "node:path";
4883
+ import path12 from "node:path";
4884
4884
  import path32 from "node:path";
4885
4885
  import { readFile as readFile22 } from "node:fs/promises";
4886
4886
  import { readFile as readFile32 } from "node:fs/promises";
4887
4887
  import path42 from "node:path";
4888
- import { readFile as readFile4 } from "node:fs/promises";
4888
+ import { readFile as readFile42 } from "node:fs/promises";
4889
4889
  import path52 from "node:path";
4890
4890
 
4891
4891
  // ../../node_modules/.bun/@ai-sdk+provider@2.0.0/node_modules/@ai-sdk/provider/dist/index.mjs
@@ -32481,34 +32481,21 @@ import { promisify as promisify2 } from "node:util";
32481
32481
  import { exec as execCallback, spawn as spawn2 } from "node:child_process";
32482
32482
  import { randomUUID } from "node:crypto";
32483
32483
  import { constants as constants22, createWriteStream } from "node:fs";
32484
- import { access as access22, mkdir as mkdir3, mkdtemp, rm as rm2, writeFile as writeFile3 } from "node:fs/promises";
32484
+ import { access as access22, mkdir as mkdir4, mkdtemp, rm as rm2, writeFile as writeFile5 } from "node:fs/promises";
32485
32485
  import { tmpdir } from "node:os";
32486
- import path9 from "node:path";
32486
+ import path92 from "node:path";
32487
32487
  import { promisify as promisify22 } from "node:util";
32488
32488
  import path82 from "node:path";
32489
- import path10 from "node:path";
32489
+ import path102 from "node:path";
32490
32490
 
32491
- // ../../node_modules/.bun/subagent@0.4.7/node_modules/subagent/dist/vscode/agentDispatch.js
32492
- import { exec, spawn } from "child_process";
32493
- import { copyFile, mkdir as mkdir2, readdir as readdir2, readFile as readFile2, stat as stat2, writeFile } from "fs/promises";
32494
- import path6 from "path";
32495
- import { promisify } from "util";
32496
-
32497
- // ../../node_modules/.bun/subagent@0.4.7/node_modules/subagent/dist/vscode/constants.js
32498
- import os from "os";
32499
- import path2 from "path";
32500
- var DEFAULT_LOCK_NAME = "subagent.lock";
32501
- var DEFAULT_ALIVE_FILENAME = ".alive";
32502
- function getDefaultSubagentRoot(vscodeCmd = "code") {
32503
- const folder = vscodeCmd === "code-insiders" ? "vscode-insiders-agents" : "vscode-agents";
32504
- return path2.join(os.homedir(), ".subagent", folder);
32505
- }
32506
- var DEFAULT_SUBAGENT_ROOT = getDefaultSubagentRoot();
32491
+ // ../../node_modules/.bun/subagent@0.5.5/node_modules/subagent/dist/vscode/agentDispatch.js
32492
+ import { stat as stat3, writeFile as writeFile3 } from "node:fs/promises";
32493
+ import path10 from "node:path";
32507
32494
 
32508
- // ../../node_modules/.bun/subagent@0.4.7/node_modules/subagent/dist/utils/fs.js
32509
- import { constants as constants2 } from "fs";
32510
- import { access as access2, mkdir, readdir, rm, stat } from "fs/promises";
32511
- import path3 from "path";
32495
+ // ../../node_modules/.bun/subagent@0.5.5/node_modules/subagent/dist/utils/fs.js
32496
+ import { constants as constants2 } from "node:fs";
32497
+ import { access as access2, mkdir, readdir, rm, stat } from "node:fs/promises";
32498
+ import path2 from "node:path";
32512
32499
  async function pathExists(target) {
32513
32500
  try {
32514
32501
  await access2(target, constants2.F_OK);
@@ -32524,7 +32511,7 @@ async function readDirEntries(target) {
32524
32511
  const entries = await readdir(target, { withFileTypes: true });
32525
32512
  return entries.map((entry) => ({
32526
32513
  name: entry.name,
32527
- absolutePath: path3.join(target, entry.name),
32514
+ absolutePath: path2.join(target, entry.name),
32528
32515
  isDirectory: entry.isDirectory()
32529
32516
  }));
32530
32517
  }
@@ -32538,10 +32525,10 @@ async function removeIfExists(target) {
32538
32525
  }
32539
32526
  }
32540
32527
 
32541
- // ../../node_modules/.bun/subagent@0.4.7/node_modules/subagent/dist/utils/path.js
32542
- import path4 from "path";
32528
+ // ../../node_modules/.bun/subagent@0.5.5/node_modules/subagent/dist/utils/path.js
32529
+ import path3 from "node:path";
32543
32530
  function pathToFileUri(filePath) {
32544
- const absolutePath = path4.isAbsolute(filePath) ? filePath : path4.resolve(filePath);
32531
+ const absolutePath = path3.isAbsolute(filePath) ? filePath : path3.resolve(filePath);
32545
32532
  const normalizedPath = absolutePath.replace(/\\/g, "/");
32546
32533
  if (/^[a-zA-Z]:\//.test(normalizedPath)) {
32547
32534
  return `file:///${normalizedPath}`;
@@ -32549,15 +32536,333 @@ function pathToFileUri(filePath) {
32549
32536
  return `file://${normalizedPath}`;
32550
32537
  }
32551
32538
 
32552
- // ../../node_modules/.bun/subagent@0.4.7/node_modules/subagent/dist/utils/time.js
32539
+ // ../../node_modules/.bun/subagent@0.5.5/node_modules/subagent/dist/vscode/promptBuilder.js
32540
+ import { readFile as readFile2 } from "node:fs/promises";
32541
+ import path4 from "node:path";
32542
+
32543
+ // ../../node_modules/.bun/subagent@0.5.5/node_modules/subagent/dist/utils/template.js
32544
+ function renderTemplate(content, variables) {
32545
+ if (!content) {
32546
+ return content;
32547
+ }
32548
+ const variableLookup = /* @__PURE__ */ new Map();
32549
+ for (const [key2, value] of Object.entries(variables)) {
32550
+ variableLookup.set(key2.toLowerCase(), value);
32551
+ }
32552
+ const referencedVariables = /* @__PURE__ */ new Set();
32553
+ const result = content.replace(/\{\{([a-zA-Z_]+)\}\}/gi, (match, variableName) => {
32554
+ const lowerCaseKey = variableName.toLowerCase();
32555
+ referencedVariables.add(lowerCaseKey);
32556
+ if (!variableLookup.has(lowerCaseKey)) {
32557
+ throw new Error(`Template variable '${variableName}' is not provided in the variables object`);
32558
+ }
32559
+ return variableLookup.get(lowerCaseKey);
32560
+ });
32561
+ return result;
32562
+ }
32563
+
32564
+ // ../../node_modules/.bun/subagent@0.5.5/node_modules/subagent/dist/vscode/templates.js
32565
+ var DEFAULT_REQUEST_TEMPLATE = `[[ ## system_instructions ## ]]
32566
+
32567
+ **IMPORTANT**: Follow these exact steps:
32568
+ 1. Create and write your complete response to: {{responseFileTmp}}
32569
+ 2. When completely finished, run these PowerShell commands to signal completion:
32570
+ \`\`\`
32571
+ Move-Item -LiteralPath '{{responseFileTmp}}' -Destination '{{responseFileFinal}}'
32572
+ if (Test-Path subagent.lock) { del subagent.lock }
32573
+ \`\`\`
32574
+
32575
+ Do not proceed to step 2 until your response is completely written to the temporary file.
32576
+
32577
+ [[ ## task ## ]]
32578
+
32579
+ {{userQuery}}
32580
+ `;
32581
+ var DEFAULT_BATCH_REQUEST_TEMPLATE = `[[ ## system_instructions ## ]]
32582
+
32583
+ **IMPORTANT**: Follow these exact steps:
32584
+ 1. Create and write your complete response to: {{responseFileTmp}}
32585
+ 2. When completely finished and the response is stable, rename it to: {{responseFileFinal}}
32586
+ 5. Do not unlock the workspace from this request; batch orchestration will handle unlocking after all responses are ready.
32587
+
32588
+ [[ ## task ## ]]
32589
+
32590
+ {{userQuery}}
32591
+ `;
32592
+ var DEFAULT_BATCH_ORCHESTRATOR_TEMPLATE = `MANDATORY: Run #runSubagent tool in your Available Actions for each request file to process them in isolated contexts.
32593
+ DO NOT read the request files yourself - only pass the file paths to each subagent:
32594
+
32595
+ {{requestFiles}}
32596
+
32597
+ After ALL queries complete, verify all responses exist and unlock:
32598
+
32599
+ \`\`\`powershell
32600
+ $responses = @({{responseList}})
32601
+ $missing = $responses | Where-Object { -not (Test-Path "messages/$_") }
32602
+ if ($missing.Count -eq 0) { del subagent.lock }
32603
+ \`\`\`
32604
+ `;
32605
+
32606
+ // ../../node_modules/.bun/subagent@0.5.5/node_modules/subagent/dist/vscode/promptBuilder.js
32607
+ async function loadTemplateFile(filePath) {
32608
+ try {
32609
+ return await readFile2(filePath, "utf8");
32610
+ } catch (error40) {
32611
+ throw new Error(`Failed to load template file '${filePath}': ${error40.message}`);
32612
+ }
32613
+ }
32614
+ function loadDefaultRequestTemplate() {
32615
+ return DEFAULT_REQUEST_TEMPLATE;
32616
+ }
32617
+ function loadDefaultBatchRequestTemplate() {
32618
+ return DEFAULT_BATCH_REQUEST_TEMPLATE;
32619
+ }
32620
+ function loadDefaultBatchOrchestratorTemplate() {
32621
+ return DEFAULT_BATCH_ORCHESTRATOR_TEMPLATE;
32622
+ }
32623
+ function createRequestPrompt(userQuery, responseFileTmp, responseFileFinal, templateContent) {
32624
+ return renderTemplate(templateContent, {
32625
+ userQuery,
32626
+ responseFileTmp,
32627
+ responseFileFinal
32628
+ });
32629
+ }
32630
+ function createBatchRequestPrompt(userQuery, responseFileTmp, responseFileFinal, templateContent) {
32631
+ return renderTemplate(templateContent, {
32632
+ userQuery,
32633
+ responseFileTmp,
32634
+ responseFileFinal
32635
+ });
32636
+ }
32637
+ function createBatchOrchestratorPrompt(requestFiles, responseFiles, templateContent) {
32638
+ const requestLines = requestFiles.map((file2, index) => `${index + 1}. messages/${path4.basename(file2)}`).join("\n");
32639
+ const responseList = responseFiles.map((file2) => `"${path4.basename(file2)}"`).join(", ");
32640
+ return renderTemplate(templateContent, {
32641
+ requestFiles: requestLines,
32642
+ responseList
32643
+ });
32644
+ }
32645
+
32646
+ // ../../node_modules/.bun/subagent@0.5.5/node_modules/subagent/dist/vscode/responseWaiter.js
32647
+ import { readFile as readFile3 } from "node:fs/promises";
32648
+ import path5 from "node:path";
32649
+
32650
+ // ../../node_modules/.bun/subagent@0.5.5/node_modules/subagent/dist/utils/time.js
32553
32651
  function sleep(ms) {
32554
32652
  return new Promise((resolve2) => {
32555
32653
  setTimeout(resolve2, ms);
32556
32654
  });
32557
32655
  }
32558
32656
 
32559
- // ../../node_modules/.bun/subagent@0.4.7/node_modules/subagent/dist/utils/workspace.js
32560
- import path5 from "path";
32657
+ // ../../node_modules/.bun/subagent@0.5.5/node_modules/subagent/dist/vscode/responseWaiter.js
32658
+ async function waitForResponseOutput(responseFileFinal, pollInterval = 1e3, silent = false) {
32659
+ if (!silent) {
32660
+ console.error(`waiting for agent to finish: ${responseFileFinal}`);
32661
+ }
32662
+ try {
32663
+ while (!await pathExists(responseFileFinal)) {
32664
+ await sleep(pollInterval);
32665
+ }
32666
+ } catch (error40) {
32667
+ if (error40.code === "ENOENT") {
32668
+ return false;
32669
+ }
32670
+ throw error40;
32671
+ }
32672
+ let attempts = 0;
32673
+ const maxAttempts = 10;
32674
+ while (attempts < maxAttempts) {
32675
+ try {
32676
+ const content = await readFile3(responseFileFinal, { encoding: "utf8" });
32677
+ if (!silent) {
32678
+ process.stdout.write(`${content}
32679
+ `);
32680
+ }
32681
+ return true;
32682
+ } catch (error40) {
32683
+ attempts += 1;
32684
+ if (error40.code !== "EBUSY" || attempts >= maxAttempts) {
32685
+ if (!silent) {
32686
+ console.error(`error: failed to read agent response: ${error40.message}`);
32687
+ }
32688
+ return false;
32689
+ }
32690
+ await sleep(pollInterval);
32691
+ }
32692
+ }
32693
+ return false;
32694
+ }
32695
+ async function waitForBatchResponses(responseFilesFinal, pollInterval = 1e3, silent = false) {
32696
+ if (!silent) {
32697
+ const fileList = responseFilesFinal.map((file2) => path5.basename(file2)).join(", ");
32698
+ console.error(`waiting for ${responseFilesFinal.length} batch response(s): ${fileList}`);
32699
+ }
32700
+ try {
32701
+ const pending = new Set(responseFilesFinal);
32702
+ while (pending.size > 0) {
32703
+ for (const file2 of [...pending]) {
32704
+ if (await pathExists(file2)) {
32705
+ pending.delete(file2);
32706
+ }
32707
+ }
32708
+ if (pending.size > 0) {
32709
+ await sleep(pollInterval);
32710
+ }
32711
+ }
32712
+ } catch (error40) {
32713
+ if (error40.code === "ENOENT") {
32714
+ return false;
32715
+ }
32716
+ throw error40;
32717
+ }
32718
+ for (const file2 of responseFilesFinal) {
32719
+ let attempts = 0;
32720
+ const maxAttempts = 10;
32721
+ while (attempts < maxAttempts) {
32722
+ try {
32723
+ const content = await readFile3(file2, { encoding: "utf8" });
32724
+ if (!silent) {
32725
+ process.stdout.write(`${content}
32726
+ `);
32727
+ }
32728
+ break;
32729
+ } catch (error40) {
32730
+ attempts += 1;
32731
+ if (error40.code !== "EBUSY" || attempts >= maxAttempts) {
32732
+ if (!silent) {
32733
+ console.error(`error: failed to read agent response: ${error40.message}`);
32734
+ }
32735
+ return false;
32736
+ }
32737
+ await sleep(pollInterval);
32738
+ }
32739
+ }
32740
+ }
32741
+ return true;
32742
+ }
32743
+
32744
+ // ../../node_modules/.bun/subagent@0.5.5/node_modules/subagent/dist/vscode/vscodeProcess.js
32745
+ import { exec, spawn } from "node:child_process";
32746
+ import { mkdir as mkdir2, writeFile } from "node:fs/promises";
32747
+ import path7 from "node:path";
32748
+ import { promisify } from "node:util";
32749
+
32750
+ // ../../node_modules/.bun/subagent@0.5.5/node_modules/subagent/dist/vscode/constants.js
32751
+ import os from "node:os";
32752
+ import path6 from "node:path";
32753
+ var DEFAULT_LOCK_NAME = "subagent.lock";
32754
+ var DEFAULT_ALIVE_FILENAME = ".alive";
32755
+ function getDefaultSubagentRoot(vscodeCmd = "code") {
32756
+ const folder = vscodeCmd === "code-insiders" ? "vscode-insiders-agents" : "vscode-agents";
32757
+ return path6.join(os.homedir(), ".subagent", folder);
32758
+ }
32759
+ var DEFAULT_SUBAGENT_ROOT = getDefaultSubagentRoot();
32760
+
32761
+ // ../../node_modules/.bun/subagent@0.5.5/node_modules/subagent/dist/vscode/vscodeProcess.js
32762
+ var execAsync = promisify(exec);
32763
+ var DEFAULT_WAKEUP_CONTENT = `---
32764
+ description: 'Wake-up Signal'
32765
+ model: Grok Code Fast 1 (copilot)
32766
+ ---`;
32767
+ async function checkWorkspaceOpened(workspaceName, vscodeCmd) {
32768
+ try {
32769
+ const { stdout } = await execAsync(`${vscodeCmd} --status`, {
32770
+ timeout: 1e4,
32771
+ windowsHide: true
32772
+ });
32773
+ return stdout.includes(workspaceName);
32774
+ } catch {
32775
+ return false;
32776
+ }
32777
+ }
32778
+ async function ensureWorkspaceFocused(workspacePath, workspaceName, subagentDir, vscodeCmd, pollInterval = 1, timeout = 60) {
32779
+ const alreadyOpen = await checkWorkspaceOpened(workspaceName, vscodeCmd);
32780
+ if (alreadyOpen) {
32781
+ spawn(vscodeCmd, [workspacePath], { windowsHide: true, shell: true, detached: false });
32782
+ return true;
32783
+ }
32784
+ const aliveFile = path7.join(subagentDir, DEFAULT_ALIVE_FILENAME);
32785
+ await removeIfExists(aliveFile);
32786
+ const githubAgentsDir = path7.join(subagentDir, ".github", "agents");
32787
+ await mkdir2(githubAgentsDir, { recursive: true });
32788
+ const wakeupDst = path7.join(githubAgentsDir, "wakeup.md");
32789
+ await writeFile(wakeupDst, DEFAULT_WAKEUP_CONTENT, "utf8");
32790
+ spawn(vscodeCmd, [workspacePath], { windowsHide: true, shell: true, detached: false });
32791
+ await sleep(100);
32792
+ const wakeupChatId = "wakeup";
32793
+ const chatArgs = [
32794
+ "-r",
32795
+ "chat",
32796
+ "-m",
32797
+ wakeupChatId,
32798
+ `create a file named .alive in the ${path7.basename(subagentDir)} folder`
32799
+ ];
32800
+ spawn(vscodeCmd, chatArgs, { windowsHide: true, shell: true, detached: false });
32801
+ const start = Date.now();
32802
+ while (!await pathExists(aliveFile)) {
32803
+ if (Date.now() - start > timeout * 1e3) {
32804
+ console.error(`warning: Workspace readiness timeout after ${timeout}s`);
32805
+ return false;
32806
+ }
32807
+ await sleep(pollInterval * 1e3);
32808
+ }
32809
+ return true;
32810
+ }
32811
+ async function launchVsCodeWithChat(subagentDir, chatId, attachmentPaths, requestInstructions, timestamp, vscodeCmd) {
32812
+ try {
32813
+ const workspacePath = path7.join(subagentDir, `${path7.basename(subagentDir)}.code-workspace`);
32814
+ const messagesDir = path7.join(subagentDir, "messages");
32815
+ await mkdir2(messagesDir, { recursive: true });
32816
+ const reqFile = path7.join(messagesDir, `${timestamp}_req.md`);
32817
+ await writeFile(reqFile, requestInstructions, { encoding: "utf8" });
32818
+ const reqUri = pathToFileUri(reqFile);
32819
+ const chatArgs = ["-r", "chat", "-m", chatId];
32820
+ for (const attachment of attachmentPaths) {
32821
+ chatArgs.push("-a", attachment);
32822
+ }
32823
+ chatArgs.push("-a", reqFile);
32824
+ chatArgs.push(`Follow instructions in [${path7.basename(reqFile)}](${reqUri})`);
32825
+ const workspaceReady = await ensureWorkspaceFocused(workspacePath, path7.basename(subagentDir), subagentDir, vscodeCmd);
32826
+ if (!workspaceReady) {
32827
+ console.error("warning: Workspace may not be fully ready");
32828
+ }
32829
+ await sleep(500);
32830
+ spawn(vscodeCmd, chatArgs, { windowsHide: true, shell: true, detached: false });
32831
+ return true;
32832
+ } catch (error40) {
32833
+ console.error(`warning: Failed to launch VS Code: ${error40.message}`);
32834
+ return false;
32835
+ }
32836
+ }
32837
+ async function launchVsCodeWithBatchChat(subagentDir, chatId, attachmentPaths, chatInstruction, vscodeCmd) {
32838
+ try {
32839
+ const workspacePath = path7.join(subagentDir, `${path7.basename(subagentDir)}.code-workspace`);
32840
+ const messagesDir = path7.join(subagentDir, "messages");
32841
+ await mkdir2(messagesDir, { recursive: true });
32842
+ const chatArgs = ["-r", "chat", "-m", chatId];
32843
+ for (const attachment of attachmentPaths) {
32844
+ chatArgs.push("-a", attachment);
32845
+ }
32846
+ chatArgs.push(chatInstruction);
32847
+ const workspaceReady = await ensureWorkspaceFocused(workspacePath, path7.basename(subagentDir), subagentDir, vscodeCmd);
32848
+ if (!workspaceReady) {
32849
+ console.error("warning: Workspace may not be fully ready");
32850
+ }
32851
+ await sleep(500);
32852
+ spawn(vscodeCmd, chatArgs, { windowsHide: true, shell: true, detached: false });
32853
+ return true;
32854
+ } catch (error40) {
32855
+ console.error(`warning: Failed to launch VS Code: ${error40.message}`);
32856
+ return false;
32857
+ }
32858
+ }
32859
+
32860
+ // ../../node_modules/.bun/subagent@0.5.5/node_modules/subagent/dist/vscode/workspaceManager.js
32861
+ import { copyFile, mkdir as mkdir3, readFile as readFile4, readdir as readdir2, stat as stat2, writeFile as writeFile2 } from "node:fs/promises";
32862
+ import path9 from "node:path";
32863
+
32864
+ // ../../node_modules/.bun/subagent@0.5.5/node_modules/subagent/dist/utils/workspace.js
32865
+ import path8 from "node:path";
32561
32866
 
32562
32867
  // ../../node_modules/.bun/json5@2.2.3/node_modules/json5/dist/index.mjs
32563
32868
  var Space_Separator = /[\u1680\u2000-\u200A\u202F\u205F\u3000]/;
@@ -33644,7 +33949,7 @@ var JSON5 = {
33644
33949
  var lib = JSON5;
33645
33950
  var dist_default = lib;
33646
33951
 
33647
- // ../../node_modules/.bun/subagent@0.4.7/node_modules/subagent/dist/utils/workspace.js
33952
+ // ../../node_modules/.bun/subagent@0.5.5/node_modules/subagent/dist/utils/workspace.js
33648
33953
  function transformWorkspacePaths(workspaceContent, templateDir) {
33649
33954
  let workspace;
33650
33955
  try {
@@ -33660,19 +33965,16 @@ function transformWorkspacePaths(workspaceContent, templateDir) {
33660
33965
  }
33661
33966
  const transformedFolders = workspace.folders.map((folder) => {
33662
33967
  const folderPath = folder.path;
33663
- if (path5.isAbsolute(folderPath)) {
33968
+ if (path8.isAbsolute(folderPath)) {
33664
33969
  return folder;
33665
33970
  }
33666
- const absolutePath = path5.resolve(templateDir, folderPath);
33971
+ const absolutePath = path8.resolve(templateDir, folderPath);
33667
33972
  return {
33668
33973
  ...folder,
33669
33974
  path: absolutePath
33670
33975
  };
33671
33976
  });
33672
- const updatedFolders = [
33673
- { path: "." },
33674
- ...transformedFolders
33675
- ];
33977
+ const updatedFolders = [{ path: "." }, ...transformedFolders];
33676
33978
  let transformedSettings = workspace.settings;
33677
33979
  if (workspace.settings) {
33678
33980
  transformedSettings = {
@@ -33688,19 +33990,19 @@ function transformWorkspacePaths(workspaceContent, templateDir) {
33688
33990
  if (locationMap && typeof locationMap === "object") {
33689
33991
  const transformedMap = {};
33690
33992
  for (const [locationPath, value] of Object.entries(locationMap)) {
33691
- const isAbsolute = path5.isAbsolute(locationPath);
33993
+ const isAbsolute = path8.isAbsolute(locationPath);
33692
33994
  if (isAbsolute) {
33693
33995
  transformedMap[locationPath] = value;
33694
33996
  } else {
33695
33997
  const firstGlobIndex = locationPath.search(/[*]/);
33696
33998
  if (firstGlobIndex === -1) {
33697
- const resolvedPath = path5.resolve(templateDir, locationPath).replace(/\\/g, "/");
33999
+ const resolvedPath = path8.resolve(templateDir, locationPath).replace(/\\/g, "/");
33698
34000
  transformedMap[resolvedPath] = value;
33699
34001
  } else {
33700
34002
  const basePathEnd = locationPath.lastIndexOf("/", firstGlobIndex);
33701
34003
  const basePath = basePathEnd !== -1 ? locationPath.substring(0, basePathEnd) : ".";
33702
34004
  const patternPath = locationPath.substring(basePathEnd !== -1 ? basePathEnd : 0);
33703
- const resolvedPath = (path5.resolve(templateDir, basePath) + patternPath).replace(/\\/g, "/");
34005
+ const resolvedPath = (path8.resolve(templateDir, basePath) + patternPath).replace(/\\/g, "/");
33704
34006
  transformedMap[resolvedPath] = value;
33705
34007
  }
33706
34008
  }
@@ -33717,11 +34019,7 @@ function transformWorkspacePaths(workspaceContent, templateDir) {
33717
34019
  return JSON.stringify(transformedWorkspace, null, 2);
33718
34020
  }
33719
34021
 
33720
- // ../../node_modules/.bun/subagent@0.4.7/node_modules/subagent/dist/vscode/agentDispatch.js
33721
- var execAsync = promisify(exec);
33722
- function generateTimestamp() {
33723
- return (/* @__PURE__ */ new Date()).toISOString().replace(/[-:TZ.]/g, "").slice(0, 14);
33724
- }
34022
+ // ../../node_modules/.bun/subagent@0.5.5/node_modules/subagent/dist/vscode/workspaceManager.js
33725
34023
  var DEFAULT_WORKSPACE_TEMPLATE = {
33726
34024
  folders: [
33727
34025
  {
@@ -33729,27 +34027,9 @@ var DEFAULT_WORKSPACE_TEMPLATE = {
33729
34027
  }
33730
34028
  ]
33731
34029
  };
33732
- var DEFAULT_WAKEUP_CONTENT = `---
33733
- description: 'Wake-up Signal'
33734
- model: Grok Code Fast 1 (copilot)
33735
- ---`;
33736
34030
  function getSubagentRoot(vscodeCmd = "code") {
33737
34031
  return getDefaultSubagentRoot(vscodeCmd);
33738
34032
  }
33739
- async function resolvePromptFile(promptFile) {
33740
- if (!promptFile) {
33741
- return void 0;
33742
- }
33743
- const resolvedPrompt = path6.resolve(promptFile);
33744
- if (!await pathExists(resolvedPrompt)) {
33745
- throw new Error(`Prompt file not found: ${resolvedPrompt}`);
33746
- }
33747
- const promptStats = await stat2(resolvedPrompt);
33748
- if (!promptStats.isFile()) {
33749
- throw new Error(`Prompt file must be a file, not a directory: ${resolvedPrompt}`);
33750
- }
33751
- return resolvedPrompt;
33752
- }
33753
34033
  async function findUnlockedSubagent(subagentRoot) {
33754
34034
  if (!await pathExists(subagentRoot)) {
33755
34035
  return null;
@@ -33760,53 +34040,17 @@ async function findUnlockedSubagent(subagentRoot) {
33760
34040
  number: Number.parseInt(entry.name.split("-")[1] ?? "", 10)
33761
34041
  })).filter((entry) => Number.isInteger(entry.number)).sort((a, b) => a.number - b.number);
33762
34042
  for (const subagent of subagents) {
33763
- const lockFile = path6.join(subagent.absolutePath, DEFAULT_LOCK_NAME);
34043
+ const lockFile = path9.join(subagent.absolutePath, DEFAULT_LOCK_NAME);
33764
34044
  if (!await pathExists(lockFile)) {
33765
34045
  return subagent.absolutePath;
33766
34046
  }
33767
34047
  }
33768
34048
  return null;
33769
34049
  }
33770
- async function checkWorkspaceOpened(workspaceName, vscodeCmd) {
33771
- try {
33772
- const { stdout } = await execAsync(`${vscodeCmd} --status`, { timeout: 1e4, windowsHide: true });
33773
- return stdout.includes(workspaceName);
33774
- } catch {
33775
- return false;
33776
- }
33777
- }
33778
- async function ensureWorkspaceFocused(workspacePath, workspaceName, subagentDir, vscodeCmd, pollInterval = 1, timeout = 60) {
33779
- const alreadyOpen = await checkWorkspaceOpened(workspaceName, vscodeCmd);
33780
- if (alreadyOpen) {
33781
- spawn(vscodeCmd, [workspacePath], { windowsHide: true, shell: true, detached: false });
33782
- return true;
33783
- }
33784
- const aliveFile = path6.join(subagentDir, DEFAULT_ALIVE_FILENAME);
33785
- await removeIfExists(aliveFile);
33786
- const githubAgentsDir = path6.join(subagentDir, ".github", "agents");
33787
- await mkdir2(githubAgentsDir, { recursive: true });
33788
- const wakeupDst = path6.join(githubAgentsDir, "wakeup.md");
33789
- const subagentDst = path6.join(githubAgentsDir, "subagent.md");
33790
- await writeFile(wakeupDst, DEFAULT_WAKEUP_CONTENT, "utf8");
33791
- spawn(vscodeCmd, [workspacePath], { windowsHide: true, shell: true, detached: false });
33792
- await sleep(100);
33793
- const wakeupChatId = "wakeup";
33794
- const chatArgs = ["-r", "chat", "-m", wakeupChatId, `create a file named .alive in the ${path6.basename(subagentDir)} folder`];
33795
- spawn(vscodeCmd, chatArgs, { windowsHide: true, shell: true, detached: false });
33796
- const start = Date.now();
33797
- while (!await pathExists(aliveFile)) {
33798
- if (Date.now() - start > timeout * 1e3) {
33799
- console.error(`warning: Workspace readiness timeout after ${timeout}s`);
33800
- return false;
33801
- }
33802
- await sleep(pollInterval * 1e3);
33803
- }
33804
- return true;
33805
- }
33806
34050
  async function copyAgentConfig(subagentDir, workspaceTemplate) {
33807
34051
  let workspaceContent;
33808
34052
  if (workspaceTemplate) {
33809
- const workspaceSrc = path6.resolve(workspaceTemplate);
34053
+ const workspaceSrc = path9.resolve(workspaceTemplate);
33810
34054
  if (!await pathExists(workspaceSrc)) {
33811
34055
  throw new Error(`workspace template not found: ${workspaceSrc}`);
33812
34056
  }
@@ -33814,129 +34058,44 @@ async function copyAgentConfig(subagentDir, workspaceTemplate) {
33814
34058
  if (!stats.isFile()) {
33815
34059
  throw new Error(`workspace template must be a file, not a directory: ${workspaceSrc}`);
33816
34060
  }
33817
- const templateText = await readFile2(workspaceSrc, "utf8");
34061
+ const templateText = await readFile4(workspaceSrc, "utf8");
33818
34062
  workspaceContent = JSON.parse(templateText);
33819
34063
  } else {
33820
34064
  workspaceContent = DEFAULT_WORKSPACE_TEMPLATE;
33821
34065
  }
33822
- const workspaceName = `${path6.basename(subagentDir)}.code-workspace`;
33823
- const workspaceDst = path6.join(subagentDir, workspaceName);
33824
- const templateDir = workspaceTemplate ? path6.dirname(path6.resolve(workspaceTemplate)) : subagentDir;
34066
+ const workspaceName = `${path9.basename(subagentDir)}.code-workspace`;
34067
+ const workspaceDst = path9.join(subagentDir, workspaceName);
34068
+ const templateDir = workspaceTemplate ? path9.dirname(path9.resolve(workspaceTemplate)) : subagentDir;
33825
34069
  const workspaceJson = JSON.stringify(workspaceContent, null, 2);
33826
34070
  const transformedContent = transformWorkspacePaths(workspaceJson, templateDir);
33827
- await writeFile(workspaceDst, transformedContent, "utf8");
33828
- const messagesDir = path6.join(subagentDir, "messages");
33829
- await mkdir2(messagesDir, { recursive: true });
34071
+ await writeFile2(workspaceDst, transformedContent, "utf8");
34072
+ const messagesDir = path9.join(subagentDir, "messages");
34073
+ await mkdir3(messagesDir, { recursive: true });
33830
34074
  return { workspace: workspaceDst, messagesDir };
33831
34075
  }
33832
34076
  async function createSubagentLock(subagentDir) {
33833
- const messagesDir = path6.join(subagentDir, "messages");
34077
+ const messagesDir = path9.join(subagentDir, "messages");
33834
34078
  if (await pathExists(messagesDir)) {
33835
34079
  const files = await readdir2(messagesDir);
33836
34080
  await Promise.all(files.map(async (file2) => {
33837
- const target = path6.join(messagesDir, file2);
34081
+ const target = path9.join(messagesDir, file2);
33838
34082
  await removeIfExists(target);
33839
34083
  }));
33840
34084
  }
33841
- const githubAgentsDir = path6.join(subagentDir, ".github", "agents");
34085
+ const githubAgentsDir = path9.join(subagentDir, ".github", "agents");
33842
34086
  if (await pathExists(githubAgentsDir)) {
33843
34087
  const agentFiles = await readdir2(githubAgentsDir);
33844
34088
  const preservedFiles = /* @__PURE__ */ new Set(["wakeup.md", "subagent.md"]);
33845
- await Promise.all(agentFiles.filter((file2) => file2.endsWith(".md") && !preservedFiles.has(file2)).map((file2) => removeIfExists(path6.join(githubAgentsDir, file2))));
34089
+ await Promise.all(agentFiles.filter((file2) => file2.endsWith(".md") && !preservedFiles.has(file2)).map((file2) => removeIfExists(path9.join(githubAgentsDir, file2))));
33846
34090
  }
33847
- const lockFile = path6.join(subagentDir, DEFAULT_LOCK_NAME);
33848
- await writeFile(lockFile, "", { encoding: "utf8" });
34091
+ const lockFile = path9.join(subagentDir, DEFAULT_LOCK_NAME);
34092
+ await writeFile2(lockFile, "", { encoding: "utf8" });
33849
34093
  return lockFile;
33850
34094
  }
33851
34095
  async function removeSubagentLock(subagentDir) {
33852
- const lockFile = path6.join(subagentDir, DEFAULT_LOCK_NAME);
34096
+ const lockFile = path9.join(subagentDir, DEFAULT_LOCK_NAME);
33853
34097
  await removeIfExists(lockFile);
33854
34098
  }
33855
- async function waitForResponseOutput(responseFileFinal, pollInterval = 1e3, silent = false) {
33856
- if (!silent) {
33857
- console.error(`waiting for agent to finish: ${responseFileFinal}`);
33858
- }
33859
- try {
33860
- while (!await pathExists(responseFileFinal)) {
33861
- await sleep(pollInterval);
33862
- }
33863
- } catch (error40) {
33864
- if (error40.code === "ENOENT") {
33865
- return false;
33866
- }
33867
- throw error40;
33868
- }
33869
- let attempts = 0;
33870
- const maxAttempts = 10;
33871
- while (attempts < maxAttempts) {
33872
- try {
33873
- const content = await readFile2(responseFileFinal, { encoding: "utf8" });
33874
- if (!silent) {
33875
- process.stdout.write(`${content}
33876
- `);
33877
- }
33878
- return true;
33879
- } catch (error40) {
33880
- attempts += 1;
33881
- if (error40.code !== "EBUSY" || attempts >= maxAttempts) {
33882
- if (!silent) {
33883
- console.error(`error: failed to read agent response: ${error40.message}`);
33884
- }
33885
- return false;
33886
- }
33887
- await sleep(pollInterval);
33888
- }
33889
- }
33890
- return false;
33891
- }
33892
- async function waitForBatchResponses(responseFilesFinal, pollInterval = 1e3, silent = false) {
33893
- if (!silent) {
33894
- const fileList = responseFilesFinal.map((file2) => path6.basename(file2)).join(", ");
33895
- console.error(`waiting for ${responseFilesFinal.length} batch response(s): ${fileList}`);
33896
- }
33897
- try {
33898
- const pending = new Set(responseFilesFinal);
33899
- while (pending.size > 0) {
33900
- for (const file2 of [...pending]) {
33901
- if (await pathExists(file2)) {
33902
- pending.delete(file2);
33903
- }
33904
- }
33905
- if (pending.size > 0) {
33906
- await sleep(pollInterval);
33907
- }
33908
- }
33909
- } catch (error40) {
33910
- if (error40.code === "ENOENT") {
33911
- return false;
33912
- }
33913
- throw error40;
33914
- }
33915
- for (const file2 of responseFilesFinal) {
33916
- let attempts = 0;
33917
- const maxAttempts = 10;
33918
- while (attempts < maxAttempts) {
33919
- try {
33920
- const content = await readFile2(file2, { encoding: "utf8" });
33921
- if (!silent) {
33922
- process.stdout.write(`${content}
33923
- `);
33924
- }
33925
- break;
33926
- } catch (error40) {
33927
- attempts += 1;
33928
- if (error40.code !== "EBUSY" || attempts >= maxAttempts) {
33929
- if (!silent) {
33930
- console.error(`error: failed to read agent response: ${error40.message}`);
33931
- }
33932
- return false;
33933
- }
33934
- await sleep(pollInterval);
33935
- }
33936
- }
33937
- }
33938
- return true;
33939
- }
33940
34099
  async function prepareSubagentDirectory(subagentDir, promptFile, chatId, workspaceTemplate, dryRun) {
33941
34100
  if (dryRun) {
33942
34101
  return 0;
@@ -33954,9 +34113,9 @@ async function prepareSubagentDirectory(subagentDir, promptFile, chatId, workspa
33954
34113
  return 1;
33955
34114
  }
33956
34115
  if (promptFile) {
33957
- const githubAgentsDir = path6.join(subagentDir, ".github", "agents");
33958
- await mkdir2(githubAgentsDir, { recursive: true });
33959
- const agentFile = path6.join(githubAgentsDir, `${chatId}.md`);
34116
+ const githubAgentsDir = path9.join(subagentDir, ".github", "agents");
34117
+ await mkdir3(githubAgentsDir, { recursive: true });
34118
+ const agentFile = path9.join(githubAgentsDir, `${chatId}.md`);
33960
34119
  try {
33961
34120
  await copyFile(promptFile, agentFile);
33962
34121
  } catch (error40) {
@@ -33966,50 +34125,24 @@ async function prepareSubagentDirectory(subagentDir, promptFile, chatId, workspa
33966
34125
  }
33967
34126
  return 0;
33968
34127
  }
33969
- function createRequestPrompt(userQuery, responseFileTmp, responseFileFinal) {
33970
- return `[[ ## task ## ]]
33971
-
33972
- ${userQuery}
33973
-
33974
- [[ ## system_instructions ## ]]
33975
-
33976
- **IMPORTANT**: Follow these exact steps:
33977
- 1. Create and write your complete response to: ${responseFileTmp}
33978
- 2. When completely finished, run these PowerShell commands to signal completion:
33979
- \`\`\`
33980
- Move-Item -LiteralPath '${responseFileTmp}' -Destination '${responseFileFinal}'
33981
- if (Test-Path subagent.lock) { del subagent.lock }
33982
- \`\`\`
33983
34128
 
33984
- Do not proceed to step 2 until your response is completely written to the temporary file.`;
34129
+ // ../../node_modules/.bun/subagent@0.5.5/node_modules/subagent/dist/vscode/agentDispatch.js
34130
+ function generateTimestamp() {
34131
+ return (/* @__PURE__ */ new Date()).toISOString().replace(/[-:TZ.]/g, "").slice(0, 14);
33985
34132
  }
33986
- function createBatchRequestPrompt(userQuery, responseFileTmp, responseFileFinal) {
33987
- return `[[ ## task ## ]]
33988
-
33989
- ${userQuery}
33990
-
33991
- [[ ## system_instructions ## ]]
33992
-
33993
- Write your complete response to: ${responseFileTmp}
33994
- When completely finished and the response is stable, rename it to: ${responseFileFinal}
33995
- Do not unlock the workspace from this request; batch orchestration will handle unlocking after all responses are ready.`;
33996
- }
33997
- function createBatchOrchestratorPrompt(requestFiles, responseFiles) {
33998
- const requestLines = requestFiles.map((file2, index) => `${index + 1}. messages/${path6.basename(file2)}`).join("\n");
33999
- const responseList = responseFiles.map((file2) => `"${path6.basename(file2)}"`).join(", ");
34000
- return `MANDATORY: Run #runSubagent tool in your Available Actions for each request file to process them in isolated contexts.
34001
- DO NOT read the request files yourself - only pass the file paths to each subagent:
34002
-
34003
- ${requestLines}
34004
-
34005
- After ALL queries complete, verify all responses exist and unlock:
34006
-
34007
- \`\`\`powershell
34008
- $responses = @(${responseList})
34009
- $missing = $responses | Where-Object { -not (Test-Path "messages/$_") }
34010
- if ($missing.Count -eq 0) { del subagent.lock }
34011
- \`\`\`
34012
- `;
34133
+ async function resolvePromptFile(promptFile) {
34134
+ if (!promptFile) {
34135
+ return void 0;
34136
+ }
34137
+ const resolvedPrompt = path10.resolve(promptFile);
34138
+ if (!await pathExists(resolvedPrompt)) {
34139
+ throw new Error(`Prompt file not found: ${resolvedPrompt}`);
34140
+ }
34141
+ const promptStats = await stat3(resolvedPrompt);
34142
+ if (!promptStats.isFile()) {
34143
+ throw new Error(`Prompt file must be a file, not a directory: ${resolvedPrompt}`);
34144
+ }
34145
+ return resolvedPrompt;
34013
34146
  }
34014
34147
  async function resolveAttachments(extraAttachments) {
34015
34148
  if (!extraAttachments) {
@@ -34017,7 +34150,7 @@ async function resolveAttachments(extraAttachments) {
34017
34150
  }
34018
34151
  const resolved = [];
34019
34152
  for (const attachment of extraAttachments) {
34020
- const resolvedPath = path6.resolve(attachment);
34153
+ const resolvedPath = path10.resolve(attachment);
34021
34154
  if (!await pathExists(resolvedPath)) {
34022
34155
  throw new Error(`Attachment not found: ${resolvedPath}`);
34023
34156
  }
@@ -34025,55 +34158,8 @@ async function resolveAttachments(extraAttachments) {
34025
34158
  }
34026
34159
  return resolved;
34027
34160
  }
34028
- async function launchVsCodeWithChat(subagentDir, chatId, attachmentPaths, requestInstructions, timestamp, vscodeCmd) {
34029
- try {
34030
- const workspacePath = path6.join(subagentDir, `${path6.basename(subagentDir)}.code-workspace`);
34031
- const messagesDir = path6.join(subagentDir, "messages");
34032
- await mkdir2(messagesDir, { recursive: true });
34033
- const reqFile = path6.join(messagesDir, `${timestamp}_req.md`);
34034
- await writeFile(reqFile, requestInstructions, { encoding: "utf8" });
34035
- const chatArgs = ["-r", "chat", "-m", chatId];
34036
- for (const attachment of attachmentPaths) {
34037
- chatArgs.push("-a", attachment);
34038
- }
34039
- chatArgs.push("-a", reqFile);
34040
- chatArgs.push(`Follow instructions in ${path6.basename(reqFile)}`);
34041
- const workspaceReady = await ensureWorkspaceFocused(workspacePath, path6.basename(subagentDir), subagentDir, vscodeCmd);
34042
- if (!workspaceReady) {
34043
- console.error("warning: Workspace may not be fully ready");
34044
- }
34045
- await sleep(500);
34046
- spawn(vscodeCmd, chatArgs, { windowsHide: true, shell: true, detached: false });
34047
- return true;
34048
- } catch (error40) {
34049
- console.error(`warning: Failed to launch VS Code: ${error40.message}`);
34050
- return false;
34051
- }
34052
- }
34053
- async function launchVsCodeWithBatchChat(subagentDir, chatId, attachmentPaths, chatInstruction, vscodeCmd) {
34054
- try {
34055
- const workspacePath = path6.join(subagentDir, `${path6.basename(subagentDir)}.code-workspace`);
34056
- const messagesDir = path6.join(subagentDir, "messages");
34057
- await mkdir2(messagesDir, { recursive: true });
34058
- const chatArgs = ["-r", "chat", "-m", chatId];
34059
- for (const attachment of attachmentPaths) {
34060
- chatArgs.push("-a", attachment);
34061
- }
34062
- chatArgs.push(chatInstruction);
34063
- const workspaceReady = await ensureWorkspaceFocused(workspacePath, path6.basename(subagentDir), subagentDir, vscodeCmd);
34064
- if (!workspaceReady) {
34065
- console.error("warning: Workspace may not be fully ready");
34066
- }
34067
- await sleep(500);
34068
- spawn(vscodeCmd, chatArgs, { windowsHide: true, shell: true, detached: false });
34069
- return true;
34070
- } catch (error40) {
34071
- console.error(`warning: Failed to launch VS Code: ${error40.message}`);
34072
- return false;
34073
- }
34074
- }
34075
34161
  async function dispatchAgentSession(options) {
34076
- const { userQuery, promptFile, extraAttachments, workspaceTemplate, dryRun = false, wait = true, vscodeCmd = "code", subagentRoot, silent = false } = options;
34162
+ const { userQuery, promptFile, requestTemplate, extraAttachments, workspaceTemplate, dryRun = false, wait = true, vscodeCmd = "code", subagentRoot, silent = false } = options;
34077
34163
  try {
34078
34164
  let resolvedPrompt;
34079
34165
  try {
@@ -34084,6 +34170,15 @@ async function dispatchAgentSession(options) {
34084
34170
  error: error40.message
34085
34171
  };
34086
34172
  }
34173
+ let templateContent;
34174
+ try {
34175
+ templateContent = requestTemplate ? await loadTemplateFile(path10.resolve(requestTemplate)) : loadDefaultRequestTemplate();
34176
+ } catch (error40) {
34177
+ return {
34178
+ exitCode: 1,
34179
+ error: error40.message
34180
+ };
34181
+ }
34087
34182
  const subagentRootPath = subagentRoot ?? getSubagentRoot(vscodeCmd);
34088
34183
  const subagentDir = await findUnlockedSubagent(subagentRootPath);
34089
34184
  if (!subagentDir) {
@@ -34092,7 +34187,7 @@ async function dispatchAgentSession(options) {
34092
34187
  error: "No unlocked subagents available. Provision additional subagents with: subagent code provision --subagents <desired_total>"
34093
34188
  };
34094
34189
  }
34095
- const subagentName = path6.basename(subagentDir);
34190
+ const subagentName = path10.basename(subagentDir);
34096
34191
  const chatId = Math.random().toString(16).slice(2, 10);
34097
34192
  const preparationResult = await prepareSubagentDirectory(subagentDir, resolvedPrompt, chatId, workspaceTemplate, dryRun);
34098
34193
  if (preparationResult !== 0) {
@@ -34113,10 +34208,10 @@ async function dispatchAgentSession(options) {
34113
34208
  };
34114
34209
  }
34115
34210
  const timestamp = generateTimestamp();
34116
- const messagesDir = path6.join(subagentDir, "messages");
34117
- const responseFileTmp = path6.join(messagesDir, `${timestamp}_res.tmp.md`);
34118
- const responseFileFinal = path6.join(messagesDir, `${timestamp}_res.md`);
34119
- const requestInstructions = createRequestPrompt(userQuery, responseFileTmp, responseFileFinal);
34211
+ const messagesDir = path10.join(subagentDir, "messages");
34212
+ const responseFileTmp = path10.join(messagesDir, `${timestamp}_res.tmp.md`);
34213
+ const responseFileFinal = path10.join(messagesDir, `${timestamp}_res.md`);
34214
+ const requestInstructions = createRequestPrompt(userQuery, responseFileTmp, responseFileFinal, templateContent);
34120
34215
  if (dryRun) {
34121
34216
  return {
34122
34217
  exitCode: 0,
@@ -34168,7 +34263,7 @@ async function dispatchAgentSession(options) {
34168
34263
  }
34169
34264
  }
34170
34265
  async function dispatchBatchAgent(options) {
34171
- const { userQueries, promptFile, extraAttachments, workspaceTemplate, dryRun = false, wait = false, vscodeCmd = "code", subagentRoot, silent = false } = options;
34266
+ const { userQueries, promptFile, requestTemplate, extraAttachments, workspaceTemplate, dryRun = false, wait = false, vscodeCmd = "code", subagentRoot, silent = false } = options;
34172
34267
  if (!userQueries || userQueries.length === 0) {
34173
34268
  return {
34174
34269
  exitCode: 1,
@@ -34193,6 +34288,18 @@ async function dispatchBatchAgent(options) {
34193
34288
  error: error40.message
34194
34289
  };
34195
34290
  }
34291
+ let batchRequestTemplateContent;
34292
+ try {
34293
+ batchRequestTemplateContent = requestTemplate ? await loadTemplateFile(path10.resolve(requestTemplate)) : loadDefaultBatchRequestTemplate();
34294
+ } catch (error40) {
34295
+ return {
34296
+ exitCode: 1,
34297
+ requestFiles,
34298
+ queryCount,
34299
+ error: error40.message
34300
+ };
34301
+ }
34302
+ const orchestratorTemplateContent = loadDefaultBatchOrchestratorTemplate();
34196
34303
  const subagentRootPath = subagentRoot ?? getSubagentRoot(vscodeCmd);
34197
34304
  const subagentDir = await findUnlockedSubagent(subagentRootPath);
34198
34305
  if (!subagentDir) {
@@ -34203,7 +34310,7 @@ async function dispatchBatchAgent(options) {
34203
34310
  error: "No unlocked subagents available. Provision additional subagents with: subagent code provision --subagents <desired_total>"
34204
34311
  };
34205
34312
  }
34206
- subagentName = path6.basename(subagentDir);
34313
+ subagentName = path10.basename(subagentDir);
34207
34314
  const chatId = Math.random().toString(16).slice(2, 10);
34208
34315
  const preparationResult = await prepareSubagentDirectory(subagentDir, resolvedPrompt, chatId, workspaceTemplate, dryRun);
34209
34316
  if (preparationResult !== 0) {
@@ -34228,15 +34335,15 @@ async function dispatchBatchAgent(options) {
34228
34335
  };
34229
34336
  }
34230
34337
  const timestamp = generateTimestamp();
34231
- const messagesDir = path6.join(subagentDir, "messages");
34232
- requestFiles = userQueries.map((_, index) => path6.join(messagesDir, `${timestamp}_${index}_req.md`));
34233
- const responseTmpFiles = userQueries.map((_, index) => path6.join(messagesDir, `${timestamp}_${index}_res.tmp.md`));
34234
- responseFilesFinal = userQueries.map((_, index) => path6.join(messagesDir, `${timestamp}_${index}_res.md`));
34235
- const orchestratorFile = path6.join(messagesDir, `${timestamp}_orchestrator.md`);
34338
+ const messagesDir = path10.join(subagentDir, "messages");
34339
+ requestFiles = userQueries.map((_, index) => path10.join(messagesDir, `${timestamp}_${index}_req.md`));
34340
+ const responseTmpFiles = userQueries.map((_, index) => path10.join(messagesDir, `${timestamp}_${index}_res.tmp.md`));
34341
+ responseFilesFinal = userQueries.map((_, index) => path10.join(messagesDir, `${timestamp}_${index}_res.md`));
34342
+ const orchestratorFile = path10.join(messagesDir, `${timestamp}_orchestrator.md`);
34236
34343
  if (!dryRun) {
34237
- await Promise.all(userQueries.map((query, index) => writeFile(requestFiles[index], createBatchRequestPrompt(query, responseTmpFiles[index], responseFilesFinal[index]), { encoding: "utf8" })));
34238
- const orchestratorContent = createBatchOrchestratorPrompt(requestFiles, responseFilesFinal);
34239
- await writeFile(orchestratorFile, orchestratorContent, { encoding: "utf8" });
34344
+ await Promise.all(userQueries.map((query, index) => writeFile3(requestFiles[index], createBatchRequestPrompt(query, responseTmpFiles[index], responseFilesFinal[index], batchRequestTemplateContent), { encoding: "utf8" })));
34345
+ const orchestratorContent = createBatchOrchestratorPrompt(requestFiles, responseFilesFinal, orchestratorTemplateContent);
34346
+ await writeFile3(orchestratorFile, orchestratorContent, { encoding: "utf8" });
34240
34347
  }
34241
34348
  const chatAttachments = [orchestratorFile, ...attachments];
34242
34349
  const orchestratorUri = pathToFileUri(orchestratorFile);
@@ -34299,9 +34406,9 @@ async function dispatchBatchAgent(options) {
34299
34406
  }
34300
34407
  }
34301
34408
 
34302
- // ../../node_modules/.bun/subagent@0.4.7/node_modules/subagent/dist/vscode/provision.js
34303
- import { writeFile as writeFile2 } from "fs/promises";
34304
- import path7 from "path";
34409
+ // ../../node_modules/.bun/subagent@0.5.5/node_modules/subagent/dist/vscode/provision.js
34410
+ import { writeFile as writeFile4 } from "node:fs/promises";
34411
+ import path11 from "node:path";
34305
34412
  var DEFAULT_WORKSPACE_TEMPLATE2 = {
34306
34413
  folders: [
34307
34414
  {
@@ -34324,7 +34431,7 @@ async function provisionSubagents(options) {
34324
34431
  if (!Number.isInteger(subagents) || subagents < 1) {
34325
34432
  throw new Error("subagents must be a positive integer");
34326
34433
  }
34327
- const targetPath = path7.resolve(targetRoot);
34434
+ const targetPath = path11.resolve(targetRoot);
34328
34435
  if (!dryRun) {
34329
34436
  await ensureDir(targetPath);
34330
34437
  }
@@ -34338,12 +34445,14 @@ async function provisionSubagents(options) {
34338
34445
  continue;
34339
34446
  }
34340
34447
  const suffix = entry.name.split("-")[1];
34448
+ if (!suffix)
34449
+ continue;
34341
34450
  const parsed = Number.parseInt(suffix, 10);
34342
34451
  if (!Number.isInteger(parsed)) {
34343
34452
  continue;
34344
34453
  }
34345
34454
  highestNumber = Math.max(highestNumber, parsed);
34346
- const lockFile = path7.join(entry.absolutePath, lockName);
34455
+ const lockFile = path11.join(entry.absolutePath, lockName);
34347
34456
  const locked = await pathExists(lockFile);
34348
34457
  if (locked) {
34349
34458
  lockedSubagents.add(entry.absolutePath);
@@ -34360,11 +34469,11 @@ async function provisionSubagents(options) {
34360
34469
  break;
34361
34470
  }
34362
34471
  const subagentDir = subagent.absolutePath;
34363
- const githubAgentsDir = path7.join(subagentDir, ".github", "agents");
34364
- const lockFile = path7.join(subagentDir, lockName);
34365
- const workspaceDst = path7.join(subagentDir, `${path7.basename(subagentDir)}.code-workspace`);
34366
- const wakeupDst = path7.join(githubAgentsDir, "wakeup.md");
34367
- const subagentDst = path7.join(githubAgentsDir, "subagent.md");
34472
+ const githubAgentsDir = path11.join(subagentDir, ".github", "agents");
34473
+ const lockFile = path11.join(subagentDir, lockName);
34474
+ const workspaceDst = path11.join(subagentDir, `${path11.basename(subagentDir)}.code-workspace`);
34475
+ const wakeupDst = path11.join(githubAgentsDir, "wakeup.md");
34476
+ const subagentDst = path11.join(githubAgentsDir, "subagent.md");
34368
34477
  const isLocked = await pathExists(lockFile);
34369
34478
  if (isLocked && !force) {
34370
34479
  continue;
@@ -34373,8 +34482,8 @@ async function provisionSubagents(options) {
34373
34482
  if (!dryRun) {
34374
34483
  await removeIfExists(lockFile);
34375
34484
  await ensureDir(githubAgentsDir);
34376
- await writeFile2(workspaceDst, JSON.stringify(workspaceTemplate, null, 2), "utf8");
34377
- await writeFile2(wakeupDst, wakeupContent, "utf8");
34485
+ await writeFile4(workspaceDst, JSON.stringify(workspaceTemplate, null, 2), "utf8");
34486
+ await writeFile4(wakeupDst, wakeupContent, "utf8");
34378
34487
  }
34379
34488
  created.push(subagentDir);
34380
34489
  lockedSubagents.delete(subagentDir);
@@ -34384,8 +34493,8 @@ async function provisionSubagents(options) {
34384
34493
  if (!isLocked && force) {
34385
34494
  if (!dryRun) {
34386
34495
  await ensureDir(githubAgentsDir);
34387
- await writeFile2(workspaceDst, JSON.stringify(workspaceTemplate, null, 2), "utf8");
34388
- await writeFile2(wakeupDst, wakeupContent, "utf8");
34496
+ await writeFile4(workspaceDst, JSON.stringify(workspaceTemplate, null, 2), "utf8");
34497
+ await writeFile4(wakeupDst, wakeupContent, "utf8");
34389
34498
  }
34390
34499
  created.push(subagentDir);
34391
34500
  subagentsProvisioned += 1;
@@ -34393,8 +34502,8 @@ async function provisionSubagents(options) {
34393
34502
  }
34394
34503
  if (!dryRun && !await pathExists(workspaceDst)) {
34395
34504
  await ensureDir(githubAgentsDir);
34396
- await writeFile2(workspaceDst, JSON.stringify(workspaceTemplate, null, 2), "utf8");
34397
- await writeFile2(wakeupDst, wakeupContent, "utf8");
34505
+ await writeFile4(workspaceDst, JSON.stringify(workspaceTemplate, null, 2), "utf8");
34506
+ await writeFile4(wakeupDst, wakeupContent, "utf8");
34398
34507
  }
34399
34508
  skippedExisting.push(subagentDir);
34400
34509
  subagentsProvisioned += 1;
@@ -34402,16 +34511,16 @@ async function provisionSubagents(options) {
34402
34511
  let nextIndex = highestNumber;
34403
34512
  while (subagentsProvisioned < subagents) {
34404
34513
  nextIndex += 1;
34405
- const subagentDir = path7.join(targetPath, `subagent-${nextIndex}`);
34406
- const githubAgentsDir = path7.join(subagentDir, ".github", "agents");
34407
- const workspaceDst = path7.join(subagentDir, `${path7.basename(subagentDir)}.code-workspace`);
34408
- const wakeupDst = path7.join(githubAgentsDir, "wakeup.md");
34409
- const subagentDst = path7.join(githubAgentsDir, "subagent.md");
34514
+ const subagentDir = path11.join(targetPath, `subagent-${nextIndex}`);
34515
+ const githubAgentsDir = path11.join(subagentDir, ".github", "agents");
34516
+ const workspaceDst = path11.join(subagentDir, `${path11.basename(subagentDir)}.code-workspace`);
34517
+ const wakeupDst = path11.join(githubAgentsDir, "wakeup.md");
34518
+ const subagentDst = path11.join(githubAgentsDir, "subagent.md");
34410
34519
  if (!dryRun) {
34411
34520
  await ensureDir(subagentDir);
34412
34521
  await ensureDir(githubAgentsDir);
34413
- await writeFile2(workspaceDst, JSON.stringify(workspaceTemplate, null, 2), "utf8");
34414
- await writeFile2(wakeupDst, wakeupContent, "utf8");
34522
+ await writeFile4(workspaceDst, JSON.stringify(workspaceTemplate, null, 2), "utf8");
34523
+ await writeFile4(wakeupDst, wakeupContent, "utf8");
34415
34524
  }
34416
34525
  created.push(subagentDir);
34417
34526
  subagentsProvisioned += 1;
@@ -34425,12 +34534,12 @@ async function provisionSubagents(options) {
34425
34534
 
34426
34535
  // ../../packages/core/dist/index.js
34427
34536
  import { constants as constants32 } from "node:fs";
34428
- import { access as access32, readFile as readFile6 } from "node:fs/promises";
34429
- import path11 from "node:path";
34537
+ import { access as access32, readFile as readFile62 } from "node:fs/promises";
34538
+ import path112 from "node:path";
34430
34539
  import { parse as parse32 } from "yaml";
34431
34540
  import { createHash, randomUUID as randomUUID2 } from "node:crypto";
34432
34541
  import { mkdir as mkdir22, writeFile as writeFile22 } from "node:fs/promises";
34433
- import path12 from "node:path";
34542
+ import path122 from "node:path";
34434
34543
  var TEST_MESSAGE_ROLE_VALUES = ["system", "user", "assistant", "tool"];
34435
34544
  var TEST_MESSAGE_ROLE_SET = new Set(TEST_MESSAGE_ROLE_VALUES);
34436
34545
  function isTestMessageRole(value) {
@@ -34568,15 +34677,15 @@ function resolveToAbsolutePath(candidate) {
34568
34677
  if (candidate.startsWith("file://")) {
34569
34678
  return new URL(candidate).pathname;
34570
34679
  }
34571
- return path8.resolve(candidate);
34680
+ return path12.resolve(candidate);
34572
34681
  }
34573
34682
  throw new TypeError("Unsupported repoRoot value. Expected string or URL.");
34574
34683
  }
34575
34684
  function buildDirectoryChain2(filePath, repoRoot) {
34576
34685
  const directories = [];
34577
34686
  const seen = /* @__PURE__ */ new Set();
34578
- const boundary = path8.resolve(repoRoot);
34579
- let current = path8.resolve(path8.dirname(filePath));
34687
+ const boundary = path12.resolve(repoRoot);
34688
+ let current = path12.resolve(path12.dirname(filePath));
34580
34689
  while (current !== void 0) {
34581
34690
  if (!seen.has(current)) {
34582
34691
  directories.push(current);
@@ -34585,7 +34694,7 @@ function buildDirectoryChain2(filePath, repoRoot) {
34585
34694
  if (current === boundary) {
34586
34695
  break;
34587
34696
  }
34588
- const parent = path8.dirname(current);
34697
+ const parent = path12.dirname(current);
34589
34698
  if (parent === current) {
34590
34699
  break;
34591
34700
  }
@@ -34599,16 +34708,16 @@ function buildDirectoryChain2(filePath, repoRoot) {
34599
34708
  function buildSearchRoots2(evalPath, repoRoot) {
34600
34709
  const uniqueRoots = [];
34601
34710
  const addRoot = (root2) => {
34602
- const normalized = path8.resolve(root2);
34711
+ const normalized = path12.resolve(root2);
34603
34712
  if (!uniqueRoots.includes(normalized)) {
34604
34713
  uniqueRoots.push(normalized);
34605
34714
  }
34606
34715
  };
34607
- let currentDir = path8.dirname(evalPath);
34716
+ let currentDir = path12.dirname(evalPath);
34608
34717
  let reachedBoundary = false;
34609
34718
  while (!reachedBoundary) {
34610
34719
  addRoot(currentDir);
34611
- const parentDir = path8.dirname(currentDir);
34720
+ const parentDir = path12.dirname(currentDir);
34612
34721
  if (currentDir === repoRoot || parentDir === currentDir) {
34613
34722
  reachedBoundary = true;
34614
34723
  } else {
@@ -34626,16 +34735,16 @@ function trimLeadingSeparators2(value) {
34626
34735
  async function resolveFileReference2(rawValue, searchRoots) {
34627
34736
  const displayPath = trimLeadingSeparators2(rawValue);
34628
34737
  const potentialPaths = [];
34629
- if (path8.isAbsolute(rawValue)) {
34630
- potentialPaths.push(path8.normalize(rawValue));
34738
+ if (path12.isAbsolute(rawValue)) {
34739
+ potentialPaths.push(path12.normalize(rawValue));
34631
34740
  }
34632
34741
  for (const base of searchRoots) {
34633
- potentialPaths.push(path8.resolve(base, displayPath));
34742
+ potentialPaths.push(path12.resolve(base, displayPath));
34634
34743
  }
34635
34744
  const attempted = [];
34636
34745
  const seen = /* @__PURE__ */ new Set();
34637
34746
  for (const candidate of potentialPaths) {
34638
- const absoluteCandidate = path8.resolve(candidate);
34747
+ const absoluteCandidate = path12.resolve(candidate);
34639
34748
  if (seen.has(absoluteCandidate)) {
34640
34749
  continue;
34641
34750
  }
@@ -34658,7 +34767,7 @@ async function loadConfig(evalFilePath, repoRoot) {
34658
34767
  continue;
34659
34768
  }
34660
34769
  try {
34661
- const rawConfig = await readFile3(configPath, "utf8");
34770
+ const rawConfig = await readFile6(configPath, "utf8");
34662
34771
  const parsed = parse5(rawConfig);
34663
34772
  if (!isJsonObject(parsed)) {
34664
34773
  logWarning(`Invalid .agentv/config.yaml format at ${configPath}`);
@@ -35053,7 +35162,7 @@ async function buildPromptInputs(testCase, mode = "lm") {
35053
35162
  continue;
35054
35163
  }
35055
35164
  try {
35056
- const content = (await readFile4(absolutePath, "utf8")).replace(/\r\n/g, "\n").trim();
35165
+ const content = (await readFile42(absolutePath, "utf8")).replace(/\r\n/g, "\n").trim();
35057
35166
  guidelineParts.push({
35058
35167
  content,
35059
35168
  isFile: true,
@@ -35799,7 +35908,7 @@ var CliProvider = class {
35799
35908
  await this.ensureHealthy(request.signal);
35800
35909
  const outputFilePath = generateOutputFilePath(request.evalCaseId);
35801
35910
  const templateValues = buildTemplateValues(request, this.config, outputFilePath);
35802
- const renderedCommand = renderTemplate(this.config.commandTemplate, templateValues);
35911
+ const renderedCommand = renderTemplate2(this.config.commandTemplate, templateValues);
35803
35912
  const result = await this.runCommand(renderedCommand, {
35804
35913
  cwd: this.config.cwd,
35805
35914
  env: process.env,
@@ -35877,7 +35986,7 @@ var CliProvider = class {
35877
35986
  }
35878
35987
  return;
35879
35988
  }
35880
- const renderedCommand = renderTemplate(
35989
+ const renderedCommand = renderTemplate2(
35881
35990
  healthcheck.commandTemplate,
35882
35991
  buildTemplateValues(
35883
35992
  {
@@ -35945,7 +36054,7 @@ function formatFileList(files, template) {
35945
36054
  return formatter.replaceAll("{path}", escapedPath).replaceAll("{basename}", escapedName);
35946
36055
  }).join(" ");
35947
36056
  }
35948
- function renderTemplate(template, values) {
36057
+ function renderTemplate2(template, values) {
35949
36058
  return template.replace(/\{([A-Z_]+)\}/g, (match, key2) => {
35950
36059
  const replacement = values[key2];
35951
36060
  return replacement !== void 0 ? replacement : match;
@@ -36143,8 +36252,8 @@ var CodexProvider = class {
36143
36252
  const logger = await this.createStreamLogger(request).catch(() => void 0);
36144
36253
  try {
36145
36254
  const promptContent = buildPromptDocument(request, inputFiles);
36146
- const promptFile = path9.join(workspaceRoot, PROMPT_FILENAME);
36147
- await writeFile3(promptFile, promptContent, "utf8");
36255
+ const promptFile = path92.join(workspaceRoot, PROMPT_FILENAME);
36256
+ await writeFile5(promptFile, promptContent, "utf8");
36148
36257
  const args = this.buildCodexArgs();
36149
36258
  const cwd = this.resolveCwd(workspaceRoot);
36150
36259
  const result = await this.executeCodex(args, cwd, promptContent, request.signal, logger);
@@ -36193,7 +36302,7 @@ var CodexProvider = class {
36193
36302
  if (!this.config.cwd) {
36194
36303
  return workspaceRoot;
36195
36304
  }
36196
- return path9.resolve(this.config.cwd);
36305
+ return path92.resolve(this.config.cwd);
36197
36306
  }
36198
36307
  buildCodexArgs() {
36199
36308
  const args = [
@@ -36235,7 +36344,7 @@ var CodexProvider = class {
36235
36344
  }
36236
36345
  }
36237
36346
  async createWorkspace() {
36238
- return await mkdtemp(path9.join(tmpdir(), WORKSPACE_PREFIX));
36347
+ return await mkdtemp(path92.join(tmpdir(), WORKSPACE_PREFIX));
36239
36348
  }
36240
36349
  async cleanupWorkspace(workspaceRoot) {
36241
36350
  try {
@@ -36249,9 +36358,9 @@ var CodexProvider = class {
36249
36358
  return void 0;
36250
36359
  }
36251
36360
  if (this.config.logDir) {
36252
- return path9.resolve(this.config.logDir);
36361
+ return path92.resolve(this.config.logDir);
36253
36362
  }
36254
- return path9.join(process.cwd(), ".agentv", "logs", "codex");
36363
+ return path92.join(process.cwd(), ".agentv", "logs", "codex");
36255
36364
  }
36256
36365
  async createStreamLogger(request) {
36257
36366
  const logDir = this.resolveLogDirectory();
@@ -36259,13 +36368,13 @@ var CodexProvider = class {
36259
36368
  return void 0;
36260
36369
  }
36261
36370
  try {
36262
- await mkdir3(logDir, { recursive: true });
36371
+ await mkdir4(logDir, { recursive: true });
36263
36372
  } catch (error40) {
36264
36373
  const message = error40 instanceof Error ? error40.message : String(error40);
36265
36374
  console.warn(`Skipping Codex stream logging (could not create ${logDir}): ${message}`);
36266
36375
  return void 0;
36267
36376
  }
36268
- const filePath = path9.join(logDir, buildLogFilename(request, this.targetName));
36377
+ const filePath = path92.join(logDir, buildLogFilename(request, this.targetName));
36269
36378
  try {
36270
36379
  const logger = await CodexStreamLogger.create({
36271
36380
  filePath,
@@ -36480,7 +36589,7 @@ function tryParseJsonValue(rawLine) {
36480
36589
  async function locateExecutable(candidate) {
36481
36590
  const includesPathSeparator = candidate.includes("/") || candidate.includes("\\");
36482
36591
  if (includesPathSeparator) {
36483
- const resolved = path9.isAbsolute(candidate) ? candidate : path9.resolve(candidate);
36592
+ const resolved = path92.isAbsolute(candidate) ? candidate : path92.resolve(candidate);
36484
36593
  const executablePath = await ensureWindowsExecutableVariant(resolved);
36485
36594
  await access22(executablePath, constants22.F_OK);
36486
36595
  return executablePath;
@@ -36823,6 +36932,39 @@ var MockProvider = class {
36823
36932
  return this.delayMs;
36824
36933
  }
36825
36934
  };
36935
+ var AGENTV_REQUEST_TEMPLATE = `[[ ## system_instructions ## ]]
36936
+
36937
+ **IMPORTANT**: You are processing an evaluation request from AgentV. Follow these exact steps:
36938
+
36939
+ 1. Read and understand all guideline files and attachments provided above
36940
+ 2. Process the user query below according to the guidelines
36941
+ 3. Write your complete response to: {{responseFileTmp}}
36942
+ 4. When completely finished, run these PowerShell commands to signal completion:
36943
+ \`\`\`powershell
36944
+ Move-Item -LiteralPath '{{responseFileTmp}}' -Destination '{{responseFileFinal}}'
36945
+ if (Test-Path subagent.lock) { Remove-Item subagent.lock }
36946
+ \`\`\`
36947
+
36948
+ Do not proceed to step 4 until your response is completely written to the temporary file.
36949
+
36950
+ [[ ## task ## ]]
36951
+
36952
+ {{userQuery}}
36953
+ `;
36954
+ var AGENTV_BATCH_REQUEST_TEMPLATE = `[[ ## system_instructions ## ]]
36955
+
36956
+ **IMPORTANT**: You are processing a batch evaluation request from AgentV. Follow these exact steps:
36957
+
36958
+ 1. Read and understand all guideline files and attachments provided above
36959
+ 2. Process the user query below according to the guidelines
36960
+ 3. Write your complete response to: {{responseFileTmp}}
36961
+ 4. When completely finished and the response is stable, rename it to: {{responseFileFinal}}
36962
+ 5. Do not unlock the workspace from this request; batch orchestration will handle unlocking after all responses are ready.
36963
+
36964
+ [[ ## task ## ]]
36965
+
36966
+ {{userQuery}}
36967
+ `;
36826
36968
  var VSCodeProvider = class {
36827
36969
  id;
36828
36970
  kind;
@@ -36844,6 +36986,7 @@ var VSCodeProvider = class {
36844
36986
  const session = await dispatchAgentSession({
36845
36987
  userQuery: promptContent,
36846
36988
  extraAttachments: inputFiles,
36989
+ requestTemplate: AGENTV_REQUEST_TEMPLATE,
36847
36990
  wait: this.config.waitForResponse,
36848
36991
  dryRun: this.config.dryRun,
36849
36992
  vscodeCmd: this.config.command,
@@ -36890,6 +37033,7 @@ var VSCodeProvider = class {
36890
37033
  const session = await dispatchBatchAgent({
36891
37034
  userQueries,
36892
37035
  extraAttachments: combinedInputFiles,
37036
+ requestTemplate: AGENTV_BATCH_REQUEST_TEMPLATE,
36893
37037
  wait: this.config.waitForResponse,
36894
37038
  dryRun: this.config.dryRun,
36895
37039
  vscodeCmd: this.config.command,
@@ -36952,7 +37096,7 @@ function buildMandatoryPrereadBlock2(guidelineFiles, attachmentFiles) {
36952
37096
  return "";
36953
37097
  }
36954
37098
  const buildList = (files) => files.map((absolutePath) => {
36955
- const fileName = path10.basename(absolutePath);
37099
+ const fileName = path102.basename(absolutePath);
36956
37100
  const fileUri = pathToFileUri22(absolutePath);
36957
37101
  return `* [${fileName}](${fileUri})`;
36958
37102
  });
@@ -36977,8 +37121,8 @@ function collectGuidelineFiles2(attachments, guidelinePatterns) {
36977
37121
  }
36978
37122
  const unique = /* @__PURE__ */ new Map();
36979
37123
  for (const attachment of attachments) {
36980
- const absolutePath = path10.resolve(attachment);
36981
- const normalized = absolutePath.split(path10.sep).join("/");
37124
+ const absolutePath = path102.resolve(attachment);
37125
+ const normalized = absolutePath.split(path102.sep).join("/");
36982
37126
  if (isGuidelineFile(normalized, guidelinePatterns)) {
36983
37127
  if (!unique.has(absolutePath)) {
36984
37128
  unique.set(absolutePath, absolutePath);
@@ -36993,7 +37137,7 @@ function collectAttachmentFiles(attachments) {
36993
37137
  }
36994
37138
  const unique = /* @__PURE__ */ new Map();
36995
37139
  for (const attachment of attachments) {
36996
- const absolutePath = path10.resolve(attachment);
37140
+ const absolutePath = path102.resolve(attachment);
36997
37141
  if (!unique.has(absolutePath)) {
36998
37142
  unique.set(absolutePath, absolutePath);
36999
37143
  }
@@ -37001,7 +37145,7 @@ function collectAttachmentFiles(attachments) {
37001
37145
  return Array.from(unique.values());
37002
37146
  }
37003
37147
  function pathToFileUri22(filePath) {
37004
- const absolutePath = path10.isAbsolute(filePath) ? filePath : path10.resolve(filePath);
37148
+ const absolutePath = path102.isAbsolute(filePath) ? filePath : path102.resolve(filePath);
37005
37149
  const normalizedPath = absolutePath.replace(/\\/g, "/");
37006
37150
  if (/^[a-zA-Z]:\//.test(normalizedPath)) {
37007
37151
  return `file:///${normalizedPath}`;
@@ -37014,7 +37158,7 @@ function normalizeAttachments(attachments) {
37014
37158
  }
37015
37159
  const deduped = /* @__PURE__ */ new Set();
37016
37160
  for (const attachment of attachments) {
37017
- deduped.add(path10.resolve(attachment));
37161
+ deduped.add(path102.resolve(attachment));
37018
37162
  }
37019
37163
  return Array.from(deduped);
37020
37164
  }
@@ -37023,7 +37167,7 @@ function mergeAttachments(all) {
37023
37167
  for (const list of all) {
37024
37168
  if (!list) continue;
37025
37169
  for (const inputFile of list) {
37026
- deduped.add(path10.resolve(inputFile));
37170
+ deduped.add(path102.resolve(inputFile));
37027
37171
  }
37028
37172
  }
37029
37173
  return deduped.size > 0 ? Array.from(deduped) : void 0;
@@ -37103,11 +37247,11 @@ async function fileExists3(filePath) {
37103
37247
  }
37104
37248
  }
37105
37249
  async function readTargetDefinitions(filePath) {
37106
- const absolutePath = path11.resolve(filePath);
37250
+ const absolutePath = path112.resolve(filePath);
37107
37251
  if (!await fileExists3(absolutePath)) {
37108
37252
  throw new Error(`targets.yaml not found at ${absolutePath}`);
37109
37253
  }
37110
- const raw = await readFile6(absolutePath, "utf8");
37254
+ const raw = await readFile62(absolutePath, "utf8");
37111
37255
  const parsed = parse32(raw);
37112
37256
  if (!isRecord(parsed)) {
37113
37257
  throw new Error(`targets.yaml at ${absolutePath} must be a YAML object with a 'targets' field`);
@@ -38238,8 +38382,8 @@ function buildEvaluatorRegistry(overrides, resolveJudgeProvider) {
38238
38382
  async function dumpPrompt(directory, evalCase, promptInputs) {
38239
38383
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
38240
38384
  const filename = `${timestamp}_${sanitizeFilename(evalCase.id)}.json`;
38241
- const filePath = path12.resolve(directory, filename);
38242
- await mkdir22(path12.dirname(filePath), { recursive: true });
38385
+ const filePath = path122.resolve(directory, filename);
38386
+ await mkdir22(path122.dirname(filePath), { recursive: true });
38243
38387
  const payload = {
38244
38388
  eval_id: evalCase.id,
38245
38389
  question: promptInputs.question,
@@ -38422,7 +38566,7 @@ async function loadEnvFromHierarchy(options) {
38422
38566
 
38423
38567
  // src/commands/eval/jsonl-writer.ts
38424
38568
  import { createWriteStream as createWriteStream2 } from "node:fs";
38425
- import { mkdir as mkdir4 } from "node:fs/promises";
38569
+ import { mkdir as mkdir5 } from "node:fs/promises";
38426
38570
  import path14 from "node:path";
38427
38571
  import { finished } from "node:stream/promises";
38428
38572
 
@@ -38641,7 +38785,7 @@ var JsonlWriter = class _JsonlWriter {
38641
38785
  this.stream = stream;
38642
38786
  }
38643
38787
  static async open(filePath) {
38644
- await mkdir4(path14.dirname(filePath), { recursive: true });
38788
+ await mkdir5(path14.dirname(filePath), { recursive: true });
38645
38789
  const stream = createWriteStream2(filePath, { flags: "w", encoding: "utf8" });
38646
38790
  return new _JsonlWriter(stream);
38647
38791
  }
@@ -38672,7 +38816,7 @@ var JsonlWriter = class _JsonlWriter {
38672
38816
 
38673
38817
  // src/commands/eval/yaml-writer.ts
38674
38818
  import { createWriteStream as createWriteStream3 } from "node:fs";
38675
- import { mkdir as mkdir5 } from "node:fs/promises";
38819
+ import { mkdir as mkdir6 } from "node:fs/promises";
38676
38820
  import path15 from "node:path";
38677
38821
  import { finished as finished2 } from "node:stream/promises";
38678
38822
  import { stringify as stringifyYaml } from "yaml";
@@ -38685,7 +38829,7 @@ var YamlWriter = class _YamlWriter {
38685
38829
  this.stream = stream;
38686
38830
  }
38687
38831
  static async open(filePath) {
38688
- await mkdir5(path15.dirname(filePath), { recursive: true });
38832
+ await mkdir6(path15.dirname(filePath), { recursive: true });
38689
38833
  const stream = createWriteStream3(filePath, { flags: "w", encoding: "utf8" });
38690
38834
  return new _YamlWriter(stream);
38691
38835
  }
@@ -39099,7 +39243,7 @@ import { parse as parse23 } from "yaml";
39099
39243
  import { readFile as readFile33 } from "node:fs/promises";
39100
39244
  import path23 from "node:path";
39101
39245
  import { parse as parse33 } from "yaml";
39102
- import { readFile as readFile42 } from "node:fs/promises";
39246
+ import { readFile as readFile43 } from "node:fs/promises";
39103
39247
  import { parse as parse42 } from "yaml";
39104
39248
  import { readFile as readFile52 } from "node:fs/promises";
39105
39249
  import path33 from "node:path";
@@ -39754,7 +39898,7 @@ var SCHEMA_CONFIG_V222 = "agentv-config-v2";
39754
39898
  async function validateConfigFile(filePath) {
39755
39899
  const errors = [];
39756
39900
  try {
39757
- const content = await readFile42(filePath, "utf8");
39901
+ const content = await readFile43(filePath, "utf8");
39758
39902
  const parsed = parse42(content);
39759
39903
  if (typeof parsed !== "object" || parsed === null) {
39760
39904
  errors.push({
@@ -40297,7 +40441,7 @@ async function runSingleEvalFile(params) {
40297
40441
  }
40298
40442
  const promptDumpDir = resolvePromptDirectory(options.dumpPrompts, cwd);
40299
40443
  if (promptDumpDir) {
40300
- await mkdir6(promptDumpDir, { recursive: true });
40444
+ await mkdir7(promptDumpDir, { recursive: true });
40301
40445
  if (options.verbose) {
40302
40446
  console.log(`Prompt dumps enabled at: ${promptDumpDir}`);
40303
40447
  }
@@ -40550,7 +40694,7 @@ async function resolveEvalPaths(evalPaths, cwd) {
40550
40694
  for (const pattern of normalizedInputs) {
40551
40695
  const candidatePath = path19.isAbsolute(pattern) ? path19.normalize(pattern) : path19.resolve(cwd, pattern);
40552
40696
  try {
40553
- const stats = await stat3(candidatePath);
40697
+ const stats = await stat4(candidatePath);
40554
40698
  if (stats.isFile() && /\.ya?ml$/i.test(candidatePath)) {
40555
40699
  results.add(candidatePath);
40556
40700
  continue;
@@ -40620,9 +40764,9 @@ function readTemplatesRecursively(dir, relativePath) {
40620
40764
  const entries = readdirSync(dir);
40621
40765
  for (const entry of entries) {
40622
40766
  const fullPath = path20.join(dir, entry);
40623
- const stat5 = statSync(fullPath);
40767
+ const stat6 = statSync(fullPath);
40624
40768
  const entryRelativePath = relativePath ? path20.join(relativePath, entry) : entry;
40625
- if (stat5.isDirectory()) {
40769
+ if (stat6.isDirectory()) {
40626
40770
  templates.push(...readTemplatesRecursively(fullPath, entryRelativePath));
40627
40771
  } else {
40628
40772
  const content = readFileSync(fullPath, "utf-8");
@@ -40861,7 +41005,7 @@ function isTTY2() {
40861
41005
 
40862
41006
  // src/commands/validate/validate-files.ts
40863
41007
  import { constants as constants7 } from "node:fs";
40864
- import { access as access7, readdir as readdir3, stat as stat4 } from "node:fs/promises";
41008
+ import { access as access7, readdir as readdir3, stat as stat5 } from "node:fs/promises";
40865
41009
  import path24 from "node:path";
40866
41010
  async function validateFiles(paths) {
40867
41011
  const filePaths = await expandPaths(paths);
@@ -40926,7 +41070,7 @@ async function expandPaths(paths) {
40926
41070
  console.warn(`Warning: Path not found: ${inputPath}`);
40927
41071
  continue;
40928
41072
  }
40929
- const stats = await stat4(absolutePath);
41073
+ const stats = await stat5(absolutePath);
40930
41074
  if (stats.isFile()) {
40931
41075
  if (isYamlFile(absolutePath)) {
40932
41076
  expanded.push(absolutePath);
@@ -41019,4 +41163,4 @@ export {
41019
41163
  createProgram,
41020
41164
  runCli
41021
41165
  };
41022
- //# sourceMappingURL=chunk-PHILDJ3W.js.map
41166
+ //# sourceMappingURL=chunk-N7M3URIJ.js.map