dispatch

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const CloudRepoLimit = 5

CloudRepoLimit caps how many repos the cloud mode may query in one request.

View Source
const GitHubForge = "gh"

GitHubForge is the forge token entire.io gives GitHub repos.

View Source
const NativeForge = "et"

NativeForge is the forge token of Entire-native repos.

View Source
const RepoSlugShapes = "gh/<owner>/<repo> or et/<project>/<repo>"

RepoSlugShapes lists every --repos shape, for error text.

Variables

This section is empty.

Functions

func GitHubRepoName added in v0.11.0

func GitHubRepoName(slug string) (string, bool)

GitHubRepoName returns the owner/repo of a gh/ slug. ok is false for every other forge or shape: there is no github.com page for it.

func NormalizeWindow

func NormalizeWindow(since, until time.Time) (time.Time, time.Time)

func ParseSinceAtNow

func ParseSinceAtNow(value string, now time.Time) (time.Time, error)

ParseSinceAtNow parses durations like 7d, relative times like "2 days ago", RFC3339 timestamps, and ISO dates.

func ParseUntilAtNow

func ParseUntilAtNow(value string, now time.Time) (time.Time, error)

func RenderMarkdown

func RenderMarkdown(dispatch *Dispatch) string

func SplitRepoSlug added in v0.11.0

func SplitRepoSlug(value string) (forge, name string, ok bool)

SplitRepoSlug parses "forge/owner/repo" into a forge token and an owner/repo name. A bare owner/repo names no forge and is refused: both forges take that shape, so guessing one would reintroduce the collision the prefix exists to prevent (the same trade `repo clone` makes). ok is false for any other shape or an unknown forge token.

Types

type APIBranches

type APIBranches struct {
	Values []string
	All    bool
}

func (*APIBranches) UnmarshalJSON

func (b *APIBranches) UnmarshalJSON(data []byte) error

type APIBullet

type APIBullet struct {
	CheckpointID string   `json:"checkpoint_id"`
	Text         string   `json:"text"`
	Source       string   `json:"source"`
	Branch       string   `json:"branch"`
	CreatedAt    string   `json:"created_at"`
	Labels       []string `json:"labels"`
}

type APIRepo

type APIRepo struct {
	FullName string       `json:"full_name"`
	URL      string       `json:"url,omitempty"`
	Sections []APISection `json:"sections"`
}

type APISection

type APISection struct {
	Label   string      `json:"label"`
	Bullets []APIBullet `json:"bullets"`
}

type APITotals

type APITotals struct {
	Checkpoints         int `json:"checkpoints"`
	UsedCheckpointCount int `json:"used_checkpoint_count"`
	Branches            int `json:"branches"`
	FilesTouched        int `json:"files_touched"`
}

type APIWarnings

type APIWarnings struct {
	AccessDeniedCount  int `json:"access_denied_count"`
	PendingCount       int `json:"pending_count"`
	FailedCount        int `json:"failed_count"`
	UnknownCount       int `json:"unknown_count"`
	UncategorizedCount int `json:"uncategorized_count"`
	TruncatedCount     int `json:"truncated_count"`
}

type APIWindow

type APIWindow struct {
	NormalizedSince          string `json:"normalized_since"`
	NormalizedUntil          string `json:"normalized_until"`
	FirstCheckpointCreatedAt string `json:"first_checkpoint_created_at,omitempty"`
	LastCheckpointCreatedAt  string `json:"last_checkpoint_created_at,omitempty"`
}

type Bullet

type Bullet struct {
	CheckpointID string
	Text         string
	Source       string
	Branch       string
	CreatedAt    time.Time
	Labels       []string
}

type CloudClient

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

func NewCloudClient

func NewCloudClient(cfg CloudConfig) *CloudClient

func (*CloudClient) CreateDispatch

func (c *CloudClient) CreateDispatch(ctx context.Context, reqBody CreateDispatchRequest, jurisdiction string) (*CreateDispatchResponse, error)

CreateDispatch generates a one-off dispatch from the cell of `jurisdiction` ("" = the caller's home jurisdiction).

type CloudConfig

type CloudConfig struct {
	BaseURL string
	Token   string
	HTTP    *http.Client
	Timeout time.Duration
}

type CreateDispatchRequest

type CreateDispatchRequest struct {
	Repos    []string `json:"repos,omitempty"`
	Since    string   `json:"since"`
	Until    string   `json:"until"`
	Generate bool     `json:"generate"`
	Voice    string   `json:"voice,omitempty"`
}

type CreateDispatchResponse

type CreateDispatchResponse struct {
	// Jurisdiction is the slug the gateway stamps onto the response: the
	// jurisdiction whose cell the dispatch was generated from. Empty from a
	// gateway that predates the selector — see runServer for how a sent
	// selector is checked against it.
	Jurisdiction      string      `json:"jurisdiction,omitempty"`
	Window            APIWindow   `json:"window"`
	Title             string      `json:"title,omitempty"`
	CoveredRepos      []string    `json:"covered_repos,omitempty"`
	Branches          APIBranches `json:"branches,omitempty"`
	Voice             *string     `json:"voice"`
	Repos             []APIRepo   `json:"repos,omitempty"`
	Totals            APITotals   `json:"totals"`
	Warnings          APIWarnings `json:"warnings"`
	GeneratedText     string      `json:"generated_text,omitempty"`
	GeneratedMarkdown string      `json:"generated_markdown,omitempty"`
}

type Dispatch

type Dispatch struct {
	Window        Window
	CoveredRepos  []string
	Repos         []RepoGroup
	GeneratedText string
}

func Run

func Run(ctx context.Context, opts Options) (*Dispatch, error)

type Mode

type Mode int
const (
	ModeServer Mode = iota
	ModeLocal
)

func (Mode) String

func (m Mode) String() string

type Options

type Options struct {
	Mode                  Mode
	RepoPaths             []string
	Since                 string
	Until                 string
	Branches              []string
	AllBranches           bool
	ImplicitCurrentBranch bool
	Voice                 string
	// Jurisdiction is the slug (e.g. "us") of the jurisdiction whose cell
	// generates a cloud dispatch. Empty means the caller's home
	// jurisdiction — the pre-selector behaviour. Cloud mode only.
	Jurisdiction     string
	InsecureHTTPAuth bool
	TextGenerator    TextGenerator
	Model            string
	// contains filtered or unexported fields
}

func PrepareLocal added in v0.9.0

func PrepareLocal(ctx context.Context, opts Options) (Options, error)

PrepareLocal validates and resolves the inputs needed before local dispatch generation can begin. The returned options can be passed to Run without repeating time-window parsing or repository-root discovery.

func ResolveOptions

func ResolveOptions(
	flagLocal bool,
	flagSince string,
	flagUntil string,
	flagAllBranches bool,
	flagRepos []string,
	flagVoice string,
	flagJurisdiction string,
	flagInsecureHTTPAuth bool,
	currentBranch func() (string, error),
) (Options, error)

type RepoGroup

type RepoGroup struct {
	FullName string
	URL      string
	Sections []Section
}

type RepoNotFoundError added in v0.10.4

type RepoNotFoundError struct {
	Jurisdiction string
	Home         string
	Repos        []string
	Message      string
	Cause        error
}

RepoNotFoundError is the gateway's 404 for a repo that is not placed in (or not visible in) the jurisdiction the request was routed to — a repo mirrored only in US, requested from an AU home, is simply unknown to the AU cell. Jurisdiction is the selector the caller sent ("" = home) and Home the caller's home jurisdiction when known (so callers know which cell answered when no selector was sent); Repos are the requested slugs the gateway's message named; Message is its sentence; Cause is the underlying *api.HTTPError.

func (*RepoNotFoundError) Error added in v0.10.4

func (e *RepoNotFoundError) Error() string

func (*RepoNotFoundError) FailedJurisdiction added in v0.10.4

func (e *RepoNotFoundError) FailedJurisdiction() string

FailedJurisdiction is the jurisdiction whose cell answered "not found": the selector when one was sent, else the home jurisdiction ("" if unknown).

func (*RepoNotFoundError) Unwrap added in v0.10.4

func (e *RepoNotFoundError) Unwrap() error

type Section

type Section struct {
	Label   string
	Bullets []Bullet
}

type TextGenerator added in v0.9.0

type TextGenerator interface {
	GenerateText(ctx context.Context, prompt string, model string) (string, error)
}

type Voice

type Voice struct {
	Name string
	Text string
}

func ResolveVoice

func ResolveVoice(value string) Voice

type Window

type Window struct {
	NormalizedSince   time.Time
	NormalizedUntil   time.Time
	FirstCheckpointAt time.Time
	LastCheckpointAt  time.Time
}

Jump to

Keyboard shortcuts

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