Some checks are pending
ci / test (push) Waiting to run
Unifies AI-first administration across the CLI (sys) and desktop GUI
(phoebus-assistant) through a shared service layer, fixes installed
desktop QML asset provisioning, adds Polkit elevation, and introduces
contextual conversation continuity.
- Extract phoebus_installer::service shared by CLI and desktop assistant bridge:
- Reviewable plan staging (PreparedPlan) with SHA-256 cryptographic digests,
15-minute TTL expiration, and replay prevention (PlanStore).
- Pre-mutation system state revalidation binding execution strictly to the reviewed plan.
- Honest recommendations displaying genuine provenance and unmeasured compile times.
- Two-phase transaction logging (begin before mutation, finish with verification).
- Provision installed desktop assets and Polkit policy in phoebus-executor::desktop:
- Added gui-apps/quickshell to canonical Mango desktop packages.
- Embed 13 QML and policy files into target root under /usr/share/phoebus/assistant/.
- Installed Polkit policy (club.phoebus.sys.policy) allowing unprivileged users to
authenticate mutating plans via pkexec without blanket passwordless sudo.
- Eliminate startup freeze and polling in phoebus-assistant:
- Multi-source update queries moved to on-demand tab switching.
- Handshake timer reduced to one-shot 100ms with fast deterministic check.
- Add phoebus_installer::conversation:
- Bounded 10-turn history with credential redaction.
- Contextual follow-up resolution for comparisons, backend switching, and confirmation.
- Implement unified cross-source removal (plan_removal) preserving user data by default.
- Verified: all 486 workspace tests pass, release and crt-static builds succeed,
and 23/23 VM acceptance cases pass (PASS=23 FAIL=0).
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/local/bin/sys", "--assistant-bridge"];
|
|
}
|
|
|
|
Timer {
|
|
interval: 100
|
|
repeat: false
|
|
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(planId, digest, yes, cb) {
|
|
call("execute", { plan_id: planId, 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);
|
|
}
|
|
}
|
|
}
|
|
}
|