@agentproto/cli 0.6.0 → 0.8.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
@@ -98,6 +98,33 @@ declare function runServe(args: readonly string[]): Promise<number>;
98
98
  */
99
99
  declare function runAcp(args: readonly string[]): Promise<number>;
100
100
 
101
+ declare function runPackSkill(args: readonly string[]): Promise<number>;
102
+
103
+ /**
104
+ * Single shared `zip` implementation for a skill pack directory. Used by
105
+ * `claude-plugin.ts` (consumer-side install, `agentproto install skill/...`)
106
+ * and by a package's own release-time build script (producer-side, see
107
+ * `packages/skill-pack-<name>/scripts/build.mjs`) — one zip technique, not
108
+ * one per caller.
109
+ */
110
+ interface ZipPackResult {
111
+ zipped: boolean;
112
+ zipPath: string;
113
+ }
114
+ /**
115
+ * Best-effort zip of `dirToZip` into `<dirToZip>.zip` (or `zipPath` when
116
+ * given). The directory is the canonical artifact; the archive is a
117
+ * convenience — `zip` may be absent on minimal/Windows environments, so a
118
+ * failure to zip is reported via `zipped: false` rather than thrown.
119
+ *
120
+ * Runs `zip` with cwd set to `dirToZip`'s parent and zips its bare basename,
121
+ * so archive entries read as `<name>/...` — not the full absolute path a
122
+ * naive `zip -r <zipPath> <dirToZip>` would bake in when `dirToZip` is
123
+ * absolute (as every caller here passes it). Unzipping must not recreate
124
+ * the machine's own directory tree.
125
+ */
126
+ declare function zipPackDir(dirToZip: string, zipPath?: string): Promise<ZipPackResult>;
127
+
101
128
  /**
102
129
  * Resolve a slug like "claude-code" to a runnable `AgentCliHandle`.
103
130
  *
@@ -123,6 +150,13 @@ interface ResolvedAdapter {
123
150
  readonly handle: AgentCliHandle;
124
151
  readonly source: "npm" | "file" | "bundled" | "acp-config" | "acp-catalog";
125
152
  readonly packageName?: string;
153
+ /** True when this resolution was served from the last-known-good cache
154
+ * because the current import attempt failed (see `importFresh`'s doc
155
+ * comment for why that happens mid-rebuild). Never present on an
156
+ * actually-fresh successful resolution — callers that only care about
157
+ * spawning don't need to check it, callers that surface status
158
+ * (`listAdaptersWithCatalog`) must not report it as plain "ready". */
159
+ readonly stale?: true;
126
160
  }
127
161
  /** Mode metadata surfaced in `adapter_list` — the UI-safe subset of an
128
162
  * AIP-45 `modes[]` entry. Omits the spawn internals (`bin_args_*`, `env`)
@@ -163,13 +197,36 @@ interface AdapterInfo {
163
197
  * adapter manifest's `models.allowed` field. Empty when the adapter
164
198
  * doesn't declare a model list (accepts whatever the underlying
165
199
  * binary accepts). Pass one of these as `model` in `agent_start`
166
- * to avoid trial-and-error validation errors. */
200
+ * to avoid trial-and-error validation errors. Flat id list — kept
201
+ * exactly as before so every existing consumer of this field keeps
202
+ * working untouched; see `modelDetails` for the provider/mode a
203
+ * structured entry additionally states. */
167
204
  models: string[];
168
205
  /** AIP-45 `modes[]` the adapter declares, projected to the UI-safe
169
206
  * subset (id + description + honest status). Empty when the adapter
170
207
  * declares no modes. `status` defaults to "active" when the manifest
171
208
  * omits it, so a declared mode is never silently statusless. */
172
209
  modes: AdapterMode[];
210
+ /** Same models as `models`, in the same order, each carrying the
211
+ * `provider`/`mode` a structured `models.allowed` entry states.
212
+ * `provider`/`mode` are undefined for a bare-string entry — an
213
+ * unstated provider is never guessed here (see AdapterModelInfo). */
214
+ modelDetails: AdapterModelInfo[];
215
+ }
216
+ /** One entry of an adapter's declared model menu, projected from a
217
+ * `models.allowed` item — bare string or {@link AgentCliModelEntry}.
218
+ * `provider`/`mode` stay undefined for a bare-string entry: an unstated
219
+ * provider must never be guessed downstream (a wrong-but-confident
220
+ * guess would bill the wrong account). See AGENTS.md / AIP-45 for the
221
+ * three-facts-in-one-string problem this splits apart. */
222
+ interface AdapterModelInfo {
223
+ id: string;
224
+ /** Who serves/bills this model (a ProviderPreset id, or a direct
225
+ * provider like "anthropic"). Undefined when unstated. */
226
+ provider?: string;
227
+ /** This adapter's mode id that routes to `provider`. Undefined when
228
+ * the adapter routes on its own or needs no mode switch. */
229
+ mode?: string;
173
230
  }
174
231
  declare function resolveAdapter(slug: string): Promise<ResolvedAdapter>;
175
232
  /**
@@ -201,24 +258,43 @@ declare function listInstalledAdapters(opts?: {
201
258
  * with its runtime availability status:
202
259
  *
203
260
  * "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)
261
+ * "available" — package resolves; requiresSetup but no ledger yet, OR
262
+ * authRequired but no billing credential resolves
263
+ * "ready" — package resolves + setup complete (or no setup needed) AND
264
+ * (authRequired is false, or a credential DOES resolve)
206
265
  *
207
266
  * Also appends any adapters discovered in node_modules that aren't in the
208
267
  * catalog, so locally-installed custom adapters still appear.
209
268
  *
210
269
  * Status is derived via the kit's `computeStatus`: resolved × requiresSetup ×
211
- * ledger-exists — never via `handle.check()` (per OQ-5).
270
+ * ledger-exists × (authRequired × authConfigured) — never via `handle.check()`
271
+ * (per OQ-5). The auth axis is independent of `requiresSetup`: claude-code
272
+ * declares no `setup[]` at all (`requiresSetup` is always false for it) but
273
+ * `authEnforce:"always"` hard-fails every spawn without a billing credential
274
+ * — `authProbe` (wired to the runtime's `isAgentCliAuthConfigured`, which
275
+ * mirrors `resolveAuthSpec`'s exact precedence including the explicit-gate
276
+ * on the providers store, PR #321) is what makes that honest instead of the
277
+ * old `!requiresSetup` short-circuit reporting "ready" on zero credentials.
278
+ *
279
+ * A fourth status, `"unresolvable"`, sits outside that kit-owned vocabulary:
280
+ * when `resolveAdapter` falls back to its last-known-good cache (see there),
281
+ * the kit sees a normally-resolved handle and would compute "ready" — which
282
+ * would silently hide the fact that the CURRENT import attempt just failed.
283
+ * `resolved.stale` (threaded through `wrapCliHandle` → `AgentCliInfo`) is
284
+ * checked below and overrides whatever the kit computed, so a rebuilding
285
+ * adapter reads as neither "ready" (a lie — a spawn against a half-written
286
+ * dist would still fail) nor "supported" (equally wrong — it tells the
287
+ * operator to reinstall something that's already there).
212
288
  */
213
289
  declare function listAdaptersWithCatalog(catalog: readonly AdapterCatalogEntry[]): Promise<(AdapterInfo & {
214
- status: "supported" | "available" | "ready";
290
+ status: "supported" | "available" | "ready" | "unresolvable";
215
291
  hint?: string;
216
292
  })[]>;
217
293
  /** A single row of the merged adapter listing — npm/native catalog
218
294
  * entries and generic ACP entries share this shape (the latter also
219
295
  * carry a `source`). */
220
296
  type AdapterListing = AdapterInfo & {
221
- status: "supported" | "available" | "ready";
297
+ status: "supported" | "available" | "ready" | "unresolvable";
222
298
  hint?: string;
223
299
  source?: "acp-config" | "acp-catalog";
224
300
  };
@@ -329,4 +405,4 @@ declare function listAcpGenericAdapters(opts?: {
329
405
  excludeSlugs?: ReadonlySet<string>;
330
406
  }): Promise<AcpGenericListEntry[]>;
331
407
 
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 };
408
+ export { ACP_CATALOG, type AcpAgentSpec, type AcpGenericListEntry, type AcpSpecSource, type AdapterInfo, type AdapterListing, type ResolvedAdapter, type ZipPackResult, acpHandleFromSpec, binOnPath, listAcpGenericAdapters, listAdaptersWithAcp, listAdaptersWithCatalog, listInstalledAdapters, resolveAcpSpec, resolveAdapter, runAcp, runInstall, runPackSkill, runRun, runServe, zipPackDir };