Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
GitHub inbox: let Enterprise (Private) accounts opt in to agent rules and hand-offs
Adam Eivyf157ae15481d
diff --git a/client/src/components/github/GitHubAccountsTab.jsx b/client/src/components/github/GitHubAccountsTab.jsxindex 44337339ec..b2d92377c2 100644--- a/client/src/components/github/GitHubAccountsTab.jsx+++ b/client/src/components/github/GitHubAccountsTab.jsx@@ -34,7 +34,7 @@ const STATUS_VIEW = {};const defaultTrustForHost = (host) => (host.trim().toLowerCase() === GITHUB_DOT_COM ? 'public' : 'private');-const emptyForm = () => ({ host: GITHUB_DOT_COM, login: '', label: '', trust: 'public', trustTouched: false, allowedProviders: [] });+const emptyForm = () => ({ host: GITHUB_DOT_COM, login: '', label: '', trust: 'public', trustTouched: false, allowedProviders: [], allowAgents: false });const formFromAccount = (account) => ({host: account.host,login: account.login || '',@@ -42,6 +42,7 @@ const formFromAccount = (account) => ({trust: account.trust,trustTouched: true,allowedProviders: account.allowedProviders || [],+ allowAgents: account.allowAgents === true,});// No provider ticked = the Private default, local providers only (null).const payloadFromForm = (form) => ({@@ -50,6 +51,7 @@ const payloadFromForm = (form) => ({label: form.label.trim(),trust: form.trust,allowedProviders: form.trust === 'private' && form.allowedProviders.length ? form.allowedProviders : null,+ allowAgents: form.trust === 'private' && form.allowAgents,});const fetchApiProviders = () => getProviders({ silent: true })@@ -114,6 +116,15 @@ function AccountForm({ form, setForm, onSubmit, onCancel, saving, submitLabel })</FormField></div>{form.trust === 'private' && <AllowedProviders form={form} setForm={setForm} />}+ {form.trust === 'private' && (+ <div className="space-y-1">+ <div className="flex items-center gap-2">+ <input id="github-allow-agents" type="checkbox" checked={form.allowAgents} onChange={(event) => setForm((prev) => ({ ...prev, allowAgents: event.target.checked }))} />+ <label htmlFor="github-allow-agents" className="text-sm text-gray-300">Allow agents to work on this account's threads</label>+ </div>+ <p className="text-xs text-gray-500">Lets Autopilot and Resolve with agent hand threads to CoS agents. They run on the providers set in PortOS, not the list above, so this code and discussion may reach those providers.</p>+ </div>+ )}<div className="flex flex-wrap gap-2"><button type="submit" disabled={saving || !form.host.trim()} className="px-4 py-2 rounded bg-port-accent text-white text-sm disabled:opacity-50">{saving ? 'Saving…' : submitLabel}diff --git a/client/src/components/github/GitHubAutomationsTab.jsx b/client/src/components/github/GitHubAutomationsTab.jsxindex 8626a05b5e..6e33cee063 100644--- a/client/src/components/github/GitHubAutomationsTab.jsx+++ b/client/src/components/github/GitHubAutomationsTab.jsx@@ -29,8 +29,8 @@ function modeHint(account) {: 'Text goes to the GitHub notifications provider in Models › LLMs › Abuse Guard.';const assist = `Screens and sorts notifications no rule decided, marks CI noise and closed threads done. Never acts on outside or suspect threads. ${where}`;if (account.mode !== 'autopilot') return assist;- const handoff = account.trust === 'private'- ? 'Private accounts never hand threads off.'+ const handoff = account.trust === 'private' && !account.allowAgents+ ? 'Private accounts hand threads off only after you allow agents on them in Accounts.': 'Also hands outside review requests, outside issues and security alerts in your PortOS apps to Untrusted:Review, the issue watcher and dependency updates when those are on for the app, one run per app for each. A security alert in another repo of yours starts one CoS task per repo that fixes it in a pull request and merges it. Agent rules below turn kinds on or off per repo and pick the provider.';return `${assist} ${handoff}`;}@@ -79,7 +79,7 @@ function AccountCard({ account, running, onRun, onMode, savingMode, onSaveRules,><Play size={12} aria-hidden="true" /> {running ? 'Checking…' : 'Run now'}</button>- {account.trust !== 'private' && <GitHubAgentRules account={account} onSave={onSaveRules} saving={savingRules} />}+ {(account.trust !== 'private' || account.allowAgents) && <GitHubAgentRules account={account} onSave={onSaveRules} saving={savingRules} />}</li>);}diff --git a/client/src/components/github/githubTriageLabels.js b/client/src/components/github/githubTriageLabels.jsindex 0e2545936e..0d2e4f466b 100644--- a/client/src/components/github/githubTriageLabels.js+++ b/client/src/components/github/githubTriageLabels.js@@ -74,13 +74,13 @@ export const AGENT_RULE_KINDS = [// Why Resolve with agent is unavailable for a thread.export const AGENT_REFUSED_LABELS = {- 'private-account': 'Private accounts never hand off to an agent',+ 'private-account': 'Allow agents on this Private account in Accounts to resolve it with an agent','no-managed-app': 'Add this repo as a PortOS app to resolve it with an agent',};// Why Autopilot left a thread with you instead of handing it off.export const HANDOFF_SKIP_LABELS = {- 'private-account': 'Private accounts never hand off: the lanes use their own AI providers',+ 'private-account': 'Agents are not allowed on this Private account (Accounts)','no-managed-app': 'No PortOS app manages this repo','lane-unavailable': 'The lane would not take it',};diff --git a/client/src/pages/GitHub.test.jsx b/client/src/pages/GitHub.test.jsxindex c8c9a87546..28372ea659 100644--- a/client/src/pages/GitHub.test.jsx+++ b/client/src/pages/GitHub.test.jsx@@ -330,6 +330,17 @@ describe('GitHub accounts tab', () => {await waitFor(() => expect(mock.updateGitHubAccount).toHaveBeenCalledWith('github-com', expect.objectContaining({ trust: 'private', allowedProviders: ['cloud-api'] })));});+ it('lets a Private Enterprise account opt in to agents', async () => {+ mock.updateGitHubAccount.mockImplementation(async (id, body) => ({ ...IMPLICIT, ...body, id }));+ renderAccounts();+ fireEvent.click(await screen.findByRole('button', { name: 'Edit' }));+ expect(screen.queryByLabelText(/Allow agents/)).toBeNull();+ fireEvent.change(screen.getByLabelText('Trust'), { target: { value: 'private' } });+ fireEvent.click(await screen.findByLabelText(/Allow agents/));+ fireEvent.click(screen.getByRole('button', { name: 'Save' }));+ await waitFor(() => expect(mock.updateGitHubAccount).toHaveBeenCalledWith('github-com', expect.objectContaining({ trust: 'private', allowAgents: true })));+ });+it('lists each account with its trust level and live sign-in state', async () => {renderAccounts();expect(await screen.findByText('Signed in')).toBeTruthy();@@ -354,7 +365,7 @@ describe('GitHub accounts tab', () => {expect(screen.getByLabelText('Trust').value).toBe('private');fireEvent.click(screen.getAllByRole('button', { name: 'Add account' }).at(-1));- expect(mock.createGitHubAccount).toHaveBeenCalledWith({ host: 'ghe.example.com', login: 'alice', label: '', trust: 'private', allowedProviders: null });+ expect(mock.createGitHubAccount).toHaveBeenCalledWith({ host: 'ghe.example.com', login: 'alice', label: '', trust: 'private', allowedProviders: null, allowAgents: false });const signIn = await screen.findByRole('link', { name: 'Sign in on ghe.example.com' });expect(decodeURIComponent(signIn.getAttribute('href'))).toBe('/shell?cmd=gh auth login --hostname ghe.example.com --web --clipboard');});@@ -566,6 +577,18 @@ describe('GitHub automations tab', () => {await waitFor(() => expect(mock.getGitHubAutomations).toHaveBeenCalledTimes(2));});+ it('shows agent rules on a Private account only once it allows agents', async () => {+ const enterprise = { ...OVERVIEW.accounts[0], id: 'ghe', label: 'ghe.example.com', host: 'ghe.example.com', trust: 'private', mode: 'autopilot', agentRules: [], repos: [] };+ mock.getGitHubAutomations.mockResolvedValue({ ...OVERVIEW, accounts: [{ ...enterprise, allowAgents: false }] });+ const { unmount } = renderTab('automations');+ expect(await screen.findByText(/only after you allow agents/)).toBeTruthy();+ expect(screen.queryByRole('button', { name: /Add rule/ })).toBeNull();+ unmount();+ mock.getGitHubAutomations.mockResolvedValue({ ...OVERVIEW, accounts: [{ ...enterprise, allowAgents: true }] });+ renderTab('automations');+ expect(await screen.findByRole('button', { name: /Add rule/ })).toBeTruthy();+ });+it('adds an agent rule for review requests in one repo and refuses a duplicate', async () => {mock.getProviders.mockResolvedValue({ providers: [{ id: 'example-provider', name: 'Example Provider', type: 'cli', enabled: true, models: ['example-model'], defaultModel: 'example-model' }] });mock.getGitHubAutomations.mockResolvedValue({diff --git a/server/lib/githubNotificationTriage.js b/server/lib/githubNotificationTriage.jsindex e55dbdea5e..8e5f960ca5 100644--- a/server/lib/githubNotificationTriage.js+++ b/server/lib/githubNotificationTriage.js@@ -246,8 +246,9 @@ const rulePin = (rule) => {/*** Which lane an agent may resolve a thread in, or null when no lane fits. A- * plan with `refused` names why it cannot go: a Private account's threads never- * go (the lanes use their own providers, which its allow-list cannot bind), and+ * plan with `refused` names why it cannot go: a Private account's threads go+ * only once the operator sets `allowAgents` on it (the lanes use their own+ * providers, which its allow-list cannot bind, so the operator accepts that), and* the per-app lanes need the repo to be a PortOS managed app. Suspect and closed* threads never qualify. The pull number comes from the subject's API url and* the link from the stored html url, never from a title or body.@@ -289,7 +290,7 @@ export function agentHandoff({ account, row }) {const pin = rulePin(rule);if (pin) plan.pin = pin;if (rule) plan.rule = { id: rule.id || null, agent: rule.agent };- if (account?.trust === 'private') return { ...plan, refused: 'private-account' };+ if (account?.trust === 'private' && account.allowAgents !== true) return { ...plan, refused: 'private-account' };const needsApp = plan.lane !== 'security-fix' && plan.lane !== 'do-review';if (needsApp && evidence.repoManaged !== true) return { ...plan, refused: 'no-managed-app' };return plan;diff --git a/server/lib/githubNotificationTriage.test.js b/server/lib/githubNotificationTriage.test.jsindex 1d1dc39ee0..df697f1fad 100644--- a/server/lib/githubNotificationTriage.test.js+++ b/server/lib/githubNotificationTriage.test.js@@ -205,7 +205,16 @@ describe('autopilotHandoff', () => {expect(agentRuleScope([], 'review-request', { optIn: true })).toEqual({ all: false, except: [], only: [] });});- it('refuses every hand-off on a Private account, whose provider allow-list the lanes cannot honor', () => {- expect(autopilotHandoff({ account: { ...account, trust: 'private' }, row: review })).toEqual({ lane: 'pr-reviewer', pullNumber: 42, refused: 'private-account' });+ it('refuses every hand-off on a Private account until the operator allows agents on it', () => {+ const enterprise = { ...account, trust: 'private' };+ expect(autopilotHandoff({ account: enterprise, row: review })).toEqual({ lane: 'pr-reviewer', pullNumber: 42, refused: 'private-account' });+ expect(autopilotHandoff({ account: { ...enterprise, allowAgents: false }, row: review })).toEqual({ lane: 'pr-reviewer', pullNumber: 42, refused: 'private-account' });+ expect(autopilotHandoff({ account: { ...enterprise, allowAgents: true }, row: review })).toEqual({ lane: 'pr-reviewer', pullNumber: 42 });+ });++ it('applies agent rules and their pin on a Private account that allows agents', () => {+ const rules = [{ id: 'r', kind: 'review-request', repo: 'acme/app', agent: true, provider: 'p1' }];+ const enterprise = { ...account, trust: 'private', allowAgents: true, agentRules: rules };+ expect(agentHandoff({ account: enterprise, row: { ...review, repo_full_name: 'acme/app' } })).toEqual({ lane: 'pr-reviewer', pullNumber: 42, pin: { provider: 'p1' }, rule: { id: 'r', agent: true } });});});diff --git a/server/lib/validation.js b/server/lib/validation.jsindex 7512b04abc..13ae1ae06f 100644--- a/server/lib/validation.js+++ b/server/lib/validation.js@@ -988,6 +988,9 @@ export const githubAccountCreateSchema = z.object({mode: z.enum(GITHUB_ACCOUNT_MODES).optional(),// Monthly subscription audit delivered as a PortOS notification (#12874).auditReport: z.boolean().optional(),+ // Private (Enterprise) accounts refuse every agent hand-off unless the operator+ // opts in: the lanes run on PortOS's own providers, which the allow-list cannot bind.+ allowAgents: z.boolean().optional(),agentRules: githubAgentRulesSchema.optional(),enabled: z.boolean().optional(),}).strict();diff --git a/server/services/githubAccounts.js b/server/services/githubAccounts.jsindex 54c8952a4c..f4a6891a74 100644--- a/server/services/githubAccounts.js+++ b/server/services/githubAccounts.js@@ -47,6 +47,7 @@ const storedAccountSchema = z.object({allowedProviders: z.array(z.string()).nullable(),mode: z.enum(GITHUB_ACCOUNT_MODES),auditReport: z.boolean().optional(),+ allowAgents: z.boolean().optional(),agentRules: z.array(z.object({}).passthrough()).optional(),enabled: z.boolean(),createdAt: z.string(),@@ -63,6 +64,7 @@ const implicitAccount = () => ({allowedProviders: null,mode: 'observe',auditReport: false,+ allowAgents: false,agentRules: [],enabled: true,createdAt: null,@@ -133,6 +135,7 @@ export function createAccount(input) {allowedProviders: data.allowedProviders ?? null,mode: data.mode || 'observe',auditReport: data.auditReport ?? false,+ allowAgents: data.allowAgents ?? false,agentRules: data.agentRules ?? [],enabled: data.enabled ?? true,createdAt: now,diff --git a/server/services/githubAccounts.test.js b/server/services/githubAccounts.test.jsindex 539bb6ff94..b5117a31a7 100644--- a/server/services/githubAccounts.test.js+++ b/server/services/githubAccounts.test.js@@ -67,6 +67,16 @@ describe('GitHub accounts API', () => {expect(duplicate.status).toBe(409);});+ it('keeps agents off an Enterprise account until the operator allows them, and persists the choice', async () => {+ const created = await request(app).post('/api/github/accounts').send({ host: 'github.example.com' });+ expect(created.body.allowAgents).toBe(false);+ const allowed = await request(app).put(`/api/github/accounts/${created.body.id}`).send({ allowAgents: true });+ expect(allowed.status).toBe(200);+ expect(allowed.body.allowAgents).toBe(true);+ const bad = await request(app).put(`/api/github/accounts/${created.body.id}`).send({ allowAgents: 'yes' });+ expect(bad.status).toBe(400);+ });+it('rejects hosts and logins that are not plain identifiers', async () => {for (const body of [{ host: '--hostname=evil' },diff --git a/server/services/githubNotifications.js b/server/services/githubNotifications.jsindex f0fa064ac3..248aaee4bf 100644--- a/server/services/githubNotifications.js+++ b/server/services/githubNotifications.js@@ -592,6 +592,7 @@ export async function getAutomationsOverview() {needsYou: counts?.needs_you || 0,suspect: counts?.suspect || 0,pending: counts?.pending || 0,+ allowAgents: account.allowAgents === true,agentRules: Array.isArray(account.agentRules) ? account.agentRules : [],repos: reposById.get(account.id) || [],};