Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.
TypeScript browser-shellcontrol-planefile-managerhomelabmobile-firstnextjsptyreactself-hostedserver-managementshadcn-uisysadmintailwindcssterminaltypescriptvpsweb-desktopweb-terminal
fix(integrations): synchronize owner-local SC credential snapshots
Rahman2c0723d5df84
diff --git a/docs/INFRASTRUCTURE-PROVIDERS.md b/docs/INFRASTRUCTURE-PROVIDERS.mdindex 596b46a9..e41de592 100644--- a/docs/INFRASTRUCTURE-PROVIDERS.md+++ b/docs/INFRASTRUCTURE-PROVIDERS.md@@ -228,3 +228,28 @@ MCP operations accept `user`, `connection` and `cwd`; explicit identities overrifolder/default resolution, and external backends never fall back to local keys.Provider-only v1 configuration is projected into `legacy` and backed up beforethe first v2 write. See [Integrations](INTEGRATIONS.md) for exact CLI/API contracts.+++## Owner-local SC synchronization++Integrations is the MSO-facing credential management surface. When an installed SC instance+already owns named direct connections, the owner can synchronize its current snapshot locally:++```bash+bun scripts/sync-sc-local.ts --source /absolute/path/to/si-coder-agent+bun scripts/sync-sc-local.ts --source /absolute/path/to/si-coder-agent --apply+```++The first command previews metadata only. The second backs up the private MSO store and applies+under its existing lock, then checks readback parity. Values never appear in arguments/output.+The source is an explicitly trusted, owner-owned local installation; the script executes its+connection APIs. It is not an endpoint for arbitrary remote paths or untrusted plugin code.+Existing values/defaults are preserved; differing accounts receive an `sc-` connection alias.+Shared aliases retain their backing reference. Unsupported fields/methods and external OAuth+fail closed; migrate legacy profile fields using SC first if the preview requests it.++This copies the current direct-connection snapshot, not ongoing bidirectional CRUD. Run preview+again after SC changes; a conflicting existing alias requires deliberate reconciliation, not+silent credential rotation. Provider verification remains a separate operation. No scheduler,+folder remapping or default-user switch is installed. The browser/MCP/CLI see applied values+through the same native store immediately; SC is not a mandatory MSO runtime dependency.diff --git a/docs/PROGRESS.md b/docs/PROGRESS.mdindex 71caa096..30ff113d 100644--- a/docs/PROGRESS.md+++ b/docs/PROGRESS.md@@ -1,3 +1,24 @@+## 2026-09-09 — Explicit SC credential synchronization++User reports existing SC credentials absent from MSO Integrations. The prior transfer discovery+was metadata-only. Added an owner-local, preview-first synchronization command using SC's+installed connection API and MSO's existing locked store, field registry and validation.+It imports direct named connections, fills compatible empty metadata, preserves existing+credentials/defaults, isolates conflicts under `sc-` aliases and keeps shared connections as+references. Old DOKU Checkout and MCP Client ID fields map to their distinct native methods.+Unknown fields, external authorization, unresolved shares and conflicting aliases fail closed.+Secret values remain in process memory and the private store; output is metadata only.+An owner-only backup precedes application. Repeating the current snapshot changes no connection.+This is an explicit local snapshot synchronization, not automatic bidirectional replication.+MSO retains standalone operation; SC remains optional and unchanged.++Live evidence: all 65 SC connections across nine users are represented; 48 added, 15 filled,+two unchanged. MSO now lists nine users and 74 connections including its existing entries.+Readback and repeated preview pass; imported Batonly GitHub authenticates through live MSO.+SC has no legacy profile fields; its sole Composio connection is empty, so synchronization+cannot supply Batonly's missing Composio Project API key. Five isolated regression tests and+typecheck/lint pass. The release pipeline records the remaining repository-wide gates.+## 2026-09-09 — Complete Semgrep parser coverage## 2026-09-09 — MCP Sessions dashboard and handover referencediff --git a/lib/infra/sc-sync.test.ts b/lib/infra/sc-sync.test.tsnew file mode 100644index 00000000..26c6cb98--- /dev/null+++ b/lib/infra/sc-sync.test.ts@@ -0,0 +1,32 @@+import { it, expect } from 'vitest';+import { syncScIn, type ScRow } from './sc-sync';+import { emptyIntegrationState, resolveSharedConnection } from './identity';+const row=(user='alice',id='main'):ScRow=>({user,id,provider:'composio',label:id,source:'sc',authMethod:'project-api-key',isDefault:true,values:{COMPOSIO_API_KEY:'synthetic_key_for_test_123456'}});+const input=(rows:ScRow[])=>({users:[...new Set(rows.map(r=>r.user))].map(id=>({id,label:id})),rows});+it('imports all users with strict isolation, no secret output, and idempotent repeat',()=>{+ const s=emptyIntegrationState(),a=row(),b={...row('bob'),values:{COMPOSIO_API_KEY:'another_synthetic_key_123456'}};+ const out=syncScIn(s,input([a,b]));expect(JSON.stringify(out)).not.toContain('synthetic');expect(s.users.alice.connections.composio.main.values.apiKey).toBe(a.values.COMPOSIO_API_KEY);expect(s.users.bob.connections.composio.main.values.apiKey).toBe(b.values.COMPOSIO_API_KEY);+ const snapshot=JSON.stringify(s);expect(syncScIn(s,input([a,b])).results.every(r=>r.action==='unchanged')).toBe(true);expect(JSON.stringify(s)).toBe(snapshot);+});+it('fills metadata-only connections and preserves conflicting credentials/defaults',()=>{+ const s=emptyIntegrationState(),a=row();syncScIn(s,input([{...a,values:{}}]));expect(syncScIn(s,input([a])).results[0].action).toBe('filled');+ const before=s.users.alice.connections.composio.main.values.apiKey;+ const other={...a,values:{COMPOSIO_API_KEY:'changed_synthetic_key_123456'}};expect(syncScIn(s,input([other])).results[0].connection).toBe('sc-main');expect(s.users.alice.connections.composio.main.values.apiKey).toBe(before);expect(s.users.alice.defaults.composio).toBe('main');+ expect(()=>syncScIn(s,input([{...other,values:{COMPOSIO_API_KEY:'third_synthetic_key_123456'}}]))).toThrow('sc_sync_conflicting_alias');+});+it('preserves shared aliases and resolves backing collisions without copying credentials',()=>{+ const s=emptyIntegrationState(),a=row(),shared={...row('bob'),sharedFrom:{user:'alice',provider:'composio',connection:'main'}};+ syncScIn(s,input([shared,a]));const alias=s.users.bob.connections.composio.main;expect(alias.values).toEqual({});expect(resolveSharedConnection(s,'bob',alias).connection).toBe(s.users.alice.connections.composio.main);+ expect(syncScIn(s,input([shared,a])).results.every(r=>r.action==='unchanged')).toBe(true);+});+it('maps old DOKU checkout and MCP client identifiers to separate methods',()=>{+ const s=emptyIntegrationState(),base={...row(),provider:'doku'};+ syncScIn(s,input([{...base,id:'checkout',authMethod:'checkout-rest',values:{DOKU_CLIENT_ID:'client123',DOKU_SECRET_KEY:'synthetic-secret'}},{...base,id:'mcp',authMethod:'mcp-api-key',values:{DOKU_CLIENT_ID:'client456',DOKU_MCP_API_KEY:'synthetic-mcp-key',DOKU_MCP_ENV:'production'}}]));+ expect(s.users.alice.connections.doku.checkout.authMethod).toBe('payment');expect(s.users.alice.connections.doku.checkout.values.paymentClientId).toBe('client123');expect(s.users.alice.connections.doku.mcp.values.mcpClientId).toBe('client456');expect(s.users.alice.connections.doku.mcp.values.paymentClientId).toBeUndefined();+});+it('fails closed for unmapped values, external credentials, missing shares and active leases',()=>{+ const a=row();expect(()=>syncScIn(emptyIntegrationState(),input([{...a,values:{UNKNOWN:'secret'}}]))).toThrow('sc_sync_unmapped_field');+ expect(()=>syncScIn(emptyIntegrationState(),input([{...a,source:'composio'}]))).toThrow('sc_sync_external_requires_reauthorization');+ expect(()=>syncScIn(emptyIntegrationState(),input([{...a,sharedFrom:{user:'missing',provider:'composio',connection:'main'}}]))).toThrow('sc_sync_missing_shared_backing');+ const s=emptyIntegrationState();syncScIn(s,input([{...a,values:{}}]));s.users.alice.connections.composio.main.lease={id:'busy',until:Date.now()+60000};expect(()=>syncScIn(s,input([a]))).toThrow('connection_busy');+});diff --git a/lib/infra/sc-sync.ts b/lib/infra/sc-sync.tsnew file mode 100644index 00000000..af88a4c1--- /dev/null+++ b/lib/infra/sc-sync.ts@@ -0,0 +1,54 @@+/** Owner-local SC import. Values stay in process memory and the locked native store. */+import { randomUUID } from 'node:crypto';+import { connectionMethod } from './connection-registry';+import { FIELD_MAP, nativeMethod } from './portable/mapping';+import { normalizeInfraValues, isInfraProviderId } from './catalog';+import { assertNotBusy, identity, connectionLabel, IntegrationError, resolveSharedConnection, type IntegrationState, type IntegrationConnection } from './identity';+export type ScRow={user:string;provider:string;id:string;label:string;source:string;authMethod:string;isDefault?:boolean;values:Record<string,string>;sharedFrom?:{user:string;provider:string;connection:string}|null};+export type ScInput={users:Array<{id:string;label:string}>;rows:ScRow[]};+const ref=(u:string,p:string,c:string)=>`${u}/${p}/${c}`;+function mapped(row:ScRow){+ const source=row.source==='sc'?'direct':row.source;+ if(source!=='direct')throw new IntegrationError('sc_sync_external_requires_reauthorization');+ const method=connectionMethod(row.provider,source,row.provider==='doku'&&row.authMethod==='checkout-rest'?'payment':nativeMethod(row.provider,source,row.authMethod));+ const map={...FIELD_MAP[row.provider]};+ if(row.provider==='doku'&&method.id==='mcp')map.DOKU_CLIENT_ID='mcpClientId';+ const allowed=new Set(method.fields.map(f=>f.key)),values:Record<string,string>={};+ for(const [k,v]of Object.entries(row.values)){+ if(!map[k]||!allowed.has(map[k]))throw new IntegrationError('sc_sync_unmapped_field');+ values[map[k]]=v;+ }+ if(!isInfraProviderId(row.provider))throw new IntegrationError('sc_sync_unsupported_provider');+ return{source,method,values:normalizeInfraValues(row.provider,values)};+}+function compatible(c:IntegrationConnection,method:string,values:Record<string,string>){return c.source==='direct'&&c.authMethod===method&&!c.sharedFrom&&Object.entries(c.values).every(([k,v])=>values[k]===v);}+/** Mutates only the supplied transaction draft. Never returns values or their digests. */+export function syncScIn(state:IntegrationState,input:ScInput){+ const results:Array<{user:string;provider:string;sourceConnection:string;connection:string;action:string}>=[],targets=new Map<string,string>();+ for(const u of input.users){identity(u.id);connectionLabel(u.label);state.users[u.id]??={id:u.id,uid:randomUUID(),label:u.label,connections:{},defaults:{}};}+ const rows=input.rows.map(row=>{identity(row.user);identity(row.provider);identity(row.id);connectionLabel(row.label);if(!state.users[row.user])throw new IntegrationError('sc_sync_unknown_user');return{row,...mapped(row)};});+ for(const {row,method,values}of rows){+ const profile=state.users[row.user],group=profile.connections[row.provider]??={},key=ref(row.user,row.provider,row.id);+ let id=row.id,c=group[id];+ const match=(candidate:IntegrationConnection)=>row.sharedFrom?candidate.source==='direct'&&candidate.authMethod===method.id&&(Boolean(candidate.sharedFrom)||!Object.keys(candidate.values).length):compatible(candidate,method.id,values);+ if(c&&!match(c)){id=identity(`sc-${row.id}`);c=group[id];if(c&&!match(c))throw new IntegrationError('sc_sync_conflicting_alias');}+ targets.set(key,id);+ const created=!c;+ if(!c){c={id,uid:randomUUID(),label:id===row.id?row.label:connectionLabel(`SC: ${row.label}`),provider:row.provider,source:'direct',authMethod:method.id,scope:method.scope,revision:1,values:{},createdAt:Date.now(),updatedAt:Date.now()};group[id]=c;}+ const changed=!row.sharedFrom&&Object.entries(values).some(([k,v])=>c.values[k]!==v);+ if(changed){assertNotBusy(c);c.values={...values};c.revision++;c.updatedAt=Date.now();delete c.verifiedAt;delete c.lastCheck;}+ if(row.isDefault&&!profile.defaults[row.provider])profile.defaults[row.provider]=id;+ results.push({user:row.user,provider:row.provider,sourceConnection:row.id,connection:id,action:created?'created':changed?'filled':'unchanged'});+ }+ for(const {row,method}of rows)if(row.sharedFrom){+ const backing=row.sharedFrom,target=targets.get(ref(backing.user,backing.provider,backing.connection));+ if(backing.provider!==row.provider||!target)throw new IntegrationError('sc_sync_missing_shared_backing');+ const c=state.users[row.user].connections[row.provider][targets.get(ref(row.user,row.provider,row.id))!];+ const sharedFrom={user:backing.user,provider:backing.provider,connection:target};+ if(c.sharedFrom&&JSON.stringify(c.sharedFrom)!==JSON.stringify(sharedFrom))throw new IntegrationError('sc_sync_shared_conflict');+ if(!c.sharedFrom){assertNotBusy(c);c.sharedFrom=sharedFrom;c.revision++;delete c.verifiedAt;delete c.lastCheck;}+ if(resolveSharedConnection(state,row.user,c).connection.authMethod!==method.id)throw new IntegrationError('sc_sync_shared_method_mismatch');+ }+ for(const {row,values}of rows){const c=state.users[row.user].connections[row.provider][targets.get(ref(row.user,row.provider,row.id))!],actual=resolveSharedConnection(state,row.user,c).connection.values;if(Object.entries(values).some(([k,v])=>actual[k]!==v))throw new IntegrationError('sc_sync_parity_failed');}+ return{users:input.users.length,connections:rows.length,results,verifiedWithProvider:false};+}diff --git a/scripts/sync-sc-local.ts b/scripts/sync-sc-local.tsnew file mode 100644index 00000000..4b76212d--- /dev/null+++ b/scripts/sync-sc-local.ts@@ -0,0 +1,32 @@+/** Explicit owner-local migration: bun scripts/sync-sc-local.ts --source /installed/sc [--apply]. */+import { createRequire } from 'node:module';+import { promises as fs } from 'node:fs';+import path from 'node:path';+import { readIntegrationState, mutateIntegrationState, INFRA_STORE_PATH } from '../lib/infra/connection-storage';+import { syncScIn, type ScInput, type ScRow } from '../lib/infra/sc-sync';+import { IntegrationError } from '../lib/infra/identity';+async function main(){+ const args=process.argv.slice(2),source=args[args.indexOf('--source')+1];+ if(args.indexOf('--source')<0||!path.isAbsolute(source)||args.some(a=>a!==source&&!['--source','--apply'].includes(a)))throw new IntegrationError('usage_source_absolute_path_required');+ const root=await fs.realpath(source),stat=await fs.stat(root);if(stat.uid!==process.getuid?.()||(stat.mode&0o002))throw new IntegrationError('unsafe_sc_source');+ const require=createRequire(path.join(root,'package.json'));+ const c=require('./lib/connections.js'),p=require('./lib/profiles.js'),{withStateLock}=require('./lib/portability/state-lock.js');+ const input:ScInput=withStateLock(()=>{+ const users=p.listProfiles().map((id:string)=>({id,label:p.profileOwner(id)||id}));+ // Refuse to silently lose legacy fields. Use SC's own migration first when present.+ if(users.some((u:{id:string})=>Object.keys(p.readProfile(u.id)).length))throw new IntegrationError('sc_legacy_migration_required');+ return{users,rows:users.flatMap((u:{id:string})=>c.list(u.id).map((r:ScRow)=>({...r,values:c.readValues(r.user,r.provider,r.id)})))};+ });+ const before=await readIntegrationState(),preview=syncScIn(structuredClone(before),input);+ if(!args.includes('--apply')){console.log(JSON.stringify({mode:'preview',...preview}));return;}+ const result=await mutateIntegrationState(async state=>{+ const result=syncScIn(structuredClone(state),input);+ const backup=`${INFRA_STORE_PATH}.sc-sync-${Date.now()}.backup`;+ await fs.writeFile(backup,JSON.stringify(state),{mode:0o600,flag:'wx'});+ syncScIn(state,input);return result;+ });+ const proof=syncScIn(structuredClone(await readIntegrationState()),input);+ if(proof.results.some(r=>r.action==='filled'))throw new IntegrationError('sc_sync_readback_failed');+ console.log(JSON.stringify({mode:'applied',readback:true,...result}));+}+main().catch(e=>{console.error(JSON.stringify({error:e instanceof IntegrationError?e.code:'sc_sync_failed_no_values_logged'}));process.exitCode=1;});