systemnotices

package
v0.34.13 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package systemnotices injects platform-level system notices into agent-bound messages at the Adapter seam (#944).

The disk-pressure nudge was originally implemented inside the proxy's raw-transport rewrite, which chat traffic abandoned twice (US-63.7 moved chat onto the Adapter, #755 moved Send off the V2 queue) — each migration silently orphaned the feature. A must-apply-to-every-message concern belongs at the ONE seam every entrypoint (HTTP chat, MCP, SDK, future triggers) shares: pkg/agent.Adapter. Wrap() decorates that seam at its single wiring point (app.go).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Notice

func Notice(level Level, ratio float64) string

Notice builds the system-notice text injected ahead of the user's message. The notice is addressed to the agent (it tells the model what to do) but reads naturally if it surfaces in the transcript.

  • Warning (>=90%): nudge the user; no deletion authority.
  • Critical (>=95%): stronger; may delete ONLY easily-replaceable files (build artifacts, caches); logs are the last resort because they cannot be reproduced; user approval required.

Wording is byte-for-byte the original proxy_disk_pressure text — this function is its new single source.

func Ratio

func Ratio(usedBytes, totalBytes int64) float64

Ratio computes the used fraction of the workspace disk. Returns 0 when total is unknown/non-positive so a not-yet-scraped workspace never trips the warning (fail-safe).

func Thresholds

func Thresholds() (float64, float64)

Thresholds returns the active (warning, critical) ratios.

func Wrap

Wrap returns an agent.Adapter that prepends the disk-pressure system notice to every Send/SendAsync text at or above the warning threshold. All other methods delegate untouched. A nil usage source disables injection (the decorator becomes a pass-through).

Types

type Level

type Level string

Level is a disk-pressure tier.

const (
	LevelNone     Level = "none"
	LevelWarning  Level = "warning"  // >= 90% full
	LevelCritical Level = "critical" // >= 95% full
)

func LevelForRatio

func LevelForRatio(ratio float64) Level

LevelForRatio maps a usage ratio to a pressure level.

type WorkspaceDiskUsage

type WorkspaceDiskUsage interface {
	DiskUsage(ctx context.Context, workspaceID string) (usedBytes, totalBytes int64, err error)
}

WorkspaceDiskUsage sources a workspace's disk usage. Implemented at the wiring layer over the Workspace CRD status (the same data the controller mirrors from agentd /v1/statusz and the frontend renders) — no new telemetry.

Jump to

Keyboard shortcuts

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