Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,22 @@ keep the agent's reply pinned in the reference panel while you write the next on

**Prompt workflow**
- **Send the prompt** (`Ctrl+Enter`) — push the current buffer into the terminal
the tab is bound to, without leaving the keyboard. Three kinds of target are
the tab is bound to, without leaving the keyboard. Four kinds of target are
supported: [Herdr](https://herdr.dev) agents (**0.7 or newer** — pane ids changed
shape after 0.6 and the older form is rejected by the command allowlist),
Herdr Core / Herdr GUI agents via `hc`,
[Orca ADE](https://github.com/stablyai/orca) agents, and plain `tmux` panes.
Multi-line prompts arrive as one block and are submitted once.
- **Herdr Core / GUI requirements:** install `hc` and make it available in
Sendoff's `PATH`, with Core running and **Auto-submit enabled**.
Currently only these detected agent types are supported: Codex CLI (`codex`),
Claude Code (`claude-code`), OpenCode (`opencode`), Antigravity CLI
(`antigravity`), and Pi Agent (`pi`). Shells and unrecognized agents are hidden;
Gemini CLI and Hermes Agent are not supported while Core reports them as `zsh`.
`hc send` always submits with Enter; Sendoff does not focus or launch the GUI.
`jq` is not required: Sendoff parses CLI JSON internally.
If `hc` is missing or discovery fails, its picker section is omitted;
use Sendoff Doctor to check Sendoff's PATH. A failed bound send reports an error.
- **Target picker** (`Ctrl+Shift+Enter`) — one list, sectioned by source, so you
pick an agent or a pane by name instead of relying on whatever is focused.
A source that is not running simply has no section.
Expand Down Expand Up @@ -219,7 +230,8 @@ to record a new one.

The editor makes **no network calls** and spawns **no arbitrary processes**. The
webview gets a deliberately narrow shell surface: `tmux`, plus `orca-ide` and
`herdr` scoped to individual read/send subcommands. Scoping matters most for
`herdr` scoped to individual read/send subcommands. Herdr Core is restricted to
`hc ls --json` and `hc send <local-address> <text>`. Scoping matters most for
`herdr` — the same binary can also run arbitrary processes and tear down
sessions, so it is allowlisted per subcommand rather than wholesale.

Expand Down
16 changes: 14 additions & 2 deletions README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,22 @@ flowchart LR

**Prompt-workflow**
- **Отправка промпта** (`Ctrl+Enter`) — пушит текущий буфер в терминал, к которому
привязан таб, не отрывая рук от клавиатуры. Поддержаны три вида целей: агенты
привязан таб, не отрывая рук от клавиатуры. Поддержаны четыре вида целей: агенты
[Herdr](https://herdr.dev) (**0.7 и новее** — после 0.6 сменился вид id панелей,
старую форму отклоняет allowlist команд), агенты
Herdr Core / Herdr GUI через `hc`, агенты
[Orca ADE](https://github.com/stablyai/orca) и обычные `tmux`-пейны.
Многострочный текст долетает одним блоком, сабмит один.
- **Требования Herdr Core / GUI:** установленный `hc` в `PATH` Sendoff,
запущенный Core и включённый **Auto-submit**.
Пока поддержаны только распознанные типы: Codex CLI (`codex`),
Claude Code (`claude-code`), OpenCode (`opencode`), Antigravity CLI
(`antigravity`) и Pi Agent (`pi`). Shell и неизвестные агенты скрыты.
Gemini CLI и Hermes Agent не поддерживаются, пока Core сообщает их как `zsh`.
`hc send` всегда нажимает Enter; Sendoff не запускает и не фокусирует GUI.
`jq` не нужен: JSON разбирается внутри приложения.
Если `hc` отсутствует или discovery падает, секция не показывается;
проверить PATH можно через Sendoff Doctor. Сбой отправки показывает ошибку.
- **Пикер целей** (`Ctrl+Shift+Enter`) — один список с секциями по источникам:
выбираешь агента или пейн по имени, а не полагаешься на то, что сейчас в фокусе.
Незапущенный источник просто не даёт секции.
Expand Down Expand Up @@ -214,7 +225,8 @@ flowchart LR

Редактор **не делает сетевых вызовов** и **не спавнит произвольные процессы**.
Webview получает намеренно узкую shell-поверхность: `tmux`, плюс `orca-ide` и
`herdr`, заскоупленные по отдельным read/send-подкомандам. Скоупинг важнее всего
`herdr`, заскоупленные по отдельным read/send-подкомандам. Herdr Core ограничен
`hc ls --json` и `hc send <локальный-address> <текст>`. Скоупинг важнее всего
для `herdr` — тот же бинарник умеет запускать произвольные процессы и сносить
сессии, поэтому он разрешён по подкомандам, а не целиком.

Expand Down
10 changes: 10 additions & 0 deletions src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@
"cmd": "orca-ide",
"args": ["terminal", "wait", "--terminal", { "validator": "^term_[0-9a-fA-F-]+$" }, "--for", "tui-idle", "--timeout-ms", { "validator": "^[0-9]+$" }, "--json"]
},
{
"name": "herdr-core-list",
"cmd": "hc",
"args": ["ls", "--json"]
},
{
"name": "herdr-core-send",
"cmd": "hc",
"args": ["send", { "validator": "^t[0-9a-z]+$" }, { "validator": "^[\\s\\S]*$" }]
},
{
"name": "herdr-agent-list",
"cmd": "herdr",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fn sniff_image_ext(bytes: &[u8]) -> Option<&'static str> {
/// Список бинарей, о которых Doctor вправе спрашивать. Задан ЗДЕСЬ, а не приходит из
/// вебвью: иначе команда превратилась бы в «проверь наличие произвольного файла» —
/// generic-проба файловой системы под видом диагностики. Вебвью не передаёт ничего.
const DIAGNOSED_EXECUTABLES: [&str; 3] = ["tmux", "herdr", "orca-ide"];
const DIAGNOSED_EXECUTABLES: [&str; 4] = ["tmux", "herdr", "orca-ide", "hc"];

#[derive(serde::Serialize)]
struct ExecutableLocation {
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Onboarding/OnboardingOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export function OnboardingOverlay({ onOpenDoctor }: { onOpenDoctor: () => void }
<div className="space-y-3">
<div className="text-text">No terminal agents found.</div>
<div className="text-text-muted leading-relaxed">
Sendoff looks for tmux, Herdr and Orca. Start one of them, or check what Sendoff
Sendoff looks for tmux, Herdr, Herdr Core and Orca. Start one of them, or check what Sendoff
actually sees.
</div>
<div className="flex gap-2">
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Settings/SettingsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export function SettingsPanel({ onClose, onOpenDoctor }: SettingsPanelProps) {
</label>

<p className="text-[10px] leading-relaxed text-text-muted/60">
A target is a herdr agent, an Orca agent or a tmux window. Choose it via the picker
A target is a Herdr, Herdr Core or Orca agent, or a tmux window. Choose it via the picker
(<kbd className="font-mono">Ctrl+Shift+Enter</kbd>) or by binding the tab
(<kbd className="font-mono">Ctrl+Alt+B</kbd>). <kbd className="font-mono">Ctrl+Enter</kbd>:
binding → last choice → picker.
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/TabSwitcher/TabSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export function TabSwitcher({ onClose }: TabSwitcherProps) {
onClick={() => toggleBoundOnly(setSelectedIndex)}
aria-label="Bound to a terminal only"
aria-pressed={boundOnly}
title="Bound to a terminal only — herdr / Orca / tmux (Tab)"
title="Bound to a terminal only — Herdr / Herdr Core / Orca / tmux (Tab)"
className={`shrink-0 flex items-center justify-center w-7 h-6 rounded-[4px] border transition-colors ${
boundOnly
? "border-accent/30 bg-accent/15 text-accent"
Expand Down
22 changes: 16 additions & 6 deletions web/src/components/TargetPicker/TargetPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { usePickerModal } from "../../hooks/usePickerModal";
import { PickerModal, PickerHeader, PickerHint } from "../PickerModal/PickerModal";
import { useEditorStore } from "../../store/editorStore";
import { useLastTargetStore } from "../../store/lastTargetStore";
import { PROVIDERS, sameBinding, type TargetSource, type TerminalTarget } from "../../lib/terminalTargets";
import { useSettingsStore } from "../../store/settingsStore";
import { PROVIDERS, type TargetSource, type TerminalTarget } from "../../lib/terminalTargets";
import { boundTargetIndex } from "../../lib/terminalTargets/preselection";

interface TargetPickerProps {
onClose: () => void;
Expand Down Expand Up @@ -31,28 +33,31 @@ export function TargetPicker({ onClose, onPick, mode = "send" }: TargetPickerPro
const [sections, setSections] = useState<Section[]>([]);
const [loading, setLoading] = useState(true);
const [query, setQuery] = useState("");
const autoSubmit = useSettingsStore((s) => s.tmuxAutoSubmit);

// Провайдеры опрашиваются параллельно и НЕЗАВИСИМО: отвалившийся источник (herdr-сервер
// не запущен, Orca не установлена) просто не даёт секции — остальные работают.
// Отдельного isAvailable() нет: это был бы второй вызов ради того же ответа.
useEffect(() => {
let cancelled = false;
Promise.allSettled(PROVIDERS.map((p) => p.listTargets())).then((results) => {
const providers = PROVIDERS.filter((p) => p.source !== "herdr-core" || autoSubmit);
Promise.allSettled(providers.map((p) => p.listTargets())).then((results) => {
if (cancelled) return;
const next: Section[] = [];
results.forEach((result, i) => {
const provider = PROVIDERS[i];
const provider = providers[i];
if (result.status === "fulfilled" && result.value.length > 0) {
next.push({ source: provider.source, label: provider.label, targets: result.value });
}
if (result.status === "rejected") console.error(`[${provider.label}] discovery failed`, result.reason);
});
setSections(next);
setLoading(false);
});
return () => {
cancelled = true;
};
}, []);
}, [autoSubmit]);

// Плоский список — источник правды для курсора; секции рисуются поверх него.
const rows = useMemo(() => {
Expand Down Expand Up @@ -92,7 +97,11 @@ export function TargetPicker({ onClose, onPick, mode = "send" }: TargetPickerPro
const binding = tabs.find((t) => t.id === activeTabId)?.binding;
const last = useLastTargetStore.getState().lastTarget;

const byBinding = binding ? rows.findIndex((r) => sameBinding(binding, r.binding)) : -1;
const byBinding = binding ? boundTargetIndex(rows, binding) : -1;
if (byBinding === null) {
setSelectedIndex(-1);
return;
}
const byLast = last ? rows.findIndex((r) => r.source === last.source && r.handle === last.handle) : -1;
const byActive = rows.findIndex((r) => r.isActive);

Expand Down Expand Up @@ -139,7 +148,8 @@ export function TargetPicker({ onClose, onPick, mode = "send" }: TargetPickerPro
{query.trim() ? "No matches" : "No targets available"}
{!query.trim() && (
<div className="mt-1 text-[10px] text-text-muted/40">
Neither herdr, Orca nor tmux is responding
No supported agents or panes found. Check installed targets with Sendoff Doctor.
{!autoSubmit && <div>Herdr Core requires Auto-submit.</div>}
</div>
)}
</div>
Expand Down
61 changes: 58 additions & 3 deletions web/src/hooks/useTerminalActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export function useTerminalActions(textareaRef: RefObject<HTMLTextAreaElement |
async (source: TargetSource, handle: string, text: string) => {
const provider = providerBySource(source);
try {
if (source === "herdr-core" && !autoSubmit) throw new Error("Herdr Core requires Auto-submit");
const where = await provider.send(handle, text, autoSubmit);
toast(`Sent to ${provider.label}: ${where} (${text.length} chars)`, "success");
// Первый запуск закрывается ровно здесь — по факту успешно отработавшего
Expand Down Expand Up @@ -88,7 +89,18 @@ export function useTerminalActions(textareaRef: RefObject<HTMLTextAreaElement |
if (tab && binding) {
const provider = providerFor(binding);
const where = provider.describe(binding);
const resolution = await provider.resolve(binding);
if (binding.source === "herdr-core" && !autoSubmit) {
toast("Herdr Core requires Auto-submit", "error");
return;
}
let resolution;
try {
resolution = await provider.resolve(binding);
} catch (error) {
toast(`${provider.label}: ${describeError(error)}`, "error");
console.error(`[${provider.label}] resolve failed`, error);
return;
}

if (resolution.kind === "ambiguous") {
// Не угадываем: промпт чужому агенту хуже лишнего клика. Зовём перепривязать —
Expand All @@ -109,6 +121,9 @@ export function useTerminalActions(textareaRef: RefObject<HTMLTextAreaElement |
if (binding.source === "herdr" && resolution.handle !== binding.paneId) {
useEditorStore.getState().setTabBinding(tab.id, { ...binding, paneId: resolution.handle });
}
if (binding.source === "herdr-core" && resolution.handle !== binding.address) {
useEditorStore.getState().setTabBinding(tab.id, { ...binding, address: resolution.handle });
}

await sendVia(binding.source, resolution.handle, text);
return;
Expand All @@ -117,13 +132,35 @@ export function useTerminalActions(textareaRef: RefObject<HTMLTextAreaElement |
// 2. Last — последний выбор в пикере (in-memory).
const last = useLastTargetStore.getState().lastTarget;
if (last) {
if (last.source === "herdr-core") {
if (!autoSubmit) {
toast("Herdr Core requires Auto-submit", "error");
return;
}
try {
if (!last.binding) {
setTargetPicker({ mode: "send" });
return;
}
const resolution = await providerFor(last.binding).resolve(last.binding);
if (resolution.kind !== "ok") {
setTargetPicker({ mode: "send" });
return;
}
await sendVia(last.source, resolution.handle, text);
} catch (error) {
toast(describeError(error), "error");
console.error("[Herdr Core] resolve failed", error);
}
return;
}
await sendVia(last.source, last.handle, text);
return;
}

// 3. Modal.
setTargetPicker({ mode: "send" });
}, [getSendText, sendVia]);
}, [getSendText, sendVia, autoSubmit]);

// Выбор в пикере: привязать таб (bind) или отправить (send).
const handlePick = useCallback(
Expand All @@ -144,8 +181,26 @@ export function useTerminalActions(textareaRef: RefObject<HTMLTextAreaElement |
source: target.source,
handle: target.handle,
label: target.primary,
binding: target.binding,
});
void sendVia(target.source, target.handle, text);
if (target.source === "herdr-core") {
void (async () => {
try {
const resolution = await providerFor(target.binding).resolve(target.binding);
if (resolution.kind !== "ok") {
toast("Herdr Core target changed — pick another target", "error");
setTargetPicker({ mode: "send" });
return;
}
await sendVia(target.source, resolution.handle, text);
} catch (error) {
toast(describeError(error), "error");
console.error("[Herdr Core] resolve failed", error);
}
})();
} else {
void sendVia(target.source, target.handle, text);
}
},
[targetPicker, getSendText, sendVia],
);
Expand Down
6 changes: 6 additions & 0 deletions web/src/lib/db.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ describe("round-trip сессии", () => {
await saveSession(snapshot({ tabs: [tab("a", { binding })] }));
expect((await loadSession()).tabs[0].binding).toEqual(binding);
});

test("привязка Herdr Core сохраняет все защитные поля", async () => {
const binding = { source: "herdr-core", address: "t1h", agent: "codex", where: "project / 1", cwd: "/project" } as const;
await saveSession(snapshot({ tabs: [tab("a", { binding })] }));
expect((await loadSession()).tabs[0].binding).toEqual(binding);
});
});

// Архив закрытых табов — новая гарантия «закрыть ≠ потерять». Он лежит в том же
Expand Down
Loading
Loading