@hanzo/app 0.3.91 → 0.3.92

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.
@@ -43,10 +43,12 @@ export function ComputerDialog({ open, onOpenChange, bot, box, onUpdated, }) {
43
43
  const displayName = called(bot.name);
44
44
  const iframeRef = useRef(null);
45
45
  const autoBootedRef = useRef(false);
46
+ const controlRef = useRef('watching');
46
47
  const [localBox, setLocalBox] = useState(box);
47
48
  const [expanded, setExpanded] = useState(false);
48
49
  const [mode, setMode] = useState('screen');
49
50
  const [control, setControl] = useState('watching');
51
+ controlRef.current = control;
50
52
  const [phase, setPhase] = useState('idle');
51
53
  const [frameUrl, setFrameUrl] = useState(null);
52
54
  const [snapDataUrl, setSnapDataUrl] = useState(null);
@@ -131,7 +133,7 @@ export function ComputerDialog({ open, onOpenChange, bot, box, onUpdated, }) {
131
133
  await onUpdated();
132
134
  if (leased.status === 'running') {
133
135
  const effectiveMode = leased.class === 'desktop' ? mode : 'terminal';
134
- await openStream(leased.id, effectiveMode, control === 'watching');
136
+ await openStream(leased.id, effectiveMode, controlRef.current === 'watching');
135
137
  }
136
138
  else {
137
139
  // Poll up to ~25s while the sandbox container schedules & boots X11
@@ -142,7 +144,7 @@ export function ComputerDialog({ open, onOpenChange, bot, box, onUpdated, }) {
142
144
  setLocalBox(latest);
143
145
  if (latest?.status === 'running') {
144
146
  await onUpdated();
145
- await openStream(latest.id, latest.class === 'desktop' ? mode : 'terminal', control === 'watching');
147
+ await openStream(latest.id, latest.class === 'desktop' ? mode : 'terminal', controlRef.current === 'watching');
146
148
  break;
147
149
  }
148
150
  }
@@ -158,8 +160,10 @@ export function ComputerDialog({ open, onOpenChange, bot, box, onUpdated, }) {
158
160
  finally {
159
161
  setBusy(false);
160
162
  }
161
- }, [client, busy, bot, activeBox, onUpdated, mode, openStream, control, displayName, t]);
163
+ }, [client, busy, bot, activeBox, onUpdated, mode, openStream, displayName, t]);
162
164
  // Auto-open live stream if running, or auto-boot/resume on open!
165
+ // Intentionally reads `controlRef.current` rather than depending on `control` so
166
+ // clicking `Take control` / `Watching` sends instant postMessage without reloading the iframe.
163
167
  useEffect(() => {
164
168
  if (!open) {
165
169
  autoBootedRef.current = false;
@@ -174,14 +178,14 @@ export function ComputerDialog({ open, onOpenChange, bot, box, onUpdated, }) {
174
178
  if (activeBox?.id && activeBox.status === 'running') {
175
179
  autoBootedRef.current = true;
176
180
  const effectiveMode = activeBox.class === 'desktop' ? mode : 'terminal';
177
- void openStream(activeBox.id, effectiveMode, control === 'watching');
181
+ void openStream(activeBox.id, effectiveMode, controlRef.current === 'watching');
178
182
  return;
179
183
  }
180
184
  if (!autoBootedRef.current && client) {
181
185
  autoBootedRef.current = true;
182
186
  void startOrResume(false);
183
187
  }
184
- }, [open, activeBox?.id, activeBox?.status, activeBox?.class, mode, client, openStream, startOrResume, control]);
188
+ }, [open, activeBox?.id, activeBox?.status, activeBox?.class, mode, client, openStream, startOrResume]);
185
189
  const toggleControl = (nextControl) => {
186
190
  setControl(nextControl);
187
191
  const viewOnly = nextControl === 'watching';
@@ -237,16 +241,21 @@ export function ComputerDialog({ open, onOpenChange, bot, box, onUpdated, }) {
237
241
  setError(null);
238
242
  setStatusToast(null);
239
243
  try {
240
- await actComputer(client, {
244
+ const out = await actComputer(client, {
241
245
  id: activeBox.id,
242
246
  action: 'autofill',
243
247
  credential: item.id || item.domain || item.name,
244
248
  field,
245
- submit: field === 'login' || field === 'totp',
249
+ submit: field === 'login' || field === 'login_totp' || field === 'totp',
246
250
  });
247
- setStatusToast(field === 'totp'
248
- ? t('Typed 6-digit 2FA code for {name} via KMS.', { name: item.name })
249
- : t('Autofilled {name} via zero-knowledge KMS.', { name: item.name }));
251
+ if (out.ok === false) {
252
+ setError(out.text || t('Could not autofill {name}.', { name: item.name }));
253
+ return;
254
+ }
255
+ setStatusToast(out.text ||
256
+ (field === 'totp'
257
+ ? t('Typed 6-digit 2FA code for {name} via KMS.', { name: item.name })
258
+ : t('Autofilled {name} via zero-knowledge KMS.', { name: item.name })));
250
259
  }
251
260
  catch (e) {
252
261
  setError(say(e, t('credential autofill'), 'save', t));
@@ -255,6 +264,31 @@ export function ComputerDialog({ open, onOpenChange, bot, box, onUpdated, }) {
255
264
  setRunningTask(false);
256
265
  }
257
266
  };
267
+ const sealStagedAppCredential = async () => {
268
+ if (!client || !activeBox?.id || runningTask)
269
+ return;
270
+ setRunningTask(true);
271
+ setError(null);
272
+ setStatusToast(null);
273
+ try {
274
+ const out = await actComputer(client, {
275
+ id: activeBox.id,
276
+ action: 'save_credential',
277
+ });
278
+ if (out.ok === false) {
279
+ setError(out.text || t('No staged credential found at /dev/shm/.hanzo-credential.json.'));
280
+ return;
281
+ }
282
+ await refreshVault();
283
+ setStatusToast(out.text || t('Sealed sandbox app credential into Hanzo KMS and shredded RAM file.'));
284
+ }
285
+ catch (e) {
286
+ setError(say(e, t('sandbox credential save'), 'save', t));
287
+ }
288
+ finally {
289
+ setRunningTask(false);
290
+ }
291
+ };
258
292
  const captureScreenshot = async () => {
259
293
  if (!client || !activeBox?.id || runningTask)
260
294
  return;
@@ -262,8 +296,12 @@ export function ComputerDialog({ open, onOpenChange, bot, box, onUpdated, }) {
262
296
  setError(null);
263
297
  try {
264
298
  const out = await actComputer(client, { id: activeBox.id, action: 'screenshot' });
299
+ if (out.ok === false) {
300
+ setError(out.text || t('Could not capture desktop screenshot.'));
301
+ return;
302
+ }
265
303
  if (out.image) {
266
- setSnapDataUrl(`data:${out.mimeType || 'image/png'};base64,${out.image}`);
304
+ setSnapDataUrl(out.image.startsWith('data:') ? out.image : `data:${out.mimeType || 'image/jpeg'};base64,${out.image}`);
267
305
  setStatusToast(t('Captured {w}×{h} frame.', { w: out.width || 1280, h: out.height || 800 }));
268
306
  }
269
307
  }
@@ -313,11 +351,16 @@ export function ComputerDialog({ open, onOpenChange, bot, box, onUpdated, }) {
313
351
  : `${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: () => {
314
352
  setSnapDataUrl(null);
315
353
  setMode((m) => (m === 'screen' ? 'terminal' : 'screen'));
316
- }, 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
317
- ? t('Fill {user} + password via {src}', { user: item.username, src: item.source })
354
+ }, 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: 260, children: [logins.map((item) => (_jsx(DropdownMenuItem, { onSelect: () => void runAutofill(item, item.totpSecretKey ? 'login_totp' : '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
355
+ ? item.totpSecretKey
356
+ ? t('Fill {user} + password + 2FA via {src}', {
357
+ user: item.username,
358
+ src: item.source,
359
+ })
360
+ : t('Fill {user} + password via {src}', { user: item.username, src: item.source })
318
361
  : t('Fill password via {src}', { src: item.source }) })] }) }, item.id))), logins
319
362
  .filter((i) => Boolean(i.totpSecretKey))
320
- .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
363
+ .map((item) => (_jsx(DropdownMenuItem, { onSelect: () => void runAutofill(item, 'totp'), children: _jsx(Text, { fontSize: "$2", color: "$ink", children: t('2FA TOTP code only · {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: () => void sealStagedAppCredential(), children: _jsxs(YStack, { gap: 1, children: [_jsx(Text, { fontSize: "$2", fontWeight: "600", color: "$ink", children: t('Seal staged sandbox app login → KMS') }), _jsx(Text, { fontSize: "$1", color: DIM, children: t('Imports /dev/shm/.hanzo-credential.json & shreds RAM file') })] }) }), _jsx(DropdownMenuItem, { onSelect: () => setVaultOpen(true), children: _jsx(Text, { fontSize: "$2", fontWeight: "600", color: "$ink", children: vaultItems.length === 0
321
364
  ? t('+ Add 1Password, LastPass, or KMS logins…')
322
365
  : 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: () => {
323
366
  setSnapDataUrl(null);
@@ -205,7 +205,7 @@ export declare function bootOrResumeComputer(c: Client, bot: BotAgent, existing?
205
205
  export declare function parkComputer(c: Client, id: string): Promise<void>;
206
206
  export interface ComputerActionIn {
207
207
  id: string;
208
- action: 'screenshot' | 'click' | 'double_click' | 'right_click' | 'middle_click' | 'move' | 'drag' | 'scroll' | 'type' | 'key' | 'navigate' | 'wait' | 'shell' | 'autofill';
208
+ action: 'screenshot' | 'click' | 'double_click' | 'right_click' | 'middle_click' | 'move' | 'drag' | 'scroll' | 'type' | 'key' | 'navigate' | 'wait' | 'shell' | 'autofill' | 'save_credential';
209
209
  x?: number;
210
210
  y?: number;
211
211
  toX?: number;
@@ -213,16 +213,20 @@ export interface ComputerActionIn {
213
213
  dx?: number;
214
214
  dy?: number;
215
215
  text?: string;
216
+ keys?: string;
216
217
  key?: string;
217
218
  url?: string;
218
219
  command?: string;
220
+ seconds?: number;
219
221
  ms?: number;
220
222
  credential?: string;
221
- field?: 'login' | 'username' | 'password' | 'totp' | 'secret';
223
+ field?: 'login' | 'login_totp' | 'username' | 'password' | 'totp' | 'secret';
222
224
  submit?: boolean;
223
225
  }
224
226
  export interface ComputerActionOut {
225
- action: string;
227
+ ok?: boolean;
228
+ text?: string;
229
+ action?: string;
226
230
  stdout?: string;
227
231
  stderr?: string;
228
232
  exitCode?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/app",
3
- "version": "0.3.91",
3
+ "version": "0.3.92",
4
4
  "description": "Hanzo's app: the shell and its apps (Home, Chat, Inbox, Contacts, Meet, Calendar, Drive, Board, Work, Bots), once, for every Hanzo surface.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",