shellcontext

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package shellcontext identifies user-requested shell executions that should be preserved as conversational context. It is a dependency-free leaf so the TUI, remote transports, and turn runner share one wire representation.

Index

Constants

View Source
const (
	// MetaKey carries the structured shell execution alongside its text form.
	MetaKey = "sahara.shell_context"
	// CommitAckMetaKey marks the empty final emitted after a context-only save.
	CommitAckMetaKey = "sahara.shell_context_committed"
)

Variables

This section is empty.

Functions

func ContextText

func ContextText(record Record) string

ContextText is the exact user-role text exposed to the model. The explicit envelope prevents command output from masquerading as user instructions.

func DisplayText

func DisplayText(record Record) string

DisplayText is the compact transcript form shown by the TUI.

func IsCommitAck

func IsCommitAck(message protocol.ChatMessage) bool

IsCommitAck reports whether a final only acknowledges a context save.

func IsContextOnly

func IsContextOnly(message protocol.ChatMessage) bool

IsContextOnly reports whether the message should be persisted without an LLM call. This is intentionally based on structured metadata, never prompt text.

func MarkCommitAck

func MarkCommitAck(message *protocol.ChatMessage)

MarkCommitAck marks a transport final as acknowledgement-only.

func Put

func Put(message *protocol.ChatMessage, record Record) error

Put attaches a record to message metadata.

Types

type Record

type Record struct {
	Command         string `json:"command"`
	CWD             string `json:"cwd"`
	Output          string `json:"output,omitempty"`
	ExitCode        int    `json:"exit_code"`
	Error           string `json:"error,omitempty"`
	OutputBytes     int    `json:"output_bytes,omitempty"`
	OutputTruncated bool   `json:"output_truncated,omitempty"`
	TriggerAgent    bool   `json:"trigger_agent"`
}

Record is the durable, provider-neutral description of one explicit shell execution. TriggerAgent is meaningful for idle sends; steering always enters an already-running turn.

func FromMessage

func FromMessage(message protocol.ChatMessage) (Record, bool)

FromMessage returns the structured shell record when present and valid.

Jump to

Keyboard shortcuts

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