Documentation
¶
Overview ¶
Package util contains small, cross-layer helpers with no business ownership.
Keep package contents generic and dependency-light. Helpers that belong to a specific subsystem should live with that subsystem instead of being added here.
Index ¶
- Constants
- func ClipRunes(s string, maxRunes int) string
- func FormatDuration(d time.Duration) string
- func FormatUnixMinute(unixSec int64) string
- func NewPrefixedID(prefix string) string
- func Ptr[T any](v T) *T
- func ResolvePath(root, userPath string) (string, error)
- func ResolveWorkspaceRoot(dir string) (string, error)
- func TruncateRunes(s string, maxRunes int) string
- func WithEnvVar(envKey, value string, fn func() error) error
- func WorkerJobNameForTaskRun(taskRunID string) string
- func WorkerJobNameForTaskRunAt(taskRunID string, now time.Time) string
Constants ¶
const ( PrefixUser = "u" PrefixTeam = "tm" PrefixIssue = "i" PrefixIssueComment = "ic" PrefixAgent = "a" PrefixAgentRevision = "arv" PrefixWorkflow = "w" PrefixWorkflowRevision = "wrv" PrefixWorkflowRun = "wr" PrefixWorkflowStepRun = "wsr" PrefixConversation = "c" PrefixTask = "t" PrefixTaskRun = "r" PrefixArtifact = "ar" PrefixArtifactItem = "f" PrefixConversationMessage = "cm" PrefixWebhookKey = "whk" PrefixLLMCall = "lc" PrefixLLMModel = "lm" PrefixAuditEvent = "ae" PrefixAuthSession = "as" PrefixSystemGrant = "sg" PrefixPlugin = "pl" PrefixPluginRelease = "plr" )
Prefix constants for prefixed IDs. Use with NewPrefixedID. Semantics: u=user, tm=team, a=agent, arv=agent revision, c=conversation, t=task, r=task run, ar=artifact, f=artifact item, cm=conversation message, ic=issue comment, wrv=workflow revision, whk=user webhook key, lc=managed LLM call, lm=managed model catalog entry, as=auth session (one login chain of refresh tokens), sg=system grant (a deployment-scoped role held by a user). Agent session IDs are internal (not user-facing) and use UUID.
Variables ¶
This section is empty.
Functions ¶
func ClipRunes ¶
ClipRunes returns at most the first maxRunes runes of s without adding a suffix. If maxRunes is non-positive, it returns the empty string.
func FormatDuration ¶
FormatDuration formats a duration in a compact human-readable way.
func FormatUnixMinute ¶
FormatUnixMinute formats a unix timestamp as YYYY-MM-DD HH:MM.
func NewPrefixedID ¶
NewPrefixedID returns a string of the form "<prefix>_<body>", where body is 20 characters from [a-z0-9] (lowercase base36), derived from 128 bits of crypto-random entropy. Ordering is by created_at; IDs are not time-ordered.
func Ptr ¶
func Ptr[T any](v T) *T
Ptr returns a pointer to v. Useful for filling optional pointer fields.
func ResolvePath ¶
ResolvePath resolves a user-supplied path relative to root, ensuring the result stays under root. Returns the absolute, cleaned path. Includes a Windows-safe prefix check (filepath.Rel can return an absolute path when roots differ on different drives). Does NOT stat the path — callers handle existence and type checks.
func ResolveWorkspaceRoot ¶
ResolveWorkspaceRoot resolves and absolutizes a workspace root directory. If dir is empty, the current working directory is used.
func TruncateRunes ¶
TruncateRunes truncates s to at most maxRunes runes and appends an ellipsis when truncation happens. If maxRunes is non-positive, it returns the empty string.
func WithEnvVar ¶
WithEnvVar sets envKey to value for the duration of fn, then restores the previous process env state.
func WorkerJobNameForTaskRun ¶
WorkerJobNameForTaskRun returns a DNS-1123-compatible worker Job name for a task run id.
Types ¶
This section is empty.