types

package
v0.68.4 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 0 Imported by: 0

README

types Package

The types package provides shared type definitions used across multiple gh-aw packages to avoid circular dependencies.

Overview

This package defines common data structures that are shared between the parser and workflow packages. Centralizing these types here allows both packages to reference the same definitions without creating import cycles.

Types

BaseMCPServerConfig

The foundational configuration structure for MCP (Model Context Protocol) servers. This type is embedded by both parser.MCPServerConfig and workflow.MCPServerConfig.

MCP servers can run as:

  • stdio processes: Command + Args, launched as a child process.
  • HTTP endpoints: URL + optional Headers and Auth, reached over HTTP/HTTPS.
  • Container services: Container image + optional Mounts, run inside a container.
import "github.com/github/gh-aw/pkg/types"

// Stdio MCP server
cfg := types.BaseMCPServerConfig{
    Type:    "stdio",
    Command: "npx",
    Args:    []string{"-y", "@modelcontextprotocol/server-filesystem"},
    Env: map[string]string{
        "ALLOWED_PATHS": "/workspace",
    },
}

// HTTP MCP server with OIDC auth
cfg := types.BaseMCPServerConfig{
    Type: "http",
    URL:  "https://my-mcp-server.example.com",
    Auth: &types.MCPAuthConfig{
        Type:     "github-oidc",
        Audience: "https://my-mcp-server.example.com",
    },
}
Fields
Field Type Description
Type string Server type: "stdio", "http", "local", or "remote"
Command string Executable to launch (stdio mode)
Args []string Arguments passed to the command
Env map[string]string Environment variables injected into the process
Version string Optional version or tag
URL string HTTP endpoint URL (HTTP mode)
Headers map[string]string Additional HTTP headers (HTTP mode)
Auth *MCPAuthConfig Upstream authentication (HTTP mode only)
Container string Container image (container mode)
Entrypoint string Optional entrypoint override for the container
EntrypointArgs []string Arguments passed to the container entrypoint
Mounts []string Volume mounts in "source:dest:mode" format
MCPAuthConfig

Authentication configuration for HTTP MCP servers. When configured, the MCP gateway dynamically acquires tokens and injects them as Authorization headers on each outgoing request.

auth := &types.MCPAuthConfig{
    Type:     "github-oidc", // Currently the only supported type
    Audience: "https://my-service.example.com",
}
Field Type Description
Type string Auth type; currently only "github-oidc" is supported
Audience string OIDC token audience (aud claim); defaults to the server URL if omitted
TokenWeights

Defines custom model cost information for effective token computation. Specified under engine.token-weights in workflow frontmatter and stored in aw_info.json at runtime.

weights := types.TokenWeights{
    Multipliers: map[string]float64{
        "gpt-4o": 2.5,
    },
    TokenClassWeights: &types.TokenClassWeights{
        Input:  1.0,
        Output: 3.0,
    },
}
TokenClassWeights

Per-token-class weights for effective token computation. Each field corresponds to one token class; a zero value means "use the default weight".

Field Token class
Input Standard input tokens
CachedInput Cache-hit input tokens
Output Generated output tokens
Reasoning Internal reasoning tokens
CacheWrite Cache-write tokens

Design Notes

  • This package has no dependencies on other gh-aw packages, making it safe to import from anywhere.
  • All struct fields use both json and yaml struct tags so they can be round-tripped through both serialization formats.
  • BaseMCPServerConfig is designed to be embedded — packages add domain-specific fields and validation on top of the shared base.

Documentation

Overview

Package types provides shared type definitions used across gh-aw packages.

This package contains common data structures and interfaces that are used by multiple packages to avoid circular dependencies and maintain clean separation of concerns. The types here are focused on configuration structures that need to be shared between parsing and workflow compilation.

Key Types

BaseMCPServerConfig: The foundational configuration structure for MCP (Model Context Protocol) servers. This type is embedded by both parser and workflow packages to maintain consistency while allowing each package to add domain-specific fields.

MCP servers are AI tool providers that can run as:

  • stdio processes (command + args)
  • HTTP endpoints (url + headers)
  • Container services (container image + mounts)

Basic Usage

config := types.BaseMCPServerConfig{
	Type:    "stdio",
	Command: "npx",
	Args:    []string{"-y", "@modelcontextprotocol/server-filesystem"},
	Env: map[string]string{
		"ALLOWED_PATHS": "/workspace",
	},
}

Architecture

This package serves as a bridge between the parser package (which reads workflow markdown files) and the workflow package (which generates GitHub Actions YAML). By defining shared types here, we avoid circular imports and ensure consistent configuration structures.

The types are designed to be:

  • Serializable to JSON and YAML
  • Embeddable by other packages
  • Extensible with package-specific fields
  • Well-documented with struct tags

pkg/parser - Embeds BaseMCPServerConfig in parser.MCPServerConfig

pkg/workflow - Embeds BaseMCPServerConfig in workflow.MCPServerConfig

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseMCPServerConfig

type BaseMCPServerConfig struct {
	// Common execution fields
	Command string            `json:"command,omitempty" yaml:"command,omitempty"` // Command to execute (for stdio mode)
	Args    []string          `json:"args,omitempty" yaml:"args,omitempty"`       // Arguments for the command
	Env     map[string]string `json:"env,omitempty" yaml:"env,omitempty"`         // Environment variables

	// Type and version
	Type    string `json:"type,omitempty" yaml:"type,omitempty"`       // MCP server type (stdio, http, local, remote)
	Version string `json:"version,omitempty" yaml:"version,omitempty"` // Optional version/tag

	// HTTP-specific fields
	URL     string            `json:"url,omitempty" yaml:"url,omitempty"`         // URL for HTTP mode MCP servers
	Headers map[string]string `json:"headers,omitempty" yaml:"headers,omitempty"` // HTTP headers for HTTP mode
	Auth    *MCPAuthConfig    `json:"auth,omitempty" yaml:"auth,omitempty"`       // Upstream authentication config (HTTP mode only)

	// Container-specific fields
	Container      string   `json:"container,omitempty" yaml:"container,omitempty"`           // Container image for the MCP server
	Entrypoint     string   `json:"entrypoint,omitempty" yaml:"entrypoint,omitempty"`         // Optional entrypoint override for container
	EntrypointArgs []string `json:"entrypointArgs,omitempty" yaml:"entrypointArgs,omitempty"` // Arguments passed to container entrypoint
	Mounts         []string `json:"mounts,omitempty" yaml:"mounts,omitempty"`                 // Volume mounts for container (format: "source:dest:mode")
}

BaseMCPServerConfig contains the shared fields common to all MCP server configurations. This base type is embedded by both parser.MCPServerConfig and workflow.MCPServerConfig to eliminate duplication while allowing each to have domain-specific fields and struct tags.

type MCPAuthConfig added in v0.65.1

type MCPAuthConfig struct {
	// Type is the authentication type. Currently only "github-oidc" is supported.
	Type string `json:"type" yaml:"type"`
	// Audience is the intended audience (aud claim) for the OIDC token.
	// If omitted, defaults to the server's url field.
	Audience string `json:"audience,omitempty" yaml:"audience,omitempty"`
}

MCPAuthConfig represents upstream authentication configuration for an HTTP MCP server. When configured, the gateway dynamically acquires tokens and injects them as Authorization headers on every outgoing request. Currently only GitHub Actions OIDC is supported.

type TokenClassWeights added in v0.65.6

type TokenClassWeights struct {
	Input       float64 `json:"input,omitempty"`
	CachedInput float64 `json:"cached-input,omitempty"`
	Output      float64 `json:"output,omitempty"`
	Reasoning   float64 `json:"reasoning,omitempty"`
	CacheWrite  float64 `json:"cache-write,omitempty"`
}

TokenClassWeights holds per-token-class weights for effective token computation. Each field corresponds to one token class; a zero value means "use default". The JSON keys use hyphens to match the frontmatter schema (engine.token-weights.token-class-weights).

type TokenWeights added in v0.65.6

type TokenWeights struct {
	// Multipliers maps model names to cost multipliers relative to the reference model.
	// Keys are matched case-insensitively with prefix matching as a fallback.
	Multipliers map[string]float64 `json:"multipliers,omitempty"`
	// TokenClassWeights overrides the per-token-class weights used before the model multiplier.
	// A nil pointer means no overrides; individual zero fields mean "use default".
	TokenClassWeights *TokenClassWeights `json:"token-class-weights,omitempty"`
}

TokenWeights defines custom model cost information for effective token computation. It mirrors the structure of model_multipliers.json and allows per-workflow overrides. Specified under engine.token-weights in the workflow frontmatter and stored in aw_info.json at runtime.

Jump to

Keyboard shortcuts

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