@hanzo/build 0.2.39 → 0.2.40
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/lib/api/machines.d.ts +4 -3
- package/lib/api/machines.js +5 -4
- package/lib/api/places.d.ts +1 -1
- package/lib/api/places.js +2 -2
- package/lib/settings/machines.js +12 -13
- package/package.json +1 -1
package/lib/api/machines.d.ts
CHANGED
|
@@ -46,10 +46,11 @@ export declare function add(t: Target, what: {
|
|
|
46
46
|
host?: string;
|
|
47
47
|
}): Promise<Machine>;
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
50
|
-
* registered status until a heartbeat arrives, so `online`
|
|
49
|
+
* A machine's status as a person reads it. The platform reports a hand-registered
|
|
50
|
+
* machine at its registered status until a heartbeat arrives, so `online` holds only
|
|
51
|
+
* once one has; before that it is `not seen yet`, and nothing is there to take a run.
|
|
51
52
|
*/
|
|
52
|
-
export declare function
|
|
53
|
+
export declare function state(m: Machine): string;
|
|
53
54
|
/** Rename a machine, or drain it (`draining`) and bring it back (`online`). */
|
|
54
55
|
export declare function change(t: Target, id: string, what: {
|
|
55
56
|
label?: string;
|
package/lib/api/machines.js
CHANGED
|
@@ -58,11 +58,12 @@ export async function add(t, what) {
|
|
|
58
58
|
return machine(await call(t, 'POST', '/v1/agent/targets', { label, kind: what.kind, ...(host ? { host } : {}) }));
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
62
|
-
* registered status until a heartbeat arrives, so `online`
|
|
61
|
+
* A machine's status as a person reads it. The platform reports a hand-registered
|
|
62
|
+
* machine at its registered status until a heartbeat arrives, so `online` holds only
|
|
63
|
+
* once one has; before that it is `not seen yet`, and nothing is there to take a run.
|
|
63
64
|
*/
|
|
64
|
-
export function
|
|
65
|
-
return m.status === 'online' && m.seen
|
|
65
|
+
export function state(m) {
|
|
66
|
+
return m.status === 'online' && !m.seen ? 'not seen yet' : m.status;
|
|
66
67
|
}
|
|
67
68
|
/** Rename a machine, or drain it (`draining`) and bring it back (`online`). */
|
|
68
69
|
export async function change(t, id, what) {
|
package/lib/api/places.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export interface Place {
|
|
|
14
14
|
label: string;
|
|
15
15
|
/** laptop | gpu | cloud | … as the platform names it; 'sandbox' for the sandbox. */
|
|
16
16
|
kind: string;
|
|
17
|
-
/** online | offline | draining; the sandbox is always online. */
|
|
17
|
+
/** online | offline | draining | not seen yet, as machines.ts `state` reads it; the sandbox is always online. */
|
|
18
18
|
status: string;
|
|
19
19
|
/** "10 vCPU / 122G / 1× GB10", when the machine reported one. */
|
|
20
20
|
capacity: string;
|
package/lib/api/places.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { machines } from './machines.js';
|
|
1
|
+
import { machines, state } from './machines.js';
|
|
2
2
|
export const SANDBOX = { id: '', label: 'Hanzo sandbox', kind: 'sandbox', status: 'online', capacity: '' };
|
|
3
3
|
export async function places(t) {
|
|
4
4
|
const list = await machines(t);
|
|
5
|
-
return [SANDBOX, ...list.map((
|
|
5
|
+
return [SANDBOX, ...list.map((m) => ({ id: m.id, label: m.label, kind: m.kind, status: state(m), capacity: m.capacity }))];
|
|
6
6
|
}
|
|
7
7
|
/** Whether a run sent here now would be taken. */
|
|
8
8
|
export const ready = (p) => p.status === 'online';
|
package/lib/settings/machines.js
CHANGED
|
@@ -11,7 +11,7 @@ import { MoreHorizontal, Plus } from '@hanzogui/lucide-icons-2';
|
|
|
11
11
|
import { Button, Dialog, DialogContent, DialogTitle, DropdownMenu, Input } from '@hanzo/ui';
|
|
12
12
|
import { CopyButton } from '@hanzo/ui/product';
|
|
13
13
|
import { useEffect, useState } from 'react';
|
|
14
|
-
import { add, change, KINDS, key,
|
|
14
|
+
import { add, change, KINDS, key, machines, remove, state } from '../api/machines.js';
|
|
15
15
|
import { Confirm, Rename } from '../ask.js';
|
|
16
16
|
import { useRead } from '../data.js';
|
|
17
17
|
import { useHost, useTarget } from '../host.js';
|
|
@@ -26,11 +26,10 @@ const UNREAD = [];
|
|
|
26
26
|
/** The line under a machine: what it is, where, how big, and what it is doing. */
|
|
27
27
|
function about(m) {
|
|
28
28
|
const load = m.running ? `${m.running} running` : m.sessions ? `${m.sessions} runs` : '';
|
|
29
|
-
|
|
30
|
-
return [state, m.kind, m.host && m.host !== m.label ? m.host : '', m.capacity, load].filter(Boolean).join(' · ');
|
|
29
|
+
return [state(m) || 'unknown', m.kind, m.host && m.host !== m.label ? m.host : '', m.capacity, load].filter(Boolean).join(' · ');
|
|
31
30
|
}
|
|
32
31
|
function Dot({ m }) {
|
|
33
|
-
const on =
|
|
32
|
+
const on = state(m) === 'online';
|
|
34
33
|
return (_jsx(YStack, { width: 8, height: 8, rounded: 999, shrink: 0, bg: on ? '$green10' : 'transparent', borderWidth: on ? 0 : 1, borderColor: m.status === 'draining' ? '$yellow10' : '$soft', "aria-hidden": true }));
|
|
35
34
|
}
|
|
36
35
|
export function Machines() {
|
|
@@ -66,15 +65,15 @@ export function Machines() {
|
|
|
66
65
|
setNote(e.message);
|
|
67
66
|
}
|
|
68
67
|
};
|
|
69
|
-
return (_jsxs(YStack, { gap: "$6", children: [_jsx(Heading, { title: "Machines", detail: "Your organization\u2019s own computers. A run sent to one runs there instead of in the Hanzo sandbox." }), _jsxs(Group, { title: "Link a machine", detail: "Run these on it. It registers under its hostname, and stays online while hanzo link runs.", children: [_jsxs(XStack, { items: "flex-start", gap: "$2", px: "$3", py: "$2.5", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", bg: "$raised", children: [_jsx(SizableText, { flex: 1, minW: 0, size: "$2", color: "$ink", "aria-label": "Link commands", style: { ...mono, whiteSpace: 'pre-wrap' }, children: LINK }), _jsx(CopyButton, { value: LINK, label: "Copy the commands" })] }), _jsx(XStack, { children: _jsxs(Button, { size: "sm", variant: "ghost", onPress: () => setAdding(true), children: [_jsx(Plus, { size: 14 }), " Register one by hand"] }) })] }),
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
68
|
+
return (_jsxs(YStack, { gap: "$6", children: [_jsx(Heading, { title: "Machines", detail: "Your organization\u2019s own computers. A run sent to one runs there instead of in the Hanzo sandbox." }), _jsxs(Group, { title: "Link a machine", detail: "Run these on it. It registers under its hostname, and stays online while hanzo link runs.", children: [_jsxs(XStack, { items: "flex-start", gap: "$2", px: "$3", py: "$2.5", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", bg: "$raised", children: [_jsx(SizableText, { flex: 1, minW: 0, size: "$2", color: "$ink", "aria-label": "Link commands", style: { ...mono, whiteSpace: 'pre-wrap' }, children: LINK }), _jsx(CopyButton, { value: LINK, label: "Copy the commands" })] }), _jsx(XStack, { children: _jsxs(Button, { size: "sm", variant: "ghost", onPress: () => setAdding(true), children: [_jsx(Plus, { size: 14 }), " Register one by hand"] }) })] }), _jsxs(Group, { title: "Linked", children: [list.value === UNREAD ? (_jsx(Soft, { children: list.error ? list.error.message : 'Reading machines…' })) : list.value.length === 0 ? (_jsx(Soft, { children: "No machine is linked yet." })) : (_jsx(Card, { children: list.value.map((m, i) => (_jsx(Row, { first: i === 0, leading: _jsx(Dot, { m: m }), title: m.label, detail: about(m), trailing: _jsx(DropdownMenu, { trigger: _jsx(XStack, { render: "button", "aria-label": `Actions for ${m.label}`, px: "$1.5", py: "$1", rounded: "$2", hoverStyle: { bg: '$hover' }, children: _jsx(MoreHorizontal, { size: 16 }) }), items: [
|
|
69
|
+
{ key: 'rename', label: 'Rename', onSelect: () => setRenaming(m) },
|
|
70
|
+
m.status === 'draining'
|
|
71
|
+
? { key: 'online', label: 'Take runs again', onSelect: () => void drain(m, 'online') }
|
|
72
|
+
: { key: 'drain', label: 'Drain', description: 'Finish what it has, take nothing new', onSelect: () => void drain(m, 'draining') },
|
|
73
|
+
{ key: 'key', label: 'Claim key', onSelect: () => setKeying(m) },
|
|
74
|
+
{ type: 'separator' },
|
|
75
|
+
{ key: 'remove', label: 'Remove', destructive: true, onSelect: () => setRemoving(m) },
|
|
76
|
+
] }) }, m.id))) })), list.error && list.value !== UNREAD ? _jsx(Soft, { children: list.error.message }) : null] }), _jsx(Note, { children: note }), _jsx(Adding, { open: adding, onOpenChange: setAdding, onAdded: (m) => {
|
|
78
77
|
setNote(`${m.label} is registered`);
|
|
79
78
|
list.reload();
|
|
80
79
|
} }), _jsx(Rename, { open: renaming !== null, onOpenChange: (o) => !o && setRenaming(null), title: "Rename machine", name: renaming?.label ?? '',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/build",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.40",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"description": "Hanzo Build — say what you want, watch it built, deployed and running. The builder as a component, mounted by the Hanzo app at hanzo.ai.",
|