Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(browser): unify remote image and credential boundaries

Dash4fdb186916e9
diff --git a/packages/lizi-mcps/src/browser/opencli-recipes.test.ts b/packages/lizi-mcps/src/browser/opencli-recipes.test.ts
index bb5243ea1b..c68994e295 100644
--- a/packages/lizi-mcps/src/browser/opencli-recipes.test.ts
+++ b/packages/lizi-mcps/src/browser/opencli-recipes.test.ts
@@ -38,6 +38,12 @@ import { validateLocalReferences } from '../../../opencli-vendor/clis/midjourney
import { tosUpload } from '../../../opencli-vendor/clis/douyin/_shared/tos-upload.js';
// @ts-expect-error Pinned upstream JavaScript media helpers have no declarations.
import * as instagramMedia from '../../../opencli-vendor/clis/instagram/_shared/private-publish.js';
+// @ts-expect-error Pinned upstream JavaScript helpers have no declarations.
+import { downloadRemoteImage, MAX_IMAGE_SIZE_BYTES } from '../../../opencli-vendor/clis/twitter/utils.js';
+// @ts-expect-error Pinned upstream JavaScript helpers have no declarations.
+import { s2Fetch } from '../../../opencli-vendor/clis/semanticscholar/utils.js';
+// @ts-expect-error Pinned upstream JavaScript helpers have no declarations.
+import { buildEutilsUrl } from '../../../opencli-vendor/clis/pubmed/utils.js';
// Wrap the native namespace so tests can replace only the subprocess boundary.
vi.mock('node:child_process', async importOriginal => ({
@@ -47,10 +53,87 @@ vi.mock('node:child_process', async importOriginal => ({
afterEach(() => {
vi.useRealTimers();
vi.unstubAllGlobals();
+ vi.unstubAllEnvs();
vi.restoreAllMocks();
});
describe("bundled OpenCLI recipes", () => {
+ // #6826 download recurrence, unit tier. Generic downloader tests missed the
+ // X composer consumer; real DNS/redirect policy with an in-memory dispatcher.
+ it.each(['http://127.0.0.1/private', 'https://private.example/image', 'https://public.example/redirect'])(
+ 'rejects private X image downloads before exposing upload bytes (%s)', async url => {
+ const agent = new MockAgent();
+ agent.disableNetConnect();
+ agent.get('https://public.example').intercept({ path: '/redirect' })
+ .reply(302, '', { headers: { location: 'http://169.254.169.254/private' } });
+ const original = guardedNetwork.fetchWithSsrFGuard;
+ vi.spyOn(guardedNetwork, 'fetchWithSsrFGuard').mockImplementation(params => original({
+ ...params,
+ lookupFn: (async (host: string) => [{ address: host === 'private.example' ? '10.0.0.1' : '8.8.8.8', family: 4 }]) as unknown as guardedNetwork.LookupFn,
+ dispatcherFactory: () => agent,
+ }));
+ const direct = vi.fn(async () => new Response('private bytes', { headers: { 'content-type': 'image/png' } }));
+ vi.stubGlobal('fetch', direct);
+ try {
+ await expect(withRecipeHost(undefined, () => downloadRemoteImage(url))).rejects.toThrow(/blocked/i);
+ expect(direct).not.toHaveBeenCalled();
+ } finally { await agent.close().catch(() => undefined); }
+ },
+ );
+
+ // First oversized chunk and absent/false length headers: cancel with bounded
+ // pipe read-ahead rather than buffering the full body as the old consumer did.
+ it.each(['missing', 'understated', 'oversized'])('bounds X image streams with %s Content-Length', async header => {
+ const release = vi.fn(async () => {});
+ const cancel = vi.fn();
+ const pull = vi.fn((controller: ReadableStreamDefaultController<Uint8Array>) => {
+ if (pull.mock.calls.length === 1) controller.enqueue(new Uint8Array(MAX_IMAGE_SIZE_BYTES + 1));
+ else if (pull.mock.calls.length < 4) controller.enqueue(new Uint8Array(1));
+ else controller.close();
+ });
+ const headers: Record<string, string> = { 'content-type': 'image/png' };
+ if (header !== 'missing') headers['content-length'] = header === 'understated' ? '1' : String(MAX_IMAGE_SIZE_BYTES + 1);
+ const response = new Response(new ReadableStream({ pull, cancel }, { highWaterMark: 0 }), { headers });
+ vi.stubGlobal('fetch', vi.fn(async () => response));
+ vi.spyOn(guardedNetwork, 'fetchWithSsrFGuard').mockResolvedValue({ response, finalUrl: 'https://cdn.example/image', release });
+ await expect(withRecipeHost(undefined, () => downloadRemoteImage('https://public.example/image'))).rejects.toThrow(/limit/i);
+ if (header === 'oversized') expect(pull).not.toHaveBeenCalled();
+ else expect(pull.mock.calls.length).toBeLessThanOrEqual(2);
+ expect(cancel).toHaveBeenCalledOnce();
+ expect(release).toHaveBeenCalledOnce();
+ });
+
+ it.each(['success', 'http-error', 'unsupported-type'])('cleans X image temporary files after %s', async outcome => {
+ const dir = await mkdtemp(path.join(tmpdir(), 'cindy-x-image-test-'));
+ const release = vi.fn(async () => {});
+ const response = new Response('public bytes', { status: outcome === 'http-error' ? 500 : 200,
+ headers: { 'content-type': outcome === 'unsupported-type' ? 'text/plain' : 'image/png' } });
+ vi.spyOn(guardedNetwork, 'fetchWithSsrFGuard').mockResolvedValue({ response, finalUrl: 'https://cdn.example/image', release });
+ vi.stubGlobal('fetch', vi.fn(async () => response));
+ try {
+ const running = withRecipeHost(undefined, async () => {
+ const image = await downloadRemoteImage('https://public.example/image');
+ expect(path.extname(image.absPath)).toBe('.png');
+ expect(await readFile(image.absPath, 'utf8')).toBe('public bytes');
+ }, { temporaryRoot: dir, read: readFileSync, open: file => openSync(file, 'r') });
+ if (outcome === 'success') await running;
+ else await expect(running).rejects.toThrow(outcome === 'http-error' ? /500/ : /Unsupported/);
+ expect(release).toHaveBeenCalledOnce();
+ expect(await readdir(dir)).toEqual([]);
+ } finally { await rm(dir, { recursive: true, force: true }); }
+ });
+
+ // Credential-family audit, unit tier. Optional public APIs must not inherit
+ // reusable launch-environment keys. Existing tests never supplied such keys.
+ it('keeps public research APIs anonymous even with ambient API keys', async () => {
+ vi.stubEnv('SEMANTIC_SCHOLAR_API_KEY', 'invalid-fixture-s2-key');
+ vi.stubEnv('NCBI_API_KEY', 'invalid-fixture-ncbi-key');
+ const fetch = vi.fn(async (_url: string, _init: RequestInit) => new Response('{"data":[]}', { headers: { 'content-type': 'application/json' } }));
+ vi.stubGlobal('fetch', fetch);
+ await s2Fetch('https://api.semanticscholar.org/graph/v1/paper/search?query=fixture', 'fixture');
+ expect(fetch.mock.calls[0][1].headers).not.toHaveProperty('x-api-key');
+ expect(new URL(buildEutilsUrl('esearch', { term: 'fixture' })).searchParams.has('api_key')).toBe(false);
+ });
// #6826 source-copy TOCTOU, unit tier. The shared copy entry must return an
// invocation-owned snapshot, not the original path after approving its bytes.
// Earlier converter cases did not exercise this separate copy source entry.
@@ -838,6 +921,12 @@ describe("bundled OpenCLI recipes", () => {
const all = await query();
expect(all.ok).toBe(true);
expect(all.recipeCount).toBe(loadRecipes().size);
+ for (const id of ['weread-official/book', 'minimax/music', 'jira/search', 'confluence/search']) {
+ expect(JSON.stringify(all)).not.toContain(`opencli:${id}`);
+ const response = await client.callTool({ name: 'call_tool', arguments: { name: 'browser', args: { action: 'recipe', recipeId: `opencli:${id}` } } });
+ expect(JSON.parse((response.content as Array<{ text: string }>)[0].text).ok).toBe(false);
+ await expect(executeAdapter(id, {}, {} as IPage)).rejects.toThrow('Unknown bundled adapter');
+ }
for (const id of ['opencli:zlibrary/search', 'opencli:slock/task-create', 'opencli:claude/login', 'opencli:claude/ask', 'opencli:spotify/auth', 'opencli:spotify/status', 'opencli:ones/login', 'opencli:ones/token-info', 'opencli:xiaoyuzhou/history', 'opencli:paperreview/submit', 'opencli:paperreview/review', 'opencli:paperreview/feedback', 'opencli:quark/share-tree', 'opencli:quark/save', 'opencli:kimi/storage-get', 'opencli:kimi/storage-keys', 'opencli:kimi/cookies', 'opencli:kimi/idb-list', 'books-list', 'hockey-search']) {
expect(JSON.stringify(all)).not.toContain(id);
const response = await client.callTool({ name: 'call_tool', arguments: { name: 'browser', args: { action: 'recipe', recipeId: id } } });
diff --git a/packages/opencli-vendor/README.md b/packages/opencli-vendor/README.md
index 2ef28c4312..e9503803c2 100644
--- a/packages/opencli-vendor/README.md
+++ b/packages/opencli-vendor/README.md
@@ -11,15 +11,15 @@
- 170 个站点/应用,1,223 条命令(916 read、307 write)。
- 1,112 个命令模块,所有生产共享代码、JSON 和其他资源一并引入;不引入上游测试。
- 上游快照完整保留,但默认目录独立选择:排除 Z-Library、Slock、Claude.ai、Spotify、ONES、
- 小宇宙适配器、PaperReview、Quark 和 Kimi 共 121 条,另暂缓 17 条直接落盘命令,
- 剩余 1,085 条命令、25 个上游别名。原因记录在 [selection.json](cindy/selection.json),
+ 小宇宙适配器、PaperReview、Quark、Kimi、微信读书官方 API、MiniMax、Jira 和 Confluence 共 139 条,
+ 另暂缓 17 条直接落盘命令,剩余 1,067 条命令、25 个上游别名。原因记录在 [selection.json](cindy/selection.json),
同步会沿用此选择,排除条目不进入模块导入表和可执行目录。
- Cindy 原有 56 个 ID:47 个转到新版适配器,7 个保留原流程,两个爬虫练习站移至
`packages/lizi-mcps/src/browser/recipe-examples`,不再出现在默认列表。
逐项记录见 [legacy-coverage.json](cindy/legacy-coverage.json)。
- Cindy 独立增加 App Store 搜索、Google Play 搜索、TapTap 中国站游戏详情、Steam 玩家评价、
Open Library 书目查询和 Crossref 文献/DOI 查询,共 6 个配方,位于
- `packages/lizi-mcps/src/browser/cindy-recipes`。共 1,170 个可发现 ID、168 份指南;这个数包含别名和兼容入口。
+ `packages/lizi-mcps/src/browser/cindy-recipes`。共 1,152 个可发现 ID、166 份指南;这个数包含别名和兼容入口。
- 兼容入口保持输入名,输出改为新版结构化结果;用户本地覆盖层仍优先于内置层。
通过 `browser(action="siteguide")` 查询精简完整目录;传 `site`(域名或上游站点名)
@@ -46,6 +46,9 @@
登录继续使用已有的通用代输入流程,不新增站点专用配置。
- Kimi 暂不进入默认目录:存储读取与 Cookie 诊断会把任意存储值或授权材料预览返回模型。
完整来源保留,不新增秘密键猜测或凭据脱敏机制。
+- 微信读书官方 API、MiniMax、Jira 和 Confluence 的 18 条命令暂缓:长期密钥、令牌或密码
+ 依赖进程环境变量,缺少宿主安全配置入口;不新增配置机制。微信读书浏览器适配器仍保留。
+ Semantic Scholar 和 PubMed 保留公开匿名查询,忽略启动环境中的可选 API key。
- 文章 stdout 输出改为 MCP 返回值;
Readability 脚本随构建打包,避免安装包运行时查找源码文件。
- 主进程使用静态入口加载所选命令及其执行依赖,不在运行期动态导入模块;导入不执行命令。
@@ -70,6 +73,8 @@
- 共享 Node 文件下载复用浏览器运行层的 SSRF fetch:首跳与每次重定向均检查协议、DNS/IP,
连接固定在已校验的公网地址;跨 origin 移除鉴权头,正文结束或失败后释放连接。
这条下载路径使用受保护的直连,不读取适配器的代理环境变量;需要代理的站点可沿用浏览器操作。
+- X 引用及回复的远程配图也复用此下载器,沿用既有 20 MiB 上限;响应长度和流式字节双检,
+ 不完整缓冲响应。成功后只交接调用内副本,HTTP、格式和限额失败都清理副本并释放连接。
- 文章自动图片下载最多 20 张,每张 10 MiB,单篇累计接收 50 MiB(包含失败传输);
先检查响应长度,再在写入前检查实际流量。超出上限或下载失败的图片保留远程链接。
- 与配方按使用维护共用暂停状态:适配器参数预检失败不会暂停配方,执行失败才暂停;
diff --git a/packages/opencli-vendor/UPSTREAM.json b/packages/opencli-vendor/UPSTREAM.json
index a93f5eddf4..bcfbe53cea 100644
--- a/packages/opencli-vendor/UPSTREAM.json
+++ b/packages/opencli-vendor/UPSTREAM.json
@@ -222,6 +222,12 @@
},
"clis/midjourney/quota.js": {
"upstreamSha256": "c9be85847c01d7a0d9673dc45b2ddbadc77a2de885825530b08886fe6e310a0f"
+ },
+ "clis/semanticscholar/utils.js": {
+ "upstreamSha256": "26b61c794be47a4480895e34a36b9e503de8c163c52e854b8b43b339e427c3a8"
+ },
+ "clis/pubmed/utils.js": {
+ "upstreamSha256": "ad4e9eff1347b667ec04aaa43bc55a4b65adedac685c55daf11965aec15fe436"
}
},
"files": {
@@ -1047,7 +1053,7 @@
"clis/pubmed/related.js": "31e3e2918dc959c9fa9ab9d6a58bc3257cce0c4f1c410708fc8a02d3ea4a3cfd",
"clis/pubmed/review.js": "e6807193e5be3c190c500d78fc74953aea13516773b80dfb3063571fc063ae74",
"clis/pubmed/search.js": "1e08fe33fdf27198a1f5353d5cd749dde0c763c9f88223edb5e01a42b08a48fc",
- "clis/pubmed/utils.js": "ad4e9eff1347b667ec04aaa43bc55a4b65adedac685c55daf11965aec15fe436",
+ "clis/pubmed/utils.js": "f7d71c1d1739cecdd1c5d9eb5423fa1a212b19fb9e4ff5b8ba2b736708ad5a33",
"clis/pypi/downloads.js": "f3d6e0287a9f266cae363c962e4a86b809cf0c804c55243358b740348a0529b6",
"clis/pypi/package.js": "fdab2a496b24ab1ada9495f8f24caff7d5ae96f99627b3e58832a875099697bf",
"clis/pypi/utils.js": "5911bd197bf040efabd9699aaed681ad9d12612b14c475bd8c5d9b7238e99047",
@@ -1116,7 +1122,7 @@
"clis/semanticscholar/paper.js": "2ff70f855f61e9bf7ca45c6791fbb561af55c94411ca5d2e87708a1b2c1bafda",
"clis/semanticscholar/recommendations.js": "b78060c985a25088fcad2a7b52a575a24e51b821445ab71f59407b6a64f88b4c",
"clis/semanticscholar/search.js": "523f125057973cb19bb49ee5e72cfb4c667541c8b9bb41f16666734c8cae6434",
- "clis/semanticscholar/utils.js": "26b61c794be47a4480895e34a36b9e503de8c163c52e854b8b43b339e427c3a8",
+ "clis/semanticscholar/utils.js": "347d743a451c42fb3974fd79f5a6d865459e00fd0071f3dceeb36335f1f169d4",
"clis/sinablog/article.js": "af014453ea15d58260c12b3cb4d2f84c79618e876694fd163f1d16d1495e5472",
"clis/sinablog/hot.js": "3d70e03db1a03498965ff1cda154226c13390d0e4fd0f1ea55e3ab643f248e27",
"clis/sinablog/search.js": "45cc756b198bb7f862d2811271edf999b4d098a3680084c0c32fd156f734a385",
@@ -1309,7 +1315,7 @@
"clis/twitter/unlike.js": "183aaf8d883fe57d504e28f41ad46aaaa6e639d7d7c562b87a06f3852fc525c9",
"clis/twitter/unretweet.js": "207a14240eb519b1be6c5e35ded2a9c3002f3cc42d8ad96d9315df88f706bdaf",
"clis/twitter/user-timeline.js": "d80d311ca4090a7c63a7ff8c6b33d612f51d7132a6f289665957bcebda321b00",
- "clis/twitter/utils.js": "18ea1463b29a6dd52d031519b53f6eac25d15782c5e97576ee148e1517e2730a",
+ "clis/twitter/utils.js": "6c73bbe45114c6f4a84e1fd30365f2bc295c6bf24e1f80a0ec0cffba6b0cc0c9",
"clis/uisdc/news.js": "7450fa65ec39331fbb4e0e911bf6ebb4bf4cd9e43e5f72b59fbba740b723ae32",
"clis/uiverse/_shared.js": "6318c65c3e3630e843278fc77b87e8da00a387909c78bbee69bfe56803fc0638",
"clis/uiverse/code.js": "3efffa78519d4c545b4c8fb2bb9c7ff607322b6a9dad8443cc7a3af4df217cd3",
diff --git a/packages/opencli-vendor/cindy/modules.js b/packages/opencli-vendor/cindy/modules.js
index 71d0590cb4..52b04f784e 100644
--- a/packages/opencli-vendor/cindy/modules.js
+++ b/packages/opencli-vendor/cindy/modules.js
@@ -162,10 +162,6 @@ import "../clis/coingecko/exchanges.js";
import "../clis/coingecko/global.js";
import "../clis/coingecko/top.js";
import "../clis/coingecko/trending.js";
-import "../clis/confluence/create.js";
-import "../clis/confluence/page.js";
-import "../clis/confluence/search.js";
-import "../clis/confluence/update.js";
import "../clis/coupang/add-to-cart.js";
import "../clis/coupang/auth.js";
import "../clis/coupang/product.js";
@@ -452,11 +448,6 @@ import "../clis/jimeng/generate.js";
import "../clis/jimeng/history.js";
import "../clis/jimeng/new.js";
import "../clis/jimeng/workspaces.js";
-import "../clis/jira/attachments.js";
-import "../clis/jira/comments.js";
-import "../clis/jira/issue.js";
-import "../clis/jira/links.js";
-import "../clis/jira/search.js";
import "../clis/juejin/hot.js";
import "../clis/juejin/recommend.js";
import "../clis/ke/auth.js";
@@ -551,7 +542,6 @@ import "../clis/midjourney/quota.js";
import "../clis/midjourney/settings.js";
import "../clis/midjourney/status.js";
import "../clis/midjourney/whoami.js";
-import "../clis/minimax/music.js";
import "../clis/mubu/doc.js";
import "../clis/mubu/docs.js";
import "../clis/mubu/notes.js";
@@ -866,14 +856,6 @@ import "../clis/weibo/user.js";
import "../clis/weixin/create-draft.js";
import "../clis/weixin/drafts.js";
import "../clis/weixin/search.js";
-import "../clis/weread-official/book.js";
-import "../clis/weread-official/discover.js";
-import "../clis/weread-official/list-apis.js";
-import "../clis/weread-official/notes.js";
-import "../clis/weread-official/readdata.js";
-import "../clis/weread-official/review.js";
-import "../clis/weread-official/search.js";
-import "../clis/weread-official/shelf.js";
import "../clis/weread/ai-outline.js";
import "../clis/weread/auth.js";
import "../clis/weread/book-search.js";
@@ -1173,10 +1155,6 @@ export const modules = {
"coingecko/global.js": true,
"coingecko/top.js": true,
"coingecko/trending.js": true,
- "confluence/create.js": true,
- "confluence/page.js": true,
- "confluence/search.js": true,
- "confluence/update.js": true,
"coupang/add-to-cart.js": true,
"coupang/auth.js": true,
"coupang/product.js": true,
@@ -1463,11 +1441,6 @@ export const modules = {
"jimeng/history.js": true,
"jimeng/new.js": true,
"jimeng/workspaces.js": true,
- "jira/attachments.js": true,
- "jira/comments.js": true,
- "jira/issue.js": true,
- "jira/links.js": true,
- "jira/search.js": true,
"juejin/hot.js": true,
"juejin/recommend.js": true,
"ke/auth.js": true,
@@ -1562,7 +1535,6 @@ export const modules = {
"midjourney/settings.js": true,
"midjourney/status.js": true,
"midjourney/whoami.js": true,
- "minimax/music.js": true,
"mubu/doc.js": true,
"mubu/docs.js": true,
"mubu/notes.js": true,
@@ -1877,14 +1849,6 @@ export const modules = {
"weixin/create-draft.js": true,
"weixin/drafts.js": true,
"weixin/search.js": true,
- "weread-official/book.js": true,
- "weread-official/discover.js": true,
- "weread-official/list-apis.js": true,
- "weread-official/notes.js": true,
- "weread-official/readdata.js": true,
- "weread-official/review.js": true,
- "weread-official/search.js": true,
- "weread-official/shelf.js": true,
"weread/ai-outline.js": true,
"weread/auth.js": true,
"weread/book-search.js": true,
diff --git a/packages/opencli-vendor/cindy/patches.json b/packages/opencli-vendor/cindy/patches.json
index f998b8c202..d9bcc3e438 100644
--- a/packages/opencli-vendor/cindy/patches.json
+++ b/packages/opencli-vendor/cindy/patches.json
@@ -3661,5 +3661,45 @@
"file": "src/download/index.ts",
"before": "import { closeRecipeFileSync, openRecipeOutputFileSync, recipeCopySource, recipeOutputPath, recipeTemporaryDirectory, resolveRecipePath } from '@jackwener/opencli/cindy/host';",
"after": "import { recipeFileExistsSync, statRecipeFileSync, closeRecipeFileSync, openRecipeOutputFileSync, recipeCopySource, recipeOutputPath, recipeTemporaryDirectory, resolveRecipePath } from '@jackwener/opencli/cindy/host';"
+ },
+ {
+ "file": "clis/twitter/utils.js",
+ "before": "import { ArgumentError } from '@jackwener/opencli/errors';",
+ "after": "import { ArgumentError } from '@jackwener/opencli/errors';\nimport { httpDownload } from '@jackwener/opencli/download';"
+ },
+ {
+ "file": "clis/twitter/utils.js",
+ "before": "export async function downloadRemoteImage(imageUrl) {\n let parsed;\n try {\n parsed = new URL(imageUrl);\n } catch {\n throw new ArgumentError(`Invalid image URL: ${imageUrl}`);\n }\n if (!/^https?:$/.test(parsed.protocol)) {\n throw new ArgumentError(`Unsupported image URL protocol: ${parsed.protocol}`);\n }\n const response = await fetch(imageUrl);\n if (!response.ok) {\n throw new ArgumentError(`Image download failed: HTTP ${response.status}`);\n }\n const contentLength = Number(response.headers.get('content-length') || '0');\n if (contentLength > MAX_IMAGE_SIZE_BYTES) {\n throw new ArgumentError(`Image too large: ${(contentLength / 1024 / 1024).toFixed(1)} MB (max ${MAX_IMAGE_SIZE_BYTES / 1024 / 1024} MB)`);\n }\n const ext = resolveImageExtension(imageUrl, response.headers.get('content-type'));\n const cleanupDir = fs.mkdtempSync(recipeOutputPath(path.join(recipeTemporaryDirectory(), 'opencli-twitter-')));\n const absPath = path.join(cleanupDir, `image${ext}`);\n const buffer = Buffer.from(await response.arrayBuffer());\n if (buffer.byteLength > MAX_IMAGE_SIZE_BYTES) {\n fs.rmSync(recipeOutputPath(cleanupDir), { recursive: true, force: true });\n throw new ArgumentError(`Image too large: ${(buffer.byteLength / 1024 / 1024).toFixed(1)} MB (max ${MAX_IMAGE_SIZE_BYTES / 1024 / 1024} MB)`);\n }\n fs.writeFileSync(recipeOutputPath(absPath), buffer);\n return { absPath, cleanupDir };\n}\n",
+ "after": "export async function downloadRemoteImage(imageUrl) {\n const cleanupDir = fs.mkdtempSync(recipeOutputPath(path.join(recipeTemporaryDirectory(), 'opencli-twitter-')));\n const pendingPath = path.join(cleanupDir, 'download');\n try {\n // Reuse the shared DNS/IP/redirect policy and streaming byte budget.\n // Only invocation-owned temporary output is granted to this consumer.\n const result = await httpDownload(imageUrl, pendingPath, {\n maxBytes: MAX_IMAGE_SIZE_BYTES,\n includeContentType: true,\n });\n if (!result.success) throw new ArgumentError(`Image download failed: ${result.error}`);\n const ext = resolveImageExtension(result.finalUrl || imageUrl, result.contentType);\n const absPath = path.join(cleanupDir, `image${ext}`);\n fs.renameSync(recipeOutputPath(pendingPath), recipeOutputPath(absPath));\n return { absPath, cleanupDir };\n } catch (error) {\n fs.rmSync(recipeOutputPath(cleanupDir), { recursive: true, force: true });\n throw error;\n }\n}\n"
+ },
+ {
+ "file": "clis/semanticscholar/utils.js",
+ "before": " const apiKey = process.env.SEMANTIC_SCHOLAR_API_KEY;\n if (apiKey) headers['x-api-key'] = apiKey;",
+ "after": " // Public mode only; ambient process credentials are not a host binding."
+ },
+ {
+ "file": "clis/semanticscholar/utils.js",
+ "before": "attempt === 0 && !apiKey",
+ "after": "attempt === 0"
+ },
+ {
+ "file": "clis/semanticscholar/utils.js",
+ "before": "Fetch with optional `SEMANTIC_SCHOLAR_API_KEY` header.",
+ "after": "Fetch anonymously without inherited API credentials."
+ },
+ {
+ "file": "clis/semanticscholar/utils.js",
+ "before": "// API. Anonymous traffic caps at roughly 100 requests / 5 minutes; an optional\n// API key (free at https://www.semanticscholar.org/product/api#api-key-form)\n// lifts the limit and is passed via `SEMANTIC_SCHOLAR_API_KEY`. Paper refs",
+ "after": "// API. Cindy uses anonymous traffic without ambient API keys. Paper refs"
+ },
+ {
+ "file": "clis/pubmed/utils.js",
+ "before": " if (process.env.NCBI_API_KEY) {\n searchParams.set('api_key', process.env.NCBI_API_KEY);\n }\n",
+ "after": " // Public mode only; do not inherit launch-environment API credentials.\n"
+ },
+ {
+ "file": "clis/pubmed/utils.js",
+ "before": "const delayMs = process.env.NCBI_API_KEY ? 110 : 360;",
+ "after": "const delayMs = 360;"
}
]
diff --git a/packages/opencli-vendor/cindy/selection.json b/packages/opencli-vendor/cindy/selection.json
index a13ae25cf2..30cae2aad6 100644
--- a/packages/opencli-vendor/cindy/selection.json
+++ b/packages/opencli-vendor/cindy/selection.json
@@ -16,6 +16,10 @@
"xiaoyuzhou": "Deferred: authenticated adapters require manually configured access/refresh tokens without a host secure configuration entry. Plaintext credential fallback is removed; the independent public Cindy recipe remains available.",
"paperreview": "Deferred: submit returns a reusable review capability token and review/feedback accept it as a model input. Keep capability credentials inside the host before inclusion.",
"quark": "Deferred: share-tree returns a reusable share capability stoken and save accepts it as a model input. Keep capability credentials inside the host before inclusion.",
- "kimi": "Deferred: storage-get returns arbitrary Web Storage values and cookies exposes credential previews. Remove these diagnostic credential exits before inclusion; no model-facing raw secrets."
+ "kimi": "Deferred: storage-get returns arbitrary Web Storage values and cookies exposes credential previews. Remove these diagnostic credential exits before inclusion; no model-facing raw secrets.",
+ "weread-official": "Deferred: requires a reusable API key from the process environment without a host secure configuration entry. Keep sources; do not advertise unusable authenticated commands.",
+ "minimax": "Deferred: requires an environment-only API key without a host secure configuration entry. No new credential configuration mechanism in this refresh.",
+ "jira": "Deferred: Atlassian authentication depends on environment-only tokens or passwords without a host secure configuration entry.",
+ "confluence": "Deferred: Atlassian authentication depends on environment-only tokens or passwords without a host secure configuration entry."
}
}
diff --git a/packages/opencli-vendor/clis/pubmed/utils.js b/packages/opencli-vendor/clis/pubmed/utils.js
index 6b735f717b..30187037f7 100644
--- a/packages/opencli-vendor/clis/pubmed/utils.js
+++ b/packages/opencli-vendor/clis/pubmed/utils.js
@@ -64,9 +64,7 @@ export function buildEutilsUrl(tool, params = {}) {
if (!params.retmode) {
searchParams.set('retmode', 'json');
}
- if (process.env.NCBI_API_KEY) {
- searchParams.set('api_key', process.env.NCBI_API_KEY);
- }
+ // Public mode only; do not inherit launch-environment API credentials.
if (process.env.NCBI_EMAIL) {
searchParams.set('email', process.env.NCBI_EMAIL);
}
@@ -82,7 +80,7 @@ async function waitForRateLimit() {
if (process.env.NODE_ENV === 'test') {
return;
}
- const delayMs = process.env.NCBI_API_KEY ? 110 : 360;
+ const delayMs = 360;
const now = Date.now();
const waitMs = Math.max(0, lastRequestAt + delayMs - now);
if (waitMs > 0) {
diff --git a/packages/opencli-vendor/clis/semanticscholar/utils.js b/packages/opencli-vendor/clis/semanticscholar/utils.js
index 8af2ee5b5c..722f1f847b 100644
--- a/packages/opencli-vendor/clis/semanticscholar/utils.js
+++ b/packages/opencli-vendor/clis/semanticscholar/utils.js
@@ -1,9 +1,7 @@
// Shared helpers for the Semantic Scholar (`api.semanticscholar.org`) adapter.
//
// Semantic Scholar exposes a free Academic Graph + a separate Recommendations
-// API. Anonymous traffic caps at roughly 100 requests / 5 minutes; an optional
-// API key (free at https://www.semanticscholar.org/product/api#api-key-form)
-// lifts the limit and is passed via `SEMANTIC_SCHOLAR_API_KEY`. Paper refs
+// API. Cindy uses anonymous traffic without ambient API keys. Paper refs
// accept Semantic Scholar paperIds, DOIs, arXiv ids, ACL ids, MAG ids, PMID,
// or full URLs; they round-trip through `paper <ref>` to `citations <ref>`
// and `recommendations <ref>`.
@@ -81,14 +79,13 @@ export function requirePaperRef(value) {
}
/**
- * Fetch with optional `SEMANTIC_SCHOLAR_API_KEY` header. Retries once on 429
+ * Fetch anonymously without inherited API credentials. Retries once on 429
* after a short pause; anonymous traffic hits the public ~100 req / 5 min
* cap, and a single retry covers the typical burst-then-cool-down case.
*/
export async function s2Fetch(url, label) {
const headers = { 'user-agent': UA, accept: 'application/json' };
- const apiKey = process.env.SEMANTIC_SCHOLAR_API_KEY;
- if (apiKey) headers['x-api-key'] = apiKey;
+ // Public mode only; ambient process credentials are not a host binding.
let resp;
let attempt = 0;
@@ -101,7 +98,7 @@ export async function s2Fetch(url, label) {
'Check that api.semanticscholar.org is reachable from this network.',
);
}
- if (resp.status === 429 && attempt === 0 && !apiKey) {
+ if (resp.status === 429 && attempt === 0) {
attempt += 1;
await new Promise(resolve => setTimeout(resolve, 1500));
continue;
diff --git a/packages/opencli-vendor/clis/twitter/utils.js b/packages/opencli-vendor/clis/twitter/utils.js
index 66dbf3e3af..76a6748b81 100644
--- a/packages/opencli-vendor/clis/twitter/utils.js
+++ b/packages/opencli-vendor/clis/twitter/utils.js
@@ -4,6 +4,7 @@ import * as fs from 'node:fs';
import * as os from 'node:os';
import * as path from 'node:path';
import { ArgumentError } from '@jackwener/opencli/errors';
+import { httpDownload } from '@jackwener/opencli/download';
/**
* Public read-only Twitter web bearer token used by the GraphQL endpoints we
@@ -85,33 +86,24 @@ export function resolveImageExtension(url, contentType) {
* @returns {Promise<{ absPath: string, cleanupDir: string }>}
*/
export async function downloadRemoteImage(imageUrl) {
- let parsed;
- try {
- parsed = new URL(imageUrl);
- } catch {
- throw new ArgumentError(`Invalid image URL: ${imageUrl}`);
- }
- if (!/^https?:$/.test(parsed.protocol)) {
- throw new ArgumentError(`Unsupported image URL protocol: ${parsed.protocol}`);
- }
- const response = await fetch(imageUrl);
- if (!response.ok) {
- throw new ArgumentError(`Image download failed: HTTP ${response.status}`);
- }
- const contentLength = Number(response.headers.get('content-length') || '0');
- if (contentLength > MAX_IMAGE_SIZE_BYTES) {
- throw new ArgumentError(`Image too large: ${(contentLength / 1024 / 1024).toFixed(1)} MB (max ${MAX_IMAGE_SIZE_BYTES / 1024 / 1024} MB)`);
- }
- const ext = resolveImageExtension(imageUrl, response.headers.get('content-type'));
const cleanupDir = fs.mkdtempSync(recipeOutputPath(path.join(recipeTemporaryDirectory(), 'opencli-twitter-')));
- const absPath = path.join(cleanupDir, `image${ext}`);
- const buffer = Buffer.from(await response.arrayBuffer());
- if (buffer.byteLength > MAX_IMAGE_SIZE_BYTES) {
+ const pendingPath = path.join(cleanupDir, 'download');
+ try {
+ // Reuse the shared DNS/IP/redirect policy and streaming byte budget.
+ // Only invocation-owned temporary output is granted to this consumer.
+ const result = await httpDownload(imageUrl, pendingPath, {
+ maxBytes: MAX_IMAGE_SIZE_BYTES,
+ includeContentType: true,
+ });
+ if (!result.success) throw new ArgumentError(`Image download failed: ${result.error}`);
+ const ext = resolveImageExtension(result.finalUrl || imageUrl, result.contentType);
+ const absPath = path.join(cleanupDir, `image${ext}`);
+ fs.renameSync(recipeOutputPath(pendingPath), recipeOutputPath(absPath));
+ return { absPath, cleanupDir };
+ } catch (error) {
fs.rmSync(recipeOutputPath(cleanupDir), { recursive: true, force: true });
- throw new ArgumentError(`Image too large: ${(buffer.byteLength / 1024 / 1024).toFixed(1)} MB (max ${MAX_IMAGE_SIZE_BYTES / 1024 / 1024} MB)`);
+ throw error;
}
- fs.writeFileSync(recipeOutputPath(absPath), buffer);
- return { absPath, cleanupDir };
}
/**