@usemo.com/sdk 0.1.0

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 ADDED
@@ -0,0 +1,233 @@
1
+ # UseMo CLI, JavaScript client and MCP
2
+
3
+ Create videos, images, written content, social posts, articles and decks from a
4
+ terminal or an AI agent. Node.js 20 or newer is required. The package includes
5
+ `usemo` and `usemo-mcp`; neither needs Python, the backend, or a local database.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install -g @usemo.com/sdk@0.1.0
11
+ usemo --version
12
+ usemo --help
13
+ ```
14
+
15
+ For a one-off command without a global install:
16
+
17
+ ```bash
18
+ npx --yes --package @usemo.com/sdk@0.1.0 usemo --help
19
+ ```
20
+
21
+ ## Install from this repository
22
+
23
+ ```bash
24
+ cd sdk/javascript
25
+ npm ci
26
+ npm install -g .
27
+ usemo --version
28
+ usemo --help
29
+ ```
30
+
31
+ To distribute the client without the backend, run `npm pack` in this directory
32
+ and install the resulting tarball with `npm install -g /path/to/usemo-sdk-0.1.0.tgz`.
33
+ The package contains only client source, its generated schemas, and this guide.
34
+
35
+ ## Authenticate
36
+
37
+ Create a workspace key in **UseMo → Settings → API Keys**. Supply it through
38
+ `USEMO_API_KEY` from your secret manager. To save an existing key as a local profile:
39
+
40
+ ```bash
41
+ printf '%s\n' "$USEMO_API_KEY" | usemo login --key-stdin --profile work
42
+ usemo whoami --profile work --json
43
+ usemo profiles list
44
+ usemo profiles use work
45
+ ```
46
+
47
+ Login verifies the key with a workspace read before saving it. It does not
48
+ create an account or a key. Browser/device login is not implemented in this CLI.
49
+ The existing hosted MCP connector has its own OAuth flow when enabled by the deployment.
50
+
51
+ Profiles are stored as plaintext in `~/.config/usemo/config.json`, with directory
52
+ mode `0700` and file mode `0600`. Override the directory with `USEMO_CONFIG_DIR`
53
+ or `XDG_CONFIG_HOME`. Environment keys take precedence over the selected profile.
54
+ `--profile` takes precedence over `USEMO_PROFILE`, then the saved active profile.
55
+ `--base-url` takes precedence over `USEMO_API_BASE`, then the profile's base URL,
56
+ then `https://api.usemo.com`. `/api` and `/api/v1` suffixes are accepted.
57
+
58
+ Saved keys are bound to their original host: changing the API host requires a
59
+ separate login/profile or explicitly supplying `USEMO_API_KEY`. HTTPS is required
60
+ except for loopback development. Keys are sent through `X-API-Key`, matching the
61
+ current REST implementation. `USEMO_WORKSPACE_ID` is optional for a scoped API key.
62
+ `usemo logout` removes the selected local profile; revoke keys separately in the app.
63
+
64
+ ## Create media and content
65
+
66
+ ```bash
67
+ # Validate and inspect the request without credentials or API calls
68
+ usemo images create "A green ceramic vase in a sunlit studio" --dry-run --json
69
+
70
+ # Create an image and wait for its result URLs
71
+ usemo images create "A green ceramic vase in a sunlit studio" --wait --json
72
+
73
+ # Brief → grounded storyboard → finished video
74
+ usemo videos create "A 30-second product launch video for our brand" --wait --json
75
+
76
+ # Animate an existing frame (use an actual image URL or asset ID)
77
+ usemo videos generate "A slow camera push toward the product" \
78
+ --input-image-url https://example.com/product.png --duration-sec 5 --wait --json
79
+
80
+ usemo content create "Write a LinkedIn post announcing our launch" --wait --json
81
+ usemo content social "Meet our new product" --cta "Explore now" --wait --json
82
+ usemo content article "How to choose a team phone system" --wait --json
83
+ usemo content deck "Product launch" --brief "Overview, audience, benefits and next steps" --wait --json
84
+ ```
85
+
86
+ Generation spends workspace credits. Commands execute the requested operation
87
+ without interactive confirmation. Use `--dry-run` to review a request. A video
88
+ brief uses asynchronous planning by default to avoid gateway timeouts. It may
89
+ initially return `planning: true`, `shippable: null`, and a job handle. A synchronous
90
+ brief (`--async-plan=false`) can return `shippable: false` when the grounding gate blocks it; that is a
91
+ planning result and no render job has been submitted. Refine the brief or brand
92
+ context. Written content may return synchronously, or return a nested job handle;
93
+ `--wait` handles both forms. Other creation responses contain asynchronous jobs.
94
+
95
+ ```bash
96
+ usemo brand get --json
97
+ usemo brand learn https://example.com --wait --json
98
+ usemo ideas suggest "Announce our new product" --json
99
+ usemo videos plan "A 30-second launch video" --json
100
+ usemo videos quote --data @quote.json --json
101
+ usemo jobs list --status processing --json
102
+ usemo jobs get JOB_ID --json
103
+ usemo jobs wait JOB_ID --max-wait-sec 600 --json
104
+ usemo assets list --type image --json
105
+ usemo twins list --json
106
+ ```
107
+
108
+ For a quote, `quote.json` contains `{"storyboard": ...}` using the actual storyboard
109
+ returned by planning. `campaigns quote` accepts a `concepts` array. Twin rendering
110
+ uses `twins render TWIN_ID --audio-asset-id AUDIO_ID`; voice generation uses
111
+ `twins speak TWIN_ID --script-text "Your script"`.
112
+
113
+ ## Agent and automation contract
114
+
115
+ - `usemo schema [GROUP COMMAND] --json` provides input JSON Schema, descriptions,
116
+ annotations and routes. `usemo discover QUERY --json` searches the command catalog.
117
+ - Field flags use dashes (`--num-images`); JSON uses underscores (`num_images`).
118
+ Nested objects/arrays can be supplied as JSON flags or through `--data`.
119
+ - `--data` accepts an inline object, `@file.json`, or `@-` for stdin. Duplicate
120
+ flags and duplicate fields between JSON and flags are rejected.
121
+ - `--json` emits a single JSON value on stdout. Errors are JSON on stderr.
122
+ Exit codes: `0` success, `1` API/auth/network/local error, `2` invalid input,
123
+ `3` wait timeout, `4` failed/cancelled job. `shippable: false` is a successful
124
+ planning response; inspect it before assuming media was generated.
125
+ - `--out receipt.json` saves JSON without overwriting an existing file.
126
+ Use `usemo download HTTPS_URL --out video.mp4` to download a result URL.
127
+ Downloads stream to a temporary file and publish atomically, do not overwrite,
128
+ and never send an API key to the media host. Redirecting asset URLs are rejected;
129
+ retrieve a direct URL from the library if necessary.
130
+ - Submission timeout defaults to 60 seconds (`--timeout`). Waiting defaults to
131
+ 180 seconds and polls every 5 seconds (`--wait-timeout`, `--poll-interval`).
132
+ The explicit `jobs wait` tool supports `max_wait_sec` 5–600 and
133
+ `poll_interval_sec` 2–30. A wait timeout leaves the remote job running and returns
134
+ its handle. Resume waiting instead of resubmitting.
135
+ - Image generation, direct video generation, video creation and text generation
136
+ accept `--idempotency-key`. The client generates one if omitted and includes it
137
+ in the receipt or ambiguous-submission error. Reuse the same key **and payload**
138
+ for a retry. No requests are automatically retried. Other endpoints are not
139
+ assumed to implement idempotency.
140
+ - `doctor` is an offline configuration check and does not print secrets.
141
+ `whoami` verifies access through the brand-profile endpoint; it does not claim
142
+ to return a complete identity/scopes record.
143
+
144
+ For API capabilities outside the curated catalog:
145
+
146
+ ```bash
147
+ usemo request GET /api/v1/assets --query job_id=JOB_ID --query offset=20 --json
148
+ usemo request POST /api/v1/jobs/JOB_ID/cancel --dry-run --json
149
+ ```
150
+
151
+ Generic requests use the selected API origin only. Read the current REST schema
152
+ for advanced payloads. CLI dry runs validate curated inputs, but cannot verify
153
+ server permissions, available credits, remote asset URLs, or runtime model health.
154
+
155
+ ## Connect MCP
156
+
157
+ Without a global installation, configure your MCP client to launch the npm package:
158
+
159
+ ```json
160
+ {
161
+ "mcpServers": {
162
+ "usemo": {
163
+ "command": "npx",
164
+ "args": ["--yes", "--package", "@usemo.com/sdk@0.1.0", "usemo-mcp"],
165
+ "env": { "USEMO_PROFILE": "work" }
166
+ }
167
+ }
168
+ }
169
+ ```
170
+
171
+ With the package globally installed, configure an MCP client to launch:
172
+
173
+ ```json
174
+ {
175
+ "mcpServers": {
176
+ "usemo": {
177
+ "command": "usemo-mcp",
178
+ "env": { "USEMO_PROFILE": "work" }
179
+ }
180
+ }
181
+ }
182
+ ```
183
+
184
+ A saved profile or a `USEMO_API_KEY` supplied by the host provides authentication.
185
+ If a GUI cannot resolve the executable on PATH, use its absolute installed path,
186
+ or `node` with the absolute path to this package's `src/mcp.js`.
187
+ `usemo mcp --profile work` is the equivalent CLI entry point. Protocol messages
188
+ are the only stdout output. The server exposes 24 tools, including offline
189
+ `usemo_get_started` and `usemo_discover_tools`. Local tool inputs are flat objects
190
+ as advertised by `tools/list`; follow the actual schema exposed by your transport.
191
+
192
+ The existing remote connector remains at `https://api.usemo.com/mcp`:
193
+
194
+ ```json
195
+ {
196
+ "mcpServers": {
197
+ "usemo": { "url": "https://api.usemo.com/mcp" }
198
+ }
199
+ }
200
+ ```
201
+
202
+ Remote clients must supply their own API key or complete the deployment's OAuth
203
+ flow. Enabling OAuth and deploying backend changes are separate release steps.
204
+ New tools in this checkout are not available on the hosted endpoint until deployed.
205
+
206
+ ## JavaScript API
207
+
208
+ ```js
209
+ import { UseMoClient } from '@usemo.com/sdk';
210
+
211
+ const usemo = new UseMoClient({ apiKey: process.env.USEMO_API_KEY });
212
+ const result = await usemo.run('images create', {
213
+ prompt: 'A green ceramic vase in a sunlit studio',
214
+ idempotency_key: 'my-unique-workflow-step-id'
215
+ }, { wait: true, timeout: 300 });
216
+ console.log(result);
217
+ ```
218
+
219
+ ## Development and release checks
220
+
221
+ ```bash
222
+ npm ci
223
+ npm test
224
+ # From the repository root, using its development Python environment:
225
+ .venv/bin/python sdk/javascript/scripts/export_catalog.py --check
226
+ ```
227
+
228
+ The catalog is generated from `app/mcp/tools.py` and the public collateral
229
+ request models. After changing those inputs, regenerate it with the same command
230
+ without `--check`. CI verifies that the checked-in catalog stays current.
231
+ Tests use mocked HTTP, a loopback API, and actual MCP SDK transports; they do not
232
+ spend credits or render real media. Validate a release with a real workspace key
233
+ and representative generations before publishing to npm and deploying the hosted tools.
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@usemo.com/sdk",
3
+ "version": "0.1.0",
4
+ "description": "UseMo CLI, JavaScript client and MCP server for videos, images and content.",
5
+ "type": "module",
6
+ "engines": {
7
+ "node": ">=20"
8
+ },
9
+ "bin": {
10
+ "usemo": "src/cli.js",
11
+ "usemo-mcp": "src/mcp.js"
12
+ },
13
+ "exports": {
14
+ ".": "./src/client.js"
15
+ },
16
+ "files": [
17
+ "src",
18
+ "README.md"
19
+ ],
20
+ "scripts": {
21
+ "test": "node --test test/*.test.js",
22
+ "check:catalog": "python scripts/export_catalog.py --check",
23
+ "prepack": "npm test"
24
+ },
25
+ "dependencies": {
26
+ "@modelcontextprotocol/sdk": "^1.27.1",
27
+ "ajv": "^8.17.1",
28
+ "ajv-formats": "^3.0.1",
29
+ "zod": "^3.25.76"
30
+ },
31
+ "homepage": "https://usemo.com",
32
+ "publishConfig": {
33
+ "access": "public",
34
+ "registry": "https://registry.npmjs.org"
35
+ },
36
+ "keywords": [
37
+ "usemo",
38
+ "mcp",
39
+ "cli",
40
+ "ai-video",
41
+ "image-generation",
42
+ "content-generation"
43
+ ]
44
+ }