@tiens.nguyen/gu-cli 1.0.719 → 1.0.721

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.
@@ -0,0 +1,36 @@
1
+ /**
2
+ * "Is that an Ollama SERVER?" — the input check behind /embed-model's server prompt (task #169).
3
+ *
4
+ * WHY A SEPARATE FILE OF ONE FUNCTION. The embed picker asks for a URL and its retry line is
5
+ * `"<typed>" is <why> — try host:port, e.g. 127.0.0.1:11434`, so the reason HAS to be a phrase
6
+ * that finishes that sentence. Keeping the check next to its words is what stops a future edit
7
+ * from returning a full sentence and printing "is The URL must not...".
8
+ *
9
+ * WHAT "OLLAMA-SHAPED" MEANS HERE. The python worker takes the saved root and appends
10
+ * /v1/embeddings, then /api/embed, then /api/embeddings itself (gonext_agent_chat._embed).
11
+ * Anything already carrying a path (/v1, /api/tags, someone pasting a dashboard link) would be
12
+ * saved as-is and every suffix would 404 — so a path is a reason to ask AGAIN, not to strip
13
+ * silently. Stripping hides the mistake; the retry teaches the shape.
14
+ *
15
+ * The vocabulary mirrors agent-model-command.ollamaAgentUrl ("not a URL", "not http(s)",
16
+ * "no host") so the agent and embed prompts read the same when they fail the same way.
17
+ *
18
+ * Returns { ok: true } or { ok: false, why }.
19
+ */
20
+ export function checkOllamaHostInput(url) {
21
+ const v = String(url ?? "").trim();
22
+ if (!v) return { ok: false, why: "empty" };
23
+ let u;
24
+ try {
25
+ u = new URL(v);
26
+ } catch {
27
+ return { ok: false, why: "not a URL" };
28
+ }
29
+ if (u.protocol !== "http:" && u.protocol !== "https:") return { ok: false, why: "not http(s)" };
30
+ if (!u.hostname) return { ok: false, why: "no host" };
31
+ if (u.username || u.password) return { ok: false, why: "carrying credentials — keys go in the key prompt" };
32
+ const path = u.pathname.replace(/\/+$/, "");
33
+ if (path) return { ok: false, why: `carrying "${path}" — I need just the server root` };
34
+ if (u.search || u.hash) return { ok: false, why: "carrying a query — I need just the server root" };
35
+ return { ok: true };
36
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiens.nguyen/gu-cli",
3
- "version": "1.0.719",
3
+ "version": "1.0.721",
4
4
  "description": "Gu CLI — the gu terminal plus the local worker that runs agent / OCR / PDF / embedding jobs on your Mac (Ollama / MLX / OpenAI-compatible).",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -73,6 +73,7 @@
73
73
  "first-run-steps.mjs",
74
74
  "proxy-config.mjs",
75
75
  "agent-model-command.mjs",
76
+ "ollama-host-snippets.mjs",
76
77
  "ollama-setup.mjs",
77
78
  "s3-setup.mjs",
78
79
  "doctor-check.mjs",