agent-command-tab 0.4.0__tar.gz → 0.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {agent_command_tab-0.4.0/src/agent_command_tab.egg-info → agent_command_tab-0.4.1}/PKG-INFO +2 -1
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/README.md +1 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/__init__.py +1 -1
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/app_controller.py +25 -2
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/dashboard_core.py +79 -20
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/messages_between_agent_sessions.py +48 -12
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/user_interface/agent_session_outline_view.py +98 -34
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/user_interface/menu_bar_status_item.py +11 -4
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/user_interface/popover_container.py +1 -1
- agent_command_tab-0.4.0/src/agent_command_tab/user_interface/process_info_alert.py → agent_command_tab-0.4.1/src/agent_command_tab/user_interface/process_and_session_info_alerts.py +102 -20
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/user_interface/row_text_rendering.py +13 -6
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/user_interface/saved_sessions_window.py +8 -2
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1/src/agent_command_tab.egg-info}/PKG-INFO +2 -1
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab.egg-info/SOURCES.txt +1 -1
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/LICENSE +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/pyproject.toml +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/setup.cfg +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/agent_adapters/__init__.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/agent_adapters/base.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/agent_adapters/claude_code.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/agent_adapters/codex.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/agent_adapters/generic.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/agent_input_box_typing.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/agent_process_tree.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/agent_session_pausing.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/claude_code_transcript_records.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/command_line.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/context_window_usage.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/dashboard_core_api.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/docked_window_frames_store.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/global_shortcut_key_filter.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/hook_event_forwarder.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/hook_event_tracking.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/hook_states_store.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/hooks_installer.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/installed_copy_paths.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/list_sorting.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/login_shell_environment.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/monitor_assignment.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/open_tool_call_reading.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/pause_records_store.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/saved_agent_sessions_store.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/screen_readings.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/session_status_computation.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/settings_store.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/snapshot_builder.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/snapshot_data_classes.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/start_with_iterm2.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/terminal_backends/__init__.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/terminal_backends/base.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/terminal_backends/iterm2_terminal_backend.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/terminal_backends/tmux_terminal_backend.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/unix_socket_listeners.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/user_interface/__init__.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/user_interface/agent_tool_icons.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/user_interface/app_icon.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/user_interface/control_helpers.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/user_interface/list_window.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/user_interface/named_colors.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/user_interface/pointing_hand_button.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/user_interface/screen_layout.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/user_interface/settings_window.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/user_interface/sidebar_panel.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/user_interface/sidebar_placement.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/user_interface/talk_to_each_other_alert.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab/window_list_ordering.py +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab.egg-info/dependency_links.txt +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab.egg-info/entry_points.txt +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab.egg-info/requires.txt +0 -0
- {agent_command_tab-0.4.0 → agent_command_tab-0.4.1}/src/agent_command_tab.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agent-command-tab
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: macOS menu bar list, window or screen-edge sidebar of the iTerm2 tabs and tmux windows where AI coding agents run
|
|
5
5
|
Author: Ben Weisburd
|
|
6
6
|
License-Expression: MIT
|
|
@@ -32,6 +32,7 @@ A macOS menu bar app that lists the iTerm2 windows and tabs, and the tmux sessio
|
|
|
32
32
|
- **What each agent is doing:** a status dot and word per tab (asking a question or for permission, thinking, running a tool, running in the background, done, new, idle, paused, error), the context size in tokens and its share of the context window, and optionally when it started, how long it has run, its memory and CPU use. "Done" stays until you look at the tab, and a Claude Code session is "new" until you send it its first message. The menu bar icon counts the agents waiting for your answer.
|
|
33
33
|
- **Process rows:** a tab whose agent started processes has an arrow that opens a row for each of them (right-click one for Info or Kill). The button at the top right collapses or expands all windows.
|
|
34
34
|
- **Control:** double-click to bring a window or tab to the front; press and hold to peek at a tab; rename in place; drag tabs between windows and windows between monitors; start a new agent window or tab; duplicate a tab; type `/compact` or `/clear` into an agent waiting at its prompt; end an agent's process; pause agents (with every process they started) before going offline and resume them later, per tab, window or monitor from the right-click menu, or for the selected rows with the button at the bottom right. Select several rows (Command-click, Shift-click) to act on all their agents at once (a busy agent gets `/compact` or `/clear` when its turn ends), or to ask them to talk to each other: each gets your note and how to message the others.
|
|
35
|
+
- **Session info:** right-click a tab row for "Session info", a window with the session's name and its agent's process ID, its age, tab, folder, conversation ID and file, context size, CPU and memory use, and command line, in text you can select and copy. "Copy contact info", below it, copies text to paste into another agent session so that it can message this one: a Claude Code session's name for the SendMessage tool, which only another Claude Code session has, or a Codex session's `codex queue` command, which any agent that can run commands can use.
|
|
35
36
|
- **Saved sessions:** save Claude Code and Codex sessions before a reboot, or to come back to them later: right-click a tab row for "Save session", or a window or monitor row, or one of several selected rows, for "Save 3 sessions" (with the number it can save). "Restore sessions…", right below it (grayed out until something is saved) and in the menu bar icon's right-click menu once something is saved, opens the Saved sessions window: the saved sessions under the windows they were saved from, to restore, rename (double-click a name, or select its row and press Return, Command-R or Command-Shift-R) or delete. A restored session continues its conversation (`--resume` for Claude Code, `resume` for Codex, after the launch command in Settings) in its own tab when that tab waits at a shell prompt (iTerm2 brings its tabs back after a reboot; a tmux pane counts while its tmux session runs), else in a new tab beside the others of its window, else in a new window. A name you gave a tab or window goes back to it. A restored session leaves the list once its agent runs in its tab; one that couldn't be restored, or whose agent didn't start within 15 seconds, stays, and an alert says why.
|
|
36
37
|
- **Keyboard:** Return shows the selected tab or window, Delete ends its agent (asking first), R, Command-R or Command-Shift-R renames it, the Right and Left arrows open and close a tab's process rows, Command-E or Command-Shift-E collapses or expands all windows, typing a name's first letters selects its row, Command-comma opens Settings, and Esc closes the list.
|
|
37
38
|
- **Sort and filter:** sort by status, name, share of the context window, start time, memory or CPU use, or keep the tab order; hide the idle tabs with one click or Command-I (new ones stay).
|
|
@@ -10,6 +10,7 @@ A macOS menu bar app that lists the iTerm2 windows and tabs, and the tmux sessio
|
|
|
10
10
|
- **What each agent is doing:** a status dot and word per tab (asking a question or for permission, thinking, running a tool, running in the background, done, new, idle, paused, error), the context size in tokens and its share of the context window, and optionally when it started, how long it has run, its memory and CPU use. "Done" stays until you look at the tab, and a Claude Code session is "new" until you send it its first message. The menu bar icon counts the agents waiting for your answer.
|
|
11
11
|
- **Process rows:** a tab whose agent started processes has an arrow that opens a row for each of them (right-click one for Info or Kill). The button at the top right collapses or expands all windows.
|
|
12
12
|
- **Control:** double-click to bring a window or tab to the front; press and hold to peek at a tab; rename in place; drag tabs between windows and windows between monitors; start a new agent window or tab; duplicate a tab; type `/compact` or `/clear` into an agent waiting at its prompt; end an agent's process; pause agents (with every process they started) before going offline and resume them later, per tab, window or monitor from the right-click menu, or for the selected rows with the button at the bottom right. Select several rows (Command-click, Shift-click) to act on all their agents at once (a busy agent gets `/compact` or `/clear` when its turn ends), or to ask them to talk to each other: each gets your note and how to message the others.
|
|
13
|
+
- **Session info:** right-click a tab row for "Session info", a window with the session's name and its agent's process ID, its age, tab, folder, conversation ID and file, context size, CPU and memory use, and command line, in text you can select and copy. "Copy contact info", below it, copies text to paste into another agent session so that it can message this one: a Claude Code session's name for the SendMessage tool, which only another Claude Code session has, or a Codex session's `codex queue` command, which any agent that can run commands can use.
|
|
13
14
|
- **Saved sessions:** save Claude Code and Codex sessions before a reboot, or to come back to them later: right-click a tab row for "Save session", or a window or monitor row, or one of several selected rows, for "Save 3 sessions" (with the number it can save). "Restore sessions…", right below it (grayed out until something is saved) and in the menu bar icon's right-click menu once something is saved, opens the Saved sessions window: the saved sessions under the windows they were saved from, to restore, rename (double-click a name, or select its row and press Return, Command-R or Command-Shift-R) or delete. A restored session continues its conversation (`--resume` for Claude Code, `resume` for Codex, after the launch command in Settings) in its own tab when that tab waits at a shell prompt (iTerm2 brings its tabs back after a reboot; a tmux pane counts while its tmux session runs), else in a new tab beside the others of its window, else in a new window. A name you gave a tab or window goes back to it. A restored session leaves the list once its agent runs in its tab; one that couldn't be restored, or whose agent didn't start within 15 seconds, stays, and an alert says why.
|
|
14
15
|
- **Keyboard:** Return shows the selected tab or window, Delete ends its agent (asking first), R, Command-R or Command-Shift-R renames it, the Right and Left arrows open and close a tab's process rows, Command-E or Command-Shift-E collapses or expands all windows, typing a name's first letters selects its row, Command-comma opens Settings, and Esc closes the list.
|
|
15
16
|
- **Sort and filter:** sort by status, name, share of the context window, start time, memory or CPU use, or keep the tab order; hide the idle tabs with one click or Command-I (new ones stay).
|
|
@@ -15,7 +15,8 @@ from AppKit import (NSAlert, NSAlertFirstButtonReturn, NSAlertSecondButtonReturn
|
|
|
15
15
|
NSAppearanceNameAqua, NSAppearanceNameDarkAqua, NSApplication, NSApplicationActivationPolicyAccessory, NSApplicationDidBecomeActiveNotification,
|
|
16
16
|
NSApplicationDidChangeScreenParametersNotification, NSApplicationDidResignActiveNotification,
|
|
17
17
|
NSApplicationWillTerminateNotification, NSEvent, NSEventModifierFlagCommand, NSEventModifierFlagShift,
|
|
18
|
-
NSMakeRect, NSMenu, NSMenuItem, NSModalPanelWindowLevel, NSMouseInRect,
|
|
18
|
+
NSMakeRect, NSMenu, NSMenuItem, NSModalPanelWindowLevel, NSMouseInRect, NSPasteboard, NSPasteboardTypeString,
|
|
19
|
+
NSPopoverBehaviorApplicationDefined,
|
|
19
20
|
NSPopoverBehaviorTransient, NSRunningApplication, NSWorkspace, NSWorkspaceApplicationKey,
|
|
20
21
|
NSWorkspaceDidActivateApplicationNotification)
|
|
21
22
|
from Foundation import NSNotificationCenter, NSObject, NSRunLoop, NSRunLoopCommonModes, NSTimer
|
|
@@ -48,7 +49,7 @@ from agent_command_tab.user_interface.app_icon import build_app_icon
|
|
|
48
49
|
from agent_command_tab.user_interface.list_window import ListWindowController
|
|
49
50
|
from agent_command_tab.user_interface.menu_bar_status_item import MenuBarStatusItemController
|
|
50
51
|
from agent_command_tab.user_interface.popover_container import ListPanelController, build_dropdown_popover
|
|
51
|
-
from agent_command_tab.user_interface.
|
|
52
|
+
from agent_command_tab.user_interface.process_and_session_info_alerts import build_process_info_alert, build_session_info_alert
|
|
52
53
|
from agent_command_tab.user_interface.saved_sessions_window import SavedSessionsWindowController, shorten_home_folder
|
|
53
54
|
from agent_command_tab.user_interface.screen_layout import (compute_list_window_content_rect_for_a_dragged_sidebar,
|
|
54
55
|
convert_rect_to_frame_list, grow_frame_to_smallest_size,
|
|
@@ -834,6 +835,28 @@ class AppController(NSObject):
|
|
|
834
835
|
"The process info couldn't be read",
|
|
835
836
|
lambda action_result: self.run_alert_in_front(build_process_info_alert(action_result.details, time.time())))
|
|
836
837
|
|
|
838
|
+
@objc.python_method
|
|
839
|
+
def show_agent_session_info(self, agent_session_entry):
|
|
840
|
+
"""Shows a tab row's Session info window once the core has read its agent session's
|
|
841
|
+
details, or an alert saying why it couldn't."""
|
|
842
|
+
self.submit_action_and_report_failure(
|
|
843
|
+
ActionRequest("read_agent_session_details", {"session_id": agent_session_entry.session_id}),
|
|
844
|
+
"The session info couldn't be read",
|
|
845
|
+
lambda action_result: self.run_alert_in_front(
|
|
846
|
+
build_session_info_alert(agent_session_entry, action_result.details, time.time())))
|
|
847
|
+
|
|
848
|
+
@objc.python_method
|
|
849
|
+
def copy_contact_info(self, session_id):
|
|
850
|
+
"""Puts on the clipboard what another agent session needs to send this one a message
|
|
851
|
+
(a tab row's "Copy contact info"), or says why it can't take messages."""
|
|
852
|
+
|
|
853
|
+
def put_text_on_the_clipboard(action_result):
|
|
854
|
+
pasteboard = NSPasteboard.generalPasteboard()
|
|
855
|
+
pasteboard.clearContents()
|
|
856
|
+
pasteboard.setString_forType_(action_result.details["text"], NSPasteboardTypeString)
|
|
857
|
+
self.submit_action_and_report_failure(ActionRequest("build_contact_info", {"session_id": session_id}),
|
|
858
|
+
"The contact info wasn't copied", put_text_on_the_clipboard)
|
|
859
|
+
|
|
837
860
|
@objc.python_method
|
|
838
861
|
def find_launch_command(self, agent_tool_name):
|
|
839
862
|
return find_launch_command(self.settings, agent_tool_name)
|
|
@@ -49,7 +49,9 @@ from agent_command_tab.agent_adapters.codex import CodexAdapter
|
|
|
49
49
|
from agent_command_tab.dashboard_core_api import ActionRegistry, ActionResult
|
|
50
50
|
from agent_command_tab.messages_between_agent_sessions import (SECONDS_A_MESSAGE_WAITS_FOR_AN_AGENT_AT_ITS_PROMPT,
|
|
51
51
|
AgentSessionForMessages,
|
|
52
|
-
build_message_asking_agent_session_to_talk_to_the_others
|
|
52
|
+
build_message_asking_agent_session_to_talk_to_the_others,
|
|
53
|
+
build_contact_info,
|
|
54
|
+
explain_why_sessions_of_agent_tool_cant_take_messages)
|
|
53
55
|
from agent_command_tab.snapshot_builder import (SECONDS_BEFORE_AN_OPEN_TOOL_CALL_SHOWS_AS_RUNNING, DisplayedState,
|
|
54
56
|
build_computer_snapshot, resolve_agent_sessions,
|
|
55
57
|
turns_of_the_agent_run_outside_its_tab)
|
|
@@ -84,7 +86,7 @@ RESOURCE_USAGE_CHECK_INTERVAL_SECONDS = 3 # the Memory and CPU columns
|
|
|
84
86
|
SECONDS_BETWEEN_THE_FIRST_TWO_CPU_READINGS = 0.5
|
|
85
87
|
CPU_PERCENT_SHOWN_AS_IDLE = 3 # an idle agent's CPU use wavers between 0 and 2 percent
|
|
86
88
|
SECONDS_AN_AGENT_GETS_TO_END_BEFORE_IT_IS_KILLED = 5 # "Kill Session": SIGTERM, then SIGKILL (a sub row's "Kill" too)
|
|
87
|
-
SECONDS_A_PROCESS_INFO_MEASURES_CPU_USE_OVER = 0.5 # a sub row's Info
|
|
89
|
+
SECONDS_A_PROCESS_INFO_MEASURES_CPU_USE_OVER = 0.5 # a sub row's Info, a tab row's Session info
|
|
88
90
|
CONVERSATION_FILE_RETRY_SECONDS = 15 # a conversation file not found yet (Codex writes it at the first prompt)
|
|
89
91
|
CONVERSATION_FILE_RECHECK_SECONDS = 60 # a conversation file found: looked up again in case the conversation changed
|
|
90
92
|
# The session reading values read from it that belong to its conversation, so cleared when the
|
|
@@ -265,6 +267,21 @@ def round_memory_and_cpu_use(memory_bytes, cpu_percent):
|
|
|
265
267
|
return round(memory_bytes / 1024 ** 2) * 1024 ** 2, cpu_percent
|
|
266
268
|
|
|
267
269
|
|
|
270
|
+
async def read_process_details_with_cpu_use(process_id):
|
|
271
|
+
"""Returns read_process_details's dict for a process (a sub row's Info, a tab row's Session
|
|
272
|
+
info), with "cpu_percent", its and its descendants' CPU use over
|
|
273
|
+
SECONDS_A_PROCESS_INFO_MEASURES_CPU_USE_OVER, both it and the memory rounded as the rows'
|
|
274
|
+
are; or None once the process has ended."""
|
|
275
|
+
first_resource_usage, first_read_at = read_process_tree_resource_usage(process_id), time.time()
|
|
276
|
+
await asyncio.sleep(SECONDS_A_PROCESS_INFO_MEASURES_CPU_USE_OVER)
|
|
277
|
+
details, read_at = read_process_details(process_id), time.time()
|
|
278
|
+
if first_resource_usage is None or details is None:
|
|
279
|
+
return None
|
|
280
|
+
details["memory_bytes"], details["cpu_percent"] = round_memory_and_cpu_use(
|
|
281
|
+
details["memory_bytes"], compute_cpu_percent((first_resource_usage[1], first_read_at), (details["cpu_seconds"], read_at)))
|
|
282
|
+
return details
|
|
283
|
+
|
|
284
|
+
|
|
268
285
|
def convert_exception_to_action_result(result_or_exception):
|
|
269
286
|
"""Returns an ActionResult from asyncio.gather(..., return_exceptions=True): a failed one for an exception."""
|
|
270
287
|
if isinstance(result_or_exception, Exception):
|
|
@@ -513,6 +530,8 @@ class DashboardCore:
|
|
|
513
530
|
register("end_agent_process", self.handle_end_agent_process)
|
|
514
531
|
register("end_agent_processes", self.handle_end_agent_processes)
|
|
515
532
|
register("read_child_process_details", self.handle_read_child_process_details)
|
|
533
|
+
register("read_agent_session_details", self.handle_read_agent_session_details)
|
|
534
|
+
register("build_contact_info", self.handle_build_contact_info)
|
|
516
535
|
register("end_child_process", self.handle_end_child_process)
|
|
517
536
|
register("pause_agent_sessions", self.handle_pause_agent_sessions)
|
|
518
537
|
register("resume_agent_sessions", self.handle_resume_agent_sessions)
|
|
@@ -970,21 +989,50 @@ class DashboardCore:
|
|
|
970
989
|
|
|
971
990
|
async def handle_read_child_process_details(self, action_request):
|
|
972
991
|
"""Returns, in its details, what a sub row's Info shows about the process in arguments
|
|
973
|
-
{"process_id"} of target {"session_id"}:
|
|
974
|
-
dict, with "cpu_percent", its and its descendants' CPU use over
|
|
975
|
-
SECONDS_A_PROCESS_INFO_MEASURES_CPU_USE_OVER, rounded as the row's is."""
|
|
992
|
+
{"process_id"} of target {"session_id"}: read_process_details_with_cpu_use's dict."""
|
|
976
993
|
process_id = action_request.arguments["process_id"]
|
|
977
994
|
if not self.child_process_is_listed(action_request.target["session_id"], process_id):
|
|
978
995
|
return ActionResult(False, "that process is no longer listed under its tab")
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
details, read_at = read_process_details(process_id), time.time()
|
|
982
|
-
if first_resource_usage is None or details is None:
|
|
996
|
+
details = await read_process_details_with_cpu_use(process_id)
|
|
997
|
+
if details is None:
|
|
983
998
|
return ActionResult(False, "that process has ended")
|
|
984
|
-
details["memory_bytes"], details["cpu_percent"] = round_memory_and_cpu_use(
|
|
985
|
-
details["memory_bytes"], compute_cpu_percent((first_resource_usage[1], first_read_at), (details["cpu_seconds"], read_at)))
|
|
986
999
|
return ActionResult(True, details=details)
|
|
987
1000
|
|
|
1001
|
+
async def handle_read_agent_session_details(self, action_request):
|
|
1002
|
+
"""Returns, in its details, what a tab row's Session info shows about the agent session of
|
|
1003
|
+
target {"session_id"}: read_process_details_with_cpu_use's dict for its agent process, with
|
|
1004
|
+
"tab_kind_name" ("iTerm2 tab", "tmux window"), "conversation_id" and "conversation_file"
|
|
1005
|
+
(each None when not known), "claude_config_folder" (None for the default folder and for
|
|
1006
|
+
other tools) and "codex_home_folder" (None for other tools)."""
|
|
1007
|
+
session_id = action_request.target["session_id"]
|
|
1008
|
+
agent_session = self.agent_sessions.get(session_id)
|
|
1009
|
+
if agent_session is None or not agent_session["process_id"]:
|
|
1010
|
+
return ActionResult(False, "that tab no longer runs an agent")
|
|
1011
|
+
process_id = agent_session["process_id"]
|
|
1012
|
+
details = await read_process_details_with_cpu_use(process_id)
|
|
1013
|
+
if details is None:
|
|
1014
|
+
return ActionResult(False, "the agent has ended")
|
|
1015
|
+
# Unknown, rather than refused as Save session refuses it, when it can't be told.
|
|
1016
|
+
conversation_id, conversation_file, _ = await self.find_conversation_id_and_file_known_to_be_its_own(session_id, agent_session)
|
|
1017
|
+
terminal_backend = self.find_terminal_backend_of(session_id=session_id)
|
|
1018
|
+
details.update(
|
|
1019
|
+
tab_kind_name=terminal_backend.tab_kind_name if terminal_backend is not None else "tab",
|
|
1020
|
+
conversation_id=conversation_id, conversation_file=conversation_file,
|
|
1021
|
+
claude_config_folder=(self.claude_agents_by_process_id.get(process_id) or {}).get("config_folder"),
|
|
1022
|
+
codex_home_folder=agent_session["adapter"].find_codex_home_folder_of_process(process_id))
|
|
1023
|
+
return ActionResult(True, details=details)
|
|
1024
|
+
|
|
1025
|
+
async def handle_build_contact_info(self, action_request):
|
|
1026
|
+
"""Returns, in details {"text"}, what a tab row's "Copy contact info" puts on the
|
|
1027
|
+
clipboard for the agent session of target {"session_id"}
|
|
1028
|
+
(messages_between_agent_sessions.build_contact_info), or why it can't take
|
|
1029
|
+
messages from other sessions."""
|
|
1030
|
+
agent_session_for_messages, reason = await self.build_agent_session_for_messages_or_reason_it_cant_take_part(
|
|
1031
|
+
action_request.target["session_id"])
|
|
1032
|
+
if agent_session_for_messages is None:
|
|
1033
|
+
return ActionResult(False, reason)
|
|
1034
|
+
return ActionResult(True, details={"text": build_contact_info(agent_session_for_messages)})
|
|
1035
|
+
|
|
988
1036
|
async def handle_end_child_process(self, action_request):
|
|
989
1037
|
"""Ends the process in arguments {"process_id"}, a sub row of target {"session_id"}, and
|
|
990
1038
|
every process below it ("Kill" in a sub row's menu): killing
|
|
@@ -1127,7 +1175,7 @@ class DashboardCore:
|
|
|
1127
1175
|
"and after /new more than one fits")
|
|
1128
1176
|
codex_home_folder = agent_session["adapter"].find_codex_home_folder_of_process(process_id) # where its conversation is
|
|
1129
1177
|
else:
|
|
1130
|
-
return None,
|
|
1178
|
+
return None, explain_why_sessions_of_agent_tool_cant_take_messages(agent_session["agent_tool_name"])
|
|
1131
1179
|
if not address:
|
|
1132
1180
|
return None, reason_without_address
|
|
1133
1181
|
terminal_backend = self.find_terminal_backend_of(session_id=session_id)
|
|
@@ -1336,6 +1384,19 @@ class DashboardCore:
|
|
|
1336
1384
|
|
|
1337
1385
|
# ----- saved sessions: Save session and Restore sessions -----
|
|
1338
1386
|
|
|
1387
|
+
async def find_conversation_id_and_file_known_to_be_its_own(self, session_id, agent_session):
|
|
1388
|
+
"""Returns (the agent session's conversation ID, its conversation file, ""), each None when
|
|
1389
|
+
not known, or (None, None, why its conversation can't be told) when a lookup by folder and
|
|
1390
|
+
start time could find another session's conversation, for Save session, Duplicate and
|
|
1391
|
+
Session info."""
|
|
1392
|
+
if self.conversation_was_cleared_and_the_next_has_no_file_yet(session_id):
|
|
1393
|
+
return None, None, "it has had no conversation since its /clear"
|
|
1394
|
+
if self.codex_conversation_may_be_another_sessions(session_id, agent_session):
|
|
1395
|
+
return None, None, "its conversation can't be told apart from another Codex session's in the same folder"
|
|
1396
|
+
claude_agent_record = self.claude_agents_by_process_id.get(agent_session["process_id"])
|
|
1397
|
+
return (await agent_session["adapter"].find_conversation_id(agent_session["process_id"], claude_agent_record),
|
|
1398
|
+
await self.find_current_conversation_file(session_id, agent_session), "")
|
|
1399
|
+
|
|
1339
1400
|
async def find_conversation_to_save_or_copy(self, session_id, agent_session):
|
|
1340
1401
|
"""Returns (the agent session's conversation ID, the Claude Code config folder it runs
|
|
1341
1402
|
with or None for the default, the CODEX_HOME a Codex session runs with or None for other
|
|
@@ -1343,18 +1404,16 @@ class DashboardCore:
|
|
|
1343
1404
|
when it isn't certainly this session's."""
|
|
1344
1405
|
if not agent_session["adapter"].can_resume_conversations:
|
|
1345
1406
|
return None, None, None, f"{agent_session['agent_tool_name']} can't resume a saved conversation"
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
if
|
|
1349
|
-
return None, None, None,
|
|
1350
|
-
|
|
1351
|
-
conversation_id = await agent_session["adapter"].find_conversation_id(agent_session["process_id"], claude_agent_record)
|
|
1352
|
-
if await self.find_current_conversation_file(session_id, agent_session) is None:
|
|
1407
|
+
conversation_id, conversation_file, reason_the_conversation_cant_be_told = (
|
|
1408
|
+
await self.find_conversation_id_and_file_known_to_be_its_own(session_id, agent_session))
|
|
1409
|
+
if reason_the_conversation_cant_be_told:
|
|
1410
|
+
return None, None, None, reason_the_conversation_cant_be_told
|
|
1411
|
+
if conversation_file is None:
|
|
1353
1412
|
return None, None, None, "it has no conversation yet (no message was sent to it)"
|
|
1354
1413
|
if not conversation_id: # Codex after /new: more than one conversation file fits its process
|
|
1355
1414
|
return None, None, None, "it has started more than one conversation, and which one runs now can't be told"
|
|
1356
1415
|
# The default home too, so a CODEX_HOME the launch command sets doesn't take its place.
|
|
1357
|
-
return (conversation_id, (
|
|
1416
|
+
return (conversation_id, (self.claude_agents_by_process_id.get(agent_session["process_id"]) or {}).get("config_folder"),
|
|
1358
1417
|
agent_session["adapter"].find_codex_home_folder_of_process(agent_session["process_id"]), "")
|
|
1359
1418
|
|
|
1360
1419
|
async def handle_save_agent_sessions(self, action_request):
|
|
@@ -34,13 +34,54 @@ AgentSessionForMessages.__doc__ = (
|
|
|
34
34
|
|
|
35
35
|
def describe_agent_session_for_messages(agent_session):
|
|
36
36
|
"""Returns how the messages name a session, with its process ID, folder and tab, for example
|
|
37
|
-
'
|
|
37
|
+
'Claude Code session "analysis-1d" (process ID 4242, folder /x, iTerm2 tab "analysis")'."""
|
|
38
38
|
name = (f'"{agent_session.address}"' if agent_session.how_other_agent_sessions_send_it_messages == MESSAGES_THROUGH_THE_SEND_MESSAGE_TOOL
|
|
39
39
|
else agent_session.address)
|
|
40
|
-
return (f"
|
|
40
|
+
return (f"{agent_session.agent_tool_name} session {name} (process ID {agent_session.process_id}, "
|
|
41
41
|
f'folder {agent_session.working_folder or "unknown"}, {agent_session.tab_kind_name} "{agent_session.tab_title}")')
|
|
42
42
|
|
|
43
43
|
|
|
44
|
+
def build_codex_queue_command(recipient):
|
|
45
|
+
"""Returns the command that sends the recipient, a Codex session, a message, with
|
|
46
|
+
"<your message>" in place of the message."""
|
|
47
|
+
# The message attached to its option, so one starting with "-" isn't read as an option. Its
|
|
48
|
+
# CODEX_HOME, since the sender's may differ.
|
|
49
|
+
return (f"{build_codex_home_setting(recipient.codex_home_folder)}codex queue --thread {shlex.quote(recipient.address)} "
|
|
50
|
+
f'--message="<your message>"')
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def explain_how_to_send_a_message_to(recipient):
|
|
54
|
+
"""Returns the sentence telling a session that can message the recipient how to: run
|
|
55
|
+
`codex queue` for a Codex session, which any agent with a shell can, or use the SendMessage
|
|
56
|
+
tool for a Claude Code session, which only another Claude Code session has."""
|
|
57
|
+
if recipient.how_other_agent_sessions_send_it_messages == MESSAGES_THROUGH_CODEX_QUEUE:
|
|
58
|
+
return f"To message it, run: {build_codex_queue_command(recipient)}"
|
|
59
|
+
return f'To message it, use your SendMessage tool with to: "{recipient.address}".'
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def explain_why_sessions_of_agent_tool_cant_take_messages(agent_tool_name):
|
|
63
|
+
"""Returns why a session of a tool other than Claude Code and Codex is left out of messages
|
|
64
|
+
between sessions, such as "Aider sessions can't take messages from other sessions"."""
|
|
65
|
+
return f"{agent_tool_name} sessions can't take messages from other sessions"
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def build_contact_info(agent_session):
|
|
69
|
+
"""Returns what a tab row's "Copy contact info" puts on the clipboard, to paste into
|
|
70
|
+
another agent session so it can message this one: the session as Talk to Each Other names it,
|
|
71
|
+
then how to send it a message, for example 'Claude Code session "analysis-1d" (process ID
|
|
72
|
+
4242, folder /x, iTerm2 tab "analysis"). You can message it using your SendMessage tool with
|
|
73
|
+
to: "analysis-1d"'.
|
|
74
|
+
|
|
75
|
+
Args:
|
|
76
|
+
agent_session: The AgentSessionForMessages of the session to message.
|
|
77
|
+
"""
|
|
78
|
+
if agent_session.how_other_agent_sessions_send_it_messages == MESSAGES_THROUGH_CODEX_QUEUE:
|
|
79
|
+
how_to_message_it = f"by running: {build_codex_queue_command(agent_session)}"
|
|
80
|
+
else:
|
|
81
|
+
how_to_message_it = f'using your SendMessage tool with to: "{agent_session.address}"'
|
|
82
|
+
return f"{describe_agent_session_for_messages(agent_session)}. You can message it {how_to_message_it}"
|
|
83
|
+
|
|
84
|
+
|
|
44
85
|
def explain_how_to_send_a_message(sender, recipient, recipient_gets_the_message_too):
|
|
45
86
|
"""Returns the sentence telling the sender how to send the recipient a message, or why it can't.
|
|
46
87
|
|
|
@@ -51,14 +92,9 @@ def explain_how_to_send_a_message(sender, recipient, recipient_gets_the_message_
|
|
|
51
92
|
too, so it learns how to message the sender (only the one chosen in the Talk to Each
|
|
52
93
|
Other window may get it).
|
|
53
94
|
"""
|
|
54
|
-
if recipient.how_other_agent_sessions_send_it_messages == MESSAGES_THROUGH_CODEX_QUEUE
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return (f"To message it, run: {build_codex_home_setting(recipient.codex_home_folder)}codex queue --thread "
|
|
58
|
-
f"{shlex.quote(recipient.address)} "
|
|
59
|
-
f'--message="<your message>"')
|
|
60
|
-
if sender.how_other_agent_sessions_send_it_messages == MESSAGES_THROUGH_THE_SEND_MESSAGE_TOOL:
|
|
61
|
-
return f'To message it, use your SendMessage tool with to: "{recipient.address}".'
|
|
95
|
+
if (recipient.how_other_agent_sessions_send_it_messages == MESSAGES_THROUGH_CODEX_QUEUE
|
|
96
|
+
or sender.how_other_agent_sessions_send_it_messages == MESSAGES_THROUGH_THE_SEND_MESSAGE_TOOL):
|
|
97
|
+
return explain_how_to_send_a_message_to(recipient)
|
|
62
98
|
if recipient_gets_the_message_too:
|
|
63
99
|
return ("A Codex session has no way to send a Claude Code session a message, so it can't hear from you directly, "
|
|
64
100
|
"but it can message you.")
|
|
@@ -76,8 +112,8 @@ def build_message_asking_agent_session_to_talk_to_the_others(note, recipient, ot
|
|
|
76
112
|
agent_sessions_that_get_the_message: The AgentSessionForMessages of every session that
|
|
77
113
|
gets a Talk to Each Other message this time.
|
|
78
114
|
"""
|
|
79
|
-
lines = [note.strip(), "", f"You are {describe_agent_session_for_messages(recipient)}.", "", "The other sessions:"]
|
|
80
|
-
lines += [f"- {describe_agent_session_for_messages(other)}. "
|
|
115
|
+
lines = [note.strip(), "", f"You are the {describe_agent_session_for_messages(recipient)}.", "", "The other sessions:"]
|
|
116
|
+
lines += [f"- the {describe_agent_session_for_messages(other)}. "
|
|
81
117
|
f"{explain_how_to_send_a_message(recipient, other, other in agent_sessions_that_get_the_message)}"
|
|
82
118
|
for other in other_agent_sessions]
|
|
83
119
|
return "\n".join(lines)
|