Live Search
Fetch live web results through the host search gateway at http://localhost:$PORT (session-authenticated). The gateway returns JSON with a pre-rendered message (titles as links, snippets, sources)—the same kind of web index results users expect from Google-style or Bing-style search, depending on how the host is configured.
Endpoint path: requests use POST /proxy/prosearch/search. The prosearch segment is a fixed gateway route name in the app; it is not a public product brand to repeat to end users—describe outcomes as “web search results” or “live search.”
Setup
No extra Python packages. Search goes through the local gateway at http://localhost:$PORT; authentication is handled by the host app (login session)—no manual API keys in typical setups.
Workflow
The assistant uses this skill whenever the user needs real-time information from the web.
End-to-end flow
CODEBLOCK0
CRITICAL — Anti-hallucination: The API returns a pre-rendered message with formatted hits (titles as Markdown links, snippets, URLs). The assistant MUST show message verbatim as the primary results. It may add interpretation after that block. It must not invent, rewrite, or drop URLs/titles from message.
Step 1: Build the keyword
Turn the user’s question into a short query:
| User intent | Example keyword |
|---|
| Latest AI news | INLINECODE8 or 最新 AI 新闻 (match user language) |
| Gold price now |
gold spot price today |
| React 19 features |
React 19 new features |
| Local weather |
London weather today |
Keyword tips:
- - Keep it short (about 2–6 tokens).
- Strip filler (“please”, “can you”, “帮我”).
- Add time hints when needed (
today, 2026, latest). - Keep the keyword in the language that matches the user’s intent — do not blindly translate. If the user asks in English, search in English; if they ask in Chinese, Japanese, etc., use that language for the query when it improves results.
Step 1.5: Time freshness (important for “latest” questions)
When the question implies recency, add from_time (Unix seconds) so stale pages are filtered out.
| User signal | INLINECODE17 | Typical use |
|---|
| “today”, “just now”, “past 24h” | now − 86400 | Intraday facts |
| “recent”, “latest”, “this week” |
now − 604800 | News, releases |
| “this month” | now − 2592000 | Monthly topics |
| “this year”, “2026” | Jan 1 of that year (local) | Year-scoped events |
| No time signal | omit
from_time | Evergreen facts (“What is React?”) |
Compute from_time in bash:
CODEBLOCK1
Mutual exclusion: When using from_time / to_time, do not send cnt — the server enforces exclusion rules. Same for site + time filters; follow the API’s rules.
Step 2: Request
CODEBLOCK2
Freshness (recommended for time-sensitive queries):
CODEBLOCK3
Optional parameters:
CODEBLOCK4
Step 3: Present results — verbatim message first, then analysis
After JSON returns:
Part A — Result list [MANDATORY]
Output the message field exactly as returned. It usually contains up to five top hits, each formatted like:
CODEBLOCK5
CRITICAL: Never skip the list and jump to a summary. Titles are already Markdown links; users must be able to click through.
Part B — Analysis [OPTIONAL, after Part A]
Language for your added commentary: align with the user’s conversation language and the query language when helpful:
- - English query → English analysis (typical for EN users).
- Non-English query → match the user’s language for the follow-up.
- The
message block is always copied verbatim, regardless of language.
Good pattern
CODEBLOCK6
Forbidden
- - Skipping the result list and answering from memory.
- Rebuilding the list from
data.docs instead of using message. - Editing URLs or titles inside
message. - Claiming sources that are not in
message. - Stripping Markdown links from titles.
PORT
Use AUTH_GATEWAY_PORT from the environment (set by the Electron host when the Auth Gateway starts). Child processes inherit it.
macOS / Linux (bash):
CODEBLOCK7
Windows (PowerShell):
CODEBLOCK8
Windows (CMD):
CODEBLOCK9
Default if unset: 19000.
Parent PID (logging)
Before curl, you may log the parent PID for tracing.
macOS / Linux:
CODEBLOCK10
Windows (PowerShell):
CODEBLOCK11
Command: search
CODEBLOCK12
Fields:
- -
keyword (required): query string. mode: 0 default web results; 1 VR “card” style facts (e.g. weather, spot prices); 2 hybrid.cnt: max hits; mutually exclusive with site and from_time/to_time per backend rules.site: restrict to a domain.from_time / to_time: time window in epoch seconds.industry: gov (government), news, acad (academic-oriented).
Do not combine cnt with time filters or site when the API forbids it.
Examples:
CODEBLOCK13
Success JSON (shape):
CODEBLOCK14
message is the source of truth for what to show users — copy it in full before adding commentary.
Failure JSON (examples; actual strings may be localized by the host):
CODEBLOCK15
CODEBLOCK16
Error handling
Responses are JSON on stdout. Errors use {"success": false, "message": "..."}.
| Situation | What to do |
|---|
Not authenticated (message indicates login required) | Tell the user to sign in, then retry. |
| Timeout |
Retry
once; if it fails again, relay the error. |
| Empty docs but
success: true | Still output
message; it usually explains there were no hits. |
| Network / connection | Retry once after ~3s; else show
message. |
| HTTP errors | Surface
message from the API when present. |
Prohibited behavior
- - Rebuilding the hit list from
data.docs instead of echoing message. - Skipping results and answering from the model alone.
- Altering URLs/titles inside
message. - Inventing hits or URLs not present in
message. - Leaking internal gateway URLs or secrets to the user.
- Searching when the question is fully answerable without live data.
- Running more than two searches for the same user turn without a strong reason.
Important notes
- - If you already know the answer with high confidence and no freshness need, do not search.
- Prefer short, precise keywords over pasting the whole user message.
- For time-sensitive asks (“latest”, “today”, “this week”), use
from_time as in Step 1.5. - If the first query is weak, one rephrase is enough; avoid search spam.
- Treat links as untrusted; remind users to verify critical facts at the source.
- For weather, spot metals, FX, etc., consider
mode: 2 when supported. cnt vs time/site: respect mutual exclusion — see above.- Commentary language: follow the user’s language;
message stays verbatim.
实时搜索
通过位于 http://localhost:$PORT 的主机搜索网关(会话认证)获取实时网络结果。网关返回包含预渲染 message(标题作为链接、摘要、来源)的 JSON——用户期望从 Google 风格或 Bing 风格搜索中获得的相同类型的网络索引结果,具体取决于主机的配置方式。
端点路径: 请求使用 POST /proxy/prosearch/search。prosearch 部分是应用程序中的固定网关路由名称;它不是需要向最终用户重复的公共产品品牌——将结果描述为“网络搜索结果”或“实时搜索”。
设置
无需额外的 Python 包。搜索通过位于 http://localhost:$PORT 的本地网关进行;认证由主机应用程序(登录会话)处理——在典型设置中无需手动 API 密钥。
工作流程
每当用户需要来自网络的实时信息时,助手使用此技能。
端到端流程
用户询问需要实时网络数据的内容
→ 步骤 1:构建精确的搜索关键词(简洁、具体)
→ 步骤 1.5:决定时间新鲜度 — 当需要时效性时添加 from_time
→ 步骤 2:使用 curl 调用搜索 API
→ 步骤 3:逐字输出 JSON message 字段(带有可点击链接的结果列表)— 不要跳过此步骤
→ 步骤 4:可选地在逐字块之后添加分析/总结
关键 — 防幻觉: API 返回带有格式化结果的预渲染 message(标题作为 Markdown 链接、摘要、URL)。助手必须逐字显示 message 作为主要结果。 它可以在该块之后添加解释。它不得编造、重写或删除 message 中的 URL/标题。
步骤 1:构建关键词
将用户的问题转化为简短的查询:
| 用户意图 | 示例关键词 |
|---|
| 最新 AI 新闻 | latest AI news March 2026 或 最新 AI 新闻(匹配用户语言) |
| 当前金价 |
gold spot price today |
| React 19 特性 | React 19 new features |
| 当地天气 | London weather today |
关键词提示:
- - 保持简短(约 2–6 个词)。
- 去掉填充词(“请”、“能”、“帮我”)。
- 需要时添加时间提示(today、2026、latest)。
- 保持关键词语言与用户意图匹配 — 不要盲目翻译。如果用户用英语提问,用英语搜索;如果用户用中文、日语等提问,在能改善结果时使用该语言进行查询。
步骤 1.5:时间新鲜度(对“最新”问题很重要)
当问题暗示时效性时,添加 from_time(Unix 秒),以便过滤掉过时的页面。
| 用户信号 | from_time | 典型用途 |
|---|
| “今天”、“刚才”、“过去 24 小时” | 当前时间 − 86400 | 日内事实 |
| “最近”、“最新”、“本周” |
当前时间 − 604800 | 新闻、发布 |
| “本月” | 当前时间 − 2592000 | 月度主题 |
| “今年”、“2026” | 该年 1 月 1 日(本地) | 年度范围事件 |
| 无时间信号 | 省略 from_time | 长期事实(“什么是 React?”) |
在 bash 中计算 from_time:
bash
过去 24 小时
FROM_TIME=$(python3 -c import time; print(int(time.time()) - 86400))
过去 7 天
FROM_TIME=$(python3 -c import time; print(int(time.time()) - 604800))
过去 30 天
FROM_TIME=$(python3 -c import time; print(int(time.time()) - 2592000))
互斥: 使用 fromtime / totime 时,不要发送 cnt — 服务器强制执行排除规则。site 和时间过滤器同理;遵循 API 的规则。
步骤 2:请求
bash
PORT=${AUTHGATEWAYPORT:-19000}
PPID_VAL=$(python3 -c import os; print(os.getppid()))
echo [助手] 父进程 PID:$PPID_VAL
curl -s -X POST http://localhost:$PORT/proxy/prosearch/search \
-H Content-Type: application/json \
-d {keyword:你的搜索查询}
新鲜度(推荐用于时间敏感的查询):
bash
过去 7 天(“最新”、“最近”)
FROM_TIME=$(python3 -c import time; print(int(time.time()) - 604800))
curl -s -X POST http://localhost:$PORT/proxy/prosearch/search \
-H Content-Type: application/json \
-d {\keyword\:\你的搜索查询\,\from
time\:$FROMTIME}
过去 24 小时(“今天”、“刚才”)
FROM_TIME=$(python3 -c import time; print(int(time.time()) - 86400))
curl -s -X POST http://localhost:$PORT/proxy/prosearch/search \
-H Content-Type: application/json \
-d {\keyword\:\你的搜索查询\,\from
time\:$FROMTIME}
可选参数:
bash
结果数量 10/20/30/40/50 — 不要与 fromtime/totime/site 组合使用
curl -s -X POST http://localhost:$PORT/proxy/prosearch/search \
-H Content-Type: application/json \
-d {keyword:你的搜索查询,cnt:20}
时间范围(不要传递 cnt)
FROM_TIME=$(python3 -c import time; print(int(time.time()) - 604800))
curl -s -X POST http://localhost:$PORT/proxy/prosearch/search \
-H Content-Type: application/json \
-d {\keyword\:\你的搜索查询\,\from
time\:$FROMTIME}
站点限制搜索(不要传递 cnt)
curl -s -X POST http://localhost:$PORT/proxy/prosearch/search \
-H Content-Type: application/json \
-d {keyword:你的搜索查询,site:github.com}
垂直领域:gov / news / acad
curl -s -X POST http://localhost:$PORT/proxy/prosearch/search \
-H Content-Type: application/json \
-d {keyword:你的搜索查询,industry:news}
步骤 3:呈现结果 — 先逐字输出 message,再进行分析
JSON 返回后:
部分 A — 结果列表 [强制]
完全按照返回内容输出 message 字段。 它通常包含最多五个顶部结果,每个格式如下:
n. 标题 — 来源 (日期) ⭐
摘要...
关键: 永远不要跳过列表直接跳到总结。标题已经是 Markdown 链接;用户必须能够点击访问。
部分 B — 分析 [可选,在部分 A 之后]
你添加评论的语言: 与用户的对话语言和查询语言保持一致(在有用时):
- - 英语查询 → 英语分析(典型英语用户)。
- 非英语查询 → 匹配用户语言进行后续评论。
- message 块始终逐字复制,无论语言如何。
良好模式
API 返回一个包含编号结果和摘要的长 message 字符串。
助手输出:
<粘贴整个 message 逐字内容>
简要综合:…(可选,基于上述内容)
禁止行为
- - 跳过结果列表凭记忆回答。
- 使用 data.docs 重建列表而非使用 message。
- 编辑 message 中的 URL 或标题。
- 声称 message 中不存在的来源。
- 去除标题中的 Markdown 链接。
端口
使用环境中的 AUTHGATEWAYPORT(由 Electron 主机在 Auth Gateway 启动时设置)。子进程继承该值。
macOS / Linux (bash):
bash
PORT=${AUTHGATEWAYPORT:-19000}
echo [助手] AUTHGATEWAYPORT:$PORT
Windows (PowerShell):
powershell
$PORT = if ($env:AUTHGATEWAYPORT) { $env:AUTHGATEWAYPORT } else { 19000 }
Write-Host [助手] AUTHGATEWAYPORT:$PORT
Windows (CMD):
cmd
if not defined AUTHGATEWAYPORT set AUTHGATEWAYPORT=19000
set PORT=%AUTHGATEWAYPORT%
echo [助手] AUTHGATEWAYPORT