@thothdev/pink 1.0.16 → 1.0.27

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.
@@ -133,9 +133,33 @@ export function parseDuckDuckGo(html, limit = 8) {
133
133
  return results;
134
134
  }
135
135
 
136
+ // wigolo (servidor de busca que a pessoa roda na própria máquina, vários buscadores, sem chave): usado só quando já está no ar
137
+ export const WIGOLO_URL = "http://127.0.0.1:3333/v1/search";
138
+
139
+ // null = sem wigolo, resposta que não é dele ou sem resultado: quem chama cai no DuckDuckGo
140
+ async function wigoloSearch(query, { fetchImpl, signal, timeoutMs }) {
141
+ try {
142
+ const res = await fetchImpl(WIGOLO_URL, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ query, max_results: 8 }), redirect: "manual", signal: signalFor(signal, timeoutMs) });
143
+ if (!res.ok) return null;
144
+ const found = JSON.parse((await readCapped(res)).text)?.results;
145
+ if (!Array.isArray(found)) return null;
146
+ const line = (s, max) => String(s ?? "").replace(/\s+/g, " ").trim().slice(0, max);
147
+ const results = found.filter((r) => /^https?:\/\//i.test(r?.url ?? "") && r?.title).slice(0, 8)
148
+ .map((r) => ({ title: line(r.title, 200), url: line(r.url, 2000), snippet: line(r.snippet || r.excerpt, 400) }));
149
+ return results.length ? results : null;
150
+ } catch { return null; }
151
+ }
152
+
153
+ const searchAnswer = (query, results, engine) => {
154
+ const text = `${OUTSIDE}\nBusca: ${query}\n\n${results.map((r, i) => `${i + 1}. ${r.title}\n ${r.url}${r.snippet ? `\n ${r.snippet}` : ""}`).join("\n")}`;
155
+ return { content: [{ type: "text", text }], details: { ok: true, query, engine, results } };
156
+ };
157
+
136
158
  export async function webSearch(query, { fetchImpl = fetch, signal, timeoutMs = FETCH_TIMEOUT_MS } = {}) {
137
159
  const q = String(query ?? "").trim();
138
160
  if (!q) return fail(t("Busca vazia", "Búsqueda vacía", "Empty search"));
161
+ const local = await wigoloSearch(q, { fetchImpl, signal, timeoutMs });
162
+ if (local) return searchAnswer(q, local, "wigolo");
139
163
  let res, html;
140
164
  try {
141
165
  res = await fetchImpl(`https://html.duckduckgo.com/html/?q=${encodeURIComponent(q)}`, { headers: { "user-agent": UA }, signal: signalFor(signal, timeoutMs) });
@@ -144,8 +168,7 @@ export async function webSearch(query, { fetchImpl = fetch, signal, timeoutMs =
144
168
  if (!res.ok) return fail(t(`O buscador respondeu ${res.status}; tente de novo mais tarde ou abra uma página conhecida com web_fetch`, `El buscador respondió ${res.status}; intenta de nuevo más tarde o abre una página conocida con web_fetch`, `The search engine responded ${res.status}; try again later or open a known page with web_fetch`));
145
169
  const results = parseDuckDuckGo(html);
146
170
  if (!results.length) return fail(/anomaly|captcha|challenge/i.test(html) ? t("O buscador pediu verificação de robô; abra uma página conhecida com web_fetch", "El buscador pidió verificación de robot; abre una página conocida con web_fetch", "The search engine asked for a robot check; open a known page with web_fetch") : t(`Nenhum resultado para: ${q}`, `Ningún resultado para: ${q}`, `No results for: ${q}`));
147
- const text = `${OUTSIDE}\nBusca: ${q}\n\n${results.map((r, i) => `${i + 1}. ${r.title}\n ${r.url}${r.snippet ? `\n ${r.snippet}` : ""}`).join("\n")}`;
148
- return { content: [{ type: "text", text }], details: { ok: true, query: q, results } };
171
+ return searchAnswer(q, results, "duckduckgo");
149
172
  }
150
173
 
151
174
  export function webExtension(pink, deps = {}) {
@@ -162,7 +185,7 @@ export function webExtension(pink, deps = {}) {
162
185
  pink.registerTool({
163
186
  name: "web_search",
164
187
  label: t("Buscar na web", "Buscar en la web", "Search the web"),
165
- description: "Search the web (DuckDuckGo, no key) and return titles, links and snippets. Use web_fetch to read a result.",
188
+ description: "Search the web (the local wigolo server when running, else DuckDuckGo; no key) and return titles, links and snippets. Use web_fetch to read a result.",
166
189
  parameters: one("query", "What to search for"),
167
190
  exposure: "codemode",
168
191
  annotations,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@thothdev/pink",
3
- "version": "1.0.16",
4
- "description": "Pink: coding agent of the Thoth project, with a pink theme",
3
+ "version": "1.0.27",
4
+ "description": "Open-source AI coding agent for the terminal that also drives Claude Code, Codex, OpenCode and other agents, with parallel sessions, visible plan and changes, and real undo.",
5
5
  "type": "module",
6
6
  "piConfig": {
7
7
  "name": "pink",
@@ -84,12 +84,24 @@
84
84
  "vitest": "4.1.11"
85
85
  },
86
86
  "keywords": [
87
- "coding-agent",
88
87
  "ai",
88
+ "ai-agent",
89
+ "ai-coding",
90
+ "coding-agent",
91
+ "coding-assistant",
92
+ "agentic-ai",
89
93
  "llm",
90
94
  "cli",
91
95
  "tui",
92
- "agent"
96
+ "terminal",
97
+ "developer-tools",
98
+ "claude-code",
99
+ "codex",
100
+ "opencode",
101
+ "gemini",
102
+ "qwen",
103
+ "mcp",
104
+ "multi-agent"
93
105
  ],
94
106
  "author": "Mario Zechner",
95
107
  "license": "MIT",