Help us shape the future of Go! Take the 2026 Go Developer Survey

agentrunner

package
v0.0.204 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package agentrunner provides lean parent-agent detection with no heavy deps. Consumers (e.g. tsk status auto-format) can import this package without pulling in subagent, logging, or UI code.

Index

Constants

This section is empty.

Variables

View Source
var TestProcessNameFunc func(pid int) string

TestProcessNameFunc, when non-nil, overrides PID → process-name lookup used during parent-process detection. Tests set this to inject a fake process tree.

Functions

func Detect

func Detect(opts Options) (runner string, ok bool)

Detect reports the parent agent runner if one is found. Priority:

  1. Options.AgentRunnerEnv env override (if name non-empty and set)
  2. CODEX_THREAD_ID → "codex"
  3. PI_CODING_AGENT → "pi"
  4. parent process name: opencode|pi|crush|codex|grok
  5. grandparent: pi|grok

Types

type Options

type Options struct {
	// AgentRunnerEnv is the env var name for explicit override (empty = skip).
	AgentRunnerEnv string
	// EnvLookup, when non-nil, is consulted before os.Getenv for detection env
	// keys. Return (value, true) to force a value (empty = treat as unset);
	// ("", false) falls through to the process environment. Request-scoped.
	EnvLookup func(key string) (string, bool)
}

Options configures detection.

Jump to

Keyboard shortcuts

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