Skip to main content

Crate ertangle_core

Crate ertangle_core 

Source
Expand description

ertangle-core — Domain model.

Contains environment-agnostic types only: agent kinds, sessions, events, message bus, tasks. The daemon, adapter, and TUI all share this set of types, making it the contract for the entire system.

Design principles:

  • Event is the single source of truth: all state is the result of folding events into State.
  • Events are serializable, persistable, and replayable, enabling TUIs to rebuild views seamlessly after disconnects.

Modules§

i18n
UI language: translate user-facing strings via gettext .po catalogs.

Macros§

tr_dyn
Translate a string known only at runtime (usually from a tr_noop!-marked table), returning String. Because it is not a literal, xtr cannot extract it, so the original text must be marked elsewhere with tr_noop! or tr!.
tr_noop
Mark a string literal for translation without translating it immediately (gettext N_): for &'static str tables so xtr -k tr_noop can extract it; translate at display time with [tr_dyn!].

Structs§

ActiveTool
Currently executing tool or subagent.
Artifact
Artifact shared by agent (file, branch, or diff).
Attachment
Attachments sent with a prompt (files or images). Content is read and inlined by the sender (TUI/CLI), so the remote daemon does not need access to the same filesystem.
BgProc
Remaining background child process.
BusMessage
ContextUsage
Current context usage of a session (tokens used by conversation and the model context window).
Cost
PermissionRequest
Normalized permission request sent by agent (regardless of source protocol).
PolicyEngine
Permission rule engine: filters unambiguously safe and high-risk operations before PermissionPolicy.
QuestionAnswer
Answer payload for an interactive user question.
QuestionOption
Single option for interactive user question.
Quota
Current quota status for an agent account (reported by agent itself, not estimated by ertangle).
QuotaWindow
A specific quota window (e.g. Claude 5 hours / 7 days).
Record
Event + sequence number + timestamp; unit of external communication (socket / log).
ReviewComment
Inline review comment on a diff line (M3 review loop).
Session
A running instance of an agent.
State
Task
UserQuestion
Normalized interactive question from agent to user.
WorktreeInfo
Worktree summary information (M3 workspace management).

Enums§

AgentKind
Supported agent kinds.
ArtifactKind
Decision
Event
System events. Append-only, serializable, replayable.
MsgKind
PermissionPolicy
Unified permission policy: determines whether agent tool execution requires human approval.
Role
Role of an agent in this system.
SessionStatus
Target
Recipient of a message.
TaskStatus

Constants§

ARCHIVED_MAX_DAYS
Default maximum age of archived sessions, counted from when they ended.
ARCHIVED_SESSIONS_CAP
Default maximum retained archived sessions with native_id (for browsing in resumption selector).
ARCHIVED_TRANSCRIPT_CAP
Maximum transcript lines retained for archived historical sessions.
ARTIFACT_CAP
Maximum retained artifacts.
MAX_IMAGE_BYTES
Image attachment size limit (5 MB) and text file embedding limit (256 KB).
MAX_TEXT_BYTES
MESSAGE_CAP
Maximum retained bus messages.
OTHER_PROMPT_MARK
Prefix for the first line of non-user prompts (other agents or ertangle) in transcript, followed by [source] .
PROMPT_FROM_ERTANGLE
Value of UserPrompt.from: daemon-generated prompt (unread reminder, conflict notification, handoff brief, auto-resume).
TRANSCRIPT_CAP
Maximum transcript lines retained per session (prevents memory growth on long conversations).
USER_PROMPT_MARK
Prefix for the first line of user prompts in transcript.
VERSION_WITH_HASH
Package version with short git commit hash when available.

Functions§

base64_encode
Standard base64 encoding (with padding).
compose_text
Merges attachments into prompt text: inlines text files in fenced blocks; converts images to a descriptive line when images_as_text is true (for agents without image block support).
env_var
Reads environment variable (ERTANGLE_X, falling back to legacy TERMADE_X if unset); non-unicode values treated as unset.
env_var_os
Same as env_var, but returns raw OsString.
format_remaining
Converts remaining milliseconds into 2h13m / 45m / 3d4h.
format_usd_limit
Formats USD budget into short string: omits decimals for whole amounts ($5), otherwise retains two decimals ($2.50).
human_tokens
Short representation of token count: 950, 36k, 1.5M.
image_mime
Guesses image MIME type from file extension; returns None if not an image.
is_subagent_tool
Checks if a tool name represents a native subagent tool.
looks_like_limit
Whether error text resembles quota exhaustion / rate limiting (conservative keyword matching across diverse agent messages).
new_id
Generates a prefixed random ID, e.g. ses_3f2a….
now_millis
Current time (Unix epoch milliseconds).
parse_prompt_line
If a transcript line is the first line of a prompt, returns (source name, None = user; prompt text).
redact_secrets
Masks common secrets and token patterns in text (protects secrets before writing to event log).
tool_summary
Summarizes tool input (JSON string) into a human-readable one-line summary: prefers command/file_path/pattern fields.
window_name
Converts window duration (minutes) to display name.

Type Aliases§

MsgId
Seq
Monotonic sequence number for each event, used for incremental sync (since).
SessionId
TaskId