wmstudio-cli 0.2.2
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/CHANGELOG.md +37 -0
- package/LICENSE +21 -0
- package/README.md +231 -0
- package/dist/index.js +660 -0
- package/dist/index.js.map +1 -0
- package/package.json +71 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# @wmstudio/cli
|
|
2
|
+
|
|
3
|
+
## 0.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Rename package to wmstudio-cli
|
|
8
|
+
|
|
9
|
+
## 0.2.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Cli Wstudi
|
|
14
|
+
|
|
15
|
+
## 0.2.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- c72bec7: Initial scaffold. Not yet published.
|
|
20
|
+
|
|
21
|
+
Commands: `login`, `whoami`, `gen image`, `gen video`, `upscale`, `campaign`,
|
|
22
|
+
`jobs list`, `jobs get`. Auth via API key (file + env + flag). Hosted REST API
|
|
23
|
+
transport via `undici`. Structured logging with `WM_LOG_FORMAT=json` parity
|
|
24
|
+
with `mcp-director`.
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- WmStudio CLI Tools - Image/video/image-to-image/image-to-video
|
|
29
|
+
|
|
30
|
+
## 0.1.0
|
|
31
|
+
|
|
32
|
+
Initial scaffold. Not yet published.
|
|
33
|
+
|
|
34
|
+
- Commands: `login`, `whoami`, `gen image`, `gen video`, `upscale`, `campaign`, `jobs`.
|
|
35
|
+
- Auth: API key stored in `~/.wm/config.json`, override via `WM_API_KEY` env.
|
|
36
|
+
- Transport: direct HTTPS to the WM Studio REST API via `undici`.
|
|
37
|
+
- Build: `tsup` β single ESM `dist/index.js` with shebang, runnable via `npx @wmstudio/cli` or `wm`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) WM Studio
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# @wmstudio/cli β `wm`
|
|
2
|
+
|
|
3
|
+
> The official command-line client for the WM Studio creative platform.
|
|
4
|
+
> Generate images, videos, brand campaigns, and 3D assets from your terminal.
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
npm i -g @wmstudio/cli
|
|
8
|
+
wm login
|
|
9
|
+
wm gen image "minimalist black ceramic mug, soft daylight" -o mug.png
|
|
10
|
+
wm gen video "slow dolly-in on the mug, golden hour" -i ./mug.png -o ad.mp4
|
|
11
|
+
wm campaign "premium oat milk launch, Scandinavian minimal" --variations 3
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Status
|
|
15
|
+
|
|
16
|
+
π§ **0.1.0 β pre-publish scaffold.** This repo currently lives at
|
|
17
|
+
`~/wm/wm-cli/` and will be moved to its own GitHub repo (`PrincipeRosso/wm-cli`)
|
|
18
|
+
before the first npm release. No `pnpm install` has been run yet β that's the
|
|
19
|
+
first action a maintainer takes when they pick this up.
|
|
20
|
+
|
|
21
|
+
## Why a separate repo?
|
|
22
|
+
|
|
23
|
+
Same reason `mcp-director` and `director-cut` are their own repos:
|
|
24
|
+
**one responsibility, one runtime, one release pipeline**.
|
|
25
|
+
|
|
26
|
+
| Repo | Runtime | What it does |
|
|
27
|
+
| --------------- | ------- | ------------------------------------- |
|
|
28
|
+
| `wmstudio` | TS/Next | Web app + REST API |
|
|
29
|
+
| `director-cut` | Python | Desktop backend + embedded MCP |
|
|
30
|
+
| `mcp-director` | Python | Hosted Streamable HTTP MCP |
|
|
31
|
+
| **`wm-cli`** | **TS** | **`wm` CLI on npm** |
|
|
32
|
+
|
|
33
|
+
See [`docs/CONVENTIONS.md`](./docs/CONVENTIONS.md) for the cross-repo contract
|
|
34
|
+
(env vars, error codes, default models, REST endpoints, logging shape).
|
|
35
|
+
|
|
36
|
+
## Architecture
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
ββββββββββββββββ API key ββββββββββββββββββββ
|
|
40
|
+
β wm (CLI) β ββββββββββββββββββββββββΆ β wmstudio REST API β
|
|
41
|
+
ββββββββββββββββ over HTTPS / undici ββββββββββββββββββββ
|
|
42
|
+
β²
|
|
43
|
+
β same endpoints
|
|
44
|
+
β
|
|
45
|
+
ββββββββββββββββββββ
|
|
46
|
+
β mcp-director β
|
|
47
|
+
ββββββββββββββββββββ
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The CLI is a thin, dependency-light HTTP client. It does **not** speak the MCP
|
|
51
|
+
protocol β there's no reason for a short-lived terminal process to negotiate
|
|
52
|
+
Streamable HTTP + OAuth PKCE when an API key works fine.
|
|
53
|
+
|
|
54
|
+
## Tech stack
|
|
55
|
+
|
|
56
|
+
| Concern | Pick | Why |
|
|
57
|
+
| -------------- | --------------------------------- | -------------------------------------------------- |
|
|
58
|
+
| Language | TypeScript 5.6, strict, ESM | Reuse `wmstudio` types later via a published pkg |
|
|
59
|
+
| CLI framework | `commander` | Small, fast cold start, mature |
|
|
60
|
+
| Prompts | `@inquirer/prompts` | Modular, tree-shakeable, async/await native |
|
|
61
|
+
| HTTP | `undici` | Built-in to Node 20+, fastest, AbortController |
|
|
62
|
+
| Schema | `zod` | Same lib `wmstudio` already uses |
|
|
63
|
+
| Bundler | `tsup` | Single ESM bundle, fast, zero config drift |
|
|
64
|
+
| Lint | ESLint v9 flat + `typescript-eslint` | Type-aware rules |
|
|
65
|
+
| Format | Prettier | Matches `wmstudio` house style |
|
|
66
|
+
| Tests | Vitest + `msw` | Same runner as `wmstudio`; MSW for HTTP fixtures |
|
|
67
|
+
| Release | Changesets + GitHub Actions | One source of truth for versions + npm publish |
|
|
68
|
+
| Node target | 20 LTS | `.nvmrc` pinned |
|
|
69
|
+
|
|
70
|
+
## Commands
|
|
71
|
+
|
|
72
|
+
| Command | What it does |
|
|
73
|
+
| ---------------------- | -------------------------------------------------------------- |
|
|
74
|
+
| `wm login` | Save your API key to `~/.wm/config.json` (chmod 0600) |
|
|
75
|
+
| `wm whoami` | Show account + remaining credits |
|
|
76
|
+
| `wm gen image <prompt>`| Text-to-image / image-to-image. `-o` to download. |
|
|
77
|
+
| `wm gen video <prompt>`| Text-to-video / image-to-video. Polls until done. |
|
|
78
|
+
| `wm upscale <url>` | Topaz upscale 1β4Γ |
|
|
79
|
+
| `wm campaign <brief>` | Full director_* pipeline. `--variations N` for parallel runs. |
|
|
80
|
+
| `wm jobs list` | Recent generation jobs |
|
|
81
|
+
| `wm jobs get <id>` | Single job status |
|
|
82
|
+
|
|
83
|
+
Global flags: `--api-url`, `--api-key`, `--json`, `-v / --version`, `--help`.
|
|
84
|
+
|
|
85
|
+
## Auth precedence
|
|
86
|
+
|
|
87
|
+
1. `--api-key` flag
|
|
88
|
+
2. `WM_API_KEY` env var
|
|
89
|
+
3. `~/.wm/config.json` (written by `wm login`)
|
|
90
|
+
4. _(none β exits with `auth_required`, code 10)_
|
|
91
|
+
|
|
92
|
+
## Exit codes
|
|
93
|
+
|
|
94
|
+
Stable contract, mirrored across `wm-cli` and `mcp-director`. See
|
|
95
|
+
[`docs/CONVENTIONS.md`](./docs/CONVENTIONS.md) Β§3.
|
|
96
|
+
|
|
97
|
+
| Code | Meaning |
|
|
98
|
+
| ---- | ------------------- |
|
|
99
|
+
| 0 | OK |
|
|
100
|
+
| 2 | Usage error |
|
|
101
|
+
| 10 | Not logged in |
|
|
102
|
+
| 11 | Invalid API key |
|
|
103
|
+
| 20 | Asset URL required |
|
|
104
|
+
| 30 | Upgrade required |
|
|
105
|
+
| 31 | Rate limited |
|
|
106
|
+
| 40 | Network error |
|
|
107
|
+
| 50 | Server error |
|
|
108
|
+
| 51 | Timeout |
|
|
109
|
+
| 99 | Unexpected crash |
|
|
110
|
+
|
|
111
|
+
## First-time setup (when you pick this up)
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
cd ~/wm/wm-cli # or wherever you moved it
|
|
115
|
+
nvm use # honours .nvmrc β Node 20
|
|
116
|
+
corepack enable # ensures pnpm 9 is available
|
|
117
|
+
pnpm install # this is what resolves all the "Cannot find module" lints
|
|
118
|
+
pnpm typecheck
|
|
119
|
+
pnpm test
|
|
120
|
+
pnpm build
|
|
121
|
+
node dist/index.js --help
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
To run the dev binary against a local `wmstudio`:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
WMSTUDIO_API_URL=http://localhost:3000/api WM_API_KEY=dev-key node dist/index.js whoami
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Project layout
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
wm-cli/
|
|
134
|
+
βββ src/
|
|
135
|
+
β βββ index.ts Entrypoint (shebang banner via tsup)
|
|
136
|
+
β βββ cli.ts commander root, registers subcommands
|
|
137
|
+
β βββ client.ts WmApiClient β thin undici-based HTTP layer
|
|
138
|
+
β βββ config.ts ~/.wm/config.json + env merge
|
|
139
|
+
β βββ constants.ts Defaults, env var names, model ids
|
|
140
|
+
β βββ errors.ts WmCliError + exit code map
|
|
141
|
+
β βββ logger.ts Pretty + JSON structured logger
|
|
142
|
+
β βββ util/
|
|
143
|
+
β β βββ download.ts Stream URL β file
|
|
144
|
+
β β βββ poll.ts Generic async-job poller
|
|
145
|
+
β βββ commands/
|
|
146
|
+
β βββ _shared.ts Ctx, requireAuth, renderResult
|
|
147
|
+
β βββ login.ts
|
|
148
|
+
β βββ whoami.ts
|
|
149
|
+
β βββ gen.ts image + video subcommands
|
|
150
|
+
β βββ upscale.ts
|
|
151
|
+
β βββ campaign.ts director_* pipeline
|
|
152
|
+
β βββ jobs.ts
|
|
153
|
+
βββ test/ Vitest + MSW
|
|
154
|
+
βββ docs/
|
|
155
|
+
β βββ CONVENTIONS.md β cross-repo contract (sync to other repos)
|
|
156
|
+
βββ .changeset/ Changesets config + per-PR notes
|
|
157
|
+
βββ .github/workflows/ CI + release pipelines
|
|
158
|
+
βββ tsup.config.ts
|
|
159
|
+
βββ vitest.config.ts
|
|
160
|
+
βββ eslint.config.js
|
|
161
|
+
βββ tsconfig.json
|
|
162
|
+
βββ package.json
|
|
163
|
+
βββ .env.example
|
|
164
|
+
βββ .editorconfig β shared across all wm-* repos
|
|
165
|
+
βββ .nvmrc 20.18.0
|
|
166
|
+
βββ LICENSE MIT
|
|
167
|
+
βββ CHANGELOG.md
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Moving this repo
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
mv ~/wm/wm-cli /path/to/new/parent/wm-cli
|
|
174
|
+
cd /path/to/new/parent/wm-cli
|
|
175
|
+
git init -b main
|
|
176
|
+
git add .
|
|
177
|
+
git commit -m "chore: import initial scaffold"
|
|
178
|
+
git remote add origin git@github.com:PrincipeRosso/wm-cli.git
|
|
179
|
+
git push -u origin main
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Nothing in this scaffold references its on-disk parent directory, so the move
|
|
183
|
+
is purely a `mv` + `git init`.
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
## Commands
|
|
187
|
+
```bash
|
|
188
|
+
cd ~/wm/wm-cli
|
|
189
|
+
nvm use && corepack enable
|
|
190
|
+
pnpm install
|
|
191
|
+
pnpm typecheck # βΆ resolves every "Cannot find module" lint
|
|
192
|
+
pnpm lint # β· rules pass
|
|
193
|
+
pnpm test # βΈ vitest: config + client (msw) unit tests go green
|
|
194
|
+
pnpm build # βΉ single ESM bundle in dist/index.js
|
|
195
|
+
node dist/index.js --help # βΊ commander prints the usage
|
|
196
|
+
node dist/index.js --version
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
## Commands to run for pushing. anew version
|
|
202
|
+
```bash
|
|
203
|
+
cd ~/wm/wm-cli
|
|
204
|
+
git commit -am "feat: <whatever>" # your code change
|
|
205
|
+
pnpm changeset # pick patch/minor/major + summary
|
|
206
|
+
pnpm changeset version # bumps version + CHANGELOG
|
|
207
|
+
git commit -am "chore: release"
|
|
208
|
+
pnpm publish --access public
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
## Commands for testing on my machine the deployed
|
|
213
|
+
```bash
|
|
214
|
+
# Install once, anywhere on macOS / Linux / Windows
|
|
215
|
+
npm i -g @jessip2323/wm-cli
|
|
216
|
+
|
|
217
|
+
# Confirm
|
|
218
|
+
wm --version
|
|
219
|
+
|
|
220
|
+
# Get an API key from your dashboard
|
|
221
|
+
open https://wmstudio.io/en/dashboard/api-keys
|
|
222
|
+
# (or http://localhost:3000/en/dashboard/api-keys for local)
|
|
223
|
+
|
|
224
|
+
# Log in
|
|
225
|
+
wm login # paste the sk_live_... token
|
|
226
|
+
|
|
227
|
+
# First call
|
|
228
|
+
wm whoami
|
|
229
|
+
wm gen image "a single red apple" -o apple.png
|
|
230
|
+
file apple.png # β PNG image data
|
|
231
|
+
```
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,660 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/cli.ts
|
|
4
|
+
import { Command } from "commander";
|
|
5
|
+
|
|
6
|
+
// src/commands/login.ts
|
|
7
|
+
import { password } from "@inquirer/prompts";
|
|
8
|
+
|
|
9
|
+
// src/config.ts
|
|
10
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync, chmodSync } from "fs";
|
|
11
|
+
import { homedir } from "os";
|
|
12
|
+
import { dirname, join } from "path";
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
|
|
15
|
+
// src/constants.ts
|
|
16
|
+
var DEFAULTS = {
|
|
17
|
+
/** Hosted WM Studio REST API base. Override via `WMSTUDIO_API_URL`. */
|
|
18
|
+
apiUrl: "https://wmstudio.io/api",
|
|
19
|
+
/** Public upload endpoint surfaced when an asset URL is missing. */
|
|
20
|
+
uploadUrl: "https://director-cut.fly.dev/upload",
|
|
21
|
+
/** Credit top-up landing page. */
|
|
22
|
+
upgradeUrl: "https://wmstudio.io/dashboard/credits",
|
|
23
|
+
/** Below this remaining-credit count we surface a warning. */
|
|
24
|
+
lowCreditsThreshold: 50,
|
|
25
|
+
/** Default request timeout (ms) for non-job calls. */
|
|
26
|
+
requestTimeoutMs: 6e4,
|
|
27
|
+
/** Polling interval (ms) for async jobs. */
|
|
28
|
+
jobPollIntervalMs: 4e3,
|
|
29
|
+
/** Hard ceiling for job polling (ms). */
|
|
30
|
+
jobPollTimeoutMs: 15 * 60 * 1e3
|
|
31
|
+
};
|
|
32
|
+
var ENV = {
|
|
33
|
+
ApiUrl: "WMSTUDIO_API_URL",
|
|
34
|
+
ApiKey: "WM_API_KEY",
|
|
35
|
+
UploadUrl: "ASSET_UPLOAD_URL",
|
|
36
|
+
UpgradeUrl: "CREDITS_UPGRADE_URL",
|
|
37
|
+
LowCreditsThreshold: "CREDITS_LOW_THRESHOLD",
|
|
38
|
+
LogLevel: "WM_LOG_LEVEL",
|
|
39
|
+
ConfigDir: "WM_CONFIG_DIR"
|
|
40
|
+
};
|
|
41
|
+
var DEFAULT_MODELS = {
|
|
42
|
+
image: "fal-ai/flux/dev",
|
|
43
|
+
videoText: "fal-ai/kling-video/v2.5-turbo/pro/text-to-video",
|
|
44
|
+
videoImage: "fal-ai/kling-video/v2.5-turbo/pro/image-to-video",
|
|
45
|
+
upscaleImage: "fal-ai/topaz/upscale/image",
|
|
46
|
+
upscaleVideo: "fal-ai/topaz/upscale/video",
|
|
47
|
+
threeD: "fal-ai/meshy/v6/image-to-3d",
|
|
48
|
+
brandshot: "fal-ai/flux/dev",
|
|
49
|
+
cameraAngles: "fal-ai/flux/dev",
|
|
50
|
+
casting: "fal-ai/flux/dev",
|
|
51
|
+
ugcRoom: "fal-ai/flux/dev"
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/config.ts
|
|
55
|
+
var FileConfigSchema = z.object({
|
|
56
|
+
apiUrl: z.string().url().optional(),
|
|
57
|
+
apiKey: z.string().min(1).optional(),
|
|
58
|
+
uploadUrl: z.string().url().optional(),
|
|
59
|
+
upgradeUrl: z.string().url().optional(),
|
|
60
|
+
lowCreditsThreshold: z.number().int().nonnegative().optional()
|
|
61
|
+
});
|
|
62
|
+
function configDir() {
|
|
63
|
+
const override = process.env[ENV.ConfigDir];
|
|
64
|
+
return override && override.length > 0 ? override : join(homedir(), ".wm");
|
|
65
|
+
}
|
|
66
|
+
function configPath() {
|
|
67
|
+
return join(configDir(), "config.json");
|
|
68
|
+
}
|
|
69
|
+
function readFileConfig() {
|
|
70
|
+
const path = configPath();
|
|
71
|
+
if (!existsSync(path)) return {};
|
|
72
|
+
try {
|
|
73
|
+
const raw = readFileSync(path, "utf8");
|
|
74
|
+
return FileConfigSchema.parse(JSON.parse(raw));
|
|
75
|
+
} catch {
|
|
76
|
+
return {};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function writeFileConfig(patch) {
|
|
80
|
+
const merged = { ...readFileConfig(), ...patch };
|
|
81
|
+
const dir = configDir();
|
|
82
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true, mode: 448 });
|
|
83
|
+
const file = configPath();
|
|
84
|
+
writeFileSync(file, JSON.stringify(merged, null, 2) + "\n", { mode: 384 });
|
|
85
|
+
try {
|
|
86
|
+
chmodSync(file, 384);
|
|
87
|
+
} catch {
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
chmodSync(dirname(file), 448);
|
|
91
|
+
} catch {
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function resolveConfig(overrides = {}) {
|
|
95
|
+
const file = readFileConfig();
|
|
96
|
+
return {
|
|
97
|
+
apiUrl: overrides.apiUrl ?? process.env[ENV.ApiUrl] ?? file.apiUrl ?? DEFAULTS.apiUrl,
|
|
98
|
+
apiKey: overrides.apiKey ?? process.env[ENV.ApiKey] ?? file.apiKey,
|
|
99
|
+
uploadUrl: process.env[ENV.UploadUrl] ?? file.uploadUrl ?? DEFAULTS.uploadUrl,
|
|
100
|
+
upgradeUrl: process.env[ENV.UpgradeUrl] ?? file.upgradeUrl ?? DEFAULTS.upgradeUrl,
|
|
101
|
+
lowCreditsThreshold: numFromEnv(process.env[ENV.LowCreditsThreshold]) ?? file.lowCreditsThreshold ?? DEFAULTS.lowCreditsThreshold,
|
|
102
|
+
configPath: configPath()
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function numFromEnv(raw) {
|
|
106
|
+
if (!raw) return void 0;
|
|
107
|
+
const n = Number(raw);
|
|
108
|
+
return Number.isFinite(n) ? n : void 0;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// src/client.ts
|
|
112
|
+
import { z as z2 } from "zod";
|
|
113
|
+
|
|
114
|
+
// src/errors.ts
|
|
115
|
+
var ExitCode = {
|
|
116
|
+
OK: 0,
|
|
117
|
+
USAGE: 2,
|
|
118
|
+
// bad arguments / unknown command
|
|
119
|
+
AUTH_REQUIRED: 10,
|
|
120
|
+
// not logged in / missing api key
|
|
121
|
+
AUTH_INVALID: 11,
|
|
122
|
+
// server rejected token (401/403)
|
|
123
|
+
ASSET_URL_REQUIRED: 20,
|
|
124
|
+
// missing or unreachable user-provided URL
|
|
125
|
+
UPGRADE_REQUIRED: 30,
|
|
126
|
+
// 402 insufficient credits
|
|
127
|
+
RATE_LIMITED: 31,
|
|
128
|
+
// 429
|
|
129
|
+
NETWORK: 40,
|
|
130
|
+
// transport / DNS / TLS
|
|
131
|
+
SERVER: 50,
|
|
132
|
+
// 5xx
|
|
133
|
+
TIMEOUT: 51,
|
|
134
|
+
// server-side or client-side deadline exceeded
|
|
135
|
+
UNEXPECTED: 99
|
|
136
|
+
// crashed / not classifiable
|
|
137
|
+
};
|
|
138
|
+
var ErrorCode = {
|
|
139
|
+
AuthRequired: "auth_required",
|
|
140
|
+
AuthInvalid: "auth_invalid",
|
|
141
|
+
AssetUrlRequired: "asset_url_required",
|
|
142
|
+
UpgradeRequired: "upgrade_required",
|
|
143
|
+
RateLimited: "rate_limited",
|
|
144
|
+
Network: "network",
|
|
145
|
+
Server: "server",
|
|
146
|
+
Timeout: "timeout",
|
|
147
|
+
Usage: "usage",
|
|
148
|
+
Unexpected: "unexpected"
|
|
149
|
+
};
|
|
150
|
+
var WmCliError = class _WmCliError extends Error {
|
|
151
|
+
code;
|
|
152
|
+
exitCode;
|
|
153
|
+
details;
|
|
154
|
+
constructor(opts) {
|
|
155
|
+
super(opts.message);
|
|
156
|
+
this.name = "WmCliError";
|
|
157
|
+
this.code = opts.code;
|
|
158
|
+
this.exitCode = opts.exitCode;
|
|
159
|
+
this.details = opts.details;
|
|
160
|
+
}
|
|
161
|
+
static authRequired(message = "Not logged in. Run `wm login` first.") {
|
|
162
|
+
return new _WmCliError({
|
|
163
|
+
code: ErrorCode.AuthRequired,
|
|
164
|
+
exitCode: ExitCode.AUTH_REQUIRED,
|
|
165
|
+
message
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
static authInvalid(message = "Invalid or expired API key.") {
|
|
169
|
+
return new _WmCliError({
|
|
170
|
+
code: ErrorCode.AuthInvalid,
|
|
171
|
+
exitCode: ExitCode.AUTH_INVALID,
|
|
172
|
+
message
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
static assetUrlRequired(uploadUrl, message) {
|
|
176
|
+
return new _WmCliError({
|
|
177
|
+
code: ErrorCode.AssetUrlRequired,
|
|
178
|
+
exitCode: ExitCode.ASSET_URL_REQUIRED,
|
|
179
|
+
message: message ?? `A real public asset URL is required. Upload at ${uploadUrl}.`,
|
|
180
|
+
details: { uploadUrl }
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
static upgradeRequired(upgradeUrl, message) {
|
|
184
|
+
return new _WmCliError({
|
|
185
|
+
code: ErrorCode.UpgradeRequired,
|
|
186
|
+
exitCode: ExitCode.UPGRADE_REQUIRED,
|
|
187
|
+
message: message ?? `Insufficient credits. Top up at ${upgradeUrl} and re-run.`,
|
|
188
|
+
details: { upgradeUrl }
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
static usage(message) {
|
|
192
|
+
return new _WmCliError({
|
|
193
|
+
code: ErrorCode.Usage,
|
|
194
|
+
exitCode: ExitCode.USAGE,
|
|
195
|
+
message
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
// src/client.ts
|
|
201
|
+
var ApiErrorSchema = z2.object({
|
|
202
|
+
code: z2.string().optional(),
|
|
203
|
+
error: z2.string().optional(),
|
|
204
|
+
message: z2.string().optional(),
|
|
205
|
+
requiresTopUp: z2.boolean().optional(),
|
|
206
|
+
upgradeUrl: z2.string().url().optional(),
|
|
207
|
+
uploadUrl: z2.string().url().optional()
|
|
208
|
+
});
|
|
209
|
+
var WmApiClient = class {
|
|
210
|
+
constructor(cfg) {
|
|
211
|
+
this.cfg = cfg;
|
|
212
|
+
}
|
|
213
|
+
cfg;
|
|
214
|
+
/** GET /me β returns account + credit balance. */
|
|
215
|
+
whoami() {
|
|
216
|
+
return this.json({ method: "GET", path: "/me" });
|
|
217
|
+
}
|
|
218
|
+
/** Validate the current api key without side-effects. */
|
|
219
|
+
async ping() {
|
|
220
|
+
try {
|
|
221
|
+
await this.whoami();
|
|
222
|
+
return true;
|
|
223
|
+
} catch (err) {
|
|
224
|
+
if (err instanceof WmCliError && err.code === "auth_invalid") return false;
|
|
225
|
+
throw err;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/** Generic JSON helper. */
|
|
229
|
+
async json(req) {
|
|
230
|
+
if (!this.cfg.apiKey) throw WmCliError.authRequired();
|
|
231
|
+
const url = new URL(req.path.replace(/^\//, ""), this.cfg.apiUrl.replace(/\/?$/, "/"));
|
|
232
|
+
if (req.query) {
|
|
233
|
+
for (const [k, v] of Object.entries(req.query)) {
|
|
234
|
+
if (v !== void 0) url.searchParams.set(k, String(v));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
const ac = new AbortController();
|
|
238
|
+
const timeoutMs = req.timeoutMs ?? DEFAULTS.requestTimeoutMs;
|
|
239
|
+
const timeout = setTimeout(() => ac.abort(), timeoutMs);
|
|
240
|
+
let res;
|
|
241
|
+
try {
|
|
242
|
+
res = await fetch(url, {
|
|
243
|
+
method: req.method,
|
|
244
|
+
headers: {
|
|
245
|
+
"content-type": "application/json",
|
|
246
|
+
accept: "application/json",
|
|
247
|
+
authorization: `Bearer ${this.cfg.apiKey}`,
|
|
248
|
+
"user-agent": userAgent()
|
|
249
|
+
},
|
|
250
|
+
body: req.body ? JSON.stringify(req.body) : void 0,
|
|
251
|
+
signal: ac.signal
|
|
252
|
+
});
|
|
253
|
+
} catch (err) {
|
|
254
|
+
clearTimeout(timeout);
|
|
255
|
+
if (err instanceof WmCliError) throw err;
|
|
256
|
+
const aborted = err?.name === "AbortError";
|
|
257
|
+
throw new WmCliError({
|
|
258
|
+
code: aborted ? "timeout" : "network",
|
|
259
|
+
exitCode: aborted ? ExitCode.TIMEOUT : ExitCode.NETWORK,
|
|
260
|
+
message: aborted ? `Request timed out after ${timeoutMs}ms (${req.method} ${req.path})` : `Network error: ${err.message}`,
|
|
261
|
+
details: { cause: err.message }
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
clearTimeout(timeout);
|
|
265
|
+
const text = await res.text();
|
|
266
|
+
const parsed = text ? safeJson(text) : void 0;
|
|
267
|
+
if (res.status >= 200 && res.status < 300) {
|
|
268
|
+
return parsed;
|
|
269
|
+
}
|
|
270
|
+
throw classify(res.status, parsed, this.cfg);
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
function safeJson(text) {
|
|
274
|
+
try {
|
|
275
|
+
return JSON.parse(text);
|
|
276
|
+
} catch {
|
|
277
|
+
return { raw: text };
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
function classify(status, payload, cfg) {
|
|
281
|
+
const parsed = ApiErrorSchema.safeParse(payload);
|
|
282
|
+
const data = parsed.success ? parsed.data : {};
|
|
283
|
+
const msg = data.message ?? data.error ?? `HTTP ${status}`;
|
|
284
|
+
if (status === 401 || status === 403) return WmCliError.authInvalid(msg);
|
|
285
|
+
if (status === 402 || data.requiresTopUp) {
|
|
286
|
+
return WmCliError.upgradeRequired(data.upgradeUrl ?? cfg.upgradeUrl, msg);
|
|
287
|
+
}
|
|
288
|
+
if (status === 422 && data.code === "asset_url_required") {
|
|
289
|
+
return WmCliError.assetUrlRequired(data.uploadUrl ?? cfg.uploadUrl, msg);
|
|
290
|
+
}
|
|
291
|
+
return new WmCliError({
|
|
292
|
+
code: status >= 500 ? "server" : "usage",
|
|
293
|
+
exitCode: status >= 500 ? 50 : 2,
|
|
294
|
+
message: msg,
|
|
295
|
+
details: { status, payload }
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
function userAgent() {
|
|
299
|
+
return `wm-cli/${process.env.npm_package_version ?? "dev"} (node ${process.version})`;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// src/logger.ts
|
|
303
|
+
import kleur from "kleur";
|
|
304
|
+
var LEVEL_ORDER = { debug: 10, info: 20, warn: 30, error: 40 };
|
|
305
|
+
function currentLevel() {
|
|
306
|
+
const raw = process.env[ENV.LogLevel]?.toLowerCase();
|
|
307
|
+
return raw && raw in LEVEL_ORDER ? raw : "info";
|
|
308
|
+
}
|
|
309
|
+
function asJson() {
|
|
310
|
+
return process.env.WM_LOG_FORMAT === "json";
|
|
311
|
+
}
|
|
312
|
+
function emit(level, message, extra) {
|
|
313
|
+
if (LEVEL_ORDER[level] < LEVEL_ORDER[currentLevel()]) return;
|
|
314
|
+
if (asJson()) {
|
|
315
|
+
const line = JSON.stringify({
|
|
316
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
317
|
+
level,
|
|
318
|
+
event: message,
|
|
319
|
+
...extra
|
|
320
|
+
});
|
|
321
|
+
process.stderr.write(line + "\n");
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
const tag = level === "error" ? kleur.red().bold("\u2716") : level === "warn" ? kleur.yellow().bold("!") : level === "info" ? kleur.cyan().bold("\u203A") : kleur.gray("\xB7");
|
|
325
|
+
const detail = extra && Object.keys(extra).length ? " " + kleur.gray(JSON.stringify(extra)) : "";
|
|
326
|
+
process.stderr.write(`${tag} ${message}${detail}
|
|
327
|
+
`);
|
|
328
|
+
}
|
|
329
|
+
var logger = {
|
|
330
|
+
debug: (m, e) => emit("debug", m, e),
|
|
331
|
+
info: (m, e) => emit("info", m, e),
|
|
332
|
+
warn: (m, e) => emit("warn", m, e),
|
|
333
|
+
error: (m, e) => emit("error", m, e)
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
// src/commands/login.ts
|
|
337
|
+
function registerLogin(program) {
|
|
338
|
+
program.command("login").description("Save your WM Studio API key to ~/.wm/config.json (chmod 0600).").option("--key <apiKey>", "Pass the API key non-interactively (useful in CI).").action(async (opts) => {
|
|
339
|
+
const apiKey = opts.key ?? await password({
|
|
340
|
+
message: "Paste your WM Studio API key:",
|
|
341
|
+
mask: "*"
|
|
342
|
+
});
|
|
343
|
+
if (!apiKey || apiKey.trim().length === 0) {
|
|
344
|
+
throw WmCliError.usage("API key cannot be empty.");
|
|
345
|
+
}
|
|
346
|
+
const cfg = resolveConfig({ apiKey: apiKey.trim() });
|
|
347
|
+
const client = new WmApiClient(cfg);
|
|
348
|
+
const me = await client.whoami();
|
|
349
|
+
writeFileConfig({ apiKey: apiKey.trim() });
|
|
350
|
+
logger.info(`Logged in as ${me.email} (${me.creditsRemaining} credits remaining).`);
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// src/commands/_shared.ts
|
|
355
|
+
function makeCtx(program) {
|
|
356
|
+
const root = program.parent ?? program;
|
|
357
|
+
const opts = root.opts();
|
|
358
|
+
const cfg = resolveConfig({ apiUrl: opts.apiUrl, apiKey: opts.apiKey });
|
|
359
|
+
return { cfg, client: new WmApiClient(cfg), json: Boolean(opts.json) };
|
|
360
|
+
}
|
|
361
|
+
function requireAuth(ctx) {
|
|
362
|
+
if (!ctx.cfg.apiKey) throw WmCliError.authRequired();
|
|
363
|
+
}
|
|
364
|
+
function renderResult(ctx, payload, summary) {
|
|
365
|
+
if (ctx.json) {
|
|
366
|
+
process.stdout.write(JSON.stringify(payload, null, 2) + "\n");
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
if (summary) logger.info(summary);
|
|
370
|
+
process.stdout.write(JSON.stringify(payload, null, 2) + "\n");
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// src/commands/whoami.ts
|
|
374
|
+
function registerWhoami(program) {
|
|
375
|
+
program.command("whoami").description("Show the logged-in account and remaining credits.").action(async () => {
|
|
376
|
+
const ctx = makeCtx(program);
|
|
377
|
+
requireAuth(ctx);
|
|
378
|
+
const me = await ctx.client.whoami();
|
|
379
|
+
renderResult(ctx, me, `${me.email} \xB7 ${me.creditsRemaining} credits \xB7 plan ${me.plan}`);
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// src/commands/gen.ts
|
|
384
|
+
import ora from "ora";
|
|
385
|
+
|
|
386
|
+
// src/util/download.ts
|
|
387
|
+
import { createWriteStream } from "fs";
|
|
388
|
+
import { mkdir } from "fs/promises";
|
|
389
|
+
import { dirname as dirname2 } from "path";
|
|
390
|
+
import { pipeline } from "stream/promises";
|
|
391
|
+
import { request } from "undici";
|
|
392
|
+
async function downloadToFile(url, outPath) {
|
|
393
|
+
await mkdir(dirname2(outPath), { recursive: true });
|
|
394
|
+
const res = await request(url, { method: "GET" });
|
|
395
|
+
if (res.statusCode >= 400) throw new Error(`download failed: HTTP ${res.statusCode}`);
|
|
396
|
+
await pipeline(res.body, createWriteStream(outPath));
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// src/util/poll.ts
|
|
400
|
+
async function poll(opts) {
|
|
401
|
+
const interval = opts.intervalMs ?? DEFAULTS.jobPollIntervalMs;
|
|
402
|
+
const deadline = Date.now() + (opts.timeoutMs ?? DEFAULTS.jobPollTimeoutMs);
|
|
403
|
+
for (; ; ) {
|
|
404
|
+
const state = await opts.fetch();
|
|
405
|
+
opts.onTick?.(state);
|
|
406
|
+
if (opts.done(state)) return state;
|
|
407
|
+
if (Date.now() > deadline) {
|
|
408
|
+
throw new WmCliError({
|
|
409
|
+
code: "timeout",
|
|
410
|
+
exitCode: ExitCode.TIMEOUT,
|
|
411
|
+
message: "Job polling timed out."
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
await sleep(interval);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
function sleep(ms) {
|
|
418
|
+
return new Promise((r) => setTimeout(r, ms));
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// src/util/await-job.ts
|
|
422
|
+
async function awaitJob(client, submit, asset, onTick) {
|
|
423
|
+
if (!submit.queued) {
|
|
424
|
+
const url2 = asset === "image" ? submit.imageUrl : submit.videoUrl;
|
|
425
|
+
if (url2) {
|
|
426
|
+
return {
|
|
427
|
+
[asset === "image" ? "imageUrl" : "videoUrl"]: url2,
|
|
428
|
+
creditsRemaining: submit.creditsRemaining
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
const id = submit.generationId ?? submit.id;
|
|
433
|
+
if (!id) {
|
|
434
|
+
throw new WmCliError({
|
|
435
|
+
code: "server",
|
|
436
|
+
exitCode: ExitCode.SERVER,
|
|
437
|
+
message: "Server did not return a generationId to poll."
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
const final = await poll({
|
|
441
|
+
fetch: () => client.json({ method: "GET", path: `/studio/jobs/${id}` }),
|
|
442
|
+
done: (s) => s.status === "succeeded" || s.status === "failed",
|
|
443
|
+
onTick
|
|
444
|
+
});
|
|
445
|
+
if (final.status !== "succeeded") {
|
|
446
|
+
throw new WmCliError({
|
|
447
|
+
code: "server",
|
|
448
|
+
exitCode: ExitCode.SERVER,
|
|
449
|
+
message: `Job ${id} finished with status ${final.status}.`
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
const url = asset === "image" ? final.imageUrl : final.videoUrl;
|
|
453
|
+
if (!url) {
|
|
454
|
+
throw new WmCliError({
|
|
455
|
+
code: "server",
|
|
456
|
+
exitCode: ExitCode.SERVER,
|
|
457
|
+
message: `Job ${id} succeeded but no ${asset} URL was returned.`
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
return {
|
|
461
|
+
[asset === "image" ? "imageUrl" : "videoUrl"]: url,
|
|
462
|
+
jobId: id
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
// src/commands/gen.ts
|
|
467
|
+
function registerGen(program) {
|
|
468
|
+
const gen = program.command("gen").description("Generate creative assets (image, video).");
|
|
469
|
+
gen.command("image <prompt>").description("Text-to-image or image-to-image generation.").option("-m, --model <id>", "Provider/model id", DEFAULT_MODELS.image).option("-i, --image-url <url>", "Reference image URL for img2img variants").option("-a, --aspect-ratio <ratio>", "1:1 | 16:9 | 9:16 | 4:3 | 3:4").option("-n, --negative-prompt <text>", "Negative prompt").option("--num-images <n>", "Batch size", "1").option("--seed <n>", "Deterministic seed").option("-o, --out <file>", "Download the result to this path").action(async (prompt, opts) => {
|
|
470
|
+
const ctx = makeCtx(program);
|
|
471
|
+
requireAuth(ctx);
|
|
472
|
+
const spinner = ctx.json ? null : ora("Generating image\u2026").start();
|
|
473
|
+
try {
|
|
474
|
+
const submit = await ctx.client.json({
|
|
475
|
+
method: "POST",
|
|
476
|
+
path: "/studio/generate-image",
|
|
477
|
+
body: {
|
|
478
|
+
prompt,
|
|
479
|
+
model: opts.model,
|
|
480
|
+
image_url: opts.imageUrl,
|
|
481
|
+
aspect_ratio: opts.aspectRatio,
|
|
482
|
+
negative_prompt: opts.negativePrompt,
|
|
483
|
+
num_images: opts.numImages ? Number(opts.numImages) : void 0,
|
|
484
|
+
seed: opts.seed ? Number(opts.seed) : void 0
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
if (spinner) spinner.text = "Rendering image\u2026";
|
|
488
|
+
const result = await awaitJob(ctx.client, submit, "image", (s) => {
|
|
489
|
+
if (spinner) spinner.text = `Image \xB7 ${s.status}`;
|
|
490
|
+
});
|
|
491
|
+
spinner?.succeed("Image ready.");
|
|
492
|
+
if (opts.out && result.imageUrl) await downloadToFile(result.imageUrl, opts.out);
|
|
493
|
+
renderResult(ctx, result, `\u2192 ${result.imageUrl}`);
|
|
494
|
+
} catch (e) {
|
|
495
|
+
spinner?.fail("Image generation failed.");
|
|
496
|
+
throw e;
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
gen.command("video <prompt>").description("Text-to-video or image-to-video. Async; polls until done.").option("-m, --model <id>", "Provider/model id (auto-picks i2v vs t2v based on --image).").option("-i, --image <url>", "Starting frame for image-to-video").option("-d, --duration <seconds>", "Clip length", "5").option("-a, --aspect-ratio <ratio>", "16:9 | 9:16 | 1:1", "16:9").option("-o, --out <file>", "Download the final clip to this path").action(async (prompt, opts) => {
|
|
500
|
+
const ctx = makeCtx(program);
|
|
501
|
+
requireAuth(ctx);
|
|
502
|
+
const model = opts.model ?? (opts.image ? DEFAULT_MODELS.videoImage : DEFAULT_MODELS.videoText);
|
|
503
|
+
const spinner = ctx.json ? null : ora("Submitting video job\u2026").start();
|
|
504
|
+
try {
|
|
505
|
+
const submit = await ctx.client.json({
|
|
506
|
+
method: "POST",
|
|
507
|
+
path: "/studio/generate-video",
|
|
508
|
+
body: {
|
|
509
|
+
prompt,
|
|
510
|
+
model,
|
|
511
|
+
image_url: opts.image,
|
|
512
|
+
duration: Number(opts.duration),
|
|
513
|
+
aspect_ratio: opts.aspectRatio
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
if (spinner) spinner.text = "Rendering video\u2026";
|
|
517
|
+
const final = await awaitJob(ctx.client, submit, "video", (s) => {
|
|
518
|
+
if (spinner) spinner.text = `Video \xB7 ${s.status}`;
|
|
519
|
+
});
|
|
520
|
+
spinner?.succeed("Video ready.");
|
|
521
|
+
if (opts.out && final.videoUrl) await downloadToFile(final.videoUrl, opts.out);
|
|
522
|
+
renderResult(ctx, final, `\u2192 ${final.videoUrl}`);
|
|
523
|
+
} catch (e) {
|
|
524
|
+
spinner?.fail("Video generation failed.");
|
|
525
|
+
throw e;
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
// src/commands/upscale.ts
|
|
531
|
+
import ora2 from "ora";
|
|
532
|
+
function registerUpscale(program) {
|
|
533
|
+
program.command("upscale <imageUrl>").description("Topaz upscale of an image (factor 1\u20134).").option("-f, --factor <n>", "Upscale factor (1|2|3|4)", "2").option("--topaz-model <name>", "Topaz preset", "Standard V2").option("--no-face-enhancement", "Disable Topaz face enhancement").option("-o, --out <file>", "Download the result to this path").action(async (imageUrl, opts) => {
|
|
534
|
+
const ctx = makeCtx(program);
|
|
535
|
+
requireAuth(ctx);
|
|
536
|
+
const spinner = ctx.json ? null : ora2("Upscaling\u2026").start();
|
|
537
|
+
try {
|
|
538
|
+
const submit = await ctx.client.json({
|
|
539
|
+
method: "POST",
|
|
540
|
+
path: "/studio/upscale-image",
|
|
541
|
+
body: {
|
|
542
|
+
image_url: imageUrl,
|
|
543
|
+
upscale_factor: opts.factor ? Number(opts.factor) : 2,
|
|
544
|
+
topaz_model: opts.topazModel,
|
|
545
|
+
face_enhancement: opts.faceEnhancement
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
const result = await awaitJob(ctx.client, submit, "image", (s) => {
|
|
549
|
+
if (spinner) spinner.text = `Upscale \xB7 ${s.status}`;
|
|
550
|
+
});
|
|
551
|
+
spinner?.succeed("Upscaled.");
|
|
552
|
+
if (opts.out && result.imageUrl) await downloadToFile(result.imageUrl, opts.out);
|
|
553
|
+
renderResult(ctx, result, `\u2192 ${result.imageUrl}`);
|
|
554
|
+
} catch (e) {
|
|
555
|
+
spinner?.fail("Upscale failed.");
|
|
556
|
+
throw e;
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// src/commands/campaign.ts
|
|
562
|
+
import ora3 from "ora";
|
|
563
|
+
function registerCampaign(program) {
|
|
564
|
+
program.command("campaign <brief>").description(
|
|
565
|
+
"Turn a creative brief into a full video run (or N variations) via the director_* pipeline."
|
|
566
|
+
).option("-n, --variations <n>", "Generate N parallel variations (1 = single run)", "1").option("-d, --duration <seconds>", "Target duration", "60").option("-p, --platform <name>", "youtube | tiktok | instagram", "youtube").option("-s, --style <name>", "cinematic | ugc | documentary | \u2026", "cinematic").option("--project-id <id>", "Existing wmstudio project id (required for variations)").option("--no-follow", "Submit and return immediately without polling").action(async (brief, opts) => {
|
|
567
|
+
const ctx = makeCtx(program);
|
|
568
|
+
requireAuth(ctx);
|
|
569
|
+
const variations = Math.max(1, Number(opts.variations ?? "1"));
|
|
570
|
+
const spinner = ctx.json ? null : ora3("Submitting brief\u2026").start();
|
|
571
|
+
try {
|
|
572
|
+
const submission = variations > 1 ? await ctx.client.json({
|
|
573
|
+
method: "POST",
|
|
574
|
+
path: "/studio/director/batch-variations",
|
|
575
|
+
body: {
|
|
576
|
+
base_prompt: brief,
|
|
577
|
+
max_concurrent: variations,
|
|
578
|
+
project_id: opts.projectId
|
|
579
|
+
}
|
|
580
|
+
}) : await ctx.client.json({
|
|
581
|
+
method: "POST",
|
|
582
|
+
path: "/studio/director/brief-to-run",
|
|
583
|
+
body: {
|
|
584
|
+
brief,
|
|
585
|
+
duration_target_seconds: Number(opts.duration),
|
|
586
|
+
platform: opts.platform,
|
|
587
|
+
style: opts.style
|
|
588
|
+
}
|
|
589
|
+
});
|
|
590
|
+
const runIds = submission.runIds ?? [];
|
|
591
|
+
if (!opts.follow || runIds.length === 0) {
|
|
592
|
+
spinner?.succeed(`Submitted ${runIds.length} run(s).`);
|
|
593
|
+
renderResult(ctx, submission);
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
if (spinner) spinner.text = `Polling ${runIds.length} run(s)\u2026`;
|
|
597
|
+
const finals = await Promise.all(
|
|
598
|
+
runIds.map(
|
|
599
|
+
(id) => poll({
|
|
600
|
+
fetch: () => ctx.client.json({ method: "GET", path: `/studio/runs/${id}` }),
|
|
601
|
+
done: (s) => ["succeeded", "failed", "cancelled"].includes(s.status)
|
|
602
|
+
})
|
|
603
|
+
)
|
|
604
|
+
);
|
|
605
|
+
spinner?.succeed("Run(s) complete.");
|
|
606
|
+
renderResult(ctx, { runs: finals });
|
|
607
|
+
} catch (e) {
|
|
608
|
+
spinner?.fail("Campaign failed.");
|
|
609
|
+
throw e;
|
|
610
|
+
}
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
// src/commands/jobs.ts
|
|
615
|
+
function registerJobs(program) {
|
|
616
|
+
const jobs = program.command("jobs").description("List and inspect generation jobs.");
|
|
617
|
+
jobs.command("list").description("List recent jobs (default: 20 most recent).").option("-l, --limit <n>", "Number of jobs", "20").option("-s, --status <s>", "Filter by status (running|succeeded|failed|cancelled)").action(async (opts) => {
|
|
618
|
+
const ctx = makeCtx(program);
|
|
619
|
+
requireAuth(ctx);
|
|
620
|
+
const data = await ctx.client.json({
|
|
621
|
+
method: "GET",
|
|
622
|
+
path: "/studio/jobs",
|
|
623
|
+
query: { limit: opts.limit, status: opts.status }
|
|
624
|
+
});
|
|
625
|
+
renderResult(ctx, data);
|
|
626
|
+
});
|
|
627
|
+
jobs.command("get <jobId>").description("Fetch a single job by id.").action(async (jobId) => {
|
|
628
|
+
const ctx = makeCtx(program);
|
|
629
|
+
requireAuth(ctx);
|
|
630
|
+
const data = await ctx.client.json({ method: "GET", path: `/studio/jobs/${jobId}` });
|
|
631
|
+
renderResult(ctx, data);
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
// src/cli.ts
|
|
636
|
+
async function run(argv) {
|
|
637
|
+
const program = new Command().name("wm").description(
|
|
638
|
+
"WM Studio command-line client. Generate images, videos, brand campaigns, and 3D assets."
|
|
639
|
+
).version(VERSION, "-v, --version").option("--api-url <url>", "Override WM Studio API base URL").option("--api-key <key>", "Override API key (otherwise WM_API_KEY or ~/.wm/config.json)").option("--json", "Emit machine-readable JSON output", false).showHelpAfterError("(run `wm <command> --help` for details)");
|
|
640
|
+
registerLogin(program);
|
|
641
|
+
registerWhoami(program);
|
|
642
|
+
registerGen(program);
|
|
643
|
+
registerUpscale(program);
|
|
644
|
+
registerCampaign(program);
|
|
645
|
+
registerJobs(program);
|
|
646
|
+
await program.parseAsync(argv);
|
|
647
|
+
}
|
|
648
|
+
var VERSION = typeof __VERSION__ !== "undefined" && __VERSION__ || process.env.npm_package_version || "0.0.0-dev";
|
|
649
|
+
|
|
650
|
+
// src/index.ts
|
|
651
|
+
run(process.argv).catch((err) => {
|
|
652
|
+
if (err instanceof WmCliError) {
|
|
653
|
+
logger.error(err.message, err.details);
|
|
654
|
+
process.exit(err.exitCode);
|
|
655
|
+
}
|
|
656
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
657
|
+
logger.error(`unexpected error: ${message}`);
|
|
658
|
+
process.exit(ExitCode.UNEXPECTED);
|
|
659
|
+
});
|
|
660
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/commands/login.ts","../src/config.ts","../src/constants.ts","../src/client.ts","../src/errors.ts","../src/logger.ts","../src/commands/_shared.ts","../src/commands/whoami.ts","../src/commands/gen.ts","../src/util/download.ts","../src/util/poll.ts","../src/util/await-job.ts","../src/commands/upscale.ts","../src/commands/campaign.ts","../src/commands/jobs.ts","../src/index.ts"],"sourcesContent":["/**\n * Commander root. Each subcommand lives in its own file under ./commands.\n */\nimport { Command } from \"commander\"\nimport { registerLogin } from \"./commands/login.js\"\nimport { registerWhoami } from \"./commands/whoami.js\"\nimport { registerGen } from \"./commands/gen.js\"\nimport { registerUpscale } from \"./commands/upscale.js\"\nimport { registerCampaign } from \"./commands/campaign.js\"\nimport { registerJobs } from \"./commands/jobs.js\"\n\nexport async function run(argv: string[]): Promise<void> {\n const program = new Command()\n .name(\"wm\")\n .description(\n \"WM Studio command-line client. Generate images, videos, brand campaigns, and 3D assets.\"\n )\n .version(VERSION, \"-v, --version\")\n .option(\"--api-url <url>\", \"Override WM Studio API base URL\")\n .option(\"--api-key <key>\", \"Override API key (otherwise WM_API_KEY or ~/.wm/config.json)\")\n .option(\"--json\", \"Emit machine-readable JSON output\", false)\n .showHelpAfterError(\"(run `wm <command> --help` for details)\")\n\n registerLogin(program)\n registerWhoami(program)\n registerGen(program)\n registerUpscale(program)\n registerCampaign(program)\n registerJobs(program)\n\n await program.parseAsync(argv)\n}\n\n// Injected at build time by tsup via `define` β fallback for `tsx`/`vitest`.\ndeclare const __VERSION__: string | undefined\nconst VERSION: string =\n (typeof __VERSION__ !== \"undefined\" && __VERSION__) ||\n process.env.npm_package_version ||\n \"0.0.0-dev\"\n","import type { Command } from \"commander\"\nimport { password } from \"@inquirer/prompts\"\nimport { writeFileConfig } from \"../config.js\"\nimport { WmApiClient } from \"../client.js\"\nimport { resolveConfig } from \"../config.js\"\nimport { logger } from \"../logger.js\"\nimport { WmCliError } from \"../errors.js\"\n\nexport function registerLogin(program: Command): void {\n program\n .command(\"login\")\n .description(\"Save your WM Studio API key to ~/.wm/config.json (chmod 0600).\")\n .option(\"--key <apiKey>\", \"Pass the API key non-interactively (useful in CI).\")\n .action(async (opts: { key?: string }) => {\n const apiKey =\n opts.key ??\n (await password({\n message: \"Paste your WM Studio API key:\",\n mask: \"*\",\n }))\n if (!apiKey || apiKey.trim().length === 0) {\n throw WmCliError.usage(\"API key cannot be empty.\")\n }\n\n const cfg = resolveConfig({ apiKey: apiKey.trim() })\n const client = new WmApiClient(cfg)\n const me = await client.whoami()\n\n writeFileConfig({ apiKey: apiKey.trim() })\n logger.info(`Logged in as ${me.email} (${me.creditsRemaining} credits remaining).`)\n })\n}\n","/**\n * On-disk config + env merge.\n *\n * Precedence (highest first):\n * 1. CLI flag (--api-url, --api-key)\n * 2. Environment variables (WMSTUDIO_API_URL, WM_API_KEY)\n * 3. ~/.wm/config.json\n * 4. Built-in defaults (constants.ts)\n */\nimport { existsSync, mkdirSync, readFileSync, writeFileSync, chmodSync } from \"node:fs\"\nimport { homedir } from \"node:os\"\nimport { dirname, join } from \"node:path\"\nimport { z } from \"zod\"\nimport { DEFAULTS, ENV } from \"./constants.js\"\n\nconst FileConfigSchema = z.object({\n apiUrl: z.string().url().optional(),\n apiKey: z.string().min(1).optional(),\n uploadUrl: z.string().url().optional(),\n upgradeUrl: z.string().url().optional(),\n lowCreditsThreshold: z.number().int().nonnegative().optional(),\n})\n\nexport type FileConfig = z.infer<typeof FileConfigSchema>\n\nexport interface ResolvedConfig {\n apiUrl: string\n apiKey: string | undefined\n uploadUrl: string\n upgradeUrl: string\n lowCreditsThreshold: number\n configPath: string\n}\n\nexport function configDir(): string {\n const override = process.env[ENV.ConfigDir]\n return override && override.length > 0 ? override : join(homedir(), \".wm\")\n}\n\nexport function configPath(): string {\n return join(configDir(), \"config.json\")\n}\n\nexport function readFileConfig(): FileConfig {\n const path = configPath()\n if (!existsSync(path)) return {}\n try {\n const raw = readFileSync(path, \"utf8\")\n return FileConfigSchema.parse(JSON.parse(raw))\n } catch {\n // Corrupt config β return empty rather than crash the CLI on every command.\n return {}\n }\n}\n\nexport function writeFileConfig(patch: FileConfig): void {\n const merged = { ...readFileConfig(), ...patch }\n const dir = configDir()\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true, mode: 0o700 })\n const file = configPath()\n writeFileSync(file, JSON.stringify(merged, null, 2) + \"\\n\", { mode: 0o600 })\n // Defensive: enforce 0600 even if file pre-existed.\n try {\n chmodSync(file, 0o600)\n } catch {\n /* non-fatal */\n }\n // And 0700 on the dir.\n try {\n chmodSync(dirname(file), 0o700)\n } catch {\n /* non-fatal */\n }\n}\n\nexport interface ConfigOverrides {\n apiUrl?: string\n apiKey?: string\n}\n\nexport function resolveConfig(overrides: ConfigOverrides = {}): ResolvedConfig {\n const file = readFileConfig()\n return {\n apiUrl: overrides.apiUrl ?? process.env[ENV.ApiUrl] ?? file.apiUrl ?? DEFAULTS.apiUrl,\n apiKey: overrides.apiKey ?? process.env[ENV.ApiKey] ?? file.apiKey,\n uploadUrl: process.env[ENV.UploadUrl] ?? file.uploadUrl ?? DEFAULTS.uploadUrl,\n upgradeUrl: process.env[ENV.UpgradeUrl] ?? file.upgradeUrl ?? DEFAULTS.upgradeUrl,\n lowCreditsThreshold:\n numFromEnv(process.env[ENV.LowCreditsThreshold]) ??\n file.lowCreditsThreshold ??\n DEFAULTS.lowCreditsThreshold,\n configPath: configPath(),\n }\n}\n\nfunction numFromEnv(raw: string | undefined): number | undefined {\n if (!raw) return undefined\n const n = Number(raw)\n return Number.isFinite(n) ? n : undefined\n}\n","/**\n * Shared constants. Keep in sync with `mcp-director/src/config.py`.\n * Anything that names an env var, an endpoint, or a model id belongs here.\n */\n\nexport const DEFAULTS = {\n /** Hosted WM Studio REST API base. Override via `WMSTUDIO_API_URL`. */\n apiUrl: \"https://wmstudio.io/api\",\n /** Public upload endpoint surfaced when an asset URL is missing. */\n uploadUrl: \"https://director-cut.fly.dev/upload\",\n /** Credit top-up landing page. */\n upgradeUrl: \"https://wmstudio.io/dashboard/credits\",\n /** Below this remaining-credit count we surface a warning. */\n lowCreditsThreshold: 50,\n /** Default request timeout (ms) for non-job calls. */\n requestTimeoutMs: 60_000,\n /** Polling interval (ms) for async jobs. */\n jobPollIntervalMs: 4_000,\n /** Hard ceiling for job polling (ms). */\n jobPollTimeoutMs: 15 * 60 * 1000,\n} as const\n\nexport const ENV = {\n ApiUrl: \"WMSTUDIO_API_URL\",\n ApiKey: \"WM_API_KEY\",\n UploadUrl: \"ASSET_UPLOAD_URL\",\n UpgradeUrl: \"CREDITS_UPGRADE_URL\",\n LowCreditsThreshold: \"CREDITS_LOW_THRESHOLD\",\n LogLevel: \"WM_LOG_LEVEL\",\n ConfigDir: \"WM_CONFIG_DIR\",\n} as const\n\n/** Default model ids per tool β mirror `mcp-director/src/tools/studio.py` defaults. */\nexport const DEFAULT_MODELS = {\n image: \"fal-ai/flux/dev\",\n videoText: \"fal-ai/kling-video/v2.5-turbo/pro/text-to-video\",\n videoImage: \"fal-ai/kling-video/v2.5-turbo/pro/image-to-video\",\n upscaleImage: \"fal-ai/topaz/upscale/image\",\n upscaleVideo: \"fal-ai/topaz/upscale/video\",\n threeD: \"fal-ai/meshy/v6/image-to-3d\",\n brandshot: \"fal-ai/flux/dev\",\n cameraAngles: \"fal-ai/flux/dev\",\n casting: \"fal-ai/flux/dev\",\n ugcRoom: \"fal-ai/flux/dev\",\n} as const\n","/**\n * Thin HTTP client for the WM Studio REST API.\n *\n * Endpoints mirror what `mcp-director/src/wmstudio_client.py` already calls\n * β keeping the contract identical means the CLI is a drop-in alternative\n * to the MCP for the same underlying backend.\n */\nimport { z } from \"zod\"\nimport { DEFAULTS } from \"./constants.js\"\nimport { ExitCode, WmCliError } from \"./errors.js\"\nimport type { ResolvedConfig } from \"./config.js\"\n\nconst ApiErrorSchema = z.object({\n code: z.string().optional(),\n error: z.string().optional(),\n message: z.string().optional(),\n requiresTopUp: z.boolean().optional(),\n upgradeUrl: z.string().url().optional(),\n uploadUrl: z.string().url().optional(),\n})\n\nexport interface JsonRequest {\n method: \"GET\" | \"POST\" | \"PATCH\" | \"DELETE\"\n path: string\n body?: Record<string, unknown>\n query?: Record<string, string | number | boolean | undefined>\n timeoutMs?: number\n}\n\nexport class WmApiClient {\n constructor(private readonly cfg: ResolvedConfig) {}\n\n /** GET /me β returns account + credit balance. */\n whoami(): Promise<{\n userId: string\n email: string\n creditsRemaining: number\n plan: string\n }> {\n return this.json({ method: \"GET\", path: \"/me\" })\n }\n\n /** Validate the current api key without side-effects. */\n async ping(): Promise<boolean> {\n try {\n await this.whoami()\n return true\n } catch (err) {\n if (err instanceof WmCliError && err.code === \"auth_invalid\") return false\n throw err\n }\n }\n\n /** Generic JSON helper. */\n async json<T = unknown>(req: JsonRequest): Promise<T> {\n if (!this.cfg.apiKey) throw WmCliError.authRequired()\n\n const url = new URL(req.path.replace(/^\\//, \"\"), this.cfg.apiUrl.replace(/\\/?$/, \"/\"))\n if (req.query) {\n for (const [k, v] of Object.entries(req.query)) {\n if (v !== undefined) url.searchParams.set(k, String(v))\n }\n }\n\n const ac = new AbortController()\n const timeoutMs = req.timeoutMs ?? DEFAULTS.requestTimeoutMs\n const timeout = setTimeout(() => ac.abort(), timeoutMs)\n\n let res: Response\n try {\n res = await fetch(url, {\n method: req.method,\n headers: {\n \"content-type\": \"application/json\",\n accept: \"application/json\",\n authorization: `Bearer ${this.cfg.apiKey}`,\n \"user-agent\": userAgent(),\n },\n body: req.body ? JSON.stringify(req.body) : undefined,\n signal: ac.signal,\n })\n } catch (err) {\n clearTimeout(timeout)\n if (err instanceof WmCliError) throw err\n const aborted = (err as { name?: string } | null)?.name === \"AbortError\"\n throw new WmCliError({\n code: aborted ? \"timeout\" : \"network\",\n exitCode: aborted ? ExitCode.TIMEOUT : ExitCode.NETWORK,\n message: aborted\n ? `Request timed out after ${timeoutMs}ms (${req.method} ${req.path})`\n : `Network error: ${(err as Error).message}`,\n details: { cause: (err as Error).message },\n })\n }\n clearTimeout(timeout)\n\n const text = await res.text()\n const parsed: unknown = text ? safeJson(text) : undefined\n\n if (res.status >= 200 && res.status < 300) {\n return parsed as T\n }\n throw classify(res.status, parsed, this.cfg)\n }\n}\n\nfunction safeJson(text: string): unknown {\n try {\n return JSON.parse(text)\n } catch {\n return { raw: text }\n }\n}\n\nfunction classify(status: number, payload: unknown, cfg: ResolvedConfig): WmCliError {\n const parsed = ApiErrorSchema.safeParse(payload)\n const data = parsed.success ? parsed.data : {}\n const msg = data.message ?? data.error ?? `HTTP ${status}`\n\n if (status === 401 || status === 403) return WmCliError.authInvalid(msg)\n if (status === 402 || data.requiresTopUp) {\n return WmCliError.upgradeRequired(data.upgradeUrl ?? cfg.upgradeUrl, msg)\n }\n if (status === 422 && data.code === \"asset_url_required\") {\n return WmCliError.assetUrlRequired(data.uploadUrl ?? cfg.uploadUrl, msg)\n }\n return new WmCliError({\n code: status >= 500 ? \"server\" : \"usage\",\n exitCode: status >= 500 ? 50 : 2,\n message: msg,\n details: { status, payload },\n })\n}\n\nfunction userAgent(): string {\n return `wm-cli/${process.env.npm_package_version ?? \"dev\"} (node ${process.version})`\n}\n","/**\n * Error model + exit codes for `wm`.\n *\n * Exit codes are stable contract β kept in sync with `mcp-director` error codes\n * (see ../docs/CONVENTIONS.md). Used by CI, shell scripts, and humans.\n */\n\nexport const ExitCode = {\n OK: 0,\n USAGE: 2, // bad arguments / unknown command\n AUTH_REQUIRED: 10, // not logged in / missing api key\n AUTH_INVALID: 11, // server rejected token (401/403)\n ASSET_URL_REQUIRED: 20, // missing or unreachable user-provided URL\n UPGRADE_REQUIRED: 30, // 402 insufficient credits\n RATE_LIMITED: 31, // 429\n NETWORK: 40, // transport / DNS / TLS\n SERVER: 50, // 5xx\n TIMEOUT: 51, // server-side or client-side deadline exceeded\n UNEXPECTED: 99, // crashed / not classifiable\n} as const\n\nexport type ExitCodeValue = (typeof ExitCode)[keyof typeof ExitCode]\n\n/**\n * The canonical error codes returned by the WM Studio API and `mcp-director`.\n * Keeping the same vocabulary across CLI / MCP / SDK is the whole point.\n */\nexport const ErrorCode = {\n AuthRequired: \"auth_required\",\n AuthInvalid: \"auth_invalid\",\n AssetUrlRequired: \"asset_url_required\",\n UpgradeRequired: \"upgrade_required\",\n RateLimited: \"rate_limited\",\n Network: \"network\",\n Server: \"server\",\n Timeout: \"timeout\",\n Usage: \"usage\",\n Unexpected: \"unexpected\",\n} as const\n\nexport type ErrorCodeValue = (typeof ErrorCode)[keyof typeof ErrorCode]\n\nexport class WmCliError extends Error {\n readonly code: ErrorCodeValue\n readonly exitCode: ExitCodeValue\n readonly details?: Record<string, unknown>\n\n constructor(opts: {\n code: ErrorCodeValue\n exitCode: ExitCodeValue\n message: string\n details?: Record<string, unknown>\n }) {\n super(opts.message)\n this.name = \"WmCliError\"\n this.code = opts.code\n this.exitCode = opts.exitCode\n this.details = opts.details\n }\n\n static authRequired(message = \"Not logged in. Run `wm login` first.\"): WmCliError {\n return new WmCliError({\n code: ErrorCode.AuthRequired,\n exitCode: ExitCode.AUTH_REQUIRED,\n message,\n })\n }\n\n static authInvalid(message = \"Invalid or expired API key.\"): WmCliError {\n return new WmCliError({\n code: ErrorCode.AuthInvalid,\n exitCode: ExitCode.AUTH_INVALID,\n message,\n })\n }\n\n static assetUrlRequired(uploadUrl: string, message?: string): WmCliError {\n return new WmCliError({\n code: ErrorCode.AssetUrlRequired,\n exitCode: ExitCode.ASSET_URL_REQUIRED,\n message: message ?? `A real public asset URL is required. Upload at ${uploadUrl}.`,\n details: { uploadUrl },\n })\n }\n\n static upgradeRequired(upgradeUrl: string, message?: string): WmCliError {\n return new WmCliError({\n code: ErrorCode.UpgradeRequired,\n exitCode: ExitCode.UPGRADE_REQUIRED,\n message: message ?? `Insufficient credits. Top up at ${upgradeUrl} and re-run.`,\n details: { upgradeUrl },\n })\n }\n\n static usage(message: string): WmCliError {\n return new WmCliError({\n code: ErrorCode.Usage,\n exitCode: ExitCode.USAGE,\n message,\n })\n }\n}\n","/**\n * Tiny structured logger. Console output is colourised for humans (stderr);\n * when `WM_LOG_FORMAT=json` is set, emits JSON lines compatible with the same\n * shape used by `mcp-director` (`event`, `level`, `ts`, β¦extra).\n */\nimport kleur from \"kleur\"\nimport { ENV } from \"./constants.js\"\n\ntype Level = \"debug\" | \"info\" | \"warn\" | \"error\"\n\nconst LEVEL_ORDER: Record<Level, number> = { debug: 10, info: 20, warn: 30, error: 40 }\n\nfunction currentLevel(): Level {\n const raw = process.env[ENV.LogLevel]?.toLowerCase() as Level | undefined\n return raw && raw in LEVEL_ORDER ? raw : \"info\"\n}\n\nfunction asJson(): boolean {\n return process.env.WM_LOG_FORMAT === \"json\"\n}\n\nfunction emit(level: Level, message: string, extra?: Record<string, unknown>): void {\n if (LEVEL_ORDER[level] < LEVEL_ORDER[currentLevel()]) return\n\n if (asJson()) {\n const line = JSON.stringify({\n ts: new Date().toISOString(),\n level,\n event: message,\n ...extra,\n })\n process.stderr.write(line + \"\\n\")\n return\n }\n\n const tag =\n level === \"error\"\n ? kleur.red().bold(\"β\")\n : level === \"warn\"\n ? kleur.yellow().bold(\"!\")\n : level === \"info\"\n ? kleur.cyan().bold(\"βΊ\")\n : kleur.gray(\"Β·\")\n const detail = extra && Object.keys(extra).length ? \" \" + kleur.gray(JSON.stringify(extra)) : \"\"\n process.stderr.write(`${tag} ${message}${detail}\\n`)\n}\n\nexport const logger = {\n debug: (m: string, e?: Record<string, unknown>) => emit(\"debug\", m, e),\n info: (m: string, e?: Record<string, unknown>) => emit(\"info\", m, e),\n warn: (m: string, e?: Record<string, unknown>) => emit(\"warn\", m, e),\n error: (m: string, e?: Record<string, unknown>) => emit(\"error\", m, e),\n}\n","/**\n * Shared command helpers: resolve config, build client, render output.\n */\nimport type { Command } from \"commander\"\nimport { resolveConfig, type ResolvedConfig } from \"../config.js\"\nimport { WmApiClient } from \"../client.js\"\nimport { logger } from \"../logger.js\"\nimport { WmCliError } from \"../errors.js\"\n\nexport interface GlobalFlags {\n apiUrl?: string\n apiKey?: string\n json?: boolean\n}\n\nexport interface CommandCtx {\n cfg: ResolvedConfig\n client: WmApiClient\n json: boolean\n}\n\nexport function makeCtx(program: Command): CommandCtx {\n // Walk up to the root program so subcommands inherit global flags.\n const root = program.parent ?? program\n const opts = root.opts<GlobalFlags>()\n const cfg = resolveConfig({ apiUrl: opts.apiUrl, apiKey: opts.apiKey })\n return { cfg, client: new WmApiClient(cfg), json: Boolean(opts.json) }\n}\n\nexport function requireAuth(\n ctx: CommandCtx\n): asserts ctx is CommandCtx & { cfg: ResolvedConfig & { apiKey: string } } {\n if (!ctx.cfg.apiKey) throw WmCliError.authRequired()\n}\n\nexport function renderResult(ctx: CommandCtx, payload: unknown, summary?: string): void {\n if (ctx.json) {\n process.stdout.write(JSON.stringify(payload, null, 2) + \"\\n\")\n return\n }\n if (summary) logger.info(summary)\n process.stdout.write(JSON.stringify(payload, null, 2) + \"\\n\")\n}\n","import type { Command } from \"commander\"\nimport { makeCtx, requireAuth, renderResult } from \"./_shared.js\"\n\nexport function registerWhoami(program: Command): void {\n program\n .command(\"whoami\")\n .description(\"Show the logged-in account and remaining credits.\")\n .action(async () => {\n const ctx = makeCtx(program)\n requireAuth(ctx)\n const me = await ctx.client.whoami()\n renderResult(ctx, me, `${me.email} Β· ${me.creditsRemaining} credits Β· plan ${me.plan}`)\n })\n}\n","/**\n * `wm gen image|video` β image and video generation.\n *\n * Calls the same REST endpoints `mcp-director` already proxies to:\n * POST /studio/generate-image\n * POST /studio/generate-video\n */\nimport type { Command } from \"commander\"\nimport ora from \"ora\"\nimport { makeCtx, requireAuth, renderResult } from \"./_shared.js\"\nimport { DEFAULT_MODELS } from \"../constants.js\"\nimport { downloadToFile } from \"../util/download.js\"\nimport { awaitJob } from \"../util/await-job.js\"\n\ninterface ImageOpts {\n model?: string\n imageUrl?: string\n aspectRatio?: string\n negativePrompt?: string\n numImages?: string\n seed?: string\n out?: string\n}\n\ninterface VideoOpts {\n model?: string\n image?: string\n duration?: string\n aspectRatio?: string\n out?: string\n}\n\nexport function registerGen(program: Command): void {\n const gen = program.command(\"gen\").description(\"Generate creative assets (image, video).\")\n\n gen\n .command(\"image <prompt>\")\n .description(\"Text-to-image or image-to-image generation.\")\n .option(\"-m, --model <id>\", \"Provider/model id\", DEFAULT_MODELS.image)\n .option(\"-i, --image-url <url>\", \"Reference image URL for img2img variants\")\n .option(\"-a, --aspect-ratio <ratio>\", \"1:1 | 16:9 | 9:16 | 4:3 | 3:4\")\n .option(\"-n, --negative-prompt <text>\", \"Negative prompt\")\n .option(\"--num-images <n>\", \"Batch size\", \"1\")\n .option(\"--seed <n>\", \"Deterministic seed\")\n .option(\"-o, --out <file>\", \"Download the result to this path\")\n .action(async (prompt: string, opts: ImageOpts) => {\n const ctx = makeCtx(program)\n requireAuth(ctx)\n const spinner = ctx.json ? null : ora(\"Generating imageβ¦\").start()\n try {\n const submit = await ctx.client.json<Record<string, unknown>>({\n method: \"POST\",\n path: \"/studio/generate-image\",\n body: {\n prompt,\n model: opts.model,\n image_url: opts.imageUrl,\n aspect_ratio: opts.aspectRatio,\n negative_prompt: opts.negativePrompt,\n num_images: opts.numImages ? Number(opts.numImages) : undefined,\n seed: opts.seed ? Number(opts.seed) : undefined,\n },\n })\n if (spinner) spinner.text = \"Rendering imageβ¦\"\n const result = await awaitJob(ctx.client, submit, \"image\", (s) => {\n if (spinner) spinner.text = `Image Β· ${s.status}`\n })\n spinner?.succeed(\"Image ready.\")\n if (opts.out && result.imageUrl) await downloadToFile(result.imageUrl, opts.out)\n renderResult(ctx, result, `β ${result.imageUrl}`)\n } catch (e) {\n spinner?.fail(\"Image generation failed.\")\n throw e\n }\n })\n\n gen\n .command(\"video <prompt>\")\n .description(\"Text-to-video or image-to-video. Async; polls until done.\")\n .option(\"-m, --model <id>\", \"Provider/model id (auto-picks i2v vs t2v based on --image).\")\n .option(\"-i, --image <url>\", \"Starting frame for image-to-video\")\n .option(\"-d, --duration <seconds>\", \"Clip length\", \"5\")\n .option(\"-a, --aspect-ratio <ratio>\", \"16:9 | 9:16 | 1:1\", \"16:9\")\n .option(\"-o, --out <file>\", \"Download the final clip to this path\")\n .action(async (prompt: string, opts: VideoOpts) => {\n const ctx = makeCtx(program)\n requireAuth(ctx)\n const model =\n opts.model ?? (opts.image ? DEFAULT_MODELS.videoImage : DEFAULT_MODELS.videoText)\n const spinner = ctx.json ? null : ora(\"Submitting video jobβ¦\").start()\n try {\n const submit = await ctx.client.json<Record<string, unknown>>({\n method: \"POST\",\n path: \"/studio/generate-video\",\n body: {\n prompt,\n model,\n image_url: opts.image,\n duration: Number(opts.duration),\n aspect_ratio: opts.aspectRatio,\n },\n })\n if (spinner) spinner.text = \"Rendering videoβ¦\"\n const final = await awaitJob(ctx.client, submit, \"video\", (s) => {\n if (spinner) spinner.text = `Video Β· ${s.status}`\n })\n spinner?.succeed(\"Video ready.\")\n if (opts.out && final.videoUrl) await downloadToFile(final.videoUrl, opts.out)\n renderResult(ctx, final, `β ${final.videoUrl}`)\n } catch (e) {\n spinner?.fail(\"Video generation failed.\")\n throw e\n }\n })\n}\n","/**\n * Stream a remote asset to a local path. Used by `--out` flags.\n */\nimport { createWriteStream } from \"node:fs\"\nimport { mkdir } from \"node:fs/promises\"\nimport { dirname } from \"node:path\"\nimport { pipeline } from \"node:stream/promises\"\nimport { request } from \"undici\"\n\nexport async function downloadToFile(url: string, outPath: string): Promise<void> {\n await mkdir(dirname(outPath), { recursive: true })\n const res = await request(url, { method: \"GET\" })\n if (res.statusCode >= 400) throw new Error(`download failed: HTTP ${res.statusCode}`)\n // undici's res.body is already a Node Readable β pipe it straight.\n await pipeline(res.body, createWriteStream(outPath))\n}\n","/**\n * Generic async-job poller. Used by `gen video` and `campaign` commands.\n */\nimport { DEFAULTS } from \"../constants.js\"\nimport { WmCliError, ExitCode } from \"../errors.js\"\n\nexport interface PollOptions<T> {\n /** Function that fetches the latest status. */\n fetch: () => Promise<T>\n /** Returns true when the job has reached a terminal state. */\n done: (state: T) => boolean\n /** Optional hook fired on each tick (for spinners / progress). */\n onTick?: (state: T) => void\n intervalMs?: number\n timeoutMs?: number\n}\n\nexport async function poll<T>(opts: PollOptions<T>): Promise<T> {\n const interval = opts.intervalMs ?? DEFAULTS.jobPollIntervalMs\n const deadline = Date.now() + (opts.timeoutMs ?? DEFAULTS.jobPollTimeoutMs)\n\n for (;;) {\n const state = await opts.fetch()\n opts.onTick?.(state)\n if (opts.done(state)) return state\n if (Date.now() > deadline) {\n throw new WmCliError({\n code: \"timeout\",\n exitCode: ExitCode.TIMEOUT,\n message: \"Job polling timed out.\",\n })\n }\n await sleep(interval)\n }\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((r) => setTimeout(r, ms))\n}\n","/**\n * Handle the queued-job response shape returned by /studio/generate-image,\n * /studio/generate-video and /studio/upscale-image.\n *\n * If the response carries `queued: true`, poll `/studio/jobs/:id` until it\n * reports `status: \"succeeded\"` (and the requested URL field is present)\n * or `status: \"failed\"`. Otherwise, return the response as-is so old/sync\n * code paths keep working.\n */\nimport type { WmApiClient } from \"../client.js\"\nimport { poll } from \"./poll.js\"\nimport { WmCliError, ExitCode } from \"../errors.js\"\n\nexport type Asset = \"image\" | \"video\"\n\ninterface SubmitResponse {\n queued?: boolean\n generationId?: string\n id?: string\n jobId?: string\n imageUrl?: string\n videoUrl?: string\n creditsRemaining?: number\n}\n\ninterface JobStatus {\n jobId: string\n status: \"succeeded\" | \"running\" | \"failed\"\n imageUrl?: string | null\n videoUrl?: string | null\n creditsCharged?: number | null\n}\n\nexport interface AwaitedJob {\n imageUrl?: string\n videoUrl?: string\n creditsRemaining?: number\n jobId?: string\n}\n\nexport async function awaitJob(\n client: WmApiClient,\n submit: SubmitResponse,\n asset: Asset,\n onTick?: (s: JobStatus) => void\n): Promise<AwaitedJob> {\n // Sync response: URL already present.\n if (!submit.queued) {\n const url = asset === \"image\" ? submit.imageUrl : submit.videoUrl\n if (url) {\n return {\n [asset === \"image\" ? \"imageUrl\" : \"videoUrl\"]: url,\n creditsRemaining: submit.creditsRemaining,\n }\n }\n }\n\n const id = submit.generationId ?? submit.id\n if (!id) {\n throw new WmCliError({\n code: \"server\",\n exitCode: ExitCode.SERVER,\n message: \"Server did not return a generationId to poll.\",\n })\n }\n\n const final = await poll<JobStatus>({\n fetch: () => client.json<JobStatus>({ method: \"GET\", path: `/studio/jobs/${id}` }),\n done: (s) => s.status === \"succeeded\" || s.status === \"failed\",\n onTick,\n })\n\n if (final.status !== \"succeeded\") {\n throw new WmCliError({\n code: \"server\",\n exitCode: ExitCode.SERVER,\n message: `Job ${id} finished with status ${final.status}.`,\n })\n }\n\n const url = asset === \"image\" ? final.imageUrl : final.videoUrl\n if (!url) {\n throw new WmCliError({\n code: \"server\",\n exitCode: ExitCode.SERVER,\n message: `Job ${id} succeeded but no ${asset} URL was returned.`,\n })\n }\n\n return {\n [asset === \"image\" ? \"imageUrl\" : \"videoUrl\"]: url,\n jobId: id,\n }\n}\n","import type { Command } from \"commander\"\nimport ora from \"ora\"\nimport { makeCtx, requireAuth, renderResult } from \"./_shared.js\"\nimport { downloadToFile } from \"../util/download.js\"\nimport { awaitJob } from \"../util/await-job.js\"\n\ninterface UpscaleOpts {\n factor?: string\n topazModel?: string\n faceEnhancement?: boolean\n out?: string\n}\n\nexport function registerUpscale(program: Command): void {\n program\n .command(\"upscale <imageUrl>\")\n .description(\"Topaz upscale of an image (factor 1β4).\")\n .option(\"-f, --factor <n>\", \"Upscale factor (1|2|3|4)\", \"2\")\n .option(\"--topaz-model <name>\", \"Topaz preset\", \"Standard V2\")\n .option(\"--no-face-enhancement\", \"Disable Topaz face enhancement\")\n .option(\"-o, --out <file>\", \"Download the result to this path\")\n .action(async (imageUrl: string, opts: UpscaleOpts) => {\n const ctx = makeCtx(program)\n requireAuth(ctx)\n const spinner = ctx.json ? null : ora(\"Upscalingβ¦\").start()\n try {\n const submit = await ctx.client.json<Record<string, unknown>>({\n method: \"POST\",\n path: \"/studio/upscale-image\",\n body: {\n image_url: imageUrl,\n upscale_factor: opts.factor ? Number(opts.factor) : 2,\n topaz_model: opts.topazModel,\n face_enhancement: opts.faceEnhancement,\n },\n })\n const result = await awaitJob(ctx.client, submit, \"image\", (s) => {\n if (spinner) spinner.text = `Upscale Β· ${s.status}`\n })\n spinner?.succeed(\"Upscaled.\")\n if (opts.out && result.imageUrl) await downloadToFile(result.imageUrl, opts.out)\n renderResult(ctx, result, `β ${result.imageUrl}`)\n } catch (e) {\n spinner?.fail(\"Upscale failed.\")\n throw e\n }\n })\n}\n","/**\n * `wm campaign` β submit a brief to `director_creative_brief_to_run` or\n * `director_creative_batch_variations`, then poll the resulting run(s).\n */\nimport type { Command } from \"commander\"\nimport ora from \"ora\"\nimport { makeCtx, requireAuth, renderResult } from \"./_shared.js\"\nimport { poll } from \"../util/poll.js\"\n\ninterface CampaignOpts {\n variations?: string\n duration?: string\n platform?: string\n style?: string\n projectId?: string\n follow?: boolean\n}\n\ninterface RunStatus {\n runId: string\n status: string\n masterVideoUrl?: string\n}\n\nexport function registerCampaign(program: Command): void {\n program\n .command(\"campaign <brief>\")\n .description(\n \"Turn a creative brief into a full video run (or N variations) via the director_* pipeline.\"\n )\n .option(\"-n, --variations <n>\", \"Generate N parallel variations (1 = single run)\", \"1\")\n .option(\"-d, --duration <seconds>\", \"Target duration\", \"60\")\n .option(\"-p, --platform <name>\", \"youtube | tiktok | instagram\", \"youtube\")\n .option(\"-s, --style <name>\", \"cinematic | ugc | documentary | β¦\", \"cinematic\")\n .option(\"--project-id <id>\", \"Existing wmstudio project id (required for variations)\")\n .option(\"--no-follow\", \"Submit and return immediately without polling\")\n .action(async (brief: string, opts: CampaignOpts) => {\n const ctx = makeCtx(program)\n requireAuth(ctx)\n const variations = Math.max(1, Number(opts.variations ?? \"1\"))\n const spinner = ctx.json ? null : ora(\"Submitting briefβ¦\").start()\n\n try {\n const submission =\n variations > 1\n ? await ctx.client.json<{ runIds: string[] }>({\n method: \"POST\",\n path: \"/studio/director/batch-variations\",\n body: {\n base_prompt: brief,\n max_concurrent: variations,\n project_id: opts.projectId,\n },\n })\n : await ctx.client.json<{ runIds: string[] }>({\n method: \"POST\",\n path: \"/studio/director/brief-to-run\",\n body: {\n brief,\n duration_target_seconds: Number(opts.duration),\n platform: opts.platform,\n style: opts.style,\n },\n })\n\n const runIds = submission.runIds ?? []\n if (!opts.follow || runIds.length === 0) {\n spinner?.succeed(`Submitted ${runIds.length} run(s).`)\n renderResult(ctx, submission)\n return\n }\n\n if (spinner) spinner.text = `Polling ${runIds.length} run(s)β¦`\n const finals = await Promise.all(\n runIds.map((id) =>\n poll<RunStatus>({\n fetch: () => ctx.client.json({ method: \"GET\", path: `/studio/runs/${id}` }),\n done: (s) => [\"succeeded\", \"failed\", \"cancelled\"].includes(s.status),\n })\n )\n )\n spinner?.succeed(\"Run(s) complete.\")\n renderResult(ctx, { runs: finals })\n } catch (e) {\n spinner?.fail(\"Campaign failed.\")\n throw e\n }\n })\n}\n","/**\n * `wm jobs list|get` β inspect async generation jobs and runs.\n */\nimport type { Command } from \"commander\"\nimport { makeCtx, requireAuth, renderResult } from \"./_shared.js\"\n\nexport function registerJobs(program: Command): void {\n const jobs = program.command(\"jobs\").description(\"List and inspect generation jobs.\")\n\n jobs\n .command(\"list\")\n .description(\"List recent jobs (default: 20 most recent).\")\n .option(\"-l, --limit <n>\", \"Number of jobs\", \"20\")\n .option(\"-s, --status <s>\", \"Filter by status (running|succeeded|failed|cancelled)\")\n .action(async (opts: { limit?: string; status?: string }) => {\n const ctx = makeCtx(program)\n requireAuth(ctx)\n const data = await ctx.client.json({\n method: \"GET\",\n path: \"/studio/jobs\",\n query: { limit: opts.limit, status: opts.status },\n })\n renderResult(ctx, data)\n })\n\n jobs\n .command(\"get <jobId>\")\n .description(\"Fetch a single job by id.\")\n .action(async (jobId: string) => {\n const ctx = makeCtx(program)\n requireAuth(ctx)\n const data = await ctx.client.json({ method: \"GET\", path: `/studio/jobs/${jobId}` })\n renderResult(ctx, data)\n })\n}\n","// Entrypoint. tsup prepends the `#!/usr/bin/env node` shebang in the build banner.\nimport { run } from \"./cli.js\"\nimport { WmCliError, ExitCode } from \"./errors.js\"\nimport { logger } from \"./logger.js\"\n\nrun(process.argv).catch((err: unknown) => {\n if (err instanceof WmCliError) {\n logger.error(err.message, err.details)\n process.exit(err.exitCode)\n }\n const message = err instanceof Error ? err.message : String(err)\n logger.error(`unexpected error: ${message}`)\n process.exit(ExitCode.UNEXPECTED)\n})\n"],"mappings":";;;AAGA,SAAS,eAAe;;;ACFxB,SAAS,gBAAgB;;;ACQzB,SAAS,YAAY,WAAW,cAAc,eAAe,iBAAiB;AAC9E,SAAS,eAAe;AACxB,SAAS,SAAS,YAAY;AAC9B,SAAS,SAAS;;;ACPX,IAAM,WAAW;AAAA;AAAA,EAEtB,QAAQ;AAAA;AAAA,EAER,WAAW;AAAA;AAAA,EAEX,YAAY;AAAA;AAAA,EAEZ,qBAAqB;AAAA;AAAA,EAErB,kBAAkB;AAAA;AAAA,EAElB,mBAAmB;AAAA;AAAA,EAEnB,kBAAkB,KAAK,KAAK;AAC9B;AAEO,IAAM,MAAM;AAAA,EACjB,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,qBAAqB;AAAA,EACrB,UAAU;AAAA,EACV,WAAW;AACb;AAGO,IAAM,iBAAiB;AAAA,EAC5B,OAAO;AAAA,EACP,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AmB,iCAAiC,EAC3D,OAAO,mBAAmB,8DAA8D,EACxF,OAAO,UAAU,qCAAqC,KAAK,EAC3D,mBAAmB,yCAAyC;AAE/D,gBAAc,OAAO;AACrB,iBAAe,OAAO;AACtB,cAAY,OAAO;AACnB,kBAAgB,OAAO;AACvB,mBAAiB,OAAO;AACxB,eAAa,OAAO;AAEpB,QAAM,QAAQ,WAAW,IAAI;AAC/B;AAIA,IAAM,UACH,OAAO,gBAAgB,eAAe,eACvC,QAAQ,IAAI,uBACZ;;;AgBjCF,IAAI,QAAQ,IAAI,EAAE,MAAM,CAAC,QAAiB;AACxC,MAAI,eAAe,YAAY;AAC7B,WAAO,MAAM,IAAI,SAAS,IAAI,OAAO;AACrC,YAAQ,KAAK,IAAI,QAAQ;AAAA,EAC3B;AACA,QAAM,UAAU,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC/D,SAAO,MAAM,qBAAqB,OAAO,EAAE;AAC3C,UAAQ,KAAK,SAAS,UAAU;AAClC,CAAC;","names":["z","z","dirname","url","ora","ora","ora","ora"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "wmstudio-cli",
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"description": "Command-line client for the WM Studio creative platform. Generates images, videos, brand campaigns, and 3D assets from your terminal.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"wm": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE",
|
|
13
|
+
"CHANGELOG.md"
|
|
14
|
+
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=20.10.0"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@inquirer/prompts": "^7.0.0",
|
|
20
|
+
"commander": "^12.1.0",
|
|
21
|
+
"kleur": "^4.1.5",
|
|
22
|
+
"ora": "^8.1.0",
|
|
23
|
+
"undici": "^6.20.0",
|
|
24
|
+
"zod": "^3.23.8"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@changesets/cli": "^2.27.9",
|
|
28
|
+
"@types/node": "^22.7.0",
|
|
29
|
+
"@vitest/coverage-v8": "^2.1.2",
|
|
30
|
+
"eslint": "^9.12.0",
|
|
31
|
+
"msw": "^2.4.9",
|
|
32
|
+
"prettier": "^3.3.3",
|
|
33
|
+
"tsup": "^8.3.0",
|
|
34
|
+
"typescript": "^5.6.2",
|
|
35
|
+
"typescript-eslint": "^8.8.0",
|
|
36
|
+
"vitest": "^2.1.2"
|
|
37
|
+
},
|
|
38
|
+
"keywords": [
|
|
39
|
+
"wmstudio",
|
|
40
|
+
"cli",
|
|
41
|
+
"ai",
|
|
42
|
+
"image-generation",
|
|
43
|
+
"video-generation",
|
|
44
|
+
"fal-ai",
|
|
45
|
+
"creative-tools"
|
|
46
|
+
],
|
|
47
|
+
"homepage": "https://wmstudio.io",
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "https://github.com/PrincipeRosso/wm-cli.git"
|
|
51
|
+
},
|
|
52
|
+
"license": "MIT",
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"access": "public"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "tsup",
|
|
58
|
+
"dev": "tsup --watch",
|
|
59
|
+
"start": "node dist/index.js",
|
|
60
|
+
"lint": "eslint .",
|
|
61
|
+
"lint:fix": "eslint . --fix",
|
|
62
|
+
"format": "prettier --write .",
|
|
63
|
+
"format:check": "prettier --check .",
|
|
64
|
+
"typecheck": "tsc --noEmit",
|
|
65
|
+
"test": "vitest run",
|
|
66
|
+
"test:watch": "vitest",
|
|
67
|
+
"test:cov": "vitest run --coverage",
|
|
68
|
+
"check": "pnpm typecheck && pnpm lint && pnpm format:check && pnpm test",
|
|
69
|
+
"release": "changeset publish"
|
|
70
|
+
}
|
|
71
|
+
}
|