Documentation
¶
Overview ¶
Package client provides the authenticated Taskronin unix-socket API client.
Index ¶
- Constants
- Variables
- func IsCode(err error, code domain.Code) bool
- type BlockQuery
- type Client
- func (c *Client) AIChanges(ctx context.Context, all bool, p PageQuery) (*api.AIChanges, error)
- func (c *Client) AcceptNew(ctx context.Context, m Mut, r api.AcceptNewRequest) (*api.OpResponse, error)
- func (c *Client) Actor(ctx context.Context) (string, error)
- func (c *Client) AddEntry(ctx context.Context, m Mut, r api.AddEntryRequest) (*api.OpResponse, error)
- func (c *Client) AddTask(ctx context.Context, m Mut, r api.AddTaskRequest) (*api.OpResponse, error)
- func (c *Client) Backups(ctx context.Context) (*api.BackupStatus, error)
- func (c *Client) BlockTask(ctx context.Context, m Mut, id int64, r api.BlockRequest) (*api.OpResponse, error)
- func (c *Client) ChangePassword(ctx context.Context, r api.PasswordRequest) error
- func (c *Client) Clock(ctx context.Context) (*api.Clock, error)
- func (c *Client) CompleteTask(ctx context.Context, m Mut, id int64, r api.CompleteRequest) (*api.OpResponse, error)
- func (c *Client) CreateToken(ctx context.Context, r api.CreateTokenRequest) (*api.TokenCreated, error)
- func (c *Client) Day(ctx context.Context, d civil.Date) (*api.Day, error)
- func (c *Client) DeferTask(ctx context.Context, m Mut, id int64, r api.DeferRequest) (*api.OpResponse, error)
- func (c *Client) DeleteEntry(ctx context.Context, m Mut, id int64) (*api.OpResponse, error)
- func (c *Client) DeleteTask(ctx context.Context, m Mut, id int64) (*api.OpResponse, error)
- func (c *Client) DropTask(ctx context.Context, m Mut, id int64) (*api.OpResponse, error)
- func (c *Client) Export(ctx context.Context, w io.Writer) error
- func (c *Client) Generation(ctx context.Context) (string, error)
- func (c *Client) GetBlock(ctx context.Context, id int64) (*api.Block, error)
- func (c *Client) GetEntry(ctx context.Context, id int64) (*api.Entry, error)
- func (c *Client) GetOp(ctx context.Context, opID string) (*api.OpDetail, error)
- func (c *Client) GetTask(ctx context.Context, id int64) (*api.TaskDetail, error)
- func (c *Client) Health(ctx context.Context) error
- func (c *Client) ListBlocks(ctx context.Context, q BlockQuery) ([]api.Block, error)
- func (c *Client) ListEntries(ctx context.Context, q EntryQuery) (*api.Page[api.Entry], error)
- func (c *Client) ListOps(ctx context.Context, q OpsQuery) (*api.Page[api.OpSummary], error)
- func (c *Client) ListTasks(ctx context.Context, q TaskQuery) (*api.Page[api.Task], error)
- func (c *Client) MarkManual(ctx context.Context, m Mut, id int64) (*api.OpResponse, error)
- func (c *Client) PlaceTask(ctx context.Context, m Mut, id int64, r api.PlaceRequest) (*api.OpResponse, error)
- func (c *Client) Reblock(ctx context.Context, m Mut, blockID int64, r api.ReblockRequest) (*api.OpResponse, error)
- func (c *Client) Redo(ctx context.Context, m Mut) (*api.OpResponse, error)
- func (c *Client) RefreshGeneration(ctx context.Context) (string, error)
- func (c *Client) RelinkEntry(ctx context.Context, m Mut, id int64, r api.RelinkRequest) (*api.OpResponse, error)
- func (c *Client) ReopenTask(ctx context.Context, m Mut, id int64, r api.ReopenRequest) (*api.OpResponse, error)
- func (c *Client) Report(ctx context.Context, q ReportQuery) (*api.Report, error)
- func (c *Client) Resend(ctx context.Context, p PendingRequest) (*ResendResult, error)
- func (c *Client) Revert(ctx context.Context, m Mut, opID string) (*api.OpResponse, error)
- func (c *Client) ReviewAIChanges(ctx context.Context, m Mut, r api.ReviewRequest) (*api.OpResponse, error)
- func (c *Client) RevokeToken(ctx context.Context, m Mut, id int64) (*api.TokenInfo, error)
- func (c *Client) RunBackup(ctx context.Context) (*api.Snapshot, error)
- func (c *Client) Search(ctx context.Context, q SearchQuery) (*api.Page[api.SearchHit], error)
- func (c *Client) SetDue(ctx context.Context, m Mut, id int64, r api.DueRequest) (*api.OpResponse, error)
- func (c *Client) SetFocus(ctx context.Context, m Mut, r api.FocusRequest) (*api.OpResponse, error)
- func (c *Client) SetOutcome(ctx context.Context, m Mut, blockID int64, r api.OutcomeRequest) (*api.OpResponse, error)
- func (c *Client) Settings(ctx context.Context) (*api.Settings, error)
- func (c *Client) Status(ctx context.Context, ifNoneMatch string) (*api.Status, string, bool, error)
- func (c *Client) Tags(ctx context.Context) ([]api.TagCount, error)
- func (c *Client) TaskHistory(ctx context.Context, id int64, p PageQuery) (*api.Page[api.EventView], error)
- func (c *Client) Today(ctx context.Context, ifNoneMatch string) (*api.Today, string, bool, error)
- func (c *Client) Tokens(ctx context.Context) ([]api.TokenInfo, error)
- func (c *Client) Unblock(ctx context.Context, m Mut, blockID int64) (*api.OpResponse, error)
- func (c *Client) UndeleteEntry(ctx context.Context, m Mut, id int64) (*api.OpResponse, error)
- func (c *Client) UndeleteTask(ctx context.Context, m Mut, id int64) (*api.OpResponse, error)
- func (c *Client) Undo(ctx context.Context, m Mut) (*api.OpResponse, error)
- func (c *Client) Upcoming(ctx context.Context) (*api.Upcoming, error)
- func (c *Client) UpdateEntry(ctx context.Context, m Mut, id int64, r api.UpdateEntryRequest) (*api.OpResponse, error)
- func (c *Client) UpdateSettings(ctx context.Context, r api.SettingsRequest) (*api.Settings, error)
- func (c *Client) UpdateTask(ctx context.Context, m Mut, id int64, r api.UpdateTaskRequest) (*api.OpResponse, error)
- func (c *Client) WhoAmI(ctx context.Context) (*api.WhoAmI, error)
- type EntryQuery
- type Mut
- type OpsQuery
- type Options
- type OutcomeUnknownError
- type PageQuery
- type PendingRequest
- type PendingStore
- type ProblemError
- type ReportQuery
- type ResendResult
- type SearchQuery
- type TaskQuery
- type TokenFileError
Constants ¶
const PendingResendWindow = 7*24*time.Hour - time.Hour
PendingResendWindow bounds a resendable pending request's age: the server's idempotency retention (service.IdemTTL, 7 d) minus a 1-hour safety margin.
AIDEV-NOTE: final review A-Minor-3. CreatedAt is stamped when the file is saved, up to the 20 s call budget AFTER the server committed, while the server forgets rows 7 d after the commit. Without the margin, a resend of an op without If-Match (add, log, focus, undo/redo/revert) near 7 d could re-execute instead of replaying; undo/redo would hit a different stack entry. Keep this in step with service.IdemTTL (pending_test.go asserts it).
Variables ¶
var ( ErrNotSent = errors.New("request not sent") ErrOutcomeUnknown = errors.New("request outcome unknown") ErrGenerationMismatch = errors.New("database generation changed") ErrTokenFile = errors.New("token file unusable") ErrPendingExpired = errors.New("pending request too old to resend safely (the server keeps idempotency records for 7 days)") ErrActorMismatch = errors.New("pending request belongs to another actor") )
Failure classes used by the CLI and pending-request recovery.
Functions ¶
Types ¶
type BlockQuery ¶
BlockQuery filters blocks by date or a concrete task.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is safe for concurrent calls. Its options and credentials are immutable.
func NewFromConfig ¶
NewFromConfig uses the resolved client configuration and supplied channel.
func (*Client) AcceptNew ¶
func (c *Client) AcceptNew(ctx context.Context, m Mut, r api.AcceptNewRequest) (*api.OpResponse, error)
AcceptNew accepts new tasks atomically using the per-item ETags; m.IfMatch is unused.
func (*Client) AddEntry ¶
func (c *Client) AddEntry(ctx context.Context, m Mut, r api.AddEntryRequest) (*api.OpResponse, error)
AddEntry logs work against an explicit task or as a standalone entry.
func (*Client) AddTask ¶
func (c *Client) AddTask(ctx context.Context, m Mut, r api.AddTaskRequest) (*api.OpResponse, error)
AddTask captures a task with optional owner placement.
func (*Client) BlockTask ¶
func (c *Client) BlockTask(ctx context.Context, m Mut, id int64, r api.BlockRequest) (*api.OpResponse, error)
BlockTask schedules a block for a task.
func (*Client) ChangePassword ¶
ChangePassword changes the owner password without saving or replaying it.
func (*Client) CompleteTask ¶
func (c *Client) CompleteTask(ctx context.Context, m Mut, id int64, r api.CompleteRequest) (*api.OpResponse, error)
CompleteTask completes a task and records its completion entry.
func (*Client) CreateToken ¶
func (c *Client) CreateToken(ctx context.Context, r api.CreateTokenRequest) (*api.TokenCreated, error)
CreateToken returns a new token and its one-time secret.
func (*Client) DeferTask ¶
func (c *Client) DeferTask(ctx context.Context, m Mut, id int64, r api.DeferRequest) (*api.OpResponse, error)
DeferTask sets or clears the task's deferral.
func (*Client) DeleteEntry ¶
DeleteEntry soft-deletes an entry.
func (*Client) DeleteTask ¶
DeleteTask soft-deletes a task.
func (*Client) Generation ¶
Generation lazily fetches and caches the database generation with the actor.
func (*Client) ListBlocks ¶
ListBlocks reads blocks by date or concrete task.
func (*Client) ListEntries ¶
ListEntries reads work and completion entries.
func (*Client) ListOps ¶
ListOps reads a page of operations matching the actor, op ID prefix and sequence filters.
func (*Client) MarkManual ¶
MarkManual adds a manual triage reason to a task.
func (*Client) PlaceTask ¶
func (c *Client) PlaceTask(ctx context.Context, m Mut, id int64, r api.PlaceRequest) (*api.OpResponse, error)
PlaceTask places a task and acknowledges its triage reasons.
func (*Client) Reblock ¶
func (c *Client) Reblock(ctx context.Context, m Mut, blockID int64, r api.ReblockRequest) (*api.OpResponse, error)
Reblock reschedules a block using both block and task preconditions.
func (*Client) RefreshGeneration ¶
RefreshGeneration invalidates the cached identity and fetches it again.
func (*Client) RelinkEntry ¶
func (c *Client) RelinkEntry(ctx context.Context, m Mut, id int64, r api.RelinkRequest) (*api.OpResponse, error)
RelinkEntry changes or clears an entry's task link.
func (*Client) ReopenTask ¶
func (c *Client) ReopenTask(ctx context.Context, m Mut, id int64, r api.ReopenRequest) (*api.OpResponse, error)
ReopenTask reopens a closed task, optionally removing its completion entry.
func (*Client) Resend ¶
func (c *Client) Resend(ctx context.Context, p PendingRequest) (*ResendResult, error)
Resend checks expiry, generation and actor before retrying the saved request. The caller discards a success or marks a definitive failure; Resend never changes pending files, including after another uncertain outcome. A request whose age reaches PendingResendWindow is refused with ErrPendingExpired.
func (*Client) ReviewAIChanges ¶
func (c *Client) ReviewAIChanges(ctx context.Context, m Mut, r api.ReviewRequest) (*api.OpResponse, error)
ReviewAIChanges advances the owner's AI review watermark.
func (*Client) RevokeToken ¶
RevokeToken revokes a non-owner token with keyed retry semantics.
func (*Client) SetDue ¶
func (c *Client) SetDue(ctx context.Context, m Mut, id int64, r api.DueRequest) (*api.OpResponse, error)
SetDue sets or clears the task's due moment.
func (*Client) SetFocus ¶
func (c *Client) SetFocus(ctx context.Context, m Mut, r api.FocusRequest) (*api.OpResponse, error)
SetFocus sets or clears today's focus without an entity precondition.
func (*Client) SetOutcome ¶
func (c *Client) SetOutcome(ctx context.Context, m Mut, blockID int64, r api.OutcomeRequest) (*api.OpResponse, error)
SetOutcome sets a block's outcome or restores automatic resolution.
func (*Client) Status ¶
Status reads the compact status, optionally reusing a cached representation.
func (*Client) TaskHistory ¶
func (c *Client) TaskHistory(ctx context.Context, id int64, p PageQuery) (*api.Page[api.EventView], error)
TaskHistory reads a page of a task's audit events.
func (*Client) UndeleteEntry ¶
UndeleteEntry restores a soft-deleted entry.
func (*Client) UndeleteTask ¶
UndeleteTask restores a soft-deleted task.
func (*Client) UpdateEntry ¶
func (c *Client) UpdateEntry(ctx context.Context, m Mut, id int64, r api.UpdateEntryRequest) (*api.OpResponse, error)
UpdateEntry patches an entry's content, work date and time.
func (*Client) UpdateSettings ¶
UpdateSettings changes retention; lowering requires password re-entry.
func (*Client) UpdateTask ¶
func (c *Client) UpdateTask(ctx context.Context, m Mut, id int64, r api.UpdateTaskRequest) (*api.OpResponse, error)
UpdateTask patches task content and metadata.
type EntryQuery ¶
type EntryQuery struct {
From, To *civil.Date
Task *int64
Standalone, IncludeDeleted bool
PageQuery
}
EntryQuery filters entries by date, task, standalone state and deletion state.
type Options ¶
type Options struct {
Socket string
TokenFile string
Channel string
Timeout time.Duration
NoRetry bool // suppress retries and automatic generation refresh
Pending *PendingStore
NewKey func() string
Clock clock.Clock
}
Options configures credentials, request budgets, retries and pending storage.
type OutcomeUnknownError ¶
OutcomeUnknownError indicates that request bytes were written but no complete response was received. Saved reports whether pending persistence succeeded.
func (*OutcomeUnknownError) Error ¶
func (e *OutcomeUnknownError) Error() string
func (*OutcomeUnknownError) Is ¶
func (e *OutcomeUnknownError) Is(target error) bool
Is recognizes the outcome-unknown sentinel.
func (*OutcomeUnknownError) Unwrap ¶
func (e *OutcomeUnknownError) Unwrap() error
Unwrap preserves transport, context and pending-write errors.
type PendingRequest ¶
type PendingRequest struct {
Key string `json:"key"`
Method string `json:"method"`
Path string `json:"path"`
IfMatch string `json:"if_match"`
Generation string `json:"generation"`
Actor string `json:"actor"`
Body json.RawMessage `json:"body"`
CreatedAt time.Time `json:"created_at"`
LastError string `json:"last_error"`
LastAttemptAt time.Time `json:"last_attempt_at"`
}
PendingRequest preserves a keyed mutation for guarded, explicit recovery.
type PendingStore ¶
PendingStore stores private, durable request files under Dir.
func (*PendingStore) Age ¶
func (s *PendingStore) Age(p PendingRequest) time.Duration
Age reports how long a request has been pending, using the store's clock.
func (*PendingStore) Discard ¶
func (s *PendingStore) Discard(key string) error
Discard removes a pending request after success or explicit user discard.
func (*PendingStore) List ¶
func (s *PendingStore) List() ([]PendingRequest, error)
List returns pending requests ordered by creation time, oldest first. A missing pending directory is an empty store.
func (*PendingStore) MarkFailed ¶
func (s *PendingStore) MarkFailed(key, lastError string) error
MarkFailed records a definitive failure without replacing the saved mutation or restarting its seven-day expiry window.
func (*PendingStore) Save ¶
func (s *PendingStore) Save(p PendingRequest) error
Save writes <Dir>/<key>.json atomically, assigning the current creation time.
type ProblemError ¶
ProblemError preserves the complete RFC 9457 problem and HTTP status.
func (*ProblemError) Code ¶
func (e *ProblemError) Code() domain.Code
Code returns the stable domain error code.
func (*ProblemError) Error ¶
func (e *ProblemError) Error() string
func (*ProblemError) Is ¶
func (e *ProblemError) Is(target error) bool
Is recognizes the generation-change sentinel without losing problem details.
type ReportQuery ¶
ReportQuery specifies a report range and optional sections.
type ResendResult ¶
type ResendResult struct {
Op *api.OpResponse
Token *api.TokenInfo
}
ResendResult holds exactly one successful keyed response: an operation or revoked token metadata. AIDEV-NOTE: BF18 requires typed revocation recovery; it cannot be decoded as OpResponse. CLI pending retry must render whichever field is populated.
type SearchQuery ¶
SearchQuery specifies a search and pagination.
type TokenFileError ¶
TokenFileError carries the credential path and the failed read or check.
func (*TokenFileError) Error ¶
func (e *TokenFileError) Error() string
func (*TokenFileError) Is ¶
func (e *TokenFileError) Is(target error) bool
Is recognizes the token-file exit class.
func (*TokenFileError) Unwrap ¶
func (e *TokenFileError) Unwrap() error
Unwrap retains the underlying filesystem error.