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
.pocatalogs.
Macros§
- tr_dyn
- Translate a string known only at runtime (usually from a
tr_noop!-marked table), returningString. Because it is not a literal,xtrcannot extract it, so the original text must be marked elsewhere withtr_noop!ortr!. - tr_noop
- Mark a string literal for translation without translating it immediately (gettext
N_): for&'static strtables soxtr -k tr_noopcan extract it; translate at display time with [tr_dyn!].
Structs§
- Active
Tool - 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
- Context
Usage - Current context usage of a session (tokens used by conversation and the model context window).
- Cost
- Permission
Request - Normalized permission request sent by agent (regardless of source protocol).
- Policy
Engine - Permission rule engine: filters unambiguously safe and high-risk operations before
PermissionPolicy. - Question
Answer - Answer payload for an interactive user question.
- Question
Option - Single option for interactive user question.
- Quota
- Current quota status for an agent account (reported by agent itself, not estimated by ertangle).
- Quota
Window - A specific quota window (e.g. Claude 5 hours / 7 days).
- Record
- Event + sequence number + timestamp; unit of external communication (socket / log).
- Review
Comment - Inline review comment on a diff line (M3 review loop).
- Session
- A running instance of an agent.
- State
- Task
- User
Question - Normalized interactive question from agent to user.
- Worktree
Info - Worktree summary information (M3 workspace management).
Enums§
- Agent
Kind - Supported agent kinds.
- Artifact
Kind - Decision
- Event
- System events. Append-only, serializable, replayable.
- MsgKind
- Permission
Policy - Unified permission policy: determines whether agent tool execution requires human approval.
- Role
- Role of an agent in this system.
- Session
Status - Target
- Recipient of a message.
- Task
Status
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_textis true (for agents without image block support). - env_var
- Reads environment variable (
ERTANGLE_X, falling back to legacyTERMADE_Xif unset); non-unicode values treated as unset. - env_
var_ os - Same as
env_var, but returns rawOsString. - 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
Noneif 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.