Skip to content

Latest commit

 

History

History
77 lines (49 loc) · 2.42 KB

File metadata and controls

77 lines (49 loc) · 2.42 KB

ACP TypeScript Examples

This directory contains examples using the ACP library for TypeScript:

  • agent.ts - A minimal agent implementation that simulates LLM interaction
  • client.ts - A minimal client implementation that spawns the agent.ts as a subprocess

Running the Agent

In Zed

While minimal, agent.ts implements a compliant ACP Agent. This means we can connect to it from an ACP client like Zed!

  1. Clone this repo
$ git clone https://github.com/zed-industries/agent-client-protocol.git
  1. Add the following at the root of your Zed settings:
  "agent_servers": {
    "Example Agent": {
      "command": "npx",
      "args": [
        "tsx",
        "/path/to/agent-client-protocol/typescript/examples/agent.ts"
      ]
  }

❕ Make sure to replace /path/to/agent-client-protocol with the path to your clone of this repository.

Note: This configuration assumes you have npx in your PATH.

  1. Run the acp: open acp logs action from the command palette (⌘⇧P on macOS, ctrl-shift-p on Windows/Linux) to see the messages exchanged between the example agent and Zed.

  2. Then open the Agent Panel, and click "New Example Agent Thread" from the + menu on the top-right.

Agent menu

  1. Finally, send a message and see the Agent respond!

Final state

By itself

You can also run the Agent directly and send messages to it:

npx tsx typescript/examples/agent.ts

Paste this into your terminal and press enter:

{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"protocolVersion":1}}

You should see it respond with something like:

{"jsonrpc":"2.0","id":0,"result":{"protocolVersion":1,"agentCapabilities":{"loadSession":false}}}

From there, you can try making a new session and sending a prompt.

Running the Client

Run the client example from the root directory:

npx tsx typescript/examples/client.ts

This client will spawn the example agent as a subprocess, send a message, and print the content it receives from it.