@agentproto/cli 0.5.0 → 0.6.0

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/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { AgentCliMode, AgentCliHandle } from '@agentproto/driver-agent-cli';
2
+ import { AdapterCatalogEntry } from '@agentproto/provider-kit';
3
+ import { AcpAgentConfigEntry, AgentprotoConfig } from '@agentproto/runtime/config';
2
4
 
3
5
  /**
4
6
  * `agentproto install <slug>`
@@ -76,6 +78,26 @@ declare function runRun(args: readonly string[]): Promise<number>;
76
78
  */
77
79
  declare function runServe(args: readonly string[]): Promise<number>;
78
80
 
81
+ /**
82
+ * `agentproto acp <subcommand>`
83
+ *
84
+ * Manage generic ACP agents — any CLI that already speaks the Agent
85
+ * Client Protocol, connectable with zero adapter code (see
86
+ * ../registry/acp-generic.ts).
87
+ *
88
+ * Subcommands:
89
+ * ls curated catalog + config agents, with status
90
+ * add <slug> --bin <bin> [--args …] write a config.acpAgents entry
91
+ * [--name] [--desc] [--env]
92
+ * [--resumable]
93
+ * rm <slug> remove a config.acpAgents entry
94
+ *
95
+ * `ls` reflects both the built-in `ACP_CATALOG` and the user's
96
+ * `~/.agentproto/config.json` `acpAgents`; `add`/`rm` only ever touch the
97
+ * config file — the curated catalog is read-only.
98
+ */
99
+ declare function runAcp(args: readonly string[]): Promise<number>;
100
+
79
101
  /**
80
102
  * Resolve a slug like "claude-code" to a runnable `AgentCliHandle`.
81
103
  *
@@ -99,7 +121,7 @@ interface AgentCliCommand {
99
121
  interface ResolvedAdapter {
100
122
  readonly slug: string;
101
123
  readonly handle: AgentCliHandle;
102
- readonly source: "npm" | "file" | "bundled";
124
+ readonly source: "npm" | "file" | "bundled" | "acp-config" | "acp-catalog";
103
125
  readonly packageName?: string;
104
126
  }
105
127
  /** Mode metadata surfaced in `adapter_list` — the UI-safe subset of an
@@ -174,5 +196,137 @@ declare function listInstalledAdapters(opts?: {
174
196
  * package's own location until we hit a `node_modules/@agentproto`. */
175
197
  searchRoot?: string;
176
198
  }): Promise<AdapterInfo[]>;
199
+ /**
200
+ * Enumerate adapters starting from a static catalog and enriching each entry
201
+ * with its runtime availability status:
202
+ *
203
+ * "supported" — known to agentproto, package not importable (not installed)
204
+ * "available" — package resolves; requiresSetup but no ledger yet
205
+ * "ready" — package resolves + setup complete (or no setup needed)
206
+ *
207
+ * Also appends any adapters discovered in node_modules that aren't in the
208
+ * catalog, so locally-installed custom adapters still appear.
209
+ *
210
+ * Status is derived via the kit's `computeStatus`: resolved × requiresSetup ×
211
+ * ledger-exists — never via `handle.check()` (per OQ-5).
212
+ */
213
+ declare function listAdaptersWithCatalog(catalog: readonly AdapterCatalogEntry[]): Promise<(AdapterInfo & {
214
+ status: "supported" | "available" | "ready";
215
+ hint?: string;
216
+ })[]>;
217
+ /** A single row of the merged adapter listing — npm/native catalog
218
+ * entries and generic ACP entries share this shape (the latter also
219
+ * carry a `source`). */
220
+ type AdapterListing = AdapterInfo & {
221
+ status: "supported" | "available" | "ready";
222
+ hint?: string;
223
+ source?: "acp-config" | "acp-catalog";
224
+ };
225
+ /**
226
+ * The full adapter listing surfaced by `adapter_list` / `GET /adapters`:
227
+ * every npm/native catalog adapter PLUS the generic ACP agents (curated
228
+ * `ACP_CATALOG` + user `config.acpAgents`). Generic entries whose slug is
229
+ * already covered by a native adapter are dropped, so a slug never appears
230
+ * twice. Native adapters keep their richer status (`ready` after setup);
231
+ * generic entries are `available` (bin on PATH) or `supported` (not yet).
232
+ */
233
+ declare function listAdaptersWithAcp(catalog: readonly AdapterCatalogEntry[]): Promise<AdapterListing[]>;
234
+
235
+ /**
236
+ * Generic ACP agents — connect any ACP-speaking CLI with zero adapter code.
237
+ *
238
+ * Our ACP protocol arm (`createAcpProtocolArm`) is fully adapter-agnostic:
239
+ * it performs the standard `initialize` / `session/new` handshake over stdio
240
+ * JSON-RPC and streams turns, regardless of which binary is on the other end.
241
+ * So any CLI that already speaks the Agent Client Protocol doesn't need a
242
+ * bespoke `@agentproto/adapter-*` package — it just needs a spawn recipe.
243
+ *
244
+ * `acpHandleFromSpec` mints a runnable `AgentCliHandle` from a plain
245
+ * `AcpAgentSpec` (bin + args + env + a few flags). Two sources feed it:
246
+ * - `ACP_CATALOG` — a conservative, curated list of known ACP CLIs.
247
+ * - `config.acpAgents` — user-defined entries in `~/.agentproto/config.json`.
248
+ * User entries shadow the catalog on slug collision.
249
+ *
250
+ * `resolveAdapter` (see ./resolve.ts) tries npm first, then these; so a real
251
+ * adapter package always wins over a generic spec of the same slug.
252
+ */
253
+
254
+ /**
255
+ * A generic ACP agent's spawn recipe. The config-file form
256
+ * (`AcpAgentConfigEntry`, keyed by slug in `acpAgents`) plus the slug
257
+ * itself. Kept in sync with the runtime config type by extension so the
258
+ * two never drift.
259
+ */
260
+ interface AcpAgentSpec extends AcpAgentConfigEntry {
261
+ /** Adapter slug, e.g. "gemini-cli". Lower-kebab, ≥3 chars (AIP-45 id). */
262
+ slug: string;
263
+ }
264
+ /** Distinguishes where a resolved generic handle came from. */
265
+ type AcpSpecSource = "acp-config" | "acp-catalog";
266
+ /**
267
+ * Mint a runnable `AgentCliHandle` from a plain spec by routing every
268
+ * field through `defineAgentCli` with `protocol: "acp"`. The result is a
269
+ * fully-validated AIP-45 handle — schema-identical to a hand-authored
270
+ * native ACP adapter, just without the npm package.
271
+ *
272
+ * The AIP-45 schema requires `install` / `version_check` / `sandbox`
273
+ * even though a generic agent is bring-your-own-binary: we synthesize
274
+ * truthful, minimal values (a `vendored` install pointing at the bin so
275
+ * `agentproto install` correctly treats it as pre-provided, a
276
+ * conventional `<bin> --version` check, and the shared GENERIC.ACP.md as
277
+ * both the `acp` wire ref and the `sandbox` ref). This keeps the existing
278
+ * schema unchanged — no fighting it.
279
+ */
280
+ declare function acpHandleFromSpec(spec: AcpAgentSpec): AgentCliHandle;
281
+ /**
282
+ * Curated catalog of known, publicly-documented ACP-speaking CLIs that do
283
+ * NOT ship a native `@agentproto/adapter-*` package. Conservative on
284
+ * purpose: every entry's ACP invocation is drawn from the agent's own
285
+ * public docs — no invented flags. Agents that already have a native
286
+ * adapter in `CATALOG` (claude-code, opencode, codex, hermes, …) are
287
+ * excluded; a native adapter always wins in `resolveAdapter` anyway.
288
+ *
289
+ * The `--experimental-acp` flag family below is the well-documented ACP
290
+ * entry point popularised by Gemini CLI and reused verbatim by its
291
+ * public forks.
292
+ */
293
+ declare const ACP_CATALOG: readonly AcpAgentSpec[];
294
+ /**
295
+ * Resolve a slug to a generic ACP spec: user config first (shadowing),
296
+ * then the curated catalog. Returns the matched spec + its source, or
297
+ * `null` when neither has the slug. Pass `config` to avoid a disk read
298
+ * (e.g. when the caller already loaded it); otherwise it's read lazily.
299
+ */
300
+ declare function resolveAcpSpec(slug: string, config?: AgentprotoConfig): Promise<{
301
+ spec: AcpAgentSpec;
302
+ source: AcpSpecSource;
303
+ } | null>;
304
+ /**
305
+ * Is `bin` runnable — a path that exists+executable, or a bare name found
306
+ * on PATH? Used to classify generic ACP agents in the listing:
307
+ * `available` when present, `supported` (install_hint) when not.
308
+ */
309
+ declare function binOnPath(bin: string): Promise<boolean>;
310
+ /** A generic ACP entry as surfaced in the adapter listing — the same
311
+ * UI-safe shape as `listAdaptersWithCatalog` entries, plus provenance. */
312
+ type AcpGenericListEntry = AdapterInfo & {
313
+ status: "supported" | "available";
314
+ hint?: string;
315
+ source: AcpSpecSource;
316
+ };
317
+ /**
318
+ * List the generic ACP agents (curated catalog + user config, config
319
+ * shadowing catalog) with a runtime `status` derived from bin presence:
320
+ * `available` when the bin is on PATH, `supported` (not installed, shows
321
+ * `install_hint`) otherwise. Config-defined agents are always listed.
322
+ *
323
+ * `excludeSlugs` drops entries already covered by an npm adapter /
324
+ * native catalog entry, so a generic spec never double-appears next to a
325
+ * real adapter of the same slug in the merged `adapter_list`.
326
+ */
327
+ declare function listAcpGenericAdapters(opts?: {
328
+ config?: AgentprotoConfig;
329
+ excludeSlugs?: ReadonlySet<string>;
330
+ }): Promise<AcpGenericListEntry[]>;
177
331
 
178
- export { type AdapterInfo, type ResolvedAdapter, listInstalledAdapters, resolveAdapter, runInstall, runRun, runServe };
332
+ export { ACP_CATALOG, type AcpAgentSpec, type AcpGenericListEntry, type AcpSpecSource, type AdapterInfo, type AdapterListing, type ResolvedAdapter, acpHandleFromSpec, binOnPath, listAcpGenericAdapters, listAdaptersWithAcp, listAdaptersWithCatalog, listInstalledAdapters, resolveAcpSpec, resolveAdapter, runAcp, runInstall, runRun, runServe };