@oiioii/cli 0.1.0 → 0.1.5

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.
Files changed (4) hide show
  1. package/README.md +180 -39
  2. package/dist/cli.js +43 -6920
  3. package/package.json +19 -10
  4. package/dist/cli.js.map +0 -1
package/README.md CHANGED
@@ -12,8 +12,9 @@ human-readable output and a stable JSON envelope for AI agents and automation.
12
12
 
13
13
  | Command | Capability | Status |
14
14
  |---|---|---|
15
- | `auth login` | Persist API Key and backend configuration | Implemented |
16
- | `workspace create/set/current` | Create, configure, and inspect workspaces | Implemented |
15
+ | `auth login` | Browser authorization for terminal/Codex/WorkBuddy/Kimi/Claude Code/DeepSeek, or explicit API Key persistence | Implemented |
16
+ | `workspace create/set/current/rename` | Create, configure, inspect, and rename workspaces | Implemented |
17
+ | `workspace assets list/download` | List workspace assets and download ready resources | Implemented |
17
18
  | `image text` | Text-to-image generation | Implemented |
18
19
  | `image edit` | Image-to-image editing | Implemented |
19
20
  | `video text` | Text-to-video generation | Implemented |
@@ -24,7 +25,7 @@ human-readable output and a stable JSON envelope for AI agents and automation.
24
25
  | `record get/open` | Query generation metadata and download resources | Implemented |
25
26
  | `inspect capabilities/models` | Inspect declared capabilities and live backend models | Implemented |
26
27
  | `preview latest/bundle` | Read local preview bundles created by generation commands | Implemented |
27
- | `task list/status/wait` | Inspect and wait for local generation tasks | Implemented |
28
+ | `task list/status/wait/retry` | Inspect, wait for, and safely retry local generation tasks | Implemented |
28
29
  | `logs list/export/path` | Inspect and export structured local logs | Implemented |
29
30
  | `points balance/quote/cost` | Inspect balance, estimate a request, and query actual charges | Implemented |
30
31
 
@@ -34,19 +35,21 @@ Important current limitations:
34
35
  - Generation submits `submit_async_media_generation` and returns immediately with the authoritative backend `task_id` plus a `local_task_id`.
35
36
  - The backend task ID, workspace, media type, asset ID, progress, and terminal outputs are cached in the owner-only local task store.
36
37
  - `task status/wait` query `query_async_media_generation` for non-terminal cached tasks and accept either the backend or local task ID.
38
+ - If submission times out or disconnects before the backend task ID is received, the task remains `submitting`; `task retry <local_task_id>` resends the saved request with the original idempotency key.
39
+ - REST metadata requests time out after 30 seconds; raw resource uploads/downloads use a 5-minute transfer timeout, and VOD transcode polling has a 10-minute overall deadline.
37
40
  - Image, video, and audio generation create local preview bundles after a queried task reaches a terminal state.
38
41
  - `inspect capabilities` is local metadata; `inspect models` requires authentication and queries the active backend.
39
- - Asset-library browsing/search/update/delete and style-library commands are not available.
42
+ - Asset search/update/delete and style-library commands are not available. Workspace-scoped asset listing and download are available.
40
43
 
41
44
  ## Requirements
42
45
 
43
- - Node.js 18 or newer when running from source or the npm package.
44
- - An existing Hogi MCP API Key.
46
+ - Node.js 18.18 or newer when running from source or the npm package.
47
+ - A Hogi account for browser authorization, or an existing Hogi MCP API Key.
45
48
  - A workspace ID for image/video/audio generation and resource upload. It can be
46
49
  created with `oiioii workspace create` or supplied from an existing project.
47
50
  - `npm` is the repository package manager.
48
51
 
49
- The hosted installer uses Node.js 18 or newer when available. If no compatible
52
+ The hosted installer uses Node.js 18.18 or newer when available. If no compatible
50
53
  Node.js/npm installation exists, it downloads an official Node.js runtime,
51
54
  verifies its SHA256, and keeps it under the oiioii installation directory.
52
55
 
@@ -83,21 +86,28 @@ write `install.json`, and create stable `oiioii` / `oiioii-cli` wrappers. CLI
83
86
  updates reuse the exact Node.js, npm, registry, package, and prefix recorded by
84
87
  the installer.
85
88
 
89
+ The maintained production bootstrap sources are `scripts/install.sh` for
90
+ macOS/Linux and `scripts/install.ps1` for Windows. They always follow npm's
91
+ `latest` dist-tag. Set `OIIOII_CLI_VERSION` only when you need one exact stable
92
+ version.
93
+
86
94
  macOS (Apple Silicon and Intel are detected automatically):
87
95
 
88
96
  ```bash
89
- curl -fsSL https://<public-host>/install.sh | bash
97
+ curl -fsSL https://static-oiioii-sg.hogiai.cn/cli/install.sh | bash
90
98
  ```
91
99
 
92
100
  Windows x64, from PowerShell:
93
101
 
94
102
  ```powershell
95
- $script = Join-Path $env:TEMP "install.ps1"; curl.exe -fsSL https://<public-host>/install.ps1 -o $script; powershell.exe -NoProfile -ExecutionPolicy Bypass -File $script; Remove-Item $script
103
+ $script = Join-Path $env:TEMP "install.ps1"; curl.exe -fsSL https://static-oiioii-sg.hogiai.cn/cli/install.ps1 -o $script; powershell.exe -NoProfile -ExecutionPolicy Bypass -File $script; Remove-Item $script
96
104
  ```
97
105
 
98
- Production is the default and follows npm's `latest` dist-tag. For the HOE test
99
- build, set `OIIOII_ENV=test`; it follows the `test` dist-tag and accepts only
100
- prerelease versions. Set `OIIOII_CLI_VERSION` to install one exact version.
106
+ Test builds use `scripts/test/install.sh` and `scripts/test/install.ps1` as
107
+ maintained static-runtime installer templates. The build writes generated
108
+ installers with the runtime MD5 embedded under `scripts/test/dist/`; they verify
109
+ the runtime archive SHA-256 before installing it and do not share the production
110
+ npm installer/update metadata.
101
111
 
102
112
  After bootstrap installation:
103
113
 
@@ -113,15 +123,28 @@ rebuilt from the checkout.
113
123
 
114
124
  ## Build Environments
115
125
 
116
- The default backend URL is embedded into the generated bundle at build time.
126
+ The default backend URL and browser authorization page are embedded into the generated bundle at build time.
117
127
 
118
- | Build command | Environment | Embedded default backend |
119
- |---|---|---|
120
- | `npm run build:production` | production | `https://api.oiioii.ai` |
121
- | `npm run build:test` | test (HOE) | `https://api-hoe.oiioii.tv` |
122
- | `npm run build:local` | local | `http://localhost:4000` |
128
+ | Build command | Environment | Embedded default backend | Authorization page |
129
+ |---|---|---|---|
130
+ | `npm run build:production` | production | `https://api.oiioii.ai` (optional `OIIOII_PRODUCTION_BASE_URL` override) | `https://oiioii.tv/auth/cli` |
131
+ | `npm run build:test` | test | `OIIOII_TEST_BASE_URL` from `.env` | Build-specific test authorization page |
132
+ | `npm run build:local` | local | `http://localhost:4000` | `http://localhost:3000/auth/cli` |
133
+
134
+ Use the environment-specific build entry points. Only test builds require a
135
+ URL in `.env`:
136
+
137
+ ```bash
138
+ npm run build:production
139
+ cp .env.example .env
140
+ npm run build:test
141
+ ```
123
142
 
124
- `npm run build` builds the test environment to preserve the existing default.
143
+ `npm run build` is an alias for `build:production`. `build:test:runtime` is a
144
+ separate release path: it builds the test bundle, installs production-only
145
+ dependencies into an isolated staging directory, verifies the embedded URL,
146
+ and writes generated installers plus an MD5-addressed runtime archive and its
147
+ SHA-256 checksum under the ignored `scripts/test/dist/` directory.
125
148
 
126
149
  For a custom deployment, override the embedded URL during the build:
127
150
 
@@ -132,6 +155,11 @@ OIIOII_BUILD_BASE_URL=https://custom.example.com npm run build:production
132
155
  Supported build environment names are exactly `production`, `test`, and
133
156
  `local`. Unknown values fail the build instead of silently selecting a domain.
134
157
 
158
+ Publishing always rebuilds the package during npm's `prepublishOnly` lifecycle.
159
+ Publishing rejects the one-off `OIIOII_BUILD_BASE_URL` override and uses the
160
+ matching environment-specific variable, so an inherited custom URL cannot leak
161
+ into a published package.
162
+
135
163
  The embedded URL is a fallback. Existing runtime overrides remain available:
136
164
 
137
165
  - Root option: `--base-url <url>` for commands that consume the root override.
@@ -140,17 +168,52 @@ The embedded URL is a fallback. Existing runtime overrides remain available:
140
168
 
141
169
  ## Authentication and Workspace
142
170
 
143
- Persist an existing MCP API Key and the backend URL:
171
+ Authorize through the Hogi browser page for the application that launched the CLI:
144
172
 
145
173
  ```bash
146
- oiioii auth login \
147
- --api-key "oii_sk_..." \
148
- --base-url "https://api-hoe.oiioii.tv"
174
+ oiioii auth login
175
+ oiioii auth login --codex
176
+ oiioii auth login --workbuddy
177
+ oiioii auth login --kimi
178
+ oiioii auth login --claude-code
179
+ oiioii auth login --deepseek
149
180
  ```
150
181
 
151
- The CLI writes the API Key and Base URL to `~/.oiioii/config.json` with file
152
- permissions `0600`. `OIIOII_API_KEY` remains available as a temporary process
153
- override. A legacy `~/.oiioii/credentials.json` file, if present, is ignored.
182
+ Without an application option, `auth login` opens the browser authorization page
183
+ and asks the user to return to the terminal when authorization completes. The
184
+ application options label the authorization for the selected host. Codex and
185
+ WorkBuddy use verified macOS/Windows activation contracts; other targets print
186
+ the localized manual-return fallback when no verified OS activation contract is
187
+ available. The browser flow uses a loopback callback, state validation, and PKCE. It creates
188
+ an API Key through the current build's backend, stores it locally, and requests
189
+ that macOS or Windows return to the selected application after the hosted success
190
+ page acknowledges it is ready, with a bounded fallback if that acknowledgement is blocked. If the browser or app
191
+ cannot be opened, the CLI prints a localized manual fallback. Use `--no-browser`
192
+ to print the authorization URL for a headless environment.
193
+
194
+ Browser authorization only runs against the backend paired with the current CLI
195
+ build. Remove `OIIOII_BASE_URL` and use `--reset-base-url` when an older persisted
196
+ override is present. For a custom backend, use the explicit `--api-key` mode.
197
+
198
+ You can still persist an existing MCP API Key only through the explicit
199
+ `--api-key` mode. The CLI keeps the backend URL
200
+ embedded for its build environment unless you explicitly override it:
201
+
202
+ ```bash
203
+ oiioii auth login --api-key "oii_sk_..."
204
+ ```
205
+
206
+ The CLI writes the API Key to `~/.oiioii/config.json` with file permissions
207
+ `0600`. Pass `--base-url` only for an intentional backend override.
208
+ `OIIOII_API_KEY` remains available as a temporary process override. A legacy
209
+ `~/.oiioii/credentials.json` file, if present, is ignored.
210
+
211
+ Remove an existing backend override and return to the default embedded in the
212
+ current CLI build:
213
+
214
+ ```bash
215
+ oiioii auth login --api-key "oii_sk_..." --reset-base-url
216
+ ```
154
217
 
155
218
  Create a workspace using the injected API Key:
156
219
 
@@ -173,6 +236,26 @@ oiioii workspace set <workspace_id> --json
173
236
  oiioii workspace current --json
174
237
  ```
175
238
 
239
+ Rename the active workspace, or pass an explicit workspace ID:
240
+
241
+ ```bash
242
+ oiioii workspace rename --name "Renamed project" --json
243
+ oiioii workspace rename <workspace_id> --name "Renamed project" --json
244
+ ```
245
+
246
+ List assets in the active workspace and download a ready asset by its workspace
247
+ asset ID:
248
+
249
+ ```bash
250
+ oiioii workspace assets list --json
251
+ oiioii workspace assets download <asset_id> --output ./downloads --json
252
+ ```
253
+
254
+ `workspace assets download` accepts either the plain `assetId` or the
255
+ `hogi://asset/<assetId>` identity returned by the list command. It resolves that
256
+ identity to the asset's downloadable `uri`; loading, uploading, empty, failed,
257
+ or URI-less assets fail before the download request.
258
+
176
259
  Workspace resolution order is:
177
260
 
178
261
  1. Root `--workspace <id>` option.
@@ -308,7 +391,7 @@ oiioii audio generate --prompt "为画面生成氛围音" --image hogi://image/<
308
391
  ```
309
392
 
310
393
  Suno supports description mode, custom lyrics/style mode, and instrumental
311
- music. The supported variants are `chirp-v4-5` and `chirp-v5`:
394
+ music. The supported variants are `chirp-v4-5`, `chirp-v5`, and `chirp-v5-5`:
312
395
 
313
396
  ```bash
314
397
  oiioii audio generate --prompt "cinematic orchestral background music" --model suno --instrumental --json
@@ -546,12 +629,25 @@ The public commands accept the cached backend ID or local ID:
546
629
  oiioii task list
547
630
  oiioii task status <task_id>
548
631
  oiioii task wait <task_id> --timeout 300
632
+ oiioii task retry <local_task_id>
549
633
  ```
550
634
 
551
635
  For non-terminal tasks, `status` makes one authenticated backend query and
552
636
  `wait` polls the backend until a terminal state or `TASK_TIMEOUT`. Every query
553
637
  uses the workspace cached with the original submission.
554
638
 
639
+ A network error or timeout before the CLI receives a backend task ID has an
640
+ unknown submission outcome, so the local task remains `submitting` instead of
641
+ being marked `failed`. Run the `retry` command shown in the JSON error. It
642
+ reuses the original local task ID and saved submission request as the
643
+ idempotency key, allowing the backend to return the already-accepted task
644
+ without creating a duplicate generation.
645
+ The task stores only a one-way fingerprint of the submitting API Key; retry is
646
+ refused if the active credential has changed because backend idempotency is
647
+ scoped to the authenticated principal.
648
+ `task wait` fails immediately with `TASK_RETRY_REQUIRED` for this state instead
649
+ of waiting for a backend ID that only an explicit retry can recover.
650
+
555
651
  Existing preview bundles can be read with:
556
652
 
557
653
  ```bash
@@ -623,6 +719,7 @@ Stable error codes include:
623
719
  | `GENERATION_TIMEOUT` | Long-running request timed out |
624
720
  | `RECORD_NOT_FOUND` | Record/resource/bundle not found |
625
721
  | `TASK_NOT_FOUND` | Local task ID not found |
722
+ | `TASK_RETRY_REQUIRED` | Submission outcome is unknown; retry the saved task with its original idempotency key |
626
723
  | `TASK_TIMEOUT` | Local task did not become terminal before the wait deadline |
627
724
  | `QUOTA_EXCEEDED` | Insufficient points, subgroup quota, or backend rate limit exceeded |
628
725
  | `PAYLOAD_TOO_LARGE` | Upload exceeds the backend limit |
@@ -648,15 +745,43 @@ feature.started
648
745
  -> feature.completed | feature.failed
649
746
  ```
650
747
 
651
- This is CLI-side observability only. It does not collect or depend on logs from
652
- inside the Hogi backend.
653
-
654
- Recorded API events use the same `request_id` for correlation:
748
+ Logs remain local; backend response IDs link them to server logs without
749
+ downloading server logs. Recorded API events use the same `clientRequestId`
750
+ (also stored as the backwards-compatible `request_id`) for local correlation:
655
751
 
656
752
  ```text
657
753
  api.request -> api.response | api.error
658
754
  ```
659
755
 
756
+ | Field | Meaning |
757
+ | --- | --- |
758
+ | `id` | Unique local log record ID, not a backend chain ID. |
759
+ | `trace_id` | One CLI command, including all of its HTTP calls. |
760
+ | `clientRequestId` / legacy `request_id` | One local API call, pairing its start and result/error. |
761
+ | `logid` | Backend chain ID read from response header `x-logid`. |
762
+ | `requestId` | Current gateway request ID read from response header `x-request-id`; never generated by CLI. |
763
+ | `uid` | Server request identity returned in `x-hogi-log-uid`, or already verified for the command's endpoint/credential. Public routes can return `anonymous_user`. |
764
+ | `workspaceId` | Explicit business target, command workspace, or `x-hogi-log-workspace-id` from the response. |
765
+
766
+ CLI sends an optional `x-workspace-id` diagnostic hint. Authentication still uses
767
+ the API Key; neither a client-provided uid nor a workspace hint authorizes access.
768
+ Incoming response fields are optional, including when talking to older servers.
769
+ Malformed/missing diagnostics and logging failures do not reject requests.
770
+
771
+ Before the response arrives, `api.request` cannot know its backend/gateway IDs.
772
+ They appear on `api.response` or `api.error` after receiving headers. Network
773
+ failures without a response legitimately have neither. Follow `clientRequestId`
774
+ back to the start event and `trace_id` to other steps of the command. Command
775
+ steps do not inherit the last HTTP request's `logid` or `requestId`: concurrent
776
+ calls, polling and follow-up requests retain their own IDs. The REST envelope's
777
+ legacy `request_id` is another API-generated ID, not the gateway `requestId`.
778
+
779
+ Resource downloads retain IDs from the backend's 302 redirect and emit
780
+ `api.redirect` before following the CDN URL. Cross-origin redirects strip
781
+ credentials and workspace hints; CDN request IDs do not replace backend IDs.
782
+ Public resource reads retain their existing anonymous access/watermark behavior;
783
+ an anonymous response does not erase the command's previously verified identity.
784
+
660
785
  Feature traces cover workspace, image/video/audio generation, upload, records,
661
786
  inspection, preview, task commands, and their local storage steps. API boundary
662
787
  events cover:
@@ -664,10 +789,12 @@ events cover:
664
789
  - GenAI and Asset MCP calls.
665
790
  - Resource upload and download.
666
791
  - Generation-record lookup.
792
+ - Workspace REST, debug APIs, model catalog and authorization exchange.
793
+ - Each VOD token, commit and polling HTTP request (third-party byte upload is separate).
667
794
 
668
795
  Logs contain safe operational fields such as source, operation, HTTP method,
669
796
  path, status, duration, and selected non-sensitive metadata. They do not record
670
- request headers, API Keys, bearer tokens, prompts, request bodies, or response
797
+ arbitrary request headers, API Keys, bearer tokens, prompts, request bodies, or response
671
798
  bodies. Sensitive key names and recognizable secret values are redacted again
672
799
  inside the central logger before persistence.
673
800
 
@@ -690,6 +817,9 @@ oiioii logs list --category api --level error --limit 20 --json
690
817
  oiioii logs list --source hogi_mcp_client --since 2026-08-14T00:00:00Z --json
691
818
  oiioii logs list --feature image.text --json
692
819
  oiioii logs list --trace trace_<id> --json
820
+ oiioii logs list --logid <backend-logid> --json
821
+ oiioii logs list --request-id <gateway-requestId> --json
822
+ oiioii logs list --uid <uid> --workspace-id <workspaceId> --json
693
823
  ```
694
824
 
695
825
  Export logs as JSONL or JSON:
@@ -769,7 +899,10 @@ Environment variables:
769
899
  | `OIIOII_BASE_URL` | Override the backend URL at runtime |
770
900
  | `OIIOII_WORKSPACE_ID` | Override the active workspace |
771
901
  | `OIIOII_BUILD_ENV` | Select `production`, `test`, or `local` while building |
772
- | `OIIOII_BUILD_BASE_URL` | Override the URL embedded in a build |
902
+ | `OIIOII_PRODUCTION_BASE_URL` | Optional override for the production build's canonical backend URL |
903
+ | `OIIOII_TEST_BASE_URL` | URL embedded by the test build |
904
+ | `OIIOII_TEST_AUTHORIZATION_PAGE_URL` | Browser authorization page embedded by the test build |
905
+ | `OIIOII_BUILD_BASE_URL` | One-off URL override for a local/custom build; rejected by publish preparation |
773
906
  | `OIIOII_API_KEY` | Temporarily override the persisted API Key for the current process |
774
907
  | `OIIOII_E2E` | Explicit opt-in marker for credit-consuming E2E workflows |
775
908
  | `OIIOII_LOG_DISABLED` | Set to `1` to disable local logging, primarily for isolated tests |
@@ -793,13 +926,11 @@ files at present; running the normal test command does not consume GenAI credits
793
926
 
794
927
  Most recent local verification for this README update:
795
928
 
796
- - 45 test files passed.
797
- - 333 tests passed.
929
+ - 54 test files passed.
930
+ - 454 tests passed; 2 Windows-only installer tests were skipped on macOS.
798
931
  - `npm run typecheck` passed.
799
932
  - `npm run lint` passed.
800
- - Production, HOE test, and local builds passed; their embedded backend
801
- URLs were verified as `api.oiioii.ai`, `api-hoe.oiioii.tv`, and
802
- `localhost:4000` respectively.
933
+ - Production, injected test, and local build configuration passed.
803
934
 
804
935
  ## Project Structure
805
936
 
@@ -825,7 +956,17 @@ oiioii-cli/
825
956
  tests/
826
957
  unit/ Unit tests
827
958
  cli/ CLI subprocess integration tests
828
- .plan/release/ Standalone installer workflow/assets
959
+ scripts/
960
+ build-environment.mjs Loads environment-specific build configuration
961
+ build-test-runtime.mjs Creates the independent test static runtime
962
+ install.sh Production macOS/Linux npm installer
963
+ install.ps1 Production Windows npm installer
964
+ test/
965
+ install.sh Test macOS/Linux installer template
966
+ install.ps1 Test Windows installer template
967
+ dist/ Ignored generated installers and MD5 runtime
968
+ prepare-publish.mjs Environment-aware npm publish preparation
969
+ verify-release-version.mjs Release channel/version validation
829
970
  tsup.config.ts Environment-aware ESM bundling
830
971
  package.json
831
972
  ```