@adhdev/daemon-standalone 0.8.4 → 0.8.6

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.
package/dist/index.js CHANGED
@@ -34609,6 +34609,37 @@ ${data.message || ""}`.trim();
34609
34609
  }
34610
34610
  return resolved;
34611
34611
  }
34612
+ function listDirectoryEntriesSafe(dirPath) {
34613
+ const entries = fs42.readdirSync(dirPath, { withFileTypes: true });
34614
+ const files = [];
34615
+ for (const entry of entries) {
34616
+ const entryPath = path6.join(dirPath, entry.name);
34617
+ try {
34618
+ if (entry.isDirectory()) {
34619
+ files.push({ name: entry.name, type: "directory" });
34620
+ continue;
34621
+ }
34622
+ if (entry.isFile()) {
34623
+ let size;
34624
+ try {
34625
+ size = fs42.statSync(entryPath).size;
34626
+ } catch {
34627
+ size = void 0;
34628
+ }
34629
+ files.push({ name: entry.name, type: "file", size });
34630
+ continue;
34631
+ }
34632
+ const stat4 = fs42.statSync(entryPath);
34633
+ files.push({
34634
+ name: entry.name,
34635
+ type: stat4.isDirectory() ? "directory" : "file",
34636
+ size: stat4.isFile() ? stat4.size : void 0
34637
+ });
34638
+ } catch {
34639
+ }
34640
+ }
34641
+ return files;
34642
+ }
34612
34643
  async function handleFileRead(h, args) {
34613
34644
  try {
34614
34645
  const filePath = resolveSafePath(args?.path);
@@ -34631,19 +34662,20 @@ ${data.message || ""}`.trim();
34631
34662
  async function handleFileList(h, args) {
34632
34663
  try {
34633
34664
  const dirPath = resolveSafePath(args?.path || ".");
34634
- const entries = fs42.readdirSync(dirPath, { withFileTypes: true });
34635
- const files = entries.map((e) => ({
34636
- name: e.name,
34637
- type: e.isDirectory() ? "directory" : "file",
34638
- size: e.isFile() ? fs42.statSync(path6.join(dirPath, e.name)).size : void 0
34639
- }));
34665
+ const files = listDirectoryEntriesSafe(dirPath);
34640
34666
  return { success: true, files, path: dirPath };
34641
34667
  } catch (e) {
34642
34668
  return { success: false, error: e.message };
34643
34669
  }
34644
34670
  }
34645
34671
  async function handleFileListBrowse(h, args) {
34646
- return handleFileList(h, args);
34672
+ try {
34673
+ const dirPath = resolveSafePath(args?.path || ".");
34674
+ const files = listDirectoryEntriesSafe(dirPath).filter((entry) => entry.type === "directory").sort((a, b2) => a.name.localeCompare(b2.name));
34675
+ return { success: true, files, path: dirPath };
34676
+ } catch (e) {
34677
+ return { success: false, error: e.message };
34678
+ }
34647
34679
  }
34648
34680
  init_logger();
34649
34681
  function getCliPresentationMode(h, targetSessionId) {
@@ -43492,6 +43524,8 @@ async (params) => {
43492
43524
  let approvalBuffer = "";
43493
43525
  let lastApprovalTime = 0;
43494
43526
  let completionSignalSeen = false;
43527
+ let autoStopTimer = null;
43528
+ let autoStopIssued = false;
43495
43529
  try {
43496
43530
  const { normalizeCliProviderForRuntime: normalizeCliProviderForRuntime2 } = await Promise.resolve().then(() => (init_provider_cli_adapter(), provider_cli_adapter_exports));
43497
43531
  const normalized = normalizeCliProviderForRuntime2(agentProvider);
@@ -43529,8 +43563,37 @@ async (params) => {
43529
43563
  lastApprovalTime = Date.now();
43530
43564
  }
43531
43565
  };
43566
+ const clearAutoStopTimer = () => {
43567
+ if (autoStopTimer) {
43568
+ clearTimeout(autoStopTimer);
43569
+ autoStopTimer = null;
43570
+ }
43571
+ };
43572
+ const scheduleAutoStopForVerification = () => {
43573
+ if (!verification || command !== "codex" || completionSignalSeen || autoStopIssued) return;
43574
+ const elapsed = Date.now() - spawnedAt;
43575
+ if (elapsed < 3e4) return;
43576
+ clearAutoStopTimer();
43577
+ autoStopTimer = setTimeout(() => {
43578
+ if (!ctx.autoImplProcess || completionSignalSeen || autoStopIssued) return;
43579
+ autoStopIssued = true;
43580
+ ctx.log(`Auto-implement output quiet for 30s after ${Math.round((Date.now() - spawnedAt) / 1e3)}s. Interrupting agent and switching to daemon verification.`);
43581
+ sendAutoImplSSE(ctx, {
43582
+ event: "output",
43583
+ data: {
43584
+ chunk: "\n[\u{1F916} ADHDev Pipeline] Agent output quiet. Interrupting and running daemon verification...\n",
43585
+ stream: "stdout"
43586
+ }
43587
+ });
43588
+ try {
43589
+ ctx.autoImplProcess.kill("SIGINT");
43590
+ } catch {
43591
+ }
43592
+ }, 3e4);
43593
+ };
43532
43594
  const finalizeCliAutoImpl = async (code) => {
43533
43595
  ctx.autoImplProcess = null;
43596
+ clearAutoStopTimer();
43534
43597
  let success2 = completionSignalSeen || code === 0;
43535
43598
  let message = success2 ? completionSignalSeen && code !== 0 ? "\u2705 Auto-implement complete (completion signal)" : "\u2705 Auto-implement complete" : `\u274C Agent exited (code: ${code})`;
43536
43599
  let verificationSummary = null;
@@ -43581,12 +43644,14 @@ async (params) => {
43581
43644
  if (isPty) {
43582
43645
  child.onData((data) => {
43583
43646
  stdout += data;
43647
+ clearAutoStopTimer();
43584
43648
  if (data.includes("\x1B[6n")) {
43585
43649
  child.write("\x1B[12;1R");
43586
43650
  ctx.log("Terminal CPR request (\\x1b[6n) intercepted in PTY, responding with dummy coordinates [12;1R]");
43587
43651
  }
43588
43652
  checkAutoApproval(data, (s15) => child.write(s15));
43589
43653
  sendAutoImplSSE(ctx, { event: "output", data: { chunk: data, stream: "stdout" } });
43654
+ scheduleAutoStopForVerification();
43590
43655
  });
43591
43656
  child.onExit(({ exitCode: code }) => {
43592
43657
  void finalizeCliAutoImpl(code);
@@ -43595,15 +43660,19 @@ async (params) => {
43595
43660
  child.stdout?.on("data", (d) => {
43596
43661
  const chunk = d.toString();
43597
43662
  stdout += chunk;
43663
+ clearAutoStopTimer();
43598
43664
  if (chunk.includes("\x1B[6n")) child.stdin?.write("\x1B[1;1R");
43599
43665
  checkAutoApproval(chunk, (s15) => child.stdin?.write(s15));
43600
43666
  sendAutoImplSSE(ctx, { event: "output", data: { chunk, stream: "stdout" } });
43667
+ scheduleAutoStopForVerification();
43601
43668
  });
43602
43669
  child.stderr?.on("data", (d) => {
43603
43670
  const chunk = d.toString();
43604
43671
  stderr += chunk;
43672
+ clearAutoStopTimer();
43605
43673
  checkAutoApproval(chunk, (s15) => child.stdin?.write(s15));
43606
43674
  sendAutoImplSSE(ctx, { event: "output", data: { chunk, stream: "stderr" } });
43675
+ scheduleAutoStopForVerification();
43607
43676
  });
43608
43677
  child.on("exit", (code) => {
43609
43678
  void finalizeCliAutoImpl(code);