@orth/cli 0.3.0 → 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.
- package/CHANGELOG.md +41 -0
- package/README.md +113 -109
- package/dist/analytics.d.ts +37 -3
- package/dist/analytics.js +253 -39
- package/dist/api.d.ts +28 -2
- package/dist/api.js +67 -13
- package/dist/command-actions.d.ts +10 -0
- package/dist/command-actions.js +42 -0
- package/dist/commands/account.d.ts +9 -1
- package/dist/commands/account.js +26 -10
- package/dist/commands/api.d.ts +3 -0
- package/dist/commands/api.js +104 -114
- package/dist/commands/auth.d.ts +3 -1
- package/dist/commands/auth.js +53 -9
- package/dist/commands/onboard/flow.d.ts +22 -0
- package/dist/commands/onboard/flow.js +155 -0
- package/dist/commands/onboard/guide.d.ts +8 -0
- package/dist/commands/onboard/guide.js +73 -0
- package/dist/commands/onboard/listing.d.ts +18 -0
- package/dist/commands/onboard/listing.js +166 -0
- package/dist/commands/onboard/progress.d.ts +44 -0
- package/dist/commands/onboard/progress.js +108 -0
- package/dist/commands/onboard/register.d.ts +2 -0
- package/dist/commands/onboard/register.js +261 -0
- package/dist/commands/onboard/requests.d.ts +24 -0
- package/dist/commands/onboard/requests.js +96 -0
- package/dist/commands/onboard/review.d.ts +31 -0
- package/dist/commands/onboard/review.js +228 -0
- package/dist/commands/onboard/setup.d.ts +68 -0
- package/dist/commands/onboard/setup.js +215 -0
- package/dist/commands/onboard/shared.d.ts +41 -0
- package/dist/commands/onboard/shared.js +97 -0
- package/dist/commands/onboard/tools.d.ts +19 -0
- package/dist/commands/onboard/tools.js +104 -0
- package/dist/commands/org.d.ts +21 -0
- package/dist/commands/org.js +126 -0
- package/dist/commands/payouts.d.ts +44 -0
- package/dist/commands/payouts.js +125 -0
- package/dist/commands/run.d.ts +1 -1
- package/dist/commands/run.js +18 -26
- package/dist/commands/search.d.ts +8 -1
- package/dist/commands/search.js +26 -4
- package/dist/commands/skills/browse.d.ts +15 -0
- package/dist/commands/skills/browse.js +194 -0
- package/dist/commands/skills/create.d.ts +5 -0
- package/dist/commands/skills/create.js +62 -0
- package/dist/commands/skills/init.d.ts +4 -0
- package/dist/commands/skills/init.js +123 -0
- package/dist/commands/skills/install.d.ts +6 -0
- package/dist/commands/skills/install.js +191 -0
- package/dist/commands/skills/local-files.d.ts +15 -0
- package/dist/commands/skills/local-files.js +110 -0
- package/dist/commands/skills/register.d.ts +2 -0
- package/dist/commands/skills/register.js +130 -0
- package/dist/commands/skills/shared.d.ts +43 -0
- package/dist/commands/skills/shared.js +69 -0
- package/dist/commands/skills/upload.d.ts +9 -0
- package/dist/commands/skills/upload.js +223 -0
- package/dist/commands/skills/verification.d.ts +5 -0
- package/dist/commands/skills/verification.js +74 -0
- package/dist/commands/telemetry.d.ts +3 -0
- package/dist/commands/telemetry.js +38 -0
- package/dist/config.d.ts +48 -1
- package/dist/config.js +99 -3
- package/dist/http.d.ts +15 -0
- package/dist/http.js +41 -0
- package/dist/index.js +131 -165
- package/dist/organizations.d.ts +14 -0
- package/dist/organizations.js +77 -0
- package/dist/urls.d.ts +3 -0
- package/dist/urls.js +34 -0
- package/dist/utils.d.ts +20 -0
- package/dist/utils.js +112 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.js +21 -0
- package/dist/x402.d.ts +7 -0
- package/dist/x402.js +27 -0
- package/package.json +23 -22
- package/dist/commands/skills.d.ts +0 -66
- package/dist/commands/skills.js +0 -821
package/dist/index.js
CHANGED
|
@@ -8,41 +8,21 @@ const api_js_1 = require("./commands/api.js");
|
|
|
8
8
|
const auth_js_1 = require("./commands/auth.js");
|
|
9
9
|
const account_js_1 = require("./commands/account.js");
|
|
10
10
|
const code_js_1 = require("./commands/code.js");
|
|
11
|
-
const skills_js_1 = require("./commands/skills.js");
|
|
12
11
|
const apiRequest_js_1 = require("./commands/apiRequest.js");
|
|
12
|
+
const register_js_1 = require("./commands/onboard/register.js");
|
|
13
|
+
const register_js_2 = require("./commands/skills/register.js");
|
|
14
|
+
const org_js_1 = require("./commands/org.js");
|
|
15
|
+
const payouts_js_1 = require("./commands/payouts.js");
|
|
16
|
+
const telemetry_js_1 = require("./commands/telemetry.js");
|
|
17
|
+
const command_actions_js_1 = require("./command-actions.js");
|
|
13
18
|
const analytics_js_1 = require("./analytics.js");
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* logged, and set the process exit code to 1. Without this,
|
|
17
|
-
* Commander.js silently swallows unhandled rejections from async actions.
|
|
18
|
-
*/
|
|
19
|
-
function asyncAction(fn) {
|
|
20
|
-
return (...args) => {
|
|
21
|
-
fn(...args).catch((err) => {
|
|
22
|
-
console.error(err instanceof Error ? err.message : "Unknown error");
|
|
23
|
-
// Avoid a hard exit so fire-and-forget failure analytics can flush.
|
|
24
|
-
process.exitCode = 1;
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
async function runTrackedSearch(command, query, operation) {
|
|
29
|
-
try {
|
|
30
|
-
const response = await operation();
|
|
31
|
-
(0, analytics_js_1.trackEvent)(command, { query }, response);
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
(0, analytics_js_1.trackEvent)(command, { query }, {
|
|
35
|
-
success: false,
|
|
36
|
-
error: error instanceof Error ? error.message : "Unknown error",
|
|
37
|
-
});
|
|
38
|
-
throw error;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
19
|
+
const utils_js_1 = require("./utils.js");
|
|
20
|
+
const version_js_1 = require("./version.js");
|
|
41
21
|
const program = new commander_1.Command();
|
|
42
22
|
program
|
|
43
|
-
.name(
|
|
23
|
+
.name((0, utils_js_1.cliName)())
|
|
44
24
|
.description("CLI to access all APIs and skills on the Orthogonal platform")
|
|
45
|
-
.version(
|
|
25
|
+
.version(version_js_1.CLI_VERSION);
|
|
46
26
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
47
27
|
// Auth commands (top-level)
|
|
48
28
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -50,40 +30,44 @@ program
|
|
|
50
30
|
.command("login")
|
|
51
31
|
.description("Authenticate with your Orthogonal API key")
|
|
52
32
|
.option("-k, --key <key>", "API key (or set ORTHOGONAL_API_KEY env var)")
|
|
53
|
-
.action(asyncAction(async (options) => {
|
|
33
|
+
.action((0, command_actions_js_1.asyncAction)(async (options) => {
|
|
54
34
|
(0, analytics_js_1.trackEvent)("login");
|
|
55
35
|
await (0, auth_js_1.loginCommand)(options);
|
|
56
36
|
}));
|
|
57
37
|
program
|
|
58
38
|
.command("logout")
|
|
59
39
|
.description("Remove stored API key")
|
|
60
|
-
.action(asyncAction(async () => {
|
|
40
|
+
.action((0, command_actions_js_1.asyncAction)(async () => {
|
|
61
41
|
(0, analytics_js_1.trackEvent)("logout");
|
|
62
42
|
await (0, auth_js_1.logoutCommand)();
|
|
63
43
|
}));
|
|
64
44
|
program
|
|
65
45
|
.command("whoami")
|
|
66
46
|
.description("Show current authentication status")
|
|
67
|
-
.
|
|
47
|
+
.option("--json", "Print JSON")
|
|
48
|
+
.action((0, command_actions_js_1.asyncAction)(async (options) => {
|
|
68
49
|
(0, analytics_js_1.trackEvent)("whoami");
|
|
69
|
-
await (0, auth_js_1.whoamiCommand)();
|
|
50
|
+
await (0, auth_js_1.whoamiCommand)(options);
|
|
70
51
|
}));
|
|
71
52
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
72
53
|
// Account commands (top-level)
|
|
73
54
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
74
55
|
program
|
|
75
56
|
.command("balance")
|
|
76
|
-
.description("Check
|
|
77
|
-
.
|
|
57
|
+
.description("Check the credit balance of whoever your key bills (you, or its organization)")
|
|
58
|
+
.option("--json", "Print JSON")
|
|
59
|
+
.action((0, command_actions_js_1.asyncAction)(async (options) => {
|
|
78
60
|
(0, analytics_js_1.trackEvent)("balance");
|
|
79
|
-
await (0, account_js_1.balanceCommand)();
|
|
61
|
+
await (0, account_js_1.balanceCommand)(options);
|
|
80
62
|
}));
|
|
81
63
|
program
|
|
82
64
|
.command("usage")
|
|
83
|
-
.description("Show recent
|
|
65
|
+
.description("Show your recent paid calls and the total spent")
|
|
84
66
|
.option("-l, --limit <number>", "Number of recent calls", "20")
|
|
85
67
|
.option("-d, --days <number>", "Number of days to look back", "30")
|
|
86
|
-
.
|
|
68
|
+
.option("--offset <number>", "Skip this many of the most recent calls")
|
|
69
|
+
.option("--json", "Print JSON")
|
|
70
|
+
.action((0, command_actions_js_1.asyncAction)(async (options) => {
|
|
87
71
|
(0, analytics_js_1.trackEvent)("usage");
|
|
88
72
|
await (0, account_js_1.usageCommand)(options);
|
|
89
73
|
}));
|
|
@@ -94,9 +78,10 @@ const apiGroup = program.command("api").description("API marketplace commands");
|
|
|
94
78
|
apiGroup
|
|
95
79
|
.command("list")
|
|
96
80
|
.description("List available APIs")
|
|
97
|
-
.
|
|
81
|
+
.option("--json", "Print JSON")
|
|
82
|
+
.action((0, command_actions_js_1.asyncAction)(async (options) => {
|
|
98
83
|
(0, analytics_js_1.trackEvent)("api.list");
|
|
99
|
-
await (0, api_js_1.apiCommand)(undefined, undefined,
|
|
84
|
+
await (0, api_js_1.apiCommand)(undefined, undefined, options);
|
|
100
85
|
}));
|
|
101
86
|
apiGroup
|
|
102
87
|
.command("show <slug> [path]")
|
|
@@ -104,7 +89,8 @@ apiGroup
|
|
|
104
89
|
.description("Show API endpoints or endpoint details")
|
|
105
90
|
.option("--x402", "Output x402 payment URL only")
|
|
106
91
|
.option("--x402-full", "Output full x402 payment details")
|
|
107
|
-
.
|
|
92
|
+
.option("--json", "Print JSON")
|
|
93
|
+
.action((0, command_actions_js_1.asyncAction)(async (slug, path, options) => {
|
|
108
94
|
(0, analytics_js_1.trackEvent)("api.show", { slug, path });
|
|
109
95
|
await (0, api_js_1.apiCommand)(slug, path, options);
|
|
110
96
|
}));
|
|
@@ -112,20 +98,21 @@ apiGroup
|
|
|
112
98
|
.command("search <query>")
|
|
113
99
|
.description("Search for APIs using natural language")
|
|
114
100
|
.option("-l, --limit <number>", "Max results", "10")
|
|
115
|
-
.
|
|
116
|
-
|
|
101
|
+
.option("--json", "Print JSON")
|
|
102
|
+
.action((0, command_actions_js_1.asyncAction)(async (query, options) => {
|
|
103
|
+
await (0, command_actions_js_1.runTrackedSearch)("api.search", query, () => (0, search_js_1.searchCommand)(query, options));
|
|
117
104
|
}));
|
|
118
105
|
apiGroup
|
|
119
106
|
.command("run <slug> <path>")
|
|
120
107
|
.description("Call an API endpoint")
|
|
121
|
-
.option("-X, --method <method>", "HTTP method
|
|
108
|
+
.option("-X, --method <method>", "HTTP method (default: POST with a body, else GET)")
|
|
122
109
|
.option("-q, --query <params...>", "Query params (key=value)")
|
|
123
|
-
.option("-b, --body <json>", "Request body JSON")
|
|
110
|
+
.option("-b, --body <json>", "Request body JSON ('-' reads stdin)")
|
|
124
111
|
.option("-d, --data <json>", "Alias for --body")
|
|
125
|
-
.option("--raw", "
|
|
112
|
+
.option("--raw", "Print only the response JSON on stdout (the cost goes to stderr)")
|
|
126
113
|
.option("-o, --output <file>", "Save response to file (auto-detects binary like images)")
|
|
127
114
|
.option("--dry-run", "Estimate cost without executing the call")
|
|
128
|
-
.action(asyncAction(async (slug, path, options) => {
|
|
115
|
+
.action((0, command_actions_js_1.asyncAction)(async (slug, path, options) => {
|
|
129
116
|
(0, analytics_js_1.trackEvent)("api.run", { slug, path });
|
|
130
117
|
await (0, run_js_1.runCommand)(slug, path, options);
|
|
131
118
|
}));
|
|
@@ -133,7 +120,7 @@ apiGroup
|
|
|
133
120
|
.command("code <slug> <path>")
|
|
134
121
|
.description("Generate integration code for an endpoint")
|
|
135
122
|
.option("-l, --lang <language>", "Language: typescript, python, curl", "typescript")
|
|
136
|
-
.action(asyncAction(async (slug, path, options) => {
|
|
123
|
+
.action((0, command_actions_js_1.asyncAction)(async (slug, path, options) => {
|
|
137
124
|
(0, analytics_js_1.trackEvent)("api.code", { slug, path });
|
|
138
125
|
await (0, code_js_1.codeCommand)(slug, path, options);
|
|
139
126
|
}));
|
|
@@ -141,153 +128,132 @@ apiGroup
|
|
|
141
128
|
.command("request <docsUrl>")
|
|
142
129
|
.description("Request an API to be added to the platform")
|
|
143
130
|
.option("-d, --description <text>", "Additional notes about the API")
|
|
144
|
-
.action(asyncAction(async (docsUrl, options) => {
|
|
131
|
+
.action((0, command_actions_js_1.asyncAction)(async (docsUrl, options) => {
|
|
145
132
|
(0, analytics_js_1.trackEvent)("api.request", { docsUrl });
|
|
146
133
|
await (0, apiRequest_js_1.apiRequestCommand)(docsUrl, options);
|
|
147
134
|
}));
|
|
148
135
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
149
|
-
// orth
|
|
136
|
+
// orth org — which of your selling organizations commands act for
|
|
150
137
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
151
|
-
const
|
|
152
|
-
.command("
|
|
153
|
-
.description("
|
|
154
|
-
|
|
155
|
-
.
|
|
156
|
-
.
|
|
157
|
-
|
|
158
|
-
.action(asyncAction(async (options) => {
|
|
159
|
-
(0, analytics_js_1.trackEvent)("skills.list");
|
|
160
|
-
await (0, skills_js_1.skillsListCommand)(options);
|
|
161
|
-
}));
|
|
162
|
-
skillsGroup
|
|
163
|
-
.command("mine")
|
|
164
|
-
.description("List your own skills")
|
|
165
|
-
.option("-l, --limit <number>", "Max results", "50")
|
|
166
|
-
.action(asyncAction(async (options) => {
|
|
167
|
-
(0, analytics_js_1.trackEvent)("skills.mine");
|
|
168
|
-
await (0, skills_js_1.skillsMineCommand)(options);
|
|
169
|
-
}));
|
|
170
|
-
skillsGroup
|
|
171
|
-
.command("search <query>")
|
|
172
|
-
.description("Search for agent skills")
|
|
173
|
-
.option("-l, --limit <number>", "Max results", "20")
|
|
174
|
-
.action(asyncAction(async (query, options) => {
|
|
175
|
-
await runTrackedSearch("skills.search", query, () => (0, skills_js_1.skillsSearchCommand)(query, options));
|
|
176
|
-
}));
|
|
177
|
-
skillsGroup
|
|
178
|
-
.command("show <slug>")
|
|
179
|
-
.description("Show skill details and files")
|
|
180
|
-
.action(asyncAction(async (slug) => {
|
|
181
|
-
(0, analytics_js_1.trackEvent)("skills.show", { slug });
|
|
182
|
-
await (0, skills_js_1.skillsShowCommand)(slug);
|
|
183
|
-
}));
|
|
184
|
-
skillsGroup
|
|
185
|
-
.command("init [name]")
|
|
186
|
-
.description("Initialize a new skill directory with SKILL.md template")
|
|
187
|
-
.option("--bare", "Only create SKILL.md, skip subdirectories")
|
|
188
|
-
.option("--path <dir>", "Output directory")
|
|
189
|
-
.action(asyncAction(async (name, options) => {
|
|
190
|
-
(0, analytics_js_1.trackEvent)("skills.init", { name });
|
|
191
|
-
await (0, skills_js_1.skillsInitCommand)(name, options);
|
|
192
|
-
}));
|
|
193
|
-
skillsGroup
|
|
194
|
-
.command("submit [path]")
|
|
195
|
-
.description("Submit a local skill to the Orthogonal platform")
|
|
196
|
-
.option("-n, --name <name>", "Override skill name from frontmatter")
|
|
197
|
-
.option("-t, --tags <tags>", "Comma-separated tags")
|
|
198
|
-
.option("--org <orgId>", "Submit to an organization instead of personal account")
|
|
199
|
-
.action(asyncAction(async (inputPath, options) => {
|
|
200
|
-
(0, analytics_js_1.trackEvent)("skills.submit", { path: inputPath });
|
|
201
|
-
await (0, skills_js_1.skillsSubmitCommand)(inputPath, options);
|
|
202
|
-
}));
|
|
203
|
-
skillsGroup
|
|
204
|
-
.command("update <slug> [path]")
|
|
205
|
-
.description("Pull latest skill version from Orthogonal to local directory")
|
|
206
|
-
.option("-f, --force", "Overwrite existing files")
|
|
207
|
-
.action(asyncAction(async (slug, inputPath, options) => {
|
|
208
|
-
(0, analytics_js_1.trackEvent)("skills.update", { slug, path: inputPath });
|
|
209
|
-
await (0, skills_js_1.skillsUpdateCommand)(slug, inputPath, options);
|
|
138
|
+
const orgGroup = program
|
|
139
|
+
.command("org")
|
|
140
|
+
.description("Organizations you administer that sell APIs, and your default one")
|
|
141
|
+
.option("--json", "Print JSON")
|
|
142
|
+
.action((0, command_actions_js_1.asyncAction)(async (options) => {
|
|
143
|
+
(0, analytics_js_1.trackEvent)("org");
|
|
144
|
+
await (0, org_js_1.orgCommand)(options);
|
|
210
145
|
}));
|
|
211
|
-
|
|
212
|
-
.command("
|
|
213
|
-
.description("
|
|
214
|
-
.
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
(0, analytics_js_1.trackEvent)("skills.push", { slug, path: inputPath });
|
|
218
|
-
await (0, skills_js_1.skillsPushCommand)(slug, inputPath, options);
|
|
146
|
+
orgGroup
|
|
147
|
+
.command("use [name]")
|
|
148
|
+
.description("Choose the default organization for api-onboarding and payouts (a name, part of one, or an id)")
|
|
149
|
+
.action((0, command_actions_js_1.asyncAction)(async (name) => {
|
|
150
|
+
(0, analytics_js_1.trackEvent)("org.use");
|
|
151
|
+
await (0, org_js_1.orgUseCommand)(name);
|
|
219
152
|
}));
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
.
|
|
229
|
-
|
|
230
|
-
.option("-p, --path <path>", "Path to skill within repo")
|
|
231
|
-
.option("-r, --ref <ref>", "Git ref (branch/tag)", "main")
|
|
232
|
-
.option("-n, --name <name>", "Skill name (auto-detected from SKILL.md)")
|
|
233
|
-
.action(asyncAction(async (githubRepo, options) => {
|
|
234
|
-
(0, analytics_js_1.trackEvent)("skills.create", { githubRepo });
|
|
235
|
-
await (0, skills_js_1.skillsCreateCommand)(githubRepo, options);
|
|
153
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
154
|
+
// orth team — the teams signed in to (one key each) and the active one
|
|
155
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
156
|
+
const teamGroup = program
|
|
157
|
+
.command("team")
|
|
158
|
+
.description("Teams you are signed in to (one key each, from login), and the active one")
|
|
159
|
+
.option("--json", "Print JSON")
|
|
160
|
+
.action((0, command_actions_js_1.asyncAction)(async (options) => {
|
|
161
|
+
(0, analytics_js_1.trackEvent)("team");
|
|
162
|
+
await (0, org_js_1.teamCommand)(options);
|
|
236
163
|
}));
|
|
237
|
-
|
|
238
|
-
.command("
|
|
239
|
-
.
|
|
240
|
-
.
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
(0, analytics_js_1.trackEvent)("skills.add", { slug });
|
|
244
|
-
await (0, skills_js_1.skillsInstallCommand)(slug, options);
|
|
164
|
+
teamGroup
|
|
165
|
+
.command("use [name]")
|
|
166
|
+
.description("Switch the active team, whose key pays for calls (a name, part of one, or an id)")
|
|
167
|
+
.action((0, command_actions_js_1.asyncAction)(async (name) => {
|
|
168
|
+
(0, analytics_js_1.trackEvent)("team.use");
|
|
169
|
+
await (0, org_js_1.teamUseCommand)(name);
|
|
245
170
|
}));
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
171
|
+
(0, register_js_1.registerOnboardCommands)(program);
|
|
172
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
173
|
+
// orth payouts — a provider org's payouts (set up in the browser)
|
|
174
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
175
|
+
const payoutsGroup = program
|
|
176
|
+
.command("payouts")
|
|
177
|
+
.description("Show your organization's payout status, what it is owed and what it earned")
|
|
178
|
+
.option(...command_actions_js_1.orgOption)
|
|
179
|
+
.option("--json", "Output raw JSON")
|
|
180
|
+
.action((0, command_actions_js_1.asyncAction)(async (options) => {
|
|
181
|
+
(0, analytics_js_1.trackEvent)("payouts");
|
|
182
|
+
await (0, payouts_js_1.payoutsCommand)(options);
|
|
253
183
|
}));
|
|
254
|
-
|
|
255
|
-
.command("
|
|
256
|
-
.description("
|
|
257
|
-
.
|
|
258
|
-
|
|
259
|
-
|
|
184
|
+
payoutsGroup
|
|
185
|
+
.command("history")
|
|
186
|
+
.description("List the payouts made to your organization, newest first")
|
|
187
|
+
.option(...command_actions_js_1.orgOption)
|
|
188
|
+
.option("--json", "Output raw JSON")
|
|
189
|
+
.action((0, command_actions_js_1.asyncAction)(async (_options, command) => {
|
|
190
|
+
(0, analytics_js_1.trackEvent)("payouts.history");
|
|
191
|
+
await (0, payouts_js_1.payoutsHistoryCommand)(command.optsWithGlobals());
|
|
260
192
|
}));
|
|
193
|
+
(0, register_js_2.registerSkillsCommands)(program);
|
|
194
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
195
|
+
// orth telemetry <subcommand> — usage telemetry opt-out (sends no event)
|
|
196
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
197
|
+
const telemetryGroup = program
|
|
198
|
+
.command("telemetry")
|
|
199
|
+
.description("Manage usage telemetry");
|
|
200
|
+
telemetryGroup
|
|
201
|
+
.command("enable")
|
|
202
|
+
.description("Turn usage telemetry on")
|
|
203
|
+
.action(() => (0, telemetry_js_1.telemetryEnableCommand)());
|
|
204
|
+
telemetryGroup
|
|
205
|
+
.command("disable")
|
|
206
|
+
.description("Turn usage telemetry off")
|
|
207
|
+
.action(() => (0, telemetry_js_1.telemetryDisableCommand)());
|
|
208
|
+
telemetryGroup
|
|
209
|
+
.command("status")
|
|
210
|
+
.description("Show whether usage telemetry is on, and why not")
|
|
211
|
+
.action(() => (0, telemetry_js_1.telemetryStatusCommand)());
|
|
261
212
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
262
213
|
// Backward-compatible aliases (flat commands)
|
|
263
214
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
264
215
|
program
|
|
265
216
|
.command("search <query>")
|
|
266
|
-
.description(
|
|
217
|
+
.description(`Search for APIs (alias for '${(0, utils_js_1.cliName)()} api search')`)
|
|
267
218
|
.option("-l, --limit <number>", "Max results", "10")
|
|
268
|
-
.
|
|
269
|
-
|
|
219
|
+
.option("--json", "Print JSON")
|
|
220
|
+
.action((0, command_actions_js_1.asyncAction)(async (query, options) => {
|
|
221
|
+
await (0, command_actions_js_1.runTrackedSearch)("search", query, () => (0, search_js_1.searchCommand)(query, options));
|
|
270
222
|
}));
|
|
271
223
|
program
|
|
272
224
|
.command("run <api> <path>")
|
|
273
|
-
.description(
|
|
274
|
-
.option("-X, --method <method>", "HTTP method
|
|
225
|
+
.description(`Call an API endpoint (alias for '${(0, utils_js_1.cliName)()} api run')`)
|
|
226
|
+
.option("-X, --method <method>", "HTTP method (default: POST with a body, else GET)")
|
|
275
227
|
.option("-q, --query <params...>", "Query params (key=value)")
|
|
276
|
-
.option("-b, --body <json>", "Request body JSON")
|
|
228
|
+
.option("-b, --body <json>", "Request body JSON ('-' reads stdin)")
|
|
277
229
|
.option("-d, --data <json>", "Alias for --body")
|
|
278
|
-
.option("--raw", "
|
|
230
|
+
.option("--raw", "Print only the response JSON on stdout (the cost goes to stderr)")
|
|
279
231
|
.option("-o, --output <file>", "Save response to file (auto-detects binary like images)")
|
|
280
232
|
.option("--dry-run", "Estimate cost without executing the call")
|
|
281
|
-
.action(asyncAction(async (api, path, options) => {
|
|
233
|
+
.action((0, command_actions_js_1.asyncAction)(async (api, path, options) => {
|
|
282
234
|
(0, analytics_js_1.trackEvent)("run", { api, path });
|
|
283
235
|
await (0, run_js_1.runCommand)(api, path, options);
|
|
284
236
|
}));
|
|
285
237
|
program
|
|
286
238
|
.command("code <api> <path>")
|
|
287
|
-
.description(
|
|
239
|
+
.description(`Generate integration code (alias for '${(0, utils_js_1.cliName)()} api code')`)
|
|
288
240
|
.option("-l, --lang <language>", "Language: typescript, python, curl", "typescript")
|
|
289
|
-
.action(asyncAction(async (api, path, options) => {
|
|
241
|
+
.action((0, command_actions_js_1.asyncAction)(async (api, path, options) => {
|
|
290
242
|
(0, analytics_js_1.trackEvent)("code", { api, path });
|
|
291
243
|
await (0, code_js_1.codeCommand)(api, path, options);
|
|
292
244
|
}));
|
|
245
|
+
program.addHelpText("after", () => {
|
|
246
|
+
const orth = (0, utils_js_1.cliName)();
|
|
247
|
+
return `
|
|
248
|
+
Examples:
|
|
249
|
+
${orth} login # sign in through the browser
|
|
250
|
+
export ORTHOGONAL_API_KEY=orth_live_... # or use a key, no login needed
|
|
251
|
+
${orth} api search "send an email" --json # find endpoints
|
|
252
|
+
${orth} api show tavily /search --json # parameters and price
|
|
253
|
+
${orth} run tavily /search -b '{"query":"AI news"}' --dry-run
|
|
254
|
+
${orth} run tavily /search -b '{"query":"AI news"}' --raw | jq .results
|
|
255
|
+
${orth} balance --json
|
|
256
|
+
|
|
257
|
+
Every command exits 1 on failure; --json and --raw print only JSON on stdout.`;
|
|
258
|
+
});
|
|
293
259
|
program.parse();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Organization } from "./config.js";
|
|
2
|
+
/**
|
|
3
|
+
* Which selling organization a command acts for, without anyone knowing an
|
|
4
|
+
* org id: --org takes a name (or part of one) or an id; else the default
|
|
5
|
+
* saved for this server; else the person's only one; else they pick from a
|
|
6
|
+
* numbered list, and that choice is saved (`orth org use` changes it).
|
|
7
|
+
*/
|
|
8
|
+
/** The organizations that sell APIs the person administers. */
|
|
9
|
+
export declare function listOrganizations(): Promise<Organization[]>;
|
|
10
|
+
/** An organization by id, exact name, or a part of one name only it has. */
|
|
11
|
+
export declare function matchOrganization(orgs: Organization[], query: string): Organization | undefined;
|
|
12
|
+
/** Ask which organization, save it as this server's default, and say so. */
|
|
13
|
+
export declare function pickOrganization(orgs: Organization[]): Promise<Organization>;
|
|
14
|
+
export declare function resolveOrganization(flag?: string): Promise<Organization>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.listOrganizations = listOrganizations;
|
|
7
|
+
exports.matchOrganization = matchOrganization;
|
|
8
|
+
exports.pickOrganization = pickOrganization;
|
|
9
|
+
exports.resolveOrganization = resolveOrganization;
|
|
10
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
+
const api_js_1 = require("./api.js");
|
|
12
|
+
const config_js_1 = require("./config.js");
|
|
13
|
+
const urls_js_1 = require("./urls.js");
|
|
14
|
+
const utils_js_1 = require("./utils.js");
|
|
15
|
+
/**
|
|
16
|
+
* Which selling organization a command acts for, without anyone knowing an
|
|
17
|
+
* org id: --org takes a name (or part of one) or an id; else the default
|
|
18
|
+
* saved for this server; else the person's only one; else they pick from a
|
|
19
|
+
* numbered list, and that choice is saved (`orth org use` changes it).
|
|
20
|
+
*/
|
|
21
|
+
/** The organizations that sell APIs the person administers. */
|
|
22
|
+
async function listOrganizations() {
|
|
23
|
+
const res = await (0, api_js_1.apiRequest)("/onboarding", {
|
|
24
|
+
method: "POST",
|
|
25
|
+
body: { tool: "list_organizations" },
|
|
26
|
+
});
|
|
27
|
+
return res.result.organizations;
|
|
28
|
+
}
|
|
29
|
+
const names = (orgs) => orgs.map((org) => `"${(0, utils_js_1.sanitizeForTerminal)(org.name)}"`).join(", ");
|
|
30
|
+
/** An organization by id, exact name, or a part of one name only it has. */
|
|
31
|
+
function matchOrganization(orgs, query) {
|
|
32
|
+
const wanted = query.trim().toLowerCase();
|
|
33
|
+
const partial = orgs.filter((org) => org.name.toLowerCase().includes(wanted));
|
|
34
|
+
return (orgs.find((org) => org.id === query.trim()) ??
|
|
35
|
+
orgs.find((org) => org.name.toLowerCase() === wanted) ??
|
|
36
|
+
(partial.length === 1 ? partial[0] : undefined));
|
|
37
|
+
}
|
|
38
|
+
function noneError() {
|
|
39
|
+
return new Error(`You don't administer an organization that sells APIs. Create your seller organization in Your listings (${(0, urls_js_1.webBaseUrl)()}/account/listings), then try again.`);
|
|
40
|
+
}
|
|
41
|
+
/** Ask which organization, save it as this server's default, and say so. */
|
|
42
|
+
async function pickOrganization(orgs) {
|
|
43
|
+
const org = orgs[await (0, utils_js_1.choose)("Which organization?", orgs.map((candidate) => candidate.name))];
|
|
44
|
+
if (!org)
|
|
45
|
+
throw noneError();
|
|
46
|
+
(0, config_js_1.setDefaultOrganization)((0, urls_js_1.apiBaseUrl)(), org);
|
|
47
|
+
console.log(chalk_1.default.gray(`\n Saved ${(0, utils_js_1.sanitizeForTerminal)(org.name)} as your default organization. Change it with: ${(0, utils_js_1.cliName)()} org use\n`));
|
|
48
|
+
return org;
|
|
49
|
+
}
|
|
50
|
+
async function resolveOrganization(flag) {
|
|
51
|
+
// An org id needs no lookup; the server checks the person administers it.
|
|
52
|
+
if (flag?.startsWith("org_"))
|
|
53
|
+
return { id: flag, name: flag };
|
|
54
|
+
if (!flag) {
|
|
55
|
+
const saved = (0, config_js_1.getDefaultOrganization)((0, urls_js_1.apiBaseUrl)());
|
|
56
|
+
if (saved)
|
|
57
|
+
return saved;
|
|
58
|
+
}
|
|
59
|
+
const orgs = await listOrganizations();
|
|
60
|
+
if (flag) {
|
|
61
|
+
const org = matchOrganization(orgs, flag);
|
|
62
|
+
if (org)
|
|
63
|
+
return org;
|
|
64
|
+
throw new Error(orgs.length
|
|
65
|
+
? `No organization of yours matches "${(0, utils_js_1.sanitizeForTerminal)(flag)}". Yours: ${names(orgs)}.`
|
|
66
|
+
: noneError().message);
|
|
67
|
+
}
|
|
68
|
+
const [only] = orgs;
|
|
69
|
+
if (!only)
|
|
70
|
+
throw noneError();
|
|
71
|
+
if (orgs.length === 1)
|
|
72
|
+
return only;
|
|
73
|
+
if (!(0, utils_js_1.isInteractive)()) {
|
|
74
|
+
throw new Error(`You administer several organizations that sell APIs: ${names(orgs)}. Choose one with \`${(0, utils_js_1.cliName)()} org use\`, or pass --org "<name>".`);
|
|
75
|
+
}
|
|
76
|
+
return pickOrganization(orgs);
|
|
77
|
+
}
|
package/dist/urls.d.ts
ADDED
package/dist/urls.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.apiBaseUrl = apiBaseUrl;
|
|
4
|
+
exports.webBaseUrl = webBaseUrl;
|
|
5
|
+
exports.protectionBypass = protectionBypass;
|
|
6
|
+
const DEFAULT_ORIGIN = "https://www.orthogonal.com";
|
|
7
|
+
function apiBaseUrl() {
|
|
8
|
+
return (process.env.ORTH_API_URL || `${DEFAULT_ORIGIN}/v1`).replace(/\/$/, "");
|
|
9
|
+
}
|
|
10
|
+
// Without ORTH_WEB_URL, the site that serves ORTH_API_URL, so `orth login`
|
|
11
|
+
// makes its key on the server the commands then call.
|
|
12
|
+
function webBaseUrl() {
|
|
13
|
+
const apiSite = process.env.ORTH_API_URL?.replace(/\/$/, "").replace(/\/v1$/, "");
|
|
14
|
+
return (process.env.ORTH_WEB_URL || apiSite || DEFAULT_ORIGIN).replace(/\/$/, "");
|
|
15
|
+
}
|
|
16
|
+
// dev.mono sits behind Vercel Authentication. Staff and agents calling it
|
|
17
|
+
// export Vercel's automation bypass secret (README, "Staff builds"), which goes
|
|
18
|
+
// as Vercel's x-vercel-protection-bypass header on each request to the
|
|
19
|
+
// configured API or web origin, and never to another host.
|
|
20
|
+
function protectionBypass(url) {
|
|
21
|
+
const secret = process.env.VERCEL_AUTOMATION_BYPASS_SECRET?.trim();
|
|
22
|
+
const origin = originOf(url);
|
|
23
|
+
return secret && origin && [apiBaseUrl(), webBaseUrl()].some((base) => originOf(base) === origin)
|
|
24
|
+
? { "x-vercel-protection-bypass": secret }
|
|
25
|
+
: {};
|
|
26
|
+
}
|
|
27
|
+
function originOf(url) {
|
|
28
|
+
try {
|
|
29
|
+
return new URL(url).origin;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1 +1,21 @@
|
|
|
1
1
|
export declare function sanitizeForTerminal(value: string): string;
|
|
2
|
+
/**
|
|
3
|
+
* The command the person typed: `orth`, or a staff build's `mono-dev` and
|
|
4
|
+
* `mono-prod`, so hints name a command that exists. `npm run cli` runs
|
|
5
|
+
* dist/index.js, which is `orth`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function cliName(): string;
|
|
8
|
+
/** Whether a person is at the terminal to answer a question. */
|
|
9
|
+
export declare function isInteractive(): boolean;
|
|
10
|
+
/** A numbered list to pick from; answers the chosen index. */
|
|
11
|
+
export declare function choose(question: string, labels: string[]): Promise<number>;
|
|
12
|
+
/** A failure as people read it: a red ✗ and the message, never a stack. */
|
|
13
|
+
export declare function printError(error: unknown): void;
|
|
14
|
+
/** A yes-or-no question; anything but y/yes is no. */
|
|
15
|
+
export declare function confirmYes(question: string): Promise<boolean>;
|
|
16
|
+
/**
|
|
17
|
+
* A secret typed without echo (an API key), or stdin when piped, so it never
|
|
18
|
+
* shows on screen, in shell history or in `ps`. The prompt goes to stderr,
|
|
19
|
+
* so stdout keeps only the command's output (--json).
|
|
20
|
+
*/
|
|
21
|
+
export declare function readSecret(question: string): Promise<string>;
|