@agentproto/cli 0.1.0-alpha.0 → 0.1.0-alpha.10

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
@@ -11,9 +11,19 @@ import { AgentCliHandle } from '@agentproto/driver-agent-cli';
11
11
  * it before reading its manifest). Bootstrapping the adapter package is
12
12
  * a separate concern — `npm i -g @agentproto/adapter-<slug>` first.
13
13
  *
14
- * v0 implements `npm` only. Other methods (brew/pip/cargo/go/curl/
15
- * download) report a clear "not yet implemented" message — they're a
16
- * shellout exercise but each needs its own checksum / chmod handling.
14
+ * Method support matrix:
15
+ * - `npm` ✓
16
+ * - `brew` ✓ (macOS / Linux Homebrew)
17
+ * - `curl` ✓ (with optional verify_sha256)
18
+ * - `download` ✓ (tarball/zip + extract_bin + optional verify_sha256)
19
+ * - `pip` ✓ (with optional `user: true`)
20
+ * - `cargo` ✓
21
+ * - `go` ✓
22
+ * - `apt/dnf/pacman` ✗ (privilege escalation needs explicit sudo policy)
23
+ * - `choco/scoop` ✗ (Windows-only; not yet platform-detected)
24
+ * - `vendored` ✗ (workspace-relative; needs a workspace root)
25
+ *
26
+ * After install, runs the optional `setup[]` pipeline (AIP-29 § Setup).
17
27
  */
18
28
  declare function runInstall(args: readonly string[]): Promise<number>;
19
29
 
@@ -30,20 +40,39 @@ declare function runInstall(args: readonly string[]): Promise<number>;
30
40
  declare function runRun(args: readonly string[]): Promise<number>;
31
41
 
32
42
  /**
33
- * `agentproto serve --connect <url>`
34
- *
35
- * Long-running daemon. Opens a WebSocket to a host (Guilde-shaped API),
36
- * authenticates with a token, then accepts spawn / stdin / stdout /
37
- * stderr / kill / exit frames over that channel — multiplexing many
38
- * ACP sessions through one process. The daemon owns local resources
39
- * (PTYs, child processes, JSONL session stores) so a host running in
40
- * the cloud can drive a CLI living on the user's laptop.
41
- *
42
- * v0.1 stub: argument parsing + connection scaffolding only. The wire
43
- * protocol is still being designed (tunnel frames need to land in
44
- * @agentproto/acp first); shipping a half-baked daemon would lock us
45
- * into the wrong shape. For now this verb prints a clear "not yet"
46
- * and exits non-zero so CI pipelines don't accidentally rely on it.
43
+ * `agentproto serve [--workspace <dir>] [--port <n>] [--connect <wss>]`
44
+ *
45
+ * The single canonical agentproto daemon. Boots a local gateway
46
+ * (HTTP + MCP server + sessions registry + workspace fs +
47
+ * heartbeat) on `--port` (default 18790), and OPTIONALLY opens an
48
+ * outbound WebSocket tunnel to a host (Guilde-shaped API) when
49
+ * `--connect <url>` is set. With or without the tunnel:
50
+ *
51
+ * - HTTP /sessions, /sessions/agent, /sessions/:id/* routes work
52
+ * - MCP tools (start_agent_session, prompt_agent_session, …) are
53
+ * reachable via the daemon's /mcp transport
54
+ * - the LocalDaemonSessionsCard in guilde-web sees every spawn
55
+ *
56
+ * When the tunnel is up, every tunnel-driven spawn is also adopted
57
+ * into the gateway's sessions registry via the
58
+ * `createTunnelServer.onChildSpawned` hook, so an operator
59
+ * dispatching from the cloud lands in the same /sessions list as a
60
+ * user spawning locally — single source of truth for what's running
61
+ * on the user's machine.
62
+ *
63
+ * Replaces the old `playground/scripts/gateway.ts` for production
64
+ * use (the playground keeps its own script for the MCP CRUD
65
+ * doctype demo). v1 reuses createGateway with empty specs + a
66
+ * noop heartbeat; the playground variant adds toolSpec/agentSpec/
67
+ * etc. for its specific spec-authoring use case.
68
+ *
69
+ * Reconnect-with-backoff is built in for the tunnel. The local
70
+ * gateway stays up across reconnects — only the tunnel cycles.
71
+ *
72
+ * Authorization: v0 trusts every spawn frame the host sends — there
73
+ * is no policy file. Future work will gate spawn requests on a
74
+ * `~/.agentproto/policy.toml` allowlist (see project_agentproto_repos
75
+ * memory). The token is the only access control today.
47
76
  */
48
77
  declare function runServe(args: readonly string[]): Promise<number>;
49
78
 
@@ -68,6 +97,52 @@ interface ResolvedAdapter {
68
97
  readonly source: "npm" | "file" | "bundled";
69
98
  readonly packageName?: string;
70
99
  }
100
+ /**
101
+ * Compact metadata about an installed adapter — the shape returned
102
+ * by `listInstalledAdapters()` and exposed via the daemon's
103
+ * `GET /adapters` route + `list_adapters` MCP tool. Only fields
104
+ * safe to surface in a UI list (no install scripts, no env keys).
105
+ * For full handle access call `resolveAdapter(slug)`.
106
+ */
107
+ interface AdapterInfo {
108
+ slug: string;
109
+ /** Display name from the manifest. */
110
+ name: string;
111
+ /** Adapter package version (matches npm package.json `version`). */
112
+ version: string;
113
+ /** One-line user-facing description. */
114
+ description: string;
115
+ /** Wire protocol — informs prompt/multi-turn semantics. */
116
+ protocol: string;
117
+ /** True when the adapter advertises a streaming session contract. */
118
+ streaming: boolean;
119
+ /** npm package name (for install hints / "open in npmjs.com" links). */
120
+ packageName: string;
121
+ }
71
122
  declare function resolveAdapter(slug: string): Promise<ResolvedAdapter>;
123
+ /**
124
+ * Enumerate every `@agentproto/adapter-*` package reachable from the
125
+ * current node module-resolution path. Used by the daemon's
126
+ * `GET /adapters` route and `list_adapters` MCP tool so UIs (web
127
+ * spawn dialog) and operators can pick from the installed set
128
+ * without trial-and-error against `resolveAdapter(slug)`.
129
+ *
130
+ * Implementation: walk `node_modules/@agentproto` looking for
131
+ * `adapter-*` directories; for each, dynamic-import the package +
132
+ * extract the AgentCliHandle's display fields. Failures (broken
133
+ * exports, missing dist) are collected as warnings rather than
134
+ * thrown — partial discovery beats failing the whole listing on
135
+ * one bad adapter.
136
+ *
137
+ * Discovery is async + reads disk on every call; cache at the
138
+ * caller layer if you list often. v0 does no caching here because
139
+ * adapter sets typically change rarely (npm i / rm) and a fresh
140
+ * scan stays fast (~10 packages worth of dynamic imports).
141
+ */
142
+ declare function listInstalledAdapters(opts?: {
143
+ /** Override the search root. Defaults to walking up from the cli
144
+ * package's own location until we hit a `node_modules/@agentproto`. */
145
+ searchRoot?: string;
146
+ }): Promise<AdapterInfo[]>;
72
147
 
73
- export { type ResolvedAdapter, resolveAdapter, runInstall, runRun, runServe };
148
+ export { type AdapterInfo, type ResolvedAdapter, listInstalledAdapters, resolveAdapter, runInstall, runRun, runServe };