@parcha/agentrun-harness-acp 0.1.0-beta.59 → 0.1.0-beta.61

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,16 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## 0.1.0-beta.61 (2026-11-26)
6
+
7
+ - 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 -->
8
+
9
+ 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.
10
+
11
+ ## 0.1.0-beta.60 (2026-11-26)
12
+
13
+ - 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 -->
14
+
5
15
  ## 0.1.0-beta.59 (2026-11-25)
6
16
 
7
17
  **Breaking:**
@@ -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,49 @@ 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), `agentrun` and 8 random hex digits, no `_` or `-`, which no server set up before the start can spell
27
+ * (8, not more: each of our tools is named with it, under the agent's cap, TOOL_NAME_CAP); under any other, `agentrun`. */
28
+ export declare function mcpServerName(announces: AcpAnnounces | undefined): string;
29
+ /** The most characters a tool's name may hold where the agent names it (agy's, as the model APIs' tool names: 64). */
30
+ export declare const TOOL_NAME_CAP = 64;
31
+ /** Of `tools`, those whose name as the agent names them at this start (`announces` as announcesAt reads them: its prefix
32
+ * and the tool's name) is longer than TOOL_NAME_CAP. Only a prefix is counted; a recipe that reads the tool's name
33
+ * from a field of its own with the server beside it (Cursor's) names none. */
34
+ export declare function namesTooLong(announces: AcpAnnounces | undefined, tools: Iterable<string>): string[];
35
+ /** The recipe's `announces` as one start reads them, our MCP server given to the agent as `server` (mcpServerName): its
36
+ * prefix names that server (`mcp_agentrun_` reads `mcp_<server>_`). ANNOUNCES_PREFIX ends a prefix at our server's
37
+ * name, so the last `agentrun` in it is that name. */
38
+ export declare function announcesAt(announces: AcpAnnounces | undefined, server: string): AcpAnnounces | undefined;
39
+ /** Whether an input schema may name an argument `name`: in its `properties`, or in those of a schema it composes (allOf,
40
+ * anyOf, oneOf, at any depth), or behind a `$ref` to its own `$defs` or `definitions`. A `$ref` it cannot read (another
41
+ * document's, or a def it lacks) may, so it counts; a `$ref` that comes back to itself adds nothing. */
42
+ export declare function declaresProperty(schema: unknown, name: string): boolean;
19
43
  /** 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
44
  * path of field names into the update (`_meta.goose.toolCall.toolName`, `rawInput.toolName`, `name`).
21
45
  * - `tool`: the tool's name. With `server`, our tool's own name; without, the name as the model calls it, our server's
22
46
  * prefix and the tool's (`prefix`, stripped).
23
47
  * - `server`: the MCP server's name, which must be ours (`agentrun`).
24
48
  * - `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.
49
+ * `mcp_agentrun_`). It names our server (ANNOUNCES_PREFIX), so a name without it is never ours. One that joins our
50
+ * server's name to the tool's with one `_` or `-` gives the server a name of each start's own (mcpServerName), which
51
+ * the prefix then reads (announcesAt).
26
52
  * - `args`: the call's arguments (default `rawInput`).
27
53
  * - `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). */
54
+ * `toolSummary`, its model's line about the call), left out before the arguments are matched when they hold text,
55
+ * except one the tool's own input schema declares (declaresProperty), which is then the call's own argument. */
31
56
  export interface AcpAnnounces {
32
57
  readonly tool: string;
33
58
  readonly server?: string;
@@ -64,22 +89,24 @@ export interface AcpCallUpdate {
64
89
  * (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
90
  * own; one it names as ours is kept as that tool; one it names nothing for is matched by its arguments alone, except
66
91
  * 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;
92
+ * without the field, one reporting no input at all is kept as a call that names nothing (CallIds.add). `declared`: for
93
+ * each tool, the recipe's extras its input schema declares (declaresProperty), matched with and without (addAnnounced). */
94
+ export declare function announceCall(calls: CallIds, update: AcpCallUpdate, announces: AcpAnnounces | undefined, tools: ReadonlySet<string>, declared?: ReadonlyMap<string, ReadonlySet<string>>): void;
69
95
  /** A tool_call_update naming a call its tool_call left unnamed with no input (Cursor's MCP calls: a tool_call titled
70
96
  * "MCP: tool" with rawInput {}, then this update with rawInput {providerIdentifier, toolName, args}): kept as that
71
97
  * tool, under the id its tool_call already counted, by the recipe's field. Only a call announceCall held for its name
72
98
  * (CallIds.held): one whose tool_call reported input, or named a tool, is never named later, so a native read whose
73
99
  * update echoes the model's arguments stays the agent's own. The tool_call's kind was checked before it was held;
74
100
  * 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;
101
+ export declare function nameCall(calls: CallIds, update: AcpCallUpdate, announces: AcpAnnounces | undefined, tools: ReadonlySet<string>, declared?: ReadonlyMap<string, ReadonlySet<string>>): void;
76
102
  /** The agent's announced calls, matched to the MCP calls of our tools that reach the server. */
77
103
  export declare class CallIds {
78
104
  private readonly seen;
79
105
  private readonly waiting;
80
106
  private readonly used;
81
107
  private readonly tools;
82
- /** The key each announcement still waiting for its MCP call is kept under. */
108
+ /** The keys each announcement still waiting for its MCP call is kept under: one, or two where its arguments may be
109
+ * read with or without an extra (add's `also`). */
83
110
  private readonly keyOf;
84
111
  /** The calls announced naming no tool and reporting no input, held for the update that names them (hold). */
85
112
  private readonly unnamed;
@@ -95,8 +122,12 @@ export declare class CallIds {
95
122
  * never keeps one elsewhere) is the last an MCP call takes, of any tool, when nothing else matches it: nothing names
96
123
  * it and nothing ties it, and its MCP call would otherwise run under an id of the adapter's, counted a second time
97
124
  * 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;
125
+ * named for an id already announced without one (a call the agent named in a later update) keys it again. `also`:
126
+ * the same call's arguments read another way (addAnnounced: without an extra its tool's schema declares), under
127
+ * which it is kept too; the first MCP call either matches takes it, and it is gone from both. */
128
+ add(id: string, tool: string | undefined, input: unknown, also?: unknown): void;
129
+ /** `id` out of every list it is kept in (keyOf), waiting for its MCP call no more. */
130
+ private unlist;
100
131
  /** The agent's call `id` ended (completed or failed) with no MCP call having taken it: an announcement that names
101
132
  * nothing and reports nothing is dropped, so a call of the agent's own never takes a later MCP call's id. */
102
133
  settle(id: string): void;
@@ -108,8 +139,15 @@ export declare class CallIds {
108
139
  * came by then. Of the announcements with the same arguments, the oldest named `tool` first, then the oldest named
109
140
  * none; then the oldest of `tool` that reported no input. Then, already there or once the wait is over, never woken
110
141
  * 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. */
142
+ * oldest that named nothing and reported nothing. Where the arguments match two or more announcements only read
143
+ * without an extra (addAnnounced), the call waits while one of them may yet be another call's whole arguments. */
112
144
  take(tool: string, args: Record<string, unknown>, signal: AbortSignal, ms: number): Promise<string | undefined>;
145
+ /** The MCP calls torn between announcements (take): how many wait under each key, and each one's retry. */
146
+ private readonly torn;
147
+ private readonly retries;
148
+ private waking;
149
+ /** Each torn call tries again, once the current one is through: an announcement was taken, or another call is torn. */
150
+ private wake;
113
151
  }
114
152
  /** The gate's id for a permission request of the agent's own tool: the same for the same request after a resume. */
115
153
  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,89 @@ 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), `agentrun` and 8 random hex digits, no `_` or `-`, which no server set up before the start can spell
66
+ * (8, not more: each of our tools is named with it, under the agent's cap, TOOL_NAME_CAP); under any other, `agentrun`. */
67
+ export function mcpServerName(announces) {
68
+ return joinsByOne(announces) ? `${MCP_SERVER}${randomBytes(4).toString("hex")}` : MCP_SERVER;
69
+ }
70
+ /** The most characters a tool's name may hold where the agent names it (agy's, as the model APIs' tool names: 64). */
71
+ export const TOOL_NAME_CAP = 64;
72
+ /** Of `tools`, those whose name as the agent names them at this start (`announces` as announcesAt reads them: its prefix
73
+ * and the tool's name) is longer than TOOL_NAME_CAP. Only a prefix is counted; a recipe that reads the tool's name
74
+ * from a field of its own with the server beside it (Cursor's) names none. */
75
+ export function namesTooLong(announces, tools) {
76
+ if (announces?.prefix === undefined || announces.server !== undefined)
77
+ return [];
78
+ const prefix = announces.prefix;
79
+ return [...tools].filter((tool) => prefix.length + tool.length > TOOL_NAME_CAP);
80
+ }
81
+ /** The recipe's `announces` as one start reads them, our MCP server given to the agent as `server` (mcpServerName): its
82
+ * prefix names that server (`mcp_agentrun_` reads `mcp_<server>_`). ANNOUNCES_PREFIX ends a prefix at our server's
83
+ * name, so the last `agentrun` in it is that name. */
84
+ export function announcesAt(announces, server) {
85
+ if (!announces || announces.prefix === undefined || server === MCP_SERVER)
86
+ return announces;
87
+ const at = announces.prefix.lastIndexOf(MCP_SERVER);
88
+ return at < 0 ? announces : { ...announces, prefix: `${announces.prefix.slice(0, at)}${server}${announces.prefix.slice(at + MCP_SERVER.length)}` };
89
+ }
90
+ /** Whether an input schema may name an argument `name`: in its `properties`, or in those of a schema it composes (allOf,
91
+ * anyOf, oneOf, at any depth), or behind a `$ref` to its own `$defs` or `definitions`. A `$ref` it cannot read (another
92
+ * document's, or a def it lacks) may, so it counts; a `$ref` that comes back to itself adds nothing. */
93
+ export function declaresProperty(schema, name) {
94
+ if (!isPlain(schema))
95
+ return false;
96
+ const root = schema;
97
+ const seen = new Set();
98
+ const walk = (node) => {
99
+ if (!isPlain(node) || seen.has(node))
100
+ return false;
101
+ seen.add(node);
102
+ if (isPlain(node.properties) && Object.hasOwn(node.properties, name))
103
+ return true;
104
+ if (typeof node.$ref === "string") {
105
+ const local = /^#\/(\$defs|definitions)\/([^/]+)$/.exec(node.$ref);
106
+ const defs = local ? root[local[1]] : undefined;
107
+ const target = local && isPlain(defs) && Object.hasOwn(defs, local[2]) ? defs[local[2]] : undefined;
108
+ if (target === undefined)
109
+ return true;
110
+ if (walk(target))
111
+ return true;
112
+ }
113
+ return ["allOf", "anyOf", "oneOf"].some((key) => Array.isArray(node[key]) && node[key].some(walk));
114
+ };
115
+ return walk(schema);
116
+ }
57
117
  /** The prefix a recipe's announces.prefix may be: our server's name, with at most one word and a `_` or `-` before it,
58
118
  * and one or two `_` or `-` after it (`agentrun__`, `mcp_agentrun_`). */
59
119
  export const ANNOUNCES_PREFIX = new RegExp(`^(?:[A-Za-z0-9]+[_-])?${MCP_SERVER}[_-]{1,2}$`);
@@ -105,21 +165,31 @@ export function announcedTool(update, announces, tools) {
105
165
  return tools.has(tool) ? tool : null;
106
166
  }
107
167
  /** 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) {
168
+ * recipe's `extras` that hold text (agy's toolSummary), but for those the tool's schema declares (`kept`). */
169
+ function announcedArgs(update, announces, kept) {
110
170
  const args = announces?.args !== undefined ? at(update, announces.args) : update.rawInput;
111
- const extras = announces?.extras ?? [];
171
+ const extras = (announces?.extras ?? []).filter((name) => !kept?.has(name));
112
172
  if (!isPlain(args) || !extras.some((name) => typeof args[name] === "string"))
113
173
  return args;
114
174
  return Object.fromEntries(Object.entries(args).filter(([name, value]) => !(extras.includes(name) && typeof value === "string")));
115
175
  }
176
+ /** Add announced call `update` of `tool` to `calls` by its arguments (announcedArgs). Where the tool's schema declares
177
+ * one of the extras (`kept`), the agent may have added its own (agy's toolSummary beside a call that sent none, the
178
+ * field being optional) or passed the call's: which, only the MCP call's arguments say. So it is kept under both forms,
179
+ * with that extra and without, and the first MCP call either form matches takes it (CallIds.add `also`). */
180
+ function addAnnounced(calls, update, announces, tool, kept) {
181
+ const args = announcedArgs(update, announces, kept);
182
+ const bare = kept?.size ? announcedArgs(update, announces) : args;
183
+ calls.add(update.toolCallId, tool, args, bare === args ? undefined : bare);
184
+ }
116
185
  const hasEffects = (kind) => typeof kind === "string" && NATIVE_EFFECT_KINDS.has(kind);
117
186
  /** 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
187
  * (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
188
  * own; one it names as ours is kept as that tool; one it names nothing for is matched by its arguments alone, except
120
189
  * 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) {
190
+ * without the field, one reporting no input at all is kept as a call that names nothing (CallIds.add). `declared`: for
191
+ * each tool, the recipe's extras its input schema declares (declaresProperty), matched with and without (addAnnounced). */
192
+ export function announceCall(calls, update, announces, tools, declared) {
123
193
  if (hasEffects(update.kind))
124
194
  return;
125
195
  const tool = announcedTool(update, announces, tools);
@@ -136,7 +206,10 @@ export function announceCall(calls, update, announces, tools) {
136
206
  // it, so it is the agent's own.
137
207
  if (tool === undefined && announces && !isPlain(raw))
138
208
  return;
139
- calls.add(update.toolCallId, tool, tool === undefined ? update.rawInput : announcedArgs(update, announces));
209
+ if (tool === undefined)
210
+ calls.add(update.toolCallId, undefined, update.rawInput);
211
+ else
212
+ addAnnounced(calls, update, announces, tool, declared?.get(tool));
140
213
  }
141
214
  /** A tool_call_update naming a call its tool_call left unnamed with no input (Cursor's MCP calls: a tool_call titled
142
215
  * "MCP: tool" with rawInput {}, then this update with rawInput {providerIdentifier, toolName, args}): kept as that
@@ -144,23 +217,26 @@ export function announceCall(calls, update, announces, tools) {
144
217
  * (CallIds.held): one whose tool_call reported input, or named a tool, is never named later, so a native read whose
145
218
  * update echoes the model's arguments stays the agent's own. The tool_call's kind was checked before it was held;
146
219
  * the update's is checked here: a shell renamed by a later update is never ours. */
147
- export function nameCall(calls, update, announces, tools) {
220
+ export function nameCall(calls, update, announces, tools, declared) {
148
221
  if (!calls.held(update.toolCallId) || hasEffects(update.kind))
149
222
  return;
150
223
  const tool = announcedTool(update, announces, tools);
151
224
  if (typeof tool !== "string")
152
225
  return;
153
- calls.add(update.toolCallId, tool, announcedArgs(update, announces));
226
+ addAnnounced(calls, update, announces, tool, declared?.get(tool));
154
227
  }
155
228
  /** The key of an announcement that names no tool and reports no input (CallIds.add). */
156
229
  const NOTHING = "\0*";
230
+ /** take's word for a call torn between announcements its arguments match only without an extra. */
231
+ const TORN = Symbol("torn");
157
232
  /** The agent's announced calls, matched to the MCP calls of our tools that reach the server. */
158
233
  export class CallIds {
159
234
  seen = new Map();
160
235
  waiting = new Map();
161
236
  used = new Set();
162
237
  tools = new Map();
163
- /** The key each announcement still waiting for its MCP call is kept under. */
238
+ /** The keys each announcement still waiting for its MCP call is kept under: one, or two where its arguments may be
239
+ * read with or without an extra (add's `also`). */
164
240
  keyOf = new Map();
165
241
  /** The calls announced naming no tool and reporting no input, held for the update that names them (hold). */
166
242
  unnamed = new Set();
@@ -181,8 +257,10 @@ export class CallIds {
181
257
  * never keeps one elsewhere) is the last an MCP call takes, of any tool, when nothing else matches it: nothing names
182
258
  * it and nothing ties it, and its MCP call would otherwise run under an id of the adapter's, counted a second time
183
259
  * 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) {
260
+ * named for an id already announced without one (a call the agent named in a later update) keys it again. `also`:
261
+ * the same call's arguments read another way (addAnnounced: without an extra its tool's schema declares), under
262
+ * which it is kept too; the first MCP call either matches takes it, and it is gone from both. */
263
+ add(id, tool, input, also) {
186
264
  if (this.used.has(id))
187
265
  return;
188
266
  if (tool !== undefined)
@@ -191,38 +269,43 @@ export class CallIds {
191
269
  this.tools.set(id, tool);
192
270
  // An announced call with input is matched only by that input (and its tool, where the field named one), so it never
193
271
  // 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*`;
272
+ const keyFor = (args) => (isPlain(args) ? `${tool ?? ""}\0${canonical(args)}` : `${tool ?? ""}\0*`);
273
+ const keys = [...new Set([keyFor(input), ...(also === undefined ? [] : [keyFor(also)])])];
195
274
  const before = this.keyOf.get(id);
196
- if (before === key)
275
+ if (before && before.length === keys.length && before.every((key, i) => key === keys[i]))
197
276
  return;
198
- if (before !== undefined) {
199
- const list = this.seen.get(before) ?? [];
277
+ this.unlist(id);
278
+ for (const key of keys) {
279
+ const waiter = this.waiting.get(key)?.shift();
280
+ if (waiter) {
281
+ this.used.add(id);
282
+ waiter(id);
283
+ return;
284
+ }
285
+ }
286
+ for (const key of keys) {
287
+ const list = this.seen.get(key) ?? [];
288
+ list.push(id);
289
+ this.seen.set(key, list);
290
+ }
291
+ this.keyOf.set(id, keys);
292
+ }
293
+ /** `id` out of every list it is kept in (keyOf), waiting for its MCP call no more. */
294
+ unlist(id) {
295
+ for (const key of this.keyOf.get(id) ?? []) {
296
+ const list = this.seen.get(key) ?? [];
200
297
  const at = list.indexOf(id);
201
298
  if (at >= 0)
202
299
  list.splice(at, 1);
203
300
  }
204
- const waiter = this.waiting.get(key)?.shift();
205
- if (waiter) {
206
- this.keyOf.delete(id);
207
- this.used.add(id);
208
- waiter(id);
209
- return;
210
- }
211
- const list = this.seen.get(key) ?? [];
212
- list.push(id);
213
- this.seen.set(key, list);
214
- this.keyOf.set(id, key);
301
+ this.keyOf.delete(id);
215
302
  }
216
303
  /** The agent's call `id` ended (completed or failed) with no MCP call having taken it: an announcement that names
217
304
  * nothing and reports nothing is dropped, so a call of the agent's own never takes a later MCP call's id. */
218
305
  settle(id) {
219
- if (this.keyOf.get(id) !== NOTHING)
306
+ if (this.keyOf.get(id)?.[0] !== NOTHING)
220
307
  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);
308
+ this.unlist(id);
226
309
  }
227
310
  /** Whether the agent announced `id` (matched or not). */
228
311
  has(id) {
@@ -236,59 +319,105 @@ export class CallIds {
236
319
  * came by then. Of the announcements with the same arguments, the oldest named `tool` first, then the oldest named
237
320
  * none; then the oldest of `tool` that reported no input. Then, already there or once the wait is over, never woken
238
321
  * 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. */
322
+ * oldest that named nothing and reported nothing. Where the arguments match two or more announcements only read
323
+ * without an extra (addAnnounced), the call waits while one of them may yet be another call's whole arguments. */
240
324
  async take(tool, args, signal, ms) {
241
325
  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;
249
- }
326
+ const key = keys[0];
327
+ // Under the first of `from` that keeps one: an announcement whose own arguments are these (its first key, the form
328
+ // with the extra) first, then the oldest. But two or more kept under this call's own key only read without an extra
329
+ // (addAnnounced) are torn: which of them sent none, only their own MCP calls say, and another's may be on its way
330
+ // with the extra, needing its own. So while there are more of them than calls waiting on them (`waiting`, this one
331
+ // among them), the call waits; once there are not, each takes the oldest.
332
+ const pick = (from, waiting) => {
333
+ for (const at of from) {
334
+ const list = this.seen.get(at);
335
+ if (!list?.length)
336
+ continue;
337
+ const id = list.find((each) => this.keyOf.get(each)?.[0] === at) ?? (at === key && list.length > 1 && list.length > waiting ? TORN : list[0]);
338
+ if (id === TORN)
339
+ return TORN;
340
+ this.unlist(id);
341
+ this.used.add(id);
342
+ this.wake();
343
+ return id;
250
344
  }
251
345
  return undefined;
252
346
  };
253
347
  // Once the wait is over, the oldest announced call named `tool` whose reported input differs from what reached MCP.
254
348
  // Never one named no tool with other arguments: its arguments are all that ties it, and they differ. Then the oldest
255
349
  // 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)
350
+ const loose = () => pick([...[...this.seen.keys()].filter((at) => at.startsWith(`${tool}\0`)), NOTHING], Infinity);
351
+ // Calls already torn on this key go first, in the order they came, unless this one's arguments are an announcement's own.
352
+ const queued = this.torn.get(key) ?? 0;
353
+ const now = queued && !this.seen.get(key)?.some((id) => this.keyOf.get(id)?.[0] === key) ? TORN : pick([...keys, NOTHING], 1);
354
+ if (typeof now === "string")
259
355
  return now;
356
+ const torn = now === TORN;
260
357
  return new Promise((resolve, reject) => {
261
- const lists = keys.map((key) => {
262
- const list = this.waiting.get(key) ?? [];
263
- this.waiting.set(key, list);
358
+ const lists = keys.map((at) => {
359
+ const list = this.waiting.get(at) ?? [];
360
+ this.waiting.set(at, list);
264
361
  return list;
265
362
  });
266
- const drop = () => {
363
+ const retry = () => {
364
+ const id = pick(keys, this.torn.get(key) ?? 0);
365
+ if (typeof id === "string")
366
+ done(id);
367
+ };
368
+ const leave = () => {
267
369
  for (const list of lists) {
268
370
  const at = list.indexOf(done);
269
371
  if (at >= 0)
270
372
  list.splice(at, 1);
271
373
  }
374
+ if (!this.retries.delete(retry))
375
+ return;
376
+ const left = (this.torn.get(key) ?? 1) - 1;
377
+ if (left > 0)
378
+ this.torn.set(key, left);
379
+ else
380
+ this.torn.delete(key);
272
381
  };
273
382
  const done = (id) => {
274
383
  clearTimeout(timer);
275
384
  signal.removeEventListener("abort", stop);
276
- drop();
385
+ leave();
277
386
  resolve(id);
278
387
  };
279
388
  const stop = () => {
280
389
  clearTimeout(timer);
281
- drop();
390
+ leave();
282
391
  reject(signal.reason instanceof Error ? signal.reason : new Error("the call was stopped"));
283
392
  };
284
393
  const timer = setTimeout(() => {
285
394
  signal.removeEventListener("abort", stop);
286
- drop();
287
- resolve(loose());
395
+ leave();
396
+ resolve((torn ? pick(keys, Infinity) : undefined) ?? loose());
288
397
  }, ms);
289
398
  signal.addEventListener("abort", stop, { once: true });
290
399
  for (const list of lists)
291
400
  list.push(done);
401
+ if (torn) {
402
+ this.torn.set(key, (this.torn.get(key) ?? 0) + 1);
403
+ this.retries.add(retry);
404
+ this.wake();
405
+ }
406
+ });
407
+ }
408
+ /** The MCP calls torn between announcements (take): how many wait under each key, and each one's retry. */
409
+ torn = new Map();
410
+ retries = new Set();
411
+ waking = false;
412
+ /** Each torn call tries again, once the current one is through: an announcement was taken, or another call is torn. */
413
+ wake() {
414
+ if (this.waking || this.retries.size === 0)
415
+ return;
416
+ this.waking = true;
417
+ queueMicrotask(() => {
418
+ this.waking = false;
419
+ for (const retry of [...this.retries])
420
+ retry();
292
421
  });
293
422
  }
294
423
  }
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, TOOL_NAME_CAP } 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";
@@ -167,6 +167,8 @@ export function acpHarness(options, control) {
167
167
  const plan = recipe.billing.kind === "plan" ? recipe.billing : undefined;
168
168
  const listed = options.tools.filter((tool) => !tool.deferred);
169
169
  const names = new Set(listed.map((tool) => tool.name));
170
+ /** For each tool, the recipe's announces.extras its own input schema declares: kept in its arguments (announceCall). */
171
+ const declared = new Map(listed.map((tool) => [tool.name, new Set((recipe.announces?.extras ?? []).filter((name) => declaresProperty(tool.inputSchema, name)))]));
170
172
  let runtime;
171
173
  /** The recipe's refusal `text` (the agent's stderr, an error it answered) says, as `<code>: <words>`; undefined when it
172
174
  * says none of them. */
@@ -263,10 +265,10 @@ export function acpHarness(options, control) {
263
265
  if (!cur)
264
266
  return;
265
267
  if (cur.turn)
266
- cur.turn.final = "";
268
+ cur.turn.final = cur.turn.kept = "";
267
269
  countCall(rt, cur, update.toolCallId);
268
270
  // 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);
271
+ announceCall(rt.calls, update, rt.announces, names, declared);
270
272
  logAnnounced(rt, update);
271
273
  return;
272
274
  }
@@ -275,12 +277,15 @@ export function acpHarness(options, control) {
275
277
  return;
276
278
  // A call the agent named only after announcing it with no input (Cursor's): by the recipe's field (nameCall).
277
279
  const held = rt.calls.held(update.toolCallId);
278
- nameCall(rt.calls, update, recipe.announces, names);
280
+ nameCall(rt.calls, update, rt.announces, names, declared);
279
281
  if (held && !rt.calls.held(update.toolCallId))
280
282
  logAnnounced(rt, update);
281
283
  // Its status is the agent's word only: what it changes is the mirror of the agent's session store.
282
284
  if (update.status !== "completed" && update.status !== "failed")
283
285
  return;
286
+ // What the agent wrote before the call ended is set aside: what it writes after is the answer.
287
+ if (cur.turn?.final.trim())
288
+ [cur.turn.kept, cur.turn.final] = [cur.turn.final, ""];
284
289
  // An ended call takes no MCP call's id (CallIds.settle).
285
290
  rt.calls.settle(update.toolCallId);
286
291
  mirrorInto(rt, cur.journal);
@@ -367,7 +372,7 @@ export function acpHarness(options, control) {
367
372
  // title never sets that: CallIds.announced comes from the field alone). Without the
368
373
  // quirk (Goose, which asks nothing for our tools: its allowFile) every request is the host gate's, journaled.
369
374
  if (recipe.quirks?.permissionTie === "title") {
370
- const mine = ourTool(request.toolCall, names);
375
+ const mine = ourTool(request.toolCall, names, rt.server);
371
376
  if (mine && rt.calls.announced(request.toolCall.toolCallId) === mine)
372
377
  return choose("allow_once");
373
378
  }
@@ -503,6 +508,13 @@ export function acpHarness(options, control) {
503
508
  }
504
509
  if (absent.length)
505
510
  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`);
511
+ // Under a start's own server name each of our tools is named longer: one past the agent's cap could never be called,
512
+ // so the start is refused before anything is made.
513
+ const serverName = mcpServerName(recipe.announces);
514
+ const prefix = announcesAt(recipe.announces, serverName)?.prefix ?? "";
515
+ const tooLong = joinsByOne(recipe.announces) ? namesTooLong(announcesAt(recipe.announces, serverName), names) : [];
516
+ if (tooLong.length)
517
+ throw new Error(`acp: ${recipe.label ?? recipe.id} 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}; ${tooLong.map((tool) => JSON.stringify(tool)).join(", ")} ${tooLong.length === 1 ? "is" : "are"} longer; the agent was not started`);
506
518
  mkdirSync(base, { recursive: true, mode: 0o700 });
507
519
  // Everything the agent kept goes: what it starts with is the session's records, never an earlier process's files.
508
520
  for (const dir of [home, tmp]) {
@@ -538,7 +550,7 @@ export function acpHarness(options, control) {
538
550
  const stopped = new AbortController();
539
551
  const signal = AbortSignal.any([ctx.signal, stopped.signal]);
540
552
  const key = randomBytes(32).toString("base64url");
541
- 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 })) };
553
+ 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 })) };
542
554
  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) });
543
555
  let proxy;
544
556
  let agent;
@@ -651,8 +663,8 @@ export function acpHarness(options, control) {
651
663
  }
652
664
  }
653
665
  const server = recipe.declares.mcp === "http"
654
- ? { type: "http", name: MCP_SERVER, url: mcp.url, headers: [{ name: "Authorization", value: `Bearer ${key}` }] }
655
- : { name: MCP_SERVER, command: process.execPath, args: [STDIO_BRIDGE], env: [{ name: "AGENTRUN_MCP_URL", value: mcp.url }, { name: "AGENTRUN_MCP_KEY", value: key }] };
666
+ ? { type: "http", name: rt.server, url: mcp.url, headers: [{ name: "Authorization", value: `Bearer ${key}` }] }
667
+ : { name: rt.server, command: process.execPath, args: [STDIO_BRIDGE], env: [{ name: "AGENTRUN_MCP_URL", value: mcp.url }, { name: "AGENTRUN_MCP_KEY", value: key }] };
656
668
  const instructions = options.instructions?.trim() ? options.instructions : undefined;
657
669
  const systemPrompt = instructions && caps.sessionCapabilities?.systemPrompt ? { mode: "append", content: [{ type: "text", text: instructions }] } : undefined;
658
670
  const last = journalRecords(ctx.state(), SESSION_STREAM).map((r) => r.data?.sessionId).filter((id) => typeof id === "string").at(-1);
@@ -805,7 +817,7 @@ export function acpHarness(options, control) {
805
817
  await journal.flush();
806
818
  const prompt = [...agent.firstBlocks.splice(0), ...body].map((text) => ({ type: "text", text }));
807
819
  let ended;
808
- const turn = { final: "", stop: new AbortController(), ended: new Promise((resolve) => (ended = resolve)) };
820
+ const turn = { final: "", kept: "", stop: new AbortController(), ended: new Promise((resolve) => (ended = resolve)) };
809
821
  cur.turn = turn;
810
822
  let answer;
811
823
  let failure;
@@ -873,8 +885,10 @@ export function acpHarness(options, control) {
873
885
  else
874
886
  outcome = { status: "failed", error: `acp: the agent ended the turn with an unknown stop reason ${JSON.stringify(reason)}` };
875
887
  }
876
- if (turn.final)
877
- journal.message({ type: "message", role: "assistant", text: turn.final });
888
+ // Only whitespace after the call (a trailing newline) is no answer of its own: the text before it is.
889
+ const lastText = turn.final.trim() ? turn.final : turn.kept;
890
+ if (lastText)
891
+ journal.message({ type: "message", role: "assistant", text: lastText });
878
892
  journal.message({ type: "turn", ...outcome });
879
893
  await journal.flush();
880
894
  return outcome;
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.59",
3
+ "version": "0.1.0-beta.61",
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.59",
52
+ "@parcha/agentrun-kernel": "0.1.0-beta.61",
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
+ }
@@ -10,8 +10,9 @@
10
10
  // (titles agentrun-<tool>: <tool>; MCP and execute ask, edits do not; a refused native call still reports
11
11
  // completed), or "goose-1.59" (as "goose", but titled as Goose 1.59.2 titles a call of an extension's tool:
12
12
  // `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);
13
+ // about it: named `mcp_<server>_<tool>`, titled `Run mcp_<server>_<tool>`, <server> the name the client gave
14
+ // its MCP server, its rawInput the call's arguments with agy's own `toolSummary` beside them, which the MCP
15
+ // call itself never carries, unless the arguments have a toolSummary of their own; options Allow and Deny);
15
16
  // titleSummary: with style "goose-1.59", the summary Goose 1.59.2 writes after such a title for a call whose
16
17
  // arguments it summarizes (a path): `agentrun: <tool> · <titleSummary>`;
17
18
  // (styles "goose" and "goose-1.59" read $HOME/.config/goose/permission.yaml at start, as Goose 1.59.2's permission
@@ -31,6 +32,8 @@
31
32
  // (a call step's `ask`, {kind, title}: what its permission request says instead of the call's own kind and title;)
32
33
  // (a native step's `lateInput`: a tool_call_update after its tool_call with that rawInput, a release that echoes the
33
34
  // model's arguments in a later update;)
35
+ // (a native step's `narrate`: text the agent writes after the call's tool_call and before it ends, as Cursor
36
+ // 2026.11.13 does;)
34
37
  // (styles "goose" and "goose-1.59": each tool_call names its tool in _meta.goose.toolCall.toolName, as Goose 1.59.2
35
38
  // does: `agentrun__<tool>` for ours, a native step's `toolName` or `developer__<kind>` for the agent's own;)
36
39
  // models: the models session/new and session/load list ({modelId, name}), the first current; session/set_model
@@ -125,7 +128,8 @@ const pgid = (() => {
125
128
  }
126
129
  })();
127
130
  said({ type: "start", env: Object.keys(process.env).sort(), home, cwd: process.cwd(), pgid, ...(config.cursorDirs ? { cursorDir, deniesWrite } : {}) });
128
- 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}`);
131
+ /** The title of a call of our `tool`, the client's MCP server given as `server` (agy names it in its title). */
132
+ 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}`);
129
133
  const late = style === "cursor" && config.announce !== "early";
130
134
  /** 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
131
135
  * builds (conversion.rs:65-91 at v1.59.2): `toolName` the name the model called, `extensionName` the part before `__`
@@ -253,7 +257,7 @@ async function openSession(id, params, history) {
253
257
  const servers = params.mcpServers ?? [];
254
258
  const server = servers.find((s) => s.name === "agentrun") ?? servers[0];
255
259
  const mcp = server ? await mcpClient(server) : undefined;
256
- const session = { id, history, mcp, turn: undefined, system: params.systemPrompt ? text(params.systemPrompt.content ?? []).join("\n") : undefined };
260
+ const session = { id, history, mcp, server: server?.name ?? "agentrun", turn: undefined, system: params.systemPrompt ? text(params.systemPrompt.content ?? []).join("\n") : undefined };
257
261
  sessions.set(id, session);
258
262
  return session;
259
263
  }
@@ -290,8 +294,9 @@ async function takeTurn(client, session, prompt, signal) {
290
294
  if ("call" in s) {
291
295
  const id = `call_${step - 1}`;
292
296
  const args = s.args ?? {};
297
+ const reported = "toolSummary" in args ? args : { ...args, toolSummary: `Call ${s.call}` };
293
298
  const update = style === "antigravity"
294
- ? { 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}` } }
299
+ ? { toolCallId: id, name: `mcp_${session.server}_${s.call}`, title: titleOf(s.call, session.server), kind: "other", status: "pending", rawInput: reported, args: reported }
295
300
  : { toolCallId: id, title: titleOf(s.call), kind: "other", status: "pending", rawInput: args };
296
301
  const entry = { kind: "call", id, tool: s.call, args, status: "pending" };
297
302
  session.history.push(entry);
@@ -351,6 +356,7 @@ async function takeTurn(client, session, prompt, signal) {
351
356
  // {announce: false}: a permission request for a call no tool_call announced.
352
357
  if (s.announce !== false) await notify({ sessionUpdate: "tool_call", ...update, ...gooseMeta(s.toolName ?? `developer__${s.native}`) });
353
358
  if (s.lateInput) await notify({ sessionUpdate: "tool_call_update", toolCallId: id, rawInput: s.lateInput });
359
+ if (s.narrate) await notify({ sessionUpdate: "agent_message_chunk", content: { type: "text", text: s.narrate } });
354
360
  const allowed = deniesWrite && EDITS.has(s.native) ? false : askNative.has(s.native) ? await permitted(client, session, update) : true;
355
361
  if (signal.aborted) return { stopReason: "cancelled" };
356
362
  if (allowed && config.nativeLog) appendFileSync(config.nativeLog, `${update.title}\n`);
@@ -448,7 +454,7 @@ const app = agent({ name: "fake-acp" })
448
454
  const session = await openSession(id, params, []);
449
455
  save(session);
450
456
  writeAuth();
451
- said({ type: "new", sessionId: id, mcp: params.mcpServers.map((s) => s.type ?? "stdio"), system: session.system });
457
+ said({ type: "new", sessionId: id, mcp: params.mcpServers.map((s) => s.type ?? "stdio"), names: params.mcpServers.map((s) => s.name), system: session.system });
452
458
  return { sessionId: id, ...(models ? { models } : {}) };
453
459
  })
454
460
  // Not in the SDK's stable methods: Cursor's own (unstable ACP) method, so its params are taken as they come.
@@ -469,7 +475,7 @@ const app = agent({ name: "fake-acp" })
469
475
  if (h.kind === "user") await client.notify("session/update", { sessionId: session.id, update: { sessionUpdate: "user_message_chunk", content: { type: "text", text: h.text } } });
470
476
  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 } } });
471
477
  if (h.kind === "call" || h.kind === "native") {
472
- 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 ?? {} } });
478
+ 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 ?? {} } });
473
479
  await client.notify("session/update", { sessionId: session.id, update: { sessionUpdate: "tool_call_update", toolCallId: h.id, status: h.status === "pending" ? "failed" : h.status } });
474
480
  }
475
481
  }