downlinkclient

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnalysisProgress

type AnalysisProgress struct {
	ArticleId  string `json:"article_id"`
	TaskName   string `json:"task_name"`
	Status     string `json:"status"`
	TaskIndex  int    `json:"task_index"`
	TotalTasks int    `json:"total_tasks"`
	TaskResult string `json:"task_result,omitempty"`
	TokenChunk string `json:"token_chunk,omitempty"`
	Error      string `json:"error,omitempty"`
}

AnalysisProgress is the Wails-friendly payload for analysis:progress events.

type AnalysisProgressEvent

type AnalysisProgressEvent struct {
	TaskName   string
	Status     string // "started", "token", "completed", "error", "done"
	TaskIndex  int
	TotalTasks int
	TaskResult string
	Error      string
	Analysis   *models.ArticleAnalysis
}

AnalysisProgressEvent mirrors the server-side progress event for use by CLI callers.

type ConnectionTestResult

type ConnectionTestResult struct {
	Success   bool   `json:"success"`
	Message   string `json:"message"`
	LatencyMs int64  `json:"latency_ms"`
}

ConnectionTestResult is returned by TestProviderConnection.

type DownlinkClient

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

DownlinkClient struct

func NewDownlinkClient

func NewDownlinkClient(conn *grpc.ClientConn) *DownlinkClient

NewDownlinkClient creates a new DownlinkClient application struct

func (*DownlinkClient) AnalyzeArticle

func (pc *DownlinkClient) AnalyzeArticle(articleId string) (models.ArticleAnalysis, error)

func (*DownlinkClient) AnalyzeArticleFast

func (pc *DownlinkClient) AnalyzeArticleFast(articleId string, fastMode bool) (models.ArticleAnalysis, error)

func (*DownlinkClient) AnalyzeArticleWithProviderModel

func (pc *DownlinkClient) AnalyzeArticleWithProviderModel(articleId string, providerType string, modelName string) (models.ArticleAnalysis, error)

func (*DownlinkClient) AnalyzeArticleWithProviderModelFast

func (pc *DownlinkClient) AnalyzeArticleWithProviderModelFast(articleId string, providerType string, modelName string, fastMode bool) (models.ArticleAnalysis, error)

func (*DownlinkClient) ApplyFeeds

func (pc *DownlinkClient) ApplyFeeds(configs []models.FeedConfig, defaults *models.Selectors, dryRun bool) (*protos.ApplyFeedsResponse, error)

ApplyFeeds reconciles the server's feeds to match the desired set: feeds in configs are created/updated, feeds absent from it are disabled.

func (*DownlinkClient) AutoConfigFeed added in v0.2.0

func (pc *DownlinkClient) AutoConfigFeed(req *protos.AutoConfigFeedRequest, onEvent func(ev *protos.AutoConfigFeedEvent)) error

AutoConfigFeed runs the server-side autonomous agent that discovers a feed's selectors (after locking the scraping mode/headers). onEvent is called for each streamed event (STEP updates and the final DONE carrying the config YAML).

func (*DownlinkClient) BackfillFeedTopics added in v0.4.0

func (pc *DownlinkClient) BackfillFeedTopics(req *protos.BackfillFeedTopicsRequest, onEvent func(ev *protos.BackfillFeedTopicsEvent)) error

BackfillFeedTopics asks the server to derive topics for the given feeds via the LLM, invoking onEvent once per feed as results stream in.

func (*DownlinkClient) ClearQueue

func (pc *DownlinkClient) ClearQueue() error

ClearQueue empties the server queue.

func (*DownlinkClient) CompleteClaudeLogin added in v0.2.0

func (pc *DownlinkClient) CompleteClaudeLogin(sessionID, code string) (*protos.CompleteClaudeLoginResponse, error)

func (*DownlinkClient) DeleteFeed

func (pc *DownlinkClient) DeleteFeed(feedId string) error

DeleteFeed removes a feed from both the models and the database

func (*DownlinkClient) DeleteFeeds

func (pc *DownlinkClient) DeleteFeeds(feedIds []string, dryRun bool) (*protos.DeleteFeedsResponse, error)

DeleteFeeds removes the given feeds (by id) from the database.

func (*DownlinkClient) DequeueArticle

func (pc *DownlinkClient) DequeueArticle(articleId string) error

DequeueArticle removes a specific article from the server queue.

func (*DownlinkClient) DiagnoseFeed added in v0.2.0

func (pc *DownlinkClient) DiagnoseFeed(feedId string) (*protos.FeedDiagnosis, error)

DiagnoseFeed runs a read-only diagnosis of a single feed: the server fetches and parses the feed but stores nothing, returning a structured report of what came back over the wire (HTTP status, content type, feed-type guess, parse error, UTF-8 problems, and the on-disk path to the saved raw body).

func (*DownlinkClient) EnqueueArticles

func (pc *DownlinkClient) EnqueueArticles(options EnqueueOptions) error

EnqueueArticles adds article IDs to the server queue.

func (*DownlinkClient) Entry

func (pc *DownlinkClient) Entry(ctx context.Context)

func (*DownlinkClient) GenerateDigest

func (pc *DownlinkClient) GenerateDigest(ctx context.Context, startTime time.Time, endTime time.Time, skipAnalysis bool, skipDuplicates bool, excludeDigested bool, layout string, onEvent func(*protos.DigestProgressEvent)) (models.Digest, error)

GenerateDigest generates a new digest, streaming progress events to onEvent as they arrive. Returns the final digest once the stream completes with a "done" event. The provided ctx controls the stream lifetime: cancel it to abort generation on the server.

func (*DownlinkClient) GenerateDigestWithOptions

func (pc *DownlinkClient) GenerateDigestWithOptions(ctx context.Context, options GenerateDigestOptions) (models.Digest, error)

func (*DownlinkClient) GetAllArticleAnalyses

func (pc *DownlinkClient) GetAllArticleAnalyses(articleId string) ([]models.ArticleAnalysis, error)

GetAllArticleAnalyses retrieves all analysis results for a specific article

func (*DownlinkClient) GetAnalysis

func (pc *DownlinkClient) GetAnalysis(articleId string) (models.ArticleAnalysis, error)

GetAnalysis retrieves the analysis results by its ID

func (*DownlinkClient) GetAnalysisConfig

func (pc *DownlinkClient) GetAnalysisConfig() (models.AnalysisConfig, error)

GetAnalysisConfig returns the current enrichment configuration

func (*DownlinkClient) GetArticle

func (pc *DownlinkClient) GetArticle(id string) (models.Article, error)

GetArticle returns a single article by Id

func (*DownlinkClient) GetArticleCounts

func (pc *DownlinkClient) GetArticleCounts(filter models.ArticleFilter) (models.ArticleCounts, error)

func (*DownlinkClient) GetAvailableModels

func (pc *DownlinkClient) GetAvailableModels() (*models.ModelsResponse, error)

func (*DownlinkClient) GetAvailableModelsForProvider

func (pc *DownlinkClient) GetAvailableModelsForProvider(providerName, providerType, baseURL string) (*models.ModelsResponse, error)

GetAvailableModelsForProvider fetches models for a single named provider.

func (*DownlinkClient) GetConfig

func (pc *DownlinkClient) GetConfig() (models.ServerConfig, error)

GetConfig returns the current application configuration

func (*DownlinkClient) GetDigest

func (pc *DownlinkClient) GetDigest(id string) (models.Digest, error)

GetDigest retrieves a digest by ID.

func (*DownlinkClient) GetDigestArticles

func (pc *DownlinkClient) GetDigestArticles(digestId string) ([]models.Article, error)

GetDigestArticles returns the articles belonging to a digest.

func (*DownlinkClient) GetLLMProviders

func (pc *DownlinkClient) GetLLMProviders() ([]models.ProviderConfig, error)

GetLLMProviders returns the current LLM provider configurations

func (*DownlinkClient) GetQueueStatus

func (pc *DownlinkClient) GetQueueStatus() QueueStatus

GetQueueStatus returns a snapshot of the server queue state.

func (*DownlinkClient) InspectArticle added in v0.2.0

func (pc *DownlinkClient) InspectArticle(url, mode string, headers map[string]string, sel *protos.Selectors, htmlLimit int) (*protos.InspectArticleResponse, error)

InspectArticle scrapes a single article URL in the given mode ("" / static, dynamic, full_browser). When selectors are supplied the response also carries the extracted content, for testing a candidate selector.

func (*DownlinkClient) InspectFeed added in v0.2.0

func (pc *DownlinkClient) InspectFeed(url string, headers map[string]string, maxLinks int) (*protos.InspectFeedResponse, error)

InspectFeed probes a feed URL (read-only, pre-registration) and returns its diagnosis, sample article links, and detected title — the scaffolding inputs for building a feed config.

func (*DownlinkClient) ListArticles

func (pc *DownlinkClient) ListArticles(filter models.ArticleFilter) ([]models.Article, error)

ListArticles returns articles based on the provided filter

func (*DownlinkClient) ListCodexCredentials

func (pc *DownlinkClient) ListCodexCredentials(providerName string) (*protos.ListCodexCredentialsResponse, error)

func (*DownlinkClient) ListDigests

func (pc *DownlinkClient) ListDigests(limit int) ([]models.Digest, error)

ListDigests returns lightweight summaries (id/title/date/article count). Use ListDigestsFull when the full payload (summary, provider results, analyses) is required.

func (*DownlinkClient) ListDigestsFull added in v0.2.0

func (pc *DownlinkClient) ListDigestsFull(limit int) ([]models.Digest, error)

ListDigestsFull lists digests with their full payload (summary, provider results, analyses). The response can be large; prefer ListDigests when only summary fields are needed.

func (*DownlinkClient) ListFeeds

func (pc *DownlinkClient) ListFeeds() ([]models.Feed, error)

ListFeeds returns all registered feeds

func (*DownlinkClient) ListGlossaryEntries added in v0.4.0

func (pc *DownlinkClient) ListGlossaryEntries(limit int) ([]models.GlossaryEntry, error)

ListGlossaryEntries lists entries from the persistent global glossary (limit <= 0 = all).

func (*DownlinkClient) MarkFeedArticlesRead

func (pc *DownlinkClient) MarkFeedArticlesRead(feedId string) error

func (*DownlinkClient) PollCodexLogin

func (pc *DownlinkClient) PollCodexLogin(sessionID string) (*protos.PollCodexLoginResponse, error)

func (*DownlinkClient) PreviewAnalysisPrompt

func (pc *DownlinkClient) PreviewAnalysisPrompt(articleId string) (string, error)

PreviewAnalysisPrompt returns the full prompt that would be sent for an article analysis

func (*DownlinkClient) RefreshAllFeeds

func (pc *DownlinkClient) RefreshAllFeeds(onEvent func(ev *protos.RefreshAllFeedsEvent)) error

RefreshAllFeeds triggers a refresh of all registered feeds. onEvent is called for each streamed event, both STARTED and COMPLETED.

func (*DownlinkClient) RefreshAllFeedsWithTimeWindow

func (pc *DownlinkClient) RefreshAllFeedsWithTimeWindow(from, to *time.Time, overwrite, restore bool, lastN int, onEvent func(ev *protos.RefreshAllFeedsEvent)) error

RefreshAllFeedsWithTimeWindow refreshes all enabled feeds within the given time window as a single bundled server operation (one RefreshAllFeeds RPC), so the monitor records them under one run. onEvent is called for each streamed event, both STARTED and COMPLETED.

func (*DownlinkClient) RefreshFeedWithTimeWindow

func (pc *DownlinkClient) RefreshFeedWithTimeWindow(feedId string, from *time.Time, to *time.Time, overwrite bool, restore bool, lastN int) (*protos.RefreshFeedResponse, error)

RefreshFeedWithTimeWindow refreshes a specific feed with optional time window filtering. Returns the per-feed stats from the server.

func (*DownlinkClient) RegisterFeed

func (pc *DownlinkClient) RegisterFeed(feedConfig models.FeedConfig) error

RegisterFeed adds a new feed to be monitored

func (*DownlinkClient) RemoveCodexCredential

func (pc *DownlinkClient) RemoveCodexCredential(providerName, credentialID string) (*protos.RemoveCodexCredentialResponse, error)

func (*DownlinkClient) ResolveLLM added in v0.2.0

func (pc *DownlinkClient) ResolveLLM(provider, model string) (providerType, modelName string, err error)

ResolveLLM resolves a provider/model selection to the concrete provider type and model name a run would use. Either argument may be empty (use defaults).

func (*DownlinkClient) SaveConfig

func (pc *DownlinkClient) SaveConfig(config models.ServerConfig) error

SaveConfig updates the application configuration

func (*DownlinkClient) SaveLLMProviders

func (pc *DownlinkClient) SaveLLMProviders(providers []models.ProviderConfig) error

SaveLLMProviders updates the LLM provider configurations

func (*DownlinkClient) SetCodexCredentialPriority

func (pc *DownlinkClient) SetCodexCredentialPriority(providerName, credentialID string, priority int32) (*protos.SetCodexCredentialPriorityResponse, error)

func (*DownlinkClient) SetGlossaryOverride added in v0.4.0

func (pc *DownlinkClient) SetGlossaryOverride(term, definition string) (models.GlossaryEntry, error)

SetGlossaryOverride sets a curated definition for a term and returns the updated entry.

func (*DownlinkClient) Shutdown

func (pc *DownlinkClient) Shutdown(_ context.Context)

Shutdown is called when the app is shutting down

func (*DownlinkClient) StartClaudeLogin added in v0.2.0

func (pc *DownlinkClient) StartClaudeLogin(providerName, modelName string) (*protos.StartClaudeLoginResponse, error)

func (*DownlinkClient) StartCodexLogin

func (pc *DownlinkClient) StartCodexLogin(providerName, modelName string) (*protos.StartCodexLoginResponse, error)

func (*DownlinkClient) StartQueue

func (pc *DownlinkClient) StartQueue() error

StartQueue tells the server to start processing queued articles.

func (*DownlinkClient) StartQueueProgressStream

func (pc *DownlinkClient) StartQueueProgressStream()

StartQueueProgressStream opens a long-lived stream from the server and forwards queue state changes and analysis progress as Wails events to the frontend. Should be called as a goroutine from startup().

func (*DownlinkClient) StopQueue

func (pc *DownlinkClient) StopQueue() error

StopQueue tells the server to pause queue processing.

func (*DownlinkClient) StreamAnalyzeArticle

func (pc *DownlinkClient) StreamAnalyzeArticle(articleId string, fastMode bool, onEvent func(AnalysisProgressEvent)) (models.ArticleAnalysis, error)

StreamAnalyzeArticle streams analysis progress using the default configured provider.

func (*DownlinkClient) StreamAnalyzeArticleWithProfile

func (pc *DownlinkClient) StreamAnalyzeArticleWithProfile(articleId, profileName string, fastMode bool, onEvent func(AnalysisProgressEvent)) (models.ArticleAnalysis, error)

StreamAnalyzeArticleWithProfile streams analysis progress using a named provider profile.

func (*DownlinkClient) StreamAnalyzeArticleWithProviderModel

func (pc *DownlinkClient) StreamAnalyzeArticleWithProviderModel(articleId, providerType, modelName string, fastMode bool, onEvent func(AnalysisProgressEvent)) (models.ArticleAnalysis, error)

StreamAnalyzeArticleWithProviderModel streams analysis progress events for a single article. The provided callback is called for each event. The final "done" event carries the completed analysis.

func (*DownlinkClient) StreamAnalyzeArticleWithSelection

func (pc *DownlinkClient) StreamAnalyzeArticleWithSelection(articleId, provider, model string, fastMode bool, onEvent func(AnalysisProgressEvent)) (models.ArticleAnalysis, error)

StreamAnalyzeArticleWithSelection streams analysis using the user-facing --provider/--model selection. provider is an auto-detect token (a provider type OR a config profile name); model may be empty. The server resolves the matching provider, including finding the provider that offers a bare model.

func (*DownlinkClient) StreamQueueEvents

func (pc *DownlinkClient) StreamQueueEvents(cb QueueStreamCallbacks)

StreamQueueEvents opens a long-lived gRPC stream and dispatches queue state changes and per-task analysis progress to the provided callbacks. Reconnects with exponential back-off up to 30s. Blocks until ctx is cancelled. Intended to be run in a goroutine.

func (*DownlinkClient) TestProviderConnection

func (pc *DownlinkClient) TestProviderConnection(providerType, baseURL, apiKey string) ConnectionTestResult

TestProviderConnection checks whether a provider's endpoint is reachable without consuming tokens. It tries lightweight read-only endpoints (health check or model listing) and returns latency.

func (*DownlinkClient) UpdateAnalysisConfig

func (pc *DownlinkClient) UpdateAnalysisConfig(analysisConfig models.AnalysisConfig) error

UpdateAnalysisConfig updates the enrichment configuration

func (*DownlinkClient) UpdateArticle

func (pc *DownlinkClient) UpdateArticle(id string, update *models.ArticleUpdate) (*emptypb.Empty, error)

UpdateArticle updates an article's properties

type EnqueueOptions

type EnqueueOptions struct {
	ArticleIds   []string `json:"article_ids"`
	ProviderType string   `json:"provider_type,omitempty"`
	ModelName    string   `json:"model_name,omitempty"`
	ProviderName string   `json:"provider_name,omitempty"`
	Provider     string   `json:"provider,omitempty"` // auto-detect token (provider type or profile name)
	FastMode     bool     `json:"fast_mode,omitempty"`
}

type GenerateDigestOptions

type GenerateDigestOptions struct {
	StartTime              time.Time
	EndTime                time.Time
	SkipAnalysis           bool
	SkipDuplicates         bool
	ExcludeDigested        bool
	Layout                 string // graphical/layout theme name; empty = server default
	OneShotAnalysis        bool
	Test                   bool
	TestDigestID           string
	GHPagesEnabled         *bool // When non-nil, overrides the server's GitHub Pages enabled config for this run
	ReanalyzeOnModelChange bool
	Reanalyze              bool
	VibeScore              *bool  // When non-nil, overrides the server's vibe_score config for this run
	Glossary               *bool  // When non-nil, overrides the server's glossary config for this run
	StandardSynthesis      *bool  // When non-nil, overrides the server's standard_synthesis config for this run
	ComprehensiveSynthesis *bool  // When non-nil, overrides the server's comprehensive_synthesis config for this run
	ExecutiveSummary       *bool  // When non-nil, overrides the server's executive_summary config for this run
	Provider               string // Provider override (type or profile name, auto-detected by the server)
	Model                  string // Model override; with empty Provider the server resolves the matching provider
	ProfileSlug            string // Editorial profile to generate for; empty = "default"
	OnEvent                func(*protos.DigestProgressEvent)
}

type QueueJobWithTitle

type QueueJobWithTitle struct {
	ID           string `json:"id"`
	ArticleId    string `json:"article_id"`
	ArticleTitle string `json:"article_title"`
	ProviderType string `json:"provider_type,omitempty"`
	ModelName    string `json:"model_name,omitempty"`
	ProviderName string `json:"provider_name,omitempty"`
}

QueueJobWithTitle represents a job with its article title for display (Wails event payload).

type QueueStatus

type QueueStatus struct {
	Queue        []QueueJobWithTitle `json:"queue"`
	CurrentId    string              `json:"current_id"`
	CurrentTitle string              `json:"current_title"`
	IsProcessing bool                `json:"is_processing"`
}

QueueStatus is the Wails-friendly payload for queue:update events.

type QueueStreamCallbacks

type QueueStreamCallbacks struct {
	OnQueueUpdate      func(QueueStatus)
	OnAnalysisProgress func(AnalysisProgress)
	OnDisconnect       func(error) // called before each reconnect attempt; may be nil
}

QueueStreamCallbacks holds event handlers for CLI queue streaming.

Jump to

Keyboard shortcuts

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