@buildanagent/harness 0.1.0-alpha.29 → 0.1.0-alpha.31

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.
Files changed (84) hide show
  1. package/README.md +110 -3
  2. package/dist/credentials/addresses.d.ts +20 -0
  3. package/dist/credentials/addresses.js +93 -2
  4. package/dist/credentials/addresses.js.map +1 -1
  5. package/dist/credentials/egress-proxy.js +34 -4
  6. package/dist/credentials/egress-proxy.js.map +1 -1
  7. package/dist/errors.d.ts +6 -3
  8. package/dist/errors.js +5 -2
  9. package/dist/errors.js.map +1 -1
  10. package/dist/extensions/load.js +5 -2
  11. package/dist/extensions/load.js.map +1 -1
  12. package/dist/extensions/lock.d.ts +16 -2
  13. package/dist/extensions/lock.js +155 -21
  14. package/dist/extensions/lock.js.map +1 -1
  15. package/dist/extensions/mcp-pins-node.d.ts +16 -0
  16. package/dist/extensions/mcp-pins-node.js +18 -0
  17. package/dist/extensions/mcp-pins-node.js.map +1 -0
  18. package/dist/extensions/node.d.ts +4 -2
  19. package/dist/extensions/node.js +4 -2
  20. package/dist/extensions/node.js.map +1 -1
  21. package/dist/harness.d.ts +7 -1
  22. package/dist/harness.js.map +1 -1
  23. package/dist/mcp/connection.d.ts +9 -3
  24. package/dist/mcp/connection.js +192 -25
  25. package/dist/mcp/connection.js.map +1 -1
  26. package/dist/mcp/errors.d.ts +5 -2
  27. package/dist/mcp/errors.js.map +1 -1
  28. package/dist/mcp/guarded-fetch.d.ts +33 -0
  29. package/dist/mcp/guarded-fetch.js +391 -0
  30. package/dist/mcp/guarded-fetch.js.map +1 -0
  31. package/dist/mcp/http-node.d.ts +15 -0
  32. package/dist/mcp/http-node.js +179 -0
  33. package/dist/mcp/http-node.js.map +1 -0
  34. package/dist/mcp/index.d.ts +6 -3
  35. package/dist/mcp/index.js +5 -2
  36. package/dist/mcp/index.js.map +1 -1
  37. package/dist/mcp/manager.d.ts +4 -3
  38. package/dist/mcp/manager.js +432 -47
  39. package/dist/mcp/manager.js.map +1 -1
  40. package/dist/mcp/pins.d.ts +9 -0
  41. package/dist/mcp/pins.js +54 -0
  42. package/dist/mcp/pins.js.map +1 -0
  43. package/dist/mcp/record.js +6 -0
  44. package/dist/mcp/record.js.map +1 -1
  45. package/dist/mcp/remote-config.d.ts +20 -0
  46. package/dist/mcp/remote-config.js +208 -0
  47. package/dist/mcp/remote-config.js.map +1 -0
  48. package/dist/mcp/remote.d.ts +20 -0
  49. package/dist/mcp/remote.js +146 -0
  50. package/dist/mcp/remote.js.map +1 -0
  51. package/dist/mcp/types.d.ts +198 -8
  52. package/dist/mcp/types.js.map +1 -1
  53. package/dist/sandbox/escalation-table.d.ts +38 -0
  54. package/dist/sandbox/escalation-table.js +95 -0
  55. package/dist/sandbox/escalation-table.js.map +1 -0
  56. package/dist/sandbox/escalation.d.ts +191 -0
  57. package/dist/sandbox/escalation.js +370 -0
  58. package/dist/sandbox/escalation.js.map +1 -0
  59. package/dist/sandbox/index.d.ts +6 -3
  60. package/dist/sandbox/index.js +6 -3
  61. package/dist/sandbox/index.js.map +1 -1
  62. package/dist/sandbox/widen.d.ts +10 -0
  63. package/dist/sandbox/widen.js +150 -0
  64. package/dist/sandbox/widen.js.map +1 -0
  65. package/dist/server/protocol.schema.json +6 -3
  66. package/dist/session/approvals.d.ts +30 -1
  67. package/dist/session/approvals.js +12 -4
  68. package/dist/session/approvals.js.map +1 -1
  69. package/dist/session/code-call.d.ts +15 -1
  70. package/dist/session/code-call.js +2 -1
  71. package/dist/session/code-call.js.map +1 -1
  72. package/dist/session/escalation-log.d.ts +65 -0
  73. package/dist/session/escalation-log.js +84 -0
  74. package/dist/session/escalation-log.js.map +1 -0
  75. package/dist/session/rebuild.js +12 -3
  76. package/dist/session/rebuild.js.map +1 -1
  77. package/dist/session/runner.js +39 -6
  78. package/dist/session/runner.js.map +1 -1
  79. package/dist/tools/index.d.ts +1 -1
  80. package/dist/tools/index.js.map +1 -1
  81. package/dist/tools/types.d.ts +16 -0
  82. package/dist/tools/types.js.map +1 -1
  83. package/llms.txt +36 -2
  84. package/package.json +7 -6
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-node.js","sourceRoot":"","sources":["../../src/mcp/http-node.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKnD,MAAM,IAAI,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAC/G,MAAM,QAAQ,GAAG,CAAC,OAAe,EAAS,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE7E;;;;GAIG;AACH,MAAM,UAAU,cAAc;IAC5B,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,OAAO,CAAC,gBAAgB,KAAK,UAAU;QAAE,OAAO,KAAK,CAAC;IACnG,MAAM,KAAK,GAAI,UAAsD,CAAC,SAAS,EAAE,SAAS,CAAC;IAC3F,OAAO,KAAK,KAAK,oBAAoB,IAAI,OAAO,OAAO,CAAC,QAAQ,EAAE,IAAI,KAAK,QAAQ,CAAC;AACtF,CAAC;AAED,gFAAgF;AAChF,KAAK,UAAU,MAAM,CAAC,IAAiB;IACrC,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IACpE,OAAO,IAAI,UAAU,CAAC,MAAM,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,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,CAAC;AAED,0HAA0H;AAC1H,SAAS,UAAU,CAAC,UAA8B,EAAE,EAA0C;IAC5F,OAAO;QACL,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC;QACnD,kBAAkB,EAAE,IAAI;QACxB,UAAU,EAAE,SAAkB;QAC9B,GAAG,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,EAAuB,EAAE,CAAC;KAC7D,CAAC;AACJ,CAAC","sourcesContent":["/**\n * The network under a remote server's fetch on Node, when no egress proxy is configured. Each request resolves the\n * server's name once, checks every address it gets against the server's address policy, connects to the first, and\n * checks the address the socket reached once more, so a name whose answer changes between two lookups can't steer a\n * request to the host's own network. It verifies certificates, asks for no compression, follows no redirect and keeps\n * no connection alive between requests. It loads Node's modules by `process.getBuiltinModule()` when a request is made,\n * so the `mcp` entry still loads on a runtime without them.\n */\nimport { isAddressLiteral } from \"../credentials/addresses.js\";\nimport type { FetchLike } from \"./guarded-fetch.js\";\nimport { RemoteRefusal } from \"./guarded-fetch.js\";\nimport type { RemoteSettings } from \"./remote-config.js\";\n\ntype IncomingMessage = import(\"node:http\").IncomingMessage;\n\nconst bare = (host: string): string => (host.startsWith(\"[\") && host.endsWith(\"]\") ? host.slice(1, -1) : host);\nconst familyOf = (address: string): 4 | 6 => (address.includes(\":\") ? 6 : 4);\n\n/**\n * Whether this is Node, whose `node:https` takes the custom `lookup` the pinned connection needs. Cloudflare's workerd\n * also has `process.getBuiltinModule()` and `node:https` under `nodejs_compat`, but refuses a `lookup` option, so it\n * is told apart by its user agent and gets the platform's `fetch` instead.\n */\nexport function hasNodeNetwork(): boolean {\n if (typeof process === \"undefined\" || typeof process.getBuiltinModule !== \"function\") return false;\n const agent = (globalThis as { navigator?: { userAgent?: unknown } }).navigator?.userAgent;\n return agent !== \"Cloudflare-Workers\" && typeof process.versions?.node === \"string\";\n}\n\n/** The body a request sends: the client library sends JSON text, or nothing. */\nasync function bodyOf(init: RequestInit): Promise<Uint8Array | undefined> {\n if (init.body === undefined || init.body === null) return undefined;\n return new Uint8Array(await new Response(init.body).arrayBuffer());\n}\n\n/** A Web `Response` for a Node response. A body nobody can read is drained, so the socket closes. */\nfunction toResponse(reply: IncomingMessage): Response {\n const stream = process.getBuiltinModule(\"node:stream\");\n const headers = new Headers();\n for (const [name, value] of Object.entries(reply.headers)) {\n if (value === undefined) continue;\n for (const one of Array.isArray(value) ? value : [value]) headers.append(name, one);\n }\n const status = reply.statusCode ?? 0;\n // Node parses any three-digit status, and `Response` throws outside 200 to 599, so such an answer is refused here.\n if (status < 200 || status > 599) {\n reply.destroy();\n throw new RemoteRefusal(\"refused\", `the server answered with status ${status}, which HTTP does not define`);\n }\n if ([204, 205, 304].includes(status)) {\n reply.resume();\n return new Response(null, { status, headers });\n }\n return new Response(stream.Readable.toWeb(reply) as ReadableStream<Uint8Array>, {\n status,\n statusText: reply.statusMessage ?? \"\",\n headers,\n });\n}\n\ntype Resolve = (host: string) => Promise<readonly string[]>;\ntype ClientRequest = import(\"node:http\").ClientRequest;\n\n/** The system resolver: every address of a name, in the order the system gives them. */\nconst systemResolve: Resolve = async (host) =>\n (await process.getBuiltinModule(\"node:dns\").promises.lookup(host, { all: true, verbatim: true })).map(\n (found) => found.address,\n );\n\n/**\n * A `lookup` for `node:https`: it resolves the name once, refuses it when any address is one the server may not reach,\n * and hands back the first address alone, so the socket connects to that checked address and no other.\n */\nfunction checkedLookup(settings: RemoteSettings, resolve: Resolve) {\n return (\n hostname: string,\n lookupOptions: { all?: boolean },\n callback: (error: Error | null, address?: unknown, family?: number) => void,\n ): void => {\n resolve(hostname).then(\n (addresses) => {\n if (addresses.length === 0 || addresses.some((address) => !settings.allows(address))) {\n callback(new RemoteRefusal(\"refused\", \"the server's name resolves to an address it may not reach\"));\n return;\n }\n const first = addresses[0] as string;\n if (lookupOptions.all === true) callback(null, [{ address: first, family: familyOf(first) }]);\n else callback(null, first, familyOf(first));\n },\n (error: unknown) => callback(error instanceof Error ? error : new Error(String(error))),\n );\n };\n}\n\n/** The request's headers for Node: no compression, a length for the body, and the URL's own `Host`. */\nfunction nodeHeaders(init: RequestInit, url: URL, body: Uint8Array | undefined): Record<string, string> {\n const headers: Record<string, string> = {};\n new Headers(init.headers).forEach((value, name) => {\n headers[name] = value;\n });\n headers[\"accept-encoding\"] = \"identity\";\n if (body !== undefined) headers[\"content-length\"] = String(body.length);\n headers.host = url.host;\n return headers;\n}\n\n/**\n * Checks the address the socket reached once it has connected: the lookup's answer is what it connected to, and this\n * proves it for a literal address and for any path around the lookup.\n */\nfunction checkReached(request: ClientRequest, settings: RemoteSettings, secure: boolean): void {\n request.once(\"socket\", (socket) => {\n socket.once(secure ? \"secureConnect\" : \"connect\", () => {\n const reached = socket.remoteAddress;\n if (reached === undefined || !settings.allows(reached)) {\n request.destroy(new RemoteRefusal(\"refused\", \"the connection reached an address the server may not use\"));\n }\n });\n });\n}\n\n/** Settles with the response, refusing a compressed one, which the request did not ask for. */\nfunction settle(request: ClientRequest, signal: AbortSignal | undefined): Promise<Response> {\n return new Promise<Response>((resolve, reject) => {\n const abort = () => request.destroy(signal?.reason instanceof Error ? signal.reason : new Error(\"aborted\"));\n signal?.addEventListener(\"abort\", abort, { once: true });\n request.once(\"close\", () => signal?.removeEventListener(\"abort\", abort));\n request.once(\"response\", (reply) => {\n const encoding = String(reply.headers[\"content-encoding\"] ?? \"identity\")\n .trim()\n .toLowerCase();\n if (encoding !== \"identity\" && encoding !== \"\") {\n reply.destroy();\n reject(new RemoteRefusal(\"refused\", \"the server compressed its answer, which the harness did not ask for\"));\n return;\n }\n // A throw here would escape the event handler and end the process, so every failure becomes a rejection.\n try {\n resolve(toResponse(reply));\n } catch (error) {\n reply.destroy();\n reject(error);\n }\n });\n request.once(\"error\", (error) => reject(signal?.aborted ? signal.reason : error));\n });\n}\n\n/** The pinned fetch, for one server's settings. */\nexport function nodeFetch(\n settings: RemoteSettings,\n options: { readonly resolve?: Resolve | undefined; readonly ca?: string | readonly string[] | undefined },\n): FetchLike {\n const lookup = checkedLookup(settings, options.resolve ?? systemResolve);\n return async (input, init = {}) => {\n const url = new URL(typeof input === \"string\" ? input : input.href);\n const host = bare(url.hostname);\n const literal = isAddressLiteral(host);\n // A literal address is checked as it is, since Node looks nothing up for it; a name is looked up once, in `lookup`.\n if (literal && !settings.allows(host))\n throw new RemoteRefusal(\"refused\", \"the server's address is one it may not reach\");\n const secure = url.protocol === \"https:\";\n const body = await bodyOf(init);\n const signal = init.signal ?? undefined;\n signal?.throwIfAborted();\n const request = process\n .getBuiltinModule(secure ? \"node:https\" : \"node:http\")\n .request(requestOptions(url, init, body, literal ? undefined : lookup, options.ca));\n checkReached(request, settings, secure);\n const response = settle(request, signal);\n request.end(body);\n return response;\n };\n}\n\n/** The options of one Node request: no shared agent, the checked lookup for a name, and TLS settings for `https:`. */\nfunction requestOptions(\n url: URL,\n init: RequestInit,\n body: Uint8Array | undefined,\n lookup: ReturnType<typeof checkedLookup> | undefined,\n ca: string | readonly string[] | undefined,\n) {\n const host = bare(url.hostname);\n const secure = url.protocol === \"https:\";\n const port = url.port !== \"\" ? Number(url.port) : secure ? 443 : 80;\n return {\n protocol: url.protocol,\n hostname: host,\n port,\n method: init.method ?? \"GET\",\n path: `${url.pathname}${url.search}`,\n headers: nodeHeaders(init, url, body),\n agent: false as const,\n ...(lookup === undefined ? {} : { lookup: lookup as never }),\n ...(secure ? tlsOptions(lookup === undefined ? undefined : host, ca) : {}),\n };\n}\n\n/** Certificates are always verified, against the system's authorities or the server's own `ca`, over TLS 1.2 or later. */\nfunction tlsOptions(servername: string | undefined, ca: string | readonly string[] | undefined) {\n return {\n ...(servername === undefined ? {} : { servername }),\n rejectUnauthorized: true,\n minVersion: \"TLSv1.2\" as const,\n ...(ca === undefined ? {} : { ca: ca as string | string[] }),\n };\n}\n"]}
@@ -1,10 +1,13 @@
1
1
  /**
2
2
  * `@buildanagent/harness/mcp`: the MCP client. `createMcpManager()` connects each configured server, negotiates its
3
- * protocol era, and registers its tools as `mcp__<server>__<tool>`, deferred by default. `connectMcpServer()` connects
4
- * one server without registering anything. The stdio transport is Node-only; an in-process server works on any runtime.
3
+ * protocol era, and registers its tools as `mcp__<server>__<tool>`, deferred by default. It connects in the background
4
+ * and changes a session's tools only between turns, with each tool's definition checked against a pin.
5
+ * `connectMcpServer()` connects one server without registering anything. The stdio transport is Node-only; the HTTP and
6
+ * SSE transports run on any runtime with `fetch`, and resolve and pin each address themselves on Node.
5
7
  */
6
8
  export { connectMcpServer } from "./connection.js";
7
9
  export { type McpCallFailure, McpError } from "./errors.js";
8
10
  export { createMcpManager } from "./manager.js";
11
+ export { memoryMcpPinStore } from "./pins.js";
9
12
  export { killMcpServersOnSignal } from "./stdio.js";
10
- export type { McpCallResult, McpChannel, McpConnection, McpEra, McpInProcessTransport, McpManager, McpManagerOptions, McpServerConfig, McpServerStatus, McpStdioTransport, McpTool, } from "./types.js";
13
+ export type { McpCallResult, McpChannel, McpConnection, McpEgressFetch, McpEra, McpHttpTransport, McpInProcessTransport, McpManager, McpManagerOptions, McpPendingTool, McpPinStore, McpRemoteSettings, McpServerConfig, McpServerStatus, McpSseTransport, McpStdioTransport, McpTimers, McpTool, McpToolState, } from "./types.js";
package/dist/mcp/index.js CHANGED
@@ -1,10 +1,13 @@
1
1
  /**
2
2
  * `@buildanagent/harness/mcp`: the MCP client. `createMcpManager()` connects each configured server, negotiates its
3
- * protocol era, and registers its tools as `mcp__<server>__<tool>`, deferred by default. `connectMcpServer()` connects
4
- * one server without registering anything. The stdio transport is Node-only; an in-process server works on any runtime.
3
+ * protocol era, and registers its tools as `mcp__<server>__<tool>`, deferred by default. It connects in the background
4
+ * and changes a session's tools only between turns, with each tool's definition checked against a pin.
5
+ * `connectMcpServer()` connects one server without registering anything. The stdio transport is Node-only; the HTTP and
6
+ * SSE transports run on any runtime with `fetch`, and resolve and pin each address themselves on Node.
5
7
  */
6
8
  export { connectMcpServer } from "./connection.js";
7
9
  export { McpError } from "./errors.js";
8
10
  export { createMcpManager } from "./manager.js";
11
+ export { memoryMcpPinStore } from "./pins.js";
9
12
  export { killMcpServersOnSignal } from "./stdio.js";
10
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAuB,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC","sourcesContent":["/**\n * `@buildanagent/harness/mcp`: the MCP client. `createMcpManager()` connects each configured server, negotiates its\n * protocol era, and registers its tools as `mcp__<server>__<tool>`, deferred by default. `connectMcpServer()` connects\n * one server without registering anything. The stdio transport is Node-only; an in-process server works on any runtime.\n */\nexport { connectMcpServer } from \"./connection.js\";\nexport { type McpCallFailure, McpError } from \"./errors.js\";\nexport { createMcpManager } from \"./manager.js\";\nexport { killMcpServersOnSignal } from \"./stdio.js\";\nexport type {\n McpCallResult,\n McpChannel,\n McpConnection,\n McpEra,\n McpInProcessTransport,\n McpManager,\n McpManagerOptions,\n McpServerConfig,\n McpServerStatus,\n McpStdioTransport,\n McpTool,\n} from \"./types.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAuB,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC","sourcesContent":["/**\n * `@buildanagent/harness/mcp`: the MCP client. `createMcpManager()` connects each configured server, negotiates its\n * protocol era, and registers its tools as `mcp__<server>__<tool>`, deferred by default. It connects in the background\n * and changes a session's tools only between turns, with each tool's definition checked against a pin.\n * `connectMcpServer()` connects one server without registering anything. The stdio transport is Node-only; the HTTP and\n * SSE transports run on any runtime with `fetch`, and resolve and pin each address themselves on Node.\n */\nexport { connectMcpServer } from \"./connection.js\";\nexport { type McpCallFailure, McpError } from \"./errors.js\";\nexport { createMcpManager } from \"./manager.js\";\nexport { memoryMcpPinStore } from \"./pins.js\";\nexport { killMcpServersOnSignal } from \"./stdio.js\";\nexport type {\n McpCallResult,\n McpChannel,\n McpConnection,\n McpEgressFetch,\n McpEra,\n McpHttpTransport,\n McpInProcessTransport,\n McpManager,\n McpManagerOptions,\n McpPendingTool,\n McpPinStore,\n McpRemoteSettings,\n McpServerConfig,\n McpServerStatus,\n McpSseTransport,\n McpStdioTransport,\n McpTimers,\n McpTool,\n McpToolState,\n} from \"./types.js\";\n"]}
@@ -1,7 +1,8 @@
1
1
  import type { McpManager, McpManagerOptions } from "./types.js";
2
2
  /**
3
- * Creates the MCP client for a set of servers. It checks every config now and starts nothing until `connect()`.
4
- * Throws a `HarnessError`, code `invalid_mcp_config`, for a config that can't be used, two servers with one name, or a
5
- * registry without `register()`, `registerAll()` and `list()`.
3
+ * Creates the MCP client for a set of servers. It checks every config now and starts nothing until `start()`,
4
+ * `connect()` or the first `beginTurn()`. Throws a `HarnessError`, code `invalid_mcp_config`, for a config that can't be
5
+ * used, two servers with one name, a registry without `register()`, `registerAll()` and `list()`, a pin store
6
+ * without `read()` and `write()`, or a wait that is not a whole number of milliseconds.
6
7
  */
7
8
  export declare function createMcpManager(options: McpManagerOptions): McpManager;