@octen.ai/cli 0.1.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.
Files changed (75) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +184 -0
  3. package/dist/api/chat.d.ts +33 -0
  4. package/dist/api/chat.js +23 -0
  5. package/dist/api/client.d.ts +19 -0
  6. package/dist/api/client.js +111 -0
  7. package/dist/api/constants.d.ts +38 -0
  8. package/dist/api/constants.js +32 -0
  9. package/dist/api/embedding.d.ts +18 -0
  10. package/dist/api/embedding.js +27 -0
  11. package/dist/api/errors.d.ts +14 -0
  12. package/dist/api/errors.js +22 -0
  13. package/dist/api/extract.d.ts +34 -0
  14. package/dist/api/extract.js +26 -0
  15. package/dist/api/search.d.ts +33 -0
  16. package/dist/api/search.js +34 -0
  17. package/dist/api/sse.d.ts +6 -0
  18. package/dist/api/sse.js +53 -0
  19. package/dist/api/vlEmbedding.d.ts +39 -0
  20. package/dist/api/vlEmbedding.js +68 -0
  21. package/dist/cli.d.ts +2 -0
  22. package/dist/cli.js +39 -0
  23. package/dist/commands/chat.d.ts +2 -0
  24. package/dist/commands/chat.js +122 -0
  25. package/dist/commands/configureMcp.d.ts +11 -0
  26. package/dist/commands/configureMcp.js +101 -0
  27. package/dist/commands/configureSkills.d.ts +11 -0
  28. package/dist/commands/configureSkills.js +118 -0
  29. package/dist/commands/embed.d.ts +2 -0
  30. package/dist/commands/embed.js +69 -0
  31. package/dist/commands/fetch.d.ts +2 -0
  32. package/dist/commands/fetch.js +26 -0
  33. package/dist/commands/reset.d.ts +11 -0
  34. package/dist/commands/reset.js +112 -0
  35. package/dist/commands/search.d.ts +2 -0
  36. package/dist/commands/search.js +31 -0
  37. package/dist/commands/utils.d.ts +10 -0
  38. package/dist/commands/utils.js +24 -0
  39. package/dist/commands/vlEmbed.d.ts +2 -0
  40. package/dist/commands/vlEmbed.js +98 -0
  41. package/dist/config/resolve.d.ts +2 -0
  42. package/dist/config/resolve.js +12 -0
  43. package/dist/mcp/clients.d.ts +9 -0
  44. package/dist/mcp/clients.js +58 -0
  45. package/dist/mcp/detect.d.ts +2 -0
  46. package/dist/mcp/detect.js +35 -0
  47. package/dist/mcp/install.d.ts +20 -0
  48. package/dist/mcp/install.js +56 -0
  49. package/dist/mcp/write.d.ts +3 -0
  50. package/dist/mcp/write.js +104 -0
  51. package/dist/output/pretty/chat.d.ts +2 -0
  52. package/dist/output/pretty/chat.js +9 -0
  53. package/dist/output/pretty/embedding.d.ts +11 -0
  54. package/dist/output/pretty/embedding.js +43 -0
  55. package/dist/output/pretty/extract.d.ts +2 -0
  56. package/dist/output/pretty/extract.js +41 -0
  57. package/dist/output/pretty/search.d.ts +2 -0
  58. package/dist/output/pretty/search.js +28 -0
  59. package/dist/output/pretty/vlEmbedding.d.ts +13 -0
  60. package/dist/output/pretty/vlEmbedding.js +47 -0
  61. package/dist/output/render.d.ts +6 -0
  62. package/dist/output/render.js +13 -0
  63. package/dist/skills/clients.d.ts +7 -0
  64. package/dist/skills/clients.js +47 -0
  65. package/dist/skills/install.d.ts +18 -0
  66. package/dist/skills/install.js +77 -0
  67. package/dist/skills/source.d.ts +12 -0
  68. package/dist/skills/source.js +56 -0
  69. package/dist/util/preflightColor.d.ts +1 -0
  70. package/dist/util/preflightColor.js +7 -0
  71. package/package.json +44 -0
  72. package/skills/manifest.json +8 -0
  73. package/skills/octen-design/SKILL.md +218 -0
  74. package/skills/octen-design/scripts/search.py +304 -0
  75. package/skills/octen-search/SKILL.md +199 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Octen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,184 @@
1
+ # @octen.ai/cli
2
+
3
+ Command-line tool for Octen — web search, extract, chat, embeddings, and one-command MCP/Skills setup for Claude Code, Cursor, and more.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm i -g @octen.ai/cli
9
+ ```
10
+
11
+ Or run without installing:
12
+
13
+ ```sh
14
+ npx @octen.ai/cli <command>
15
+ ```
16
+
17
+ Requires Node.js 18+.
18
+
19
+ ## Auth
20
+
21
+ Set your API key (get one at https://octen.ai):
22
+
23
+ ```sh
24
+ export OCTEN_API_KEY=your_key_here
25
+ ```
26
+
27
+ You can also pass `--api-key <key>` on any command. To point at a self-hosted or staging endpoint, set `OCTEN_API_URL` or pass `--base-url <url>`.
28
+
29
+ ## Commands
30
+
31
+ ### `octen search`
32
+
33
+ Search the live web.
34
+
35
+ ```sh
36
+ octen search "latest LLM benchmarks" -n 10 --topic news --highlight --time-range 7d
37
+ ```
38
+
39
+ Options: `-n` (result count 1–100), `--topic` (general|news), `--highlight`, `--time-range`, `--start-time`, `--end-time`, `--include-domains`, `--exclude-domains`, `--full-content`, `--images`, `--videos`, `--format` (text|markdown), `--safesearch`.
40
+
41
+ ---
42
+
43
+ ### `octen news`
44
+
45
+ News-focused web search (same flags as `search` minus `--topic`).
46
+
47
+ ```sh
48
+ octen news "OpenAI announcement" --highlight --time-range 1d
49
+ ```
50
+
51
+ ---
52
+
53
+ ### `octen fetch`
54
+
55
+ Extract content from one or more URLs (1–20).
56
+
57
+ ```sh
58
+ octen fetch https://example.com --query "pricing" --max-age 3600 --images
59
+ ```
60
+
61
+ Options: `--query` (relevance hint), `--max-age <sec>` (cache age), `--images`, `--videos`, `--audio`, `--favicon`, `--format` (markdown|text), `--fetch-timeout <sec>`.
62
+
63
+ ---
64
+
65
+ ### `octen chat`
66
+
67
+ Chat completion with optional streaming.
68
+
69
+ ```sh
70
+ octen chat "Summarize the Octen docs" -m octen-r1
71
+ ```
72
+
73
+ 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.
74
+
75
+ Options: `-m/--model`, `--system`, `--web-search` (on|off), `--temperature`, `--top-p`, `--max-tokens`, `--reasoning-effort` (low|medium|high), `--frequency-penalty`, `--presence-penalty`, `--stop`, `--seed`, `--no-stream`, `-i/--interactive`.
76
+
77
+ ---
78
+
79
+ ### `octen embed`
80
+
81
+ Create text embeddings.
82
+
83
+ ```sh
84
+ octen embed "semantic search query" -m 4b
85
+ ```
86
+
87
+ Accepts multiple positional args, `--file <path>` (one text per line), or stdin. Use `--json` (global flag) to print the raw vector array.
88
+
89
+ Options: `-m/--model` (0.6b|4b|8b or full ID), `--dimension`, `--input-type` (query|document), `--truncation`/`--no-truncation`.
90
+
91
+ ---
92
+
93
+ ### `octen vl-embed`
94
+
95
+ Create multimodal embeddings from text, images, and/or video.
96
+
97
+ ```sh
98
+ octen vl-embed "text:a red car" "image:https://example.com/car.jpg" -m base --fusion
99
+ ```
100
+
101
+ Content tokens are prefixed with `text:`, `image:`, or `video:`. Image/video values can be URLs or local file paths.
102
+
103
+ Options: `-m/--model` (base|large or full ID), `--fusion`/`--no-fusion`, `--dimension`, `--fps`, `--instruct`.
104
+
105
+ ---
106
+
107
+ ### `octen configure-mcp`
108
+
109
+ Configure the Octen MCP server in AI clients (merges into existing config, does not clobber).
110
+
111
+ ```sh
112
+ # Configure all supported clients at once
113
+ octen configure-mcp --all
114
+
115
+ # Or pick specific clients
116
+ octen configure-mcp --claude-code --cursor
117
+
118
+ # Pin to a specific octen-mcp version
119
+ octen configure-mcp --all --pin 0.2.1
120
+ ```
121
+
122
+ Supported clients: Claude Code, Claude Desktop, Cursor, Windsurf, VS Code, Codex.
123
+
124
+ Options: `--all`, `--claude-code`, `--cursor`, `--claude-desktop`, `--windsurf`, `--vscode`, `--codex`, `--scope` (user|project), `--pin <version>`.
125
+
126
+ Run without flags to print current status for each client.
127
+
128
+ ---
129
+
130
+ ### `octen configure-skills`
131
+
132
+ Install Octen Agent Skills into AI clients.
133
+
134
+ ```sh
135
+ # Install into all supported clients (fetches latest from upstream)
136
+ octen configure-skills --all
137
+
138
+ # Use bundled skills — no network required
139
+ octen configure-skills --all --offline
140
+
141
+ # Fetch from a specific git ref
142
+ octen configure-skills --claude-code --ref v0.3.0
143
+ ```
144
+
145
+ Supported clients: Claude Code, Cursor, Codex, OpenClaw, Hermes.
146
+
147
+ Options: `--all`, `--claude-code`, `--cursor`, `--codex`, `--openclaw`, `--hermes`, `--scope` (user|project), `--ref <ref>` (default: main), `--bundled`/`--offline` (use vendored skills), `--only <names>` (comma-separated skill names), `--skills-dir <path>` (custom source directory).
148
+
149
+ Run without flags to show installed skills per client.
150
+
151
+ ---
152
+
153
+ ### `octen reset`
154
+
155
+ Remove the Octen MCP server and/or skills from AI clients.
156
+
157
+ ```sh
158
+ # Remove everything from all clients
159
+ octen reset --all
160
+
161
+ # Remove only MCP entries
162
+ octen reset --mcp
163
+
164
+ # Remove only skills from a specific client
165
+ octen reset --skills --claude-code
166
+ ```
167
+
168
+ Options: `--all` (both surfaces, all clients), `--mcp`, `--skills`, plus per-client flags: `--claude-code`, `--cursor`, `--claude-desktop`, `--windsurf`, `--vscode`, `--codex`, `--openclaw`, `--hermes`, `--scope` (user|project).
169
+
170
+ ---
171
+
172
+ ## Output
173
+
174
+ All commands print human-readable output when stdout is a TTY. When stdout is piped or `--json` is passed, commands emit raw JSON. Use `--pretty` to force human-readable output even when piped. `--no-color` disables ANSI colors.
175
+
176
+ ## Keeping things up to date
177
+
178
+ - **MCP server**: `octen-mcp` is invoked via `npx` so it auto-pulls the latest version on each run. Pin a version with `--pin` if you need stability.
179
+ - **Skills**: re-run `octen configure-skills --all` to fetch the latest skills from upstream.
180
+ - **CLI itself**: `npm i -g @octen.ai/cli@latest`
181
+
182
+ ## About
183
+
184
+ `@octen.ai/cli` wraps the Octen API (web search, content extraction, chat completions, text and multimodal embeddings) and handles one-command setup of the [Octen MCP server](https://www.npmjs.com/package/octen-mcp) and Agent Skills across Claude Code (CLI and Desktop app), Cursor, Claude Desktop, Windsurf, VS Code, Codex, OpenClaw, and Hermes.
@@ -0,0 +1,33 @@
1
+ export type ChatMessage = {
2
+ role: "system" | "user" | "assistant";
3
+ content: string;
4
+ };
5
+ /** Non-stream chat completion response. All fields optional — the server is untyped. */
6
+ export interface ChatCompletion {
7
+ choices?: Array<{
8
+ message?: {
9
+ content?: string;
10
+ };
11
+ }>;
12
+ usage?: Record<string, unknown>;
13
+ }
14
+ /** A single SSE stream event from the chat endpoint. */
15
+ export interface StreamEvent {
16
+ choices?: Array<{
17
+ delta?: {
18
+ content?: string;
19
+ };
20
+ }>;
21
+ }
22
+ export interface ChatOpts {
23
+ webSearch?: "on" | "off";
24
+ maxTokens?: number;
25
+ temperature?: number;
26
+ topP?: number;
27
+ frequencyPenalty?: number;
28
+ presencePenalty?: number;
29
+ stop?: string[];
30
+ seed?: number;
31
+ reasoningEffort?: "low" | "medium" | "high";
32
+ }
33
+ export declare function buildChatRequest(messages: ChatMessage[], model: string | undefined, o: ChatOpts): Record<string, unknown>;
@@ -0,0 +1,23 @@
1
+ import { OctenValidationError } from "./errors.js";
2
+ export function buildChatRequest(messages, model, o) {
3
+ if (!model)
4
+ throw new OctenValidationError("model is required (pass --model or set OCTEN_CHAT_MODEL)");
5
+ if (!messages.length)
6
+ throw new OctenValidationError("messages must not be empty");
7
+ const req = { model, messages };
8
+ const put = (k, v) => {
9
+ if (v != null)
10
+ req[k] = v;
11
+ };
12
+ put("web_search", o.webSearch);
13
+ put("max_tokens", o.maxTokens);
14
+ put("temperature", o.temperature);
15
+ put("top_p", o.topP);
16
+ put("frequency_penalty", o.frequencyPenalty);
17
+ put("presence_penalty", o.presencePenalty);
18
+ put("stop", o.stop);
19
+ put("seed", o.seed);
20
+ if (o.reasoningEffort != null)
21
+ req["reasoning"] = { effort: o.reasoningEffort };
22
+ return req;
23
+ }
@@ -0,0 +1,19 @@
1
+ export interface OctenClientOptions {
2
+ apiKey: string;
3
+ baseUrl?: string;
4
+ timeoutMs?: number;
5
+ maxRetries?: number;
6
+ retryBaseMs?: number;
7
+ }
8
+ export declare class OctenClient {
9
+ private apiKey;
10
+ private baseUrl;
11
+ private timeoutMs;
12
+ private maxRetries;
13
+ private retryBaseMs;
14
+ constructor(opts: OctenClientOptions);
15
+ private headers;
16
+ request<T = unknown>(endpoint: string, body: unknown, timeoutMs?: number): Promise<T>;
17
+ /** Returns the raw Response for SSE streaming (chat). */
18
+ stream(endpoint: string, body: Record<string, unknown>, timeoutMs?: number): Promise<Response>;
19
+ }
@@ -0,0 +1,111 @@
1
+ import { DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT_MS, ENDPOINTS } from "./constants.js";
2
+ import { OctenAPIError, OctenAuthError, OctenTimeoutError } from "./errors.js";
3
+ const RETRYABLE = new Set([429, 500, 502, 503, 504]);
4
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
5
+ export class OctenClient {
6
+ apiKey;
7
+ baseUrl;
8
+ timeoutMs;
9
+ maxRetries;
10
+ retryBaseMs;
11
+ constructor(opts) {
12
+ if (!opts.apiKey)
13
+ throw new OctenAuthError("API key is required");
14
+ this.apiKey = opts.apiKey;
15
+ this.baseUrl = (opts.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, "");
16
+ this.timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
17
+ this.maxRetries = opts.maxRetries ?? DEFAULT_MAX_RETRIES;
18
+ this.retryBaseMs = opts.retryBaseMs ?? 500;
19
+ }
20
+ headers(endpoint) {
21
+ // Chat uses the OpenAI-compatible /v1/chat/completions surface (Authorization: Bearer); native Octen endpoints use x-api-key.
22
+ const h = { "Content-Type": "application/json" };
23
+ if (endpoint === ENDPOINTS.chat)
24
+ h["Authorization"] = `Bearer ${this.apiKey}`;
25
+ else
26
+ h["x-api-key"] = this.apiKey;
27
+ return h;
28
+ }
29
+ async request(endpoint, body, timeoutMs) {
30
+ // Retry policy: retry only on 429/5xx with exponential backoff; 4xx (except 429) and timeouts are NOT retried; the timeout is per-attempt, not total.
31
+ let lastErr;
32
+ for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
33
+ const ac = new AbortController();
34
+ const t = setTimeout(() => ac.abort(), timeoutMs ?? this.timeoutMs);
35
+ try {
36
+ const res = await fetch(`${this.baseUrl}${endpoint}`, {
37
+ method: "POST",
38
+ headers: this.headers(endpoint),
39
+ body: JSON.stringify(body),
40
+ signal: ac.signal,
41
+ });
42
+ if (res.ok) {
43
+ try {
44
+ return (await res.json());
45
+ }
46
+ catch {
47
+ throw new OctenAPIError("API returned a 2xx response with an invalid JSON body", res.status);
48
+ }
49
+ }
50
+ const rawText = await res.text().catch(() => "");
51
+ let errBody = {};
52
+ try {
53
+ errBody = rawText ? JSON.parse(rawText) : {};
54
+ }
55
+ catch { /* keep raw text */ }
56
+ const msg = errBody?.msg ?? errBody?.error ?? (rawText ? rawText.slice(0, 500) : `HTTP ${res.status}`);
57
+ if (RETRYABLE.has(res.status) && attempt < this.maxRetries) {
58
+ await sleep(this.retryBaseMs * 2 ** attempt);
59
+ continue;
60
+ }
61
+ if (res.status === 401)
62
+ throw new OctenAuthError(msg);
63
+ throw new OctenAPIError(msg, res.status, errBody);
64
+ }
65
+ catch (e) {
66
+ if (e instanceof OctenAPIError || e instanceof OctenAuthError)
67
+ throw e;
68
+ if (e.name === "AbortError")
69
+ throw new OctenTimeoutError("request timed out");
70
+ lastErr = e;
71
+ if (attempt < this.maxRetries) {
72
+ await sleep(this.retryBaseMs * 2 ** attempt);
73
+ continue;
74
+ }
75
+ throw lastErr;
76
+ }
77
+ finally {
78
+ clearTimeout(t);
79
+ }
80
+ }
81
+ throw lastErr;
82
+ }
83
+ /** Returns the raw Response for SSE streaming (chat). */
84
+ async stream(endpoint, body, timeoutMs) {
85
+ const ac = new AbortController();
86
+ const ms = timeoutMs ?? this.timeoutMs;
87
+ const t = ms ? setTimeout(() => ac.abort(), ms) : undefined;
88
+ try {
89
+ const res = await fetch(`${this.baseUrl}${endpoint}`, {
90
+ method: "POST",
91
+ headers: this.headers(endpoint),
92
+ body: JSON.stringify({ ...body, stream: true }),
93
+ signal: ac.signal,
94
+ });
95
+ if (!res.ok) {
96
+ const rawText = await res.text().catch(() => "");
97
+ let errBody = {};
98
+ try {
99
+ errBody = rawText ? JSON.parse(rawText) : {};
100
+ }
101
+ catch { /* keep raw text */ }
102
+ const msg = errBody?.msg ?? errBody?.error ?? (rawText ? rawText.slice(0, 500) : `HTTP ${res.status}`);
103
+ throw new OctenAPIError(msg, res.status, errBody);
104
+ }
105
+ return res;
106
+ }
107
+ finally {
108
+ clearTimeout(t);
109
+ }
110
+ }
111
+ }
@@ -0,0 +1,38 @@
1
+ export declare const DEFAULT_BASE_URL = "https://api.octen.ai";
2
+ export declare const DEFAULT_TIMEOUT_MS = 30000;
3
+ export declare const DEFAULT_MAX_RETRIES = 3;
4
+ export declare const ENDPOINTS: {
5
+ readonly search: "/search";
6
+ readonly extract: "/extract";
7
+ readonly embedding: "/embedding";
8
+ readonly vlEmbedding: "/vl-embedding";
9
+ readonly chat: "/v1/chat/completions";
10
+ };
11
+ export declare const EMBEDDING_MODELS: Record<string, string>;
12
+ export declare const VL_EMBEDDING_MODELS: Record<string, string>;
13
+ export declare const LIMITS: {
14
+ readonly searchCount: {
15
+ readonly min: 1;
16
+ readonly max: 100;
17
+ };
18
+ readonly includeText: 5;
19
+ readonly excludeText: 5;
20
+ readonly extractUrls: {
21
+ readonly min: 1;
22
+ readonly max: 20;
23
+ };
24
+ readonly extractTimeout: {
25
+ readonly min: 1;
26
+ readonly max: 60;
27
+ };
28
+ readonly cacheWindow: {
29
+ readonly min: 300;
30
+ readonly max: 31536000;
31
+ readonly default: 86400;
32
+ };
33
+ readonly vlContents: 20;
34
+ readonly vlImages: 5;
35
+ readonly vlVideos: 1;
36
+ };
37
+ export declare const SKILLS_REPO = "Octen-Team/octen-skills";
38
+ export declare const SKILLS_REPO_TARBALL: (ref: string) => string;
@@ -0,0 +1,32 @@
1
+ export const DEFAULT_BASE_URL = "https://api.octen.ai";
2
+ export const DEFAULT_TIMEOUT_MS = 30_000;
3
+ export const DEFAULT_MAX_RETRIES = 3;
4
+ export const ENDPOINTS = {
5
+ search: "/search",
6
+ extract: "/extract",
7
+ embedding: "/embedding",
8
+ vlEmbedding: "/vl-embedding",
9
+ chat: "/v1/chat/completions",
10
+ };
11
+ export const EMBEDDING_MODELS = {
12
+ "0.6b": "octen-embedding-0.6b",
13
+ "4b": "octen-embedding-4b",
14
+ "8b": "octen-embedding-8b",
15
+ };
16
+ export const VL_EMBEDDING_MODELS = {
17
+ base: "octen-vl-embedding",
18
+ large: "octen-vl-embedding-large",
19
+ };
20
+ export const LIMITS = {
21
+ searchCount: { min: 1, max: 100 },
22
+ includeText: 5,
23
+ excludeText: 5,
24
+ extractUrls: { min: 1, max: 20 },
25
+ extractTimeout: { min: 1, max: 60 },
26
+ cacheWindow: { min: 300, max: 31_536_000, default: 86_400 },
27
+ vlContents: 20,
28
+ vlImages: 5,
29
+ vlVideos: 1,
30
+ };
31
+ export const SKILLS_REPO = "Octen-Team/octen-skills";
32
+ export const SKILLS_REPO_TARBALL = (ref) => `https://github.com/${SKILLS_REPO}/archive/${ref}.tar.gz`;
@@ -0,0 +1,18 @@
1
+ /** A single embedding item. All fields optional — the server is untyped. */
2
+ export interface EmbeddingItem {
3
+ embedding?: number[];
4
+ vector?: number[];
5
+ }
6
+ /** Response shape for the /embedding endpoint. */
7
+ export interface EmbeddingResponse {
8
+ model?: string;
9
+ data?: EmbeddingItem[];
10
+ embeddings?: (number[] | EmbeddingItem)[];
11
+ }
12
+ export interface EmbeddingOpts {
13
+ model?: string;
14
+ dimension?: number;
15
+ inputType?: "query" | "document";
16
+ truncation?: boolean;
17
+ }
18
+ export declare function buildEmbeddingRequest(input: string | string[], o: EmbeddingOpts): Record<string, unknown>;
@@ -0,0 +1,27 @@
1
+ import { EMBEDDING_MODELS } from "./constants.js";
2
+ import { OctenValidationError } from "./errors.js";
3
+ export function buildEmbeddingRequest(input, o) {
4
+ // Validate: empty string or empty array both count as no input
5
+ if (input === "" || (Array.isArray(input) && input.length === 0)) {
6
+ throw new OctenValidationError("input is required");
7
+ }
8
+ // Resolve model: map shortcut aliases (e.g. "4b" → "octen-embedding-4b");
9
+ // full ids and unknown values pass through unchanged.
10
+ const model = o.model != null ? (EMBEDDING_MODELS[o.model] ?? o.model) : undefined;
11
+ // The /embedding endpoint requires `input` to be an array — a bare string
12
+ // returns 400 "Invalid params" — so always send an array (single or batch).
13
+ const req = { input: Array.isArray(input) ? input : [input] };
14
+ // Use `put` for optional fields that are null/undefined when absent.
15
+ const put = (k, v) => {
16
+ if (v != null)
17
+ req[k] = v;
18
+ };
19
+ put("model", model);
20
+ put("dimension", o.dimension);
21
+ put("input_type", o.inputType);
22
+ // truncation is tri-state: forward an explicit true/false, omit when undefined.
23
+ if (o.truncation !== undefined) {
24
+ req["truncation"] = o.truncation;
25
+ }
26
+ return req;
27
+ }
@@ -0,0 +1,14 @@
1
+ export declare class OctenError extends Error {
2
+ }
3
+ export declare class OctenAuthError extends OctenError {
4
+ }
5
+ export declare class OctenValidationError extends OctenError {
6
+ }
7
+ export declare class OctenTimeoutError extends OctenError {
8
+ }
9
+ export declare class OctenAPIError extends OctenError {
10
+ status: number;
11
+ body?: unknown | undefined;
12
+ constructor(message: string, status: number, body?: unknown | undefined);
13
+ }
14
+ export declare function exitCodeFor(err: unknown): number;
@@ -0,0 +1,22 @@
1
+ export class OctenError extends Error {
2
+ }
3
+ export class OctenAuthError extends OctenError {
4
+ }
5
+ export class OctenValidationError extends OctenError {
6
+ }
7
+ export class OctenTimeoutError extends OctenError {
8
+ }
9
+ export class OctenAPIError extends OctenError {
10
+ status;
11
+ body;
12
+ constructor(message, status, body) {
13
+ super(message);
14
+ this.status = status;
15
+ this.body = body;
16
+ }
17
+ }
18
+ export function exitCodeFor(err) {
19
+ if (err instanceof OctenAuthError || err instanceof OctenValidationError)
20
+ return 2;
21
+ return 1;
22
+ }
@@ -0,0 +1,34 @@
1
+ /** A single extracted item. All fields optional — the server is untyped. */
2
+ export interface ExtractItem {
3
+ url?: string;
4
+ status?: string;
5
+ title?: string;
6
+ category?: {
7
+ primary?: string;
8
+ secondary?: string;
9
+ };
10
+ page_structure?: {
11
+ primary?: string;
12
+ secondary?: string;
13
+ };
14
+ time_published?: string;
15
+ full_content?: string;
16
+ highlights?: string[];
17
+ error_message?: string;
18
+ }
19
+ /** Response shape for the /extract endpoint. */
20
+ export interface ExtractResponse {
21
+ items?: ExtractItem[];
22
+ results?: ExtractItem[];
23
+ }
24
+ export interface ExtractOpts {
25
+ query?: string;
26
+ maxAge?: number;
27
+ format?: "markdown" | "text";
28
+ fetchTimeout?: number;
29
+ images?: boolean;
30
+ videos?: boolean;
31
+ audio?: boolean;
32
+ favicon?: boolean;
33
+ }
34
+ export declare function buildExtractRequest(urls: string[], o: ExtractOpts): Record<string, unknown>;
@@ -0,0 +1,26 @@
1
+ import { LIMITS } from "./constants.js";
2
+ import { OctenValidationError } from "./errors.js";
3
+ export function buildExtractRequest(urls, o) {
4
+ if (urls.length < LIMITS.extractUrls.min || urls.length > LIMITS.extractUrls.max)
5
+ throw new OctenValidationError(`urls must be ${LIMITS.extractUrls.min}-${LIMITS.extractUrls.max} items`);
6
+ if (o.fetchTimeout != null && (o.fetchTimeout < LIMITS.extractTimeout.min || o.fetchTimeout > LIMITS.extractTimeout.max))
7
+ throw new OctenValidationError(`fetch-timeout must be ${LIMITS.extractTimeout.min}-${LIMITS.extractTimeout.max}`);
8
+ // Auto-prefix bare hosts
9
+ const normalizedUrls = urls.map((u) => (u.includes("://") ? u : `https://${u}`));
10
+ // Clamp maxAge
11
+ const maxAge = o.maxAge != null
12
+ ? Math.min(LIMITS.cacheWindow.max, Math.max(LIMITS.cacheWindow.min, o.maxAge))
13
+ : undefined;
14
+ const req = { urls: normalizedUrls };
15
+ const put = (k, v) => { if (v != null)
16
+ req[k] = v; };
17
+ put("query", o.query);
18
+ put("max_age_seconds", maxAge);
19
+ put("format", o.format);
20
+ put("timeout", o.fetchTimeout);
21
+ put("include_images", o.images);
22
+ put("include_videos", o.videos);
23
+ put("include_audio", o.audio);
24
+ put("include_favicon", o.favicon);
25
+ return req;
26
+ }
@@ -0,0 +1,33 @@
1
+ /** A single search result. All fields optional — the server is untyped. */
2
+ export interface SearchResult {
3
+ title?: string;
4
+ url?: string;
5
+ highlight?: string;
6
+ full_content?: string;
7
+ time_published?: string;
8
+ }
9
+ /** Response shape for the /search endpoint. */
10
+ export interface SearchResponse {
11
+ results?: SearchResult[];
12
+ }
13
+ export interface SearchOpts {
14
+ topic?: "general" | "news";
15
+ count?: number;
16
+ includeDomains?: string[];
17
+ excludeDomains?: string[];
18
+ includeText?: string[];
19
+ excludeText?: string[];
20
+ timeBasis?: "auto" | "published" | "crawled";
21
+ timeRange?: string;
22
+ startTime?: string;
23
+ endTime?: string;
24
+ format?: "text" | "markdown";
25
+ safesearch?: "off" | "strict";
26
+ highlight?: boolean;
27
+ highlightMaxTokens?: number;
28
+ fullContent?: boolean;
29
+ fullContentMaxTokens?: number;
30
+ images?: boolean;
31
+ videos?: boolean;
32
+ }
33
+ export declare function buildSearchRequest(query: string, o: SearchOpts): Record<string, unknown>;