@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,73 @@
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.onboardGuideCommand = onboardGuideCommand;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const urls_js_1 = require("../../urls.js");
9
+ const utils_js_1 = require("../../utils.js");
10
+ const shared_js_1 = require("./shared.js");
11
+ /**
12
+ * orth api-onboarding guide - How listing an API works, for people and agents
13
+ * (--json: the same text as {"guide": ...}, for an agent that adds --json
14
+ * to every command)
15
+ */
16
+ function onboardGuideCommand(options = {}) {
17
+ const c = (rest) => chalk_1.default.cyan((0, shared_js_1.cmd)(rest));
18
+ const steps = [
19
+ ["start", "start the Agent, or resume it"],
20
+ ['start -m "<reply>"', "reply in your own words, or tell it what to change"],
21
+ ['approve / deny -m "<why>"', "answer the calls the Agent asks to run"],
22
+ ["base-url <https://…>", "where the API is served from"],
23
+ ["setup, then confirm", "review the endpoints and prices, then confirm them"],
24
+ ['price "GET /path" <usd|free>', "set a price per call"],
25
+ ['leave-out "GET /path"', "keep an endpoint out of the listing"],
26
+ ["key", "add the API key (typed hidden, never in chat)"],
27
+ ["test", "one real call to every endpoint"],
28
+ ["submit / withdraw", "send it for Orthogonal's review, or take it back"],
29
+ ["resubmit / cancel", "fix a declined request, or drop one"],
30
+ ["listing", "once live: the live version, the next one, what it changes"],
31
+ ['update --sync / -m "<what>"', "open the next version with the Agent"],
32
+ ["discard", "close the next version and drop its changes"],
33
+ ]
34
+ .map(([command, what]) => ` ${chalk_1.default.cyan((command ?? "").padEnd(29))} ${what}`)
35
+ .join("\n");
36
+ const guide = `
37
+ ${chalk_1.default.bold("List your API on Orthogonal")}
38
+
39
+ Orthogonal's Agent sets your API up in the background: it reads your docs,
40
+ drafts the endpoints and prices, calls every endpoint and writes a report.
41
+ You make the decisions, and ${c("status")} always says the next one.
42
+
43
+ ${chalk_1.default.bold("1")} ${c("new <docsUrl> --name <api>")}
44
+ Orthogonal approves the request first (${c("status --watch")} waits for it).
45
+ ${chalk_1.default.bold("2")} The Agent starts by itself once the request is approved (${c("start")} starts
46
+ it if it has not, or resumes it). You can close the terminal any time.
47
+ ${chalk_1.default.bold("3")} ${c("status --watch")}
48
+ Shows where it is and the one command to run next (after ${chalk_1.default.cyan((0, shared_js_1.cmd)("").trim())}):
49
+ ${steps}
50
+ ${chalk_1.default.bold("4")} Orthogonal reviews it; ${c("status")} says when it is live, as version 1.
51
+ ${chalk_1.default.bold("5")} To change a live API: ${c("update --sync")} (or ${c('update -m "<what to change>"')})
52
+ opens the next version with the Agent; buyers keep the live one until
53
+ Orthogonal accepts it. ${c("listing")} shows the versions and what changed;
54
+ ${c("discard")} closes the next version and drops its changes.
55
+
56
+ Several organizations: ${chalk_1.default.cyan(`${(0, utils_js_1.cliName)()} org use`)}. Several APIs: name one, e.g. ${c('status "Weather"')}.
57
+ The same run shows on the dashboard link that ${c("status")} prints. ${c("stop")} pauses the Agent.
58
+ Docs, including the dashboard and MCP: ${chalk_1.default.cyan(`${(0, urls_js_1.webBaseUrl)()}/docs/list-your-api`)}
59
+
60
+ ${chalk_1.default.bold("For AI agents")}: add --json to every command, then run
61
+ ${chalk_1.default.cyan(`${(0, utils_js_1.cliName)()} <nextStep.command>`)} from ${c("status --json")}; with --json,
62
+ --watch prints once, so check again later. The Agent decides every open
63
+ choice itself and asks nothing; confirm, approve, submit, withdraw, discard
64
+ and cancel take --yes. Submit only once your user read the final report and
65
+ wants it listed. Never ask for, read or pass an API key: your user runs
66
+ ${c("key")}.
67
+ `;
68
+ if (options.json) {
69
+ console.log(JSON.stringify({ guide: (0, shared_js_1.stripAnsi)(guide).trim() }, null, 2));
70
+ return;
71
+ }
72
+ console.log(guide);
73
+ }
@@ -0,0 +1,18 @@
1
+ import { type OnboardFlowOptions } from "./shared.js";
2
+ /**
3
+ * orth api-onboarding listing [api] - The live version, the next one being
4
+ * prepared, what it changes, and Orthogonal's latest decision
5
+ */
6
+ export declare function onboardListingCommand(given: string | undefined, options: OnboardFlowOptions): Promise<void>;
7
+ /**
8
+ * orth api-onboarding update [api] - Open the next version of a live
9
+ * listing with the Agent (--sync: it checks the live one against your docs)
10
+ */
11
+ export declare function onboardUpdateCommand(given: string | undefined, options: OnboardFlowOptions & {
12
+ sync?: boolean;
13
+ }): Promise<void>;
14
+ /**
15
+ * orth api-onboarding discard [api] - Close the open version of a live
16
+ * listing and drop its changes: the live version stays
17
+ */
18
+ export declare function onboardDiscardCommand(given: string | undefined, options: OnboardFlowOptions): Promise<void>;
@@ -0,0 +1,166 @@
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.onboardListingCommand = onboardListingCommand;
7
+ exports.onboardUpdateCommand = onboardUpdateCommand;
8
+ exports.onboardDiscardCommand = onboardDiscardCommand;
9
+ const chalk_1 = __importDefault(require("chalk"));
10
+ const utils_js_1 = require("../../utils.js");
11
+ const progress_js_1 = require("./progress.js");
12
+ const requests_js_1 = require("./requests.js");
13
+ const shared_js_1 = require("./shared.js");
14
+ const UPDATE_STATES = {
15
+ live: "Live, no update open",
16
+ drafting: "Being prepared with the Agent",
17
+ in_review: "With Orthogonal for review",
18
+ changes_requested: "Orthogonal asked for changes",
19
+ declined: "Declined by Orthogonal",
20
+ };
21
+ const REVIEWS = {
22
+ approved: "Approved the request",
23
+ rejected: "Declined the request",
24
+ changes_requested: "Asked for changes",
25
+ declined: "Declined",
26
+ accepted: "Accepted",
27
+ };
28
+ const day = (at) => (0, shared_js_1.clean)(at).slice(0, 10);
29
+ const changeCount = (count) => `${count} ${count === 1 ? "change" : "changes"}`;
30
+ /** One line per change: + added, - removed, ~ changed (with its fields). */
31
+ function changeLines(changes) {
32
+ const field = (change) => `${(0, shared_js_1.clean)(change.field)}: ${(0, shared_js_1.shorten)(change.before || "(none)", 60)} → ${(0, shared_js_1.shorten)(change.after || "(none)", 60)}`;
33
+ return [
34
+ ...changes.api.map((change) => ` ~ ${field(change)}`),
35
+ ...changes.endpoints.map((endpoint) => {
36
+ const mark = { added: chalk_1.default.green("+"), removed: chalk_1.default.red("-"), changed: chalk_1.default.yellow("~") }[endpoint.kind];
37
+ const route = chalk_1.default.cyan(`${(0, shared_js_1.clean)(endpoint.method)} ${(0, shared_js_1.clean)(endpoint.path)}`);
38
+ const fields = endpoint.fields.map(field).join("; ");
39
+ return ` ${mark} ${route}${fields ? chalk_1.default.gray(` ${fields}`) : ""}`;
40
+ }),
41
+ ];
42
+ }
43
+ function printListing(listing, org, fallbackName) {
44
+ const name = listing.apiName ?? fallbackName;
45
+ console.log(chalk_1.default.bold(`\n ${name ? (0, shared_js_1.clean)(name) : "Your listing"}`) + chalk_1.default.gray(` ${(0, utils_js_1.sanitizeForTerminal)(org.name)}\n`));
46
+ if (listing.liveVersion === null) {
47
+ console.log((0, shared_js_1.row)("Live", chalk_1.default.gray("not yet: version 1 goes live once Orthogonal accepts it")));
48
+ }
49
+ else {
50
+ console.log((0, shared_js_1.row)("Live", `version ${listing.liveVersion}` +
51
+ chalk_1.default.gray(`${listing.liveSince ? ` since ${day(listing.liveSince)}` : ""} · ${listing.endpoints.length} ${listing.endpoints.length === 1 ? "endpoint" : "endpoints"}`)));
52
+ if (listing.publicUrl)
53
+ console.log((0, shared_js_1.row)("Page", chalk_1.default.cyan((0, utils_js_1.sanitizeForTerminal)(listing.publicUrl))));
54
+ if (listing.state) {
55
+ const draft = listing.draftVersion ? `version ${listing.draftVersion} · ` : "";
56
+ const count = listing.draftVersion && listing.changeCount !== null ? chalk_1.default.gray(` · ${changeCount(listing.changeCount)}`) : "";
57
+ console.log((0, shared_js_1.row)("Update", `${draft}${UPDATE_STATES[listing.state]}${count}`));
58
+ }
59
+ }
60
+ if (listing.lastReview) {
61
+ const review = listing.lastReview;
62
+ console.log((0, shared_js_1.row)("Review", `${REVIEWS[review.decision] ?? (0, shared_js_1.clean)(review.decision)}${review.version ? ` version ${review.version}` : ""}` +
63
+ chalk_1.default.gray(` on ${day(review.at)}`) +
64
+ (review.reason ? `: ${(0, shared_js_1.clean)(review.reason)}` : "")));
65
+ }
66
+ console.log((0, shared_js_1.row)("Next", chalk_1.default.bold((0, shared_js_1.clean)(listing.next))));
67
+ const command = listing.nextStep?.command;
68
+ if (command)
69
+ console.log((0, shared_js_1.row)("Run", chalk_1.default.cyan(`${(0, utils_js_1.cliName)()} ${(0, utils_js_1.sanitizeForTerminal)(command)}`)));
70
+ if (listing.draftVersion && listing.changes && (listing.changes.api.length || listing.changes.endpoints.length)) {
71
+ console.log(chalk_1.default.bold(`\n What version ${listing.draftVersion} changes`));
72
+ for (const line of changeLines(listing.changes))
73
+ console.log(line);
74
+ }
75
+ if (listing.versions.length) {
76
+ console.log(chalk_1.default.bold("\n Versions"));
77
+ for (const version of listing.versions) {
78
+ console.log(` ${`v${version.version}`.padEnd(5)} ${day(version.publishedAt)} ` +
79
+ chalk_1.default.gray(`${version.endpoints} ${version.endpoints === 1 ? "endpoint" : "endpoints"}` +
80
+ (version.changes === null ? "" : ` · ${changeCount(version.changes)}`)));
81
+ }
82
+ }
83
+ console.log();
84
+ }
85
+ /**
86
+ * orth api-onboarding listing [api] - The live version, the next one being
87
+ * prepared, what it changes, and Orthogonal's latest decision
88
+ */
89
+ async function onboardListingCommand(given, options) {
90
+ try {
91
+ const { org, requestId, apiName } = await (0, requests_js_1.stepContext)(given, options, "show the listing of", "listing", requests_js_1.approved);
92
+ const listing = await (0, shared_js_1.runTool)("listing_status", org, requestId);
93
+ if (options.json) {
94
+ console.log(JSON.stringify(listing, null, 2));
95
+ return;
96
+ }
97
+ printListing(listing, org, apiName);
98
+ }
99
+ catch (error) {
100
+ (0, shared_js_1.fail)(error);
101
+ }
102
+ }
103
+ /**
104
+ * orth api-onboarding update [api] - Open the next version of a live
105
+ * listing with the Agent (--sync: it checks the live one against your docs)
106
+ */
107
+ async function onboardUpdateCommand(given, options) {
108
+ try {
109
+ if (options.sync && options.message)
110
+ throw new Error("Pass --sync or -m, not both.");
111
+ const { org, requestId } = await (0, requests_js_1.stepContext)(given, options, "update", "update", requests_js_1.approved);
112
+ const result = await (0, shared_js_1.runTool)("start_update", org, requestId, {
113
+ ...(options.sync ? { sync: true } : {}),
114
+ ...(options.message ? { message: options.message } : {}),
115
+ });
116
+ if (options.json) {
117
+ console.log(JSON.stringify(result, null, 2));
118
+ return;
119
+ }
120
+ (0, shared_js_1.done)([
121
+ chalk_1.default.green(result.alreadyOpen ? `Version ${result.version} is already open.` : `Opened version ${result.version}.`) + ` Buyers keep version ${result.liveVersion} until Orthogonal accepts it.`,
122
+ options.sync
123
+ ? `${(0, shared_js_1.goesOn)(result.agent)} It checks version ${result.liveVersion} against your API and its docs and drafts only what differs.`
124
+ : options.message
125
+ ? `${(0, shared_js_1.goesOn)(result.agent)} It drafts what you asked.`
126
+ : `Tell the Agent what to change: ${chalk_1.default.cyan((0, shared_js_1.cmd)('start -m "<what to change>"'))}`,
127
+ `Then follow it to confirm, test and submit version ${result.version}: ${chalk_1.default.cyan((0, shared_js_1.cmd)("status --watch"))}`,
128
+ ]);
129
+ if (options.watch && result.agent) {
130
+ await (0, progress_js_1.watchProgress)(requestId, org, await (0, progress_js_1.fetchProgress)(requestId, org), 3);
131
+ }
132
+ }
133
+ catch (error) {
134
+ (0, shared_js_1.fail)(error);
135
+ }
136
+ }
137
+ /**
138
+ * orth api-onboarding discard [api] - Close the open version of a live
139
+ * listing and drop its changes: the live version stays
140
+ */
141
+ async function onboardDiscardCommand(given, options) {
142
+ try {
143
+ const { org, requestId, apiName } = await (0, requests_js_1.stepContext)(given, options, "discard", "discard", (request) => request.status === "approved" && request.setupPhase !== "submitted");
144
+ if (!options.yes) {
145
+ if (!(0, utils_js_1.isInteractive)())
146
+ throw new Error("Pass --yes to discard without a question.");
147
+ const { draftVersion, liveVersion } = await (0, shared_js_1.runTool)("listing_status", org, requestId);
148
+ if (draftVersion !== null &&
149
+ !(await (0, utils_js_1.confirmYes)(`Discard version ${draftVersion}${apiName ? ` of ${(0, shared_js_1.clean)(apiName)}` : ""}? Version ${liveVersion} stays live.`))) {
150
+ (0, shared_js_1.done)([chalk_1.default.gray("Still open.")]);
151
+ return;
152
+ }
153
+ }
154
+ const result = await (0, shared_js_1.runTool)("discard_update", org, requestId);
155
+ (0, shared_js_1.report)(options, result, () => [
156
+ result.discardedVersion === null
157
+ ? `Nothing to discard: version ${result.liveVersion} is live.`
158
+ : chalk_1.default.green(`Discarded version ${result.discardedVersion}.`) +
159
+ ` Version ${result.liveVersion} stays live, with nothing for Orthogonal to review.`,
160
+ chalk_1.default.cyan((0, shared_js_1.cmd)("listing")),
161
+ ]);
162
+ }
163
+ catch (error) {
164
+ (0, shared_js_1.fail)(error);
165
+ }
166
+ }
@@ -0,0 +1,44 @@
1
+ import type { Organization } from "../../config.js";
2
+ import { type RequestSummary } from "./shared.js";
3
+ export interface RecentMessage {
4
+ id: string;
5
+ role: string;
6
+ text: string;
7
+ tools: string[];
8
+ }
9
+ interface NextStep {
10
+ action: string;
11
+ /** The CLI command after the CLI's own name, e.g. `api-onboarding confirm`. */
12
+ command: string | null;
13
+ }
14
+ export interface Progress {
15
+ requestId: string;
16
+ apiName: string;
17
+ requestStatus: RequestSummary["status"];
18
+ dashboardUrl: string;
19
+ next: string;
20
+ nextStep?: NextStep;
21
+ note?: string | null;
22
+ setupRevision?: number;
23
+ phase?: string;
24
+ agentWorking?: boolean;
25
+ waitingFor?: string | null;
26
+ pendingAction?: string | null;
27
+ progress?: string | null;
28
+ approvals?: {
29
+ approvalId: string;
30
+ tool: string;
31
+ what: string;
32
+ input: unknown;
33
+ }[];
34
+ recent?: RecentMessage[];
35
+ }
36
+ export declare function printProgress(progress: Progress, org: Organization): void;
37
+ export declare function fetchProgress(requestId: string, org: Organization): Promise<Progress>;
38
+ /**
39
+ * Prints what is new in the conversation (new text and tools of each
40
+ * message) until the Agent stops working; `grace` polls wait for a run that
41
+ * was just started to take its turn.
42
+ */
43
+ export declare function watchProgress(requestId: string, org: Organization, first: Progress, grace?: number): Promise<void>;
44
+ export {};
@@ -0,0 +1,108 @@
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.printProgress = printProgress;
7
+ exports.fetchProgress = fetchProgress;
8
+ exports.watchProgress = watchProgress;
9
+ const chalk_1 = __importDefault(require("chalk"));
10
+ const utils_js_1 = require("../../utils.js");
11
+ const requests_js_1 = require("./requests.js");
12
+ const shared_js_1 = require("./shared.js");
13
+ const WATCH_INTERVAL_MS = 5_000;
14
+ function stateLine(progress) {
15
+ if (progress.requestStatus !== "approved")
16
+ return (0, requests_js_1.requestStatus)(progress.requestStatus);
17
+ const phase = requests_js_1.PHASES[progress.phase ?? ""] ?? progress.phase ?? "";
18
+ return progress.agentWorking
19
+ ? `${phase} ${chalk_1.default.cyan("· Agent working in the background")}`
20
+ : phase;
21
+ }
22
+ /** One message, cut to `max` characters, or whole and wrapped without `max`. */
23
+ function printMessage(message, max) {
24
+ const who = message.role === "user" ? chalk_1.default.blue("You ") : chalk_1.default.magenta("Agent");
25
+ const tools = message.tools.length ? chalk_1.default.gray(` [${message.tools.map(shared_js_1.clean).join(", ")}]`) : "";
26
+ const lines = max === undefined ? (0, shared_js_1.wrapped)(message.text, 8) : [];
27
+ if (lines.length) {
28
+ lines[0] = ` ${who} ${lines[0].trimStart()}`;
29
+ lines[lines.length - 1] += tools;
30
+ for (const line of lines)
31
+ console.log(line);
32
+ return;
33
+ }
34
+ const text = message.text && max !== undefined ? ` ${(0, shared_js_1.shorten)(message.text, max)}` : "";
35
+ console.log(` ${who}${text}${tools}`);
36
+ }
37
+ /** A row whose long value wraps under itself. */
38
+ function printWrappedRow(label, text) {
39
+ const [first, ...rest] = (0, shared_js_1.wrapped)(text, 13);
40
+ if (first === undefined)
41
+ return;
42
+ console.log((0, shared_js_1.row)(label, first.trimStart()));
43
+ for (const line of rest)
44
+ console.log(line);
45
+ }
46
+ function printProgress(progress, org) {
47
+ console.log(chalk_1.default.bold(`\n ${(0, utils_js_1.sanitizeForTerminal)(progress.apiName)}`) +
48
+ chalk_1.default.gray(` ${(0, utils_js_1.sanitizeForTerminal)(org.name)}\n`));
49
+ console.log((0, shared_js_1.row)("Status", stateLine(progress)));
50
+ if (progress.progress)
51
+ printWrappedRow("Progress", progress.progress);
52
+ if (progress.note)
53
+ console.log((0, shared_js_1.row)("Note", (0, shared_js_1.clean)(progress.note)));
54
+ console.log((0, shared_js_1.row)("Next", chalk_1.default.bold((0, shared_js_1.clean)(progress.next))));
55
+ const command = progress.nextStep?.command;
56
+ if (command)
57
+ console.log((0, shared_js_1.row)("Run", chalk_1.default.cyan(`${(0, utils_js_1.cliName)()} ${(0, utils_js_1.sanitizeForTerminal)(command)}`)));
58
+ console.log((0, shared_js_1.row)("Dashboard", chalk_1.default.cyan((0, utils_js_1.sanitizeForTerminal)(progress.dashboardUrl))));
59
+ if (progress.approvals?.length) {
60
+ console.log(chalk_1.default.bold("\n The Agent asks your approval"));
61
+ for (const approval of progress.approvals) {
62
+ console.log(` - ${(0, shared_js_1.clean)(approval.what)}`);
63
+ console.log(chalk_1.default.gray(` ${(0, shared_js_1.shorten)(JSON.stringify(approval.input ?? {}), 400)}`));
64
+ }
65
+ }
66
+ if (progress.recent?.length) {
67
+ console.log(chalk_1.default.bold("\n Latest"));
68
+ // Orth's latest message whole: it holds what Orth asks or which values it needs.
69
+ const recent = progress.recent.slice(-3);
70
+ const last = recent.map((message) => message.role !== "user").lastIndexOf(true);
71
+ recent.forEach((message, index) => printMessage(message, index === last ? undefined : 240));
72
+ }
73
+ console.log();
74
+ }
75
+ async function fetchProgress(requestId, org) {
76
+ return (0, shared_js_1.runTool)("onboarding_status", org, requestId);
77
+ }
78
+ /**
79
+ * Prints what is new in the conversation (new text and tools of each
80
+ * message) until the Agent stops working; `grace` polls wait for a run that
81
+ * was just started to take its turn.
82
+ */
83
+ async function watchProgress(requestId, org, first, grace = 0) {
84
+ const shown = new Map((first.recent ?? []).map((message) => [message.id, message]));
85
+ let progress = first;
86
+ console.log(chalk_1.default.gray(first.requestStatus === "pending"
87
+ ? " Waiting for Orthogonal's approval (Ctrl+C stops waiting)\n"
88
+ : " Following the Agent (Ctrl+C stops following; the Agent keeps working)\n"));
89
+ // A pending request is watched too, at the dashboard's slower pace.
90
+ while (progress.agentWorking || progress.requestStatus === "pending" || grace-- > 0) {
91
+ const pending = progress.requestStatus === "pending" && !progress.agentWorking;
92
+ await new Promise((resolve) => setTimeout(resolve, pending ? 15_000 : WATCH_INTERVAL_MS));
93
+ progress = await fetchProgress(requestId, org);
94
+ if (progress.agentWorking)
95
+ grace = 0;
96
+ for (const message of progress.recent ?? []) {
97
+ const before = shown.get(message.id);
98
+ shown.set(message.id, message);
99
+ const text = before && message.text.startsWith(before.text)
100
+ ? message.text.slice(before.text.length).trim()
101
+ : message.text;
102
+ const tools = message.tools.filter((tool) => !before?.tools.includes(tool));
103
+ if (text || tools.length)
104
+ printMessage({ ...message, text, tools }, message.role === "user" ? 600 : undefined);
105
+ }
106
+ }
107
+ printProgress(progress, org);
108
+ }
@@ -0,0 +1,2 @@
1
+ import type { Command } from "commander";
2
+ export declare function registerOnboardCommands(program: Command): void;