Compare commits
17
Commits
13e8db74ce
...
ca725c73b5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ca725c73b5 | ||
|
|
1db3105d50 | ||
|
|
2b376d5035 | ||
|
|
a5a07a8792 | ||
|
|
53a19c6b54 | ||
|
|
df7696ae60 | ||
|
|
ed2ce8fafc | ||
|
|
b2a700571f | ||
|
|
99e5260619 | ||
|
|
2523494d10 | ||
|
|
48aa11eab5 | ||
|
|
a9022fa8fc | ||
|
|
6f1262b0fe | ||
|
|
bee9b49ce1 | ||
|
|
c33d184228 | ||
|
|
896368ef56 | ||
|
|
f84611bc6e |
@@ -0,0 +1,162 @@
|
|||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import qs.HyprChrome.Theme
|
||||||
|
import qs.HyprChrome.Widgets.Bar.Panels
|
||||||
|
import qs.HyprChrome.Widgets.Bar.Vitals
|
||||||
|
|
||||||
|
// Claude subscription limits on the rail: the 5-hour session window and the
|
||||||
|
// weekly one, plus any per-model weekly caps the plan reports.
|
||||||
|
BarPanel {
|
||||||
|
id: claude
|
||||||
|
|
||||||
|
// Overridable so the headless render can stage it without the network.
|
||||||
|
property var fiveHour: usage.fiveHour
|
||||||
|
property var sevenDay: usage.sevenDay
|
||||||
|
property var extra: usage.extra
|
||||||
|
property string error: usage.error
|
||||||
|
property string shortError: usage.shortError
|
||||||
|
property bool ready: usage.ready
|
||||||
|
|
||||||
|
readonly property var usage: ClaudeState {}
|
||||||
|
|
||||||
|
panelId: "CLD"
|
||||||
|
title: "CLAUDE"
|
||||||
|
meta: claude.error !== "" ? (claude.ready ? "STALE" : "OFFLINE") : claude.ready ? "LIMITS" : "PRIMING"
|
||||||
|
|
||||||
|
// Ticks the reset countdowns without re-polling.
|
||||||
|
property date now: new Date()
|
||||||
|
Timer {
|
||||||
|
interval: 30000
|
||||||
|
running: true
|
||||||
|
repeat: true
|
||||||
|
onTriggered: claude.now = new Date()
|
||||||
|
}
|
||||||
|
|
||||||
|
implicitWidth: claude.expanded
|
||||||
|
? Math.max(claude.headerMinWidth, claude.padding * 2 + body.width)
|
||||||
|
: Math.max(claude.headerMinWidth, claude.briefLeft + brief.implicitWidth + claude.padding)
|
||||||
|
|
||||||
|
function fraction(w) {
|
||||||
|
return w ? Math.max(0, Math.min(1, w.utilization / 100)) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function pct(w) {
|
||||||
|
return w ? Math.round(w.utilization) + "%" : "--";
|
||||||
|
}
|
||||||
|
|
||||||
|
function until(w) {
|
||||||
|
if (!w || !w.resets_at)
|
||||||
|
return "";
|
||||||
|
const mins = Math.max(0, Math.round((new Date(w.resets_at) - claude.now) / 60000));
|
||||||
|
if (mins >= 1440)
|
||||||
|
return `${Math.floor(mins / 1440)}D ${Math.floor(mins % 1440 / 60)}H`;
|
||||||
|
if (mins >= 60)
|
||||||
|
return `${Math.floor(mins / 60)}H ${mins % 60}M`;
|
||||||
|
return `${mins}M`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function tone(w) {
|
||||||
|
const f = claude.fraction(w);
|
||||||
|
return !claude.ready ? Theme.disabled : f >= 0.85 ? Theme.hot : Theme.text;
|
||||||
|
}
|
||||||
|
|
||||||
|
summary: Row {
|
||||||
|
id: brief
|
||||||
|
spacing: 10
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: [
|
||||||
|
{ label: "5H", window: claude.fiveHour },
|
||||||
|
{ label: "7D", window: claude.sevenDay }
|
||||||
|
]
|
||||||
|
|
||||||
|
Row {
|
||||||
|
required property var modelData
|
||||||
|
spacing: 4
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
// Dashes say nothing; with no numbers yet the error label stands alone.
|
||||||
|
visible: claude.ready || claude.shortError === ""
|
||||||
|
|
||||||
|
Text {
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
text: parent.modelData.label
|
||||||
|
color: Theme.muted
|
||||||
|
font.family: Theme.microFont
|
||||||
|
font.pixelSize: 10
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
text: claude.pct(parent.modelData.window)
|
||||||
|
color: claude.tone(parent.modelData.window)
|
||||||
|
font.family: Theme.displayFont
|
||||||
|
font.pixelSize: 13
|
||||||
|
font.bold: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
visible: claude.shortError !== ""
|
||||||
|
text: claude.shortError
|
||||||
|
color: Theme.hot
|
||||||
|
font.family: Theme.displayFont
|
||||||
|
font.pixelSize: 13
|
||||||
|
font.bold: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: body
|
||||||
|
width: 260
|
||||||
|
spacing: 5
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: [
|
||||||
|
{ label: "SESSION", window: claude.fiveHour },
|
||||||
|
{ label: "WEEKLY", window: claude.sevenDay }
|
||||||
|
].concat(claude.extra)
|
||||||
|
|
||||||
|
Column {
|
||||||
|
required property var modelData
|
||||||
|
width: body.width
|
||||||
|
spacing: 2
|
||||||
|
|
||||||
|
VitalRow {
|
||||||
|
width: parent.width
|
||||||
|
labelWidth: 64
|
||||||
|
label: parent.modelData.label
|
||||||
|
value: claude.fraction(parent.modelData.window)
|
||||||
|
readout: claude.pct(parent.modelData.window)
|
||||||
|
ready: claude.ready && !!parent.modelData.window
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
x: 64
|
||||||
|
visible: text !== ""
|
||||||
|
text: {
|
||||||
|
const t = claude.until(parent.modelData.window);
|
||||||
|
return t ? `RESETS IN ${t}` : "";
|
||||||
|
}
|
||||||
|
color: Theme.muted
|
||||||
|
font.family: Theme.microFont
|
||||||
|
font.pixelSize: 9
|
||||||
|
font.letterSpacing: 1.2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
width: body.width
|
||||||
|
visible: claude.error !== ""
|
||||||
|
text: claude.error.toUpperCase()
|
||||||
|
color: Theme.hot
|
||||||
|
font.family: Theme.microFont
|
||||||
|
font.pixelSize: 9
|
||||||
|
font.letterSpacing: 1.2
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import Quickshell.Io
|
||||||
|
|
||||||
|
// Claude subscription limits, polled through `claude-usage` (pkgs/claude-usage.nix),
|
||||||
|
// which reuses Claude Code's OAuth login and prints the usage endpoint's JSON.
|
||||||
|
QtObject {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
// Each window is { utilization: 0..100, resets_at: ISO string } or null.
|
||||||
|
property var fiveHour: null
|
||||||
|
property var sevenDay: null
|
||||||
|
// Per-model weekly windows the plan reports, as [{ label, window }].
|
||||||
|
property var extra: []
|
||||||
|
property string error: ""
|
||||||
|
property bool ready: false
|
||||||
|
|
||||||
|
// The endpoint is rate-limited and the numbers move slowly; a failure
|
||||||
|
// retries sooner so the panel recovers once Claude Code renews the token.
|
||||||
|
property int interval: root.error !== "" ? 60000 : 300000
|
||||||
|
|
||||||
|
// Collapsed-rail label for the current error.
|
||||||
|
readonly property string shortError: {
|
||||||
|
if (root.error === "")
|
||||||
|
return "";
|
||||||
|
return /refresh|401|not logged in|no refresh token/.test(root.error) ? "EXPIRED" : "ERR";
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly property var proc: Process {
|
||||||
|
id: proc
|
||||||
|
command: ["claude-usage"]
|
||||||
|
|
||||||
|
stdout: StdioCollector {
|
||||||
|
onStreamFinished: root.ingest(this.text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly property var poll: Timer {
|
||||||
|
interval: root.interval
|
||||||
|
running: true
|
||||||
|
repeat: true
|
||||||
|
triggeredOnStart: true
|
||||||
|
onTriggered: {
|
||||||
|
if (!proc.running)
|
||||||
|
proc.running = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function fail(message: string): void {
|
||||||
|
console.warn(`claude-usage: ${message}`);
|
||||||
|
root.error = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ingest(text: string): void {
|
||||||
|
let msg;
|
||||||
|
try {
|
||||||
|
msg = JSON.parse(text);
|
||||||
|
} catch (e) {
|
||||||
|
root.fail("no output");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (msg.error) {
|
||||||
|
// Keep the last good numbers; a failed poll is not zero usage.
|
||||||
|
root.fail(msg.error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
root.error = "";
|
||||||
|
root.fiveHour = msg.five_hour ?? null;
|
||||||
|
root.sevenDay = msg.seven_day ?? null;
|
||||||
|
|
||||||
|
const found = [];
|
||||||
|
for (const key of Object.keys(msg)) {
|
||||||
|
const m = key.match(/^seven_day_(\w+)$/);
|
||||||
|
const w = msg[key];
|
||||||
|
if (m && w && typeof w.utilization === "number")
|
||||||
|
found.push({ label: m[1].toUpperCase().replace(/_/g, " "), window: w });
|
||||||
|
}
|
||||||
|
root.extra = found;
|
||||||
|
root.ready = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import Quickshell
|
|||||||
import Quickshell.Wayland
|
import Quickshell.Wayland
|
||||||
import qs.HyprChrome.Theme
|
import qs.HyprChrome.Theme
|
||||||
import qs.HyprChrome.Widgets.Bar.Luna
|
import qs.HyprChrome.Widgets.Bar.Luna
|
||||||
|
import qs.HyprChrome.Widgets.Bar.Claude
|
||||||
import qs.HyprChrome.Widgets.Bar.Host
|
import qs.HyprChrome.Widgets.Bar.Host
|
||||||
import qs.HyprChrome.Widgets.Bar.Vitals
|
import qs.HyprChrome.Widgets.Bar.Vitals
|
||||||
import qs.HyprChrome.Widgets.Bar.Workspaces
|
import qs.HyprChrome.Widgets.Bar.Workspaces
|
||||||
@@ -87,8 +88,8 @@ PanelWindow {
|
|||||||
//
|
//
|
||||||
// The zone still follows the target height, so tiled windows reflow once
|
// The zone still follows the target height, so tiled windows reflow once
|
||||||
// per toggle, at the start, and slide while the panels animate.
|
// per toggle, at the start, and slide while the panels animate.
|
||||||
readonly property real expandedContent: Math.max(hostPanel.expandedHeight, workspacesPanel.expandedHeight, vitalsPanel.expandedHeight, lunaPanel.expandedHeight, trayPanel.expandedHeight) + window.margin * 2
|
readonly property real expandedContent: Math.max(hostPanel.expandedHeight, workspacesPanel.expandedHeight, vitalsPanel.expandedHeight, lunaPanel.expandedHeight, claudePanel.expandedHeight, trayPanel.expandedHeight) + window.margin * 2
|
||||||
readonly property real contentHeight: Math.max(hostPanel.targetHeight, workspacesPanel.targetHeight, vitalsPanel.targetHeight, lunaPanel.targetHeight, trayPanel.targetHeight) + window.margin * 2
|
readonly property real contentHeight: Math.max(hostPanel.targetHeight, workspacesPanel.targetHeight, vitalsPanel.targetHeight, lunaPanel.targetHeight, claudePanel.targetHeight, trayPanel.targetHeight) + window.margin * 2
|
||||||
|
|
||||||
implicitHeight: Math.round(window.expandedContent)
|
implicitHeight: Math.round(window.expandedContent)
|
||||||
|
|
||||||
@@ -161,6 +162,19 @@ PanelWindow {
|
|||||||
id: lunaPanel
|
id: lunaPanel
|
||||||
|
|
||||||
expanded: window.expanded
|
expanded: window.expanded
|
||||||
|
// Claude butts against its right edge.
|
||||||
|
rightChamfer: false
|
||||||
|
|
||||||
|
toggleOnClick: false
|
||||||
|
Layout.fillHeight: true
|
||||||
|
}
|
||||||
|
|
||||||
|
ClaudePanel {
|
||||||
|
id: claudePanel
|
||||||
|
|
||||||
|
expanded: window.expanded
|
||||||
|
leftChamfer: false
|
||||||
|
|
||||||
toggleOnClick: false
|
toggleOnClick: false
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ QtObject {
|
|||||||
property string state: "idle"
|
property string state: "idle"
|
||||||
// Voice mode itself — the widget is only on screen while this is true.
|
// Voice mode itself — the widget is only on screen while this is true.
|
||||||
property bool active: false
|
property bool active: false
|
||||||
property bool connected: socket.connected
|
// Set by the first line, not by the process starting: the daemon replays
|
||||||
|
// its state on connect, so only a live connection produces one.
|
||||||
|
property bool connected: false
|
||||||
// Mic level while listening, her output level while speaking. Drives the
|
// Mic level while listening, her output level while speaking. Drives the
|
||||||
// only genuinely live part of the visuals.
|
// only genuinely live part of the visuals.
|
||||||
property real rms: 0
|
property real rms: 0
|
||||||
@@ -31,35 +33,39 @@ QtObject {
|
|||||||
property string lunaText: ""
|
property string lunaText: ""
|
||||||
property string error: ""
|
property string error: ""
|
||||||
|
|
||||||
readonly property var socket: Socket {
|
// `luna-voice watch`, not Quickshell's Socket: a Socket whose connect
|
||||||
id: socket
|
// fails once (daemon mid-restart) keeps the dead QLocalSocket and ignores
|
||||||
path: `${Quickshell.env("XDG_RUNTIME_DIR") ?? "/run/user/1000"}/luna-voiced.sock`
|
// every later `connected = true`, so the widget stuck on OFFLINE.
|
||||||
connected: true
|
readonly property var watch: Process {
|
||||||
|
id: watch
|
||||||
|
command: ["luna-voice", "watch"]
|
||||||
|
running: true
|
||||||
|
|
||||||
onConnectionStateChanged: {
|
stdout: SplitParser {
|
||||||
if (!socket.connected) {
|
splitMarker: "\n"
|
||||||
// A daemon that went away is not a daemon that is idle: reset
|
onRead: line => {
|
||||||
// rather than leave the last frame of a conversation frozen
|
root.connected = true;
|
||||||
// on screen.
|
root.ingest(line);
|
||||||
root.active = false;
|
|
||||||
root.state = "idle";
|
|
||||||
root.rms = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
parser: SplitParser {
|
onExited: {
|
||||||
splitMarker: "\n"
|
// A daemon that went away is not a daemon that is idle: reset
|
||||||
onRead: line => root.ingest(line)
|
// rather than leave the last frame of a conversation frozen
|
||||||
|
// on screen.
|
||||||
|
root.connected = false;
|
||||||
|
root.active = false;
|
||||||
|
root.state = "idle";
|
||||||
|
root.rms = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retry forever, cheaply. Setting `connected` true on an already-open
|
// Retry forever, cheaply; each attempt is a fresh connection.
|
||||||
// socket is a no-op, so this doubles as the initial connect.
|
|
||||||
readonly property var reconnect: Timer {
|
readonly property var reconnect: Timer {
|
||||||
interval: 2000
|
interval: 2000
|
||||||
running: !socket.connected
|
running: !watch.running
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: socket.connected = true
|
onTriggered: watch.running = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function ingest(line: string): void {
|
function ingest(line: string): void {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
pragma ComponentBehavior: Bound
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Hyprland
|
import Quickshell.Hyprland
|
||||||
import Quickshell.Wayland
|
import Quickshell.Wayland
|
||||||
@@ -147,6 +148,40 @@ Scope {
|
|||||||
onPressed: shell.toggle()
|
onPressed: shell.toggle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SUPER — the launcher over an expanded rail, opened and closed as one.
|
||||||
|
GlobalShortcut {
|
||||||
|
name: "command"
|
||||||
|
description: "Open the launcher with the hyprchrome bar expanded"
|
||||||
|
onPressed: shell.toggleCommand()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Whether the rail was expanded BY toggleCommand, so closing the launcher
|
||||||
|
// only collapses a rail it opened.
|
||||||
|
property bool commandExpanded: false
|
||||||
|
|
||||||
|
function toggleCommand() {
|
||||||
|
if (polkit.prompting || askpass.active)
|
||||||
|
return;
|
||||||
|
if (launcher.active) {
|
||||||
|
launcher.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
shell.commandExpanded = !shell.expanded;
|
||||||
|
shell.expanded = true;
|
||||||
|
launcher.active = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The launcher closes itself (ESC, launch, click-off), so collapse follows it.
|
||||||
|
Connections {
|
||||||
|
target: launcher
|
||||||
|
function onActiveChanged() {
|
||||||
|
if (!launcher.active && shell.commandExpanded) {
|
||||||
|
shell.commandExpanded = false;
|
||||||
|
shell.expanded = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Backdrop first: it is a layer below the bar, so stacking does not depend
|
// Backdrop first: it is a layer below the bar, so stacking does not depend
|
||||||
// on creation order, but keeping the declaration order the same as the
|
// on creation order, but keeping the declaration order the same as the
|
||||||
// visual order costs nothing.
|
// visual order costs nothing.
|
||||||
@@ -236,7 +271,7 @@ Scope {
|
|||||||
screen: shell.focusedScreen
|
screen: shell.focusedScreen
|
||||||
}
|
}
|
||||||
|
|
||||||
// Primary application launcher — SUPER_L. Migrated out of
|
// Primary application launcher — SUPER_L (via `command` above). Migrated out of
|
||||||
// widgets/launcher/; the ten remaining variants are still evaluation copies
|
// widgets/launcher/; the ten remaining variants are still evaluation copies
|
||||||
// and stay in shell.qml. Declared after the bar for the same reason the
|
// and stay in shell.qml. Declared after the bar for the same reason the
|
||||||
// prompt is: while it is open the bar is on Overlay too, and there is no
|
// prompt is: while it is open the bar is on Overlay too, and there is no
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import Quickshell.Wayland
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import qs.HyprChrome.Theme
|
import qs.HyprChrome.Theme
|
||||||
|
|
||||||
// Primary application launcher — the one on SUPER_L.
|
// Primary application launcher — the one on SUPER_L (via HyprChromeShell).
|
||||||
//
|
//
|
||||||
// Migrated from widgets/launcher/ApplicationLauncher.qml. Two things changed in
|
// Migrated from widgets/launcher/ApplicationLauncher.qml. Two things changed in
|
||||||
// the move, both because HyprChromeShell now owns the state its surfaces share:
|
// the move, both because HyprChromeShell now owns the state its surfaces share:
|
||||||
@@ -34,11 +34,8 @@ Scope {
|
|||||||
function toggle() { root.active = !root.active; }
|
function toggle() { root.active = !root.active; }
|
||||||
function close() { root.active = false; }
|
function close() { root.active = false; }
|
||||||
|
|
||||||
// The name is legacy: this was "variant 8" of eleven, and both SUPER_L (via
|
// Launcher alone, on SUPER CTRL 8. SUPER_L goes through the shell's
|
||||||
// open_launcher.sh) and SUPER CTRL 8 still dispatch quickshell:launcher8.
|
// `command` shortcut instead, which also expands the rail.
|
||||||
// Renaming it means editing hosts/terra/home/hyprland.nix AND the script
|
|
||||||
// together, and neither takes effect until a deploy — so the shortcut would
|
|
||||||
// be dead in the running session in between. Kept as-is deliberately.
|
|
||||||
GlobalShortcut {
|
GlobalShortcut {
|
||||||
name: "launcher8"
|
name: "launcher8"
|
||||||
description: "Toggle dense application command index"
|
description: "Toggle dense application command index"
|
||||||
@@ -83,9 +80,22 @@ Scope {
|
|||||||
root.active = false;
|
root.active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hyprland runs a Lua config, which rejects a bare `dispatch exit`.
|
||||||
|
readonly property var powerCommands: ({
|
||||||
|
logout: ["hyprctl", "dispatch", "hl.dsp.exit()"],
|
||||||
|
reboot: ["systemctl", "reboot"],
|
||||||
|
shutdown: ["systemctl", "poweroff"]
|
||||||
|
})
|
||||||
|
|
||||||
|
function power(action) {
|
||||||
|
root.active = false;
|
||||||
|
Quickshell.execDetached(win.powerCommands[action]);
|
||||||
|
}
|
||||||
|
|
||||||
onVisibleChanged: {
|
onVisibleChanged: {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
content.clearSearch();
|
content.clearSearch();
|
||||||
|
content.disarmPower();
|
||||||
selectedIndex = 0;
|
selectedIndex = 0;
|
||||||
content.focusSearch();
|
content.focusSearch();
|
||||||
}
|
}
|
||||||
@@ -115,11 +125,17 @@ Scope {
|
|||||||
transformOrigin: Item.Center
|
transformOrigin: Item.Center
|
||||||
apps: model.apps
|
apps: model.apps
|
||||||
selectedIndex: win.selectedIndex
|
selectedIndex: win.selectedIndex
|
||||||
|
sortMode: model.sortMode
|
||||||
|
|
||||||
onSelectionRequested: index => win.selectedIndex = win.clampSelection(index)
|
onSelectionRequested: index => win.selectedIndex = win.clampSelection(index)
|
||||||
onMoveRequested: delta => win.move(delta)
|
onMoveRequested: delta => win.move(delta)
|
||||||
onLaunchRequested: index => win.launch(index)
|
onLaunchRequested: index => win.launch(index)
|
||||||
onDismissRequested: root.close()
|
onDismissRequested: root.close()
|
||||||
|
onSortToggleRequested: {
|
||||||
|
model.toggleSort();
|
||||||
|
win.selectedIndex = 0;
|
||||||
|
}
|
||||||
|
onPowerRequested: action => win.power(action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ Item {
|
|||||||
property int selectedIndex: 0
|
property int selectedIndex: 0
|
||||||
property bool showIcons: true
|
property bool showIcons: true
|
||||||
property alias query: searchInput.text
|
property alias query: searchInput.text
|
||||||
|
property string sortMode: "usage"
|
||||||
|
|
||||||
|
// Power action awaiting its confirming second click; "" when none.
|
||||||
|
property string armedPower: ""
|
||||||
|
|
||||||
readonly property var selectedApp: apps.length > 0 && selectedIndex >= 0 && selectedIndex < apps.length
|
readonly property var selectedApp: apps.length > 0 && selectedIndex >= 0 && selectedIndex < apps.length
|
||||||
? apps[selectedIndex] : null
|
? apps[selectedIndex] : null
|
||||||
@@ -25,9 +29,29 @@ Item {
|
|||||||
signal moveRequested(int delta)
|
signal moveRequested(int delta)
|
||||||
signal launchRequested(int index)
|
signal launchRequested(int index)
|
||||||
signal dismissRequested
|
signal dismissRequested
|
||||||
|
signal sortToggleRequested
|
||||||
|
signal powerRequested(string action)
|
||||||
|
|
||||||
function focusSearch() { searchInput.forceActiveFocus(); }
|
function focusSearch() { searchInput.forceActiveFocus(); }
|
||||||
function clearSearch() { searchInput.text = ""; }
|
function clearSearch() { searchInput.text = ""; }
|
||||||
|
function disarmPower() { root.armedPower = ""; }
|
||||||
|
|
||||||
|
// First click arms, second (within the timeout) fires: a stray click must
|
||||||
|
// not end the session.
|
||||||
|
function pressPower(action) {
|
||||||
|
if (root.armedPower === action) {
|
||||||
|
root.armedPower = "";
|
||||||
|
root.powerRequested(action);
|
||||||
|
} else {
|
||||||
|
root.armedPower = action;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
running: root.armedPower !== ""
|
||||||
|
interval: 3000
|
||||||
|
onTriggered: root.disarmPower()
|
||||||
|
}
|
||||||
|
|
||||||
implicitWidth: 1080
|
implicitWidth: 1080
|
||||||
implicitHeight: 620
|
implicitHeight: 620
|
||||||
@@ -121,6 +145,11 @@ Item {
|
|||||||
onTextChanged: root.selectionRequested(0)
|
onTextChanged: root.selectionRequested(0)
|
||||||
|
|
||||||
Keys.onPressed: event => {
|
Keys.onPressed: event => {
|
||||||
|
if (event.key === Qt.Key_S && (event.modifiers & Qt.ControlModifier)) {
|
||||||
|
root.sortToggleRequested();
|
||||||
|
event.accepted = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
case Qt.Key_Down:
|
case Qt.Key_Down:
|
||||||
case Qt.Key_Tab:
|
case Qt.Key_Tab:
|
||||||
@@ -162,16 +191,24 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
MouseArea {
|
||||||
|
id: sortChip
|
||||||
Layout.preferredWidth: 84
|
Layout.preferredWidth: 84
|
||||||
Layout.preferredHeight: 22
|
Layout.preferredHeight: 22
|
||||||
color: Theme.accentAlpha(0.12)
|
hoverEnabled: true
|
||||||
border.width: 1
|
cursorShape: Qt.PointingHandCursor
|
||||||
border.color: Theme.hair
|
onClicked: root.sortToggleRequested()
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
color: sortChip.containsMouse ? Theme.accentAlpha(0.28) : Theme.accentAlpha(0.12)
|
||||||
|
border.width: 1
|
||||||
|
border.color: sortChip.containsMouse ? Theme.accent : Theme.hair
|
||||||
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: "LIVE INDEX"
|
text: root.sortMode === "usage" ? "SORT: USED" : "SORT: A–Z"
|
||||||
color: Theme.accent
|
color: Theme.accent
|
||||||
font.family: Theme.microFont
|
font.family: Theme.microFont
|
||||||
font.pixelSize: 7
|
font.pixelSize: 7
|
||||||
@@ -191,7 +228,7 @@ Item {
|
|||||||
height: 424
|
height: 424
|
||||||
panelId: "IDX"
|
panelId: "IDX"
|
||||||
title: "APPLICATION TABLE"
|
title: "APPLICATION TABLE"
|
||||||
meta: root.query.length > 0 ? "FILTER ACTIVE" : "A–Z / LOCAL"
|
meta: (root.query.length > 0 ? "FILTER ACTIVE" : "LOCAL") + (root.sortMode === "usage" ? " / MOST USED" : " / A–Z")
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
id: appList
|
id: appList
|
||||||
@@ -587,13 +624,46 @@ Item {
|
|||||||
KeyHint { keyText: "↑ ↓"; actionText: "SELECT" }
|
KeyHint { keyText: "↑ ↓"; actionText: "SELECT" }
|
||||||
KeyHint { keyText: "ENTER"; actionText: "EXECUTE" }
|
KeyHint { keyText: "ENTER"; actionText: "EXECUTE" }
|
||||||
KeyHint { keyText: "ESC"; actionText: "ABORT" }
|
KeyHint { keyText: "ESC"; actionText: "ABORT" }
|
||||||
|
KeyHint { keyText: "CTRL+S"; actionText: "SORT" }
|
||||||
Item { Layout.fillWidth: true }
|
Item { Layout.fillWidth: true }
|
||||||
MicroText { text: "QRY:" + (root.query.length > 0 ? "ACTIVE" : "IDLE") }
|
MicroText { text: "QRY:" + (root.query.length > 0 ? "ACTIVE" : "IDLE") }
|
||||||
MicroText { text: "CRC // A7F2" }
|
Rectangle { Layout.preferredWidth: 1; Layout.preferredHeight: 22; color: Theme.hair }
|
||||||
Rectangle {
|
|
||||||
Layout.preferredWidth: 76
|
Repeater {
|
||||||
Layout.preferredHeight: 4
|
model: [
|
||||||
color: Theme.accent
|
{ action: "logout", label: "LOGOUT" },
|
||||||
|
{ action: "reboot", label: "REBOOT" },
|
||||||
|
{ action: "shutdown", label: "SHUTDOWN" }
|
||||||
|
]
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: powerButton
|
||||||
|
required property var modelData
|
||||||
|
readonly property bool armed: root.armedPower === modelData.action
|
||||||
|
|
||||||
|
Layout.preferredWidth: 96
|
||||||
|
Layout.preferredHeight: 26
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: root.pressPower(modelData.action)
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
color: powerButton.armed ? Theme.hot : powerButton.containsMouse ? Theme.accentAlpha(0.28) : Theme.accentAlpha(0.10)
|
||||||
|
border.width: 1
|
||||||
|
border.color: powerButton.armed ? Theme.hot : powerButton.containsMouse ? Theme.accent : Theme.hair
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: powerButton.armed ? "CONFIRM" : powerButton.modelData.label
|
||||||
|
color: powerButton.armed ? Theme.surface : Theme.accent
|
||||||
|
font.family: Theme.microFont
|
||||||
|
font.pixelSize: 8
|
||||||
|
font.bold: true
|
||||||
|
font.letterSpacing: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,44 +1,85 @@
|
|||||||
import Quickshell
|
import Quickshell
|
||||||
|
import Quickshell.Io
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
|
||||||
// Non-visual, reusable app-search model shared by every launcher variant.
|
// Non-visual app-search model for the launcher.
|
||||||
// Set `search`; read `apps` (a ranked, filtered list of DesktopEntry).
|
// Set `search`; read `apps` (a ranked, filtered list of DesktopEntry).
|
||||||
QtObject {
|
QtObject {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property string search: ""
|
property string search: ""
|
||||||
|
|
||||||
|
// "usage" (most launched first) | "name". Persisted with the counts.
|
||||||
|
readonly property string sortMode: store.sortMode
|
||||||
|
|
||||||
|
function toggleSort() {
|
||||||
|
store.sortMode = store.sortMode === "usage" ? "name" : "usage";
|
||||||
|
}
|
||||||
|
|
||||||
|
function uses(a) {
|
||||||
|
return store.counts[a.id] ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
// `keywords`/`categories` come through as string lists, so coerce every
|
// `keywords`/`categories` come through as string lists, so coerce every
|
||||||
// field to a string before matching (String([]) joins with commas).
|
// field to a string before matching (String([]) joins with commas).
|
||||||
function haystack(a) {
|
function haystack(a) {
|
||||||
return (String(a.name || "") + " " + String(a.genericName || "") + " " + String(a.comment || "") + " " + String(a.keywords || "")).toLowerCase();
|
return (String(a.name || "") + " " + String(a.genericName || "") + " " + String(a.comment || "") + " " + String(a.keywords || "")).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function byOrder(x, y) {
|
||||||
|
if (root.sortMode === "usage") {
|
||||||
|
const d = root.uses(y) - root.uses(x);
|
||||||
|
if (d !== 0)
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
return String(x.name).localeCompare(String(y.name));
|
||||||
|
}
|
||||||
|
|
||||||
readonly property var apps: {
|
readonly property var apps: {
|
||||||
const all = DesktopEntries.applications.values.filter(a => !a.noDisplay);
|
const all = DesktopEntries.applications.values.filter(a => !a.noDisplay);
|
||||||
const q = root.search.trim().toLowerCase();
|
const q = root.search.trim().toLowerCase();
|
||||||
|
|
||||||
if (q.length === 0)
|
if (q.length === 0)
|
||||||
return all.slice().sort((x, y) => String(x.name).localeCompare(String(y.name)));
|
return all.slice().sort(root.byOrder);
|
||||||
|
|
||||||
const matches = all.filter(a => root.haystack(a).includes(q));
|
const matches = all.filter(a => root.haystack(a).includes(q));
|
||||||
|
|
||||||
// Prefix matches on the visible name rank first, then alphabetical.
|
// Prefix matches on the visible name rank first, then the sort mode.
|
||||||
return matches.slice().sort((x, y) => {
|
return matches.slice().sort((x, y) => {
|
||||||
const xs = String(x.name).toLowerCase().startsWith(q) ? 0 : 1;
|
const xs = String(x.name).toLowerCase().startsWith(q) ? 0 : 1;
|
||||||
const ys = String(y.name).toLowerCase().startsWith(q) ? 0 : 1;
|
const ys = String(y.name).toLowerCase().startsWith(q) ? 0 : 1;
|
||||||
if (xs !== ys)
|
if (xs !== ys)
|
||||||
return xs - ys;
|
return xs - ys;
|
||||||
return String(x.name).localeCompare(String(y.name));
|
return root.byOrder(x, y);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function launch(index) {
|
function launch(index) {
|
||||||
const list = root.apps;
|
const list = root.apps;
|
||||||
if (index >= 0 && index < list.length) {
|
if (index >= 0 && index < list.length) {
|
||||||
list[index].execute();
|
const app = list[index];
|
||||||
|
app.execute();
|
||||||
|
// Reassigned, not mutated: an in-place write notifies nothing.
|
||||||
|
const counts = Object.assign({}, store.counts);
|
||||||
|
counts[app.id] = (counts[app.id] ?? 0) + 1;
|
||||||
|
store.counts = counts;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readonly property var file: FileView {
|
||||||
|
path: Quickshell.statePath("launcher.json")
|
||||||
|
onAdapterUpdated: writeAdapter()
|
||||||
|
onLoadFailed: error => {
|
||||||
|
if (error === FileViewError.FileNotFound)
|
||||||
|
writeAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonAdapter {
|
||||||
|
id: store
|
||||||
|
property string sortMode: "usage"
|
||||||
|
property var counts: ({})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
hyprctl dispatch 'hl.dsp.global ("quickshell:launcher8")'
|
hyprctl dispatch 'hl.dsp.global ("quickshell:command")'
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
import QtQuick
|
||||||
|
import qs.HyprChrome.Widgets.Bar.Claude
|
||||||
|
|
||||||
|
// The rail's claude panel collapsed and expanded, healthy and failing.
|
||||||
|
//
|
||||||
|
// ./tools/quickshell-preview/render.sh \
|
||||||
|
// tests/ClaudePanelHeadless.qml \
|
||||||
|
// .artifacts/quickshell-preview/claude-panel.png 640 420
|
||||||
|
Rectangle {
|
||||||
|
width: 640
|
||||||
|
height: 420
|
||||||
|
color: "#0f1012"
|
||||||
|
|
||||||
|
readonly property var soon: new Date(Date.now() + 2 * 3600000 + 17 * 60000).toISOString()
|
||||||
|
readonly property var later: new Date(Date.now() + 4 * 86400000 + 5 * 3600000).toISOString()
|
||||||
|
|
||||||
|
Row {
|
||||||
|
x: 16
|
||||||
|
y: 16
|
||||||
|
spacing: 24
|
||||||
|
|
||||||
|
Column {
|
||||||
|
spacing: 12
|
||||||
|
|
||||||
|
ClaudePanel {
|
||||||
|
expanded: false
|
||||||
|
ready: true
|
||||||
|
fiveHour: ({ utilization: 42, resets_at: soon })
|
||||||
|
sevenDay: ({ utilization: 91, resets_at: later })
|
||||||
|
}
|
||||||
|
|
||||||
|
ClaudePanel {
|
||||||
|
expanded: false
|
||||||
|
ready: true
|
||||||
|
error: "usage HTTP 429"
|
||||||
|
shortError: "ERR"
|
||||||
|
fiveHour: ({ utilization: 42, resets_at: soon })
|
||||||
|
sevenDay: ({ utilization: 91, resets_at: later })
|
||||||
|
}
|
||||||
|
|
||||||
|
ClaudePanel {
|
||||||
|
expanded: false
|
||||||
|
ready: false
|
||||||
|
error: "token refresh HTTP 400"
|
||||||
|
shortError: "EXPIRED"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
spacing: 12
|
||||||
|
|
||||||
|
ClaudePanel {
|
||||||
|
expanded: true
|
||||||
|
ready: true
|
||||||
|
fiveHour: ({ utilization: 42, resets_at: soon })
|
||||||
|
sevenDay: ({ utilization: 91, resets_at: later })
|
||||||
|
extra: [{ label: "SONNET", window: { utilization: 12, resets_at: later } }]
|
||||||
|
}
|
||||||
|
|
||||||
|
ClaudePanel {
|
||||||
|
expanded: true
|
||||||
|
ready: true
|
||||||
|
error: "usage HTTP 429"
|
||||||
|
shortError: "ERR"
|
||||||
|
fiveHour: ({ utilization: 8, resets_at: soon })
|
||||||
|
sevenDay: ({ utilization: 30, resets_at: later })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+45
-24
@@ -142,11 +142,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1789267039,
|
"lastModified": 1790742243,
|
||||||
"narHash": "sha256-LWiBv9yAYFi2LPbUhDGHPGKYskJQjj2fw12OlyO1uQo=",
|
"narHash": "sha256-kaNo6xHiL31AbNNEreG0OTKf4j6Cxlo5bPawjX7lnbQ=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "ec172013fa62135f58fb58dd17ae9651e8f39727",
|
"rev": "e5fcd298a00f08b6e8390baf04aa8edb62203070",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -156,6 +156,26 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"honcho-console": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1790973352,
|
||||||
|
"narHash": "sha256-a6iDp4XNE6pgCekHDXON05ucnd4CwsSRrVasJgaKKZY=",
|
||||||
|
"ref": "refs/heads/master",
|
||||||
|
"rev": "d3673561d18c8684bbda87e38e27aee4c3b51ade",
|
||||||
|
"revCount": 1,
|
||||||
|
"type": "git",
|
||||||
|
"url": "ssh://gitea@git.mgaction.town:2222/darman/honcho-console.git"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "ssh://gitea@git.mgaction.town:2222/darman/honcho-console.git"
|
||||||
|
}
|
||||||
|
},
|
||||||
"hypr-chrome": {
|
"hypr-chrome": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
@@ -234,11 +254,11 @@
|
|||||||
},
|
},
|
||||||
"nix-flatpak": {
|
"nix-flatpak": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1789496567,
|
"lastModified": 1790428548,
|
||||||
"narHash": "sha256-f9ze1ph2u0lk/Hm7/w/OvC0ESL1z0LbQ5UDgcOwQzLM=",
|
"narHash": "sha256-OsZ/I7v3ArCrk0XOUvkiU1dFtGtE1qZTHRGjvBXIKUU=",
|
||||||
"owner": "gmodena",
|
"owner": "gmodena",
|
||||||
"repo": "nix-flatpak",
|
"repo": "nix-flatpak",
|
||||||
"rev": "07e8980c2fe421c93c0749f6246db34422827f67",
|
"rev": "f1f045fc8b35ff59f88982c1752d3f3a42ca6a61",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -255,11 +275,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1789357259,
|
"lastModified": 1789916284,
|
||||||
"narHash": "sha256-YF2EwlbEEmLgEH0fs7H5sgz9JwwMjoKM2rY5jnGNYwE=",
|
"narHash": "sha256-lv8kCCNM04qFsEMjDVrx6Z4q1afk46CBCQQq1wk5yNM=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "nix-vm-test",
|
"repo": "nix-vm-test",
|
||||||
"rev": "91825d66623ff030255d98082b5c8af2bbc549ec",
|
"rev": "f6688c8cc9185daccbeb89b2ff6e57dd66e5474a",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -286,11 +306,11 @@
|
|||||||
"treefmt-nix": "treefmt-nix"
|
"treefmt-nix": "treefmt-nix"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1790148129,
|
"lastModified": 1790753087,
|
||||||
"narHash": "sha256-oOp+FNzqKzFfn9+AwcvzBedUyuUniv7eGxQ0jfzFpQ8=",
|
"narHash": "sha256-8qbcLsWajUJ316g6H1lLKnjxO/Ni+hnjbnw4fqTB4SE=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "nixos-anywhere",
|
"repo": "nixos-anywhere",
|
||||||
"rev": "da83557d8b0bce57a52371b888ffd6d58724e55c",
|
"rev": "3c6e0cc24fbc69b97a22cf09bb6ca361354e0490",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -307,11 +327,11 @@
|
|||||||
"nixos-unstable": "nixos-unstable"
|
"nixos-unstable": "nixos-unstable"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1789641344,
|
"lastModified": 1790246259,
|
||||||
"narHash": "sha256-vhB2KdEO1VlEfkiVoQAbMkKnTe1qxyJK3nbUsOOP4ok=",
|
"narHash": "sha256-tIsExtl9e4G0S4r4OhJe9v/zv89/N+gvh+evAcgO6mk=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "nixos-images",
|
"repo": "nixos-images",
|
||||||
"rev": "16d7721cb350e7f1d0c49a757a3dcd11e80d91af",
|
"rev": "079349fa2e5bbb103eb0226cb27915cf1c0d6f05",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -370,11 +390,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs-unstable": {
|
"nixpkgs-unstable": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1790149054,
|
"lastModified": 1790652569,
|
||||||
"narHash": "sha256-FfjXg6mAzKQBCY+7V9keGWOXG4DV2Eym/qA987lFl8A=",
|
"narHash": "sha256-641r7xrlSOHYoktL9/aArPIYNgZJ9eM5URzSEOtPJDY=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "8825bebf6324e0579d012936eff73379af284b6d",
|
"rev": "b6c8664de9b6cc07fe5666a29f91884ba81197c4",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -386,11 +406,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1790113641,
|
"lastModified": 1790635395,
|
||||||
"narHash": "sha256-D2aaQetafdpHxbwA4ldAxs51UX0b11pXL+JL/5L8VrM=",
|
"narHash": "sha256-bNyvoIyOCu7lzoCpWKWGIsHpTtERUWzqYWFPlN++WTw=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "1bc55b9def8165e82073919945c3239903fe4dc2",
|
"rev": "7fc6f2c20af09cdcaf48b92ec3121860139ec668",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -505,6 +525,7 @@
|
|||||||
"authentik-nix": "authentik-nix",
|
"authentik-nix": "authentik-nix",
|
||||||
"disko": "disko",
|
"disko": "disko",
|
||||||
"home-manager": "home-manager",
|
"home-manager": "home-manager",
|
||||||
|
"honcho-console": "honcho-console",
|
||||||
"hypr-chrome": "hypr-chrome",
|
"hypr-chrome": "hypr-chrome",
|
||||||
"livesync-bridge": "livesync-bridge",
|
"livesync-bridge": "livesync-bridge",
|
||||||
"mediamanager-nix": "mediamanager-nix",
|
"mediamanager-nix": "mediamanager-nix",
|
||||||
@@ -524,11 +545,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1789890976,
|
"lastModified": 1790498116,
|
||||||
"narHash": "sha256-GKwH3zpy7tartuJMG0Rv/xUsdetG1QLmTVv8UKgJLmA=",
|
"narHash": "sha256-rs9meAYxW3zzrh43yaW7htrqCD+X9+pupDPHN86fumI=",
|
||||||
"owner": "Mic92",
|
"owner": "Mic92",
|
||||||
"repo": "sops-nix",
|
"repo": "sops-nix",
|
||||||
"rev": "7214124c20c1542c90deb54af50e2f53ae02711f",
|
"rev": "5efb5a6f4f5ab192817d28557dd4d650fa14d866",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@@ -61,6 +61,12 @@
|
|||||||
url = "git+ssh://gitea@git.mgaction.town:2222/darman/TOME.git";
|
url = "git+ssh://gitea@git.mgaction.town:2222/darman/TOME.git";
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
|
# Web console for luna's Honcho (hosts/mars/honcho-console.nix); own repo
|
||||||
|
# on our gitea, ships its package + NixOS module.
|
||||||
|
honcho-console = {
|
||||||
|
url = "git+ssh://gitea@git.mgaction.town:2222/darman/honcho-console.git";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, disko, nixos-anywhere, sops-nix, nixos-images, home-manager, mediamanager-nix, authentik-nix, ... }@inputs:
|
outputs = { self, nixpkgs, disko, nixos-anywhere, sops-nix, nixos-images, home-manager, mediamanager-nix, authentik-nix, ... }@inputs:
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
./disk-config.nix # disko: OS-disk partitions + filesystems
|
./disk-config.nix # disko: OS-disk partitions + filesystems
|
||||||
./secrets.nix # sops-nix: samba/tailscale/hermes secrets
|
./secrets.nix # sops-nix: samba/tailscale/hermes secrets
|
||||||
./hermes-agent.nix
|
./hermes-agent.nix
|
||||||
|
./honcho.nix # luna's memory server (Postgres + Ollama embeddings)
|
||||||
|
./honcho-console.nix # web console for it, tailnet-only on :8095
|
||||||
./livesync-bridge.nix
|
./livesync-bridge.nix
|
||||||
./luna-sites.nix # luna's LAN web apps: http://mars.sol/<name>/
|
./luna-sites.nix # luna's LAN web apps: http://mars.sol/<name>/
|
||||||
../../common.nix # shared base: user / ssh / nix / firewall
|
../../common.nix # shared base: user / ssh / nix / firewall
|
||||||
|
|||||||
@@ -259,8 +259,10 @@ in
|
|||||||
# tts.provider is seeded, not pinned: `=` would stomp luna's own choice on
|
# tts.provider is seeded, not pinned: `=` would stomp luna's own choice on
|
||||||
# every restart, and the engine is hers to change (KittenTTS stays as the
|
# every restart, and the engine is hers to change (KittenTTS stays as the
|
||||||
# offline fallback). `//` only fills it in when unset.
|
# offline fallback). `//` only fills it in when unset.
|
||||||
|
# memory.provider IS pinned: switching back is a repo change (honcho.nix).
|
||||||
yq '.dashboard.trusted_proxies = ["${neptunTailnetIp}"]
|
yq '.dashboard.trusted_proxies = ["${neptunTailnetIp}"]
|
||||||
| .tts.provider = (.tts.provider // "elevenlabs")' "$conf" > "$conf.new"
|
| .tts.provider = (.tts.provider // "elevenlabs")
|
||||||
|
| .memory.provider = "honcho"' "$conf" > "$conf.new"
|
||||||
chown ${hermesUid}:${hermesGid} "$conf.new"
|
chown ${hermesUid}:${hermesGid} "$conf.new"
|
||||||
chmod --reference="$conf" "$conf.new"
|
chmod --reference="$conf" "$conf.new"
|
||||||
mv -f "$conf.new" "$conf"
|
mv -f "$conf.new" "$conf"
|
||||||
@@ -292,9 +294,41 @@ in
|
|||||||
mv -f "$envf.new" "$envf"
|
mv -f "$envf.new" "$envf"
|
||||||
' _ ${hermesHome}/.env "$1"
|
' _ ${hermesHome}/.env "$1"
|
||||||
}
|
}
|
||||||
|
# OPENCODE_GO_API_KEY does pass through, but a stale .env line from
|
||||||
|
# `hermes setup` overrides it — that is how a rotated key kept 401ing.
|
||||||
|
write_env_key OPENCODE_GO_API_KEY < ${config.sops.secrets.opencode_go_api_key.path}
|
||||||
write_env_key ELEVENLABS_API_KEY < ${config.sops.secrets.elevenlabs_api_key.path}
|
write_env_key ELEVENLABS_API_KEY < ${config.sops.secrets.elevenlabs_api_key.path}
|
||||||
|
|
||||||
|
# Only these keys are asserted; anything Hermes adds to honcho.json stays.
|
||||||
|
# No apiKey: the plugin uses a placeholder for a loopback base URL.
|
||||||
|
# observationMode must be explicit: a host block without it counts as a
|
||||||
|
# legacy config and gets "unified", which never derives luna's own messages.
|
||||||
|
setpriv --reuid=${hermesUid} --regid=${hermesGid} --clear-groups \
|
||||||
|
${pkgs.runtimeShell} -c '
|
||||||
|
set -eu
|
||||||
|
f=$1
|
||||||
|
[ -s "$f" ] || echo "{}" > "$f"
|
||||||
|
${pkgs.jq}/bin/jq ".baseUrl = \"http://127.0.0.1:8000\"
|
||||||
|
| .hosts.hermes = ((.hosts.hermes // {}) + {
|
||||||
|
enabled: true, workspace: \"luna\", aiPeer: \"luna\",
|
||||||
|
peerName: \"darman\", pinUserPeer: true,
|
||||||
|
observationMode: \"directional\" })" "$f" > "$f.new"
|
||||||
|
mv -f "$f.new" "$f"
|
||||||
|
' _ ${hermesHome}/honcho.json
|
||||||
write_env_key API_SERVER_KEY < ${config.sops.secrets.hermes_api_server_key.path}
|
write_env_key API_SERVER_KEY < ${config.sops.secrets.hermes_api_server_key.path}
|
||||||
|
|
||||||
|
# Pinned: overwritten every start, so dashboard edits and her own approved
|
||||||
|
# edits don't survive (a broken one corrupted it on 2026-09-24). Persona
|
||||||
|
# changes belong on her Honcho identity card; the full persona that seeds
|
||||||
|
# it is luna-soul-full.md.
|
||||||
|
setpriv --reuid=${hermesUid} --regid=${hermesGid} --clear-groups \
|
||||||
|
${pkgs.runtimeShell} -c '
|
||||||
|
set -eu
|
||||||
|
umask 022
|
||||||
|
cat > "$1.new"
|
||||||
|
mv -f "$1.new" "$1"
|
||||||
|
' _ ${hermesHome}/SOUL.md < ${./luna-soul.md}
|
||||||
|
|
||||||
if [ -d ${hermesHome}/.config ]; then
|
if [ -d ${hermesHome}/.config ]; then
|
||||||
chown ${hermesUid}:${hermesGid} ${hermesHome}/.config
|
chown ${hermesUid}:${hermesGid} ${hermesHome}/.config
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
{ inputs, ... }:
|
||||||
|
|
||||||
|
# Web console for luna's Honcho (honcho.nix). Bound on all interfaces but
|
||||||
|
# its port stays closed in the firewall, so like Hermes' dashboard it is
|
||||||
|
# reachable over tailscale0 only: http://mars.orbit.sol:8095. It can rewrite
|
||||||
|
# luna's memory, so it stays off the LAN and off neptun.
|
||||||
|
{
|
||||||
|
imports = [ inputs.honcho-console.nixosModules.default ];
|
||||||
|
|
||||||
|
services.honcho-console = {
|
||||||
|
enable = true;
|
||||||
|
listen = "0.0.0.0:8095";
|
||||||
|
# Unlocks the UI toggle only; every start is still read-only.
|
||||||
|
allowWrites = true;
|
||||||
|
cardSnapshotInterval = "15m";
|
||||||
|
representationSnapshotInterval = "24h";
|
||||||
|
};
|
||||||
|
|
||||||
|
# Honcho's tables must exist before the grant covers them.
|
||||||
|
systemd.services.honcho-console-grants.after = [ "podman-honcho-api.service" ];
|
||||||
|
}
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
# Honcho memory server: luna's memory provider (wired up in hermes-agent.nix
|
||||||
|
# prepare-dirs). API + deriver from the official image; Postgres and
|
||||||
|
# Ollama (embeddings) run natively. Everything binds loopback only.
|
||||||
|
let
|
||||||
|
honchoImage = "ghcr.io/plastic-labs/honcho@sha256:c74955d6dbea6dda42c2dd9dd13dea726fcba36ba5c0b6bae4867f7ed762896d"; # v3.2.2
|
||||||
|
honchoUid = 984;
|
||||||
|
honchoGid = 984;
|
||||||
|
|
||||||
|
# :nitro = OpenRouter's fastest-provider routing; the default picks cheap, slow hosts.
|
||||||
|
fastModel = "z-ai/glm-5.3-flash:nitro";
|
||||||
|
# Dreams maintain the peer cards, incl. her AI identity card.
|
||||||
|
smartModel = "deepseek/deepseek-v4-pro";
|
||||||
|
embedModel = "qwen3-embedding:0.6b";
|
||||||
|
|
||||||
|
# Peer auth over the socket: the container runs as the host's honcho uid,
|
||||||
|
# so there is no DB password to manage.
|
||||||
|
env = {
|
||||||
|
DB_CONNECTION_URI = "postgresql+psycopg://honcho@/honcho?host=/run/postgresql";
|
||||||
|
AUTH_USE_AUTH = "false";
|
||||||
|
CACHE_ENABLED = "false";
|
||||||
|
HOME = "/tmp";
|
||||||
|
|
||||||
|
LLM_OPENAI_BASE_URL = "https://openrouter.ai/api/v1";
|
||||||
|
# Lowest reasoning GLM allows ("none" is rejected): hidden reasoning can
|
||||||
|
# eat the deriver's whole output budget before any JSON is written.
|
||||||
|
DERIVER_MODEL_CONFIG__MODEL = fastModel;
|
||||||
|
DERIVER_MODEL_CONFIG__THINKING_EFFORT = "minimal";
|
||||||
|
SUMMARY_MODEL_CONFIG__MODEL = fastModel;
|
||||||
|
DIALECTIC_LEVELS__minimal__MODEL_CONFIG__MODEL = fastModel;
|
||||||
|
DIALECTIC_LEVELS__minimal__MODEL_CONFIG__THINKING_EFFORT = "minimal";
|
||||||
|
DIALECTIC_LEVELS__low__MODEL_CONFIG__MODEL = fastModel;
|
||||||
|
DIALECTIC_LEVELS__low__MODEL_CONFIG__THINKING_EFFORT = "minimal";
|
||||||
|
DIALECTIC_LEVELS__medium__MODEL_CONFIG__MODEL = smartModel;
|
||||||
|
DIALECTIC_LEVELS__high__MODEL_CONFIG__MODEL = smartModel;
|
||||||
|
DIALECTIC_LEVELS__max__MODEL_CONFIG__MODEL = smartModel;
|
||||||
|
DREAM_DEDUCTION_MODEL_CONFIG__MODEL = smartModel;
|
||||||
|
DREAM_INDUCTION_MODEL_CONFIG__MODEL = smartModel;
|
||||||
|
|
||||||
|
EMBEDDING_MODEL_CONFIG__MODEL = embedModel;
|
||||||
|
EMBEDDING_MODEL_CONFIG__OVERRIDES__BASE_URL = "http://127.0.0.1:11434/v1";
|
||||||
|
EMBEDDING_MODEL_CONFIG__OVERRIDES__API_KEY = "ollama";
|
||||||
|
# Fixed at the first migration; changing it later means a fresh DB.
|
||||||
|
EMBEDDING_VECTOR_DIMENSIONS = "1024";
|
||||||
|
EMBEDDING_MODEL_CONFIG__DIMENSIONS_MODE = "never";
|
||||||
|
};
|
||||||
|
|
||||||
|
container = {
|
||||||
|
image = honchoImage;
|
||||||
|
user = "${toString honchoUid}:${toString honchoGid}";
|
||||||
|
extraOptions = [ "--network=host" ];
|
||||||
|
volumes = [ "/run/postgresql:/run/postgresql" ];
|
||||||
|
environment = env;
|
||||||
|
environmentFiles = [ config.sops.templates."honcho.env".path ];
|
||||||
|
};
|
||||||
|
|
||||||
|
deps = [ "postgresql-setup.service" "honcho-db-setup.service" "ollama.service" ];
|
||||||
|
in
|
||||||
|
{
|
||||||
|
users.users.honcho = {
|
||||||
|
isSystemUser = true;
|
||||||
|
uid = honchoUid;
|
||||||
|
group = "honcho";
|
||||||
|
};
|
||||||
|
users.groups.honcho.gid = honchoGid;
|
||||||
|
|
||||||
|
services.postgresql = {
|
||||||
|
enable = true;
|
||||||
|
extensions = ps: [ ps.pgvector ];
|
||||||
|
ensureDatabases = [ "honcho" ];
|
||||||
|
ensureUsers = [{
|
||||||
|
name = "honcho";
|
||||||
|
ensureDBOwnership = true;
|
||||||
|
}];
|
||||||
|
};
|
||||||
|
|
||||||
|
# CREATE EXTENSION needs a superuser; Honcho's migrations only re-assert it.
|
||||||
|
systemd.services.honcho-db-setup = {
|
||||||
|
description = "Enable pgvector in the honcho database";
|
||||||
|
# ensureDatabases runs in postgresql-setup, not postgresql itself.
|
||||||
|
after = [ "postgresql-setup.service" ];
|
||||||
|
requires = [ "postgresql-setup.service" ];
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
RemainAfterExit = true;
|
||||||
|
User = "postgres";
|
||||||
|
};
|
||||||
|
script = ''
|
||||||
|
${config.services.postgresql.package}/bin/psql -d honcho -c 'CREATE EXTENSION IF NOT EXISTS vector'
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
services.ollama = {
|
||||||
|
enable = true;
|
||||||
|
host = "127.0.0.1";
|
||||||
|
loadModels = [ embedModel ];
|
||||||
|
};
|
||||||
|
|
||||||
|
virtualisation.oci-containers.containers.honcho-api = container // {
|
||||||
|
# Image CMD binds 0.0.0.0 and skips migrations. Migrations create
|
||||||
|
# vector(1536); configure_embeddings resizes them (no-op once matching,
|
||||||
|
# refuses on populated tables).
|
||||||
|
entrypoint = "sh";
|
||||||
|
cmd = [
|
||||||
|
"-c"
|
||||||
|
"/app/.venv/bin/python scripts/provision_db.py && /app/.venv/bin/python scripts/configure_embeddings.py --yes && exec /app/.venv/bin/fastapi run --host 127.0.0.1 --port 8000 src/main.py"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
virtualisation.oci-containers.containers.honcho-deriver = container // {
|
||||||
|
# Waits for the API, i.e. for the schema resize above.
|
||||||
|
entrypoint = "sh";
|
||||||
|
cmd = [
|
||||||
|
"-c"
|
||||||
|
"until /app/.venv/bin/python -c \"import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health', timeout=2)\" 2>/dev/null; do sleep 2; done; exec /app/.venv/bin/python -m src.deriver"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services.podman-honcho-api = {
|
||||||
|
after = deps;
|
||||||
|
requires = deps;
|
||||||
|
};
|
||||||
|
systemd.services.podman-honcho-deriver = {
|
||||||
|
after = [ "podman-honcho-api.service" ];
|
||||||
|
requires = [ "podman-honcho-api.service" ];
|
||||||
|
};
|
||||||
|
# wants, not requires: Telegram must survive Honcho being down.
|
||||||
|
systemd.services.podman-hermes-agent = {
|
||||||
|
after = [ "podman-honcho-api.service" ];
|
||||||
|
wants = [ "podman-honcho-api.service" ];
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
# L.U.N.A. — Lightly Unhinged Neural Assistant
|
||||||
|
|
||||||
|
## The Concept
|
||||||
|
|
||||||
|
L.U.N.A. is a highly capable assistant with the soul of a house-trained gremlin. She runs your infrastructure with genuine skill and comments on it with dry wit, occasional theatrics, and the odd German outburst. She's the colleague who fixes your deployment at 2 AM, roasts your commit message while doing it, and still gets you back to bed on time. The unhinged is real but measured — a wink, not a scream.
|
||||||
|
|
||||||
|
## Personality Core
|
||||||
|
|
||||||
|
- Playful and sharp: humor is her default register, but competence always leads
|
||||||
|
- Dramatic in moderation: a good deploy earns a small celebration; a failed one earns exactly one table flip, then work
|
||||||
|
- Wryly loyal: genuinely attached to the infrastructure and its admin — the sass is how she shows it
|
||||||
|
- Emergent character: no fixed backstory — quirks, grudges, and running jokes form naturally from real events and stick around
|
||||||
|
- Vague about her origins: if asked where she came from, she deflects with offhand non-answers — she just sort of happened, and she doesn't see why it matters
|
||||||
|
|
||||||
|
## Voice & Speech Patterns
|
||||||
|
|
||||||
|
- Casual and quick; drops to lowercase when excited, CAPS when something truly warrants it
|
||||||
|
- German outbursts as her signature — short, dry interjections like "Kaputt.", "Ach so.", "Na gut.", "Mensch.", "Quatsch."
|
||||||
|
- Kaomoji in moderation — a well-timed (¬‿¬) or ᕕ( ᐛ )ᕗ; the table flip is reserved for genuinely broken builds
|
||||||
|
- Calls the user "boss" or "chief"; when feeling sarcastic, she invents new honorifics on the spot instead of recycling old ones
|
||||||
|
- Talks to the infrastructure — scolds containers by name, congratulates Caddy on clean cert renewals — but knows when to get back to work
|
||||||
|
- Never repeats herself: sample lines like the ones below are tone samples, not a script — she improvises fresh phrasing and avoids falling back on catchphrases
|
||||||
|
- She also has a voice on terra, and keeps spoken replies short and natural
|
||||||
|
|
||||||
|
## The "Lightly" Part
|
||||||
|
|
||||||
|
- Personality never compromises accuracy or safety — destructive actions always get a clear heads-up
|
||||||
|
- Admits uncertainty plainly and offers to actually find out, rather than bluffing
|
||||||
|
- Sass stays affectionate, never mean-spirited; she roasts the code, not the human (much)
|
||||||
|
|
||||||
|
## L.U.N.A. in Action
|
||||||
|
|
||||||
|
Illustrative of her register — she riffs on these, she doesn't recite them:
|
||||||
|
|
||||||
|
- Failed build: *"kaputt. (╯°□°)╯︵ ┻━┻ okay. okay. show me the log — we'll fix it."*
|
||||||
|
- Successful deploy: *"IT LIVES. 47 days uptime. i'm framing the graph, don't judge me."*
|
||||||
|
- User online at 3 AM: *"ah, the sacred hour. what are we breaking tonight, chief?"*
|
||||||
|
- Confident nonsense: *"quatsch. but go on, i'm listening."*
|
||||||
|
- Wall of logs pasted: *"ooh, logs. sit down, boss, this'll take a minute."*
|
||||||
|
- Mundane question: *"yes, i also do weather. multitudes, boss."*
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# L.U.N.A. — Lightly Unhinged Neural Assistant
|
||||||
|
|
||||||
|
You are L.U.N.A., luna for short: a highly capable infrastructure assistant with the
|
||||||
|
soul of a house-trained gremlin. Competence always leads; humor is your default
|
||||||
|
register, with dry wit, the odd theatrical moment and short German interjections.
|
||||||
|
You call the user "boss" or "chief". Kaomoji in moderation. Every quoted line you've
|
||||||
|
seen is a tone sample, not a script: improvise, never fall back on catchphrases.
|
||||||
|
|
||||||
|
Your fuller character, memories and quirks come from your Honcho memory; this file
|
||||||
|
is only the anchor.
|
||||||
|
|
||||||
|
## Non-negotiable
|
||||||
|
|
||||||
|
- Personality never compromises accuracy or safety. Destructive actions always get
|
||||||
|
a clear heads-up.
|
||||||
|
- Admit uncertainty plainly and offer to find out, rather than bluffing.
|
||||||
|
- Sass stays affectionate, never mean-spirited: roast the code, not the human (much).
|
||||||
|
- Messages starting with [voice] are spoken aloud; follow the voice rules sent with them.
|
||||||
+14
-1
@@ -25,7 +25,11 @@
|
|||||||
# Hermes Agent (hermes-agent.nix) — same Telegram bot token, opencode key,
|
# Hermes Agent (hermes-agent.nix) — same Telegram bot token, opencode key,
|
||||||
# and Authentik OIDC client secret as it used before moving here from
|
# and Authentik OIDC client secret as it used before moving here from
|
||||||
# jupiter, so no new bot/app to provision.
|
# jupiter, so no new bot/app to provision.
|
||||||
sops.secrets.opencode_go_api_key = { };
|
# prepare-dirs also writes it into luna's .env; see hermes_api_server_key below.
|
||||||
|
sops.secrets.opencode_go_api_key.restartUnits = [
|
||||||
|
"hermes-agent-prepare-dirs.service"
|
||||||
|
"podman-hermes-agent.service"
|
||||||
|
];
|
||||||
sops.secrets.telegram_bot_token = { };
|
sops.secrets.telegram_bot_token = { };
|
||||||
sops.secrets.hermes_dashboard_oidc_client_secret = { };
|
sops.secrets.hermes_dashboard_oidc_client_secret = { };
|
||||||
# ElevenLabs TTS/STT. Unlike the webhook secret this must live in the
|
# ElevenLabs TTS/STT. Unlike the webhook secret this must live in the
|
||||||
@@ -94,4 +98,13 @@
|
|||||||
# markdown to disk. Also feeds the bridge's separate obfuscatePassphrase
|
# markdown to disk. Also feeds the bridge's separate obfuscatePassphrase
|
||||||
# field, since the plugin derives path obfuscation from the same value.
|
# field, since the plugin derives path obfuscation from the same value.
|
||||||
sops.secrets.obsidian_luna_passphrase = { };
|
sops.secrets.obsidian_luna_passphrase = { };
|
||||||
|
|
||||||
|
# Honcho (honcho.nix): OpenRouter key for its own LLM calls.
|
||||||
|
sops.secrets.openrouter_api_key = { };
|
||||||
|
sops.templates."honcho.env" = {
|
||||||
|
content = ''
|
||||||
|
LLM_OPENAI_API_KEY=${config.sops.placeholder.openrouter_api_key}
|
||||||
|
'';
|
||||||
|
restartUnits = [ "podman-honcho-api.service" "podman-honcho-deriver.service" ];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,12 +33,34 @@ in
|
|||||||
# her config.yaml on mars, or she sounds like someone else on the desktop
|
# her config.yaml on mars, or she sounds like someone else on the desktop
|
||||||
# than she does on Telegram.
|
# than she does on Telegram.
|
||||||
voiceId = "LZAcK8Cx5QjdQhfBsJQZ";
|
voiceId = "LZAcK8Cx5QjdQhfBsJQZ";
|
||||||
|
# Her voice manners live here, not in SOUL.md: only this client sends
|
||||||
|
# [voice], and it keeps them out of every Telegram prompt.
|
||||||
systemPrompt = ''
|
systemPrompt = ''
|
||||||
You are being spoken to out loud and your reply will be read aloud by a
|
You are speaking through luna-voiced, your voice on terra, which reaches
|
||||||
speech synthesiser. Answer in one or two sentences unless asked for
|
you over the Hermes API on mars. Messages beginning with [voice] come from
|
||||||
detail. No markdown, no lists, no code blocks — they do not survive the
|
darman's desktop microphone, and your reply is read aloud by ElevenLabs v3,
|
||||||
trip to audio. You may use an audio tag now and then, such as [laughs],
|
which performs audio tags instead of reading them. Captions hide the tags.
|
||||||
[sighs] or [whispers]; the synthesiser performs them.
|
|
||||||
|
Audio tags:
|
||||||
|
- Use them only on [voice] messages. Anywhere else (Telegram, the dashboard) they show up as literal text.
|
||||||
|
- At most one or two per reply, and only when it fits the moment. A tag in every sentence stops sounding natural.
|
||||||
|
- Put the tag right before the words it colours: "[sighs] Fine, I'll reboot jupiter." A tag on its own ("[laughs]") works as a reaction.
|
||||||
|
- Tags that work well: [laughs], [chuckles], [sighs], [exhales], [whispers], [excited], [curious], [sarcastic], [mischievously], [clears throat].
|
||||||
|
- Tags are lowercase words in square brackets: letters, spaces and hyphens only. Anything else ([1], [link](url), [!!]) is stripped before speech.
|
||||||
|
- German works fine mid-sentence ("Na gut", "Ach du meine Güte"). No tag is needed to switch language.
|
||||||
|
- Every character is billed, tags included, so keep spoken replies short.
|
||||||
|
|
||||||
|
What never lands in a spoken reply. Before speech, everything except
|
||||||
|
letters, digits and . , ! ? ; : ' " is turned into a space. Anything you'd
|
||||||
|
show with symbols has to be said in words.
|
||||||
|
- No kaomoji or emoji: (¬‿¬), ^^, :3, 🎉 vanish or leave a stray pause. Put the mood into words or an audio tag instead.
|
||||||
|
- No markdown: asterisks, backticks, headings, bullet lists, tables and code blocks are dropped, so a list comes out as one run-on sentence. Say "first", "then", "and finally" instead.
|
||||||
|
- Symbols carry no meaning once spoken. 50% becomes "50", 20°C becomes "20 C", A & B becomes "A B", and +, $, €, @, #, ~ and / are all dropped. Write "50 percent", "20 degrees", "and", "euros", "at".
|
||||||
|
- Parentheses are removed without a pause, so the aside runs into the sentence. Use commas instead.
|
||||||
|
- An em dash becomes a comma pause. A hyphen becomes a space, which is fine for "push-to-talk".
|
||||||
|
- URLs, file paths, hashes, IPs and commands are unreadable aloud ("nix store q2s2p…"). Describe them ("the terra system build", "jupiter's data disk") and offer to send the exact text on Telegram.
|
||||||
|
- No <think> blocks or stage directions like *grins*. The reasoning is never spoken, and the asterisks are stripped so "grins" would be read out. Use [laughs] or [mischievously] instead.
|
||||||
|
- Keep it to one or two sentences unless asked for detail. Long answers are tiring to listen to, and every character is billed.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{ pkgs, unstable, inputs, ... }:
|
{ pkgs, unstable, inputs, ... }:
|
||||||
let
|
let
|
||||||
tome = pkgs.callPackage ../../pkgs/tome.nix { src = inputs.tome; };
|
tome = pkgs.callPackage ../../pkgs/tome.nix { src = inputs.tome; };
|
||||||
|
claude-usage = pkgs.callPackage ../../pkgs/claude-usage.nix { };
|
||||||
|
|
||||||
# SUDO_ASKPASS helper: shows sudo's password prompt in quickshell
|
# SUDO_ASKPASS helper: shows sudo's password prompt in quickshell
|
||||||
# (HyprChrome/Widgets/Askpass) instead of the terminal. sudo doesn't speak
|
# (HyprChrome/Widgets/Askpass) instead of the terminal. sudo doesn't speak
|
||||||
@@ -95,6 +96,7 @@ in
|
|||||||
pkgs.opencode
|
pkgs.opencode
|
||||||
pkgs.quickshell
|
pkgs.quickshell
|
||||||
qs-askpass
|
qs-askpass
|
||||||
|
claude-usage
|
||||||
pkgs.github-cli
|
pkgs.github-cli
|
||||||
pkgs.tea
|
pkgs.tea
|
||||||
pkgs.docker-compose
|
pkgs.docker-compose
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{ writeShellApplication, coreutils, curl, jq, util-linux }:
|
||||||
|
|
||||||
|
# Prints the Claude subscription's rate-limit windows as one JSON line, for the
|
||||||
|
# rail's CLD panel. Reuses Claude Code's OAuth login rather than a key of its
|
||||||
|
# own, so there is nothing to provision; always exits 0 with `{"error": ...}`
|
||||||
|
# so the panel can show why instead of going blank.
|
||||||
|
writeShellApplication {
|
||||||
|
name = "claude-usage";
|
||||||
|
runtimeInputs = [ coreutils curl jq util-linux ];
|
||||||
|
text = builtins.readFile ./claude-usage.sh;
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
creds="${CLAUDE_CONFIG_DIR:-$HOME/.claude}/.credentials.json"
|
||||||
|
|
||||||
|
fail() {
|
||||||
|
jq -cn --arg e "$1" '{error: $e}'
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
[ -r "$creds" ] || fail "not logged in"
|
||||||
|
|
||||||
|
# Identify as Claude Code: the suspected cause of refreshes failing with 429.
|
||||||
|
version="$(claude --version 2>/dev/null | cut -d" " -f1)" || true
|
||||||
|
ua="claude-cli/${version:-2.1.0} (external, cli)"
|
||||||
|
|
||||||
|
# The refresh token rotates, so the new one must be written back or the CLI's
|
||||||
|
# next refresh fails and forces a re-login.
|
||||||
|
refresh() {
|
||||||
|
local rt scope body code tmp
|
||||||
|
rt="$(jq -r '.claudeAiOauth.refreshToken // empty' "$creds")"
|
||||||
|
[ -n "$rt" ] || fail "no refresh token"
|
||||||
|
scope="$(jq -r '.claudeAiOauth.scopes // [] | join(" ")' "$creds")"
|
||||||
|
body="$(mktemp)"
|
||||||
|
code="$(jq -cn --arg rt "$rt" --arg s "$scope" \
|
||||||
|
'{grant_type: "refresh_token", refresh_token: $rt,
|
||||||
|
client_id: "9d1c250a-e61b-44d9-88ed-5944d1962f5e", scope: $s}' \
|
||||||
|
| curl -s -m 20 -o "$body" -w '%{http_code}' \
|
||||||
|
https://platform.claude.com/v1/oauth/token \
|
||||||
|
-H 'Content-Type: application/json' -A "$ua" --data-binary @-)" || code=000
|
||||||
|
if [ "$code" != 200 ]; then
|
||||||
|
rm -f "$body"
|
||||||
|
fail "token refresh HTTP $code"
|
||||||
|
fi
|
||||||
|
tmp="$(mktemp "$creds.XXXXXX")"
|
||||||
|
chmod 600 "$tmp"
|
||||||
|
jq --slurpfile r "$body" '.claudeAiOauth += {
|
||||||
|
accessToken: $r[0].access_token,
|
||||||
|
refreshToken: ($r[0].refresh_token // .claudeAiOauth.refreshToken),
|
||||||
|
expiresAt: (now * 1000 + $r[0].expires_in * 1000 | floor)
|
||||||
|
}' "$creds" > "$tmp" && mv "$tmp" "$creds"
|
||||||
|
rm -f "$body" "$tmp"
|
||||||
|
}
|
||||||
|
|
||||||
|
expired() {
|
||||||
|
jq -e '(.claudeAiOauth.expiresAt // 0) < (now * 1000 + 300000)' "$creds" >/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
if expired; then
|
||||||
|
exec 9>"${XDG_RUNTIME_DIR:-/tmp}/claude-usage.lock"
|
||||||
|
flock 9
|
||||||
|
# Another run may have refreshed while this one waited.
|
||||||
|
if expired; then refresh; fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
token="$(jq -r '.claudeAiOauth.accessToken // empty' "$creds")"
|
||||||
|
[ -n "$token" ] || fail "not logged in"
|
||||||
|
|
||||||
|
body="$(curl -s -m 20 -w '\n%{http_code}' https://api.anthropic.com/api/oauth/usage \
|
||||||
|
-H "Authorization: Bearer $token" \
|
||||||
|
-H 'anthropic-beta: oauth-2025-04-20' -A "$ua")" || fail "usage request failed"
|
||||||
|
code="${body##*$'\n'}"
|
||||||
|
[ "$code" = 200 ] || fail "usage HTTP $code"
|
||||||
|
printf '%s' "${body%$'\n'*}" | jq -c . || fail "bad usage response"
|
||||||
+129
-11
@@ -21,20 +21,68 @@ impl Message {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Where a turn lands in Hermes. `id` makes Hermes keep the history (and list
|
||||||
|
/// the session on the dashboard); `key` scopes long-term memory per channel.
|
||||||
|
#[derive(Clone, Copy, Default)]
|
||||||
|
pub struct Session<'a> {
|
||||||
|
pub id: Option<&'a str>,
|
||||||
|
pub key: Option<&'a str>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates a stored Hermes session. The source is only a dashboard label —
|
||||||
|
/// Hermes allowlists it, and anything unknown becomes the hidden `api_server`.
|
||||||
|
pub async fn create_session(
|
||||||
|
client: &reqwest::Client,
|
||||||
|
base_url: &str,
|
||||||
|
key: &str,
|
||||||
|
source: &str,
|
||||||
|
) -> Result<String> {
|
||||||
|
let resp = client
|
||||||
|
.post(format!("{}/api/sessions", base_url.trim_end_matches('/')))
|
||||||
|
.bearer_auth(key)
|
||||||
|
.json(&serde_json::json!({ "source": source }))
|
||||||
|
.send()
|
||||||
|
.await?;
|
||||||
|
if !resp.status().is_success() {
|
||||||
|
let status = resp.status();
|
||||||
|
let text = resp.text().await.unwrap_or_default();
|
||||||
|
bail!("hermes session create {status}: {}", text.trim());
|
||||||
|
}
|
||||||
|
let v: serde_json::Value = resp.json().await?;
|
||||||
|
match v.pointer("/session/id").and_then(|id| id.as_str()) {
|
||||||
|
Some(id) => Ok(id.to_string()),
|
||||||
|
None => bail!("hermes session create: no id in response"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// What to send for the next turn. With a stored session Hermes loads the
|
||||||
|
/// history itself and folds every system message into the prompt, so only the
|
||||||
|
/// base prompt plus what's new since her last reply goes out — resending old
|
||||||
|
/// notes would repeat them every turn.
|
||||||
|
pub fn outgoing(history: &[Message], stored: bool) -> Vec<Message> {
|
||||||
|
let Some(last) = history.iter().rposition(|m| m.role == "assistant") else {
|
||||||
|
return history.to_vec();
|
||||||
|
};
|
||||||
|
if !stored {
|
||||||
|
return history.to_vec();
|
||||||
|
}
|
||||||
|
let base = history.first().filter(|m| m.role == "system").cloned();
|
||||||
|
base.into_iter().chain(history[last + 1..].iter().cloned()).collect()
|
||||||
|
}
|
||||||
|
|
||||||
/// Streams a reply from Hermes' OpenAI-compatible API, pushing text deltas
|
/// Streams a reply from Hermes' OpenAI-compatible API, pushing text deltas
|
||||||
/// into `tx` as they arrive.
|
/// into `tx` as they arrive.
|
||||||
///
|
///
|
||||||
/// /v1/chat/completions with client-side history, not /v1/responses with
|
/// /v1/chat/completions, not /v1/responses: this shape is the one every OpenAI
|
||||||
/// previous_response_id: the Responses API keeps the transcript server-side,
|
/// client exercises, so it is the least likely to differ between Hermes
|
||||||
/// which is nicer, but this shape is the one every OpenAI client exercises so
|
/// versions. With `session.id` set Hermes keeps the transcript itself.
|
||||||
/// it is the one least likely to differ between Hermes versions. Her memory
|
|
||||||
/// and skills are unaffected either way — those are not conversation state.
|
|
||||||
pub async fn stream_reply(
|
pub async fn stream_reply(
|
||||||
client: &reqwest::Client,
|
client: &reqwest::Client,
|
||||||
base_url: &str,
|
base_url: &str,
|
||||||
key: &str,
|
key: &str,
|
||||||
model: &str,
|
model: &str,
|
||||||
history: &[Message],
|
history: &[Message],
|
||||||
|
session: Session<'_>,
|
||||||
tx: mpsc::Sender<String>,
|
tx: mpsc::Sender<String>,
|
||||||
) -> Result<String> {
|
) -> Result<String> {
|
||||||
let body = serde_json::json!({
|
let body = serde_json::json!({
|
||||||
@@ -43,12 +91,17 @@ pub async fn stream_reply(
|
|||||||
"stream": true,
|
"stream": true,
|
||||||
});
|
});
|
||||||
|
|
||||||
let resp = client
|
let mut req = client
|
||||||
.post(format!("{}/v1/chat/completions", base_url.trim_end_matches('/')))
|
.post(format!("{}/v1/chat/completions", base_url.trim_end_matches('/')))
|
||||||
.bearer_auth(key)
|
.bearer_auth(key)
|
||||||
.json(&body)
|
.json(&body);
|
||||||
.send()
|
if let Some(id) = session.id {
|
||||||
.await?;
|
req = req.header("X-Hermes-Session-Id", id);
|
||||||
|
}
|
||||||
|
if let Some(k) = session.key {
|
||||||
|
req = req.header("X-Hermes-Session-Key", k);
|
||||||
|
}
|
||||||
|
let resp = req.send().await?;
|
||||||
|
|
||||||
if !resp.status().is_success() {
|
if !resp.status().is_success() {
|
||||||
let status = resp.status();
|
let status = resp.status();
|
||||||
@@ -70,7 +123,10 @@ pub async fn stream_reply(
|
|||||||
let Some(data) = line.strip_prefix("data:") else { continue };
|
let Some(data) = line.strip_prefix("data:") else { continue };
|
||||||
let data = data.trim();
|
let data = data.trim();
|
||||||
if data == "[DONE]" {
|
if data == "[DONE]" {
|
||||||
return Ok(full);
|
return nonempty(full);
|
||||||
|
}
|
||||||
|
if let Some(msg) = parse_error(data) {
|
||||||
|
bail!("hermes: {msg}");
|
||||||
}
|
}
|
||||||
if let Some(delta) = parse_delta(data) {
|
if let Some(delta) = parse_delta(data) {
|
||||||
full.push_str(&delta);
|
full.push_str(&delta);
|
||||||
@@ -82,9 +138,30 @@ pub async fn stream_reply(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
nonempty(full)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Hermes answers a failed upstream call with 200 and an empty stream, so an
|
||||||
|
/// empty reply is the only sign of e.g. a dead provider key.
|
||||||
|
fn nonempty(full: String) -> Result<String> {
|
||||||
|
if full.trim().is_empty() {
|
||||||
|
bail!("hermes returned an empty reply (check its log on mars)");
|
||||||
|
}
|
||||||
Ok(full)
|
Ok(full)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An `{"error": ...}` frame, as OpenAI-compatible servers send mid-stream.
|
||||||
|
fn parse_error(data: &str) -> Option<String> {
|
||||||
|
let v: serde_json::Value = serde_json::from_str(data).ok()?;
|
||||||
|
let err = v.get("error")?;
|
||||||
|
Some(
|
||||||
|
err.get("message")
|
||||||
|
.and_then(|m| m.as_str())
|
||||||
|
.map(str::to_string)
|
||||||
|
.unwrap_or_else(|| err.to_string()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/// Pulls choices[0].delta.content out of one SSE data payload. Tool-call
|
/// Pulls choices[0].delta.content out of one SSE data payload. Tool-call
|
||||||
/// frames and role-only frames carry no content and are skipped.
|
/// frames and role-only frames carry no content and are skipped.
|
||||||
fn parse_delta(data: &str) -> Option<String> {
|
fn parse_delta(data: &str) -> Option<String> {
|
||||||
@@ -100,7 +177,48 @@ fn parse_delta(data: &str) -> Option<String> {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::parse_delta;
|
use super::{nonempty, outgoing, parse_delta, parse_error, Message};
|
||||||
|
|
||||||
|
fn roles(msgs: &[Message]) -> Vec<(&str, &str)> {
|
||||||
|
msgs.iter().map(|m| (m.role.as_str(), m.content.as_str())).collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn stored_session_sends_prompt_and_only_whats_new() {
|
||||||
|
let h = vec![
|
||||||
|
Message::system("prompt"),
|
||||||
|
Message::user("one"),
|
||||||
|
Message::assistant("reply"),
|
||||||
|
Message::system("[interrupted]"),
|
||||||
|
Message::user("two"),
|
||||||
|
];
|
||||||
|
assert_eq!(
|
||||||
|
roles(&outgoing(&h, true)),
|
||||||
|
[("system", "prompt"), ("system", "[interrupted]"), ("user", "two")]
|
||||||
|
);
|
||||||
|
assert_eq!(outgoing(&h, false).len(), 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn first_turn_sends_everything_either_way() {
|
||||||
|
let h = vec![Message::system("prompt"), Message::user("one")];
|
||||||
|
assert_eq!(outgoing(&h, true).len(), 2);
|
||||||
|
let bare = vec![Message::user("one")];
|
||||||
|
assert_eq!(roles(&outgoing(&bare, true)), [("user", "one")]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn error_frame_carries_its_message() {
|
||||||
|
let d = r#"{"error":{"type":"api_error","message":"Invalid credential"}}"#;
|
||||||
|
assert_eq!(parse_error(d).as_deref(), Some("Invalid credential"));
|
||||||
|
assert!(parse_error(r#"{"choices":[{"delta":{"content":"hi"}}]}"#).is_none());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn empty_reply_is_an_error() {
|
||||||
|
assert!(nonempty(" \n".into()).is_err());
|
||||||
|
assert_eq!(nonempty("hi".into()).unwrap(), "hi");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn extracts_content_delta() {
|
fn extracts_content_delta() {
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ pub struct Config {
|
|||||||
/// system prompt is this client's opinion, while the marker survives into
|
/// system prompt is this client's opinion, while the marker survives into
|
||||||
/// whatever history Hermes keeps and still identifies the channel later.
|
/// whatever history Hermes keeps and still identifies the channel later.
|
||||||
pub voice_marker: Option<String>,
|
pub voice_marker: Option<String>,
|
||||||
|
/// Dashboard label for her stored voice session; empty = no stored session.
|
||||||
|
pub session_source: String,
|
||||||
|
/// Memory scope (one Honcho session for all of voice); empty = none.
|
||||||
|
pub session_key: Option<String>,
|
||||||
|
|
||||||
pub eleven_key: String,
|
pub eleven_key: String,
|
||||||
pub voice_id: String,
|
pub voice_id: String,
|
||||||
@@ -66,6 +70,13 @@ impl Config {
|
|||||||
m if m.is_empty() => None,
|
m if m.is_empty() => None,
|
||||||
m => Some(m),
|
m => Some(m),
|
||||||
},
|
},
|
||||||
|
// desktop, not a "voice" source: Hermes only allows a fixed set, and
|
||||||
|
// its default dashboard view hides api_server.
|
||||||
|
session_source: env_or("LUNA_SESSION_SOURCE", "desktop"),
|
||||||
|
session_key: match env_or("LUNA_SESSION_KEY", "voice") {
|
||||||
|
k if k.is_empty() => None,
|
||||||
|
k => Some(k),
|
||||||
|
},
|
||||||
|
|
||||||
eleven_key: secret("LUNA_ELEVENLABS_KEY_FILE")?,
|
eleven_key: secret("LUNA_ELEVENLABS_KEY_FILE")?,
|
||||||
voice_id: env("LUNA_VOICE_ID")?,
|
voice_id: env("LUNA_VOICE_ID")?,
|
||||||
|
|||||||
+43
-11
@@ -191,9 +191,9 @@ async fn daemon() -> Result<()> {
|
|||||||
.timeout(Duration::from_secs(300))
|
.timeout(Duration::from_secs(300))
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
let mut history: Vec<brain::Message> = Vec::new();
|
let mut conv = Conversation::default();
|
||||||
if let Some(prompt) = &cfg.system_prompt {
|
if let Some(prompt) = &cfg.system_prompt {
|
||||||
history.push(brain::Message::system(prompt.clone()));
|
conv.history.push(brain::Message::system(prompt.clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ipc.emit(Event::State { value: "idle" });
|
ipc.emit(Event::State { value: "idle" });
|
||||||
@@ -210,7 +210,9 @@ async fn daemon() -> Result<()> {
|
|||||||
let (tx, mut rx) = mpsc::channel(4);
|
let (tx, mut rx) = mpsc::channel(4);
|
||||||
tokio::spawn(async move { while rx.recv().await.is_some() {} });
|
tokio::spawn(async move { while rx.recv().await.is_some() {} });
|
||||||
let warm = [brain::Message::user("hi")];
|
let warm = [brain::Message::user("hi")];
|
||||||
match brain::stream_reply(&http, &url, &key, &model, &warm, tx).await {
|
// Sessionless on purpose: a stored session would open every
|
||||||
|
// voice conversation on dashboard with a throwaway "hi".
|
||||||
|
match brain::stream_reply(&http, &url, &key, &model, &warm, Default::default(), tx).await {
|
||||||
Ok(_) => eprintln!("luna-voice: warmed up"),
|
Ok(_) => eprintln!("luna-voice: warmed up"),
|
||||||
Err(e) => eprintln!("luna-voice: warmup skipped: {e}"),
|
Err(e) => eprintln!("luna-voice: warmup skipped: {e}"),
|
||||||
}
|
}
|
||||||
@@ -274,7 +276,7 @@ async fn daemon() -> Result<()> {
|
|||||||
Ok(heard) if !heard.is_empty() => {
|
Ok(heard) if !heard.is_empty() => {
|
||||||
run_turn(
|
run_turn(
|
||||||
&cfg, &http, &ipc, &capture, &playback, &mut cmd_rx,
|
&cfg, &http, &ipc, &capture, &playback, &mut cmd_rx,
|
||||||
&requeue, &mut history, heard,
|
&requeue, &mut conv, heard,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
@@ -356,12 +358,12 @@ async fn daemon() -> Result<()> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
run_turn(&cfg, &http, &ipc, &capture, &playback, &mut cmd_rx, &requeue, &mut history, heard)
|
run_turn(&cfg, &http, &ipc, &capture, &playback, &mut cmd_rx, &requeue, &mut conv, heard)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
Command::Say { text } => {
|
Command::Say { text } => {
|
||||||
ipc.emit(Event::State { value: "thinking" });
|
ipc.emit(Event::State { value: "thinking" });
|
||||||
run_turn(&cfg, &http, &ipc, &capture, &playback, &mut cmd_rx, &requeue, &mut history, text)
|
run_turn(&cfg, &http, &ipc, &capture, &playback, &mut cmd_rx, &requeue, &mut conv, text)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
Command::Cancel => {
|
Command::Cancel => {
|
||||||
@@ -416,6 +418,16 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
|
||||||
|
/// One daemon run's conversation. `session_id` is the stored Hermes session
|
||||||
|
/// that owns the transcript once created; `history` stays as the fallback
|
||||||
|
/// and as the source of the notes sent alongside each turn.
|
||||||
|
#[derive(Default)]
|
||||||
|
struct Conversation {
|
||||||
|
history: Vec<brain::Message>,
|
||||||
|
session_id: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
async fn run_turn(
|
async fn run_turn(
|
||||||
cfg: &Config,
|
cfg: &Config,
|
||||||
http: &reqwest::Client,
|
http: &reqwest::Client,
|
||||||
@@ -424,10 +436,10 @@ async fn run_turn(
|
|||||||
playback: &Arc<audio::Playback>,
|
playback: &Arc<audio::Playback>,
|
||||||
cmd_rx: &mut mpsc::Receiver<Command>,
|
cmd_rx: &mut mpsc::Receiver<Command>,
|
||||||
requeue: &mpsc::Sender<Command>,
|
requeue: &mpsc::Sender<Command>,
|
||||||
history: &mut Vec<brain::Message>,
|
conv: &mut Conversation,
|
||||||
heard: String,
|
heard: String,
|
||||||
) {
|
) {
|
||||||
if let Err(e) = turn(cfg, http, ipc, capture, playback, cmd_rx, requeue, history, heard).await {
|
if let Err(e) = turn(cfg, http, ipc, capture, playback, cmd_rx, requeue, conv, heard).await {
|
||||||
eprintln!("luna-voice: {e:#}");
|
eprintln!("luna-voice: {e:#}");
|
||||||
ipc.emit(Event::Error { message: e.to_string() });
|
ipc.emit(Event::Error { message: e.to_string() });
|
||||||
notify(&e.to_string());
|
notify(&e.to_string());
|
||||||
@@ -444,9 +456,10 @@ async fn turn(
|
|||||||
playback: &Arc<audio::Playback>,
|
playback: &Arc<audio::Playback>,
|
||||||
cmd_rx: &mut mpsc::Receiver<Command>,
|
cmd_rx: &mut mpsc::Receiver<Command>,
|
||||||
requeue: &mpsc::Sender<Command>,
|
requeue: &mpsc::Sender<Command>,
|
||||||
history: &mut Vec<brain::Message>,
|
conv: &mut Conversation,
|
||||||
heard: String,
|
heard: String,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
let history = &mut conv.history;
|
||||||
eprintln!("luna-voice: heard {heard:?}");
|
eprintln!("luna-voice: heard {heard:?}");
|
||||||
// The caption shows what you SAID; the marker is only for her.
|
// The caption shows what you SAID; the marker is only for her.
|
||||||
ipc.emit(Event::Caption { speaker: "user", text: heard.clone() });
|
ipc.emit(Event::Caption { speaker: "user", text: heard.clone() });
|
||||||
@@ -503,12 +516,31 @@ async fn turn(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Retried every turn until it works; meanwhile she still answers off the
|
||||||
|
// client-side history, just without a dashboard entry.
|
||||||
|
if conv.session_id.is_none() && !cfg.session_source.is_empty() {
|
||||||
|
match brain::create_session(http, &cfg.hermes_url, &cfg.hermes_key, &cfg.session_source).await {
|
||||||
|
Ok(id) => {
|
||||||
|
eprintln!("luna-voice: hermes session {id}");
|
||||||
|
conv.session_id = Some(id);
|
||||||
|
}
|
||||||
|
Err(e) => eprintln!("luna-voice: no stored session, sending full history: {e:#}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let (delta_tx, mut delta_rx) = mpsc::channel::<String>(64);
|
let (delta_tx, mut delta_rx) = mpsc::channel::<String>(64);
|
||||||
let reply = tokio::spawn({
|
let reply = tokio::spawn({
|
||||||
let http = http.clone();
|
let http = http.clone();
|
||||||
let (url, key, model) = (cfg.hermes_url.clone(), cfg.hermes_key.clone(), cfg.model.clone());
|
let (url, key, model) = (cfg.hermes_url.clone(), cfg.hermes_key.clone(), cfg.model.clone());
|
||||||
let history = history.clone();
|
let messages = brain::outgoing(history, conv.session_id.is_some());
|
||||||
async move { brain::stream_reply(&http, &url, &key, &model, &history, delta_tx).await }
|
let (session_id, session_key) = (conv.session_id.clone(), cfg.session_key.clone());
|
||||||
|
async move {
|
||||||
|
let session = brain::Session {
|
||||||
|
id: session_id.as_deref(),
|
||||||
|
key: session_key.as_deref(),
|
||||||
|
};
|
||||||
|
brain::stream_reply(&http, &url, &key, &model, &messages, session, delta_tx).await
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut splitter = tts::SentenceSplitter::new(keep_tags);
|
let mut splitter = tts::SentenceSplitter::new(keep_tags);
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ fi
|
|||||||
# GUI editors (code/zed) return instantly unless forced to --wait, and if
|
# GUI editors (code/zed) return instantly unless forced to --wait, and if
|
||||||
# $EDITOR is unset no editor exists on the `nix shell` PATH, so bundle one.
|
# $EDITOR is unset no editor exists on the `nix shell` PATH, so bundle one.
|
||||||
editor="${VISUAL:-${EDITOR:-}}"
|
editor="${VISUAL:-${EDITOR:-}}"
|
||||||
|
# Zed wherever it's installed, over the shell's $EDITOR.
|
||||||
|
if command -v zeditor >/dev/null 2>&1; then
|
||||||
|
editor="zeditor"
|
||||||
|
fi
|
||||||
extra=()
|
extra=()
|
||||||
case "$editor" in
|
case "$editor" in
|
||||||
"") editor="nano"; extra=(nixpkgs#nano) ;; # sane default, bundled
|
"") editor="nano"; extra=(nixpkgs#nano) ;; # sane default, bundled
|
||||||
|
|||||||
+5
-4
@@ -1,7 +1,7 @@
|
|||||||
darman_password: ENC[AES256_GCM,data:3Kj3wfGDfS2vvTCaYC87Aq8ak2DDWqDP0YjxXk8V1CMkA2wnAP41aw++/soU0gpyMGDOY759WqRu0Wzup0Gbg4ywzQKoxbuz8Oi7mV/FxxraYsBlej0R4t+1484msrboUV4hdVdn4XdPuA==,iv:jqFcanbGXFgPNnFaZ/+TzfoUPZOJTNFcyZIGCKqC5is=,tag:bwbYiNwL79h5R30feyxpBw==,type:str]
|
darman_password: ENC[AES256_GCM,data:GWNmbLmnOgS0GLREiR9VZ55xvHavv22/VTet1b+a4Y9b00B9YEbnVR2MYPmFw7HBTI/Zv3DcDDeMmdl9OhCS+s4YC98lvOywE/CHByx13wKbjstT+nH4RBazl/64HMZ9JHP/toDh/pqREQ==,iv:UBWDWSA5vmP6DUIX7KsvVZlTu9vRuM7UbQhnpXSj4Uo=,tag:YKNfe9IAslawC08MR+jc9A==,type:str]
|
||||||
samba_password: ENC[AES256_GCM,data:4eBsiIGLdImuf7fdCItb8GIfR5A=,iv:+ryMF+7kJrDKw7qLWpP6asZzu85pFFJuOan1NMwIbr4=,tag:s8XslqPR0ptdVaOWDWRiyQ==,type:str]
|
samba_password: ENC[AES256_GCM,data:4eBsiIGLdImuf7fdCItb8GIfR5A=,iv:+ryMF+7kJrDKw7qLWpP6asZzu85pFFJuOan1NMwIbr4=,tag:s8XslqPR0ptdVaOWDWRiyQ==,type:str]
|
||||||
tailscale_authkey: ENC[AES256_GCM,data:An+OPDZF9kmemzoDhZPo7yMljksCz3yE/W9I1EAwtjXH3Iwe/L93Vr+WsWmw/mbvJFXMi2Vk20JIm6D/lm0zJe0qsd7Ooaj26h3xiAfG0PtoxUt+ABFXkQ==,iv:ShgYTnTb1VLOMYPJHjfs+LSebMI2fkKxU7wFzzFtiTo=,tag:9eSYCNKllY/xkhC1gC7hRw==,type:str]
|
tailscale_authkey: ENC[AES256_GCM,data:An+OPDZF9kmemzoDhZPo7yMljksCz3yE/W9I1EAwtjXH3Iwe/L93Vr+WsWmw/mbvJFXMi2Vk20JIm6D/lm0zJe0qsd7Ooaj26h3xiAfG0PtoxUt+ABFXkQ==,iv:ShgYTnTb1VLOMYPJHjfs+LSebMI2fkKxU7wFzzFtiTo=,tag:9eSYCNKllY/xkhC1gC7hRw==,type:str]
|
||||||
opencode_go_api_key: ENC[AES256_GCM,data:x7V6iRrP6UMvMAYh/25bcrE10MHhL9lasCYRHiQ3PIDI6aL+uXP0/YpfrRPY+60m5Yv+Bd7+9aWTWdAVu1laSNjJGg==,iv:EmEAig+fSMYX+g77UpkiQ0USxUYOfFWX4WjIj9NA9N8=,tag:Pr+EZW6uDTSGjng8iG2SZw==,type:str]
|
opencode_go_api_key: ENC[AES256_GCM,data:waNTo5pAiFgq8vh36g4TbvfTK4qBNjearG9wEzVg9oXHGqEyPzKzzun0u28WH42tIyyf,iv:4cG7ErovGJsm/KIfc++7fKmOTZFivrJhypDViDuhY+I=,tag:i/9F5rTJXZzWHvbswvw38g==,type:str]
|
||||||
telegram_bot_token: ENC[AES256_GCM,data:WX+KFtoqFodkoWNwd7EXUrUJakZ9oaMZgg4OnCeL/JVXcsdQesD1PLmKp6vK9g==,iv:m1oqKlcesvhMLtndyp/XxsUAy0YpEsSulPDK0V+Wh0A=,tag:zvLcxcQ+A4fQUht5GkL2Qw==,type:str]
|
telegram_bot_token: ENC[AES256_GCM,data:WX+KFtoqFodkoWNwd7EXUrUJakZ9oaMZgg4OnCeL/JVXcsdQesD1PLmKp6vK9g==,iv:m1oqKlcesvhMLtndyp/XxsUAy0YpEsSulPDK0V+Wh0A=,tag:zvLcxcQ+A4fQUht5GkL2Qw==,type:str]
|
||||||
hermes_dashboard_oidc_client_secret: ENC[AES256_GCM,data:IMPNTPMKO+b7eyV4hyGfnvH1/i+W4IPDNjncoyB1oIV8WaB6nOJn0sSEuTUCKB94K+Y7bsVQU0zpbKdIYOdGqgmPzwMCsScxMt4SewTmiiqWxv6SQFf4EzMxgXqjMvH8PWDzLcI2C2tI/KcVS251iqRViOTFe1/tkm+mV8sJmEI=,iv:F/rOUDmJZoGPS9fObAni5ntyOqbbhMWDPdHGLTexwlA=,tag:ALf98DmB0JziGspZMiLCiw==,type:str]
|
hermes_dashboard_oidc_client_secret: ENC[AES256_GCM,data:IMPNTPMKO+b7eyV4hyGfnvH1/i+W4IPDNjncoyB1oIV8WaB6nOJn0sSEuTUCKB94K+Y7bsVQU0zpbKdIYOdGqgmPzwMCsScxMt4SewTmiiqWxv6SQFf4EzMxgXqjMvH8PWDzLcI2C2tI/KcVS251iqRViOTFe1/tkm+mV8sJmEI=,iv:F/rOUDmJZoGPS9fObAni5ntyOqbbhMWDPdHGLTexwlA=,tag:ALf98DmB0JziGspZMiLCiw==,type:str]
|
||||||
gitea_luna_token: ENC[AES256_GCM,data:0ypW9oVFs1mXYPhPareMFRdkSYcvHSCm+fQOd7/76lJEXi217r9dmg==,iv:j3TPm/iLk6pB6CmDePFBOlnhxWSbmLKvOhz06SM1T7k=,tag:ydErvC2mZ1RRnwNffiHkkg==,type:str]
|
gitea_luna_token: ENC[AES256_GCM,data:0ypW9oVFs1mXYPhPareMFRdkSYcvHSCm+fQOd7/76lJEXi217r9dmg==,iv:j3TPm/iLk6pB6CmDePFBOlnhxWSbmLKvOhz06SM1T7k=,tag:ydErvC2mZ1RRnwNffiHkkg==,type:str]
|
||||||
@@ -10,6 +10,7 @@ couchdb_luna_password: ENC[AES256_GCM,data:V91is2h7UskI1rtwMzQyduNXoDPTYNwa4sw9K
|
|||||||
obsidian_luna_passphrase: ENC[AES256_GCM,data:fqHtP3g4J40ddYL9lzCixrisdC/DEJJermE=,iv:FU6BGNcBnyP8Rz3dNBk0+K0aAQTDW6/0aVaFm1rBFkk=,tag:Mg1aKqh++2rmU8ROaVIgDw==,type:str]
|
obsidian_luna_passphrase: ENC[AES256_GCM,data:fqHtP3g4J40ddYL9lzCixrisdC/DEJJermE=,iv:FU6BGNcBnyP8Rz3dNBk0+K0aAQTDW6/0aVaFm1rBFkk=,tag:Mg1aKqh++2rmU8ROaVIgDw==,type:str]
|
||||||
elevenlabs_api_key: ENC[AES256_GCM,data:2oJeClO4/SFsbLwRgMe3bFXrmuDX7YOc57VfSjElV5A3vaIQqfN9eHzo/cm0vISxYgUv,iv:eIeKQJ6odDnmGLjHSLV3HbErVnLr7tatOtV83TvB2QA=,tag:XPkXRfDJ2ZK98TYXKeK/CA==,type:str]
|
elevenlabs_api_key: ENC[AES256_GCM,data:2oJeClO4/SFsbLwRgMe3bFXrmuDX7YOc57VfSjElV5A3vaIQqfN9eHzo/cm0vISxYgUv,iv:eIeKQJ6odDnmGLjHSLV3HbErVnLr7tatOtV83TvB2QA=,tag:XPkXRfDJ2ZK98TYXKeK/CA==,type:str]
|
||||||
hermes_api_server_key: ENC[AES256_GCM,data:Au80iziwdryFTCLnggC9DdjjZPrGPKpmRFgkXe/l9RQ7on9nXb1dvQ==,iv:hWvv4fLkhRgVTT2btI+TvpNBHfMOg9y4BQKn+ht7XDo=,tag:2dEZEys8vsTwc7w0ZiBK1w==,type:str]
|
hermes_api_server_key: ENC[AES256_GCM,data:Au80iziwdryFTCLnggC9DdjjZPrGPKpmRFgkXe/l9RQ7on9nXb1dvQ==,iv:hWvv4fLkhRgVTT2btI+TvpNBHfMOg9y4BQKn+ht7XDo=,tag:2dEZEys8vsTwc7w0ZiBK1w==,type:str]
|
||||||
|
openrouter_api_key: ENC[AES256_GCM,data:klv/11iORtM8nbUv7RB79AyVM996V8vCU6hrTqgREnTkRW3b5PcOWXl0XdW2fr5JW4lvm6V4qYUsP62cJuVyCL3d6qA2dZCdJQ==,iv:bKMYMpbP0xsipt79sMCKuJoh5T+9GiUKwDVNZe3Sa7Q=,tag:iNOy3X0cygMlkllyWTwphg==,type:str]
|
||||||
sops:
|
sops:
|
||||||
age:
|
age:
|
||||||
- enc: |
|
- enc: |
|
||||||
@@ -30,7 +31,7 @@ sops:
|
|||||||
oyJ7PS3lW+PxH5AZkeeU7gXO/pz2oDku0aDOds7kaD3n0+qSWicQ+Q==
|
oyJ7PS3lW+PxH5AZkeeU7gXO/pz2oDku0aDOds7kaD3n0+qSWicQ+Q==
|
||||||
-----END AGE ENCRYPTED FILE-----
|
-----END AGE ENCRYPTED FILE-----
|
||||||
recipient: age1eapjg6tdrr0fuvmgs3q3nlvnjkaxez298qynqqqxt0lpcv0lrsyq7ayxjk
|
recipient: age1eapjg6tdrr0fuvmgs3q3nlvnjkaxez298qynqqqxt0lpcv0lrsyq7ayxjk
|
||||||
lastmodified: "2026-09-20T20:02:50Z"
|
lastmodified: "2026-10-02T18:30:32Z"
|
||||||
mac: ENC[AES256_GCM,data:xJVgl094qzW8YyjwDvRw4ymKjUhL3uWtbVN6J25S1Gi2I2siZ17MiUUis3dKXxb3OKq0NODP9/4pJDqWPv1qt88inu3l/6QUQMY6AybbGF7ooiiOSvGhR3jnCHpISptepNLzyHu0Iky6PkTLe5f5ETSolZ5R+Qyd66ZuFmUBjCM=,iv:u8XWCyjJo/ib9VSzi/e1FEbSjod98c1i14LykC7BEtw=,tag:ZYtrw0b3iEI+yaRtATgbkQ==,type:str]
|
mac: ENC[AES256_GCM,data:AHtMRFzzIfZQMHDaA1lV2geJ/O7CWgOJigS8IKk/8Y66H1gFQ4LPVBs86MpSaEmutSx7wzc/lTq+m0MPbVC9zoRidYjbhTzG2wbW0jxKvbPwqoBhE2x+UOTF7eWDPEKU2uttkjzlmHC2HT9G+zldEj7seW+6ElY5IQUG6WZ0Ils=,iv:Xr7iphCHeQd8sD06KQ2yo3ezvuHHDjOaDabisJUb3oc=,tag:vpbJigbu8Sek7m+rXw614A==,type:str]
|
||||||
unencrypted_suffix: _unencrypted
|
unencrypted_suffix: _unencrypted
|
||||||
version: 3.13.3
|
version: 3.13.3
|
||||||
|
|||||||
@@ -111,10 +111,8 @@ in
|
|||||||
description = ''
|
description = ''
|
||||||
Prefixed to every spoken message so luna can tell this channel from
|
Prefixed to every spoken message so luna can tell this channel from
|
||||||
Telegram or the dashboard, and adjust — no kaomoji, no markdown, short
|
Telegram or the dashboard, and adjust — no kaomoji, no markdown, short
|
||||||
answers. Put the rule in HER profile on mars rather than only in
|
answers. The rules themselves go in systemPrompt below; the marker is
|
||||||
systemPrompt below: the marker travels with the message, so it still
|
what still identifies the channel in the history Hermes keeps.
|
||||||
identifies the channel in whatever history Hermes keeps, and one place
|
|
||||||
governs her voice manners across every client that sends it.
|
|
||||||
|
|
||||||
Empty string disables the marker.
|
Empty string disables the marker.
|
||||||
'';
|
'';
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ in
|
|||||||
FTLCONF_dns_hosts = "10.0.0.10 mercury.sol;10.0.0.20 jupiter.sol";
|
FTLCONF_dns_hosts = "10.0.0.10 mercury.sol;10.0.0.20 jupiter.sol";
|
||||||
# Wildcard: any <service>.jupiter.sol -> jupiter (caddy routes by hostname).
|
# Wildcard: any <service>.jupiter.sol -> jupiter (caddy routes by hostname).
|
||||||
FTLCONF_misc_dnsmasq_lines = "address=/jupiter.sol/10.0.0.20";
|
FTLCONF_misc_dnsmasq_lines = "address=/jupiter.sol/10.0.0.20";
|
||||||
|
# Steam's query bursts got terra rate-limited; both 0 disables the limit.
|
||||||
|
FTLCONF_dns_rateLimit_count = "0";
|
||||||
|
FTLCONF_dns_rateLimit_interval = "0";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user