@octen.ai/cli 0.12.0 → 0.13.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 +48 -1
- package/dist/api/constants.d.ts +11 -0
- package/dist/api/constants.js +5 -0
- package/dist/api/designSearch.d.ts +55 -0
- package/dist/api/designSearch.js +136 -0
- package/dist/api/premierSearch.d.ts +19 -0
- package/dist/api/premierSearch.js +37 -0
- package/dist/cli.js +9 -1
- package/dist/commands/designSearch.d.ts +2 -0
- package/dist/commands/designSearch.js +63 -0
- package/dist/commands/premierSearch.d.ts +8 -0
- package/dist/commands/premierSearch.js +37 -0
- package/dist/output/pretty/designSearch.d.ts +15 -0
- package/dist/output/pretty/designSearch.js +202 -0
- package/dist/output/pretty/envelope.d.ts +2 -0
- package/dist/output/pretty/envelope.js +4 -0
- package/dist/output/pretty/search.d.ts +9 -3
- package/dist/output/pretty/search.js +26 -11
- package/dist/util/terminalText.d.ts +14 -0
- package/dist/util/terminalText.js +30 -0
- package/package.json +1 -1
- package/skills/manifest.json +1 -0
- package/skills/octen-design-search/SKILL.md +312 -0
- package/skills/octen-design-search/agents/openai.yaml +4 -0
- package/skills/octen-search/SKILL.md +53 -5
- package/skills/octen-web-search/SKILL.md +14 -2
package/README.md
CHANGED
|
@@ -379,6 +379,25 @@ Options: `--max-queries` (decompose into up to N sub-queries, 1–30, default 5)
|
|
|
379
379
|
|
|
380
380
|
---
|
|
381
381
|
|
|
382
|
+
### `octen premier-search`
|
|
383
|
+
|
|
384
|
+
Web Search Premier: the same search with deeper retrieval and more careful reranking behind it — for the exact page that holds an answer, a niche document, or a query `octen search` answered thinly.
|
|
385
|
+
|
|
386
|
+
```sh
|
|
387
|
+
octen premier-search "kafka default topic retention period" -n 5
|
|
388
|
+
octen premier-search "EU AI Act obligations for general-purpose models" --result-type dynamic --time-range year
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
It posts to its own endpoint, `/search-premier`, which takes the request `/search` takes and returns the same response. So the flags, the output and the JSON are `octen search`'s.
|
|
392
|
+
|
|
393
|
+
**Use `octen search` by default.** Premier takes longer, and it is billed at its own per-call rate, which a Search Plan's unlimited searches do not cover.
|
|
394
|
+
|
|
395
|
+
Options: every `octen search` flag except `--topic`, plus `--result-type` (`standard`|`dynamic`). `standard` returns results as the other flags specify; `dynamic` returns only the relevant results, up to `-n`, and adjusts the highlight length per result.
|
|
396
|
+
|
|
397
|
+
A token cap given without its switch is not dropped here: `--highlight-max-tokens` alone caps the highlights, and `--full-content-max-tokens` without `--full-content` exits 2, since it would return no content.
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
382
401
|
### `octen extract`
|
|
383
402
|
|
|
384
403
|
Extract content from one or more URLs (1–20).
|
|
@@ -488,6 +507,34 @@ Unlike `octen search` and `octen video-search`, this endpoint has no time filter
|
|
|
488
507
|
|
|
489
508
|
---
|
|
490
509
|
|
|
510
|
+
### `octen design-search`
|
|
511
|
+
|
|
512
|
+
Real designs to build from: screenshots of web pages, page sections, app screens and slides, each with the design values behind it — colours, fonts, sizes — and, for page sections, the HTML. Web results on the same query come back alongside.
|
|
513
|
+
|
|
514
|
+
```sh
|
|
515
|
+
octen design-search "saas pricing page"
|
|
516
|
+
octen design-search "landing page hero section" -n 10 --no-web
|
|
517
|
+
octen design-search "startup pitch deck slide" --no-snippet
|
|
518
|
+
octen design-search --group <group_id> -n 28
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
A page section or a slide carries the `group` it belongs to. `--group <group_id>` returns every image of that page or deck, in order, instead of searching — it needs no query, and a query given beside it drives the web results only; it does not search within the group. **It still returns five unless told otherwise**, so set `-n` to the group's `total` (the most one call returns is 100). In the terminal, each section or slide prints the command that does this.
|
|
522
|
+
|
|
523
|
+
The response has two parts, each with its own flags:
|
|
524
|
+
|
|
525
|
+
- **Design references** (`data.images`): `-n` (1–100, default 5), `--no-design-facts` (leave out the design values), `--no-snippet` (leave out the code), `--snippet-max-tokens` (100–100000), `--group <id>`. `--no-images` returns web results only.
|
|
526
|
+
- **Web results** (`data.results`): `--web-count` (1–100, default 5), `--include-domains`, `--exclude-domains`, `--language`, `--time-basis`, `--time-range`, `--start-time`, `--end-time`, `--highlight` (+`--highlight-max-tokens`), `--full-content` (+`--full-content-max-tokens`). `--no-web` returns design references only.
|
|
527
|
+
|
|
528
|
+
**The web flags narrow the web results only — never the design references.** A flag for a part that is switched off is refused rather than ignored: `--no-web --include-domains stripe.com` exits 2, because the likeliest reason to type it is expecting the screenshots to be filtered. So is a web flag on a `--group` lookup that has no query — a lookup alone returns no web results — and `--full-content-max-tokens` without `--full-content`, which would return no content.
|
|
529
|
+
|
|
530
|
+
The design values are whatever the API returned for that image, and they differ by kind: design tokens for a web page, colour and font lists for a slide, component counts for an app screen. The terminal view shortens them and the code; `--json` (or a pipe) prints both in full.
|
|
531
|
+
|
|
532
|
+
Image links are signed and expire, so download a screenshot when you get it rather than keeping its link.
|
|
533
|
+
|
|
534
|
+
`octen image-search --topic design` was removed in 0.11.0. Design search has an endpoint of its own now, and this is the command for it; `image-search` is unchanged and still takes no `--topic`.
|
|
535
|
+
|
|
536
|
+
---
|
|
537
|
+
|
|
491
538
|
### `octen video-search`
|
|
492
539
|
|
|
493
540
|
**In Beta** — contact us to request beta access.
|
|
@@ -681,7 +728,7 @@ Scripts must check the exit status, not just the output.
|
|
|
681
728
|
| Status | When |
|
|
682
729
|
|---|---|
|
|
683
730
|
| `0` | The command completed and the response was complete. |
|
|
684
|
-
| `2` | Bad input, caught before any request: a malformed number (`--count 1.5`, `--count 2junk`), an empty comma list (`--include-domains ""`), a blank query, an unknown `--scope`, or a missing API key. |
|
|
731
|
+
| `2` | Bad input, caught before any request: a malformed number (`--count 1.5`, `--count 2junk`), an empty comma list (`--include-domains ""`), a blank query, an unknown `--scope`, flags that cannot be combined (`octen design-search --no-images --no-web`), or a missing API key. |
|
|
685
732
|
| `1` | Everything else: HTTP errors, an API envelope with a non-zero `code`, a timeout, and stream failures. |
|
|
686
733
|
|
|
687
734
|
Two consequences worth knowing:
|
package/dist/api/constants.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export declare const ENDPOINTS: {
|
|
|
14
14
|
readonly businessSearch: "/business-search";
|
|
15
15
|
readonly placeSearch: "/place-search";
|
|
16
16
|
readonly pulseSearch: "/pulse-search";
|
|
17
|
+
readonly searchPremier: "/search-premier";
|
|
18
|
+
readonly designSearch: "/design-search";
|
|
17
19
|
};
|
|
18
20
|
export declare const EMBEDDING_MODELS: Record<string, string>;
|
|
19
21
|
export declare const VL_EMBEDDING_MODELS: Record<string, string>;
|
|
@@ -109,6 +111,14 @@ export declare const LIMITS: {
|
|
|
109
111
|
readonly min: -180;
|
|
110
112
|
readonly max: 180;
|
|
111
113
|
};
|
|
114
|
+
readonly designCount: {
|
|
115
|
+
readonly min: 1;
|
|
116
|
+
readonly max: 100;
|
|
117
|
+
};
|
|
118
|
+
readonly snippetMaxTokens: {
|
|
119
|
+
readonly min: 100;
|
|
120
|
+
readonly max: 100000;
|
|
121
|
+
};
|
|
112
122
|
};
|
|
113
123
|
export declare const TOPIC_OPTIONS: readonly ["general", "news"];
|
|
114
124
|
export declare const TIME_BASIS_OPTIONS: readonly ["auto", "published", "crawled"];
|
|
@@ -118,5 +128,6 @@ export declare const FORMAT_OPTIONS: readonly ["text", "markdown"];
|
|
|
118
128
|
export declare const EXTRACT_MODE_OPTIONS: readonly ["standard", "advanced", "auto"];
|
|
119
129
|
export declare const LINK_SCOPE_OPTIONS: readonly ["prefer_internal", "prefer_external"];
|
|
120
130
|
export declare const PULSE_MODE_OPTIONS: readonly ["lite", "standard"];
|
|
131
|
+
export declare const RESULT_TYPE_OPTIONS: readonly ["standard", "dynamic"];
|
|
121
132
|
export declare const SKILLS_REPO = "Octen-Team/octen-skills";
|
|
122
133
|
export declare const SKILLS_REPO_TARBALL: (ref: string) => string;
|
package/dist/api/constants.js
CHANGED
|
@@ -14,6 +14,8 @@ export const ENDPOINTS = {
|
|
|
14
14
|
businessSearch: "/business-search",
|
|
15
15
|
placeSearch: "/place-search",
|
|
16
16
|
pulseSearch: "/pulse-search",
|
|
17
|
+
searchPremier: "/search-premier",
|
|
18
|
+
designSearch: "/design-search",
|
|
17
19
|
};
|
|
18
20
|
export const EMBEDDING_MODELS = {
|
|
19
21
|
"0.6b": "octen-embedding-0.6b",
|
|
@@ -52,6 +54,8 @@ export const LIMITS = {
|
|
|
52
54
|
placeRadius: { min: 1, max: 50_000 },
|
|
53
55
|
latitude: { min: -90, max: 90 },
|
|
54
56
|
longitude: { min: -180, max: 180 },
|
|
57
|
+
designCount: { min: 1, max: 100 },
|
|
58
|
+
snippetMaxTokens: { min: 100, max: 100_000 },
|
|
55
59
|
};
|
|
56
60
|
export const TOPIC_OPTIONS = ["general", "news"];
|
|
57
61
|
export const TIME_BASIS_OPTIONS = ["auto", "published", "crawled"];
|
|
@@ -61,5 +65,6 @@ export const FORMAT_OPTIONS = ["text", "markdown"];
|
|
|
61
65
|
export const EXTRACT_MODE_OPTIONS = ["standard", "advanced", "auto"];
|
|
62
66
|
export const LINK_SCOPE_OPTIONS = ["prefer_internal", "prefer_external"];
|
|
63
67
|
export const PULSE_MODE_OPTIONS = ["lite", "standard"];
|
|
68
|
+
export const RESULT_TYPE_OPTIONS = ["standard", "dynamic"];
|
|
64
69
|
export const SKILLS_REPO = "Octen-Team/octen-skills";
|
|
65
70
|
export const SKILLS_REPO_TARBALL = (ref) => `https://github.com/${SKILLS_REPO}/archive/${ref}.tar.gz`;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type SearchResult } from "./search.js";
|
|
2
|
+
export interface DesignSearchOpts {
|
|
3
|
+
count?: number;
|
|
4
|
+
group?: string;
|
|
5
|
+
noImages?: boolean;
|
|
6
|
+
noDesignFacts?: boolean;
|
|
7
|
+
noSnippet?: boolean;
|
|
8
|
+
snippetMaxTokens?: number;
|
|
9
|
+
noWeb?: boolean;
|
|
10
|
+
webCount?: number;
|
|
11
|
+
includeDomains?: string[];
|
|
12
|
+
excludeDomains?: string[];
|
|
13
|
+
language?: string[];
|
|
14
|
+
timeBasis?: "auto" | "published" | "crawled";
|
|
15
|
+
timeRange?: string;
|
|
16
|
+
startTime?: string;
|
|
17
|
+
endTime?: string;
|
|
18
|
+
highlight?: boolean;
|
|
19
|
+
highlightMaxTokens?: number;
|
|
20
|
+
fullContent?: boolean;
|
|
21
|
+
fullContentMaxTokens?: number;
|
|
22
|
+
}
|
|
23
|
+
/** The page or deck an image belongs to. */
|
|
24
|
+
export interface DesignImageGroup {
|
|
25
|
+
group_id?: string;
|
|
26
|
+
type?: string;
|
|
27
|
+
name?: string;
|
|
28
|
+
position?: number;
|
|
29
|
+
total?: number;
|
|
30
|
+
master?: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
/** One design reference. All fields optional — the server is untyped. */
|
|
33
|
+
export interface DesignImage {
|
|
34
|
+
type?: string;
|
|
35
|
+
title?: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
url?: string;
|
|
38
|
+
thumbnail?: string;
|
|
39
|
+
source_page?: string;
|
|
40
|
+
width?: number;
|
|
41
|
+
height?: number;
|
|
42
|
+
group?: DesignImageGroup;
|
|
43
|
+
design_facts?: Record<string, unknown>;
|
|
44
|
+
snippet?: {
|
|
45
|
+
format?: string;
|
|
46
|
+
code?: string;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** Response shape for the /design-search endpoint. */
|
|
50
|
+
export interface DesignSearchResponse {
|
|
51
|
+
query?: string;
|
|
52
|
+
images?: DesignImage[];
|
|
53
|
+
results?: SearchResult[];
|
|
54
|
+
}
|
|
55
|
+
export declare function buildDesignSearchRequest(query: string, o: DesignSearchOpts): Record<string, unknown>;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request builder for /design-search.
|
|
3
|
+
*
|
|
4
|
+
* The endpoint returns two groups of results and takes a block of options for
|
|
5
|
+
* each: `images` — the design references, which are what the search is for —
|
|
6
|
+
* and `web_search`, pages on the same query. Both are on unless switched off,
|
|
7
|
+
* and an option is only ever sent when the caller gave it, so the defaults
|
|
8
|
+
* stay the API's.
|
|
9
|
+
*
|
|
10
|
+
* `images.group_id` replaces the search with a lookup: every image of one page
|
|
11
|
+
* or deck, in order. A lookup needs no query.
|
|
12
|
+
*
|
|
13
|
+
* A token cap is a request for the thing it caps, so `--snippet-max-tokens`
|
|
14
|
+
* and `--highlight-max-tokens` are sent with `enable: true`. This endpoint
|
|
15
|
+
* honours a cap sent alone, but `/search` reads a block with no `enable` as
|
|
16
|
+
* switched off; saying it leaves nothing to interpretation.
|
|
17
|
+
*
|
|
18
|
+
* Refused here rather than spent on a request:
|
|
19
|
+
* - nothing to search for and no group to fetch;
|
|
20
|
+
* - a group with the images switched off;
|
|
21
|
+
* - both groups switched off — the API answers that with an empty success
|
|
22
|
+
* that still counts as a search;
|
|
23
|
+
* - an option for a group that is switched off, which does nothing at the API
|
|
24
|
+
* and is usually typed in the belief that it applies to the other group;
|
|
25
|
+
* - a web option on a lookup that has no query, which returns no web results
|
|
26
|
+
* for it to apply to;
|
|
27
|
+
* - a full-content cap without `--full-content`, which returns no content.
|
|
28
|
+
*/
|
|
29
|
+
import { LIMITS, TIME_BASIS_OPTIONS, TIME_RANGE_OPTIONS } from "./constants.js";
|
|
30
|
+
import { OctenValidationError } from "./errors.js";
|
|
31
|
+
import { assertRange, normalizeTimeBound, validateEnum } from "./search.js";
|
|
32
|
+
/** The first option in the list that the caller actually gave. */
|
|
33
|
+
function firstGiven(options) {
|
|
34
|
+
return options.find(([, v]) => v != null && v !== false)?.[0];
|
|
35
|
+
}
|
|
36
|
+
/** An object of the fields that were given, or undefined when none were. */
|
|
37
|
+
function block(fields) {
|
|
38
|
+
const set = fields.filter(([, v]) => v != null);
|
|
39
|
+
return set.length ? Object.fromEntries(set) : undefined;
|
|
40
|
+
}
|
|
41
|
+
export function buildDesignSearchRequest(query, o) {
|
|
42
|
+
const hasQuery = query.trim().length > 0;
|
|
43
|
+
// Trimmed before it is checked, so the id that was checked is the id sent.
|
|
44
|
+
const group = o.group?.trim();
|
|
45
|
+
if (o.group != null && !group)
|
|
46
|
+
throw new OctenValidationError("--group must not be empty");
|
|
47
|
+
if (!hasQuery && !group)
|
|
48
|
+
throw new OctenValidationError("give a query, or --group <id> to fetch every image of one page or deck");
|
|
49
|
+
if (group && o.noImages)
|
|
50
|
+
throw new OctenValidationError("--group returns images, so it cannot be combined with --no-images");
|
|
51
|
+
if (o.noImages && o.noWeb)
|
|
52
|
+
throw new OctenValidationError("--no-images and --no-web together leave nothing to return");
|
|
53
|
+
const imageOnly = [
|
|
54
|
+
["--count", o.count],
|
|
55
|
+
["--no-design-facts", o.noDesignFacts],
|
|
56
|
+
["--no-snippet", o.noSnippet],
|
|
57
|
+
["--snippet-max-tokens", o.snippetMaxTokens],
|
|
58
|
+
];
|
|
59
|
+
const webOnly = [
|
|
60
|
+
["--web-count", o.webCount],
|
|
61
|
+
["--include-domains", o.includeDomains],
|
|
62
|
+
["--exclude-domains", o.excludeDomains],
|
|
63
|
+
["--language", o.language],
|
|
64
|
+
["--time-basis", o.timeBasis],
|
|
65
|
+
["--time-range", o.timeRange],
|
|
66
|
+
["--start-time", o.startTime],
|
|
67
|
+
["--end-time", o.endTime],
|
|
68
|
+
["--highlight", o.highlight],
|
|
69
|
+
["--highlight-max-tokens", o.highlightMaxTokens],
|
|
70
|
+
["--full-content", o.fullContent],
|
|
71
|
+
["--full-content-max-tokens", o.fullContentMaxTokens],
|
|
72
|
+
];
|
|
73
|
+
const strayImage = o.noImages ? firstGiven(imageOnly) : undefined;
|
|
74
|
+
if (strayImage)
|
|
75
|
+
throw new OctenValidationError(`${strayImage} applies to the design references, which --no-images switches off`);
|
|
76
|
+
const strayWeb = o.noWeb ? firstGiven(webOnly) : undefined;
|
|
77
|
+
if (strayWeb)
|
|
78
|
+
throw new OctenValidationError(`${strayWeb} applies to the web results, which --no-web switches off`);
|
|
79
|
+
// A lookup with no query returns no web results, so a web option beside it
|
|
80
|
+
// has nothing to apply to — and it does not reach the images either.
|
|
81
|
+
const idleWeb = group && !hasQuery && !o.noWeb ? firstGiven(webOnly) : undefined;
|
|
82
|
+
if (idleWeb)
|
|
83
|
+
throw new OctenValidationError(`${idleWeb} applies to the web results, which need a query — a group lookup alone returns none`);
|
|
84
|
+
if (o.noSnippet && o.snippetMaxTokens != null)
|
|
85
|
+
throw new OctenValidationError("--snippet-max-tokens has no effect with --no-snippet");
|
|
86
|
+
if (o.fullContentMaxTokens != null && !o.fullContent)
|
|
87
|
+
throw new OctenValidationError("--full-content-max-tokens needs --full-content — full content is off unless asked for");
|
|
88
|
+
assertRange("count", o.count, LIMITS.designCount);
|
|
89
|
+
assertRange("snippet-max-tokens", o.snippetMaxTokens, LIMITS.snippetMaxTokens);
|
|
90
|
+
assertRange("web-count", o.webCount, LIMITS.searchCount);
|
|
91
|
+
assertRange("highlight-max-tokens", o.highlightMaxTokens, LIMITS.highlightMaxTokens);
|
|
92
|
+
assertRange("full-content-max-tokens", o.fullContentMaxTokens, LIMITS.fullContentMaxTokens);
|
|
93
|
+
validateEnum("--time-basis", o.timeBasis, TIME_BASIS_OPTIONS);
|
|
94
|
+
validateEnum("--time-range", o.timeRange, TIME_RANGE_OPTIONS);
|
|
95
|
+
const req = {};
|
|
96
|
+
// Sent as typed; a query of only whitespace beside a group is not sent at all.
|
|
97
|
+
if (hasQuery)
|
|
98
|
+
req.query = query;
|
|
99
|
+
const images = o.noImages
|
|
100
|
+
? { enable: false }
|
|
101
|
+
: block([
|
|
102
|
+
["count", o.count],
|
|
103
|
+
["design_facts", o.noDesignFacts ? false : undefined],
|
|
104
|
+
[
|
|
105
|
+
"snippet",
|
|
106
|
+
o.noSnippet
|
|
107
|
+
? { enable: false }
|
|
108
|
+
: o.snippetMaxTokens != null ? { enable: true, max_tokens: o.snippetMaxTokens } : undefined,
|
|
109
|
+
],
|
|
110
|
+
["group_id", group],
|
|
111
|
+
]);
|
|
112
|
+
if (images)
|
|
113
|
+
req.images = images;
|
|
114
|
+
const web = o.noWeb
|
|
115
|
+
? { enable: false }
|
|
116
|
+
: block([
|
|
117
|
+
["count", o.webCount],
|
|
118
|
+
["include_domains", o.includeDomains],
|
|
119
|
+
["exclude_domains", o.excludeDomains],
|
|
120
|
+
["language", o.language],
|
|
121
|
+
["time_basis", o.timeBasis],
|
|
122
|
+
["time_range", o.timeRange],
|
|
123
|
+
["start_time", normalizeTimeBound("--start-time", o.startTime, false)],
|
|
124
|
+
["end_time", normalizeTimeBound("--end-time", o.endTime, true)],
|
|
125
|
+
[
|
|
126
|
+
"highlight",
|
|
127
|
+
o.highlight || o.highlightMaxTokens != null
|
|
128
|
+
? { enable: true, ...block([["max_tokens", o.highlightMaxTokens]]) }
|
|
129
|
+
: undefined,
|
|
130
|
+
],
|
|
131
|
+
["full_content", o.fullContent ? { enable: true, ...block([["max_tokens", o.fullContentMaxTokens]]) } : undefined],
|
|
132
|
+
]);
|
|
133
|
+
if (web)
|
|
134
|
+
req.web_search = web;
|
|
135
|
+
return req;
|
|
136
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request builder for /search-premier.
|
|
3
|
+
*
|
|
4
|
+
* The API reference gives this endpoint the request body of `/search`, so the
|
|
5
|
+
* shared options go through the search builder rather than a second copy of
|
|
6
|
+
* it. Kept here are the places where this command differs from `search`:
|
|
7
|
+
*
|
|
8
|
+
* - `result_type`, which the reference documents and `search` does not offer;
|
|
9
|
+
* - `topic`, which is `search`'s own and is never forwarded;
|
|
10
|
+
* - a token cap given without its switch. The search builder sends a cap only
|
|
11
|
+
* beside `--highlight` / `--full-content` and drops it otherwise. Here a
|
|
12
|
+
* highlight cap is sent, and a full-content cap is refused — see below.
|
|
13
|
+
*/
|
|
14
|
+
import { RESULT_TYPE_OPTIONS } from "./constants.js";
|
|
15
|
+
import { type SearchOpts } from "./search.js";
|
|
16
|
+
export interface PremierSearchOpts extends Omit<SearchOpts, "topic"> {
|
|
17
|
+
resultType?: (typeof RESULT_TYPE_OPTIONS)[number];
|
|
18
|
+
}
|
|
19
|
+
export declare function buildPremierSearchRequest(query: string, o: PremierSearchOpts): Record<string, unknown>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request builder for /search-premier.
|
|
3
|
+
*
|
|
4
|
+
* The API reference gives this endpoint the request body of `/search`, so the
|
|
5
|
+
* shared options go through the search builder rather than a second copy of
|
|
6
|
+
* it. Kept here are the places where this command differs from `search`:
|
|
7
|
+
*
|
|
8
|
+
* - `result_type`, which the reference documents and `search` does not offer;
|
|
9
|
+
* - `topic`, which is `search`'s own and is never forwarded;
|
|
10
|
+
* - a token cap given without its switch. The search builder sends a cap only
|
|
11
|
+
* beside `--highlight` / `--full-content` and drops it otherwise. Here a
|
|
12
|
+
* highlight cap is sent, and a full-content cap is refused — see below.
|
|
13
|
+
*/
|
|
14
|
+
import { RESULT_TYPE_OPTIONS } from "./constants.js";
|
|
15
|
+
import { OctenValidationError } from "./errors.js";
|
|
16
|
+
import { buildSearchOptions, validateEnum } from "./search.js";
|
|
17
|
+
export function buildPremierSearchRequest(query, o) {
|
|
18
|
+
if (query.trim().length === 0)
|
|
19
|
+
throw new OctenValidationError("query is required");
|
|
20
|
+
validateEnum("--result-type", o.resultType, RESULT_TYPE_OPTIONS);
|
|
21
|
+
// Full content is off unless asked for, and the API returns none for a cap
|
|
22
|
+
// sent alone. Dropping the cap would hide that; switching a billed option on
|
|
23
|
+
// from a flag that did not name it would be worse.
|
|
24
|
+
if (o.fullContentMaxTokens != null && !o.fullContent)
|
|
25
|
+
throw new OctenValidationError("--full-content-max-tokens needs --full-content — full content is off unless asked for");
|
|
26
|
+
// Dropped by name, not by type: an options object built for `search` would
|
|
27
|
+
// otherwise carry its `topic` straight through.
|
|
28
|
+
const { topic: _topic, resultType, ...shared } = o;
|
|
29
|
+
// A highlight cap is a request for highlights of that length, so it is sent
|
|
30
|
+
// as one. It has to carry `enable`: the API returns no highlights at all for
|
|
31
|
+
// a `highlight` block without it, whatever the documented default.
|
|
32
|
+
const highlight = shared.highlight || shared.highlightMaxTokens != null;
|
|
33
|
+
const req = { query, ...buildSearchOptions({ ...shared, highlight }) };
|
|
34
|
+
if (resultType != null)
|
|
35
|
+
req.result_type = resultType;
|
|
36
|
+
return req;
|
|
37
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -5,15 +5,18 @@ import { readFileSync } from "node:fs";
|
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import pc from "picocolors";
|
|
7
7
|
import { exitCodeFor } from "./api/errors.js";
|
|
8
|
+
import { printable } from "./util/terminalText.js";
|
|
8
9
|
import { registerSearch } from "./commands/search.js";
|
|
9
10
|
import { registerBusinessSearch, registerNewsSearch, registerPulseSearch, } from "./commands/verticalSearch.js";
|
|
10
11
|
import { registerPlaceSearch } from "./commands/placeSearch.js";
|
|
11
12
|
import { registerBroadSearch } from "./commands/broadSearch.js";
|
|
13
|
+
import { registerPremierSearch } from "./commands/premierSearch.js";
|
|
12
14
|
import { registerExtract } from "./commands/extract.js";
|
|
13
15
|
import { registerChat } from "./commands/chat.js";
|
|
14
16
|
import { registerEmbed } from "./commands/embed.js";
|
|
15
17
|
import { registerVlEmbed } from "./commands/vlEmbed.js";
|
|
16
18
|
import { registerImageSearch } from "./commands/imageSearch.js";
|
|
19
|
+
import { registerDesignSearch } from "./commands/designSearch.js";
|
|
17
20
|
import { registerVideoSearch } from "./commands/videoSearch.js";
|
|
18
21
|
import { registerConfigureMcp } from "./commands/configureMcp.js";
|
|
19
22
|
import { registerConfigureSkills } from "./commands/configureSkills.js";
|
|
@@ -47,11 +50,13 @@ registerBusinessSearch(program);
|
|
|
47
50
|
registerPlaceSearch(program);
|
|
48
51
|
registerPulseSearch(program);
|
|
49
52
|
registerBroadSearch(program);
|
|
53
|
+
registerPremierSearch(program);
|
|
50
54
|
registerExtract(program);
|
|
51
55
|
registerChat(program);
|
|
52
56
|
registerEmbed(program);
|
|
53
57
|
registerVlEmbed(program);
|
|
54
58
|
registerImageSearch(program);
|
|
59
|
+
registerDesignSearch(program);
|
|
55
60
|
registerVideoSearch(program);
|
|
56
61
|
registerLogin(program);
|
|
57
62
|
registerLogout(program);
|
|
@@ -59,6 +64,9 @@ registerWhoami(program);
|
|
|
59
64
|
// Register LAST so introspection sees every command and its flags.
|
|
60
65
|
registerCompletion(program);
|
|
61
66
|
program.parseAsync().catch((err) => {
|
|
62
|
-
|
|
67
|
+
// An API error carries the server's own message, which is response text
|
|
68
|
+
// like any other: shown, never sent, if it holds control characters.
|
|
69
|
+
const message = printable(String(err?.message ?? err));
|
|
70
|
+
process.stderr.write(pc.red(`error: ${message}\n`));
|
|
63
71
|
process.exit(exitCodeFor(err));
|
|
64
72
|
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ENDPOINTS } from "../api/constants.js";
|
|
2
|
+
import { buildDesignSearchRequest, } from "../api/designSearch.js";
|
|
3
|
+
import { chooseMode, emit } from "../output/render.js";
|
|
4
|
+
import { renderDesignSearch } from "../output/pretty/designSearch.js";
|
|
5
|
+
import { makeClient, parseCsvOpt, parseIntOpt } from "./utils.js";
|
|
6
|
+
export function registerDesignSearch(program) {
|
|
7
|
+
program.command("design-search")
|
|
8
|
+
.argument("[query...]", "what to find, e.g. 'saas pricing page' (optional with --group)")
|
|
9
|
+
.description("Real web pages, page sections, app screens and slides as design references — each a screenshot with its design values and, for page sections, the HTML. Web results on the same query come back alongside")
|
|
10
|
+
.option("-n, --count <n>", "design references to return, 1-100", parseIntOpt("--count"))
|
|
11
|
+
.option("--group <id>", "every image of one page or deck, in order — takes a result's group_id; set -n to the group's total")
|
|
12
|
+
.option("--no-design-facts", "leave out the design values")
|
|
13
|
+
.option("--no-snippet", "leave out the code")
|
|
14
|
+
.option("--snippet-max-tokens <n>", "max tokens of code per result, 100-100000", parseIntOpt("--snippet-max-tokens"))
|
|
15
|
+
.option("--no-images", "web results only")
|
|
16
|
+
.option("--no-web", "design references only")
|
|
17
|
+
.option("--web-count <n>", "web results, 1-100", parseIntOpt("--web-count"))
|
|
18
|
+
.option("--include-domains <list>", "web results only: comma list", parseCsvOpt("--include-domains"))
|
|
19
|
+
.option("--exclude-domains <list>", "web results only: comma list", parseCsvOpt("--exclude-domains"))
|
|
20
|
+
.option("--language <list>", "web results only: ISO 639-1 codes, comma-separated, e.g. en,ja", parseCsvOpt("--language"))
|
|
21
|
+
.option("--time-basis <b>", "web results only: auto|published|crawled")
|
|
22
|
+
.option("--time-range <r>", "web results only: day|week|month|year (or d|w|m|y)")
|
|
23
|
+
.option("--start-time <when>", "web results only: YYYY-MM-DD or ISO datetime")
|
|
24
|
+
.option("--end-time <when>", "web results only: YYYY-MM-DD or ISO datetime")
|
|
25
|
+
.option("--highlight", "web results only")
|
|
26
|
+
.option("--highlight-max-tokens <n>", "web results only: max tokens per highlight", parseIntOpt("--highlight-max-tokens"))
|
|
27
|
+
.option("--full-content", "web results only")
|
|
28
|
+
.option("--full-content-max-tokens <n>", "web results only: max tokens per result (needs --full-content)", parseIntOpt("--full-content-max-tokens"))
|
|
29
|
+
.action(async (queryArg, opts, command) => {
|
|
30
|
+
const g = command.optsWithGlobals();
|
|
31
|
+
const client = makeClient(g);
|
|
32
|
+
// Picked field by field, not spread: commander gives every `--no-x`
|
|
33
|
+
// option a default of `true`, and the builder wants to know only whether
|
|
34
|
+
// it was switched off.
|
|
35
|
+
const o = {
|
|
36
|
+
count: opts.count,
|
|
37
|
+
group: opts.group,
|
|
38
|
+
noImages: opts.images === false,
|
|
39
|
+
noDesignFacts: opts.designFacts === false,
|
|
40
|
+
noSnippet: opts.snippet === false,
|
|
41
|
+
snippetMaxTokens: opts.snippetMaxTokens,
|
|
42
|
+
noWeb: opts.web === false,
|
|
43
|
+
webCount: opts.webCount,
|
|
44
|
+
includeDomains: opts.includeDomains,
|
|
45
|
+
excludeDomains: opts.excludeDomains,
|
|
46
|
+
language: opts.language,
|
|
47
|
+
timeBasis: opts.timeBasis,
|
|
48
|
+
timeRange: opts.timeRange,
|
|
49
|
+
startTime: opts.startTime,
|
|
50
|
+
endTime: opts.endTime,
|
|
51
|
+
highlight: opts.highlight,
|
|
52
|
+
highlightMaxTokens: opts.highlightMaxTokens,
|
|
53
|
+
fullContent: opts.fullContent,
|
|
54
|
+
fullContentMaxTokens: opts.fullContentMaxTokens,
|
|
55
|
+
};
|
|
56
|
+
const req = buildDesignSearchRequest((queryArg ?? []).join(" "), o);
|
|
57
|
+
const res = await client.request(ENDPOINTS.designSearch, req);
|
|
58
|
+
// The renderer is told when this was a lookup: it prints different hints
|
|
59
|
+
// for a group that was asked for than for one a search happened to hit.
|
|
60
|
+
const group = req.images?.group_id;
|
|
61
|
+
emit(res, chooseMode(g, process.stdout.isTTY ?? false), (d) => renderDesignSearch(d, { group, baseUrl: g.baseUrl }));
|
|
62
|
+
});
|
|
63
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
/**
|
|
3
|
+
* `/search-premier` takes the request body of `/search` and returns the same
|
|
4
|
+
* response, so this is `search`'s flag set and `search`'s renderer. It is a
|
|
5
|
+
* command of its own because it is a different endpoint, slower and billed at
|
|
6
|
+
* its own rate — not something a flag on `search` should switch on quietly.
|
|
7
|
+
*/
|
|
8
|
+
export declare function registerPremierSearch(program: Command): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ENDPOINTS } from "../api/constants.js";
|
|
2
|
+
import { buildPremierSearchRequest } from "../api/premierSearch.js";
|
|
3
|
+
import { chooseMode, emit } from "../output/render.js";
|
|
4
|
+
import { renderSearch } from "../output/pretty/search.js";
|
|
5
|
+
import { makeClient, parseCsvOpt, parseIntOpt } from "./utils.js";
|
|
6
|
+
/**
|
|
7
|
+
* `/search-premier` takes the request body of `/search` and returns the same
|
|
8
|
+
* response, so this is `search`'s flag set and `search`'s renderer. It is a
|
|
9
|
+
* command of its own because it is a different endpoint, slower and billed at
|
|
10
|
+
* its own rate — not something a flag on `search` should switch on quietly.
|
|
11
|
+
*/
|
|
12
|
+
export function registerPremierSearch(program) {
|
|
13
|
+
program.command("premier-search")
|
|
14
|
+
.argument("<query...>", "search query")
|
|
15
|
+
.description("Search the live web with deeper retrieval and reranking — slower than `search` and billed at its own rate, so reach for it when `search` falls short")
|
|
16
|
+
.option("--result-type <t>", "standard|dynamic")
|
|
17
|
+
.option("-n, --count <n>", "results 1-100", parseIntOpt("--count"))
|
|
18
|
+
.option("--include-domains <list>", "comma list", parseCsvOpt("--include-domains"))
|
|
19
|
+
.option("--exclude-domains <list>", "comma list", parseCsvOpt("--exclude-domains"))
|
|
20
|
+
.option("--include-text <list>", "comma list", parseCsvOpt("--include-text"))
|
|
21
|
+
.option("--exclude-text <list>", "comma list", parseCsvOpt("--exclude-text"))
|
|
22
|
+
.option("--time-basis <b>", "auto|published|crawled").option("--time-range <r>", "day|week|month|year (or d|w|m|y)")
|
|
23
|
+
.option("--start-time <when>", "YYYY-MM-DD or ISO datetime (e.g. 2024-01-01T00:00:00Z)")
|
|
24
|
+
.option("--end-time <when>", "YYYY-MM-DD or ISO datetime (e.g. 2024-12-31T23:59:59Z)")
|
|
25
|
+
.option("--format <f>", "text|markdown").option("--safesearch <s>", "off|strict")
|
|
26
|
+
.option("--language <list>", "ISO 639-1 codes, comma-separated, e.g. en,ja", parseCsvOpt("--language"))
|
|
27
|
+
.option("--highlight").option("--highlight-max-tokens <n>", "max tokens per highlight", parseIntOpt("--highlight-max-tokens"))
|
|
28
|
+
.option("--full-content").option("--full-content-max-tokens <n>", "max tokens per result", parseIntOpt("--full-content-max-tokens"))
|
|
29
|
+
.option("--images")
|
|
30
|
+
.action(async (queryArg, opts, command) => {
|
|
31
|
+
const g = command.optsWithGlobals();
|
|
32
|
+
const client = makeClient(g);
|
|
33
|
+
const req = buildPremierSearchRequest(queryArg.join(" "), opts);
|
|
34
|
+
const res = await client.request(ENDPOINTS.searchPremier, req);
|
|
35
|
+
emit(res, chooseMode(g, process.stdout.isTTY ?? false), renderSearch);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface DesignRenderContext {
|
|
2
|
+
/** Set when the request was a group lookup, to the id that was asked for. */
|
|
3
|
+
group?: string;
|
|
4
|
+
/**
|
|
5
|
+
* Set when the search was sent to a base URL given on the command line, so
|
|
6
|
+
* the command printed for a follow-up lookup goes to the same place. A base
|
|
7
|
+
* URL from the environment needs nothing: it carries over by itself.
|
|
8
|
+
*/
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Design references live under `data.images`; `data.results` holds the web
|
|
13
|
+
* results that come back alongside.
|
|
14
|
+
*/
|
|
15
|
+
export declare function renderDesignSearch(data: any, ctx?: DesignRenderContext): string;
|