amplifier-agent-ts 0.3.1 → 0.5.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.
@@ -14,7 +14,7 @@ export interface AssembleArgvInput {
14
14
  sessionId: string;
15
15
  /** Final user prompt — emitted last as a positional argument. */
16
16
  prompt: string;
17
- /** Protocol version the wrapper speaks (e.g. "0.1.0"). */
17
+ /** Protocol version the wrapper speaks (e.g. "0.2.0"). */
18
18
  protocolVersion: string;
19
19
  /** When true, emit `--resume` instead of `--fresh`. */
20
20
  resume?: boolean;
@@ -22,25 +22,22 @@ export interface AssembleArgvInput {
22
22
  cwd?: string;
23
23
  /** Provider override; emits `--provider <providerOverride>`. */
24
24
  providerOverride?: string;
25
- /**
26
- * Pre-resolved value for `--mcp-servers`. Caller decides whether this is
27
- * inline JSON or an `@/path/to/file.json` spill reference; argv-builder
28
- * threads it through unchanged.
29
- */
30
- mcpServersFlag?: string;
31
- /** Host capabilities object — emitted as `--host-capabilities <JSON>`. */
32
- hostCapabilities?: unknown;
33
- /** Allowlisted env variable names — emits `--env-allowlist <comma-joined>`. */
34
- envAllowlist?: string[];
35
- /** Extra env entries — emitted as `--env-extra <JSON>`. */
36
- envExtra?: Record<string, string>;
37
- /** When true, emit `--allow-protocol-skew`. */
38
- allowProtocolSkew?: boolean;
39
25
  }
40
26
  /**
41
27
  * Build the argv array for `amplifier-agent run`.
42
28
  *
43
29
  * Pure function: no I/O, no env reads, no globals. Order is canonical and
44
30
  * stable so wrapper integration tests can pin against it.
31
+ *
32
+ * Removed argv flags (no longer emitted by this wrapper):
33
+ * - `--mcp-config-path` (engine PR #29): MCP config is now forwarded via the
34
+ * `AMPLIFIER_MCP_CONFIG` env var injected into the engine's subprocess
35
+ * environment at spawn time (or via `host_config["mcp"]["configPath"]` in
36
+ * the host's config file).
37
+ * - `--env-allowlist`, `--env-extra` (engine PR #27): env composition is
38
+ * the host's responsibility. Hosts either set `$AMPLIFIER_AGENT_CONFIG`
39
+ * in the subprocess env or pass `--config <path>` per turn.
40
+ * - `--allow-protocol-skew` (engine PR #27): the unsafe override moved to
41
+ * `host_config.allowProtocolSkew: true` in the JSON config file.
45
42
  */
46
43
  export declare function assembleArgv(input: AssembleArgvInput): string[];
@@ -14,6 +14,17 @@
14
14
  *
15
15
  * Pure function: no I/O, no env reads, no globals. Order is canonical and
16
16
  * stable so wrapper integration tests can pin against it.
17
+ *
18
+ * Removed argv flags (no longer emitted by this wrapper):
19
+ * - `--mcp-config-path` (engine PR #29): MCP config is now forwarded via the
20
+ * `AMPLIFIER_MCP_CONFIG` env var injected into the engine's subprocess
21
+ * environment at spawn time (or via `host_config["mcp"]["configPath"]` in
22
+ * the host's config file).
23
+ * - `--env-allowlist`, `--env-extra` (engine PR #27): env composition is
24
+ * the host's responsibility. Hosts either set `$AMPLIFIER_AGENT_CONFIG`
25
+ * in the subprocess env or pass `--config <path>` per turn.
26
+ * - `--allow-protocol-skew` (engine PR #27): the unsafe override moved to
27
+ * `host_config.allowProtocolSkew: true` in the JSON config file.
17
28
  */
18
29
  export function assembleArgv(input) {
19
30
  const argv = [];
@@ -26,23 +37,8 @@ export function assembleArgv(input) {
26
37
  if (input.providerOverride !== undefined) {
27
38
  argv.push("--provider", input.providerOverride);
28
39
  }
29
- if (input.mcpServersFlag !== undefined) {
30
- argv.push("--mcp-servers", input.mcpServersFlag);
31
- }
32
- if (input.hostCapabilities !== undefined) {
33
- argv.push("--host-capabilities", JSON.stringify(input.hostCapabilities));
34
- }
35
- if (input.envAllowlist !== undefined && input.envAllowlist.length > 0) {
36
- argv.push("--env-allowlist", input.envAllowlist.join(","));
37
- }
38
- if (input.envExtra !== undefined) {
39
- argv.push("--env-extra", JSON.stringify(input.envExtra));
40
- }
41
40
  argv.push("--output", "json");
42
41
  argv.push("--protocol-version", input.protocolVersion);
43
- if (input.allowProtocolSkew === true) {
44
- argv.push("--allow-protocol-skew");
45
- }
46
42
  // SC-C: wrapper enforces auto-allow at the bundle layer.
47
43
  argv.push("-y");
48
44
  // Prompt is the final positional argument.
package/dist/index.d.ts CHANGED
@@ -14,13 +14,13 @@ export type { EngineVersionPayload } from "./spawn.js";
14
14
  import { SessionHandle } from "./session.js";
15
15
  import type { DisplayEvent } from "./session.js";
16
16
  import type { ApprovalResponse } from "./approval.js";
17
- import type { McpServerConfig, HostCapabilities } from "./types.js";
18
- export type { McpServerConfig, HostCapabilities } from "./types.js";
17
+ import type { McpServerConfig } from "./types.js";
18
+ export type { McpServerConfig } from "./types.js";
19
19
  /**
20
20
  * The protocol version that this TypeScript wrapper requires.
21
21
  * Forwarded to the engine via `--protocol-version` on every `submit()`.
22
22
  */
23
- export declare const PROTOCOL_VERSION_REQUIRED_BY_WRAPPER = "0.1.0";
23
+ export declare const PROTOCOL_VERSION_REQUIRED_BY_WRAPPER = "0.2.0";
24
24
  /** Parameters for spawnAgent(). Signature is locked verbatim by design §8.2. */
25
25
  export interface SpawnAgentParams {
26
26
  /** 'burst' reserved; throws AaaError(lifecycle_unsupported) at runtime. */
@@ -48,14 +48,14 @@ export interface SpawnAgentParams {
48
48
  onEvent?: (event: DisplayEvent) => void;
49
49
  subagentEvents?: "all" | "none";
50
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). */
51
+ /**
52
+ * Optional MCP servers. Spilled to a 0600 tmpfile per submit and forwarded
53
+ * to the engine via the `AMPLIFIER_MCP_CONFIG` env var injected into the
54
+ * subprocess environment. The former `--mcp-config-path` argv flag was
55
+ * removed; `tool-mcp` reads the env var natively via its config-discovery
56
+ * priority chain.
57
+ */
54
58
  mcpServers?: Record<string, McpServerConfig>;
55
- /** Optional host envelope forwarded via `--host-capabilities` (A1). */
56
- host?: {
57
- capabilities?: HostCapabilities;
58
- };
59
59
  /** Per-submit timeout in ms (default: 10 minutes). */
60
60
  timeoutMs?: number;
61
61
  /** Replaces the real resolveBinaryPath() call. */
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ import { resolveBinaryPath, buildEnv, DEFAULT_ALLOWLIST } from "./spawn.js";
16
16
  * The protocol version that this TypeScript wrapper requires.
17
17
  * Forwarded to the engine via `--protocol-version` on every `submit()`.
18
18
  */
19
- export const PROTOCOL_VERSION_REQUIRED_BY_WRAPPER = "0.1.0";
19
+ export const PROTOCOL_VERSION_REQUIRED_BY_WRAPPER = "0.2.0";
20
20
  // ---------------------------------------------------------------------------
21
21
  // spawnAgent() — locked public entry point (Mode A v2)
22
22
  // ---------------------------------------------------------------------------
@@ -77,10 +77,9 @@ export async function spawnAgent(params) {
77
77
  extra,
78
78
  });
79
79
  // 4. Return a SessionHandle. NO subprocess spawned here — the engine is
80
- // launched per submit() (amendment §5.2). NOTE: `version.ts` /
81
- // `checkProtocolVersion` are unused in Mode A v2 (skew is enforced via
82
- // argv `--protocol-version` + `--allow-protocol-skew` at the engine
83
- // side); flagged for Task-9 cleanup.
80
+ // launched per submit() (amendment §5.2). Skew override now lives in
81
+ // `host_config.allowProtocolSkew: true` in the host config file (engine
82
+ // PR #27); the wrapper no longer forwards an argv flag for it.
84
83
  return new SessionHandle({
85
84
  binaryPath,
86
85
  sessionId: params.sessionId,
@@ -88,17 +87,9 @@ export async function spawnAgent(params) {
88
87
  ...(params.resume !== undefined ? { resume: params.resume } : {}),
89
88
  ...(params.cwd !== undefined ? { cwd: params.cwd } : {}),
90
89
  ...(params.mcpServers !== undefined ? { mcpServers: params.mcpServers } : {}),
91
- ...(params.host?.capabilities !== undefined
92
- ? { hostCapabilities: params.host.capabilities }
93
- : {}),
94
- envAllowlist: allowlist,
95
- envExtra: extra,
96
90
  ...(params.providerOverride !== undefined
97
91
  ? { providerOverride: params.providerOverride }
98
92
  : {}),
99
- ...(params.allowProtocolSkew !== undefined
100
- ? { allowProtocolSkew: params.allowProtocolSkew }
101
- : {}),
102
93
  protocolVersion: PROTOCOL_VERSION_REQUIRED_BY_WRAPPER,
103
94
  ...(params.timeoutMs !== undefined ? { timeoutMs: params.timeoutMs } : {}),
104
95
  });
@@ -1,40 +1,42 @@
1
1
  /**
2
- * Result of resolving the `--mcp-servers` flag value.
2
+ * Result of spilling the MCP servers map to a tmpfile.
3
3
  *
4
- * - When `mcpServers` is null/undefined/empty: both fields are `null`.
5
- * - When no server has a non-empty env block: `flag` is inline JSON,
6
- * `spillPath` is `null` (no cleanup needed).
7
- * - When any server has a non-empty env block: `flag` is `@<spillPath>`,
8
- * `spillPath` points at the 0600 tmpfile (caller must cleanup).
4
+ * - When `mcpServers` is null/undefined/empty: `configPath` is `null`.
5
+ * - When servers are present: `configPath` points at the 0600 spill file.
6
+ * The file contains `{"mcpServers": <map>}` in the format that
7
+ * amplifier-module-tool-mcp expects when reading `AMPLIFIER_MCP_CONFIG`.
8
+ * The caller injects the path into the engine's subprocess environment
9
+ * as `AMPLIFIER_MCP_CONFIG`.
9
10
  */
10
11
  export interface McpSpillResult {
11
- flag: string | null;
12
- spillPath: string | null;
12
+ configPath: string | null;
13
13
  }
14
14
  /**
15
- * Loose shape for an MCP server entry. We only inspect `env` here; the rest
16
- * is threaded through untouched into the spilled JSON or inline payload.
15
+ * Loose shape for an MCP server entry. The full map is written verbatim
16
+ * into the spill file; no field is inspected beyond presence of the key.
17
17
  */
18
18
  interface McpServerLike {
19
- env?: Record<string, string> | undefined;
20
19
  [k: string]: unknown;
21
20
  }
22
21
  type McpServersMap = Record<string, McpServerLike>;
23
22
  /**
24
- * Resolve the value to pass for `--mcp-servers`.
23
+ * Resolve the MCP config file path to pass as `--mcp-config-path`.
24
+ *
25
+ * Always spills to a 0600 tmpfile. The file content wraps the server map
26
+ * in the top-level `mcpServers` key that amplifier-module-tool-mcp expects.
25
27
  *
26
28
  * @param mcpServers Map of server-id -> config, or null/undefined.
27
29
  * @param sessionId Session identifier; used as the per-session subdirectory
28
30
  * under the spill base so concurrent sessions never clash.
29
31
  *
30
- * @returns A `McpSpillResult` with the flag value and (if spilled) the
31
- * on-disk path for later cleanup.
32
+ * @returns A `McpSpillResult` with the on-disk config path (or null if there
33
+ * are no servers to spill).
32
34
  */
33
- export declare function resolveMcpServersFlag(mcpServers: McpServersMap | null | undefined, sessionId: string): Promise<McpSpillResult>;
35
+ export declare function resolveMcpConfigPath(mcpServers: McpServersMap | null | undefined, sessionId: string): Promise<McpSpillResult>;
34
36
  /**
35
37
  * Idempotently remove a spill file. Safe to call with `null` (no-op) and
36
38
  * safe to call when the file is already gone (ENOENT swallowed). Other
37
39
  * I/O errors propagate.
38
40
  */
39
- export declare function cleanupSpillFile(spillPath: string | null | undefined): Promise<void>;
41
+ export declare function cleanupSpillFile(configPath: string | null | undefined): Promise<void>;
40
42
  export {};
package/dist/mcp-spill.js CHANGED
@@ -1,12 +1,14 @@
1
1
  /**
2
- * mcp-spill.ts — secret-aware MCP servers config resolution (CR-A).
2
+ * mcp-spill.ts — MCP servers config path resolution (CR-A, protocol 0.2.0).
3
3
  *
4
- * A3'/CR-A: When forwarding `--mcp-servers` to the engine binary, the wrapper
5
- * must avoid placing secret-bearing env blocks on the command line. If any
6
- * server in the config has a non-empty `env` block, the full JSON is spilled
7
- * to a 0600 tmpfile under `${XDG_RUNTIME_DIR || os.tmpdir()}/amplifier-agent/<sessionId>/`
8
- * and the flag value is `@<path>`. When no server has env, the JSON is inlined
9
- * directly (no spill, no cleanup needed).
4
+ * The wrapper always spills the MCP server map to a 0600 tmpfile under
5
+ * `${XDG_RUNTIME_DIR || os.tmpdir()}/amplifier-agent/<sessionId>/mcp.json`.
6
+ * The file is written in the format documented by amplifier-module-tool-mcp:
7
+ * a top-level `{"mcpServers": <map>}` object. The caller (`SessionHandle`)
8
+ * injects the spilled path into the engine's subprocess environment as
9
+ * `AMPLIFIER_MCP_CONFIG`; the module reads it via its standard config
10
+ * discovery (config.py priority chain). The former `--mcp-config-path` argv
11
+ * flag was dropped — the env var is the single forwarding mechanism.
10
12
  *
11
13
  * `cleanupSpillFile` is the matching teardown — idempotent unlink that
12
14
  * swallows ENOENT so callers can call it unconditionally on every exit path.
@@ -14,23 +16,6 @@
14
16
  import { mkdir, writeFile, unlink } from "node:fs/promises";
15
17
  import { tmpdir } from "node:os";
16
18
  import { join } from "node:path";
17
- /**
18
- * Return true when at least one server has a non-empty `env` block.
19
- * An empty object (`{}`) does NOT trigger spilling — only env blocks with
20
- * at least one key are considered secret-bearing.
21
- */
22
- function anyServerHasEnv(mcpServers) {
23
- for (const key of Object.keys(mcpServers)) {
24
- const server = mcpServers[key];
25
- if (!server)
26
- continue;
27
- const env = server.env;
28
- if (env && typeof env === "object" && Object.keys(env).length > 0) {
29
- return true;
30
- }
31
- }
32
- return false;
33
- }
34
19
  /**
35
20
  * Compute the base directory for spill files. Prefers
36
21
  * `$XDG_RUNTIME_DIR/amplifier-agent` (typically a tmpfs on Linux) and falls
@@ -44,40 +29,43 @@ function spillBaseDir() {
44
29
  return join(tmpdir(), "amplifier-agent");
45
30
  }
46
31
  /**
47
- * Resolve the value to pass for `--mcp-servers`.
32
+ * Resolve the MCP config file path to pass as `--mcp-config-path`.
33
+ *
34
+ * Always spills to a 0600 tmpfile. The file content wraps the server map
35
+ * in the top-level `mcpServers` key that amplifier-module-tool-mcp expects.
48
36
  *
49
37
  * @param mcpServers Map of server-id -> config, or null/undefined.
50
38
  * @param sessionId Session identifier; used as the per-session subdirectory
51
39
  * under the spill base so concurrent sessions never clash.
52
40
  *
53
- * @returns A `McpSpillResult` with the flag value and (if spilled) the
54
- * on-disk path for later cleanup.
41
+ * @returns A `McpSpillResult` with the on-disk config path (or null if there
42
+ * are no servers to spill).
55
43
  */
56
- export async function resolveMcpServersFlag(mcpServers, sessionId) {
44
+ export async function resolveMcpConfigPath(mcpServers, sessionId) {
57
45
  if (!mcpServers || Object.keys(mcpServers).length === 0) {
58
- return { flag: null, spillPath: null };
59
- }
60
- if (!anyServerHasEnv(mcpServers)) {
61
- // No secrets — safe to inline as a JSON string.
62
- return { flag: JSON.stringify(mcpServers), spillPath: null };
46
+ return { configPath: null };
63
47
  }
64
- // Secret-bearing: spill to a 0600 tmpfile under a 0700 per-session dir.
48
+ // Always spill to a 0600 tmpfile under a 0700 per-session dir.
49
+ // Wrap the server map in the top-level "mcpServers" key that the module
50
+ // expects when reading AMPLIFIER_MCP_CONFIG (see tool-mcp/config.py).
65
51
  const dir = join(spillBaseDir(), sessionId);
66
52
  await mkdir(dir, { recursive: true, mode: 0o700 });
67
53
  const filePath = join(dir, "mcp.json");
68
- await writeFile(filePath, JSON.stringify(mcpServers), { mode: 0o600 });
69
- return { flag: `@${filePath}`, spillPath: filePath };
54
+ await writeFile(filePath, JSON.stringify({ mcpServers: mcpServers }), {
55
+ mode: 0o600,
56
+ });
57
+ return { configPath: filePath };
70
58
  }
71
59
  /**
72
60
  * Idempotently remove a spill file. Safe to call with `null` (no-op) and
73
61
  * safe to call when the file is already gone (ENOENT swallowed). Other
74
62
  * I/O errors propagate.
75
63
  */
76
- export async function cleanupSpillFile(spillPath) {
77
- if (!spillPath)
64
+ export async function cleanupSpillFile(configPath) {
65
+ if (!configPath)
78
66
  return;
79
67
  try {
80
- await unlink(spillPath);
68
+ await unlink(configPath);
81
69
  }
82
70
  catch (err) {
83
71
  const code = err.code;
package/dist/session.d.ts CHANGED
@@ -23,7 +23,7 @@
23
23
  * - `dispose()` is a synonym for `cancel()`.
24
24
  */
25
25
  import type { ChildProcess } from "node:child_process";
26
- import type { McpServerConfig, HostCapabilities } from "./types.js";
26
+ import type { McpServerConfig } from "./types.js";
27
27
  /**
28
28
  * A display event yielded by `SessionHandle.submit()`.
29
29
  *
@@ -89,19 +89,16 @@ export interface SessionHandleParams {
89
89
  resume?: boolean;
90
90
  /** Working directory for the subprocess. */
91
91
  cwd?: string;
92
- /** MCP servers to forward via `--mcp-servers` (CR-A spill applies). */
92
+ /**
93
+ * MCP servers to forward to the engine. CR-A spill applies: the map is
94
+ * written to a 0600 tmpfile and the path is injected into the engine's
95
+ * subprocess environment as `AMPLIFIER_MCP_CONFIG`. The former
96
+ * `--mcp-config-path` argv flag was removed.
97
+ */
93
98
  mcpServers?: Record<string, McpServerConfig>;
94
- /** Host capabilities forwarded via `--host-capabilities`. */
95
- hostCapabilities?: HostCapabilities;
96
- /** Allowlisted env variable names forwarded via `--env-allowlist`. */
97
- envAllowlist?: string[];
98
- /** Extra env entries forwarded via `--env-extra`. */
99
- envExtra?: Record<string, string>;
100
99
  /** Provider override forwarded via `--provider`. */
101
100
  providerOverride?: string;
102
- /** When true, append `--allow-protocol-skew` to argv. */
103
- allowProtocolSkew?: boolean;
104
- /** Protocol version the wrapper speaks (e.g. "0.1.0"). */
101
+ /** Protocol version the wrapper speaks (e.g. "0.2.0"). */
105
102
  protocolVersion: string;
106
103
  /** Per-submit timeout in milliseconds. Defaults to 10 minutes. */
107
104
  timeoutMs?: number;
@@ -133,8 +130,10 @@ export declare class SessionHandle {
133
130
  /**
134
131
  * Async generator implementing the §5.2 iterable behavior:
135
132
  * (i) yield `{type:'init', sessionId}` synchronously (SC-1);
136
- * (ii) CR-A: resolve `--mcp-servers` flag (spill if env-bearing);
137
- * (iii) build argv via `assembleArgv`;
133
+ * (ii) CR-A: spill MCP servers to a 0600 tmpfile (when provided);
134
+ * (iii) build argv via `assembleArgv` and the subprocess env (injecting
135
+ * `AMPLIFIER_MCP_CONFIG` for the spilled path when present — the
136
+ * former `--mcp-config-path` argv flag was removed);
138
137
  * (iv) SC-B: spawn with `detached:true` so PID == PGID for group signals;
139
138
  * (v) accumulate stdout/stderr from chunks;
140
139
  * (vi) start a 2s activity ticker → queue;
package/dist/session.js CHANGED
@@ -24,7 +24,7 @@
24
24
  */
25
25
  import { spawn as childSpawn } from "node:child_process";
26
26
  import { assembleArgv } from "./argv-builder.js";
27
- import { resolveMcpServersFlag, cleanupSpillFile } from "./mcp-spill.js";
27
+ import { resolveMcpConfigPath, cleanupSpillFile } from "./mcp-spill.js";
28
28
  import { parseRunOutput, STDERR_TAIL_BYTES } from "./run-output-parser.js";
29
29
  /** Typed error for AaA wrapper lifecycle and protocol violations. */
30
30
  export class AaaError extends Error {
@@ -121,8 +121,10 @@ export class SessionHandle {
121
121
  /**
122
122
  * Async generator implementing the §5.2 iterable behavior:
123
123
  * (i) yield `{type:'init', sessionId}` synchronously (SC-1);
124
- * (ii) CR-A: resolve `--mcp-servers` flag (spill if env-bearing);
125
- * (iii) build argv via `assembleArgv`;
124
+ * (ii) CR-A: spill MCP servers to a 0600 tmpfile (when provided);
125
+ * (iii) build argv via `assembleArgv` and the subprocess env (injecting
126
+ * `AMPLIFIER_MCP_CONFIG` for the spilled path when present — the
127
+ * former `--mcp-config-path` argv flag was removed);
126
128
  * (iv) SC-B: spawn with `detached:true` so PID == PGID for group signals;
127
129
  * (v) accumulate stdout/stderr from chunks;
128
130
  * (vi) start a 2s activity ticker → queue;
@@ -135,14 +137,17 @@ export class SessionHandle {
135
137
  async *makeIterable(prompt) {
136
138
  // (i) SC-1: yield init synchronously, BEFORE any async work.
137
139
  yield { type: "init", sessionId: this.params.sessionId };
138
- // (ii) CR-A: resolve --mcp-servers (inline JSON OR spill to 0600 tmpfile).
140
+ // (ii) CR-A: spill MCP servers to a 0600 tmpfile (configPath is null when
141
+ // mcpServers is null/empty).
139
142
  // Cast through `unknown`: McpServerConfig is the schema-validated wire type
140
- // (no index signature), while resolveMcpServersFlag's McpServerLike has an
141
- // open index signature. The two are runtime-compatible — only `env` is
142
- // inspected — but TS rightly rejects assignability without the cast.
143
- const spill = await resolveMcpServersFlag((this.params.mcpServers ?? null), this.params.sessionId);
144
- this.mcpSpillPath = spill.spillPath;
145
- // (iii) build argv (pure function — no I/O).
143
+ // (no index signature), while resolveMcpConfigPath's McpServerLike has an
144
+ // open index signature. The two are runtime-compatible but TS rightly
145
+ // rejects assignability without the cast.
146
+ const spill = await resolveMcpConfigPath((this.params.mcpServers ?? null), this.params.sessionId);
147
+ this.mcpSpillPath = spill.configPath;
148
+ // (iii) build argv (pure function — no I/O). The MCP config path is
149
+ // forwarded to the engine via AMPLIFIER_MCP_CONFIG (subprocess env)
150
+ // rather than via an argv flag.
146
151
  const argv = assembleArgv({
147
152
  sessionId: this.params.sessionId,
148
153
  prompt,
@@ -150,17 +155,22 @@ export class SessionHandle {
150
155
  resume: this.params.resume,
151
156
  cwd: this.params.cwd,
152
157
  providerOverride: this.params.providerOverride,
153
- mcpServersFlag: spill.flag ?? undefined,
154
- hostCapabilities: this.params.hostCapabilities,
155
- envAllowlist: this.params.envAllowlist,
156
- envExtra: this.params.envExtra,
157
- allowProtocolSkew: this.params.allowProtocolSkew,
158
158
  });
159
+ // Build the subprocess env. When we spilled an MCP config, set
160
+ // AMPLIFIER_MCP_CONFIG so tool-mcp reads it natively via its
161
+ // config-discovery priority chain. We copy the params env into a fresh
162
+ // object so the stored SessionHandle env is never mutated.
163
+ const subprocessEnv = {
164
+ ...this.params.subprocessEnv,
165
+ };
166
+ if (spill.configPath !== null) {
167
+ subprocessEnv.AMPLIFIER_MCP_CONFIG = spill.configPath;
168
+ }
159
169
  // (iv) SC-B: spawn detached → new session group → PID == PGID.
160
170
  const child = childSpawn(this.params.binaryPath, argv, {
161
171
  detached: true,
162
172
  stdio: ["ignore", "pipe", "pipe"],
163
- env: this.params.subprocessEnv,
173
+ env: subprocessEnv,
164
174
  ...(this.params.cwd !== undefined ? { cwd: this.params.cwd } : {}),
165
175
  });
166
176
  this.subprocess = child;
package/dist/types.d.ts CHANGED
@@ -85,22 +85,6 @@ export interface ErrorNotification {
85
85
  message: string;
86
86
  recoverable: boolean;
87
87
  }
88
- /**
89
- * Capabilities advertised by the host to the agent (design §4.10.1).
90
- */
91
- export interface HostCapabilities {
92
- supports_steering?: boolean;
93
- supports_structured_errors?: boolean;
94
- }
95
- /**
96
- * ``initialize.params.host`` envelope for host-side capability advertisement.
97
- */
98
- export interface InitializeHostParams {
99
- capabilities?: HostCapabilities;
100
- }
101
- /**
102
- * Capabilities advertised by the host to the agent (design §4.10.1).
103
- */
104
88
  /**
105
89
  * Parameters for the ``initialize`` JSON-RPC method.
106
90
  */
@@ -114,35 +98,11 @@ export interface InitializeParams {
114
98
  resume?: boolean;
115
99
  providerOverride?: string;
116
100
  cwd?: string;
117
- mcpServers?: {
118
- [k: string]: McpServerConfig;
119
- };
120
- host?: InitializeHostParams;
101
+ mcpConfigPath?: string;
121
102
  }
122
103
  /**
123
104
  * Identity of the connecting client.
124
105
  */
125
- /**
126
- * Per-server MCP configuration passed via ``initialize.params.mcpServers``.
127
- */
128
- export interface McpServerConfig {
129
- transport: string;
130
- command?: string;
131
- args?: string[];
132
- env?: {
133
- [k: string]: string;
134
- };
135
- url?: string;
136
- headers?: {
137
- [k: string]: string;
138
- };
139
- }
140
- /**
141
- * ``initialize.params.host`` envelope for host-side capability advertisement.
142
- */
143
- /**
144
- * Capabilities advertised by the host to the agent (design §4.10.1).
145
- */
146
106
  /**
147
107
  * Result returned by the ``initialize`` JSON-RPC method.
148
108
  */
@@ -170,6 +130,18 @@ export interface SessionState {
170
130
  /**
171
131
  * Per-server MCP configuration passed via ``initialize.params.mcpServers``.
172
132
  */
133
+ export interface McpServerConfig {
134
+ transport: string;
135
+ command?: string;
136
+ args?: string[];
137
+ env?: {
138
+ [k: string]: string;
139
+ };
140
+ url?: string;
141
+ headers?: {
142
+ [k: string]: string;
143
+ };
144
+ }
173
145
  /**
174
146
  * Arbitrary progress update. ``percent`` is optional (0-100).
175
147
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amplifier-agent-ts",
3
- "version": "0.3.1",
3
+ "version": "0.5.0",
4
4
  "description": "TypeScript SDK for the Amplifier agent. Spawns and drives the amplifier-agent Python CLI over a stdio protocol.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -51,6 +51,6 @@
51
51
  "json-schema-to-typescript": "^15.0.0",
52
52
  "tsx": "^4.7.0",
53
53
  "typescript": "^5.4.0",
54
- "vitest": "^1.4.0"
54
+ "vitest": "^4.1.0"
55
55
  }
56
56
  }