@octen.ai/cli 0.1.0 → 0.1.2

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.
@@ -16,11 +16,12 @@ export function registerFetch(program) {
16
16
  .option("--videos", "include videos")
17
17
  .option("--audio", "include audio")
18
18
  .option("--favicon", "include favicon")
19
+ .option("--full", "print full page content untruncated (pretty mode)")
19
20
  .action(async (urls, opts, command) => {
20
21
  const g = command.optsWithGlobals();
21
22
  const client = makeClient(g);
22
23
  const req = buildExtractRequest(urls, opts);
23
24
  const res = await client.request(ENDPOINTS.extract, req);
24
- emit(res, chooseMode(g, process.stdout.isTTY ?? false), renderExtract);
25
+ emit(res, chooseMode(g, process.stdout.isTTY ?? false), (d) => renderExtract(d, opts.full));
25
26
  });
26
27
  }
@@ -5,7 +5,7 @@ import { renderSearch } from "../output/pretty/search.js";
5
5
  import { makeClient, parseIntOpt } from "./utils.js";
6
6
  export function registerSearch(program, fixedTopic) {
7
7
  const cmd = program.command(fixedTopic ?? "search")
8
- .argument("<query>", "search query")
8
+ .argument("<query...>", "search query")
9
9
  .description(fixedTopic ? "News-focused web search" : "Search the live web")
10
10
  .option("-n, --count <n>", "results 1-100", parseIntOpt("--count"))
11
11
  .option("--include-domains <list>", "comma list", (v) => v.split(","))
@@ -20,9 +20,10 @@ export function registerSearch(program, fixedTopic) {
20
20
  .option("--images").option("--videos");
21
21
  if (!fixedTopic)
22
22
  cmd.option("--topic <t>", "general|news");
23
- cmd.action(async (query, opts, command) => {
23
+ cmd.action(async (queryArg, opts, command) => {
24
24
  const g = command.optsWithGlobals();
25
25
  const client = makeClient(g);
26
+ const query = Array.isArray(queryArg) ? queryArg.join(" ") : queryArg;
26
27
  const searchOpts = { ...opts, topic: fixedTopic ?? opts.topic };
27
28
  const req = buildSearchRequest(query, searchOpts);
28
29
  const res = await client.request(ENDPOINTS.search, req);
@@ -1,11 +1,12 @@
1
- import type { EmbeddingResponse } from "../../api/embedding.js";
2
1
  /**
3
2
  * Render an OpenAI-style /embedding response in a compact table.
4
- * The response shape is handled robustly:
5
- * - vectors at data.data ?? data.embeddings ?? []
3
+ *
4
+ * The Octen API wraps the payload in an envelope: { data: { results }, code, msg, ... }.
5
+ * We unwrap to the inner body when present, then handle the shape robustly:
6
+ * - vectors at body.results ?? body.data ?? body.embeddings ?? []
6
7
  * - each item's vector at item.embedding ?? item.vector ?? item (item may itself be the array)
7
- * - model at data.model
8
+ * - model at body.model ?? data.model
8
9
  *
9
10
  * Raw float arrays are never printed in pretty mode.
10
11
  */
11
- export declare function renderEmbedding(data: EmbeddingResponse): string;
12
+ export declare function renderEmbedding(data: any): string;
@@ -1,19 +1,28 @@
1
1
  import pc from "picocolors";
2
2
  /**
3
3
  * Render an OpenAI-style /embedding response in a compact table.
4
- * The response shape is handled robustly:
5
- * - vectors at data.data ?? data.embeddings ?? []
4
+ *
5
+ * The Octen API wraps the payload in an envelope: { data: { results }, code, msg, ... }.
6
+ * We unwrap to the inner body when present, then handle the shape robustly:
7
+ * - vectors at body.results ?? body.data ?? body.embeddings ?? []
6
8
  * - each item's vector at item.embedding ?? item.vector ?? item (item may itself be the array)
7
- * - model at data.model
9
+ * - model at body.model ?? data.model
8
10
  *
9
11
  * Raw float arrays are never printed in pretty mode.
10
12
  */
11
13
  export function renderEmbedding(data) {
12
- const items = (data?.data ?? data?.embeddings ?? []);
14
+ // Unwrap the envelope only when `data.data` is a non-array object (the real
15
+ // API shape). When `data.data` is itself an array (legacy un-enveloped shape),
16
+ // keep `data` as-is so the `?? data` fallback paths below still work.
17
+ const inner = data?.data;
18
+ const body = data && typeof data === "object" && inner && typeof inner === "object" && !Array.isArray(inner)
19
+ ? inner
20
+ : data;
21
+ const items = (body?.results ?? body?.data ?? body?.embeddings ?? []);
13
22
  if (!items.length) {
14
23
  return pc.dim("No embeddings returned.");
15
24
  }
16
- const model = data?.model;
25
+ const model = body?.model ?? data?.model;
17
26
  const lines = [];
18
27
  // Header
19
28
  const modelLabel = model ? pc.dim(` (${model})`) : "";
@@ -1,2 +1 @@
1
- import type { ExtractResponse } from "../../api/extract.js";
2
- export declare function renderExtract(data: ExtractResponse): string;
1
+ export declare function renderExtract(data: any, full?: boolean): string;
@@ -1,11 +1,25 @@
1
1
  import pc from "picocolors";
2
2
  const MAX_CONTENT = 500;
3
- export function renderExtract(data) {
4
- const items = data?.items ??
5
- data?.results ??
3
+ export function renderExtract(data, full = false) {
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 items = body?.items ??
12
+ body?.results ??
6
13
  [];
7
- if (!items.length)
14
+ if (!items.length) {
15
+ // Surface app-level API errors (non-zero code) instead of a bland "No results."
16
+ const code = data?.code;
17
+ const msg = data?.msg;
18
+ if (code != null && code !== 0 && msg) {
19
+ return pc.red(`error: ${msg}`);
20
+ }
8
21
  return pc.dim("No results.");
22
+ }
9
23
  return items
10
24
  .map((item) => {
11
25
  const lines = [];
@@ -31,7 +45,7 @@ export function renderExtract(data) {
31
45
  }
32
46
  else if (item.full_content) {
33
47
  const raw = item.full_content;
34
- const snippet = raw.length > MAX_CONTENT ? raw.slice(0, MAX_CONTENT) + "…" : raw;
48
+ const snippet = !full && raw.length > MAX_CONTENT ? raw.slice(0, MAX_CONTENT) + "…" : raw;
35
49
  lines.push(` ${snippet}`);
36
50
  }
37
51
  }
@@ -1,2 +1 @@
1
- import type { SearchResponse } from "../../api/search.js";
2
- export declare function renderSearch(data: SearchResponse): string;
1
+ export declare function renderSearch(data: any): string;
@@ -1,9 +1,23 @@
1
1
  import pc from "picocolors";
2
2
  const MAX_SNIPPET = 300;
3
3
  export function renderSearch(data) {
4
- const res = data?.results ?? [];
5
- if (!res.length)
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
+ }
6
19
  return pc.dim("No results.");
20
+ }
7
21
  return res
8
22
  .map((r, i) => {
9
23
  const lines = [];
@@ -1,13 +1,13 @@
1
- import type { VLEmbeddingResponse } from "../../api/vlEmbedding.js";
2
1
  /**
3
2
  * Render an Octen /vl-embedding response in a compact table.
4
3
  *
5
- * Response shape is handled robustly:
6
- * - item list at data.data ?? data.embeddings ?? data.items ?? []
4
+ * The Octen API wraps the payload in an envelope: { data: { results }, code, msg, ... }.
5
+ * We unwrap to the inner body when present, then handle the shape robustly:
6
+ * - item list at body.results ?? body.data ?? body.embeddings ?? body.items ?? []
7
7
  * - each item's vector at item.embedding ?? item.vector ?? item (bare array)
8
8
  * - item type label at item.type (e.g. "fusion" | "vl") when present
9
- * - model from data.model
9
+ * - model from body.model ?? data.model
10
10
  *
11
11
  * Raw float arrays are never printed — use --json for those.
12
12
  */
13
- export declare function renderVlEmbedding(data: VLEmbeddingResponse): string;
13
+ export declare function renderVlEmbedding(data: any): string;
@@ -2,20 +2,28 @@ import pc from "picocolors";
2
2
  /**
3
3
  * Render an Octen /vl-embedding response in a compact table.
4
4
  *
5
- * Response shape is handled robustly:
6
- * - item list at data.data ?? data.embeddings ?? data.items ?? []
5
+ * The Octen API wraps the payload in an envelope: { data: { results }, code, msg, ... }.
6
+ * We unwrap to the inner body when present, then handle the shape robustly:
7
+ * - item list at body.results ?? body.data ?? body.embeddings ?? body.items ?? []
7
8
  * - each item's vector at item.embedding ?? item.vector ?? item (bare array)
8
9
  * - item type label at item.type (e.g. "fusion" | "vl") when present
9
- * - model from data.model
10
+ * - model from body.model ?? data.model
10
11
  *
11
12
  * Raw float arrays are never printed — use --json for those.
12
13
  */
13
14
  export function renderVlEmbedding(data) {
14
- const items = (data?.data ?? data?.embeddings ?? data?.items ?? []);
15
+ // Unwrap the envelope only when `data.data` is a non-array object (the real
16
+ // API shape). When `data.data` is itself an array (legacy un-enveloped shape),
17
+ // keep `data` as-is so the `?? data` fallback paths below still work.
18
+ const inner = data?.data;
19
+ const body = data && typeof data === "object" && inner && typeof inner === "object" && !Array.isArray(inner)
20
+ ? inner
21
+ : data;
22
+ const items = (body?.results ?? body?.data ?? body?.embeddings ?? body?.items ?? []);
15
23
  if (!items.length) {
16
24
  return pc.dim("No embeddings returned.");
17
25
  }
18
- const model = data?.model;
26
+ const model = body?.model ?? data?.model;
19
27
  const modelLabel = model ? pc.dim(` (${model})`) : "";
20
28
  const lines = [];
21
29
  // Header
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octen.ai/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Command-line tool for Octen — web search, extract, chat, embeddings, and one-command MCP/Skills setup.",
5
5
  "type": "module",
6
6
  "license": "MIT",