@orth/cli 0.4.0 → 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 +17 -0
- package/dist/api.d.ts +6 -0
- package/dist/api.js +1 -0
- package/dist/commands/api.js +19 -12
- package/dist/commands/onboard/flow.d.ts +1 -1
- package/dist/commands/onboard/flow.js +9 -9
- package/dist/commands/onboard/guide.js +8 -8
- package/dist/commands/onboard/listing.d.ts +1 -1
- package/dist/commands/onboard/listing.js +3 -3
- package/dist/commands/onboard/progress.d.ts +1 -1
- package/dist/commands/onboard/progress.js +6 -6
- package/dist/commands/onboard/register.js +15 -15
- package/dist/commands/onboard/review.d.ts +2 -2
- package/dist/commands/onboard/review.js +7 -7
- package/dist/commands/onboard/setup.js +3 -3
- package/dist/commands/onboard/shared.d.ts +1 -1
- package/dist/commands/onboard/shared.js +2 -2
- package/dist/commands/run.d.ts +1 -0
- package/dist/commands/run.js +5 -3
- package/dist/commands/search.js +2 -0
- package/dist/config.d.ts +7 -0
- package/dist/config.js +3 -0
- package/dist/index.js +2 -0
- package/dist/last-search.d.ts +19 -0
- package/dist/last-search.js +60 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
0.4.1 was never published to npm; its change ships in this release.
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `orth run` names the search that led to the call: it sends the last
|
|
10
|
+
`orth search`'s id when that search returned the endpoint (path parameters
|
|
11
|
+
filled in), with the same key, in the last hour, or the one `--search-id`
|
|
12
|
+
gives. Optional; the server ignores a bad one, and remembering it never
|
|
13
|
+
fails a search.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- `orth api-onboarding` calls Orthogonal's onboarding agent Orth Agent: its
|
|
18
|
+
messages are labelled "Orth Agent", and help text and guidance say "the agent".
|
|
19
|
+
|
|
3
20
|
## 0.4.0
|
|
4
21
|
|
|
5
22
|
The CLI is now built and published from Orthogonal's monorepo. Upgrade with
|
package/dist/api.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export declare function apiRequest<T = unknown>(endpoint: string, options?: {
|
|
|
3
3
|
body?: unknown;
|
|
4
4
|
}): Promise<T>;
|
|
5
5
|
export interface SearchResponse {
|
|
6
|
+
/** This search's id: /v1/run takes it back to link the call to it. */
|
|
7
|
+
searchId?: string;
|
|
6
8
|
results: Array<{
|
|
7
9
|
name: string;
|
|
8
10
|
slug: string;
|
|
@@ -149,6 +151,8 @@ export interface ApiBySlugResponse {
|
|
|
149
151
|
method: string;
|
|
150
152
|
description?: string;
|
|
151
153
|
price?: number;
|
|
154
|
+
/** The price as the site words it ("from $0.04 per call", "Free"). */
|
|
155
|
+
priceText?: string;
|
|
152
156
|
isPayable?: boolean;
|
|
153
157
|
hasDynamicPricing?: boolean;
|
|
154
158
|
pricing_formula?: string;
|
|
@@ -176,6 +180,8 @@ export declare function run(api: string, path: string, options?: {
|
|
|
176
180
|
query?: Record<string, string>;
|
|
177
181
|
body?: unknown;
|
|
178
182
|
dryRun?: boolean;
|
|
183
|
+
/** The search that led to this call (optional; servers ignore a bad one). */
|
|
184
|
+
searchId?: string;
|
|
179
185
|
}): Promise<RunResponse>;
|
|
180
186
|
export declare function integrate(api: string, path: string, format?: string): Promise<IntegrateResponse>;
|
|
181
187
|
export interface MeResponse {
|
package/dist/api.js
CHANGED
package/dist/commands/api.js
CHANGED
|
@@ -71,19 +71,22 @@ async function apiCommand(slug, path, options) {
|
|
|
71
71
|
const isDynamic = data.hasDynamicPricing || data.endpoint?.hasDynamicPricing || !!data.pricing_formula;
|
|
72
72
|
if (isDynamic) {
|
|
73
73
|
const maxPrice = data.endpoint?.maxPrice;
|
|
74
|
+
// The catalog's own words: the price, its kind and how it is worked out.
|
|
75
|
+
const [headline, ...rules] = (data.endpoint?.pricingNote ?? "").split("\n");
|
|
74
76
|
console.log(chalk_1.default.bold("Price: ") +
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
(headline
|
|
78
|
+
? chalk_1.default.yellow(headline)
|
|
79
|
+
: chalk_1.default.yellow("dynamic") +
|
|
80
|
+
(maxPrice ? chalk_1.default.yellow(`, up to $${maxPrice}`) : "")) +
|
|
81
|
+
chalk_1.default.gray(" (use --dry-run to see a request's price)"));
|
|
82
|
+
for (const rule of rules)
|
|
83
|
+
console.log(chalk_1.default.gray(rule));
|
|
81
84
|
}
|
|
82
85
|
else if (endpointPrice !== undefined && endpointPrice !== null) {
|
|
83
86
|
const isFree = endpointPrice === 0 || endpointPrice === "free" || endpointPrice === "0";
|
|
84
87
|
const priceDisplay = typeof endpointPrice === 'string'
|
|
85
88
|
? endpointPrice
|
|
86
|
-
: `$${parseFloat(Number(endpointPrice).toFixed(
|
|
89
|
+
: `$${parseFloat(Number(endpointPrice).toFixed(6))}`;
|
|
87
90
|
console.log(chalk_1.default.bold("Price: ") +
|
|
88
91
|
(isFree ? chalk_1.default.green("free") : chalk_1.default.yellow(priceDisplay)));
|
|
89
92
|
}
|
|
@@ -185,11 +188,15 @@ async function apiCommand(slug, path, options) {
|
|
|
185
188
|
const ep = endpoint.price;
|
|
186
189
|
const epIsDynamic = endpoint.hasDynamicPricing || !!endpoint.pricing_formula;
|
|
187
190
|
const isFreePrice = ep === 0 || ep == null || ep === "free" || ep === "0";
|
|
188
|
-
const price =
|
|
189
|
-
?
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
const price = endpoint.priceText
|
|
192
|
+
? endpoint.priceText === "Free"
|
|
193
|
+
? chalk_1.default.green("Free")
|
|
194
|
+
: chalk_1.default.dim(endpoint.priceText)
|
|
195
|
+
: epIsDynamic
|
|
196
|
+
? chalk_1.default.dim("price varies by request")
|
|
197
|
+
: isFreePrice
|
|
198
|
+
? chalk_1.default.green("Free")
|
|
199
|
+
: chalk_1.default.dim(typeof ep === "string" ? ep : `$${parseFloat(Number(ep).toFixed(6))}`);
|
|
193
200
|
// Group members commonly collide on the same upstream path (e.g.
|
|
194
201
|
// AbstractAPI's many products all expose "/v1"): when the endpoint's
|
|
195
202
|
// own callable slug differs from the card's flat slug, show it so the
|
|
@@ -17,6 +17,6 @@ export declare function onboardStartCommand(given: string | undefined, options:
|
|
|
17
17
|
*/
|
|
18
18
|
export declare function onboardStatusCommand(given: string | undefined, options: OnboardFlowOptions): Promise<void>;
|
|
19
19
|
/**
|
|
20
|
-
* orth api-onboarding stop [request] - Stop the
|
|
20
|
+
* orth api-onboarding stop [request] - Stop the agent's background work
|
|
21
21
|
*/
|
|
22
22
|
export declare function onboardStopCommand(given: string | undefined, options: OnboardFlowOptions): Promise<void>;
|
|
@@ -67,7 +67,7 @@ async function onboardNewCommand(docsUrl, options) {
|
|
|
67
67
|
}
|
|
68
68
|
console.log(chalk_1.default.green(`\n Requested ${(0, utils_js_1.sanitizeForTerminal)(request.apiName)}`) +
|
|
69
69
|
chalk_1.default.gray(` for ${(0, utils_js_1.sanitizeForTerminal)(org.name)}`));
|
|
70
|
-
console.log(`\n Orthogonal reviews the request. Once it is approved, the
|
|
70
|
+
console.log(`\n Orthogonal reviews the request. Once it is approved, the agent starts setting up the API by itself.\n Follow it: ${chalk_1.default.cyan((0, shared_js_1.cmd)("status --watch"))}\n`);
|
|
71
71
|
}
|
|
72
72
|
catch (error) {
|
|
73
73
|
(0, shared_js_1.fail)(error);
|
|
@@ -82,7 +82,7 @@ async function onboardStartCommand(given, options) {
|
|
|
82
82
|
const org = await (0, organizations_js_1.resolveOrganization)(options.org);
|
|
83
83
|
const request = await (0, requests_js_1.resolveRequest)(org, given, requests_js_1.inProgress, "start");
|
|
84
84
|
const requestId = request.id;
|
|
85
|
-
const spinner = options.json ? null : (0, ora_1.default)("Starting the
|
|
85
|
+
const spinner = options.json ? null : (0, ora_1.default)("Starting the agent...").start();
|
|
86
86
|
const started = await (0, shared_js_1.runTool)("start_onboarding", org, requestId, options.message ? { message: options.message } : {});
|
|
87
87
|
spinner?.stop();
|
|
88
88
|
if (options.json) {
|
|
@@ -92,10 +92,10 @@ async function onboardStartCommand(given, options) {
|
|
|
92
92
|
const api = request.apiName ? (0, shared_js_1.clean)(request.apiName) : "your API";
|
|
93
93
|
const said = {
|
|
94
94
|
started: options.message
|
|
95
|
-
? "The
|
|
96
|
-
: `The
|
|
97
|
-
queued: "The
|
|
98
|
-
running: "The
|
|
95
|
+
? "The agent has your reply and works on it in the background."
|
|
96
|
+
: `The agent is onboarding ${api} in the background.`,
|
|
97
|
+
queued: "The agent is working; it reads your reply in its next step.",
|
|
98
|
+
running: "The agent is already working on it.",
|
|
99
99
|
}[started.state];
|
|
100
100
|
console.log(chalk_1.default.green(`\n ${said}`));
|
|
101
101
|
console.log(chalk_1.default.gray(" You can close this terminal. Follow it here or in the dashboard:"));
|
|
@@ -118,7 +118,7 @@ async function onboardStatusCommand(given, options) {
|
|
|
118
118
|
const { id: requestId } = await (0, requests_js_1.resolveRequest)(org, given, requests_js_1.inProgress, "check", "status");
|
|
119
119
|
const progress = await (0, progress_js_1.fetchProgress)(requestId, org);
|
|
120
120
|
// With --json, --watch prints once. nextStep.command says `status
|
|
121
|
-
// --watch` while the
|
|
121
|
+
// --watch` while the agent works or Orthogonal approves, and an agent
|
|
122
122
|
// running it with --json checks again later instead of blocking for hours.
|
|
123
123
|
if (options.json) {
|
|
124
124
|
console.log(JSON.stringify(progress, null, 2));
|
|
@@ -133,7 +133,7 @@ async function onboardStatusCommand(given, options) {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
/**
|
|
136
|
-
* orth api-onboarding stop [request] - Stop the
|
|
136
|
+
* orth api-onboarding stop [request] - Stop the agent's background work
|
|
137
137
|
*/
|
|
138
138
|
async function onboardStopCommand(given, options) {
|
|
139
139
|
try {
|
|
@@ -147,7 +147,7 @@ async function onboardStopCommand(given, options) {
|
|
|
147
147
|
}
|
|
148
148
|
console.log(stopped
|
|
149
149
|
? chalk_1.default.green(`\n Stopped${request.apiName ? ` ${(0, shared_js_1.clean)(request.apiName)}` : ""}. Resume any time: ${(0, shared_js_1.cmd)("start")}\n`)
|
|
150
|
-
: chalk_1.default.gray("\n The
|
|
150
|
+
: chalk_1.default.gray("\n The agent was not working.\n"));
|
|
151
151
|
}
|
|
152
152
|
catch (error) {
|
|
153
153
|
(0, shared_js_1.fail)(error);
|
|
@@ -16,9 +16,9 @@ const shared_js_1 = require("./shared.js");
|
|
|
16
16
|
function onboardGuideCommand(options = {}) {
|
|
17
17
|
const c = (rest) => chalk_1.default.cyan((0, shared_js_1.cmd)(rest));
|
|
18
18
|
const steps = [
|
|
19
|
-
["start", "start the
|
|
19
|
+
["start", "start the agent, or resume it"],
|
|
20
20
|
['start -m "<reply>"', "reply in your own words, or tell it what to change"],
|
|
21
|
-
['approve / deny -m "<why>"', "answer the calls the
|
|
21
|
+
['approve / deny -m "<why>"', "answer the calls the agent asks to run"],
|
|
22
22
|
["base-url <https://…>", "where the API is served from"],
|
|
23
23
|
["setup, then confirm", "review the endpoints and prices, then confirm them"],
|
|
24
24
|
['price "GET /path" <usd|free>', "set a price per call"],
|
|
@@ -28,7 +28,7 @@ function onboardGuideCommand(options = {}) {
|
|
|
28
28
|
["submit / withdraw", "send it for Orthogonal's review, or take it back"],
|
|
29
29
|
["resubmit / cancel", "fix a declined request, or drop one"],
|
|
30
30
|
["listing", "once live: the live version, the next one, what it changes"],
|
|
31
|
-
['update --sync / -m "<what>"', "open the next version with the
|
|
31
|
+
['update --sync / -m "<what>"', "open the next version with the agent"],
|
|
32
32
|
["discard", "close the next version and drop its changes"],
|
|
33
33
|
]
|
|
34
34
|
.map(([command, what]) => ` ${chalk_1.default.cyan((command ?? "").padEnd(29))} ${what}`)
|
|
@@ -36,30 +36,30 @@ function onboardGuideCommand(options = {}) {
|
|
|
36
36
|
const guide = `
|
|
37
37
|
${chalk_1.default.bold("List your API on Orthogonal")}
|
|
38
38
|
|
|
39
|
-
Orthogonal's
|
|
39
|
+
Orth Agent, Orthogonal's agent, sets your API up in the background: it reads your docs,
|
|
40
40
|
drafts the endpoints and prices, calls every endpoint and writes a report.
|
|
41
41
|
You make the decisions, and ${c("status")} always says the next one.
|
|
42
42
|
|
|
43
43
|
${chalk_1.default.bold("1")} ${c("new <docsUrl> --name <api>")}
|
|
44
44
|
Orthogonal approves the request first (${c("status --watch")} waits for it).
|
|
45
|
-
${chalk_1.default.bold("2")} The
|
|
45
|
+
${chalk_1.default.bold("2")} The agent starts by itself once the request is approved (${c("start")} starts
|
|
46
46
|
it if it has not, or resumes it). You can close the terminal any time.
|
|
47
47
|
${chalk_1.default.bold("3")} ${c("status --watch")}
|
|
48
48
|
Shows where it is and the one command to run next (after ${chalk_1.default.cyan((0, shared_js_1.cmd)("").trim())}):
|
|
49
49
|
${steps}
|
|
50
50
|
${chalk_1.default.bold("4")} Orthogonal reviews it; ${c("status")} says when it is live, as version 1.
|
|
51
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
|
|
52
|
+
opens the next version with the agent; buyers keep the live one until
|
|
53
53
|
Orthogonal accepts it. ${c("listing")} shows the versions and what changed;
|
|
54
54
|
${c("discard")} closes the next version and drops its changes.
|
|
55
55
|
|
|
56
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
|
|
57
|
+
The same run shows on the dashboard link that ${c("status")} prints. ${c("stop")} pauses the agent.
|
|
58
58
|
Docs, including the dashboard and MCP: ${chalk_1.default.cyan(`${(0, urls_js_1.webBaseUrl)()}/docs/list-your-api`)}
|
|
59
59
|
|
|
60
60
|
${chalk_1.default.bold("For AI agents")}: add --json to every command, then run
|
|
61
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
|
|
62
|
+
--watch prints once, so check again later. The agent decides every open
|
|
63
63
|
choice itself and asks nothing; confirm, approve, submit, withdraw, discard
|
|
64
64
|
and cancel take --yes. Submit only once your user read the final report and
|
|
65
65
|
wants it listed. Never ask for, read or pass an API key: your user runs
|
|
@@ -6,7 +6,7 @@ import { type OnboardFlowOptions } from "./shared.js";
|
|
|
6
6
|
export declare function onboardListingCommand(given: string | undefined, options: OnboardFlowOptions): Promise<void>;
|
|
7
7
|
/**
|
|
8
8
|
* orth api-onboarding update [api] - Open the next version of a live
|
|
9
|
-
* listing with the
|
|
9
|
+
* listing with the agent (--sync: it checks the live one against your docs)
|
|
10
10
|
*/
|
|
11
11
|
export declare function onboardUpdateCommand(given: string | undefined, options: OnboardFlowOptions & {
|
|
12
12
|
sync?: boolean;
|
|
@@ -13,7 +13,7 @@ const requests_js_1 = require("./requests.js");
|
|
|
13
13
|
const shared_js_1 = require("./shared.js");
|
|
14
14
|
const UPDATE_STATES = {
|
|
15
15
|
live: "Live, no update open",
|
|
16
|
-
drafting: "Being prepared with the
|
|
16
|
+
drafting: "Being prepared with the agent",
|
|
17
17
|
in_review: "With Orthogonal for review",
|
|
18
18
|
changes_requested: "Orthogonal asked for changes",
|
|
19
19
|
declined: "Declined by Orthogonal",
|
|
@@ -102,7 +102,7 @@ async function onboardListingCommand(given, options) {
|
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
104
|
* orth api-onboarding update [api] - Open the next version of a live
|
|
105
|
-
* listing with the
|
|
105
|
+
* listing with the agent (--sync: it checks the live one against your docs)
|
|
106
106
|
*/
|
|
107
107
|
async function onboardUpdateCommand(given, options) {
|
|
108
108
|
try {
|
|
@@ -123,7 +123,7 @@ async function onboardUpdateCommand(given, options) {
|
|
|
123
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
124
|
: options.message
|
|
125
125
|
? `${(0, shared_js_1.goesOn)(result.agent)} It drafts what you asked.`
|
|
126
|
-
: `Tell the
|
|
126
|
+
: `Tell the agent what to change: ${chalk_1.default.cyan((0, shared_js_1.cmd)('start -m "<what to change>"'))}`,
|
|
127
127
|
`Then follow it to confirm, test and submit version ${result.version}: ${chalk_1.default.cyan((0, shared_js_1.cmd)("status --watch"))}`,
|
|
128
128
|
]);
|
|
129
129
|
if (options.watch && result.agent) {
|
|
@@ -37,7 +37,7 @@ export declare function printProgress(progress: Progress, org: Organization): vo
|
|
|
37
37
|
export declare function fetchProgress(requestId: string, org: Organization): Promise<Progress>;
|
|
38
38
|
/**
|
|
39
39
|
* Prints what is new in the conversation (new text and tools of each
|
|
40
|
-
* message) until the
|
|
40
|
+
* message) until the agent stops working; `grace` polls wait for a run that
|
|
41
41
|
* was just started to take its turn.
|
|
42
42
|
*/
|
|
43
43
|
export declare function watchProgress(requestId: string, org: Organization, first: Progress, grace?: number): Promise<void>;
|
|
@@ -16,14 +16,14 @@ function stateLine(progress) {
|
|
|
16
16
|
return (0, requests_js_1.requestStatus)(progress.requestStatus);
|
|
17
17
|
const phase = requests_js_1.PHASES[progress.phase ?? ""] ?? progress.phase ?? "";
|
|
18
18
|
return progress.agentWorking
|
|
19
|
-
? `${phase} ${chalk_1.default.cyan("· Agent working in the background")}`
|
|
19
|
+
? `${phase} ${chalk_1.default.cyan("· Orth Agent working in the background")}`
|
|
20
20
|
: phase;
|
|
21
21
|
}
|
|
22
22
|
/** One message, cut to `max` characters, or whole and wrapped without `max`. */
|
|
23
23
|
function printMessage(message, max) {
|
|
24
|
-
const who = message.role === "user" ? chalk_1.default.blue("You
|
|
24
|
+
const who = message.role === "user" ? chalk_1.default.blue("You ") : chalk_1.default.magenta("Orth Agent");
|
|
25
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,
|
|
26
|
+
const lines = max === undefined ? (0, shared_js_1.wrapped)(message.text, 13) : [];
|
|
27
27
|
if (lines.length) {
|
|
28
28
|
lines[0] = ` ${who} ${lines[0].trimStart()}`;
|
|
29
29
|
lines[lines.length - 1] += tools;
|
|
@@ -57,7 +57,7 @@ function printProgress(progress, org) {
|
|
|
57
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
58
|
console.log((0, shared_js_1.row)("Dashboard", chalk_1.default.cyan((0, utils_js_1.sanitizeForTerminal)(progress.dashboardUrl))));
|
|
59
59
|
if (progress.approvals?.length) {
|
|
60
|
-
console.log(chalk_1.default.bold("\n The
|
|
60
|
+
console.log(chalk_1.default.bold("\n The agent asks your approval"));
|
|
61
61
|
for (const approval of progress.approvals) {
|
|
62
62
|
console.log(` - ${(0, shared_js_1.clean)(approval.what)}`);
|
|
63
63
|
console.log(chalk_1.default.gray(` ${(0, shared_js_1.shorten)(JSON.stringify(approval.input ?? {}), 400)}`));
|
|
@@ -77,7 +77,7 @@ async function fetchProgress(requestId, org) {
|
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
79
|
* Prints what is new in the conversation (new text and tools of each
|
|
80
|
-
* message) until the
|
|
80
|
+
* message) until the agent stops working; `grace` polls wait for a run that
|
|
81
81
|
* was just started to take its turn.
|
|
82
82
|
*/
|
|
83
83
|
async function watchProgress(requestId, org, first, grace = 0) {
|
|
@@ -85,7 +85,7 @@ async function watchProgress(requestId, org, first, grace = 0) {
|
|
|
85
85
|
let progress = first;
|
|
86
86
|
console.log(chalk_1.default.gray(first.requestStatus === "pending"
|
|
87
87
|
? " Waiting for Orthogonal's approval (Ctrl+C stops waiting)\n"
|
|
88
|
-
: " Following the
|
|
88
|
+
: " Following the agent (Ctrl+C stops following; the agent keeps working)\n"));
|
|
89
89
|
// A pending request is watched too, at the dashboard's slower pace.
|
|
90
90
|
while (progress.agentWorking || progress.requestStatus === "pending" || grace-- > 0) {
|
|
91
91
|
const pending = progress.requestStatus === "pending" && !progress.agentWorking;
|
|
@@ -17,7 +17,7 @@ const guide_js_1 = require("./guide.js");
|
|
|
17
17
|
function registerOnboardCommands(program) {
|
|
18
18
|
const onboardGroup = program
|
|
19
19
|
.command("api-onboarding")
|
|
20
|
-
.description("List your API on Orthogonal: the
|
|
20
|
+
.description("List your API on Orthogonal: the agent sets it up in the background (start with: guide)");
|
|
21
21
|
const requestArgument = "[api]";
|
|
22
22
|
onboardGroup
|
|
23
23
|
.command("list", { isDefault: true })
|
|
@@ -43,9 +43,9 @@ function registerOnboardCommands(program) {
|
|
|
43
43
|
}));
|
|
44
44
|
onboardGroup
|
|
45
45
|
.command(`start ${requestArgument}`)
|
|
46
|
-
.description("Start the
|
|
47
|
-
.option("-m, --message <text>", "Your reply to the
|
|
48
|
-
.option("-w, --watch", "Follow the
|
|
46
|
+
.description("Start the agent in the background, reply to it (-m), or resume it")
|
|
47
|
+
.option("-m, --message <text>", "Your reply to the agent")
|
|
48
|
+
.option("-w, --watch", "Follow the agent's work as it happens (with --json: print once)")
|
|
49
49
|
.option(...command_actions_js_1.orgOption)
|
|
50
50
|
.option("--json", "Print JSON")
|
|
51
51
|
.action((0, command_actions_js_1.asyncAction)(async (api, options) => {
|
|
@@ -54,8 +54,8 @@ function registerOnboardCommands(program) {
|
|
|
54
54
|
}));
|
|
55
55
|
onboardGroup
|
|
56
56
|
.command(`status ${requestArgument}`)
|
|
57
|
-
.description("Where the onboarding is, what the
|
|
58
|
-
.option("-w, --watch", "Follow the
|
|
57
|
+
.description("Where the onboarding is, what the agent asks to run, and your next step")
|
|
58
|
+
.option("-w, --watch", "Follow the agent's work until it stops (with --json: print once)")
|
|
59
59
|
.option(...command_actions_js_1.orgOption)
|
|
60
60
|
.option("--json", "Print JSON")
|
|
61
61
|
.action((0, command_actions_js_1.asyncAction)(async (api, options) => {
|
|
@@ -64,7 +64,7 @@ function registerOnboardCommands(program) {
|
|
|
64
64
|
}));
|
|
65
65
|
onboardGroup
|
|
66
66
|
.command(`stop ${requestArgument}`)
|
|
67
|
-
.description("Stop the
|
|
67
|
+
.description("Stop the agent's background work (start resumes it)")
|
|
68
68
|
.option(...command_actions_js_1.orgOption)
|
|
69
69
|
.option("--json", "Print JSON")
|
|
70
70
|
.action((0, command_actions_js_1.asyncAction)(async (api, options) => {
|
|
@@ -109,7 +109,7 @@ function registerOnboardCommands(program) {
|
|
|
109
109
|
}));
|
|
110
110
|
onboardGroup
|
|
111
111
|
.command(`confirm ${requestArgument}`)
|
|
112
|
-
.description("Review the setup, then confirm it so the
|
|
112
|
+
.description("Review the setup, then confirm it so the agent goes on")
|
|
113
113
|
.option("-y, --yes", "Confirm without asking")
|
|
114
114
|
.option(...command_actions_js_1.orgOption)
|
|
115
115
|
.option("--json", "Print JSON")
|
|
@@ -128,7 +128,7 @@ function registerOnboardCommands(program) {
|
|
|
128
128
|
}));
|
|
129
129
|
onboardGroup
|
|
130
130
|
.command(`approve ${requestArgument}`)
|
|
131
|
-
.description("Let the
|
|
131
|
+
.description("Let the agent run the calls it asks your approval for")
|
|
132
132
|
.option("-y, --yes", "Approve without asking")
|
|
133
133
|
.option(...command_actions_js_1.orgOption)
|
|
134
134
|
.option("--json", "Print JSON")
|
|
@@ -138,8 +138,8 @@ function registerOnboardCommands(program) {
|
|
|
138
138
|
}));
|
|
139
139
|
onboardGroup
|
|
140
140
|
.command(`deny ${requestArgument}`)
|
|
141
|
-
.description("Refuse the calls the
|
|
142
|
-
.option("-m, --message <why>", "Why, for the
|
|
141
|
+
.description("Refuse the calls the agent asks your approval for")
|
|
142
|
+
.option("-m, --message <why>", "Why, for the agent")
|
|
143
143
|
.option(...command_actions_js_1.orgOption)
|
|
144
144
|
.option("--json", "Print JSON")
|
|
145
145
|
.action((0, command_actions_js_1.asyncAction)(async (api, options) => {
|
|
@@ -209,10 +209,10 @@ function registerOnboardCommands(program) {
|
|
|
209
209
|
}));
|
|
210
210
|
onboardGroup
|
|
211
211
|
.command(`update ${requestArgument}`)
|
|
212
|
-
.description("Open the next version of your live listing with the
|
|
213
|
-
.option("-s, --sync", "Have the
|
|
214
|
-
.option("-m, --message <text>", "What the next version should change, for the
|
|
215
|
-
.option("-w, --watch", "Follow the
|
|
212
|
+
.description("Open the next version of your live listing with the agent (buyers keep the live one)")
|
|
213
|
+
.option("-s, --sync", "Have the agent check the live version against your API and its docs")
|
|
214
|
+
.option("-m, --message <text>", "What the next version should change, for the agent")
|
|
215
|
+
.option("-w, --watch", "Follow the agent's work as it happens (with --json: print once)")
|
|
216
216
|
.option(...command_actions_js_1.orgOption)
|
|
217
217
|
.option("--json", "Print JSON")
|
|
218
218
|
.action((0, command_actions_js_1.asyncAction)(async (api, options) => {
|
|
@@ -10,11 +10,11 @@ export declare function onboardSubmitCommand(given: string | undefined, options:
|
|
|
10
10
|
yes?: boolean;
|
|
11
11
|
}): Promise<void>;
|
|
12
12
|
/**
|
|
13
|
-
* orth api-onboarding approve [api] - Let the
|
|
13
|
+
* orth api-onboarding approve [api] - Let the agent run the calls it asks for
|
|
14
14
|
*/
|
|
15
15
|
export declare function onboardApproveCommand(given: string | undefined, options: OnboardFlowOptions): Promise<void>;
|
|
16
16
|
/**
|
|
17
|
-
* orth api-onboarding deny [api] -m <why> - Refuse the calls the
|
|
17
|
+
* orth api-onboarding deny [api] -m <why> - Refuse the calls the agent asks for
|
|
18
18
|
*/
|
|
19
19
|
export declare function onboardDenyCommand(given: string | undefined, options: OnboardFlowOptions): Promise<void>;
|
|
20
20
|
/**
|
|
@@ -52,7 +52,7 @@ async function onboardTestCommand(given, options) {
|
|
|
52
52
|
(counts.failed ? chalk_1.default.red(`, ${counts.failed} failed`) : "") +
|
|
53
53
|
(counts.needsInput ? chalk_1.default.yellow(`, ${counts.needsInput} need input`) : "") +
|
|
54
54
|
".",
|
|
55
|
-
result.agent ? "The
|
|
55
|
+
result.agent ? "The agent reviews the results next." : "",
|
|
56
56
|
chalk_1.default.cyan((0, shared_js_1.cmd)("status --watch")),
|
|
57
57
|
]);
|
|
58
58
|
}
|
|
@@ -99,16 +99,16 @@ async function onboardSubmitCommand(given, options) {
|
|
|
99
99
|
(0, shared_js_1.fail)(error);
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
/** Approve or deny everything the
|
|
102
|
+
/** Approve or deny everything the agent waits on, after showing it. */
|
|
103
103
|
async function answerApproval(given, options, approved) {
|
|
104
104
|
const verb = approved ? "approve" : "deny";
|
|
105
105
|
const { org, requestId } = await (0, requests_js_1.stepContext)(given, options, verb, verb);
|
|
106
106
|
const progress = await (0, progress_js_1.fetchProgress)(requestId, org);
|
|
107
107
|
const approvals = progress.approvals ?? [];
|
|
108
108
|
if (!approvals.length)
|
|
109
|
-
throw new Error(`The
|
|
109
|
+
throw new Error(`The agent is not waiting for an approval. Check: ${(0, shared_js_1.cmd)("status")}`);
|
|
110
110
|
if (!options.json) {
|
|
111
|
-
console.log(chalk_1.default.bold(`\n The
|
|
111
|
+
console.log(chalk_1.default.bold(`\n The agent asks to`));
|
|
112
112
|
for (const approval of approvals) {
|
|
113
113
|
console.log(` - ${(0, shared_js_1.clean)(approval.what)}`);
|
|
114
114
|
console.log(chalk_1.default.gray(` ${(0, shared_js_1.shorten)(JSON.stringify(approval.input ?? {}), 600)}`));
|
|
@@ -129,12 +129,12 @@ async function answerApproval(given, options, approved) {
|
|
|
129
129
|
});
|
|
130
130
|
(0, shared_js_1.report)(options, result, () => [
|
|
131
131
|
approved ? chalk_1.default.green("Approved.") : chalk_1.default.yellow("Denied."),
|
|
132
|
-
"The
|
|
132
|
+
"The agent goes on in the background.",
|
|
133
133
|
chalk_1.default.cyan((0, shared_js_1.cmd)("status --watch")),
|
|
134
134
|
]);
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
|
-
* orth api-onboarding approve [api] - Let the
|
|
137
|
+
* orth api-onboarding approve [api] - Let the agent run the calls it asks for
|
|
138
138
|
*/
|
|
139
139
|
async function onboardApproveCommand(given, options) {
|
|
140
140
|
try {
|
|
@@ -145,7 +145,7 @@ async function onboardApproveCommand(given, options) {
|
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
/**
|
|
148
|
-
* orth api-onboarding deny [api] -m <why> - Refuse the calls the
|
|
148
|
+
* orth api-onboarding deny [api] -m <why> - Refuse the calls the agent asks for
|
|
149
149
|
*/
|
|
150
150
|
async function onboardDenyCommand(given, options) {
|
|
151
151
|
try {
|
|
@@ -61,7 +61,7 @@ function printSetup(setup, org) {
|
|
|
61
61
|
for (const endpoint of setup.leftOut) {
|
|
62
62
|
console.log(" " +
|
|
63
63
|
chalk_1.default.cyan(`${(0, shared_js_1.clean)(endpoint.method)} ${(0, shared_js_1.clean)(endpoint.path)}`) +
|
|
64
|
-
chalk_1.default.gray(` ${endpoint.by === "orth" ? "by the
|
|
64
|
+
chalk_1.default.gray(` ${endpoint.by === "orth" ? "by the agent" : "by you"}: ${(0, shared_js_1.shorten)(endpoint.reason, 160)}`));
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
if (setup.endpoints.length) {
|
|
@@ -129,7 +129,7 @@ async function onboardConfirmCommand(given, options) {
|
|
|
129
129
|
if (!(0, utils_js_1.isInteractive)())
|
|
130
130
|
throw new Error("Pass --yes to confirm without a question.");
|
|
131
131
|
if (!(await (0, utils_js_1.confirmYes)(`Confirm this setup (revision ${setup.revision})?`))) {
|
|
132
|
-
(0, shared_js_1.done)([chalk_1.default.gray("Not confirmed. Tell the
|
|
132
|
+
(0, shared_js_1.done)([chalk_1.default.gray("Not confirmed. Tell the agent what to change:"), chalk_1.default.cyan((0, shared_js_1.cmd)('start -m "<what to change>"'))]);
|
|
133
133
|
return;
|
|
134
134
|
}
|
|
135
135
|
}
|
|
@@ -152,7 +152,7 @@ async function onboardKeyCommand(given, options) {
|
|
|
152
152
|
const { org, requestId } = await (0, requests_js_1.stepContext)(given, options, "add the key of", "key");
|
|
153
153
|
const setup = await fetchSetup(org, requestId);
|
|
154
154
|
if (!setup.key) {
|
|
155
|
-
throw new Error("The
|
|
155
|
+
throw new Error("The agent hasn't decided where the key goes yet. Check: " + (0, shared_js_1.cmd)("status"));
|
|
156
156
|
}
|
|
157
157
|
if (setup.key.location === "none") {
|
|
158
158
|
throw new Error("This API needs no key: every endpoint is public.");
|
|
@@ -35,7 +35,7 @@ export declare function httpsUrl(value: string, what: string): string;
|
|
|
35
35
|
export declare function wrapped(text: string, indent: number): string[];
|
|
36
36
|
/** Prints the result as JSON, or the lines that say what happened. */
|
|
37
37
|
export declare function report(options: OnboardFlowOptions, result: unknown, lines: () => string[]): void;
|
|
38
|
-
export declare const goesOn: (agent: string | null | undefined) => "" | "The
|
|
38
|
+
export declare const goesOn: (agent: string | null | undefined) => "" | "The agent goes on in the background." | "The agent is working; it picks this up next.";
|
|
39
39
|
/** A multi-line text (the final report) indented, each line made safe. */
|
|
40
40
|
export declare const indented: (text: string) => string;
|
|
41
41
|
export declare function done(lines: string[]): void;
|
|
@@ -81,9 +81,9 @@ function report(options, result, lines) {
|
|
|
81
81
|
done(lines());
|
|
82
82
|
}
|
|
83
83
|
const goesOn = (agent) => agent === "queued"
|
|
84
|
-
? "The
|
|
84
|
+
? "The agent is working; it picks this up next."
|
|
85
85
|
: agent
|
|
86
|
-
? "The
|
|
86
|
+
? "The agent goes on in the background."
|
|
87
87
|
: "";
|
|
88
88
|
exports.goesOn = goesOn;
|
|
89
89
|
/** A multi-line text (the final report) indented, each line made safe. */
|
package/dist/commands/run.d.ts
CHANGED
package/dist/commands/run.js
CHANGED
|
@@ -9,6 +9,7 @@ const ora_1 = __importDefault(require("ora"));
|
|
|
9
9
|
const fs_1 = require("fs");
|
|
10
10
|
const path_1 = require("path");
|
|
11
11
|
const api_js_1 = require("../api.js");
|
|
12
|
+
const last_search_js_1 = require("../last-search.js");
|
|
12
13
|
const utils_js_1 = require("../utils.js");
|
|
13
14
|
// Map content-type to file extension
|
|
14
15
|
const CONTENT_TYPE_EXT = {
|
|
@@ -135,9 +136,9 @@ function printFailureHint(body) {
|
|
|
135
136
|
}
|
|
136
137
|
function formatCost(result) {
|
|
137
138
|
if (result.price)
|
|
138
|
-
return result.price;
|
|
139
|
+
return /^\$?0(\.0+)?$/.test(result.price) ? "Free" : result.price;
|
|
139
140
|
if (result.priceCents != null && result.priceCents > 0) {
|
|
140
|
-
return `$${parseFloat((result.priceCents / 100).toFixed(
|
|
141
|
+
return `$${parseFloat((result.priceCents / 100).toFixed(6))}`;
|
|
141
142
|
}
|
|
142
143
|
return null;
|
|
143
144
|
}
|
|
@@ -192,6 +193,7 @@ async function runCommand(api, path, options) {
|
|
|
192
193
|
query: Object.keys(query).length > 0 ? query : undefined,
|
|
193
194
|
body,
|
|
194
195
|
dryRun: options.dryRun,
|
|
196
|
+
searchId: options.searchId ?? (0, last_search_js_1.searchIdFor)(api, path),
|
|
195
197
|
});
|
|
196
198
|
spinner.stop();
|
|
197
199
|
// Handle dry-run response
|
|
@@ -202,7 +204,7 @@ async function runCommand(api, path, options) {
|
|
|
202
204
|
: null) ||
|
|
203
205
|
result.price ||
|
|
204
206
|
"unknown";
|
|
205
|
-
console.log(chalk_1.default.bold("\
|
|
207
|
+
console.log(chalk_1.default.bold("\nThis request: ") + chalk_1.default.yellow(estimatedCost));
|
|
206
208
|
console.log(chalk_1.default.gray("(Use without --dry-run to execute)"));
|
|
207
209
|
return;
|
|
208
210
|
}
|
package/dist/commands/search.js
CHANGED
|
@@ -10,6 +10,7 @@ const ora_1 = __importDefault(require("ora"));
|
|
|
10
10
|
const api_js_1 = require("../api.js");
|
|
11
11
|
const utils_js_1 = require("../utils.js");
|
|
12
12
|
const api_js_2 = require("./api.js");
|
|
13
|
+
const last_search_js_1 = require("../last-search.js");
|
|
13
14
|
/**
|
|
14
15
|
* "99.6%", "83.9% degraded" or "99.6% · API-wide": a hit's 30-day success
|
|
15
16
|
* rate, the website's warning word and whose calls; null below 100 calls.
|
|
@@ -28,6 +29,7 @@ async function searchCommand(query, options) {
|
|
|
28
29
|
try {
|
|
29
30
|
const data = await (0, api_js_1.search)(query, parseInt(options.limit, 10));
|
|
30
31
|
spinner.stop();
|
|
32
|
+
(0, last_search_js_1.rememberSearch)(data);
|
|
31
33
|
if (options.json) {
|
|
32
34
|
console.log(JSON.stringify(data, null, 2));
|
|
33
35
|
return data;
|
package/dist/config.d.ts
CHANGED
|
@@ -24,6 +24,13 @@ interface ConfigSchema {
|
|
|
24
24
|
installId?: string;
|
|
25
25
|
/** The default organization per API server (org ids differ between them). */
|
|
26
26
|
organizations?: Record<string, Organization>;
|
|
27
|
+
/** The last search's id and endpoints (last-search.ts). */
|
|
28
|
+
lastSearch?: {
|
|
29
|
+
id: string;
|
|
30
|
+
at: number;
|
|
31
|
+
key?: string;
|
|
32
|
+
endpoints: string[];
|
|
33
|
+
};
|
|
27
34
|
}
|
|
28
35
|
export declare const config: Conf<ConfigSchema>;
|
|
29
36
|
export declare function getApiKey(): string | undefined;
|
package/dist/config.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -112,6 +112,7 @@ apiGroup
|
|
|
112
112
|
.option("--raw", "Print only the response JSON on stdout (the cost goes to stderr)")
|
|
113
113
|
.option("-o, --output <file>", "Save response to file (auto-detects binary like images)")
|
|
114
114
|
.option("--dry-run", "Estimate cost without executing the call")
|
|
115
|
+
.option("--search-id <id>", "The search that led to this call (default: the last search, if it returned this endpoint)")
|
|
115
116
|
.action((0, command_actions_js_1.asyncAction)(async (slug, path, options) => {
|
|
116
117
|
(0, analytics_js_1.trackEvent)("api.run", { slug, path });
|
|
117
118
|
await (0, run_js_1.runCommand)(slug, path, options);
|
|
@@ -230,6 +231,7 @@ program
|
|
|
230
231
|
.option("--raw", "Print only the response JSON on stdout (the cost goes to stderr)")
|
|
231
232
|
.option("-o, --output <file>", "Save response to file (auto-detects binary like images)")
|
|
232
233
|
.option("--dry-run", "Estimate cost without executing the call")
|
|
234
|
+
.option("--search-id <id>", "The search that led to this call (default: the last search, if it returned this endpoint)")
|
|
233
235
|
.action((0, command_actions_js_1.asyncAction)(async (api, path, options) => {
|
|
234
236
|
(0, analytics_js_1.trackEvent)("run", { api, path });
|
|
235
237
|
await (0, run_js_1.runCommand)(api, path, options);
|
|
@@ -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
|
+
}
|