|
| 1 | +/** |
| 2 | + * amplifier-agent-client-ts — public entry point. |
| 3 | + * |
| 4 | + * Exports the locked public API from design §8.2, narrowed to Mode A v2 |
| 5 | + * (amendment §5). `spawnAgent` is synchronous-in-spirit: it validates |
| 6 | + * parameters, resolves the engine binary path, builds the subprocess |
| 7 | + * environment, and constructs a `SessionHandle`. **No subprocess is spawned |
| 8 | + * at spawn-time** — the engine is launched per `submit()` (amendment §5.2). |
| 9 | + */ |
| 10 | +export { AaaError, SessionHandle } from "./session.js"; |
| 11 | +export type { DisplayEvent, EngineInfo, SessionHandleParams, } from "./session.js"; |
| 12 | +export type { ApprovalResponse } from "./approval.js"; |
| 13 | +export type { EngineVersionPayload } from "./spawn.js"; |
| 14 | +import { SessionHandle } from "./session.js"; |
| 15 | +import type { DisplayEvent } from "./session.js"; |
| 16 | +import type { ApprovalResponse } from "./approval.js"; |
| 17 | +import type { McpServerConfig, HostCapabilities } from "./types.js"; |
| 18 | +export type { McpServerConfig, HostCapabilities } from "./types.js"; |
| 19 | +/** |
| 20 | + * The protocol version that this TypeScript wrapper requires. |
| 21 | + * Forwarded to the engine via `--protocol-version` on every `submit()`. |
| 22 | + */ |
| 23 | +export declare const PROTOCOL_VERSION_REQUIRED_BY_WRAPPER = "0.1.0"; |
| 24 | +/** Parameters for spawnAgent(). Signature is locked verbatim by design §8.2. */ |
| 25 | +export interface SpawnAgentParams { |
| 26 | + /** 'burst' reserved; throws AaaError(lifecycle_unsupported) at runtime. */ |
| 27 | + lifecycle: "one-shot"; |
| 28 | + sessionId: string; |
| 29 | + resume?: boolean; |
| 30 | + cwd?: string; |
| 31 | + env?: { |
| 32 | + allowlist: string[]; |
| 33 | + extra?: Record<string, string>; |
| 34 | + }; |
| 35 | + providerOverride?: string; |
| 36 | + /** |
| 37 | + * Mid-turn approval callback. |
| 38 | + * |
| 39 | + * **NOT SUPPORTED IN v1.** Passing a non-null `onRequest` throws |
| 40 | + * `AaaError(approval_not_supported_in_v1)` at spawnAgent() time. The v1 wire |
| 41 | + * is Mode A (per-turn subprocess); there is no mid-turn host channel. |
| 42 | + */ |
| 43 | + approval?: { |
| 44 | + onRequest: (req: unknown) => Promise<ApprovalResponse>; |
| 45 | + timeoutMs: number; |
| 46 | + }; |
| 47 | + display?: { |
| 48 | + onEvent?: (event: DisplayEvent) => void; |
| 49 | + subagentEvents?: "all" | "none"; |
| 50 | + }; |
| 51 | + /** Default false; opt out of D6 strict-refuse version check. */ |
| 52 | + allowProtocolSkew?: boolean; |
| 53 | + /** Optional MCP servers to forward via `--mcp-servers` (A1). */ |
| 54 | + mcpServers?: Record<string, McpServerConfig>; |
| 55 | + /** Optional host envelope forwarded via `--host-capabilities` (A1). */ |
| 56 | + host?: { |
| 57 | + capabilities?: HostCapabilities; |
| 58 | + }; |
| 59 | + /** Per-submit timeout in ms (default: 10 minutes). */ |
| 60 | + timeoutMs?: number; |
| 61 | + /** Replaces the real resolveBinaryPath() call. */ |
| 62 | + _binaryResolver?: () => string; |
| 63 | +} |
| 64 | +/** |
| 65 | + * Compose all internal components into the single public entry point. |
| 66 | + * |
| 67 | + * Mode A v2 flow (amendment §5): |
| 68 | + * 1. Guard: lifecycle must be 'one-shot' (D10). |
| 69 | + * 2. Reject `approval.onRequest !== undefined` (SC-C — v1 has no mid-turn channel). |
| 70 | + * 3. Resolve engine binary path (or inject via `_binaryResolver`). |
| 71 | + * 4. Build subprocess environment via `buildEnv`. |
| 72 | + * 5. Return `new SessionHandle(params)` — **NO subprocess is spawned here**. |
| 73 | + * |
| 74 | + * The engine is launched per `submit()` (amendment §5.2). `agent/initialize` |
| 75 | + * is gone; protocol-version handshake moves to argv at submit-time. Engine |
| 76 | + * metadata (`engineVersion`, `bundleDigest`) is populated lazily once the |
| 77 | + * first envelope arrives (TODO: Task-9 wires this from `parseRunOutput`). |
| 78 | + */ |
| 79 | +export declare function spawnAgent(params: SpawnAgentParams): Promise<SessionHandle>; |
0 commit comments