@parcha/agentrun-harness-acp 0.1.0-beta.50 → 0.1.0-beta.52

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/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## 0.1.0-beta.52 (2026-11-21)
6
+
7
+ - An ACP agent's failure words no longer keep a piece of a recipe key when the agent is still writing that key at the end of its stderr tail, or when two keys overlap: every place a key or its start appears is found in the text as written, then all of them are cut at once. <!-- changes/acp-key-cut-tail-end.md -->
8
+
9
+ ## 0.1.0-beta.51 (2026-11-21)
10
+
11
+ - A person's answer to an ACP agent's own tool call (Cursor's shell) now reaches the run when the agent, started again, asks for another command instead: the adapter asks about each request the turn left waiting before it starts the agent, so the answer is taken and the run's pending approval moves on, and with no answer yet the run parks again with no prompt sent. Before, the answer was never taken, and the run restarted the agent every few seconds, each time with a new approval, until the plan's turn limit. The recovery note tells the agent what the person answered, and an agent that asks for another command three times (`REASK_LIMIT`) instead of the one the person allowed ends its turn with `ACP_REASK_LIMIT`. <!-- changes/acp-parked-permission-settled.md -->
12
+ - An ACP agent (Cursor) that skipped a command the person allowed no longer has its turn cut after three more commands its tool setting allows: only commands that wait for the person count toward `REASK_LIMIT`. An allow-once is now used once: if a later agent process in the same turn asks for the same command again, the person is asked again instead of the old allow running it a second time. <!-- changes/acp-reask-parks-only.md -->
13
+
5
14
  ## 0.1.0-beta.48 (2026-11-20)
6
15
 
7
16
  - A harness module builds its harness the way the built-in harnesses are built: `entries(builtins, kit)` now gets a kit with `kit.adapterEntry(facts, adapter)` and `kit.acpEntry({ facts, recipe, proxy })`, so the harness is offered its wire's vendor's models, named on that vendor's and OpenRouter's key rows, and gated and named by its own facts. [HARNESS.md](../../HARNESS.md) is the guide, and `examples/harness-module` is a whole module (Goose under an id of its own). <!-- changes/harness-modules-kit.md -->
package/dist/facts.d.ts CHANGED
@@ -24,6 +24,8 @@ export declare const ACP_CODES: Readonly<{
24
24
  readonly keyMissing: "ACP_KEY_MISSING";
25
25
  /** The run's model (recipe.model) is not one the agent lists for its key: no prompt was sent. */
26
26
  readonly modelUnlisted: "ACP_MODEL_UNLISTED";
27
+ /** The agent asked for another call of its own tools REASK_LIMIT times in a turn instead of one the person allowed. */
28
+ readonly reaskLimit: "ACP_REASK_LIMIT";
27
29
  }>;
28
30
  export interface AcpFacts {
29
31
  readonly id: string;
package/dist/facts.js CHANGED
@@ -27,6 +27,8 @@ export const ACP_CODES = Object.freeze({
27
27
  keyMissing: "ACP_KEY_MISSING",
28
28
  /** The run's model (recipe.model) is not one the agent lists for its key: no prompt was sent. */
29
29
  modelUnlisted: "ACP_MODEL_UNLISTED",
30
+ /** The agent asked for another call of its own tools REASK_LIMIT times in a turn instead of one the person allowed. */
31
+ reaskLimit: "ACP_REASK_LIMIT",
30
32
  });
31
33
  /** The facts of the ACP harness `id`. */
32
34
  export function acpFacts(id, label = id) {
package/dist/harness.d.ts CHANGED
@@ -11,6 +11,12 @@ export declare const PROMPT_STREAM = "acp.prompt";
11
11
  export declare const CALL_STREAM = "acp.call";
12
12
  /** The permission requests for the agent's own tools: `asked` before the gate is, `answered` with what it said. */
13
13
  export declare const PERMISSION_STREAM = "acp.permission";
14
+ /** How many of the agent's own calls, in one turn, may park on the person while a call the person allowed on a resume is
15
+ * still not asked for again. At the limit the turn ends ACP_REASK_LIMIT on the resume, before the agent starts again: an
16
+ * agent that writes a new command after each restart (Cursor) never gets to the approved one. A call the gate answers
17
+ * without parking (a tool set to allow or to deny) is never counted. Read on the resume because a park commits the run
18
+ * parked before the gate answers. */
19
+ export declare const REASK_LIMIT = 3;
14
20
  /** One record per tool call the agent announced (or MCP call it made unannounced): the calls a plan-billed run counts. */
15
21
  export declare const TOOLS_STREAM = "acp.tools";
16
22
  /** The model chosen for the agent's session (recipe.model, as the agent lists it), one record each time one is chosen. */
package/dist/harness.js CHANGED
@@ -34,6 +34,12 @@ export const PROMPT_STREAM = "acp.prompt";
34
34
  export const CALL_STREAM = "acp.call";
35
35
  /** The permission requests for the agent's own tools: `asked` before the gate is, `answered` with what it said. */
36
36
  export const PERMISSION_STREAM = "acp.permission";
37
+ /** How many of the agent's own calls, in one turn, may park on the person while a call the person allowed on a resume is
38
+ * still not asked for again. At the limit the turn ends ACP_REASK_LIMIT on the resume, before the agent starts again: an
39
+ * agent that writes a new command after each restart (Cursor) never gets to the approved one. A call the gate answers
40
+ * without parking (a tool set to allow or to deny) is never counted. Read on the resume because a park commits the run
41
+ * parked before the gate answers. */
42
+ export const REASK_LIMIT = 3;
37
43
  /** One record per tool call the agent announced (or MCP call it made unannounced): the calls a plan-billed run counts. */
38
44
  export const TOOLS_STREAM = "acp.tools";
39
45
  /** The model chosen for the agent's session (recipe.model, as the agent lists it), one record each time one is chosen. */
@@ -262,6 +268,62 @@ export function acpHarness(options, control) {
262
268
  return;
263
269
  }
264
270
  };
271
+ /** The gate's call for a permission request of the agent's own tool: the same when the agent asks and when a resume
272
+ * asks about it again (settlePermissions), so both reach the one approval. */
273
+ const permissionGateCall = (callId, kind, title, input) => ({ callId, tool: `acp_${kind.replace(/[^A-Za-z0-9_]/g, "_")}`, args: { title, kind, input } });
274
+ /** The open turn's permission requests still waiting (asked, never answered), in order, as the records hold them. */
275
+ const waitingPermissions = (state) => {
276
+ const since = openTurn(state)?.since ?? Number.POSITIVE_INFINITY;
277
+ const records = journalRecords(state, PERMISSION_STREAM);
278
+ const answered = new Set(records.filter((r) => r.data?.type === "answered").map((r) => r.data.callId));
279
+ return records.filter((r) => r.at > since && r.data?.type === "asked" && !answered.has(r.data.callId)).map((r) => r.data);
280
+ };
281
+ /** The recovery note's line for a settled answer: the request as the agent asked it (its kind, title and input, so an
282
+ * agent started without session/load can ask for the same call) and what the person said. */
283
+ const answerLine = (asked, answer) => {
284
+ const kind = asked?.kind ?? "other";
285
+ const input = asked?.input === undefined || asked.input === null ? "" : JSON.stringify(asked.input);
286
+ const shown = input ? ` Its input: ${clip(input, 1500)}${input.length > 1500 ? " (cut here: ask with the whole input you first sent)" : ""}.` : "";
287
+ const named = `${kind} ${JSON.stringify(clip(asked?.title ?? kind, 300))}.${shown}`;
288
+ return answer.answer === "deny"
289
+ ? `- ${named} The person refused it.${answer.words ? ` Their words: ${clip(answer.words, 500).replace(/\n/g, " ")}` : ""}`
290
+ : `- ${named} The person allowed it once. Ask for it again exactly as before (the same kind, title and input) and it runs; any other request waits for the person again.`;
291
+ };
292
+ /** A resumed turn's waiting permission requests, each asked about again before the agent starts: the person's answer
293
+ * is taken whatever the agent asks next (an agent may write another command after its restart), and with none yet the
294
+ * gate parks the drive here, before any prompt is sent. The lines say every answer of the open turn the agent has not
295
+ * been given yet, those taken now and those an earlier drive took before it stopped, for the agent's recovery note.
296
+ * `limit`: the turn's other calls parked on the person REASK_LIMIT times while an allow went unasked, so the turn ends
297
+ * here, before the agent starts again. */
298
+ const settlePermissions = async (ctx, journal) => {
299
+ const gate = options.gate;
300
+ if (!gate)
301
+ return { lines: [] };
302
+ const turn = openTurn(ctx.state());
303
+ const turnId = turn?.placed[0] ?? "";
304
+ const since = turn?.since ?? Number.POSITIVE_INFINITY;
305
+ const records = journalRecords(ctx.state(), PERMISSION_STREAM).filter((r) => r.at > since).map((r) => r.data);
306
+ const askedOf = (callId) => records.find((r) => r?.type === "asked" && r.callId === callId);
307
+ const given = new Set(records.filter((r) => r?.type === "given").map((r) => r.callId));
308
+ const said = records.filter((r) => r?.type === "answered" && r.settled && r.turn === turnId && !given.has(r.callId)).map((r) => answerLine(askedOf(r.callId), r));
309
+ for (const request of waitingPermissions(ctx.state())) {
310
+ const kind = request.kind ?? "other";
311
+ const title = request.title ?? kind;
312
+ const refused = await askGate(gate, permissionGateCall(request.callId, kind, title, request.input ?? null), ctx.signal);
313
+ const answer = { type: "answered", callId: request.callId, answer: refused ? "deny" : "allow", ...(refused?.deny ? { words: refused.deny } : {}), settled: true, turn: turnId };
314
+ journal.append(PERMISSION_STREAM, answer);
315
+ await journal.flush();
316
+ said.push(answerLine(request, answer));
317
+ records.push(answer);
318
+ }
319
+ // A `reasked` call parked if a resume took its answer (settled; one the gate answered at once is not).
320
+ const settledIds = new Set(records.filter((r) => r?.type === "answered" && r.settled).map((r) => r.callId));
321
+ const parks = records.filter((r) => r?.type === "reasked" && r.turn === turnId && settledIds.has(r.callId));
322
+ if (parks.length < REASK_LIMIT)
323
+ return { lines: said };
324
+ const approved = askedOf(parks.at(-1)?.instead ?? "");
325
+ return { lines: said, limit: `${ACP_CODES.reaskLimit}: the agent asked ${parks.length} times for another command instead of the one the person allowed (${approved?.kind ?? "other"} ${JSON.stringify(clip(approved?.title ?? "", 300))}), each waiting for the person, so the turn ends here; the agent is not started again and nothing more of the plan is spent on it` };
326
+ };
265
327
  const onPermission = async (rt, request, connection) => {
266
328
  const choose = (kind) => {
267
329
  const option = request.options.find((o) => o.kind === kind);
@@ -290,18 +352,20 @@ export function acpHarness(options, control) {
290
352
  const input = call.rawInput ?? null;
291
353
  // The request's id is the open turn's: the turn, what it asks, and which of the turn's requests that ask the same it
292
354
  // is. The records hold the ids the turn's requests took (another runner's agent process asked some of them): this
293
- // process's request takes, of those it has not taken itself, the first one still waiting for its answer (the one a
294
- // swap left parked), else the first one answered (the agent asking again for what it was answered), else a new one.
355
+ // process's request takes, of those it has not taken itself and whose answer no agent was handed (`given`: an
356
+ // allow-once is used once), the first one still waiting for its answer, else the first one answered (an answer a
357
+ // resume took, the agent asking again for it), else a new one.
295
358
  const opened = openTurn(cur.ctx.state());
296
359
  const turnId = opened?.placed[0] ?? "";
297
360
  const all = cur.journal.records(PERMISSION_STREAM).map((r) => r.data);
298
361
  const askedIds = new Set(all.filter((r) => r?.type === "asked").map((r) => r.callId));
299
362
  const answeredIds = new Set(all.filter((r) => r?.type === "answered").map((r) => r.callId));
363
+ const givenIds = new Set(all.filter((r) => r?.type === "given").map((r) => r.callId));
300
364
  let callId;
301
365
  let firstAnswered;
302
366
  for (let nth = 0; callId === undefined; nth++) {
303
367
  const id = permissionCallId(turnId, { title, kind, rawInput: input }, nth);
304
- if (rt.claimed.has(id))
368
+ if (rt.claimed.has(id) || givenIds.has(id))
305
369
  continue;
306
370
  if (!askedIds.has(id))
307
371
  callId = firstAnswered ?? id;
@@ -313,23 +377,36 @@ export function acpHarness(options, control) {
313
377
  rt.claimed.add(callId);
314
378
  const records = all.filter((r) => r?.callId === callId);
315
379
  const answered = records.find((r) => r.type === "answered");
316
- if (answered)
380
+ if (answered) {
381
+ // An answer a resume took (settled) reaches the agent here: it asked again for the same call, and uses it up.
382
+ cur.journal.append(PERMISSION_STREAM, { type: "given", callId, turn: turnId });
383
+ await cur.journal.flush();
317
384
  return choose(answered.answer === "allow" ? "allow_once" : "reject_once");
385
+ }
318
386
  if (!records.some((r) => r.type === "asked")) {
387
+ // A new call while an allow the person gave on a resume is still not asked for: the agent asked for something else
388
+ // instead (Cursor writes a new command after a restart). Marked `reasked` here, before the gate (whose park
389
+ // commits the run parked before it answers): it counts toward REASK_LIMIT only if it parked, which the next resume
390
+ // reads (settlePermissions). One the gate answers at once (a tool set to allow) is the turn going on.
391
+ const unasked = all.find((r) => r?.type === "answered" && r.settled && r.turn === turnId && r.answer === "allow" && !givenIds.has(r.callId));
392
+ if (unasked)
393
+ cur.journal.append(PERMISSION_STREAM, { type: "reasked", callId, turn: turnId, instead: unasked.callId });
319
394
  cur.journal.append(PERMISSION_STREAM, { type: "asked", callId, toolCallId: call.toolCallId, title, kind, input });
320
395
  await cur.journal.flush();
321
396
  }
322
397
  let refused;
323
398
  if (options.gate) {
324
399
  try {
325
- refused = await askGate(options.gate, { callId, tool: `acp_${kind.replace(/[^A-Za-z0-9_]/g, "_")}`, args: { title, kind, input } }, AbortSignal.any([cur.signal, connection, turn.stop.signal]));
400
+ refused = await askGate(options.gate, permissionGateCall(callId, kind, title, input), AbortSignal.any([cur.signal, connection, turn.stop.signal]));
326
401
  }
327
402
  catch {
328
403
  // Parked, and the session let go (or the turn was cancelled): nothing is answered, nothing recorded.
329
404
  return cancelled;
330
405
  }
331
406
  }
407
+ // Answered and handed to the agent at once: given with it, so a later ask of the same request is a call of its own.
332
408
  cur.journal.append(PERMISSION_STREAM, { type: "answered", callId, answer: refused ? "deny" : "allow", ...(refused ? { words: refused.deny } : {}) });
409
+ cur.journal.append(PERMISSION_STREAM, { type: "given", callId, turn: turnId });
333
410
  await cur.journal.flush();
334
411
  return choose(refused ? "reject_once" : "allow_once");
335
412
  };
@@ -616,6 +693,18 @@ export function acpHarness(options, control) {
616
693
  if (!ctx.state().effects.has(toolKey(call.callId)))
617
694
  refusedLines.push(`- ${call.tool}(${clip(JSON.stringify(call.args) ?? "{}", 300)}), call ${call.callId}: refused by the host. Its answer:`, indent(clip(outcome.text, 1500)));
618
695
  });
696
+ // So is each request for a tool of the agent's own the turn left waiting: its answer is taken now, or the drive parks
697
+ // here, with no agent started and no prompt sent. Past REASK_LIMIT, the open turn ends here, saying so, with nothing
698
+ // of the inbox placed: a message sent while the run waited is a turn of its own, below, the agent started for it.
699
+ const { lines: permissionLines, limit: reaskLimit } = await settlePermissions(ctx, journal);
700
+ if (reaskLimit) {
701
+ log("acp: the agent kept asking for other calls instead of the allowed one", { limit: REASK_LIMIT });
702
+ journal.message({ type: "turn", status: "failed", error: reaskLimit });
703
+ await journal.flush();
704
+ await ctx.refresh();
705
+ if (ctx.pending().length === 0)
706
+ return;
707
+ }
619
708
  let rt = runtime;
620
709
  if (!rt || rt.ctx !== ctx || !rt.agent.alive()) {
621
710
  if (rt)
@@ -741,9 +830,13 @@ export function acpHarness(options, control) {
741
830
  try {
742
831
  // A turn a crash cut off: the kernel's note (quoting the turn's prompts, which a new agent session never saw), as a
743
832
  // user message, with the pending messages it carries.
744
- const note = recoveryNote(ctx.state(), { prompts: true });
833
+ const note = reaskLimit ? undefined : recoveryNote(ctx.state(), { prompts: true });
745
834
  if (note) {
746
- const text = refusedLines.length ? `${note.text}\n\nThe host answered these calls of yours since:\n${refusedLines.join("\n")}` : note.text;
835
+ const text = [
836
+ note.text,
837
+ ...(refusedLines.length ? [`The host answered these calls of yours since:\n${refusedLines.join("\n")}`] : []),
838
+ ...(permissionLines.length ? [`The person answered these requests of yours while the run waited:\n${permissionLines.join("\n")}`] : []),
839
+ ].join("\n\n");
747
840
  journal.message({ type: "message", role: "user", text, synthetic: "recovery" });
748
841
  await placeSubmissions(ctx, note.pending);
749
842
  await runTurn([text], `recovery:${transcriptOf(ctx.state()).length}`, [...note.turn.placed, ...note.pending.map((s) => s.id)]);
@@ -3,14 +3,15 @@
3
3
  // - It starts with the environment allowlist (child.ts), in its own process group, watched by this process
4
4
  // (parentWatched) inside the host's confinement: a SIGKILLed host leaves no agent behind.
5
5
  // - Its stderr is kept, its tail only, for a failure's words; nothing it prints reaches the log whole. The keys it was
6
- // handed are cut from the tail before it is shortened, and a key's end at the head of a cut tail goes too (key-cut.ts).
6
+ // handed are cut from the tail before it is shortened, a key's end at the head of a cut tail goes too, and so does a
7
+ // key's start at its end (one the agent is still writing, read mid-run) (key-cut.ts).
7
8
  // - kill() ends its whole group; so does an abort of `signal`.
8
9
  import { spawn } from "node:child_process";
9
10
  import { Readable, Writable } from "node:stream";
10
11
  import { client, ndJsonStream } from "@agentclientprotocol/sdk";
11
12
  import { parentWatched } from "@parcha/agentrun-kernel/host";
12
13
  import { childEnv, confined } from "./child.js";
13
- import { cutKeyEndAtHead, cutKeys, keysToCut } from "./key-cut.js";
14
+ import { cutKeys, keysToCut } from "./key-cut.js";
14
15
  const STDERR_TAIL = 8 * 1024;
15
16
  /** Start the agent and open the client connection over its stdio. */
16
17
  export function startAgent(options) {
@@ -29,10 +30,9 @@ export function startAgent(options) {
29
30
  cut = true;
30
31
  }
31
32
  };
32
- const stderrTail = () => {
33
- const text = cutKeys(raw, keys);
34
- return (cut ? cutKeyEndAtHead(text, keys) : text).slice(-STDERR_TAIL);
35
- };
33
+ // A key's start at the end goes at every read, the agent alive or not: alive, it may be a key still being written;
34
+ // ended, the most it drops is a key's length less one, and only text that spells a key's start.
35
+ const stderrTail = () => cutKeys(raw, keys, { head: cut, tail: true }).slice(-STDERR_TAIL);
36
36
  child.stderr.setEncoding("utf8");
37
37
  child.stderr.on("data", take);
38
38
  // A write to a stdin the agent closed is its exit's to report, never an unhandled error.
@@ -3,8 +3,14 @@ export declare const KEY_CUT_MIN = 8;
3
3
  export declare const KEY_CUT = "[redacted]";
4
4
  /** The values worth cutting: those at least KEY_CUT_MIN long, longest first (a key holding another is cut whole). */
5
5
  export declare const keysToCut: (values: readonly (string | undefined)[]) => string[];
6
- /** `text` with each of `keys` (keysToCut) replaced, as written. */
7
- export declare function cutKeys(text: string, keys: readonly string[]): string;
8
- /** `text`, a tail whose start was cut, without the end of a key at its head: the longest piece that ends one of `keys`
9
- * and starts the text goes (a key's end matches no key, so no cut of whole keys finds it). */
10
- export declare function cutKeyEndAtHead(text: string, keys: readonly string[]): string;
6
+ /** Which pieces at the text's edges go too, beside whole keys. `head`: a key's end at its start (a tail whose start was
7
+ * cut). `tail`: a key's start at its end (a key still being written, read mid-run). Neither matches a whole key. */
8
+ export interface KeyEdges {
9
+ readonly head?: boolean;
10
+ readonly tail?: boolean;
11
+ }
12
+ /** `text` with no piece of `keys` (keysToCut): each whole key becomes KEY_CUT, and a piece of one at an edge named in
13
+ * `edges` is dropped. Every piece is found in `text` as written before any is cut, so keys that overlap, or one that
14
+ * holds another's start or end, can't hide each other. A run of marked text that reaches into an edge piece is dropped
15
+ * whole; any other run becomes one KEY_CUT. */
16
+ export declare function cutKeys(text: string, keys: readonly string[], edges?: KeyEdges): string;
@@ -6,24 +6,42 @@ export const KEY_CUT_MIN = 8;
6
6
  export const KEY_CUT = "[redacted]";
7
7
  /** The values worth cutting: those at least KEY_CUT_MIN long, longest first (a key holding another is cut whole). */
8
8
  export const keysToCut = (values) => [...new Set(values.filter((value) => typeof value === "string" && value.length >= KEY_CUT_MIN))].sort((a, b) => b.length - a.length);
9
- /** `text` with each of `keys` (keysToCut) replaced, as written. */
10
- export function cutKeys(text, keys) {
11
- let out = text;
12
- for (const key of keys)
13
- out = out.split(key).join(KEY_CUT);
9
+ /** `text` with no piece of `keys` (keysToCut): each whole key becomes KEY_CUT, and a piece of one at an edge named in
10
+ * `edges` is dropped. Every piece is found in `text` as written before any is cut, so keys that overlap, or one that
11
+ * holds another's start or end, can't hide each other. A run of marked text that reaches into an edge piece is dropped
12
+ * whole; any other run becomes one KEY_CUT. */
13
+ export function cutKeys(text, keys, edges = {}) {
14
+ const WHOLE = 1;
15
+ const EDGE = 2;
16
+ const mark = new Uint8Array(text.length);
17
+ for (const key of keys) {
18
+ for (let at = text.indexOf(key); at !== -1; at = text.indexOf(key, at + 1))
19
+ mark.fill(WHOLE, at, at + key.length);
20
+ }
21
+ if (edges.head)
22
+ mark.fill(EDGE, 0, edgeLength(keys, text.length, (key, n) => text.startsWith(key.slice(-n))));
23
+ if (edges.tail)
24
+ mark.fill(EDGE, text.length - edgeLength(keys, text.length, (key, n) => text.endsWith(key.slice(0, n))));
25
+ let out = "";
26
+ for (let from = 0, to = 0; from < text.length; from = to) {
27
+ const marked = mark[from] !== 0;
28
+ let edge = false;
29
+ for (; to < text.length && (mark[to] !== 0) === marked; to++)
30
+ edge ||= mark[to] === EDGE;
31
+ out += !marked ? text.slice(from, to) : edge ? "" : KEY_CUT;
32
+ }
14
33
  return out;
15
34
  }
16
- /** `text`, a tail whose start was cut, without the end of a key at its head: the longest piece that ends one of `keys`
17
- * and starts the text goes (a key's end matches no key, so no cut of whole keys finds it). */
18
- export function cutKeyEndAtHead(text, keys) {
19
- let drop = 0;
35
+ /** The longest n, shorter than its key, for which `fits(key, n)` holds for one of `keys`; 0 if none does. */
36
+ function edgeLength(keys, max, fits) {
37
+ let longest = 0;
20
38
  for (const key of keys) {
21
- for (let n = Math.min(key.length - 1, text.length); n > drop; n--) {
22
- if (text.startsWith(key.slice(-n))) {
23
- drop = n;
39
+ for (let n = Math.min(key.length - 1, max); n > longest; n--) {
40
+ if (fits(key, n)) {
41
+ longest = n;
24
42
  break;
25
43
  }
26
44
  }
27
45
  }
28
- return text.slice(drop);
46
+ return longest;
29
47
  }
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { acpAdapter, type AcpAdapterOptions, type AcpProxy, type AcpProxySession } from "./adapter.js";
2
2
  export { ACP_CODES, acpFacts, type AcpFacts } from "./facts.js";
3
3
  export { homePath, MODEL_ID, recipeProblems, RESERVED_ENV, type AcpBilling, type AcpRecipe, type AcpRefusal } from "./recipe.js";
4
- export { CALL_STREAM, contextNote, MODEL_STREAM, PERMISSION_STREAM, PROMPT_STREAM, SESSION_STREAM, sentSubmissions, TOOLS_STREAM } from "./harness.js";
4
+ export { CALL_STREAM, contextNote, MODEL_STREAM, PERMISSION_STREAM, PROMPT_STREAM, REASK_LIMIT, SESSION_STREAM, sentSubmissions, TOOLS_STREAM } from "./harness.js";
5
5
  export { STATE_STREAM, type StateRecord } from "./state.js";
6
6
  export type { ConfineChild } from "./host/child.js";
7
7
  export { GOOSE_INSTALL, GOOSE_NOT_INSTALLED, gooseFacts } from "./goose-facts.js";
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  export { acpAdapter } from "./adapter.js";
3
3
  export { ACP_CODES, acpFacts } from "./facts.js";
4
4
  export { homePath, MODEL_ID, recipeProblems, RESERVED_ENV } from "./recipe.js";
5
- export { CALL_STREAM, contextNote, MODEL_STREAM, PERMISSION_STREAM, PROMPT_STREAM, SESSION_STREAM, sentSubmissions, TOOLS_STREAM } from "./harness.js";
5
+ export { CALL_STREAM, contextNote, MODEL_STREAM, PERMISSION_STREAM, PROMPT_STREAM, REASK_LIMIT, SESSION_STREAM, sentSubmissions, TOOLS_STREAM } from "./harness.js";
6
6
  export { STATE_STREAM } from "./state.js";
7
7
  export { GOOSE_INSTALL, GOOSE_NOT_INSTALLED, gooseFacts } from "./goose-facts.js";
8
8
  export { gooseAdapter, gooseRecipe, recipeFile } from "./goose.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcha/agentrun-harness-acp",
3
- "version": "0.1.0-beta.50",
3
+ "version": "0.1.0-beta.52",
4
4
  "description": "Any Agent Client Protocol agent as an AgentRun harness: the agent over stdio in a private HOME, the host's tools as one loopback MCP server, its permission asks through the host's gate, durable in AgentRun's own store.",
5
5
  "keywords": [
6
6
  "agentrun",
@@ -49,7 +49,7 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@agentclientprotocol/sdk": "2.7.0",
52
- "@parcha/agentrun-kernel": "0.1.0-beta.50",
52
+ "@parcha/agentrun-kernel": "0.1.0-beta.52",
53
53
  "zod": "4.6.6"
54
54
  },
55
55
  "publishConfig": {
@@ -33,6 +33,9 @@
33
33
  // config directory is $CURSOR_CONFIG_DIR, else $XDG_CONFIG_HOME/cursor, else $HOME/.cursor; sessions in
34
34
  // <dir>/acp-sessions, and an edit, write, delete or move refused unasked when <dir>/cli-config.json denies
35
35
  // Write(**) (Cursor reports it completed all the same).
36
+ // tally: a file the takes of a `retitled` native step are counted in: a step {native, title, retitled: [t2, t3, ...]}
37
+ // asks with its title the first time and with the next of `retitled` each time it is taken again (the last
38
+ // one repeats), its input's command that title, as Cursor writes a new command after a restart.
36
39
  // A script step {hang: true} is a model that never answers (until a cancel the agent heeds).
37
40
  // The step the model takes is the number it took before: its session's history (calls, native calls, answers), plus the
38
41
  // calls a recovery or context note names that its history does not hold, as a resumed model reads its conversation.
@@ -110,6 +113,14 @@ function writeAuth() {
110
113
  said({ type: "auth", file, keySha, saved: true });
111
114
  }
112
115
  const steps = (history) => history.filter((h) => h.kind === "call" || h.kind === "native" || h.kind === "say").length;
116
+ /** How many times script step `index` was taken before, across this agent's processes (config.tally, a file each take
117
+ * appends its index to); this take is added. */
118
+ function tally(index) {
119
+ if (!config.tally) throw new Error("fake-acp: a retitled step needs config.tally");
120
+ const before = existsSync(config.tally) ? readFileSync(config.tally, "utf8").split("\n").filter((line) => line === String(index)).length : 0;
121
+ appendFileSync(config.tally, `${index}\n`);
122
+ return before;
123
+ }
113
124
  const text = (blocks) => blocks.filter((b) => b.type === "text").map((b) => b.text);
114
125
 
115
126
  /** The calls a note names (`- name(...), call <id>:`), a nested one's (`<id>/<key>`) left out. */
@@ -281,7 +292,10 @@ async function takeTurn(client, session, prompt, signal) {
281
292
  }
282
293
  if ("native" in s) {
283
294
  const id = `native_${step - 1}`;
284
- const update = { toolCallId: id, title: s.title ?? s.native, kind: s.native, status: "pending", rawInput: s.input ?? {} };
295
+ // A model that, taking a step again (after a restart), writes another command for it (retitled).
296
+ const again = s.retitled?.length ? tally(step - 1) : 0;
297
+ const title = again > 0 ? s.retitled[Math.min(again, s.retitled.length) - 1] : (s.title ?? s.native);
298
+ const update = { toolCallId: id, title, kind: s.native, status: "pending", rawInput: again > 0 ? { ...(s.input ?? {}), command: title } : (s.input ?? {}) };
285
299
  const entry = { kind: "native", id, title: update.title, status: "pending" };
286
300
  session.history.push(entry);
287
301
  save(session);