@orth/cli 0.2.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/README.md +192 -0
- package/dist/analytics.d.ts +5 -0
- package/dist/analytics.js +53 -0
- package/dist/api.d.ts +81 -0
- package/dist/api.js +85 -0
- package/dist/commands/account.d.ts +4 -0
- package/dist/commands/account.js +60 -0
- package/dist/commands/api.d.ts +6 -0
- package/dist/commands/api.js +150 -0
- package/dist/commands/apiRequest.d.ts +6 -0
- package/dist/commands/apiRequest.js +36 -0
- package/dist/commands/auth.d.ts +5 -0
- package/dist/commands/auth.js +42 -0
- package/dist/commands/code.d.ts +3 -0
- package/dist/commands/code.js +43 -0
- package/dist/commands/run.d.ts +7 -0
- package/dist/commands/run.js +78 -0
- package/dist/commands/search.d.ts +3 -0
- package/dist/commands/search.js +47 -0
- package/dist/commands/skills.d.ts +28 -0
- package/dist/commands/skills.js +638 -0
- package/dist/config.d.ts +10 -0
- package/dist/config.js +36 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +249 -0
- package/package.json +57 -0
|
@@ -0,0 +1,42 @@
|
|
|
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.loginCommand = loginCommand;
|
|
7
|
+
exports.logoutCommand = logoutCommand;
|
|
8
|
+
exports.whoamiCommand = whoamiCommand;
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
const config_js_1 = require("../config.js");
|
|
11
|
+
async function loginCommand(options) {
|
|
12
|
+
const key = options.key || process.env.ORTHOGONAL_API_KEY;
|
|
13
|
+
if (!key) {
|
|
14
|
+
console.log(chalk_1.default.yellow("Usage: orth login --key <your-api-key>"));
|
|
15
|
+
console.log(chalk_1.default.gray("\nGet your API key at: https://orthogonal.com/dashboard/settings/api-keys"));
|
|
16
|
+
console.log(chalk_1.default.gray("Or set ORTHOGONAL_API_KEY environment variable"));
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
// Validate the key format
|
|
20
|
+
if (!key.startsWith("orth_")) {
|
|
21
|
+
console.error(chalk_1.default.red("Invalid API key format. Keys should start with 'orth_'"));
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
(0, config_js_1.setApiKey)(key);
|
|
25
|
+
console.log(chalk_1.default.green("✓ Logged in successfully!"));
|
|
26
|
+
console.log(chalk_1.default.gray(` Key: ${key.slice(0, 15)}...${key.slice(-4)}`));
|
|
27
|
+
}
|
|
28
|
+
async function logoutCommand() {
|
|
29
|
+
(0, config_js_1.clearApiKey)();
|
|
30
|
+
console.log(chalk_1.default.green("✓ Logged out. API key removed."));
|
|
31
|
+
}
|
|
32
|
+
async function whoamiCommand() {
|
|
33
|
+
const key = (0, config_js_1.getApiKey)();
|
|
34
|
+
if (!key) {
|
|
35
|
+
console.log(chalk_1.default.yellow("Not authenticated"));
|
|
36
|
+
console.log(chalk_1.default.gray("Run 'orth login' to authenticate"));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
console.log(chalk_1.default.green("✓ Authenticated"));
|
|
40
|
+
console.log(chalk_1.default.gray(` Key: ${key.slice(0, 15)}...${key.slice(-4)}`));
|
|
41
|
+
console.log(chalk_1.default.gray(` Source: ${process.env.ORTHOGONAL_API_KEY ? "environment" : "config file"}`));
|
|
42
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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.codeCommand = codeCommand;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const ora_1 = __importDefault(require("ora"));
|
|
9
|
+
const api_js_1 = require("../api.js");
|
|
10
|
+
const LANG_MAP = {
|
|
11
|
+
typescript: "orth-sdk",
|
|
12
|
+
ts: "orth-sdk",
|
|
13
|
+
python: "x402-python",
|
|
14
|
+
py: "x402-python",
|
|
15
|
+
curl: "curl",
|
|
16
|
+
sdk: "orth-sdk",
|
|
17
|
+
run: "run-api",
|
|
18
|
+
};
|
|
19
|
+
async function codeCommand(api, path, options) {
|
|
20
|
+
const spinner = (0, ora_1.default)("Generating code...").start();
|
|
21
|
+
try {
|
|
22
|
+
const format = LANG_MAP[options.lang.toLowerCase()] || options.lang;
|
|
23
|
+
const data = await (0, api_js_1.integrate)(api, path, format);
|
|
24
|
+
spinner.stop();
|
|
25
|
+
console.log(chalk_1.default.bold(`\n${chalk_1.default.cyan(api)}${chalk_1.default.white(path)} - ${options.lang}\n`));
|
|
26
|
+
const snippets = data.snippets;
|
|
27
|
+
const code = snippets[format] ||
|
|
28
|
+
snippets["orth-sdk"] ||
|
|
29
|
+
Object.values(snippets)[0];
|
|
30
|
+
if (code) {
|
|
31
|
+
console.log(code);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
console.log(chalk_1.default.yellow("No code snippet available for this format."));
|
|
35
|
+
console.log(chalk_1.default.gray("Available formats: typescript, python, curl"));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
spinner.stop();
|
|
40
|
+
console.error(chalk_1.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
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.runCommand = runCommand;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const ora_1 = __importDefault(require("ora"));
|
|
9
|
+
const api_js_1 = require("../api.js");
|
|
10
|
+
async function runCommand(api, path, options) {
|
|
11
|
+
const spinner = (0, ora_1.default)(`Calling ${api}${path}...`).start();
|
|
12
|
+
try {
|
|
13
|
+
// Parse query params
|
|
14
|
+
const query = {};
|
|
15
|
+
if (options.query) {
|
|
16
|
+
for (const param of options.query) {
|
|
17
|
+
const [key, value] = param.split("=");
|
|
18
|
+
if (key && value !== undefined) {
|
|
19
|
+
query[key] = value;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// Parse body
|
|
24
|
+
let body = undefined;
|
|
25
|
+
const bodyJson = options.body || options.data;
|
|
26
|
+
if (bodyJson) {
|
|
27
|
+
try {
|
|
28
|
+
body = JSON.parse(bodyJson);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
spinner.stop();
|
|
32
|
+
console.error(chalk_1.default.red("Error: Invalid JSON in --body"));
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// Check for stdin input
|
|
37
|
+
if (!process.stdin.isTTY && !body) {
|
|
38
|
+
const chunks = [];
|
|
39
|
+
for await (const chunk of process.stdin) {
|
|
40
|
+
chunks.push(chunk);
|
|
41
|
+
}
|
|
42
|
+
const input = Buffer.concat(chunks).toString().trim();
|
|
43
|
+
if (input) {
|
|
44
|
+
try {
|
|
45
|
+
body = JSON.parse(input);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
spinner.stop();
|
|
49
|
+
console.error(chalk_1.default.red("Error: Invalid JSON from stdin"));
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const result = await (0, api_js_1.run)(api, path, {
|
|
55
|
+
method: options.method,
|
|
56
|
+
query: Object.keys(query).length > 0 ? query : undefined,
|
|
57
|
+
body,
|
|
58
|
+
});
|
|
59
|
+
spinner.stop();
|
|
60
|
+
if (options.raw) {
|
|
61
|
+
console.log(JSON.stringify(result.data, null, 2));
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
// Show cost
|
|
65
|
+
if (result.price) {
|
|
66
|
+
console.log(chalk_1.default.gray(`Cost: $${result.price}`));
|
|
67
|
+
}
|
|
68
|
+
// Pretty print the response
|
|
69
|
+
console.log(chalk_1.default.bold("\nResponse:\n"));
|
|
70
|
+
console.log(JSON.stringify(result.data, null, 2));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
spinner.stop();
|
|
75
|
+
console.error(chalk_1.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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.searchCommand = searchCommand;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const ora_1 = __importDefault(require("ora"));
|
|
9
|
+
const api_js_1 = require("../api.js");
|
|
10
|
+
async function searchCommand(query, options) {
|
|
11
|
+
const spinner = (0, ora_1.default)("Searching APIs...").start();
|
|
12
|
+
try {
|
|
13
|
+
const data = await (0, api_js_1.search)(query, parseInt(options.limit, 10));
|
|
14
|
+
spinner.stop();
|
|
15
|
+
if (!data.results || data.results.length === 0) {
|
|
16
|
+
console.log(chalk_1.default.yellow("No APIs found matching your query."));
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
console.log(chalk_1.default.bold(`\nFound ${data.apisCount} APIs with ${data.count} matching endpoints:\n`));
|
|
20
|
+
for (const api of data.results) {
|
|
21
|
+
console.log(chalk_1.default.cyan.bold(`${api.name}`) + chalk_1.default.gray(` (${api.slug})`));
|
|
22
|
+
for (const endpoint of api.endpoints.slice(0, 3)) {
|
|
23
|
+
const method = endpoint.method.padEnd(6);
|
|
24
|
+
const price = endpoint.price ? chalk_1.default.green(`$${endpoint.price.toFixed(2)}`) : chalk_1.default.gray("free");
|
|
25
|
+
console.log(chalk_1.default.gray(" ") +
|
|
26
|
+
chalk_1.default.yellow(method) +
|
|
27
|
+
chalk_1.default.white(endpoint.path) +
|
|
28
|
+
chalk_1.default.gray(" - ") +
|
|
29
|
+
price);
|
|
30
|
+
if (endpoint.description) {
|
|
31
|
+
console.log(chalk_1.default.gray(` ${endpoint.description.slice(0, 80)}${endpoint.description.length > 80 ? "..." : ""}`));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (api.endpoints.length > 3) {
|
|
35
|
+
console.log(chalk_1.default.gray(` ... and ${api.endpoints.length - 3} more endpoints`));
|
|
36
|
+
}
|
|
37
|
+
console.log();
|
|
38
|
+
}
|
|
39
|
+
console.log(chalk_1.default.gray(`Run 'orth api <slug>' to see all endpoints for an API`));
|
|
40
|
+
console.log(chalk_1.default.gray(`Run 'orth run <api> <path>' to call an endpoint`));
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
spinner.stop();
|
|
44
|
+
console.error(chalk_1.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare function skillsListCommand(options: {
|
|
2
|
+
limit: string;
|
|
3
|
+
}): Promise<void>;
|
|
4
|
+
export declare function skillsSearchCommand(query: string, options: {
|
|
5
|
+
limit: string;
|
|
6
|
+
}): Promise<void>;
|
|
7
|
+
export declare function skillsShowCommand(slug: string): Promise<void>;
|
|
8
|
+
export declare function skillsCreateCommand(githubRepo: string, options: {
|
|
9
|
+
path?: string;
|
|
10
|
+
ref?: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
}): Promise<void>;
|
|
13
|
+
export declare function skillsInstallCommand(slug: string, options: {
|
|
14
|
+
agent?: string;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
export declare function skillsInitCommand(name: string | undefined, options: {
|
|
17
|
+
bare?: boolean;
|
|
18
|
+
path?: string;
|
|
19
|
+
}): Promise<void>;
|
|
20
|
+
export declare function skillsSubmitCommand(inputPath: string | undefined, options: {
|
|
21
|
+
name?: string;
|
|
22
|
+
tags?: string;
|
|
23
|
+
}): Promise<void>;
|
|
24
|
+
export declare function skillsRequestVerificationCommand(slug: string): Promise<void>;
|
|
25
|
+
export declare function skillsPublishCommand(slug: string, options: {
|
|
26
|
+
unpublish?: boolean;
|
|
27
|
+
}): Promise<void>;
|
|
28
|
+
export declare function skillsRequestCommand(input: string): Promise<void>;
|