@oiioii/cli 0.1.1 → 0.1.6

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 (3) hide show
  1. package/README.md +100 -19
  2. package/dist/cli.js +43 -7627
  3. package/package.json +3 -1
package/README.md CHANGED
@@ -12,7 +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 |
15
+ | `auth login` | Browser authorization for terminal/Codex/WorkBuddy/Kimi/Claude Code/DeepSeek, or explicit API Key persistence | Implemented |
16
+ | `auth status` | Check configured authentication without exposing the API Key | Implemented |
17
+ | `auth logout` | Remove locally persisted authentication without exposing the API Key | Implemented |
16
18
  | `workspace create/set/current/rename` | Create, configure, inspect, and rename workspaces | Implemented |
17
19
  | `workspace assets list/download` | List workspace assets and download ready resources | Implemented |
18
20
  | `image text` | Text-to-image generation | Implemented |
@@ -44,7 +46,7 @@ Important current limitations:
44
46
  ## Requirements
45
47
 
46
48
  - Node.js 18.18 or newer when running from source or the npm package.
47
- - An existing Hogi MCP API Key.
49
+ - A Hogi account for browser authorization, or an existing Hogi MCP API Key.
48
50
  - A workspace ID for image/video/audio generation and resource upload. It can be
49
51
  created with `oiioii workspace create` or supplied from an existing project.
50
52
  - `npm` is the repository package manager.
@@ -123,20 +125,20 @@ rebuilt from the checkout.
123
125
 
124
126
  ## Build Environments
125
127
 
126
- The default backend URL is embedded into the generated bundle at build time.
128
+ The default backend URL and browser authorization page are embedded into the generated bundle at build time.
127
129
 
128
- | Build command | Environment | Embedded default backend |
129
- |---|---|---|
130
- | `npm run build:production` | production | `OIIOII_PRODUCTION_BASE_URL` from `.env` |
131
- | `npm run build:test` | test | `OIIOII_TEST_BASE_URL` from `.env` |
132
- | `npm run build:local` | local | `http://localhost:4000` |
130
+ | Build command | Environment | Embedded default backend | Authorization page |
131
+ |---|---|---|---|
132
+ | `npm run build:production` | production | `https://api.oiioii.ai` (optional `OIIOII_PRODUCTION_BASE_URL` override) | `https://oiioii.tv/auth/cli` |
133
+ | `npm run build:test` | test | `OIIOII_TEST_BASE_URL` from `.env` | Build-specific test authorization page |
134
+ | `npm run build:local` | local | `http://localhost:4000` | `http://localhost:3000/auth/cli` |
133
135
 
134
- Copy the environment template once, then use the environment-specific build
135
- entry points:
136
+ Use the environment-specific build entry points. Only test builds require a
137
+ URL in `.env`:
136
138
 
137
139
  ```bash
138
- cp .env.example .env
139
140
  npm run build:production
141
+ cp .env.example .env
140
142
  npm run build:test
141
143
  ```
142
144
 
@@ -168,8 +170,36 @@ The embedded URL is a fallback. Existing runtime overrides remain available:
168
170
 
169
171
  ## Authentication and Workspace
170
172
 
171
- Persist an existing MCP API Key. The CLI keeps the backend URL embedded for its
172
- build environment unless you explicitly override it:
173
+ Authorize through the Hogi browser page for the application that launched the CLI:
174
+
175
+ ```bash
176
+ oiioii auth login
177
+ oiioii auth login --codex
178
+ oiioii auth login --workbuddy
179
+ oiioii auth login --kimi
180
+ oiioii auth login --claude-code
181
+ oiioii auth login --deepseek
182
+ ```
183
+
184
+ Without an application option, `auth login` opens the browser authorization page
185
+ and asks the user to return to the terminal when authorization completes. The
186
+ application options label the authorization for the selected host. Codex and
187
+ WorkBuddy use verified macOS/Windows activation contracts; other targets print
188
+ the localized manual-return fallback when no verified OS activation contract is
189
+ available. The browser flow uses a loopback callback, state validation, and PKCE. It creates
190
+ an API Key through the current build's backend, stores it locally, and requests
191
+ that macOS or Windows return to the selected application after the hosted success
192
+ page acknowledges it is ready, with a bounded fallback if that acknowledgement is blocked. If the browser or app
193
+ cannot be opened, the CLI prints a localized manual fallback. Use `--no-browser`
194
+ to print the authorization URL for a headless environment.
195
+
196
+ Browser authorization only runs against the backend paired with the current CLI
197
+ build. Remove `OIIOII_BASE_URL` and use `--reset-base-url` when an older persisted
198
+ override is present. For a custom backend, use the explicit `--api-key` mode.
199
+
200
+ You can still persist an existing MCP API Key only through the explicit
201
+ `--api-key` mode. The CLI keeps the backend URL
202
+ embedded for its build environment unless you explicitly override it:
173
203
 
174
204
  ```bash
175
205
  oiioii auth login --api-key "oii_sk_..."
@@ -180,6 +210,23 @@ The CLI writes the API Key to `~/.oiioii/config.json` with file permissions
180
210
  `OIIOII_API_KEY` remains available as a temporary process override. A legacy
181
211
  `~/.oiioii/credentials.json` file, if present, is ignored.
182
212
 
213
+ Check whether the current process is authenticated, or remove the locally
214
+ persisted API Key:
215
+
216
+ ```bash
217
+ oiioii auth status
218
+ oiioii auth logout
219
+ ```
220
+
221
+ Neither command prints the API Key. `auth status` exits with status `0` when an
222
+ API Key is configured for the current process and `1` when unauthenticated. It identifies only whether
223
+ the credential comes from local configuration or `OIIOII_API_KEY`. `auth logout`
224
+ is idempotent and preserves unrelated settings such as the Base URL and active
225
+ workspace. It cannot unset an inherited `OIIOII_API_KEY`; when that override is
226
+ present, the command reports that effective authentication remains active. If
227
+ the local config is unreadable, logout removes that unusable file so credential
228
+ fragments cannot remain on disk.
229
+
183
230
  Remove an existing backend override and return to the default embedded in the
184
231
  current CLI build:
185
232
 
@@ -717,15 +764,43 @@ feature.started
717
764
  -> feature.completed | feature.failed
718
765
  ```
719
766
 
720
- This is CLI-side observability only. It does not collect or depend on logs from
721
- inside the Hogi backend.
722
-
723
- Recorded API events use the same `request_id` for correlation:
767
+ Logs remain local; backend response IDs link them to server logs without
768
+ downloading server logs. Recorded API events use the same `clientRequestId`
769
+ (also stored as the backwards-compatible `request_id`) for local correlation:
724
770
 
725
771
  ```text
726
772
  api.request -> api.response | api.error
727
773
  ```
728
774
 
775
+ | Field | Meaning |
776
+ | --- | --- |
777
+ | `id` | Unique local log record ID, not a backend chain ID. |
778
+ | `trace_id` | One CLI command, including all of its HTTP calls. |
779
+ | `clientRequestId` / legacy `request_id` | One local API call, pairing its start and result/error. |
780
+ | `logid` | Backend chain ID read from response header `x-logid`. |
781
+ | `requestId` | Current gateway request ID read from response header `x-request-id`; never generated by CLI. |
782
+ | `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`. |
783
+ | `workspaceId` | Explicit business target, command workspace, or `x-hogi-log-workspace-id` from the response. |
784
+
785
+ CLI sends an optional `x-workspace-id` diagnostic hint. Authentication still uses
786
+ the API Key; neither a client-provided uid nor a workspace hint authorizes access.
787
+ Incoming response fields are optional, including when talking to older servers.
788
+ Malformed/missing diagnostics and logging failures do not reject requests.
789
+
790
+ Before the response arrives, `api.request` cannot know its backend/gateway IDs.
791
+ They appear on `api.response` or `api.error` after receiving headers. Network
792
+ failures without a response legitimately have neither. Follow `clientRequestId`
793
+ back to the start event and `trace_id` to other steps of the command. Command
794
+ steps do not inherit the last HTTP request's `logid` or `requestId`: concurrent
795
+ calls, polling and follow-up requests retain their own IDs. The REST envelope's
796
+ legacy `request_id` is another API-generated ID, not the gateway `requestId`.
797
+
798
+ Resource downloads retain IDs from the backend's 302 redirect and emit
799
+ `api.redirect` before following the CDN URL. Cross-origin redirects strip
800
+ credentials and workspace hints; CDN request IDs do not replace backend IDs.
801
+ Public resource reads retain their existing anonymous access/watermark behavior;
802
+ an anonymous response does not erase the command's previously verified identity.
803
+
729
804
  Feature traces cover workspace, image/video/audio generation, upload, records,
730
805
  inspection, preview, task commands, and their local storage steps. API boundary
731
806
  events cover:
@@ -733,10 +808,12 @@ events cover:
733
808
  - GenAI and Asset MCP calls.
734
809
  - Resource upload and download.
735
810
  - Generation-record lookup.
811
+ - Workspace REST, debug APIs, model catalog and authorization exchange.
812
+ - Each VOD token, commit and polling HTTP request (third-party byte upload is separate).
736
813
 
737
814
  Logs contain safe operational fields such as source, operation, HTTP method,
738
815
  path, status, duration, and selected non-sensitive metadata. They do not record
739
- request headers, API Keys, bearer tokens, prompts, request bodies, or response
816
+ arbitrary request headers, API Keys, bearer tokens, prompts, request bodies, or response
740
817
  bodies. Sensitive key names and recognizable secret values are redacted again
741
818
  inside the central logger before persistence.
742
819
 
@@ -759,6 +836,9 @@ oiioii logs list --category api --level error --limit 20 --json
759
836
  oiioii logs list --source hogi_mcp_client --since 2026-08-14T00:00:00Z --json
760
837
  oiioii logs list --feature image.text --json
761
838
  oiioii logs list --trace trace_<id> --json
839
+ oiioii logs list --logid <backend-logid> --json
840
+ oiioii logs list --request-id <gateway-requestId> --json
841
+ oiioii logs list --uid <uid> --workspace-id <workspaceId> --json
762
842
  ```
763
843
 
764
844
  Export logs as JSONL or JSON:
@@ -838,8 +918,9 @@ Environment variables:
838
918
  | `OIIOII_BASE_URL` | Override the backend URL at runtime |
839
919
  | `OIIOII_WORKSPACE_ID` | Override the active workspace |
840
920
  | `OIIOII_BUILD_ENV` | Select `production`, `test`, or `local` while building |
841
- | `OIIOII_PRODUCTION_BASE_URL` | URL embedded by the production build |
921
+ | `OIIOII_PRODUCTION_BASE_URL` | Optional override for the production build's canonical backend URL |
842
922
  | `OIIOII_TEST_BASE_URL` | URL embedded by the test build |
923
+ | `OIIOII_TEST_AUTHORIZATION_PAGE_URL` | Browser authorization page embedded by the test build |
843
924
  | `OIIOII_BUILD_BASE_URL` | One-off URL override for a local/custom build; rejected by publish preparation |
844
925
  | `OIIOII_API_KEY` | Temporarily override the persisted API Key for the current process |
845
926
  | `OIIOII_E2E` | Explicit opt-in marker for credit-consuming E2E workflows |