Documentation
¶
Index ¶
- Constants
- Variables
- func Clean(value string) string
- func ExportAsciicast(w io.Writer, rec Recording) error
- func ParseSize(value string) (int64, error)
- func Path(stateDir string, id string) string
- func PathForRecord(stateDir string, record state.SessionRecord) string
- func Replay(w io.Writer, rec Recording, speed float64, noDelay bool) error
- func Text(rec Recording, opts TextOptions) string
- type BundleExportResult
- type BundleImportResult
- type BundleManifest
- type BundlePreview
- type Frame
- type Header
- type Match
- type Recording
- type TextOptions
- type Writer
- func (w *Writer) Close(ended time.Time) (state.TranscriptSpec, error)
- func (w *Writer) Snapshot() state.TranscriptSpec
- func (w *Writer) StopReason() string
- func (w *Writer) WriteInput(at time.Time, data []byte)
- func (w *Writer) WriteMarker(at time.Time, message string)
- func (w *Writer) WriteOutput(at time.Time, data []byte)
- type WriterOptions
Constants ¶
const ( FormatAsciicast = "asciicast-v2" DefaultMaxBytes = 50 * 1024 * 1024 )
Variables ¶
var ErrTornTail = errors.New("transcript tail is incomplete")
ErrTornTail reports a transcript whose final line is incomplete or unparseable (crash, ENOSPC, power loss mid-write). The Recording returned alongside it carries every frame parsed before the tear, so callers can errors.Is(err, ErrTornTail) and continue with a warning.
Functions ¶
func Clean ¶
Clean strips terminal escape sequences from recorded output and normalizes carriage returns to newlines. Transcript frames are untrusted (a hostile remote, or an imported bundle, controls the bytes), so it removes the full ESC grammar via termstyle.Strip (the single ECMA-48 scanner shared with the UI) and then drops raw control characters that survive as literal bytes — C0 (except newline and tab), DEL, and the C1 range U+0080–U+009F, where U+009B is CSI to xterm-class terminals — so cleaned text printed to a real terminal cannot carry an escape introducer.
func PathForRecord ¶
func PathForRecord(stateDir string, record state.SessionRecord) string
func Text ¶
func Text(rec Recording, opts TextOptions) string
Types ¶
type BundleExportResult ¶
type BundleExportResult struct {
Path string `json:"path"`
Manifest BundleManifest `json:"manifest"`
Bytes int64 `json:"bytes"`
Warning string `json:"warning,omitempty"`
}
func ExportBundle ¶
func ExportBundle(stateDir string, record state.SessionRecord, identity state.MachineIdentity, outputPath string, now time.Time) (BundleExportResult, error)
type BundleImportResult ¶
type BundleImportResult struct {
Record state.SessionRecord `json:"record"`
Manifest BundleManifest `json:"manifest"`
OriginClass string `json:"origin_class"`
BundleSHA256 string `json:"bundle_sha256"`
TranscriptPath string `json:"transcript_path"`
Warning string `json:"warning,omitempty"`
}
func ImportBundle ¶
func ImportBundle(stateDir string, bundlePath string, identity state.MachineIdentity, now time.Time) (BundleImportResult, error)
type BundleManifest ¶
type BundleManifest struct {
BundleVersion int `json:"bundle_version"`
ExportedAt time.Time `json:"exported_at"`
ExportedByMachineID string `json:"exported_by_machine_id,omitempty"`
SourceMachineID string `json:"source_machine_id,omitempty"`
SourceSessionID string `json:"source_session_id"`
Target string `json:"target,omitempty"`
Route []string `json:"route,omitempty"`
TranscriptSHA256 string `json:"transcript_sha256"`
RecordSHA256 string `json:"record_sha256"`
// TranscriptTornTail flags a transcript whose final line is incomplete
// (the recorder crashed or ran out of disk). Additive to bundle_version 1.
TranscriptTornTail bool `json:"transcript_torn_tail,omitempty"`
}
type BundlePreview ¶
type BundlePreview struct {
Manifest BundleManifest `json:"manifest"`
BundleSHA256 string `json:"bundle_sha256"`
Bytes int64 `json:"bytes"`
}
func PreviewBundle ¶
func PreviewBundle(bundlePath string) (BundlePreview, error)
type Match ¶
type Recording ¶
type TextOptions ¶
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
func OpenWriter ¶
func OpenWriter(opts WriterOptions) (*Writer, state.TranscriptSpec, error)
func (*Writer) Snapshot ¶
func (w *Writer) Snapshot() state.TranscriptSpec
func (*Writer) StopReason ¶ added in v1.10.0
StopReason reports why recording stopped early: "" while healthy, "size limit reached" once MaxBytes is hit, or "write error: ..." after an I/O failure. The same text is appended to the cast as a final marker.