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.

feat(project-settings): canonical trust-content builders (full executable blast radius)

enes1e06e40e38ed
diff --git a/src/shared/project-settings.test.ts b/src/shared/project-settings.test.ts
index 230283c3a..83f33513c 100644
--- a/src/shared/project-settings.test.ts
+++ b/src/shared/project-settings.test.ts
@@ -1,7 +1,8 @@
import { describe, it, expect } from 'vitest'
import {
parseProjectSettingsFile, sanitizeProjectSettingsDoc, sanitizeProjectLocalSettings,
- serializeProjectSettingsFile, sameProjectSettingsContent, resolveProjectSettings
+ serializeProjectSettingsFile, sameProjectSettingsContent, resolveProjectSettings,
+ projectTrustContent
} from './project-settings'
describe('sanitizeProjectSettingsDoc', () => {
@@ -119,3 +120,22 @@ describe('resolveProjectSettings', () => {
{ setup: {}, worktree: {}, agents: {}, terminal: {} })
})
})
+
+describe('projectTrustContent', () => {
+ it('covers both scripts and is insensitive to key order', () => {
+ expect(projectTrustContent('setup', { setup: { setupScript: 'a' } }))
+ .toBe(JSON.stringify({ setupScript: 'a', archiveScript: '' }))
+ expect(projectTrustContent('setup', {})).toBeNull()
+ })
+ it('agents hash covers launchCmd AND env with sorted keys', () => {
+ const a = projectTrustContent('agents', { agents: { launchCmd: 'x', env: { B: '2', A: '1' } } })
+ const b = projectTrustContent('agents', { agents: { env: { A: '1', B: '2' }, launchCmd: 'x' } })
+ expect(a).toBe(b)
+ expect(a).toContain('"A":"1"')
+ expect(projectTrustContent('agents', { agents: { defaultAgentId: 'claude' } })).toBeNull()
+ })
+ it('shell content is the bare shell or null', () => {
+ expect(projectTrustContent('shell', { terminal: { shell: '/bin/sh' } })).toBe('/bin/sh')
+ expect(projectTrustContent('shell', { terminal: { theme: 'dark' } })).toBeNull()
+ })
+})
diff --git a/src/shared/project-settings.ts b/src/shared/project-settings.ts
index 5d891256c..fdd003bf6 100644
--- a/src/shared/project-settings.ts
+++ b/src/shared/project-settings.ts
@@ -320,3 +320,40 @@ export function resolveProjectSettings(
}
return out
}
+
+export type ProjectTrustFamily = 'setup' | 'agents' | 'shell'
+
+/**
+ * Canonical string covering EVERYTHING executable a family ships — the same shape of problem
+ * `execTrusted` (node-exec.ts) solves for shell/ssh fields: a caller compares this against what it
+ * last saw to decide whether re-approval is needed. `null` means the family has nothing executable
+ * right now, so there is nothing to (re-)approve.
+ *
+ * Deliberately excludes fields that cannot introduce code: `waitForSetup` (a boolean gate, not a
+ * command) and `defaultAgentId` (selects among locally-configured agents; it cannot name new code
+ * to run). `env` IS included in `agents` — an env var is attack surface (PATH/LD_PRELOAD hijack),
+ * so it is part of the launch family's blast radius even though it never appears as a command line.
+ */
+export function projectTrustContent(family: ProjectTrustFamily, doc: ProjectSettingsDoc): string | null {
+ switch (family) {
+ case 'setup': {
+ const s = doc.setup
+ if (s?.setupScript === undefined && s?.archiveScript === undefined) return null
+ return JSON.stringify({ setupScript: s?.setupScript ?? '', archiveScript: s?.archiveScript ?? '' })
+ }
+ case 'agents': {
+ const a = doc.agents
+ const envKeys = a?.env ? Object.keys(a.env).sort() : []
+ if (a?.launchCmd === undefined && envKeys.length === 0) return null
+ const env: Record<string, string> = {}
+ for (const k of envKeys) env[k] = a!.env![k]
+ return JSON.stringify({ launchCmd: a?.launchCmd ?? '', env })
+ }
+ case 'shell': {
+ const shell = doc.terminal?.shell
+ return shell ? shell : null
+ }
+ default:
+ return null
+ }
+}