@sisu-ai/tool-wikipedia 8.0.1 → 8.0.3

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 CHANGED
@@ -1,3 +1,9 @@
1
+ <div align="right">
2
+ <a href="https://github.com/finger-gun/sisu"><img src="https://github.com/finger-gun/sisu/raw/main/sisu-light.svg" alt="ProjectSpecs" width="100" /></a>
3
+ </div>
4
+
5
+ ---
6
+
1
7
  # @sisu-ai/tool-wikipedia
2
8
 
3
9
  Wikipedia lookup tool using the REST API. Fetch a page summary, HTML, or related pages given an approximate title. The REST API performs redirects and normalization, so near-matches often resolve.
@@ -55,3 +61,78 @@ Discover what you can do through examples or documentation. Check it out at http
55
61
  - [License](https://github.com/finger-gun/sisu/blob/main/LICENSE)
56
62
  - [Report a Bug](https://github.com/finger-gun/sisu/issues/new?template=bug_report.md)
57
63
  - [Request a Feature](https://github.com/finger-gun/sisu/issues/new?template=feature_request.md)
64
+
65
+ ---
66
+
67
+ ## Documentation
68
+
69
+ **Core** — [Package docs](packages/core/README.md) · [Error types](packages/core/ERROR_TYPES.md)
70
+
71
+ **Adapters** — [OpenAI](packages/adapters/openai/README.md) · [Anthropic](packages/adapters/anthropic/README.md) · [Ollama](packages/adapters/ollama/README.md)
72
+
73
+ <details>
74
+ <summary>All middleware packages</summary>
75
+
76
+ - [@sisu-ai/mw-agent-run-api](packages/middleware/agent-run-api/README.md)
77
+ - [@sisu-ai/mw-context-compressor](packages/middleware/context-compressor/README.md)
78
+ - [@sisu-ai/mw-control-flow](packages/middleware/control-flow/README.md)
79
+ - [@sisu-ai/mw-conversation-buffer](packages/middleware/conversation-buffer/README.md)
80
+ - [@sisu-ai/mw-cors](packages/middleware/cors/README.md)
81
+ - [@sisu-ai/mw-error-boundary](packages/middleware/error-boundary/README.md)
82
+ - [@sisu-ai/mw-guardrails](packages/middleware/guardrails/README.md)
83
+ - [@sisu-ai/mw-invariants](packages/middleware/invariants/README.md)
84
+ - [@sisu-ai/mw-orchestration](packages/middleware/orchestration/README.md)
85
+ - [@sisu-ai/mw-rag](packages/middleware/rag/README.md)
86
+ - [@sisu-ai/mw-react-parser](packages/middleware/react-parser/README.md)
87
+ - [@sisu-ai/mw-register-tools](packages/middleware/register-tools/README.md)
88
+ - [@sisu-ai/mw-tool-calling](packages/middleware/tool-calling/README.md)
89
+ - [@sisu-ai/mw-trace-viewer](packages/middleware/trace-viewer/README.md)
90
+ - [@sisu-ai/mw-usage-tracker](packages/middleware/usage-tracker/README.md)
91
+ </details>
92
+
93
+ <details>
94
+ <summary>All tool packages</summary>
95
+
96
+ - [@sisu-ai/tool-aws-s3](packages/tools/aws-s3/README.md)
97
+ - [@sisu-ai/tool-azure-blob](packages/tools/azure-blob/README.md)
98
+ - [@sisu-ai/tool-extract-urls](packages/tools/extract-urls/README.md)
99
+ - [@sisu-ai/tool-github-projects](packages/tools/github-projects/README.md)
100
+ - [@sisu-ai/tool-summarize-text](packages/tools/summarize-text/README.md)
101
+ - [@sisu-ai/tool-terminal](packages/tools/terminal/README.md)
102
+ - [@sisu-ai/tool-vec-chroma](packages/tools/vec-chroma/README.md)
103
+ - [@sisu-ai/tool-web-fetch](packages/tools/web-fetch/README.md)
104
+ - [@sisu-ai/tool-web-search-duckduckgo](packages/tools/web-search-duckduckgo/README.md)
105
+ - [@sisu-ai/tool-web-search-google](packages/tools/web-search-google/README.md)
106
+ - [@sisu-ai/tool-web-search-openai](packages/tools/web-search-openai/README.md)
107
+ - [@sisu-ai/tool-wikipedia](packages/tools/wikipedia/README.md)
108
+ </details>
109
+
110
+ <details>
111
+ <summary>All examples</summary>
112
+
113
+ **Anthropic** — [hello](examples/anthropic-hello/README.md) · [control-flow](examples/anthropic-control-flow/README.md) · [stream](examples/anthropic-stream/README.md) · [weather](examples/anthropic-weather/README.md)
114
+
115
+ **Ollama** — [hello](examples/ollama-hello/README.md) · [stream](examples/ollama-stream/README.md) · [vision](examples/ollama-vision/README.md) · [weather](examples/ollama-weather/README.md) · [web-search](examples/ollama-web-search/README.md)
116
+
117
+ **OpenAI** — [hello](examples/openai-hello/README.md) · [weather](examples/openai-weather/README.md) · [stream](examples/openai-stream/README.md) · [vision](examples/openai-vision/README.md) · [reasoning](examples/openai-reasoning/README.md) · [react](examples/openai-react/README.md) · [control-flow](examples/openai-control-flow/README.md) · [branch](examples/openai-branch/README.md) · [parallel](examples/openai-parallel/README.md) · [graph](examples/openai-graph/README.md) · [orchestration](examples/openai-orchestration/README.md) · [orchestration-adaptive](examples/openai-orchestration-adaptive/README.md) · [guardrails](examples/openai-guardrails/README.md) · [error-handling](examples/openai-error-handling/README.md) · [rag-chroma](examples/openai-rag-chroma/README.md) · [web-search](examples/openai-web-search/README.md) · [web-fetch](examples/openai-web-fetch/README.md) · [wikipedia](examples/openai-wikipedia/README.md) · [terminal](examples/openai-terminal/README.md) · [github-projects](examples/openai-github-projects/README.md) · [server](examples/openai-server/README.md) · [aws-s3](examples/openai-aws-s3/README.md) · [azure-blob](examples/openai-azure-blob/README.md)
118
+ </details>
119
+
120
+ ---
121
+
122
+ ## Contributing
123
+
124
+ We build Sisu in the open. Contributions welcome.
125
+
126
+ [Contributing Guide](CONTRIBUTING.md) · [Report a Bug](https://github.com/finger-gun/sisu/issues/new?template=bug_report.md) · [Request a Feature](https://github.com/finger-gun/sisu/issues/new?template=feature_request.md) · [Code of Conduct](CODE_OF_CONDUCT.md)
127
+
128
+ ---
129
+
130
+ <div align="center">
131
+
132
+ **[Star on GitHub](https://github.com/finger-gun/sisu)** if Sisu helps you build better agents.
133
+
134
+ *Quiet, determined, relentlessly useful.*
135
+
136
+ [Apache 2.0 License](LICENSE)
137
+
138
+ </div>
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { Tool } from '@sisu-ai/core';
2
- export type WikipediaFormat = 'summary' | 'html' | 'related';
1
+ import type { Tool } from "@sisu-ai/core";
2
+ export type WikipediaFormat = "summary" | "html" | "related";
3
3
  export interface WikipediaArgs {
4
4
  title: string;
5
5
  format?: WikipediaFormat;
package/dist/index.js CHANGED
@@ -1,35 +1,40 @@
1
- import { firstConfigValue } from '@sisu-ai/core';
2
- import { z } from 'zod';
1
+ import { firstConfigValue } from "@sisu-ai/core";
2
+ import { z } from "zod";
3
3
  export const wikipedia = {
4
- name: 'wikipediaLookup',
5
- description: 'Fetch a Wikipedia page summary, HTML, or related pages given an approximate title. Defaults to summary.',
4
+ name: "wikipediaLookup",
5
+ description: "Fetch a Wikipedia page summary, HTML, or related pages given an approximate title. Defaults to summary.",
6
6
  schema: z.object({
7
7
  title: z.string().min(1),
8
- format: z.enum(['summary', 'html', 'related']).optional(),
8
+ format: z.enum(["summary", "html", "related"]).optional(),
9
9
  lang: z.string().min(2).max(10).optional(),
10
10
  }),
11
- handler: async ({ title, format = 'summary', lang }, ctx) => {
11
+ handler: async ({ title, format = "summary", lang }, ctx) => {
12
12
  const base = resolveBaseUrl(ctx, lang);
13
- if (format === 'html')
13
+ if (format === "html")
14
14
  return fetchHtml(base, title);
15
- if (format === 'related')
15
+ if (format === "related")
16
16
  return fetchRelated(base, title);
17
17
  return fetchSummary(base, title);
18
- }
18
+ },
19
19
  };
20
20
  export default wikipedia;
21
21
  function resolveBaseUrl(ctx, lang) {
22
22
  // Precedence: CLI flags (via core helpers) > env vars; allow overriding full base or just language
23
- const baseFromFlags = firstConfigValue(['WIKIPEDIA_BASE_URL', 'WIKI_BASE_URL']);
24
- const langFromFlags = firstConfigValue(['WIKIPEDIA_LANG', 'WIKI_LANG']) || lang;
23
+ const baseFromFlags = firstConfigValue([
24
+ "WIKIPEDIA_BASE_URL",
25
+ "WIKI_BASE_URL",
26
+ ]);
27
+ const langFromFlags = firstConfigValue(["WIKIPEDIA_LANG", "WIKI_LANG"]) || lang;
25
28
  if (baseFromFlags)
26
- return baseFromFlags.replace(/\/$/, '');
27
- const chosenLang = (langFromFlags || 'en').toLowerCase();
29
+ return baseFromFlags.replace(/\/$/, "");
30
+ const chosenLang = (langFromFlags || "en").toLowerCase();
28
31
  return `https://${chosenLang}.wikipedia.org/api/rest_v1`;
29
32
  }
30
33
  async function fetchSummary(baseUrl, title) {
31
34
  const url = `${baseUrl}/page/summary/${encodeURIComponent(title)}`;
32
- const res = await fetch(url, { headers: { Accept: 'application/json' } });
35
+ const res = await globalThis.fetch(url, {
36
+ headers: { Accept: "application/json" },
37
+ });
33
38
  const raw = await res.text();
34
39
  if (!res.ok)
35
40
  throw new Error(`Wikipedia summary failed: ${res.status} ${res.statusText}`);
@@ -45,28 +50,32 @@ async function fetchSummary(baseUrl, title) {
45
50
  }
46
51
  async function fetchHtml(baseUrl, title) {
47
52
  const url = `${baseUrl}/page/html/${encodeURIComponent(title)}`;
48
- const res = await fetch(url, { headers: { Accept: 'text/html' } });
53
+ const res = await globalThis.fetch(url, { headers: { Accept: "text/html" } });
49
54
  const raw = await res.text();
50
- const ct = res.headers?.get?.('content-type') || '';
55
+ const ct = res.headers?.get?.("content-type") || "";
51
56
  if (!res.ok)
52
57
  throw new Error(`Wikipedia html failed: ${res.status} ${res.statusText}`);
53
- if (!ct.toLowerCase().includes('text/html'))
58
+ if (!ct.toLowerCase().includes("text/html"))
54
59
  throw new Error(`Wikipedia html returned non-HTML content (content-type: ${ct})`);
55
60
  return raw;
56
61
  }
57
62
  async function fetchRelated(baseUrl, title) {
58
63
  const url = `${baseUrl}/page/related/${encodeURIComponent(title)}`;
59
- const res = await fetch(url, { headers: { Accept: 'application/json' } });
64
+ const res = await globalThis.fetch(url, {
65
+ headers: { Accept: "application/json" },
66
+ });
60
67
  const raw = await res.text();
61
68
  if (!res.ok)
62
69
  throw new Error(`Wikipedia related failed: ${res.status} ${res.statusText}`);
63
70
  const json = raw ? JSON.parse(raw) : {};
64
71
  const pages = Array.isArray(json.pages) ? json.pages : [];
65
- return pages.map(p => ({
66
- title: String(p.title || ''),
72
+ return pages
73
+ .map((p) => ({
74
+ title: String(p.title || ""),
67
75
  description: p.description,
68
76
  extract: p.extract,
69
77
  url: p.content_urls?.desktop?.page,
70
78
  thumbnailUrl: p.thumbnail?.source,
71
- })).filter(r => r.title);
79
+ }))
80
+ .filter((r) => r.title);
72
81
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sisu-ai/tool-wikipedia",
3
- "version": "8.0.1",
3
+ "version": "8.0.3",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -12,7 +12,7 @@
12
12
  "zod": "^3.23.8"
13
13
  },
14
14
  "peerDependencies": {
15
- "@sisu-ai/core": "^2.3.1"
15
+ "@sisu-ai/core": "^2.3.2"
16
16
  },
17
17
  "repository": {
18
18
  "type": "git",