@octen.ai/cli 0.10.0 → 0.12.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 +63 -5
- package/dist/api/constants.d.ts +50 -5
- package/dist/api/constants.js +17 -2
- package/dist/api/mediaSearch.d.ts +0 -4
- package/dist/api/mediaSearch.js +2 -10
- package/dist/api/placeSearch.d.ts +19 -0
- package/dist/api/placeSearch.js +54 -0
- package/dist/api/verticalSearch.d.ts +41 -0
- package/dist/api/verticalSearch.js +112 -0
- package/dist/cli.js +6 -1
- package/dist/commands/configureSkills.js +1 -1
- package/dist/commands/imageSearch.js +1 -7
- package/dist/commands/placeSearch.d.ts +2 -0
- package/dist/commands/placeSearch.js +36 -0
- package/dist/commands/search.d.ts +1 -1
- package/dist/commands/search.js +5 -7
- package/dist/commands/verticalSearch.d.ts +4 -0
- package/dist/commands/verticalSearch.js +82 -0
- package/dist/output/pretty/businessSearch.d.ts +7 -0
- package/dist/output/pretty/businessSearch.js +159 -0
- package/dist/output/pretty/envelope.d.ts +22 -0
- package/dist/output/pretty/envelope.js +17 -0
- package/dist/output/pretty/newsSearch.d.ts +10 -0
- package/dist/output/pretty/newsSearch.js +72 -0
- package/dist/output/pretty/placeSearch.d.ts +6 -0
- package/dist/output/pretty/placeSearch.js +87 -0
- package/dist/output/pretty/pulseSearch.d.ts +11 -0
- package/dist/output/pretty/pulseSearch.js +31 -0
- package/package.json +1 -1
- package/skills/manifest.json +1 -1
- package/skills/octen-image-search/SKILL.md +3 -18
- package/skills/octen-image-search/agents/openai.yaml +1 -1
- package/skills/octen-place-search/SKILL.md +196 -0
- package/skills/octen-place-search/agents/openai.yaml +4 -0
- package/skills/octen-search/SKILL.md +195 -4
- package/skills/octen-web-search/SKILL.md +10 -6
- package/skills/octen-design/SKILL.md +0 -241
- package/skills/octen-design/agents/openai.yaml +0 -4
- package/skills/octen-design/scripts/search.py +0 -559
- package/skills/octen-design/scripts/tests/test_search.py +0 -449
package/README.md
CHANGED
|
@@ -297,12 +297,72 @@ Options: `-n` (result count 1–100), `--topic` (general|news), `--highlight` (+
|
|
|
297
297
|
|
|
298
298
|
### `octen news`
|
|
299
299
|
|
|
300
|
-
|
|
300
|
+
Recent news from the dedicated `/news-search` endpoint. Returns ranked articles **and** `subjects` — the coverage grouped into storylines, each with a summary and the span it covers, so "what happened with X" is answerable without reading every article.
|
|
301
301
|
|
|
302
302
|
```sh
|
|
303
303
|
octen news "OpenAI announcement" --highlight --time-range day
|
|
304
|
+
octen news "EU AI Act" --subjects-count 3
|
|
305
|
+
octen news "chip export rules" --no-subjects
|
|
304
306
|
```
|
|
305
307
|
|
|
308
|
+
Options: `-n` (1–100), `--include-domains`, `--exclude-domains`, `--language`, `--time-basis`, `--time-range`, `--start-time`, `--end-time`, `--highlight` (+`--highlight-max-tokens`), `--full-content` (+`--full-content-max-tokens`), `--subjects-count` (1–5), `--max-sub-news` (1–20), `--no-subjects`.
|
|
309
|
+
|
|
310
|
+
**`--include-domains` / `--exclude-domains` narrow the ranked articles only — never the storylines.** The storylines are built from the open web either way, so a question that restricts its sources has to be answered from the articles.
|
|
311
|
+
|
|
312
|
+
Not the same flag set as `search`: this endpoint has no `--include-text`/`--exclude-text`, `--format`, `--safesearch` or `--images`. It accepts them and ignores them, so they are not offered here.
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
### `octen business`
|
|
317
|
+
|
|
318
|
+
A company, or a person in a business context, as **structured cards** — profile, financial and stock metrics, key people and their career history, recent announcements — alongside the ranked sources.
|
|
319
|
+
|
|
320
|
+
```sh
|
|
321
|
+
octen business "NVIDIA" --highlight
|
|
322
|
+
octen business "AMD and Intel" --entities-count 2
|
|
323
|
+
octen business "Anthropic funding" --no-entities
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
Options: the same retrieval flags as `news`, plus `--entities-count` (1–20), `--max-activities` (1–20), `--max-entity-news` (1–20), `--no-entities`.
|
|
327
|
+
|
|
328
|
+
Domain, time and language filters narrow the ranked sources only, never the cards.
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
### `octen place`
|
|
333
|
+
|
|
334
|
+
Real-world places as structured cards: name, category, address, coordinates, phone, website, opening hours, status, rating and review count.
|
|
335
|
+
|
|
336
|
+
```sh
|
|
337
|
+
octen place "coffee shop" --latitude 35.6812 --longitude 139.7671
|
|
338
|
+
octen place "ramen in Shinjuku"
|
|
339
|
+
octen place "museums" --city Lisbon
|
|
340
|
+
octen place "coffee shop" --latitude 35.6812 --longitude 139.7671 --max-reviews 3
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
Pass `--latitude` and `--longitude` to search around a point — each card then carries its `distance` — and `--radius` (metres, 1–50000) to cap how far. When only the city is known, use `--city` / `--region` / `--country`. A query that names its own area needs neither.
|
|
344
|
+
|
|
345
|
+
Options: `-n` (places, 1–20), `--max-reviews` (0–5, off by default), `--web` (+`--web-count`) to also return pages about these places.
|
|
346
|
+
|
|
347
|
+
The places arrive in `data.places`; `data.results` is where the optional web pages go.
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
### `octen pulse`
|
|
352
|
+
|
|
353
|
+
The URL a query most likely means, in about 10ms. One inference predicts destinations instead of searching and ranking them — for official docs, help centres and sites you could almost name.
|
|
354
|
+
|
|
355
|
+
```sh
|
|
356
|
+
octen pulse "uv documentation"
|
|
357
|
+
octen pulse "github docs" --mode standard --highlight
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
Options: `--mode` (`lite`/`standard`), `-n` (1–10), `--safesearch`, `--images`, `--highlight` (+`--highlight-max-tokens`), `--full-content` (+`--full-content-max-tokens`).
|
|
361
|
+
|
|
362
|
+
`lite` (the default) returns titles and URLs only and ignores the content options; `standard` turns them on at roughly twice the latency. The API returns lite URLs **without a scheme**; the CLI puts `https://` back, so what you get is a URL you can actually open.
|
|
363
|
+
|
|
364
|
+
No domain, text, time or language filters — pulse runs no retrieval to filter. For those, use `search` or `news`.
|
|
365
|
+
|
|
306
366
|
---
|
|
307
367
|
|
|
308
368
|
### `octen broad-search`
|
|
@@ -412,19 +472,17 @@ Options: `-m/--model` (base|large or full ID), `--fusion`/`--no-fusion`, `--dime
|
|
|
412
472
|
|
|
413
473
|
### `octen image-search`
|
|
414
474
|
|
|
415
|
-
**In Beta** — contact us to request beta access.
|
|
416
|
-
|
|
417
475
|
Search the web for images, either by text query or by example image.
|
|
418
476
|
|
|
419
477
|
```sh
|
|
420
|
-
octen image-search "red sports car" -n 10
|
|
478
|
+
octen image-search "red sports car" -n 10
|
|
421
479
|
octen image-search --image https://example.com/car.jpg
|
|
422
480
|
octen image-search --image ./car.png
|
|
423
481
|
```
|
|
424
482
|
|
|
425
483
|
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).
|
|
426
484
|
|
|
427
|
-
Options: `--image <url|path>`,
|
|
485
|
+
Options: `--image <url|path>`, `-n` (result count 1–10), `--include-domains`, `--exclude-domains`, `--safesearch` (off|strict).
|
|
428
486
|
|
|
429
487
|
Unlike `octen search` and `octen video-search`, this endpoint has no time filters.
|
|
430
488
|
|
package/dist/api/constants.d.ts
CHANGED
|
@@ -10,6 +10,10 @@ export declare const ENDPOINTS: {
|
|
|
10
10
|
readonly chat: "/v1/chat/completions";
|
|
11
11
|
readonly imageSearch: "/image-search";
|
|
12
12
|
readonly videoSearch: "/video-search";
|
|
13
|
+
readonly newsSearch: "/news-search";
|
|
14
|
+
readonly businessSearch: "/business-search";
|
|
15
|
+
readonly placeSearch: "/place-search";
|
|
16
|
+
readonly pulseSearch: "/pulse-search";
|
|
13
17
|
};
|
|
14
18
|
export declare const EMBEDDING_MODELS: Record<string, string>;
|
|
15
19
|
export declare const VL_EMBEDDING_MODELS: Record<string, string>;
|
|
@@ -49,10 +53,6 @@ export declare const LIMITS: {
|
|
|
49
53
|
readonly min: 100;
|
|
50
54
|
readonly max: 100000;
|
|
51
55
|
};
|
|
52
|
-
readonly htmlSnippetMaxTokens: {
|
|
53
|
-
readonly min: 100;
|
|
54
|
-
readonly max: 100000;
|
|
55
|
-
};
|
|
56
56
|
readonly vlContents: 20;
|
|
57
57
|
readonly vlImages: 5;
|
|
58
58
|
readonly vlVideos: 1;
|
|
@@ -64,14 +64,59 @@ export declare const LIMITS: {
|
|
|
64
64
|
readonly min: 1;
|
|
65
65
|
readonly max: 10;
|
|
66
66
|
};
|
|
67
|
+
readonly pulseCount: {
|
|
68
|
+
readonly min: 1;
|
|
69
|
+
readonly max: 10;
|
|
70
|
+
};
|
|
71
|
+
readonly pulseQueryLength: 500;
|
|
72
|
+
readonly subjectsCount: {
|
|
73
|
+
readonly min: 1;
|
|
74
|
+
readonly max: 5;
|
|
75
|
+
};
|
|
76
|
+
readonly maxSubNews: {
|
|
77
|
+
readonly min: 1;
|
|
78
|
+
readonly max: 20;
|
|
79
|
+
};
|
|
80
|
+
readonly entitiesCount: {
|
|
81
|
+
readonly min: 1;
|
|
82
|
+
readonly max: 20;
|
|
83
|
+
};
|
|
84
|
+
readonly maxActivities: {
|
|
85
|
+
readonly min: 1;
|
|
86
|
+
readonly max: 20;
|
|
87
|
+
};
|
|
88
|
+
readonly maxEntityNews: {
|
|
89
|
+
readonly min: 1;
|
|
90
|
+
readonly max: 20;
|
|
91
|
+
};
|
|
92
|
+
readonly placesCount: {
|
|
93
|
+
readonly min: 1;
|
|
94
|
+
readonly max: 20;
|
|
95
|
+
};
|
|
96
|
+
readonly maxReviews: {
|
|
97
|
+
readonly min: 0;
|
|
98
|
+
readonly max: 5;
|
|
99
|
+
};
|
|
100
|
+
readonly placeRadius: {
|
|
101
|
+
readonly min: 1;
|
|
102
|
+
readonly max: 50000;
|
|
103
|
+
};
|
|
104
|
+
readonly latitude: {
|
|
105
|
+
readonly min: -90;
|
|
106
|
+
readonly max: 90;
|
|
107
|
+
};
|
|
108
|
+
readonly longitude: {
|
|
109
|
+
readonly min: -180;
|
|
110
|
+
readonly max: 180;
|
|
111
|
+
};
|
|
67
112
|
};
|
|
68
113
|
export declare const TOPIC_OPTIONS: readonly ["general", "news"];
|
|
69
|
-
export declare const IMAGE_TOPIC_OPTIONS: readonly ["general", "design"];
|
|
70
114
|
export declare const TIME_BASIS_OPTIONS: readonly ["auto", "published", "crawled"];
|
|
71
115
|
export declare const TIME_RANGE_OPTIONS: readonly ["day", "week", "month", "year", "d", "w", "m", "y"];
|
|
72
116
|
export declare const SAFESEARCH_OPTIONS: readonly ["off", "strict"];
|
|
73
117
|
export declare const FORMAT_OPTIONS: readonly ["text", "markdown"];
|
|
74
118
|
export declare const EXTRACT_MODE_OPTIONS: readonly ["standard", "advanced", "auto"];
|
|
75
119
|
export declare const LINK_SCOPE_OPTIONS: readonly ["prefer_internal", "prefer_external"];
|
|
120
|
+
export declare const PULSE_MODE_OPTIONS: readonly ["lite", "standard"];
|
|
76
121
|
export declare const SKILLS_REPO = "Octen-Team/octen-skills";
|
|
77
122
|
export declare const SKILLS_REPO_TARBALL: (ref: string) => string;
|
package/dist/api/constants.js
CHANGED
|
@@ -10,6 +10,10 @@ export const ENDPOINTS = {
|
|
|
10
10
|
chat: "/v1/chat/completions",
|
|
11
11
|
imageSearch: "/image-search",
|
|
12
12
|
videoSearch: "/video-search",
|
|
13
|
+
newsSearch: "/news-search",
|
|
14
|
+
businessSearch: "/business-search",
|
|
15
|
+
placeSearch: "/place-search",
|
|
16
|
+
pulseSearch: "/pulse-search",
|
|
13
17
|
};
|
|
14
18
|
export const EMBEDDING_MODELS = {
|
|
15
19
|
"0.6b": "octen-embedding-0.6b",
|
|
@@ -31,20 +35,31 @@ export const LIMITS = {
|
|
|
31
35
|
cacheWindow: { min: 300, max: 31_536_000, default: 86_400 },
|
|
32
36
|
highlightMaxTokens: { min: 100, max: 20_000 },
|
|
33
37
|
fullContentMaxTokens: { min: 100, max: 100_000 },
|
|
34
|
-
htmlSnippetMaxTokens: { min: 100, max: 100_000 },
|
|
35
38
|
vlContents: 20,
|
|
36
39
|
vlImages: 5,
|
|
37
40
|
vlVideos: 1,
|
|
38
41
|
imageCount: { min: 1, max: 10 },
|
|
39
42
|
videoCount: { min: 1, max: 10 },
|
|
43
|
+
pulseCount: { min: 1, max: 10 },
|
|
44
|
+
pulseQueryLength: 500,
|
|
45
|
+
subjectsCount: { min: 1, max: 5 },
|
|
46
|
+
maxSubNews: { min: 1, max: 20 },
|
|
47
|
+
entitiesCount: { min: 1, max: 20 },
|
|
48
|
+
maxActivities: { min: 1, max: 20 },
|
|
49
|
+
maxEntityNews: { min: 1, max: 20 },
|
|
50
|
+
placesCount: { min: 1, max: 20 },
|
|
51
|
+
maxReviews: { min: 0, max: 5 },
|
|
52
|
+
placeRadius: { min: 1, max: 50_000 },
|
|
53
|
+
latitude: { min: -90, max: 90 },
|
|
54
|
+
longitude: { min: -180, max: 180 },
|
|
40
55
|
};
|
|
41
56
|
export const TOPIC_OPTIONS = ["general", "news"];
|
|
42
|
-
export const IMAGE_TOPIC_OPTIONS = ["general", "design"];
|
|
43
57
|
export const TIME_BASIS_OPTIONS = ["auto", "published", "crawled"];
|
|
44
58
|
export const TIME_RANGE_OPTIONS = ["day", "week", "month", "year", "d", "w", "m", "y"];
|
|
45
59
|
export const SAFESEARCH_OPTIONS = ["off", "strict"];
|
|
46
60
|
export const FORMAT_OPTIONS = ["text", "markdown"];
|
|
47
61
|
export const EXTRACT_MODE_OPTIONS = ["standard", "advanced", "auto"];
|
|
48
62
|
export const LINK_SCOPE_OPTIONS = ["prefer_internal", "prefer_external"];
|
|
63
|
+
export const PULSE_MODE_OPTIONS = ["lite", "standard"];
|
|
49
64
|
export const SKILLS_REPO = "Octen-Team/octen-skills";
|
|
50
65
|
export const SKILLS_REPO_TARBALL = (ref) => `https://github.com/${SKILLS_REPO}/archive/${ref}.tar.gz`;
|
|
@@ -10,7 +10,6 @@ export interface ImageSearchResult {
|
|
|
10
10
|
time_published?: string;
|
|
11
11
|
time_last_crawled?: string;
|
|
12
12
|
summary?: string;
|
|
13
|
-
html_snippet?: string;
|
|
14
13
|
}
|
|
15
14
|
/** Response shape for the /image-search endpoint. */
|
|
16
15
|
export interface ImageSearchResponse {
|
|
@@ -19,13 +18,10 @@ export interface ImageSearchResponse {
|
|
|
19
18
|
export interface ImageSearchOpts {
|
|
20
19
|
/** Optional image input: a public http(s) URL or a local file path. */
|
|
21
20
|
image?: string;
|
|
22
|
-
topic?: "general" | "design";
|
|
23
21
|
count?: number;
|
|
24
22
|
includeDomains?: string[];
|
|
25
23
|
excludeDomains?: string[];
|
|
26
24
|
safesearch?: "off" | "strict";
|
|
27
|
-
htmlSnippet?: boolean;
|
|
28
|
-
htmlSnippetMaxTokens?: number;
|
|
29
25
|
}
|
|
30
26
|
export declare function buildImageSearchRequest(query: string, o: ImageSearchOpts): Record<string, unknown>;
|
|
31
27
|
/** Matched segment within a video result. */
|
package/dist/api/mediaSearch.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync, existsSync, statSync } from "node:fs";
|
|
2
|
-
import { LIMITS,
|
|
2
|
+
import { LIMITS, TIME_RANGE_OPTIONS, SAFESEARCH_OPTIONS, } from "./constants.js";
|
|
3
3
|
import { OctenValidationError } from "./errors.js";
|
|
4
|
-
import { validateEnum, normalizeTimeBound
|
|
4
|
+
import { validateEnum, normalizeTimeBound } 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
|
/**
|
|
@@ -40,22 +40,14 @@ export function buildImageSearchRequest(query, o) {
|
|
|
40
40
|
throw new OctenValidationError("provide a query or --image");
|
|
41
41
|
if (o.count != null && (o.count < LIMITS.imageCount.min || o.count > LIMITS.imageCount.max))
|
|
42
42
|
throw new OctenValidationError(`count must be ${LIMITS.imageCount.min}-${LIMITS.imageCount.max}`);
|
|
43
|
-
assertRange("--html-snippet-max-tokens", o.htmlSnippetMaxTokens, LIMITS.htmlSnippetMaxTokens);
|
|
44
|
-
validateEnum("--topic", o.topic, IMAGE_TOPIC_OPTIONS);
|
|
45
43
|
validateEnum("--safesearch", o.safesearch, SAFESEARCH_OPTIONS);
|
|
46
44
|
const req = { inputs };
|
|
47
45
|
const put = (k, v) => { if (v != null)
|
|
48
46
|
req[k] = v; };
|
|
49
|
-
put("topic", o.topic);
|
|
50
47
|
put("count", o.count);
|
|
51
48
|
put("include_domains", o.includeDomains);
|
|
52
49
|
put("exclude_domains", o.excludeDomains);
|
|
53
50
|
put("safesearch", o.safesearch);
|
|
54
|
-
if (o.htmlSnippet)
|
|
55
|
-
req.html_snippet = {
|
|
56
|
-
enable: true,
|
|
57
|
-
...(o.htmlSnippetMaxTokens ? { max_tokens: o.htmlSnippetMaxTokens } : {}),
|
|
58
|
-
};
|
|
59
51
|
return req;
|
|
60
52
|
}
|
|
61
53
|
export function buildVideoSearchRequest(query, o) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface PlaceSearchOpts {
|
|
2
|
+
latitude?: number;
|
|
3
|
+
longitude?: number;
|
|
4
|
+
radius?: number;
|
|
5
|
+
city?: string;
|
|
6
|
+
region?: string;
|
|
7
|
+
country?: string;
|
|
8
|
+
count?: number;
|
|
9
|
+
maxReviews?: number;
|
|
10
|
+
web?: boolean;
|
|
11
|
+
webCount?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface PlaceSearchResponse {
|
|
14
|
+
query?: string;
|
|
15
|
+
location?: Record<string, unknown> | null;
|
|
16
|
+
places?: Array<Record<string, unknown>>;
|
|
17
|
+
results?: Array<Record<string, unknown>>;
|
|
18
|
+
}
|
|
19
|
+
export declare function buildPlaceSearchRequest(query: string, o: PlaceSearchOpts): Record<string, unknown>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request builder for /place-search.
|
|
3
|
+
*
|
|
4
|
+
* Not a search variant: it shares no options with `/search`. It takes a point
|
|
5
|
+
* (`latitude` + `longitude`, optionally capped by `radius`), or an approximate
|
|
6
|
+
* `user_location` when only the city is known, or neither when the query names
|
|
7
|
+
* its own area. Web results are off by default and nest under `web_search` —
|
|
8
|
+
* the inverse of the other endpoints, where the pages are the answer.
|
|
9
|
+
*
|
|
10
|
+
* Half a coordinate pair, or a radius with no point, is refused here rather
|
|
11
|
+
* than spent on a round trip the API answers with a 400.
|
|
12
|
+
*/
|
|
13
|
+
import { LIMITS } from "./constants.js";
|
|
14
|
+
import { OctenValidationError } from "./errors.js";
|
|
15
|
+
import { assertRange } from "./search.js";
|
|
16
|
+
export function buildPlaceSearchRequest(query, o) {
|
|
17
|
+
if (!query.trim())
|
|
18
|
+
throw new OctenValidationError("query is required");
|
|
19
|
+
const hasLat = o.latitude != null;
|
|
20
|
+
const hasLon = o.longitude != null;
|
|
21
|
+
if (hasLat !== hasLon) {
|
|
22
|
+
const missing = hasLat ? "--longitude" : "--latitude";
|
|
23
|
+
throw new OctenValidationError(`${missing} is required when the other is given — a point needs both`);
|
|
24
|
+
}
|
|
25
|
+
if (o.radius != null && !hasLat)
|
|
26
|
+
throw new OctenValidationError("--radius needs --latitude and --longitude — it measures from that point");
|
|
27
|
+
assertRange("latitude", o.latitude, LIMITS.latitude);
|
|
28
|
+
assertRange("longitude", o.longitude, LIMITS.longitude);
|
|
29
|
+
assertRange("radius", o.radius, LIMITS.placeRadius);
|
|
30
|
+
assertRange("count", o.count, LIMITS.placesCount);
|
|
31
|
+
assertRange("max-reviews", o.maxReviews, LIMITS.maxReviews);
|
|
32
|
+
assertRange("web-count", o.webCount, LIMITS.searchCount);
|
|
33
|
+
const req = { query };
|
|
34
|
+
const put = (k, v) => { if (v != null)
|
|
35
|
+
req[k] = v; };
|
|
36
|
+
put("latitude", o.latitude);
|
|
37
|
+
put("longitude", o.longitude);
|
|
38
|
+
put("radius", o.radius);
|
|
39
|
+
// `user_location` is the fallback when coordinates are unknown. The API
|
|
40
|
+
// takes it as an approximate place, so it is only sent when something was
|
|
41
|
+
// actually given for it.
|
|
42
|
+
const loc = [["city", o.city], ["region", o.region], ["country", o.country]]
|
|
43
|
+
.filter(([, v]) => v != null);
|
|
44
|
+
if (loc.length)
|
|
45
|
+
req.user_location = { type: "approximate", ...Object.fromEntries(loc) };
|
|
46
|
+
const places = [["count", o.count], ["max_reviews", o.maxReviews]].filter(([, v]) => v != null);
|
|
47
|
+
if (places.length)
|
|
48
|
+
req.places = Object.fromEntries(places);
|
|
49
|
+
// Off unless asked for, matching the server. `--web-count` alone does not
|
|
50
|
+
// turn it on: a count without `--web` would otherwise read as enabling it.
|
|
51
|
+
if (o.web)
|
|
52
|
+
req.web_search = { enable: true, ...(o.webCount != null ? { count: o.webCount } : {}) };
|
|
53
|
+
return req;
|
|
54
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** Options common to /news-search and /business-search. */
|
|
2
|
+
export interface VerticalSearchOpts {
|
|
3
|
+
count?: number;
|
|
4
|
+
includeDomains?: string[];
|
|
5
|
+
excludeDomains?: string[];
|
|
6
|
+
language?: string[];
|
|
7
|
+
timeBasis?: "auto" | "published" | "crawled";
|
|
8
|
+
timeRange?: string;
|
|
9
|
+
startTime?: string;
|
|
10
|
+
endTime?: string;
|
|
11
|
+
highlight?: boolean;
|
|
12
|
+
highlightMaxTokens?: number;
|
|
13
|
+
fullContent?: boolean;
|
|
14
|
+
fullContentMaxTokens?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface NewsSearchOpts extends VerticalSearchOpts {
|
|
17
|
+
subjects?: boolean;
|
|
18
|
+
noSubjects?: boolean;
|
|
19
|
+
subjectsCount?: number;
|
|
20
|
+
maxSubNews?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface BusinessSearchOpts extends VerticalSearchOpts {
|
|
23
|
+
entities?: boolean;
|
|
24
|
+
noEntities?: boolean;
|
|
25
|
+
entitiesCount?: number;
|
|
26
|
+
maxActivities?: number;
|
|
27
|
+
maxEntityNews?: number;
|
|
28
|
+
}
|
|
29
|
+
export interface PulseSearchOpts {
|
|
30
|
+
mode?: "lite" | "standard";
|
|
31
|
+
count?: number;
|
|
32
|
+
safesearch?: "off" | "strict";
|
|
33
|
+
images?: boolean;
|
|
34
|
+
highlight?: boolean;
|
|
35
|
+
highlightMaxTokens?: number;
|
|
36
|
+
fullContent?: boolean;
|
|
37
|
+
fullContentMaxTokens?: number;
|
|
38
|
+
}
|
|
39
|
+
export declare function buildNewsSearchRequest(query: string, o: NewsSearchOpts): Record<string, unknown>;
|
|
40
|
+
export declare function buildBusinessSearchRequest(query: string, o: BusinessSearchOpts): Record<string, unknown>;
|
|
41
|
+
export declare function buildPulseSearchRequest(query: string, o: PulseSearchOpts): Record<string, unknown>;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request builders for the three search verticals that post to their own
|
|
3
|
+
* endpoints: /news-search, /business-search and /pulse-search.
|
|
4
|
+
*
|
|
5
|
+
* They are not `/search` with a flag. Each takes a subset of the shared
|
|
6
|
+
* retrieval options plus one structured block of its own, and the subsets
|
|
7
|
+
* differ — news and business drop `include_text`/`exclude_text`, `format`,
|
|
8
|
+
* `safesearch` and `include_images`, while pulse drops the domain, text, time
|
|
9
|
+
* and language filters entirely because it runs no retrieval to filter.
|
|
10
|
+
*
|
|
11
|
+
* The API accepts the dropped parameters and ignores them rather than
|
|
12
|
+
* erroring, which is why they are picked explicitly here instead of being
|
|
13
|
+
* derived from `SearchOpts` by omission. Forwarding a parameter the endpoint
|
|
14
|
+
* silently drops is worse than refusing it: the caller gets results that do
|
|
15
|
+
* not reflect what they asked for, with nothing to indicate why.
|
|
16
|
+
*/
|
|
17
|
+
import { LIMITS, PULSE_MODE_OPTIONS, SAFESEARCH_OPTIONS, TIME_BASIS_OPTIONS, TIME_RANGE_OPTIONS, } from "./constants.js";
|
|
18
|
+
import { OctenValidationError } from "./errors.js";
|
|
19
|
+
import { assertRange, normalizeTimeBound, validateEnum } from "./search.js";
|
|
20
|
+
/** Shared validation + field mapping for news and business. */
|
|
21
|
+
function buildVerticalOptions(o) {
|
|
22
|
+
if (o.count != null && (o.count < LIMITS.searchCount.min || o.count > LIMITS.searchCount.max))
|
|
23
|
+
throw new OctenValidationError(`count must be ${LIMITS.searchCount.min}-${LIMITS.searchCount.max}`);
|
|
24
|
+
assertRange("highlight-max-tokens", o.highlightMaxTokens, LIMITS.highlightMaxTokens);
|
|
25
|
+
assertRange("full-content-max-tokens", o.fullContentMaxTokens, LIMITS.fullContentMaxTokens);
|
|
26
|
+
validateEnum("--time-basis", o.timeBasis, TIME_BASIS_OPTIONS);
|
|
27
|
+
validateEnum("--time-range", o.timeRange, TIME_RANGE_OPTIONS);
|
|
28
|
+
const req = {};
|
|
29
|
+
const put = (k, v) => { if (v != null)
|
|
30
|
+
req[k] = v; };
|
|
31
|
+
put("count", o.count);
|
|
32
|
+
put("include_domains", o.includeDomains);
|
|
33
|
+
put("exclude_domains", o.excludeDomains);
|
|
34
|
+
put("language", o.language);
|
|
35
|
+
put("time_basis", o.timeBasis);
|
|
36
|
+
put("time_range", o.timeRange);
|
|
37
|
+
put("start_time", normalizeTimeBound("--start-time", o.startTime, false));
|
|
38
|
+
put("end_time", normalizeTimeBound("--end-time", o.endTime, true));
|
|
39
|
+
if (o.highlight)
|
|
40
|
+
req.highlight = { enable: true, ...(o.highlightMaxTokens ? { max_tokens: o.highlightMaxTokens } : {}) };
|
|
41
|
+
if (o.fullContent)
|
|
42
|
+
req.full_content = { enable: true, ...(o.fullContentMaxTokens ? { max_tokens: o.fullContentMaxTokens } : {}) };
|
|
43
|
+
return req;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Assemble a structured sub-block (`subjects`, `entities`) only when the
|
|
47
|
+
* caller set something in it.
|
|
48
|
+
*
|
|
49
|
+
* An absent block is not the same as `{enable: false}`: the server turns these
|
|
50
|
+
* on by default, so sending an empty object would be the CLI pinning a default
|
|
51
|
+
* that belongs to the API.
|
|
52
|
+
*/
|
|
53
|
+
function subBlock(disable, fields) {
|
|
54
|
+
if (disable)
|
|
55
|
+
return { enable: false };
|
|
56
|
+
const set = fields.filter(([, v]) => v != null);
|
|
57
|
+
return set.length ? Object.fromEntries(set) : undefined;
|
|
58
|
+
}
|
|
59
|
+
export function buildNewsSearchRequest(query, o) {
|
|
60
|
+
if (!query.trim())
|
|
61
|
+
throw new OctenValidationError("query is required");
|
|
62
|
+
assertRange("subjects-count", o.subjectsCount, LIMITS.subjectsCount);
|
|
63
|
+
assertRange("max-sub-news", o.maxSubNews, LIMITS.maxSubNews);
|
|
64
|
+
const req = { query, ...buildVerticalOptions(o) };
|
|
65
|
+
const subjects = subBlock(o.noSubjects, [
|
|
66
|
+
["count", o.subjectsCount],
|
|
67
|
+
["max_sub_news", o.maxSubNews],
|
|
68
|
+
]);
|
|
69
|
+
if (subjects)
|
|
70
|
+
req.subjects = subjects;
|
|
71
|
+
return req;
|
|
72
|
+
}
|
|
73
|
+
export function buildBusinessSearchRequest(query, o) {
|
|
74
|
+
if (!query.trim())
|
|
75
|
+
throw new OctenValidationError("query is required");
|
|
76
|
+
assertRange("entities-count", o.entitiesCount, LIMITS.entitiesCount);
|
|
77
|
+
assertRange("max-activities", o.maxActivities, LIMITS.maxActivities);
|
|
78
|
+
assertRange("max-entity-news", o.maxEntityNews, LIMITS.maxEntityNews);
|
|
79
|
+
const req = { query, ...buildVerticalOptions(o) };
|
|
80
|
+
const entities = subBlock(o.noEntities, [
|
|
81
|
+
["count", o.entitiesCount],
|
|
82
|
+
["max_activities", o.maxActivities],
|
|
83
|
+
["max_news", o.maxEntityNews],
|
|
84
|
+
]);
|
|
85
|
+
if (entities)
|
|
86
|
+
req.entities = entities;
|
|
87
|
+
return req;
|
|
88
|
+
}
|
|
89
|
+
export function buildPulseSearchRequest(query, o) {
|
|
90
|
+
if (!query.trim())
|
|
91
|
+
throw new OctenValidationError("query is required");
|
|
92
|
+
if (query.length > LIMITS.pulseQueryLength)
|
|
93
|
+
throw new OctenValidationError(`query must be at most ${LIMITS.pulseQueryLength} characters`);
|
|
94
|
+
if (o.count != null && (o.count < LIMITS.pulseCount.min || o.count > LIMITS.pulseCount.max))
|
|
95
|
+
throw new OctenValidationError(`count must be ${LIMITS.pulseCount.min}-${LIMITS.pulseCount.max}`);
|
|
96
|
+
assertRange("highlight-max-tokens", o.highlightMaxTokens, LIMITS.highlightMaxTokens);
|
|
97
|
+
assertRange("full-content-max-tokens", o.fullContentMaxTokens, LIMITS.fullContentMaxTokens);
|
|
98
|
+
validateEnum("--mode", o.mode, PULSE_MODE_OPTIONS);
|
|
99
|
+
validateEnum("--safesearch", o.safesearch, SAFESEARCH_OPTIONS);
|
|
100
|
+
const req = { query };
|
|
101
|
+
const put = (k, v) => { if (v != null)
|
|
102
|
+
req[k] = v; };
|
|
103
|
+
put("mode", o.mode);
|
|
104
|
+
put("count", o.count);
|
|
105
|
+
put("safesearch", o.safesearch);
|
|
106
|
+
put("include_images", o.images);
|
|
107
|
+
if (o.highlight)
|
|
108
|
+
req.highlight = { enable: true, ...(o.highlightMaxTokens ? { max_tokens: o.highlightMaxTokens } : {}) };
|
|
109
|
+
if (o.fullContent)
|
|
110
|
+
req.full_content = { enable: true, ...(o.fullContentMaxTokens ? { max_tokens: o.fullContentMaxTokens } : {}) };
|
|
111
|
+
return req;
|
|
112
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -6,6 +6,8 @@ import { fileURLToPath } from "node:url";
|
|
|
6
6
|
import pc from "picocolors";
|
|
7
7
|
import { exitCodeFor } from "./api/errors.js";
|
|
8
8
|
import { registerSearch } from "./commands/search.js";
|
|
9
|
+
import { registerBusinessSearch, registerNewsSearch, registerPulseSearch, } from "./commands/verticalSearch.js";
|
|
10
|
+
import { registerPlaceSearch } from "./commands/placeSearch.js";
|
|
9
11
|
import { registerBroadSearch } from "./commands/broadSearch.js";
|
|
10
12
|
import { registerExtract } from "./commands/extract.js";
|
|
11
13
|
import { registerChat } from "./commands/chat.js";
|
|
@@ -40,7 +42,10 @@ registerReset(program);
|
|
|
40
42
|
registerConfigureMcp(program);
|
|
41
43
|
registerConfigureSkills(program);
|
|
42
44
|
registerSearch(program);
|
|
43
|
-
|
|
45
|
+
registerNewsSearch(program);
|
|
46
|
+
registerBusinessSearch(program);
|
|
47
|
+
registerPlaceSearch(program);
|
|
48
|
+
registerPulseSearch(program);
|
|
44
49
|
registerBroadSearch(program);
|
|
45
50
|
registerExtract(program);
|
|
46
51
|
registerChat(program);
|
|
@@ -25,7 +25,7 @@ export function registerConfigureSkills(program, internal = {}) {
|
|
|
25
25
|
.option("--hermes", "install into Hermes")
|
|
26
26
|
.option("--skills-dir <path>", "use a custom skills source directory")
|
|
27
27
|
.option("--scope <s>", "config scope: user | project (default: user)", parseScopeOpt("--scope"), "user")
|
|
28
|
-
.option("--only <names>", "comma-separated list of skill names to install (e.g. octen-search,octen-
|
|
28
|
+
.option("--only <names>", "comma-separated list of skill names to install (e.g. octen-search,octen-place-search)", parseCsvOpt("--only"))
|
|
29
29
|
.option("--ref <ref>", "upstream git ref to fetch skills from", "main")
|
|
30
30
|
.option("--bundled", "force use of bundled (vendored) skills — no network")
|
|
31
31
|
.option("--offline", "alias for --bundled")
|
|
@@ -7,28 +7,22 @@ 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("
|
|
10
|
+
.description("Search the web for images by text or by image (one or the other)")
|
|
11
11
|
.option("--image <url|path>", "image input: public URL or local file path")
|
|
12
|
-
.option("--topic <t>", "general|design")
|
|
13
12
|
.option("-n, --count <n>", "results 1-10", parseIntOpt("--count"))
|
|
14
13
|
.option("--include-domains <list>", "comma list", parseCsvOpt("--include-domains"))
|
|
15
14
|
.option("--exclude-domains <list>", "comma list", parseCsvOpt("--exclude-domains"))
|
|
16
15
|
.option("--safesearch <s>", "off|strict")
|
|
17
|
-
.option("--html-snippet", "include HTML snippet for each result")
|
|
18
|
-
.option("--html-snippet-max-tokens <n>", "max tokens per HTML snippet", parseIntOpt("--html-snippet-max-tokens"))
|
|
19
16
|
.action(async (queryArg, opts, command) => {
|
|
20
17
|
const g = command.optsWithGlobals();
|
|
21
18
|
const client = makeClient(g);
|
|
22
19
|
const query = Array.isArray(queryArg) ? queryArg.join(" ") : (queryArg ?? "");
|
|
23
20
|
const imageOpts = {
|
|
24
21
|
image: opts.image,
|
|
25
|
-
topic: opts.topic,
|
|
26
22
|
count: opts.count,
|
|
27
23
|
includeDomains: opts.includeDomains,
|
|
28
24
|
excludeDomains: opts.excludeDomains,
|
|
29
25
|
safesearch: opts.safesearch,
|
|
30
|
-
htmlSnippet: opts.htmlSnippet,
|
|
31
|
-
htmlSnippetMaxTokens: opts.htmlSnippetMaxTokens,
|
|
32
26
|
};
|
|
33
27
|
const req = buildImageSearchRequest(query, imageOpts);
|
|
34
28
|
const res = await client.request(ENDPOINTS.imageSearch, req);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ENDPOINTS } from "../api/constants.js";
|
|
2
|
+
import { buildPlaceSearchRequest, } from "../api/placeSearch.js";
|
|
3
|
+
import { chooseMode, emit } from "../output/render.js";
|
|
4
|
+
import { renderPlaceSearch } from "../output/pretty/placeSearch.js";
|
|
5
|
+
import { makeClient, parseIntOpt } from "./utils.js";
|
|
6
|
+
/** commander hands numeric options back as strings; coordinates need floats. */
|
|
7
|
+
function parseFloatOpt(flag) {
|
|
8
|
+
return (raw) => {
|
|
9
|
+
const n = Number(raw);
|
|
10
|
+
if (!Number.isFinite(n))
|
|
11
|
+
throw new Error(`${flag} must be a number`);
|
|
12
|
+
return n;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export function registerPlaceSearch(program) {
|
|
16
|
+
program.command("place")
|
|
17
|
+
.argument("<query...>", "what to find, e.g. 'coffee shop'")
|
|
18
|
+
.description("Real-world places with address, hours, rating and distance")
|
|
19
|
+
.option("--latitude <n>", "WGS84 latitude to search around", parseFloatOpt("--latitude"))
|
|
20
|
+
.option("--longitude <n>", "WGS84 longitude to search around", parseFloatOpt("--longitude"))
|
|
21
|
+
.option("--radius <m>", "cap distance from the point, in metres (1-50000)", parseIntOpt("--radius"))
|
|
22
|
+
.option("--city <name>", "approximate location, when coordinates are unknown")
|
|
23
|
+
.option("--region <name>", "approximate location: region or state")
|
|
24
|
+
.option("--country <code>", "approximate location: country")
|
|
25
|
+
.option("-n, --count <n>", "places to return, 1-20", parseIntOpt("--count"))
|
|
26
|
+
.option("--max-reviews <n>", "review excerpts per place, 0-5 (off by default)", parseIntOpt("--max-reviews"))
|
|
27
|
+
.option("--web", "also return web pages about these places")
|
|
28
|
+
.option("--web-count <n>", "web results, 1-100 (needs --web)", parseIntOpt("--web-count"))
|
|
29
|
+
.action(async (queryArg, opts, command) => {
|
|
30
|
+
const g = command.optsWithGlobals();
|
|
31
|
+
const client = makeClient(g);
|
|
32
|
+
const req = buildPlaceSearchRequest(queryArg.join(" "), opts);
|
|
33
|
+
const res = await client.request(ENDPOINTS.placeSearch, req);
|
|
34
|
+
emit(res, chooseMode(g, process.stdout.isTTY ?? false), renderPlaceSearch);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Command } from "commander";
|
|
2
|
-
export declare function registerSearch(program: Command
|
|
2
|
+
export declare function registerSearch(program: Command): void;
|
package/dist/commands/search.js
CHANGED
|
@@ -3,10 +3,10 @@ import { buildSearchRequest } from "../api/search.js";
|
|
|
3
3
|
import { chooseMode, emit } from "../output/render.js";
|
|
4
4
|
import { renderSearch } from "../output/pretty/search.js";
|
|
5
5
|
import { makeClient, parseCsvOpt, parseIntOpt } from "./utils.js";
|
|
6
|
-
export function registerSearch(program
|
|
7
|
-
const cmd = program.command(
|
|
6
|
+
export function registerSearch(program) {
|
|
7
|
+
const cmd = program.command("search")
|
|
8
8
|
.argument("<query...>", "search query")
|
|
9
|
-
.description(
|
|
9
|
+
.description("Search the live web")
|
|
10
10
|
.option("-n, --count <n>", "results 1-100", parseIntOpt("--count"))
|
|
11
11
|
.option("--include-domains <list>", "comma list", parseCsvOpt("--include-domains"))
|
|
12
12
|
.option("--exclude-domains <list>", "comma list", parseCsvOpt("--exclude-domains"))
|
|
@@ -20,14 +20,12 @@ export function registerSearch(program, fixedTopic) {
|
|
|
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
22
|
.option("--images");
|
|
23
|
-
|
|
24
|
-
cmd.option("--topic <t>", "general|news");
|
|
23
|
+
cmd.option("--topic <t>", "general|news");
|
|
25
24
|
cmd.action(async (queryArg, opts, command) => {
|
|
26
25
|
const g = command.optsWithGlobals();
|
|
27
26
|
const client = makeClient(g);
|
|
28
27
|
const query = Array.isArray(queryArg) ? queryArg.join(" ") : queryArg;
|
|
29
|
-
const
|
|
30
|
-
const req = buildSearchRequest(query, searchOpts);
|
|
28
|
+
const req = buildSearchRequest(query, opts);
|
|
31
29
|
const res = await client.request(ENDPOINTS.search, req);
|
|
32
30
|
emit(res, chooseMode(g, process.stdout.isTTY ?? false), renderSearch);
|
|
33
31
|
});
|