go

module
v0.0.0-...-be6a141 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0

README

Kagent Go

This directory is a single Go module (github.com/kagent-dev/kagent/go) containing the top-level package trees that make up the Go components of Kagent.

Packages

Package Path Description
api go/api/ Public API: CRD types, generated protobuf code, gRPC and A2A clients, Kubernetes clientset
core go/core/ Control plane: Kubernetes controllers, gRPC and HTTP servers, PostgreSQL store, CLI
adk go/adk/ Go Agent Development Kit for building and running agents
harness go/harness/ Native Claude and Codex Actor runtimes plus their shared A2A execution support
pkg go/pkg/ Logging, OpenTelemetry setup, and the shared tracing contract
sandbox go/sandbox/ Sandbox guest image and entry point
Dependencies between trees

go/api does not import any other tree in this module, so importing its packages does not compile the controller, ADK, or harness code. The other trees import each other at the package level:

  • core uses adk and harness configuration packages to compile runtime inputs.
  • adk and harness use core packages such as core/pkg/env and core/pkg/config.
  • pkg uses core/pkg/env; sandbox uses pkg.

Run go list -deps ./<tree>/... to check the current graph.

Directory Structure

go/
├── go.mod               # Single Go module file
├── Makefile              # Unified build targets
├── Dockerfile            # Shared multi-stage Docker build
│
├── api/                  # Public API types and clients
│   ├── v1alpha3/         # Current CRD types
│   ├── gen/kagent/       # Generated protobuf code (api, config, runtime)
│   ├── client/           # gRPC and A2A client SDK
│   ├── clientset/        # Generated Kubernetes clientset
│   ├── a2a/              # A2A metadata and runtime identity helpers
│   ├── agentplugin/      # Skill and Agent Plugin package configuration
│   ├── authorization/    # Authorization scope types
│   ├── bootstrap/        # Runtime configuration bundles
│   ├── sandbox/          # Sandbox routing metadata
│   ├── scheduledrun/     # ScheduledRun scheduling semantics
│   ├── structuredobject/ # StructuredObject conversion helpers
│   └── hack/             # Code generation boilerplate
│
├── core/                 # Control plane
│   ├── cmd/              # Controller binary entry point
│   ├── cli/              # kagent CLI application
│   ├── internal/         # Controllers, gRPC and HTTP servers, store, A2A gateway, MCP, Substrate
│   ├── pkg/              # App wiring, auth, config, env vars, install, migrations
│   ├── hack/             # Development utilities (mock LLM, agent config generator)
│   └── test/e2e/         # End-to-end tests
│
├── adk/                  # Go Agent Development Kit
│   ├── cmd/              # ADK server entry point
│   ├── pkg/              # Agent runtime, models, MCP, sessions, skills
│   └── examples/         # Example tools (oneshot runner, BYO agent)
│
├── harness/              # Native Harness Actor runtimes
│   ├── claude/           # Claude Code adapter and image
│   ├── codex/            # Codex App Server adapter and image
│   ├── runtime/          # Public event, A2A executor, and continuation APIs
│   └── internal/utils/   # Private OS utilities
│
├── pkg/                  # Shared observability libraries
│   ├── logging/          # JSON logger
│   ├── telemetry/        # OpenTelemetry SDK setup
│   └── tracing/          # Invocation span contract shared by runtimes
│
└── sandbox/
    └── guest/            # Sandbox guest image and entry point

Building

All commands are run from the go/ directory via the unified Makefile.

# Generate CRD manifests and DeepCopy methods (after changing api/ types)
make generate
make manifests

# Build CLI binaries for all platforms
make build

# Build CLI for local development
make core/bin/kagent-local

# Run the controller locally
make run

make run reads /etc/kagent/controller.yaml, the path the Helm chart mounts. To run with another file, use go run ./core/cmd/controller --config <file>; see controller configuration.

Testing

# Run all unit tests across the workspace
make test

# Run end-to-end tests (requires Kind cluster)
make e2e

Code Quality

# Lint all modules
make lint

# Auto-fix lint issues
make lint-fix

# Format all modules
make fmt

# Vet all modules
make vet

Docker

The workspace uses a single Dockerfile parameterized with BUILD_PACKAGE:

# Build controller image (default)
docker build --build-arg BUILD_PACKAGE=./core/cmd/controller -t controller .

# Build Go ADK image
docker build --build-arg BUILD_PACKAGE=adk/cmd/main.go -t golang-adk .

In practice, use the root Makefile targets (make build-controller, make build-golang-adk).

Agent runtime image digests

Published Helm charts contain the matching release's digest-pinned golang-adk, claude-harness, and codex-harness images. Release packaging consumes each image build's final Buildx digest; controller builds run independently and never wait for runtime-image digests. OCI and GitHub releases share the same chart archive.

Package a release with:

make helm-release VERSION=1.0.0-alpha9 \
  RUNTIME_IMAGE_METADATA_DIR=/path/to/buildx-metadata

The directory must contain golang-adk.json, claude-harness.json, and codex-harness.json from those builds. The target validates the digests and packages the catalog with the charts in a temporary directory, then writes the completed archives to dist. It does not modify the chart sources. make helm-publish requires the same metadata input. For local registries, set RUNTIME_IMAGE_REPOSITORY=localhost:5001/kagent-dev/kagent.

The chart supplies typed harnessImages in the mounted controller.yaml file. For built-in Harnesses, workload: {} selects the default image. An explicit workload.image overrides it and must include its @sha256: digest. BYO requires an explicit image and command. This works for inline and referenced Harnesses. Agent.status.workloadImage reports the image selected for its desired revision.

Local installations can set config.harnessImages.kagent, .claude, and .codex to full digest-pinned references. Missing defaults only prevent Agents that need those entries from compiling. global.imageRegistry rewrites the registry of these defaults; it does not rewrite explicit Harness overrides. A supplied config.harnessImages.release must match the controller version; omit it for independently built local images.

The native images use make build-claude-harness and make build-codex-harness. kagent-adk remains available for Python runtime overrides.

Quick Testing with Oneshot

The adk/examples/oneshot tool lets you test agent configs locally:

# Run a single prompt with a sample config (requires OPENAI_API_KEY)
cd go/adk && go run ./examples/oneshot -config examples/oneshot/testdata/openai.json -task "Hello"

adk/examples/oneshot/testdata has a config for each supported model provider and lists the environment variables each needs.

Directories

Path Synopsis
adk module
cmd command
examples/byo command
Package main demonstrates how to build a BYO (Bring Your Own) agent using the Go ADK's pkg/app builder with hardcoded agent configuration and Google ADK's ParallelAgent for concurrent sub-agent execution.
Package main demonstrates how to build a BYO (Bring Your Own) agent using the Go ADK's pkg/app builder with hardcoded agent configuration and Google ADK's ParallelAgent for concurrent sub-agent execution.
examples/oneshot command
Command oneshot runs a single prompt against an agent config and prints the response.
Command oneshot runs a single prompt against an agent config and prints the response.
pkg/bootstrap
Package bootstrap loads immutable configuration before a runtime becomes ready.
Package bootstrap loads immutable configuration before a runtime becomes ready.
pkg/config
Package config loads, validates, and adapts ADK runtime configuration.
Package config loads, validates, and adapts ADK runtime configuration.
pkg/fileextract
Package fileextract turns uploaded text-like file blobs into text the model can read.
Package fileextract turns uploaded text-like file blobs into text the model can read.
pkg/internal/azureai
Package azureai contains helpers shared by the Azure providers: credential construction, token acquisition, the bearer-token middleware, and the SDK client constructors.
Package azureai contains helpers shared by the Azure providers: credential construction, token acquisition, the bearer-token middleware, and the SDK client constructors.
pkg/models
Package models: Anthropic model implementing Google ADK model.LLM using genai types.
Package models: Anthropic model implementing Google ADK model.LLM using genai types.
pkg/outputschema
Package outputschema converts kagent's portable output schema into the narrower schema representation used by Go ADK.
Package outputschema converts kagent's portable output schema into the narrower schema representation used by Go ADK.
pkg/sts
Package sts implements OAuth 2.0 Token Exchange (RFC 8693) for the Go ADK.
Package sts implements OAuth 2.0 Token Exchange (RFC 8693) for the Go ADK.
pkg/taskstore
Package taskstore connects the upstream A2A SDK to kagent's private gRPC persistence service.
Package taskstore connects the upstream A2A SDK to kagent's private gRPC persistence service.
api module
a2a
agentplugin
Package agentplugin defines the runtime-neutral configuration for immutable standalone skills and Agent Plugin packages.
Package agentplugin defines the runtime-neutral configuration for immutable standalone skills and Agent Plugin packages.
bootstrap
Package bootstrap defines immutable runtime configuration delivery.
Package bootstrap defines immutable runtime configuration delivery.
clientset/versioned/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
clientset/versioned/typed/api/v1alpha3
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
clientset/versioned/typed/api/v1alpha3/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
sandbox
Package sandbox defines routing metadata for sandbox execution APIs.
Package sandbox defines routing metadata for sandbox execution APIs.
scheduledrun
Package scheduledrun contains the scheduling semantics shared by services and transactional reservation.
Package scheduledrun contains the scheduling semantics shared by services and transactional reservation.
v1alpha3
Package v1alpha3 contains API Schema definitions for the api.kagent.dev v1alpha3 API group.
Package v1alpha3 contains API Schema definitions for the api.kagent.dev v1alpha3 API group.
core
cli
cli/cmd/kagent command
cli/internal/commands/db
Package db wires the CLI configuration to the database commands.
Package db wires the CLI configuration to the database commands.
cli/internal/commands/sandbox
Package sandbox implements standalone sandbox commands.
Package sandbox implements standalone sandbox commands.
cli/internal/commands/session
Package session implements Session CLI commands.
Package session implements Session CLI commands.
cli/internal/config
Package config resolves local CLI settings before command execution.
Package config resolves local CLI settings before command execution.
cli/internal/connection
Package connection owns CLI server connectivity and Kubernetes port-forward fallback.
Package connection owns CLI server connectivity and Kubernetes port-forward fallback.
cli/internal/db
Package db hosts the `kagent db` parent command and its subcommands.
Package db hosts the `kagent db` parent command and its subcommands.
cli/internal/db/migrate
Package migrate provides the database migration commands.
Package migrate provides the database migration commands.
cli/internal/output
Package output owns the CLI's shared machine-output contract.
Package output owns the CLI's shared machine-output contract.
cli/internal/tui/session
Package session renders Session control-plane fields for the terminal.
Package session renders Session control-plane fields for the terminal.
cmd/controller command
hack/mockllm command
internal/a2agateway
Package a2agateway routes public A2A calls to actors and persisted Session state.
Package a2agateway routes public A2A calls to actors and persisted Session state.
internal/anthropicselfhostedsandboxes
Package anthropicselfhostedsandboxes launches stock Anthropic workers through kagent services.
Package anthropicselfhostedsandboxes launches stock Anthropic workers through kagent services.
internal/controller/remotemcpserver
Package remotemcpserver reconciles the discovered tool catalog published in RemoteMCPServer status.
Package remotemcpserver reconciles the discovered tool catalog published in RemoteMCPServer status.
internal/controller/toolcatalog
Package toolcatalog normalizes and publishes MCP catalog observations.
Package toolcatalog normalizes and publishes MCP catalog observations.
internal/dbtest
Package dbtest provides PostgreSQL test helpers: a real Postgres container and a fake server that rejects logins.
Package dbtest provides PostgreSQL test helpers: a real Postgres container and a fake server that rejects logins.
internal/jwttest
Package jwttest serves a test OIDC issuer for runtime authentication tests.
Package jwttest serves a test OIDC issuer for runtime authentication tests.
internal/runtimeauth
Package runtimeauth authenticates Substrate actors without granting user authority.
Package runtimeauth authenticates Substrate actors without granting user authority.
internal/scheduling
Package scheduling contains scheduling semantics shared across services.
Package scheduling contains scheduling semantics shared across services.
internal/service/agentidentity
Package agentidentity resolves metadata using narrowly scoped Actor credentials.
Package agentidentity resolves metadata using narrowly scoped Actor credentials.
internal/service/authscope
Package authscope validates and evaluates collection scopes over named identities.
Package authscope validates and evaluates collection scopes over named identities.
internal/service/bootstrap
Package bootstrap authorizes configuration reads before a Session exists.
Package bootstrap authorizes configuration reads before a Session exists.
internal/service/inventoryauth
Package inventoryauth matches collection scopes against trusted inventory identities.
Package inventoryauth matches collection scopes against trusted inventory identities.
internal/service/taskstore
Package taskstore owns the private persistence API used by runtime SDKs.
Package taskstore owns the private persistence API used by runtime SDKs.
internal/skillsinit
Package skillsinit fetches skill and plugin artifacts from remote sources.
Package skillsinit fetches skill and plugin artifacts from remote sources.
internal/translator/claude
Package claude compiles resolved v1alpha3 inputs for the native Claude Harness adapter.
Package claude compiles resolved v1alpha3 inputs for the native Claude Harness adapter.
internal/translator/codex
Package codex compiles resolved v1alpha3 inputs for the native Codex Harness adapter.
Package codex compiles resolved v1alpha3 inputs for the native Codex Harness adapter.
pkg/app
Package app boots the kagent controller.
Package app boots the kagent controller.
pkg/config
Package config loads explicit CLI and controller configuration.
Package config loads explicit CLI and controller configuration.
pkg/egresspolicy
Package egresspolicy lets an embedding controller extend actor EgressPolicies.
Package egresspolicy lets an embedding controller extend actor EgressPolicies.
pkg/env
Package env provides a centralized registry for environment variables used throughout kagent.
Package env provides a centralized registry for environment variables used throughout kagent.
pkg/install
Package install plans and applies kagent installations without command-line or terminal dependencies.
Package install plans and applies kagent installations without command-line or terminal dependencies.
pkg/migrations
Package migrations embeds the SQL migration files for the kagent database schema and provides the runner that applies them at startup.
Package migrations embeds the SQL migration files for the kagent database schema and provides the runner that applies them at startup.
pkg/postgres
Package postgres builds kagent's PostgreSQL connection pool configuration.
Package postgres builds kagent's PostgreSQL connection pool configuration.
pkg/postgressetup
Package postgressetup provides the PostgreSQL identity setup for Kagent.
Package postgressetup provides the PostgreSQL identity setup for Kagent.
test/byoa2a command
harness
claude/cmd command
Command kagent-claude runs the Claude Harness runtime adapter.
Command kagent-claude runs the Claude Harness runtime adapter.
claude/config
Package config defines the versioned, non-secret Claude Harness runtime configuration shared by its compiler and Actor entrypoint.
Package config defines the versioned, non-secret Claude Harness runtime configuration shared by its compiler and Actor entrypoint.
claude/executor
Package executor builds the Claude Harness A2A executor for kagent-claude and for binaries that embed the harness elsewhere.
Package executor builds the Claude Harness A2A executor for kagent-claude and for binaries that embed the harness elsewhere.
claude/internal/adapter
Package adapter constructs the Claude runtime from compiler-owned configuration and Actor-owned paths.
Package adapter constructs the Claude runtime from compiler-owned configuration and Actor-owned paths.
claude/internal/driver
Package driver translates Claude Code's streaming process protocol into the runtime-neutral events consumed by the shared A2A executor.
Package driver translates Claude Code's streaming process protocol into the runtime-neutral events consumed by the shared A2A executor.
codex/cmd command
Command kagent-codex runs the Codex Harness runtime adapter.
Command kagent-codex runs the Codex Harness runtime adapter.
codex/config
Package config defines the versioned, non-secret Codex Harness runtime configuration shared by its compiler and Actor entrypoint.
Package config defines the versioned, non-secret Codex Harness runtime configuration shared by its compiler and Actor entrypoint.
codex/executor
Package executor builds the Codex Harness A2A executor for kagent-codex and for binaries that embed the harness elsewhere.
Package executor builds the Codex Harness A2A executor for kagent-codex and for binaries that embed the harness elsewhere.
codex/internal/adapter
Package adapter validates and materializes compiler-owned Codex state.
Package adapter validates and materializes compiler-owned Codex state.
codex/internal/driver
Package driver translates the Codex App Server protocol into the runtime-neutral events consumed by the shared A2A executor.
Package driver translates the Codex App Server protocol into the runtime-neutral events consumed by the shared A2A executor.
internal/utils
Package utils provides small, shared operating-system helpers for Harness runtimes.
Package utils provides small, shared operating-system helpers for Harness runtimes.
runtime
Package runtime defines the minimal turn and event vocabulary shared by Harness runtime adapters.
Package runtime defines the minimal turn and event vocabulary shared by Harness runtime adapters.
runtime/a2a
Package a2a supervises Harness runtime turns behind kagent's private A2A service.
Package a2a supervises Harness runtime turns behind kagent's private A2A service.
runtime/continuation
Package continuation persists the private native conversation identity owned by one Harness Actor.
Package continuation persists the private native conversation identity owned by one Harness Actor.
pkg
telemetry
Package telemetry boots the OpenTelemetry SDK from explicit configuration with standard OTEL environment overrides.
Package telemetry boots the OpenTelemetry SDK from explicit configuration with standard OTEL environment overrides.
telemetry/conv
Package conv holds the attribute and metric names of the kagent telemetry contract.
Package conv holds the attribute and metric names of the kagent telemetry contract.
telemetry/telemetrytest
Package telemetrytest checks the shape of exported telemetry in tests.
Package telemetrytest checks the shape of exported telemetry in tests.
tracing
Package tracing holds the invocation span contract shared by kagent runtimes.
Package tracing holds the invocation span contract shared by kagent runtimes.
workspace
Package workspace owns repository initialization and its durable receipt.
Package workspace owns repository initialization and its durable receipt.
sandbox
guest/cmd command

Jump to

Keyboard shortcuts

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