adhoc

package
v0.0.218 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 12 Imported by: 1 module, 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.

README

Process-scoped Codex Responses connections

Connection is a versioned, non-secret session binding: provider identity, base URL, raw upstream model, reasoning policy, and a credential reference. It is independent of Marcus, model-directory discovery, and llm-proxy.

connection := &adhoc.Connection{
    Version: adhoc.Version,
    Provider: "my-gateway",
    BaseURL: "http://127.0.0.1:9000/v1",
    Model: "raw-upstream-model",
    Reasoning: adhoc.ReasoningPolicy{
        Requested: "high", Effort: "high",
        Supported: []string{"low", "high"}, Origin: "api",
    },
    Auth: adhoc.Credential{File: "/existing/private/token"},
}
// Set agentrunapi.Opts.CodexConnection or agentrunapi.RunOpts.CodexConnection.
// The host application must dispatch agentruncli.Handle for re-exec, including
// the internal __codex-adhoc-exec receiver. Native sessions need no connection.

The normal lifecycle reserves the binding before launch, restores it on retry/resume, and preserves existing native sessions. Apply(argv, interactive) is the lower-level pure compiler: call it before appending prompts/separators. It returns process-only provider overrides, responses, a raw model, and TUI --no-daemon; it does not read a credential or write config. Caller model/provider/effort conflicts fail closed.

SupportedEfforts means direct wire-compatible values verified with Codex 0.166.0, not a claim that every provider/model supports them. max passes through. CLI ultra maps to wire xhigh, so is excluded from this direct-effort vocabulary. Newer/older Codex versions need re-verification; unsupported flags/values must fail rather than route elsewhere.

Credentials may reference a process environment key, existing token file, or JSON pointer with non-secret identity guards. Optional SHA256 pins are available when value identity must also remain fixed. Use PublicToken only for an explicitly public dummy marker, never a real credential. Do not put secrets in guards, connection fields, session Env, argv, logs, or UI DTOs. ValidatePersistedEnv enforces the owned credential-variable boundary; the final receiver resolves the reference immediately before replacing the Codex process. On Windows it uses an stdio-connected child instead of Unix exec.

The actual host driver must support --require-codex-connection-v1; use agentdriver.VerifyCodexAdhoc rather than relying on the parent SDK's version. Follow-up commands must carry the guard and the same store home. A stale receiver or missing/corrupt binding fails closed.

Tests: public compile/reference tests, agentrunapi lifecycle hooks, real receiver subprocess boundary, plus opt-in AGENT_PRO_TEST_REAL_CODEX=1 go test -v ./agent/codex/adhoc. Real Codex only contacts local SSE mocks. GPT-5.5 covers conventional shell tools; GPT-6.1-Sol covers text/SSE and effort mapping, not code-mode tool execution. Temporary config fixtures are test isolation, not a production configuration writer.

Documentation

Overview

Package adhoc implements process-scoped Codex Responses connections. It never creates or rewrites Codex configuration, auth, or model-catalog files.

Index

Constants

View Source
const TokenEnv = "AGENT_PRO_CODEX_AUTH_TOKEN"
View Source
const Version = 1

Variables

This section is empty.

Functions

func FilterEfforts

func FilterEfforts(values []string) []string

func SupportedEfforts

func SupportedEfforts() []string

SupportedEfforts is the direct Responses wire vocabulary verified with Codex 0.166, not an upstream capability claim. max is passed through; ultra is a CLI orchestration level that emits xhigh, so it cannot represent API effort ultra.

func SupportsEffort

func SupportsEffort(e string) bool

Types

type Connection

type Connection struct {
	Version   int             `json:"version"`
	Provider  string          `json:"provider"`
	BaseURL   string          `json:"base_url"`
	Model     string          `json:"model"`
	Reasoning ReasoningPolicy `json:"reasoning"`
	Auth      Credential      `json:"auth"`
}

Connection is safe to persist: Auth contains references or an explicitly public dummy credential, never a private bearer token.

func (Connection) Apply

func (c Connection) Apply(argv []string, interactive bool) ([]string, error)

Apply compiles provider flags without touching files or resolving a secret. It rejects conflicting caller flags rather than silently routing elsewhere. Call before appending a positional prompt. interactive applies to TUI/resume, not to codex exec (which doesn't accept --no-daemon).

func (Connection) ChildEnv

func (c Connection) ChildEnv(inherited []string) ([]string, error)

ChildEnv removes a stale reserved token and injects this credential only into the final Codex child. Never feed the returned slice into persisted RunOptions.Env.

func (*Connection) Clone

func (c *Connection) Clone() *Connection

func (Connection) ProviderID

func (c Connection) ProviderID() string

ProviderID is deterministic across resume and independent of display labels.

func (Connection) Validate

func (c Connection) Validate() error

func (Connection) ValidatePersistedEnv

func (c Connection) ValidatePersistedEnv(entries []string) error

ValidatePersistedEnv prevents callers from accidentally sending the provider secret through the legacy persisted Env / env-file transport. File/JSON refs or a value inherited by the final wrapper are the supported private sources.

type Credential

type Credential struct {
	EnvKey      string            `json:"env_key,omitempty"`
	File        string            `json:"file,omitempty"`
	JSONPointer string            `json:"json_pointer,omitempty"`
	Guards      map[string]string `json:"guards,omitempty"`
	PublicToken string            `json:"public_token,omitempty"`
	// SHA256 optionally pins unnamed inline credentials against accidental reorder.
	SHA256 string `json:"sha256,omitempty"`
}

Credential is a non-secret reference resolved in the final spawn process. PublicToken is ONLY for public proxy-managed dummy values, not API secrets.

func (Credential) Empty

func (c Credential) Empty() bool

func (Credential) Resolve

func (c Credential) Resolve(environ []string) (string, error)

func (Credential) Validate

func (c Credential) Validate() error

type ReasoningPolicy

type ReasoningPolicy struct {
	Requested string   `json:"requested,omitempty"`
	Effort    string   `json:"effort,omitempty"`
	Supported []string `json:"supported,omitempty"`
	Origin    string   `json:"origin,omitempty"`
}

Jump to

Keyboard shortcuts

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