@orth/cli 0.3.1 → 0.4.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.
Files changed (80) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +113 -109
  3. package/dist/analytics.d.ts +36 -8
  4. package/dist/analytics.js +247 -47
  5. package/dist/api.d.ts +28 -2
  6. package/dist/api.js +67 -13
  7. package/dist/command-actions.d.ts +10 -0
  8. package/dist/command-actions.js +42 -0
  9. package/dist/commands/account.d.ts +9 -1
  10. package/dist/commands/account.js +26 -10
  11. package/dist/commands/api.d.ts +3 -0
  12. package/dist/commands/api.js +104 -114
  13. package/dist/commands/auth.d.ts +3 -1
  14. package/dist/commands/auth.js +53 -9
  15. package/dist/commands/onboard/flow.d.ts +22 -0
  16. package/dist/commands/onboard/flow.js +155 -0
  17. package/dist/commands/onboard/guide.d.ts +8 -0
  18. package/dist/commands/onboard/guide.js +73 -0
  19. package/dist/commands/onboard/listing.d.ts +18 -0
  20. package/dist/commands/onboard/listing.js +166 -0
  21. package/dist/commands/onboard/progress.d.ts +44 -0
  22. package/dist/commands/onboard/progress.js +108 -0
  23. package/dist/commands/onboard/register.d.ts +2 -0
  24. package/dist/commands/onboard/register.js +261 -0
  25. package/dist/commands/onboard/requests.d.ts +24 -0
  26. package/dist/commands/onboard/requests.js +96 -0
  27. package/dist/commands/onboard/review.d.ts +31 -0
  28. package/dist/commands/onboard/review.js +228 -0
  29. package/dist/commands/onboard/setup.d.ts +68 -0
  30. package/dist/commands/onboard/setup.js +215 -0
  31. package/dist/commands/onboard/shared.d.ts +41 -0
  32. package/dist/commands/onboard/shared.js +97 -0
  33. package/dist/commands/onboard/tools.d.ts +19 -0
  34. package/dist/commands/onboard/tools.js +104 -0
  35. package/dist/commands/org.d.ts +21 -0
  36. package/dist/commands/org.js +126 -0
  37. package/dist/commands/payouts.d.ts +44 -0
  38. package/dist/commands/payouts.js +125 -0
  39. package/dist/commands/run.d.ts +1 -1
  40. package/dist/commands/run.js +18 -26
  41. package/dist/commands/search.d.ts +8 -1
  42. package/dist/commands/search.js +26 -4
  43. package/dist/commands/skills/browse.d.ts +15 -0
  44. package/dist/commands/skills/browse.js +194 -0
  45. package/dist/commands/skills/create.d.ts +5 -0
  46. package/dist/commands/skills/create.js +62 -0
  47. package/dist/commands/skills/init.d.ts +4 -0
  48. package/dist/commands/skills/init.js +123 -0
  49. package/dist/commands/skills/install.d.ts +6 -0
  50. package/dist/commands/skills/install.js +191 -0
  51. package/dist/commands/skills/local-files.d.ts +15 -0
  52. package/dist/commands/skills/local-files.js +110 -0
  53. package/dist/commands/skills/register.d.ts +2 -0
  54. package/dist/commands/skills/register.js +130 -0
  55. package/dist/commands/skills/shared.d.ts +43 -0
  56. package/dist/commands/skills/shared.js +69 -0
  57. package/dist/commands/skills/upload.d.ts +9 -0
  58. package/dist/commands/skills/upload.js +223 -0
  59. package/dist/commands/skills/verification.d.ts +5 -0
  60. package/dist/commands/skills/verification.js +74 -0
  61. package/dist/commands/telemetry.d.ts +3 -0
  62. package/dist/commands/telemetry.js +38 -0
  63. package/dist/config.d.ts +48 -1
  64. package/dist/config.js +99 -3
  65. package/dist/http.d.ts +15 -0
  66. package/dist/http.js +41 -0
  67. package/dist/index.js +131 -162
  68. package/dist/organizations.d.ts +14 -0
  69. package/dist/organizations.js +77 -0
  70. package/dist/urls.d.ts +3 -0
  71. package/dist/urls.js +34 -0
  72. package/dist/utils.d.ts +20 -0
  73. package/dist/utils.js +112 -0
  74. package/dist/version.d.ts +5 -0
  75. package/dist/version.js +21 -0
  76. package/dist/x402.d.ts +7 -0
  77. package/dist/x402.js +27 -0
  78. package/package.json +23 -22
  79. package/dist/commands/skills.d.ts +0 -66
  80. package/dist/commands/skills.js +0 -821
package/CHANGELOG.md ADDED
@@ -0,0 +1,41 @@
1
+ # Changelog
2
+
3
+ ## 0.4.0
4
+
5
+ The CLI is now built and published from Orthogonal's monorepo. Upgrade with
6
+ `npm install -g @orth/cli@latest`; your saved login carries over.
7
+
8
+ ### Changed
9
+
10
+ - Calls go to `https://www.orthogonal.com/v1`, and `orth login` opens
11
+ `https://www.orthogonal.com` (was `api.orthogonal.com` and `orthogonal.sh`).
12
+ - `orth run` with `-b`/`-d` and no `-X` sends a POST, as curl does. An explicit
13
+ `-X` always wins; without a body the default is still GET.
14
+ - `orth run` reads the body from stdin only with `-b -`. Piping without it no
15
+ longer works, and a command whose stdin stays open no longer hangs.
16
+ - `orth api show <unknown-api>` fails with exit code 1.
17
+ - Requires Node.js 22.12 or later.
18
+
19
+ ### Added
20
+
21
+ - `--json` on `whoami`, `balance`, `usage`, `api list`, `api show`, `api search`,
22
+ `search`, `skills list`, `skills search` and `skills show`.
23
+ - `orth login` chooses which team the new key belongs to, and `orth team` /
24
+ `orth team use` switch between the teams you signed in to.
25
+ - For API providers: `orth api-onboarding` (list your API; start with
26
+ `orth api-onboarding guide`), `orth org`, `orth payouts`.
27
+ - `orth telemetry enable|disable|status`.
28
+ - `orth --help` shows examples.
29
+
30
+ ### Fixed
31
+
32
+ - `orth skills add` and `orth skills update` never write a skill's files
33
+ outside its folder.
34
+ - `orth api show <api> <path> --x402-full` prints the x402 v2 challenge from
35
+ the `PAYMENT-REQUIRED` header.
36
+ - `orth --version` and telemetry report the real CLI version.
37
+ - `orth run --raw` keeps stdout pure JSON; the cost goes to stderr.
38
+
39
+ ## 0.3.1 and earlier
40
+
41
+ Released from the orthogonal-sh/cli repository.
package/README.md CHANGED
@@ -1,78 +1,18 @@
1
- <div align="center">
2
-
3
1
  # Orthogonal CLI
4
2
 
5
- **Command-line tool for the [Orthogonal](https://orthogonal.com) platform — discover and call APIs and agent skills from your terminal.**
6
-
7
- Search for APIs in natural language, call them with a single command, and pay per request from your Orthogonal credit balance.
8
-
9
- [![npm version](https://img.shields.io/npm/v/@orth/cli.svg?logo=npm&color=cb3837)](https://www.npmjs.com/package/@orth/cli)
10
- [![npm downloads](https://img.shields.io/npm/dm/@orth/cli.svg?color=cb3837)](https://www.npmjs.com/package/@orth/cli)
11
- [![node](https://img.shields.io/node/v/@orth/cli.svg?logo=node.js&color=339933)](https://nodejs.org)
12
- [![license](https://img.shields.io/npm/l/@orth/cli.svg?color=blue)](./LICENSE)
13
-
14
- ![Demo](https://raw.githubusercontent.com/orthogonal-sh/cli/main/demos/demo.gif)
15
-
16
- </div>
17
-
18
- ## Table of Contents
19
-
20
- - [Why Orthogonal](#why-orthogonal)
21
- - [Installation](#installation)
22
- - [Quick Start](#quick-start)
23
- - [Authentication](#authentication)
24
- - [Calling APIs](#calling-apis)
25
- - [Agent Skills](#agent-skills)
26
- - [Account & Usage](#account--usage)
27
- - [Command Reference](#command-reference)
28
- - [Configuration](#configuration)
29
- - [Programmatic Use](#programmatic-use)
30
- - [Development](#development)
31
- - [License](#license)
32
-
33
- ## Why Orthogonal
34
-
35
- Orthogonal puts a catalog of APIs and agent skills behind one account and one balance. The CLI lets you — and your AI agents — find and call them without leaving the terminal:
36
-
37
- - **Discover** APIs and skills with natural-language search.
38
- - **Call** any endpoint with one command — auth, billing, and routing are handled for you.
39
- - **Pay per use** from a single credit balance instead of juggling dozens of provider subscriptions.
40
- - **Script it** — clean JSON output (`--raw`) pipes straight into `jq` and shell pipelines.
41
-
42
- ## Installation
43
-
44
- Requires **Node.js 18+**.
3
+ `orth` gives you and your AI agents every API and skill on
4
+ [Orthogonal](https://www.orthogonal.com) from the terminal: search the catalog,
5
+ call any endpoint with one key, generate integration code, install skills, and
6
+ list your own API.
45
7
 
46
8
  ```bash
47
- # Install globally
48
9
  npm install -g @orth/cli
49
-
50
- # …or run without installing
51
- npx @orth/cli <command>
52
- ```
53
-
54
- Verify the install:
55
-
56
- ```bash
57
- orth --version
58
- ```
59
-
60
- ## Quick Start
61
-
62
- ```bash
63
- # 1. Authenticate (get a key at https://orthogonal.com)
64
- orth login --key orth_live_your_key
65
-
66
- # 2. Find an API in plain English
10
+ orth login
67
11
  orth api search "search the web"
68
-
69
- # 3. Call an endpoint
70
- orth run tavily /search -q query="latest AI news"
71
-
72
- # 4. See what it cost
73
- orth balance
74
12
  ```
75
13
 
14
+ Requires Node.js 22.12 or later.
15
+
76
16
  ## Authentication
77
17
 
78
18
  ```bash
@@ -82,14 +22,15 @@ orth login --key orth_live_your_key
82
22
  # …or use an environment variable (takes precedence — great for CI)
83
23
  export ORTHOGONAL_API_KEY=orth_live_your_key
84
24
 
85
- # Show the current identity
25
+ # Show the current identity (--json for scripts and agents)
86
26
  orth whoami
87
27
 
88
28
  # Remove the stored key
89
29
  orth logout
90
30
  ```
91
31
 
92
- Get an API key from your [Orthogonal dashboard](https://orthogonal.com/dashboard).
32
+ `orth login` makes a key in your browser. To copy one yourself, open
33
+ [Account → Keys](https://www.orthogonal.com/account/keys).
93
34
 
94
35
  ## Calling APIs
95
36
 
@@ -127,7 +68,7 @@ orth run some-api /v1/generate --dry-run
127
68
  # Save a binary response (image, audio, PDF, …) to a file
128
69
  orth run image-api /v1/render -q prompt="sunset" -o out.png
129
70
 
130
- # Machine-readable output for pipelines
71
+ # Machine-readable output for pipelines (only the response on stdout; the cost goes to stderr)
131
72
  orth run tavily /search -q query="orthogonal" --raw | jq '.results[0].url'
132
73
  ```
133
74
 
@@ -176,23 +117,94 @@ orth skills request <input> # request a skill by URL or description
176
117
  ## Account & Usage
177
118
 
178
119
  ```bash
179
- orth balance # current credit balance
180
- orth usage # recent API usage
120
+ orth balance # credit balance, and where to add credits
121
+ orth usage # recent paid calls and the total spent
122
+ orth usage -l 50 -d 7 # the last 50 calls of the past 7 days
123
+ orth usage --offset 50 # older calls, after the 50 most recent
181
124
  ```
182
125
 
126
+ `balance` and `usage` read whoever the key bills: your own account for a
127
+ personal key, the organization's shared credits for an organization key. Add
128
+ `--json` to either for machine-readable output.
129
+
130
+ ## Payouts (API providers)
131
+
132
+ ```bash
133
+ orth payouts # payout status, what you are owed, and what you earned
134
+ orth payouts history # payouts made, newest first
135
+ ```
136
+
137
+ For your organization's admins; add `--json` for raw output. `orth payouts`
138
+ shows lifetime earnings, earnings this month and paid calls. With several
139
+ selling organizations, the first command asks which one and remembers it
140
+ (`orth org use` changes it, `--org <name>` picks one for a single command). Stripe setup itself happens in the browser, at the link `orth payouts` prints.
141
+
142
+ ## List your API (API providers)
143
+
144
+ ```bash
145
+ orth api-onboarding new https://docs.example.com --name "Weather" --use-case "Forecasts for agents" \
146
+ --more-docs https://docs.example.com/auth
147
+ orth api-onboarding start # the Agent sets it up in the background
148
+ orth api-onboarding status --watch # where it is, and the one command to run next
149
+ orth api-onboarding guide # every step, for you and your AI agent
150
+ ```
151
+
152
+ Every `api-onboarding` command takes `--json`, and the ones that act for an
153
+ organization take `--org <name>`. Requests are named by their API name.
154
+ `status` always prints the next command; with `--json`, an agent runs
155
+ `orth <nextStep.command>`: the Agent decides every open choice itself and asks
156
+ nothing, so only adding the key and submitting wait for you. With `--json`,
157
+ `--watch` prints the status once, so an agent checks again later. Only you add
158
+ your API key, with `orth api-onboarding key`.
159
+
160
+ To do the setup with your own agent, `orth api-onboarding tools --json` prints
161
+ the guide and every tool's schema, and this runs one tool:
162
+
163
+ ```bash
164
+ orth api-onboarding call get_setup --request "Weather" --input '{}'
165
+ ```
166
+
167
+ `--call-id <uuid>` makes a retried call repeat no write.
168
+
183
169
  ## Command Reference
184
170
 
185
- | Command | Description |
186
- | --- | --- |
187
- | `orth login` / `logout` / `whoami` | Manage authentication |
188
- | `orth balance` / `usage` | Credit balance and recent usage |
189
- | `orth api list` | List available APIs |
190
- | `orth api search <query>` | Natural-language API search |
191
- | `orth api show <slug> [path]` | Show endpoints / endpoint details (alias: `info`) |
192
- | `orth api run <slug> <path>` | Call an endpoint |
193
- | `orth api code <slug> <path>` | Generate integration code |
194
- | `orth api request <docsUrl>` | Request an API to be added |
195
- | `orth skills …` | Browse, install, author, and publish skills |
171
+ | Command | Description |
172
+ | ---------------------------------------- | -------------------------------------------------------------------------------- |
173
+ | `orth login` / `logout` / `whoami` | Manage authentication (`whoami --json`) |
174
+ | `orth balance` | Credit balance and where to add credits (`--json`) |
175
+ | `orth usage` | Recent paid calls and total spent (`-l`, `-d`, `--offset`, `--json`) |
176
+ | `orth api list` | List available APIs |
177
+ | `orth api search <query>` | Natural-language API search |
178
+ | `orth api show <slug> [path]` | Show endpoints / endpoint details (alias: `info`) |
179
+ | `orth api run <slug> <path>` | Call an endpoint |
180
+ | `orth api code <slug> <path>` | Generate integration code |
181
+ | `orth api request <docsUrl>` | Request an API to be added |
182
+ | `orth org [use [name]]` | Organizations you sell APIs with; `use` sets the default for onboarding, payouts |
183
+ | `orth team [use [name]]` | Teams you are signed in to (one key each, from `orth login`); `use` switches |
184
+ | `orth api-onboarding [list]` | Your API onboarding requests |
185
+ | `orth api-onboarding new <docsUrl>` | Request listing your API (`--name`, `--use-case`, `--website`, `--more-docs`) |
186
+ | `orth api-onboarding start [api]` | Start the Agent in the background (`-m` replies) |
187
+ | `orth api-onboarding status [api]` | Progress, approvals, next step (`--watch`) |
188
+ | `orth api-onboarding stop [api]` | Stop the Agent's background work |
189
+ | `orth api-onboarding setup [api]` | The setup to review: base URL, key, endpoints |
190
+ | `orth api-onboarding base-url <url>` | Set the address the API is served from |
191
+ | `orth api-onboarding price <ep> <usd>` | Set a price per call (`free` lists it at $0) |
192
+ | `orth api-onboarding leave-out <ep>` | Keep an endpoint out of the listing |
193
+ | `orth api-onboarding confirm [api]` | Review the setup, then confirm it |
194
+ | `orth api-onboarding approve [api]` | Let the Agent run the calls it asks for |
195
+ | `orth api-onboarding deny [api]` | Refuse them (`-m` says why) |
196
+ | `orth api-onboarding key [api]` | Add the API key (typed hidden, or piped in) |
197
+ | `orth api-onboarding test [api]` | One real call per endpoint, writes included |
198
+ | `orth api-onboarding submit [api]` | Send it for Orthogonal's review |
199
+ | `orth api-onboarding withdraw [api]` | Take a submission back before review |
200
+ | `orth api-onboarding resubmit [api]` | Fix a declined request and send it again |
201
+ | `orth api-onboarding cancel [api]` | Cancel a request before its setup starts |
202
+ | `orth api-onboarding guide` | How it works, step by step (for you and agents) |
203
+ | `orth api-onboarding tools [name]` | Onboarding tools for your own agent / one's schema (`--json`: all) |
204
+ | `orth api-onboarding call <tool>` | Run an onboarding tool (`--request <api>`, `--input`, `--approve`, `--call-id`) |
205
+ | `orth payouts [history]` | Payout status, owed and earnings, or the payouts made (`--org`, `--json`) |
206
+ | `orth skills …` | Browse, install, author, and publish skills |
207
+ | `orth telemetry enable\|disable\|status` | Turn usage telemetry on or off, or show it |
196
208
 
197
209
  **Shorthand aliases** for the most common commands:
198
210
 
@@ -206,24 +218,31 @@ Run `orth <command> --help` for the full options on any command.
206
218
 
207
219
  ### `run` options
208
220
 
209
- | Flag | Description |
210
- | --- | --- |
211
- | `-X, --method <method>` | HTTP method (default `GET`) |
212
- | `-q, --query <k=v...>` | Query params (repeatable, or one `a=1&b=2` string) |
213
- | `-b, --body <json>` / `-d, --data <json>` | JSON request body |
214
- | `-o, --output <file>` | Save the response to a file (auto-detects binary) |
215
- | `--raw` | Print raw JSON (ideal for piping) |
216
- | `--dry-run` | Estimate the cost without executing |
221
+ | Flag | Description |
222
+ | ----------------------------------------- | -------------------------------------------------- |
223
+ | `-X, --method <method>` | HTTP method (default `GET`) |
224
+ | `-q, --query <k=v...>` | Query params (repeatable, or one `a=1&b=2` string) |
225
+ | `-b, --body <json>` / `-d, --data <json>` | JSON request body |
226
+ | `-o, --output <file>` | Save the response to a file (auto-detects binary) |
227
+ | `--raw` | Print only the response JSON (cost on stderr) |
228
+ | `--dry-run` | Estimate the cost without executing |
217
229
 
218
230
  ## Configuration
219
231
 
220
- | Environment variable | Purpose |
221
- | --- | --- |
232
+ | Environment variable | Purpose |
233
+ | -------------------- | ---------------------------------------------------- |
222
234
  | `ORTHOGONAL_API_KEY` | API key; overrides the stored credential (use in CI) |
223
- | `ORTH_API_URL` | Override the API base URL (advanced) |
235
+ | `ORTH_API_URL` | Override the API base URL (advanced) |
236
+ | `ORTH_WEB_URL` | Override the website used for browser login |
224
237
 
225
238
  Credentials from `orth login` are stored in your OS user-config directory (managed automatically); use `orth logout` to remove them.
226
239
 
240
+ ## Telemetry
241
+
242
+ When you are logged in, each command sends one usage event when it ends: the command name, catalog identifiers (API slug, skill slug, tool), exit code, duration, CLI version, OS and Node version, linked to your API key and a random install id. `orth login` also sends one event when it starts, before you have a key, with only the install id and CLI version. Search queries, file paths, request bodies and responses are never sent; other arguments are recorded only as present. The first event prints a one-time notice.
243
+
244
+ Turn it off with `orth telemetry disable`, `ORTH_TELEMETRY_DISABLED=1` or `DO_NOT_TRACK=1`; `orth telemetry status` shows whether it is on. `ORTH_TELEMETRY_DEBUG=1` prints each event to stderr instead of sending it.
245
+
227
246
  ## Programmatic Use
228
247
 
229
248
  Building an application instead of scripting the terminal? Use one of the official SDKs:
@@ -231,21 +250,6 @@ Building an application instead of scripting the terminal? Use one of the offici
231
250
  - **[`@orth/sdk`](https://www.npmjs.com/package/@orth/sdk)** — TypeScript/JavaScript (`npm install @orth/sdk`)
232
251
  - **[`orth`](https://pypi.org/project/orth/)** — Python (`pip install orth`)
233
252
 
234
- ## Development
235
-
236
- ```bash
237
- git clone https://github.com/orthogonal-sh/cli.git
238
- cd cli
239
- npm install
240
-
241
- npm run build # compile TypeScript to dist/
242
- npm run dev # compile in watch mode
243
- npm test # run the test suite (vitest)
244
- npm start # run the built CLI
245
- ```
246
-
247
- Contributions are welcome — please open an issue or a pull request.
248
-
249
253
  ## License
250
254
 
251
255
  [MIT](./LICENSE) © Orthogonal
@@ -1,11 +1,39 @@
1
- /** Preserve the server correlation ID when search errors become CLI telemetry. */
2
- export declare function getSearchFailureResponse(error: unknown): {
3
- searchEventId?: string | undefined;
1
+ /** What a search's telemetry carries: success and the server's correlation ID. */
2
+ export interface SearchSummary {
4
3
  success: boolean;
5
- error: string;
6
- };
4
+ searchEventId?: string;
5
+ }
6
+ type EventArgs = Record<string, string | undefined>;
7
+ /** Why telemetry is off, or undefined when it is on. */
8
+ export declare function telemetryDisabledReason(): "DO_NOT_TRACK" | "ORTH_TELEMETRY_DISABLED" | "config" | undefined;
9
+ /** Preserve the server correlation ID when search errors become CLI telemetry. */
10
+ export declare function getSearchFailureResponse(error: unknown): SearchSummary;
11
+ /** Reduce a search response to success and correlation ID; never the body. */
12
+ export declare function summarizeSearchResponse(response: unknown): SearchSummary;
13
+ /**
14
+ * Remember the running command for its end-of-command event. Sends nothing;
15
+ * the asyncAction wrapper in command-actions.ts calls finishCommand when it
16
+ * ends.
17
+ */
18
+ export declare function trackEvent(command: string, args?: EventArgs, response?: unknown): void;
19
+ /** Queue an event raised mid-command; it goes out with the command's own. */
20
+ export declare function queueEvent(command: string, args?: EventArgs): void;
21
+ /** Start timing a command; a direct process.exit still reports it. */
22
+ export declare function beginCommand(): void;
23
+ /**
24
+ * `orth login` has started, before any key exists: one key-less event with
25
+ * only the install id and CLI version, sent at once (the login waits for the
26
+ * browser meanwhile). Never throws, never prints errors.
27
+ */
28
+ export declare function sendLoginStarted(): void;
29
+ /**
30
+ * Send the command's event with its exit code and duration, waiting at most
31
+ * SEND_TIMEOUT_MS. Never throws, never prints errors.
32
+ */
33
+ export declare function finishCommand(exitCode: number): Promise<void>;
7
34
  /**
8
- * Fire-and-forget analytics event for CLI usage tracking.
9
- * Never blocks, never throws, never shows errors to the user.
35
+ * process.exit mid-command: hand unsent events to a detached child so this
36
+ * process exits at once.
10
37
  */
11
- export declare function trackEvent(command: string, args?: Record<string, string | undefined>, response?: unknown): void;
38
+ export declare function flushOnExit(code: number): void;
39
+ export {};