v0.48.1 deaab59

subagent_interrupt.go RawHistoryFolder

1package tools
2
3import (
4	"context"
5	"encoding/json"
6	"fmt"
7	"strings"
8
9	"github.com/bnema/zut/packages/agent/subagents"
10	"github.com/bnema/zut/packages/core"
11)
12
13// SubagentInterruptTool cancels only a sub-agent's running turn. Unlike stop,
14// the child stays alive with its transcript, so a later resume continues with
15// full context.
16type SubagentInterruptTool struct {
17	ResidentManager *subagents.ResidentManager
18	Enabled         func() bool
19}
20
21type subagentInterruptArgs struct {
22	AgentID string `json:"agent_id"`
23}
24
25// Name returns the shared facade name: this type is an internal
26// implementation and is never registered on its own.
27func (t *SubagentInterruptTool) Name() string { return SubagentToolName }
28
29func (t *SubagentInterruptTool) Execute(ctx context.Context, raw json.RawMessage, _ func(string)) (core.ToolResult, error) {
30	if ctx != nil {
31		select {
32		case <-ctx.Done():
33			return core.ToolResult{}, ctx.Err()
34		default:
35		}
36	}
37	prefix := t.Name()
38	if t.ResidentManager == nil {
39		return protocolToolError(prefix + ": subagent runtime not available in this mode")
40	}
41	if t.Enabled == nil || !t.Enabled() {
42		return protocolToolError(prefix + ": subagent management is unavailable in this mode")
43	}
44	var args subagentInterruptArgs
45	if err := decodeSubagentArgs(raw, &args); err != nil {
46		return core.ToolResult{}, err
47	}
48	id := strings.TrimSpace(args.AgentID)
49	if id == "" {
50		return protocolToolError(prefix + ": agent_id is required")
51	}
52	snapshot, ok := findResidentStatusSnapshot(t.ResidentManager.Snapshot(), id)
53	if !ok {
54		return protocolToolError(fmt.Sprintf("%s: no such agent %q", prefix, id))
55	}
56	interrupted, err := t.ResidentManager.Interrupt(ctx, snapshot.ID)
57	if err != nil {
58		return protocolToolError(prefix + ": " + err.Error())
59	}
60	if !interrupted {
61		return protocolToolError(fmt.Sprintf("%s: agent %q has no running turn to interrupt", prefix, snapshot.ID))
62	}
63	if updated, ok := t.ResidentManager.SnapshotFor(snapshot.ID); ok {
64		snapshot = updated
65	}
66	return renderResidentAction("interrupt_requested", publicResidentStatus(snapshot))
67}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 476

↑↓ moveenter openesc close