@hanzo/app 0.3.89 → 0.3.91

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.
@@ -15,9 +15,16 @@ import { useAi } from '../lib/ai.js';
15
15
  import { say } from '../failure.js';
16
16
  import { called } from '../team.js';
17
17
  import { VaultDialog, readVault } from '../vault.js';
18
- import { actComputer, bootOrResumeComputer, disk, findBotComputer, grant, parkComputer, updateBotMeta, } from './api.js';
18
+ import { actComputer, bootOrResumeComputer, disk, findBotComputer, grant, opened, parkComputer, updateBotMeta, } from './api.js';
19
19
  import { CLIP, PILL, WORD } from './kit.js';
20
- import { DIM, FLOOR, INK, LINE, PICKED, RAISED } from './ink.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)';
21
28
  function PulsingCluster({ label }) {
22
29
  const [step, setStep] = useState(0);
23
30
  useEffect(() => {
@@ -30,17 +37,6 @@ function PulsingCluster({ label }) {
30
37
  return (_jsx(YStack, { width: mid ? 7 : 4, height: mid ? 7 : 4, rounded: 999, bg: "var(--pure-white)", opacity: active ? 1 : 0.35 }, i));
31
38
  }) }), _jsx(Text, { fontSize: 13, lineHeight: 18, fontWeight: "500", color: "var(--pure-white)", opacity: 0.58, children: label })] }));
32
39
  }
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
- }
44
40
  export function ComputerDialog({ open, onOpenChange, bot, box, onUpdated, }) {
45
41
  const { t } = useI18n();
46
42
  const { client } = useAi();
@@ -105,7 +101,7 @@ export function ComputerDialog({ open, onOpenChange, bot, box, onUpdated, }) {
105
101
  try {
106
102
  const g = await grant(client, targetId, kind);
107
103
  if (g.url) {
108
- const finalUrl = kind === 'screen' ? appendViewParam(g.url, wantViewOnly) : g.url;
104
+ const finalUrl = opened(g.url, kind === 'screen' ? wantViewOnly : undefined);
109
105
  setFrameUrl(finalUrl);
110
106
  // Terminal or older edge screen page without postMessage transitions smoothly after load
111
107
  window.setTimeout(() => {
@@ -326,7 +322,7 @@ export function ComputerDialog({ open, onOpenChange, bot, box, onUpdated, }) {
326
322
  : 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
323
  setSnapDataUrl(null);
328
324
  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,
325
+ }, 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,
330
326
  title: `${displayName} desktop ${mode}`,
331
327
  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
328
  setVaultOpen(next);
@@ -178,6 +178,15 @@ export interface Grant {
178
178
  expiresIn?: number;
179
179
  }
180
180
  export declare const grant: (c: Client, id: string, kind: 'terminal' | 'screen') => Promise<Grant>;
181
+ /**
182
+ * Where a grant opens: its address on the API host, and for a screen whether it
183
+ * opens to watch or to control. Cloud answers a PATH
184
+ * (`/v1/sandbox/<id>/screen?ticket=…`, cloud apps/sandbox `ticketGrant`), and the
185
+ * API's host serves it, never the page's: on hanzo.bot the page's own host is the
186
+ * static site, which answers that path with a page that refuses to be framed, and
187
+ * a bot's computer read "hanzo.bot refused to connect".
188
+ */
189
+ export declare function opened(url: string, viewOnly?: boolean): string;
181
190
  /**
182
191
  * Finds the bot's existing desktop sandbox across both named project disks (`bot-<name>`)
183
192
  * and Free-tier persistent `disk: true` sandboxes bound via `bot.computeRef`.
package/dist/bots/api.js CHANGED
@@ -180,6 +180,20 @@ export async function slackChannels(signal) {
180
180
  }
181
181
  }
182
182
  export const grant = (c, id, kind) => c.http.json({ method: 'POST', path: `/v1/sandbox/${encodeURIComponent(id)}/${kind}/ticket` });
183
+ /**
184
+ * Where a grant opens: its address on the API host, and for a screen whether it
185
+ * opens to watch or to control. Cloud answers a PATH
186
+ * (`/v1/sandbox/<id>/screen?ticket=…`, cloud apps/sandbox `ticketGrant`), and the
187
+ * API's host serves it, never the page's: on hanzo.bot the page's own host is the
188
+ * static site, which answers that path with a page that refuses to be framed, and
189
+ * a bot's computer read "hanzo.bot refused to connect".
190
+ */
191
+ export function opened(url, viewOnly) {
192
+ const u = new URL(url, `${api()}/`);
193
+ if (viewOnly !== undefined)
194
+ u.searchParams.set('viewOnly', viewOnly ? '1' : '0');
195
+ return u.toString();
196
+ }
183
197
  function bestSandbox(boxes) {
184
198
  return (boxes.find((b) => b.status === 'running') ??
185
199
  boxes.find((b) => b.status === 'pending') ??
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/app",
3
- "version": "0.3.89",
3
+ "version": "0.3.91",
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",