Documentation
¶
Overview ¶
Package diagnostics contains the opt-in, protocol-neutral event contract shared by MCP and transport adapters. It deliberately accepts typed fields only; raw URLs, headers, bodies, cookies and arbitrary log text do not belong in this package.
Index ¶
- func Emit(ctx context.Context, event Event)
- func WithChildScope(ctx context.Context, module Module, requestID uint64) context.Context
- func WithScope(ctx context.Context, sink Sink, module Module, requestID uint64) context.Context
- type Event
- type EventKind
- type Module
- type Reason
- type Scope
- type Sink
- type SinkFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithChildScope ¶
WithChildScope changes only the module and request number while preserving the parent sink. Without a parent scope it deliberately remains a no-op; this keeps public SDK usage quiet outside the CLI/MCP bootstrap.
Types ¶
type Event ¶
type Event struct {
Module Module
Kind EventKind
Operation string
Resource string
Route string
Target string
Proxy string
UserAgent string
Reason Reason
Status int
Count int
RequestID uint64
Duration time.Duration
}
Event is the complete safe diagnostic payload. Resource and Target are non-secret identifiers or local destinations supplied by trusted adapters; the presenter removes URL userinfo, query and fragment before rendering.
type EventKind ¶
type EventKind string
EventKind is a closed set of diagnostic lifecycle stages. Event data is intentionally finite and safe; callers cannot supply preformatted output.
const ( EventStarted EventKind = "started" EventCompleted EventKind = "completed" EventFailed EventKind = "failed" EventNetworkRequest EventKind = "network_request" EventChallenge EventKind = "challenge" EventSolverStarted EventKind = "solver_started" EventSolverCompleted EventKind = "solver_completed" EventReplay EventKind = "replay" EventDownload EventKind = "download" EventAccount EventKind = "account" EventConfiguration EventKind = "configuration" )
type Module ¶
type Module string
Module is the stable product and subsystem prefix shown by the presenter.
const ( ModulePixivCLI Module = "Pixiv CLI" ModuleFanboxCLI Module = "FANBOX CLI" ModulePixivMCP Module = "Pixiv MCP server" ModuleFanboxMCP Module = "FANBOX MCP server" ModulePixivAccount Module = "Pixiv account pool" ModulePixivAuth Module = "Pixiv authentication" ModuleFanboxAuth Module = "FANBOX authentication" ModulePixivAuthDB Module = "Pixiv authentication database" ModuleFanboxAuthDB Module = "FANBOX authentication database" ModulePixivConfig Module = "Pixiv configuration" ModuleFanboxConfig Module = "FANBOX configuration" ModulePixivNetwork Module = "Pixiv network" ModuleFanboxNetwork Module = "FANBOX network" ModuleFanboxSolver Module = "FANBOX FlareSolverr" ModulePixivDownload Module = "Pixiv download" ModuleFanboxDownload Module = "FANBOX download" // Descriptive aliases keep call sites readable when they distinguish the // server subsystem from the product name. ModulePixivMCPServer = ModulePixivMCP ModuleFanboxMCPServer = ModuleFanboxMCP )
type Reason ¶
type Reason string
Reason is a stable, non-secret explanation selected by the emitting layer. Raw Go errors do not belong in Event; the command boundary still returns the original business error through its normal error path.
const ( ReasonRequestCancelled Reason = "request cancelled" ReasonTransportInterrupted Reason = "transport interrupted" ReasonSubscriptionReleased Reason = "subscription released" ReasonServiceClosed Reason = "service closed" ReasonAuthorizationExpired Reason = "authorization expired" ReasonAuthorizationInvalidated Reason = "authorization invalidated" ReasonNone Reason = "" ReasonCommandFailed Reason = "command failed" ReasonToolFailed Reason = "tool failed" ReasonChallenge Reason = "challenge required" ReasonSolverFailed Reason = "solver failed" ReasonMalformedSolver Reason = "malformed solver response" ReasonAccountFrozen Reason = "account frozen" ReasonAccountExhausted Reason = "account pool exhausted" ReasonConfigurationFailed Reason = "configuration failed" ReasonAuthenticationFailed Reason = "authentication failed" )
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
Scope binds a sink, module and optional MCP-local request number to a context. A zero request ID is reserved for a top-level CLI operation.
func ScopeFromContext ¶
ScopeFromContext returns the current scope for tests and controlled adapter composition. The sink itself is intentionally not exported as a field.