Class: AgentsControl::Session
- Inherits:
-
Object
- Object
- AgentsControl::Session
- Defined in:
- lib/agents_control/session.rb
Overview
One session — a terminal tab, or an agent with no terminal at all.
Deliberately knows nothing about Claude or iTerm2: this is the common denominator the core and Telegram operate on. Anything backend-specific lives in the adapters.
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
-
#agent_pid ⇒ Object
readonly
Returns the value of attribute agent_pid.
-
#backend ⇒ Object
readonly
Returns the value of attribute backend.
-
#cwd ⇒ Object
readonly
Returns the value of attribute cwd.
-
#foreground_command ⇒ Object
readonly
Returns the value of attribute foreground_command.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#tty ⇒ Object
readonly
Returns the value of attribute tty.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
-
#agent? ⇒ Boolean
Agent presence is confirmed by the process tree, not the tab title.
- #at_shell_prompt? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(id:, backend: nil, tty: nil, title: nil, cwd: nil, processing: nil, at_shell_prompt: nil, agent: nil, agent_pid: nil, foreground_command: nil) ⇒ Session
constructor
A new instance of Session.
-
#label ⇒ Object
Short name for the Telegram list: the directory name is more informative than a full path or a title that may be stale.
-
#processing? ⇒ Boolean
Terminal is busy working.
-
#terminalless? ⇒ Boolean
A session without a tab: launched from VS Code or another GUI client.
- #to_h ⇒ Object
- #with(**attrs) ⇒ Object
Constructor Details
#initialize(id:, backend: nil, tty: nil, title: nil, cwd: nil, processing: nil, at_shell_prompt: nil, agent: nil, agent_pid: nil, foreground_command: nil) ⇒ Session
Returns a new instance of Session.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/agents_control/session.rb', line 12 def initialize(id:, backend: nil, tty: nil, title: nil, cwd: nil, processing: nil, at_shell_prompt: nil, agent: nil, agent_pid: nil, foreground_command: nil) @id = id @backend = backend @tty = tty @title = title @cwd = cwd @processing = processing @at_shell_prompt = at_shell_prompt @agent = agent @agent_pid = agent_pid @foreground_command = foreground_command end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
10 11 12 |
# File 'lib/agents_control/session.rb', line 10 def agent @agent end |
#agent_pid ⇒ Object (readonly)
Returns the value of attribute agent_pid.
10 11 12 |
# File 'lib/agents_control/session.rb', line 10 def agent_pid @agent_pid end |
#backend ⇒ Object (readonly)
Returns the value of attribute backend.
10 11 12 |
# File 'lib/agents_control/session.rb', line 10 def backend @backend end |
#cwd ⇒ Object (readonly)
Returns the value of attribute cwd.
10 11 12 |
# File 'lib/agents_control/session.rb', line 10 def cwd @cwd end |
#foreground_command ⇒ Object (readonly)
Returns the value of attribute foreground_command.
10 11 12 |
# File 'lib/agents_control/session.rb', line 10 def foreground_command @foreground_command end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/agents_control/session.rb', line 10 def id @id end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
10 11 12 |
# File 'lib/agents_control/session.rb', line 10 def title @title end |
#tty ⇒ Object (readonly)
Returns the value of attribute tty.
10 11 12 |
# File 'lib/agents_control/session.rb', line 10 def tty @tty end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
61 |
# File 'lib/agents_control/session.rb', line 61 def ==(other) = other.is_a?(Session) && other.to_h == to_h |
#agent? ⇒ Boolean
Agent presence is confirmed by the process tree, not the tab title.
34 |
# File 'lib/agents_control/session.rb', line 34 def agent? = !@agent.nil? |
#at_shell_prompt? ⇒ Boolean
31 |
# File 'lib/agents_control/session.rb', line 31 def at_shell_prompt? = @at_shell_prompt == true |
#hash ⇒ Object
64 |
# File 'lib/agents_control/session.rb', line 64 def hash = to_h.hash |
#label ⇒ Object
Short name for the Telegram list: the directory name is more informative than a full path or a title that may be stale.
42 43 44 45 46 47 |
# File 'lib/agents_control/session.rb', line 42 def label return File.basename(cwd) if cwd && !cwd.empty? return title if title && !title.empty? id.to_s end |
#processing? ⇒ Boolean
Terminal is busy working. iTerm2 has is processing; tmux has no
direct equivalent, so the value can be nil — "unknown", not "no".
29 |
# File 'lib/agents_control/session.rb', line 29 def processing? = @processing == true |
#terminalless? ⇒ Boolean
A session without a tab: launched from VS Code or another GUI client. Can't be controlled through a terminal, only reached via hooks.
38 |
# File 'lib/agents_control/session.rb', line 38 def terminalless? = @backend.nil? || @tty.nil? |
#to_h ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/agents_control/session.rb', line 53 def to_h { id: id, backend: backend, tty: tty, title: title, cwd: cwd, processing: @processing, at_shell_prompt: @at_shell_prompt, agent: agent, agent_pid: agent_pid, foreground_command: foreground_command } end |