The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Isolate shared machine access and document verified harness sharing
Dee21d39eec036b
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dartindex 5e2904c45..9b2f136f4 100644--- a/desktop/lib/screens/swarm_screen.dart+++ b/desktop/lib/screens/swarm_screen.dart@@ -505,15 +505,16 @@ class _SwarmScreenState extends State<SwarmScreen> {DateTime? _localModelsAt;Future<void> _refreshLocalModels() async {- final machines = app.machines;+ final machines = app.machines.where((machine) => !machine.isShared).toList();if (machines.isEmpty) return;// The daemon memoises its answer, so a repeat is nearly free — but this is called on every app// change, and an RPC per keystroke-sized notification is not free. One read per window is// plenty for a list that changes when someone starts or stops serving a model.final now = DateTime.now();final last = _localModelsAt;- if (last != null && now.difference(last) < const Duration(seconds: 10))+ if (last != null && now.difference(last) < const Duration(seconds: 10)) {return;+ }_localModelsAt = now;final preferred = machines.firstWhere((m) => app.stateOf(m.machineId)?.isLocalMachine == true,diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dartindex 4bb0903bf..29b000f4c 100644--- a/desktop/lib/state/app_state.dart+++ b/desktop/lib/state/app_state.dart@@ -3709,6 +3709,9 @@ class AppNotifier extends ChangeNotifier {}WsConn _conn(String machineId) {+ if (machineStates[machineId]?.machine.isShared == true) {+ throw StateError('This harness is shared with view-only access.');+ }final testConnection = connectionForTest;if (testConnection != null) return testConnection(machineId);// The local-manual dev fixture exercises a locally-run backend+node stack directly (no realdiff --git a/desktop/test/machines_menu_test.dart b/desktop/test/machines_menu_test.dartindex 8281f663b..37dba2ad7 100644--- a/desktop/test/machines_menu_test.dart+++ b/desktop/test/machines_menu_test.dart@@ -27,6 +27,32 @@ class _RecordingApi extends ApiClient {}void main() {+ test(+ 'shared machines never enter the general machine connection path',+ () async {+ var requestedConnections = 0;+ final app = createApp(+ connectionForTest: (_) {+ requestedConnections++;+ throw StateError('A shared machine requested a full connection');+ },+ );+ const shared = Machine(+ machineId: 'shared',+ authMode: MachineAuthMode.remote,+ isShared: true,+ );+ app.machines.add(shared);+ app.machineStates['shared'] = MachineState(shared);+ await expectLater(app.listRemoteFolder('shared', '/'), throwsStateError);+ final restart = await app.restartAgent('shared', 'shared-agent');+ expect(restart.error, contains('view-only'));+ await app.gridModels('shared');+ expect(requestedConnections, 0);+ app.dispose();+ },+ );+testWidgets('shared machines expose only invited agents and carry a view-only owner label',(tester) async {diff --git a/docs/plans/2026-09-17-002-share-harness-plan.md b/docs/plans/2026-09-17-002-share-harness-plan.mdindex 85dc9460c..8431a025c 100644--- a/docs/plans/2026-09-17-002-share-harness-plan.md+++ b/docs/plans/2026-09-17-002-share-harness-plan.md@@ -1,17 +1,22 @@# Share a harness-Status: implementation in `codex/share-harness`.+Status: implemented and pushed in `codex/share-harness`; verified locally on 2026-09-18.## ExperienceThe agent pane offers **Share harness**. Its owner enters one or more email addresses and grants**Can view** access. The dialog lists recipients, expiry, and active observers and supports removal.Invitations are account-bound and appear in the recipient's app, including after first sign-in.+The app discovers invitations every 15 seconds. The dialog supports 7-, 30- and 90-day invitations,+normalizes and deduplicates addresses, reports pending or failed synchronization, and shows who is+watching. This version grants access inside Harness; it does not send invitation emails.Machines has **Your machines** and **Shared with you** sections. Shared machines carry an owner labeland a distinct icon. Their submenus contain only harnesses shared with the signed-in recipient.Opening one shows a live terminal and viewer with a persistent **View only** indicator. Disconnectspreserve the pane and recover automatically. Revocation immediately ends access.+Wide panes show terminal and viewer side by side; narrow panes offer Terminal and Viewer tabs.+The owner keeps terminal control and dimensions while observers join and leave.## Boundaries@@ -23,16 +28,49 @@ preserve the pane and recover automatically. Revocation immediately ends access.- The owner daemon keeps its own durable grant allow-list. Backend metadata alone cannot grant access.- Live viewer images are rendered on the owner's machine. The observer gets pixels, never a proxyto a local viewer's APIs. Renderers use a separate browser profile without the owner's credentials.+- Shared machines cannot enter the desktop's general machine connection path. Model discovery,+ new-harness creation and management controls use owned machines only.- Publishing results and collaborative input are separate future work.## Verification-Cover invite normalization and validation, owner/recipient authorization, duplicate and pending-invitations, discovery filtering, simultaneous observers, encryption and replay rejection, denied-input/resize/file access, immediate revocation, expiry, reconnect, offline state, terminal fidelity,-viewer updates, and existing owner controls. Measure coverage of the new feature modules and report-the actual numbers. Exercise real sockets and a disposable tmux session as well as desktop widgets;-keep test identities, daemons and runtime data isolated from the user's running sessions.+Verified invite validation, owner/recipient authorization, duplicate and pending invitations, discovery+filtering, simultaneous observers, encryption and replay rejection, denied input/resize/file access,+revocation, expiry, reconnect, offline state, terminal fidelity, viewer updates and owner controls.+Test identities, daemons and runtime data were isolated from existing sessions.++| Check | Result |+| --- | --- |+| CLI sharing modules | 35 tests pass; 100% statements (466), branches (285), functions (102), lines (306) |+| Backend sharing routes and observer socket | 17 tests pass; 100% statements (141), branches (84), functions (35), lines (99) |+| Sharing UI and affected desktop regressions | 61 tests pass across 8 files, including real loopback WebSockets |+| Share dialog line coverage | 164/164 (100%) |+| Observer pane line coverage | 161/166 (97%); remaining lines are fallback transport callbacks |+| Full backend suite | 440 pass, 11 optional tests skipped |+| TypeScript type checks | CLI and backend pass |+| Desktop analysis | No issues in the 17 analyzed implementation/test targets |+| macOS app | Debug build succeeds using Flutter 3.47.2 with Swift Package Manager |+| Real stack | Passes with production backend, three daemons, MongoDB, Redis, tmux and Chrome |++The 100% thresholds apply to the named sharing modules, not the entire repository or all changed+integration code. `npm run test:sharing` in `cli` and `backend` enforces all four thresholds.++The complete CLI run had 2,959 passes, 52 skips and 6 failures. Two login timeouts and three offline-hook+failures reproduce on the untouched base commit `e077d176`; the sixth (Grok offline registry) passes+when rerun in isolation. The complete desktop run had 1,941 passes, 2 skips and 6 failures: five+sharing-related discovery/header expectations were corrected and pass in the final targeted run.+The remaining terminal-input batching failure also reproduces on `e077d176`. These baseline failures+remain; the repository-wide suites are not claimed green.++Reproduce desktop verification from `desktop`:++```sh+flutter test --no-pub --coverage test/share_harness_test.dart test/shared_harness_panel_test.dart test/api_client_test.dart test/machines_menu_test.dart test/profile_startup_test.dart test/pane_machine_unknown_test.dart test/terminal_panel_presentation_test.dart test/swarm_interactions_test.dart+FLUTTER_SWIFT_PACKAGE_MANAGER=true DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer flutter build macos --debug --no-pub+```++Set `HARNESS_SHARE_SCREENSHOT=/tmp/sharing.png` when running the dialog test to export its rendered+invitation state. The dialog was visually reviewed with the app's real fonts.### Real stack verification@@ -43,9 +81,23 @@ live viewer. The test checks invitation discovery, two viewers, unchanged ownerblocked input/resize/deletion, changing viewer pixels, reconnect, immediate revocation, offlinediscovery, and durable permissions after restarting the owner daemon.-Run from `cli` with `HARNESS_SHARE_E2E_SERVICES=/path/to/services.json node --import tsx scripts/share-harness-e2e.ts`.+Run from `cli` with `HARNESS_SHARE_E2E_SERVICES=/path/to/services.json npm run test:sharing-e2e`.The JSON contains `mongo` and `redis` URLs for **disposable loopback services**; the test creates a uniqueMongo database and isolates every daemon, identity, project, browser profile and terminal.Set `HARNESS_SHARE_KEEP=1` to retain logs on success. Failure logs are always retained.-This flow passed locally on 2026-09-17 with MongoDB 7.0.15, Redis 7.4.0, tmux and Chrome.+This flow passed locally with MongoDB 7.0.15, Redis 7.4.0, tmux and Chrome, including a final run on+2026-09-18. Disposable services were stopped after verification.++## Runtime requirements++Ship the backend, CLI and desktop changes together. The existing backend startup schema step creates+the new MongoDB collection and indexes; the new Prisma client must be generated during the build.+An older daemon or backend returns an actionable update message in the sharing dialog.++Terminal observation requires the owner's daemon to be online. Live viewer images additionally need+Chrome, Chromium or Brave on that machine; `HARNESS_VIEWER_BROWSER` can point to another compatible+executable. Missing browser support is explained in the viewer while terminal observation continues.+The viewer runs in a fresh browser profile, so authenticated pages may show a sign-in screen. Capture+is fixed at 1280×800, updates approximately every 400 ms, and shares one renderer among recipients of+the same harness, with at most eight active harness renderers per owner.