@miosa/cli 1.0.5 → 1.0.7
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/bin/miosa.js +8 -0
- package/dist/bin/miosa.js.map +1 -1
- package/dist/commands/checkpoints.d.ts.map +1 -1
- package/dist/commands/checkpoints.js +166 -6
- package/dist/commands/checkpoints.js.map +1 -1
- package/dist/commands/computers.d.ts.map +1 -1
- package/dist/commands/computers.js +166 -5
- package/dist/commands/computers.js.map +1 -1
- package/dist/commands/dashboard.d.ts +13 -0
- package/dist/commands/dashboard.d.ts.map +1 -0
- package/dist/commands/dashboard.js +54 -0
- package/dist/commands/dashboard.js.map +1 -0
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +134 -2
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +69 -25
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/domains.d.ts.map +1 -1
- package/dist/commands/domains.js +118 -9
- package/dist/commands/domains.js.map +1 -1
- package/dist/commands/enterprise-util.d.ts.map +1 -1
- package/dist/commands/enterprise-util.js +14 -10
- package/dist/commands/enterprise-util.js.map +1 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +89 -21
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.d.ts.map +1 -1
- package/dist/commands/logout.js +27 -4
- package/dist/commands/logout.js.map +1 -1
- package/dist/commands/logs.d.ts.map +1 -1
- package/dist/commands/logs.js +59 -1
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +228 -1380
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/menu.d.ts +16 -0
- package/dist/commands/menu.d.ts.map +1 -0
- package/dist/commands/menu.js +113 -0
- package/dist/commands/menu.js.map +1 -0
- package/dist/commands/network-policy.d.ts.map +1 -1
- package/dist/commands/network-policy.js +120 -5
- package/dist/commands/network-policy.js.map +1 -1
- package/dist/commands/sandbox.d.ts.map +1 -1
- package/dist/commands/sandbox.js +157 -5
- package/dist/commands/sandbox.js.map +1 -1
- package/dist/commands/whoami.d.ts.map +1 -1
- package/dist/commands/whoami.js +76 -19
- package/dist/commands/whoami.js.map +1 -1
- package/dist/tui/dashboard.d.ts +35 -0
- package/dist/tui/dashboard.d.ts.map +1 -0
- package/dist/tui/dashboard.js +191 -0
- package/dist/tui/dashboard.js.map +1 -0
- package/dist/tui/logs.d.ts +26 -0
- package/dist/tui/logs.d.ts.map +1 -0
- package/dist/tui/logs.js +276 -0
- package/dist/tui/logs.js.map +1 -0
- package/dist/ui/picker.d.ts +41 -0
- package/dist/ui/picker.d.ts.map +1 -0
- package/dist/ui/picker.js +77 -0
- package/dist/ui/picker.js.map +1 -0
- package/dist/ui/render.d.ts +91 -0
- package/dist/ui/render.d.ts.map +1 -0
- package/dist/ui/render.js +138 -0
- package/dist/ui/render.js.map +1 -0
- package/package.json +4 -1
package/dist/commands/whoami.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import { loadConfig, loadAuthCache, saveAuthCache, redactKey, } from "../config.js";
|
|
3
3
|
import { MiosaClient } from "../client.js";
|
|
4
|
-
import {
|
|
4
|
+
import { banner, errorEnvelope, hintBlock, icon, kvPanel, } from "../ui/render.js";
|
|
5
|
+
import { printJson } from "./util.js";
|
|
5
6
|
export function register(program) {
|
|
6
7
|
program
|
|
7
8
|
.command("whoami")
|
|
@@ -10,15 +11,19 @@ export function register(program) {
|
|
|
10
11
|
.option("--refresh", "Force a network refresh of the cached identity")
|
|
11
12
|
.action(async (opts) => {
|
|
12
13
|
const config = loadConfig();
|
|
14
|
+
// ── Not signed in ────────────────────────────────────────────────
|
|
13
15
|
if (!config.api_key) {
|
|
14
16
|
if (opts.json) {
|
|
15
17
|
printJson({ authenticated: false });
|
|
16
18
|
return;
|
|
17
19
|
}
|
|
18
|
-
console.log(
|
|
20
|
+
console.log();
|
|
21
|
+
console.log(` ${icon.warn} ${chalk.bold("Not signed in")}`);
|
|
22
|
+
console.log();
|
|
23
|
+
console.log(hintBlock("Sign in", ["miosa login"]));
|
|
19
24
|
process.exit(1);
|
|
20
25
|
}
|
|
21
|
-
// Fast path: serve from cache
|
|
26
|
+
// ── Fast path: serve from cache ─────────────────────────────────
|
|
22
27
|
const cached = opts.refresh ? null : loadAuthCache();
|
|
23
28
|
if (cached) {
|
|
24
29
|
if (opts.json) {
|
|
@@ -34,16 +39,18 @@ export function register(program) {
|
|
|
34
39
|
});
|
|
35
40
|
return;
|
|
36
41
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
renderIdentity({
|
|
43
|
+
name: cached.name,
|
|
44
|
+
slug: cached.slug,
|
|
45
|
+
plan: cached.plan,
|
|
46
|
+
credit_balance: cached.credit_balance,
|
|
47
|
+
region: cached.region ?? config.region ?? "auto",
|
|
48
|
+
api_key: config.api_key,
|
|
49
|
+
fromCache: true,
|
|
50
|
+
});
|
|
44
51
|
return;
|
|
45
52
|
}
|
|
46
|
-
// Slow path: fetch
|
|
53
|
+
// ── Slow path: fetch + cache ────────────────────────────────────
|
|
47
54
|
try {
|
|
48
55
|
const client = new MiosaClient(config);
|
|
49
56
|
const tenant = await client.getTenant();
|
|
@@ -68,17 +75,67 @@ export function register(program) {
|
|
|
68
75
|
});
|
|
69
76
|
return;
|
|
70
77
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
renderIdentity({
|
|
79
|
+
name: tenant.name,
|
|
80
|
+
slug: tenant.slug,
|
|
81
|
+
plan: tenant.plan,
|
|
82
|
+
credit_balance: tenant.credit_balance,
|
|
83
|
+
region: config.region ?? "auto",
|
|
84
|
+
api_key: config.api_key,
|
|
85
|
+
fromCache: false,
|
|
86
|
+
});
|
|
78
87
|
}
|
|
79
88
|
catch (err) {
|
|
80
|
-
|
|
89
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
90
|
+
console.log();
|
|
91
|
+
console.log(errorEnvelope({
|
|
92
|
+
title: "Could not load identity",
|
|
93
|
+
body: message,
|
|
94
|
+
suggest: [
|
|
95
|
+
"miosa whoami --refresh # bypass the local cache",
|
|
96
|
+
"miosa login # re-authenticate if your key was revoked",
|
|
97
|
+
],
|
|
98
|
+
withDebugHint: true,
|
|
99
|
+
}));
|
|
100
|
+
process.exit(1);
|
|
81
101
|
}
|
|
82
102
|
});
|
|
83
103
|
}
|
|
104
|
+
function renderIdentity(s) {
|
|
105
|
+
console.log();
|
|
106
|
+
console.log(` ${banner({ subtitle: "Identity" })}`);
|
|
107
|
+
console.log();
|
|
108
|
+
console.log(kvPanel([
|
|
109
|
+
{
|
|
110
|
+
icon: icon.ok,
|
|
111
|
+
label: "Tenant",
|
|
112
|
+
value: chalk.bold(s.name) + chalk.dim(` (${s.slug})`),
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
label: "Plan",
|
|
116
|
+
value: chalk.bold(s.plan),
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
label: "Credits",
|
|
120
|
+
value: s.credit_balance > 0
|
|
121
|
+
? chalk.bold(s.credit_balance.toLocaleString())
|
|
122
|
+
: chalk.yellow("0 — top up at https://miosa.ai/billing"),
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
label: "Region",
|
|
126
|
+
value: s.region,
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
label: "API key",
|
|
130
|
+
value: chalk.dim(redactKey(s.api_key)),
|
|
131
|
+
},
|
|
132
|
+
]));
|
|
133
|
+
if (s.fromCache) {
|
|
134
|
+
console.log();
|
|
135
|
+
console.log(` ${chalk.dim("(cached — use ")}` +
|
|
136
|
+
chalk.cyan("miosa whoami --refresh") +
|
|
137
|
+
chalk.dim(" for live data)"));
|
|
138
|
+
}
|
|
139
|
+
console.log();
|
|
140
|
+
}
|
|
84
141
|
//# sourceMappingURL=whoami.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../src/commands/whoami.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,UAAU,EACV,aAAa,EACb,aAAa,EACb,SAAS,GACV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,
|
|
1
|
+
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../src/commands/whoami.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,UAAU,EACV,aAAa,EACb,aAAa,EACb,SAAS,GACV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EACL,MAAM,EACN,aAAa,EACb,SAAS,EACT,IAAI,EACJ,OAAO,GACR,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,UAAU,QAAQ,CAAC,OAAgB;IACvC,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,8CAA8C,CAAC;SAC3D,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC;SAClC,MAAM,CAAC,WAAW,EAAE,gDAAgD,CAAC;SACrE,MAAM,CAAC,KAAK,EAAE,IAA2C,EAAE,EAAE;QAC5D,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;QAE5B,oEAAoE;QACpE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;gBACd,SAAS,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC;gBACpC,O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Q;YACf,KAAK,EAAE,CAAC,CAAC,MAAM;SAChB;QACD;YACE,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;SACvC;KACF,CAAC,CACH,CAAC;IACF,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;QAChB,OAAO,CAAC,GAAG,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CACT,KAAK,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE;YAChC,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC;YACpC,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAC/B,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,GAAG,EAAE,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `miosa watch` — live terminal dashboard.
|
|
3
|
+
*
|
|
4
|
+
* React component (rendered by ink) that polls the MIOSA API every few
|
|
5
|
+
* seconds and shows a single-screen snapshot:
|
|
6
|
+
*
|
|
7
|
+
* - Sign-in identity (tenant + plan)
|
|
8
|
+
* - Counts: running computers, sandboxes, deployments
|
|
9
|
+
* - Last fetch time + auto-refresh interval
|
|
10
|
+
* - Recent activity (most recent N rows from computers/sandboxes/deps)
|
|
11
|
+
* - Quit hint
|
|
12
|
+
*
|
|
13
|
+
* The component is self-contained — bin/miosa.ts is unchanged; the new
|
|
14
|
+
* watch.ts command just mounts this with `ink.render()`.
|
|
15
|
+
*/
|
|
16
|
+
import React from "react";
|
|
17
|
+
import type { MiosaConfig } from "../types.js";
|
|
18
|
+
interface DashboardProps {
|
|
19
|
+
config: MiosaConfig;
|
|
20
|
+
}
|
|
21
|
+
interface ResourceRow {
|
|
22
|
+
id: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
status?: string;
|
|
25
|
+
state?: string;
|
|
26
|
+
template_type?: string;
|
|
27
|
+
updated_at?: string;
|
|
28
|
+
created_at?: string;
|
|
29
|
+
}
|
|
30
|
+
declare function isActive(row: ResourceRow): boolean;
|
|
31
|
+
declare function timeAgo(iso?: string): string;
|
|
32
|
+
declare function sortRecent(rows: ResourceRow[]): ResourceRow[];
|
|
33
|
+
export declare const Dashboard: React.FC<DashboardProps>;
|
|
34
|
+
export { sortRecent, timeAgo, isActive };
|
|
35
|
+
//# sourceMappingURL=dashboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../../src/tui/dashboard.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAuC,MAAM,OAAO,CAAC;AAG5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,UAAU,cAAc;IACtB,MAAM,EAAE,WAAW,CAAC;CACrB;AAED,UAAU,WAAW;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAqCD,iBAAS,QAAQ,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAG3C;AAED,iBAAS,OAAO,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAQrC;AAED,iBAAS,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,WAAW,EAAE,CAMtD;AAED,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAuN9C,CAAC;AAmEF,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* `miosa watch` — live terminal dashboard.
|
|
4
|
+
*
|
|
5
|
+
* React component (rendered by ink) that polls the MIOSA API every few
|
|
6
|
+
* seconds and shows a single-screen snapshot:
|
|
7
|
+
*
|
|
8
|
+
* - Sign-in identity (tenant + plan)
|
|
9
|
+
* - Counts: running computers, sandboxes, deployments
|
|
10
|
+
* - Last fetch time + auto-refresh interval
|
|
11
|
+
* - Recent activity (most recent N rows from computers/sandboxes/deps)
|
|
12
|
+
* - Quit hint
|
|
13
|
+
*
|
|
14
|
+
* The component is self-contained — bin/miosa.ts is unchanged; the new
|
|
15
|
+
* watch.ts command just mounts this with `ink.render()`.
|
|
16
|
+
*/
|
|
17
|
+
import { useEffect, useMemo, useState } from "react";
|
|
18
|
+
import { Box, Text, useApp, useInput } from "ink";
|
|
19
|
+
import { MiosaClient } from "../client.js";
|
|
20
|
+
const POLL_INTERVAL_MS = 5_000;
|
|
21
|
+
async function safeList(client, path) {
|
|
22
|
+
try {
|
|
23
|
+
const result = await client.apiGet(path);
|
|
24
|
+
if (Array.isArray(result))
|
|
25
|
+
return result;
|
|
26
|
+
if (result && typeof result === "object") {
|
|
27
|
+
const rec = result;
|
|
28
|
+
for (const key of [
|
|
29
|
+
"data",
|
|
30
|
+
"computers",
|
|
31
|
+
"sandboxes",
|
|
32
|
+
"deployments",
|
|
33
|
+
"items",
|
|
34
|
+
]) {
|
|
35
|
+
if (Array.isArray(rec[key]))
|
|
36
|
+
return rec[key];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// Snapshot stays consistent even if one endpoint is flaky.
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function isActive(row) {
|
|
47
|
+
const s = (row.status ?? row.state ?? "").toLowerCase();
|
|
48
|
+
return s === "active" || s === "running" || s === "ready";
|
|
49
|
+
}
|
|
50
|
+
function timeAgo(iso) {
|
|
51
|
+
if (!iso)
|
|
52
|
+
return "—";
|
|
53
|
+
const ms = Date.now() - new Date(iso).getTime();
|
|
54
|
+
if (Number.isNaN(ms) || ms < 0)
|
|
55
|
+
return "—";
|
|
56
|
+
if (ms < 60_000)
|
|
57
|
+
return `${Math.floor(ms / 1000)}s ago`;
|
|
58
|
+
if (ms < 3_600_000)
|
|
59
|
+
return `${Math.floor(ms / 60_000)}m ago`;
|
|
60
|
+
if (ms < 86_400_000)
|
|
61
|
+
return `${Math.floor(ms / 3_600_000)}h ago`;
|
|
62
|
+
return `${Math.floor(ms / 86_400_000)}d ago`;
|
|
63
|
+
}
|
|
64
|
+
function sortRecent(rows) {
|
|
65
|
+
return [...rows].sort((a, b) => {
|
|
66
|
+
const ta = new Date(a.updated_at ?? a.created_at ?? 0).getTime();
|
|
67
|
+
const tb = new Date(b.updated_at ?? b.created_at ?? 0).getTime();
|
|
68
|
+
return tb - ta;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
export const Dashboard = ({ config }) => {
|
|
72
|
+
const { exit } = useApp();
|
|
73
|
+
const [snapshot, setSnapshot] = useState({
|
|
74
|
+
fetchedAt: 0,
|
|
75
|
+
computers: [],
|
|
76
|
+
sandboxes: [],
|
|
77
|
+
deployments: [],
|
|
78
|
+
});
|
|
79
|
+
const [tick, setTick] = useState(0);
|
|
80
|
+
// Quit handling
|
|
81
|
+
useInput((input, key) => {
|
|
82
|
+
if (input === "q" || (key.ctrl && input === "c")) {
|
|
83
|
+
exit();
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
const client = useMemo(() => new MiosaClient(config), [config]);
|
|
87
|
+
// Initial load + interval poll
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
let cancelled = false;
|
|
90
|
+
const fetch = async () => {
|
|
91
|
+
try {
|
|
92
|
+
const [computers, sandboxes, deployments, tenant] = await Promise.all([
|
|
93
|
+
safeList(client, "/api/v1/computers"),
|
|
94
|
+
safeList(client, "/api/v1/sandboxes"),
|
|
95
|
+
safeList(client, "/api/v1/deployments"),
|
|
96
|
+
client.getTenant().catch(() => null),
|
|
97
|
+
]);
|
|
98
|
+
if (cancelled)
|
|
99
|
+
return;
|
|
100
|
+
setSnapshot({
|
|
101
|
+
fetchedAt: Date.now(),
|
|
102
|
+
tenant: tenant
|
|
103
|
+
? {
|
|
104
|
+
name: tenant.name,
|
|
105
|
+
plan: tenant.plan,
|
|
106
|
+
slug: tenant.slug,
|
|
107
|
+
credit_balance: tenant.credit_balance,
|
|
108
|
+
}
|
|
109
|
+
: undefined,
|
|
110
|
+
computers,
|
|
111
|
+
sandboxes,
|
|
112
|
+
deployments,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
if (cancelled)
|
|
117
|
+
return;
|
|
118
|
+
setSnapshot((prev) => ({
|
|
119
|
+
...prev,
|
|
120
|
+
fetchedAt: Date.now(),
|
|
121
|
+
error: err instanceof Error ? err.message : String(err),
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
void fetch();
|
|
126
|
+
const id = setInterval(() => void fetch(), POLL_INTERVAL_MS);
|
|
127
|
+
return () => {
|
|
128
|
+
cancelled = true;
|
|
129
|
+
clearInterval(id);
|
|
130
|
+
};
|
|
131
|
+
}, [client]);
|
|
132
|
+
// Local clock tick so "1s ago" labels stay fresh between polls
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
const id = setInterval(() => setTick((t) => t + 1), 1000);
|
|
135
|
+
return () => clearInterval(id);
|
|
136
|
+
}, []);
|
|
137
|
+
const computeActive = snapshot.computers.filter(isActive).length;
|
|
138
|
+
const sandboxActive = snapshot.sandboxes.filter(isActive).length;
|
|
139
|
+
const deployActive = snapshot.deployments.filter(isActive).length;
|
|
140
|
+
const recent = useMemo(() => [
|
|
141
|
+
...snapshot.computers.map((r) => ({
|
|
142
|
+
kind: "computer",
|
|
143
|
+
row: r,
|
|
144
|
+
})),
|
|
145
|
+
...snapshot.sandboxes.map((r) => ({
|
|
146
|
+
kind: "sandbox",
|
|
147
|
+
row: r,
|
|
148
|
+
})),
|
|
149
|
+
...snapshot.deployments.map((r) => ({
|
|
150
|
+
kind: "deployment",
|
|
151
|
+
row: r,
|
|
152
|
+
})),
|
|
153
|
+
]
|
|
154
|
+
.sort((a, b) => {
|
|
155
|
+
const ta = new Date(a.row.updated_at ?? a.row.created_at ?? 0).getTime();
|
|
156
|
+
const tb = new Date(b.row.updated_at ?? b.row.created_at ?? 0).getTime();
|
|
157
|
+
return tb - ta;
|
|
158
|
+
})
|
|
159
|
+
.slice(0, 6), [snapshot, tick]);
|
|
160
|
+
const lastFetchAgo = snapshot.fetchedAt === 0
|
|
161
|
+
? "—"
|
|
162
|
+
: `${Math.max(0, Math.floor((Date.now() - snapshot.fetchedAt) / 1000))}s ago`;
|
|
163
|
+
return (_jsxs(Box, { flexDirection: "column", paddingX: 1, paddingY: 0, children: [_jsxs(Box, { justifyContent: "space-between", marginBottom: 1, children: [_jsxs(Text, { children: [_jsx(Text, { color: "cyan", bold: true, children: "\u25AE\u25AE\u25AE MIOSA \u25AE\u25AE\u25AE" }), snapshot.tenant ? (_jsxs(_Fragment, { children: [" ", _jsx(Text, { bold: true, children: snapshot.tenant.name }), _jsxs(Text, { dimColor: true, children: [" \u00B7 ", snapshot.tenant.plan] })] })) : (_jsx(Text, { dimColor: true, children: " (loading identity\u2026)" }))] }), _jsxs(Text, { dimColor: true, children: ["last fetch ", lastFetchAgo, " \u00B7 refresh ", POLL_INTERVAL_MS / 1000, "s"] })] }), _jsxs(Box, { flexDirection: "row", marginBottom: 1, children: [_jsx(CountTile, { label: "COMPUTERS", total: snapshot.computers.length, active: computeActive, accent: "green" }), _jsx(Box, { marginLeft: 2, children: _jsx(CountTile, { label: "SANDBOXES", total: snapshot.sandboxes.length, active: sandboxActive, accent: "blue" }) }), _jsx(Box, { marginLeft: 2, children: _jsx(CountTile, { label: "DEPLOYMENTS", total: snapshot.deployments.length, active: deployActive, accent: "magenta" }) }), snapshot.tenant && (_jsx(Box, { marginLeft: 2, children: _jsx(CountTile, { label: "CREDITS", total: snapshot.tenant.credit_balance, active: null, accent: snapshot.tenant.credit_balance > 0 ? "yellow" : "red" }) }))] }), _jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsx(Text, { dimColor: true, bold: true, children: "RECENT" }), recent.length === 0 ? (_jsxs(Text, { dimColor: true, children: [" ", "(no resources yet \u2014 run `miosa login` then create a sandbox)"] })) : (recent.map((item, idx) => (_jsxs(Box, { children: [_jsx(Text, { color: "cyan", children: kindGlyph(item.kind) }), _jsx(Text, { children: " " }), _jsx(Text, { children: (item.row.name ?? item.row.id).slice(0, 32).padEnd(32) }), _jsx(Text, { children: " " }), _jsx(Text, { color: statusColor(item.row), children: (item.row.status ?? item.row.state ?? "—").padEnd(12) }), _jsx(Text, { dimColor: true, children: timeAgo(item.row.updated_at ?? item.row.created_at) })] }, `${item.kind}-${item.row.id}-${idx}`))))] }), snapshot.error && (_jsxs(Box, { marginBottom: 1, children: [_jsx(Text, { color: "red", children: "\u2717 " }), _jsx(Text, { color: "red", children: snapshot.error })] })), _jsx(Box, { children: _jsxs(Text, { dimColor: true, children: ["press ", _jsx(Text, { bold: true, children: "q" }), " to quit \u00B7 ", _jsx(Text, { bold: true, children: "r" }), " to refresh now (auto every ", POLL_INTERVAL_MS / 1000, "s)"] }) })] }));
|
|
164
|
+
};
|
|
165
|
+
const CountTile = ({ label, total, active, accent, }) => {
|
|
166
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: accent, paddingX: 1, minWidth: 18, children: [_jsx(Text, { dimColor: true, bold: true, children: label }), _jsxs(Text, { children: [_jsx(Text, { color: accent, bold: true, children: total }), active !== null && (_jsxs(_Fragment, { children: [_jsx(Text, { dimColor: true, children: " total \u00B7 " }), _jsx(Text, { color: accent, children: active }), _jsx(Text, { dimColor: true, children: " active" })] }))] })] }));
|
|
167
|
+
};
|
|
168
|
+
// ── Helpers ────────────────────────────────────────────────────────────────
|
|
169
|
+
function kindGlyph(kind) {
|
|
170
|
+
switch (kind) {
|
|
171
|
+
case "computer":
|
|
172
|
+
return "◆";
|
|
173
|
+
case "sandbox":
|
|
174
|
+
return "□";
|
|
175
|
+
case "deployment":
|
|
176
|
+
return "▲";
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function statusColor(row) {
|
|
180
|
+
const s = (row.status ?? row.state ?? "").toLowerCase();
|
|
181
|
+
if (s === "active" || s === "running" || s === "ready")
|
|
182
|
+
return "green";
|
|
183
|
+
if (s === "provisioning" || s === "building" || s === "pending")
|
|
184
|
+
return "yellow";
|
|
185
|
+
if (s === "error" || s === "failed")
|
|
186
|
+
return "red";
|
|
187
|
+
return "gray";
|
|
188
|
+
}
|
|
189
|
+
// Re-export for any future TUI command that wants to reuse helpers.
|
|
190
|
+
export { sortRecent, timeAgo, isActive };
|
|
191
|
+
//# sourceMappingURL=dashboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard.js","sourceRoot":"","sources":["../../src/tui/dashboard.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAc,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAyB/B,KAAK,UAAU,QAAQ,CACrB,MAAmB,EACnB,IAAY;IAEZ,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAU,IAAI,CAAC,CAAC;QAClD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;YAAE,OAAO,MAAa,CAAC;QAChD,IAAI,MA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,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IACxD,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,OAAO;QAAE,OAAO,OAAO,CAAC;IACvE,IAAI,CAAC,KAAK,cAAc,IAAI,CAAC,KAAK,UAAU,IAAI,CAAC,KAAK,SAAS;QAC7D,OAAO,QAAQ,CAAC;IAClB,IAAI,CAAC,KAAK,OAAO,IAAI,CAAC,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAClD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,oEAAoE;AACpE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `miosa logs <id> --follow` — live log tail TUI.
|
|
3
|
+
*
|
|
4
|
+
* React component (rendered by ink) that polls the MIOSA API every 2 seconds
|
|
5
|
+
* and streams the last 200 log lines into a scrollable pane with a header bar.
|
|
6
|
+
*
|
|
7
|
+
* How it differs from one-shot `miosa logs`:
|
|
8
|
+
* - Runs interactively in the terminal instead of dumping once and exiting.
|
|
9
|
+
* - Polls continuously, appending new lines to an in-memory ring buffer.
|
|
10
|
+
* - Renders a header bar (resource id, status, region, age, clock).
|
|
11
|
+
* - Colors stdout/stderr/error lines differently.
|
|
12
|
+
* - Responds to keyboard: q / Ctrl+C to quit, / to toggle filter mode.
|
|
13
|
+
*
|
|
14
|
+
* Mounted by `src/commands/logs.ts` when --follow / -f is passed and
|
|
15
|
+
* process.stdout.isTTY is true.
|
|
16
|
+
*/
|
|
17
|
+
import React from "react";
|
|
18
|
+
import type { MiosaConfig } from "../types.js";
|
|
19
|
+
export type ResourceKind = "computer" | "sandbox" | "deployment" | "database";
|
|
20
|
+
export interface LogsTUIProps {
|
|
21
|
+
resourceId: string;
|
|
22
|
+
resourceKind: ResourceKind;
|
|
23
|
+
config: MiosaConfig;
|
|
24
|
+
}
|
|
25
|
+
export declare const LogsTUI: React.FC<LogsTUIProps>;
|
|
26
|
+
//# sourceMappingURL=logs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../src/tui/logs.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAMN,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAS/C,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,SAAS,GAAG,YAAY,GAAG,UAAU,CAAC;AAE9E,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;IAC3B,MAAM,EAAE,WAAW,CAAC;CACrB;AAkQD,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CA2J1C,CAAC"}
|