copilot

package
v1.0.0-alpha.21 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 22 Imported by: 0 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 copilot reads `copilot -p --output-format json` runs of GitHub Copilot CLI.

The stream carries no token counts. The session's events.jsonl, which Copilot CLI writes under its home, holds one session.usage_record per model request and one session.shutdown with each model's totals. The plan names the session, so the budget is watched in that file during the run. The rows come from the usage records, and the shutdown's totals check them.

Index

Constants

View Source
const Name = "copilot"

Name is the costroid/agent tag.

View Source
const UnitNanoAIU = "nano-AIU"

UnitNanoAIU is Copilot's own unit for its AI credits: nano-AI units, as totalNanoAiu states them.

Variables

This section is empty.

Functions

func ReadEvents

func ReadEvents(events io.Reader, keyed bool) (adapter.Report, error)

ReadEvents reads one session's events.jsonl. Each session.usage_record is one request. The records' sums for each model must equal the model's totals in session.shutdown, or the file is refused. keyed says the provider variables named the user's own key, which decides the basis of a record that does not state isByok.

Copilot's own credits, totalNanoAiu and each model's requests.cost, are its figures in its own units. They reach AgentStated and a warning, never a row, and never become dollars.

Types

type Agent

type Agent struct{}

Agent is Copilot CLI.

func (Agent) Name

func (Agent) Name() string

Name returns the costroid/agent tag.

func (Agent) NewSession

func (Agent) NewSession(plan adapter.Plan) adapter.Session

NewSession starts reading a run of the planned command.

func (Agent) Plan

func (Agent) Plan(argv []string, _ decimal.Decimal) (adapter.Plan, error)

Plan requires -p, adds --output-format json, whose result line names the session, and names a new session with --session-id, so the run can watch that session's file from its start. Copilot CLI writes its usage only to that file.

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session reads one Copilot CLI run. Feed and Tail run on separate goroutines, so the lock covers everything below it.

func (*Session) Feed

func (s *Session) Feed(line []byte, _ time.Time) error

Feed reads one stdout line. Only the result line is read: it names the session.

func (*Session) Finish

func (s *Session) Finish() (adapter.Report, error)

Finish reads the session file of the session the result line names, or, when a stop left no result line, of the session the plan named.

func (*Session) Tail

func (s *Session) Tail(ctx context.Context, settled func([]adapter.Request))

Tail follows the session file the plan named until ctx ends, and reports the run's requests each time a usage record settles.

Jump to

Keyboard shortcuts

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