Module: Terret

Defined in:
lib/terret.rb,
lib/terret/llm.rb,
lib/terret/loop.rb,
lib/terret/store.rb,
lib/terret/tools.rb,
lib/terret/titler.rb,
lib/terret/redactor.rb,
lib/terret/sessions.rb,
lib/terret/approvals.rb,
lib/terret/compactor.rb,
lib/terret/subagents.rb,
lib/terret/credentials.rb

Defined Under Namespace

Modules: LLM, Store, Tools Classes: Agent, AgentCapExceeded, AgentDisposed, AgentExists, Claim, Compactor, Credentials, LogInvariantViolation, Loop, NonPrimitivePayload, Prompt, Redactor, RoleSummarizer, ScrubberContractViolation, SessionEvent, Sessions, Subagents, Titler, TurnAlreadyRunning, TurnOpenInLog

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.declare_events!Object

Event vocabulary. Durable events land in the session log; the rest are live extension points. Modes are the public contract (see docs/events.md).



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/terret.rb', line 14

def self.declare_events!
  e = ->(name, mode, durable: false, doc: nil) {
    Hames.event(name, mode:, durable:, doc:)
  }
  # durable session events
  e.("session/created",   :emit, durable: true, doc: "session opened")
  e.("session/forked",    :emit, durable: true, doc: "lineage record")
  e.("turn/start",        :emit, durable: true, doc: "turn opened")
  e.("turn/end",          :emit, durable: true, doc: "turn closed with status")
  e.("step/start",        :emit, durable: true, doc: "model step opened")
  e.("step/end",          :emit, durable: true, doc: "model step closed")
  e.("user/message",      :emit, durable: true, doc: "entered user input")
  e.("assistant/chunk",   :emit, durable: true, doc: "raw stream delta (replay/UI fidelity)")
  e.("assistant/message", :emit, durable: true, doc: "completed assistant message")
  e.("tool/call",         :emit, durable: true, doc: "tool invocation requested by model")
  e.("tool/result",       :emit, durable: true, doc: "tool outcome")
  e.("context/injected",  :emit, durable: true, doc: "agent.inject landed in a request")
  e.("session/compacted", :emit, durable: true,
     doc: "history up to upto_seq replaced by summary (still model-visible)")
  e.("approval/requested", :emit, durable: true, doc: "tool call parked awaiting a decision")
  e.("approval/resolved",  :emit, durable: true, doc: "parked call decided (approve/deny)")
  e.("policy/updated",   :emit, durable: true,
     doc: "agent allow-list replaced (metadata; projection-invisible)")
  e.("session/titled",   :emit, durable: true, doc: "session titled (metadata; projection-invisible)")
  # live extension points
  e.("agent/disposed",    :emit,      doc: "an agent was disposed (session_id); reap its session-keyed runtime state")
  e.("config/updated",    :emit,      doc: "a row's config was hot-swapped (id, config)")
  e.("session/event",     :emit,      doc: "fan-out of every durable append")
  e.("agent/pre_step",    :waterfall, doc: "rewrite or reject the claimed messages")
  e.("agent/request",     :waterfall, doc: "rewrite the outbound model request")
  e.("llm/stream",        :waterfall, doc: "wrap/replace the adapter stream")
  e.("tools/pre_execute",  :waterfall, doc: "validate, veto, or rewrite a call")
  e.("tools/execute",      :waterfall, doc: "a provider may replace execution")
  e.("tools/post_execute", :waterfall, doc: "truncate/redact the result")
  e.("fs/authorize",       :waterfall, doc: "veto or admit an fs operation")
  e.("agent/turn_stopping", :serial,   doc: "ordered veto point before turn/end")
end