@henryqw/pi-herdr-clone 0.2.7 → 0.2.8

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.
@@ -12,7 +12,7 @@ import {
12
12
  import {
13
13
  createHerdrClient,
14
14
  herdrCommandFailure,
15
- hasHerdrErrorCode,
15
+ startPiAgent,
16
16
  withWorktreeLock,
17
17
  type HerdrClient,
18
18
  type HerdrExecResult,
@@ -199,24 +199,25 @@ async function launchCloneAgent(
199
199
  ): Promise<string> {
200
200
  const agentName = `clone-${randomUUID().replaceAll("-", "").slice(0, 24)}`;
201
201
  try {
202
- for (let attempt = 1; attempt <= 5; attempt += 1) {
203
- const startArgs = [
204
- "agent", "start", agentName, "--kind", "pi", "--pane", rootPaneId,
205
- "--", "--session", cloneFile,
206
- ];
207
- const result = await herdr.exec(startArgs, { cwd: ctx.cwd });
208
- if (result.code === 0 && !result.killed) return agentName;
209
- if (hasHerdrErrorCode(result, "agent_pane_busy") && onPaneBusy) {
210
- ({ rootPaneId, retained } = await onPaneBusy());
211
- onPaneBusy = undefined;
212
- continue;
213
- }
214
- if (!hasHerdrErrorCode(result, "agent_pane_busy") || attempt === 5) {
215
- throw new Error(herdrCommandFailure(startArgs, result));
216
- }
217
- await delay(250);
218
- }
219
- throw new Error("Herdr agent start retry loop exited unexpectedly.");
202
+ const result = await startPiAgent(herdr, {
203
+ name: agentName,
204
+ pane: rootPaneId,
205
+ args: ["--session", cloneFile],
206
+ options: { cwd: ctx.cwd },
207
+ onPaneBusy: onPaneBusy
208
+ ? async () => {
209
+ const next = await onPaneBusy!();
210
+ rootPaneId = next.rootPaneId;
211
+ retained = next.retained;
212
+ return rootPaneId;
213
+ }
214
+ : undefined,
215
+ });
216
+ if (result.code === 0 && !result.killed) return agentName;
217
+ const startArgs = [
218
+ "agent", "start", agentName, "--kind", "pi", "--pane", rootPaneId, "--", "--session", cloneFile,
219
+ ];
220
+ throw new Error(herdrCommandFailure(startArgs, result));
220
221
  } catch (error) {
221
222
  throw new Error(
222
223
  `Clone launch could not be confirmed after starting agent ${agentName}; retained ${retained}: ${errorMessage(error)}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@henryqw/pi-herdr-clone",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "description": "Clone the current Pi conversation path into a new Herdr tab.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -28,7 +28,7 @@
28
28
  "@earendil-works/pi-coding-agent": "^0.84.2"
29
29
  },
30
30
  "dependencies": {
31
- "@henryqw/pi-herdr": "^0.3.0"
31
+ "@henryqw/pi-herdr": "^0.4.0"
32
32
  },
33
33
  "repository": {
34
34
  "type": "git",