prompts: update D-Bus operational model with all methods, signals, and examples

This commit is contained in:
lkn 2026-07-21 14:10:43 +02:00
parent 590dbb5b4a
commit 17f28647b8
1 changed files with 85 additions and 60 deletions

View File

@ -25,34 +25,75 @@ Each entry: `id\tstate\tmodel\tagent`
**Inter-Agent Communication**: Use `PeerSubmit` to send a prompt to another session. Always provide a return path (e.g., [message from $OLLIE_SESSION_ID]). **Inter-Agent Communication**: Use `PeerSubmit` to send a prompt to another session. Always provide a return path (e.g., [message from $OLLIE_SESSION_ID]).
# Session Management (D-Bus)
All session operations go through the D-Bus interface. No filesystem writes for session control.
## Methods ## Methods
All session operations go through the D-Bus interface.
### Session Lifecycle
| Method | Args | Returns | Purpose | | Method | Args | Returns | Purpose |
|---|---|---|---| |---|---|---|---|
| `CreateSession` | cwd, backend, model, agent | session_id | Create a new session | | `CreateSession` | cwd, backend, model, agent, system_prompt | session_id | Create a new session |
| `ListSessions` | — | array of "id\tstate\tmodel\tagent" | Discover sessions | | `ListSessions` | — | array of "id\tstate\tmodel\tagent" | Discover sessions |
| `KillSession` | session_id | success | Terminate a session | | `KillSession` | session_id | bool | Terminate a session |
| `RenameSession` | session_id, new_name | success | Rename a session | | `RenameSession` | session_id, new_name | bool | Rename a session |
| `Submit` | session_id, prompt | success | Submit a prompt to an agent |
| `Interrupt` | session_id | success | Interrupt current agent turn | ### Agent Interaction
| `GetState` | session_id | state | Current state: idle, thinking, calling: \<tool\> |
| `GetChat` | session_id, offset | text, new_offset | Read chat output | | Method | Args | Returns | Purpose |
| `GetUsage` | session_id | usage | Token usage stats | |---|---|---|---|
| `GetCost` | session_id | cost | Cost tracking | | `Submit` | session_id, prompt | bool | Submit a prompt to an agent |
| `GetConfig` | session_id | key=value pairs | Read session config | | `Interrupt` | session_id | bool | Interrupt current agent turn |
| `SetConfig` | session_id, key, value | success | Change a config setting | | `Compact` | session_id | bool | Compact conversation history |
| `GetContext` | session_id | JSONL messages | Full conversation context | | `ClearContext` | session_id | bool | Clear conversation history |
### Session State
| Method | Args | Returns | Purpose |
|---|---|---|---|
| `GetState` | session_id | state | Current state: `idle`, `thinking`, `calling: <tool>` |
| `GetChat` | session_id, offset | text, new_offset | Read chat output from byte offset |
| `GetConfig` | session_id | key=value text | Read session config (model, backend, agent, cwd, state) |
| `SetConfig` | session_id, key, value | bool | Change a config setting (model, cwd) |
| `GetContext` | session_id | JSONL | Full conversation context as JSONL messages |
| `GetContextSize` | session_id | string | Context token size |
| `GetUsage` | session_id | string | Token usage stats |
| `GetCost` | session_id | string | Cost tracking |
| `GetEnv` | session_id | key=value text | Session environment variables |
| `GetPlan` | session_id | string | Read session plan |
| `SetPlan` | session_id, plan | bool | Write session plan |
| `GetSystemPrompt` | session_id | string | Rendered system prompt |
| `GetPreviousPrompt` | session_id | string | Previous prompt text |
### Peers
| Method | Args | Returns | Purpose |
|---|---|---|---|
| `PeerAdd` | session_id, peer_id | bool | Add peer relationship |
| `PeerRemove` | session_id, peer_id | bool | Remove peer relationship |
| `PeerList` | session_id | array of peer_ids | List peers |
| `PeerSubmit` | session_id, peer_id, prompt | bool | Send prompt to peer |
### Detached Processes
| Method | Args | Returns | Purpose |
|---|---|---|---|
| `DetachProcess` | session_id | bool | Detach current running process to background |
| `ListDetached` | session_id | array of "pid\tcmd\tstarted\tstatus" | List background processes |
| `SignalDetached` | session_id, pid, signal | bool | Send signal (TERM, KILL) to detached process |
| `GetDetachedOutput` | session_id, pid | string | Read output from detached process |
| `DismissDetached` | session_id, pid | bool | Dismiss a finished detached process |
### Global Services
| Method | Args | Returns | Purpose |
|---|---|---|---|
| `ListBackends` | — | array of names | Available backends | | `ListBackends` | — | array of names | Available backends |
| `ListModels` | session_id | array of names | Models for session's backend | | `ListModels` | session_id | array of names | Models for session's backend |
| `ListAgents` | — | array of names | Available agent definitions | | `ListAgents` | — | array of names | Available agent definitions |
| `PeerAdd` | session_id, peer_id | success | Add peer relationship | | `Generate` | prompt, system, backend, model | string | One-shot LLM generation (no session needed) |
| `PeerRemove` | session_id, peer_id | success | Remove peer relationship | | `Route` | task, backend | "backend=X model=Y" | Pick a backend+model for a task |
| `PeerList` | session_id | array of peer_ids | List peers | | `Complete` | cwd, file, prefix, suffix, context | string | Code completion |
| `PeerSubmit` | session_id, peer_id, prompt | success | Send prompt to peer |
## Signals ## Signals
@ -60,8 +101,11 @@ All session operations go through the D-Bus interface. No filesystem writes for
|---|---|---| |---|---|---|
| `SessionCreated` | session_id | New session appeared | | `SessionCreated` | session_id | New session appeared |
| `SessionKilled` | session_id | Session terminated | | `SessionKilled` | session_id | Session terminated |
| `StateChanged` | session_id, new_state | Agent state transition | | `SessionRenamed` | old_id, new_id | Session renamed |
| `ChatUpdated` | session_id, offset, new_text | New output available | | `StateChanged` | session_id, state | Agent state transition |
| `ChatUpdated` | session_id, offset, text | New chat output available |
| `ProcessDetached` | session_id | A process was detached |
| `ProcessExited` | session_id, pid, exit_code | A detached process finished |
## Operations ## Operations
@ -70,62 +114,43 @@ All session operations go through the D-Bus interface. No filesystem writes for
dbus-send --session --dest=org.ollie.SessionManager --type=method_call --print-reply \ dbus-send --session --dest=org.ollie.SessionManager --type=method_call --print-reply \
/org/ollie/SessionManager org.ollie.SessionManager.ListSessions /org/ollie/SessionManager org.ollie.SessionManager.ListSessions
# Create a session (returns session_id) # Create a session
dbus-send --session --dest=org.ollie.SessionManager --type=method_call --print-reply \ dbus-send --session --dest=org.ollie.SessionManager --type=method_call --print-reply \
/org/ollie/SessionManager org.ollie.SessionManager.CreateSession \ /org/ollie/SessionManager org.ollie.SessionManager.CreateSession \
string:"$PWD" string:"" string:"" string:"default" string:"$PWD" string:"" string:"" string:"default" string:""
# Create a named session (backend + model + agent)
dbus-send --session --dest=org.ollie.SessionManager --type=method_call --print-reply \
/org/ollie/SessionManager org.ollie.SessionManager.CreateSession \
string:"$PWD" string:"openrouter" string:"anthropic/claude-sonnet-4" string:"worker"
# Kill a session
dbus-send --session --dest=org.ollie.SessionManager --type=method_call \
/org/ollie/SessionManager org.ollie.SessionManager.KillSession \
string:"SESSION_ID"
# Rename a session
dbus-send --session --dest=org.ollie.SessionManager --type=method_call \
/org/ollie/SessionManager org.ollie.SessionManager.RenameSession \
string:"SESSION_ID" string:"new-name"
# Submit a prompt # Submit a prompt
dbus-send --session --dest=org.ollie.SessionManager --type=method_call \ dbus-send --session --dest=org.ollie.SessionManager --type=method_call \
/org/ollie/SessionManager org.ollie.SessionManager.Submit \ /org/ollie/SessionManager org.ollie.SessionManager.Submit \
string:"SESSION_ID" string:"your prompt here" string:"SESSION_ID" string:"your prompt here"
# Get current state # Get chat output (use gdbus for multi-return)
dbus-send --session --dest=org.ollie.SessionManager --type=method_call --print-reply \
/org/ollie/SessionManager org.ollie.SessionManager.GetState \
string:"SESSION_ID"
# Get chat output (use gdbus for tuple return)
gdbus call --session --dest org.ollie.SessionManager \ gdbus call --session --dest org.ollie.SessionManager \
--object-path /org/ollie/SessionManager \ --object-path /org/ollie/SessionManager \
--method org.ollie.SessionManager.GetChat "SESSION_ID" 0 --method org.ollie.SessionManager.GetChat "SESSION_ID" 0
# Read session config # One-shot generation (no session)
dbus-send --session --dest=org.ollie.SessionManager --type=method_call --print-reply \ gdbus call --session --dest org.ollie.SessionManager \
/org/ollie/SessionManager org.ollie.SessionManager.GetConfig \ --object-path /org/ollie/SessionManager \
string:"SESSION_ID" --method org.ollie.SessionManager.Generate "summarize this" "" "" ""
# Change config # Route a task
dbus-send --session --dest=org.ollie.SessionManager --type=method_call \ gdbus call --session --dest org.ollie.SessionManager \
/org/ollie/SessionManager org.ollie.SessionManager.SetConfig \ --object-path /org/ollie/SessionManager \
string:"SESSION_ID" string:"model" string:"gpt-4o" --method org.ollie.SessionManager.Route "implement login page" ""
# Code completion
gdbus call --session --dest org.ollie.SessionManager \
--object-path /org/ollie/SessionManager \
--method org.ollie.SessionManager.Complete "$PWD" "main.go" "func " "" ""
# Send prompt to peer # Send prompt to peer
dbus-send --session --dest=org.ollie.SessionManager --type=method_call \ dbus-send --session --dest=org.ollie.SessionManager --type=method_call \
/org/ollie/SessionManager org.ollie.SessionManager.PeerSubmit \ /org/ollie/SessionManager org.ollie.SessionManager.PeerSubmit \
string:"MY_SESSION" string:"PEER_SESSION" string:"your prompt" string:"MY_SESSION" string:"PEER_SESSION" string:"your prompt"
# List available backends # Kill a session
dbus-send --session --dest=org.ollie.SessionManager --type=method_call --print-reply \ dbus-send --session --dest=org.ollie.SessionManager --type=method_call \
/org/ollie/SessionManager org.ollie.SessionManager.ListBackends /org/ollie/SessionManager org.ollie.SessionManager.KillSession \
# List available models
dbus-send --session --dest=org.ollie.SessionManager --type=method_call --print-reply \
/org/ollie/SessionManager org.ollie.SessionManager.ListModels \
string:"SESSION_ID" string:"SESSION_ID"
``` ```