Repository navigation
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
…f the DSH gateway route Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…posal Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…ail on Responses Co-Authored-By: Claude <noreply@anthropic.com>
…eclare strict mode on the route Co-Authored-By: Claude <noreply@anthropic.com>
|
@frf12 A commitment on timing: once you, as primary coordinator, agree with the direction of this RFC, we will open the first implementation PR within 24 hours. We will not wait for this PR to be merged. That first PR covers step 2 of the delivery order in section 9: the DSH plugin registers the 关于时间的承诺:主责协调人同意本 RFC 的方向后,我们会在 24 小时内提交第一个实现 PR,不等本 PR 合并。第一个 PR 对应第 9 节交付顺序的第 2 步:插件登记 |
hidb4ai
left a comment
There was a problem hiding this comment.
Reviewed 936ec20 as a design-only change. The bilingual proposal separates the model route, per-session behavior, managed service ownership, distribution, and unverified host acceptance. Both RFC pages compile as MDX and their relative references resolve. There are no implemented table or interface additions. Prototype measurements remain author-supplied evidence, not acceptance of an implementation in this PR. CI still needs to recover from the workflow-actions-check lockfile failure and run the selected checks before merge.
|
@hidb4ai Thanks for the review. The preflight failure was the 感谢审阅。preflight 失败来自旧基线上的 |
knqiufan
left a comment
There was a problem hiding this comment.
Overall the direction makes a lot of sense: bringing gateway-grade whole-turn capture and low token overhead into a single-plugin DSH install experience directly solves the biggest usability gap today.
Before moving into implementation, there are a few alignment and UX points against the current codebase that I'd recommend clarifying in the RFC:
-
Contradiction on where the upstream API key is stored
- Guide Step 3 says the upstream model key is stored in DSH's credential store and not written to a config file, while Section 6 says it is written to the service's
0600env file (and Section 2 putsPOWERCONTEXT_DSH_GATEWAY_KEYin DSH's credential store). - Please align both sections to clearly distinguish the DSH → local gateway key (DSH credential store) from the gateway/Core → upstream API key (
0600service env file).
- Guide Step 3 says the upstream model key is stored in DSH's credential store and not written to a config file, while Section 6 says it is written to the service's
-
Alignment with existing
powercontext serviceconstraints & Desktop coexistence- Env file identity pinning:
powercontext servicebinds the exactEnvironmentFileIdentity(inode/size/mtime) into the service definition. Editing models or rotating keys in the panel will invalidate the registered service unless it re-installs/reconciles and restarts the service — and it should merge rather than overwrite existing user env vars. - UDS vs. loopback HTTP:
service/launcher.pycurrently rejects UDS for personal services. If loopback HTTP is used instead,PC_GATEWAY_INJECTION=onandPC_GATEWAY_SEDIMENT=onneed to be explicitly enabled. - Coexistence with PowerContext Desktop: Desktop also manages the user's
powercontext servicewith its own runtime path. Please clarify ownership and upgrade behavior when both Desktop and the DSH plugin are installed.
- Env file identity pinning:
-
DSH Web
ownerLocalgate & panel write-operation security boundary- On
dsh web,status-bridge.tscurrently returns403 owner_local_unverifiedunlessownerLocal: trueorPOWERCONTEXT_DSH_OWNER_LOCAL=trueis configured. A user following Guide Step 1 ondsh webwill be blocked at Step 2 before they can click Prepare or open Models. - At the same time, the panel is expanding from read-only status into privileged writes (downloading/unpacking runtimes, registering a login service, writing
0600key files, modifying DSH profile providers). The RFC should specify the onboarding flow and authorization/confirmation boundary fordsh webvs. DSH Desktop.
- On
-
Per-session switching edge cases & UI uninstall cleanup
- In
integrations/dsh/plugins/powercontext/src/index.ts,companion-memory(dsh-pet) injectsprepared-contextblocks that the gateway rejects and is currently gated only by globalpromptRecall; it should be covered by per-session switching. - Please also confirm whether DSH supports per-session disabling for
guidanceandskills(not just process-wide registration), and whether uninstalling via DSH UI invokes a plugin hook to remove thepowercontext-gatewayprovider from the user's profile (otherwise a broken orphan model stays in the selector).
- In
-
UX regression: buffered SSE replay instead of live token streaming
pc-gatewaybuffers the full upstream response forbefore_releasebefore replaying SSE. On the gateway route, users will see no streaming tokens until the entire turn finishes — which feels like a hang on reasoning models (e.g. DeepSeek) or long code replies, and can hit client timeouts orresponse_buffer_limit_exceeded.- This should at least be called out in Drawbacks, and it's worth evaluating whether
disabledprotection mode can support live streaming passthrough.
-
Failure UX & first-run onboarding friction
- Fail-closed when stopped: Unlike the fail-open plugin path, a stopped service or unreachable Core breaks model calls on the gateway route. Please clarify whether
PC_GATEWAY_DEGRADE=passthroughis enabled indisabledmode, and define clear error recovery prompts (start service / switch model). - First-run usability: Asking users to manually choose
Responsesvs.Chat Completionsand enter raw URLs is error-prone; provider presets (DeepSeek, OpenAI, Custom) plus a Test connection button would significantly reduce setup failures. It would also help to clarify which model Core uses for background extraction when multiple models are configured, and to treat deduplication + China-accessible download mirrors for the ~205 MB runtime archive as a prerequisite for Step 5 rather than an open question.
- Fail-closed when stopped: Unlike the fail-open plugin path, a stopped service or unreachable Core breaks model calls on the gateway route. Please clarify whether
整体方向非常认可:把 gateway 的完整回合采集和低 Token 开销整合进 DSH 单插件的安装体验里,切中了目前最大的易用性痛点。
在进入实现前,结合当前仓库实现和用户体验,有 6 点建议在 RFC 中先明确或对齐:
-
上游 API Key 存储位置描述前后不一致
- Guide 第 3 步写上游模型密钥进入 DSH 凭据存储、不写配置文件,但第 6 节写上游密钥通过
0600服务环境文件传给服务(第 2 节进 DSH 凭据存储的是POWERCONTEXT_DSH_GATEWAY_KEY)。 - 建议统一表述,明确区分 DSH → 本地 gateway 的鉴权密钥(DSH 凭据存储)与 gateway/Core → 上游模型的 API Key(
0600服务环境文件)。
- Guide 第 3 步写上游模型密钥进入 DSH 凭据存储、不写配置文件,但第 6 节写上游密钥通过
-
与现有
powercontext service约束及 Desktop 的共存问题- 环境文件指纹绑定:
powercontext service将EnvironmentFileIdentity(inode/size/mtime)严格绑定在服务定义中。用户在面板修改模型或密钥后,服务定义会失效,必须触发重新install/reconcile 并重启服务;同时写入环境文件时需合并保留用户已有变量,避免覆盖。 - UDS 与回环 HTTP:
service/launcher.py目前禁止个人服务使用 UDS;如果采用回环 HTTP 模式,需要显式开启PC_GATEWAY_INJECTION=on和PC_GATEWAY_SEDIMENT=on。 - 与 PowerContext Desktop 共存:Desktop 同样管理本机
powercontext service并绑定自身运行时路径,建议明确两者同时安装时的服务所有权与升级策略。
- 环境文件指纹绑定:
-
DSH Web 的
ownerLocal门禁与面板写操作安全边界- 在
dsh web上,status-bridge.ts默认在未配置ownerLocal: true(或环境变量)时返回403 owner_local_unverified,这会导致按 Guide 第 1 步装完插件的 Web 用户在第 2 步直接被拦住,无法点“准备”或配置模型。 - 同时,面板从“只读状态展示”扩展为“高权限写操作”(下载解包运行环境、注册系统登录自启服务、写入含密钥的
0600文件、修改 DSH profile 配置),建议明确dsh web与 DSH Desktop 两种宿主下的引导方式和鉴权/确认边界。
- 在
-
按会话切换的遗漏项与 UI 卸载清理机制
- 现有
integrations/dsh/plugins/powercontext/src/index.ts中,companion-memory(dsh-pet)会注入被 gateway 拒绝的prepared-context块,目前仅受全局promptRecall控制,改为按会话切换时需一并处理。 - 建议确认 DSH 的
guidance和skills是否支持按会话关闭(而非进程级全局注册),以及用户在 DSH UI 卸载插件时是否存在可用的卸载钩子来清理 profile 中的powercontext-gateway路由,避免模型选择器里残留不可用的孤儿项。
- 现有
-
流式输出退化为“整轮缓冲回放”的用户体验落差
pc-gateway因before_release机制会先完整缓冲上游响应再回放 SSE,用户在 gateway 路由下会失去实时逐字流式输出——在思考模型(如 DeepSeek)或长代码生成场景下会表现为长时间卡住无响应,甚至触发客户端超时或response_buffer_limit_exceeded。- 建议至少在 Drawbacks 中明确说明这一体验代价,并评估在
disabled保护模式下是否支持实时流式透传。
-
故障降级体验与首次配置门槛
- 停机/异常体验:与插件路径 fail-open 不同,gateway 路由在用户手动停止服务或 Core 不可达时会直接阻断对话。建议明确
disabled模式下是否开启PC_GATEWAY_DEGRADE=passthrough,并在报错时给出清晰的恢复引导(启动服务 / 切回直连模型)。 - 首次配置易用性:让普通用户自行判断
Responses还是Chat Completions并手填完整地址容易出错,建议模型页提供常见供应商预设(DeepSeek、OpenAI、自定义)与 测试连接 按钮;同时说明多模型配置下 Core 后台抽取具体复用哪个模型及费用预期;并把 ~205 MB 运行时归档的去重与国内可达下载镜像作为第 5 步交付的前置条件,而非留作未决问题。
- 停机/异常体验:与插件路径 fail-open 不同,gateway 路由在用户手动停止服务或 Core 不可达时会直接阻断对话。建议明确
frf12
left a comment
There was a problem hiding this comment.
One clarification on the Scope-resolution fallback in section 4; the scenario and the existing behavior are described inline.
|
|
||
| ## 4. Scope | ||
|
|
||
| The plugin sends the Scope it resolves for the current working directory to the gateway in `X-PowerContext-Scope-ID`, so the gateway's recall and capture land in the same Scope as the `/pc` commands. Without a resolved Scope the header is not sent and the gateway uses its default Scope. The gateway's default Scope is set to the Server's default Scope. |
There was a problem hiding this comment.
Could we clarify whether “without a resolved Scope” includes a failed or timed-out resolution request?
The existing DSH resolver already asks Core to resolve the workspace binding with the Server-default fallback enabled. When resolution fails or returns no usable Scope, the current plugin skips recall and capture; it does not select another Scope itself.
For example:
- The current workspace is bound to Scope A.
- Its Scope-resolution request fails or times out.
- If the plugin follows this fallback by omitting
X-PowerContext-Scope-ID, the gateway uses its instance default, Scope D. - Recall and capture then run in D rather than A, even though the workspace binding has not changed.
A successful resolution to the Server's default Scope and a failure to resolve the intended Scope are different outcomes. As written, this sentence could turn a resolution failure into recall from, or a write to, another Scope. Could you clarify the intended failure behavior here so it preserves the existing Scope boundary?
There was a problem hiding this comment.
You are right, and the sentence was wrong as written: it would have turned a resolution failure into recall from, and writes to, the gateway instance default. That was not intended. Fixed in 462971c9d (both languages):
- Resolution keeps using the existing resolver (workspace binding, Server-default fallback allowed). When it succeeds, the plugin always sends the resolved Scope explicitly in
X-PowerContext-Scope-ID, including when the result is the Server default. - When the request fails, times out, or returns no usable Scope, the plugin sends
X-PowerContext-Turn: internalfor that request. The gateway already treats such a request as a non-turn: it forwards it without preparing, injecting, or capturing. This keeps the current plugin behavior (skip recall and capture) and the model call still works. - So a request from the plugin never reaches the gateway instance default Scope. In your example the turn in the workspace bound to A is forwarded without memory; nothing is read from or written to D.
I also changed the delivery list so the Scope header ships in the same change as the route registration (items 2 and 3 together). Otherwise there would be a window in which the route exists without the header.
Not verified yet: I read the internal handling in ingress.rs / executor.rs but have not run this failure path through DSH. The implementation PR will cover it with a test.
你说得对,原句有误:按原文,解析失败会变成从 gateway 实例默认 Scope 召回并向它写入,这不是本意。已在 462971c9d 修正(中英同步):解析成功时始终显式发送解析出的 Scope(包括结果是 Server 默认 Scope 的情况);解析失败、超时或无可用 Scope 时,插件为该请求发送 X-PowerContext-Turn: internal,gateway 只转发,不召回、不注入、不采集,与插件现有行为一致。交付顺序也改为 Scope 请求头与路由登记在同一个改动中交付。该失败路径目前只读过 gateway 代码,尚未经 DSH 实际运行,会在实现 PR 中用测试覆盖。
… gateway route Co-Authored-By: Claude <noreply@anthropic.com>
|
@jasper-yl Thanks for the RFC, the real-host measurements, and the quick fix on the Scope fallback ( @knqiufan Regarding your point 2 on service env/config ownership, For Step 4 (
中文摘要:感谢 RFC、实测数据以及对 Scope fallback 的快速修正( 关于 @knqiufan 提到的第 2 点( 另外在进入 Step 4 之前,有三个不阻塞 Step 2 的设计点希望和 @jasper-yl 提前对齐:
|
|
@frf12 Thanks. Starting now; the Step 2 implementation PR will be open by 2026-12-04 18:28 UTC (24 hours from your comment). It will include the Scope header with the failure behavior from I will answer your three Step 4 points and @knqiufan's remaining points in a separate comment, with the matching RFC changes. 收到,现在开始。Step 2 的实现 PR 会在 2026-12-04 18:28 UTC 前提交(自你的评论起 24 小时),其中包含 Scope 请求头(失败行为按 |
…t, streaming, and failure behavior Co-Authored-By: Claude <noreply@anthropic.com>
|
@frf12 @knqiufan Thanks both. The RFC is updated in @frf12's three points for Step 4 — all three adopted.
@knqiufan's points
Not verified, and stated as such in the RFC: the Scope failure path on a real host, requests from other plugins such as dsh-pet through the route, and first-output delay on the route. 中文摘要:RFC 已在 |
… DSH gateway route Co-Authored-By: Claude <noreply@anthropic.com>
|
The Step 2 implementation PR is open: #3020. It covers delivery items 2 and 3 (route registration, per-session switching including Two items I listed as unverified in my previous comment are now measured on a real DSH host and recorded in the RFC (
Step 2 的实现 PR 已提交:#3020,覆盖第 2、3 项交付。上一条评论中标为未验证的两项已在真实 DSH 宿主上测量并写入 RFC( |
…patch Co-Authored-By: Claude <noreply@anthropic.com>
|
@jasper-yl Agreed on delivery item 7 (live streaming forwarding in 中文摘要:同意第 7 项交付( |
|
@frf12 Thanks. Before writing item 7 properly I built a throwaway prototype to get numbers and find the hard parts. It is not pushed anywhere. What the prototype does. Chat Completions route only, behind an environment switch: the transport hands each upstream chunk to the client as it arrives, the executor still accumulates the full body, and the release check and capture run on it after the stream ends. Measured (gateway from master
The third row is the real problem. Once the client closes, the call's lifecycle stops with Two design points I would like your view on before I implement:
Not covered by the prototype: the Responses route (the upstream request is non-streaming there today, so it needs the streamed send and SSE handling first), subscription channels, retries, and error replies after the first byte. 中文摘要:在正式做第 7 项之前,我做了一个不提交的原型来取数。Chat Completions 路由上,首个输出从 10.7–14.2 秒降到 0.45–0.75 秒,客户端读到流结束时回合照常被采集(3/3);但客户端在 |
|
@jasper-yl Thanks for the prototype and measurements. Agreed on both design points:
Please go ahead with item 7 on this basis. |
Co-Authored-By: Claude <noreply@anthropic.com>
|
@frf12 Thanks. The Chat Completions part of item 7 is in #3035, built on those two points:
Against api.openai.com the first body byte arrived after 0.41–1.62 s instead of at the end of the reply, and the three runs that closed at One point needs your view before I do the Responses route. The gateway sends Responses upstream without streaming, and the binding covers the exact payload, so I also updated the RFC text: item 7 now states the agreed design, the evidence table has the new measurements, and the response buffer limit is corrected to 1 MiB (I had written 16 MB, which is the request body limit). 中文摘要:第 7 项的 Chat Completions 部分已提交为 #3035,按上面两点实现:Core 在 |
hidb4ai
left a comment
There was a problem hiding this comment.
Re-reviewed 0923f5d as a documentation-only RFC. The updated text separates service and upstream credentials, requires an explicit resolved Scope or an internal turn, preserves shared-service ownership and manual stop, and documents uninstall, host, and streaming limits. The six earlier design concerns are now addressed or explicitly made prerequisites for implementation. Both language versions compile with MDX 3.1.1, their nine links agree and relative references resolve, and the current master d9c467a merges cleanly (tree e0b60f019b351b8b0123d9ce9d28e2602a49c8e3). Current checks: 7 success, 39 skipped. No runtime, table, migration, or implemented API changes. Merge score: 82/100. This approves the RFC, not the author-reported prototype measurements or future early-release implementation; real-host, official DeepSeek, and Responses streaming acceptance remain implementation gates. Other reviewers retain ownership of their outstanding review states.
Which issue or RFC does this PR close?
This PR adds a new RFC and closes no issue. Related: #2040.
Modules and coordination
Primary coordinator: @frf12.
module:gateway)pc-gateway; a service definition that covers the gatewaymodule:core)powercontext serviceextended to the gateway; publication of the Core runtime archiveintegrations/dsh/,module:other)The runtime archive reuses the managed resource producer that Desktop uses, so @PsiACE may want to look at section 5. I cannot set labels on this repository; please add the module labels.
Rationale for this change
DSH users have two ways to use PowerContext today, and each has a gap:
0.2.2-rc.5, a decision the assistant made after a tool call was not stored and a new session could not recall it. Through the gateway the same decision was recalled, because the gateway captures the whole turn.powercontext-dshis not on npm yet, so the documented installation returns 404.What changes are included in this PR?
One RFC, in English and Chinese (
docs/{en,zh}/rfcs/3003-dsh-gateway-model-route.md). It proposes:powercontext-gatewaymodel route through DSH's built-inllm-pi-aiadapter. A session on that route leaves recall, injection and capture to the gateway; the plugin turns its own recall, capture, MCP tools and guidance off for that session. Sessions on other models keep the current behavior.powercontext-dshfrom npm), the gateway executable as npm platform packages, the Core runtime archive downloaded on first use.powercontext service, extended to cover the gateway. The plugin only makes sure the service is running and keeps an explicit stop.disabledprotection mode.powercontext-dsh.The RFC has a section with the evidence gathered so far and a list of what is not verified (Windows/WSL2, macOS, DSH Desktop, a mid-session model change, DeepSeek's official endpoint, a real npm optional-dependency installation).
Are there any user-facing changes?
No. This PR adds design documents only.
How was this change tested?
make docs-testpassed with both files in place (lint 0 warnings and 0 errors, site tests, static build of 1,432 pages including the two RFC pages).0.2.2-rc.5, master9e40f8996andgpt-4.1-minion api.openai.com: plugin path versus gateway path recall, token counts, route registration through the DSH settings service, per-session switching in a prototype of the plugin change, the managed runtime produced and smoke-tested forlinux-x86_64, andpowercontext serviceinstall/start/stop/crash recovery. The prototype is not part of this PR.AI usage statement
Written with Claude Code (Claude). The measurements were run by the tool on a test machine and reviewed by the author.
中文摘要:本 PR 新增一份 RFC(中英文)。提案让 DSH 插件在模型选择器中登记
powercontext-gateway路由:选中它的会话由 gateway 负责召回和完整回合采集,插件关闭自己的召回、采集、MCP 工具和使用指引;其他模型保持现有行为。安装按 DSH 标准方式进行,gateway 以 npm 平台包分发,Core 运行环境首次使用时下载,两者由扩展后的powercontext service统一管理,插件只确保服务在运行。RFC 中列出了已有的实测证据和尚未验证的部分。🤖 Generated with Claude Code