@hanzo/app 0.3.88 → 0.3.89

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,216 @@
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, FLOOR, INK, LINE, PICKED, RAISED } from './ink.js';
21
+ function PulsingCluster({ label }) {
22
+ const [step, setStep] = useState(0);
23
+ useEffect(() => {
24
+ const id = window.setInterval(() => setStep((s) => (s + 1) % 3), 480);
25
+ return () => window.clearInterval(id);
26
+ }, []);
27
+ 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) => {
28
+ const active = step === i;
29
+ const mid = i === 1;
30
+ return (_jsx(YStack, { width: mid ? 7 : 4, height: mid ? 7 : 4, rounded: 999, bg: "var(--pure-white)", opacity: active ? 1 : 0.35 }, i));
31
+ }) }), _jsx(Text, { fontSize: 13, lineHeight: 18, fontWeight: "500", color: "var(--pure-white)", opacity: 0.58, children: label })] }));
32
+ }
33
+ function appendViewParam(rawUrl, viewOnly) {
34
+ try {
35
+ const u = new URL(rawUrl, typeof window !== 'undefined' ? window.location.origin : 'https://api.hanzo.ai');
36
+ u.searchParams.set('viewOnly', viewOnly ? '1' : '0');
37
+ return u.toString();
38
+ }
39
+ catch {
40
+ const join = rawUrl.includes('?') ? '&' : '?';
41
+ return `${rawUrl}${join}viewOnly=${viewOnly ? '1' : '0'}`;
42
+ }
43
+ }
20
44
  export function ComputerDialog({ open, onOpenChange, bot, box, onUpdated, }) {
21
45
  const { t } = useI18n();
22
46
  const { client } = useAi();
23
47
  const displayName = called(bot.name);
48
+ const iframeRef = useRef(null);
49
+ const autoBootedRef = useRef(false);
50
+ const [localBox, setLocalBox] = useState(box);
51
+ const [expanded, setExpanded] = useState(false);
24
52
  const [mode, setMode] = useState('screen');
53
+ const [control, setControl] = useState('watching');
54
+ const [phase, setPhase] = useState('idle');
25
55
  const [frameUrl, setFrameUrl] = useState(null);
26
56
  const [snapDataUrl, setSnapDataUrl] = useState(null);
27
57
  const [busy, setBusy] = useState(false);
58
+ const [promptOpen, setPromptOpen] = useState(false);
28
59
  const [task, setTask] = useState('');
29
60
  const [runningTask, setRunningTask] = useState(false);
30
- const [lastAnswer, setLastAnswer] = useState(null);
61
+ const [statusToast, setStatusToast] = useState(null);
31
62
  const [error, setError] = useState(null);
32
- const awake = box?.status === 'running';
33
- const waking = box?.status === 'pending';
34
- const openStream = useCallback(async (targetId, kind) => {
63
+ const [vaultOpen, setVaultOpen] = useState(false);
64
+ const [vaultItems, setVaultItems] = useState([]);
65
+ useEffect(() => {
66
+ if (box)
67
+ setLocalBox(box);
68
+ }, [box]);
69
+ const activeBox = localBox ?? box;
70
+ const awake = activeBox?.status === 'running';
71
+ const refreshVault = useCallback(async () => {
72
+ const doc = await readVault();
73
+ setVaultItems(doc.items);
74
+ }, []);
75
+ useEffect(() => {
76
+ if (open)
77
+ void refreshVault();
78
+ }, [open, refreshVault]);
79
+ // Listen for live state handshakes from `apps/sandbox/screen/page.html`
80
+ useEffect(() => {
81
+ if (!open)
82
+ return;
83
+ const onMessage = (ev) => {
84
+ const data = ev.data;
85
+ if (!data || data.type !== 'hanzo-screen-state')
86
+ return;
87
+ if (data.state === 'connected') {
88
+ setPhase('live');
89
+ }
90
+ else if (data.state === 'connecting') {
91
+ setPhase((prev) => (prev === 'live' ? 'live' : 'connecting'));
92
+ }
93
+ if (typeof data.viewOnly === 'boolean') {
94
+ setControl(data.viewOnly ? 'watching' : 'controlling');
95
+ }
96
+ };
97
+ window.addEventListener('message', onMessage);
98
+ return () => window.removeEventListener('message', onMessage);
99
+ }, [open]);
100
+ const openStream = useCallback(async (targetId, kind, wantViewOnly) => {
35
101
  if (!client)
36
102
  return;
37
103
  setError(null);
104
+ setPhase('connecting');
38
105
  try {
39
106
  const g = await grant(client, targetId, kind);
40
107
  if (g.url) {
41
- setFrameUrl(g.url);
108
+ const finalUrl = kind === 'screen' ? appendViewParam(g.url, wantViewOnly) : g.url;
109
+ setFrameUrl(finalUrl);
110
+ // Terminal or older edge screen page without postMessage transitions smoothly after load
111
+ window.setTimeout(() => {
112
+ setPhase((cur) => (cur === 'connecting' ? 'live' : cur));
113
+ }, 1600);
42
114
  }
43
115
  else {
44
116
  setError(t('Desktop stream ticket was minted without a stream URL.'));
117
+ setPhase('idle');
45
118
  }
46
119
  }
47
120
  catch (e) {
48
121
  setError(say(e, t('{name}’s desktop stream', { name: displayName }), 'read', t));
122
+ setPhase('idle');
49
123
  }
50
124
  }, [client, displayName, t]);
125
+ const startOrResume = useCallback(async (manual = false) => {
126
+ if (!client || busy)
127
+ return;
128
+ setBusy(true);
129
+ setError(null);
130
+ setSnapDataUrl(null);
131
+ setPhase('starting');
132
+ try {
133
+ const leased = await bootOrResumeComputer(client, bot, activeBox);
134
+ setLocalBox(leased);
135
+ await onUpdated();
136
+ if (leased.status === 'running') {
137
+ const effectiveMode = leased.class === 'desktop' ? mode : 'terminal';
138
+ await openStream(leased.id, effectiveMode, control === 'watching');
139
+ }
140
+ else {
141
+ // Poll up to ~25s while the sandbox container schedules & boots X11
142
+ for (let attempt = 0; attempt < 12; attempt++) {
143
+ await new Promise((r) => window.setTimeout(r, 2000));
144
+ const latest = await findBotComputer(client, { ...bot, computeRef: leased.id });
145
+ if (latest)
146
+ setLocalBox(latest);
147
+ if (latest?.status === 'running') {
148
+ await onUpdated();
149
+ await openStream(latest.id, latest.class === 'desktop' ? mode : 'terminal', control === 'watching');
150
+ break;
151
+ }
152
+ }
153
+ }
154
+ if (manual) {
155
+ setStatusToast(t('Desktop ready.'));
156
+ }
157
+ }
158
+ catch (e) {
159
+ setError(say(e, t('{name}’s desktop computer', { name: displayName }), 'save', t));
160
+ setPhase('idle');
161
+ }
162
+ finally {
163
+ setBusy(false);
164
+ }
165
+ }, [client, busy, bot, activeBox, onUpdated, mode, openStream, control, displayName, t]);
166
+ // Auto-open live stream if running, or auto-boot/resume on open!
51
167
  useEffect(() => {
52
168
  if (!open) {
169
+ autoBootedRef.current = false;
53
170
  setFrameUrl(null);
54
171
  setSnapDataUrl(null);
55
172
  setError(null);
173
+ setStatusToast(null);
174
+ setControl('watching');
175
+ setPhase('idle');
56
176
  return;
57
177
  }
58
- if (box?.id && box.status === 'running') {
59
- const effectiveMode = box.class === 'desktop' ? mode : 'terminal';
60
- void openStream(box.id, effectiveMode);
178
+ if (activeBox?.id && activeBox.status === 'running') {
179
+ autoBootedRef.current = true;
180
+ const effectiveMode = activeBox.class === 'desktop' ? mode : 'terminal';
181
+ void openStream(activeBox.id, effectiveMode, control === 'watching');
182
+ return;
61
183
  }
62
- else {
63
- setFrameUrl(null);
184
+ if (!autoBootedRef.current && client) {
185
+ autoBootedRef.current = true;
186
+ void startOrResume(false);
64
187
  }
65
- }, [open, box?.id, box?.status, box?.class, mode, openStream]);
66
- const startComputer = async () => {
67
- if (!client || busy)
188
+ }, [open, activeBox?.id, activeBox?.status, activeBox?.class, mode, client, openStream, startOrResume, control]);
189
+ const toggleControl = (nextControl) => {
190
+ setControl(nextControl);
191
+ const viewOnly = nextControl === 'watching';
192
+ try {
193
+ iframeRef.current?.contentWindow?.postMessage({ type: 'hanzo-screen-control', viewOnly }, '*');
194
+ if (!viewOnly) {
195
+ iframeRef.current?.focus();
196
+ }
197
+ }
198
+ catch {
199
+ // ignore cross-frame focus errors
200
+ }
201
+ };
202
+ const handlePark = async () => {
203
+ if (!client || !activeBox?.id || busy)
68
204
  return;
69
205
  setBusy(true);
70
206
  setError(null);
71
207
  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
- }
208
+ await parkComputer(client, activeBox.id);
209
+ setFrameUrl(null);
210
+ setLocalBox((prev) => (prev ? { ...prev, status: 'stopped' } : null));
211
+ setPhase('parked');
212
+ setStatusToast(t('Desktop parked — workspace disk is preserved and resumes instantly.'));
76
213
  await onUpdated();
77
- if (leased?.id && leased.status === 'running') {
78
- await openStream(leased.id, 'screen');
79
- }
80
214
  }
81
215
  catch (e) {
82
216
  setError(say(e, t('{name}’s desktop computer', { name: displayName }), 'save', t));
@@ -85,33 +219,56 @@ export function ComputerDialog({ open, onOpenChange, bot, box, onUpdated, }) {
85
219
  setBusy(false);
86
220
  }
87
221
  };
88
- const handlePark = async () => {
89
- if (!client || !box?.id || busy)
222
+ const pasteClipboardToDesktop = async () => {
223
+ try {
224
+ const text = await navigator.clipboard.readText();
225
+ if (!text)
226
+ return;
227
+ iframeRef.current?.contentWindow?.postMessage({ type: 'hanzo-screen-clipboard', text }, '*');
228
+ if (client && activeBox?.id) {
229
+ await actComputer(client, { id: activeBox.id, action: 'type', text });
230
+ }
231
+ setStatusToast(t('Pasted clipboard to desktop.'));
232
+ }
233
+ catch {
234
+ setError(t('Grant browser clipboard permission or take control to paste directly.'));
235
+ }
236
+ };
237
+ const runAutofill = async (item, field) => {
238
+ if (!client || !activeBox?.id || runningTask)
90
239
  return;
91
- setBusy(true);
240
+ setRunningTask(true);
92
241
  setError(null);
242
+ setStatusToast(null);
93
243
  try {
94
- await parkComputer(client, box.id);
95
- setFrameUrl(null);
96
- await onUpdated();
244
+ await actComputer(client, {
245
+ id: activeBox.id,
246
+ action: 'autofill',
247
+ credential: item.id || item.domain || item.name,
248
+ field,
249
+ submit: field === 'login' || field === 'totp',
250
+ });
251
+ setStatusToast(field === 'totp'
252
+ ? t('Typed 6-digit 2FA code for {name} via KMS.', { name: item.name })
253
+ : t('Autofilled {name} via zero-knowledge KMS.', { name: item.name }));
97
254
  }
98
255
  catch (e) {
99
- setError(say(e, t('{name}’s desktop computer', { name: displayName }), 'save', t));
256
+ setError(say(e, t('credential autofill'), 'save', t));
100
257
  }
101
258
  finally {
102
- setBusy(false);
259
+ setRunningTask(false);
103
260
  }
104
261
  };
105
262
  const captureScreenshot = async () => {
106
- if (!client || !box?.id || runningTask)
263
+ if (!client || !activeBox?.id || runningTask)
107
264
  return;
108
265
  setRunningTask(true);
109
266
  setError(null);
110
267
  try {
111
- const out = await actComputer(client, { id: box.id, action: 'screenshot' });
268
+ const out = await actComputer(client, { id: activeBox.id, action: 'screenshot' });
112
269
  if (out.image) {
113
270
  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 }));
271
+ setStatusToast(t('Captured {w}×{h} frame.', { w: out.width || 1280, h: out.height || 800 }));
115
272
  }
116
273
  }
117
274
  catch (e) {
@@ -128,17 +285,19 @@ export function ComputerDialog({ open, onOpenChange, bot, box, onUpdated, }) {
128
285
  return;
129
286
  setRunningTask(true);
130
287
  setError(null);
131
- setLastAnswer(null);
288
+ setStatusToast(null);
132
289
  if (!preset)
133
290
  setTask('');
291
+ // Automatically switch to Watching mode so the user sees the bot move the cursor live
292
+ if (control === 'controlling')
293
+ toggleControl('watching');
134
294
  try {
135
- // Ensure the bot has full tool access so `computer_in_sandbox` is active on the run.
136
295
  if (!bot.tools?.length) {
137
- await updateBotMeta(client, bot.name, { tools: ['*'], computeRef: box?.id || bot.computeRef }).catch(() => null);
296
+ await updateBotMeta(client, bot.name, { tools: ['*'], computeRef: activeBox?.id || bot.computeRef }).catch(() => null);
138
297
  }
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}`;
298
+ 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
299
  const ran = await client.agents.run(bot.name, directive);
141
- setLastAnswer(ran.output || ran.error || t('Task completed on desktop computer.'));
300
+ setStatusToast(ran.output || ran.error || t('Task completed on desktop computer.'));
142
301
  await onUpdated();
143
302
  }
144
303
  catch (err) {
@@ -148,28 +307,30 @@ export function ComputerDialog({ open, onOpenChange, bot, box, onUpdated, }) {
148
307
  setRunningTask(false);
149
308
  }
150
309
  };
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)))] })] })] }) }) }));
310
+ const logins = vaultItems.filter((i) => i.kind === 'login');
311
+ const otherSecrets = vaultItems.filter((i) => i.kind !== 'login');
312
+ const showBottomBar = phase === 'connecting' || phase === 'live' || awake;
313
+ 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
314
+ ? `${displayName} · ${activeBox?.id ?? disk(bot.name)}`
315
+ : phase === 'parked'
316
+ ? `${displayName} · ${t('Parked (resumable)')}`
317
+ : `${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: () => {
318
+ setSnapDataUrl(null);
319
+ setMode((m) => (m === 'screen' ? 'terminal' : 'screen'));
320
+ }, 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
321
+ ? t('Fill {user} + password via {src}', { user: item.username, src: item.source })
322
+ : t('Fill password via {src}', { src: item.source }) })] }) }, item.id))), logins
323
+ .filter((i) => Boolean(i.totpSecretKey))
324
+ .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
325
+ ? t('+ Add 1Password, LastPass, or KMS logins…')
326
+ : 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: () => {
327
+ setSnapDataUrl(null);
328
+ void openStream(activeBox.id, mode, control === 'watching');
329
+ }, 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, 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,
330
+ title: `${displayName} desktop ${mode}`,
331
+ 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) => {
332
+ setVaultOpen(next);
333
+ if (!next)
334
+ void refreshVault();
335
+ }, onAutofill: awake ? (item, field) => void runAutofill(item, field ?? 'login') : undefined, onChanged: (doc) => setVaultItems(doc.items) })] }));
175
336
  }