Skip to content

AI Bridge: let an assistant change a server, with permission - #15

Merged
dhivadhiva merged 9 commits into
mainfrom
feature/ai-bridge-1.7
Nov 16, 2026
Merged

dhivadhiva merged 9 commits into
mainfrom
feature/ai-bridge-1.7

Conversation

@dhivadhiva

Copy link
Copy Markdown
Contributor

What this adds

1.6.0 let a paired assistant read from the hosts the user shares. This
lets it change them, and only with the user's yes. Everything new ships
off, and a shared host stays read-only until the user switches more on.

  • Tools: run_command, write_file, service_action, run_on_hosts,
    and a terminal (open_terminal, send_input, read_screen,
    close_terminal).
  • A change needs approval on a card in the app that shows exactly what
    will run, with hidden and direction-changing characters made visible.
    Deny has the focus, the Allow buttons wait a second, and an unanswered
    card is a denial after two minutes.
  • Two exceptions the user sets up beforehand: an exact-match list of
    allowed commands per host, and an approval for a limited time given on
    a card. A timed approval covers every change tool on that host for
    that assistant. A terminal always asks.
  • Per host: "Share with AI assistants", "Let the assistant request
    changes", "Allowed commands", "Full control terminal". In Settings:
    "Allow for a while" and "Approvals in force". Nine languages.

How it stays safe

  • One policy function still decides every call. Hosts and settings are
    read again after planning and after a yes, so a host edited while its
    card waited, or stepped down meanwhile, is refused.
  • Approvals, timed approvals and terminals end at once when the bridge
    goes off, the app locks, the assistant is revoked or the host changes
    (address, port, user, connection type or jump host).
  • The command on the card is the string that is matched against the
    allowed list and the string that runs.
  • A file is written through a temporary file with a random name, and is
    refused if it changed after the card.
  • A stop sends TERM, then KILL. Changes have their own run slots.
  • No bridge connection carries the user's SSH agent or X11, and the
    bridge does not borrow an open session that forwards either.
  • Commands are quoted so a fish login shell cannot reopen a value.

Changes outside the bridge

  • HostStore.changes, a stream of the host list after each change.
  • SessionManager.open(activate:) and a marker on a session an
    assistant drives. Nothing changes for ordinary sessions.
  • SystemdCommands.reload.
  • Settings helpers built on copyWith, so a field added later is kept.
  • Tests that waited a fixed time for a save now wait for the save. This
    is what fails on main on Linux arm64 and Windows x64.

Tested

  • flutter analyze: no issues
  • flutter test: 5828 passed, 491 skipped
  • Real sshd on Linux (SSGO_SSHD=1): 36 passed, including a planted
    link at the temp file's name, a command that ignores TERM, the
    terminal end to end, and no agent socket in a bridge command
  • Live through the launcher and the running app: an allowed command ran
    with no card; a near miss, a file write and a service action each
    waited for approval and ran nothing when cancelled; the terminal and
    unknown hosts were refused; the activity log recorded each call
  • Local CI on a clean checkout

Not verified

  • A person approving a card by hand. The card is covered by widget
    tests, including keys held down and clicks already in flight.
  • Anything on Windows beyond what CI runs.
  • A host whose login shell is fish. The quoting is checked on sh and
    bash and against a model of fish's rules.
  • The eight translations, which were not read by native speakers.
  • See store/release-checklist-1.7.md.

Known limits

  • The card does not alert a backgrounded app; unanswered, it is denied.
  • An approved terminal is a live shell as the sign-in user. The
    blocked-path list does not apply inside it.
  • A process that moves into its own session survives a stop.
  • A file changed to the same size within the same second is not noticed.
  • macOS and Android do not have the bridge.

Overlap with open PRs

This branch contains the fixes in #13 (backups keep every setting) and
#14 (fish quoting). Whichever lands second will need a small merge.

Before release

Version strings still say 1.6.0, and the plugin is already at 1.7.0.

The server's sshd hands the whole command line to the account's login
shell. Values were embedded in POSIX single quotes, where nothing is
special. fish reads a backslash inside single quotes as an escape, so a
value ending in a backslash escaped its closing quote and the rest of
the line could be re-read by the shell. Paths and file-name patterns
come from the assistant, so on a host whose login shell is fish a
read-only tool could be made to run text the app did not intend.

The outer command line is now quoted so that no backslash is ever left
inside single quotes. Text read by /bin/sh inside the wrapper keeps
POSIX quoting, which is correct there. A comment says which shell reads
which layer.

Tested against real sh and bash with hostile values. fish is not
installed where this was written, so its rules are checked against a
model; a test runs the same check through real fish when it is present.
1.6.0 let a paired assistant read from the hosts the user shares. This
lets it change them, and only with the user's yes. Everything new ships
off, and a shared host stays read-only until the user switches more on.

- Tools: run_command, write_file, service_action, run_on_hosts, and a
  terminal (open_terminal, send_input, read_screen, close_terminal).
- A change needs the user's approval on a card in the app that shows
  exactly what will run, with hidden and direction-changing characters
  made visible. Deny has the focus, the Allow buttons wait a second,
  and an unanswered card is a denial after two minutes.
- Two exceptions the user sets up beforehand: an exact-match list of
  allowed commands per host, and an approval for a limited time given
  on a card. A terminal always asks.
- One policy function still decides every call. Hosts and settings are
  read again after planning and after a yes, so a host edited while its
  card waited, or stepped down meanwhile, is refused. Approvals, timed
  approvals and terminals end at once when the bridge goes off, the app
  locks, the assistant is revoked or the host changes.
- A file is written through a temporary file with a random name and is
  refused if it changed after the card. A stop sends TERM, then KILL.
  Changes have their own run slots, apart from reads.
- No bridge connection carries the user's SSH agent or X11, and the
  bridge does not borrow an open session that forwards either.
- Commands are quoted so a fish login shell cannot reopen a value.
- Per-host switches, the allowed-command editor, "Allow for a while",
  the list of approvals in force, the banner on an assistant's terminal
  and the activity labels, in nine languages.
- Skill, architecture notes, privacy policy, change notes and the 1.7
  release checklist. Plugin version 1.7.0.

Also: tests that waited a fixed time for a save now wait for the save,
which is what failed on slower runners.
dhivadhiva and others added 7 commits November 16, 2026 14:05
…e wait

The wrapper around every bridge command has a watcher that sends it
USR1 when stdin reaches end-of-file, which is how a stop is signalled.
A trapped signal cuts a shell's `wait` short with a status above 128,
so if USR1 arrived while the wrapper waited for the command, it exited
138 whatever the command's status was.

The wrapper now repeats the wait until the command has really been
reaped. A command that died of a signal is already reaped, so its own
status stands.

The test that caught this started its command with stdin at
end-of-file, so the watcher raced the command; it now holds stdin open
as the app does. New tests pin both sides: stdin held open gives the
command's status, and stdin closed from the start is a stop.
The test ran the supervised wrapper with its input already at
end-of-file. That is the wrapper's stop signal, so on a slow runner the
command was ended before it printed and the test failed. Run it as the
app does, with the input held open until the command has finished.
The backup fix, the fish quoting fix and the departed-peer fix all ship
in 1.6.0, so their notes move from docs/changes into the 1.6.0 section
of CHANGELOG.md. The release date is 16 November 2026 in the changelog,
the Debian changelog, the Flatpak metadata and the privacy policy.
Version 1.7.0+17 in pubspec.yaml (and the MSIX version), the snap, the
About box and the Flatpak metadata, with a new Debian changelog entry.
The AI Bridge notes move from docs/changes into CHANGELOG.md under
1.7.0, dated 16 November 2026. The README names 1.7.0 as the latest
release.
@dhivadhiva
dhivadhiva merged commit 5c6d152 into main Nov 16, 2026
27 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant