@hyper3d/cli 0.0.1 → 0.1.0-beta.3.1

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/README.md CHANGED
@@ -1,7 +1,185 @@
1
- # Hyper3D CLI — initialization placeholder
1
+ # Hyper3D CLI
2
2
 
3
- Version 0.0.1 is a minimal package used to initialize the npm package and configure trusted publishing from GitHub Actions.
3
+ Generate 3D models from text or images, follow their progress, and get the finished
4
+ files from your terminal.
4
5
 
5
- This version does not contain a CLI executable or runtime functionality. It is published under the `init` dist-tag. Use a subsequent functional release to run the Hyper3D CLI.
6
+ ## Install
6
7
 
7
- Source: https://github.com/DeemosTech/hyper3d-cli
8
+ Requires **Node.js 22 or newer**. The package is being prepared for its first npm
9
+ release; the registry commands below become available after that release.
10
+
11
+ ```sh
12
+ npm install --global @hyper3d/cli
13
+ hyper3d --help
14
+ ```
15
+
16
+ You can also use pnpm or Yarn, or run the CLI without a global installation:
17
+
18
+ ```sh
19
+ pnpm add --global @hyper3d/cli
20
+ # Yarn Classic
21
+ yarn global add @hyper3d/cli
22
+ # Run once with npm, pnpm, or modern Yarn
23
+ npx @hyper3d/cli@latest --help
24
+ pnpm dlx @hyper3d/cli@latest --help
25
+ yarn dlx @hyper3d/cli@latest --help
26
+ ```
27
+
28
+ For a project-local installation, run `npm install --save-dev @hyper3d/cli`, then
29
+ `npx hyper3d --help`. To try the latest beta build, use `@hyper3d/cli@beta`
30
+ in place of `@hyper3d/cli`.
31
+
32
+ ## Sign in
33
+
34
+ ```sh
35
+ hyper3d auth login
36
+ ```
37
+
38
+ Compare the code shown in your terminal with the browser, then approve access.
39
+ On a remote machine, use `hyper3d auth login --no-browser` and open the printed link
40
+ on another device. Press Ctrl+C to cancel.
41
+
42
+ ```sh
43
+ hyper3d auth status # Account and credit balances
44
+ hyper3d auth logout # Remove saved credentials from this machine
45
+ ```
46
+
47
+ Credentials are saved in `~/.hyper3d` by default and refreshed automatically when
48
+ needed. Set `HYPER3D_CONFIG_DIR` to use a different directory.
49
+ Signing out locally does not revoke your server-side authorization.
50
+
51
+ ## Generate a model
52
+
53
+ Generation uses credits from your authorized workspace.
54
+
55
+ ```sh
56
+ # From text
57
+ hyper3d generate --prompt "a ceramic teapot" --format glb
58
+
59
+ # From one image
60
+ hyper3d generate --image ./reference.png
61
+
62
+ # From multiple views, with an optional description
63
+ hyper3d generate --image ./front.png --image ./side.jpg --prompt "a ceramic teapot"
64
+ ```
65
+
66
+ Provide a prompt, one to five images, or both. Generation options:
67
+
68
+ | Option | Accepted values | Default when omitted |
69
+ | ------------- | -------------------------------------------------------------- | ---------------------------- |
70
+ | `--tier` | `Gen-2.5-Medium`, `Gen-2.5-High`, `Gen-2.5-Extreme-Low` | `Gen-2.5-Medium` |
71
+ | `--mesh-mode` | `Raw`, `Quad` | `Raw` |
72
+ | `--format` | `glb`, `usdz`, `fbx`, `obj`, `stl` | `glb` |
73
+ | `--quality` | Target polygon count: Raw `500–1,000,000`; Quad `1,000–50,000` | Raw `500,000`; Quad `18,000` |
74
+
75
+ Defaults are applied by the server. The response includes a generation ID; use
76
+ it to check progress and retrieve the result:
77
+
78
+ ```sh
79
+ hyper3d status <generation-id>
80
+ hyper3d poll <generation-id> --timeout 300
81
+ hyper3d result <generation-id>
82
+ ```
83
+
84
+ `poll` waits up to the requested number of seconds. `result` returns download URLs;
85
+ it does not download files to your machine.
86
+
87
+ To separate a completed model into parts:
88
+
89
+ ```sh
90
+ hyper3d bang <generation-id> --instruction "separate the handle and lid"
91
+ ```
92
+
93
+ | Option | Meaning / accepted values | Default when omitted |
94
+ | --------------- | --------------------------------------------------------------------------------- | ------------------------ |
95
+ | `--instruction` | Description of the parts to separate | Automatic split planning |
96
+ | `--strength` | Integer `1–12`; soft target for the number of parts, so the actual count may vary | `5` |
97
+ | `--format` | `glb`, `usdz`, `fbx`, `obj`, `stl` | `glb` |
98
+
99
+ Run `hyper3d <command> --help` for more options. If a generation request times out,
100
+ check your existing tasks before submitting it again; the CLI never retries
101
+ billable generation automatically.
102
+
103
+ ## Use JSON output
104
+
105
+ Output is readable text by default. Add `--output json` for scripts:
106
+
107
+ ```sh
108
+ hyper3d auth status --output json
109
+ hyper3d generate --prompt "a ceramic teapot" --output json
110
+ hyper3d status <generation-id> --output json
111
+ ```
112
+
113
+ Warnings and errors go to stderr. Successful commands exit with code `0`; errors
114
+ exit with code `1`.
115
+
116
+ ## Updates
117
+
118
+ ```sh
119
+ hyper3d update --check
120
+ hyper3d update
121
+ ```
122
+
123
+ An interactive **npm global installation** checks for updates once a day before
124
+ model commands and only displays an update notice by default. Stable installations
125
+ follow `latest`; prerelease-branch builds follow `beta`. Run `hyper3d update` to install
126
+ an available update.
127
+
128
+ Set `HYPER3D_AUTO_UPDATE=1` to opt into automatic installation (which asks you to
129
+ rerun your command before submitting the model operation), or
130
+ `HYPER3D_UPDATE_CHECK=0` to disable automatic checks and automatic installation.
131
+ These switches require the exact values `1` and `0`, respectively. Automatic checks
132
+ and installation are also skipped when `CI` is nonempty (including `CI=0`) or stderr
133
+ is not a TTY. These settings do not disable manual `hyper3d update` or
134
+ `hyper3d update --check`. Network failures leave your command usable.
135
+
136
+ For pnpm, Yarn, or project-local installations, update with the package manager
137
+ that installed the CLI. For one-off runs, specify `@latest`:
138
+
139
+ ```sh
140
+ pnpm add --global @hyper3d/cli@latest
141
+ yarn global add @hyper3d/cli@latest # Yarn Classic
142
+ npm install --save-dev @hyper3d/cli@latest
143
+ npx @hyper3d/cli@latest --help
144
+ ```
145
+
146
+ To switch channels explicitly, install `@hyper3d/cli@latest` or
147
+ `@hyper3d/cli@beta` with your package manager. `hyper3d update` only upgrades to a
148
+ newer version and never downgrades a pinned installation.
149
+
150
+ ## Troubleshooting
151
+
152
+ - **Not signed in or access denied:** run `hyper3d auth login` again. Check that you
153
+ authorized the intended personal or team workspace.
154
+ - **Browser does not open:** follow the printed link, or use `--no-browser`.
155
+ - **Command not found:** check that your package manager's global bin directory is
156
+ on `PATH`, or use `npx @hyper3d/cli@latest`.
157
+ - **Update permission error:** update with the package manager and permissions used
158
+ for the original installation.
159
+ - **An interrupted update leaves future checks inactive:** close other CLI
160
+ processes and remove the empty `update.lock` directory inside your configuration
161
+ directory (`~/.hyper3d` by default, or the directory set by `HYPER3D_CONFIG_DIR`),
162
+ then run `hyper3d update`.
163
+
164
+ The API base URL defaults to `https://api.hyper3d.com/api`. Set `BASE_URL` to
165
+ use another environment; a trailing slash is optional:
166
+
167
+ ```sh
168
+ BASE_URL=https://api.hyper3d.com/api/ hyper3d auth status
169
+ hyper3d --base-url https://api.hyper3d.com/api auth status
170
+ ```
171
+
172
+ `--base-url` overrides `BASE_URL`. MCP (`mcp`), account (`user/get_info`) and
173
+ team (`group/group_info`) endpoints are derived from this base. HTTPS is required
174
+ except for localhost. OAuth endpoints remain server-discovered, and upload/result
175
+ URLs remain server-provided.
176
+
177
+ `HYPER3D_CONFIG_DIR` changes the directory for credentials, the update cache
178
+ (`update-check.json`), and the update lock (`update.lock`). If unset, it defaults to
179
+ `~/.hyper3d`. Relative paths resolve from the current working directory; an empty
180
+ value uses the current working directory rather than the default. Use a nonempty
181
+ absolute path for a consistent location across commands.
182
+
183
+ For development and releases, see [CONTRIBUTING.md](https://github.com/DeemosTech/hyper3d-cli/blob/main/CONTRIBUTING.md) and the
184
+ [release guide](https://github.com/DeemosTech/hyper3d-cli/blob/main/docs/releasing.md). Report problems in
185
+ [GitHub Issues](https://github.com/DeemosTech/hyper3d-cli/issues).
@@ -0,0 +1,26 @@
1
+ export declare function accountInfo({ fetchFn }?: {
2
+ fetchFn?: typeof fetch | undefined;
3
+ }): Promise<{
4
+ authenticated: boolean;
5
+ user?: undefined;
6
+ wallet?: undefined;
7
+ } | {
8
+ authenticated: boolean;
9
+ user: {
10
+ uuid: string;
11
+ username: string;
12
+ };
13
+ wallet: {
14
+ subscription_balance: number;
15
+ balance: number;
16
+ frozen: number;
17
+ type: "personal";
18
+ } | {
19
+ subscription_balance?: number | undefined;
20
+ balance: number;
21
+ frozen: number;
22
+ type: "group";
23
+ group_uuid: string;
24
+ name?: string;
25
+ };
26
+ }>;
@@ -0,0 +1,136 @@
1
+ import { auth } from '@modelcontextprotocol/sdk/client/auth.js';
2
+ import { z } from 'zod';
3
+ import { loadCredentials, createProvider } from './auth.js';
4
+ import { endpoints, secureUrl } from './endpoints.js';
5
+ const WALLET_UNITS_PER_CREDIT = 10;
6
+ const identitySchema = z.object({
7
+ user_uuid: z.string().min(1),
8
+ username: z.string(),
9
+ });
10
+ const personalMetaSchema = identitySchema.extend({
11
+ balance: z.number(),
12
+ frozen: z.number(),
13
+ subscriptions: z.object({
14
+ active_subscriptions: z.array(z.object({ wallet_balance: z.number() })),
15
+ }),
16
+ });
17
+ const accountResponseSchema = z.object({
18
+ meta: identitySchema.passthrough(),
19
+ billing_workspace: z.discriminatedUnion('type', [
20
+ z.object({ type: z.literal('personal') }),
21
+ z.object({ type: z.literal('group'), group_uuid: z.string().min(1) }),
22
+ ]),
23
+ });
24
+ const groupResponseSchema = z.object({
25
+ group_meta: z.object({
26
+ uuid: z.string().min(1),
27
+ name: z.string().optional(),
28
+ frozen: z.number(),
29
+ }),
30
+ balance: z.number(),
31
+ });
32
+ function parseResponse(schema, data) {
33
+ const result = schema.safeParse(data);
34
+ if (!result.success) {
35
+ const details = result.error.issues
36
+ .map((issue) => `${issue.path.join('.')}: ${issue.message}`)
37
+ .join('; ');
38
+ throw new Error(`Invalid account response: ${details}`);
39
+ }
40
+ return result.data;
41
+ }
42
+ export async function accountInfo({ fetchFn = fetch } = {}) {
43
+ const endpoint = endpoints.mcp;
44
+ const data = await loadCredentials(endpoint);
45
+ const provider = data.clientId ? createProvider(endpoint, data) : undefined;
46
+ let accessToken = data.tokens?.access_token;
47
+ if (!accessToken)
48
+ return { authenticated: false };
49
+ const request = async (input, init = {}) => {
50
+ secureUrl(input);
51
+ return fetchFn(input, {
52
+ ...init,
53
+ redirect: 'error',
54
+ signal: AbortSignal.timeout(15000),
55
+ });
56
+ };
57
+ let refreshed = false;
58
+ const post_with_optional_token_refresh = async (path, body) => {
59
+ const send = async () => request(path, {
60
+ method: 'POST',
61
+ headers: {
62
+ Authorization: `Bearer ${accessToken}`,
63
+ 'Content-Type': 'application/json',
64
+ Accept: 'application/json',
65
+ },
66
+ body: JSON.stringify(body),
67
+ });
68
+ let response = await send();
69
+ if (response.status === 401 &&
70
+ !refreshed &&
71
+ provider &&
72
+ data.tokens?.refresh_token) {
73
+ refreshed = true;
74
+ await response.body?.cancel();
75
+ await auth(provider, { serverUrl: endpoint, fetchFn: request });
76
+ accessToken = provider.tokens()?.access_token;
77
+ response = await send();
78
+ }
79
+ if (!response.ok) {
80
+ await response.body?.cancel();
81
+ if ([401, 403].includes(response.status))
82
+ throw new Error('Account access denied. Run hyper3d auth login to authorize account:read and an available billing workspace.');
83
+ throw new Error(`Account lookup failed (HTTP ${response.status}).`);
84
+ }
85
+ const result = await response.json();
86
+ if (result.error)
87
+ throw new Error(`Account lookup failed: ${result.error}`);
88
+ return result;
89
+ };
90
+ const { meta, billing_workspace: workspace } = parseResponse(accountResponseSchema, await post_with_optional_token_refresh(endpoints.userInfo, {}));
91
+ let wallet;
92
+ switch (workspace.type) {
93
+ case 'personal': {
94
+ const personal = parseResponse(personalMetaSchema, meta);
95
+ const subscriptionBalance = personal.subscriptions.active_subscriptions.reduce((total, subscription) => total + subscription.wallet_balance, 0);
96
+ wallet = {
97
+ type: 'personal',
98
+ balance: personal.balance,
99
+ subscription_balance: subscriptionBalance,
100
+ frozen: personal.frozen,
101
+ };
102
+ break;
103
+ }
104
+ case 'group': {
105
+ const result = parseResponse(groupResponseSchema, await post_with_optional_token_refresh(endpoints.groupInfo, {
106
+ group_uuid: workspace.group_uuid,
107
+ }));
108
+ if (result.group_meta?.uuid !== workspace.group_uuid)
109
+ throw new Error('The returned wallet does not match the authorized billing workspace.');
110
+ wallet = {
111
+ type: 'group',
112
+ group_uuid: workspace.group_uuid,
113
+ name: result.group_meta.name,
114
+ balance: result.balance,
115
+ frozen: result.group_meta.frozen,
116
+ };
117
+ break;
118
+ }
119
+ }
120
+ const displayedWallet = {
121
+ ...wallet,
122
+ balance: wallet.balance / WALLET_UNITS_PER_CREDIT,
123
+ frozen: wallet.frozen / WALLET_UNITS_PER_CREDIT,
124
+ ...(wallet.type === 'personal'
125
+ ? {
126
+ subscription_balance: wallet.subscription_balance / WALLET_UNITS_PER_CREDIT,
127
+ }
128
+ : {}),
129
+ };
130
+ return {
131
+ authenticated: true,
132
+ user: { uuid: meta.user_uuid, username: meta.username },
133
+ wallet: displayedWallet,
134
+ };
135
+ }
136
+ //# sourceMappingURL=account.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC;AAChE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEtD,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAEnC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;CACrB,CAAC,CAAC;AACH,MAAM,kBAAkB,GAAG,cAAc,CAAC,MAAM,CAAC;IAC/C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,aAAa,EAAE,CAAC,CAAC,MAAM,CAAC;QACtB,oBAAoB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAA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5B,CAAC,CAAC;gBACE,oBAAoB,EAClB,MAAM,CAAC,oBAAoB,GAAG,uBAAuB;aACxD;YACH,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;IACF,OAAO;QACL,aAAa,EAAE,IAAI;QACnB,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE;QACvD,MAAM,EAAE,eAAe;KACxB,CAAC;AACJ,CAAC"}
package/dist/auth.d.ts ADDED
@@ -0,0 +1,63 @@
1
+ import { setTimeout as sleep } from 'node:timers/promises';
2
+ import type { Credentials } from './types.js';
3
+ import type { OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
4
+ interface LoginOptions {
5
+ browser?: boolean;
6
+ fetchFn?: typeof fetch;
7
+ open?: (url: string) => Promise<void>;
8
+ write?: (text: string) => unknown;
9
+ wait?: typeof sleep;
10
+ now?: () => number;
11
+ signal?: AbortSignal;
12
+ }
13
+ export declare const DEVICE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
14
+ export declare const CLI_CLIENT_ID = "https://hyper3d.ai/oauth_cimd/cli.json";
15
+ export declare const CLI_SCOPES = "rodin:generate rodin:read account:read offline_access";
16
+ export declare function clientMetadata(): {
17
+ client_id: string;
18
+ client_name: string;
19
+ client_uri: string;
20
+ application_type: string;
21
+ redirect_uris: never[];
22
+ grant_types: string[];
23
+ response_types: never[];
24
+ token_endpoint_auth_method: string;
25
+ scope: string;
26
+ };
27
+ export declare function credentialPath(endpoint: string): string;
28
+ export declare function loadCredentials(endpoint: string): Promise<Credentials>;
29
+ export declare function logout(endpoint: string): Promise<void>;
30
+ export declare function createProvider(endpoint: string, data: Credentials): {
31
+ redirectUrl: undefined;
32
+ saveCodeVerifier: () => Promise<never>;
33
+ codeVerifier: () => Promise<string>;
34
+ clientMetadataUrl: string;
35
+ readonly clientMetadata: Omit<{
36
+ client_id: string;
37
+ client_name: string;
38
+ client_uri: string;
39
+ application_type: string;
40
+ redirect_uris: never[];
41
+ grant_types: string[];
42
+ response_types: never[];
43
+ token_endpoint_auth_method: string;
44
+ scope: string;
45
+ }, "client_id">;
46
+ clientInformation: () => {
47
+ client_id: string;
48
+ };
49
+ tokens: () => {
50
+ access_token: string;
51
+ token_type: string;
52
+ id_token?: string | undefined;
53
+ expires_in?: number | undefined;
54
+ scope?: string | undefined;
55
+ refresh_token?: string | undefined;
56
+ } | undefined;
57
+ saveTokens: (tokens: OAuthTokens) => Promise<void>;
58
+ prepareTokenRequest: () => URLSearchParams;
59
+ redirectToAuthorization: () => never;
60
+ invalidateCredentials: (scope: string) => Promise<void>;
61
+ };
62
+ export declare function login(endpoint: string, { browser, fetchFn, open, write, wait, now, signal, }?: LoginOptions): Promise<void>;
63
+ export {};