claude-task-worker 0.88.0 → 0.89.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.
Files changed (2) hide show
  1. package/dist/index.js +35 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -583,6 +583,8 @@ __export(herdr_runner_exports, {
583
583
  PANE_OUTPUT_LINES: () => PANE_OUTPUT_LINES,
584
584
  PANE_READY_POLL_INTERVAL_MS: () => PANE_READY_POLL_INTERVAL_MS,
585
585
  PANE_READY_TIMEOUT_MS: () => PANE_READY_TIMEOUT_MS,
586
+ PROMPT_ACCEPT_POLL_INTERVAL_MS: () => PROMPT_ACCEPT_POLL_INTERVAL_MS,
587
+ PROMPT_ACCEPT_TIMEOUT_MS: () => PROMPT_ACCEPT_TIMEOUT_MS,
586
588
  buildHerdrTaskResult: () => buildHerdrTaskResult,
587
589
  createCompletionTracker: () => createCompletionTracker,
588
590
  observeAgentStatus: () => observeAgentStatus,
@@ -657,13 +659,43 @@ async function startHerdrTask({
657
659
  }
658
660
  await mod.agentStart(paneId, { name: toAgentName(label), args, readyTimeoutMs: timing?.agentStartReadyTimeoutMs });
659
661
  await mod.agentPrompt(paneId, prompt);
662
+ await ensurePromptAccepted(paneId, prompt, mod, timing);
660
663
  } catch (err) {
664
+ console.error(`[herdr-runner] failed to start task in pane ${paneId}: ${err}`);
661
665
  await mod.tabClose(tabId).catch(() => {
662
666
  });
663
667
  throw err;
664
668
  }
665
669
  return { paneId, tabId };
666
670
  }
671
+ async function ensurePromptAccepted(paneId, prompt, mod, timing) {
672
+ if (await waitForPromptAccepted(paneId, mod, timing)) return;
673
+ console.warn(`[herdr-runner] the prompt was not accepted in pane ${paneId} (claude stayed idle); resending it`);
674
+ await mod.agentPrompt(paneId, prompt);
675
+ if (await waitForPromptAccepted(paneId, mod, timing)) return;
676
+ throw new Error(
677
+ `the claude session in pane ${paneId} did not start the task after the prompt was submitted twice (a startup dialog most likely swallowed it)`
678
+ );
679
+ }
680
+ async function waitForPromptAccepted(paneId, mod, timing) {
681
+ const timeoutMs = timing?.promptAcceptTimeoutMs ?? PROMPT_ACCEPT_TIMEOUT_MS;
682
+ const pollIntervalMs = timing?.promptAcceptPollIntervalMs ?? PROMPT_ACCEPT_POLL_INTERVAL_MS;
683
+ const deadline = Date.now() + timeoutMs;
684
+ let loggedError = false;
685
+ for (; ; ) {
686
+ try {
687
+ const { agentStatus } = await mod.agentGet(paneId);
688
+ if (agentStatus === "working" || agentStatus === "done") return true;
689
+ } catch (err) {
690
+ if (!loggedError) {
691
+ console.error(`[herdr-runner] failed to read agent status for pane ${paneId} after the prompt: ${err}`);
692
+ loggedError = true;
693
+ }
694
+ }
695
+ if (Date.now() >= deadline) return false;
696
+ await sleep(pollIntervalMs);
697
+ }
698
+ }
667
699
  async function waitForPaneReady(paneId, mod, options) {
668
700
  const timeoutMs = options?.timeoutMs ?? PANE_READY_TIMEOUT_MS;
669
701
  const pollIntervalMs = options?.pollIntervalMs ?? PANE_READY_POLL_INTERVAL_MS;
@@ -769,7 +801,7 @@ async function stopHerdrTask(task, herdr, options) {
769
801
  function sleep(ms) {
770
802
  return new Promise((resolve3) => setTimeout(resolve3, ms));
771
803
  }
772
- var AGENT_POLL_INTERVAL_MS, PANE_OUTPUT_LINES, PANE_READY_TIMEOUT_MS, PANE_READY_POLL_INTERVAL_MS, CLAUDE_EXIT_TIMEOUT_MS, CLAUDE_EXIT_POLL_INTERVAL_MS;
804
+ var AGENT_POLL_INTERVAL_MS, PANE_OUTPUT_LINES, PANE_READY_TIMEOUT_MS, PANE_READY_POLL_INTERVAL_MS, PROMPT_ACCEPT_TIMEOUT_MS, PROMPT_ACCEPT_POLL_INTERVAL_MS, CLAUDE_EXIT_TIMEOUT_MS, CLAUDE_EXIT_POLL_INTERVAL_MS;
773
805
  var init_herdr_runner = __esm({
774
806
  "src/herdr-runner.ts"() {
775
807
  "use strict";
@@ -778,6 +810,8 @@ var init_herdr_runner = __esm({
778
810
  PANE_OUTPUT_LINES = 300;
779
811
  PANE_READY_TIMEOUT_MS = 30 * 1e3;
780
812
  PANE_READY_POLL_INTERVAL_MS = 200;
813
+ PROMPT_ACCEPT_TIMEOUT_MS = 20 * 1e3;
814
+ PROMPT_ACCEPT_POLL_INTERVAL_MS = 500;
781
815
  CLAUDE_EXIT_TIMEOUT_MS = 15 * 1e3;
782
816
  CLAUDE_EXIT_POLL_INTERVAL_MS = 200;
783
817
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-task-worker",
3
- "version": "0.88.0",
3
+ "version": "0.89.0",
4
4
  "description": "CLI tool that polls GitHub Issues/PRs and delegates work to Claude CLI",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",