@hanzo/app 0.3.85 → 0.3.87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,43 +5,43 @@ import { useI18n } from '@hanzo/i18n/react';
5
5
  import { useIam } from '@hanzo/iam/react';
6
6
  import { Input, Text, XStack, YStack } from '@hanzo/gui';
7
7
  import { Dialog, DialogContent, DialogTitle } from '@hanzo/ui';
8
- import { Check, ChevronRight, Plug, Plus, RefreshCw, Search, X } from 'lucide-react';
8
+ import { Check, ChevronRight, ExternalLink, Plug, Plus, RefreshCw, Search, X } from 'lucide-react';
9
9
  import { siDropbox, siGithub, siGooglecalendar, siGoogledrive, siHubspot, siLinear, siNotion, siQuickbooks, siShopify, siStripe, siSupabase, } from 'simple-icons';
10
- import { useKept } from '../kept.js';
11
10
  import { Network } from '../network.js';
12
11
  import { api } from '../lib/api.js';
13
12
  import { scope } from '../lib/session.js';
14
13
  import { enter } from '../lib/destination.js';
14
+ import { slackSyncChannels } from './api.js';
15
15
  import { CLIP, PILL, ROUND, WORD } from './kit.js';
16
16
  import { DIM, FLOOR, GROUND, INK, LINE, PICKED, RAISED } from './ink.js';
17
17
  export const CONNECTOR_CATALOG = [
18
18
  // Popular
19
- { id: 'gmail', name: 'Gmail', description: 'Read, draft, triage, and manage Gmail threads', section: 'popular', filter: 'productivity', network: 'gmail' },
20
- { id: 'google-drive', name: 'Google Drive', description: 'Drive, Docs, Sheets, and Slides', section: 'popular', filter: 'productivity', icon: siGoogledrive },
21
- { id: 'slack', name: 'Slack', description: 'Answer channels, threads, and workspace DMs', section: 'popular', filter: 'channels', network: 'slack' },
19
+ { id: 'slack', name: 'Slack', description: 'Sync @hanzo to Slack channels, threads, and workspace DMs', section: 'popular', filter: 'channels', network: 'slack' },
22
20
  { id: 'github', name: 'GitHub', description: 'Triage PRs, issues, CI runs, and release flows', section: 'popular', filter: 'productivity', icon: siGithub },
21
+ { id: 'linear', name: 'Linear', description: 'Track issues, cycles, projects, and triage', section: 'popular', filter: 'productivity', icon: siLinear },
22
+ { id: 'gmail', providerId: 'google', name: 'Gmail', description: 'Read, draft, triage, and manage Gmail threads', section: 'popular', filter: 'productivity', network: 'gmail' },
23
+ { id: 'google-drive', providerId: 'google', name: 'Google Drive', description: 'Drive, Docs, Sheets, and Slides', section: 'popular', filter: 'productivity', icon: siGoogledrive },
23
24
  { id: 'whatsapp', name: 'WhatsApp', description: 'Reply to customer and team chats on WhatsApp', section: 'popular', filter: 'channels', network: 'whatsapp' },
24
- { id: 'supabase', name: 'Supabase', description: 'Manage and query Postgres databases', section: 'popular', filter: 'productivity', icon: siSupabase },
25
25
  // Messaging & Social
26
- { id: 'telegram', name: 'Telegram', description: 'Run bots across Telegram chats and groups', section: 'channels', filter: 'channels', network: 'telegram' },
27
26
  { id: 'discord', name: 'Discord', description: 'Respond in community servers, channels, and threads', section: 'channels', filter: 'channels', network: 'discord' },
27
+ { id: 'telegram', name: 'Telegram', description: 'Run bots across Telegram chats and groups', section: 'channels', filter: 'channels', network: 'telegram' },
28
+ { id: 'teams', name: 'Microsoft Teams', description: 'Join organization channels and enterprise chats', section: 'channels', filter: 'channels', network: 'teams' },
28
29
  { id: 'x', name: 'X', description: 'Post updates, monitor mentions, and reply to DMs', section: 'channels', filter: 'channels', network: 'x' },
29
30
  { id: 'instagram', name: 'Instagram', description: 'Publish media and answer Instagram messages', section: 'channels', filter: 'channels', network: 'instagram' },
30
31
  { id: 'linkedin', name: 'LinkedIn', description: 'Schedule posts and manage company presence', section: 'channels', filter: 'channels', network: 'linkedin' },
31
- { id: 'teams', name: 'Microsoft Teams', description: 'Join organization channels and enterprise chats', section: 'channels', filter: 'channels', network: 'teams' },
32
32
  { id: 'signal', name: 'Signal', description: 'Encrypted direct messages and group alerts', section: 'channels', filter: 'channels', network: 'signal' },
33
33
  { id: 'zoom', name: 'Zoom', description: 'Join meetings, summaries, and call transcripts', section: 'channels', filter: 'channels', network: 'zoom' },
34
34
  // Small Business
35
- { id: 'dropbox', name: 'Dropbox', description: 'Find, create, and organize shared files', section: 'business', filter: 'business', icon: siDropbox },
36
- { id: 'quickbooks', name: 'Intuit QuickBooks', description: 'Accounting, invoices, payments, and payroll', section: 'business', filter: 'business', icon: siQuickbooks },
37
- { id: 'hubspot', name: 'HubSpot', description: 'Insights to action in HubSpot CRM', section: 'business', filter: 'business', icon: siHubspot },
38
35
  { id: 'stripe', name: 'Stripe', description: 'Accept payments, inspect invoices, and grow revenue', section: 'business', filter: 'business', icon: siStripe },
36
+ { id: 'hubspot', name: 'HubSpot', description: 'Insights to action in HubSpot CRM', section: 'business', filter: 'business', icon: siHubspot },
39
37
  { id: 'shopify', name: 'Shopify', description: 'Orders, catalog inventory, and customer support', section: 'business', filter: 'business', icon: siShopify },
38
+ { id: 'dropbox', name: 'Dropbox', description: 'Find, create, and organize shared files', section: 'business', filter: 'business', icon: siDropbox },
39
+ { id: 'quickbooks', name: 'Intuit QuickBooks', description: 'Accounting, invoices, payments, and payroll', section: 'business', filter: 'business', icon: siQuickbooks },
40
40
  // Productivity & Developer
41
41
  { id: 'notion', name: 'Notion', description: 'Create docs, tasks, and databases', section: 'productivity', filter: 'productivity', icon: siNotion },
42
- { id: 'google-calendar', name: 'Google Calendar', description: 'Read availability and schedule events', section: 'productivity', filter: 'productivity', icon: siGooglecalendar },
43
- { id: 'linear', name: 'Linear', description: 'Track issues, cycles, projects, and triage', section: 'productivity', filter: 'productivity', icon: siLinear },
44
- { id: 'outlook', name: 'Outlook', description: 'Read and send Microsoft 365 mail and invites', section: 'productivity', filter: 'productivity', network: 'outlook' },
42
+ { id: 'supabase', name: 'Supabase', description: 'Manage and query Postgres databases', section: 'productivity', filter: 'productivity', icon: siSupabase },
43
+ { id: 'google-calendar', providerId: 'google', name: 'Google Calendar', description: 'Read availability and schedule events', section: 'productivity', filter: 'productivity', icon: siGooglecalendar },
44
+ { id: 'outlook', providerId: 'microsoft', name: 'Outlook', description: 'Read and send Microsoft 365 mail and invites', section: 'productivity', filter: 'productivity', network: 'outlook' },
45
45
  ];
46
46
  const SECTIONS = [
47
47
  { id: 'popular', title: 'Popular' },
@@ -50,12 +50,15 @@ const SECTIONS = [
50
50
  { id: 'productivity', title: 'Productivity & Developer' },
51
51
  ];
52
52
  const FILTERS = [
53
- { id: 'all', label: 'Public' },
54
- { id: 'personal', label: 'Personal' },
53
+ { id: 'all', label: 'All' },
54
+ { id: 'personal', label: 'Connected' },
55
55
  { id: 'channels', label: 'Messaging & Social' },
56
56
  { id: 'business', label: 'Small Business' },
57
57
  { id: 'productivity', label: 'Productivity' },
58
58
  ];
59
+ function backendId(item) {
60
+ return (item.providerId || item.id).toLowerCase();
61
+ }
59
62
  function Mark({ item }) {
60
63
  if (item.network) {
61
64
  return (_jsx(YStack, { width: 36, height: 36, rounded: 10, items: "center", justify: "center", shrink: 0, overflow: "hidden", children: _jsx(Network, { transport: item.network, size: 36 }) }));
@@ -71,14 +74,14 @@ export function ConnectorsCatalog({ defaultFilter = 'all', embedded = false, onC
71
74
  const signed = isAuthenticated && Boolean(accessToken);
72
75
  const [filter, setFilter] = useState(defaultFilter);
73
76
  const [query, setQuery] = useState('');
74
- const [localSaved, setLocalSaved] = useKept('hanzo.connectors.v1', {});
75
- const [remoteRegistry, setRemoteRegistry] = useState({});
77
+ const [registry, setRegistry] = useState({});
76
78
  const [busyId, setBusyId] = useState(null);
79
+ const [pendingOAuth, setPendingOAuth] = useState(null);
77
80
  const [configuring, setConfiguring] = useState(null);
78
81
  const [secret, setSecret] = useState('');
79
82
  const [statusNote, setStatusNote] = useState(null);
83
+ const [syncingSlack, setSyncingSlack] = useState(false);
80
84
  const [turn, setTurn] = useState(0);
81
- const registry = useMemo(() => ({ ...(localSaved ?? {}), ...remoteRegistry }), [localSaved, remoteRegistry]);
82
85
  const load = useCallback(async () => {
83
86
  if (!signed)
84
87
  return;
@@ -98,71 +101,116 @@ export function ConnectorsCatalog({ defaultFilter = 'all', embedded = false, onC
98
101
  connected: Boolean(p.connected),
99
102
  available: Boolean(p.available),
100
103
  account: String(link.account ?? link.label ?? ''),
104
+ scope: 'org',
101
105
  };
102
106
  }
103
107
  }
104
108
  if (connRes.status === 'fulfilled' && connRes.value?.connectors) {
105
109
  for (const c of connRes.value.connectors) {
106
- const id = String(c.provider ?? c.id ?? '').toLowerCase();
107
- if (!id)
110
+ const rawId = String(c.id ?? '');
111
+ const prov = String(c.provider ?? rawId.split(':')[0] ?? '').toLowerCase();
112
+ if (!prov)
108
113
  continue;
109
- next[id] = {
114
+ next[prov] = {
110
115
  connected: true,
111
- available: next[id]?.available ?? true,
112
- account: String(c.account ?? c.name ?? next[id]?.account ?? ''),
116
+ available: next[prov]?.available ?? true,
117
+ account: String(c.account ?? c.label ?? c.name ?? next[prov]?.account ?? ''),
118
+ scope: next[prov]?.connected ? next[prov]?.scope : 'user',
119
+ connectionId: rawId || `${prov}:default`,
113
120
  };
114
121
  }
115
122
  }
116
- setRemoteRegistry(next);
117
- }, [signed]);
123
+ setRegistry(next);
124
+ if (pendingOAuth && next[pendingOAuth]?.connected) {
125
+ setPendingOAuth(null);
126
+ setStatusNote(t('Connected {name}.', { name: pendingOAuth }));
127
+ onConnected?.();
128
+ }
129
+ }, [signed, pendingOAuth, onConnected, t]);
118
130
  useEffect(() => {
119
131
  void load();
120
132
  }, [turn, load]);
133
+ // Re-check live provider status whenever the user returns from an OAuth popup/tab.
134
+ useEffect(() => {
135
+ if (!signed)
136
+ return;
137
+ const refresh = () => {
138
+ if (document.visibilityState === 'visible')
139
+ void load();
140
+ };
141
+ window.addEventListener('focus', refresh);
142
+ document.addEventListener('visibilitychange', refresh);
143
+ return () => {
144
+ window.removeEventListener('focus', refresh);
145
+ document.removeEventListener('visibilitychange', refresh);
146
+ };
147
+ }, [signed, load]);
148
+ useEffect(() => {
149
+ if (!pendingOAuth || !signed)
150
+ return;
151
+ const timer = window.setInterval(() => void load(), 3000);
152
+ return () => window.clearInterval(timer);
153
+ }, [pendingOAuth, signed, load]);
154
+ const stateOf = useCallback((item) => registry[item.id] ?? registry[backendId(item)], [registry]);
121
155
  const connectItem = async (item) => {
122
156
  if (!signed) {
123
157
  enter();
124
158
  return;
125
159
  }
126
- const state = registry[item.id];
160
+ const target = backendId(item);
161
+ const state = stateOf(item);
127
162
  setBusyId(item.id);
128
163
  setStatusNote(null);
129
164
  if (state?.connected) {
130
165
  try {
131
- await fetch(`${api()}/v1/provider/${encodeURIComponent(item.id)}/disconnect`, {
132
- method: 'POST',
133
- headers: { ...scope(), 'Content-Type': 'application/json' },
134
- body: '{}',
135
- }).catch(() => null);
166
+ if (state.scope === 'user' && state.connectionId) {
167
+ await fetch(`${api()}/v1/connection/${encodeURIComponent(state.connectionId)}`, {
168
+ method: 'DELETE',
169
+ headers: scope(),
170
+ }).catch(() => null);
171
+ }
172
+ else {
173
+ await fetch(`${api()}/v1/provider/${encodeURIComponent(target)}/disconnect`, {
174
+ method: 'POST',
175
+ headers: { ...scope(), 'Content-Type': 'application/json' },
176
+ body: '{}',
177
+ }).catch(() => null);
178
+ }
136
179
  }
137
180
  finally {
138
- const copy = { ...(localSaved ?? {}) };
139
- delete copy[item.id];
140
- setLocalSaved(copy);
141
- setRemoteRegistry((prev) => {
142
- const next = { ...prev };
143
- delete next[item.id];
144
- return next;
145
- });
181
+ await load();
146
182
  setBusyId(null);
147
183
  onConnected?.();
148
184
  }
149
185
  return;
150
186
  }
151
187
  try {
152
- const r = await fetch(`${api()}/v1/provider/${encodeURIComponent(item.id)}/connect`, {
153
- method: 'POST',
154
- headers: { ...scope(), 'Content-Type': 'application/json' },
155
- body: '{}',
156
- });
157
- if (r.ok) {
158
- const j = (await r.json());
159
- if (j.authorizeUrl) {
160
- window.open(j.authorizeUrl, '_blank', 'noopener,noreferrer');
188
+ // User-scoped Google / GitHub connectors also expose `/user/connect`.
189
+ const connectPaths = target === 'google'
190
+ ? [`/v1/provider/google/connect`, `/v1/provider/google/user/connect`]
191
+ : [`/v1/provider/${encodeURIComponent(target)}/connect`];
192
+ for (const p of connectPaths) {
193
+ const r = await fetch(`${api()}${p}`, {
194
+ method: 'POST',
195
+ headers: { ...scope(), 'Content-Type': 'application/json' },
196
+ body: '{}',
197
+ });
198
+ if (r.ok) {
199
+ const j = (await r.json());
200
+ if (j.authorizeUrl) {
201
+ window.open(j.authorizeUrl, '_blank', 'noopener,noreferrer');
202
+ setPendingOAuth(target);
203
+ setStatusNote(t('Complete {name} authorization in the opened tab — status updates automatically once approved.', {
204
+ name: item.name,
205
+ }));
206
+ return;
207
+ }
208
+ if (j.connected) {
209
+ await load();
210
+ onConnected?.();
211
+ return;
212
+ }
161
213
  }
162
- setLocalSaved({ ...(localSaved ?? {}), [item.id]: { connected: true } });
163
- setTurn((n) => n + 1);
164
- onConnected?.();
165
- return;
166
214
  }
167
215
  setConfiguring(item);
168
216
  setSecret('');
@@ -178,25 +226,60 @@ export function ConnectorsCatalog({ defaultFilter = 'all', embedded = false, onC
178
226
  const saveCredential = async () => {
179
227
  if (!configuring || !secret.trim())
180
228
  return;
229
+ const target = backendId(configuring);
230
+ const token = secret.trim();
181
231
  setBusyId(configuring.id);
182
232
  setStatusNote(null);
183
233
  try {
184
- const r = await fetch(`${api()}/v1/connection`, {
185
- method: 'POST',
186
- headers: { ...scope(), 'Content-Type': 'application/json' },
187
- body: JSON.stringify({
188
- provider: configuring.id,
189
- name: configuring.name,
190
- token: secret.trim(),
191
- }),
192
- }).catch(() => null);
193
- setLocalSaved({
194
- ...(localSaved ?? {}),
195
- [configuring.id]: { connected: true, available: true },
196
- });
197
- setStatusNote(r?.ok
198
- ? t('Connected {name}.', { name: configuring.name })
199
- : t('Connected {name} for this workspace.', { name: configuring.name }));
234
+ let ok = false;
235
+ let detail = '';
236
+ // Telegram bot tokens bind directly on the org provider plane (`/v1/provider/telegram/connect`).
237
+ if (target === 'telegram') {
238
+ const r = await fetch(`${api()}/v1/provider/telegram/connect`, {
239
+ method: 'POST',
240
+ headers: { ...scope(), 'Content-Type': 'application/json' },
241
+ body: JSON.stringify({ token }),
242
+ });
243
+ ok = r.ok;
244
+ if (!r.ok) {
245
+ const j = (await r.json().catch(() => ({})));
246
+ detail = j.error?.message || j.message || '';
247
+ }
248
+ }
249
+ else {
250
+ // Try org-scoped apikey connect first, then per-user `/v1/connection/:provider/credential`.
251
+ const orgRes = await fetch(`${api()}/v1/provider/${encodeURIComponent(target)}/connect`, {
252
+ method: 'POST',
253
+ headers: { ...scope(), 'Content-Type': 'application/json' },
254
+ body: JSON.stringify({ token, apiKey: token }),
255
+ }).catch(() => null);
256
+ if (orgRes?.ok) {
257
+ const j = (await orgRes.json().catch(() => ({})));
258
+ if (!j.authorizeUrl)
259
+ ok = true;
260
+ }
261
+ if (!ok) {
262
+ const userRes = await fetch(`${api()}/v1/connection/${encodeURIComponent(target)}/credential`, {
263
+ method: 'POST',
264
+ headers: { ...scope(), 'Content-Type': 'application/json' },
265
+ body: JSON.stringify({ label: 'default', token }),
266
+ }).catch(() => null);
267
+ ok = Boolean(userRes?.ok);
268
+ if (userRes && !userRes.ok) {
269
+ const j = (await userRes.json().catch(() => ({})));
270
+ detail = j.error?.message || j.message || '';
271
+ }
272
+ }
273
+ }
274
+ if (!ok) {
275
+ setStatusNote(detail ||
276
+ t('Could not verify credential for {name}. Check the token or workspace OAuth configuration.', {
277
+ name: configuring.name,
278
+ }));
279
+ return;
280
+ }
281
+ await load();
282
+ setStatusNote(t('Connected {name}.', { name: configuring.name }));
200
283
  setConfiguring(null);
201
284
  setSecret('');
202
285
  onConnected?.();
@@ -205,10 +288,27 @@ export function ConnectorsCatalog({ defaultFilter = 'all', embedded = false, onC
205
288
  setBusyId(null);
206
289
  }
207
290
  };
291
+ const handleSlackSync = async () => {
292
+ setSyncingSlack(true);
293
+ setStatusNote(null);
294
+ try {
295
+ const res = await slackSyncChannels();
296
+ setStatusNote(res.ok
297
+ ? res.joined !== undefined
298
+ ? t('Synced @hanzo across {n} Slack channels.', { n: res.joined })
299
+ : t('Synced @hanzo across workspace Slack channels.')
300
+ : t('Could not sync Slack channels. Make sure Slack is connected with org admin permissions.'));
301
+ onConnected?.();
302
+ }
303
+ finally {
304
+ setSyncingSlack(false);
305
+ }
306
+ };
208
307
  const filtered = useMemo(() => {
209
308
  const q = query.trim().toLowerCase();
210
309
  return CONNECTOR_CATALOG.filter((item) => {
211
- if (filter === 'personal' && !registry[item.id]?.connected)
310
+ const st = stateOf(item);
311
+ if (filter === 'personal' && !st?.connected)
212
312
  return false;
213
313
  if (filter !== 'all' && filter !== 'personal' && item.filter !== filter)
214
314
  return false;
@@ -216,30 +316,36 @@ export function ConnectorsCatalog({ defaultFilter = 'all', embedded = false, onC
216
316
  return true;
217
317
  return item.name.toLowerCase().includes(q) || item.description.toLowerCase().includes(q) || item.id.includes(q);
218
318
  });
219
- }, [filter, query, registry]);
220
- return (_jsxs(YStack, { flex: 1, minH: 0, bg: embedded ? 'transparent' : GROUND, children: [_jsxs(YStack, { px: embedded ? 0 : 28, pt: embedded ? 0 : 22, pb: 14, gap: 14, borderBottomWidth: 1, borderColor: LINE, bg: embedded ? 'transparent' : FLOOR, children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: 12, flexWrap: "wrap", children: [_jsx(YStack, { gap: 3, children: embedded ? (_jsx(Text, { fontSize: 14, lineHeight: 20, color: DIM, children: t('Connect external apps, socials, and MCP servers to work across your tools.') })) : (_jsxs(_Fragment, { children: [_jsx(DialogTitle, { children: _jsx(Text, { fontSize: 21, lineHeight: 27, fontWeight: "600", color: INK, children: t('Connectors') }) }), _jsx(Text, { fontSize: 13, lineHeight: 18, color: DIM, children: t('Connect external apps, socials, and channels to work across your tools.') })] })) }), _jsxs(XStack, { items: "center", gap: 8, children: [_jsxs(XStack, { height: 34, width: 220, px: 11, gap: 7, items: "center", rounded: 999, bg: RAISED, borderWidth: 1, borderColor: LINE, children: [_jsx(Search, { size: 14, color: DIM, "aria-hidden": true }), _jsx(Input, { unstyled: true, value: query, onChange: (e) => setQuery(e.target.value), placeholder: t('Search connectors'), "aria-label": t('Search connectors'), flex: 1, minW: 0, color: INK, fontSize: 13, placeholderTextColor: "$placeholderColor" }), query ? (_jsx(XStack, { render: "button", type: 'button', "aria-label": t('Clear search'), onClick: () => setQuery(''), bg: "transparent", borderWidth: 0, p: 0, cursor: "pointer", children: _jsx(X, { size: 13, color: DIM, "aria-hidden": true }) })) : null] }), _jsx(XStack, { ...ROUND, width: 34, height: 34, "aria-label": t('Refresh connectors'), onClick: () => setTurn((n) => n + 1), children: _jsx(RefreshCw, { size: 14, color: DIM, "aria-hidden": true }) }), _jsxs(XStack, { ...PILL, render: "button", type: 'button', height: 34, px: 14, bg: INK, borderColor: INK, onClick: () => setConfiguring({
221
- id: 'custom-mcp',
222
- name: t('Custom MCP Server'),
223
- description: t('Connect any Model Context Protocol URL or bearer token'),
319
+ }, [filter, query, stateOf]);
320
+ return (_jsxs(YStack, { flex: 1, minH: 0, bg: embedded ? 'transparent' : GROUND, children: [_jsxs(YStack, { px: embedded ? 0 : 28, pt: embedded ? 0 : 22, pb: 14, gap: 14, borderBottomWidth: 1, borderColor: LINE, bg: embedded ? 'transparent' : FLOOR, children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: 12, flexWrap: "wrap", children: [_jsx(YStack, { gap: 3, children: embedded ? (_jsx(Text, { fontSize: 14, lineHeight: 20, color: DIM, children: t('Sync Slack (@hanzo), GitHub, Linear, and MCP servers so your Primary Bot and groups act across your stack.') })) : (_jsxs(_Fragment, { children: [_jsx(DialogTitle, { children: _jsx(Text, { fontSize: 21, lineHeight: 27, fontWeight: "600", color: INK, children: t('Connectors & Channels') }) }), _jsx(Text, { fontSize: 13, lineHeight: 18, color: DIM, children: t('Add @hanzo to Slack, link repos, and connect tools across every bot and group.') })] })) }), _jsxs(XStack, { items: "center", gap: 8, children: [_jsxs(XStack, { height: 34, width: 220, px: 11, gap: 7, items: "center", rounded: 999, bg: RAISED, borderWidth: 1, borderColor: LINE, children: [_jsx(Search, { size: 14, color: DIM, "aria-hidden": true }), _jsx(Input, { unstyled: true, value: query, onChange: (e) => setQuery(e.target.value), placeholder: t('Search connectors'), "aria-label": t('Search connectors'), flex: 1, minW: 0, color: INK, fontSize: 13, placeholderTextColor: "$placeholderColor" }), query ? (_jsx(XStack, { render: "button", type: 'button', "aria-label": t('Clear search'), onClick: () => setQuery(''), bg: "transparent", borderWidth: 0, p: 0, cursor: "pointer", children: _jsx(X, { size: 13, color: DIM, "aria-hidden": true }) })) : null] }), _jsx(XStack, { ...ROUND, width: 34, height: 34, "aria-label": t('Refresh connectors'), onClick: () => setTurn((n) => n + 1), children: _jsx(RefreshCw, { size: 14, color: DIM, "aria-hidden": true }) }), _jsxs(XStack, { ...PILL, render: "button", type: 'button', height: 34, px: 14, bg: INK, borderColor: INK, onClick: () => setConfiguring({
321
+ id: 'openai',
322
+ name: t('API Key Credential'),
323
+ description: t('Store a verified provider API token in KMS'),
224
324
  section: 'productivity',
225
325
  filter: 'productivity',
226
- }), children: [_jsx(Plus, { size: 13, color: "var(--background)", "aria-hidden": true }), _jsx(Text, { ...WORD, fontSize: 13, color: "var(--background)", children: t('Add') })] }), onClose ? (_jsx(XStack, { ...ROUND, width: 34, height: 34, "aria-label": t('Close connectors'), onClick: onClose, children: _jsx(X, { size: 15, color: INK, "aria-hidden": true }) })) : null] })] }), _jsx(XStack, { items: "center", gap: 6, flexWrap: "wrap", children: FILTERS.map((f) => {
326
+ }), children: [_jsx(Plus, { size: 13, color: "var(--background)", "aria-hidden": true }), _jsx(Text, { ...WORD, fontSize: 13, color: "var(--background)", children: t('Add token') })] }), onClose ? (_jsx(XStack, { ...ROUND, width: 34, height: 34, "aria-label": t('Close connectors'), onClick: onClose, children: _jsx(X, { size: 15, color: INK, "aria-hidden": true }) })) : null] })] }), _jsx(XStack, { items: "center", gap: 6, flexWrap: "wrap", children: FILTERS.map((f) => {
227
327
  const active = filter === f.id;
228
328
  return (_jsx(XStack, { render: "button", type: 'button', 'aria-pressed': active, onClick: () => setFilter(f.id), height: 30, px: 13, rounded: 999, items: "center", bg: active ? PICKED : 'transparent', borderWidth: 1, borderColor: active ? LINE : 'transparent', cursor: "pointer", hoverStyle: { bg: PICKED }, children: _jsx(Text, { fontSize: 13, lineHeight: 18, fontWeight: active ? '500' : '400', color: active ? INK : DIM, children: t(f.label) }) }, f.id));
229
- }) })] }), configuring ? (_jsxs(YStack, { px: embedded ? 0 : 28, py: 14, gap: 10, bg: RAISED, borderBottomWidth: 1, borderColor: LINE, children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: 10, children: [_jsxs(XStack, { items: "center", gap: 10, children: [_jsx(Mark, { item: configuring }), _jsxs(YStack, { children: [_jsx(Text, { fontSize: 14, lineHeight: 19, fontWeight: "600", color: INK, children: t('Connect {name}', { name: configuring.name }) }), _jsx(Text, { fontSize: 12, lineHeight: 17, color: DIM, children: configuring.id === 'custom-mcp'
230
- ? t('Enter an MCP server URL (https://…) or bearer credential.')
231
- : t('Paste an API key, webhook URL, or bot token for {name}.', { name: configuring.name }) })] })] }), _jsx(XStack, { ...ROUND, width: 28, height: 28, "aria-label": t('Cancel'), onClick: () => setConfiguring(null), children: _jsx(X, { size: 14, color: DIM, "aria-hidden": true }) })] }), _jsxs(XStack, { gap: 8, items: "center", children: [_jsx(Input, { unstyled: true, autoFocus: true, type: configuring.id === 'custom-mcp' ? 'url' : 'password', value: secret, onChange: (e) => setSecret(e.target.value), placeholder: configuring.id === 'custom-mcp' ? 'https://mcp.example.com/sse' : `${configuring.name} API key or token`, "aria-label": t('{name} credential', { name: configuring.name }), flex: 1, height: 36, px: 12, rounded: 9, bg: GROUND, borderWidth: 1, borderColor: LINE, color: INK, fontSize: 13, placeholderTextColor: "$placeholderColor" }), _jsx(XStack, { ...PILL, render: "button", type: 'button', height: 36, px: 16, bg: INK, borderColor: INK, opacity: secret.trim() ? 1 : 0.45, onClick: () => void saveCredential(), children: _jsx(Text, { ...WORD, fontSize: 13, color: "var(--background)", children: t('Connect') }) })] })] })) : null, statusNote ? (_jsxs(XStack, { px: embedded ? 0 : 28, py: 9, bg: RAISED, borderBottomWidth: 1, borderColor: LINE, items: "center", justify: "space-between", children: [_jsx(Text, { fontSize: 12, lineHeight: 17, color: DIM, children: statusNote }), _jsx(XStack, { render: "button", type: 'button', onClick: () => setStatusNote(null), bg: "transparent", borderWidth: 0, cursor: "pointer", children: _jsx(X, { size: 13, color: DIM, "aria-hidden": true }) })] })) : null, _jsxs(YStack, { flex: 1, minH: 0, overflowY: embedded ? undefined : 'auto', px: embedded ? 0 : 28, py: 20, gap: 24, children: [SECTIONS.map((sec) => {
329
+ }) })] }), configuring ? (_jsxs(YStack, { px: embedded ? 0 : 28, py: 14, gap: 10, bg: RAISED, borderBottomWidth: 1, borderColor: LINE, children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: 10, children: [_jsxs(XStack, { items: "center", gap: 10, children: [_jsx(Mark, { item: configuring }), _jsxs(YStack, { children: [_jsx(Text, { fontSize: 14, lineHeight: 19, fontWeight: "600", color: INK, children: t('Connect {name}', { name: configuring.name }) }), _jsx(Text, { fontSize: 12, lineHeight: 17, color: DIM, children: t('Paste an API key or bot token for {name}. Verified live before sealing in KMS.', {
330
+ name: configuring.name,
331
+ }) })] })] }), _jsx(XStack, { ...ROUND, width: 28, height: 28, "aria-label": t('Cancel'), onClick: () => setConfiguring(null), children: _jsx(X, { size: 14, color: DIM, "aria-hidden": true }) })] }), _jsxs(XStack, { gap: 8, items: "center", children: [_jsx(Input, { unstyled: true, autoFocus: true, type: "password", value: secret, onChange: (e) => setSecret(e.target.value), placeholder: `${configuring.name} token`, "aria-label": t('{name} credential', { name: configuring.name }), flex: 1, height: 36, px: 12, rounded: 9, bg: GROUND, borderWidth: 1, borderColor: LINE, color: INK, fontSize: 13, placeholderTextColor: "$placeholderColor" }), _jsx(XStack, { ...PILL, render: "button", type: 'button', height: 36, px: 16, bg: INK, borderColor: INK, opacity: secret.trim() ? 1 : 0.45, onClick: () => void saveCredential(), children: _jsx(Text, { ...WORD, fontSize: 13, color: "var(--background)", children: t('Verify & Save') }) })] })] })) : null, statusNote ? (_jsxs(XStack, { px: embedded ? 0 : 28, py: 9, bg: RAISED, borderBottomWidth: 1, borderColor: LINE, items: "center", justify: "space-between", gap: 8, children: [_jsx(Text, { fontSize: 12, lineHeight: 17, color: INK, children: statusNote }), _jsx(XStack, { render: "button", type: 'button', onClick: () => setStatusNote(null), bg: "transparent", borderWidth: 0, cursor: "pointer", children: _jsx(X, { size: 13, color: DIM, "aria-hidden": true }) })] })) : null, _jsxs(YStack, { flex: 1, minH: 0, overflowY: embedded ? undefined : 'auto', px: embedded ? 0 : 28, py: 20, gap: 24, children: [SECTIONS.map((sec) => {
232
332
  const items = filtered.filter((i) => i.section === sec.id);
233
333
  if (!items.length)
234
334
  return null;
235
335
  return (_jsxs(YStack, { gap: 10, children: [_jsxs(XStack, { items: "center", gap: 4, children: [_jsx(Text, { fontSize: 13, lineHeight: 18, fontWeight: "600", color: INK, children: t(sec.title) }), _jsx(ChevronRight, { size: 14, color: DIM, "aria-hidden": true })] }), _jsx(XStack, { flexWrap: "wrap", columnGap: 24, rowGap: 6, children: items.map((item) => {
236
- const state = registry[item.id];
336
+ const state = stateOf(item);
237
337
  const connected = Boolean(state?.connected);
338
+ const waiting = pendingOAuth === backendId(item);
238
339
  const busy = busyId === item.id;
239
- return (_jsxs(XStack, { "data-connector": item.id, width: "calc(50% - 12px)", "$max-md": { width: '100%' }, minH: 56, px: 10, py: 8, rounded: 12, items: "center", gap: 12, hoverStyle: { bg: RAISED }, children: [_jsx(Mark, { item: item }), _jsxs(YStack, { flex: 1, minW: 0, gap: 1, children: [_jsx(Text, { ...CLIP, fontSize: 14, lineHeight: 19, fontWeight: "500", color: INK, children: item.name }), _jsx(Text, { ...CLIP, fontSize: 12, lineHeight: 17, color: DIM, children: connected && state?.account ? `${t('Connected')} · ${state.account}` : item.description })] }), _jsx(XStack, { render: "button", type: 'button', "aria-label": connected ? t('Disconnect {name}', { name: item.name }) : t('Connect {name}', { name: item.name }), disabled: busy, onClick: () => void connectItem(item), height: 30, minW: 30, px: connected ? 10 : 0, rounded: 999, items: "center", justify: "center", gap: 5, bg: connected ? PICKED : 'transparent', borderWidth: connected ? 1 : 0, borderColor: LINE, cursor: "pointer", opacity: busy ? 0.5 : 1, hoverStyle: { bg: PICKED }, children: connected ? (_jsxs(_Fragment, { children: [_jsx(Check, { size: 13, color: INK, "aria-hidden": true }), _jsx(Text, { fontSize: 12, lineHeight: 16, fontWeight: "500", color: INK, children: t('Connected') })] })) : (_jsx(Plus, { size: 17, color: DIM, "aria-hidden": true })) })] }, item.id));
340
+ const isSlack = item.id === 'slack';
341
+ return (_jsxs(XStack, { "data-connector": item.id, width: "calc(50% - 12px)", "$max-md": { width: '100%' }, minH: 60, px: 10, py: 8, rounded: 12, items: "center", gap: 12, hoverStyle: { bg: RAISED }, children: [_jsx(Mark, { item: item }), _jsxs(YStack, { flex: 1, minW: 0, gap: 1, children: [_jsx(Text, { ...CLIP, fontSize: 14, lineHeight: 19, fontWeight: "500", color: INK, children: item.name }), _jsx(Text, { ...CLIP, fontSize: 12, lineHeight: 17, color: DIM, children: connected && state?.account
342
+ ? `${t('Connected')} · ${state.account}`
343
+ : waiting
344
+ ? t('Waiting for authorization…')
345
+ : item.description })] }), isSlack && connected ? (_jsxs(XStack, { render: "button", type: 'button', disabled: syncingSlack, onClick: () => void handleSlackSync(), height: 30, px: 10, rounded: 999, items: "center", gap: 5, bg: RAISED, borderWidth: 1, borderColor: LINE, cursor: "pointer", opacity: syncingSlack ? 0.5 : 1, hoverStyle: { bg: PICKED }, children: [_jsx(RefreshCw, { size: 12, color: INK, "aria-hidden": true }), _jsx(Text, { fontSize: 12, lineHeight: 16, fontWeight: "500", color: INK, children: syncingSlack ? t('Syncing…') : t('Sync channels') })] })) : null, _jsx(XStack, { render: "button", type: 'button', "aria-label": connected ? t('Disconnect {name}', { name: item.name }) : t('Connect {name}', { name: item.name }), disabled: busy, onClick: () => void connectItem(item), height: 30, minW: 30, px: connected || isSlack ? 11 : 8, rounded: 999, items: "center", justify: "center", gap: 5, bg: connected ? PICKED : isSlack ? INK : RAISED, borderWidth: 1, borderColor: connected ? LINE : isSlack ? INK : LINE, cursor: "pointer", opacity: busy ? 0.5 : 1, hoverStyle: { bg: connected ? PICKED : isSlack ? INK : PICKED, opacity: isSlack && !connected ? 0.9 : 1 }, children: connected ? (_jsxs(_Fragment, { children: [_jsx(Check, { size: 13, color: INK, "aria-hidden": true }), _jsx(Text, { fontSize: 12, lineHeight: 16, fontWeight: "500", color: INK, children: t('Connected') })] })) : isSlack ? (_jsxs(_Fragment, { children: [_jsx(ExternalLink, { size: 12, color: "var(--background)", "aria-hidden": true }), _jsx(Text, { fontSize: 12, lineHeight: 16, fontWeight: "500", color: "var(--background)", children: t('Add to Slack') })] })) : (_jsxs(_Fragment, { children: [_jsx(Plus, { size: 14, color: INK, "aria-hidden": true }), _jsx(Text, { fontSize: 12, lineHeight: 16, fontWeight: "500", color: INK, children: t('Connect') })] })) })] }, item.id));
240
346
  }) })] }, sec.id));
241
347
  }), filtered.length === 0 ? (_jsx(YStack, { py: 36, items: "center", gap: 8, children: _jsx(Text, { fontSize: 14, lineHeight: 20, color: DIM, children: filter === 'personal' && !query
242
- ? t('No personal connectors connected yet. Switch to Public to connect Slack, Stripe, Gmail, GitHub, and more.')
348
+ ? t('No connectors active yet. Switch to All to add @hanzo to Slack, connect GitHub, Linear, and more.')
243
349
  : t('No connectors match “{query}”.', { query }) }) })) : null] })] }));
244
350
  }
245
351
  export function ConnectorsDialog({ open, onOpenChange, defaultFilter = 'all', onConnected, }) {
@@ -0,0 +1,26 @@
1
+ import { type BotAgent, type BotGroup } from './api.js';
2
+ export declare function MakeGroupDialog({ bots, groups, initial, onDone, onCancel, }: {
3
+ bots: readonly BotAgent[];
4
+ groups: readonly BotGroup[];
5
+ initial?: BotGroup | null;
6
+ onDone: (g: BotGroup) => void | Promise<void>;
7
+ onCancel: () => void;
8
+ }): import("react").JSX.Element;
9
+ export declare function GroupThread({ group, bots, side, onSide, onBack, onEdit, onPickBot, }: {
10
+ group: BotGroup;
11
+ bots: readonly BotAgent[];
12
+ side: boolean;
13
+ onSide: () => void;
14
+ onBack: () => void;
15
+ onEdit: () => void;
16
+ onPickBot: (name: string) => void;
17
+ }): import("react").JSX.Element;
18
+ export declare function GroupPanel({ group, groups, bots, onClose, onEdit, onDelete, onPickBot, }: {
19
+ group: BotGroup;
20
+ groups: readonly BotGroup[];
21
+ bots: readonly BotAgent[];
22
+ onClose: () => void;
23
+ onEdit: () => void;
24
+ onDelete: () => Promise<void>;
25
+ onPickBot: (name: string) => void;
26
+ }): import("react").JSX.Element;