an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions
HTML agent-harnessagent-orchestrationagentsai-agentsautonomous-agentsclaude-codecodexcoding-agentsdesktop-appdeveloper-toolselectrongemini-cliharnessharness-engineeringlocal-firstmemorymulti-agentopencodeorchestrationtypescript
feat(settings): integrations configuration UI (registry-driven, write-only secrets)
Chaitanya Giriee1266873bed
diff --git a/src/renderer/src/components/IntegrationsRegistry.tsx b/src/renderer/src/components/IntegrationsRegistry.tsxnew file mode 100644index 00000000..5d2b264f--- /dev/null+++ b/src/renderer/src/components/IntegrationsRegistry.tsx@@ -0,0 +1,382 @@+import { useEffect, useState, type CSSProperties } from 'react';+import { PixelButton } from './PixelButton';+import {+ integrationsClient,+ type IntegrationDraft,+ type IntegrationEntry,+ type IntegrationStatus,+ type IntegrationTemplate,+ type IntegrationWorker+} from '@/integrations/registryClient';++// Connected-services registry UI. Goal (per dispatch): CLEAN + EASY TO+// UNDERSTAND. You see your integrations at a glance, add/edit one in a small+// inline form, test the connection, and pick which workers may use it.+//+// All data flows through integrationsClient — this component never touches IPC+// directly, so it is unaffected when that client is wired to Jim's registry.++const labelStyle: CSSProperties = {+ fontFamily: 'var(--cth-font-display)',+ fontSize: 8,+ lineHeight: '12px',+ color: 'var(--cth-ink-500)',+ textTransform: 'uppercase'+};++const inputStyle: CSSProperties = {+ padding: '6px 8px',+ background: 'var(--cth-paper-100)',+ border: 'none',+ boxShadow: 'inset 0 0 0 1px var(--cth-ink-300)',+ fontSize: 13,+ lineHeight: '18px',+ color: 'var(--cth-ink-900)'+};++const STATUS_META: Record<IntegrationStatus, { dot: string; color: string; text: string }> = {+ ok: { dot: '●', color: 'var(--cth-mint-700, #1f7a4d)', text: 'Connected' },+ error: { dot: '●', color: '#6E1423', text: 'Error' },+ untested: { dot: '○', color: 'var(--cth-ink-500)', text: 'Not tested' }+};++/** Blank draft for the Add form, seeded to the first template. */+function blankDraft(templates: IntegrationTemplate[]): IntegrationDraft {+ return {+ label: '',+ templateId: templates[0]?.id ?? '',+ fields: {},+ secret: '',+ workers: []+ };+}++/** Draft for editing an existing entry — note: no secret is ever pulled back. */+function draftFromEntry(entry: IntegrationEntry): IntegrationDraft {+ return {+ id: entry.id,+ label: entry.label,+ templateId: entry.templateId,+ fields: { ...entry.fields },+ secret: '', // write-only: starts empty, blank-on-save keeps the stored secret+ workers: [...entry.workers]+ };+}++export function IntegrationsRegistry() {+ const [templates, setTemplates] = useState<IntegrationTemplate[]>([]);+ const [workers, setWorkers] = useState<IntegrationWorker[]>([]);+ const [entries, setEntries] = useState<IntegrationEntry[]>([]);+ const [draft, setDraft] = useState<IntegrationDraft | null>(null);+ const [busy, setBusy] = useState(false);+ const [testingId, setTestingId] = useState<string | null>(null);+ const [note, setNote] = useState('');++ const flash = (msg: string) => {+ setNote(msg);+ setTimeout(() => setNote(''), 2200);+ };++ const refresh = async () => {+ setEntries(await integrationsClient.list());+ };++ useEffect(() => {+ let alive = true;+ (async () => {+ const [tpls, wkrs, list] = await Promise.all([+ integrationsClient.listTemplates(),+ integrationsClient.listWorkers(),+ integrationsClient.list()+ ]);+ if (!alive) return;+ setTemplates(tpls);+ setWorkers(wkrs);+ setEntries(list);+ })();+ return () => { alive = false; };+ }, []);++ const templateOf = (id: string) => templates.find((t) => t.id === id);+ const editing = draft?.id != null;+ const editEntry = editing ? entries.find((e) => e.id === draft?.id) : undefined;+ const activeTemplate = draft ? templateOf(draft.templateId) : undefined;++ const onSave = async () => {+ if (!draft) return;+ if (!draft.label.trim()) { flash('Give it a label first.'); return; }+ if (!draft.templateId) { flash('Pick a kind first.'); return; }+ setBusy(true);+ try {+ // Write-only secret: only send it when the user actually typed one.+ const payload: IntegrationDraft = {+ ...draft,+ label: draft.label.trim(),+ secret: draft.secret && draft.secret.length > 0 ? draft.secret : undefined+ };+ await integrationsClient.save(payload);+ setDraft(null);+ await refresh();+ flash(editing ? 'Integration updated.' : 'Integration added.');+ } catch {+ flash('Could not save.');+ } finally {+ setBusy(false);+ }+ };++ const onRemove = async (entry: IntegrationEntry) => {+ setBusy(true);+ try {+ await integrationsClient.remove(entry.id);+ if (draft?.id === entry.id) setDraft(null);+ await refresh();+ flash(`Removed “${entry.label}”.`);+ } catch {+ flash('Could not remove.');+ } finally {+ setBusy(false);+ }+ };++ const onTest = async (entry: IntegrationEntry) => {+ setTestingId(entry.id);+ try {+ const res = await integrationsClient.test(entry.id);+ await refresh();+ flash(res.message);+ } catch {+ flash('Test failed to run.');+ } finally {+ setTestingId(null);+ }+ };++ const setField = (key: string, value: string) =>+ setDraft((d) => (d ? { ...d, fields: { ...d.fields, [key]: value } } : d));++ const toggleWorker = (id: string) =>+ setDraft((d) => {+ if (!d) return d;+ const has = d.workers.includes(id);+ return { ...d, workers: has ? d.workers.filter((w) => w !== id) : [...d.workers, id] };+ });++ return (+ <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>+ <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 12 }}>+ <div style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>+ <div style={{ ...labelStyle, marginBottom: 2 }}>Connected services</div>+ <span style={{ fontSize: 12, lineHeight: '16px', color: 'var(--cth-ink-500)' }}>+ Add a service once, store its secret securely, and choose which workers may use it.+ </span>+ </div>+ {!draft && (+ <PixelButton+ variant="primary"+ size="sm"+ onClick={() => setDraft(blankDraft(templates))}+ disabled={busy || templates.length === 0}+ >+ + add integration+ </PixelButton>+ )}+ </div>++ {/* List of configured integrations */}+ {entries.length === 0 && !draft && (+ <div style={{+ padding: '14px 12px', textAlign: 'center',+ background: 'var(--cth-paper-100)',+ boxShadow: 'inset 0 0 0 1px var(--cth-ink-300)',+ fontSize: 12, lineHeight: '16px', color: 'var(--cth-ink-500)'+ }}>+ No integrations yet. Press “add integration” to connect your first service.+ </div>+ )}++ {entries.length > 0 && (+ <div style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>+ {entries.map((entry) => {+ const tpl = templateOf(entry.templateId);+ const st = STATUS_META[entry.status];+ const assigned = workers.filter((w) => entry.workers.includes(w.id));+ return (+ <div+ key={entry.id}+ style={{+ display: 'flex', flexDirection: 'column', gap: 6, padding: '8px 10px',+ background: 'var(--cth-paper-100)',+ boxShadow: 'inset 0 0 0 1px var(--cth-ink-300)'+ }}+ >+ <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 12 }}>+ <div style={{ display: 'flex', flexDirection: 'column', gap: 2, minWidth: 0 }}>+ <span style={{ fontSize: 13, lineHeight: '18px', color: 'var(--cth-ink-900)', fontWeight: 600 }}>+ {entry.label}+ <code style={{ marginLeft: 6, fontFamily: 'var(--cth-font-mono)', fontSize: 11, color: 'var(--cth-ink-500)', fontWeight: 400 }}>+ {tpl?.label ?? entry.templateId}+ </code>+ </span>+ <span style={{ fontSize: 11, lineHeight: '15px', color: 'var(--cth-ink-500)' }}>+ {entry.hasSecret ? 'secret set' : 'no secret'}+ {' · '}+ <span style={{ color: st.color }}>{st.dot} {st.text}</span>+ </span>+ </div>+ <div style={{ display: 'flex', gap: 6, flexShrink: 0 }}>+ <PixelButton+ variant="secondary" size="sm"+ onClick={() => { void onTest(entry); }}+ disabled={busy || testingId === entry.id}+ >+ {testingId === entry.id ? '…' : 'test'}+ </PixelButton>+ <PixelButton variant="ghost" size="sm" onClick={() => setDraft(draftFromEntry(entry))} disabled={busy}>+ edit+ </PixelButton>+ <PixelButton variant="ghost" size="sm" onClick={() => { void onRemove(entry); }} disabled={busy}>+ remove+ </PixelButton>+ </div>+ </div>++ {/* Which workers can use it */}+ <div style={{ display: 'flex', alignItems: 'center', gap: 6, flexWrap: 'wrap' }}>+ <span style={{ ...labelStyle }}>Workers</span>+ {assigned.length === 0 ? (+ <span style={{ fontSize: 11, color: 'var(--cth-ink-500)' }}>none assigned</span>+ ) : (+ assigned.map((w) => (+ <span key={w.id} style={{+ fontSize: 11, lineHeight: '16px', padding: '1px 6px',+ background: 'var(--cth-cream-200)',+ boxShadow: 'inset 0 0 0 1px var(--cth-ink-300)',+ color: 'var(--cth-ink-900)'+ }}>{w.label}</span>+ ))+ )}+ </div>+ </div>+ );+ })}+ </div>+ )}++ {/* Add / edit form */}+ {draft && (+ <div style={{+ display: 'flex', flexDirection: 'column', gap: 10, padding: '12px',+ background: 'var(--cth-paper-100)',+ boxShadow: 'inset 0 0 0 2px var(--cth-ink-700)'+ }}>+ <div style={{ ...labelStyle, color: 'var(--cth-ink-700)' }}>+ {editing ? 'Edit integration' : 'New integration'}+ </div>++ <label style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>+ <span style={labelStyle}>Label</span>+ <input+ value={draft.label}+ onChange={(e) => setDraft({ ...draft, label: e.target.value })}+ placeholder="e.g. Prod GitHub"+ style={inputStyle}+ />+ </label>++ <label style={{ display: 'flex', flexDirection: 'column', gap: 4, width: 280 }}>+ <span style={labelStyle}>Kind</span>+ <select+ value={draft.templateId}+ onChange={(e) => setDraft({ ...draft, templateId: e.target.value, fields: {} })}+ disabled={editing /* kind is fixed once created */}+ style={{ ...inputStyle, fontFamily: 'var(--cth-font-mono)' }}+ >+ {templates.map((t) => (+ <option key={t.id} value={t.id}>{t.label}</option>+ ))}+ </select>+ {activeTemplate?.description && (+ <span style={{ fontSize: 11, lineHeight: '15px', color: 'var(--cth-ink-500)' }}>+ {activeTemplate.description}+ </span>+ )}+ </label>++ {/* Non-secret fields the chosen kind needs */}+ {activeTemplate?.fields.map((f) => (+ <label key={f.key} style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>+ <span style={labelStyle}>{f.label}{f.optional ? ' (optional)' : ''}</span>+ <input+ value={draft.fields[f.key] ?? ''}+ onChange={(e) => setField(f.key, e.target.value)}+ placeholder={f.placeholder}+ style={{ ...inputStyle, fontFamily: 'var(--cth-font-mono)' }}+ />+ </label>+ ))}++ {/* Secret — WRITE-ONLY. Never pre-filled, never echoed back. */}+ <label style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>+ <span style={labelStyle}>{activeTemplate?.secretLabel ?? 'Secret'}</span>+ <input+ type="password"+ value={draft.secret ?? ''}+ onChange={(e) => setDraft({ ...draft, secret: e.target.value })}+ placeholder={+ editing && editEntry?.hasSecret+ ? '•••••••• stored — leave blank to keep'+ : `Paste your ${(activeTemplate?.secretLabel ?? 'secret').toLowerCase()}`+ }+ autoComplete="off"+ style={{ ...inputStyle, fontFamily: 'var(--cth-font-mono)' }}+ />+ <span style={{ fontSize: 11, lineHeight: '15px', color: 'var(--cth-ink-500)' }}>+ Stored securely and never shown again.+ {editing && editEntry?.hasSecret ? ' Leave blank to keep the current secret.' : ''}+ </span>+ </label>++ {/* Which workers can use it */}+ <div style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>+ <span style={labelStyle}>Workers that can use it</span>+ <div style={{ display: 'flex', flexWrap: 'wrap', gap: 6 }}>+ {workers.length === 0 && (+ <span style={{ fontSize: 11, color: 'var(--cth-ink-500)' }}>no workers available</span>+ )}+ {workers.map((w) => {+ const on = draft.workers.includes(w.id);+ return (+ <button+ key={w.id}+ type="button"+ onClick={() => toggleWorker(w.id)}+ style={{+ padding: '2px 8px', border: 'none', cursor: 'pointer',+ fontSize: 11, lineHeight: '16px', color: 'var(--cth-ink-900)',+ background: on ? 'var(--cth-lemon)' : 'var(--cth-cream-200)',+ boxShadow: `inset 0 0 0 1px ${on ? 'var(--cth-ink-900)' : 'var(--cth-ink-300)'}`+ }}+ >+ {on ? '✓ ' : ''}{w.label}+ </button>+ );+ })}+ </div>+ </div>++ <div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>+ <PixelButton variant="primary" size="sm" onClick={() => { void onSave(); }} disabled={busy}>+ {busy ? '…' : editing ? 'save changes' : 'add'}+ </PixelButton>+ <PixelButton variant="secondary" size="sm" onClick={() => setDraft(null)} disabled={busy}>+ cancel+ </PixelButton>+ </div>+ </div>+ )}++ {note && <span style={{ fontSize: 12, color: 'var(--cth-ink-700)' }}>{note}</span>}+ </div>+ );+}diff --git a/src/renderer/src/components/SettingsModal.tsx b/src/renderer/src/components/SettingsModal.tsxindex aa14f862..0b6d8c7d 100644--- a/src/renderer/src/components/SettingsModal.tsx+++ b/src/renderer/src/components/SettingsModal.tsx@@ -6,6 +6,7 @@ import { PixelButton } from './PixelButton';import { Icon } from './Icon';import { OfficeThemePicker } from './OfficeThemePicker';import { McpDefaultsSettings } from './McpDefaultsSettings';+import { IntegrationsRegistry } from './IntegrationsRegistry';export interface SettingsModalProps {config: HarnessConfig;@@ -799,6 +800,13 @@ export function SettingsModal({ config, onClose }: SettingsModalProps) {{/* INTEGRATIONS */}{activeSection === 'Integrations' && (<>+ {/* Connected-services registry (generic, registry-driven).+ Leads the section; the hardcoded Slack/Webhook/Free Flow+ blocks below stay as-is. */}+ <IntegrationsRegistry />++ <div style={{ height: 2, background: 'var(--cth-ink-300)' }} />+{/* Slack integration */}<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}><div style={{diff --git a/src/renderer/src/integrations/registryClient.ts b/src/renderer/src/integrations/registryClient.tsnew file mode 100644index 00000000..5baa83b9--- /dev/null+++ b/src/renderer/src/integrations/registryClient.ts@@ -0,0 +1,180 @@+// Integrations registry client — the renderer's single doorway to the+// integrations registry + secret broker.+//+// ⚠️ PROVISIONAL: the types and the client body below are a scaffold. They will+// be CONFORMED to Jim's hive/docs/integrations-spec.md (registry schema + IPC+// channel names) once it is published. Conforming is intentionally a ONE-FILE+// change: swap the in-memory mock bodies for `window.cth.*` IPC calls and align+// the types with the spec. The UI (IntegrationsRegistry.tsx) talks ONLY to this+// module, never to IPC directly, so nothing downstream changes when we wire up.+//+// SECURITY INVARIANT (must survive conformance): a secret value flows ONE WAY —+// from the form into save()/test() and onward to the broker. It is NEVER read+// back. `IntegrationEntry` carries `hasSecret: boolean` (presence only); there+// is no field that could carry the secret value back to the renderer.++/** A non-secret field a template asks the user to fill in. */+export interface IntegrationFieldSpec {+ key: string;+ label: string;+ placeholder?: string;+ optional?: boolean;+}++/** A kind/template of integration (authored by Dwight; served by the registry). */+export interface IntegrationTemplate {+ /** Stable kind id, e.g. 'slack', 'github', 'generic-http'. */+ id: string;+ label: string;+ description?: string;+ /** Human label for the one secret this kind needs, e.g. 'Bot token'. */+ secretLabel: string;+ /** Non-secret config fields. */+ fields: IntegrationFieldSpec[];+}++export type IntegrationStatus = 'untested' | 'ok' | 'error';++/** A configured integration instance. The secret value is NEVER present here. */+export interface IntegrationEntry {+ id: string;+ /** User-given label. */+ label: string;+ /** Template/kind id this instance is built from. */+ templateId: string;+ /** Non-secret field values. */+ fields: Record<string, string>;+ /** Whether a secret has been stored in the broker for this entry (value never echoed). */+ hasSecret: boolean;+ /** Worker ids that are allowed to use this integration. */+ workers: string[];+ status: IntegrationStatus;+ /** Epoch ms of the last test-connection, if any. */+ lastTestedAt?: number;+}++/** A worker that may be granted use of an integration. */+export interface IntegrationWorker {+ id: string;+ label: string;+}++/** Result of a test-connection probe. */+export interface TestResult {+ ok: boolean;+ message: string;+}++/**+ * Payload for add (no `id`) or edit (with `id`). `secret` is WRITE-ONLY:+ * include it to (re)set the secret; omit it to leave the stored secret as-is.+ */+export interface IntegrationDraft {+ id?: string;+ label: string;+ templateId: string;+ fields: Record<string, string>;+ secret?: string;+ workers: string[];+}++export interface IntegrationsClient {+ listTemplates(): Promise<IntegrationTemplate[]>;+ listWorkers(): Promise<IntegrationWorker[]>;+ list(): Promise<IntegrationEntry[]>;+ /** Add (draft.id absent) or edit (draft.id present). Returns the saved entry (no secret). */+ save(draft: IntegrationDraft): Promise<IntegrationEntry>;+ remove(id: string): Promise<void>;+ test(id: string): Promise<TestResult>;+}++// ---------------------------------------------------------------------------+// PROVISIONAL in-memory mock. Replaced wholesale when Jim's IPC lands:+// listTemplates() -> window.cth.integrationsTemplates()+// listWorkers() -> derive from the agent roster / window.cth.hiveRegistry()+// list() -> window.cth.integrationsList()+// save(draft) -> window.cth.integrationsSave(draft) (secret -> broker)+// remove(id) -> window.cth.integrationsRemove(id)+// test(id) -> window.cth.integrationsTest(id)+// ---------------------------------------------------------------------------++const MOCK_TEMPLATES: IntegrationTemplate[] = [+ {+ id: 'generic-http',+ label: 'HTTP API',+ description: 'A generic bearer-token HTTP endpoint.',+ secretLabel: 'API token',+ fields: [{ key: 'baseUrl', label: 'Base URL', placeholder: 'https://api.example.com' }]+ },+ {+ id: 'github',+ label: 'GitHub',+ description: 'Read/write GitHub via a personal access token.',+ secretLabel: 'Personal access token',+ fields: [{ key: 'org', label: 'Org / owner', placeholder: 'acme', optional: true }]+ },+ {+ id: 'slack',+ label: 'Slack',+ description: 'Post and read messages with a bot token.',+ secretLabel: 'Bot token',+ fields: [{ key: 'defaultChannel', label: 'Default channel id', placeholder: 'C0123…', optional: true }]+ }+];++const MOCK_WORKERS: IntegrationWorker[] = [+ { id: 'michael', label: 'Michael (manager)' },+ { id: 'jim', label: 'Jim' },+ { id: 'pam', label: 'Pam' },+ { id: 'dwight', label: 'Dwight' }+];++let mockEntries: IntegrationEntry[] = [];+let mockSeq = 1;+// Secrets live only in this set's membership (presence), never their values —+// mirrors the broker boundary so the UI behaves identically once wired.+const mockHasSecret = new Set<string>();++function delay<T>(value: T): Promise<T> {+ return Promise.resolve(value);+}++export const integrationsClient: IntegrationsClient = {+ listTemplates: () => delay(MOCK_TEMPLATES.map((t) => ({ ...t }))),+ listWorkers: () => delay(MOCK_WORKERS.map((w) => ({ ...w }))),+ list: () => delay(mockEntries.map((e) => ({ ...e, hasSecret: mockHasSecret.has(e.id) }))),+ save: (draft) => {+ const id = draft.id ?? `int-${mockSeq++}`;+ if (draft.secret && draft.secret.length > 0) mockHasSecret.add(id);+ const entry: IntegrationEntry = {+ id,+ label: draft.label,+ templateId: draft.templateId,+ fields: { ...draft.fields },+ hasSecret: mockHasSecret.has(id),+ workers: [...draft.workers],+ // Changing config invalidates a prior pass; force a re-test.+ status: 'untested'+ };+ const idx = mockEntries.findIndex((e) => e.id === id);+ if (idx >= 0) mockEntries[idx] = entry;+ else mockEntries.push(entry);+ return delay({ ...entry });+ },+ remove: (id) => {+ mockEntries = mockEntries.filter((e) => e.id !== id);+ mockHasSecret.delete(id);+ return delay(undefined);+ },+ test: (id) => {+ const entry = mockEntries.find((e) => e.id === id);+ if (!entry) return delay({ ok: false, message: 'No such integration.' });+ const ok = mockHasSecret.has(id);+ entry.status = ok ? 'ok' : 'error';+ entry.lastTestedAt = 0; // stamped by the real broker; mock leaves 0+ return delay({+ ok,+ message: ok ? 'Connection OK (mock).' : 'No secret set — add one to connect.'+ });+ }+};