@octen.ai/cli 0.6.0 → 0.7.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 +9 -7
- package/dist/api/constants.d.ts +9 -0
- package/dist/api/constants.js +3 -1
- package/dist/api/mediaSearch.d.ts +0 -3
- package/dist/api/mediaSearch.js +12 -10
- package/dist/api/search.d.ts +8 -1
- package/dist/api/search.js +13 -3
- package/dist/commands/broadSearch.js +1 -1
- package/dist/commands/imageSearch.js +1 -7
- package/dist/commands/search.js +1 -1
- package/package.json +1 -1
- package/skills/octen-search/SKILL.md +2 -2
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ Search the live web.
|
|
|
61
61
|
octen search "latest LLM benchmarks" -n 10 --topic news --highlight --time-range week
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
Options: `-n` (result count 1–100), `--topic` (general|news), `--highlight` (+`--highlight-max-tokens`,
|
|
64
|
+
Options: `-n` (result count 1–100), `--topic` (general|news), `--highlight` (+`--highlight-max-tokens`, 100–20000), `--time-range` (day|week|month|year or d|w|m|y), `--start-time`/`--end-time` (YYYY-MM-DD or ISO datetime), `--include-domains`, `--exclude-domains`, `--language` (comma-separated ISO 639-1 codes, e.g. `en,ja` — one of `ar de en es fr hi id it ja ko nl pl pt ru th tr vi zh`), `--full-content` (+`--full-content-max-tokens`, 100–100000), `--images`, `--format` (text|markdown), `--safesearch`.
|
|
65
65
|
|
|
66
66
|
---
|
|
67
67
|
|
|
@@ -85,7 +85,7 @@ Use it for comparisons across many sources (pricing, products, vendors), surveys
|
|
|
85
85
|
octen broad-search "compare cloud GPU pricing across providers" --max-queries 5 -n 10
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
-
Options: `--max-queries` (decompose into up to N sub-queries, 1–30, default 5), plus all `octen search` flags (`-n/--count` per sub-query, `--topic`, `--highlight`, `--full-content`, `--time-range`, `--start-time`/`--end-time`, `--include-domains`/`--exclude-domains`, `--include-text`/`--exclude-text`, `--language`, `--images`, `--
|
|
88
|
+
Options: `--max-queries` (decompose into up to N sub-queries, 1–30, default 5), plus all `octen search` flags (`-n/--count` per sub-query, `--topic`, `--highlight`, `--full-content`, `--time-range`, `--start-time`/`--end-time`, `--include-domains`/`--exclude-domains`, `--include-text`/`--exclude-text`, `--language`, `--images`, `--format`, `--safesearch`).
|
|
89
89
|
|
|
90
90
|
---
|
|
91
91
|
|
|
@@ -164,17 +164,19 @@ Options: `-m/--model` (base|large or full ID), `--fusion`/`--no-fusion`, `--dime
|
|
|
164
164
|
|
|
165
165
|
**In Beta** — contact us to request beta access.
|
|
166
166
|
|
|
167
|
-
Search the web for images by text query
|
|
167
|
+
Search the web for images, either by text query or by example image.
|
|
168
168
|
|
|
169
169
|
```sh
|
|
170
|
-
octen image-search "red sports car" -n 10 --topic design
|
|
170
|
+
octen image-search "red sports car" -n 10 --topic design
|
|
171
171
|
octen image-search --image https://example.com/car.jpg
|
|
172
|
-
octen image-search
|
|
172
|
+
octen image-search --image ./car.png
|
|
173
173
|
```
|
|
174
174
|
|
|
175
|
-
`--image` accepts a public URL or a local file path (read inline as base64, max 5MB).
|
|
175
|
+
The endpoint takes exactly one input, so pass a query **or** `--image`, not both. `--image` accepts a public URL or a local file path (read inline as base64, max 5MB).
|
|
176
176
|
|
|
177
|
-
Options: `--image <url|path>`, `--topic` (general|design), `-n` (result count 1–10), `--include-domains`, `--exclude-domains`, `--
|
|
177
|
+
Options: `--image <url|path>`, `--topic` (general|design), `-n` (result count 1–10), `--include-domains`, `--exclude-domains`, `--safesearch` (off|strict), `--html-snippet` (+`--html-snippet-max-tokens`, 100–100000).
|
|
178
|
+
|
|
179
|
+
Unlike `octen search` and `octen video-search`, this endpoint has no time filters.
|
|
178
180
|
|
|
179
181
|
---
|
|
180
182
|
|
package/dist/api/constants.d.ts
CHANGED
|
@@ -39,6 +39,15 @@ export declare const LIMITS: {
|
|
|
39
39
|
};
|
|
40
40
|
readonly highlightMaxTokens: {
|
|
41
41
|
readonly min: 100;
|
|
42
|
+
readonly max: 20000;
|
|
43
|
+
};
|
|
44
|
+
readonly fullContentMaxTokens: {
|
|
45
|
+
readonly min: 100;
|
|
46
|
+
readonly max: 100000;
|
|
47
|
+
};
|
|
48
|
+
readonly htmlSnippetMaxTokens: {
|
|
49
|
+
readonly min: 100;
|
|
50
|
+
readonly max: 100000;
|
|
42
51
|
};
|
|
43
52
|
readonly vlContents: 20;
|
|
44
53
|
readonly vlImages: 5;
|
package/dist/api/constants.js
CHANGED
|
@@ -28,7 +28,9 @@ export const LIMITS = {
|
|
|
28
28
|
extractUrls: { min: 1, max: 20 },
|
|
29
29
|
extractTimeout: { min: 1, max: 60 },
|
|
30
30
|
cacheWindow: { min: 300, max: 31_536_000, default: 86_400 },
|
|
31
|
-
highlightMaxTokens: { min: 100 },
|
|
31
|
+
highlightMaxTokens: { min: 100, max: 20_000 },
|
|
32
|
+
fullContentMaxTokens: { min: 100, max: 100_000 },
|
|
33
|
+
htmlSnippetMaxTokens: { min: 100, max: 100_000 },
|
|
32
34
|
vlContents: 20,
|
|
33
35
|
vlImages: 5,
|
|
34
36
|
vlVideos: 1,
|
|
@@ -23,9 +23,6 @@ export interface ImageSearchOpts {
|
|
|
23
23
|
count?: number;
|
|
24
24
|
includeDomains?: string[];
|
|
25
25
|
excludeDomains?: string[];
|
|
26
|
-
timeRange?: string;
|
|
27
|
-
startTime?: string;
|
|
28
|
-
endTime?: string;
|
|
29
26
|
safesearch?: "off" | "strict";
|
|
30
27
|
htmlSnippet?: boolean;
|
|
31
28
|
htmlSnippetMaxTokens?: number;
|
package/dist/api/mediaSearch.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync, existsSync, statSync } from "node:fs";
|
|
2
2
|
import { LIMITS, IMAGE_TOPIC_OPTIONS, TIME_RANGE_OPTIONS, SAFESEARCH_OPTIONS, } from "./constants.js";
|
|
3
3
|
import { OctenValidationError } from "./errors.js";
|
|
4
|
-
import { validateEnum, normalizeTimeBound } from "./search.js";
|
|
4
|
+
import { validateEnum, normalizeTimeBound, assertRange } from "./search.js";
|
|
5
5
|
/** Max size of a local image read inline as base64. */
|
|
6
6
|
const MAX_IMAGE_BYTES = 5 * 1024 * 1024; // 5 MB
|
|
7
7
|
/**
|
|
@@ -26,17 +26,22 @@ function resolveImageInput(value) {
|
|
|
26
26
|
return { type: "image", data: buf.toString("base64") };
|
|
27
27
|
}
|
|
28
28
|
export function buildImageSearchRequest(query, o) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (o.image)
|
|
33
|
-
|
|
29
|
+
// The endpoint takes exactly one input, so a query and --image are
|
|
30
|
+
// alternatives. Sending both produced a two-entry array the API answered
|
|
31
|
+
// with 400 "Inputs exceeds 1 entries".
|
|
32
|
+
if (query && o.image)
|
|
33
|
+
throw new OctenValidationError("pass a query or --image, not both: image search accepts exactly one input");
|
|
34
|
+
const inputs = query
|
|
35
|
+
? [{ type: "text", data: query }]
|
|
36
|
+
: o.image
|
|
37
|
+
? [resolveImageInput(o.image)]
|
|
38
|
+
: [];
|
|
34
39
|
if (inputs.length === 0)
|
|
35
40
|
throw new OctenValidationError("provide a query or --image");
|
|
36
41
|
if (o.count != null && (o.count < LIMITS.imageCount.min || o.count > LIMITS.imageCount.max))
|
|
37
42
|
throw new OctenValidationError(`count must be ${LIMITS.imageCount.min}-${LIMITS.imageCount.max}`);
|
|
43
|
+
assertRange("--html-snippet-max-tokens", o.htmlSnippetMaxTokens, LIMITS.htmlSnippetMaxTokens);
|
|
38
44
|
validateEnum("--topic", o.topic, IMAGE_TOPIC_OPTIONS);
|
|
39
|
-
validateEnum("--time-range", o.timeRange, TIME_RANGE_OPTIONS);
|
|
40
45
|
validateEnum("--safesearch", o.safesearch, SAFESEARCH_OPTIONS);
|
|
41
46
|
const req = { inputs };
|
|
42
47
|
const put = (k, v) => { if (v != null)
|
|
@@ -45,9 +50,6 @@ export function buildImageSearchRequest(query, o) {
|
|
|
45
50
|
put("count", o.count);
|
|
46
51
|
put("include_domains", o.includeDomains);
|
|
47
52
|
put("exclude_domains", o.excludeDomains);
|
|
48
|
-
put("time_range", o.timeRange);
|
|
49
|
-
put("start_time", normalizeTimeBound("--start-time", o.startTime, false));
|
|
50
|
-
put("end_time", normalizeTimeBound("--end-time", o.endTime, true));
|
|
51
53
|
put("safesearch", o.safesearch);
|
|
52
54
|
if (o.htmlSnippet)
|
|
53
55
|
req.html_snippet = {
|
package/dist/api/search.d.ts
CHANGED
|
@@ -5,6 +5,14 @@ export declare function validateEnum(flag: string, value: unknown, allowed: read
|
|
|
5
5
|
* (23:59:59Z) of that day; a full datetime passes through. Anything else is
|
|
6
6
|
* rejected client-side with a clear message instead of a server 400.
|
|
7
7
|
*/
|
|
8
|
+
/**
|
|
9
|
+
* Reject a numeric option the API would reject anyway, so the failure names
|
|
10
|
+
* the flag instead of arriving as a 400 several hundred milliseconds later.
|
|
11
|
+
*/
|
|
12
|
+
export declare function assertRange(flag: string, value: number | undefined, bounds: {
|
|
13
|
+
min: number;
|
|
14
|
+
max: number;
|
|
15
|
+
}): void;
|
|
8
16
|
export declare function normalizeTimeBound(flag: string, value: string | undefined, endOfDay: boolean): string | undefined;
|
|
9
17
|
/** A single search result. All fields optional — the server is untyped. */
|
|
10
18
|
export interface SearchResult {
|
|
@@ -49,7 +57,6 @@ export interface SearchOpts {
|
|
|
49
57
|
fullContent?: boolean;
|
|
50
58
|
fullContentMaxTokens?: number;
|
|
51
59
|
images?: boolean;
|
|
52
|
-
videos?: boolean;
|
|
53
60
|
}
|
|
54
61
|
/**
|
|
55
62
|
* Build the per-query search options object (everything except `query`).
|
package/dist/api/search.js
CHANGED
|
@@ -10,6 +10,16 @@ export function validateEnum(flag, value, allowed) {
|
|
|
10
10
|
* (23:59:59Z) of that day; a full datetime passes through. Anything else is
|
|
11
11
|
* rejected client-side with a clear message instead of a server 400.
|
|
12
12
|
*/
|
|
13
|
+
/**
|
|
14
|
+
* Reject a numeric option the API would reject anyway, so the failure names
|
|
15
|
+
* the flag instead of arriving as a 400 several hundred milliseconds later.
|
|
16
|
+
*/
|
|
17
|
+
export function assertRange(flag, value, bounds) {
|
|
18
|
+
if (value == null)
|
|
19
|
+
return;
|
|
20
|
+
if (value < bounds.min || value > bounds.max)
|
|
21
|
+
throw new OctenValidationError(`${flag} must be ${bounds.min}-${bounds.max}`);
|
|
22
|
+
}
|
|
13
23
|
export function normalizeTimeBound(flag, value, endOfDay) {
|
|
14
24
|
if (value == null)
|
|
15
25
|
return undefined;
|
|
@@ -34,8 +44,8 @@ export function buildSearchOptions(o) {
|
|
|
34
44
|
throw new OctenValidationError(`include-text max ${LIMITS.includeText}`);
|
|
35
45
|
if (o.excludeText && o.excludeText.length > LIMITS.excludeText)
|
|
36
46
|
throw new OctenValidationError(`exclude-text max ${LIMITS.excludeText}`);
|
|
37
|
-
|
|
38
|
-
|
|
47
|
+
assertRange("highlight-max-tokens", o.highlightMaxTokens, LIMITS.highlightMaxTokens);
|
|
48
|
+
assertRange("full-content-max-tokens", o.fullContentMaxTokens, LIMITS.fullContentMaxTokens);
|
|
39
49
|
validateEnum("--topic", o.topic, TOPIC_OPTIONS);
|
|
40
50
|
validateEnum("--time-basis", o.timeBasis, TIME_BASIS_OPTIONS);
|
|
41
51
|
validateEnum("--time-range", o.timeRange, TIME_RANGE_OPTIONS);
|
|
@@ -57,8 +67,8 @@ export function buildSearchOptions(o) {
|
|
|
57
67
|
put("format", o.format);
|
|
58
68
|
put("safesearch", o.safesearch);
|
|
59
69
|
put("language", o.language);
|
|
70
|
+
// No include_videos: the API reference documents it on /extract only.
|
|
60
71
|
put("include_images", o.images);
|
|
61
|
-
put("include_videos", o.videos);
|
|
62
72
|
if (o.highlight)
|
|
63
73
|
opts.highlight = { enable: true, ...(o.highlightMaxTokens ? { max_tokens: o.highlightMaxTokens } : {}) };
|
|
64
74
|
if (o.fullContent)
|
|
@@ -22,7 +22,7 @@ export function registerBroadSearch(program) {
|
|
|
22
22
|
.option("--language <list>", "ISO 639-1 codes, comma-separated, e.g. en,ja", (v) => v.split(","))
|
|
23
23
|
.option("--highlight").option("--highlight-max-tokens <n>", "max tokens per highlight", parseIntOpt("--highlight-max-tokens"))
|
|
24
24
|
.option("--full-content").option("--full-content-max-tokens <n>", "max tokens per result", parseIntOpt("--full-content-max-tokens"))
|
|
25
|
-
.option("--images")
|
|
25
|
+
.option("--images")
|
|
26
26
|
.action(async (queryArg, opts, command) => {
|
|
27
27
|
const g = command.optsWithGlobals();
|
|
28
28
|
const client = makeClient(g);
|
|
@@ -7,15 +7,12 @@ export function registerImageSearch(program) {
|
|
|
7
7
|
program
|
|
8
8
|
.command("image-search")
|
|
9
9
|
.argument("[query...]", "search query (optional if --image is given)")
|
|
10
|
-
.description("In Beta. Contact us to request beta access. — Search the web for images by text
|
|
10
|
+
.description("In Beta. Contact us to request beta access. — Search the web for images by text or by image (one or the other). Use --topic design for UI design references (returns a style summary and html_snippet per result)")
|
|
11
11
|
.option("--image <url|path>", "image input: public URL or local file path")
|
|
12
12
|
.option("--topic <t>", "general|design")
|
|
13
13
|
.option("-n, --count <n>", "results 1-10", parseIntOpt("--count"))
|
|
14
14
|
.option("--include-domains <list>", "comma list", (v) => v.split(","))
|
|
15
15
|
.option("--exclude-domains <list>", "comma list", (v) => v.split(","))
|
|
16
|
-
.option("--time-range <r>", "day|week|month|year (or d|w|m|y)")
|
|
17
|
-
.option("--start-time <when>", "YYYY-MM-DD or ISO datetime (e.g. 2024-01-01T00:00:00Z)")
|
|
18
|
-
.option("--end-time <when>", "YYYY-MM-DD or ISO datetime (e.g. 2024-12-31T23:59:59Z)")
|
|
19
16
|
.option("--safesearch <s>", "off|strict")
|
|
20
17
|
.option("--html-snippet", "include HTML snippet for each result")
|
|
21
18
|
.option("--html-snippet-max-tokens <n>", "max tokens per HTML snippet", parseIntOpt("--html-snippet-max-tokens"))
|
|
@@ -29,9 +26,6 @@ export function registerImageSearch(program) {
|
|
|
29
26
|
count: opts.count,
|
|
30
27
|
includeDomains: opts.includeDomains,
|
|
31
28
|
excludeDomains: opts.excludeDomains,
|
|
32
|
-
timeRange: opts.timeRange,
|
|
33
|
-
startTime: opts.startTime,
|
|
34
|
-
endTime: opts.endTime,
|
|
35
29
|
safesearch: opts.safesearch,
|
|
36
30
|
htmlSnippet: opts.htmlSnippet,
|
|
37
31
|
htmlSnippetMaxTokens: opts.htmlSnippetMaxTokens,
|
package/dist/commands/search.js
CHANGED
|
@@ -19,7 +19,7 @@ export function registerSearch(program, fixedTopic) {
|
|
|
19
19
|
.option("--language <list>", "ISO 639-1 codes, comma-separated, e.g. en,ja", (v) => v.split(","))
|
|
20
20
|
.option("--highlight").option("--highlight-max-tokens <n>", "max tokens per highlight", parseIntOpt("--highlight-max-tokens"))
|
|
21
21
|
.option("--full-content").option("--full-content-max-tokens <n>", "max tokens per result", parseIntOpt("--full-content-max-tokens"))
|
|
22
|
-
.option("--images")
|
|
22
|
+
.option("--images");
|
|
23
23
|
if (!fixedTopic)
|
|
24
24
|
cmd.option("--topic <t>", "general|news");
|
|
25
25
|
cmd.action(async (queryArg, opts, command) => {
|
package/package.json
CHANGED
|
@@ -94,8 +94,8 @@ POST https://api.octen.ai/search
|
|
|
94
94
|
|--|--|--|--|--|
|
|
95
95
|
| `query` | string | **Yes** | - | Search query (max 500 chars) |
|
|
96
96
|
| `count` | integer | No | `5` | Number of results (1–100) |
|
|
97
|
-
| `include_domains` | string[] | No | - | Only include results from these domains (max
|
|
98
|
-
| `exclude_domains` | string[] | No | - | Exclude results from these domains (max
|
|
97
|
+
| `include_domains` | string[] | No | - | Only include results from these domains (max 1200 domains, each max 60 chars) |
|
|
98
|
+
| `exclude_domains` | string[] | No | - | Exclude results from these domains (max 1200 domains, each max 60 chars) |
|
|
99
99
|
| `include_text` | string[] | No | - | Strings that must appear in result page text (max 5 items, each max 30 chars) |
|
|
100
100
|
| `exclude_text` | string[] | No | - | Strings that must not appear in result page text (max 5 items, each max 30 chars) |
|
|
101
101
|
| `time_basis` | string | No | `auto` | Time field used for filtering: `auto`, `published`, `crawled` |
|