@hfyjq/crannia 1.1.2 → 1.2.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/LICENSE +201 -201
- package/NOTICE +48 -45
- package/README.md +1 -1
- package/THIRD-PARTY-FRONTEND.md +5266 -5266
- package/THIRD-PARTY-PYTHON-linux.md +174 -0
- package/THIRD-PARTY-PYTHON.md +176 -162
- package/THIRD-PARTY.md +323 -316
- package/apps/desktop/quotes.txt +56 -56
- package/bus/core.py +677 -671
- package/bus/loaders/channel_loader.py +64 -64
- package/bus/loaders/provider_loader.py +4 -7
- package/bus/loaders/skill_loader.py +46 -27
- package/bus/loaders/skill_md.py +9 -9
- package/bus/mcp_disabled.py +4 -6
- package/bus/quarantine.py +10 -13
- package/bus/registry.py +2315 -2284
- package/bus/skill_state.py +124 -124
- package/channels/cli_channel/handler.py +3 -3
- package/channels/cli_channel/manifest.yaml +5 -5
- package/channels/dingtalk_channel/handler.py +32 -32
- package/channels/dingtalk_channel/manifest.yaml +12 -12
- package/channels/feishu_channel/handler.py +33 -33
- package/channels/feishu_channel/manifest.yaml +12 -12
- package/channels/qq_bot_channel/__init__.py +1 -1
- package/channels/qq_bot_channel/handler.py +24 -24
- package/channels/qq_bot_channel/manifest.yaml +4 -4
- package/channels/telegram_channel/__init__.py +1 -1
- package/channels/telegram_channel/handler.py +21 -21
- package/channels/telegram_channel/manifest.yaml +4 -4
- package/channels/telegram_channel/media.py +231 -231
- package/channels/textfmt.py +58 -58
- package/channels/wechat_channel/__init__.py +1 -1
- package/channels/wechat_channel/converter.py +1 -1
- package/channels/wechat_channel/handler.py +8 -8
- package/channels/wechat_channel/manifest.yaml +5 -5
- package/channels/wechat_channel/media.py +178 -178
- package/core/activity.py +753 -709
- package/core/agent_loop.py +7673 -7522
- package/core/allowlist.py +2 -3
- package/core/approval.py +34 -24
- package/core/approval_timeout.py +256 -228
- package/core/artifacts.py +3 -3
- package/core/attachment_gc.py +21 -0
- package/core/auto_review.py +2 -2
- package/core/browser/cdp.py +5 -2
- package/core/browser/discover.py +55 -19
- package/core/browser/session.py +4 -4
- package/core/cache_break_detector.py +97 -0
- package/core/cache_breakpoints.py +103 -0
- package/core/cache_policies.py +255 -0
- package/core/cancellation.py +3 -3
- package/core/channel_configs.py +3 -3
- package/core/channel_turns.py +13 -13
- package/core/child_approval.py +2 -3
- package/core/code_intel.py +11 -11
- package/core/command_policy.py +13 -7
- package/core/computer/annotate.py +231 -11
- package/core/computer/capture.py +140 -1
- package/core/computer/guard.py +7 -4
- package/core/computer/input.py +452 -26
- package/core/computer/session.py +563 -381
- package/core/computer/tools.py +2170 -928
- package/core/computer/uia.py +100 -1
- package/core/computer/watch.py +1 -1
- package/core/computer/win32.py +302 -7
- package/core/config_requirements.py +205 -205
- package/core/cron/runner.py +4 -4
- package/core/daily_log.py +2 -2
- package/core/dedup.py +2 -2
- package/core/egress_channels.py +326 -0
- package/core/egress_gate.py +96 -8
- package/core/egress_preapproved.py +59 -3
- package/core/endpoint.py +141 -141
- package/core/events.py +17 -8
- package/core/extension.py +2 -2
- package/core/file_history.py +10 -10
- package/core/file_tools.py +3 -3
- package/core/github_config.py +1 -1
- package/core/group_digest.py +3 -4
- package/core/group_minutes.py +5 -5
- package/core/group_reply.py +24 -0
- package/core/groups.py +5 -9
- package/core/hooks.py +15 -15
- package/core/i18n.py +2 -2
- package/core/ice/canary.py +3 -3
- package/core/ice/net_heuristics.py +2 -2
- package/core/im_routing.py +2 -2
- package/core/image_input.py +183 -43
- package/core/inbound.py +3 -3
- package/core/jobs.py +6 -6
- package/core/last_good.py +150 -150
- package/core/leaf_md.py +3 -3
- package/core/llm_errors.py +36 -27
- package/core/mail_config.py +2 -2
- package/core/memory/compressor.py +8 -8
- package/core/memory/manager.py +30 -45
- package/core/memory/session_memory.py +1 -2
- package/core/memory/short_term.py +4 -4
- package/core/memory_extract.py +1 -1
- package/core/memory_organize.py +8 -8
- package/core/memory_store.py +7 -9
- package/core/memory_transfer.py +2 -2
- package/core/model_capabilities.py +2 -2
- package/core/model_configs.py +219 -68
- package/core/model_profiles.py +333 -0
- package/core/modes.py +12 -11
- package/core/net_proxy.py +3 -3
- package/core/pipeline/scheduler.py +48 -43
- package/core/pipeline/stage.py +3 -0
- package/core/pipeline/stages/agent_loop.py +36 -15
- package/core/pipeline/stages/group_reply.py +22 -20
- package/core/pipeline/stages/post_process.py +7 -7
- package/core/pipeline/stages/pre_process.py +360 -68
- package/core/prompt_assembler.py +13 -4
- package/core/recycle.py +227 -16
- package/core/response_language.py +1 -1
- package/core/retention.py +2 -2
- package/core/rg.py +4 -3
- package/core/security.py +26 -8
- package/core/services.py +8 -8
- package/core/session_model.py +3 -5
- package/core/session_pool.py +35 -5
- package/core/session_recap.py +40 -3
- package/core/session_workspace.py +2 -3
- package/core/settings_baseline.py +2 -2
- package/core/settings_transfer.py +25 -1
- package/core/shell.py +52 -20
- package/core/side_call.py +3 -3
- package/core/skill_config.py +164 -0
- package/core/skill_factory.py +2 -2
- package/core/skill_guidance.py +2 -4
- package/core/skill_index.py +3 -4
- package/core/skill_settings.py +1 -1
- package/core/skill_sources.py +7 -7
- package/core/ssh_config.py +129 -0
- package/core/state_registry.py +67 -5
- package/core/subagent.py +28 -5
- package/core/subagent_defs.py +3 -3
- package/core/summarizer.py +4 -5
- package/core/tasks_notify.py +6 -6
- package/core/tiers.py +2 -2
- package/core/todos.py +1 -1
- package/core/token_calibrator.py +1 -4
- package/core/tool_outcome.py +108 -108
- package/core/touched_files.py +1 -1
- package/core/trace.py +12 -3
- package/core/unlock.py +4 -4
- package/core/update_tui.py +184 -158
- package/core/updater.py +5 -3
- package/core/version.py +14 -14
- package/core/vision_budget.py +235 -0
- package/core/web_cache.py +152 -152
- package/core/web_request.py +474 -0
- package/core/window_estimate.py +1 -1
- package/core/workspace.py +56 -26
- package/crannia_tray.py +278 -278
- package/licenses/GPL-3.0.txt +619 -619
- package/licenses/LGPL-2.1.txt +502 -502
- package/licenses/LGPL-3.0.txt +165 -165
- package/licenses/MIT-chat-on-wechat.txt +18 -18
- package/licenses/MIT-deepseek-harness.txt +21 -21
- package/licenses/Molio-LICENSE.txt +44 -44
- package/locales/en.json +1876 -1755
- package/main.py +154 -154
- package/mcpx/client.py +12 -1
- package/mcpx/manager.py +530 -522
- package/mcpx/servers/web_search.py +5 -13
- package/package.json +15 -23
- package/providers/anthropic/client.py +35 -33
- package/providers/base.py +13 -13
- package/providers/cache_policies.json +294 -0
- package/providers/cost_table.json +3779 -3779
- package/providers/lmstudio/client.py +2 -2
- package/providers/model_capabilities.json +6665 -6665
- package/providers/model_profiles.json +629 -0
- package/providers/ollama/client.py +2 -2
- package/providers/openai_compat.py +37 -16
- package/providers/openrouter/client.py +2 -2
- package/providers/qwen/__init__.py +1 -1
- package/providers/qwen/client.py +2 -2
- package/providers/qwen/manifest.yaml +16 -16
- package/providers/rate_limiter.py +2 -2
- package/providers/siliconflow/client.py +2 -2
- package/providers/validation.py +171 -171
- package/providers/vision_profiles.json +89 -0
- package/providers/window_table.json +8909 -8909
- package/requirements.txt +59 -51
- package/sbom-linux-x64.json +4580 -0
- package/sbom.json +4600 -4413
- package/skills/diagram/SKILL.md +47 -0
- package/skills/diagram/__init__.py +1 -0
- package/skills/diagram/handler.py +294 -0
- package/skills/diagram/layout.py +174 -0
- package/skills/diagram/manifest.yaml +106 -0
- package/skills/diagram/mermaid.py +170 -0
- package/skills/diagram/svg.py +223 -0
- package/skills/entertainment/SKILL.md +35 -35
- package/skills/entertainment/__init__.py +1 -1
- package/skills/entertainment/handler.py +91 -91
- package/skills/entertainment/manifest.yaml +26 -26
- package/skills/file_parser/GUIDANCE.md +10 -10
- package/skills/file_parser/handler.py +33 -11
- package/skills/github/SKILL.md +32 -32
- package/skills/github/__init__.py +1 -1
- package/skills/mail_parser/SKILL.md +68 -68
- package/skills/mail_parser/__init__.py +1 -1
- package/skills/mail_parser/handler.py +1 -1
- package/skills/media_gen/GUIDANCE.md +19 -19
- package/skills/media_gen/SKILL.md +43 -43
- package/skills/media_gen/__init__.py +1 -1
- package/skills/media_gen/handler.py +1 -1
- package/skills/media_gen/manifest.yaml +93 -93
- package/skills/netops/SKILL.md +45 -0
- package/skills/netops/__init__.py +1 -0
- package/skills/netops/handler.py +418 -0
- package/skills/netops/manifest.yaml +118 -0
- package/skills/office_parser/_excel_io.py +3 -3
- package/skills/office_parser/handler.py +2 -2
- package/skills/office_parser/ppt_tools.py +1 -1
- package/skills/office_parser/pptx_export/console_encoding.py +27 -27
- package/skills/office_parser/pptx_export/resource_paths.py +88 -88
- package/skills/office_parser/pptx_export/svg_finalize/__init__.py +12 -12
- package/skills/office_parser/pptx_export/svg_finalize/crop_images.py +366 -366
- package/skills/office_parser/pptx_export/svg_finalize/embed_images.py +288 -288
- package/skills/office_parser/pptx_export/svg_finalize/fix_image_aspect.py +388 -388
- package/skills/office_parser/pptx_export/svg_finalize/flatten_tspan.py +818 -818
- package/skills/office_parser/pptx_export/svg_finalize/svg_rect_to_path.py +345 -345
- package/skills/office_parser/pptx_export/svg_to_pptx/__init__.py +14 -14
- package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/__init__.py +1 -1
- package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/context.py +186 -186
- package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/converter.py +781 -781
- package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/paths.py +429 -429
- package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/utils.py +40 -21
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/__init__.py +1 -1
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/builder.py +1267 -1267
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/dimensions.py +155 -155
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/discovery.py +101 -101
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/narration.py +236 -236
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/notes.py +257 -257
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/slide_xml.py +136 -136
- package/skills/office_parser/pptx_export/svg_to_pptx/tspan_flattener.py +44 -44
- package/skills/office_parser/pptx_export/svg_to_pptx/use_expander.py +129 -129
- package/skills/office_parser/references/LICENSE-Office-Word-MCP-Server.txt +20 -20
- package/skills/office_parser/references/LICENSE-excel-mcp-server.txt +21 -21
- package/skills/office_parser/references/layout_library.md +816 -816
- package/skills/office_parser/references/ppt-master/LICENSE +21 -21
- package/skills/office_parser/references/ppt-master/references/executor-base.md +474 -474
- package/skills/office_parser/references/ppt-master/references/shared-standards.md +1002 -1002
- package/skills/office_parser/references/ppt-master/references/strategist.md +880 -880
- package/skills/office_parser/references/ppt-master/references/template-designer.md +402 -402
- package/skills/office_parser/references/ppt-master/references/visual-review.md +240 -240
- package/skills/office_parser/references/ppt-master/references/visual-styles/_index.md +106 -106
- package/skills/office_parser/references/ppt-master/references/visual-styles/blueprint.md +37 -37
- package/skills/office_parser/references/ppt-master/references/visual-styles/brutalist.md +38 -38
- package/skills/office_parser/references/ppt-master/references/visual-styles/chalkboard.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/dark-tech.md +37 -37
- package/skills/office_parser/references/ppt-master/references/visual-styles/data-journalism.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/editorial.md +38 -38
- package/skills/office_parser/references/ppt-master/references/visual-styles/glassmorphism.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/ink-notes.md +37 -37
- package/skills/office_parser/references/ppt-master/references/visual-styles/ink-wash.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/memphis.md +37 -37
- package/skills/office_parser/references/ppt-master/references/visual-styles/paper-cut.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/photo-editorial.md +38 -38
- package/skills/office_parser/references/ppt-master/references/visual-styles/pixel-art.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/sketch-notes.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/soft-rounded.md +37 -37
- package/skills/office_parser/references/ppt-master/references/visual-styles/swiss-minimal.md +38 -38
- package/skills/office_parser/references/ppt-master/references/visual-styles/vintage-poster.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/zine.md +37 -37
- package/skills/office_parser/references/spec_lock.md +235 -235
- package/skills/office_parser/soffice.py +68 -68
- package/skills/office_parser/word_tools.py +3 -3
- package/skills/ssh/SKILL.md +81 -0
- package/skills/ssh/__init__.py +1 -0
- package/skills/ssh/handler.py +609 -0
- package/skills/ssh/manifest.yaml +182 -0
- package/tui/crannia.cmd +134 -134
- package/tui/crannia.sh +82 -0
- package/tui/crannia_tui/__init__.py +1 -1
- package/tui/crannia_tui/app.py +240 -17
- package/tui/crannia_tui/app.tcss +21 -0
- package/tui/crannia_tui/clipboard.py +78 -10
- package/tui/crannia_tui/commands.py +37 -0
- package/tui/crannia_tui/events.py +6 -0
- package/tui/crannia_tui/i18n.py +164 -164
- package/tui/crannia_tui/locales/en.json +31 -6
- package/tui/crannia_tui/paths.py +4 -1
- package/tui/crannia_tui/profile.py +178 -169
- package/tui/crannia_tui/settings.py +134 -134
- package/tui/crannia_tui/setup.py +44 -5
- package/tui/crannia_tui/ui.py +156 -16
- package/tui/crannia_tui/update.py +393 -389
- package/vendor/ripgrep/COPYING.txt +3 -3
- package/vendor/ripgrep/LICENSE-MIT.txt +21 -21
- package/vendor/ripgrep/NOTICE-vscode-ripgrep.txt +13 -13
- package/vendor/ripgrep/README.md +30 -14
- package/vendor/ripgrep/UNLICENSE.txt +24 -24
- package/vendor/ripgrep/linux-x64/rg +0 -0
- package/vendor/ripgrep/package-source.json +15 -16
- package/web/__main__.py +12 -15
- package/web/server.py +8481 -8594
- package/web/static/img/channel-telegram.svg +1 -1
- package/web/static/img/channel-wechat.svg +1 -1
- package/web/templates/logs.html +49 -49
- package/web/templates/models.html +46 -46
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""出网能力目录 —— 「能力 × 目的地 × 授权」三轴模型的第一轴()。
|
|
3
|
+
|
|
4
|
+
## 它是什么
|
|
5
|
+
|
|
6
|
+
一张中心表:**每条出网通路声明它是哪个通道、目的地是哪个参数、
|
|
7
|
+
替掉了哪些 deny 命令族、分类器能不能自动放行、要不要写审计。**
|
|
8
|
+
|
|
9
|
+
两个来源,一个查询口:
|
|
10
|
+
|
|
11
|
+
· 框架工具 → `FRAMEWORK_CHANNELS`(本文件,静态)
|
|
12
|
+
· 技能工具 → manifest 的 `egress:` 段(装载期由
|
|
13
|
+
`bus/loaders/skill_loader` 调 :func:`declare` 登记,运行期只读)
|
|
14
|
+
|
|
15
|
+
## 为什么要有它
|
|
16
|
+
|
|
17
|
+
`deny` 档拒绝的是"无结构的静默通道"(`curl` / `ssh` / `nc` 这些命令)。
|
|
18
|
+
拒绝必须有出路,而出路是一组注册着的工具。没有这张表时,
|
|
19
|
+
"哪些命令有替身、替身叫什么、哪个参数是目的地"散落在四处
|
|
20
|
+
(`command_policy` 的拒绝话术、各 skill 的 manifest、审批的 subject、
|
|
21
|
+
审计的字段),改一处漏三处。
|
|
22
|
+
|
|
23
|
+
## deny 路线表
|
|
24
|
+
|
|
25
|
+
:data:`DENY_ROUTES` 把 `core/command_policy.EGRESS_COMMANDS` 的每个命令族
|
|
26
|
+
映射到一个结构化替身(或一个"不提供"的理由)。命令那一侧的拒绝话术
|
|
27
|
+
从它生成 —— 一处写。
|
|
28
|
+
|
|
29
|
+
判据():只承诺注册着的工具。所以路线里的每个工具名都必须能在
|
|
30
|
+
注册表里找到(`tests/test_egress_channels.py` 按注册表反查)。
|
|
31
|
+
|
|
32
|
+
## 声明字段(一个都不能少)
|
|
33
|
+
|
|
34
|
+
channel 通道:http / ssh / dns / tcp
|
|
35
|
+
target 哪个参数是目的地("" = 固定后端,如 web_search);
|
|
36
|
+
审批、授权、审计都以它为单位
|
|
37
|
+
route_for 它替代哪些 deny 命令族(没有就空)
|
|
38
|
+
auto 分类器能不能自动放行(False = 永不被自动放行,必问)
|
|
39
|
+
audit True = 每次调用写一行 EGRESS 审计
|
|
40
|
+
|
|
41
|
+
`auto=False` 的两条依据:敏感数据外发与远端执行属最高风险,分类器不得代答。
|
|
42
|
+
`ssh_exec` / `ssh_upload` 是第一批。
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
from __future__ import annotations
|
|
46
|
+
|
|
47
|
+
import threading
|
|
48
|
+
from dataclasses import dataclass
|
|
49
|
+
from typing import Optional
|
|
50
|
+
|
|
51
|
+
__all__ = [
|
|
52
|
+
"EGRESS_FIELDS", "EgressChannel", "Route",
|
|
53
|
+
"FRAMEWORK_CHANNELS", "FRAMEWORK_TOOLS",
|
|
54
|
+
"DENY_ROUTES", "route_of_family", "deny_message",
|
|
55
|
+
"declare", "forget_declared", "declared_channels",
|
|
56
|
+
"channels", "lookup", "auto_allowed", "auto_allowed_for_call",
|
|
57
|
+
"audit_enabled", "channel_of", "route_for_tool",
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
#: 一条声明必须给全的字段(读者逐项核)。
|
|
61
|
+
EGRESS_FIELDS: tuple[str, ...] = ("channel", "target", "route_for", "auto", "audit")
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@dataclass(frozen=True, slots=True)
|
|
65
|
+
class EgressChannel:
|
|
66
|
+
"""一条出网通路的声明。字段含义见模块 docstring。"""
|
|
67
|
+
tool: str
|
|
68
|
+
channel: str
|
|
69
|
+
target: str = ""
|
|
70
|
+
route_for: tuple[str, ...] = ()
|
|
71
|
+
auto: bool = True
|
|
72
|
+
audit: bool = True
|
|
73
|
+
source: str = ""
|
|
74
|
+
#: 没有对应 deny 族时,为什么它仍然值得存在(读者 ④ 点名要它)。
|
|
75
|
+
note: str = ""
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
# 框架自带的出网工具
|
|
79
|
+
#
|
|
80
|
+
# 只收"真的会发出网络请求"的那些工具。`file_parser` 的本地工具、
|
|
81
|
+
# `net_ifaces` / `net_routes`(只读本机状态,不出网)不在表里 ——
|
|
82
|
+
# 它们没有目的地,审批与审计以目的地为单位,没有目的话这两件事无从谈起。
|
|
83
|
+
FRAMEWORK_CHANNELS: dict[str, EgressChannel] = {
|
|
84
|
+
# 取网页 / 下载二进制。GET 一族,走地板 + 域名闸。
|
|
85
|
+
"web_fetch": EgressChannel(
|
|
86
|
+
tool="web_fetch", channel="http", target="url",
|
|
87
|
+
route_for=("curl", "wget", "wget2"), auto=True, audit=True,
|
|
88
|
+
source="framework"),
|
|
89
|
+
# 搜索:目的地固定是搜索后端,query 不是目的地(见 `§3.10` 作用域边界)。
|
|
90
|
+
"web_search": EgressChannel(
|
|
91
|
+
tool="web_search", channel="http", target="",
|
|
92
|
+
route_for=(), auto=True, audit=True, source="framework",
|
|
93
|
+
note="固定后端:模型能给的不是目的地(是 query),"
|
|
94
|
+
"所以它替代不了任何 deny 族 —— 它就是搜索本身"),
|
|
95
|
+
# 带自定义头的 HTTP 请求(P2)。纯只读 GET 可被分类器放行,
|
|
96
|
+
# 带 body / 凭据 / 非 GET 的永远要问(`auto_allowed_for_call`)。
|
|
97
|
+
"web_request": EgressChannel(
|
|
98
|
+
tool="web_request", channel="http", target="url",
|
|
99
|
+
route_for=("curl", "wget", "wget2"), auto=True, audit=True,
|
|
100
|
+
source="framework"),
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
#: 框架自带的出网工具名(测试与环境探测用)。
|
|
104
|
+
FRAMEWORK_TOOLS: frozenset[str] = frozenset(FRAMEWORK_CHANNELS)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
@dataclass(frozen=True, slots=True)
|
|
108
|
+
class Route:
|
|
109
|
+
"""一个 deny 命令族的结构化替身(或"不提供"的理由)。
|
|
110
|
+
|
|
111
|
+
`tools` 非空 -> 提供替身,`hint` 给最小调用示例;
|
|
112
|
+
`tools` 为空 -> 明说"不提供",`reason` 说明为什么。
|
|
113
|
+
"""
|
|
114
|
+
families: tuple[str, ...]
|
|
115
|
+
tools: tuple[str, ...] = ()
|
|
116
|
+
hint: str = ""
|
|
117
|
+
reason: str = ""
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
# 路线表 —— 17 个命令族一个不漏(读者按 `EGRESS_COMMANDS` 反查)。
|
|
121
|
+
#
|
|
122
|
+
# 每条的判据:替身必须兑现得了( 的"敢不敢承诺")。做不到的那几族
|
|
123
|
+
# 明确写"不提供"并给理由 —— 沉默会让模型以为换个写法就能绕过去。
|
|
124
|
+
DENY_ROUTES: tuple[Route, ...] = (
|
|
125
|
+
Route(
|
|
126
|
+
families=("curl", "wget", "wget2"),
|
|
127
|
+
tools=("web_fetch", "web_request"),
|
|
128
|
+
hint=('取网页或下载文件:web_fetch(url="https://…");'
|
|
129
|
+
"要自定义请求头或用非 GET 方法:web_request(url=…, method=…, "
|
|
130
|
+
'headers=…)。'),
|
|
131
|
+
),
|
|
132
|
+
Route(
|
|
133
|
+
families=("ssh", "scp", "sftp"),
|
|
134
|
+
tools=("ssh_exec", "ssh_upload", "ssh_download"),
|
|
135
|
+
hint=('远端执行 ssh_exec(host="…", command="…");'
|
|
136
|
+
'传文件 ssh_upload / ssh_download。'),
|
|
137
|
+
),
|
|
138
|
+
Route(
|
|
139
|
+
families=("nc", "netcat", "ncat", "socat"),
|
|
140
|
+
tools=("net_ports", "ssh_probe", "ssh_forward"),
|
|
141
|
+
hint='端口探活 net_ports(host="…", ports="22,80");'
|
|
142
|
+
'SSH 探活 ssh_probe(host="…");'
|
|
143
|
+
'隧道 ssh_forward(host="…", remote_host="…", remote_port=…)'
|
|
144
|
+
'(本地转发,后台跑)。',
|
|
145
|
+
),
|
|
146
|
+
Route(
|
|
147
|
+
families=("rsync",),
|
|
148
|
+
tools=("ssh_upload", "ssh_download"),
|
|
149
|
+
hint="没有增量同步语义;逐个文件走 ssh_upload / ssh_download。",
|
|
150
|
+
),
|
|
151
|
+
Route(
|
|
152
|
+
families=("aria2c",),
|
|
153
|
+
reason="多连接、分片、BT 下载不属于 agent 必需;单个文件用 web_fetch 下载。",
|
|
154
|
+
),
|
|
155
|
+
Route(
|
|
156
|
+
families=("ftp", "lftp", "cadaver"),
|
|
157
|
+
reason="明文协议与 WebDAV 没有替身;传文件请用 ssh_upload / ssh_download(SFTP)。",
|
|
158
|
+
),
|
|
159
|
+
Route(
|
|
160
|
+
families=("telnet",),
|
|
161
|
+
reason="明文交互没有替身;端口探活请用 net_ports。",
|
|
162
|
+
),
|
|
163
|
+
Route(
|
|
164
|
+
families=("rclone",),
|
|
165
|
+
reason="云盘同步的凭据面太大;应作为 MCP 服务器或单独的 skill 接入。",
|
|
166
|
+
),
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
#: 族 → 路线(派生一次;读者查"每个族都有路线")。
|
|
170
|
+
_ROUTE_BY_FAMILY: dict[str, Route] = {}
|
|
171
|
+
for _r in DENY_ROUTES:
|
|
172
|
+
for _f in _r.families:
|
|
173
|
+
_ROUTE_BY_FAMILY[_f] = _r
|
|
174
|
+
del _r, _f
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def route_of_family(family: str) -> Optional[Route]:
|
|
178
|
+
"""这个命令族有没有路线;没有返回 `None`(读者会红)。"""
|
|
179
|
+
return _ROUTE_BY_FAMILY.get(str(family or "").strip().lower())
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
_DENY_HEAD = (
|
|
183
|
+
"`{name}` 是出网类命令,框架不执行它 —— 这一档是**确定性拒绝**(不问):"
|
|
184
|
+
"出网地板只对框架自己的联网工具生效,放开这条命令等于把地板绕过去。"
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def deny_message(name: str) -> str:
|
|
189
|
+
"""`deny` 档的拒绝话术 —— 按族取路线。不承诺没注册的工具()。
|
|
190
|
+
|
|
191
|
+
`name` 是命令名(小写)。路线表里没有它时退回一句给 `web_fetch` 的
|
|
192
|
+
通用路线 —— 那是安全的那一侧(少给一条具体路线,不是多承诺一个工具)。
|
|
193
|
+
读者钉着"路线表覆盖 `EGRESS_COMMANDS` 全集",所以兜底不会在
|
|
194
|
+
已知族上被走到。
|
|
195
|
+
"""
|
|
196
|
+
n = str(name or "").strip().lower()
|
|
197
|
+
head = _DENY_HEAD.format(name=n)
|
|
198
|
+
route = _ROUTE_BY_FAMILY.get(n)
|
|
199
|
+
if route is None:
|
|
200
|
+
return head + '要做网络请求请用 web_fetch(url="https://…")。'
|
|
201
|
+
if route.tools:
|
|
202
|
+
return head + "要做同样的事请改用:" + route.hint
|
|
203
|
+
return head + "这一类**没有替身**:" + route.reason
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
# 技能工具的声明(manifest 的 `egress:` 段,装载期登记)
|
|
207
|
+
#
|
|
208
|
+
# 运行期只读;重新装载同名工具时就地替换(与 `register_tool` 的幂等
|
|
209
|
+
# 同一条规矩:`/api/restart` 会在同一进程里再登记一遍)。
|
|
210
|
+
_LOCK = threading.Lock()
|
|
211
|
+
_DECLARED: dict[str, EgressChannel] = {}
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
def declare(tool: str, spec: dict, *, source: str = "") -> tuple[bool, str]:
|
|
215
|
+
"""登记一条技能工具的 egress 声明。返回 `(是否成功, 错误原因)`。
|
|
216
|
+
|
|
217
|
+
缺字段 / 类型不对一律拒(出声,不猜默认值)—— 默认值会把
|
|
218
|
+
"没声明"变成"声明成 auto=True",而那是放行的一侧。
|
|
219
|
+
"""
|
|
220
|
+
t = str(tool or "").strip()
|
|
221
|
+
if not t:
|
|
222
|
+
return False, "工具名为空"
|
|
223
|
+
if not isinstance(spec, dict):
|
|
224
|
+
return False, "egress 段不是对象"
|
|
225
|
+
missing = [k for k in EGRESS_FIELDS if k not in spec]
|
|
226
|
+
if missing:
|
|
227
|
+
return False, "缺字段:" + "、".join(missing)
|
|
228
|
+
ch = str(spec.get("channel") or "").strip().lower()
|
|
229
|
+
if not ch:
|
|
230
|
+
return False, "channel 不能为空"
|
|
231
|
+
target = spec.get("target")
|
|
232
|
+
if not isinstance(target, str):
|
|
233
|
+
return False, "target 必须是字符串(固定后端写空串)"
|
|
234
|
+
rf = spec.get("route_for") or ()
|
|
235
|
+
if not isinstance(rf, (list, tuple)) or not all(isinstance(x, str) for x in rf):
|
|
236
|
+
return False, "route_for 必须是字符串列表"
|
|
237
|
+
auto = spec.get("auto")
|
|
238
|
+
audit = spec.get("audit")
|
|
239
|
+
if not isinstance(auto, bool):
|
|
240
|
+
return False, "auto 必须是布尔"
|
|
241
|
+
if not isinstance(audit, bool):
|
|
242
|
+
return False, "audit 必须是布尔"
|
|
243
|
+
with _LOCK:
|
|
244
|
+
_DECLARED[t] = EgressChannel(
|
|
245
|
+
tool=t, channel=ch, target=target,
|
|
246
|
+
route_for=tuple(x.lower() for x in rf),
|
|
247
|
+
auto=auto, audit=audit, source=source or "",
|
|
248
|
+
note=str(spec.get("note") or ""))
|
|
249
|
+
return True, ""
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
def forget_declared(*, source: str = "") -> None:
|
|
253
|
+
"""撤掉声明。`source` 非空只撤那一个技能的(重新装载时先撤后登)。"""
|
|
254
|
+
with _LOCK:
|
|
255
|
+
if not source:
|
|
256
|
+
_DECLARED.clear()
|
|
257
|
+
return
|
|
258
|
+
for k in [k for k, v in _DECLARED.items() if v.source == source]:
|
|
259
|
+
del _DECLARED[k]
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
def declared_channels() -> dict[str, EgressChannel]:
|
|
263
|
+
"""当前已登记的技能工具声明(快照)。"""
|
|
264
|
+
with _LOCK:
|
|
265
|
+
return dict(_DECLARED)
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
def channels() -> dict[str, EgressChannel]:
|
|
269
|
+
"""框架 + 技能,合并后的全表(同名以技能声明为准)。"""
|
|
270
|
+
out = dict(FRAMEWORK_CHANNELS)
|
|
271
|
+
out.update(declared_channels())
|
|
272
|
+
return out
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
def lookup(tool: str) -> Optional[EgressChannel]:
|
|
276
|
+
"""一个工具的出网声明;不是出网工具返回 `None`。"""
|
|
277
|
+
t = str(tool or "")
|
|
278
|
+
ch = declared_channels().get(t)
|
|
279
|
+
return ch if ch is not None else FRAMEWORK_CHANNELS.get(t)
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
def channel_of(tool: str) -> str:
|
|
283
|
+
ch = lookup(tool)
|
|
284
|
+
return ch.channel if ch is not None else ""
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
def auto_allowed(tool: str) -> bool:
|
|
288
|
+
"""分类器能不能自动放行这个工具。
|
|
289
|
+
|
|
290
|
+
没声明 -> `True`(默认行为不变:不是出网工具的那些工具不受本表管辖)。
|
|
291
|
+
声明了且 `auto=False` -> 永不被自动放行(`core/agent_loop` 消费)。
|
|
292
|
+
"""
|
|
293
|
+
ch = lookup(tool)
|
|
294
|
+
return True if ch is None else ch.auto
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
def auto_allowed_for_call(tool: str, args=None) -> bool:
|
|
298
|
+
"""按这一次的具体调用判分类器能不能代答。
|
|
299
|
+
|
|
300
|
+
与 auto_allowed 的差别只有一条:web_request 的只读那一半。
|
|
301
|
+
纯只读 GET(无 body、无凭据)可自动放行;带 body / 凭据 / 非 GET
|
|
302
|
+
的一律要问 —— 一次 POST 的副作用分类器判不了。
|
|
303
|
+
"""
|
|
304
|
+
if not auto_allowed(tool):
|
|
305
|
+
return False
|
|
306
|
+
if str(tool or "") == "web_request":
|
|
307
|
+
a = args if isinstance(args, dict) else {}
|
|
308
|
+
method = str(a.get("method") or "GET").strip().upper()
|
|
309
|
+
if method not in ("GET", "HEAD"):
|
|
310
|
+
return False
|
|
311
|
+
if a.get("body"):
|
|
312
|
+
return False
|
|
313
|
+
if a.get("credential"):
|
|
314
|
+
return False
|
|
315
|
+
return True
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
def audit_enabled(tool: str) -> bool:
|
|
319
|
+
ch = lookup(tool)
|
|
320
|
+
return False if ch is None else ch.audit
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
def route_for_tool(tool: str) -> tuple[str, ...]:
|
|
324
|
+
"""这个工具替代了哪些 deny 命令族(没有就空)。"""
|
|
325
|
+
ch = lookup(tool)
|
|
326
|
+
return ch.route_for if ch is not None else ()
|
package/core/egress_gate.py
CHANGED
|
@@ -71,7 +71,50 @@ from urllib.parse import urlsplit
|
|
|
71
71
|
from core.i18n import t as tr
|
|
72
72
|
from core.i18n import tr_fmt as trf
|
|
73
73
|
|
|
74
|
-
__all__ = ["host_of", "egress_gate", "is_granted"
|
|
74
|
+
__all__ = ["host_of", "egress_gate", "is_granted", "ssh_subject", "gate_for",
|
|
75
|
+
"subject_from_args", "same_site"]
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def same_site(a: str, b: str) -> bool:
|
|
79
|
+
"""两个 URL 是不是同一个站(scheme + 端口 + host,忽略 www. 前缀)。
|
|
80
|
+
|
|
81
|
+
唯一一处实现:`web_fetch` 与 `web_request` 都从这儿取。
|
|
82
|
+
判据见 `web_fetch` 那边的原注释(跨站跳转交回模型、同站跟随)。
|
|
83
|
+
"""
|
|
84
|
+
try:
|
|
85
|
+
pa, pb = urlsplit(str(a)), urlsplit(str(b))
|
|
86
|
+
except ValueError:
|
|
87
|
+
return False
|
|
88
|
+
|
|
89
|
+
def norm(p):
|
|
90
|
+
host = (p.hostname or "").lower()
|
|
91
|
+
if host.startswith("www."):
|
|
92
|
+
host = host[4:]
|
|
93
|
+
port = p.port or (443 if p.scheme == "https" else 80)
|
|
94
|
+
return (p.scheme.lower(), host, port)
|
|
95
|
+
|
|
96
|
+
return norm(pa) == norm(pb)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
#: SSH 目标的 subject 前缀。
|
|
100
|
+
#:
|
|
101
|
+
#: 出网白名单是同一张表(egress kind 同时装 HTTP 主机与 SSH 目标)。
|
|
102
|
+
#: 前缀让两者不撞:裸主机名是 HTTP 的,ssh:user@host 是 SSH 的 -
|
|
103
|
+
#: 信任 example.com 不等于信任 ssh:root@example.com。
|
|
104
|
+
SSH_PREFIX = "ssh:"
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def ssh_subject(user: str, host: str) -> str:
|
|
108
|
+
"""SSH 的授权单位:ssh:user@host - 写入与匹配同形。
|
|
109
|
+
|
|
110
|
+
主机名小写;用户名保持原样(SSH 用户名区分大小写)。
|
|
111
|
+
主机为空则返回空串(调用方 fail-closed)。
|
|
112
|
+
"""
|
|
113
|
+
h = str(host or "").strip().lower()
|
|
114
|
+
if not h:
|
|
115
|
+
return ""
|
|
116
|
+
u = str(user or "").strip() or "default"
|
|
117
|
+
return "%s%s@%s" % (SSH_PREFIX, u, h)
|
|
75
118
|
|
|
76
119
|
|
|
77
120
|
def host_of(url: str) -> str:
|
|
@@ -99,14 +142,13 @@ def is_granted(host: str, path: str = "/") -> bool:
|
|
|
99
142
|
from bus.registry import get_workspace_manager
|
|
100
143
|
wm = get_workspace_manager()
|
|
101
144
|
except Exception as exc: # noqa: BLE001
|
|
102
|
-
print(f"[egress]
|
|
145
|
+
print(f"[egress] wm lookup failed (treating as not allowed): {type(exc).__name__}: {exc}")
|
|
103
146
|
# ① 会话级 ∪ 一次性 ∪ 逐字的持久白名单(调度器每轮投影进 wm)
|
|
104
147
|
try:
|
|
105
148
|
if wm is not None and wm.has_target_grant("egress", h):
|
|
106
149
|
return True
|
|
107
150
|
except Exception as exc: # noqa: BLE001
|
|
108
|
-
print(f"[egress]
|
|
109
|
-
f"{type(exc).__name__}: {exc}")
|
|
151
|
+
print(f"[egress] session authorization lookup failed (treating as not allowed): {type(exc).__name__}: {exc}")
|
|
110
152
|
# ② 通配模式(`*.example.com`)—— 见模块 docstring 里"为什么不能只靠 ①"。
|
|
111
153
|
# 它原来直接 `return` —— 现在下面还有 ③④,改成命中才 return,
|
|
112
154
|
# 读失败不吞掉后面两层(吞了 = 表里的站点反而被问,是"更严"那一侧,
|
|
@@ -116,19 +158,65 @@ def is_granted(host: str, path: str = "/") -> bool:
|
|
|
116
158
|
if matches_any(list_for("egress"), h):
|
|
117
159
|
return True
|
|
118
160
|
except Exception as exc: # noqa: BLE001
|
|
119
|
-
print(f"[egress]
|
|
120
|
-
f"{type(exc).__name__}: {exc}")
|
|
161
|
+
print(f"[egress] allowlist read failed (treating as not allowed): {type(exc).__name__}: {exc}")
|
|
121
162
|
# ③ 预批准域名表
|
|
122
163
|
try:
|
|
123
164
|
from core.egress_preapproved import is_preapproved
|
|
124
165
|
if is_preapproved(h, path):
|
|
125
166
|
return True
|
|
126
167
|
except Exception as exc: # noqa: BLE001
|
|
127
|
-
print(f"[egress]
|
|
128
|
-
f"{type(exc).__name__}: {exc}")
|
|
168
|
+
print(f"[egress] pre-approved table read failed (treating as not allowed): {type(exc).__name__}: {exc}")
|
|
129
169
|
return False
|
|
130
170
|
|
|
131
171
|
|
|
172
|
+
def subject_from_args(tool_name: str, args) -> str:
|
|
173
|
+
"""出网工具的 subject - 审批、授权、自动/完全权限预授权共用这一个算法。
|
|
174
|
+
|
|
175
|
+
SSH 走 ssh:user@host(用户名取自参数,缺省取配置条目);
|
|
176
|
+
其余按 URL 取主机名。两处若各算各的,"批过却不生效"会再次出现。
|
|
177
|
+
"""
|
|
178
|
+
a = args if isinstance(args, dict) else {}
|
|
179
|
+
name = str(tool_name or "")
|
|
180
|
+
if name.startswith("ssh_"):
|
|
181
|
+
user = str(a.get("user") or "")
|
|
182
|
+
if not user:
|
|
183
|
+
try:
|
|
184
|
+
from core import ssh_config
|
|
185
|
+
user = str(ssh_config.resolve_entry(
|
|
186
|
+
str(a.get("key_name") or "")).get("user") or "")
|
|
187
|
+
except Exception: # noqa: BLE001
|
|
188
|
+
user = ""
|
|
189
|
+
return ssh_subject(user, str(a.get("host") or ""))
|
|
190
|
+
return host_of(str(a.get("url") or ""))
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def gate_for(subject: str, *, tool_name: str, body: str) -> Optional[dict]:
|
|
194
|
+
"""按给定的 subject 过闸(SSH 目标用它;HTTP 走 egress_gate)。
|
|
195
|
+
|
|
196
|
+
放行返回 None;要问返回待审批载荷。subject 与 data/allowlist.json /
|
|
197
|
+
会话授权比的是同一个串 - 写入与匹配同形。
|
|
198
|
+
"""
|
|
199
|
+
s = str(subject or "").strip()
|
|
200
|
+
if not s:
|
|
201
|
+
# 取不到 subject 是调用方的 bug(fail-closed 的方向在调用方:
|
|
202
|
+
# 它应该直接拒这次调用,而不是拿一个空目标去问用户)。
|
|
203
|
+
return None
|
|
204
|
+
if is_granted(s):
|
|
205
|
+
return None
|
|
206
|
+
from core.approval import pending_payload
|
|
207
|
+
|
|
208
|
+
return pending_payload(
|
|
209
|
+
"egress",
|
|
210
|
+
body=body,
|
|
211
|
+
ask_index=_ask_index(),
|
|
212
|
+
footer=True,
|
|
213
|
+
subject=s,
|
|
214
|
+
detail=s,
|
|
215
|
+
tool=tool_name,
|
|
216
|
+
status="pending_egress_approval",
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
|
|
132
220
|
def _ask_index(kind: str = "egress") -> int:
|
|
133
221
|
"""这是第几次问起 —— 升级项(选项 5)按它决定出不出现。
|
|
134
222
|
|
|
@@ -210,6 +210,7 @@ _GOV_INTL: tuple[str, ...] = (
|
|
|
210
210
|
"bls.gov",
|
|
211
211
|
"bea.gov",
|
|
212
212
|
"federalreserve.gov",
|
|
213
|
+
"fred.stlouisfed.org", # 圣路易斯联储 FRED:序列级宏观/市场数据
|
|
213
214
|
"eur-lex.europa.eu",
|
|
214
215
|
"law.cornell.edu",
|
|
215
216
|
"sec.gov",
|
|
@@ -234,8 +235,12 @@ _PLATFORM: tuple[str, ...] = (
|
|
|
234
235
|
# 办公平台的开放平台 —— 只收开发者文档,不收办公内容
|
|
235
236
|
# (文档 / 表格 / 会话全要登录,抓回来是登录页,理由同表 4)
|
|
236
237
|
"open.feishu.cn",
|
|
238
|
+
"open.larksuite.com", # 飞书国际版 Lark 的开放平台
|
|
237
239
|
"open.dingtalk.com",
|
|
238
|
-
"developer.work.weixin.qq.com",
|
|
240
|
+
"developer.work.weixin.qq.com", # 企业微信开发者文档
|
|
241
|
+
"developers.weixin.qq.com", # 微信开发者文档(小程序 / 智能对话 / 开放平台)
|
|
242
|
+
"open.weixin.qq.com", # 微信开放平台入口
|
|
243
|
+
"core.telegram.org", # Telegram Bot API 官方文档
|
|
239
244
|
"developers.notion.com",
|
|
240
245
|
"api.slack.com",
|
|
241
246
|
"developers.zoom.us",
|
|
@@ -275,10 +280,61 @@ _FINANCE_CN: tuple[str, ...] = (
|
|
|
275
280
|
"eastmoney.com",
|
|
276
281
|
)
|
|
277
282
|
|
|
278
|
-
#:
|
|
283
|
+
#: 表 9|系统与硬件文档
|
|
284
|
+
#:
|
|
285
|
+
#: 负责:装驱动 / 配开发机 / 查系统调用时用户会贴的官方站 —— 显卡与芯片厂商
|
|
286
|
+
#: 的驱动下载页、Linux 内核与 man pages、单板机文档、创意软件帮助中心、
|
|
287
|
+
#: 游戏平台的开发者文档、开放地图与路线规划的文档/接口。
|
|
288
|
+
#: 不收:第三方驱动下载站(驱动精灵、各种"驱动下载"聚合站)、论坛与问答
|
|
289
|
+
#: (内容随时变、也不是官方口径)、需要登录才看得到的开发者后台
|
|
290
|
+
#: (partner.steamgames.com 的登录区抓回来是登录页,但它的公开文档页
|
|
291
|
+
#: 与 Valve 开发者 wiki 是事实标准,故收)。
|
|
292
|
+
#: 中文站与英文站内容同源,但域名是不同身份,逐条列(本表不做子域/别名推导)。
|
|
293
|
+
_SYSTEM_HW: tuple[str, ...] = (
|
|
294
|
+
# 显卡与芯片厂商驱动(含中文站,域名是不同身份)
|
|
295
|
+
"nvidia.com",
|
|
296
|
+
"nvidia.cn",
|
|
297
|
+
"amd.com",
|
|
298
|
+
"intel.com",
|
|
299
|
+
"intel.cn",
|
|
300
|
+
# 单板机 / 嵌入式开发板(官网与文档子域各自是独立身份,逐条列)
|
|
301
|
+
"raspberrypi.com",
|
|
302
|
+
"docs.nvidia.com", # Jetson 官方文档(nvidia.com 精确匹配不覆盖子域)
|
|
303
|
+
"developer.nvidia.com", # Jetson 开发者下载区
|
|
304
|
+
"arduino.cc",
|
|
305
|
+
"docs.arduino.cc",
|
|
306
|
+
"st.com", # STM32 Nucleo 官方页(www 形式另列)
|
|
307
|
+
"www.st.com",
|
|
308
|
+
"beagleboard.org", # BeagleBone 官方站
|
|
309
|
+
"www.beagleboard.org",
|
|
310
|
+
"beaglebone.org", # 官方别名(301 到 beagleboard.org)
|
|
311
|
+
"pjrc.com", # Teensy 官方站(PJRC)
|
|
312
|
+
"www.pjrc.com",
|
|
313
|
+
# Linux / GNU 核心文档
|
|
314
|
+
"kernel.org",
|
|
315
|
+
"man7.org",
|
|
316
|
+
"gnu.org",
|
|
317
|
+
# Android 源码(developer.android.com 已在表 6)
|
|
318
|
+
"source.android.com",
|
|
319
|
+
# HarmonyOS 官网(开发者入口 developer.huawei.com 已在表 6)
|
|
320
|
+
"harmonyos.com",
|
|
321
|
+
# 创意软件帮助中心
|
|
322
|
+
"adobe.com",
|
|
323
|
+
"helpx.adobe.com",
|
|
324
|
+
# 游戏平台开发者文档 / 文献库
|
|
325
|
+
"partner.steamgames.com",
|
|
326
|
+
"developer.valvesoftware.com",
|
|
327
|
+
# 开放地图与路线规划(实测 web_fetch 能抓正文/JSON;
|
|
328
|
+
# 百度/高德地图界面是 JS 壳 + 人机验证,不收)
|
|
329
|
+
"openstreetmap.org", # 地点/POI/坐标的文字结果
|
|
330
|
+
"project-osrm.org", # OSRM 路线规划 API 文档
|
|
331
|
+
"router.project-osrm.org", # 路线规划 API:返回距离/时长 JSON
|
|
332
|
+
)
|
|
333
|
+
|
|
334
|
+
#: 九张表拼成一张查询集 —— 对外只有一个名字,分表只是让每一份能说清自己管什么。
|
|
279
335
|
PREAPPROVED_HOSTS: tuple[str, ...] = (
|
|
280
336
|
_PROGRAMMING + _ACADEMIC + _REFERENCE + _GOV_CN + _GOV_INTL + _PLATFORM
|
|
281
|
-
+ _ARTS + _FINANCE_CN
|
|
337
|
+
+ _ARTS + _FINANCE_CN + _SYSTEM_HW
|
|
282
338
|
)
|
|
283
339
|
|
|
284
340
|
#: 带路径的条目 —— 做法是 `host + 路径前缀`。
|