acp

package
v0.1.0-beta.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package acp holds Lagrange's conventions for coding agents served with a2aacp (tunnel --acp, or an executor of your own), so that every Lagrange client sees what such an agent does, not only the machine that runs it.

  • Tool calls: a working status message when a call starts, not only when it finishes, each with a {"toolCall": {...}} data part (id, title, kind, status, input, and the output once it finished). The relay records that part in the activity log.
  • Usage: the agent's token and cost reports, as a status message with a {"usage": {...}} data part (see Usage).
  • Thoughts: with Options.Thoughts, the agent's thinking streams into the ThoughtsArtifact artifact. Its reply streams into "response" as before.

Wrap the converter of your a2aacp.Config with Converter:

cfg := &a2aacp.Config{Converter: acp.Converter(nil, acp.Options{Thoughts: true})}

Index

Constants

View Source
const (
	// ToolCallKey is the data part key of a tool call: {"toolCall": {"id", "title",
	// "kind", "status", "input", "output"}}. a2aacp uses the same shape.
	ToolCallKey = "toolCall"
	// UsageKey is the data part key of a usage report: {"usage": {...}}.
	UsageKey = "usage"
	// ThoughtsArtifact is the name of the artifact the agent's thinking streams
	// into, with Options.Thoughts.
	ThoughtsArtifact = "thoughts"
	// StatusRunning is the toolCall status of a call that started.
	StatusRunning = "in_progress"
	// MaxOutput caps a finished tool call's output, in bytes; the end is kept.
	MaxOutput = 4096
)

Keys and names this package writes.

Variables

This section is empty.

Functions

func Converter

func Converter(next a2aacp.Converter, o Options) a2aacp.Converter

Converter wraps next (a2aacp.ConvertUpdate if nil) with Lagrange's conventions. It is safe for concurrent tasks.

func Find

func Find(parts []*a2a.Part, key string) any

Find returns the value of the first data part of parts with key, or nil.

Types

type Cost

type Cost struct {
	Amount   float64 `json:"amount"`
	Currency string  `json:"currency"`
}

Cost is an amount of money.

type Options

type Options struct {
	// Thoughts streams the agent's thinking into the thoughts artifact. Each
	// chunk is an event, so it costs activity log space.
	Thoughts bool
}

Options select what Converter adds to a2aacp's built-in conversion.

type Usage

type Usage struct {
	// Used is the number of tokens in the context window, Size the window's size.
	Used int64 `json:"used,omitempty"`
	Size int64 `json:"size,omitempty"`
	// Cost is the session's cost so far (for claude-agent-acp, Claude Code's
	// estimate at API prices).
	Cost *Cost `json:"cost,omitempty"`
}

Usage is an agent's usage report for its session (the A2A context), as the agent sends it: Cost is cumulative over the session, so the session's cost is its latest report.

func ParseUsage

func ParseUsage(v any) (Usage, bool)

ParseUsage reads a usage data part's value ({"used", "size", "cost"}), as found in a message or an activity entry's data.

func (Usage) Map

func (u Usage) Map() map[string]any

Map returns u as the JSON object of a usage data part.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL