Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

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/agentclientprotocol/typescript-sdk.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/src/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 src/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 src/examples/client.ts

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