@hanzo/app 0.3.88 → 0.3.90

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.
package/dist/Account.js CHANGED
@@ -130,7 +130,12 @@ function usePlan(org, enabled) {
130
130
  /** The person's picture, or their initials. */
131
131
  export function Face({ host, size = 28 }) {
132
132
  const p = host.person;
133
- return (_jsx(XStack, { width: size, height: size, rounded: 9999, items: "center", justify: "center", bg: "$raised", overflow: "hidden", shrink: 0, borderWidth: 1, borderColor: "$borderColor", children: p?.avatar ? (_jsx("img", { src: p.avatar, alt: "", width: size, height: size })) : (_jsx(SizableText, { fontSize: Math.max(10, Math.round(size * 0.39)), lineHeight: size, fontWeight: "600", color: "$ink", children: initials(p?.name || p?.email || '') })) }));
133
+ const cleanSrc = p?.avatar && !(p.avatar.includes('gravatar.com/avatar/') && p.avatar.includes('d=identicon')) ? p.avatar : undefined;
134
+ const [failed, setFailed] = useState(false);
135
+ useEffect(() => {
136
+ setFailed(false);
137
+ }, [cleanSrc]);
138
+ return (_jsx(XStack, { width: size, height: size, rounded: 9999, items: "center", justify: "center", bg: "$raised", overflow: "hidden", shrink: 0, borderWidth: 1, borderColor: "$borderColor", children: cleanSrc && !failed ? (_jsx("img", { src: cleanSrc, alt: "", width: size, height: size, onError: () => setFailed(true) })) : (_jsx(SizableText, { fontSize: Math.max(10, Math.round(size * 0.39)), lineHeight: size, fontWeight: "600", color: "$ink", children: initials(p?.name || p?.email || '') })) }));
134
139
  }
135
140
  /** A row's face: its icon in a 20px well, its words, and what trails them. */
136
141
  function Line({ icon, children, sub, trail }) {
@@ -1,82 +1,223 @@
1
1
  'use client';
2
2
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- // Embedded Desktop Sandbox Computer modal for any bot on hanzo.bot:
4
- // - Live interactive X11 GUI desktop (`screen` ticket -> noVNC) + interactive shell (`terminal` ticket)
5
- // - Persistent per-bot disk (`bot-<name>`) and `computeRef` binding on the bot record
6
- // - Full Computer Use task bar so the user can watch the bot click, type, browse,
7
- // take screenshots, and run commands on its dedicated desktop in real time.
8
- import { useCallback, useEffect, useState } from 'react';
3
+ // Sleek, resumable macOS-framed Desktop Sandbox Computer modal for every bot on hanzo.bot:
4
+ // - Auto-boots or resumes persistent per-bot desktop sandbox (`Starting desktop` -> `Connecting` -> live 60fps X11/noVNC stream)
5
+ // - Floating bottom-center pill: `👁 Watching` | `[Take control]` (instant live toggle via postMessage to screen/page.html)
6
+ // - Native Desktop GUI + Interactive Terminal modes, Clipboard paste, Screenshot, Park/Sleep & instant Resume
7
+ // - Zero-knowledge 1-click Login & 2FA TOTP Autofill (`action: 'autofill'`) from Unified Vault (Hanzo KMS, 1Password, LastPass)
8
+ // - Co-working prompt drawer so you can watch the bot click, browse, log in, and work in real time or jump in yourself.
9
+ import { useCallback, useEffect, useRef, useState } from 'react';
9
10
  import { useI18n } from '@hanzo/i18n/react';
10
11
  import { Input, Text, XStack, YStack } from '@hanzo/gui';
11
- import { Dialog, DialogContent, DialogTitle } from '@hanzo/ui';
12
- import { Camera, ExternalLink, Monitor, Pause, Play, RefreshCw, Send, Terminal, X } from 'lucide-react';
12
+ import { Dialog, DialogContent, DialogTitle, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '@hanzo/ui';
13
+ import { Camera, ClipboardPaste, ExternalLink, Eye, KeyRound, Maximize2, Minimize2, Monitor, MousePointerClick, Pause, Play, RefreshCw, Send, Sparkles, Terminal, } from 'lucide-react';
13
14
  import { useAi } from '../lib/ai.js';
14
15
  import { say } from '../failure.js';
15
16
  import { called } from '../team.js';
16
- import { Face } from './face.js';
17
- import { actComputer, disk, grant, parkComputer, updateBotMeta } from './api.js';
18
- import { CLIP, PILL, ROUND, WORD } from './kit.js';
19
- import { DIM, FLOOR, GROUND, INK, LINE, PICKED, RAISED } from './ink.js';
17
+ import { VaultDialog, readVault } from '../vault.js';
18
+ import { actComputer, bootOrResumeComputer, disk, findBotComputer, grant, parkComputer, updateBotMeta, } from './api.js';
19
+ import { CLIP, PILL, WORD } from './kit.js';
20
+ import { DIM } from './ink.js';
21
+ // Always-dark translucent surfaces inside the pure-black desktop window chrome,
22
+ // invariant across light and dark page themes.
23
+ const FLOOR = 'var(--white-05)';
24
+ const RAISED = 'var(--white-08)';
25
+ const PICKED = 'var(--white-16)';
26
+ const LINE = 'var(--white-15)';
27
+ const INK = 'var(--pure-white)';
28
+ function PulsingCluster({ label }) {
29
+ const [step, setStep] = useState(0);
30
+ useEffect(() => {
31
+ const id = window.setInterval(() => setStep((s) => (s + 1) % 3), 480);
32
+ return () => window.clearInterval(id);
33
+ }, []);
34
+ return (_jsxs(YStack, { items: "center", justify: "center", gap: 18, "aria-live": "polite", children: [_jsx(XStack, { items: "center", justify: "center", gap: 6, height: 20, children: [0, 1, 2].map((i) => {
35
+ const active = step === i;
36
+ const mid = i === 1;
37
+ return (_jsx(YStack, { width: mid ? 7 : 4, height: mid ? 7 : 4, rounded: 999, bg: "var(--pure-white)", opacity: active ? 1 : 0.35 }, i));
38
+ }) }), _jsx(Text, { fontSize: 13, lineHeight: 18, fontWeight: "500", color: "var(--pure-white)", opacity: 0.58, children: label })] }));
39
+ }
40
+ function appendViewParam(rawUrl, viewOnly) {
41
+ try {
42
+ const u = new URL(rawUrl, typeof window !== 'undefined' ? window.location.origin : 'https://api.hanzo.ai');
43
+ u.searchParams.set('viewOnly', viewOnly ? '1' : '0');
44
+ return u.toString();
45
+ }
46
+ catch {
47
+ const join = rawUrl.includes('?') ? '&' : '?';
48
+ return `${rawUrl}${join}viewOnly=${viewOnly ? '1' : '0'}`;
49
+ }
50
+ }
20
51
  export function ComputerDialog({ open, onOpenChange, bot, box, onUpdated, }) {
21
52
  const { t } = useI18n();
22
53
  const { client } = useAi();
23
54
  const displayName = called(bot.name);
55
+ const iframeRef = useRef(null);
56
+ const autoBootedRef = useRef(false);
57
+ const [localBox, setLocalBox] = useState(box);
58
+ const [expanded, setExpanded] = useState(false);
24
59
  const [mode, setMode] = useState('screen');
60
+ const [control, setControl] = useState('watching');
61
+ const [phase, setPhase] = useState('idle');
25
62
  const [frameUrl, setFrameUrl] = useState(null);
26
63
  const [snapDataUrl, setSnapDataUrl] = useState(null);
27
64
  const [busy, setBusy] = useState(false);
65
+ const [promptOpen, setPromptOpen] = useState(false);
28
66
  const [task, setTask] = useState('');
29
67
  const [runningTask, setRunningTask] = useState(false);
30
- const [lastAnswer, setLastAnswer] = useState(null);
68
+ const [statusToast, setStatusToast] = useState(null);
31
69
  const [error, setError] = useState(null);
32
- const awake = box?.status === 'running';
33
- const waking = box?.status === 'pending';
34
- const openStream = useCallback(async (targetId, kind) => {
70
+ const [vaultOpen, setVaultOpen] = useState(false);
71
+ const [vaultItems, setVaultItems] = useState([]);
72
+ useEffect(() => {
73
+ if (box)
74
+ setLocalBox(box);
75
+ }, [box]);
76
+ const activeBox = localBox ?? box;
77
+ const awake = activeBox?.status === 'running';
78
+ const refreshVault = useCallback(async () => {
79
+ const doc = await readVault();
80
+ setVaultItems(doc.items);
81
+ }, []);
82
+ useEffect(() => {
83
+ if (open)
84
+ void refreshVault();
85
+ }, [open, refreshVault]);
86
+ // Listen for live state handshakes from `apps/sandbox/screen/page.html`
87
+ useEffect(() => {
88
+ if (!open)
89
+ return;
90
+ const onMessage = (ev) => {
91
+ const data = ev.data;
92
+ if (!data || data.type !== 'hanzo-screen-state')
93
+ return;
94
+ if (data.state === 'connected') {
95
+ setPhase('live');
96
+ }
97
+ else if (data.state === 'connecting') {
98
+ setPhase((prev) => (prev === 'live' ? 'live' : 'connecting'));
99
+ }
100
+ if (typeof data.viewOnly === 'boolean') {
101
+ setControl(data.viewOnly ? 'watching' : 'controlling');
102
+ }
103
+ };
104
+ window.addEventListener('message', onMessage);
105
+ return () => window.removeEventListener('message', onMessage);
106
+ }, [open]);
107
+ const openStream = useCallback(async (targetId, kind, wantViewOnly) => {
35
108
  if (!client)
36
109
  return;
37
110
  setError(null);
111
+ setPhase('connecting');
38
112
  try {
39
113
  const g = await grant(client, targetId, kind);
40
114
  if (g.url) {
41
- setFrameUrl(g.url);
115
+ const finalUrl = kind === 'screen' ? appendViewParam(g.url, wantViewOnly) : g.url;
116
+ setFrameUrl(finalUrl);
117
+ // Terminal or older edge screen page without postMessage transitions smoothly after load
118
+ window.setTimeout(() => {
119
+ setPhase((cur) => (cur === 'connecting' ? 'live' : cur));
120
+ }, 1600);
42
121
  }
43
122
  else {
44
123
  setError(t('Desktop stream ticket was minted without a stream URL.'));
124
+ setPhase('idle');
45
125
  }
46
126
  }
47
127
  catch (e) {
48
128
  setError(say(e, t('{name}’s desktop stream', { name: displayName }), 'read', t));
129
+ setPhase('idle');
49
130
  }
50
131
  }, [client, displayName, t]);
132
+ const startOrResume = useCallback(async (manual = false) => {
133
+ if (!client || busy)
134
+ return;
135
+ setBusy(true);
136
+ setError(null);
137
+ setSnapDataUrl(null);
138
+ setPhase('starting');
139
+ try {
140
+ const leased = await bootOrResumeComputer(client, bot, activeBox);
141
+ setLocalBox(leased);
142
+ await onUpdated();
143
+ if (leased.status === 'running') {
144
+ const effectiveMode = leased.class === 'desktop' ? mode : 'terminal';
145
+ await openStream(leased.id, effectiveMode, control === 'watching');
146
+ }
147
+ else {
148
+ // Poll up to ~25s while the sandbox container schedules & boots X11
149
+ for (let attempt = 0; attempt < 12; attempt++) {
150
+ await new Promise((r) => window.setTimeout(r, 2000));
151
+ const latest = await findBotComputer(client, { ...bot, computeRef: leased.id });
152
+ if (latest)
153
+ setLocalBox(latest);
154
+ if (latest?.status === 'running') {
155
+ await onUpdated();
156
+ await openStream(latest.id, latest.class === 'desktop' ? mode : 'terminal', control === 'watching');
157
+ break;
158
+ }
159
+ }
160
+ }
161
+ if (manual) {
162
+ setStatusToast(t('Desktop ready.'));
163
+ }
164
+ }
165
+ catch (e) {
166
+ setError(say(e, t('{name}’s desktop computer', { name: displayName }), 'save', t));
167
+ setPhase('idle');
168
+ }
169
+ finally {
170
+ setBusy(false);
171
+ }
172
+ }, [client, busy, bot, activeBox, onUpdated, mode, openStream, control, displayName, t]);
173
+ // Auto-open live stream if running, or auto-boot/resume on open!
51
174
  useEffect(() => {
52
175
  if (!open) {
176
+ autoBootedRef.current = false;
53
177
  setFrameUrl(null);
54
178
  setSnapDataUrl(null);
55
179
  setError(null);
180
+ setStatusToast(null);
181
+ setControl('watching');
182
+ setPhase('idle');
56
183
  return;
57
184
  }
58
- if (box?.id && box.status === 'running') {
59
- const effectiveMode = box.class === 'desktop' ? mode : 'terminal';
60
- void openStream(box.id, effectiveMode);
185
+ if (activeBox?.id && activeBox.status === 'running') {
186
+ autoBootedRef.current = true;
187
+ const effectiveMode = activeBox.class === 'desktop' ? mode : 'terminal';
188
+ void openStream(activeBox.id, effectiveMode, control === 'watching');
189
+ return;
61
190
  }
62
- else {
63
- setFrameUrl(null);
191
+ if (!autoBootedRef.current && client) {
192
+ autoBootedRef.current = true;
193
+ void startOrResume(false);
64
194
  }
65
- }, [open, box?.id, box?.status, box?.class, mode, openStream]);
66
- const startComputer = async () => {
67
- if (!client || busy)
195
+ }, [open, activeBox?.id, activeBox?.status, activeBox?.class, mode, client, openStream, startOrResume, control]);
196
+ const toggleControl = (nextControl) => {
197
+ setControl(nextControl);
198
+ const viewOnly = nextControl === 'watching';
199
+ try {
200
+ iframeRef.current?.contentWindow?.postMessage({ type: 'hanzo-screen-control', viewOnly }, '*');
201
+ if (!viewOnly) {
202
+ iframeRef.current?.focus();
203
+ }
204
+ }
205
+ catch {
206
+ // ignore cross-frame focus errors
207
+ }
208
+ };
209
+ const handlePark = async () => {
210
+ if (!client || !activeBox?.id || busy)
68
211
  return;
69
212
  setBusy(true);
70
213
  setError(null);
71
214
  try {
72
- const leased = await client.sandboxes.lease({ class: 'desktop', project: disk(bot.name) });
73
- if (leased?.id && bot.computeRef !== leased.id) {
74
- await updateBotMeta(client, bot.name, { computeRef: leased.id, tools: ['*'] }).catch(() => null);
75
- }
215
+ await parkComputer(client, activeBox.id);
216
+ setFrameUrl(null);
217
+ setLocalBox((prev) => (prev ? { ...prev, status: 'stopped' } : null));
218
+ setPhase('parked');
219
+ setStatusToast(t('Desktop parked — workspace disk is preserved and resumes instantly.'));
76
220
  await onUpdated();
77
- if (leased?.id && leased.status === 'running') {
78
- await openStream(leased.id, 'screen');
79
- }
80
221
  }
81
222
  catch (e) {
82
223
  setError(say(e, t('{name}’s desktop computer', { name: displayName }), 'save', t));
@@ -85,33 +226,56 @@ export function ComputerDialog({ open, onOpenChange, bot, box, onUpdated, }) {
85
226
  setBusy(false);
86
227
  }
87
228
  };
88
- const handlePark = async () => {
89
- if (!client || !box?.id || busy)
229
+ const pasteClipboardToDesktop = async () => {
230
+ try {
231
+ const text = await navigator.clipboard.readText();
232
+ if (!text)
233
+ return;
234
+ iframeRef.current?.contentWindow?.postMessage({ type: 'hanzo-screen-clipboard', text }, '*');
235
+ if (client && activeBox?.id) {
236
+ await actComputer(client, { id: activeBox.id, action: 'type', text });
237
+ }
238
+ setStatusToast(t('Pasted clipboard to desktop.'));
239
+ }
240
+ catch {
241
+ setError(t('Grant browser clipboard permission or take control to paste directly.'));
242
+ }
243
+ };
244
+ const runAutofill = async (item, field) => {
245
+ if (!client || !activeBox?.id || runningTask)
90
246
  return;
91
- setBusy(true);
247
+ setRunningTask(true);
92
248
  setError(null);
249
+ setStatusToast(null);
93
250
  try {
94
- await parkComputer(client, box.id);
95
- setFrameUrl(null);
96
- await onUpdated();
251
+ await actComputer(client, {
252
+ id: activeBox.id,
253
+ action: 'autofill',
254
+ credential: item.id || item.domain || item.name,
255
+ field,
256
+ submit: field === 'login' || field === 'totp',
257
+ });
258
+ setStatusToast(field === 'totp'
259
+ ? t('Typed 6-digit 2FA code for {name} via KMS.', { name: item.name })
260
+ : t('Autofilled {name} via zero-knowledge KMS.', { name: item.name }));
97
261
  }
98
262
  catch (e) {
99
- setError(say(e, t('{name}’s desktop computer', { name: displayName }), 'save', t));
263
+ setError(say(e, t('credential autofill'), 'save', t));
100
264
  }
101
265
  finally {
102
- setBusy(false);
266
+ setRunningTask(false);
103
267
  }
104
268
  };
105
269
  const captureScreenshot = async () => {
106
- if (!client || !box?.id || runningTask)
270
+ if (!client || !activeBox?.id || runningTask)
107
271
  return;
108
272
  setRunningTask(true);
109
273
  setError(null);
110
274
  try {
111
- const out = await actComputer(client, { id: box.id, action: 'screenshot' });
275
+ const out = await actComputer(client, { id: activeBox.id, action: 'screenshot' });
112
276
  if (out.image) {
113
277
  setSnapDataUrl(`data:${out.mimeType || 'image/png'};base64,${out.image}`);
114
- setLastAnswer(t('Captured live {w}×{h} desktop frame.', { w: out.width || 1280, h: out.height || 800 }));
278
+ setStatusToast(t('Captured {w}×{h} frame.', { w: out.width || 1280, h: out.height || 800 }));
115
279
  }
116
280
  }
117
281
  catch (e) {
@@ -128,17 +292,19 @@ export function ComputerDialog({ open, onOpenChange, bot, box, onUpdated, }) {
128
292
  return;
129
293
  setRunningTask(true);
130
294
  setError(null);
131
- setLastAnswer(null);
295
+ setStatusToast(null);
132
296
  if (!preset)
133
297
  setTask('');
298
+ // Automatically switch to Watching mode so the user sees the bot move the cursor live
299
+ if (control === 'controlling')
300
+ toggleControl('watching');
134
301
  try {
135
- // Ensure the bot has full tool access so `computer_in_sandbox` is active on the run.
136
302
  if (!bot.tools?.length) {
137
- await updateBotMeta(client, bot.name, { tools: ['*'], computeRef: box?.id || bot.computeRef }).catch(() => null);
303
+ await updateBotMeta(client, bot.name, { tools: ['*'], computeRef: activeBox?.id || bot.computeRef }).catch(() => null);
138
304
  }
139
- const directive = `[Desktop Computer Use] Use your desktop sandbox computer (computer_in_sandbox — screenshot, click, move, drag, type, key, scroll, navigate, shell) to complete this task and report what you did:\n\n${prompt}`;
305
+ const directive = `[Desktop Computer Use] Use your resumable desktop sandbox computer (computer_in_sandbox — screenshot, click, move, drag, type, key, scroll, navigate, autofill for KMS/1Password/LastPass logins, and shell) to complete this task while I watch live:\n\n${prompt}`;
140
306
  const ran = await client.agents.run(bot.name, directive);
141
- setLastAnswer(ran.output || ran.error || t('Task completed on desktop computer.'));
307
+ setStatusToast(ran.output || ran.error || t('Task completed on desktop computer.'));
142
308
  await onUpdated();
143
309
  }
144
310
  catch (err) {
@@ -148,28 +314,30 @@ export function ComputerDialog({ open, onOpenChange, bot, box, onUpdated, }) {
148
314
  setRunningTask(false);
149
315
  }
150
316
  };
151
- return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsx(DialogContent, { "data-parity-key": "bots.computer.dialog", width: "95vw", maxW: 1060, p: 0, showCloseButton: false, bg: GROUND, borderWidth: 1, borderColor: LINE, rounded: 18, overflow: "hidden", children: _jsxs(YStack, { maxH: "90vh", bg: GROUND, children: [_jsxs(XStack, { px: 18, py: 12, items: "center", justify: "space-between", gap: 12, flexWrap: "wrap", bg: FLOOR, borderBottomWidth: 1, borderColor: LINE, children: [_jsxs(XStack, { items: "center", gap: 10, minW: 0, children: [_jsx(Face, { bot: bot, size: 34, starred: Boolean(bot.isPrimary) }), _jsxs(YStack, { minW: 0, children: [_jsx(DialogTitle, { children: _jsx(Text, { ...CLIP, fontSize: 15, lineHeight: 20, fontWeight: "600", color: INK, children: t('{name}’s Desktop Computer', { name: displayName }) }) }), _jsxs(XStack, { items: "center", gap: 7, children: [_jsx(YStack, { width: 7, height: 7, rounded: 999, bg: awake ? 'var(--state-online)' : waking ? 'var(--chrome-dot-yellow)' : DIM }), _jsx(Text, { fontSize: 12, lineHeight: 16, color: DIM, children: awake
152
- ? `${t('Awake')} · ${box?.id ?? disk(bot.name)}`
153
- : waking
154
- ? t('Starting desktop sandbox…')
155
- : `${t('Asleep')} · ${disk(bot.name)}` })] })] })] }), _jsxs(XStack, { items: "center", gap: 8, flexWrap: "wrap", children: [_jsx(XStack, { p: 3, rounded: 999, bg: RAISED, borderWidth: 1, borderColor: LINE, gap: 2, children: [
156
- { id: 'screen', label: t('Desktop GUI'), Icon: Monitor },
157
- { id: 'terminal', label: t('Terminal'), Icon: Terminal },
158
- ].map(({ id, label, Icon }) => {
159
- const active = mode === id;
160
- return (_jsxs(XStack, { render: "button", type: 'button', onClick: () => {
161
- setSnapDataUrl(null);
162
- setMode(id);
163
- }, height: 28, px: 12, gap: 6, rounded: 999, items: "center", bg: active ? PICKED : 'transparent', borderWidth: 0, cursor: "pointer", children: [_jsx(Icon, { size: 13, color: active ? INK : DIM, "aria-hidden": true }), _jsx(Text, { fontSize: 12, lineHeight: 16, fontWeight: active ? '500' : '400', color: active ? INK : DIM, children: label })] }, id));
164
- }) }), awake && box?.id ? (_jsxs(_Fragment, { children: [_jsx(XStack, { ...ROUND, width: 32, height: 32, "aria-label": t('Capture screenshot'), onClick: () => void captureScreenshot(), children: _jsx(Camera, { size: 14, color: INK, "aria-hidden": true }) }), _jsx(XStack, { ...ROUND, width: 32, height: 32, "aria-label": t('Refresh desktop stream'), onClick: () => {
165
- setSnapDataUrl(null);
166
- void openStream(box.id, mode);
167
- }, children: _jsx(RefreshCw, { size: 14, color: INK, "aria-hidden": true }) }), frameUrl ? (_jsx(XStack, { ...ROUND, width: 32, height: 32, "aria-label": t('Open in new tab'), onClick: () => window.open(frameUrl, '_blank', 'noopener,noreferrer'), children: _jsx(ExternalLink, { size: 14, color: INK, "aria-hidden": true }) })) : null, _jsxs(XStack, { ...PILL, height: 32, px: 12, disabled: busy, onClick: () => void handlePark(), children: [_jsx(Pause, { size: 12, color: INK, "aria-hidden": true }), _jsx(Text, { fontSize: 12, lineHeight: 16, fontWeight: "500", color: INK, children: t('Park') })] })] })) : (_jsxs(XStack, { ...PILL, height: 32, px: 13, bg: INK, borderColor: INK, disabled: busy || waking, opacity: busy || waking ? 0.5 : 1, onClick: () => void startComputer(), children: [_jsx(Play, { size: 12, color: "var(--background)", "aria-hidden": true }), _jsx(Text, { fontSize: 12, lineHeight: 16, fontWeight: "500", color: "var(--background)", children: busy || waking ? t('Waking…') : t('Wake Desktop') })] })), _jsx(XStack, { ...ROUND, width: 32, height: 32, "aria-label": t('Close'), onClick: () => onOpenChange(false), children: _jsx(X, { size: 15, color: INK, "aria-hidden": true }) })] })] }), _jsx(YStack, { height: 470, bg: "var(--pure-black)", items: "center", justify: "center", position: "relative", overflow: "hidden", children: snapDataUrl ? (_jsxs(YStack, { width: "100%", height: "100%", items: "center", justify: "center", position: "relative", children: [_jsx(YStack, { render: "img", src: snapDataUrl, alt: `${displayName} desktop screenshot`, maxW: "100%", maxH: "100%", objectFit: "contain" }), _jsx(XStack, { position: "absolute", t: 12, r: 12, children: _jsx(XStack, { ...PILL, height: 30, px: 12, onClick: () => setSnapDataUrl(null), children: _jsx(Text, { fontSize: 12, lineHeight: 16, color: INK, children: t('Back to live stream') }) }) })] })) : awake && frameUrl ? (_jsx(YStack, { render: "iframe", src: frameUrl,
168
- title: `${displayName} desktop ${mode}`,
169
- allow: 'clipboard-read; clipboard-write; fullscreen', width: "100%", height: "100%", borderWidth: 0 })) : (_jsxs(YStack, { maxW: 460, px: 24, items: "center", gap: 14, children: [_jsx(YStack, { width: 56, height: 56, rounded: 16, bg: RAISED, borderWidth: 1, borderColor: LINE, items: "center", justify: "center", children: _jsx(Monitor, { size: 24, color: INK, "aria-hidden": true }) }), _jsx(Text, { fontSize: 17, lineHeight: 23, fontWeight: "600", color: "var(--pure-white)", text: "center", children: waking ? t('Booting X11 Desktop Sandbox…') : t('Dedicated Desktop Sandbox Computer') }), _jsx(Text, { fontSize: 13, lineHeight: 19, color: "var(--pure-white)", opacity: 0.72, text: "center", children: t('Every bot gets its own isolated Linux GUI desktop with Chromium, persistent workspace disk ({disk}), and full Computer Use — mouse clicks, drags, keyboard typing, live screenshots, and shell execution.', { disk: disk(bot.name) }) }), _jsxs(XStack, { ...PILL, bg: "var(--pure-white)", borderColor: "var(--pure-white)", disabled: busy || waking, opacity: busy || waking ? 0.5 : 1, onClick: () => void startComputer(), children: [_jsx(Play, { size: 14, color: "var(--pure-black)", "aria-hidden": true }), _jsx(Text, { ...WORD, color: "var(--pure-black)", children: busy || waking ? t('Starting computer…') : t('Start Desktop Computer') })] })] })) }), _jsxs(YStack, { px: 18, py: 12, gap: 10, bg: FLOOR, borderTopWidth: 1, borderColor: LINE, children: [error ? (_jsx(Text, { role: "alert", fontSize: 12, lineHeight: 17, color: DIM, children: error })) : null, lastAnswer ? (_jsx(YStack, { px: 12, py: 9, rounded: 10, bg: RAISED, borderWidth: 1, borderColor: LINE, maxH: 96, overflowY: "auto", children: _jsx(Text, { fontSize: 12, lineHeight: 17, color: INK, children: lastAnswer }) })) : null, _jsxs(XStack, { render: "form", onSubmit: (e) => void submitComputerTask(e), gap: 8, items: "center", children: [_jsx(Input, { unstyled: true, value: task, onChange: (e) => setTask(e.target.value), placeholder: t('Ask {name} to use its computer (open a URL, click UI, inspect logs, run tests…)', {
170
- name: displayName,
171
- }), "aria-label": t('Computer Use directive'), flex: 1, height: 38, px: 14, rounded: 999, bg: RAISED, borderWidth: 1, borderColor: LINE, color: INK, fontSize: 13, placeholderTextColor: "$placeholderColor" }), _jsxs(XStack, { ...PILL, type: 'submit', height: 38, px: 15, bg: INK, borderColor: INK, disabled: !task.trim() || runningTask, opacity: !task.trim() || runningTask ? 0.45 : 1, children: [_jsx(Send, { size: 13, color: "var(--background)", "aria-hidden": true }), _jsx(Text, { ...WORD, fontSize: 13, color: "var(--background)", children: runningTask ? t('Working…') : t('Computer Use') })] })] }), _jsxs(XStack, { items: "center", gap: 6, flexWrap: "wrap", children: [_jsx(Text, { fontSize: 11, lineHeight: 15, color: DIM, children: t('Quick actions:') }), [
172
- { label: t('Open hanzo.ai in browser'), prompt: 'Navigate to https://hanzo.ai on the desktop browser, take a screenshot, and summarize what is visible.' },
173
- { label: t('Inspect workspace & tools'), prompt: 'Run uname -a, check installed browsers and developer tools in your sandbox, and take a desktop screenshot.' },
174
- ].map((q) => (_jsx(XStack, { render: "button", type: 'button', disabled: runningTask, onClick: () => void submitComputerTask(undefined, q.prompt), height: 25, px: 10, rounded: 999, items: "center", bg: RAISED, borderWidth: 1, borderColor: LINE, cursor: "pointer", hoverStyle: { bg: PICKED }, children: _jsx(Text, { fontSize: 11, lineHeight: 15, color: DIM, children: q.label }) }, q.label)))] })] })] }) }) }));
317
+ const logins = vaultItems.filter((i) => i.kind === 'login');
318
+ const otherSecrets = vaultItems.filter((i) => i.kind !== 'login');
319
+ const showBottomBar = phase === 'connecting' || phase === 'live' || awake;
320
+ return (_jsxs(_Fragment, { children: [_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsx(DialogContent, { "data-parity-key": "bots.computer.dialog", width: expanded ? '98vw' : '95vw', maxW: expanded ? 1480 : 1140, p: 0, showCloseButton: false, bg: "var(--pure-black)", borderWidth: 1, borderColor: LINE, rounded: 18, overflow: "hidden", children: _jsxs(YStack, { height: expanded ? '94vh' : '86vh', maxH: "95vh", bg: "var(--pure-black)", children: [_jsxs(XStack, { height: 44, px: 16, items: "center", justify: "space-between", gap: 12, shrink: 0, children: [_jsxs(XStack, { items: "center", gap: 12, minW: 0, children: [_jsxs(XStack, { items: "center", gap: 8, shrink: 0, children: [_jsx(YStack, { render: "button", type: 'button', "aria-label": t('Close computer window'), onClick: () => onOpenChange(false), width: 12, height: 12, rounded: 999, bg: "var(--chrome-dot-red)", borderWidth: 0, p: 0, cursor: "pointer" }), _jsx(YStack, { render: "button", type: 'button', "aria-label": t('Park desktop computer'), onClick: () => (awake ? void handlePark() : onOpenChange(false)), width: 12, height: 12, rounded: 999, bg: "var(--chrome-dot-yellow)", borderWidth: 0, p: 0, cursor: "pointer" }), _jsx(YStack, { render: "button", type: 'button', "aria-label": expanded ? t('Exit fullscreen size') : t('Expand computer window'), onClick: () => setExpanded((v) => !v), width: 12, height: 12, rounded: 999, bg: "var(--chrome-dot-green)", borderWidth: 0, p: 0, cursor: "pointer" })] }), _jsx(DialogTitle, { children: _jsx(Text, { ...CLIP, fontSize: 12, lineHeight: 16, fontWeight: "500", color: "var(--pure-white)", opacity: 0.55, children: awake
321
+ ? `${displayName} · ${activeBox?.id ?? disk(bot.name)}`
322
+ : phase === 'parked'
323
+ ? `${displayName} · ${t('Parked (resumable)')}`
324
+ : `${displayName} · ${t('Desktop')}` }) })] }), _jsxs(XStack, { items: "center", gap: 6, children: [awake && activeBox?.id ? (_jsxs(_Fragment, { children: [_jsxs(XStack, { render: "button", type: 'button', "aria-label": mode === 'screen' ? t('Switch to Terminal') : t('Switch to Desktop GUI'), onClick: () => {
325
+ setSnapDataUrl(null);
326
+ setMode((m) => (m === 'screen' ? 'terminal' : 'screen'));
327
+ }, height: 26, px: 9, gap: 5, rounded: 999, items: "center", bg: RAISED, borderWidth: 1, borderColor: LINE, cursor: "pointer", children: [mode === 'screen' ? (_jsx(Terminal, { size: 12, color: "var(--pure-white)", "aria-hidden": true })) : (_jsx(Monitor, { size: 12, color: "var(--pure-white)", "aria-hidden": true })), _jsx(Text, { fontSize: 11, lineHeight: 15, color: "var(--pure-white)", opacity: 0.85, children: mode === 'screen' ? t('Terminal') : t('Desktop') })] }), _jsxs(DropdownMenu, { placement: "bottom-end", offset: 6, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(XStack, { render: "button", type: 'button', "aria-label": t('Autofill login or secret'), height: 26, px: 9, gap: 5, rounded: 999, items: "center", bg: RAISED, borderWidth: 1, borderColor: LINE, cursor: "pointer", children: [_jsx(KeyRound, { size: 12, color: "var(--pure-white)", "aria-hidden": true }), _jsx(Text, { fontSize: 11, lineHeight: 15, color: "var(--pure-white)", opacity: 0.85, children: t('Autofill') })] }) }), _jsxs(DropdownMenuContent, { minW: 240, children: [logins.map((item) => (_jsx(DropdownMenuItem, { onSelect: () => void runAutofill(item, 'login'), children: _jsxs(YStack, { gap: 1, children: [_jsx(Text, { fontSize: "$3", fontWeight: "500", color: "$ink", children: `${item.name}${item.domain ? ` (${item.domain})` : ''}` }), _jsx(Text, { fontSize: "$1", color: DIM, children: item.username
328
+ ? t('Fill {user} + password via {src}', { user: item.username, src: item.source })
329
+ : t('Fill password via {src}', { src: item.source }) })] }) }, item.id))), logins
330
+ .filter((i) => Boolean(i.totpSecretKey))
331
+ .map((item) => (_jsx(DropdownMenuItem, { onSelect: () => void runAutofill(item, 'totp'), children: _jsx(Text, { fontSize: "$2", color: "$ink", children: t('2FA TOTP code · {name}', { name: item.name }) }) }, `${item.id}-totp`))), otherSecrets.slice(0, 5).map((item) => (_jsx(DropdownMenuItem, { onSelect: () => void runAutofill(item, 'secret'), children: _jsx(Text, { fontSize: "$2", color: "$ink", children: t('Type secret · {name}', { name: item.name }) }) }, item.id))), _jsx(DropdownMenuItem, { onSelect: () => setVaultOpen(true), children: _jsx(Text, { fontSize: "$2", fontWeight: "600", color: "$ink", children: vaultItems.length === 0
332
+ ? t('+ Add 1Password, LastPass, or KMS logins…')
333
+ : t('Manage Vault & Password Managers…') }) })] })] }), _jsx(XStack, { render: "button", type: 'button', "aria-label": t('Paste clipboard to desktop'), onClick: () => void pasteClipboardToDesktop(), width: 26, height: 26, rounded: 999, items: "center", justify: "center", bg: "transparent", borderWidth: 0, cursor: "pointer", hoverStyle: { bg: RAISED }, children: _jsx(ClipboardPaste, { size: 13, color: "var(--pure-white)", opacity: 0.7, "aria-hidden": true }) }), _jsx(XStack, { render: "button", type: 'button', "aria-label": t('Capture screenshot'), onClick: () => void captureScreenshot(), width: 26, height: 26, rounded: 999, items: "center", justify: "center", bg: "transparent", borderWidth: 0, cursor: "pointer", hoverStyle: { bg: RAISED }, children: _jsx(Camera, { size: 13, color: "var(--pure-white)", opacity: 0.7, "aria-hidden": true }) }), _jsx(XStack, { render: "button", type: 'button', "aria-label": t('Reconnect stream'), onClick: () => {
334
+ setSnapDataUrl(null);
335
+ void openStream(activeBox.id, mode, control === 'watching');
336
+ }, width: 26, height: 26, rounded: 999, items: "center", justify: "center", bg: "transparent", borderWidth: 0, cursor: "pointer", hoverStyle: { bg: RAISED }, children: _jsx(RefreshCw, { size: 13, color: "var(--pure-white)", opacity: 0.7, "aria-hidden": true }) }), frameUrl ? (_jsx(XStack, { render: "button", type: 'button', "aria-label": t('Open stream in new tab'), onClick: () => window.open(frameUrl, '_blank', 'noopener,noreferrer'), width: 26, height: 26, rounded: 999, items: "center", justify: "center", bg: "transparent", borderWidth: 0, cursor: "pointer", hoverStyle: { bg: RAISED }, children: _jsx(ExternalLink, { size: 13, color: "var(--pure-white)", opacity: 0.7, "aria-hidden": true }) })) : null, _jsxs(XStack, { render: "button", type: 'button', "aria-label": t('Park desktop'), disabled: busy, onClick: () => void handlePark(), height: 26, px: 9, gap: 4, rounded: 999, items: "center", bg: RAISED, borderWidth: 1, borderColor: LINE, cursor: "pointer", children: [_jsx(Pause, { size: 11, color: "var(--pure-white)", "aria-hidden": true }), _jsx(Text, { fontSize: 11, lineHeight: 15, color: "var(--pure-white)", opacity: 0.85, children: t('Park') })] })] })) : null, _jsx(XStack, { render: "button", type: 'button', "aria-label": expanded ? t('Collapse window') : t('Expand window'), onClick: () => setExpanded((v) => !v), width: 28, height: 28, rounded: 8, items: "center", justify: "center", bg: "transparent", borderWidth: 0, cursor: "pointer", hoverStyle: { bg: RAISED }, children: expanded ? (_jsx(Minimize2, { size: 14, color: "var(--pure-white)", opacity: 0.65, "aria-hidden": true })) : (_jsx(Maximize2, { size: 14, color: "var(--pure-white)", opacity: 0.65, "aria-hidden": true })) })] })] }), _jsx(YStack, { flex: 1, minH: 0, px: 10, pt: 4, pb: showBottomBar ? 0 : 12, items: "center", justify: "center", children: phase === 'starting' && !frameUrl ? (_jsx(YStack, { flex: 1, width: "100%", items: "center", justify: "center", children: _jsx(PulsingCluster, { label: t('Starting desktop') }) })) : phase === 'parked' || (!awake && !busy && !frameUrl) ? (_jsxs(YStack, { flex: 1, width: "100%", rounded: 12, borderWidth: 1, borderColor: LINE, bg: FLOOR, items: "center", justify: "center", gap: 14, px: 24, children: [_jsx(Text, { fontSize: 16, lineHeight: 22, fontWeight: "600", color: "var(--pure-white)", text: "center", children: phase === 'parked' ? t('Desktop is parked') : t('{name}’s resumable desktop', { name: displayName }) }), _jsx(Text, { fontSize: 13, lineHeight: 19, maxW: 440, color: "var(--pure-white)", opacity: 0.62, text: "center", children: t('Persistent home volume preserves open files, browser sessions, and tools across sleep/wake cycles.') }), error ? (_jsx(Text, { role: "alert", fontSize: 12, lineHeight: 17, color: "var(--pure-white)", opacity: 0.75, text: "center", children: error })) : null, _jsxs(XStack, { ...PILL, bg: "var(--pure-white)", borderColor: "var(--pure-white)", disabled: busy, onClick: () => void startOrResume(true), children: [_jsx(Play, { size: 13, color: "var(--pure-black)", "aria-hidden": true }), _jsx(Text, { ...WORD, color: "var(--pure-black)", children: phase === 'parked' ? t('Resume desktop') : t('Start desktop') })] })] })) : (_jsx(YStack, { flex: 1, width: "100%", rounded: 10, borderWidth: 1, borderColor: LINE, bg: FLOOR, overflow: "hidden", position: "relative", items: "center", justify: "center", children: snapDataUrl ? (_jsxs(YStack, { width: "100%", height: "100%", items: "center", justify: "center", position: "relative", children: [_jsx(YStack, { render: "img", src: snapDataUrl, alt: `${displayName} desktop screenshot`, maxW: "100%", maxH: "100%", objectFit: "contain" }), _jsx(XStack, { position: "absolute", t: 12, r: 12, children: _jsx(XStack, { ...PILL, height: 30, px: 12, bg: RAISED, borderColor: LINE, onClick: () => setSnapDataUrl(null), children: _jsx(Text, { fontSize: 12, lineHeight: 16, color: INK, children: t('Back to live desktop') }) }) })] })) : frameUrl ? (_jsx(YStack, { ref: iframeRef, render: "iframe", src: frameUrl,
337
+ title: `${displayName} desktop ${mode}`,
338
+ allow: 'clipboard-read; clipboard-write; fullscreen', width: "100%", height: "100%", borderWidth: 0 })) : (_jsx(PulsingCluster, { label: t('Connecting') })) })) }), promptOpen && awake ? (_jsx(YStack, { px: 16, pt: 10, gap: 8, children: _jsxs(XStack, { render: "form", onSubmit: (e) => void submitComputerTask(e), gap: 8, items: "center", children: [_jsx(Input, { unstyled: true, autoFocus: true, value: task, onChange: (e) => setTask(e.target.value), placeholder: t('Tell {name} what to do on this desktop (e.g., "Log in with my GitHub vault credentials and review open PRs")…', { name: displayName }), "aria-label": t('Co-work with {name} on desktop', { name: displayName }), flex: 1, height: 36, px: 14, rounded: 999, bg: RAISED, borderWidth: 1, borderColor: LINE, color: INK, fontSize: 13, placeholderTextColor: "$placeholderColor" }), _jsxs(XStack, { ...PILL, type: 'submit', height: 36, px: 14, bg: "var(--pure-white)", borderColor: "var(--pure-white)", disabled: !task.trim() || runningTask, opacity: !task.trim() || runningTask ? 0.5 : 1, children: [_jsx(Send, { size: 12, color: "var(--pure-black)", "aria-hidden": true }), _jsx(Text, { ...WORD, fontSize: 12, color: "var(--pure-black)", children: runningTask ? t('Working…') : t('Run on desktop') })] })] }) })) : null, showBottomBar ? (_jsxs(XStack, { height: 58, px: 16, items: "center", justify: "space-between", gap: 12, shrink: 0, children: [_jsx(XStack, { flex: 1, items: "center", gap: 8, minW: 0, children: error ? (_jsx(Text, { ...CLIP, role: "alert", fontSize: 12, lineHeight: 16, color: "var(--pure-white)", opacity: 0.75, children: error })) : statusToast ? (_jsx(Text, { ...CLIP, fontSize: 12, lineHeight: 16, color: "var(--pure-white)", opacity: 0.68, children: statusToast })) : null }), _jsxs(XStack, { "data-parity-key": "bots.computer.control-pill", height: 38, pl: 14, pr: 5, gap: 12, rounded: 999, items: "center", bg: RAISED, borderWidth: 1, borderColor: LINE, children: [_jsxs(XStack, { items: "center", gap: 7, children: [control === 'watching' ? (_jsx(Eye, { size: 14, color: "var(--pure-white)", opacity: 0.75, "aria-hidden": true })) : (_jsx(MousePointerClick, { size: 14, color: "var(--state-online)", "aria-hidden": true })), _jsx(Text, { fontSize: 13, lineHeight: 18, fontWeight: "500", color: "var(--pure-white)", opacity: 0.88, children: control === 'watching' ? t('Watching') : t('In control') })] }), control === 'watching' ? (_jsx(XStack, { render: "button", type: 'button', onClick: () => toggleControl('controlling'), height: 28, px: 13, rounded: 999, items: "center", justify: "center", bg: "var(--pure-white)", borderWidth: 0, cursor: "pointer", children: _jsx(Text, { fontSize: 12, lineHeight: 16, fontWeight: "600", color: "var(--pure-black)", children: t('Take control') }) })) : (_jsx(XStack, { render: "button", type: 'button', onClick: () => toggleControl('watching'), height: 28, px: 13, rounded: 999, items: "center", justify: "center", bg: PICKED, borderWidth: 1, borderColor: LINE, cursor: "pointer", children: _jsx(Text, { fontSize: 12, lineHeight: 16, fontWeight: "500", color: "var(--pure-white)", children: t('Watch only') }) }))] }), _jsx(XStack, { flex: 1, items: "center", justify: "flex-end", gap: 8, children: awake ? (_jsxs(XStack, { render: "button", type: 'button', onClick: () => setPromptOpen((v) => !v), height: 30, px: 11, gap: 6, rounded: 999, items: "center", bg: promptOpen ? PICKED : 'transparent', borderWidth: 1, borderColor: promptOpen ? LINE : 'transparent', cursor: "pointer", hoverStyle: { bg: RAISED }, children: [_jsx(Sparkles, { size: 12, color: "var(--pure-white)", opacity: 0.78, "aria-hidden": true }), _jsx(Text, { fontSize: 12, lineHeight: 16, color: "var(--pure-white)", opacity: 0.78, children: runningTask ? t('{name} working…', { name: displayName }) : t('Work with {name}', { name: displayName }) })] })) : null })] })) : null] }) }) }), _jsx(VaultDialog, { open: vaultOpen, onOpenChange: (next) => {
339
+ setVaultOpen(next);
340
+ if (!next)
341
+ void refreshVault();
342
+ }, onAutofill: awake ? (item, field) => void runAutofill(item, field ?? 'login') : undefined, onChanged: (doc) => setVaultItems(doc.items) })] }));
175
343
  }