Documentation
¶
Overview ¶
Package linkfeed implements Discord link-feed ingestion + enrichment.
Layer 1: pullDiscordLinkFeed() — scheduled Discord pull with pagination,
deduplication, and CogDoc creation.
Layer 2: enrichLink() — lightweight URL fetch + decomposition + cross-ref.
Both are registered as agent tools (pull_link_feed, enrich_link) via RegisterLinkFeedTools, and the helpers (ScanInbox, LinkFeedLastPull, BuildInboxSummaryForAPI) are called directly from the observation pipeline for inbox awareness.
Extracted from apps/cogos/agent_linkfeed.go as wave 1a of ADR-085. The file retains its original logic; only the package boundary and the Harness interface (to decouple from *main.AgentHarness) are new.
Index ¶
Constants ¶
const InboxLinksRelPath = ".cog/mem/semantic/inbox/links"
InboxLinksRelPath is the memory-relative path to the inbox.
const LinkFeedChannelID = "1366246672275083375"
LinkFeedChannelID is the Discord channel for #link-feed.
const LinkFeedCheckInterval = 2 * time.Hour
LinkFeedCheckInterval is how often the agent should pull new links.
Variables ¶
This section is empty.
Functions ¶
func LinkFeedLastPull ¶
LinkFeedLastPull returns how long ago the last pull happened.
func ReadDiscordAuth ¶
ReadDiscordAuth reads the bot token from .cog/config/discord/auth.yaml. Exported so the observation pipeline can probe "configured?" status.
func RegisterLinkFeedTools ¶
RegisterLinkFeedTools adds link feed tools to the agent harness.
Types ¶
type AgentInboxSummary ¶
type AgentInboxSummary struct {
RawCount int `json:"raw_count"`
EnrichedCount int `json:"enriched_count"`
FailedCount int `json:"failed_count"`
TotalCount int `json:"total_count"`
LastPull string `json:"last_pull,omitempty"`
LastPullAgo string `json:"last_pull_ago,omitempty"`
NextPullIn string `json:"next_pull_in,omitempty"`
RecentEnrichments []RecentEnrichmentItem `json:"recent_enrichments,omitempty"`
}
AgentInboxSummary is the enrichment data for the status API.
func BuildInboxSummaryForAPI ¶
func BuildInboxSummaryForAPI(root string) *AgentInboxSummary
BuildInboxSummaryForAPI constructs the inbox summary for the status endpoint.
type Harness ¶
type Harness interface {
// RegisterTool registers a callable tool with the agent's tool loop.
RegisterTool(name, description string, parameters json.RawMessage,
fn func(ctx context.Context, args json.RawMessage) (json.RawMessage, error))
// GenerateJSON sends a prompt to the model in JSON mode and returns
// the raw JSON content.
GenerateJSON(ctx context.Context, systemPrompt, userPrompt string) (string, error)
}
Harness is the minimal surface linkfeed needs from the agent harness. The main package adapts its *AgentHarness to this interface. Using an interface (rather than importing the concrete type) keeps linkfeed a leaf package: main depends on linkfeed, not vice versa.
RegisterTool takes flat arguments (not ToolDefinition/ToolFunc structs) so main's adapter can translate into its own types without linkfeed needing to agree on a shared struct layout.
type InboxSummary ¶
type InboxSummary struct {
RawCount int `json:"raw_count"`
EnrichedCount int `json:"enriched_count"`
FailedCount int `json:"failed_count"`
TotalCount int `json:"total_count"`
NewestRaw []string `json:"newest_raw,omitempty"`
}
InboxSummary holds counts for the inbox awareness observation.
func ScanInbox ¶
func ScanInbox(root string) *InboxSummary
ScanInbox reads the inbox directory and returns a summary.
type LinkFeedItem ¶
type LinkFeedItem struct {
URL string `json:"url"`
Title string `json:"title"`
File string `json:"file"`
MessageID string `json:"message_id"`
Author string `json:"author"`
}
LinkFeedItem represents a single link extracted from a Discord message.
type RecentEnrichmentItem ¶
type RecentEnrichmentItem struct {
Title string `json:"title"`
Connections int `json:"connections"`
Ago string `json:"ago"`
}
RecentEnrichmentItem is a single recent enrichment for the dashboard.