diff --git a/docs/embed.md b/docs/embed.md index 40a8e4f..24b514b 100644 --- a/docs/embed.md +++ b/docs/embed.md @@ -1,7 +1,7 @@ # Embed 1. Copy `libDesktopTools.dylib` and `desktop-tools-client`, and optionally `desktop-tools-mcp`, from a [native build](build.md) into the app bundle, and ship `Licenses/`. -2. Sign the library, the client, and the app with the same Apple Development or Developer ID team. Sign the client with an exact identifier, for example `codesign --identifier .desktop-client`, and the MCP server with the same one, since the host admits exactly one client identifier. +2. Sign the library, the client, and the app with the same Apple Development or Developer ID team. Sign the client with an exact identifier, for example `codesign --identifier .desktop-client`, and the MCP server with the same one, since the host admits exactly one client identifier. Run the MCP server with `--socket `; it names the app it ships in, or `--name`, in its instructions. 3. From the app's GUI process, load the library and call its C ABI: | Symbol | Meaning | diff --git a/docs/node.md b/docs/node.md index a7f9315..1b38df1 100644 --- a/docs/node.md +++ b/docs/node.md @@ -23,3 +23,15 @@ Each result has: Each request goes whole to the host, through its `desktop-tools-client`, as one tool call, so the host checks the arguments and shapes the result. One client process serves every call (`desktop-tools-client --serve`) and is replaced when it exits. Results take the compact shape described in [Result shape](tools.md#result-shape). Pass `verbose: true` in the config, or set `DESKTOP_TOOLS_VERBOSE=1`, for native results whole, with their `target_receipt`. Check the inventory completeness fields before relying on a listing. Image bytes appear only in `image`. `client` must be the `desktop-tools-client` of a host that embeds the Swift runtime from `native2/` (#143), such as Desktop Tools 0.17.0 or later. The `wire` option, which chose it while the Peekaboo stack shipped beside it, is accepted and ignored. + +## Embedding from Node + +The npm package is a thin layer for embedders such as Ace. It holds no tool logic, which all lives in the Swift package in `native2/`: + +- `createDesktop` (`@githubnext/desktop-tools`): the transport above, through the embedding app's own signed client. +- `@githubnext/desktop-tools/tools`: `desktopTools({ place, app })`, `desktopToolRules(app)`, `desktopRequest` and the limits. The descriptions, schemas and rules are declared in Swift (`native2/Sources/DesktopProtocol/ContractTools.swift`), and the package exports them from `src/contract.ts`, which `npm run contract` generates from that file. `place` and `app` fill in where the tools act and which app holds the permissions. `desktopRequest` keeps the arguments the tool's schema names; the host checks them all, including the exclusive forms a schema can't state. +- `@githubnext/desktop-tools/protocol`: the request and result types, the named keys and wait conditions (generated from the same declarations), and `isDesktopAction`, which follows each tool's declared action flag. +- `desktop-tools-build` and `desktop-tools-app`: build the Swift products and the app (see [Install and build](build.md)). +- `desktop-tools-mcp`: a launcher that runs an app's own Swift MCP server (see [Use from an MCP client](mcp.md#npx-setups)). + +To serve your app's grants to MCP clients too, ship `desktop-tools-mcp` from the native build beside your client, signed with the same identifier (see [Embed](embed.md)). It names your app (its `CFBundleName`) in its instructions; pass `--socket` with the socket your app serves, since it looks for Desktop Tools' state folder otherwise.