Some checks are pending
ci / test (push) Waiting to run
- Default natural-language and conversational routing for sys install, sys please install, and sys ask through shared AI workflow - Constrain AI candidate evaluation when source flags are supplied without bypassing the model - Enforce explicit --legacy flag for deterministic administration; legacy install without a source flag refuses execution and offers choices - Audit --action and --action-file entry points to require --legacy or --broker - Provide truthful guidance on absent or failing AI models without silent mutation or unverified fallback - Implement package correctness safeguards: Nix attribute evaluation probe, Portage binary check with source compile abort guard, cross-source installed application tracking, and data preservation on removal - Provide Quickshell desktop assistant (phoebus-assistant) backed by stdio JSON-RPC bridge (sys --assistant-bridge) and desktop integration - Implement unified multi-source update checking across all package lanes - Implement quiet proactive assistance monitor with alert deduplication and snoozing - Expand acceptance suite in installer/tests/vm/sys-acceptance.sh to 22 cases (22/22 PASS)
175 lines
4.7 KiB
Bash
175 lines
4.7 KiB
Bash
pragma Singleton
|
|
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Io
|
|
|
|
// Typed JSON-RPC bridge to `sys --assistant-bridge`.
|
|
// Shares the exact same deterministic and AI admin broker with the CLI.
|
|
Singleton {
|
|
id: root
|
|
|
|
property bool ready: false
|
|
property bool crashed: false
|
|
property string lastError: ""
|
|
property var handshake: null
|
|
|
|
property var pending: ({})
|
|
property int nextId: 1
|
|
|
|
signal event(string name, var data)
|
|
signal handshakeReady()
|
|
|
|
readonly property var bridgeCommand: {
|
|
const override = Quickshell.env("PHOEBUS_ASSISTANT_BRIDGE_CMD");
|
|
if (override && override.length > 0)
|
|
return override.split(" ").filter(part => part.length > 0);
|
|
return ["/usr/bin/sudo", "-n", "/usr/local/bin/sys", "--assistant-bridge"];
|
|
}
|
|
|
|
Timer {
|
|
interval: 400
|
|
repeat: true
|
|
running: proc.running && root.handshake === null
|
|
onTriggered: root.refreshHandshake(null)
|
|
}
|
|
|
|
function start() {
|
|
if (!proc.running)
|
|
proc.running = true;
|
|
}
|
|
|
|
function stop() {
|
|
if (proc.running)
|
|
proc.running = false;
|
|
}
|
|
|
|
function call(op, payload, onDone) {
|
|
const id = root.nextId++;
|
|
if (onDone)
|
|
root.pending[id] = onDone;
|
|
const request = Object.assign({ id: id, op: op }, payload || {});
|
|
const line = JSON.stringify(request) + "\n";
|
|
if (!proc.running) {
|
|
delete root.pending[id];
|
|
root.lastError = "backend not running";
|
|
if (onDone)
|
|
onDone({ ok: false, error: "The assistant broker is not running." });
|
|
return;
|
|
}
|
|
proc.write(line);
|
|
}
|
|
|
|
function handleLine(line) {
|
|
const text = ("" + line).trim();
|
|
if (text.length === 0)
|
|
return;
|
|
let msg;
|
|
try {
|
|
msg = JSON.parse(text);
|
|
} catch (e) {
|
|
console.log("assistant-bridge: unparsable line: " + text);
|
|
return;
|
|
}
|
|
if (msg.id !== undefined && root.pending[msg.id]) {
|
|
const cb = root.pending[msg.id];
|
|
delete root.pending[msg.id];
|
|
cb(msg);
|
|
}
|
|
}
|
|
|
|
function refreshHandshake(cb) {
|
|
call("handshake", {}, reply => {
|
|
if (reply.ok) {
|
|
root.handshake = reply.result;
|
|
root.handshakeReady();
|
|
}
|
|
if (cb)
|
|
cb(reply);
|
|
});
|
|
}
|
|
|
|
function ask(query, backend, cb) {
|
|
call("ask", { request: query, backend: backend }, cb);
|
|
}
|
|
|
|
function execute(actions, digest, yes, cb) {
|
|
call("execute", { actions: actions, digest: digest, yes: yes }, cb);
|
|
}
|
|
|
|
function legacyInstall(application, backend, cb) {
|
|
call("legacy_install", { application: application, backend: backend }, cb);
|
|
}
|
|
|
|
function legacyExecute(phrase, action, yes, cb) {
|
|
call("legacy_execute", { phrase: phrase, action: action, yes: yes }, cb);
|
|
}
|
|
|
|
function getUpdates(cb) {
|
|
call("updates", {}, cb);
|
|
}
|
|
|
|
function getProactiveAlerts(cb) {
|
|
call("proactive_alerts", {}, cb);
|
|
}
|
|
|
|
function snoozeAlerts(durationSeconds, cb) {
|
|
call("proactive_snooze", { duration_seconds: durationSeconds }, cb);
|
|
}
|
|
|
|
function dismissAlert(fingerprint, cb) {
|
|
call("proactive_dismiss", { fingerprint: fingerprint }, cb);
|
|
}
|
|
|
|
function getPreferences(cb) {
|
|
call("get_preferences", {}, cb);
|
|
}
|
|
|
|
function setPreferences(prefs, cb) {
|
|
call("set_preferences", { preferences: prefs }, cb);
|
|
}
|
|
|
|
function getHistory(cb) {
|
|
call("history", {}, cb);
|
|
}
|
|
|
|
function undo(snapshot, cb) {
|
|
call("undo", { snapshot: snapshot, yes: true }, cb);
|
|
}
|
|
|
|
Process {
|
|
id: proc
|
|
command: root.bridgeCommand
|
|
stdinEnabled: true
|
|
running: false
|
|
|
|
onStarted: {
|
|
root.ready = true;
|
|
root.crashed = false;
|
|
root.refreshHandshake(null);
|
|
}
|
|
|
|
onExited: exitCode => {
|
|
root.ready = false;
|
|
root.crashed = true;
|
|
const ids = Object.keys(root.pending);
|
|
for (let i = 0; i < ids.length; i++) {
|
|
const cb = root.pending[ids[i]];
|
|
delete root.pending[ids[i]];
|
|
try {
|
|
cb({ ok: false, error: "The assistant bridge stopped (exit " + exitCode + ")." });
|
|
} catch (e) {}
|
|
}
|
|
}
|
|
|
|
stdout: SplitParser {
|
|
onRead: line => root.handleLine(line)
|
|
}
|
|
|
|
stderr: SplitParser {
|
|
onRead: line => {
|
|
root.lastError = line;
|
|
console.log("assistant-bridge err: " + line);
|
|
}
|
|
}
|
|
}
|
|
}
|