@octen.ai/cli 0.2.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/README.md +63 -3
- package/dist/api/chat.d.ts +73 -4
- package/dist/api/chat.js +91 -4
- package/dist/api/constants.d.ts +16 -0
- package/dist/api/constants.js +7 -0
- package/dist/api/mediaSearch.d.ts +63 -0
- package/dist/api/mediaSearch.js +76 -0
- package/dist/api/search.d.ts +29 -0
- package/dist/api/search.js +35 -8
- package/dist/cli.js +8 -2
- package/dist/commands/broadSearch.d.ts +2 -0
- package/dist/commands/broadSearch.js +33 -0
- package/dist/commands/chat.js +81 -5
- package/dist/commands/extract.d.ts +2 -0
- package/dist/commands/{fetch.js → extract.js} +2 -2
- package/dist/commands/imageSearch.d.ts +2 -0
- package/dist/commands/imageSearch.js +43 -0
- package/dist/commands/videoSearch.d.ts +2 -0
- package/dist/commands/videoSearch.js +24 -0
- package/dist/output/pretty/broadSearch.d.ts +1 -0
- package/dist/output/pretty/broadSearch.js +26 -0
- package/dist/output/pretty/chat.js +25 -5
- package/dist/output/pretty/imageSearch.d.ts +1 -0
- package/dist/output/pretty/imageSearch.js +45 -0
- package/dist/output/pretty/search.d.ts +3 -0
- package/dist/output/pretty/search.js +5 -1
- package/dist/output/pretty/videoSearch.d.ts +1 -0
- package/dist/output/pretty/videoSearch.js +50 -0
- package/package.json +1 -1
- package/dist/commands/fetch.d.ts +0 -2
package/README.md
CHANGED
|
@@ -75,12 +75,26 @@ octen news "OpenAI announcement" --highlight --time-range day
|
|
|
75
75
|
|
|
76
76
|
---
|
|
77
77
|
|
|
78
|
-
### `octen
|
|
78
|
+
### `octen broad-search`
|
|
79
|
+
|
|
80
|
+
Broad multi-angle web search (alias: `octen broad`). Decomposes the query into sub-queries searched concurrently, returning results grouped by sub-query for comprehensive coverage.
|
|
81
|
+
|
|
82
|
+
Use it for comparisons across many sources (pricing, products, vendors), surveys/research, and multi-angle questions — cases where a single `octen search` only reaches a few subtopics. Pass the query as-is (sub-queries are generated for you); raise `--max-queries` for broader coverage, or use `octen search` for a single focused query.
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
octen broad-search "compare cloud GPU pricing across providers" --max-queries 5 -n 10
|
|
86
|
+
```
|
|
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`, `--images`, `--videos`, `--format`, `--safesearch`).
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
### `octen extract`
|
|
79
93
|
|
|
80
94
|
Extract content from one or more URLs (1–20).
|
|
81
95
|
|
|
82
96
|
```sh
|
|
83
|
-
octen
|
|
97
|
+
octen extract https://example.com --query "pricing" --max-age 3600 --images
|
|
84
98
|
```
|
|
85
99
|
|
|
86
100
|
Options: `--query` (relevance hint), `--max-age <sec>` (cache age, 300–31536000), `--images`, `--videos`, `--audio`, `--favicon`, `--format` (markdown|text), `--fetch-timeout <sec>` (1–60), `--full` (print full page content).
|
|
@@ -99,7 +113,21 @@ octen chat "Summarize the Octen docs" -m anthropic/claude-haiku-4.5
|
|
|
99
113
|
|
|
100
114
|
Streaming is on by default when output is a TTY; use `--no-stream` to get a single JSON response. Pass `-i` for interactive REPL mode. Set `OCTEN_CHAT_MODEL` to avoid specifying `-m` every time.
|
|
101
115
|
|
|
102
|
-
|
|
116
|
+
**Web search** is now powered by the built-in `octen_search` tool. Pass `--search` to let the model search the web (the old `--web-search on` flag has been removed):
|
|
117
|
+
|
|
118
|
+
```sh
|
|
119
|
+
octen chat "What launched at the latest Octen event?" -m anthropic/claude-haiku-4.5 --search --search-count 10
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
When search runs, cited sources are listed after the answer (pretty mode) and the raw response includes `search_results` and per-message `annotations`.
|
|
123
|
+
|
|
124
|
+
Core options: `-m/--model`, `--system`, `--cache-system` (mark the system message as a cache_control ephemeral block), `--no-stream`, `-i/--interactive`.
|
|
125
|
+
|
|
126
|
+
Sampling: `--temperature`, `--top-p`, `--top-k`, `--min-p`, `--top-a`, `--repetition-penalty`, `--frequency-penalty`, `--presence-penalty`, `--max-tokens`, `--stop`, `--seed`, `--verbosity` (low|medium|high).
|
|
127
|
+
|
|
128
|
+
Reasoning: `--reasoning-effort` (xhigh|high|medium|low|minimal|none), `--reasoning-max-tokens`. When a model emits reasoning it is shown under a dim `reasoning:` prefix in pretty mode.
|
|
129
|
+
|
|
130
|
+
Web search (only meaningful with `--search`): `--search-max-searches <n>` (default 5), `--search-count <n>` (1-100), `--search-include-domains <list>`, `--search-exclude-domains <list>`, `--search-time-basis` (auto|published|crawled), `--search-start-time <when>`, `--search-end-time <when>`, `--search-format` (markdown|text), `--search-safesearch` (off|strict), `--search-full-content` (+`--search-full-content-max-tokens <n>`), `--search-highlight-max-tokens <n>`.
|
|
103
131
|
|
|
104
132
|
---
|
|
105
133
|
|
|
@@ -131,6 +159,38 @@ Options: `-m/--model` (base|large or full ID), `--fusion`/`--no-fusion`, `--dime
|
|
|
131
159
|
|
|
132
160
|
---
|
|
133
161
|
|
|
162
|
+
### `octen image-search`
|
|
163
|
+
|
|
164
|
+
**In Beta** — contact us to request beta access.
|
|
165
|
+
|
|
166
|
+
Search the web for images by text query and/or an example image.
|
|
167
|
+
|
|
168
|
+
```sh
|
|
169
|
+
octen image-search "red sports car" -n 10 --topic design --time-range week
|
|
170
|
+
octen image-search --image https://example.com/car.jpg
|
|
171
|
+
octen image-search "similar to this" --image ./car.png
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
`--image` accepts a public URL or a local file path (read inline as base64, max 5MB). At least one of a query or `--image` is required.
|
|
175
|
+
|
|
176
|
+
Options: `--image <url|path>`, `--topic` (general|design), `-n` (result count 1–10), `--include-domains`, `--exclude-domains`, `--time-range` (day|week|month|year or d|w|m|y), `--start-time`/`--end-time` (YYYY-MM-DD or ISO datetime), `--safesearch` (off|strict), `--html-snippet` (+`--html-snippet-max-tokens`).
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
### `octen video-search`
|
|
181
|
+
|
|
182
|
+
**In Beta** — contact us to request beta access.
|
|
183
|
+
|
|
184
|
+
Search the web for videos by text query.
|
|
185
|
+
|
|
186
|
+
```sh
|
|
187
|
+
octen video-search "how to make espresso" -n 10 --time-range month
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Options: `-n` (result count 1–10), `--time-range` (day|week|month|year or d|w|m|y), `--start-time`/`--end-time` (YYYY-MM-DD or ISO datetime), `--safesearch` (off|strict).
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
134
194
|
### `octen configure-mcp`
|
|
135
195
|
|
|
136
196
|
Configure the Octen MCP server in AI clients (merges into existing config, does not clobber).
|
package/dist/api/chat.d.ts
CHANGED
|
@@ -1,33 +1,102 @@
|
|
|
1
|
+
/** A cache_control marker that can ride along on a content block. */
|
|
2
|
+
export interface CacheControl {
|
|
3
|
+
type: "ephemeral";
|
|
4
|
+
ttl?: "5m" | "1h";
|
|
5
|
+
}
|
|
6
|
+
/** A structured content block (used when we need to attach cache_control). */
|
|
7
|
+
export interface ContentBlock {
|
|
8
|
+
type: "text";
|
|
9
|
+
text: string;
|
|
10
|
+
cache_control?: CacheControl;
|
|
11
|
+
}
|
|
1
12
|
export type ChatMessage = {
|
|
2
13
|
role: "system" | "user" | "assistant";
|
|
3
|
-
content: string;
|
|
14
|
+
content: string | ContentBlock[];
|
|
4
15
|
};
|
|
16
|
+
/** A url_citation annotation attached to an assistant message. */
|
|
17
|
+
export interface UrlCitation {
|
|
18
|
+
type: "url_citation";
|
|
19
|
+
url_citation?: {
|
|
20
|
+
url?: string;
|
|
21
|
+
title?: string;
|
|
22
|
+
start_index?: number;
|
|
23
|
+
end_index?: number;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
5
26
|
/** Non-stream chat completion response. All fields optional — the server is untyped. */
|
|
6
27
|
export interface ChatCompletion {
|
|
7
28
|
choices?: Array<{
|
|
8
29
|
message?: {
|
|
9
30
|
content?: string;
|
|
31
|
+
/** The model's reasoning trace, when reasoning is enabled. */
|
|
32
|
+
reasoning?: string;
|
|
33
|
+
annotations?: UrlCitation[];
|
|
10
34
|
};
|
|
11
35
|
}>;
|
|
36
|
+
/** Web search results surfaced by the octen_search tool. */
|
|
37
|
+
search_results?: Array<Record<string, unknown>>;
|
|
12
38
|
usage?: Record<string, unknown>;
|
|
13
39
|
}
|
|
14
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* A single SSE stream event from the chat endpoint. The new protocol emits typed
|
|
42
|
+
* chunks (search_done / content / finish / usage) terminated by a `[DONE]` sentinel.
|
|
43
|
+
*/
|
|
15
44
|
export interface StreamEvent {
|
|
45
|
+
type?: "search_done" | "content" | "finish" | "usage" | string;
|
|
16
46
|
choices?: Array<{
|
|
17
47
|
delta?: {
|
|
18
48
|
content?: string;
|
|
49
|
+
reasoning?: string;
|
|
19
50
|
};
|
|
20
51
|
}>;
|
|
52
|
+
usage?: Record<string, unknown>;
|
|
53
|
+
}
|
|
54
|
+
export declare const VERBOSITY_OPTIONS: readonly ["low", "medium", "high"];
|
|
55
|
+
export type Verbosity = (typeof VERBOSITY_OPTIONS)[number];
|
|
56
|
+
export declare const REASONING_EFFORT_OPTIONS: readonly ["xhigh", "high", "medium", "low", "minimal", "none"];
|
|
57
|
+
export type ReasoningEffort = (typeof REASONING_EFFORT_OPTIONS)[number];
|
|
58
|
+
export declare const SEARCH_TIME_BASIS_OPTIONS: readonly ["auto", "published", "crawled"];
|
|
59
|
+
export type SearchTimeBasis = (typeof SEARCH_TIME_BASIS_OPTIONS)[number];
|
|
60
|
+
export declare const SEARCH_SAFESEARCH_OPTIONS: readonly ["off", "strict"];
|
|
61
|
+
export type SearchSafesearch = (typeof SEARCH_SAFESEARCH_OPTIONS)[number];
|
|
62
|
+
export declare const SEARCH_FORMAT_OPTIONS: readonly ["markdown", "text"];
|
|
63
|
+
export type SearchFormat = (typeof SEARCH_FORMAT_OPTIONS)[number];
|
|
64
|
+
/** Options for the built-in octen_search tool (web search). */
|
|
65
|
+
export interface SearchOpts {
|
|
66
|
+
enabled?: boolean;
|
|
67
|
+
maxSearches?: number;
|
|
68
|
+
count?: number;
|
|
69
|
+
includeDomains?: string[];
|
|
70
|
+
excludeDomains?: string[];
|
|
71
|
+
includeText?: string[];
|
|
72
|
+
excludeText?: string[];
|
|
73
|
+
timeBasis?: SearchTimeBasis;
|
|
74
|
+
startTime?: string;
|
|
75
|
+
endTime?: string;
|
|
76
|
+
format?: SearchFormat;
|
|
77
|
+
safesearch?: SearchSafesearch;
|
|
78
|
+
fullContent?: boolean;
|
|
79
|
+
fullContentMaxTokens?: number;
|
|
80
|
+
highlightMaxTokens?: number;
|
|
21
81
|
}
|
|
22
82
|
export interface ChatOpts {
|
|
23
|
-
|
|
83
|
+
search?: SearchOpts;
|
|
24
84
|
maxTokens?: number;
|
|
85
|
+
maxCompletionTokens?: number;
|
|
25
86
|
temperature?: number;
|
|
26
87
|
topP?: number;
|
|
88
|
+
topK?: number;
|
|
89
|
+
minP?: number;
|
|
90
|
+
topA?: number;
|
|
91
|
+
repetitionPenalty?: number;
|
|
27
92
|
frequencyPenalty?: number;
|
|
28
93
|
presencePenalty?: number;
|
|
29
94
|
stop?: string[];
|
|
30
95
|
seed?: number;
|
|
31
|
-
|
|
96
|
+
verbosity?: Verbosity;
|
|
97
|
+
reasoningEffort?: ReasoningEffort;
|
|
98
|
+
reasoningMaxTokens?: number;
|
|
99
|
+
/** When true, attach cache_control to the system message content block. */
|
|
100
|
+
cacheSystem?: boolean;
|
|
32
101
|
}
|
|
33
102
|
export declare function buildChatRequest(messages: ChatMessage[], model: string | undefined, o: ChatOpts): Record<string, unknown>;
|
package/dist/api/chat.js
CHANGED
|
@@ -1,23 +1,110 @@
|
|
|
1
1
|
import { OctenValidationError } from "./errors.js";
|
|
2
|
+
import { normalizeTimeBound } from "./search.js";
|
|
3
|
+
import { LIMITS } from "./constants.js";
|
|
4
|
+
export const VERBOSITY_OPTIONS = ["low", "medium", "high"];
|
|
5
|
+
export const REASONING_EFFORT_OPTIONS = [
|
|
6
|
+
"xhigh",
|
|
7
|
+
"high",
|
|
8
|
+
"medium",
|
|
9
|
+
"low",
|
|
10
|
+
"minimal",
|
|
11
|
+
"none",
|
|
12
|
+
];
|
|
13
|
+
export const SEARCH_TIME_BASIS_OPTIONS = ["auto", "published", "crawled"];
|
|
14
|
+
export const SEARCH_SAFESEARCH_OPTIONS = ["off", "strict"];
|
|
15
|
+
export const SEARCH_FORMAT_OPTIONS = ["markdown", "text"];
|
|
16
|
+
function assertEnum(value, allowed, flag) {
|
|
17
|
+
if (value != null && !allowed.includes(value)) {
|
|
18
|
+
throw new OctenValidationError(`${flag} must be one of: ${allowed.join(", ")}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** Build the octen_search tool entry from search options. */
|
|
22
|
+
function buildSearchTool(s) {
|
|
23
|
+
assertEnum(s.timeBasis, SEARCH_TIME_BASIS_OPTIONS, "--search-time-basis");
|
|
24
|
+
assertEnum(s.safesearch, SEARCH_SAFESEARCH_OPTIONS, "--search-safesearch");
|
|
25
|
+
assertEnum(s.format, SEARCH_FORMAT_OPTIONS, "--search-format");
|
|
26
|
+
if (s.count != null && (s.count < LIMITS.searchCount.min || s.count > LIMITS.searchCount.max))
|
|
27
|
+
throw new OctenValidationError(`--search-count must be ${LIMITS.searchCount.min}-${LIMITS.searchCount.max}`);
|
|
28
|
+
const parameters = {};
|
|
29
|
+
const put = (k, v) => {
|
|
30
|
+
if (v != null)
|
|
31
|
+
parameters[k] = v;
|
|
32
|
+
};
|
|
33
|
+
put("max_searches", s.maxSearches);
|
|
34
|
+
put("count", s.count);
|
|
35
|
+
put("include_domains", s.includeDomains);
|
|
36
|
+
put("exclude_domains", s.excludeDomains);
|
|
37
|
+
put("include_text", s.includeText);
|
|
38
|
+
put("exclude_text", s.excludeText);
|
|
39
|
+
put("time_basis", s.timeBasis);
|
|
40
|
+
put("start_time", normalizeTimeBound("--search-start-time", s.startTime, false));
|
|
41
|
+
put("end_time", normalizeTimeBound("--search-end-time", s.endTime, true));
|
|
42
|
+
put("format", s.format);
|
|
43
|
+
put("safesearch", s.safesearch);
|
|
44
|
+
if (s.fullContent) {
|
|
45
|
+
parameters["full_content"] = {
|
|
46
|
+
enable: true,
|
|
47
|
+
...(s.fullContentMaxTokens != null ? { max_tokens: s.fullContentMaxTokens } : {}),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (s.highlightMaxTokens != null) {
|
|
51
|
+
parameters["highlight"] = { enable: true, max_tokens: s.highlightMaxTokens };
|
|
52
|
+
}
|
|
53
|
+
return { type: "octen_search", parameters };
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Wrap message content so the system message can carry cache_control. The system
|
|
57
|
+
* message becomes a single text content block tagged ephemeral; other messages are
|
|
58
|
+
* left untouched.
|
|
59
|
+
*/
|
|
60
|
+
function applyCacheControl(messages) {
|
|
61
|
+
return messages.map((m) => {
|
|
62
|
+
if (m.role !== "system" || typeof m.content !== "string")
|
|
63
|
+
return m;
|
|
64
|
+
const block = {
|
|
65
|
+
type: "text",
|
|
66
|
+
text: m.content,
|
|
67
|
+
cache_control: { type: "ephemeral", ttl: "5m" },
|
|
68
|
+
};
|
|
69
|
+
return { role: "system", content: [block] };
|
|
70
|
+
});
|
|
71
|
+
}
|
|
2
72
|
export function buildChatRequest(messages, model, o) {
|
|
3
73
|
if (!model)
|
|
4
74
|
throw new OctenValidationError("model is required (pass --model or set OCTEN_CHAT_MODEL)");
|
|
5
75
|
if (!messages.length)
|
|
6
76
|
throw new OctenValidationError("messages must not be empty");
|
|
7
|
-
|
|
77
|
+
assertEnum(o.verbosity, VERBOSITY_OPTIONS, "--verbosity");
|
|
78
|
+
assertEnum(o.reasoningEffort, REASONING_EFFORT_OPTIONS, "--reasoning-effort");
|
|
79
|
+
const outMessages = o.cacheSystem ? applyCacheControl(messages) : messages;
|
|
80
|
+
const req = { model, messages: outMessages };
|
|
8
81
|
const put = (k, v) => {
|
|
9
82
|
if (v != null)
|
|
10
83
|
req[k] = v;
|
|
11
84
|
};
|
|
12
|
-
put("web_search", o.webSearch);
|
|
13
85
|
put("max_tokens", o.maxTokens);
|
|
86
|
+
put("max_completion_tokens", o.maxCompletionTokens);
|
|
14
87
|
put("temperature", o.temperature);
|
|
15
88
|
put("top_p", o.topP);
|
|
89
|
+
put("top_k", o.topK);
|
|
90
|
+
put("min_p", o.minP);
|
|
91
|
+
put("top_a", o.topA);
|
|
92
|
+
put("repetition_penalty", o.repetitionPenalty);
|
|
16
93
|
put("frequency_penalty", o.frequencyPenalty);
|
|
17
94
|
put("presence_penalty", o.presencePenalty);
|
|
18
95
|
put("stop", o.stop);
|
|
19
96
|
put("seed", o.seed);
|
|
20
|
-
|
|
21
|
-
|
|
97
|
+
put("verbosity", o.verbosity);
|
|
98
|
+
if (o.reasoningEffort != null || o.reasoningMaxTokens != null) {
|
|
99
|
+
const reasoning = {};
|
|
100
|
+
if (o.reasoningEffort != null)
|
|
101
|
+
reasoning["effort"] = o.reasoningEffort;
|
|
102
|
+
if (o.reasoningMaxTokens != null)
|
|
103
|
+
reasoning["max_tokens"] = o.reasoningMaxTokens;
|
|
104
|
+
req["reasoning"] = reasoning;
|
|
105
|
+
}
|
|
106
|
+
if (o.search?.enabled) {
|
|
107
|
+
req["tools"] = [buildSearchTool(o.search)];
|
|
108
|
+
}
|
|
22
109
|
return req;
|
|
23
110
|
}
|
package/dist/api/constants.d.ts
CHANGED
|
@@ -3,10 +3,13 @@ export declare const DEFAULT_TIMEOUT_MS = 30000;
|
|
|
3
3
|
export declare const DEFAULT_MAX_RETRIES = 3;
|
|
4
4
|
export declare const ENDPOINTS: {
|
|
5
5
|
readonly search: "/search";
|
|
6
|
+
readonly broadSearch: "/broad-search";
|
|
6
7
|
readonly extract: "/extract";
|
|
7
8
|
readonly embedding: "/embedding";
|
|
8
9
|
readonly vlEmbedding: "/vl-embedding";
|
|
9
10
|
readonly chat: "/v1/chat/completions";
|
|
11
|
+
readonly imageSearch: "/image-search";
|
|
12
|
+
readonly videoSearch: "/video-search";
|
|
10
13
|
};
|
|
11
14
|
export declare const EMBEDDING_MODELS: Record<string, string>;
|
|
12
15
|
export declare const VL_EMBEDDING_MODELS: Record<string, string>;
|
|
@@ -15,6 +18,10 @@ export declare const LIMITS: {
|
|
|
15
18
|
readonly min: 1;
|
|
16
19
|
readonly max: 100;
|
|
17
20
|
};
|
|
21
|
+
readonly maxQueries: {
|
|
22
|
+
readonly min: 1;
|
|
23
|
+
readonly max: 30;
|
|
24
|
+
};
|
|
18
25
|
readonly includeText: 5;
|
|
19
26
|
readonly excludeText: 5;
|
|
20
27
|
readonly extractUrls: {
|
|
@@ -36,8 +43,17 @@ export declare const LIMITS: {
|
|
|
36
43
|
readonly vlContents: 20;
|
|
37
44
|
readonly vlImages: 5;
|
|
38
45
|
readonly vlVideos: 1;
|
|
46
|
+
readonly imageCount: {
|
|
47
|
+
readonly min: 1;
|
|
48
|
+
readonly max: 10;
|
|
49
|
+
};
|
|
50
|
+
readonly videoCount: {
|
|
51
|
+
readonly min: 1;
|
|
52
|
+
readonly max: 10;
|
|
53
|
+
};
|
|
39
54
|
};
|
|
40
55
|
export declare const TOPIC_OPTIONS: readonly ["general", "news"];
|
|
56
|
+
export declare const IMAGE_TOPIC_OPTIONS: readonly ["general", "design"];
|
|
41
57
|
export declare const TIME_BASIS_OPTIONS: readonly ["auto", "published", "crawled"];
|
|
42
58
|
export declare const TIME_RANGE_OPTIONS: readonly ["day", "week", "month", "year", "d", "w", "m", "y"];
|
|
43
59
|
export declare const SAFESEARCH_OPTIONS: readonly ["off", "strict"];
|
package/dist/api/constants.js
CHANGED
|
@@ -3,10 +3,13 @@ export const DEFAULT_TIMEOUT_MS = 30_000;
|
|
|
3
3
|
export const DEFAULT_MAX_RETRIES = 3;
|
|
4
4
|
export const ENDPOINTS = {
|
|
5
5
|
search: "/search",
|
|
6
|
+
broadSearch: "/broad-search",
|
|
6
7
|
extract: "/extract",
|
|
7
8
|
embedding: "/embedding",
|
|
8
9
|
vlEmbedding: "/vl-embedding",
|
|
9
10
|
chat: "/v1/chat/completions",
|
|
11
|
+
imageSearch: "/image-search",
|
|
12
|
+
videoSearch: "/video-search",
|
|
10
13
|
};
|
|
11
14
|
export const EMBEDDING_MODELS = {
|
|
12
15
|
"0.6b": "octen-embedding-0.6b",
|
|
@@ -19,6 +22,7 @@ export const VL_EMBEDDING_MODELS = {
|
|
|
19
22
|
};
|
|
20
23
|
export const LIMITS = {
|
|
21
24
|
searchCount: { min: 1, max: 100 },
|
|
25
|
+
maxQueries: { min: 1, max: 30 },
|
|
22
26
|
includeText: 5,
|
|
23
27
|
excludeText: 5,
|
|
24
28
|
extractUrls: { min: 1, max: 20 },
|
|
@@ -28,8 +32,11 @@ export const LIMITS = {
|
|
|
28
32
|
vlContents: 20,
|
|
29
33
|
vlImages: 5,
|
|
30
34
|
vlVideos: 1,
|
|
35
|
+
imageCount: { min: 1, max: 10 },
|
|
36
|
+
videoCount: { min: 1, max: 10 },
|
|
31
37
|
};
|
|
32
38
|
export const TOPIC_OPTIONS = ["general", "news"];
|
|
39
|
+
export const IMAGE_TOPIC_OPTIONS = ["general", "design"];
|
|
33
40
|
export const TIME_BASIS_OPTIONS = ["auto", "published", "crawled"];
|
|
34
41
|
export const TIME_RANGE_OPTIONS = ["day", "week", "month", "year", "d", "w", "m", "y"];
|
|
35
42
|
export const SAFESEARCH_OPTIONS = ["off", "strict"];
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** A single image-search result. All fields optional — the server is untyped. */
|
|
2
|
+
export interface ImageSearchResult {
|
|
3
|
+
title?: string;
|
|
4
|
+
url?: string;
|
|
5
|
+
source_page?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
width?: number;
|
|
8
|
+
height?: number;
|
|
9
|
+
thumbnail?: string;
|
|
10
|
+
time_published?: string;
|
|
11
|
+
time_last_crawled?: string;
|
|
12
|
+
summary?: string;
|
|
13
|
+
html_snippet?: string;
|
|
14
|
+
}
|
|
15
|
+
/** Response shape for the /image-search endpoint. */
|
|
16
|
+
export interface ImageSearchResponse {
|
|
17
|
+
results?: ImageSearchResult[];
|
|
18
|
+
}
|
|
19
|
+
export interface ImageSearchOpts {
|
|
20
|
+
/** Optional image input: a public http(s) URL or a local file path. */
|
|
21
|
+
image?: string;
|
|
22
|
+
topic?: "general" | "design";
|
|
23
|
+
count?: number;
|
|
24
|
+
includeDomains?: string[];
|
|
25
|
+
excludeDomains?: string[];
|
|
26
|
+
timeRange?: string;
|
|
27
|
+
startTime?: string;
|
|
28
|
+
endTime?: string;
|
|
29
|
+
safesearch?: "off" | "strict";
|
|
30
|
+
htmlSnippet?: boolean;
|
|
31
|
+
htmlSnippetMaxTokens?: number;
|
|
32
|
+
}
|
|
33
|
+
export declare function buildImageSearchRequest(query: string, o: ImageSearchOpts): Record<string, unknown>;
|
|
34
|
+
/** Matched segment within a video result. */
|
|
35
|
+
export interface VideoMatchSegment {
|
|
36
|
+
start_seconds?: number;
|
|
37
|
+
end_seconds?: number;
|
|
38
|
+
}
|
|
39
|
+
/** A single video-search result. All fields optional — the server is untyped. */
|
|
40
|
+
export interface VideoSearchResult {
|
|
41
|
+
title?: string;
|
|
42
|
+
url?: string;
|
|
43
|
+
source_page?: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
cover_url?: string;
|
|
46
|
+
duration_seconds?: number;
|
|
47
|
+
match_segment?: VideoMatchSegment;
|
|
48
|
+
authors?: string[];
|
|
49
|
+
time_published?: string;
|
|
50
|
+
time_last_crawled?: string;
|
|
51
|
+
}
|
|
52
|
+
/** Response shape for the /video-search endpoint. */
|
|
53
|
+
export interface VideoSearchResponse {
|
|
54
|
+
results?: VideoSearchResult[];
|
|
55
|
+
}
|
|
56
|
+
export interface VideoSearchOpts {
|
|
57
|
+
count?: number;
|
|
58
|
+
timeRange?: string;
|
|
59
|
+
startTime?: string;
|
|
60
|
+
endTime?: string;
|
|
61
|
+
safesearch?: "off" | "strict";
|
|
62
|
+
}
|
|
63
|
+
export declare function buildVideoSearchRequest(query: string, o: VideoSearchOpts): Record<string, unknown>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { readFileSync, existsSync, statSync } from "node:fs";
|
|
2
|
+
import { LIMITS, IMAGE_TOPIC_OPTIONS, TIME_RANGE_OPTIONS, SAFESEARCH_OPTIONS, } from "./constants.js";
|
|
3
|
+
import { OctenValidationError } from "./errors.js";
|
|
4
|
+
import { validateEnum, normalizeTimeBound } from "./search.js";
|
|
5
|
+
/** Max size of a local image read inline as base64. */
|
|
6
|
+
const MAX_IMAGE_BYTES = 5 * 1024 * 1024; // 5 MB
|
|
7
|
+
/**
|
|
8
|
+
* Resolve an image option into an `inputs` entry.
|
|
9
|
+
* - http(s) URL → { type: "image", url }
|
|
10
|
+
* - otherwise treat as a local file path: read raw bytes, base64-encode them
|
|
11
|
+
* (no data: prefix) → { type: "image", data }. Throws if the file is missing
|
|
12
|
+
* or larger than 5MB.
|
|
13
|
+
*/
|
|
14
|
+
function resolveImageInput(value) {
|
|
15
|
+
if (/^https?:\/\//.test(value)) {
|
|
16
|
+
return { type: "image", url: value };
|
|
17
|
+
}
|
|
18
|
+
if (!existsSync(value)) {
|
|
19
|
+
throw new OctenValidationError(`file not found: ${value}`);
|
|
20
|
+
}
|
|
21
|
+
const { size } = statSync(value);
|
|
22
|
+
if (size > MAX_IMAGE_BYTES) {
|
|
23
|
+
throw new OctenValidationError(`file ${value} is ${(size / 1048576).toFixed(1)}MB; max 5MB — pass an https URL instead`);
|
|
24
|
+
}
|
|
25
|
+
const buf = readFileSync(value);
|
|
26
|
+
return { type: "image", data: buf.toString("base64") };
|
|
27
|
+
}
|
|
28
|
+
export function buildImageSearchRequest(query, o) {
|
|
29
|
+
const inputs = [];
|
|
30
|
+
if (query)
|
|
31
|
+
inputs.push({ type: "text", data: query });
|
|
32
|
+
if (o.image)
|
|
33
|
+
inputs.push(resolveImageInput(o.image));
|
|
34
|
+
if (inputs.length === 0)
|
|
35
|
+
throw new OctenValidationError("provide a query or --image");
|
|
36
|
+
if (o.count != null && (o.count < LIMITS.imageCount.min || o.count > LIMITS.imageCount.max))
|
|
37
|
+
throw new OctenValidationError(`count must be ${LIMITS.imageCount.min}-${LIMITS.imageCount.max}`);
|
|
38
|
+
validateEnum("--topic", o.topic, IMAGE_TOPIC_OPTIONS);
|
|
39
|
+
validateEnum("--time-range", o.timeRange, TIME_RANGE_OPTIONS);
|
|
40
|
+
validateEnum("--safesearch", o.safesearch, SAFESEARCH_OPTIONS);
|
|
41
|
+
const req = { inputs };
|
|
42
|
+
const put = (k, v) => { if (v != null)
|
|
43
|
+
req[k] = v; };
|
|
44
|
+
put("topic", o.topic);
|
|
45
|
+
put("count", o.count);
|
|
46
|
+
put("include_domains", o.includeDomains);
|
|
47
|
+
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
|
+
put("safesearch", o.safesearch);
|
|
52
|
+
if (o.htmlSnippet)
|
|
53
|
+
req.html_snippet = {
|
|
54
|
+
enable: true,
|
|
55
|
+
...(o.htmlSnippetMaxTokens ? { max_tokens: o.htmlSnippetMaxTokens } : {}),
|
|
56
|
+
};
|
|
57
|
+
return req;
|
|
58
|
+
}
|
|
59
|
+
export function buildVideoSearchRequest(query, o) {
|
|
60
|
+
if (!query)
|
|
61
|
+
throw new OctenValidationError("query is required");
|
|
62
|
+
if (o.count != null && (o.count < LIMITS.videoCount.min || o.count > LIMITS.videoCount.max))
|
|
63
|
+
throw new OctenValidationError(`count must be ${LIMITS.videoCount.min}-${LIMITS.videoCount.max}`);
|
|
64
|
+
validateEnum("--time-range", o.timeRange, TIME_RANGE_OPTIONS);
|
|
65
|
+
validateEnum("--safesearch", o.safesearch, SAFESEARCH_OPTIONS);
|
|
66
|
+
const inputs = [{ type: "text", data: query }];
|
|
67
|
+
const req = { inputs };
|
|
68
|
+
const put = (k, v) => { if (v != null)
|
|
69
|
+
req[k] = v; };
|
|
70
|
+
put("count", o.count);
|
|
71
|
+
put("time_range", o.timeRange);
|
|
72
|
+
put("start_time", normalizeTimeBound("--start-time", o.startTime, false));
|
|
73
|
+
put("end_time", normalizeTimeBound("--end-time", o.endTime, true));
|
|
74
|
+
put("safesearch", o.safesearch);
|
|
75
|
+
return req;
|
|
76
|
+
}
|
package/dist/api/search.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare function validateEnum(flag: string, value: unknown, allowed: readonly string[]): void;
|
|
1
2
|
/**
|
|
2
3
|
* Normalize a time bound to an ISO 8601 datetime the API accepts.
|
|
3
4
|
* A bare date (YYYY-MM-DD) is expanded to the start (00:00:00Z) or end
|
|
@@ -17,6 +18,18 @@ export interface SearchResult {
|
|
|
17
18
|
export interface SearchResponse {
|
|
18
19
|
results?: SearchResult[];
|
|
19
20
|
}
|
|
21
|
+
/** One sub-query's result group in a /broad-search response. */
|
|
22
|
+
export interface SearchResultGroup {
|
|
23
|
+
query?: string;
|
|
24
|
+
results?: SearchResult[];
|
|
25
|
+
latency?: number;
|
|
26
|
+
}
|
|
27
|
+
/** Response shape for the /broad-search endpoint. */
|
|
28
|
+
export interface BroadSearchResponse {
|
|
29
|
+
query?: string;
|
|
30
|
+
queries?: string[];
|
|
31
|
+
search_results?: SearchResultGroup[];
|
|
32
|
+
}
|
|
20
33
|
export interface SearchOpts {
|
|
21
34
|
topic?: "general" | "news";
|
|
22
35
|
count?: number;
|
|
@@ -37,4 +50,20 @@ export interface SearchOpts {
|
|
|
37
50
|
images?: boolean;
|
|
38
51
|
videos?: boolean;
|
|
39
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Build the per-query search options object (everything except `query`).
|
|
55
|
+
* Shared by /search (spread alongside `query`) and /broad-search (nested under
|
|
56
|
+
* `search_options`). Validates ranges/enums and drops unset fields so server
|
|
57
|
+
* defaults apply.
|
|
58
|
+
*/
|
|
59
|
+
export declare function buildSearchOptions(o: SearchOpts): Record<string, unknown>;
|
|
40
60
|
export declare function buildSearchRequest(query: string, o: SearchOpts): Record<string, unknown>;
|
|
61
|
+
export interface BroadSearchOpts extends SearchOpts {
|
|
62
|
+
maxQueries?: number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Build a /broad-search request: `{ query, max_queries?, search_options? }`.
|
|
66
|
+
* The same per-query options as /search go under `search_options`; `query` and
|
|
67
|
+
* `max_queries` stay at the top level.
|
|
68
|
+
*/
|
|
69
|
+
export declare function buildBroadSearchRequest(query: string, o: BroadSearchOpts): Record<string, unknown>;
|
package/dist/api/search.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LIMITS, TOPIC_OPTIONS, TIME_BASIS_OPTIONS, TIME_RANGE_OPTIONS, SAFESEARCH_OPTIONS, FORMAT_OPTIONS, } from "./constants.js";
|
|
2
2
|
import { OctenValidationError } from "./errors.js";
|
|
3
|
-
function validateEnum(flag, value, allowed) {
|
|
3
|
+
export function validateEnum(flag, value, allowed) {
|
|
4
4
|
if (value != null && !allowed.includes(value))
|
|
5
5
|
throw new OctenValidationError(`${flag} must be one of: ${allowed.join(", ")}`);
|
|
6
6
|
}
|
|
@@ -21,9 +21,13 @@ export function normalizeTimeBound(flag, value, endOfDay) {
|
|
|
21
21
|
}
|
|
22
22
|
throw new OctenValidationError(`${flag} must be a date (YYYY-MM-DD) or ISO datetime (e.g. 2024-01-01T00:00:00Z)`);
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Build the per-query search options object (everything except `query`).
|
|
26
|
+
* Shared by /search (spread alongside `query`) and /broad-search (nested under
|
|
27
|
+
* `search_options`). Validates ranges/enums and drops unset fields so server
|
|
28
|
+
* defaults apply.
|
|
29
|
+
*/
|
|
30
|
+
export function buildSearchOptions(o) {
|
|
27
31
|
if (o.count != null && (o.count < LIMITS.searchCount.min || o.count > LIMITS.searchCount.max))
|
|
28
32
|
throw new OctenValidationError(`count must be ${LIMITS.searchCount.min}-${LIMITS.searchCount.max}`);
|
|
29
33
|
if (o.includeText && o.includeText.length > LIMITS.includeText)
|
|
@@ -37,9 +41,9 @@ export function buildSearchRequest(query, o) {
|
|
|
37
41
|
validateEnum("--time-range", o.timeRange, TIME_RANGE_OPTIONS);
|
|
38
42
|
validateEnum("--safesearch", o.safesearch, SAFESEARCH_OPTIONS);
|
|
39
43
|
validateEnum("--format", o.format, FORMAT_OPTIONS);
|
|
40
|
-
const
|
|
44
|
+
const opts = {};
|
|
41
45
|
const put = (k, v) => { if (v != null)
|
|
42
|
-
|
|
46
|
+
opts[k] = v; };
|
|
43
47
|
put("topic", o.topic);
|
|
44
48
|
put("count", o.count);
|
|
45
49
|
put("include_domains", o.includeDomains);
|
|
@@ -55,8 +59,31 @@ export function buildSearchRequest(query, o) {
|
|
|
55
59
|
put("include_images", o.images);
|
|
56
60
|
put("include_videos", o.videos);
|
|
57
61
|
if (o.highlight)
|
|
58
|
-
|
|
62
|
+
opts.highlight = { enable: true, ...(o.highlightMaxTokens ? { max_tokens: o.highlightMaxTokens } : {}) };
|
|
59
63
|
if (o.fullContent)
|
|
60
|
-
|
|
64
|
+
opts.full_content = { enable: true, ...(o.fullContentMaxTokens ? { max_tokens: o.fullContentMaxTokens } : {}) };
|
|
65
|
+
return opts;
|
|
66
|
+
}
|
|
67
|
+
export function buildSearchRequest(query, o) {
|
|
68
|
+
if (!query)
|
|
69
|
+
throw new OctenValidationError("query is required");
|
|
70
|
+
return { query, ...buildSearchOptions(o) };
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Build a /broad-search request: `{ query, max_queries?, search_options? }`.
|
|
74
|
+
* The same per-query options as /search go under `search_options`; `query` and
|
|
75
|
+
* `max_queries` stay at the top level.
|
|
76
|
+
*/
|
|
77
|
+
export function buildBroadSearchRequest(query, o) {
|
|
78
|
+
if (!query)
|
|
79
|
+
throw new OctenValidationError("query is required");
|
|
80
|
+
if (o.maxQueries != null && (o.maxQueries < LIMITS.maxQueries.min || o.maxQueries > LIMITS.maxQueries.max))
|
|
81
|
+
throw new OctenValidationError(`max-queries must be ${LIMITS.maxQueries.min}-${LIMITS.maxQueries.max}`);
|
|
82
|
+
const searchOptions = buildSearchOptions(o);
|
|
83
|
+
const req = { query };
|
|
84
|
+
if (o.maxQueries != null)
|
|
85
|
+
req.max_queries = o.maxQueries;
|
|
86
|
+
if (Object.keys(searchOptions).length > 0)
|
|
87
|
+
req.search_options = searchOptions;
|
|
61
88
|
return req;
|
|
62
89
|
}
|
package/dist/cli.js
CHANGED
|
@@ -6,10 +6,13 @@ 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 {
|
|
9
|
+
import { registerBroadSearch } from "./commands/broadSearch.js";
|
|
10
|
+
import { registerExtract } from "./commands/extract.js";
|
|
10
11
|
import { registerChat } from "./commands/chat.js";
|
|
11
12
|
import { registerEmbed } from "./commands/embed.js";
|
|
12
13
|
import { registerVlEmbed } from "./commands/vlEmbed.js";
|
|
14
|
+
import { registerImageSearch } from "./commands/imageSearch.js";
|
|
15
|
+
import { registerVideoSearch } from "./commands/videoSearch.js";
|
|
13
16
|
import { registerConfigureMcp } from "./commands/configureMcp.js";
|
|
14
17
|
import { registerConfigureSkills } from "./commands/configureSkills.js";
|
|
15
18
|
import { registerReset } from "./commands/reset.js";
|
|
@@ -35,10 +38,13 @@ registerConfigureMcp(program);
|
|
|
35
38
|
registerConfigureSkills(program);
|
|
36
39
|
registerSearch(program);
|
|
37
40
|
registerSearch(program, "news");
|
|
38
|
-
|
|
41
|
+
registerBroadSearch(program);
|
|
42
|
+
registerExtract(program);
|
|
39
43
|
registerChat(program);
|
|
40
44
|
registerEmbed(program);
|
|
41
45
|
registerVlEmbed(program);
|
|
46
|
+
registerImageSearch(program);
|
|
47
|
+
registerVideoSearch(program);
|
|
42
48
|
// Register LAST so introspection sees every command and its flags.
|
|
43
49
|
registerCompletion(program);
|
|
44
50
|
program.parseAsync().catch((err) => {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ENDPOINTS } from "../api/constants.js";
|
|
2
|
+
import { buildBroadSearchRequest, } from "../api/search.js";
|
|
3
|
+
import { chooseMode, emit } from "../output/render.js";
|
|
4
|
+
import { renderBroadSearch } from "../output/pretty/broadSearch.js";
|
|
5
|
+
import { makeClient, parseIntOpt } from "./utils.js";
|
|
6
|
+
export function registerBroadSearch(program) {
|
|
7
|
+
program.command("broad-search")
|
|
8
|
+
.alias("broad")
|
|
9
|
+
.argument("<query...>", "search query")
|
|
10
|
+
.description("Broad multi-angle web search — expands the query into sub-queries searched concurrently. Best for comparisons, surveys/research, and multi-angle questions; pass the query as-is and raise --max-queries for broader coverage (use `search` for a single focused query)")
|
|
11
|
+
.option("--max-queries <n>", "decompose into up to N sub-queries (1-30; default 5, raise toward 30 for surveys/research)", parseIntOpt("--max-queries"))
|
|
12
|
+
.option("--topic <t>", "general|news")
|
|
13
|
+
.option("-n, --count <n>", "results per sub-query 1-100", parseIntOpt("--count"))
|
|
14
|
+
.option("--include-domains <list>", "comma list", (v) => v.split(","))
|
|
15
|
+
.option("--exclude-domains <list>", "comma list", (v) => v.split(","))
|
|
16
|
+
.option("--include-text <list>", "comma list", (v) => v.split(","))
|
|
17
|
+
.option("--exclude-text <list>", "comma list", (v) => v.split(","))
|
|
18
|
+
.option("--time-basis <b>", "auto|published|crawled").option("--time-range <r>", "day|week|month|year (or d|w|m|y)")
|
|
19
|
+
.option("--start-time <when>", "YYYY-MM-DD or ISO datetime (e.g. 2024-01-01T00:00:00Z)")
|
|
20
|
+
.option("--end-time <when>", "YYYY-MM-DD or ISO datetime (e.g. 2024-12-31T23:59:59Z)")
|
|
21
|
+
.option("--format <f>", "text|markdown").option("--safesearch <s>", "off|strict")
|
|
22
|
+
.option("--highlight").option("--highlight-max-tokens <n>", "max tokens per highlight", parseIntOpt("--highlight-max-tokens"))
|
|
23
|
+
.option("--full-content").option("--full-content-max-tokens <n>", "max tokens per result", parseIntOpt("--full-content-max-tokens"))
|
|
24
|
+
.option("--images").option("--videos")
|
|
25
|
+
.action(async (queryArg, opts, command) => {
|
|
26
|
+
const g = command.optsWithGlobals();
|
|
27
|
+
const client = makeClient(g);
|
|
28
|
+
const query = Array.isArray(queryArg) ? queryArg.join(" ") : queryArg;
|
|
29
|
+
const req = buildBroadSearchRequest(query, opts);
|
|
30
|
+
const res = await client.request(ENDPOINTS.broadSearch, req);
|
|
31
|
+
emit(res, chooseMode(g, process.stdout.isTTY ?? false), renderBroadSearch);
|
|
32
|
+
});
|
|
33
|
+
}
|
package/dist/commands/chat.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { createInterface } from "node:readline";
|
|
2
2
|
import { ENDPOINTS } from "../api/constants.js";
|
|
3
|
-
import { buildChatRequest } from "../api/chat.js";
|
|
3
|
+
import { buildChatRequest, } from "../api/chat.js";
|
|
4
|
+
import pc from "picocolors";
|
|
4
5
|
import { parseSSE } from "../api/sse.js";
|
|
5
6
|
import { OctenValidationError } from "../api/errors.js";
|
|
6
7
|
import { chooseMode, emit } from "../output/render.js";
|
|
7
8
|
import { renderChat } from "../output/pretty/chat.js";
|
|
8
9
|
import { makeClient, parseIntOpt, parseFloatOpt } from "./utils.js";
|
|
10
|
+
const splitList = (v) => v.split(",").map((s) => s.trim()).filter(Boolean);
|
|
9
11
|
/**
|
|
10
12
|
* Drive an interactive chat REPL until the input closes (EOF, /exit, /quit).
|
|
11
13
|
* `send` performs one round-trip given the running history and returns the reply.
|
|
@@ -74,13 +76,35 @@ export function registerChat(program) {
|
|
|
74
76
|
.description("Chat completion")
|
|
75
77
|
.option("-m, --model <id>", "model ID, e.g. anthropic/claude-haiku-4.5 (required unless OCTEN_CHAT_MODEL is set)")
|
|
76
78
|
.option("--system <s>", "system message")
|
|
77
|
-
.option("--
|
|
79
|
+
.option("--cache-system", "send the system message as a cache_control ephemeral block")
|
|
80
|
+
// ── Web search (octen_search tool) ──────────────────────────────────────
|
|
81
|
+
.option("--search", "enable web search via the built-in octen_search tool")
|
|
82
|
+
.option("--search-max-searches <n>", "octen_search: max searches (default 5)", parseIntOpt("--search-max-searches"))
|
|
83
|
+
.option("--search-count <n>", "octen_search: results per search (1-100)", parseIntOpt("--search-count"))
|
|
84
|
+
.option("--search-include-domains <list>", "octen_search: comma-separated domains to include", splitList)
|
|
85
|
+
.option("--search-exclude-domains <list>", "octen_search: comma-separated domains to exclude", splitList)
|
|
86
|
+
.option("--search-time-basis <b>", "octen_search: auto|published|crawled")
|
|
87
|
+
.option("--search-start-time <when>", "octen_search: start time filter")
|
|
88
|
+
.option("--search-end-time <when>", "octen_search: end time filter")
|
|
89
|
+
.option("--search-format <f>", "octen_search: markdown|text")
|
|
90
|
+
.option("--search-safesearch <s>", "octen_search: off|strict")
|
|
91
|
+
.option("--search-full-content", "octen_search: include full page content")
|
|
92
|
+
.option("--search-full-content-max-tokens <n>", "octen_search: max tokens for full content", parseIntOpt("--search-full-content-max-tokens"))
|
|
93
|
+
.option("--search-highlight-max-tokens <n>", "octen_search: max tokens for highlights", parseIntOpt("--search-highlight-max-tokens"))
|
|
94
|
+
// ── Sampling ────────────────────────────────────────────────────────────
|
|
78
95
|
.option("--temperature <n>", "sampling temperature", parseFloatOpt("--temperature"))
|
|
79
96
|
.option("--top-p <n>", "nucleus sampling top-p", parseFloatOpt("--top-p"))
|
|
97
|
+
.option("--top-k <n>", "top-k sampling", parseIntOpt("--top-k"))
|
|
98
|
+
.option("--min-p <n>", "min-p sampling", parseFloatOpt("--min-p"))
|
|
99
|
+
.option("--top-a <n>", "top-a sampling", parseFloatOpt("--top-a"))
|
|
100
|
+
.option("--repetition-penalty <n>", "repetition penalty", parseFloatOpt("--repetition-penalty"))
|
|
80
101
|
.option("--frequency-penalty <n>", "frequency penalty", parseFloatOpt("--frequency-penalty"))
|
|
81
102
|
.option("--presence-penalty <n>", "presence penalty", parseFloatOpt("--presence-penalty"))
|
|
82
103
|
.option("--max-tokens <n>", "max output tokens", parseIntOpt("--max-tokens"))
|
|
83
|
-
.option("--
|
|
104
|
+
.option("--max-completion-tokens <n>", "max completion tokens (includes reasoning tokens)", parseIntOpt("--max-completion-tokens"))
|
|
105
|
+
.option("--verbosity <v>", "low|medium|high")
|
|
106
|
+
.option("--reasoning-effort <e>", "xhigh|high|medium|low|minimal|none")
|
|
107
|
+
.option("--reasoning-max-tokens <n>", "max reasoning tokens", parseIntOpt("--reasoning-max-tokens"))
|
|
84
108
|
.option("--stop <list>", "comma-separated stop sequences", (v) => v.split(","))
|
|
85
109
|
.option("--seed <n>", "random seed", parseIntOpt("--seed"))
|
|
86
110
|
.option("--no-stream", "disable streaming (use request/response)")
|
|
@@ -91,15 +115,37 @@ export function registerChat(program) {
|
|
|
91
115
|
const mode = chooseMode(g, process.stdout.isTTY ?? false);
|
|
92
116
|
const model = opts.model ?? process.env.OCTEN_CHAT_MODEL;
|
|
93
117
|
const chatOpts = {
|
|
94
|
-
|
|
118
|
+
search: {
|
|
119
|
+
enabled: Boolean(opts.search),
|
|
120
|
+
maxSearches: opts.searchMaxSearches,
|
|
121
|
+
count: opts.searchCount,
|
|
122
|
+
includeDomains: opts.searchIncludeDomains,
|
|
123
|
+
excludeDomains: opts.searchExcludeDomains,
|
|
124
|
+
timeBasis: opts.searchTimeBasis,
|
|
125
|
+
startTime: opts.searchStartTime,
|
|
126
|
+
endTime: opts.searchEndTime,
|
|
127
|
+
format: opts.searchFormat,
|
|
128
|
+
safesearch: opts.searchSafesearch,
|
|
129
|
+
fullContent: Boolean(opts.searchFullContent),
|
|
130
|
+
fullContentMaxTokens: opts.searchFullContentMaxTokens,
|
|
131
|
+
highlightMaxTokens: opts.searchHighlightMaxTokens,
|
|
132
|
+
},
|
|
95
133
|
maxTokens: opts.maxTokens,
|
|
134
|
+
maxCompletionTokens: opts.maxCompletionTokens,
|
|
96
135
|
temperature: opts.temperature,
|
|
97
136
|
topP: opts.topP,
|
|
137
|
+
topK: opts.topK,
|
|
138
|
+
minP: opts.minP,
|
|
139
|
+
topA: opts.topA,
|
|
140
|
+
repetitionPenalty: opts.repetitionPenalty,
|
|
98
141
|
frequencyPenalty: opts.frequencyPenalty,
|
|
99
142
|
presencePenalty: opts.presencePenalty,
|
|
100
143
|
stop: opts.stop,
|
|
101
144
|
seed: opts.seed,
|
|
145
|
+
verbosity: opts.verbosity,
|
|
102
146
|
reasoningEffort: opts.reasoningEffort,
|
|
147
|
+
reasoningMaxTokens: opts.reasoningMaxTokens,
|
|
148
|
+
cacheSystem: Boolean(opts.cacheSystem),
|
|
103
149
|
};
|
|
104
150
|
// ── REPL mode ──────────────────────────────────────────────────────────
|
|
105
151
|
if (opts.interactive) {
|
|
@@ -134,14 +180,44 @@ export function registerChat(program) {
|
|
|
134
180
|
emit(res, mode, renderChat);
|
|
135
181
|
return;
|
|
136
182
|
}
|
|
137
|
-
// Streaming pretty mode
|
|
183
|
+
// Streaming pretty mode. The new protocol emits typed chunks
|
|
184
|
+
// (search_done / content / finish / usage) terminated by [DONE].
|
|
138
185
|
const httpRes = await client.stream(ENDPOINTS.chat, req);
|
|
186
|
+
let noted = false;
|
|
187
|
+
let reasoningNoted = false;
|
|
188
|
+
const sources = [];
|
|
139
189
|
for await (const ev of parseSSE(httpRes)) {
|
|
140
190
|
const e = ev;
|
|
191
|
+
if (e.type === "search_done") {
|
|
192
|
+
if (!noted) {
|
|
193
|
+
process.stderr.write("(web search complete)\n");
|
|
194
|
+
noted = true;
|
|
195
|
+
}
|
|
196
|
+
// Collect cited sources to list after the answer.
|
|
197
|
+
for (const grp of (e.search_results ?? []))
|
|
198
|
+
for (const r of grp.results ?? [])
|
|
199
|
+
sources.push({ title: r.title, url: r.url });
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
// Reasoning trace streams to stderr (keeps stdout = answer only).
|
|
203
|
+
const reasoning = e.choices?.[0]?.delta?.reasoning;
|
|
204
|
+
if (reasoning) {
|
|
205
|
+
if (!reasoningNoted) {
|
|
206
|
+
process.stderr.write(pc.dim("reasoning: "));
|
|
207
|
+
reasoningNoted = true;
|
|
208
|
+
}
|
|
209
|
+
process.stderr.write(pc.dim(reasoning));
|
|
210
|
+
}
|
|
141
211
|
const piece = e.choices?.[0]?.delta?.content;
|
|
142
212
|
if (piece)
|
|
143
213
|
process.stdout.write(piece);
|
|
144
214
|
}
|
|
215
|
+
if (reasoningNoted)
|
|
216
|
+
process.stderr.write("\n");
|
|
145
217
|
process.stdout.write("\n");
|
|
218
|
+
if (sources.length) {
|
|
219
|
+
process.stderr.write(pc.dim("Sources:\n"));
|
|
220
|
+
sources.forEach((s, i) => process.stderr.write(pc.dim(` [${i + 1}] ${s.title ?? ""} ${s.url ?? ""}\n`)));
|
|
221
|
+
}
|
|
146
222
|
});
|
|
147
223
|
}
|
|
@@ -3,9 +3,9 @@ import { buildExtractRequest } from "../api/extract.js";
|
|
|
3
3
|
import { chooseMode, emit } from "../output/render.js";
|
|
4
4
|
import { renderExtract } from "../output/pretty/extract.js";
|
|
5
5
|
import { makeClient, parseIntOpt } from "./utils.js";
|
|
6
|
-
export function
|
|
6
|
+
export function registerExtract(program) {
|
|
7
7
|
program
|
|
8
|
-
.command("
|
|
8
|
+
.command("extract")
|
|
9
9
|
.argument("<urls...>", "one or more URLs (1-20)")
|
|
10
10
|
.description("Extract content from URLs")
|
|
11
11
|
.option("--query <q>", "optional search query for relevance")
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ENDPOINTS } from "../api/constants.js";
|
|
2
|
+
import { buildImageSearchRequest, } from "../api/mediaSearch.js";
|
|
3
|
+
import { chooseMode, emit } from "../output/render.js";
|
|
4
|
+
import { renderImageSearch } from "../output/pretty/imageSearch.js";
|
|
5
|
+
import { makeClient, parseIntOpt } from "./utils.js";
|
|
6
|
+
export function registerImageSearch(program) {
|
|
7
|
+
program
|
|
8
|
+
.command("image-search")
|
|
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 and/or image. Use --topic design for UI design references (returns a style summary and html_snippet per result)")
|
|
11
|
+
.option("--image <url|path>", "image input: public URL or local file path")
|
|
12
|
+
.option("--topic <t>", "general|design")
|
|
13
|
+
.option("-n, --count <n>", "results 1-10", parseIntOpt("--count"))
|
|
14
|
+
.option("--include-domains <list>", "comma list", (v) => v.split(","))
|
|
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
|
+
.option("--safesearch <s>", "off|strict")
|
|
20
|
+
.option("--html-snippet", "include HTML snippet for each result")
|
|
21
|
+
.option("--html-snippet-max-tokens <n>", "max tokens per HTML snippet", parseIntOpt("--html-snippet-max-tokens"))
|
|
22
|
+
.action(async (queryArg, opts, command) => {
|
|
23
|
+
const g = command.optsWithGlobals();
|
|
24
|
+
const client = makeClient(g);
|
|
25
|
+
const query = Array.isArray(queryArg) ? queryArg.join(" ") : (queryArg ?? "");
|
|
26
|
+
const imageOpts = {
|
|
27
|
+
image: opts.image,
|
|
28
|
+
topic: opts.topic,
|
|
29
|
+
count: opts.count,
|
|
30
|
+
includeDomains: opts.includeDomains,
|
|
31
|
+
excludeDomains: opts.excludeDomains,
|
|
32
|
+
timeRange: opts.timeRange,
|
|
33
|
+
startTime: opts.startTime,
|
|
34
|
+
endTime: opts.endTime,
|
|
35
|
+
safesearch: opts.safesearch,
|
|
36
|
+
htmlSnippet: opts.htmlSnippet,
|
|
37
|
+
htmlSnippetMaxTokens: opts.htmlSnippetMaxTokens,
|
|
38
|
+
};
|
|
39
|
+
const req = buildImageSearchRequest(query, imageOpts);
|
|
40
|
+
const res = await client.request(ENDPOINTS.imageSearch, req);
|
|
41
|
+
emit(res, chooseMode(g, process.stdout.isTTY ?? false), renderImageSearch);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ENDPOINTS } from "../api/constants.js";
|
|
2
|
+
import { buildVideoSearchRequest, } from "../api/mediaSearch.js";
|
|
3
|
+
import { chooseMode, emit } from "../output/render.js";
|
|
4
|
+
import { renderVideoSearch } from "../output/pretty/videoSearch.js";
|
|
5
|
+
import { makeClient, parseIntOpt } from "./utils.js";
|
|
6
|
+
export function registerVideoSearch(program) {
|
|
7
|
+
program
|
|
8
|
+
.command("video-search")
|
|
9
|
+
.argument("<query...>", "search query")
|
|
10
|
+
.description("In Beta. Contact us to request beta access. — Search the web for videos by text")
|
|
11
|
+
.option("-n, --count <n>", "results 1-10", parseIntOpt("--count"))
|
|
12
|
+
.option("--time-range <r>", "day|week|month|year (or d|w|m|y)")
|
|
13
|
+
.option("--start-time <when>", "YYYY-MM-DD or ISO datetime (e.g. 2024-01-01T00:00:00Z)")
|
|
14
|
+
.option("--end-time <when>", "YYYY-MM-DD or ISO datetime (e.g. 2024-12-31T23:59:59Z)")
|
|
15
|
+
.option("--safesearch <s>", "off|strict")
|
|
16
|
+
.action(async (queryArg, opts, command) => {
|
|
17
|
+
const g = command.optsWithGlobals();
|
|
18
|
+
const client = makeClient(g);
|
|
19
|
+
const query = Array.isArray(queryArg) ? queryArg.join(" ") : queryArg;
|
|
20
|
+
const req = buildVideoSearchRequest(query, opts);
|
|
21
|
+
const res = await client.request(ENDPOINTS.videoSearch, req);
|
|
22
|
+
emit(res, chooseMode(g, process.stdout.isTTY ?? false), renderVideoSearch);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function renderBroadSearch(data: any): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import pc from "picocolors";
|
|
2
|
+
import { formatResultList } from "./search.js";
|
|
3
|
+
export function renderBroadSearch(data) {
|
|
4
|
+
// Same envelope as /search: { data: { query, queries, search_results }, code, msg, ... }.
|
|
5
|
+
const inner = data?.data;
|
|
6
|
+
const body = data && typeof data === "object" && inner && typeof inner === "object" && !Array.isArray(inner)
|
|
7
|
+
? inner
|
|
8
|
+
: data;
|
|
9
|
+
const groups = body?.search_results ?? [];
|
|
10
|
+
if (!groups.length) {
|
|
11
|
+
const code = data?.code;
|
|
12
|
+
const msg = data?.msg;
|
|
13
|
+
if (code != null && code !== 0 && msg) {
|
|
14
|
+
return pc.red(`error: ${msg}`);
|
|
15
|
+
}
|
|
16
|
+
return pc.dim("No results.");
|
|
17
|
+
}
|
|
18
|
+
return groups
|
|
19
|
+
.map((g) => {
|
|
20
|
+
const header = pc.bold(`# ${g.query ?? "(sub-query)"}`);
|
|
21
|
+
const results = g.results ?? [];
|
|
22
|
+
const listing = results.length ? formatResultList(results) : pc.dim(" No results.");
|
|
23
|
+
return `${header}\n\n${listing}`;
|
|
24
|
+
})
|
|
25
|
+
.join("\n\n");
|
|
26
|
+
}
|
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
import pc from "picocolors";
|
|
2
2
|
export function renderChat(data) {
|
|
3
|
-
const
|
|
3
|
+
const message = data?.choices?.[0]?.message;
|
|
4
|
+
const content = message?.content ?? "";
|
|
5
|
+
const reasoning = message?.reasoning;
|
|
6
|
+
const annotations = message?.annotations;
|
|
4
7
|
const usage = data?.usage;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
const parts = [];
|
|
9
|
+
if (reasoning) {
|
|
10
|
+
parts.push(pc.dim(`reasoning: ${reasoning}`));
|
|
11
|
+
}
|
|
12
|
+
parts.push(content);
|
|
13
|
+
// Surface url_citation annotations as a list of cited sources.
|
|
14
|
+
const citations = (annotations ?? [])
|
|
15
|
+
.filter((a) => a?.type === "url_citation" && a.url_citation?.url)
|
|
16
|
+
.map((a) => {
|
|
17
|
+
const c = a.url_citation;
|
|
18
|
+
return c.title ? `${c.title} — ${c.url}` : `${c.url}`;
|
|
19
|
+
});
|
|
20
|
+
if (citations.length) {
|
|
21
|
+
parts.push(pc.dim("citations:") + "\n" + citations.map((c) => pc.dim(` - ${c}`)).join("\n"));
|
|
22
|
+
}
|
|
23
|
+
if (usage) {
|
|
24
|
+
const cached = usage.prompt_tokens_details?.cached_tokens;
|
|
25
|
+
const cachedSuffix = cached != null ? `, cached=${cached}` : "";
|
|
26
|
+
parts.push(pc.dim(`[tokens: prompt=${usage.prompt_tokens ?? "?"}, completion=${usage.completion_tokens ?? "?"}, total=${usage.total_tokens ?? "?"}${cachedSuffix}]`));
|
|
27
|
+
}
|
|
28
|
+
return parts.join("\n\n");
|
|
9
29
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function renderImageSearch(data: any): string;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import pc from "picocolors";
|
|
2
|
+
const MAX_SNIPPET = 300;
|
|
3
|
+
export function renderImageSearch(data) {
|
|
4
|
+
// The Octen API wraps the payload in an envelope: { data: { results }, code, msg, ... }.
|
|
5
|
+
// Unwrap to the inner body only when `data.data` is a non-array object (the real
|
|
6
|
+
// API shape); fall back to the raw object otherwise so un-enveloped inputs still work.
|
|
7
|
+
const inner = data?.data;
|
|
8
|
+
const body = data && typeof data === "object" && inner && typeof inner === "object" && !Array.isArray(inner)
|
|
9
|
+
? inner
|
|
10
|
+
: data;
|
|
11
|
+
const res = body?.results ?? [];
|
|
12
|
+
if (!res.length) {
|
|
13
|
+
// Surface app-level API errors (non-zero code) instead of a bland "No results."
|
|
14
|
+
const code = data?.code;
|
|
15
|
+
const msg = data?.msg;
|
|
16
|
+
if (code != null && code !== 0 && msg) {
|
|
17
|
+
return pc.red(`error: ${msg}`);
|
|
18
|
+
}
|
|
19
|
+
return pc.dim("No results.");
|
|
20
|
+
}
|
|
21
|
+
return res
|
|
22
|
+
.map((r, i) => {
|
|
23
|
+
const lines = [];
|
|
24
|
+
// Numbered + bold title
|
|
25
|
+
const title = r.title ?? "(no title)";
|
|
26
|
+
lines.push(`${i + 1}. ${pc.bold(title)}`);
|
|
27
|
+
// Dim URL
|
|
28
|
+
if (r.url)
|
|
29
|
+
lines.push(` ${pc.dim(r.url)}`);
|
|
30
|
+
// Dim source page
|
|
31
|
+
if (r.source_page)
|
|
32
|
+
lines.push(` ${pc.dim(r.source_page)}`);
|
|
33
|
+
// Dimensions WxH
|
|
34
|
+
if (r.width != null && r.height != null)
|
|
35
|
+
lines.push(` ${pc.dim(`${r.width}x${r.height}`)}`);
|
|
36
|
+
// Snippet from description or summary (truncated)
|
|
37
|
+
const raw = r.description ?? r.summary ?? "";
|
|
38
|
+
if (raw) {
|
|
39
|
+
const snippet = raw.length > MAX_SNIPPET ? raw.slice(0, MAX_SNIPPET) + "…" : raw;
|
|
40
|
+
lines.push(` ${snippet}`);
|
|
41
|
+
}
|
|
42
|
+
return lines.join("\n");
|
|
43
|
+
})
|
|
44
|
+
.join("\n\n");
|
|
45
|
+
}
|
|
@@ -18,7 +18,11 @@ export function renderSearch(data) {
|
|
|
18
18
|
}
|
|
19
19
|
return pc.dim("No results.");
|
|
20
20
|
}
|
|
21
|
-
return res
|
|
21
|
+
return formatResultList(res);
|
|
22
|
+
}
|
|
23
|
+
/** Render a list of search results as numbered, titled blocks. */
|
|
24
|
+
export function formatResultList(results) {
|
|
25
|
+
return results
|
|
22
26
|
.map((r, i) => {
|
|
23
27
|
const lines = [];
|
|
24
28
|
// Numbered + bold title
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function renderVideoSearch(data: any): string;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import pc from "picocolors";
|
|
2
|
+
const MAX_SNIPPET = 300;
|
|
3
|
+
export function renderVideoSearch(data) {
|
|
4
|
+
// The Octen API wraps the payload in an envelope: { data: { results }, code, msg, ... }.
|
|
5
|
+
// Unwrap to the inner body only when `data.data` is a non-array object (the real
|
|
6
|
+
// API shape); fall back to the raw object otherwise so un-enveloped inputs still work.
|
|
7
|
+
const inner = data?.data;
|
|
8
|
+
const body = data && typeof data === "object" && inner && typeof inner === "object" && !Array.isArray(inner)
|
|
9
|
+
? inner
|
|
10
|
+
: data;
|
|
11
|
+
const res = body?.results ?? [];
|
|
12
|
+
if (!res.length) {
|
|
13
|
+
// Surface app-level API errors (non-zero code) instead of a bland "No results."
|
|
14
|
+
const code = data?.code;
|
|
15
|
+
const msg = data?.msg;
|
|
16
|
+
if (code != null && code !== 0 && msg) {
|
|
17
|
+
return pc.red(`error: ${msg}`);
|
|
18
|
+
}
|
|
19
|
+
return pc.dim("No results.");
|
|
20
|
+
}
|
|
21
|
+
return res
|
|
22
|
+
.map((r, i) => {
|
|
23
|
+
const lines = [];
|
|
24
|
+
// Numbered + bold title
|
|
25
|
+
const title = r.title ?? "(no title)";
|
|
26
|
+
lines.push(`${i + 1}. ${pc.bold(title)}`);
|
|
27
|
+
// Dim URL
|
|
28
|
+
if (r.url)
|
|
29
|
+
lines.push(` ${pc.dim(r.url)}`);
|
|
30
|
+
// Duration in seconds
|
|
31
|
+
if (r.duration_seconds != null)
|
|
32
|
+
lines.push(` ${pc.dim(`${r.duration_seconds}s`)}`);
|
|
33
|
+
// Matched segment start–end
|
|
34
|
+
const seg = r.match_segment;
|
|
35
|
+
if (seg && (seg.start_seconds != null || seg.end_seconds != null)) {
|
|
36
|
+
lines.push(` ${pc.dim(`match ${seg.start_seconds ?? 0}–${seg.end_seconds ?? 0} s`)}`);
|
|
37
|
+
}
|
|
38
|
+
// Authors
|
|
39
|
+
if (r.authors && r.authors.length)
|
|
40
|
+
lines.push(` ${pc.dim(r.authors.join(", "))}`);
|
|
41
|
+
// Snippet from description (truncated)
|
|
42
|
+
const raw = r.description ?? "";
|
|
43
|
+
if (raw) {
|
|
44
|
+
const snippet = raw.length > MAX_SNIPPET ? raw.slice(0, MAX_SNIPPET) + "…" : raw;
|
|
45
|
+
lines.push(` ${snippet}`);
|
|
46
|
+
}
|
|
47
|
+
return lines.join("\n");
|
|
48
|
+
})
|
|
49
|
+
.join("\n\n");
|
|
50
|
+
}
|
package/package.json
CHANGED
package/dist/commands/fetch.d.ts
DELETED