@orth/cli 0.3.1 → 0.5.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 +58 -0
- package/README.md +113 -109
- package/dist/analytics.d.ts +36 -8
- package/dist/analytics.js +247 -47
- package/dist/api.d.ts +34 -2
- package/dist/api.js +68 -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 +114 -117
- 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 +2 -1
- package/dist/commands/run.js +23 -29
- package/dist/commands/search.d.ts +8 -1
- package/dist/commands/search.js +28 -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 +55 -1
- package/dist/config.js +102 -3
- package/dist/http.d.ts +15 -0
- package/dist/http.js +41 -0
- package/dist/index.js +133 -162
- package/dist/last-search.d.ts +19 -0
- package/dist/last-search.js +60 -0
- 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,38 +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 }, (0, analytics_js_1.getSearchFailureResponse)(error));
|
|
35
|
-
throw error;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
19
|
+
const utils_js_1 = require("./utils.js");
|
|
20
|
+
const version_js_1 = require("./version.js");
|
|
38
21
|
const program = new commander_1.Command();
|
|
39
22
|
program
|
|
40
|
-
.name(
|
|
23
|
+
.name((0, utils_js_1.cliName)())
|
|
41
24
|
.description("CLI to access all APIs and skills on the Orthogonal platform")
|
|
42
|
-
.version(
|
|
25
|
+
.version(version_js_1.CLI_VERSION);
|
|
43
26
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
44
27
|
// Auth commands (top-level)
|
|
45
28
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -47,40 +30,44 @@ program
|
|
|
47
30
|
.command("login")
|
|
48
31
|
.description("Authenticate with your Orthogonal API key")
|
|
49
32
|
.option("-k, --key <key>", "API key (or set ORTHOGONAL_API_KEY env var)")
|
|
50
|
-
.action(asyncAction(async (options) => {
|
|
33
|
+
.action((0, command_actions_js_1.asyncAction)(async (options) => {
|
|
51
34
|
(0, analytics_js_1.trackEvent)("login");
|
|
52
35
|
await (0, auth_js_1.loginCommand)(options);
|
|
53
36
|
}));
|
|
54
37
|
program
|
|
55
38
|
.command("logout")
|
|
56
39
|
.description("Remove stored API key")
|
|
57
|
-
.action(asyncAction(async () => {
|
|
40
|
+
.action((0, command_actions_js_1.asyncAction)(async () => {
|
|
58
41
|
(0, analytics_js_1.trackEvent)("logout");
|
|
59
42
|
await (0, auth_js_1.logoutCommand)();
|
|
60
43
|
}));
|
|
61
44
|
program
|
|
62
45
|
.command("whoami")
|
|
63
46
|
.description("Show current authentication status")
|
|
64
|
-
.
|
|
47
|
+
.option("--json", "Print JSON")
|
|
48
|
+
.action((0, command_actions_js_1.asyncAction)(async (options) => {
|
|
65
49
|
(0, analytics_js_1.trackEvent)("whoami");
|
|
66
|
-
await (0, auth_js_1.whoamiCommand)();
|
|
50
|
+
await (0, auth_js_1.whoamiCommand)(options);
|
|
67
51
|
}));
|
|
68
52
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
69
53
|
// Account commands (top-level)
|
|
70
54
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
71
55
|
program
|
|
72
56
|
.command("balance")
|
|
73
|
-
.description("Check
|
|
74
|
-
.
|
|
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) => {
|
|
75
60
|
(0, analytics_js_1.trackEvent)("balance");
|
|
76
|
-
await (0, account_js_1.balanceCommand)();
|
|
61
|
+
await (0, account_js_1.balanceCommand)(options);
|
|
77
62
|
}));
|
|
78
63
|
program
|
|
79
64
|
.command("usage")
|
|
80
|
-
.description("Show recent
|
|
65
|
+
.description("Show your recent paid calls and the total spent")
|
|
81
66
|
.option("-l, --limit <number>", "Number of recent calls", "20")
|
|
82
67
|
.option("-d, --days <number>", "Number of days to look back", "30")
|
|
83
|
-
.
|
|
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) => {
|
|
84
71
|
(0, analytics_js_1.trackEvent)("usage");
|
|
85
72
|
await (0, account_js_1.usageCommand)(options);
|
|
86
73
|
}));
|
|
@@ -91,9 +78,10 @@ const apiGroup = program.command("api").description("API marketplace commands");
|
|
|
91
78
|
apiGroup
|
|
92
79
|
.command("list")
|
|
93
80
|
.description("List available APIs")
|
|
94
|
-
.
|
|
81
|
+
.option("--json", "Print JSON")
|
|
82
|
+
.action((0, command_actions_js_1.asyncAction)(async (options) => {
|
|
95
83
|
(0, analytics_js_1.trackEvent)("api.list");
|
|
96
|
-
await (0, api_js_1.apiCommand)(undefined, undefined,
|
|
84
|
+
await (0, api_js_1.apiCommand)(undefined, undefined, options);
|
|
97
85
|
}));
|
|
98
86
|
apiGroup
|
|
99
87
|
.command("show <slug> [path]")
|
|
@@ -101,7 +89,8 @@ apiGroup
|
|
|
101
89
|
.description("Show API endpoints or endpoint details")
|
|
102
90
|
.option("--x402", "Output x402 payment URL only")
|
|
103
91
|
.option("--x402-full", "Output full x402 payment details")
|
|
104
|
-
.
|
|
92
|
+
.option("--json", "Print JSON")
|
|
93
|
+
.action((0, command_actions_js_1.asyncAction)(async (slug, path, options) => {
|
|
105
94
|
(0, analytics_js_1.trackEvent)("api.show", { slug, path });
|
|
106
95
|
await (0, api_js_1.apiCommand)(slug, path, options);
|
|
107
96
|
}));
|
|
@@ -109,20 +98,22 @@ apiGroup
|
|
|
109
98
|
.command("search <query>")
|
|
110
99
|
.description("Search for APIs using natural language")
|
|
111
100
|
.option("-l, --limit <number>", "Max results", "10")
|
|
112
|
-
.
|
|
113
|
-
|
|
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));
|
|
114
104
|
}));
|
|
115
105
|
apiGroup
|
|
116
106
|
.command("run <slug> <path>")
|
|
117
107
|
.description("Call an API endpoint")
|
|
118
|
-
.option("-X, --method <method>", "HTTP method
|
|
108
|
+
.option("-X, --method <method>", "HTTP method (default: POST with a body, else GET)")
|
|
119
109
|
.option("-q, --query <params...>", "Query params (key=value)")
|
|
120
|
-
.option("-b, --body <json>", "Request body JSON")
|
|
110
|
+
.option("-b, --body <json>", "Request body JSON ('-' reads stdin)")
|
|
121
111
|
.option("-d, --data <json>", "Alias for --body")
|
|
122
|
-
.option("--raw", "
|
|
112
|
+
.option("--raw", "Print only the response JSON on stdout (the cost goes to stderr)")
|
|
123
113
|
.option("-o, --output <file>", "Save response to file (auto-detects binary like images)")
|
|
124
114
|
.option("--dry-run", "Estimate cost without executing the call")
|
|
125
|
-
.
|
|
115
|
+
.option("--search-id <id>", "The search that led to this call (default: the last search, if it returned this endpoint)")
|
|
116
|
+
.action((0, command_actions_js_1.asyncAction)(async (slug, path, options) => {
|
|
126
117
|
(0, analytics_js_1.trackEvent)("api.run", { slug, path });
|
|
127
118
|
await (0, run_js_1.runCommand)(slug, path, options);
|
|
128
119
|
}));
|
|
@@ -130,7 +121,7 @@ apiGroup
|
|
|
130
121
|
.command("code <slug> <path>")
|
|
131
122
|
.description("Generate integration code for an endpoint")
|
|
132
123
|
.option("-l, --lang <language>", "Language: typescript, python, curl", "typescript")
|
|
133
|
-
.action(asyncAction(async (slug, path, options) => {
|
|
124
|
+
.action((0, command_actions_js_1.asyncAction)(async (slug, path, options) => {
|
|
134
125
|
(0, analytics_js_1.trackEvent)("api.code", { slug, path });
|
|
135
126
|
await (0, code_js_1.codeCommand)(slug, path, options);
|
|
136
127
|
}));
|
|
@@ -138,153 +129,133 @@ apiGroup
|
|
|
138
129
|
.command("request <docsUrl>")
|
|
139
130
|
.description("Request an API to be added to the platform")
|
|
140
131
|
.option("-d, --description <text>", "Additional notes about the API")
|
|
141
|
-
.action(asyncAction(async (docsUrl, options) => {
|
|
132
|
+
.action((0, command_actions_js_1.asyncAction)(async (docsUrl, options) => {
|
|
142
133
|
(0, analytics_js_1.trackEvent)("api.request", { docsUrl });
|
|
143
134
|
await (0, apiRequest_js_1.apiRequestCommand)(docsUrl, options);
|
|
144
135
|
}));
|
|
145
136
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
146
|
-
// orth
|
|
137
|
+
// orth org — which of your selling organizations commands act for
|
|
147
138
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
148
|
-
const
|
|
149
|
-
.command("
|
|
150
|
-
.description("
|
|
151
|
-
|
|
152
|
-
.
|
|
153
|
-
.
|
|
154
|
-
|
|
155
|
-
.action(asyncAction(async (options) => {
|
|
156
|
-
(0, analytics_js_1.trackEvent)("skills.list");
|
|
157
|
-
await (0, skills_js_1.skillsListCommand)(options);
|
|
158
|
-
}));
|
|
159
|
-
skillsGroup
|
|
160
|
-
.command("mine")
|
|
161
|
-
.description("List your own skills")
|
|
162
|
-
.option("-l, --limit <number>", "Max results", "50")
|
|
163
|
-
.action(asyncAction(async (options) => {
|
|
164
|
-
(0, analytics_js_1.trackEvent)("skills.mine");
|
|
165
|
-
await (0, skills_js_1.skillsMineCommand)(options);
|
|
166
|
-
}));
|
|
167
|
-
skillsGroup
|
|
168
|
-
.command("search <query>")
|
|
169
|
-
.description("Search for agent skills")
|
|
170
|
-
.option("-l, --limit <number>", "Max results", "20")
|
|
171
|
-
.action(asyncAction(async (query, options) => {
|
|
172
|
-
await runTrackedSearch("skills.search", query, () => (0, skills_js_1.skillsSearchCommand)(query, options));
|
|
173
|
-
}));
|
|
174
|
-
skillsGroup
|
|
175
|
-
.command("show <slug>")
|
|
176
|
-
.description("Show skill details and files")
|
|
177
|
-
.action(asyncAction(async (slug) => {
|
|
178
|
-
(0, analytics_js_1.trackEvent)("skills.show", { slug });
|
|
179
|
-
await (0, skills_js_1.skillsShowCommand)(slug);
|
|
180
|
-
}));
|
|
181
|
-
skillsGroup
|
|
182
|
-
.command("init [name]")
|
|
183
|
-
.description("Initialize a new skill directory with SKILL.md template")
|
|
184
|
-
.option("--bare", "Only create SKILL.md, skip subdirectories")
|
|
185
|
-
.option("--path <dir>", "Output directory")
|
|
186
|
-
.action(asyncAction(async (name, options) => {
|
|
187
|
-
(0, analytics_js_1.trackEvent)("skills.init", { name });
|
|
188
|
-
await (0, skills_js_1.skillsInitCommand)(name, options);
|
|
189
|
-
}));
|
|
190
|
-
skillsGroup
|
|
191
|
-
.command("submit [path]")
|
|
192
|
-
.description("Submit a local skill to the Orthogonal platform")
|
|
193
|
-
.option("-n, --name <name>", "Override skill name from frontmatter")
|
|
194
|
-
.option("-t, --tags <tags>", "Comma-separated tags")
|
|
195
|
-
.option("--org <orgId>", "Submit to an organization instead of personal account")
|
|
196
|
-
.action(asyncAction(async (inputPath, options) => {
|
|
197
|
-
(0, analytics_js_1.trackEvent)("skills.submit", { path: inputPath });
|
|
198
|
-
await (0, skills_js_1.skillsSubmitCommand)(inputPath, options);
|
|
199
|
-
}));
|
|
200
|
-
skillsGroup
|
|
201
|
-
.command("update <slug> [path]")
|
|
202
|
-
.description("Pull latest skill version from Orthogonal to local directory")
|
|
203
|
-
.option("-f, --force", "Overwrite existing files")
|
|
204
|
-
.action(asyncAction(async (slug, inputPath, options) => {
|
|
205
|
-
(0, analytics_js_1.trackEvent)("skills.update", { slug, path: inputPath });
|
|
206
|
-
await (0, skills_js_1.skillsUpdateCommand)(slug, inputPath, options);
|
|
139
|
+
const orgGroup = program
|
|
140
|
+
.command("org")
|
|
141
|
+
.description("Organizations you administer that sell APIs, and your default one")
|
|
142
|
+
.option("--json", "Print JSON")
|
|
143
|
+
.action((0, command_actions_js_1.asyncAction)(async (options) => {
|
|
144
|
+
(0, analytics_js_1.trackEvent)("org");
|
|
145
|
+
await (0, org_js_1.orgCommand)(options);
|
|
207
146
|
}));
|
|
208
|
-
|
|
209
|
-
.command("
|
|
210
|
-
.description("
|
|
211
|
-
.
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
(0, analytics_js_1.trackEvent)("skills.push", { slug, path: inputPath });
|
|
215
|
-
await (0, skills_js_1.skillsPushCommand)(slug, inputPath, options);
|
|
147
|
+
orgGroup
|
|
148
|
+
.command("use [name]")
|
|
149
|
+
.description("Choose the default organization for api-onboarding and payouts (a name, part of one, or an id)")
|
|
150
|
+
.action((0, command_actions_js_1.asyncAction)(async (name) => {
|
|
151
|
+
(0, analytics_js_1.trackEvent)("org.use");
|
|
152
|
+
await (0, org_js_1.orgUseCommand)(name);
|
|
216
153
|
}));
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
.
|
|
226
|
-
|
|
227
|
-
.option("-p, --path <path>", "Path to skill within repo")
|
|
228
|
-
.option("-r, --ref <ref>", "Git ref (branch/tag)", "main")
|
|
229
|
-
.option("-n, --name <name>", "Skill name (auto-detected from SKILL.md)")
|
|
230
|
-
.action(asyncAction(async (githubRepo, options) => {
|
|
231
|
-
(0, analytics_js_1.trackEvent)("skills.create", { githubRepo });
|
|
232
|
-
await (0, skills_js_1.skillsCreateCommand)(githubRepo, options);
|
|
154
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
155
|
+
// orth team — the teams signed in to (one key each) and the active one
|
|
156
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
157
|
+
const teamGroup = program
|
|
158
|
+
.command("team")
|
|
159
|
+
.description("Teams you are signed in to (one key each, from login), and the active one")
|
|
160
|
+
.option("--json", "Print JSON")
|
|
161
|
+
.action((0, command_actions_js_1.asyncAction)(async (options) => {
|
|
162
|
+
(0, analytics_js_1.trackEvent)("team");
|
|
163
|
+
await (0, org_js_1.teamCommand)(options);
|
|
233
164
|
}));
|
|
234
|
-
|
|
235
|
-
.command("
|
|
236
|
-
.
|
|
237
|
-
.
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
(0, analytics_js_1.trackEvent)("skills.add", { slug });
|
|
241
|
-
await (0, skills_js_1.skillsInstallCommand)(slug, options);
|
|
165
|
+
teamGroup
|
|
166
|
+
.command("use [name]")
|
|
167
|
+
.description("Switch the active team, whose key pays for calls (a name, part of one, or an id)")
|
|
168
|
+
.action((0, command_actions_js_1.asyncAction)(async (name) => {
|
|
169
|
+
(0, analytics_js_1.trackEvent)("team.use");
|
|
170
|
+
await (0, org_js_1.teamUseCommand)(name);
|
|
242
171
|
}));
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
172
|
+
(0, register_js_1.registerOnboardCommands)(program);
|
|
173
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
174
|
+
// orth payouts — a provider org's payouts (set up in the browser)
|
|
175
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
176
|
+
const payoutsGroup = program
|
|
177
|
+
.command("payouts")
|
|
178
|
+
.description("Show your organization's payout status, what it is owed and what it earned")
|
|
179
|
+
.option(...command_actions_js_1.orgOption)
|
|
180
|
+
.option("--json", "Output raw JSON")
|
|
181
|
+
.action((0, command_actions_js_1.asyncAction)(async (options) => {
|
|
182
|
+
(0, analytics_js_1.trackEvent)("payouts");
|
|
183
|
+
await (0, payouts_js_1.payoutsCommand)(options);
|
|
250
184
|
}));
|
|
251
|
-
|
|
252
|
-
.command("
|
|
253
|
-
.description("
|
|
254
|
-
.
|
|
255
|
-
|
|
256
|
-
|
|
185
|
+
payoutsGroup
|
|
186
|
+
.command("history")
|
|
187
|
+
.description("List the payouts made to your organization, newest first")
|
|
188
|
+
.option(...command_actions_js_1.orgOption)
|
|
189
|
+
.option("--json", "Output raw JSON")
|
|
190
|
+
.action((0, command_actions_js_1.asyncAction)(async (_options, command) => {
|
|
191
|
+
(0, analytics_js_1.trackEvent)("payouts.history");
|
|
192
|
+
await (0, payouts_js_1.payoutsHistoryCommand)(command.optsWithGlobals());
|
|
257
193
|
}));
|
|
194
|
+
(0, register_js_2.registerSkillsCommands)(program);
|
|
195
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
196
|
+
// orth telemetry <subcommand> — usage telemetry opt-out (sends no event)
|
|
197
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
198
|
+
const telemetryGroup = program
|
|
199
|
+
.command("telemetry")
|
|
200
|
+
.description("Manage usage telemetry");
|
|
201
|
+
telemetryGroup
|
|
202
|
+
.command("enable")
|
|
203
|
+
.description("Turn usage telemetry on")
|
|
204
|
+
.action(() => (0, telemetry_js_1.telemetryEnableCommand)());
|
|
205
|
+
telemetryGroup
|
|
206
|
+
.command("disable")
|
|
207
|
+
.description("Turn usage telemetry off")
|
|
208
|
+
.action(() => (0, telemetry_js_1.telemetryDisableCommand)());
|
|
209
|
+
telemetryGroup
|
|
210
|
+
.command("status")
|
|
211
|
+
.description("Show whether usage telemetry is on, and why not")
|
|
212
|
+
.action(() => (0, telemetry_js_1.telemetryStatusCommand)());
|
|
258
213
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
259
214
|
// Backward-compatible aliases (flat commands)
|
|
260
215
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
261
216
|
program
|
|
262
217
|
.command("search <query>")
|
|
263
|
-
.description(
|
|
218
|
+
.description(`Search for APIs (alias for '${(0, utils_js_1.cliName)()} api search')`)
|
|
264
219
|
.option("-l, --limit <number>", "Max results", "10")
|
|
265
|
-
.
|
|
266
|
-
|
|
220
|
+
.option("--json", "Print JSON")
|
|
221
|
+
.action((0, command_actions_js_1.asyncAction)(async (query, options) => {
|
|
222
|
+
await (0, command_actions_js_1.runTrackedSearch)("search", query, () => (0, search_js_1.searchCommand)(query, options));
|
|
267
223
|
}));
|
|
268
224
|
program
|
|
269
225
|
.command("run <api> <path>")
|
|
270
|
-
.description(
|
|
271
|
-
.option("-X, --method <method>", "HTTP method
|
|
226
|
+
.description(`Call an API endpoint (alias for '${(0, utils_js_1.cliName)()} api run')`)
|
|
227
|
+
.option("-X, --method <method>", "HTTP method (default: POST with a body, else GET)")
|
|
272
228
|
.option("-q, --query <params...>", "Query params (key=value)")
|
|
273
|
-
.option("-b, --body <json>", "Request body JSON")
|
|
229
|
+
.option("-b, --body <json>", "Request body JSON ('-' reads stdin)")
|
|
274
230
|
.option("-d, --data <json>", "Alias for --body")
|
|
275
|
-
.option("--raw", "
|
|
231
|
+
.option("--raw", "Print only the response JSON on stdout (the cost goes to stderr)")
|
|
276
232
|
.option("-o, --output <file>", "Save response to file (auto-detects binary like images)")
|
|
277
233
|
.option("--dry-run", "Estimate cost without executing the call")
|
|
278
|
-
.
|
|
234
|
+
.option("--search-id <id>", "The search that led to this call (default: the last search, if it returned this endpoint)")
|
|
235
|
+
.action((0, command_actions_js_1.asyncAction)(async (api, path, options) => {
|
|
279
236
|
(0, analytics_js_1.trackEvent)("run", { api, path });
|
|
280
237
|
await (0, run_js_1.runCommand)(api, path, options);
|
|
281
238
|
}));
|
|
282
239
|
program
|
|
283
240
|
.command("code <api> <path>")
|
|
284
|
-
.description(
|
|
241
|
+
.description(`Generate integration code (alias for '${(0, utils_js_1.cliName)()} api code')`)
|
|
285
242
|
.option("-l, --lang <language>", "Language: typescript, python, curl", "typescript")
|
|
286
|
-
.action(asyncAction(async (api, path, options) => {
|
|
243
|
+
.action((0, command_actions_js_1.asyncAction)(async (api, path, options) => {
|
|
287
244
|
(0, analytics_js_1.trackEvent)("code", { api, path });
|
|
288
245
|
await (0, code_js_1.codeCommand)(api, path, options);
|
|
289
246
|
}));
|
|
247
|
+
program.addHelpText("after", () => {
|
|
248
|
+
const orth = (0, utils_js_1.cliName)();
|
|
249
|
+
return `
|
|
250
|
+
Examples:
|
|
251
|
+
${orth} login # sign in through the browser
|
|
252
|
+
export ORTHOGONAL_API_KEY=orth_live_... # or use a key, no login needed
|
|
253
|
+
${orth} api search "send an email" --json # find endpoints
|
|
254
|
+
${orth} api show tavily /search --json # parameters and price
|
|
255
|
+
${orth} run tavily /search -b '{"query":"AI news"}' --dry-run
|
|
256
|
+
${orth} run tavily /search -b '{"query":"AI news"}' --raw | jq .results
|
|
257
|
+
${orth} balance --json
|
|
258
|
+
|
|
259
|
+
Every command exits 1 on failure; --json and --raw print only JSON on stdout.`;
|
|
260
|
+
});
|
|
290
261
|
program.parse();
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SearchResponse } from "./api.js";
|
|
2
|
+
/**
|
|
3
|
+
* The last search's `searchId` and the endpoints it returned, so the `run`
|
|
4
|
+
* that follows it can name the search that led to the call. Each search
|
|
5
|
+
* replaces it; a run sends it only for an endpoint that search returned,
|
|
6
|
+
* with the same key, within an hour, so an unrelated call is never linked.
|
|
7
|
+
* Remembering is best effort: it never fails a search or a run.
|
|
8
|
+
*/
|
|
9
|
+
export interface LastSearch {
|
|
10
|
+
id: string;
|
|
11
|
+
at: number;
|
|
12
|
+
/** A fingerprint of the key that searched (never the key itself). */
|
|
13
|
+
key?: string;
|
|
14
|
+
/** "slug path" for every endpoint returned, under its card and member slug. */
|
|
15
|
+
endpoints: string[];
|
|
16
|
+
}
|
|
17
|
+
export declare function rememberSearch(response: SearchResponse, now?: number): void;
|
|
18
|
+
/** The last search's id when it returned this endpoint, with this key, in the last hour. */
|
|
19
|
+
export declare function searchIdFor(api: string, path: string, now?: number): string | undefined;
|
|
@@ -0,0 +1,60 @@
|
|
|
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.rememberSearch = rememberSearch;
|
|
7
|
+
exports.searchIdFor = searchIdFor;
|
|
8
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
9
|
+
const config_js_1 = require("./config.js");
|
|
10
|
+
const MAX_AGE_MS = 60 * 60 * 1000;
|
|
11
|
+
const keyPrint = () => {
|
|
12
|
+
const key = (0, config_js_1.getApiKey)();
|
|
13
|
+
return key ? crypto_1.default.createHash("sha256").update(key).digest("hex").slice(0, 16) : "";
|
|
14
|
+
};
|
|
15
|
+
const normalize = (path) => (path.startsWith("/") ? path : `/${path}`).replace(/(.)\/+$/, "$1");
|
|
16
|
+
const entry = (slug, path) => `${slug.toLowerCase()} ${normalize(path)}`;
|
|
17
|
+
/** A returned path matches the run's, its {params} standing for one segment. */
|
|
18
|
+
function matches(stored, slug, path) {
|
|
19
|
+
const space = stored.indexOf(" ");
|
|
20
|
+
if (stored.slice(0, space) !== slug.toLowerCase())
|
|
21
|
+
return false;
|
|
22
|
+
const pattern = stored
|
|
23
|
+
.slice(space + 1)
|
|
24
|
+
.split(/\{[^/{}]+\}/)
|
|
25
|
+
.map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))
|
|
26
|
+
.join("[^/]+");
|
|
27
|
+
return new RegExp(`^${pattern}$`).test(normalize(path));
|
|
28
|
+
}
|
|
29
|
+
function rememberSearch(response, now = Date.now()) {
|
|
30
|
+
try {
|
|
31
|
+
if (typeof response.searchId !== "string") {
|
|
32
|
+
config_js_1.config.delete("lastSearch");
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const endpoints = new Set();
|
|
36
|
+
for (const api of response.results ?? []) {
|
|
37
|
+
for (const endpoint of api.endpoints ?? []) {
|
|
38
|
+
endpoints.add(entry(api.slug, endpoint.path));
|
|
39
|
+
if (endpoint.apiSlug)
|
|
40
|
+
endpoints.add(entry(endpoint.apiSlug, endpoint.path));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
config_js_1.config.set("lastSearch", { id: response.searchId, at: now, key: keyPrint(), endpoints: [...endpoints] });
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
// A read-only config only loses the link.
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** The last search's id when it returned this endpoint, with this key, in the last hour. */
|
|
50
|
+
function searchIdFor(api, path, now = Date.now()) {
|
|
51
|
+
try {
|
|
52
|
+
const last = config_js_1.config.get("lastSearch");
|
|
53
|
+
if (!last || now - last.at > MAX_AGE_MS || last.key !== keyPrint())
|
|
54
|
+
return undefined;
|
|
55
|
+
return last.endpoints.some((stored) => matches(stored, api, path)) ? last.id : undefined;
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -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
|
+
}
|