@parcha/agentrun-harness-acp 0.1.0-beta.51 → 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 +4 -0
- package/dist/host/agent.js +6 -6
- package/dist/host/key-cut.d.ts +11 -5
- package/dist/host/key-cut.js +31 -13
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
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
|
+
|
|
5
9
|
## 0.1.0-beta.51 (2026-11-21)
|
|
6
10
|
|
|
7
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 -->
|
package/dist/host/agent.js
CHANGED
|
@@ -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,
|
|
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 {
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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.
|
package/dist/host/key-cut.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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;
|
package/dist/host/key-cut.js
CHANGED
|
@@ -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
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
/**
|
|
17
|
-
|
|
18
|
-
|
|
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,
|
|
22
|
-
if (
|
|
23
|
-
|
|
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
|
|
46
|
+
return longest;
|
|
29
47
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcha/agentrun-harness-acp",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
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.
|
|
52
|
+
"@parcha/agentrun-kernel": "0.1.0-beta.52",
|
|
53
53
|
"zod": "4.6.6"
|
|
54
54
|
},
|
|
55
55
|
"publishConfig": {
|