@parcha/agentrun-harness-acp 0.1.0-beta.60 → 0.1.0-beta.62

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,18 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## 0.1.0-beta.62 (2026-11-26)
6
+
7
+ - A late MCP call of a call that ended first (a cancel can report a call failed while its MCP call is on its way) takes its own announcement again before a live one that names no tool or reports no input, such as the agent's own think, whether that one was announced before the MCP call or while it held. Before, it could take that one's id: on a recipe with no announces field the think's, and on any recipe one announced during the hold. <!-- changes/acp-ended-own-first.md -->
8
+ - Under Antigravity, an MCP call that reaches AgentRun up to half a second before agy's announcement of it no longer takes another call's id. This happens when the call's arguments match another call's except for the `toolSummary` that the other call sent. Such a call now holds for half a second (`ANNOUNCE_GRACE_MS`) before it takes an announcement it matches only without `toolSummary`. So a call of a tool that declares `toolSummary`, where the model left it out and agy added its own, now starts at least half a second after it reaches AgentRun. An announcement that arrives while a call waits is handed to that call only when its arguments match exactly. An announcement whose call ended before its MCP call came is passed over for any live one, so a retry with the same arguments takes its own id, under Antigravity or any other ACP agent. A late MCP call of its own still takes it after half a second, when no other call's announcement matches it. <!-- changes/agy-call-id-early.md -->
9
+ - Under Antigravity, a tool of AgentRun's named 44 to 51 characters no longer refuses the start. The start's own name for AgentRun's MCP server is now `ar` and 6 random hex digits, as long as `agentrun`, so a tool's own name may again be up to 51 characters under agy's 64-character cap. A longer tool is left out of the tools agy is given at that start. The run gets a notice naming it and goes on with the rest. The fake ACP agent (`./testing`) gains a `{ sayTools }` step that answers with the names its MCP server lists. <!-- changes/agy-long-tool-names.md -->
10
+
11
+ ## 0.1.0-beta.61 (2026-11-26)
12
+
13
+ - Google Antigravity's recipe ships with the ACP adapter, and every command takes its name where it takes a recipe file: `agentrun harness install antigravity`, `agentrun harness-check --recipe antigravity`, `agentrun harness sign-in --recipe antigravity` and `agentrun-serve --harness-recipe antigravity` (or `AGENTRUN_SERVE_HARNESS_RECIPES=antigravity`). It is still a recipe, with the same pins, check, keys page and sign-in. Each command says which recipe it resolved. A file of that name in the directory is never passed over: the command is refused, saying both, and `./antigravity` names the file. The hints a recipe prints (install, check, sign-in) name a shipped recipe by its name, not by where the package is installed. The recipe file moved from `examples/harness-recipe/antigravity.json` to the package's `recipes/bundled/antigravity.json`. An AgentRun release that changes it asks for a new check and the keys to be saved again, as an edit of your own recipe file would. <!-- changes/antigravity-bundled.md -->
14
+
15
+ agy joins server and tool with a single `_`, so another MCP server's tool could spell one of AgentRun's (a server `agentrun_look` with a tool `up` reads as `mcp_agentrun_look_up`), be taken as AgentRun's by the recipe's `announces.prefix`, and have its permission request allowed once on the title tie without the host's gate. Under a recipe whose `announces.prefix` joins `agentrun` to the tool's name with one `_` or `-`, as the Antigravity recipe's `mcp_agentrun_` does, the agent is now given AgentRun's MCP server under a name of each start's own, `agentrun` and 8 random hex digits, and the prefix and the title tie read that name alone: any other server's call goes to the host's gate. Goose's and Cursor's recipes keep `agentrun`. agy caps a tool's name at 64 characters, so under that name a tool of AgentRun's may be named at most 43: a longer one refuses the start, naming it. An agent that announces a call with a field the tool's schema declares but the model left out has that announcement matched to its MCP call with the field or without it, so two such calls in flight keep their own ids. An `announces.extras` field that a tool's own input schema declares (a `toolSummary` argument of the tool's, at its top, in `allOf`, `anyOf` or `oneOf`, or behind a local `$ref`) is kept as that call's argument, never left out as agy's. Two calls in flight whose arguments differ only in that field, one sending it and one leaving it out, keep their own ids whichever reaches MCP first: a call matching more than one announcement only without the field waits while another call may still need one of them.
16
+
5
17
  ## 0.1.0-beta.60 (2026-11-26)
6
18
 
7
19
  - An ACP agent's answer is the text it writes after its last call ended, not that text joined to what it wrote while the call was in flight. Cursor 2026.11.13 writes a line such as "Running it now…" after announcing its own shell call and before it ends, and the answer read "…approved.6765". What it writes before a call ends is the answer only when nothing follows. The fake agent's native step takes `narrate`, text written in that window. <!-- changes/acp-final-after-call-end.md -->
@@ -0,0 +1,4 @@
1
+ /** The recipes this package ships, by name: each one its recipe's id, and none a built-in harness's. */
2
+ export declare const BUNDLED_RECIPES: readonly string[];
3
+ /** The file of the recipe this package ships as `name`, absolute; undefined for any other name. */
4
+ export declare function bundledRecipePath(name: string): string | undefined;
@@ -0,0 +1,11 @@
1
+ // The harness recipes this package ships whole (recipes/bundled): each one a recipe file as AgentRun's server loads it
2
+ // (HARNESS.md#a-recipe, serve's harness-recipe.ts), its five rules, its pins and its check its own, named by its id.
3
+ // Google Antigravity's is the one (agy CLI 1.5.14, checked with harness-check). Not a harness module: no code here is
4
+ // any one agent's. Written for AgentRun.
5
+ import { fileURLToPath } from "node:url";
6
+ /** The recipes this package ships, by name: each one its recipe's id, and none a built-in harness's. */
7
+ export const BUNDLED_RECIPES = Object.freeze(["antigravity"]);
8
+ /** The file of the recipe this package ships as `name`, absolute; undefined for any other name. */
9
+ export function bundledRecipePath(name) {
10
+ return BUNDLED_RECIPES.includes(name) ? fileURLToPath(new URL(`../recipes/bundled/${name}.json`, import.meta.url)) : undefined;
11
+ }
package/dist/calls.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /** The MCP server's name, as the agent is given it. */
1
+ /** The MCP server's name, as the agent is given it (under agy's recipe, the start of it: mcpServerName). */
2
2
  export declare const MCP_SERVER = "agentrun";
3
3
  /** JSON text of `value` with every object's keys sorted: two argument objects that say the same are the same text. */
4
4
  export declare function canonical(value: unknown): string;
@@ -10,24 +10,53 @@ export declare const NATIVE_EFFECT_KINDS: ReadonlySet<string>;
10
10
  * (`mcp_agentrun_<tool>`, titled `Run mcp_agentrun_<tool>`, the whole text), when it is one of `tools` and its kind is
11
11
  * not one with effects of its own. Read for the title tie alone (quirks.permissionTie: Cursor's and agy's), and only
12
12
  * beside the call's announcement: the title is the agent's text, so a request is tied only when it is for a call the
13
- * recipe's announces field named as the same tool (CallIds.announced). Nothing else reads a title. */
13
+ * recipe's announces field named as the same tool (CallIds.announced). Nothing else reads a title. `server` is the name
14
+ * our MCP server was given to the agent under at this start (mcpServerName): agy's name and title carry it. */
14
15
  export declare function ourTool(update: {
15
16
  title?: string | null;
16
17
  name?: string | null;
17
18
  kind?: string | null;
18
- }, tools: ReadonlySet<string>): string | undefined;
19
+ }, tools: ReadonlySet<string>, server?: string): string | undefined;
20
+ /** Whether a recipe's announces names our server by a prefix that joins it to a tool's name with one `_` or `-` (agy's
21
+ * `mcp_agentrun_`): a join another server's own name may hold, so a server `agentrun_look` with a tool `up`
22
+ * (`mcp_agentrun_look_up`) would spell our `look_up`. Not Goose's default `agentrun__`, nor a recipe that reads the
23
+ * server from a field of its own (Cursor's). */
24
+ export declare function joinsByOne(announces: AcpAnnounces | undefined): boolean;
25
+ /** The name our MCP server is given to the agent under at one start: under a recipe whose prefix joins by one character
26
+ * (joinsByOne), `ar` and 6 random hex digits, no `_` or `-`, which no server set up before the start can spell; under
27
+ * any other, `agentrun`. As long as `agentrun`, no longer: each of our tools is named with it, under the agent's cap
28
+ * (TOOL_NAME_CAP), so a tool fits as it would under `agentrun`. */
29
+ export declare function mcpServerName(announces: AcpAnnounces | undefined): string;
30
+ /** The most characters a tool's name may hold where the agent names it (agy's, as the model APIs' tool names: 64). */
31
+ export declare const TOOL_NAME_CAP = 64;
32
+ /** Of `tools`, those whose name as the agent names them at this start (`announces` as announcesAt reads them: its prefix
33
+ * and the tool's name) is longer than TOOL_NAME_CAP. Only a prefix is counted; a recipe that reads the tool's name
34
+ * from a field of its own with the server beside it (Cursor's) names none. */
35
+ export declare function namesTooLong(announces: AcpAnnounces | undefined, tools: Iterable<string>): string[];
36
+ /** The run's notice for the tools `label` (an agent naming ours `<prefix><tool>`) is not given at a start: those
37
+ * namesTooLong names, which it could never call. */
38
+ export declare function toolsLeftOut(label: string, prefix: string, tools: readonly string[]): string;
39
+ /** The recipe's `announces` as one start reads them, our MCP server given to the agent as `server` (mcpServerName): its
40
+ * prefix names that server (`mcp_agentrun_` reads `mcp_<server>_`). ANNOUNCES_PREFIX ends a prefix at our server's
41
+ * name, so the last `agentrun` in it is that name. */
42
+ export declare function announcesAt(announces: AcpAnnounces | undefined, server: string): AcpAnnounces | undefined;
43
+ /** Whether an input schema may name an argument `name`: in its `properties`, or in those of a schema it composes (allOf,
44
+ * anyOf, oneOf, at any depth), or behind a `$ref` to its own `$defs` or `definitions`. A `$ref` it cannot read (another
45
+ * document's, or a def it lacks) may, so it counts; a `$ref` that comes back to itself adds nothing. */
46
+ export declare function declaresProperty(schema: unknown, name: string): boolean;
19
47
  /** Where in an agent's tool_call (or the update that names it later) a recipe finds which tool it calls, each a dotted
20
48
  * path of field names into the update (`_meta.goose.toolCall.toolName`, `rawInput.toolName`, `name`).
21
49
  * - `tool`: the tool's name. With `server`, our tool's own name; without, the name as the model calls it, our server's
22
50
  * prefix and the tool's (`prefix`, stripped).
23
51
  * - `server`: the MCP server's name, which must be ours (`agentrun`).
24
52
  * - `prefix`: without `server`, what comes before our tool's name in `tool` (default `agentrun__`; agy's
25
- * `mcp_agentrun_`). It names our server (ANNOUNCES_PREFIX), so a name without it is never ours.
53
+ * `mcp_agentrun_`). It names our server (ANNOUNCES_PREFIX), so a name without it is never ours. One that joins our
54
+ * server's name to the tool's with one `_` or `-` gives the server a name of each start's own (mcpServerName), which
55
+ * the prefix then reads (announcesAt).
26
56
  * - `args`: the call's arguments (default `rawInput`).
27
57
  * - `extras`: fields the agent writes beside the call's arguments that the MCP call never carries (agy's
28
- * `toolSummary`, its model's line about the call), left out before the arguments are matched when they hold text. A tool of ours with a
29
- * text argument of that name loses it too: its call never matches its arguments, waits CALL_ID_WAIT_MS and takes the
30
- * oldest call of its tool, so two in flight can swap ids (custody only: a call's permission never reads extras). */
58
+ * `toolSummary`, its model's line about the call), left out before the arguments are matched when they hold text,
59
+ * except one the tool's own input schema declares (declaresProperty), which is then the call's own argument. */
31
60
  export interface AcpAnnounces {
32
61
  readonly tool: string;
33
62
  readonly server?: string;
@@ -64,22 +93,29 @@ export interface AcpCallUpdate {
64
93
  * (a shell named as our tool never takes an MCP call's id); one the recipe's field names as another tool is the agent's
65
94
  * own; one it names as ours is kept as that tool; one it names nothing for is matched by its arguments alone, except
66
95
  * one with no arguments on a recipe whose field names calls, which waits for the update that names it. On a recipe
67
- * without the field, one reporting no input at all is kept as a call that names nothing (CallIds.add). */
68
- export declare function announceCall(calls: CallIds, update: AcpCallUpdate, announces: AcpAnnounces | undefined, tools: ReadonlySet<string>): void;
96
+ * without the field, one reporting no input at all is kept as a call that names nothing (CallIds.add). `declared`: for
97
+ * each tool, the recipe's extras its input schema declares (declaresProperty), matched with and without (addAnnounced). */
98
+ export declare function announceCall(calls: CallIds, update: AcpCallUpdate, announces: AcpAnnounces | undefined, tools: ReadonlySet<string>, declared?: ReadonlyMap<string, ReadonlySet<string>>): void;
69
99
  /** A tool_call_update naming a call its tool_call left unnamed with no input (Cursor's MCP calls: a tool_call titled
70
100
  * "MCP: tool" with rawInput {}, then this update with rawInput {providerIdentifier, toolName, args}): kept as that
71
101
  * tool, under the id its tool_call already counted, by the recipe's field. Only a call announceCall held for its name
72
102
  * (CallIds.held): one whose tool_call reported input, or named a tool, is never named later, so a native read whose
73
103
  * update echoes the model's arguments stays the agent's own. The tool_call's kind was checked before it was held;
74
104
  * the update's is checked here: a shell renamed by a later update is never ours. */
75
- export declare function nameCall(calls: CallIds, update: AcpCallUpdate, announces: AcpAnnounces | undefined, tools: ReadonlySet<string>): void;
105
+ export declare function nameCall(calls: CallIds, update: AcpCallUpdate, announces: AcpAnnounces | undefined, tools: ReadonlySet<string>, declared?: ReadonlyMap<string, ReadonlySet<string>>): void;
106
+ /** How long an MCP call that matches an announcement only without an extra (addAnnounced) holds for its own (take): an
107
+ * MCP call can reach MCP a little before the agent's announcement of it, and in that while the other's may be the only
108
+ * one there. */
109
+ export declare const ANNOUNCE_GRACE_MS = 500;
76
110
  /** The agent's announced calls, matched to the MCP calls of our tools that reach the server. */
77
111
  export declare class CallIds {
112
+ private readonly grace;
78
113
  private readonly seen;
79
114
  private readonly waiting;
80
115
  private readonly used;
81
116
  private readonly tools;
82
- /** The key each announcement still waiting for its MCP call is kept under. */
117
+ /** The keys each announcement still waiting for its MCP call is kept under: one, or two where its arguments may be
118
+ * read with or without an extra (add's `also`). */
83
119
  private readonly keyOf;
84
120
  /** The calls announced naming no tool and reporting no input, held for the update that names them (hold). */
85
121
  private readonly unnamed;
@@ -95,11 +131,23 @@ export declare class CallIds {
95
131
  * never keeps one elsewhere) is the last an MCP call takes, of any tool, when nothing else matches it: nothing names
96
132
  * it and nothing ties it, and its MCP call would otherwise run under an id of the adapter's, counted a second time
97
133
  * against a plan's limit and memoized under a key a resume never asks again. Until its call ends (settle). A tool
98
- * named for an id already announced without one (a call the agent named in a later update) keys it again. */
99
- add(id: string, tool: string | undefined, input: unknown): void;
134
+ * named for an id already announced without one (a call the agent named in a later update) keys it again. `also`:
135
+ * the same call's arguments read another way (addAnnounced: without an extra its tool's schema declares), under
136
+ * which it is kept too; the first MCP call either matches takes it, and it is gone from both. A call already waiting
137
+ * is handed it only where it is the call's own first key, its tool and its whole arguments. One that matches it only
138
+ * without the extra may be another call's, whose own announcement is on its way, and one naming no tool or reporting
139
+ * no input may come second to the call's own ended one, so for those the call tries again as take says (wake). */
140
+ add(id: string, tool: string | undefined, input: unknown, also?: unknown): void;
141
+ /** `id` out of every list it is kept in (keyOf), waiting for its MCP call no more. */
142
+ private unlist;
100
143
  /** The agent's call `id` ended (completed or failed) with no MCP call having taken it: an announcement that names
101
- * nothing and reports nothing is dropped, so a call of the agent's own never takes a later MCP call's id. */
144
+ * nothing and reports nothing is dropped, so a call of the agent's own never takes a later MCP call's id. Any other
145
+ * is `ended`: a live announcement comes before it in every match (take), so a retry with the same arguments takes its
146
+ * own id, and it holds no later MCP call; but it stays for a late MCP call of its own (a cancel can report a call
147
+ * failed while its MCP call is on its way), which takes it after the hold when no live one matches. */
102
148
  settle(id: string): void;
149
+ /** The announcements whose call ended with no MCP call (settle), still listed. */
150
+ private readonly ended;
103
151
  /** Whether the agent announced `id` (matched or not). */
104
152
  has(id: string): boolean;
105
153
  /** The tool of ours the agent's tool_call `id` was announced as, or undefined when no tool_call named one. */
@@ -108,8 +156,19 @@ export declare class CallIds {
108
156
  * came by then. Of the announcements with the same arguments, the oldest named `tool` first, then the oldest named
109
157
  * none; then the oldest of `tool` that reported no input. Then, already there or once the wait is over, never woken
110
158
  * by one coming in during it (which may be the agent's own while this call's own announcement is on its way), the
111
- * oldest that named nothing and reported nothing. */
159
+ * oldest that named nothing and reported nothing. Where the arguments match announcements only read without an extra
160
+ * (addAnnounced), the call holds for `grace` first, and then while one of them may yet be another call's whole
161
+ * arguments. */
112
162
  take(tool: string, args: Record<string, unknown>, signal: AbortSignal, ms: number): Promise<string | undefined>;
163
+ /** How long an MCP call holds before it takes an announcement it matches only without an extra (take). */
164
+ constructor(grace?: number);
165
+ /** The MCP calls waiting (take): how many under each key, and each one's retry. */
166
+ private readonly pending;
167
+ private readonly retries;
168
+ private waking;
169
+ /** Each waiting call tries again, once the current one is through: an announcement was taken, listed or dropped, or
170
+ * another call waits. */
171
+ private wake;
113
172
  }
114
173
  /** The gate's id for a permission request of the agent's own tool: the same for the same request after a resume. */
115
174
  export declare function permissionCallId(turn: string, request: {
package/dist/calls.js CHANGED
@@ -11,8 +11,8 @@
11
11
  // what a second request for the same call after a resume says the same: the open turn, the tool's title, kind and input,
12
12
  // and how many such requests came before it in the drive. Never from the agent's tool call id, which a new agent
13
13
  // session (no load) mints afresh.
14
- import { createHash } from "node:crypto";
15
- /** The MCP server's name, as the agent is given it. */
14
+ import { createHash, randomBytes } from "node:crypto";
15
+ /** The MCP server's name, as the agent is given it (under agy's recipe, the start of it: mcpServerName). */
16
16
  export const MCP_SERVER = "agentrun";
17
17
  const isPlain = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
18
18
  /** JSON text of `value` with every object's keys sorted: two argument objects that say the same are the same text. */
@@ -31,29 +31,96 @@ export const NATIVE_EFFECT_KINDS = new Set(["execute", "edit", "delete", "move",
31
31
  * (`mcp_agentrun_<tool>`, titled `Run mcp_agentrun_<tool>`, the whole text), when it is one of `tools` and its kind is
32
32
  * not one with effects of its own. Read for the title tie alone (quirks.permissionTie: Cursor's and agy's), and only
33
33
  * beside the call's announcement: the title is the agent's text, so a request is tied only when it is for a call the
34
- * recipe's announces field named as the same tool (CallIds.announced). Nothing else reads a title. */
35
- export function ourTool(update, tools) {
34
+ * recipe's announces field named as the same tool (CallIds.announced). Nothing else reads a title. `server` is the name
35
+ * our MCP server was given to the agent under at this start (mcpServerName): agy's name and title carry it. */
36
+ export function ourTool(update, tools, server = MCP_SERVER) {
36
37
  if (typeof update.kind === "string" && NATIVE_EFFECT_KINDS.has(update.kind))
37
38
  return undefined;
38
39
  const candidates = [];
39
40
  for (const said of [update.name, update.title]) {
40
41
  if (typeof said !== "string")
41
42
  continue;
42
- const named = new RegExp(`^${MCP_SERVER}__(.+)$`).exec(said);
43
+ const named = new RegExp(`^${server}__(.+)$`).exec(said);
43
44
  if (named)
44
45
  candidates.push(named[1]);
45
- const cursor = new RegExp(`^${MCP_SERVER}-[^:]*: (.+)$`).exec(said);
46
+ const cursor = new RegExp(`^${server}-[^:]*: (.+)$`).exec(said);
46
47
  if (cursor)
47
48
  candidates.push(cursor[1].trim());
48
- const agy = AGY_NAME.exec(said);
49
+ // agy's (Antigravity's): `mcp_<server>_<tool>`, titled `Run mcp_<server>_<tool>`, the whole text (agy 1.5.14 writes
50
+ // no summary after either).
51
+ const agy = new RegExp(`^(?:Run )?mcp_${server}_(.+)$`).exec(said);
49
52
  if (agy)
50
53
  candidates.push(agy[1]);
51
54
  }
52
55
  return candidates.find((name) => tools.has(name));
53
56
  }
54
- /** agy's (Antigravity's) name or title for a call of our MCP server's tool `<tool>`: `mcp_agentrun_<tool>`, titled
55
- * `Run mcp_agentrun_<tool>`, the whole text (agy 1.5.14 writes no summary after either). */
56
- const AGY_NAME = new RegExp(`^(?:Run )?mcp_${MCP_SERVER}_(.+)$`);
57
+ /** Whether a recipe's announces names our server by a prefix that joins it to a tool's name with one `_` or `-` (agy's
58
+ * `mcp_agentrun_`): a join another server's own name may hold, so a server `agentrun_look` with a tool `up`
59
+ * (`mcp_agentrun_look_up`) would spell our `look_up`. Not Goose's default `agentrun__`, nor a recipe that reads the
60
+ * server from a field of its own (Cursor's). */
61
+ export function joinsByOne(announces) {
62
+ return announces !== undefined && announces.server === undefined && announces.prefix !== undefined && new RegExp(`${MCP_SERVER}[_-]$`).test(announces.prefix);
63
+ }
64
+ /** The name our MCP server is given to the agent under at one start: under a recipe whose prefix joins by one character
65
+ * (joinsByOne), `ar` and 6 random hex digits, no `_` or `-`, which no server set up before the start can spell; under
66
+ * any other, `agentrun`. As long as `agentrun`, no longer: each of our tools is named with it, under the agent's cap
67
+ * (TOOL_NAME_CAP), so a tool fits as it would under `agentrun`. */
68
+ export function mcpServerName(announces) {
69
+ return joinsByOne(announces) ? `ar${randomBytes(3).toString("hex")}` : MCP_SERVER;
70
+ }
71
+ /** The most characters a tool's name may hold where the agent names it (agy's, as the model APIs' tool names: 64). */
72
+ export const TOOL_NAME_CAP = 64;
73
+ /** Of `tools`, those whose name as the agent names them at this start (`announces` as announcesAt reads them: its prefix
74
+ * and the tool's name) is longer than TOOL_NAME_CAP. Only a prefix is counted; a recipe that reads the tool's name
75
+ * from a field of its own with the server beside it (Cursor's) names none. */
76
+ export function namesTooLong(announces, tools) {
77
+ if (announces?.prefix === undefined || announces.server !== undefined)
78
+ return [];
79
+ const prefix = announces.prefix;
80
+ return [...tools].filter((tool) => prefix.length + tool.length > TOOL_NAME_CAP);
81
+ }
82
+ /** The run's notice for the tools `label` (an agent naming ours `<prefix><tool>`) is not given at a start: those
83
+ * namesTooLong names, which it could never call. */
84
+ export function toolsLeftOut(label, prefix, tools) {
85
+ const one = tools.length === 1;
86
+ return `${label} names each of our tools ${prefix}<tool>, at most ${TOOL_NAME_CAP} characters in all, so a tool's own name may be at most ${TOOL_NAME_CAP - prefix.length}; ${tools.map((tool) => JSON.stringify(tool)).join(", ")} ${one ? "is" : "are"} longer, so ${one ? "it is" : "they are"} left out of the tools it is given at this start`;
87
+ }
88
+ /** The recipe's `announces` as one start reads them, our MCP server given to the agent as `server` (mcpServerName): its
89
+ * prefix names that server (`mcp_agentrun_` reads `mcp_<server>_`). ANNOUNCES_PREFIX ends a prefix at our server's
90
+ * name, so the last `agentrun` in it is that name. */
91
+ export function announcesAt(announces, server) {
92
+ if (!announces || announces.prefix === undefined || server === MCP_SERVER)
93
+ return announces;
94
+ const at = announces.prefix.lastIndexOf(MCP_SERVER);
95
+ return at < 0 ? announces : { ...announces, prefix: `${announces.prefix.slice(0, at)}${server}${announces.prefix.slice(at + MCP_SERVER.length)}` };
96
+ }
97
+ /** Whether an input schema may name an argument `name`: in its `properties`, or in those of a schema it composes (allOf,
98
+ * anyOf, oneOf, at any depth), or behind a `$ref` to its own `$defs` or `definitions`. A `$ref` it cannot read (another
99
+ * document's, or a def it lacks) may, so it counts; a `$ref` that comes back to itself adds nothing. */
100
+ export function declaresProperty(schema, name) {
101
+ if (!isPlain(schema))
102
+ return false;
103
+ const root = schema;
104
+ const seen = new Set();
105
+ const walk = (node) => {
106
+ if (!isPlain(node) || seen.has(node))
107
+ return false;
108
+ seen.add(node);
109
+ if (isPlain(node.properties) && Object.hasOwn(node.properties, name))
110
+ return true;
111
+ if (typeof node.$ref === "string") {
112
+ const local = /^#\/(\$defs|definitions)\/([^/]+)$/.exec(node.$ref);
113
+ const defs = local ? root[local[1]] : undefined;
114
+ const target = local && isPlain(defs) && Object.hasOwn(defs, local[2]) ? defs[local[2]] : undefined;
115
+ if (target === undefined)
116
+ return true;
117
+ if (walk(target))
118
+ return true;
119
+ }
120
+ return ["allOf", "anyOf", "oneOf"].some((key) => Array.isArray(node[key]) && node[key].some(walk));
121
+ };
122
+ return walk(schema);
123
+ }
57
124
  /** The prefix a recipe's announces.prefix may be: our server's name, with at most one word and a `_` or `-` before it,
58
125
  * and one or two `_` or `-` after it (`agentrun__`, `mcp_agentrun_`). */
59
126
  export const ANNOUNCES_PREFIX = new RegExp(`^(?:[A-Za-z0-9]+[_-])?${MCP_SERVER}[_-]{1,2}$`);
@@ -105,21 +172,31 @@ export function announcedTool(update, announces, tools) {
105
172
  return tools.has(tool) ? tool : null;
106
173
  }
107
174
  /** The arguments an update reports for its call: at the recipe's `announces.args`, or its rawInput, without the
108
- * recipe's `extras` that hold text (agy's toolSummary). */
109
- function announcedArgs(update, announces) {
175
+ * recipe's `extras` that hold text (agy's toolSummary), but for those the tool's schema declares (`kept`). */
176
+ function announcedArgs(update, announces, kept) {
110
177
  const args = announces?.args !== undefined ? at(update, announces.args) : update.rawInput;
111
- const extras = announces?.extras ?? [];
178
+ const extras = (announces?.extras ?? []).filter((name) => !kept?.has(name));
112
179
  if (!isPlain(args) || !extras.some((name) => typeof args[name] === "string"))
113
180
  return args;
114
181
  return Object.fromEntries(Object.entries(args).filter(([name, value]) => !(extras.includes(name) && typeof value === "string")));
115
182
  }
183
+ /** Add announced call `update` of `tool` to `calls` by its arguments (announcedArgs). Where the tool's schema declares
184
+ * one of the extras (`kept`), the agent may have added its own (agy's toolSummary beside a call that sent none, the
185
+ * field being optional) or passed the call's: which, only the MCP call's arguments say. So it is kept under both forms,
186
+ * with that extra and without, and the first MCP call either form matches takes it (CallIds.add `also`). */
187
+ function addAnnounced(calls, update, announces, tool, kept) {
188
+ const args = announcedArgs(update, announces, kept);
189
+ const bare = kept?.size ? announcedArgs(update, announces) : args;
190
+ calls.add(update.toolCallId, tool, args, bare === args ? undefined : bare);
191
+ }
116
192
  const hasEffects = (kind) => typeof kind === "string" && NATIVE_EFFECT_KINDS.has(kind);
117
193
  /** The agent's tool_call `update`, kept for the MCP call it may be: a call whose kind has effects of its own never is
118
194
  * (a shell named as our tool never takes an MCP call's id); one the recipe's field names as another tool is the agent's
119
195
  * own; one it names as ours is kept as that tool; one it names nothing for is matched by its arguments alone, except
120
196
  * one with no arguments on a recipe whose field names calls, which waits for the update that names it. On a recipe
121
- * without the field, one reporting no input at all is kept as a call that names nothing (CallIds.add). */
122
- export function announceCall(calls, update, announces, tools) {
197
+ * without the field, one reporting no input at all is kept as a call that names nothing (CallIds.add). `declared`: for
198
+ * each tool, the recipe's extras its input schema declares (declaresProperty), matched with and without (addAnnounced). */
199
+ export function announceCall(calls, update, announces, tools, declared) {
123
200
  if (hasEffects(update.kind))
124
201
  return;
125
202
  const tool = announcedTool(update, announces, tools);
@@ -136,7 +213,10 @@ export function announceCall(calls, update, announces, tools) {
136
213
  // it, so it is the agent's own.
137
214
  if (tool === undefined && announces && !isPlain(raw))
138
215
  return;
139
- calls.add(update.toolCallId, tool, tool === undefined ? update.rawInput : announcedArgs(update, announces));
216
+ if (tool === undefined)
217
+ calls.add(update.toolCallId, undefined, update.rawInput);
218
+ else
219
+ addAnnounced(calls, update, announces, tool, declared?.get(tool));
140
220
  }
141
221
  /** A tool_call_update naming a call its tool_call left unnamed with no input (Cursor's MCP calls: a tool_call titled
142
222
  * "MCP: tool" with rawInput {}, then this update with rawInput {providerIdentifier, toolName, args}): kept as that
@@ -144,23 +224,31 @@ export function announceCall(calls, update, announces, tools) {
144
224
  * (CallIds.held): one whose tool_call reported input, or named a tool, is never named later, so a native read whose
145
225
  * update echoes the model's arguments stays the agent's own. The tool_call's kind was checked before it was held;
146
226
  * the update's is checked here: a shell renamed by a later update is never ours. */
147
- export function nameCall(calls, update, announces, tools) {
227
+ export function nameCall(calls, update, announces, tools, declared) {
148
228
  if (!calls.held(update.toolCallId) || hasEffects(update.kind))
149
229
  return;
150
230
  const tool = announcedTool(update, announces, tools);
151
231
  if (typeof tool !== "string")
152
232
  return;
153
- calls.add(update.toolCallId, tool, announcedArgs(update, announces));
233
+ addAnnounced(calls, update, announces, tool, declared?.get(tool));
154
234
  }
155
235
  /** The key of an announcement that names no tool and reports no input (CallIds.add). */
156
236
  const NOTHING = "\0*";
237
+ /** take's word for a call torn between announcements its arguments match only without an extra. */
238
+ const TORN = Symbol("torn");
239
+ /** How long an MCP call that matches an announcement only without an extra (addAnnounced) holds for its own (take): an
240
+ * MCP call can reach MCP a little before the agent's announcement of it, and in that while the other's may be the only
241
+ * one there. */
242
+ export const ANNOUNCE_GRACE_MS = 500;
157
243
  /** The agent's announced calls, matched to the MCP calls of our tools that reach the server. */
158
244
  export class CallIds {
245
+ grace;
159
246
  seen = new Map();
160
247
  waiting = new Map();
161
248
  used = new Set();
162
249
  tools = new Map();
163
- /** The key each announcement still waiting for its MCP call is kept under. */
250
+ /** The keys each announcement still waiting for its MCP call is kept under: one, or two where its arguments may be
251
+ * read with or without an extra (add's `also`). */
164
252
  keyOf = new Map();
165
253
  /** The calls announced naming no tool and reporting no input, held for the update that names them (hold). */
166
254
  unnamed = new Set();
@@ -181,8 +269,13 @@ export class CallIds {
181
269
  * never keeps one elsewhere) is the last an MCP call takes, of any tool, when nothing else matches it: nothing names
182
270
  * it and nothing ties it, and its MCP call would otherwise run under an id of the adapter's, counted a second time
183
271
  * against a plan's limit and memoized under a key a resume never asks again. Until its call ends (settle). A tool
184
- * named for an id already announced without one (a call the agent named in a later update) keys it again. */
185
- add(id, tool, input) {
272
+ * named for an id already announced without one (a call the agent named in a later update) keys it again. `also`:
273
+ * the same call's arguments read another way (addAnnounced: without an extra its tool's schema declares), under
274
+ * which it is kept too; the first MCP call either matches takes it, and it is gone from both. A call already waiting
275
+ * is handed it only where it is the call's own first key, its tool and its whole arguments. One that matches it only
276
+ * without the extra may be another call's, whose own announcement is on its way, and one naming no tool or reporting
277
+ * no input may come second to the call's own ended one, so for those the call tries again as take says (wake). */
278
+ add(id, tool, input, also) {
186
279
  if (this.used.has(id))
187
280
  return;
188
281
  if (tool !== undefined)
@@ -191,39 +284,59 @@ export class CallIds {
191
284
  this.tools.set(id, tool);
192
285
  // An announced call with input is matched only by that input (and its tool, where the field named one), so it never
193
286
  // takes an MCP call with other arguments that is waiting for its own announcement.
194
- const key = isPlain(input) ? `${tool ?? ""}\0${canonical(input)}` : `${tool ?? ""}\0*`;
287
+ const keyFor = (args) => (isPlain(args) ? `${tool ?? ""}\0${canonical(args)}` : `${tool ?? ""}\0*`);
288
+ const keys = [...new Set([keyFor(input), ...(also === undefined ? [] : [keyFor(also)])])];
195
289
  const before = this.keyOf.get(id);
196
- if (before === key)
290
+ if (before && before.length === keys.length && before.every((key, i) => key === keys[i]))
197
291
  return;
198
- if (before !== undefined) {
199
- const list = this.seen.get(before) ?? [];
200
- const at = list.indexOf(id);
201
- if (at >= 0)
202
- list.splice(at, 1);
203
- }
204
- const waiter = this.waiting.get(key)?.shift();
292
+ // An ended one (settle) keyed again stays ended, and is never handed to a waiting call at once.
293
+ const ended = this.ended.has(id);
294
+ this.unlist(id);
295
+ const waiter = ended ? undefined : this.waiting.get(keys[0])?.shift();
205
296
  if (waiter) {
206
- this.keyOf.delete(id);
207
297
  this.used.add(id);
208
298
  waiter(id);
299
+ this.wake();
209
300
  return;
210
301
  }
211
- const list = this.seen.get(key) ?? [];
212
- list.push(id);
213
- this.seen.set(key, list);
214
- this.keyOf.set(id, key);
302
+ for (const key of keys) {
303
+ const list = this.seen.get(key) ?? [];
304
+ list.push(id);
305
+ this.seen.set(key, list);
306
+ }
307
+ this.keyOf.set(id, keys);
308
+ if (ended)
309
+ this.ended.add(id);
310
+ this.wake();
311
+ }
312
+ /** `id` out of every list it is kept in (keyOf), waiting for its MCP call no more. */
313
+ unlist(id) {
314
+ for (const key of this.keyOf.get(id) ?? []) {
315
+ const list = this.seen.get(key) ?? [];
316
+ const at = list.indexOf(id);
317
+ if (at >= 0)
318
+ list.splice(at, 1);
319
+ }
320
+ this.keyOf.delete(id);
321
+ this.ended.delete(id);
215
322
  }
216
323
  /** The agent's call `id` ended (completed or failed) with no MCP call having taken it: an announcement that names
217
- * nothing and reports nothing is dropped, so a call of the agent's own never takes a later MCP call's id. */
324
+ * nothing and reports nothing is dropped, so a call of the agent's own never takes a later MCP call's id. Any other
325
+ * is `ended`: a live announcement comes before it in every match (take), so a retry with the same arguments takes its
326
+ * own id, and it holds no later MCP call; but it stays for a late MCP call of its own (a cancel can report a call
327
+ * failed while its MCP call is on its way), which takes it after the hold when no live one matches. */
218
328
  settle(id) {
219
- if (this.keyOf.get(id) !== NOTHING)
329
+ const keys = this.keyOf.get(id);
330
+ if (!keys)
220
331
  return;
221
- const list = this.seen.get(NOTHING) ?? [];
222
- const at = list.indexOf(id);
223
- if (at >= 0)
224
- list.splice(at, 1);
225
- this.keyOf.delete(id);
332
+ if (keys[0] === NOTHING)
333
+ this.unlist(id);
334
+ else
335
+ this.ended.add(id);
336
+ this.wake();
226
337
  }
338
+ /** The announcements whose call ended with no MCP call (settle), still listed. */
339
+ ended = new Set();
227
340
  /** Whether the agent announced `id` (matched or not). */
228
341
  has(id) {
229
342
  return this.used.has(id) || this.keyOf.has(id);
@@ -236,59 +349,142 @@ export class CallIds {
236
349
  * came by then. Of the announcements with the same arguments, the oldest named `tool` first, then the oldest named
237
350
  * none; then the oldest of `tool` that reported no input. Then, already there or once the wait is over, never woken
238
351
  * by one coming in during it (which may be the agent's own while this call's own announcement is on its way), the
239
- * oldest that named nothing and reported nothing. */
352
+ * oldest that named nothing and reported nothing. Where the arguments match announcements only read without an extra
353
+ * (addAnnounced), the call holds for `grace` first, and then while one of them may yet be another call's whole
354
+ * arguments. */
240
355
  async take(tool, args, signal, ms) {
241
356
  const keys = [`${tool}\0${canonical(args)}`, `\0${canonical(args)}`, `${tool}\0*`];
242
- const ready = (from) => {
243
- for (const key of from) {
244
- const id = this.seen.get(key)?.shift();
245
- if (id) {
246
- this.keyOf.delete(id);
247
- this.used.add(id);
248
- return id;
357
+ const key = keys[0];
358
+ // Under the first of `from` that keeps one: an announcement whose own arguments are these (its first key, the form
359
+ // with the extra) at once. One kept under this call's own key only read without an extra (addAnnounced) is a guess:
360
+ // its call may have sent the extra, its own MCP call on its way with it, and this call's own announcement still on
361
+ // its way (an MCP call can reach MCP before it). So the call takes one only once it is `aged`, past the grace, and
362
+ // while there are no more of them than calls waiting on them (`waiting`, this one among them); then the oldest. When
363
+ // every call left the extra out, which of them takes which, by when its MCP call came, may not be the order they
364
+ // were announced in: their inputs are the same, so it changes nothing a call is given. Every rule here reads the
365
+ // live announcements alone; one whose call ended (settle) is taken only once the call is `aged` and no live one
366
+ // under any of `from` is left: then the oldest whose own arguments are these, else the oldest. One whose own
367
+ // arguments are these (a late MCP call of a call a cancel reported failed) also comes before a live one that matches
368
+ // them less closely, under a later key: one naming no tool, or reporting no input, or neither, whether it was
369
+ // announced before the MCP call or during its hold (add hands a waiting call only its own first key). Only an
370
+ // announcement whose own first key is this one counts as its own: one kept here only read without an extra
371
+ // (addAnnounced) is a guess, and a live one under a later key comes first, as before. So a retry announced with
372
+ // less than its call's whole arguments (no tool, or no input), after a call with these arguments ended, takes the
373
+ // ended one's id after the hold: the same tool with the same arguments, the order the two came in lost. Beyond this: an
374
+ // announcement that comes more than the grace after its own MCP call (that call takes the other's), and a call torn
375
+ // until the wait is over, more than ms behind the other's MCP call (it takes the oldest, which may be the other's);
376
+ // in both the other's MCP call falls back once its wait is over. Two calls with the same arguments, one ended, can
377
+ // swap ids when the ended one's MCP call comes after the other's announcement: their arguments cannot tell them
378
+ // apart. Once the wait is over, loose may take an ended announcement of the tool with other arguments, as it does a
379
+ // live one.
380
+ const pick = (from, waiting, aged) => {
381
+ const take = (id) => {
382
+ this.unlist(id);
383
+ this.used.add(id);
384
+ this.wake();
385
+ return id;
386
+ };
387
+ let gone;
388
+ let own = false;
389
+ for (const at of from) {
390
+ const list = this.seen.get(at);
391
+ if (!list?.length)
392
+ continue;
393
+ const live = list.filter((each) => !this.ended.has(each));
394
+ if (!live.length) {
395
+ if (gone === undefined) {
396
+ const exact = list.find((each) => this.keyOf.get(each)?.[0] === at);
397
+ gone = exact ?? list[0];
398
+ own = exact !== undefined && (at === keys[0] || at === keys[1]);
399
+ }
400
+ continue;
249
401
  }
402
+ if (own)
403
+ break;
404
+ const id = live.find((each) => this.keyOf.get(each)?.[0] === at) ?? (at === key && (!aged || live.length > waiting) ? TORN : live[0]);
405
+ return id === TORN ? TORN : take(id);
250
406
  }
251
- return undefined;
407
+ if (gone === undefined)
408
+ return undefined;
409
+ return aged ? take(gone) : TORN;
252
410
  };
253
411
  // Once the wait is over, the oldest announced call named `tool` whose reported input differs from what reached MCP.
254
412
  // Never one named no tool with other arguments: its arguments are all that ties it, and they differ. Then the oldest
255
413
  // that named nothing and reported nothing.
256
- const loose = () => ready([...[...this.seen.keys()].filter((key) => key.startsWith(`${tool}\0`)), NOTHING]);
257
- const now = ready([...keys, NOTHING]);
258
- if (now)
414
+ const loose = () => pick([...[...this.seen.keys()].filter((at) => at.startsWith(`${tool}\0`)), NOTHING], Infinity, true);
415
+ const now = pick([...keys, NOTHING], (this.pending.get(key) ?? 0) + 1, this.grace <= 0);
416
+ if (typeof now === "string")
259
417
  return now;
260
418
  return new Promise((resolve, reject) => {
261
- const lists = keys.map((key) => {
262
- const list = this.waiting.get(key) ?? [];
263
- this.waiting.set(key, list);
264
- return list;
265
- });
266
- const drop = () => {
267
- for (const list of lists) {
268
- const at = list.indexOf(done);
269
- if (at >= 0)
270
- list.splice(at, 1);
271
- }
419
+ let aged = this.grace <= 0;
420
+ // A call is handed an announcement at once (add) only under its own first key: its own arguments with its tool. One
421
+ // that names no tool or reports no input is listed, and wakes the call, whose retry takes it by pick's rules (its
422
+ // own ended announcement comes first). Never on one that named nothing: those are only kept on a recipe without
423
+ // announces, and an extra (the one cause to wait) needs announces.
424
+ const handed = this.waiting.get(key) ?? [];
425
+ this.waiting.set(key, handed);
426
+ const retry = () => {
427
+ const id = pick(keys, this.pending.get(key) ?? 0, aged);
428
+ if (typeof id === "string")
429
+ done(id);
272
430
  };
273
- const done = (id) => {
431
+ const leave = () => {
274
432
  clearTimeout(timer);
433
+ clearTimeout(held);
434
+ const at = handed.indexOf(done);
435
+ if (at >= 0)
436
+ handed.splice(at, 1);
437
+ if (!this.retries.delete(retry))
438
+ return;
439
+ const left = (this.pending.get(key) ?? 1) - 1;
440
+ if (left > 0)
441
+ this.pending.set(key, left);
442
+ else
443
+ this.pending.delete(key);
444
+ };
445
+ const done = (id) => {
275
446
  signal.removeEventListener("abort", stop);
276
- drop();
447
+ leave();
277
448
  resolve(id);
278
449
  };
279
450
  const stop = () => {
280
- clearTimeout(timer);
281
- drop();
451
+ leave();
282
452
  reject(signal.reason instanceof Error ? signal.reason : new Error("the call was stopped"));
283
453
  };
284
454
  const timer = setTimeout(() => {
285
455
  signal.removeEventListener("abort", stop);
286
- drop();
287
- resolve(loose());
456
+ leave();
457
+ resolve(pick(keys, Infinity, true) ?? loose());
288
458
  }, ms);
459
+ const held = setTimeout(() => {
460
+ aged = true;
461
+ retry();
462
+ }, Math.max(this.grace, 0));
289
463
  signal.addEventListener("abort", stop, { once: true });
290
- for (const list of lists)
291
- list.push(done);
464
+ handed.push(done);
465
+ this.pending.set(key, (this.pending.get(key) ?? 0) + 1);
466
+ this.retries.add(retry);
467
+ this.wake();
468
+ });
469
+ }
470
+ /** How long an MCP call holds before it takes an announcement it matches only without an extra (take). */
471
+ constructor(grace = ANNOUNCE_GRACE_MS) {
472
+ this.grace = grace;
473
+ }
474
+ /** The MCP calls waiting (take): how many under each key, and each one's retry. */
475
+ pending = new Map();
476
+ retries = new Set();
477
+ waking = false;
478
+ /** Each waiting call tries again, once the current one is through: an announcement was taken, listed or dropped, or
479
+ * another call waits. */
480
+ wake() {
481
+ if (this.waking || this.retries.size === 0)
482
+ return;
483
+ this.waking = true;
484
+ queueMicrotask(() => {
485
+ this.waking = false;
486
+ for (const retry of [...this.retries])
487
+ retry();
292
488
  });
293
489
  }
294
490
  }
package/dist/harness.js CHANGED
@@ -19,7 +19,7 @@ import { dirname, isAbsolute, join, normalize } from "node:path";
19
19
  import { fileURLToPath } from "node:url";
20
20
  import { PROTOCOL_VERSION } from "@agentclientprotocol/sdk";
21
21
  import { askGate, journalRecords, NativeJournal, openTurn, placeSubmissions, recoveryNote, resumeUnstartedCalls, toolBridge, toolKey, transcriptOf } from "@parcha/agentrun-kernel/process";
22
- import { announceCall, announcedField, CallIds, MCP_SERVER, nameCall, ourTool, permissionCallId } from "./calls.js";
22
+ import { announceCall, announcedField, announcesAt, CallIds, declaresProperty, joinsByOne, mcpServerName, nameCall, namesTooLong, ourTool, permissionCallId, toolsLeftOut } from "./calls.js";
23
23
  import { ACP_CODES } from "./facts.js";
24
24
  import { allowFileText, homePath } from "./recipe.js";
25
25
  import { restoreState, STATE_STREAM, StateMirror } from "./state.js";
@@ -165,8 +165,14 @@ export function acpHarness(options, control) {
165
165
  const log = options.log ?? (() => { });
166
166
  const recipe = options.recipe;
167
167
  const plan = recipe.billing.kind === "plan" ? recipe.billing : undefined;
168
- const listed = options.tools.filter((tool) => !tool.deferred);
168
+ const offered = options.tools.filter((tool) => !tool.deferred);
169
+ /** Those the agent names past its cap under our server's name (namesTooLong), which it could never call: never listed,
170
+ * and each start says so (toolsLeftOut). The name's length is the same at every start (mcpServerName). */
171
+ const capped = joinsByOne(recipe.announces) ? namesTooLong(announcesAt(recipe.announces, mcpServerName(recipe.announces)), offered.map((tool) => tool.name)) : [];
172
+ const listed = offered.filter((tool) => !capped.includes(tool.name));
169
173
  const names = new Set(listed.map((tool) => tool.name));
174
+ /** For each tool, the recipe's announces.extras its own input schema declares: kept in its arguments (announceCall). */
175
+ const declared = new Map(listed.map((tool) => [tool.name, new Set((recipe.announces?.extras ?? []).filter((name) => declaresProperty(tool.inputSchema, name)))]));
170
176
  let runtime;
171
177
  /** The recipe's refusal `text` (the agent's stderr, an error it answered) says, as `<code>: <words>`; undefined when it
172
178
  * says none of them. */
@@ -266,7 +272,7 @@ export function acpHarness(options, control) {
266
272
  cur.turn.final = cur.turn.kept = "";
267
273
  countCall(rt, cur, update.toolCallId);
268
274
  // Kept for the MCP call it may be, named by the recipe's announces field, never by its title (announceCall).
269
- announceCall(rt.calls, update, recipe.announces, names);
275
+ announceCall(rt.calls, update, rt.announces, names, declared);
270
276
  logAnnounced(rt, update);
271
277
  return;
272
278
  }
@@ -275,7 +281,7 @@ export function acpHarness(options, control) {
275
281
  return;
276
282
  // A call the agent named only after announcing it with no input (Cursor's): by the recipe's field (nameCall).
277
283
  const held = rt.calls.held(update.toolCallId);
278
- nameCall(rt.calls, update, recipe.announces, names);
284
+ nameCall(rt.calls, update, rt.announces, names, declared);
279
285
  if (held && !rt.calls.held(update.toolCallId))
280
286
  logAnnounced(rt, update);
281
287
  // Its status is the agent's word only: what it changes is the mirror of the agent's session store.
@@ -370,7 +376,7 @@ export function acpHarness(options, control) {
370
376
  // title never sets that: CallIds.announced comes from the field alone). Without the
371
377
  // quirk (Goose, which asks nothing for our tools: its allowFile) every request is the host gate's, journaled.
372
378
  if (recipe.quirks?.permissionTie === "title") {
373
- const mine = ourTool(request.toolCall, names);
379
+ const mine = ourTool(request.toolCall, names, rt.server);
374
380
  if (mine && rt.calls.announced(request.toolCall.toolCallId) === mine)
375
381
  return choose("allow_once");
376
382
  }
@@ -506,6 +512,13 @@ export function acpHarness(options, control) {
506
512
  }
507
513
  if (absent.length)
508
514
  throw new Error(`${ACP_CODES.keyMissing}: ${recipe.label ?? recipe.id} runs on ${absent.join(" and ")}, which this host does not hold; the agent was not started`);
515
+ // A tool of ours the agent would name past its cap is not listed (capped); the run is told which, and goes on.
516
+ const serverName = mcpServerName(recipe.announces);
517
+ if (capped.length) {
518
+ const words = toolsLeftOut(recipe.label ?? recipe.id, announcesAt(recipe.announces, serverName)?.prefix ?? "", capped);
519
+ log("acp: tools left out of the agent's listing, named past its cap", { tools: capped });
520
+ ctx.live({ type: "notice", text: words });
521
+ }
509
522
  mkdirSync(base, { recursive: true, mode: 0o700 });
510
523
  // Everything the agent kept goes: what it starts with is the session's records, never an earlier process's files.
511
524
  for (const dir of [home, tmp]) {
@@ -541,7 +554,7 @@ export function acpHarness(options, control) {
541
554
  const stopped = new AbortController();
542
555
  const signal = AbortSignal.any([ctx.signal, stopped.signal]);
543
556
  const key = randomBytes(32).toString("base64url");
544
- const rt = { ctx, loading: false, fresh: true, wiped: false, firstBlocks: [], calls: new CallIds(), counted: new Set(), claimed: new Set(), ownIds: new Set(), sessionId: "", mirror: new StateMirror(home, (recipe.state ?? []).map((p) => homePath(p)), own, records, log, (words) => (rt.current?.ctx ?? ctx).live({ type: "notice", text: words })) };
557
+ const rt = { ctx, loading: false, fresh: true, wiped: false, firstBlocks: [], calls: new CallIds(), server: serverName, announces: announcesAt(recipe.announces, serverName), counted: new Set(), claimed: new Set(), ownIds: new Set(), sessionId: "", mirror: new StateMirror(home, (recipe.state ?? []).map((p) => homePath(p)), own, records, log, (words) => (rt.current?.ctx ?? ctx).live({ type: "notice", text: words })) };
545
558
  const mcp = await startMcpServer({ tools: listed.map((t) => ({ name: t.name, description: t.description, inputSchema: t.inputSchema })), key, log, call: (name, args, callSignal) => onMcpCall(rt, name, args, callSignal) });
546
559
  let proxy;
547
560
  let agent;
@@ -654,8 +667,8 @@ export function acpHarness(options, control) {
654
667
  }
655
668
  }
656
669
  const server = recipe.declares.mcp === "http"
657
- ? { type: "http", name: MCP_SERVER, url: mcp.url, headers: [{ name: "Authorization", value: `Bearer ${key}` }] }
658
- : { name: MCP_SERVER, command: process.execPath, args: [STDIO_BRIDGE], env: [{ name: "AGENTRUN_MCP_URL", value: mcp.url }, { name: "AGENTRUN_MCP_KEY", value: key }] };
670
+ ? { type: "http", name: rt.server, url: mcp.url, headers: [{ name: "Authorization", value: `Bearer ${key}` }] }
671
+ : { name: rt.server, command: process.execPath, args: [STDIO_BRIDGE], env: [{ name: "AGENTRUN_MCP_URL", value: mcp.url }, { name: "AGENTRUN_MCP_KEY", value: key }] };
659
672
  const instructions = options.instructions?.trim() ? options.instructions : undefined;
660
673
  const systemPrompt = instructions && caps.sessionCapabilities?.systemPrompt ? { mode: "append", content: [{ type: "text", text: instructions }] } : undefined;
661
674
  const last = journalRecords(ctx.state(), SESSION_STREAM).map((r) => r.data?.sessionId).filter((id) => typeof id === "string").at(-1);
package/dist/index.d.ts CHANGED
@@ -10,4 +10,5 @@ export { gooseAdapter, gooseRecipe, recipeFile, type AcpRecipeFile, type AcpReci
10
10
  export { applyGoose, GOOSE_BETAS, GOOSE_OWN_TOOLS, gooseProxy, goosePolicy, gooseRoutes, gooseToolName, gooseUsage, limitGooseOutput, type GoosePolicyOptions, type GooseProvider, type GooseProxyOptions } from "./host/goose-proxy.js";
11
11
  export { acpPlatform, AcpBinaryRefused, CURSOR_PIN, GOOSE_PIN, pinnedRelease, treeDigest, verifyPinnedBinary, verifyPinnedBinaryAsync, verifyPinnedTree, type AcpArchivePin, type AcpBinaryPin, type AcpPlatform, type PinnedRelease } from "./pinned-binary.js";
12
12
  export { CURSOR_CODES, CURSOR_INSTALL, CURSOR_LIMITS, cursorCard, cursorFacts, type CursorLimits } from "./cursor-facts.js";
13
+ export { BUNDLED_RECIPES, bundledRecipePath } from "./bundled.js";
13
14
  export { cursorAdapter, cursorRecipe, cursorRelease, cursorRootOf, type CursorAdapterOptions, type CursorRecipeOptions, type CursorRelease } from "./cursor.js";
package/dist/index.js CHANGED
@@ -10,4 +10,5 @@ export { gooseAdapter, gooseRecipe, recipeFile } from "./goose.js";
10
10
  export { applyGoose, GOOSE_BETAS, GOOSE_OWN_TOOLS, gooseProxy, goosePolicy, gooseRoutes, gooseToolName, gooseUsage, limitGooseOutput } from "./host/goose-proxy.js";
11
11
  export { acpPlatform, AcpBinaryRefused, CURSOR_PIN, GOOSE_PIN, pinnedRelease, treeDigest, verifyPinnedBinary, verifyPinnedBinaryAsync, verifyPinnedTree } from "./pinned-binary.js";
12
12
  export { CURSOR_CODES, CURSOR_INSTALL, CURSOR_LIMITS, cursorCard, cursorFacts } from "./cursor-facts.js";
13
+ export { BUNDLED_RECIPES, bundledRecipePath } from "./bundled.js";
13
14
  export { cursorAdapter, cursorRecipe, cursorRelease, cursorRootOf } from "./cursor.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcha/agentrun-harness-acp",
3
- "version": "0.1.0-beta.60",
3
+ "version": "0.1.0-beta.62",
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.60",
52
+ "@parcha/agentrun-kernel": "0.1.0-beta.62",
53
53
  "zod": "4.6.6"
54
54
  },
55
55
  "publishConfig": {
@@ -0,0 +1,44 @@
1
+ {
2
+ "id": "antigravity",
3
+ "label": "Google Antigravity",
4
+ "description": "Google's agy CLI as an ACP agent (agy acp), as T3 Code runs it: on a Gemini API key from Google AI Studio saved for it alone, or, on its owner's own machine alone, on their own Google sign-in, made by the agent itself with agy acp --login (agentrun harness sign-in). AgentRun never reads, refreshes or sends the sign-in (HARNESS.md#sign-in).",
5
+ "release": {
6
+ "version": "1.5.14",
7
+ "archives": {
8
+ "linux-x86_64": {
9
+ "url": "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.5.14-5302690847260672/linux-x64/cli_linux_x64.tar.gz",
10
+ "format": "tar.gz",
11
+ "sha512": "83311d3f354567612dc16c1ae2ea9b503d6f6833aa4e138d39aa229da3f3bb99b0e4d7cca0bce4796b0060d6a51d8113eb7449ed5dc0e7900bf217107ea5bff9",
12
+ "cmd": "./antigravity"
13
+ },
14
+ "linux-aarch64": {
15
+ "url": "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.5.14-5302690847260672/linux-arm/cli_linux_arm64.tar.gz",
16
+ "format": "tar.gz",
17
+ "sha512": "c9b29bba475f63a1a80161ae93ba72b221c7a586d9851e4d0061546704bab66d6b2760b25d716d191724fc7564f3246456ee151e28aa37af48dbcd72bdc6c463",
18
+ "cmd": "./antigravity"
19
+ },
20
+ "darwin-x86_64": {
21
+ "url": "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.5.14-5302690847260672/darwin-x64/cli_mac_x64.tar.gz",
22
+ "format": "tar.gz",
23
+ "sha512": "1b6a1fc6dbe46ba6d9d0405d1b6095189f35ebfc4c3c33ceb1fd1b6d0c9fd702b52ac10b64b8b52aed0d8d71ae02c5df3cffd5e3e3d37549c2daffcce2a853c7",
24
+ "cmd": "./antigravity"
25
+ },
26
+ "darwin-aarch64": {
27
+ "url": "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.5.14-5302690847260672/darwin-arm/cli_mac_arm64.tar.gz",
28
+ "format": "tar.gz",
29
+ "sha512": "26830fd46bfb9200d073cf3e71bf94b707552557b4380ec01afd6e99f3a2b030e65422dab1867f77318078692defc859a7547d17ec4b0b1e9369f13c9c3caea6",
30
+ "cmd": "./antigravity"
31
+ }
32
+ }
33
+ },
34
+ "args": ["acp", "--disable-telemetry"],
35
+ "env": { "AGY_CLI_DISABLE_AUTO_UPDATE": "1", "AGY_ACP_FORCE_FILE_STORAGE": "1" },
36
+ "model": { "billing": "plan", "maxTurns": 20, "maxToolCalls": 40, "hosts": ["cloudcode-pa.googleapis.com", "oauth2.googleapis.com", "www.googleapis.com", "generativelanguage.googleapis.com"] },
37
+ "keys": [{ "name": "ANTIGRAVITY_GEMINI_API_KEY", "env": "GEMINI_API_KEY" }],
38
+ "keyMethod": "gemini-api-key",
39
+ "signIn": { "args": ["--login"], "homeArg": "--gemini-dir", "terms": "https://antigravity.google/terms" },
40
+ "announces": { "tool": "name", "prefix": "mcp_agentrun_", "extras": ["toolSummary"] },
41
+ "state": [".gemini/antigravity-cli/conversations"],
42
+ "declares": { "load": true, "mcp": "stdio" },
43
+ "quirks": { "permissionTie": "title" }
44
+ }
@@ -2,7 +2,8 @@
2
2
  // A stand-in ACP agent for the adapter's tests and the conformance suite: a stdio agent on the official SDK whose "model"
3
3
  // is a script. No binary, no model, no network beyond loopback. Its one argument is a JSON config file:
4
4
  // script: the model's steps, the conformance suite's ScriptStep ({call, args} | {say, cut} | {sayLastSteer} |
5
- // {sayLastResult}) plus {native: kind, title, input}, a tool of the agent's own (a shell, an edit);
5
+ // {sayLastResult}) plus {native: kind, title, input}, a tool of the agent's own (a shell, an edit), and
6
+ // {sayTools}, the names its MCP server lists (tools/list), joined by commas;
6
7
  // load: advertise session/load and keep sessions in $HOME/.fake-acp/sessions (default true);
7
8
  // advertiseLoad / advertiseHttp: what initialize says, when it should differ from what the agent does;
8
9
  // http: advertise MCP over HTTP (default true); the client then picks the transport;
@@ -10,8 +11,9 @@
10
11
  // (titles agentrun-<tool>: <tool>; MCP and execute ask, edits do not; a refused native call still reports
11
12
  // completed), or "goose-1.59" (as "goose", but titled as Goose 1.59.2 titles a call of an extension's tool:
12
13
  // `agentrun: <tool, its underscores as spaces>`), or "antigravity" (an MCP call as agy 1.5.14 announces and asks
13
- // about it: named `mcp_agentrun_<tool>`, titled `Run mcp_agentrun_<tool>`, its rawInput the call's arguments
14
- // with agy's own `toolSummary` beside them, which the MCP call itself never carries; options Allow and Deny);
14
+ // about it: named `mcp_<server>_<tool>`, titled `Run mcp_<server>_<tool>`, <server> the name the client gave
15
+ // its MCP server, its rawInput the call's arguments with agy's own `toolSummary` beside them, which the MCP
16
+ // call itself never carries, unless the arguments have a toolSummary of their own; options Allow and Deny);
15
17
  // titleSummary: with style "goose-1.59", the summary Goose 1.59.2 writes after such a title for a call whose
16
18
  // arguments it summarizes (a path): `agentrun: <tool> · <titleSummary>`;
17
19
  // (styles "goose" and "goose-1.59" read $HOME/.config/goose/permission.yaml at start, as Goose 1.59.2's permission
@@ -127,7 +129,8 @@ const pgid = (() => {
127
129
  }
128
130
  })();
129
131
  said({ type: "start", env: Object.keys(process.env).sort(), home, cwd: process.cwd(), pgid, ...(config.cursorDirs ? { cursorDir, deniesWrite } : {}) });
130
- const titleOf = (tool) => (style === "cursor" ? `agentrun-${tool}: ${tool}` : style === "antigravity" ? `Run mcp_agentrun_${tool}` : style === "goose-1.59" ? `agentrun: ${tool.replace(/_/g, " ")}${config.titleSummary ? ` · ${config.titleSummary}` : ""}` : `agentrun__${tool}`);
132
+ /** The title of a call of our `tool`, the client's MCP server given as `server` (agy names it in its title). */
133
+ const titleOf = (tool, server = "agentrun") => (style === "cursor" ? `agentrun-${tool}: ${tool}` : style === "antigravity" ? `Run mcp_${server}_${tool}` : style === "goose-1.59" ? `agentrun: ${tool.replace(/_/g, " ")}${config.titleSummary ? ` · ${config.titleSummary}` : ""}` : `agentrun__${tool}`);
131
134
  const late = style === "cursor" && config.announce !== "early";
132
135
  /** Goose's field naming a tool_call's tool, on its first tool_call only, in the shape goose-acp's goose_tool_call_meta
133
136
  * builds (conversion.rs:65-91 at v1.59.2): `toolName` the name the model called, `extensionName` the part before `__`
@@ -255,7 +258,7 @@ async function openSession(id, params, history) {
255
258
  const servers = params.mcpServers ?? [];
256
259
  const server = servers.find((s) => s.name === "agentrun") ?? servers[0];
257
260
  const mcp = server ? await mcpClient(server) : undefined;
258
- const session = { id, history, mcp, turn: undefined, system: params.systemPrompt ? text(params.systemPrompt.content ?? []).join("\n") : undefined };
261
+ const session = { id, history, mcp, server: server?.name ?? "agentrun", turn: undefined, system: params.systemPrompt ? text(params.systemPrompt.content ?? []).join("\n") : undefined };
259
262
  sessions.set(id, session);
260
263
  return session;
261
264
  }
@@ -292,8 +295,9 @@ async function takeTurn(client, session, prompt, signal) {
292
295
  if ("call" in s) {
293
296
  const id = `call_${step - 1}`;
294
297
  const args = s.args ?? {};
298
+ const reported = "toolSummary" in args ? args : { ...args, toolSummary: `Call ${s.call}` };
295
299
  const update = style === "antigravity"
296
- ? { toolCallId: id, name: `mcp_agentrun_${s.call}`, title: titleOf(s.call), kind: "other", status: "pending", rawInput: { ...args, toolSummary: `Call ${s.call}` }, args: { ...args, toolSummary: `Call ${s.call}` } }
300
+ ? { toolCallId: id, name: `mcp_${session.server}_${s.call}`, title: titleOf(s.call, session.server), kind: "other", status: "pending", rawInput: reported, args: reported }
297
301
  : { toolCallId: id, title: titleOf(s.call), kind: "other", status: "pending", rawInput: args };
298
302
  const entry = { kind: "call", id, tool: s.call, args, status: "pending" };
299
303
  session.history.push(entry);
@@ -385,6 +389,7 @@ async function takeTurn(client, session, prompt, signal) {
385
389
  let words;
386
390
  if ("say" in s) words = s.say;
387
391
  else if ("sayLastResult" in s) words = lastResult ?? "";
392
+ else if ("sayTools" in s) words = ((await session.mcp?.request("tools/list", {}))?.tools ?? []).map((tool) => tool.name).join(",");
388
393
  else if ("sayLastSteer" in s) words = (notes.includes("[Recovery]") ? lastQuote(blocks.find((b) => b.includes("[Recovery]"))) : undefined) ?? said_;
389
394
  else words = "";
390
395
  session.history.push({ kind: "say", text: words });
@@ -451,7 +456,7 @@ const app = agent({ name: "fake-acp" })
451
456
  const session = await openSession(id, params, []);
452
457
  save(session);
453
458
  writeAuth();
454
- said({ type: "new", sessionId: id, mcp: params.mcpServers.map((s) => s.type ?? "stdio"), system: session.system });
459
+ said({ type: "new", sessionId: id, mcp: params.mcpServers.map((s) => s.type ?? "stdio"), names: params.mcpServers.map((s) => s.name), system: session.system });
455
460
  return { sessionId: id, ...(models ? { models } : {}) };
456
461
  })
457
462
  // Not in the SDK's stable methods: Cursor's own (unstable ACP) method, so its params are taken as they come.
@@ -472,7 +477,7 @@ const app = agent({ name: "fake-acp" })
472
477
  if (h.kind === "user") await client.notify("session/update", { sessionId: session.id, update: { sessionUpdate: "user_message_chunk", content: { type: "text", text: h.text } } });
473
478
  if (h.kind === "say" && h.text) await client.notify("session/update", { sessionId: session.id, update: { sessionUpdate: "agent_message_chunk", content: { type: "text", text: h.text } } });
474
479
  if (h.kind === "call" || h.kind === "native") {
475
- await client.notify("session/update", { sessionId: session.id, update: { sessionUpdate: "tool_call", toolCallId: h.id, title: h.kind === "call" ? titleOf(h.tool) : h.title, status: "pending", rawInput: h.args ?? {} } });
480
+ await client.notify("session/update", { sessionId: session.id, update: { sessionUpdate: "tool_call", toolCallId: h.id, title: h.kind === "call" ? titleOf(h.tool, session.server) : h.title, status: "pending", rawInput: h.args ?? {} } });
476
481
  await client.notify("session/update", { sessionId: session.id, update: { sessionUpdate: "tool_call_update", toolCallId: h.id, status: h.status === "pending" ? "failed" : h.status } });
477
482
  }
478
483
  }