Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

Merge remote-tracking branch 'origin/main' into HEAD

reviewc85081618078
diff --cc src/main/index.ts
index c9428005e,bd1afba7d..460218170
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@@ -4267,18 -4311,8 +4311,18 @@@ app.whenReady().then(async () =>
// NEW interactive relay host (Stage 4): a connecting peer desktop becomes a first-class
// CorePlatform client of this desktop after mutual SAS approval. Runs BESIDE initRemoteHost (the
// phone still uses the legacy flow). Inert until `relay:host:start` — a solo user pays nothing.
- // Revocation reaches its sessions via `killRelayHostsByPeerKey` (peerRevoker, above).
+ // Revocation reaches its sessions via the peer-revoke.ts registry (relay-host.ts registers).
- initRelayHost(win, corePlatform, {})
+ initRelayHost(win, corePlatform, {
+ // A project-scoped seat is judged message by message against THIS core's own records: which
+ // projects hold a node (persisted canvases), which node a live session runs, and the project's
+ // local folder. Never anything the peer sends. See core/relay/scoped-guest-policy.ts.
+ scope: {
+ projectsOfNode: (nodeId) => workspaceStore.projectIdsForNode(nodeId),
+ nodeOfSession: (sessionId) => ptyManager.nodeOfSession(sessionId),
+ projectCwd: (projectId) => workspaceStore.localCwdForProject(projectId),
+ hostDataDir: app.getPath('userData')
+ }
+ })
// Standing (phone) relay host: keep a host connection registered so a paired phone can reach
// this Mac from anywhere. Honors settings.phoneAccessEnabled internally.
const standingHost = initStandingHost(win, ptyManager, () => settingsStore.get(), listProjectsOutput, hostBridge)
diff --cc src/main/remote/relay-host-service.ts
index e023f4787,65d8cbd11..c611461b9
--- a/src/main/remote/relay-host-service.ts
+++ b/src/main/remote/relay-host-service.ts
@@@ -36,7 -37,7 +37,8 @@@ import { loadOrCreatePeerKeyPair } fro
import { isPremium as licenseIsPremium, getStoredEntitlement, licensedSeats as licenseSeats } from '../../core/license'
import { RELAY_URL, relayAllowed as hostRelayAllowed, mintPairingToken } from './host-service'
import { canAcceptSeat } from './seat-cap'
+import type { ScopedGuestDeps } from '../../core/relay/scoped-guest-policy'
+ import { revokePeerKey } from './peer-revoke'
/** Thrown (as an Error message) when a new invite would exceed the licensed seat cap. The renderer
* maps it to "All seats in use — add a seat." Host-side/UX enforcement only (see below). */
diff --cc src/main/remote/relay-host.test.ts
index 86f2e48f7,32104f3ba..624cb8f91
--- a/src/main/remote/relay-host.test.ts
+++ b/src/main/remote/relay-host.test.ts
@@@ -648,43 -654,18 +671,57 @@@ describe('relay host — teardown mirro
// A stranger's key cuts nothing.
killRelayHostsByPeerKey('some-other-key')
})
+
+ it('the shared revoke primitive (peer-revoke.ts) reaches Team Access sessions and unpins the guest', async () => {
+ const s = openHostAgainstFakeRelay()
+ await s.openMutually()
+ const id = s.session.clientId()!
+ await vi.waitFor(() => expect(disk.pubkeys).toEqual([s.peerKeyB64])) // pinned as a GUEST
+ expect(otherPins.phone?.pubkeys ?? []).toEqual([]) // never as a phone
+
+ expect(await revokePeerKey(s.peerKeyB64, ['guest'])).toEqual({ persisted: true, killed: true })
+
+ expect(disk.pubkeys).toEqual([])
+ expect(peerRegistry().ids()).not.toContain(id)
+ expect(gone).toEqual([id])
+ })
})
+
+describe('relay host — a project-scoped session is a boundary (scoped-guest-policy)', () => {
+ it('refuses to open a scoped session with no scope policy', () => {
+ expect(() =>
+ connectRelayHost({
+ url: 'wss://relay.example', token: 'tok', ourKeys: genKeyPair(), platform,
+ transport: { bufferedAmount: 0, send: () => {}, close: () => {}, onMessage: () => {}, onClose: () => {} },
+ sharedProjectId: 'proj-1',
+ onPeerPending: () => {}, onOpen: () => {}, onClose: () => {}
+ })
+ ).toThrow(/scope policy/)
+ })
+
+ it('refuses files outside the shared folder, settings:save and an unknown channel before dispatch', async () => {
+ const reached: string[] = []
+ for (const m of [IPC.fsRead, IPC.settingsSave, 'brand:new-channel']) {
+ platform.handle(m, async () => { reached.push(m); return 'x' })
+ }
+ const s = openHostAgainstFakeRelay({ sharedProjectId: 'proj-1' })
+ await s.openMutually()
+ s.peerSendsTunnelText(JSON.stringify({ t: 'req', id: 401, method: IPC.fsRead, args: ['/etc/hosts'] }))
+ s.peerSendsTunnelText(JSON.stringify({ t: 'req', id: 402, method: IPC.settingsSave, args: [{}] }))
+ s.peerSendsTunnelText(JSON.stringify({ t: 'req', id: 403, method: 'brand:new-channel', args: [] }))
+ await vi.waitFor(() =>
+ expect(s.textFrames.map((f) => JSON.parse(f)).filter((m) => m.id >= 401 && m.ok === false)).toHaveLength(3)
+ )
+ expect(reached).toEqual([])
+ })
+
+ it('an unscoped session still reaches files (full access, as its invite copy says)', async () => {
+ platform.handle(IPC.fsRead, async () => 'contents')
+ const s = openHostAgainstFakeRelay()
+ await s.openMutually()
+ s.peerSendsTunnelText(JSON.stringify({ t: 'req', id: 404, method: IPC.fsRead, args: ['/etc/hosts'] }))
+ await vi.waitFor(() =>
+ expect(s.textFrames.map((f) => JSON.parse(f)).find((m) => m.id === 404)).toMatchObject({ ok: true, result: 'contents' })
+ )
+ })
+})
diff --cc src/main/remote/relay-host.ts
index cc8ea9561,086720f3a..cbe981e78
--- a/src/main/remote/relay-host.ts
+++ b/src/main/remote/relay-host.ts
@@@ -42,8 -41,8 +43,9 @@@ import { recordApproval } from '../../c
import type { ElectronPlatform } from '../platform-electron'
import { registerPeerSink, unregisterPeerSink } from '../peer-registry'
import { allocateRelayClientId, presenceHub } from '../../core/presence/hub'
- import { updateApprovedDevices } from './approved-devices'
+ import { guestPins } from './approved-devices'
+ import { registerPeerSessionKiller } from './peer-revoke'
+import { scopedGuestHooks, type ScopedGuestDeps } from '../../core/relay/scoped-guest-policy'
export { killRelayHostsByPeerKey }
diff --cc src/shared/host-control.ts
index 925a34601,4e7dfce9f..25ada496c
--- a/src/shared/host-control.ts
+++ b/src/shared/host-control.ts
@@@ -74,20 -55,9 +74,23 @@@ export const HOST_ONLY_CHANNELS: Readon
IPC.agentBoardCommentDeliver,
IPC.stationNoticeDropped,
IPC.stationNoticeList,
+ // Unscoped: every project's station outcomes and their notes. A relay guest bound to one project
+ // must not read another's, and a relay tab's launch loop is refused anyway (its stub is inert).
- IPC.stationOutcomeList
++ IPC.stationOutcomeList,
+ // The host's settings. `settings:save` is the dangerous half: `modelGateway.baseUrl` is the TRUST
+ // ANCHOR `agent:discover-models` uses to decide whether it may resolve the stored
+ // `${secret:model-gateway-api-key}` (core/agent-env-ipc.ts), so a peer that could save settings
+ // and then ask for discovery would have the keychain-held key sent to a URL of its choosing.
+ // `settings:load` goes too: settings.json carries custom agents' launch env (API keys), and a
+ // relay tab keeps its settings LOCAL (relay-api.ts), so no legitimate peer reads the host's.
+ IPC.settingsLoad,
+ IPC.settingsSave,
+ // Model-gateway discovery and the write-only gateway credential. Discovery resolves host-side
+ // secrets against the saved gateway; the credential verbs write/clear the keychain-held key.
+ IPC.agentDiscoverModels,
+ IPC.agentGatewayCredentialStatus,
+ IPC.agentGatewayCredentialSave,
+ IPC.agentGatewayCredentialClear
])
/** What a refused peer is told. One wording, so the two shells answer identically. */