manage

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 19 Imported by: 0 modules, 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.

Documentation

Overview

Package manage is a small client for the DocsGPT account-level ("management") API: identity, agents (list/export/plan/apply/delete), sources (list/upload/task status/delete), prompts and tools. Every request carries a personal access token as `Authorization: Bearer dgpt_pat_…`.

Failures reported by the server are returned as *APIError, which surfaces the server `message`, the machine-readable `error` code and, for insufficient_scope, the scope the token is missing.

Index

Constants

View Source
const (
	StatusMatched     = "matched"     // source / built-in model id resolved
	StatusMissing     = "missing"     // source name not found for this user
	StatusReuse       = "reuse"       // tool / prompt / custom model already exists
	StatusCreate      = "create"      // will be created from the file
	StatusBuiltin     = "builtin"     // built-in tool available on this instance
	StatusUnavailable = "unavailable" // tool type / model id unknown to this instance
	StatusDefault     = "default"     // prompt: the agent uses the default prompt
)

Plan statuses reported by POST /api/import_agent/plan.

View Source
const (
	DefaultTimeout       = 60 * time.Second // JSON requests
	DefaultUploadTimeout = 15 * time.Minute // multipart uploads
)

Timeouts applied when the caller's context carries no earlier deadline.

View Source
const (
	CodeInvalidToken       = "invalid_token"
	CodeInsufficientScope  = "insufficient_scope"
	CodeResourceNotAllowed = "resource_not_allowed"
	CodeNotForTokens       = "not_available_to_tokens" // endpoint has no token scope at all
)

Server error codes (the JSON `error` field).

View Source
const DeduplicatedTaskID = "deduplicated"

DeduplicatedTaskID is the task_id sentinel the server returns when an Idempotency-Key repeat matched a request whose task record is gone: the original ingest already ran, and there is nothing left to poll.

View Source
const DefaultUserAgent = "docsgpt-cli"

DefaultUserAgent is used when the caller does not stamp a version.

View Source
const IdempotencyKeyMaxLen = 256

IdempotencyKeyMaxLen mirrors the server's Idempotency-Key limit.

View Source
const KindAgent = "Agent"

KindAgent is the only document kind the import API accepts.

View Source
const WebhookPath = "/api/webhooks/agents/"

WebhookPath is the path of an agent's incoming webhook, up to its token.

Variables

View Source
var TriggerPoll = WaitOptions{Initial: time.Second, Max: 5 * time.Second}

TriggerPoll is the --wait cadence: agent runs finish in seconds to minutes, so the backoff tops out sooner than an ingest's.

Functions

func DeriveIdempotencyKey

func DeriveIdempotencyKey(name string, paths []string) (string, error)

DeriveIdempotencyKey builds a deterministic Idempotency-Key from the source name and the SHA-256 of every file (paired with its base name, order independent). The same name + content always yields the same key, so a CI retry of an upload is deduplicated server-side; any change to the name, a filename or a byte of content yields a new key.

func IsInsufficientScope

func IsInsufficientScope(err error) bool

IsInsufficientScope reports whether err is a missing-scope rejection.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound reports whether err is a 404.

func IsResourceNotAllowed

func IsResourceNotAllowed(err error) bool

IsResourceNotAllowed reports whether err is a resource-restriction rejection.

func IsUnauthorized

func IsUnauthorized(err error) bool

IsUnauthorized reports whether err is a 401 / invalid_token rejection.

func ReadPayload added in v1.7.0

func ReadPayload(file string, stdin io.Reader) ([]byte, error)

ReadPayload reads a webhook payload from a file or stdin ("-") and checks it is JSON the webhook accepts: the server refuses a missing body and null.

func SplitYAMLDocuments

func SplitYAMLDocuments(text string) []string

SplitYAMLDocuments splits a YAML stream on its document markers, keeping each document's text verbatim (the server receives exactly what was written). A `---` line starts a document and a `...` line ends one; the YAML spec forbids both at column 0 inside any scalar, so a textual split is exact. Chunks that are entirely blank are dropped; chunks holding only comments are kept and discarded by ParseDocuments.

Types

type APIError

type APIError struct {
	Method        string
	Path          string
	Status        int
	Code          string // server `error` field, e.g. insufficient_scope
	Message       string // server `message` field
	RequiredScope string // server `required_scope` (insufficient_scope only)
	Body          string // truncated raw body, for diagnostics
}

APIError is a failure reported by the server (any non-2xx response, or a 2xx body with success:false).

func (*APIError) Error

func (e *APIError) Error() string

type Agent

type Agent struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Slug        string `json:"slug"`
	Description string `json:"description"`
	AgentType   string `json:"agent_type"`
	Status      string `json:"status"`
	Ownership   string `json:"ownership"`
	UpdatedAt   any    `json:"updated_at"`
}

Agent is the subset of an agent document the CLI renders. The full server document is available through the raw return of ListAgents.

type AgentRun added in v1.6.1

type AgentRun struct {
	Answer    string
	ToolCalls int
}

AgentRun is what a finished webhook task reports: {"status":"success","result":{"answer","sources","tool_calls","thought"}}.

func AgentRunResult added in v1.6.1

func AgentRunResult(taskID string, t *TaskStatus) (*AgentRun, error)

AgentRunResult decodes the result of a SUCCESS webhook task.

type AgentRunFailedError added in v1.6.1

type AgentRunFailedError struct {
	TaskID string
	Status string
	Detail string
}

AgentRunFailedError is a webhook task that finished as SUCCESS but whose result reports a failed run: the worker returns, rather than raises, errors that a retry cannot fix ({"status":"quota_exceeded","error":…}) and the idempotency guard's give-up ({"success":false,"error":…}).

func (*AgentRunFailedError) Error added in v1.6.1

func (e *AgentRunFailedError) Error() string

type ApplyResult

type ApplyResult struct {
	AgentID   string   `json:"agent_id"`
	Action    string   `json:"action"` // created | updated
	Status    string   `json:"status"` // draft on create; unchanged on update
	AgentType string   `json:"agent_type"`
	Slug      string   `json:"slug"`
	Warnings  []string `json:"warnings"`
}

ApplyResult is the POST /api/import_agent reply.

type Blocker

type Blocker struct {
	Kind   string `json:"kind"` // source | tool | model
	Ref    string `json:"ref"`  // source name, tool key, model id/name
	Status string `json:"status"`
	Hint   string `json:"hint"`
}

Blocker is one unresolved reference that stops an apply.

func (Blocker) String

func (b Blocker) String() string

type Client

type Client struct {
	BaseURL   string
	Token     string
	UserAgent string // "docsgpt-cli/<version>"

	Timeout       time.Duration // per JSON request; 0 = DefaultTimeout
	UploadTimeout time.Duration // per upload; 0 = DefaultUploadTimeout
}

Client talks to one DocsGPT deployment with one personal access token.

func New

func New(baseURL, token, userAgent string) *Client

New returns a client for baseURL authenticating with token.

func (*Client) AgentWebhook added in v1.6.1

func (c *Client) AgentWebhook(ctx context.Context, agentID string) (*Webhook, error)

AgentWebhook calls GET /api/agent_webhook?id= (scope agents:keys) and returns the agent's incoming webhook. The server creates the webhook token if the agent has none yet. The server builds the URL from its API_URL setting, which is not always the address this client reaches it at (a self-hosted default is http://localhost:7091), so the token is re-rooted on c.BaseURL.

func (*Client) ApplyImport

func (c *Client) ApplyImport(ctx context.Context, yamlDoc string, res *Resolution) (*ApplyResult, error)

ApplyImport calls POST /api/import_agent with {"yaml": <document>, "resolution": {...}} (scope agents:write). A new agent is created as a draft; an update keeps the matched agent's status.

func (*Client) DeleteAgent

func (c *Client) DeleteAgent(ctx context.Context, id string) error

DeleteAgent calls DELETE /api/delete_agent?id= (scope agents:write).

func (*Client) DeleteSource

func (c *Client) DeleteSource(ctx context.Context, id string) error

DeleteSource calls GET /api/delete_old?source_id= (scope sources:write). The server exposes the deletion as a GET.

func (*Client) ExportAgent

func (c *Client) ExportAgent(ctx context.Context, id string) ([]byte, error)

ExportAgent calls GET /api/export_agent?id= and returns the YAML document (scope agents:read).

func (*Client) GetTaskStatus

func (c *Client) GetTaskStatus(ctx context.Context, taskID string) (*TaskStatus, error)

GetTaskStatus calls GET /api/task_status?task_id= (any of sources:read, sources:write or chat:run).

func (*Client) Ingest added in v1.7.0

func (c *Client) Ingest(ctx context.Context, opts IngestOptions) (report *UploadReport, err error)

Ingest uploads the files as a new source and, with Wait, polls the ingest task, then applies Replace. The report is nil when the upload itself failed; otherwise it carries the error too.

func (*Client) ListAgents

func (c *Client) ListAgents(ctx context.Context) ([]Agent, json.RawMessage, error)

ListAgents calls GET /api/get_agents (scope agents:read).

func (*Client) ListPrompts

func (c *Client) ListPrompts(ctx context.Context) ([]Prompt, json.RawMessage, error)

ListPrompts calls GET /api/get_prompts (scope prompts:read).

func (*Client) ListSources

func (c *Client) ListSources(ctx context.Context) ([]Source, json.RawMessage, error)

ListSources calls GET /api/sources (scope sources:read).

func (*Client) ListTools

func (c *Client) ListTools(ctx context.Context) ([]Tool, json.RawMessage, error)

ListTools calls GET /api/get_tools (scope tools:read). raw is the server's `tools` array.

func (*Client) Me

func (c *Client) Me(ctx context.Context) (*Identity, error)

Me calls GET /api/user/me.

func (*Client) PlanImport

func (c *Client) PlanImport(ctx context.Context, yamlDoc string) (*Plan, error)

PlanImport calls POST /api/import_agent/plan with {"yaml": <document>} (scope agents:write, like the apply itself). Nothing is written server-side.

func (*Client) TriggerWebhook added in v1.6.1

func (c *Client) TriggerWebhook(ctx context.Context, w *Webhook, payload []byte, idempotencyKey string) (*TriggerResult, error)

TriggerWebhook POSTs payload (JSON, sent verbatim) to the agent's incoming webhook; the agent runs asynchronously as task TaskID. idempotencyKey, when non-empty, is sent as the Idempotency-Key header: a repeat within the server's dedup window returns the original task instead of running again.

The request never carries the client's token: the webhook authenticates by the secret in its URL, and the server refuses personal access tokens there. Errors name the redacted URL only.

func (*Client) UploadSource

func (c *Client) UploadSource(ctx context.Context, name string, paths []string, idempotencyKey string) (*UploadResult, error)

UploadSource calls POST /api/upload (scope sources:write) with a multipart body: `user`, `name` and one `file` part per path. idempotencyKey, when non-empty, is sent as the Idempotency-Key header: a repeat within the server's dedup window returns the original task instead of re-ingesting. File contents are streamed, so large files are never buffered in memory.

func (*Client) WaitTask

func (c *Client) WaitTask(ctx context.Context, taskID string, opts WaitOptions) (*TaskStatus, error)

WaitTask polls GET /api/task_status with exponential backoff until the task reaches SUCCESS (returned), FAILURE/REVOKED (*TaskFailedError) or ctx ends (the timeout). A 503 is transient and polling continues.

type Decision

type Decision struct {
	Resolution *Resolution // what to send with the apply (nil when empty)
	Blockers   []Blocker   // missing / unavailable references left uncovered
	Notices    []string    // non-blocking heads-ups
	// Covered maps "kind:ref" to a short description of the covering entry,
	// for the plan summary.
	Covered map[string]string
}

Decision is the outcome of matching the --resolve entries against one document's plan.

func (*Decision) Blocked

func (d *Decision) Blocked() bool

Blocked reports whether the apply must not proceed.

type Document

type Document struct {
	Source string // "agents/support.yaml", "agents/all.yaml#2", or "<stdin>"
	Index  int    // 1-based position within its file
	Text   string // the document text exactly as written (comments included)

	Kind       string
	APIVersion string
	Name       string // spec.name
	ID         string // metadata.id
	Slug       string // metadata.slug
}

Document is one YAML document destined for the agent import API.

func LoadDocuments

func LoadDocuments(args []string, stdin io.Reader) ([]Document, error)

LoadDocuments expands -f arguments into agent documents, in order. Each argument is a file, a directory (its *.yaml / *.yml files, sorted by name, not recursive) or "-" for stdin. Multi-document files are split. A document whose kind is not Agent, or that is not valid YAML, is an error; nothing is returned in that case so a bad file never leads to a partial apply.

func ParseDocuments

func ParseDocuments(source string, data []byte) ([]Document, error)

ParseDocuments splits data into its YAML documents and validates each one locally. Empty documents (blank, or comments only) are dropped.

func (Document) Label

func (d Document) Label() string

Label names the document in plans and errors.

type Identity

type Identity struct {
	Success    bool       `json:"success"`
	UserID     string     `json:"user_id"`
	Roles      []string   `json:"roles"`
	Email      string     `json:"email,omitempty"`
	Name       string     `json:"name,omitempty"`
	AuthMethod string     `json:"auth_method,omitempty"` // "pat" for a personal access token
	Token      *TokenInfo `json:"token,omitempty"`

	Raw json.RawMessage `json:"-"` // server document, verbatim
}

Identity is the GET /api/user/me document. Token is set only when the caller authenticated with a personal access token.

type IngestOptions added in v1.7.0

type IngestOptions struct {
	Name    string
	Files   []string
	Key     string // Idempotency-Key; "" sends none
	Wait    bool
	Timeout time.Duration
	// Replace deletes the caller's older sources with the same name once the
	// new one is ingested, so agents that reference the source by name pick
	// up the new content on their next apply. Needs Wait.
	Replace bool
	Poll    WaitOptions // zero: WaitTask defaults
	Log     io.Writer   // progress lines
}

IngestOptions are the inputs of Ingest.

type ModelDecision

type ModelDecision struct {
	APIKey string `json:"api_key,omitempty"`
}

ModelDecision is one entry of Resolution.Models: the API key used to create a custom model that does not exist yet.

type Plan

type Plan struct {
	Target   PlanTarget    `json:"target"`
	Sources  []PlanSource  `json:"sources"`
	Tools    []PlanTool    `json:"tools"`
	Prompt   PlanPrompt    `json:"prompt"`
	Models   []PlanModel   `json:"models"`
	Workflow *PlanWorkflow `json:"workflow"`

	Raw json.RawMessage `json:"-"` // the server `plan` object, verbatim
}

Plan is the dry-run resolution report for one agent document.

type PlanModel

type PlanModel struct {
	ID              string   `json:"id"`
	DisplayName     string   `json:"display_name"`
	Status          string   `json:"status"` // matched | unavailable | reuse | create
	RequiresSecrets []string `json:"requires_secrets"`
}

PlanModel is one spec.model.available entry: a plain model id (ID set) or a custom model (DisplayName set).

func (PlanModel) Label

func (m PlanModel) Label() string

Label is the identity the resolution map (and the user) addresses.

type PlanPrompt

type PlanPrompt struct {
	Status string `json:"status"` // reuse | create | default
	Name   string `json:"name"`
}

PlanPrompt is the spec.prompt resolution.

type PlanSource

type PlanSource struct {
	Name     string `json:"name"`
	Type     string `json:"type"`
	Status   string `json:"status"` // matched | missing
	TargetID string `json:"target_id"`
}

PlanSource is one spec.sources entry.

type PlanTarget

type PlanTarget struct {
	Action    string `json:"action"` // create | update
	AgentID   string `json:"agent_id"`
	MatchedBy string `json:"matched_by"` // id | slug
	Status    string `json:"status"`     // existing agent status (draft/published)
}

PlanTarget says whether the document creates an agent or updates one (matched by metadata.id, then metadata.slug).

type PlanTool

type PlanTool struct {
	Key             string   `json:"key"`
	Type            string   `json:"type"`
	Name            string   `json:"name"`
	Builtin         bool     `json:"builtin"`
	Status          string   `json:"status"` // builtin | reuse | create | unavailable
	TargetID        string   `json:"target_id"`
	RequiresSecrets []string `json:"requires_secrets"`
}

PlanTool is one spec.tools entry. Key ("tool-N", N = index in the file) is how the resolution map addresses it.

type PlanWorkflow

type PlanWorkflow struct {
	Action string `json:"action"` // create | update | delete
	Nodes  int    `json:"nodes"`
	Edges  int    `json:"edges"`
}

PlanWorkflow describes the workflow graph change of a workflow agent.

type Prompt

type Prompt struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Type string `json:"type"`
}

Prompt is one GET /api/get_prompts entry. Type is "public" for the built-in prompts, "private" for the caller's own and "team" for shared ones.

type Resolution

type Resolution struct {
	Sources map[string]string        `json:"sources,omitempty"` // spec source name -> existing source id
	Tools   map[string]ToolDecision  `json:"tools,omitempty"`   // "tool-N" -> decision
	Models  map[string]ModelDecision `json:"models,omitempty"`  // custom model display_name -> api key
}

Resolution is the `resolution` object of POST /api/import_agent. Every section is optional.

func (*Resolution) Empty

func (r *Resolution) Empty() bool

Empty reports whether no decision is present.

type ResolveEntry

type ResolveEntry struct {
	Raw      string // the flag value with any secret redacted, for messages
	Kind     string // source | tool | model
	Selector string
	Secret   string // tool secret field name ("" for a decision entry)
	Value    string
	// contains filtered or unexported fields
}

ResolveEntry is one parsed --resolve flag.

type ResolveSet

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

ResolveSet is the parsed --resolve flags for one command invocation.

func ParseResolve

func ParseResolve(flags []string) (*ResolveSet, error)

ParseResolve parses --resolve flag values.

func (*ResolveSet) CheckDocumentCount

func (s *ResolveSet) CheckDocumentCount(n int) error

CheckDocumentCount rejects positional tool keys when several documents are processed together: tool-0 would silently address a different tool in every document.

func (*ResolveSet) Decide

func (s *ResolveSet) Decide(plan *Plan) (*Decision, error)

Decide matches the entries against plan. It builds the resolution to send and lists every `missing` / `unavailable` reference that no entry covers:

  • a missing source is covered by source:<name>=<id> or =skip;
  • an unavailable tool is covered by =skip, or (non-built-in only, since the server ignores decisions for built-ins) by =reuse:<tool-id>;
  • an unavailable model id is covered by =skip.

An error means the entries are invalid for this plan (ambiguous selector).

func (*ResolveSet) Unused

func (s *ResolveSet) Unused() []string

Unused lists the entries that matched nothing in any planned document.

type Source

type Source struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	Date      any    `json:"date"`
	Tokens    any    `json:"tokens"`
	Type      string `json:"type"`
	Retriever string `json:"retriever"`
	Provider  string `json:"provider"`
	Ownership string `json:"ownership"`
}

Source is one GET /api/sources entry.

type TaskFailedError

type TaskFailedError struct {
	TaskID string
	Status string
	Detail string
}

TaskFailedError is returned by WaitTask when the task ends in FAILURE or REVOKED.

func (*TaskFailedError) Error

func (e *TaskFailedError) Error() string

type TaskStatus

type TaskStatus struct {
	Status string          `json:"status"` // PENDING | STARTED | PROGRESS | RETRY | SUCCESS | FAILURE | REVOKED
	Result json.RawMessage `json:"result"`
}

TaskStatus is the GET /api/task_status reply.

func (*TaskStatus) Progress

func (t *TaskStatus) Progress() (int, bool)

Progress extracts a 0-100 completion figure from a PROGRESS result, when the worker reports one.

func (*TaskStatus) ResultText

func (t *TaskStatus) ResultText() string

ResultText renders the task result for an error message.

type TokenInfo

type TokenInfo struct {
	ID             string              `json:"id"`
	Name           string              `json:"name"`
	Scopes         []string            `json:"scopes"`
	ResourceFilter map[string][]string `json:"resource_filter"` // family -> allowed ids; empty = unrestricted
}

TokenInfo describes the presented personal access token.

type Tool

type Tool struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	CustomName  string `json:"customName"`
	DisplayName string `json:"displayName"`
	Status      bool   `json:"status"`
	Builtin     bool   `json:"builtin"`
	Default     bool   `json:"default"`
	Ownership   string `json:"ownership"`
}

Tool is the subset of a GET /api/get_tools entry the CLI renders. Name is the tool type (e.g. "brave"); CustomName is the user's label.

type ToolDecision

type ToolDecision struct {
	// Decision is "reuse" (link ToolID, which must be the caller's tool),
	// "create" (create a new tool even if a (type, name) match exists),
	// "skip" (leave the tool off the agent), or "" (server default: reuse a
	// (type, name) match, otherwise create).
	Decision string `json:"decision,omitempty"`
	ToolID   string `json:"tool_id,omitempty"`
	// Secrets are merged into the tool config when the tool is created
	// (config-requirement field name -> value).
	Secrets map[string]string `json:"secrets,omitempty"`
}

ToolDecision is one entry of Resolution.Tools.

type TriggerOptions added in v1.7.0

type TriggerOptions struct {
	AgentID    string
	WebhookURL string
	Payload    []byte
	Key        string // Idempotency-Key; "" sends none
	Wait       bool
	Timeout    time.Duration
	Poll       WaitOptions // zero: TriggerPoll

	BaseURL   string // where the token is valid
	Token     string // personal access token; "" when none
	UserAgent string
	Log       io.Writer // progress lines
}

TriggerOptions are the inputs of Trigger. Exactly one of AgentID and WebhookURL is set.

type TriggerReport added in v1.7.0

type TriggerReport struct {
	TaskID         string          `json:"task_id"`
	IdempotencyKey string          `json:"idempotency_key,omitempty"`
	Deduplicated   bool            `json:"deduplicated,omitempty"`
	Waited         bool            `json:"waited"`
	Status         string          `json:"status,omitempty"`
	Answer         string          `json:"answer,omitempty"`
	Result         json.RawMessage `json:"result,omitempty"` // the task's result, verbatim
	Error          string          `json:"error,omitempty"`

	ToolCalls int           `json:"-"` // of a finished run
	Elapsed   time.Duration `json:"-"` // spent waiting for the run
}

TriggerReport is the outcome of Trigger (and the `agents trigger --json` document).

func Trigger added in v1.7.0

func Trigger(ctx context.Context, opts TriggerOptions) (report *TriggerReport, err error)

Trigger resolves the agent's webhook (looking it up with the token when given an agent id), posts the payload and, with Wait, polls the run until it finishes. The report is nil when nothing was queued; otherwise it carries the error too. No error or log line ever contains the webhook token.

type TriggerResult added in v1.6.1

type TriggerResult struct {
	Success bool   `json:"success"`
	TaskID  string `json:"task_id"`
}

TriggerResult is the webhook's reply.

type UploadReport added in v1.7.0

type UploadReport struct {
	Name           string   `json:"name"`
	TaskID         string   `json:"task_id"`
	SourceID       string   `json:"source_id,omitempty"`
	IdempotencyKey string   `json:"idempotency_key,omitempty"`
	Deduplicated   bool     `json:"deduplicated,omitempty"`
	Waited         bool     `json:"waited"`
	Status         string   `json:"status,omitempty"`
	Replaced       []string `json:"replaced,omitempty"`
	Error          string   `json:"error,omitempty"`
}

UploadReport is the outcome of Ingest (and the `sources upload --json` document).

type UploadResult

type UploadResult struct {
	Success  bool   `json:"success"`
	TaskID   string `json:"task_id"`
	SourceID string `json:"source_id,omitempty"`
}

UploadResult is the POST /api/upload reply.

type UsageError added in v1.7.0

type UsageError struct{ Err error }

UsageError is a failure fixed by different flags or configuration rather than by retrying; the CLI exits 2 for it.

func (*UsageError) Error added in v1.7.0

func (e *UsageError) Error() string

func (*UsageError) Unwrap added in v1.7.0

func (e *UsageError) Unwrap() error

type WaitOptions

type WaitOptions struct {
	Initial time.Duration // first delay; default 1s
	Max     time.Duration // backoff ceiling; default 10s
	Factor  float64       // backoff multiplier; default 1.5
	// OnUpdate is called after every poll with the latest state. For a
	// transient 503 (no idle worker answered the server's ping, typical while
	// a solo worker is busy with this very task) status is "WAITING".
	OnUpdate func(status string, task *TaskStatus)
}

WaitOptions tunes WaitTask. Zero values pick the defaults.

type Webhook added in v1.6.1

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

Webhook is an agent's incoming webhook URL, split into the base URL the API is served from and the secret token that ends the path. It never renders the token: String and Redacted show "<base>/api/webhooks/agents/...".

func ParseWebhookURL added in v1.6.1

func ParseWebhookURL(raw string) (*Webhook, error)

ParseWebhookURL accepts http(s)://host[/prefix]/api/webhooks/agents/<token>. The error never contains raw, which is a secret.

func (*Webhook) BaseURL added in v1.6.1

func (w *Webhook) BaseURL() string

BaseURL is the API base URL the webhook lives under; /api/task_status for its runs is served there too.

func (*Webhook) Redact added in v1.6.1

func (w *Webhook) Redact(s string) string

Redact replaces every occurrence of the token (as given, or unescaped) in s.

func (*Webhook) Redacted added in v1.6.1

func (w *Webhook) Redacted() string

Redacted is the URL with the token replaced by "...", safe for logs.

func (*Webhook) SameOrigin added in v1.6.1

func (w *Webhook) SameOrigin(baseURL string) bool

SameOrigin reports whether the webhook is served from the same scheme and host as baseURL, i.e. whether a token meant for baseURL may be sent there.

func (*Webhook) String added in v1.6.1

func (w *Webhook) String() string

String keeps %v and %s from ever printing the token.

func (*Webhook) URL added in v1.6.1

func (w *Webhook) URL() string

URL is the full webhook URL, token included. Never print it.

Jump to

Keyboard shortcuts

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