Skip to content

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.

Answer scm_project_info beside git_project_info

Adam Hafez3aecfe274b0c
diff --git a/cli/src/backendSocket.spec.ts b/cli/src/backendSocket.spec.ts
index dcdbc573b..a8e797d0a 100644
--- a/cli/src/backendSocket.spec.ts
+++ b/cli/src/backendSocket.spec.ts
@@ -18,6 +18,7 @@ import { AgentStopError } from './lib/stopAgentService.js'
import type { PurgeAgentService } from './lib/purgeAgentService.js'
import * as mediaPreview from './lib/mediaPreview.js'
import * as gitProject from './lib/gitProject.js'
+import * as scmProjects from './scm/scmProjects.js'
import * as machineResources from './lib/machineResources.js'
import * as projectFolder from './lib/projectFolder.js'
import * as claudeTrust from './lib/claudeTrust.js'
@@ -1012,6 +1013,54 @@ describe('BackendSocket outbound queue', () => {
await socket.stop()
})
+ it.each([false, true])('answers scm_project_info (refresh=%s) through the SCM seam, to the requesting encrypted connection only', async refresh => {
+ const preview = { kind: 'git' as const, git: { isGit: true, root: '/remote/workspace', branch: 'main', branches: [{ ref: 'refs/heads/private-branch', name: 'private-branch', remote: false }] } }
+ const detect = vi.spyOn(scmProjects, 'detectScmProject').mockResolvedValue(preview)
+ const socket = new BackendSocket('token')
+ socket.connect()
+ const ws = wsMock.instances[0]
+ ws.open()
+ vi.spyOn(socket.e2ee, 'unwrapDown').mockReturnValue({ type: 'scm_project_info', payload: {
+ requestId: 'preview-2', path: '/remote/workspace', refresh,
+ } })
+ vi.spyOn(socket.e2ee, 'hasSession').mockReturnValue(true)
+ const wrap = vi.spyOn(socket.e2ee, 'wrapRpcReply').mockReturnValue({
+ type: 'scm_project_info_result', payload: { __e2e: { v: 1, k: 'p', n: 1, ct: 'encrypted-preview' } },
+ })
+ ws.message({ t: 'down', connId: 'viewer-a', frame: {
+ type: 'scm_project_info', payload: { __e2e: { v: 1, k: 'p', n: 1, ct: 'encrypted-request' } },
+ } })
+ await vi.waitFor(() => expect(wrap).toHaveBeenCalledWith('viewer-a', 'scm_project_info_result', 'preview-2', preview))
+ // The same fence git_project_info passes: no registered agents here, so the home folder alone.
+ expect(detect).toHaveBeenCalledWith('/remote/workspace', { refresh, knownRoots: [] })
+ expect(parseSent(ws)).toContainEqual(expect.objectContaining({ targetConnId: 'viewer-a', frame: {
+ type: 'scm_project_info_result', payload: { __e2e: { v: 1, k: 'p', n: 1, ct: 'encrypted-preview' } },
+ } }))
+ expect(JSON.stringify(parseSent(ws))).not.toContain('private-branch')
+ await socket.stop()
+ })
+
+ it('answers scm_project_info for a malformed path as the git probe does, correlated', async () => {
+ const read = vi.spyOn(gitProject, 'readGitProject')
+ const socket = new BackendSocket('token')
+ socket.connect()
+ const ws = wsMock.instances[0]
+ ws.open()
+ vi.spyOn(socket.e2ee, 'unwrapDown').mockReturnValue({ type: 'scm_project_info', payload: {
+ requestId: 'scm-error', path: 42,
+ } })
+ vi.spyOn(socket.e2ee, 'hasSession').mockReturnValue(true)
+ const wrap = vi.spyOn(socket.e2ee, 'wrapRpcReply').mockReturnValue({
+ type: 'scm_project_info_result', payload: { __e2e: { v: 1, k: 'p', n: 1, ct: 'encrypted-error' } },
+ })
+ ws.message({ t: 'down', connId: 'viewer-a', frame: {
+ type: 'scm_project_info', payload: { __e2e: { v: 1, k: 'p', n: 1, ct: 'encrypted-request' } },
+ } })
+ await vi.waitFor(() => expect(wrap).toHaveBeenCalledWith('viewer-a', 'scm_project_info_result', 'scm-error', { kind: 'none', error: 'INVALID_PATH' }))
+ expect(read).toHaveBeenCalledWith('', { refresh: false, knownRoots: [] })
+ await socket.stop()
+ })
+
it('returns PR status only to the requesting encrypted connection', async () => {
const preview = { status: 'found' as const, number: 12, state: 'Merged' as const, url: 'https://github.com/private/repo/pull/12' }
vi.spyOn(registry, 'resolve').mockReturnValue({ cwd: '/remote/workspace' } as RegisteredSession)
diff --git a/cli/src/backendSocket.ts b/cli/src/backendSocket.ts
index 09491f346..618a6e507 100644
--- a/cli/src/backendSocket.ts
+++ b/cli/src/backendSocket.ts
@@ -67,6 +67,7 @@ import { parseProjectFolder, prepareProjectFolder, projectsRoot, ProjectFolderEr
import { claudeTrusts, codexTrusts, preTrustClaudeProject, preTrustCodexProject } from './lib/claudeTrust.js'
import { projectPreview } from './lib/projectPreview.js'
import { readGitProject } from './lib/gitProject.js'
+import { detectScmProject } from './scm/scmProjects.js'
import { agentFrame, lastActivityAt, type AgentDshContext, type AgentFrame } from './lib/agentFrame.js'
import { agentTokenUsage } from './lib/agentTokenUsage.js'
import { installedDsh, listInstalledDsh } from './dsh/installed.js'
@@ -1685,7 +1686,7 @@ export class BackendSocket {
const resultType = rpcResultType(type)
if (connId && deviceDump.enabled && this.e2ee.sessionRole(connId) === 'device') deviceDump.record('out', 'legacy', connId, { type: resultType, payload: { requestId, ...payload } })
// Before the E2EE wrap: an RPC reply is only readable here.
- if (env.LOG_FRAMES && !TEAM_REQUEST_TYPES.has(type) && !OWNER_COMMAND_TYPES.has(type) && !type.startsWith('viewer_') && type !== 'phone_pair' && type !== 'api_connections' && type !== 'orchestrator' && !type.startsWith('grid_fleet_') && type !== 'agent_read_file' && type !== 'project_preview' && type !== 'git_project_info' && type !== 'git_pull_request' && type !== 'agent_handoff_prepare' && !SHARE_REQUEST_TYPES.has(type) && !type.startsWith('pair')) logFrame('→', connId ? `conn:${sid(connId)}` : 'backend', { type: resultType, payload: { requestId, ...payload } })
+ if (env.LOG_FRAMES && !TEAM_REQUEST_TYPES.has(type) && !OWNER_COMMAND_TYPES.has(type) && !type.startsWith('viewer_') && type !== 'phone_pair' && type !== 'api_connections' && type !== 'orchestrator' && !type.startsWith('grid_fleet_') && type !== 'agent_read_file' && type !== 'project_preview' && type !== 'git_project_info' && type !== 'scm_project_info' && type !== 'git_pull_request' && type !== 'agent_handoff_prepare' && !SHARE_REQUEST_TYPES.has(type) && !type.startsWith('pair')) logFrame('→', connId ? `conn:${sid(connId)}` : 'backend', { type: resultType, payload: { requestId, ...payload } })
if (this.localClients.has(connId)) {
this.sendTo(connId, { type: resultType, payload: { requestId, ...payload } })
return
@@ -1812,7 +1813,7 @@ export class BackendSocket {
// than as an opaque __e2e envelope.
// Terminal frames contain raw keystrokes, paste text and screen bytes after
// unwrap. Never pass them to the frame logger, even in diagnostic mode.
- if (env.LOG_FRAMES && !TEAM_REQUEST_TYPES.has(type) && !OWNER_COMMAND_TYPES.has(type) && !type.startsWith('terminal_') && !type.startsWith('viewer_') && !type.startsWith('grid_fleet_') && type !== 'agent_read_file' && type !== 'project_preview' && type !== 'git_project_info' && type !== 'git_pull_request' && type !== 'agent_handoff_prepare' && type !== 'orchestrator' && type !== 'api_connections' && type !== 'phone_pair' && !SHARE_REQUEST_TYPES.has(type) && !type.startsWith('pair')) {
+ if (env.LOG_FRAMES && !TEAM_REQUEST_TYPES.has(type) && !OWNER_COMMAND_TYPES.has(type) && !type.startsWith('terminal_') && !type.startsWith('viewer_') && !type.startsWith('grid_fleet_') && type !== 'agent_read_file' && type !== 'project_preview' && type !== 'git_project_info' && type !== 'scm_project_info' && type !== 'git_pull_request' && type !== 'agent_handoff_prepare' && type !== 'orchestrator' && type !== 'api_connections' && type !== 'phone_pair' && !SHARE_REQUEST_TYPES.has(type) && !type.startsWith('pair')) {
logFrame('←', connId ? `conn:${sid(connId)}` : 'backend', frame)
}
const reply = (t: string, rid: unknown, p: Record<string, unknown>): void => this.emitReply(connId, t, rid, p)
@@ -3300,6 +3301,18 @@ export class BackendSocket {
return
}
+ // The same probe through the SCM seam, answering `{kind, git?, error?}`. Beside
+ // `git_project_info`, not in its place: an older client keeps asking the old question and gets
+ // the old answer. Same fence and refresh as above.
+ case 'scm_project_info': {
+ const path = typeof payload.path === 'string' ? payload.path : ''
+ void detectScmProject(path, { refresh: payload.refresh === true,
+ knownRoots: registry.list().flatMap(agent => agent.cwd ? [agent.cwd] : []) })
+ .then(result => reply(type, requestId, result))
+ .catch(() => reply(type, requestId, { kind: 'none', error: 'UNAVAILABLE' }))
+ return
+ }
+
case 'project_preview': {
const path = typeof payload.path === 'string' ? payload.path : ''
// Preview work is detached so typing and other RPCs stay responsive.
diff --git a/cli/src/lib/e2ee/applicationFrames.ts b/cli/src/lib/e2ee/applicationFrames.ts
index bdcc21097..bbd7d2369 100644
--- a/cli/src/lib/e2ee/applicationFrames.ts
+++ b/cli/src/lib/e2ee/applicationFrames.ts
@@ -18,7 +18,7 @@ const FLEET_REQUESTS = new Set(['grid_fleet_capabilities', 'grid_fleet_run', 'gr
'grid_fleet_models_list', 'grid_fleet_model_download', 'grid_fleet_model_start', 'grid_fleet_model_stop'])
const FLEET_RESULTS = new Set([...FLEET_REQUESTS].map(type => `${type}_result`))
// `group_sync`: the trust-group roster exchange (groupSyncer.ts) — keys, so always sealed.
-const MACHINE_REQUESTS = new Set(['agent_purge', 'agent_worktree_delete', 'agents_cleanup_preview', 'agent_close', 'git_project_info', 'git_pull_request', 'machine_resources', 'api_connections', 'group_sync', 'phone_pair', 'viewer_surface', 'orchestrator', 'agent_handoff_prepare', ...OWNER_COMMAND_TYPES])
+const MACHINE_REQUESTS = new Set(['agent_purge', 'agent_worktree_delete', 'agents_cleanup_preview', 'agent_close', 'git_project_info', 'scm_project_info', 'git_pull_request', 'machine_resources', 'api_connections', 'group_sync', 'phone_pair', 'viewer_surface', 'orchestrator', 'agent_handoff_prepare', ...OWNER_COMMAND_TYPES])
const MACHINE_RESULTS = new Set([...MACHINE_REQUESTS].map(type => `${type}_result`))
/** The pair brain, machine to machine (daemons/BRAIN.md). A watch carries question text and recaps; the
* writes (answer, send, stop, start, pause, resume) act on a harness through the owning machine's floor
diff --git a/cli/src/scm/scmProjects.spec.ts b/cli/src/scm/scmProjects.spec.ts
index cb14477b7..9503204b4 100644
--- a/cli/src/scm/scmProjects.spec.ts
+++ b/cli/src/scm/scmProjects.spec.ts
@@ -5,6 +5,7 @@ import { basename, join } from 'node:path'
import { promisify } from 'node:util'
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
import { agentProject } from '../lib/agentProject.js'
+import { encryptDownFrame, encryptRpcResult } from '../lib/e2ee/applicationFrames.js'
import { readGitProject } from '../lib/gitProject.js'
import { sweepWorktrees } from '../lib/worktreeSweep.js'
import { GitScmProject } from './gitScmProject.js'
@@ -74,6 +75,11 @@ describe('the SCM seam, with git as its only implementation', { timeout: 30_000
expect(await detectScmProject(repo, {}, [throws as unknown as ScmProject])).toEqual(none('UNAVAILABLE'))
})
+ it('travels encrypted end to end, as git_project_info does: the answer names private branches', () => {
+ expect(encryptDownFrame('scm_project_info')).toBe(true)
+ expect(encryptRpcResult('scm_project_info_result')).toBe(true)
+ })
+
it('renames through the seam and answers null where git would', async () => {
expect(await renameScmProject(plain, 'A title')).toBeNull()
expect(await renameScmProject(repo, 'A title')).toBeNull()