@parcha/agentrun-harness-acp 0.1.0-beta.53 → 0.1.0-beta.55
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 +1 -1
- package/dist/harness.js +15 -18
- package/dist/host/agent.js +7 -6
- package/dist/host/key-cut.d.ts +6 -4
- package/dist/host/key-cut.js +9 -4
- package/package.json +2 -2
- package/testing/fake-acp-agent.mjs +14 -10
package/CHANGELOG.md
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
## 0.1.0-beta.51 (2026-11-21)
|
|
27
27
|
|
|
28
|
-
-
|
|
28
|
+
- An ACP agent's own tool call (Cursor's shell) that parked on a person no longer loops once answered: the resume takes the answer before the agent starts, and the recovery note says what the person decided. Before, restarted Cursor asked for a different command, the answer was never taken, and the run restarted every few seconds until the plan's turn limit. An agent that keeps asking the person about other commands instead of the one they allowed ends its turn with `ACP_REASK_LIMIT`. <!-- changes/acp-parked-permission-settled.md -->
|
|
29
29
|
- 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 -->
|
|
30
30
|
|
|
31
31
|
## 0.1.0-beta.48 (2026-11-20)
|
package/dist/harness.js
CHANGED
|
@@ -283,13 +283,6 @@ export function acpHarness(options, control) {
|
|
|
283
283
|
/** The gate's call for a permission request of the agent's own tool: the same when the agent asks and when a resume
|
|
284
284
|
* asks about it again (settlePermissions), so both reach the one approval. */
|
|
285
285
|
const permissionGateCall = (callId, kind, title, input) => ({ callId, tool: `acp_${kind.replace(/[^A-Za-z0-9_]/g, "_")}`, args: { title, kind, input } });
|
|
286
|
-
/** The open turn's permission requests still waiting (asked, never answered), in order, as the records hold them. */
|
|
287
|
-
const waitingPermissions = (state) => {
|
|
288
|
-
const since = openTurn(state)?.since ?? Number.POSITIVE_INFINITY;
|
|
289
|
-
const records = journalRecords(state, PERMISSION_STREAM);
|
|
290
|
-
const answered = new Set(records.filter((r) => r.data?.type === "answered").map((r) => r.data.callId));
|
|
291
|
-
return records.filter((r) => r.at > since && r.data?.type === "asked" && !answered.has(r.data.callId)).map((r) => r.data);
|
|
292
|
-
};
|
|
293
286
|
/** The recovery note's line for a settled answer: the request as the agent asked it (its kind, title and input, so an
|
|
294
287
|
* agent started without session/load can ask for the same call) and what the person said. */
|
|
295
288
|
const answerLine = (asked, answer) => {
|
|
@@ -318,7 +311,9 @@ export function acpHarness(options, control) {
|
|
|
318
311
|
const askedOf = (callId) => records.find((r) => r?.type === "asked" && r.callId === callId);
|
|
319
312
|
const given = new Set(records.filter((r) => r?.type === "given").map((r) => r.callId));
|
|
320
313
|
const said = records.filter((r) => r?.type === "answered" && r.settled && r.turn === turnId && !given.has(r.callId)).map((r) => answerLine(askedOf(r.callId), r));
|
|
321
|
-
|
|
314
|
+
const answered = new Set(records.filter((r) => r?.type === "answered").map((r) => r.callId));
|
|
315
|
+
const waiting = records.filter((r) => r?.type === "asked" && !answered.has(r.callId));
|
|
316
|
+
for (const request of waiting) {
|
|
322
317
|
const kind = request.kind ?? "other";
|
|
323
318
|
const title = request.title ?? kind;
|
|
324
319
|
const refused = await askGate(gate, permissionGateCall(request.callId, kind, title, request.input ?? null), ctx.signal);
|
|
@@ -363,14 +358,12 @@ export function acpHarness(options, control) {
|
|
|
363
358
|
const title = typeof call.title === "string" ? call.title : kind;
|
|
364
359
|
const input = call.rawInput ?? null;
|
|
365
360
|
// 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
|
|
366
|
-
// is.
|
|
367
|
-
//
|
|
368
|
-
//
|
|
369
|
-
// resume took, the agent asking again for it), else a new one.
|
|
361
|
+
// is. Of the ids this process has not taken and no agent was handed an answer for (`given`: an allow-once is used
|
|
362
|
+
// once), it takes the first one answered (a resume took the answer; the agent asks again for it), else the first
|
|
363
|
+
// unanswered one. With a gate no id is left waiting by now: settlePermissions answered them before the agent started.
|
|
370
364
|
const opened = openTurn(cur.ctx.state());
|
|
371
365
|
const turnId = opened?.placed[0] ?? "";
|
|
372
366
|
const all = cur.journal.records(PERMISSION_STREAM).map((r) => r.data);
|
|
373
|
-
const askedIds = new Set(all.filter((r) => r?.type === "asked").map((r) => r.callId));
|
|
374
367
|
const answeredIds = new Set(all.filter((r) => r?.type === "answered").map((r) => r.callId));
|
|
375
368
|
const givenIds = new Set(all.filter((r) => r?.type === "given").map((r) => r.callId));
|
|
376
369
|
let callId;
|
|
@@ -379,12 +372,10 @@ export function acpHarness(options, control) {
|
|
|
379
372
|
const id = permissionCallId(turnId, { title, kind, rawInput: input }, nth);
|
|
380
373
|
if (rt.claimed.has(id) || givenIds.has(id))
|
|
381
374
|
continue;
|
|
382
|
-
if (
|
|
383
|
-
callId = firstAnswered ?? id;
|
|
384
|
-
else if (!answeredIds.has(id))
|
|
385
|
-
callId = id;
|
|
386
|
-
else
|
|
375
|
+
if (answeredIds.has(id))
|
|
387
376
|
firstAnswered ??= id;
|
|
377
|
+
else
|
|
378
|
+
callId = firstAnswered ?? id;
|
|
388
379
|
}
|
|
389
380
|
rt.claimed.add(callId);
|
|
390
381
|
const records = all.filter((r) => r?.callId === callId);
|
|
@@ -406,6 +397,12 @@ export function acpHarness(options, control) {
|
|
|
406
397
|
cur.journal.append(PERMISSION_STREAM, { type: "asked", callId, toolCallId: call.toolCallId, title, kind, input });
|
|
407
398
|
await cur.journal.flush();
|
|
408
399
|
}
|
|
400
|
+
else if (options.gate) {
|
|
401
|
+
// Asked before and still unanswered, with a gate: settlePermissions answers every request a turn left waiting before
|
|
402
|
+
// the agent starts, so this should not be. Where it is, a start skipped that step and the pick above (an answered id
|
|
403
|
+
// before an unanswered one) may not be the call the person meant. Said, so a host's log shows it.
|
|
404
|
+
log("acp: a request matched one still waiting for the person, which the resume should have answered before the agent started", { callId, toolCallId: call.toolCallId });
|
|
405
|
+
}
|
|
409
406
|
let refused;
|
|
410
407
|
if (options.gate) {
|
|
411
408
|
try {
|
package/dist/host/agent.js
CHANGED
|
@@ -3,10 +3,9 @@
|
|
|
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,
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
// its exit status alone.
|
|
6
|
+
// handed are cut from the tail before it is shortened, with any piece of one at either edge (key-cut.ts). With
|
|
7
|
+
// `stderr: "none"` (an agent run on a person's sign-in, whose token no key cut knows) nothing of it is kept or read:
|
|
8
|
+
// its end is said by its exit status alone.
|
|
10
9
|
// - kill() ends its whole group; so does an abort of `signal`.
|
|
11
10
|
import { spawn } from "node:child_process";
|
|
12
11
|
import { Readable, Writable } from "node:stream";
|
|
@@ -21,9 +20,11 @@ export function startAgent(options) {
|
|
|
21
20
|
const quiet = options.stderr === "none";
|
|
22
21
|
const errTo = quiet ? "ignore" : "pipe";
|
|
23
22
|
const child = spawn(run.command, run.args, { cwd: options.cwd, env: childEnv(options.from ?? process.env, options.env), detached: true, stdio: ["pipe", "pipe", errTo] });
|
|
24
|
-
// What it printed, raw,
|
|
25
|
-
//
|
|
23
|
+
// What it printed, raw, its last `keep` characters: a key split across chunks is whole here and cut whole, and a piece
|
|
24
|
+
// of one the trim left at the head goes with the head edge (stderrTail). `cut`: whether its start was dropped.
|
|
26
25
|
const keys = keysToCut(options.keys ?? []);
|
|
26
|
+
// The longest key's length kept beyond the tail: a key longer than the tail, cut short by the agent's end, is still its
|
|
27
|
+
// start here, which the tail edge drops; trimmed to the tail alone, it would leave a piece from inside it.
|
|
27
28
|
const keep = STDERR_TAIL + (keys[0]?.length ?? 0);
|
|
28
29
|
let raw = "";
|
|
29
30
|
let cut = false;
|
package/dist/host/key-cut.d.ts
CHANGED
|
@@ -9,8 +9,10 @@ export interface KeyEdges {
|
|
|
9
9
|
readonly head?: boolean;
|
|
10
10
|
readonly tail?: boolean;
|
|
11
11
|
}
|
|
12
|
-
/** `text` with
|
|
13
|
-
* `edges`
|
|
14
|
-
*
|
|
15
|
-
*
|
|
12
|
+
/** `text` with each whole key of `keys` (keysToCut), as written, made KEY_CUT, and a piece of one at an edge named in
|
|
13
|
+
* `edges` dropped. A piece inside the text stays, as does a key spelled another way (a host's redactor cuts the
|
|
14
|
+
* spellings it knows, whole).
|
|
15
|
+
* Every key is found in `text` as written before any is cut, so keys that overlap, or one that holds another's start
|
|
16
|
+
* or end, can't hide each other. A run of marked text that reaches into an edge piece is dropped whole; any other run
|
|
17
|
+
* becomes one KEY_CUT. */
|
|
16
18
|
export declare function cutKeys(text: string, keys: readonly string[], edges?: KeyEdges): string;
|
package/dist/host/key-cut.js
CHANGED
|
@@ -6,15 +6,20 @@ 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
|
-
* `edges`
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
/** `text` with each whole key of `keys` (keysToCut), as written, made KEY_CUT, and a piece of one at an edge named in
|
|
10
|
+
* `edges` dropped. A piece inside the text stays, as does a key spelled another way (a host's redactor cuts the
|
|
11
|
+
* spellings it knows, whole).
|
|
12
|
+
* Every key is found in `text` as written before any is cut, so keys that overlap, or one that holds another's start
|
|
13
|
+
* or end, can't hide each other. A run of marked text that reaches into an edge piece is dropped whole; any other run
|
|
14
|
+
* becomes one KEY_CUT. */
|
|
13
15
|
export function cutKeys(text, keys, edges = {}) {
|
|
14
16
|
const WHOLE = 1;
|
|
15
17
|
const EDGE = 2;
|
|
16
18
|
const mark = new Uint8Array(text.length);
|
|
17
19
|
for (const key of keys) {
|
|
20
|
+
// An empty key is no key, and "".indexOf past the end returns the end, never -1.
|
|
21
|
+
if (!key)
|
|
22
|
+
continue;
|
|
18
23
|
for (let at = text.indexOf(key); at !== -1; at = text.indexOf(key, at + 1))
|
|
19
24
|
mark.fill(WHOLE, at, at + key.length);
|
|
20
25
|
}
|
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.55",
|
|
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.55",
|
|
53
53
|
"zod": "4.6.6"
|
|
54
54
|
},
|
|
55
55
|
"publishConfig": {
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
// "answer" in the words of the error it answers, alive.
|
|
45
45
|
// grow: {bytes}: at each save of a session, append `bytes` random bytes to <sessions>/store.db-wal and rewrite a
|
|
46
46
|
// store.db-shm beside it: a store that grows each turn, as Cursor's SQLite WAL does.
|
|
47
|
+
// holdInit: a file; while it exists, initialize is not answered, so the host can send this process nothing.
|
|
47
48
|
// A script step {hang: true} is a model that never answers (until a cancel the agent heeds).
|
|
48
49
|
// The step the model takes is the number it took before: its session's history (calls, native calls, answers), plus the
|
|
49
50
|
// calls a recovery or context note names that its history does not hold, as a resumed model reads its conversation.
|
|
@@ -375,16 +376,19 @@ const signInWith = (methodId) => {
|
|
|
375
376
|
};
|
|
376
377
|
|
|
377
378
|
const app = agent({ name: "fake-acp" })
|
|
378
|
-
.onRequest("initialize", () =>
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
379
|
+
.onRequest("initialize", async () => {
|
|
380
|
+
while (config.holdInit && existsSync(config.holdInit)) await new Promise((resolve) => setTimeout(resolve, 20));
|
|
381
|
+
return {
|
|
382
|
+
protocolVersion: 1,
|
|
383
|
+
agentCapabilities: {
|
|
384
|
+
loadSession: config.advertiseLoad ?? loads,
|
|
385
|
+
mcpCapabilities: { http: config.advertiseHttp ?? config.http ?? true, sse: false },
|
|
386
|
+
...(config.systemPrompt ? { sessionCapabilities: { systemPrompt: {} } } : {}),
|
|
387
|
+
},
|
|
388
|
+
agentInfo: { name: "fake-acp", version: "1.0.0" },
|
|
389
|
+
authMethods: (config.auth?.methods ?? []).map((id) => ({ id, name: id })),
|
|
390
|
+
};
|
|
391
|
+
})
|
|
388
392
|
.onRequest("authenticate", ({ params }) => {
|
|
389
393
|
const text = signInWith(params.methodId);
|
|
390
394
|
if (text === undefined) throw RequestError.authRequired({ methodId: params.methodId });
|