@abhishek944/pi-web-access 0.0.0-stage → 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.
- package/ASTACK.md +23 -0
- package/CHANGELOG.md +1289 -0
- package/LICENSE +21 -0
- package/README.md +1215 -2
- package/SECURITY.md +5 -0
- package/abortable.ts +17 -0
- package/activity.ts +101 -0
- package/anysearch.ts +188 -0
- package/auth-fetch.ts +152 -0
- package/baizhi.ts +124 -0
- package/banner.png +0 -0
- package/bocha.ts +203 -0
- package/brave-rate-limit.ts +176 -0
- package/brave.ts +247 -0
- package/brightdata-unlocker.ts +272 -0
- package/ceramic.ts +220 -0
- package/chrome-cookies.ts +752 -0
- package/cloudflare-search.ts +237 -0
- package/content-find.ts +255 -0
- package/crawl4ai.ts +196 -0
- package/credential-source.ts +242 -0
- package/curator-page.ts +3607 -0
- package/curator-run.ts +45 -0
- package/curator-server.ts +761 -0
- package/custom-search.ts +226 -0
- package/data-uri-sanitize.ts +406 -0
- package/datalab-pdf-extract.ts +568 -0
- package/declared-web-links.ts +173 -0
- package/deepseek.ts +377 -0
- package/degoog.ts +323 -0
- package/dist/index.js +28286 -0
- package/dist/mcp-cli.js +29186 -0
- package/dist/pi-mcp.js +20855 -0
- package/dist/types/abortable.d.ts +2 -0
- package/dist/types/activity.d.ts +33 -0
- package/dist/types/anysearch.d.ts +7 -0
- package/dist/types/auth-fetch.d.ts +14 -0
- package/dist/types/baizhi.d.ts +3 -0
- package/dist/types/bocha.d.ts +3 -0
- package/dist/types/brave-rate-limit.d.ts +35 -0
- package/dist/types/brave.d.ts +3 -0
- package/dist/types/brightdata-unlocker.d.ts +11 -0
- package/dist/types/ceramic.d.ts +3 -0
- package/dist/types/chrome-cookies.d.ts +44 -0
- package/dist/types/cloudflare-search.d.ts +4 -0
- package/dist/types/content-find.d.ts +10 -0
- package/dist/types/crawl4ai.d.ts +8 -0
- package/dist/types/credential-source.d.ts +29 -0
- package/dist/types/curator-page.d.ts +5 -0
- package/dist/types/curator-run.d.ts +10 -0
- package/dist/types/curator-server.d.ts +72 -0
- package/dist/types/custom-search.d.ts +22 -0
- package/dist/types/data-uri-sanitize.d.ts +20 -0
- package/dist/types/datalab-pdf-extract.d.ts +59 -0
- package/dist/types/declared-web-links.d.ts +7 -0
- package/dist/types/deepseek.d.ts +13 -0
- package/dist/types/degoog.d.ts +3 -0
- package/dist/types/domain-filter-normalization.d.ts +9 -0
- package/dist/types/duckduckgo-rate-limit.d.ts +52 -0
- package/dist/types/duckduckgo.d.ts +6 -0
- package/dist/types/endpoint-pdf-extract.d.ts +22 -0
- package/dist/types/exa.d.ts +17 -0
- package/dist/types/extract.d.ts +70 -0
- package/dist/types/feature-config.d.ts +2 -0
- package/dist/types/fetch-params.d.ts +39 -0
- package/dist/types/field-extract.d.ts +37 -0
- package/dist/types/firecrawl.d.ts +18 -0
- package/dist/types/gemini-adc.d.ts +9 -0
- package/dist/types/gemini-api.d.ts +37 -0
- package/dist/types/gemini-pdf-extract.d.ts +8 -0
- package/dist/types/gemini-search.d.ts +76 -0
- package/dist/types/gemini-url-context.d.ts +3 -0
- package/dist/types/gemini-web-config.d.ts +25 -0
- package/dist/types/gemini-web.d.ts +31 -0
- package/dist/types/github-api.d.ts +6 -0
- package/dist/types/github-extract.d.ts +19 -0
- package/dist/types/github-issue-pr.d.ts +28 -0
- package/dist/types/index.d.ts +53 -0
- package/dist/types/jina-search.d.ts +7 -0
- package/dist/types/kagi.d.ts +14 -0
- package/dist/types/keenable.d.ts +3 -0
- package/dist/types/kimi-search.d.ts +4 -0
- package/dist/types/linkup.d.ts +5 -0
- package/dist/types/mcp-cli.d.ts +2 -0
- package/dist/types/mcp-server.d.ts +10 -0
- package/dist/types/mcp-tool-definitions.d.ts +16 -0
- package/dist/types/mistral-search.d.ts +3 -0
- package/dist/types/ninerouter.d.ts +3 -0
- package/dist/types/offtopic-judge.d.ts +26 -0
- package/dist/types/ollama.d.ts +14 -0
- package/dist/types/openai-search.d.ts +23 -0
- package/dist/types/page-query.d.ts +22 -0
- package/dist/types/parallel-mcp.d.ts +10 -0
- package/dist/types/parallel.d.ts +13 -0
- package/dist/types/pdf-extract.d.ts +44 -0
- package/dist/types/perplexity.d.ts +26 -0
- package/dist/types/pi-mcp.d.ts +56 -0
- package/dist/types/pi-session-results.d.ts +8 -0
- package/dist/types/querit.d.ts +9 -0
- package/dist/types/query-rewrite.d.ts +2 -0
- package/dist/types/render-search-error.d.ts +56 -0
- package/dist/types/retrieval-only.d.ts +78 -0
- package/dist/types/rsc-extract.d.ts +11 -0
- package/dist/types/search-answer-formatting.d.ts +7 -0
- package/dist/types/search-result-count-normalization.d.ts +1 -0
- package/dist/types/searchinfinity.d.ts +7 -0
- package/dist/types/searxng.d.ts +3 -0
- package/dist/types/source-check.d.ts +102 -0
- package/dist/types/ssrf-protection.d.ts +66 -0
- package/dist/types/storage.d.ts +69 -0
- package/dist/types/summary-model-scope.d.ts +33 -0
- package/dist/types/summary-review.d.ts +30 -0
- package/dist/types/tabstack.d.ts +5 -0
- package/dist/types/tavily.d.ts +7 -0
- package/dist/types/tinyfish.d.ts +10 -0
- package/dist/types/tool-activation.d.ts +7 -0
- package/dist/types/tool-arguments.d.ts +1 -0
- package/dist/types/upgrade-notice.d.ts +6 -0
- package/dist/types/utils.d.ts +55 -0
- package/dist/types/valyu.d.ts +5 -0
- package/dist/types/video-extract.d.ts +15 -0
- package/dist/types/web-tool-contract.d.ts +98 -0
- package/dist/types/web-tool-core.d.ts +227 -0
- package/dist/types/xai-search.d.ts +12 -0
- package/dist/types/you.d.ts +3 -0
- package/dist/types/youtube-extract.d.ts +29 -0
- package/dist/types/zai.d.ts +3 -0
- package/docs/pi-mcp.md +41 -0
- package/domain-filter-normalization.ts +44 -0
- package/duckduckgo-rate-limit.ts +205 -0
- package/duckduckgo.ts +123 -0
- package/endpoint-pdf-extract.ts +225 -0
- package/exa.ts +620 -0
- package/extract.ts +1721 -0
- package/feature-config.ts +29 -0
- package/fetch-params.ts +147 -0
- package/field-extract.ts +347 -0
- package/firecrawl.ts +476 -0
- package/gemini-adc.ts +345 -0
- package/gemini-api.ts +368 -0
- package/gemini-pdf-extract.ts +108 -0
- package/gemini-search.ts +1162 -0
- package/gemini-url-context.ts +128 -0
- package/gemini-web-config.ts +131 -0
- package/gemini-web.ts +527 -0
- package/github-api.ts +197 -0
- package/github-extract.ts +1064 -0
- package/github-issue-pr.ts +717 -0
- package/index.ts +2819 -0
- package/jina-search.ts +275 -0
- package/kagi.ts +257 -0
- package/keenable.ts +222 -0
- package/kimi-search.ts +209 -0
- package/linkup.ts +170 -0
- package/mcp-cli.ts +40 -0
- package/mcp-server.ts +84 -0
- package/mcp-tool-definitions.ts +143 -0
- package/mistral-search.ts +268 -0
- package/ninerouter.ts +92 -0
- package/offtopic-judge.ts +72 -0
- package/ollama.ts +237 -0
- package/openai-search.ts +855 -0
- package/package.json +108 -4
- package/page-query.ts +185 -0
- package/parallel-mcp.ts +255 -0
- package/parallel.ts +373 -0
- package/pdf-extract.ts +447 -0
- package/perplexity.ts +245 -0
- package/pi-mcp.ts +139 -0
- package/pi-session-results.ts +40 -0
- package/pi-web-fetch-demo.mp4 +0 -0
- package/promise-try.d.ts +7 -0
- package/querit.ts +394 -0
- package/query-rewrite.ts +84 -0
- package/render-search-error.ts +170 -0
- package/retrieval-only.ts +102 -0
- package/rsc-extract.ts +338 -0
- package/search-answer-formatting.ts +11 -0
- package/search-result-count-normalization.ts +4 -0
- package/searchinfinity.ts +246 -0
- package/searxng.ts +236 -0
- package/source-check.ts +269 -0
- package/ssrf-protection.ts +602 -0
- package/storage.ts +547 -0
- package/summary-model-scope.ts +72 -0
- package/summary-review.ts +476 -0
- package/tabstack.ts +289 -0
- package/tavily.ts +257 -0
- package/tinyfish.ts +373 -0
- package/tool-activation.ts +169 -0
- package/tool-arguments.ts +23 -0
- package/upgrade-notice.ts +47 -0
- package/utils.ts +693 -0
- package/valyu.ts +177 -0
- package/video-extract.ts +398 -0
- package/web-tool-contract.ts +93 -0
- package/web-tool-core.ts +1810 -0
- package/xai-search.ts +443 -0
- package/you.ts +165 -0
- package/youtube-extract.ts +336 -0
- package/zai.ts +161 -0
package/github-api.ts
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import type { ExtractedContent } from "./extract.ts";
|
|
3
|
+
import type { GitHubUrlInfo } from "./github-extract.ts";
|
|
4
|
+
|
|
5
|
+
const MAX_TREE_ENTRIES = 200;
|
|
6
|
+
const MAX_INLINE_FILE_CHARS = 100_000;
|
|
7
|
+
|
|
8
|
+
let ghAvailable: boolean | null = null;
|
|
9
|
+
let ghHintShown = false;
|
|
10
|
+
|
|
11
|
+
export async function checkGhAvailable(signal?: AbortSignal): Promise<boolean> {
|
|
12
|
+
if (ghAvailable !== null) return ghAvailable;
|
|
13
|
+
|
|
14
|
+
return new Promise((resolve) => {
|
|
15
|
+
execFile("gh", ["--version"], { timeout: 5000, ...(signal ? { signal } : {}) }, (err) => {
|
|
16
|
+
const available = !err;
|
|
17
|
+
if (!signal?.aborted) ghAvailable = available;
|
|
18
|
+
resolve(available);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function showGhHint(): void {
|
|
24
|
+
if (!ghHintShown) {
|
|
25
|
+
ghHintShown = true;
|
|
26
|
+
console.error("[pi-web-access] Install `gh` CLI for better GitHub repo access including private repos.");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function checkRepoSize(owner: string, repo: string): Promise<number | null> {
|
|
31
|
+
if (!(await checkGhAvailable())) return null;
|
|
32
|
+
|
|
33
|
+
return new Promise((resolve) => {
|
|
34
|
+
execFile("gh", ["api", `repos/${owner}/${repo}`, "--jq", ".size"], { timeout: 10000 }, (err, stdout) => {
|
|
35
|
+
if (err) {
|
|
36
|
+
resolve(null);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const kb = parseInt(stdout.trim(), 10);
|
|
40
|
+
resolve(Number.isNaN(kb) ? null : kb);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function getDefaultBranch(owner: string, repo: string): Promise<string | null> {
|
|
46
|
+
if (!(await checkGhAvailable())) return null;
|
|
47
|
+
|
|
48
|
+
return new Promise((resolve) => {
|
|
49
|
+
execFile("gh", ["api", `repos/${owner}/${repo}`, "--jq", ".default_branch"], { timeout: 10000 }, (err, stdout) => {
|
|
50
|
+
if (err) {
|
|
51
|
+
resolve(null);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const branch = stdout.trim();
|
|
55
|
+
resolve(branch || null);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function fetchTreeViaApi(owner: string, repo: string, ref: string): Promise<string | null> {
|
|
61
|
+
if (!(await checkGhAvailable())) return null;
|
|
62
|
+
|
|
63
|
+
return new Promise((resolve) => {
|
|
64
|
+
execFile(
|
|
65
|
+
"gh",
|
|
66
|
+
["api", `repos/${owner}/${repo}/git/trees/${ref}?recursive=1`, "--jq", ".tree[].path"],
|
|
67
|
+
{ timeout: 15000, maxBuffer: 5 * 1024 * 1024 },
|
|
68
|
+
(err, stdout) => {
|
|
69
|
+
if (err) {
|
|
70
|
+
resolve(null);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const paths = stdout.trim().split("\n").filter(Boolean);
|
|
74
|
+
if (paths.length === 0) {
|
|
75
|
+
resolve(null);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const truncated = paths.length > MAX_TREE_ENTRIES;
|
|
79
|
+
const display = paths.slice(0, MAX_TREE_ENTRIES).join("\n");
|
|
80
|
+
resolve(truncated ? display + `\n... (${paths.length} total entries)` : display);
|
|
81
|
+
},
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function fetchReadmeViaApi(owner: string, repo: string, ref: string): Promise<string | null> {
|
|
87
|
+
if (!(await checkGhAvailable())) return null;
|
|
88
|
+
|
|
89
|
+
return new Promise((resolve) => {
|
|
90
|
+
execFile(
|
|
91
|
+
"gh",
|
|
92
|
+
["api", `repos/${owner}/${repo}/readme?ref=${ref}`, "--jq", ".content"],
|
|
93
|
+
{ timeout: 10000 },
|
|
94
|
+
(err, stdout) => {
|
|
95
|
+
if (err) {
|
|
96
|
+
resolve(null);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
const decoded = Buffer.from(stdout.trim(), "base64").toString("utf-8");
|
|
101
|
+
resolve(decoded.length > MAX_INLINE_FILE_CHARS ? `${decoded.slice(0, MAX_INLINE_FILE_CHARS)}\n\n[README truncated at 100K chars]` : decoded);
|
|
102
|
+
} catch {
|
|
103
|
+
resolve(null);
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function fetchFileViaApi(owner: string, repo: string, path: string, ref: string): Promise<string | null> {
|
|
111
|
+
if (!(await checkGhAvailable())) return null;
|
|
112
|
+
|
|
113
|
+
return new Promise((resolve) => {
|
|
114
|
+
execFile(
|
|
115
|
+
"gh",
|
|
116
|
+
["api", `repos/${owner}/${repo}/contents/${path}?ref=${ref}`, "--jq", ".content"],
|
|
117
|
+
{ timeout: 10000, maxBuffer: 2 * 1024 * 1024 },
|
|
118
|
+
(err, stdout) => {
|
|
119
|
+
if (err) {
|
|
120
|
+
resolve(null);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
try {
|
|
124
|
+
resolve(Buffer.from(stdout.trim(), "base64").toString("utf-8"));
|
|
125
|
+
} catch {
|
|
126
|
+
resolve(null);
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export async function fetchViaApi(
|
|
134
|
+
url: string,
|
|
135
|
+
owner: string,
|
|
136
|
+
repo: string,
|
|
137
|
+
info: GitHubUrlInfo,
|
|
138
|
+
sizeNote?: string,
|
|
139
|
+
): Promise<ExtractedContent | null> {
|
|
140
|
+
const ref = info.ref || (await getDefaultBranch(owner, repo));
|
|
141
|
+
if (!ref) return null;
|
|
142
|
+
|
|
143
|
+
const lines: string[] = [];
|
|
144
|
+
if (sizeNote) {
|
|
145
|
+
lines.push(sizeNote);
|
|
146
|
+
lines.push("");
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (info.type === "blob" && info.path) {
|
|
150
|
+
const content = await fetchFileViaApi(owner, repo, info.path, ref);
|
|
151
|
+
if (!content) return null;
|
|
152
|
+
|
|
153
|
+
lines.push(`## ${info.path}`);
|
|
154
|
+
if (content.length > MAX_INLINE_FILE_CHARS) {
|
|
155
|
+
lines.push(content.slice(0, MAX_INLINE_FILE_CHARS));
|
|
156
|
+
lines.push(`\n[File truncated at 100K chars]`);
|
|
157
|
+
} else {
|
|
158
|
+
lines.push(content);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return {
|
|
162
|
+
url,
|
|
163
|
+
title: `${owner}/${repo} - ${info.path}`,
|
|
164
|
+
content: lines.join("\n"),
|
|
165
|
+
error: null,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const [tree, readme] = await Promise.all([
|
|
170
|
+
fetchTreeViaApi(owner, repo, ref),
|
|
171
|
+
fetchReadmeViaApi(owner, repo, ref),
|
|
172
|
+
]);
|
|
173
|
+
|
|
174
|
+
if (!tree && !readme) return null;
|
|
175
|
+
|
|
176
|
+
if (tree) {
|
|
177
|
+
lines.push("## Structure");
|
|
178
|
+
lines.push(tree);
|
|
179
|
+
lines.push("");
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (readme) {
|
|
183
|
+
lines.push("## README.md");
|
|
184
|
+
lines.push(readme);
|
|
185
|
+
lines.push("");
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
lines.push("This is an API-only view. Clone the repo or use `read`/`bash` for deeper exploration.");
|
|
189
|
+
|
|
190
|
+
const title = info.path ? `${owner}/${repo} - ${info.path}` : `${owner}/${repo}`;
|
|
191
|
+
return {
|
|
192
|
+
url,
|
|
193
|
+
title,
|
|
194
|
+
content: lines.join("\n"),
|
|
195
|
+
error: null,
|
|
196
|
+
};
|
|
197
|
+
}
|