@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
@@ -0,0 +1,74 @@
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.skillsRequestVerificationCommand = skillsRequestVerificationCommand;
7
+ exports.skillsPublishCommand = skillsPublishCommand;
8
+ exports.skillsRequestCommand = skillsRequestCommand;
9
+ const chalk_1 = __importDefault(require("chalk"));
10
+ const ora_1 = __importDefault(require("ora"));
11
+ const api_js_1 = require("../../api.js");
12
+ const urls_js_1 = require("../../urls.js");
13
+ const utils_js_1 = require("../../utils.js");
14
+ // ─────────────────────────────────────────────────────────────────────────────
15
+ // orth skills request-verification <slug>
16
+ // ─────────────────────────────────────────────────────────────────────────────
17
+ async function skillsRequestVerificationCommand(slug) {
18
+ const spinner = (0, ora_1.default)("Submitting verification request...").start();
19
+ try {
20
+ // First get the skill to find its ID
21
+ const skillData = await (0, api_js_1.apiRequest)(`/skills/${slug}`);
22
+ if (!skillData.skill) {
23
+ spinner.stop();
24
+ console.error(chalk_1.default.red(`Error: Skill '${slug}' not found`));
25
+ process.exit(1);
26
+ }
27
+ // Request verification via the public API endpoint
28
+ await (0, api_js_1.apiRequest)(`/skills/${slug}/request-verification`, {
29
+ method: "POST",
30
+ });
31
+ spinner.stop();
32
+ console.log(chalk_1.default.green("\n✓ Verification request submitted!"));
33
+ console.log(chalk_1.default.gray("Our team will review your skill. Once verified, you can toggle discoverability anytime."));
34
+ console.log(chalk_1.default.gray("Check the status on your dashboard."));
35
+ }
36
+ catch (error) {
37
+ spinner.stop();
38
+ console.error(chalk_1.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
39
+ process.exit(1);
40
+ }
41
+ }
42
+ // ─────────────────────────────────────────────────────────────────────────────
43
+ // orth skills publish <slug> (deprecated - redirects to request-verification)
44
+ // ─────────────────────────────────────────────────────────────────────────────
45
+ async function skillsPublishCommand(slug, options) {
46
+ console.log(chalk_1.default.yellow("Note: Direct publishing has been replaced with a verification workflow."));
47
+ console.log(chalk_1.default.white(`\nTo request your skill to be verified, run:\n ${chalk_1.default.cyan(`${(0, utils_js_1.cliName)()} skills request-verification ${slug}`)}`));
48
+ console.log(chalk_1.default.white("Once verified, you can toggle discoverability from your dashboard."));
49
+ console.log(chalk_1.default.gray(`\nOr manage from the dashboard: ${(0, urls_js_1.webBaseUrl)()}/agents`));
50
+ }
51
+ // ─────────────────────────────────────────────────────────────────────────────
52
+ // orth skills request <input>
53
+ // ─────────────────────────────────────────────────────────────────────────────
54
+ async function skillsRequestCommand(input) {
55
+ const spinner = (0, ora_1.default)("Submitting skill request...").start();
56
+ try {
57
+ // Determine if input is a GitHub URL or description
58
+ const isGitHub = input.includes("github.com") ||
59
+ /^[a-zA-Z0-9_-]+\/[a-zA-Z0-9_.-]+$/.test(input);
60
+ const body = isGitHub ? { githubRepo: input } : { description: input };
61
+ await (0, api_js_1.apiRequest)("/requests/skill", {
62
+ method: "POST",
63
+ body,
64
+ });
65
+ spinner.stop();
66
+ console.log(chalk_1.default.green("\n✓ Skill request submitted!"));
67
+ console.log(chalk_1.default.gray("Our team has been notified and will review your request."));
68
+ }
69
+ catch (error) {
70
+ spinner.stop();
71
+ console.error(chalk_1.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
72
+ process.exit(1);
73
+ }
74
+ }
@@ -0,0 +1,3 @@
1
+ export declare function telemetryEnableCommand(): void;
2
+ export declare function telemetryDisableCommand(): void;
3
+ export declare function telemetryStatusCommand(): void;
@@ -0,0 +1,38 @@
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.telemetryEnableCommand = telemetryEnableCommand;
7
+ exports.telemetryDisableCommand = telemetryDisableCommand;
8
+ exports.telemetryStatusCommand = telemetryStatusCommand;
9
+ const chalk_1 = __importDefault(require("chalk"));
10
+ const analytics_js_1 = require("../analytics.js");
11
+ const config_js_1 = require("../config.js");
12
+ const utils_js_1 = require("../utils.js");
13
+ const REASONS = {
14
+ DO_NOT_TRACK: "DO_NOT_TRACK is set",
15
+ ORTH_TELEMETRY_DISABLED: "ORTH_TELEMETRY_DISABLED is set",
16
+ config: `disabled with '${(0, utils_js_1.cliName)()} telemetry disable'`,
17
+ };
18
+ function telemetryEnableCommand() {
19
+ (0, config_js_1.setTelemetryEnabled)(true);
20
+ console.log(chalk_1.default.green("✓ Telemetry enabled"));
21
+ const reason = (0, analytics_js_1.telemetryDisabledReason)();
22
+ if (reason)
23
+ console.log(chalk_1.default.yellow(` Still off: ${REASONS[reason]}`));
24
+ }
25
+ function telemetryDisableCommand() {
26
+ (0, config_js_1.setTelemetryEnabled)(false);
27
+ console.log(chalk_1.default.green("✓ Telemetry disabled"));
28
+ }
29
+ function telemetryStatusCommand() {
30
+ const reason = (0, analytics_js_1.telemetryDisabledReason)();
31
+ if (reason) {
32
+ console.log(`Telemetry is off (${REASONS[reason]})`);
33
+ return;
34
+ }
35
+ console.log("Telemetry is on");
36
+ console.log(chalk_1.default.gray(" Sends command name, exit code, duration, CLI version and OS, linked to your API key."));
37
+ console.log(chalk_1.default.gray(` Turn off with '${(0, utils_js_1.cliName)()} telemetry disable', ORTH_TELEMETRY_DISABLED=1 or DO_NOT_TRACK=1.`));
38
+ }
package/dist/config.d.ts CHANGED
@@ -1,10 +1,57 @@
1
1
  import Conf from "conf";
2
+ export interface Organization {
3
+ id: string;
4
+ name: string;
5
+ }
6
+ /** A team with a stored key: a company team, or the personal team. */
7
+ export interface KeyTeam {
8
+ /** The company team's organization id; "personal" for the personal team. */
9
+ id: string;
10
+ name: string;
11
+ }
12
+ export declare const PERSONAL_TEAM: KeyTeam;
13
+ type TeamKeys = Record<string, {
14
+ name: string;
15
+ apiKey: string;
16
+ }>;
2
17
  interface ConfigSchema {
18
+ /** The key every command sends: the active team's. */
3
19
  apiKey?: string;
20
+ /** One key per team signed in to, by team id (`orth team use` switches). */
21
+ teamKeys?: TeamKeys;
22
+ telemetry?: boolean;
23
+ telemetryNoticeShown?: boolean;
24
+ installId?: string;
25
+ /** The default organization per API server (org ids differ between them). */
26
+ organizations?: Record<string, Organization>;
4
27
  }
5
28
  export declare const config: Conf<ConfigSchema>;
6
29
  export declare function getApiKey(): string | undefined;
7
- export declare function setApiKey(key: string): void;
30
+ /**
31
+ * Stores a team's key (replacing its last one) and makes it the active one.
32
+ * A key given without a team (`login --key`) is filed as the personal team's.
33
+ */
34
+ export declare function setApiKey(key: string, team?: KeyTeam): void;
8
35
  export declare function clearApiKey(): void;
36
+ /** The teams with a stored key, and which one is active (commands send its key). */
37
+ export declare function getKeyTeams(): Array<KeyTeam & {
38
+ active: boolean;
39
+ }>;
40
+ /** Makes a stored team's key the one commands send; false if it has none. */
41
+ export declare function switchKeyTeam(id: string): boolean;
9
42
  export declare function requireApiKey(): string;
43
+ /** Usage telemetry is on unless `orth telemetry disable` stored false. */
44
+ export declare function getTelemetryEnabled(): boolean;
45
+ export declare function setTelemetryEnabled(enabled: boolean): void;
46
+ /** Whether the one-time telemetry notice has been printed. */
47
+ export declare function getTelemetryNoticeShown(): boolean;
48
+ export declare function setTelemetryNoticeShown(): void;
49
+ /**
50
+ * A random id for this install, made on first use: it ties a login attempt
51
+ * (sent before any key exists) to the events that follow. Nothing else.
52
+ */
53
+ export declare function getInstallId(): string;
54
+ /** The organization this server's commands act for, once chosen. */
55
+ export declare function getDefaultOrganization(server: string): Organization | undefined;
56
+ export declare function setDefaultOrganization(server: string, organization: Organization): void;
10
57
  export {};
package/dist/config.js CHANGED
@@ -3,34 +3,130 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.config = void 0;
6
+ exports.config = exports.PERSONAL_TEAM = void 0;
7
7
  exports.getApiKey = getApiKey;
8
8
  exports.setApiKey = setApiKey;
9
9
  exports.clearApiKey = clearApiKey;
10
+ exports.getKeyTeams = getKeyTeams;
11
+ exports.switchKeyTeam = switchKeyTeam;
10
12
  exports.requireApiKey = requireApiKey;
13
+ exports.getTelemetryEnabled = getTelemetryEnabled;
14
+ exports.setTelemetryEnabled = setTelemetryEnabled;
15
+ exports.getTelemetryNoticeShown = getTelemetryNoticeShown;
16
+ exports.setTelemetryNoticeShown = setTelemetryNoticeShown;
17
+ exports.getInstallId = getInstallId;
18
+ exports.getDefaultOrganization = getDefaultOrganization;
19
+ exports.setDefaultOrganization = setDefaultOrganization;
11
20
  const conf_1 = __importDefault(require("conf"));
21
+ const crypto_1 = __importDefault(require("crypto"));
22
+ const utils_js_1 = require("./utils.js");
23
+ exports.PERSONAL_TEAM = { id: "personal", name: "Personal team" };
12
24
  exports.config = new conf_1.default({
13
25
  projectName: "orthogonal-cli",
14
26
  schema: {
15
27
  apiKey: {
16
28
  type: "string",
17
29
  },
30
+ teamKeys: {
31
+ type: "object",
32
+ },
33
+ telemetry: {
34
+ type: "boolean",
35
+ },
36
+ telemetryNoticeShown: {
37
+ type: "boolean",
38
+ },
39
+ installId: {
40
+ type: "string",
41
+ },
42
+ organizations: {
43
+ type: "object",
44
+ },
18
45
  },
19
46
  });
20
47
  function getApiKey() {
21
48
  return process.env.ORTHOGONAL_API_KEY || exports.config.get("apiKey");
22
49
  }
23
- function setApiKey(key) {
50
+ /**
51
+ * Every stored key by team. A config from before teams holds only `apiKey`:
52
+ * that key is the personal team's.
53
+ */
54
+ function teamKeys() {
55
+ const stored = exports.config.get("teamKeys") ?? {};
56
+ const active = exports.config.get("apiKey");
57
+ if (!active || Object.values(stored).some((team) => team.apiKey === active))
58
+ return stored;
59
+ return { ...stored, [exports.PERSONAL_TEAM.id]: { name: exports.PERSONAL_TEAM.name, apiKey: active } };
60
+ }
61
+ /**
62
+ * Stores a team's key (replacing its last one) and makes it the active one.
63
+ * A key given without a team (`login --key`) is filed as the personal team's.
64
+ */
65
+ function setApiKey(key, team = exports.PERSONAL_TEAM) {
66
+ exports.config.set("teamKeys", { ...teamKeys(), [team.id]: { name: team.name, apiKey: key } });
24
67
  exports.config.set("apiKey", key);
25
68
  }
26
69
  function clearApiKey() {
27
70
  exports.config.delete("apiKey");
71
+ exports.config.delete("teamKeys");
72
+ }
73
+ /** The teams with a stored key, and which one is active (commands send its key). */
74
+ function getKeyTeams() {
75
+ const active = exports.config.get("apiKey");
76
+ return Object.entries(teamKeys()).map(([id, team]) => ({
77
+ id,
78
+ name: team.name,
79
+ active: team.apiKey === active,
80
+ }));
81
+ }
82
+ /** Makes a stored team's key the one commands send; false if it has none. */
83
+ function switchKeyTeam(id) {
84
+ const keys = teamKeys();
85
+ const team = keys[id];
86
+ if (!team)
87
+ return false;
88
+ exports.config.set("teamKeys", keys);
89
+ exports.config.set("apiKey", team.apiKey);
90
+ return true;
28
91
  }
29
92
  function requireApiKey() {
30
93
  const key = getApiKey();
31
94
  if (!key) {
32
- console.error("Error: Not authenticated. Run 'orth login' first or set ORTHOGONAL_API_KEY.");
95
+ console.error(`Error: Not authenticated. Run '${(0, utils_js_1.cliName)()} login' first or set ORTHOGONAL_API_KEY.`);
33
96
  process.exit(1);
34
97
  }
35
98
  return key;
36
99
  }
100
+ /** Usage telemetry is on unless `orth telemetry disable` stored false. */
101
+ function getTelemetryEnabled() {
102
+ return exports.config.get("telemetry") !== false;
103
+ }
104
+ function setTelemetryEnabled(enabled) {
105
+ exports.config.set("telemetry", enabled);
106
+ }
107
+ /** Whether the one-time telemetry notice has been printed. */
108
+ function getTelemetryNoticeShown() {
109
+ return exports.config.get("telemetryNoticeShown") === true;
110
+ }
111
+ function setTelemetryNoticeShown() {
112
+ exports.config.set("telemetryNoticeShown", true);
113
+ }
114
+ /**
115
+ * A random id for this install, made on first use: it ties a login attempt
116
+ * (sent before any key exists) to the events that follow. Nothing else.
117
+ */
118
+ function getInstallId() {
119
+ const stored = exports.config.get("installId");
120
+ if (stored)
121
+ return stored;
122
+ const id = crypto_1.default.randomUUID();
123
+ exports.config.set("installId", id);
124
+ return id;
125
+ }
126
+ /** The organization this server's commands act for, once chosen. */
127
+ function getDefaultOrganization(server) {
128
+ return exports.config.get("organizations")?.[server];
129
+ }
130
+ function setDefaultOrganization(server, organization) {
131
+ exports.config.set("organizations", { ...exports.config.get("organizations"), [server]: organization });
132
+ }
package/dist/http.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * fetch for every call the CLI makes to Orthogonal: the API, telemetry and
3
+ * the payment doors, each with Vercel's bypass header where it may go
4
+ * (protectionBypass).
5
+ */
6
+ export declare function orthFetch(url: string, init?: Omit<RequestInit, "headers"> & {
7
+ headers?: Record<string, string>;
8
+ }): Promise<Response>;
9
+ /**
10
+ * When Vercel answered `url` itself, before Orthogonal could: a deployment
11
+ * behind Vercel Authentication (dev.mono) answers a JSON request with a 401
12
+ * whose body names its `protection`, and any other with a redirect to
13
+ * vercel.com's sign-in. What to do about it, or undefined for any other answer.
14
+ */
15
+ export declare function vercelProtectionMessage(url: string, response: Response, body: unknown): string | undefined;
package/dist/http.js ADDED
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.orthFetch = orthFetch;
4
+ exports.vercelProtectionMessage = vercelProtectionMessage;
5
+ const urls_js_1 = require("./urls.js");
6
+ /**
7
+ * fetch for every call the CLI makes to Orthogonal: the API, telemetry and
8
+ * the payment doors, each with Vercel's bypass header where it may go
9
+ * (protectionBypass).
10
+ */
11
+ function orthFetch(url, init = {}) {
12
+ return fetch(url, { ...init, headers: { ...init.headers, ...(0, urls_js_1.protectionBypass)(url) } });
13
+ }
14
+ function isRecord(value) {
15
+ return typeof value === "object" && value !== null;
16
+ }
17
+ function hostOf(url) {
18
+ try {
19
+ return new URL(url).hostname;
20
+ }
21
+ catch {
22
+ return "";
23
+ }
24
+ }
25
+ /**
26
+ * When Vercel answered `url` itself, before Orthogonal could: a deployment
27
+ * behind Vercel Authentication (dev.mono) answers a JSON request with a 401
28
+ * whose body names its `protection`, and any other with a redirect to
29
+ * vercel.com's sign-in. What to do about it, or undefined for any other answer.
30
+ */
31
+ function vercelProtectionMessage(url, response, body) {
32
+ const signIn = response.redirected && /(^|\.)vercel\.com$/.test(hostOf(response.url));
33
+ const refused = response.status === 401 && isRecord(body) && isRecord(body.protection);
34
+ if (!signIn && !refused)
35
+ return undefined;
36
+ const host = new URL(url).host;
37
+ const how = 'as "Staff builds" in packages/cli/README.md shows, then try again.';
38
+ return Object.keys((0, urls_js_1.protectionBypass)(url)).length > 0
39
+ ? `Vercel Authentication on ${host} refused the bypass secret in VERCEL_AUTOMATION_BYPASS_SECRET; it may have been rotated. Read it again ${how}`
40
+ : `${host} is behind Vercel Authentication, which refused this call before it reached Orthogonal. Export VERCEL_AUTOMATION_BYPASS_SECRET ${how}`;
41
+ }