Class: AgentsControl::Terminals::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/agents_control/terminals/base.rb

Overview

The terminal backend contract.

There are three implementations right now (iTerm2, tmux, null), and they're chosen not globally but per session: the same machine can hold bare iTerm2 tabs, tmux panes, and VS Code sessions with no terminal at all, all at once.

Every method must be safe when the backend is unavailable: return an empty result or false, never raise out to the caller or hang it.

Direct Known Subclasses

ITerm2, Null, Tmux

Instance Method Summary collapse

Constructor Details

#initialize(executor: Executor.new, probe: nil) ⇒ Base

Returns a new instance of Base.



19
20
21
22
# File 'lib/agents_control/terminals/base.rb', line 19

def initialize(executor: Executor.new, probe: nil)
  @executor = executor
  @probe = probe
end

Instance Method Details

#available?Boolean

Whether the backend can answer right now. Must have no side effects: in particular, must not launch an app the user hasn't already opened.

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


30
# File 'lib/agents_control/terminals/base.rb', line 30

def available? = raise(NotImplementedError)

#capture(_id, lines: 200) ⇒ Object

Raises:



39
# File 'lib/agents_control/terminals/base.rb', line 39

def capture(_id, lines: 200) = raise(Unsupported, "#{name}: reading the screen is not supported")

#close(_id) ⇒ Object

Raises:



43
# File 'lib/agents_control/terminals/base.rb', line 43

def close(_id) = raise(Unsupported, "#{name}: closing is not supported")

#create_tab(cwd: nil, command: nil) ⇒ Object

Raises:



35
# File 'lib/agents_control/terminals/base.rb', line 35

def create_tab(cwd: nil, command: nil) = raise(Unsupported, "#{name}: creating a tab is not supported")

#focus(_id) ⇒ Object

Raises:



41
# File 'lib/agents_control/terminals/base.rb', line 41

def focus(_id) = raise(Unsupported, "#{name}: focusing is not supported")

#nameObject

The backend's symbolic name — ends up in Session#backend.

Raises:

  • (NotImplementedError)


25
# File 'lib/agents_control/terminals/base.rb', line 25

def name = raise(NotImplementedError)

#send_text(_id, _text, newline: true) ⇒ Object

Raises:



37
# File 'lib/agents_control/terminals/base.rb', line 37

def send_text(_id, _text, newline: true) = raise(Unsupported, "#{name}: sending input is not supported")

#sessionsObject

[Session] — all of this backend's tabs/panes.

Raises:

  • (NotImplementedError)


33
# File 'lib/agents_control/terminals/base.rb', line 33

def sessions = raise(NotImplementedError)