@octen.ai/cli 0.1.12 → 0.1.13
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 +13 -8
- package/dist/api/constants.d.ts +3 -0
- package/dist/api/constants.js +1 -0
- package/dist/api/extract.d.ts +6 -0
- package/dist/api/extract.js +26 -6
- package/dist/api/search.d.ts +7 -0
- package/dist/api/search.js +21 -2
- package/dist/cli.js +7 -2
- package/dist/commands/chat.d.ts +17 -0
- package/dist/commands/chat.js +67 -42
- package/dist/commands/search.js +2 -1
- package/dist/commands/vlEmbed.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,24 +4,29 @@ Command-line tool for Octen — web search, extract, chat, embeddings, and one-c
|
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
|
+
**With Node.js (npm):**
|
|
8
|
+
|
|
7
9
|
```sh
|
|
8
10
|
npm i -g @octen.ai/cli
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
Or run without installing: `npx @octen.ai/cli <command>`. Requires Node.js 18+.
|
|
14
|
+
|
|
15
|
+
**Without Node.js (standalone binary):** download the binary for your platform
|
|
16
|
+
from the [latest release](https://github.com/Octen-Team/octen-cli/releases/latest)
|
|
17
|
+
(`octen-darwin-arm64`, `octen-darwin-x64`, `octen-linux-x64`, `octen-linux-arm64`),
|
|
18
|
+
`chmod +x` it, and put it on your `PATH`. On macOS/Linux you can also use Homebrew:
|
|
12
19
|
|
|
13
20
|
```sh
|
|
14
|
-
|
|
21
|
+
brew install Octen-Team/tap/octen
|
|
15
22
|
```
|
|
16
23
|
|
|
17
|
-
|
|
24
|
+
Then enable tab-completion (one-time; `bash` / `zsh` / `fish`):
|
|
18
25
|
|
|
19
26
|
```sh
|
|
20
|
-
|
|
27
|
+
octen completion zsh --install # writes to ~/.zshrc — then: source ~/.zshrc
|
|
21
28
|
```
|
|
22
29
|
|
|
23
|
-
Requires Node.js 18+.
|
|
24
|
-
|
|
25
30
|
## Auth
|
|
26
31
|
|
|
27
32
|
Set your API key (get one at https://octen.ai):
|
|
@@ -42,7 +47,7 @@ Search the live web.
|
|
|
42
47
|
octen search "latest LLM benchmarks" -n 10 --topic news --highlight --time-range week
|
|
43
48
|
```
|
|
44
49
|
|
|
45
|
-
Options: `-n` (result count 1–100), `--topic` (general|news), `--highlight`, `--time-range` (day|week|month|year or d|w|m|y), `--start-time
|
|
50
|
+
Options: `-n` (result count 1–100), `--topic` (general|news), `--highlight` (+`--highlight-max-tokens`, min 100), `--time-range` (day|week|month|year or d|w|m|y), `--start-time`/`--end-time` (YYYY-MM-DD or ISO datetime), `--include-domains`, `--exclude-domains`, `--full-content`, `--images`, `--videos`, `--format` (text|markdown), `--safesearch`.
|
|
46
51
|
|
|
47
52
|
---
|
|
48
53
|
|
|
@@ -64,7 +69,7 @@ Extract content from one or more URLs (1–20).
|
|
|
64
69
|
octen fetch https://example.com --query "pricing" --max-age 3600 --images
|
|
65
70
|
```
|
|
66
71
|
|
|
67
|
-
Options: `--query` (relevance hint), `--max-age <sec>` (cache age), `--images`, `--videos`, `--audio`, `--favicon`, `--format` (markdown|text), `--fetch-timeout <sec
|
|
72
|
+
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).
|
|
68
73
|
|
|
69
74
|
Pretty output truncates page content to ~500 chars for readability; pass `--full` to print the whole thing (or `--json` for the raw response).
|
|
70
75
|
|
package/dist/api/constants.d.ts
CHANGED
package/dist/api/constants.js
CHANGED
package/dist/api/extract.d.ts
CHANGED
|
@@ -31,4 +31,10 @@ export interface ExtractOpts {
|
|
|
31
31
|
audio?: boolean;
|
|
32
32
|
favicon?: boolean;
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Auto-prefix bare hosts with https:// and reject inputs that are not plausible
|
|
36
|
+
* http(s) URLs, so obvious typos fail client-side instead of being silently
|
|
37
|
+
* sent to the server (which reports them as failed but still accepts the call).
|
|
38
|
+
*/
|
|
39
|
+
export declare function normalizeExtractUrl(raw: string): string;
|
|
34
40
|
export declare function buildExtractRequest(urls: string[], o: ExtractOpts): Record<string, unknown>;
|
package/dist/api/extract.js
CHANGED
|
@@ -1,16 +1,36 @@
|
|
|
1
1
|
import { LIMITS } from "./constants.js";
|
|
2
2
|
import { OctenValidationError } from "./errors.js";
|
|
3
|
+
/**
|
|
4
|
+
* Auto-prefix bare hosts with https:// and reject inputs that are not plausible
|
|
5
|
+
* http(s) URLs, so obvious typos fail client-side instead of being silently
|
|
6
|
+
* sent to the server (which reports them as failed but still accepts the call).
|
|
7
|
+
*/
|
|
8
|
+
export function normalizeExtractUrl(raw) {
|
|
9
|
+
const candidate = raw.includes("://") ? raw : `https://${raw}`;
|
|
10
|
+
let parsed;
|
|
11
|
+
try {
|
|
12
|
+
parsed = new URL(candidate);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
throw new OctenValidationError(`invalid URL: ${raw}`);
|
|
16
|
+
}
|
|
17
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:")
|
|
18
|
+
throw new OctenValidationError(`invalid URL (only http/https): ${raw}`);
|
|
19
|
+
const host = parsed.hostname;
|
|
20
|
+
// A real host is a domain (has a dot), an IP/IPv6 (has a colon), or localhost.
|
|
21
|
+
if (host !== "localhost" && !host.includes(".") && !host.includes(":"))
|
|
22
|
+
throw new OctenValidationError(`invalid URL: ${raw} (expected a domain like example.com or a full https:// URL)`);
|
|
23
|
+
return candidate;
|
|
24
|
+
}
|
|
3
25
|
export function buildExtractRequest(urls, o) {
|
|
4
26
|
if (urls.length < LIMITS.extractUrls.min || urls.length > LIMITS.extractUrls.max)
|
|
5
27
|
throw new OctenValidationError(`urls must be ${LIMITS.extractUrls.min}-${LIMITS.extractUrls.max} items`);
|
|
6
28
|
if (o.fetchTimeout != null && (o.fetchTimeout < LIMITS.extractTimeout.min || o.fetchTimeout > LIMITS.extractTimeout.max))
|
|
7
29
|
throw new OctenValidationError(`fetch-timeout must be ${LIMITS.extractTimeout.min}-${LIMITS.extractTimeout.max}`);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const maxAge = o.maxAge
|
|
12
|
-
? Math.min(LIMITS.cacheWindow.max, Math.max(LIMITS.cacheWindow.min, o.maxAge))
|
|
13
|
-
: undefined;
|
|
30
|
+
if (o.maxAge != null && (o.maxAge < LIMITS.cacheWindow.min || o.maxAge > LIMITS.cacheWindow.max))
|
|
31
|
+
throw new OctenValidationError(`max-age must be ${LIMITS.cacheWindow.min}-${LIMITS.cacheWindow.max} seconds`);
|
|
32
|
+
const normalizedUrls = urls.map(normalizeExtractUrl);
|
|
33
|
+
const maxAge = o.maxAge;
|
|
14
34
|
const req = { urls: normalizedUrls };
|
|
15
35
|
const put = (k, v) => { if (v != null)
|
|
16
36
|
req[k] = v; };
|
package/dist/api/search.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize a time bound to an ISO 8601 datetime the API accepts.
|
|
3
|
+
* A bare date (YYYY-MM-DD) is expanded to the start (00:00:00Z) or end
|
|
4
|
+
* (23:59:59Z) of that day; a full datetime passes through. Anything else is
|
|
5
|
+
* rejected client-side with a clear message instead of a server 400.
|
|
6
|
+
*/
|
|
7
|
+
export declare function normalizeTimeBound(flag: string, value: string | undefined, endOfDay: boolean): string | undefined;
|
|
1
8
|
/** A single search result. All fields optional — the server is untyped. */
|
|
2
9
|
export interface SearchResult {
|
|
3
10
|
title?: string;
|
package/dist/api/search.js
CHANGED
|
@@ -4,6 +4,23 @@ 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
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Normalize a time bound to an ISO 8601 datetime the API accepts.
|
|
9
|
+
* A bare date (YYYY-MM-DD) is expanded to the start (00:00:00Z) or end
|
|
10
|
+
* (23:59:59Z) of that day; a full datetime passes through. Anything else is
|
|
11
|
+
* rejected client-side with a clear message instead of a server 400.
|
|
12
|
+
*/
|
|
13
|
+
export function normalizeTimeBound(flag, value, endOfDay) {
|
|
14
|
+
if (value == null)
|
|
15
|
+
return undefined;
|
|
16
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
17
|
+
return endOfDay ? `${value}T23:59:59Z` : `${value}T00:00:00Z`;
|
|
18
|
+
}
|
|
19
|
+
if (/^\d{4}-\d{2}-\d{2}T/.test(value) && !Number.isNaN(Date.parse(value))) {
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
throw new OctenValidationError(`${flag} must be a date (YYYY-MM-DD) or ISO datetime (e.g. 2024-01-01T00:00:00Z)`);
|
|
23
|
+
}
|
|
7
24
|
export function buildSearchRequest(query, o) {
|
|
8
25
|
if (!query)
|
|
9
26
|
throw new OctenValidationError("query is required");
|
|
@@ -13,6 +30,8 @@ export function buildSearchRequest(query, o) {
|
|
|
13
30
|
throw new OctenValidationError(`include-text max ${LIMITS.includeText}`);
|
|
14
31
|
if (o.excludeText && o.excludeText.length > LIMITS.excludeText)
|
|
15
32
|
throw new OctenValidationError(`exclude-text max ${LIMITS.excludeText}`);
|
|
33
|
+
if (o.highlightMaxTokens != null && o.highlightMaxTokens < LIMITS.highlightMaxTokens.min)
|
|
34
|
+
throw new OctenValidationError(`highlight-max-tokens must be at least ${LIMITS.highlightMaxTokens.min}`);
|
|
16
35
|
validateEnum("--topic", o.topic, TOPIC_OPTIONS);
|
|
17
36
|
validateEnum("--time-basis", o.timeBasis, TIME_BASIS_OPTIONS);
|
|
18
37
|
validateEnum("--time-range", o.timeRange, TIME_RANGE_OPTIONS);
|
|
@@ -29,8 +48,8 @@ export function buildSearchRequest(query, o) {
|
|
|
29
48
|
put("exclude_text", o.excludeText);
|
|
30
49
|
put("time_basis", o.timeBasis);
|
|
31
50
|
put("time_range", o.timeRange);
|
|
32
|
-
put("start_time", o.startTime);
|
|
33
|
-
put("end_time", o.endTime);
|
|
51
|
+
put("start_time", normalizeTimeBound("--start-time", o.startTime, false));
|
|
52
|
+
put("end_time", normalizeTimeBound("--end-time", o.endTime, true));
|
|
34
53
|
put("format", o.format);
|
|
35
54
|
put("safesearch", o.safesearch);
|
|
36
55
|
put("include_images", o.images);
|
package/dist/cli.js
CHANGED
|
@@ -14,12 +14,17 @@ import { registerConfigureMcp } from "./commands/configureMcp.js";
|
|
|
14
14
|
import { registerConfigureSkills } from "./commands/configureSkills.js";
|
|
15
15
|
import { registerReset } from "./commands/reset.js";
|
|
16
16
|
import { registerCompletion } from "./commands/completion.js";
|
|
17
|
-
|
|
17
|
+
function resolveVersion() {
|
|
18
|
+
if (typeof __OCTEN_VERSION__ !== "undefined")
|
|
19
|
+
return __OCTEN_VERSION__;
|
|
20
|
+
const pkg = JSON.parse(readFileSync(fileURLToPath(new URL("../package.json", import.meta.url)), "utf8"));
|
|
21
|
+
return pkg.version;
|
|
22
|
+
}
|
|
18
23
|
const program = new Command();
|
|
19
24
|
program
|
|
20
25
|
.name("octen")
|
|
21
26
|
.description("Octen CLI — search, extract, chat, embeddings, and MCP/Skills setup")
|
|
22
|
-
.version(
|
|
27
|
+
.version(resolveVersion())
|
|
23
28
|
.option("--api-key <key>", "Octen API key")
|
|
24
29
|
.option("--base-url <url>", "API base URL")
|
|
25
30
|
.option("--json", "raw JSON output")
|
package/dist/commands/chat.d.ts
CHANGED
|
@@ -1,2 +1,19 @@
|
|
|
1
1
|
import type { Command } from "commander";
|
|
2
|
+
import { type ChatMessage } from "../api/chat.js";
|
|
3
|
+
export interface ReplStreams {
|
|
4
|
+
input: NodeJS.ReadableStream;
|
|
5
|
+
/** prompts, errors and notices (stderr) */
|
|
6
|
+
promptOut: NodeJS.WritableStream;
|
|
7
|
+
/** assistant replies (stdout) */
|
|
8
|
+
replyOut: NodeJS.WritableStream;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Drive an interactive chat REPL until the input closes (EOF, /exit, /quit).
|
|
12
|
+
* `send` performs one round-trip given the running history and returns the reply.
|
|
13
|
+
*
|
|
14
|
+
* Every readline operation is guarded by a `closed` flag: piped/scripted input
|
|
15
|
+
* can hit EOF (and close the interface) while a request is still in flight, and
|
|
16
|
+
* resuming/prompting a closed readline throws ERR_USE_AFTER_CLOSE.
|
|
17
|
+
*/
|
|
18
|
+
export declare function runChatRepl(streams: ReplStreams, send: (history: ChatMessage[]) => Promise<string>, system?: string): Promise<void>;
|
|
2
19
|
export declare function registerChat(program: Command): void;
|
package/dist/commands/chat.js
CHANGED
|
@@ -6,12 +6,73 @@ import { OctenValidationError } from "../api/errors.js";
|
|
|
6
6
|
import { chooseMode, emit } from "../output/render.js";
|
|
7
7
|
import { renderChat } from "../output/pretty/chat.js";
|
|
8
8
|
import { makeClient, parseIntOpt, parseFloatOpt } from "./utils.js";
|
|
9
|
+
/**
|
|
10
|
+
* Drive an interactive chat REPL until the input closes (EOF, /exit, /quit).
|
|
11
|
+
* `send` performs one round-trip given the running history and returns the reply.
|
|
12
|
+
*
|
|
13
|
+
* Every readline operation is guarded by a `closed` flag: piped/scripted input
|
|
14
|
+
* can hit EOF (and close the interface) while a request is still in flight, and
|
|
15
|
+
* resuming/prompting a closed readline throws ERR_USE_AFTER_CLOSE.
|
|
16
|
+
*/
|
|
17
|
+
export async function runChatRepl(streams, send, system) {
|
|
18
|
+
const history = [];
|
|
19
|
+
if (system)
|
|
20
|
+
history.push({ role: "system", content: system });
|
|
21
|
+
const rl = createInterface({ input: streams.input, output: streams.promptOut, prompt: "> " });
|
|
22
|
+
let closed = false;
|
|
23
|
+
const prompt = () => {
|
|
24
|
+
if (!closed)
|
|
25
|
+
rl.prompt();
|
|
26
|
+
};
|
|
27
|
+
await new Promise((resolve) => {
|
|
28
|
+
rl.on("close", () => {
|
|
29
|
+
closed = true;
|
|
30
|
+
resolve();
|
|
31
|
+
});
|
|
32
|
+
rl.on("line", async (line) => {
|
|
33
|
+
const trimmed = line.trim();
|
|
34
|
+
if (trimmed === "/exit" || trimmed === "/quit") {
|
|
35
|
+
rl.close();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (trimmed === "/reset") {
|
|
39
|
+
history.length = 0;
|
|
40
|
+
if (system)
|
|
41
|
+
history.push({ role: "system", content: system });
|
|
42
|
+
streams.promptOut.write("(conversation reset)\n");
|
|
43
|
+
prompt();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (!trimmed) {
|
|
47
|
+
prompt();
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
history.push({ role: "user", content: trimmed });
|
|
51
|
+
rl.pause();
|
|
52
|
+
try {
|
|
53
|
+
const reply = await send(history);
|
|
54
|
+
history.push({ role: "assistant", content: reply });
|
|
55
|
+
streams.replyOut.write(reply + "\n");
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
streams.promptOut.write(`error: ${err.message}\n`);
|
|
59
|
+
}
|
|
60
|
+
finally {
|
|
61
|
+
if (!closed) {
|
|
62
|
+
rl.resume();
|
|
63
|
+
rl.prompt();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
rl.prompt();
|
|
68
|
+
});
|
|
69
|
+
}
|
|
9
70
|
export function registerChat(program) {
|
|
10
71
|
program
|
|
11
72
|
.command("chat")
|
|
12
73
|
.argument("[prompt]", "prompt (or read stdin / use -i)")
|
|
13
74
|
.description("Chat completion")
|
|
14
|
-
.option("-m, --model <id>", "model ID")
|
|
75
|
+
.option("-m, --model <id>", "model ID, e.g. anthropic/claude-haiku-4.5 (required unless OCTEN_CHAT_MODEL is set)")
|
|
15
76
|
.option("--system <s>", "system message")
|
|
16
77
|
.option("--web-search <onoff>", "on|off")
|
|
17
78
|
.option("--temperature <n>", "sampling temperature", parseFloatOpt("--temperature"))
|
|
@@ -42,47 +103,11 @@ export function registerChat(program) {
|
|
|
42
103
|
};
|
|
43
104
|
// ── REPL mode ──────────────────────────────────────────────────────────
|
|
44
105
|
if (opts.interactive) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
rl.on("line", async (line) => {
|
|
51
|
-
const trimmed = line.trim();
|
|
52
|
-
if (trimmed === "/exit" || trimmed === "/quit") {
|
|
53
|
-
rl.close();
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
if (trimmed === "/reset") {
|
|
57
|
-
history.length = 0;
|
|
58
|
-
if (opts.system)
|
|
59
|
-
history.push({ role: "system", content: opts.system });
|
|
60
|
-
process.stderr.write("(conversation reset)\n");
|
|
61
|
-
rl.prompt();
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
if (!trimmed) {
|
|
65
|
-
rl.prompt();
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
history.push({ role: "user", content: trimmed });
|
|
69
|
-
rl.pause();
|
|
70
|
-
try {
|
|
71
|
-
const req = buildChatRequest(history, model, chatOpts);
|
|
72
|
-
const res = await client.request(ENDPOINTS.chat, req);
|
|
73
|
-
const reply = res?.choices?.[0]?.message?.content ?? "";
|
|
74
|
-
history.push({ role: "assistant", content: reply });
|
|
75
|
-
process.stdout.write(reply + "\n");
|
|
76
|
-
}
|
|
77
|
-
catch (err) {
|
|
78
|
-
process.stderr.write(`error: ${err.message}\n`);
|
|
79
|
-
}
|
|
80
|
-
finally {
|
|
81
|
-
rl.resume();
|
|
82
|
-
rl.prompt();
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
await new Promise((resolve) => rl.on("close", resolve));
|
|
106
|
+
await runChatRepl({ input: process.stdin, promptOut: process.stderr, replyOut: process.stdout }, async (history) => {
|
|
107
|
+
const req = buildChatRequest(history, model, chatOpts);
|
|
108
|
+
const res = await client.request(ENDPOINTS.chat, req);
|
|
109
|
+
return res?.choices?.[0]?.message?.content ?? "";
|
|
110
|
+
}, opts.system);
|
|
86
111
|
return;
|
|
87
112
|
}
|
|
88
113
|
// ── Single-turn mode ───────────────────────────────────────────────────
|
package/dist/commands/search.js
CHANGED
|
@@ -13,7 +13,8 @@ export function registerSearch(program, fixedTopic) {
|
|
|
13
13
|
.option("--include-text <list>", "comma list", (v) => v.split(","))
|
|
14
14
|
.option("--exclude-text <list>", "comma list", (v) => v.split(","))
|
|
15
15
|
.option("--time-basis <b>", "auto|published|crawled").option("--time-range <r>", "day|week|month|year (or d|w|m|y)")
|
|
16
|
-
.option("--start-time <
|
|
16
|
+
.option("--start-time <when>", "YYYY-MM-DD or ISO datetime (e.g. 2024-01-01T00:00:00Z)")
|
|
17
|
+
.option("--end-time <when>", "YYYY-MM-DD or ISO datetime (e.g. 2024-12-31T23:59:59Z)")
|
|
17
18
|
.option("--format <f>", "text|markdown").option("--safesearch <s>", "off|strict")
|
|
18
19
|
.option("--highlight").option("--highlight-max-tokens <n>", "max tokens per highlight", parseIntOpt("--highlight-max-tokens"))
|
|
19
20
|
.option("--full-content").option("--full-content-max-tokens <n>", "max tokens per result", parseIntOpt("--full-content-max-tokens"))
|
package/dist/commands/vlEmbed.js
CHANGED
|
@@ -65,7 +65,7 @@ export function registerVlEmbed(program) {
|
|
|
65
65
|
.command("vl-embed")
|
|
66
66
|
.argument("<content...>", "ordered content tokens: text:... image:... video:...")
|
|
67
67
|
.description("Create multimodal embeddings")
|
|
68
|
-
.option("-m, --model <id>", "model: base | large | full id")
|
|
68
|
+
.option("-m, --model <id>", "model (required): base | large | full id")
|
|
69
69
|
.option("--dimension <n>", "output vector dimension", parseIntOpt("--dimension"))
|
|
70
70
|
.option("--fps <n>", "video frames per second to sample", parseFloatOpt("--fps"))
|
|
71
71
|
.option("--instruct <s>", "task instruction for embedding")
|