fix(web): keep process-specific values out of the system prompt

The harness checkout path and Web GUI URL now reach the model as runtime
context from the new dsh-harness-dev-context plugin, so a process started
on another port, checkout, or installation no longer rewrites a Session's
logged system prompt. A Session whose prompt already embeds the earlier
value-bearing paragraphs keeps them verbatim through a host-only session
projection.

dsh-host-webserver gains WebServer.origin and bindUrlHost(); web-app keeps
only DSH_WEB_URL, the startup URL, and the browser handoff, and its root
declares the webStartup service type. app-boot drops
addHarnessSourceSection and HARNESS_SOURCE_SECTION.
This commit is contained in:
imccyu committed 2026-10-11 23:25:19 +08:00
1 parent 9cac4beb05
commit 36779dcf09
55 files changed
+1328 -339

No files matched your search

@@ -0,0 +1,31 @@
# Bilingual-pair consistency record for 2026-10-11-process-specific-prompt-values-in-runtime-context.md (docs/i18n/README.md): per heading
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
# After editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write .agents/notes/implemented/bug-fix/2026-10-11-process-specific-prompt-values-in-runtime-context.md
/agent-note-process-specific-checkout-path-and-web-url-move-to-runtime-context:
en: 711ce3e3afb1f905
zh: 2d4e4aea44043c4a
/agent-note-process-specific-checkout-path-and-web-url-move-to-runtime-context/problem:
en: f4e050c7dbf645da
zh: 722bcdc409d09bec
/agent-note-process-specific-checkout-path-and-web-url-move-to-runtime-context/decision:
en: 5222f00fd05d3801
zh: fcfa430a0fa5588c
/agent-note-process-specific-checkout-path-and-web-url-move-to-runtime-context/decision/ownership:
en: 819556fd85d945dd
zh: 7c346c261e2940a1
/agent-note-process-specific-checkout-path-and-web-url-move-to-runtime-context/decision/new-sessions:
en: 1ee144c39905bb89
zh: a6669d7ad394e41c
/agent-note-process-specific-checkout-path-and-web-url-move-to-runtime-context/decision/earlier-format-sessions:
en: ee29d4cfa8175116
zh: 65cebbfe07afe81c
/agent-note-process-specific-checkout-path-and-web-url-move-to-runtime-context/alternatives-considered:
en: be511ed9845587f0
zh: 4312f2410c799be7
/agent-note-process-specific-checkout-path-and-web-url-move-to-runtime-context/consequences:
en: dc4c15a88ac09de0
zh: 0d65b4b3f2471d5c
/agent-note-process-specific-checkout-path-and-web-url-move-to-runtime-context/testing:
en: 0f2be07092471cdc
zh: bd2771ca1b970be8
@@ -0,0 +1,95 @@
# Agent Note: Process-specific checkout path and Web URL move to runtime context
Status: implemented
English | [中文](2026-10-11-process-specific-prompt-values-in-runtime-context.zh.md)
## Problem
`dsh web` wrote two process-specific values directly into the system prompt: the implementation checkout path in the `harness:source` section (four directories above the web-app module) and the Web GUI URL in the `app:web-surface` section (the bound port or `publicUrl`). These operations change them without the user perceiving a system-prompt change:
| Operation | Changed value |
|---|---|
| Every Desktop launch (`--port 0` picks a random port) | Web URL |
| A different `--port`, or alternating A/B checkouts | Web URL, checkout path |
| npm and Desktop installations sharing one `DSH_HOME` | Checkout path |
On resume the loop renders the prompt again. On a route without `systemPromptUpdate: 'in-history'`, such as a hand-declared pi-ai `anthropic-messages` route, the changed prompt rewrites the surface head node. Claude binds historical thinking-block signatures to the conversation prefix, system prompt included, so the upstream answers 400 (`Invalid signature … bound to a different conversation`) and the Session cannot continue until the environment is restored. In-history routes do not fail, but every change appends a complete prompt.
## Decision
Both values become runtime context and the system prompt keeps only value-free guidance; a Session whose log already holds the earlier format keeps its logged paragraphs.
### Ownership
| Package | Responsibility |
|---|---|
| `@deepseek-ai/dsh-harness-dev-context` (`packages/context/harness-dev-context`) | Both sections, both contexts, and the earlier-format projection; all module-private, exporting only the plugin protocol (`name`, `inject`, `apply`) and the projection state type `LegacyPrompt` |
| `@deepseek-ai/dsh-host-webserver` | `WebServer.origin` (the bind address's URL form with protocol and bound port) and `bindUrlHost(host)` |
| `@deepseek-ai/dsh-web-app` | The `web-startup` plugin provides `webStartup` and publishes a canonical `publicUrl`; the package root declares `Context.webStartup`; the bundle patch mounts the `harness-dev-context` row; the runtime plugin keeps only `DSH_WEB_URL`, the startup URL, and the browser handoff |
| `@deepseek-ai/dsh-system-prompt` | `CONTEXT_ORDERS.HARNESS_SOURCE = 200` and `WEB_SURFACE = 210` |
The plugin injects `systemPrompt`, `sessionProjections`, `webServer`, and `webStartup` and reads those services in code; its patch row carries no configuration expression. The checkout path is four directories above this package's source or built entry, the same depth as the former web-app location, so source, npm, and Desktop installations resolve the same root. The URL is `webStartup.publicUrl`, or `webServer.origin` without one. The plugin reaches the `webStartup` type through `import type {} from '@deepseek-ai/dsh-web-app'`, the package root that declares it; the import is erased at runtime, so the web-app bundle's dependency on this package remains the only runtime edge.
### New Sessions
| Registration | Content |
|---|---|
| Section `harness:source` (the `HARNESS_SOURCE` slot) | `The runtime context names the DeepSeek Harness implementation checkout. …`, the remaining guidance unchanged |
| Context `harness:source` (`CONTEXT_ORDERS.HARNESS_SOURCE = 200`) | `Current DeepSeek Harness implementation checkout: "<path>".` |
| Section `app:web-surface` (the `WEB_SURFACE` slot) | `You are interacting with the user through the DeepSeek Harness Web GUI whose URL the runtime context names. …`, the remaining guidance unchanged |
| Context `app:web-surface` (`CONTEXT_ORDERS.WEB_SURFACE = 210`) | `Current DeepSeek Harness Web GUI URL: "<url>".` |
Both contexts are optional (no `required`). The only complete persona, web-app's minimal preset, also disables optional runtime context, so it still sees neither value. Runtime context follows the existing mechanism: an unchanged value emits no snapshot, a change appends a complete snapshot before the step's user message, and resume compares against the latest logged snapshot, never rewriting a committed message.
### Earlier-format Sessions
The plugin registers the host-only session projection `harnessDevLegacyPrompt`, folding every nonempty `system/message` in event order into `{ source, web }`: the paragraphs of that prompt that match an earlier template verbatim, or `null`.
| Earlier template | Matching rule |
|---|---|
| `harness:source` | Starts with `The DeepSeek Harness implementation checkout is at `, ends with the earlier fixed guidance, no line break between |
| `app:web-surface` | Starts with `You are interacting with the user through the DeepSeek Harness Web GUI at `, ends with `. ` plus the current fixed guidance, no line break between |
Both section text providers read the projection state of `AssembleContext.agent.session`: with an earlier paragraph they return it verbatim (`interpolate: false`), otherwise the current guidance. Diagnostic assemblies without an agent use the current guidance. `sessionProjections` is a required injection and the plugin registers its own unit, so the state is readable whenever an agent exists.
An earlier-format Session therefore satisfies both requirements:
| Scenario | System prompt | Runtime context |
|---|---|---|
| First resume after upgrading, same port | Byte-identical to the log; the loop emits no `system/message` | Appends a snapshot with both current values |
| Port, slot, or installation change after upgrading | Still the logged earlier paragraphs | Appends a snapshot with the new values |
The projection computes only on each committed `system/message`, adding no synchronous read of historical events; its state persists with projection checkpoints. When compaction or a new request series rewrites the head, the rendering still contains the same earlier paragraphs, so the projection state does not change.
## Alternatives considered
**Move both values to runtime context without keeping earlier paragraphs.** The upgrade itself changes the prompt text, so every existing Claude Session rewrites its head and fails with 400 on its first turn after the upgrade.
**Offer `supportsMidConvoSystemMessages` on hand-declared Anthropic routes.** The upstream accepts mid-conversation system messages in a live probe, but the pi-ai catalog already supplies that capability for named Anthropic routes and hand-declared routes withhold catalog fields by convention; in-history routes would still append a complete prompt on every value change.
**Ask the upstream to drop mismatched thinking blocks (`prefix_mismatch_behavior: "drop_block"`).** It silently loses historical reasoning and covers one vendor.
**Freeze the whole system prompt per Session.** Legitimate prompt changes such as plan mode, skills, and tool guidance would also be frozen and never reach the model.
**Keep the implementation in web-app and app-boot.** Development-facing context and earlier-format compatibility would enlarge the public API of two core packages; app-boot's `addHarnessSourceSection` had web-app as its only caller.
**Pass `publicUrl` through a configuration expression on the patch row.** The plugin injects `webStartup` as a service and reads it in code, so the row needs no configuration.
**Read the head node text from Session history directly.** The synchronous arbitrary-history read APIs are deprecated and new calls are prohibited; a projection is the established way to obtain that state after resume.
## Consequences
- A new Session's system prompt no longer changes with the port, slot, or installation; both current values arrive as runtime-context snapshots, and a change appends a few lines.
- An earlier-format Session keeps the old values of its earlier paragraphs for its whole lifetime; the later `Current …` runtime context in the same request gives the current values.
- Only these two paragraphs are protected. When other prompt text changes between releases, routes without in-history updates still rewrite the head.
- A release without this fix rewrites the head of a new-format Session with the earlier template on resume; both A/B checkouts need this fix before they alternate.
- app-boot no longer exports `addHarnessSourceSection` or `HARNESS_SOURCE_SECTION`; web-app's `surfaceContext` controls only `DSH_WEB_URL`, and disabling the `harness-dev-context` row turns both contexts off.
- Runtime context in recorded Web e2e Sessions gains two lines, and the test scaffold must normalize the URL and checkout path to placeholders.
## Testing
- `packages/context/harness-dev-context/tests/harness-dev-context.spec.ts`: on a production AgentLoop, an earlier-format Session resumed on another port emits no `system/message`, the request's system prompt is byte-identical to the log, and runtime context carries the current URL; a second port change keeps this; replace-only and in-history routes each run. When a series consolidation only empties a later version, the next turn keeps the earlier paragraphs. Similar text without the fixed ending or broken across lines receives the current guidance. A new Session keeps its system prompt across a port change and only appends a runtime-context snapshot. Sections carry no values, the context carries the origin or `publicUrl`, and disposing the plugin fiber removes every registration.
- `packages/host/webserver/tests/webserver.spec.ts`: `bindUrlHost` across address forms; `origin` on HTTP and HTTPS listeners, and its error for a zoned non-loopback address.
- `packages/bundle/web-app/tests/startup.spec.ts`: `webStartup.publicUrl` publishes the canonical form.
- `packages/core/system-prompt/tests/system-prompt.spec.ts`: the added context positions are unique integers.
@@ -0,0 +1,95 @@
# Agent Note: 进程相关的 checkout 路径与 Web URL 改走运行时上下文
Status: implemented
[English](2026-10-11-process-specific-prompt-values-in-runtime-context.md) | 中文
## 问题
`dsh web` 曾把两项随进程变化的值直接写进 system prompt:`harness:source` 段里的实现 checkout 路径(web-app 模块位置上溯四层),以及 `app:web-surface` 段里的 Web GUI URL(实际监听端口或 `publicUrl`)。下列操作都会改变它们,而用户感知不到 system prompt 变了:
| 操作 | 变化的值 |
|---|---|
| Desktop 每次启动(`--port 0` 取随机端口) | Web URL |
| 换 `--port`、A/B 两个 checkout 交替运行 | Web URL、checkout 路径 |
| npm 安装与 Desktop 安装共用同一个 `DSH_HOME` | checkout 路径 |
会话恢复时 loop 重新渲染 prompt。对不声明 `systemPromptUpdate: 'in-history'` 的路由(例如手写的 pi-ai `anthropic-messages` 路由),变化的 prompt 会改写 surface 头节点。Claude 的历史 thinking 块签名绑定包括 system prompt 在内的对话前缀,前缀一变上游返回 400(`Invalid signature … bound to a different conversation`),会话在环境恢复原样之前无法继续。声明 in-history 的路由不报错,但每次变化都追加一份完整 prompt。
## 决定
两项值改为运行时上下文,system prompt 只保留不含值的说明;已经按旧格式写入日志的会话继续沿用日志里的旧段落。
### 归属
| 包 | 职责 |
|---|---|
| `@deepseek-ai/dsh-harness-dev-context`(`packages/context/harness-dev-context`) | 两个 section、两个 context、旧格式投影;全部模块私有,只导出插件协议(`name`、`inject`、`apply`)与投影状态类型 `LegacyPrompt` |
| `@deepseek-ai/dsh-host-webserver` | `WebServer.origin`(绑定地址的 URL 形式加协议与实际端口)与 `bindUrlHost(host)` |
| `@deepseek-ai/dsh-web-app` | `web-startup` 插件提供 `webStartup`,并发布规范化的 `publicUrl`;包根声明 `Context.webStartup`;bundle patch 挂载 `harness-dev-context` 行;运行时插件只保留 `DSH_WEB_URL`、启动 URL 与浏览器交接 |
| `@deepseek-ai/dsh-system-prompt` | `CONTEXT_ORDERS.HARNESS_SOURCE = 200`、`WEB_SURFACE = 210` |
插件 `inject` 为 `systemPrompt`、`sessionProjections`、`webServer`、`webStartup`,在代码里直接读取这些服务;patch 行不写任何配置表达式。checkout 路径取本包源码或构建入口上溯四层,与原 web-app 位置同深度,源码、npm 与 Desktop 安装下结果不变。URL 取 `webStartup.publicUrl`,没有时取 `webServer.origin`。插件通过 `import type {} from '@deepseek-ai/dsh-web-app'` 从声明它的包根取得 `webStartup` 类型;该导入在运行时被擦除,因此 web-app bundle 对本包的依赖仍是唯一的运行时依赖。
### 新会话
| 注册 | 内容 |
|---|---|
| section `harness:source`(`HARNESS_SOURCE` 位) | `The runtime context names the DeepSeek Harness implementation checkout. …`,其余说明不变 |
| context `harness:source`(`CONTEXT_ORDERS.HARNESS_SOURCE = 200`) | `Current DeepSeek Harness implementation checkout: "<path>".` |
| section `app:web-surface`(`WEB_SURFACE` 位) | `You are interacting with the user through the DeepSeek Harness Web GUI whose URL the runtime context names. …`,其余说明不变 |
| context `app:web-surface`(`CONTEXT_ORDERS.WEB_SURFACE = 210`) | `Current DeepSeek Harness Web GUI URL: "<url>".` |
两个 context 都是可选项(不设 `required`)。唯一的 complete persona(web-app 的 minimal 预设)同时关闭了可选运行时上下文,因此它仍然看不到这两项。运行时上下文按既有机制工作:值不变不发新快照,变化时在本轮 user 消息前追加完整快照,恢复时从会话日志取上一份快照比较,不改写任何已提交消息。
### 旧格式会话
插件注册仅限宿主的会话投影 `harnessDevLegacyPrompt`,按事件顺序折叠每个非空 `system/message`,状态为 `{ source, web }`:该 prompt 中按旧模板逐字匹配到的段落,未匹配为 `null`。
| 旧模板 | 匹配规则 |
|---|---|
| `harness:source` | `The DeepSeek Harness implementation checkout is at ` 开头、旧版固定说明结尾、中间不含换行 |
| `app:web-surface` | `You are interacting with the user through the DeepSeek Harness Web GUI at ` 开头、`. ` 加现行固定说明结尾、中间不含换行 |
两个 section 的文本提供函数读取 `AssembleContext.agent.session` 的投影状态:有旧段落时原样返回该段落(`interpolate: false`),否则返回新说明。没有 agent 的诊断性组装使用新说明。`sessionProjections` 是插件的必需注入,投影单元由插件自己注册,因此存在 agent 时状态必然可读。
旧会话因此满足两点:
| 场景 | system prompt | 运行时上下文 |
|---|---|---|
| 升级后首次恢复,端口不变 | 与日志逐字相同,loop 不产生 `system/message` | 追加含两项当前值的快照 |
| 升级后换端口、slot 或安装位置 | 仍是日志里的旧段落 | 追加新值快照 |
投影只在每次提交的 `system/message` 上计算,不新增同步读取历史事件的调用;状态随投影检查点持久化。压缩或新请求序列重写头节点时,渲染结果仍含同一旧段落,投影状态不变。
## 备选方案
**只把两项值移到运行时上下文,不保留旧段落。** 升级本身会改变 prompt 文本,所有既有 Claude 会话在升级后第一轮改写头节点并报 400。
**为手写 Anthropic 路由开放 `supportsMidConvoSystemMessages`。** 上游实测接受对话中途的 system 消息,但 pi-ai 目录已为具名 Anthropic 路由提供该能力,手写路由按既有约定不开放目录字段;而且 in-history 路由每次值变化仍追加一份完整 prompt。
**请求上游丢弃不匹配的 thinking 块(`prefix_mismatch_behavior: "drop_block"`)。** 会静默丢失历史推理,且只覆盖一个供应商。
**会话内冻结整份 system prompt。** plan 模式、技能和工具说明等合法的 prompt 变化也会被冻结,无法到达模型。
**留在 web-app 与 app-boot 中实现。** 面向开发的上下文与旧格式兼容逻辑会扩大两个核心包的公开 API;app-boot 的 `addHarnessSourceSection` 当时只有 web-app 一个调用方。
**由 patch 行用配置表达式传入 `publicUrl`。** 插件把 `webStartup` 当作服务注入后在代码里读取,行内不需要任何配置。
**直接读取会话历史中的头节点文本。** 同步读取任意历史事件的 API 已弃用,新调用被禁止;投影是恢复后取得该状态的既定方式。
## 后果
- 新会话的 system prompt 不再随端口、slot 或安装位置变化;两项当前值以运行时上下文快照送达,变化时只追加几行。
- 旧会话在整个生命周期内保留旧段落中的旧值;同一请求里更晚的 `Current …` 运行时上下文给出当前值。
- 只保护这两段。其他提示文本在版本之间变化时,不支持 in-history 的路由仍会改写头节点。
- 不含本修复的旧版本恢复新格式会话时会按旧模板改写头节点;A/B 两个 checkout 都需包含本修复后再交替运行。
- app-boot 不再导出 `addHarnessSourceSection` 与 `HARNESS_SOURCE_SECTION`;web-app 的 `surfaceContext` 只控制 `DSH_WEB_URL`,关闭这两项上下文改为禁用 `harness-dev-context` 行。
- Web e2e 录制会话里的运行时上下文多出两行,测试脚手架需把 URL 与 checkout 路径规范化为占位符。
## 测试
- `packages/context/harness-dev-context/tests/harness-dev-context.spec.ts`:真实 AgentLoop 上,旧格式会话在另一端口恢复时不产生 `system/message`、请求中的 system prompt 与日志逐字相同、运行时上下文携带当前 URL;再换一次端口仍成立;不支持与支持 in-history 的路由各跑一遍。series 合并只清空后续版本时,下一轮仍沿用旧段落。缺少固定结尾或跨行的相似文本得到新说明。新会话换端口后 system prompt 不变、只追加运行时上下文快照。section 不含值、context 携带 origin 或 `publicUrl`,销毁插件 fiber 后全部注册消失。
- `packages/host/webserver/tests/webserver.spec.ts`:`bindUrlHost` 各地址形式;`origin` 在 HTTP 与 HTTPS 监听上的值,带 zone 的非回环地址抛错。
- `packages/bundle/web-app/tests/startup.spec.ts`:`webStartup.publicUrl` 发布规范化形式。
- `packages/core/system-prompt/tests/system-prompt.spec.ts`:新增的 context 位置唯一且为整数。
@@ -1 +1 @@
You are interacting with the user through the DeepSeek Harness Web GUI at {{webUrl}}. When the user refers to "this page", "this GUI", or "this app" without naming another target, they mean this GUI. The browser provides no implicit DOM, route, or screenshot context. The client-plugin HMR receiver is active, but client-plugin changes reload without a refresh only while `pnpm run dev:web` is also running from this same checkout to rebuild their bundles; verify that watcher before promising automatic updates. Every other change — the apps/web shell and plain packages — requires rebuilding the affected Web artifacts and verifying this existing URL after a page refresh. Starting another server does not update this GUI. The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__. Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL.
You are interacting with the user through the DeepSeek Harness Web GUI whose URL the runtime context names. When the user refers to "this page", "this GUI", or "this app" without naming another target, they mean this GUI. The browser provides no implicit DOM, route, or screenshot context. The client-plugin HMR receiver is active, but client-plugin changes reload without a refresh only while `pnpm run dev:web` is also running from this same checkout to rebuild their bundles; verify that watcher before promising automatic updates. Every other change — the apps/web shell and plain packages — requires rebuilding the affected Web artifacts and verifying this existing URL after a page refresh. Starting another server does not update this GUI. The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__. Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL.
+2
View File
@@ -230,6 +230,8 @@ describe('web e2e: fresh round trip through the real assembly', () => {
const userText = agent.session.deriveMessages().filter(message => message.role === 'user')
.flatMap(message => message.content.flatMap(block => block.type === 'text' ? [block.text] : []))
expect(userText.some(text => text.includes(`Current working directory: ${JSON.stringify(cwd)}.`))).toBe(true)
expect(system).not.toContain(scaffold.baseUrl)
expect(userText.some(text => text.includes(`Current DeepSeek Harness Web GUI URL: ${JSON.stringify(scaffold.baseUrl)}.`))).toBe(true)
const suffix = paragraphs.slice(-2).join('\n\n')
.split(REPO_ROOT).join('{{sourceRoot}}')
.split(join(scaffold.workspaceCwd, 'workspace')).join('{{cwd}}')
+6 -1
View File
@@ -476,8 +476,13 @@ describe('dsh web keyless CLI smoke', () => {
.flatMap(message => message.content ?? [])
.find(block => block.type === 'text' && block.text?.includes('web-workspace-context-probe'))
const expectedWebSection = readFileSync(WEB_SURFACE_PROMPT, 'utf8').trimEnd()
.replace('{{webUrl}}', new URL(baseUrl).origin)
expect(captured.system).toContain(expectedWebSection)
expect(captured.system).not.toContain(new URL(baseUrl).origin)
expect(captured.messages?.filter(message => message.role === 'user')
.flatMap(message => message.content ?? [])
.some(block => block.type === 'text'
&& block.text?.includes(`Current DeepSeek Harness Web GUI URL: ${JSON.stringify(new URL(baseUrl).origin)}.`)))
.toBe(true)
expect(workspaceMessage).toMatchInlineSnapshot(`
{
"text": "<system-reminder>
+7 -8
View File
@@ -3477,7 +3477,7 @@ export interface Config {
## `@deepseek-ai/dsh-system-prompt`
- `source`: [`packages/core/system-prompt/src/index.ts:254`](../packages/core/system-prompt/src/index.ts)
- `source`: [`packages/core/system-prompt/src/index.ts:257`](../packages/core/system-prompt/src/index.ts)
```ts config-catalog
/** Plugin config: the deployment-authored fragment of the system prompt (see {@link Config.personaPrefix} for its contract). */
@@ -4266,7 +4266,7 @@ export interface WebRuntimeConfig {
## `@deepseek-ai/dsh-web-app`
- `inject`: `webServer`
- `source`: [`packages/bundle/web-app/src/index.ts:43`](../packages/bundle/web-app/src/index.ts)
- `source`: [`packages/bundle/web-app/src/index.ts:47`](../packages/bundle/web-app/src/index.ts)
```ts config-catalog
/** Plugin config: composed deployment settings plus per-invocation command-line values. */
@@ -4276,15 +4276,13 @@ export interface Config {
/** Print the URL line on activation; a non-interactive layer can turn it off. */
printUrl: boolean
/**
* Register the model-visible surface context (the `app:web-surface` prompt
* section and the `DSH_WEB_URL` bash variable). A one-shot non-interactive
* layer can turn it off when its user is not in the GUI, so the
* orientation text would be false.
* Register the `DSH_WEB_URL` bash variable naming this GUI. A one-shot
* non-interactive layer can turn it off when its user is not in the GUI.
*/
surfaceContext: boolean
/**
* Canonical HTTP(S) root to advertise in the printed and opened URL,
* `DSH_WEB_URL`, and the web-surface orientation, e.g.
* Canonical HTTP(S) root to advertise in the printed and opened URL and
* `DSH_WEB_URL`, e.g.
* `https://app.example/ui/`, normalized to end in `/`. Configures no routing
* or authentication; see [public deployments](../README.md#public-deployments).
* Absent or YAML `null` advertises the bind-address URL.
@@ -4574,6 +4572,7 @@ These load from a `cordis.yml` entry with no `config:` block; they declare no co
| `@deepseek-ai/dsh-fs-observation-policy` | — | [`packages/fs/fs-observation-policy/src/index.ts`](../packages/fs/fs-observation-policy/src/index.ts) |
| `@deepseek-ai/dsh-fs-ssh` | `ssh` · `sandboxPolicy` | [`packages/ssh/fs-ssh/src/index.ts`](../packages/ssh/fs-ssh/src/index.ts) |
| `@deepseek-ai/dsh-goal-round-driver` | `agents` · `goals` · `sessions` | [`packages/goal/goal-round-driver/src/index.ts`](../packages/goal/goal-round-driver/src/index.ts) |
| `@deepseek-ai/dsh-harness-dev-context` | `systemPrompt` · `sessionProjections` · `webServer` · `webStartup` | [`packages/context/harness-dev-context/src/index.ts`](../packages/context/harness-dev-context/src/index.ts) |
| `@deepseek-ai/dsh-host-directory-picker-auto` | `webServer` · `connection` · `loader` | [`packages/host/directory-picker-auto/src/index.ts`](../packages/host/directory-picker-auto/src/index.ts) |
| `@deepseek-ai/dsh-host-directory-picker-native` | — | [`packages/host/directory-picker-native/src/index.ts`](../packages/host/directory-picker-native/src/index.ts) |
| `@deepseek-ai/dsh-host-plugin-inventory` | `loader` | [`packages/host/plugin-inventory/src/index.ts`](../packages/host/plugin-inventory/src/index.ts) |
+7 -8
View File
@@ -3479,7 +3479,7 @@ export interface Config {
## `@deepseek-ai/dsh-system-prompt`
- `source`: [`packages/core/system-prompt/src/index.ts:254`](../packages/core/system-prompt/src/index.ts)
- `source`: [`packages/core/system-prompt/src/index.ts:257`](../packages/core/system-prompt/src/index.ts)
```ts config-catalog
/** Plugin config: the deployment-authored fragment of the system prompt (see {@link Config.personaPrefix} for its contract). */
@@ -4268,7 +4268,7 @@ export interface WebRuntimeConfig {
## `@deepseek-ai/dsh-web-app`
- `inject`: `webServer`
- `source`: [`packages/bundle/web-app/src/index.ts:43`](../packages/bundle/web-app/src/index.ts)
- `source`: [`packages/bundle/web-app/src/index.ts:47`](../packages/bundle/web-app/src/index.ts)
```ts config-catalog
/** Plugin config: composed deployment settings plus per-invocation command-line values. */
@@ -4278,15 +4278,13 @@ export interface Config {
/** Print the URL line on activation; a non-interactive layer can turn it off. */
printUrl: boolean
/**
* Register the model-visible surface context (the `app:web-surface` prompt
* section and the `DSH_WEB_URL` bash variable). A one-shot non-interactive
* layer can turn it off when its user is not in the GUI, so the
* orientation text would be false.
* Register the `DSH_WEB_URL` bash variable naming this GUI. A one-shot
* non-interactive layer can turn it off when its user is not in the GUI.
*/
surfaceContext: boolean
/**
* Canonical HTTP(S) root to advertise in the printed and opened URL,
* `DSH_WEB_URL`, and the web-surface orientation, e.g.
* Canonical HTTP(S) root to advertise in the printed and opened URL and
* `DSH_WEB_URL`, e.g.
* `https://app.example/ui/`, normalized to end in `/`. Configures no routing
* or authentication; see [public deployments](../README.md#public-deployments).
* Absent or YAML `null` advertises the bind-address URL.
@@ -4576,6 +4574,7 @@ export interface Config {
| `@deepseek-ai/dsh-fs-observation-policy` | — | [`packages/fs/fs-observation-policy/src/index.ts`](../packages/fs/fs-observation-policy/src/index.ts) |
| `@deepseek-ai/dsh-fs-ssh` | `ssh` · `sandboxPolicy` | [`packages/ssh/fs-ssh/src/index.ts`](../packages/ssh/fs-ssh/src/index.ts) |
| `@deepseek-ai/dsh-goal-round-driver` | `agents` · `goals` · `sessions` | [`packages/goal/goal-round-driver/src/index.ts`](../packages/goal/goal-round-driver/src/index.ts) |
| `@deepseek-ai/dsh-harness-dev-context` | `systemPrompt` · `sessionProjections` · `webServer` · `webStartup` | [`packages/context/harness-dev-context/src/index.ts`](../packages/context/harness-dev-context/src/index.ts) |
| `@deepseek-ai/dsh-host-directory-picker-auto` | `webServer` · `connection` · `loader` | [`packages/host/directory-picker-auto/src/index.ts`](../packages/host/directory-picker-auto/src/index.ts) |
| `@deepseek-ai/dsh-host-directory-picker-native` | — | [`packages/host/directory-picker-native/src/index.ts`](../packages/host/directory-picker-native/src/index.ts) |
| `@deepseek-ai/dsh-host-plugin-inventory` | `loader` | [`packages/host/plugin-inventory/src/index.ts`](../packages/host/plugin-inventory/src/index.ts) |
+8
View File
@@ -212,6 +212,14 @@ renderIndex(html: string): string
Source: [`packages/host/webserver/src/index.ts`](../../packages/host/webserver/src/index.ts)
<a id="ctxwebstartup--webstartupvalues"></a>
### `ctx.webStartup` — `WebStartupValues`
What the web rows read from WEB_STARTUP_SERVICE.
Source: [`packages/bundle/web-app/src/startup.ts`](../../packages/bundle/web-app/src/startup.ts)
<a id="connection-events"></a>
### `connection/*` events
+8
View File
@@ -212,6 +212,14 @@ renderIndex(html: string): string
Source: [`packages/host/webserver/src/index.ts`](../../packages/host/webserver/src/index.ts)
<a id="ctxwebstartup--webstartupvalues"></a>
### `ctx.webStartup` — `WebStartupValues`
What the web rows read from WEB_STARTUP_SERVICE.
Source: [`packages/bundle/web-app/src/startup.ts`](../../packages/bundle/web-app/src/startup.ts)
<a id="connection-events"></a>
### `connection/*` events
+10 -13
View File
@@ -36,11 +36,8 @@
en: a9afb263b03d112c
zh: 31f5e797cd953c15
/deepseek-ai-dsh-app-boot/use-this-package/startup-and-reload-failures:
en: 09890e218ab49c84
zh: e3d86597e7fb1adb
/deepseek-ai-dsh-app-boot/use-this-package/telling-the-agent-where-the-harness-lives:
en: 07c459f26f4f8517
zh: 210f1e4894731b1a
en: 206c9093965bc5e1
zh: d8525e950595c399
/deepseek-ai-dsh-app-boot/understand-the-implementation:
en: f4a2695cb4c8a570
zh: 89837235d2f376cf
@@ -48,20 +45,20 @@
en: 25a0d1b46fd66d68
zh: 5cd8b4ac382dccdc
/deepseek-ai-dsh-app-boot/understand-the-implementation/helper-behavior:
en: f7bc3a8dd4b00bdd
zh: 30098428aa769ad0
en: 6fa850d1bb000d0e
zh: aa83a40a9d3db295
/deepseek-ai-dsh-app-boot/understand-the-implementation/source-map:
en: 3da01827e3354655
zh: 06ccfaed83f65a76
en: 541700d5c39e0ab4
zh: 7522dbd9cd68c930
/deepseek-ai-dsh-app-boot/further-exploration:
en: 401269cc5ea8593e
zh: cd337c356b320565
/deepseek-ai-dsh-app-boot/model-experience:
en: 769777f1cb1a9408
zh: f02b2834179df50d
en: d2d0a21502d88c50
zh: 82a60c7a490a6834
/deepseek-ai-dsh-app-boot/model-experience/kv-cache-effect:
en: c4d49630b68ae896
zh: 6f450ec6ba39bb81
en: 5a1d9344c8fdc790
zh: 0b32579f658b2ca1
/deepseek-ai-dsh-app-boot/known-limitations-and-deferred-work:
en: bf1a49013cad8e9c
zh: 41b2b010f8650ec3
+4 -8
View File
@@ -116,10 +116,6 @@ The [Web process matrix](../../../apps/cli/tests/profiles/web/tests/web-failure-
If your app owns the terminal, it can hand the terminal back before the process exits, so your shell is never left in raw mode. The handoff is bounded: a stuck cleanup delays the fatal exit but never cancels it.
### Telling the agent where the harness lives
When your app boots a model-backed agent, you can tell the agent where the DSH implementation checkout lives: it learns that path and that it must not infer the working directory from it — it should use `pwd`. The instruction appears once near the top of the system prompt. Apps without a system prompt service skip it; in development, reloading the system prompt drops it until the next boot.
-----
<a id="understand-the-implementation"></a>
@@ -151,13 +147,13 @@ The startup error also retains inactive-entry metadata and raw startup warning/e
### Helper behavior
The exports each own one stage of the boot: config resolution and snapshot replay, layered environment loading, fail-loud reporting, activation auditing, patch parsing, root-include mounting, config dump rendering, profile composition, and the harness-source section. Per-export contracts live in the code, not this README — see [`src/index.ts`](src/index.ts) and [`src/profile.ts`](src/profile.ts).
The exports each own one stage of the boot: config resolution and snapshot replay, layered environment loading, fail-loud reporting, activation auditing, patch parsing, root-include mounting, config dump rendering, and profile composition. Per-export contracts live in the code, not this README — see [`src/index.ts`](src/index.ts) and [`src/profile.ts`](src/profile.ts).
### Source map
| File | Role |
|---|---|
| [`src/index.ts`](src/index.ts) | Boot helpers: config resolution, environment loading, fail-loud guard, activation audit, patch parsing, config dump, harness-source section |
| [`src/index.ts`](src/index.ts) | Boot helpers: config resolution, environment loading, fail-loud guard, activation audit, patch parsing, config dump |
| [`src/profile.ts`](src/profile.ts) | Profile discovery, initialization, bundle resolution, runtime resolution construction |
| [`src/profile-plugins.ts`](src/profile-plugins.ts) | Installed dependencies, bundle activation policy, and manifest updates |
| [`src/profile-sanitize.ts`](src/profile-sanitize.ts) | Profile patch backup and recovery bundle activation |
@@ -187,11 +183,11 @@ Read these pages when the package-level contract is not enough. They move from t
<a id="model-experience"></a>
## Model Experience
Indirectly, through the loaded plugin tree, which alone contributes model context; the one export that adds model-visible text, `addHarnessSourceSection`, does so only when a consumer calls it after boot.
Indirectly, through the loaded plugin tree, which alone contributes model context; no export adds model-visible text.
#### KV Cache effect
Boot itself changes no request prefix. `addHarnessSourceSection` places its source path after first-party reusable instructions, so different checkouts leave those preceding bytes unchanged when tools and configuration match. Provider cache reuse is not guaranteed.
Boot itself changes no request prefix.
## Known Limitations and Deferred Work
+4 -8
View File
@@ -116,10 +116,6 @@ Loader 结算后,app-boot 在仅 optional 条目未激活时输出警告。如
如果你的应用持有终端,它可以在进程退出前把终端交还,你的 shell 绝不会残留在 raw 模式。交还过程有界:卡住的清理只会延迟致命退出,而不会取消它。
### 告诉 agent(智能体)harness 所在位置
当你的应用启动模型驱动的 agent 时,你可以告诉 agent DSH 实现代码 checkout 的位置:它得知该路径,也知道不得据此推断工作目录——它应使用 `pwd`。这条指示在系统提示词靠前位置出现一次。没有系统提示词服务的应用会跳过;开发环境中,重新加载系统提示词后它会消失,直至下次启动。
-----
<a id="understand-the-implementation"></a>
@@ -151,13 +147,13 @@ Loader 结算后,app-boot 在仅 optional 条目未激活时输出警告。如
### Helper 行为
每个导出各负责启动的一个阶段:配置解析与快照回放、分层环境加载、明确报错的保护机制、激活审计、patch 解析、根 include 挂载、配置 dump 渲染、profile 组合,以及 harness 源码段落。各导出的约定在代码中,不在本 README——见 [`src/index.ts`](src/index.ts) 与 [`src/profile.ts`](src/profile.ts)。
每个导出各负责启动的一个阶段:配置解析与快照回放、分层环境加载、明确报错的保护机制、激活审计、patch 解析、根 include 挂载、配置 dump 渲染与 profile 组合。各导出的约定在代码中,不在本 README——见 [`src/index.ts`](src/index.ts) 与 [`src/profile.ts`](src/profile.ts)。
### 源码地图
| 文件 | 职责 |
|---|---|
| [`src/index.ts`](src/index.ts) | 启动 helper:配置解析、环境加载、会明确报错的保护机制、激活审计、patch 解析、配置 dump、harness 源码段落 |
| [`src/index.ts`](src/index.ts) | 启动 helper:配置解析、环境加载、会明确报错的保护机制、激活审计、patch 解析、配置 dump |
| [`src/profile.ts`](src/profile.ts) | profile 发现、初始化、组合包解析、runtime resolution 构造 |
| [`src/profile-plugins.ts`](src/profile-plugins.ts) | 已安装依赖、bundle 启用策略与 manifest 更新 |
| [`src/profile-sanitize.ts`](src/profile-sanitize.ts) | profile patch 备份与恢复 bundle 启用状态 |
@@ -187,11 +183,11 @@ Loader 结算后,app-boot 在仅 optional 条目未激活时输出警告。如
<a id="model-experience"></a>
## 模型体验
模型通过此包加载的插件树间接受影响——只有该树贡献模型上下文;唯一贡献模型可见文本的导出 `addHarnessSourceSection`,也只有在消费方启动后调用它时才会产生影响。
模型通过此包加载的插件树间接受影响——只有该树贡献模型上下文;没有导出会添加模型可见文本。
#### KV Cache 影响
启动本身不改变请求前缀。`addHarnessSourceSection` 将源码路径放在第一方可复用指令之后,因此工具与配置一致时,不同 checkout 不会改变前置字节。不保证提供方复用缓存。
启动本身不改变请求前缀。
## 已知限制与延期工作
-1
View File
@@ -47,7 +47,6 @@
"@deepseek-ai/cordis-plugin-loader": "workspace:~",
"@deepseek-ai/dsh-launch-environment": "workspace:*",
"@deepseek-ai/dsh-home-paths": "workspace:*",
"@deepseek-ai/dsh-system-prompt": "workspace:*",
"@deepseek-ai/cordis": "workspace:~"
},
"devDependencies": {
-29
View File
@@ -31,7 +31,6 @@ export { ON_DEMAND_BUNDLES, OFFICIAL_ON_DEMAND_CATALOG, type OfficialBundleCatal
export { generateConfigSchema, type ConfigSchemaDump, type NativeConfigSchema } from './config-schema/index.ts'
export { createConfigProjector, LOADER_EXPRESSION_SCHEMA, type ConfigProjection } from './config-schema/projector.ts'
export { isNativeConfigSchema } from './config-schema/native.ts'
import type {} from '@deepseek-ai/dsh-system-prompt'
export {
readProfilePlugins, reconcileProfilePlugins, writeProfileBundles,
@@ -1039,31 +1038,3 @@ export async function boot(
await diagnostics.fiber.dispose()
}
}
/** Prompt-section name for the harness-source location line an app bin adds after boot. */
export const HARNESS_SOURCE_SECTION = 'harness:source'
/**
* Add a global prompt section naming the on-disk harness source checkout while
* explicitly distinguishing it from the task workspace and current working
* directory. The self-referential `dsh-tool-cordis` toolset reads and edits this
* checkout. Call once on the settled boot context ({@link boot}); the section
* uses the shared first-party placement after reusable instructions
* and before the Web surface and persona suffix. A booted tree with no
* `systemPrompt` service has no prompt to augment, so this is then a no-op
* that returns `undefined`. The section is
* registered against the `systemPrompt` service's fiber, so a dev HMR reload of
* that plugin drops it until the next boot.
* @param ctx - the settled boot context whose global system prompt to augment.
* @param sourceRoot - the absolute path to the harness checkout root.
* @returns the section disposer, or `undefined` when no `systemPrompt` service is mounted.
*/
export function addHarnessSourceSection(ctx: Context, sourceRoot: string): (() => void) | undefined {
const systemPrompt = ctx.get('systemPrompt')
if (systemPrompt === undefined) return undefined
return systemPrompt.section({
name: HARNESS_SOURCE_SECTION,
order: systemPrompt.getSectionOrder('HARNESS_SOURCE'),
text: `The DeepSeek Harness implementation checkout is at ${sourceRoot}. The checkout location and current working directory are separate values and may differ; never infer the working directory from this path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend DSH itself.`,
})
}
+3 -61
View File
@@ -5,10 +5,10 @@ import { pathToFileURL } from 'node:url'
import { inspect } from 'node:util'
import { afterAll, describe, expect, it, vi } from 'vitest'
import { Context } from '@deepseek-ai/cordis'
import SystemPrompt, { renderPrompt } from '@deepseek-ai/dsh-system-prompt'
import type {} from '@deepseek-ai/dsh-system-prompt'
import {
addHarnessSourceSection, auditStartupEntries, boot, StartupError,
FAIL_LOUD_RELEASE_TIMEOUT_MS, HARNESS_SOURCE_SECTION,
auditStartupEntries, boot, StartupError,
FAIL_LOUD_RELEASE_TIMEOUT_MS,
installFailLoud, loadEnv, loadLayeredEnv, loadOverlayPatches, resolveConfigPath, type FailLoudEvent, type FailLoudProcess,
} from '../src/index.ts'
@@ -1266,61 +1266,3 @@ describe('boot', () => {
})
})
describe('addHarnessSourceSection', () => {
const SOURCE_ROOT = `${sep}opt${sep}harness-src`
const EXPECTED = `The DeepSeek Harness implementation checkout is at ${SOURCE_ROOT}. The checkout location and current working directory are separate values and may differ; never infer the working directory from this path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend DSH itself.`
it('distinguishes the source path from the current workdir after reusable instructions', async () => {
const ctx = new Context()
try {
await ctx.plugin(SystemPrompt, { personaPrefix: 'You are a coding agent.' })
ctx.systemPrompt.section({
name: 'tools:sdk', order: ctx.systemPrompt.getSectionOrder('TOOLS_SDK'), text: 'Reusable tool SDK.',
})
const dispose = addHarnessSourceSection(ctx, SOURCE_ROOT)
expect(dispose).toBeTypeOf('function')
const systemPrompt = ctx.get('systemPrompt')!
const rendered = renderPrompt(await systemPrompt.assemble())
expect(rendered).toContain(EXPECTED)
// The >= 0 guards keep a drifted opener/persona string from a false pass
// through `-1 < n`.
const identityAt = rendered.indexOf('You are an AI agent powered by DeepSeek Harness.')
const sourceAt = rendered.indexOf(EXPECTED)
const personaAt = rendered.indexOf('You are a coding agent.')
expect(identityAt).toBeGreaterThanOrEqual(0)
expect(personaAt).toBeGreaterThanOrEqual(0)
const sdkAt = rendered.indexOf('Reusable tool SDK.')
expect(personaAt).toBeGreaterThan(identityAt)
expect(sdkAt).toBeGreaterThan(personaAt)
expect(sdkAt).toBeLessThan(sourceAt)
} finally {
await ctx.fiber.dispose()
}
})
it('is a no-op returning undefined when no systemPrompt service is mounted', async () => {
const ctx = new Context()
try {
expect(addHarnessSourceSection(ctx, SOURCE_ROOT)).toBeUndefined()
} finally {
await ctx.fiber.dispose()
}
})
it('disposes the section it added, so a systemPrompt reload leaves no residue', async () => {
const ctx = new Context()
try {
await ctx.plugin(SystemPrompt, {})
const systemPrompt = ctx.get('systemPrompt')!
const dispose = addHarnessSourceSection(ctx, SOURCE_ROOT)!
const present = await systemPrompt.assemble()
expect(present.sections.some(section => section.name === HARNESS_SOURCE_SECTION)).toBe(true)
dispose()
const gone = await systemPrompt.assemble()
expect(gone.sections.some(section => section.name === HARNESS_SOURCE_SECTION)).toBe(false)
} finally {
await ctx.fiber.dispose()
}
})
})
-3
View File
@@ -20,9 +20,6 @@
{
"path": "../../../vendor/group"
},
{
"path": "../../core/system-prompt"
},
{
"path": "../../util/launch-environment"
},
+18 -18
View File
@@ -21,11 +21,11 @@
en: e3cac911f080d8ef
zh: 60749e9f5c39c1bc
/deepseek-ai-dsh-web-app/use-this-package/configuration:
en: 2b09528c8fc8d370
zh: 7b374ebda8841172
en: ad3bf2a8a2a8a99e
zh: cf24ef814a0352b9
/deepseek-ai-dsh-web-app/use-this-package/listening-trust-and-public-deployments:
en: 177400de33509826
zh: dd88bc096accffc8
en: e6ddea1d2fc40501
zh: ff08b6fa3fc24136
/deepseek-ai-dsh-web-app/use-this-package/running-over-ssh:
en: df205a26b6d49168
zh: e46ed7cf9e06248a
@@ -39,8 +39,8 @@
en: 8a2554b3d17daa1f
zh: 66f18946791cabb6
/deepseek-ai-dsh-web-app/understand-the-implementation/advertised-application-url:
en: ca977d2b2bcf72c5
zh: 2b81b377c133c1a8
en: 0b22e03e28d41420
zh: fd45a97dd4336c25
/deepseek-ai-dsh-web-app/understand-the-implementation/readiness:
en: 973128fd346869df
zh: 54e6792f9f82a192
@@ -53,18 +53,18 @@
/deepseek-ai-dsh-web-app/model-experience:
en: 215e7ba838619b7b
zh: a311da3843709f90
/deepseek-ai-dsh-web-app/model-experience/harness-source-and-web-surface-context:
en: e6febc53efe0f51d
zh: 9177816a8678d65d
/deepseek-ai-dsh-web-app/model-experience/harness-source-and-web-surface-context/what-the-model-sees:
en: 583592075e04687d
zh: 9defddfd77bab0f7
/deepseek-ai-dsh-web-app/model-experience/harness-source-and-web-surface-context/token-effect:
en: 908fc84d6849a830
zh: 56fe5e418bab60ba
/deepseek-ai-dsh-web-app/model-experience/harness-source-and-web-surface-context/kv-cache-effect:
en: 1d7d87f54b20b563
zh: d150a51615d278e8
/deepseek-ai-dsh-web-app/model-experience/web-runtime-variable:
en: 623bf8a0bf05599d
zh: 398ded2e7b20c1ea
/deepseek-ai-dsh-web-app/model-experience/web-runtime-variable/what-the-model-sees:
en: ebaddc153ad7a835
zh: 21aa60f73d14f26c
/deepseek-ai-dsh-web-app/model-experience/web-runtime-variable/token-effect:
en: 449fbfa3986f98f0
zh: a7d66333594ab2dd
/deepseek-ai-dsh-web-app/model-experience/web-runtime-variable/kv-cache-effect:
en: 37542a8b81a744f5
zh: c0048aaadecae296
/deepseek-ai-dsh-web-app/known-limitations-and-deferred-work:
en: 635c1336e2f4e821
zh: caabdecb02e2df14
+7 -7
View File
@@ -52,7 +52,7 @@ Saved model selections override the composition default. The settings card accep
|---|---|---|
| `openBrowser` | `true` | Open the default browser after startup; SSH launches suppress it |
| `printUrl` | `true` | Print the `dsh web:` URL line at startup |
| `surfaceContext` | `true` | Give the agent GUI-orientation context and expose `DSH_WEB_URL` to its shell commands |
| `surfaceContext` | `true` | Expose `DSH_WEB_URL` to the agent's shell commands |
| `publicUrl` | Unset | Advertised HTTP(S) application root; otherwise announce the bind-address URL |
The generated [configuration catalog](../../../docs/config-catalog.md#deepseek-aidsh-web-app) lists this runtime plugin's accepted fields and their JSDoc. The shipped composition inserts the `schedule` service row and the `ui-schedule` task page row, while the clock reading and the four reminder tools belong to the `standard`, `cordis`, and `ptc` presets. The `tool-subagent` and `tool-subagent-fork` rows in those presets deny the four tools, so a delegated child's scope never lists them.
@@ -74,7 +74,7 @@ dsh --profile web --no-open --host "$(hostname -i | awk '{print $1}')" --public-
Without `--public-url`, mapped IPv6 loopback binds such as `::ffff:127.0.0.1` advertise their IPv4 form, `127.0.0.1`, so the browser recognizes a local, trustworthy origin. The listener keeps the configured bind address. A dotted-quad IPv6 tail names the address's own low 32 bits, exactly as `listen` reads it, so `::0.0.0.1` is IPv6 loopback and advertises `[::1]`, while `::127.0.0.1` is a non-loopback address, not IPv4 loopback.
`--public-url` advertises the HTTP(S) root browsers use — the printed and opened startup URL, `DSH_WEB_URL`, and the web-surface orientation. Advertisement grants no trust: the browser-visible authority must also be named with `--trusted-host`. The flag configures no listener, routing, or cookie scope, because the proxy owns the external leg: [Publish the Web UI behind a reverse proxy](../../../docs/user/guide/public-deployments.md) lists what such a deployment must provide.
`--public-url` advertises the HTTP(S) root browsers use — the printed and opened startup URL, `DSH_WEB_URL`, and the Web GUI URL in the agent's runtime context. Advertisement grants no trust: the browser-visible authority must also be named with `--trusted-host`. The flag configures no listener, routing, or cookie scope, because the proxy owns the external leg: [Publish the Web UI behind a reverse proxy](../../../docs/user/guide/public-deployments.md) lists what such a deployment must provide.
Neither the advertised URL nor the browser-trust fence protects the port itself, so restrict the port to the trusted proxy or network.
@@ -104,7 +104,7 @@ A patch replaces the targeted row's whole `config`, so each web row restates eve
### Advertised application URL
Startup display and browser handoff receive the advertised root with its launch token; the web-surface prompt and `DSH_WEB_URL` receive it clean. The root itself is defined under [Listening, trust, and public deployments](#public-deployments).
Startup display and browser handoff receive the advertised root with its launch token; the agent's runtime context and `DSH_WEB_URL` receive it clean. The root itself is defined under [Listening, trust, and public deployments](#public-deployments).
### Readiness
@@ -144,19 +144,19 @@ Read these pages when you want to go deeper into the shared core, the browser re
<a id="model-experience"></a>
## Model Experience
### Harness-source and Web-surface context
### Web runtime variable
#### What the model sees
When `surfaceContext` is true, the `harness:source` section identifies the on-disk Harness implementation without claiming it is the working directory, and the `app:web-surface` global section (first-party order 10100, after reusable instructions) orients the model to the GUI: the advertised application URL (defined under Listening, trust, and public deployments above), the "this page" referent, the update contract (the reload receiver is always on; no-refresh reloads additionally need the `pnpm run dev:web` watcher), and the instruction not to start replacement servers. `DSH_WEB_URL` additionally appears in the managed bash environment with its description, resolved per invocation from the live server. When it is false, neither section nor the variable is registered.
When `surfaceContext` is true, `DSH_WEB_URL` appears in the managed bash environment with its description, resolved per invocation as the advertised application URL defined under Listening, trust, and public deployments above. When it is false, the variable is not registered. The GUI orientation, the implementation checkout, and the current GUI URL come from the [`dsh-harness-dev-context`](../../context/harness-dev-context/README.md) row this bundle mounts.
#### Token effect
One source line and one prompt paragraph per session plus two managed-environment variable lines; constant per process.
Two managed-environment variable lines; constant per process.
#### KV Cache effect
Source and Web sections follow first-party reusable instructions. Different checkout paths or application URLs leave that preceding prefix unchanged when tools and configuration match; provider cache reuse is not guaranteed.
None; the plugin contributes no system-prompt text.
## Known Limitations and Deferred Work
+7 -7
View File
@@ -52,7 +52,7 @@ dsh --profile web --no-open --port 8080
|---|---|---|
| `openBrowser` | `true` | 启动后用默认浏览器打开;SSH 启动会抑制它 |
| `printUrl` | `true` | 启动时打印 `dsh web:` URL 行 |
| `surfaceContext` | `true` | 给 agent 提供 GUI 定位上下文,并把 `DSH_WEB_URL` 暴露给其 shell 命令 |
| `surfaceContext` | `true` | 把 `DSH_WEB_URL` 暴露给 agent 的 shell 命令 |
| `publicUrl` | 未设置 | 对外公告的 HTTP(S) 应用根;否则公告绑定地址 URL |
生成的[配置目录](../../../docs/config-catalog.zh.md#deepseek-aidsh-web-app)列出了本运行时插件接受的字段及其 JSDoc。随发行版交付的组合插入 `schedule` 服务行与 `ui-schedule` 任务页面行,时钟读数与四个提醒工具则属于 `standard`、`cordis` 与 `ptc` 三个 preset。这三个 preset 的 `tool-subagent` 与 `tool-subagent-fork` 两行都 deny 这四个工具,因此被委派子 agent 的作用域不会列出它们。
@@ -74,7 +74,7 @@ dsh --profile web --no-open --host "$(hostname -i | awk '{print $1}')" --public-
未设置 `--public-url` 时,`::ffff:127.0.0.1` 这样的 mapped IPv6 回环绑定会公告其 IPv4 形式 `127.0.0.1`,让浏览器将其识别为本地可信来源。监听器仍使用配置的绑定地址。点分四段式的 IPv6 尾部表示该地址自身的低 32 位,与 `listen` 的读法完全一致:`::0.0.0.1` 属于 IPv6 回环并公告 `[::1]`,而 `::127.0.0.1` 是非回环地址,并非 IPv4 回环。
`--public-url` 公告浏览器使用的 HTTP(S) 根——打印与打开的启动 URL、`DSH_WEB_URL` 与 web 表层定位。公告不授予任何信任:浏览器可见的 authority 还必须用 `--trusted-host` 点名。该 flag 不配置监听器、路由或 cookie 作用域,因为外部链路归代理所有:[在反向代理之后发布 Web UI](../../../docs/user/guide/public-deployments.zh.md)列出了这样的部署必须提供什么。
`--public-url` 公告浏览器使用的 HTTP(S) 根——打印与打开的启动 URL、`DSH_WEB_URL`,以及 agent 运行时上下文中的 Web GUI URL。公告不授予任何信任:浏览器可见的 authority 还必须用 `--trusted-host` 点名。该 flag 不配置监听器、路由或 cookie 作用域,因为外部链路归代理所有:[在反向代理之后发布 Web UI](../../../docs/user/guide/public-deployments.zh.md)列出了这样的部署必须提供什么。
无论是公告 URL 还是浏览器信任栅栏都不保护端口本身,因此请把端口限制在可信代理或网络内。
@@ -104,7 +104,7 @@ patch 会替换目标行的整个 `config`,因此每个 Web 行都重述自己
### 公告应用 URL
启动显示与浏览器交接接收附带启动 token 的公告根;web 表层提示词与 `DSH_WEB_URL` 接收不含凭据的形式。根本身由[监听、信任与公开部署](#public-deployments)定义。
启动显示与浏览器交接接收附带启动 token 的公告根;agent 的运行时上下文与 `DSH_WEB_URL` 接收不含凭据的形式。根本身由[监听、信任与公开部署](#public-deployments)定义。
### 就绪宣告
@@ -144,19 +144,19 @@ URL 行与浏览器交接都是就绪信号:监督方一观察到该行就发
<a id="model-experience"></a>
## 模型体验
### Harness 源码与 Web 表层上下文
### Web 运行时变量
#### 模型看到什么
当 `surfaceContext` 为 true 时,`harness:source` 段落标明磁盘上的 Harness 实现,但不会声称它就是工作目录;全局段落 `app:web-surface`(first-party 顺序 10100,位于可复用指令之后)则向模型说明 GUI:公告应用 URL(定义见上文「监听、信任与公开部署」)、「this page」指代什么、更新约定(重载接收端始终开启;无刷新重载还需要 `pnpm run dev:web` watcher),以及不要启动替代服务器的指令。`DSH_WEB_URL` 还会连同描述出现在受管 bash 环境中,每次调用时从运行中的服务器解析。当它为 false 时,这两个段落和该变量都不会注册。
当 `surfaceContext` 为 true 时,`DSH_WEB_URL` 连同描述出现在受管 bash 环境中,每次调用时解析为上文「监听、信任与公开部署」定义的公告应用 URL。为 false 时不注册该变量。GUI 定位、实现 checkout 与当前 GUI URL 由本 bundle 挂载的 [`dsh-harness-dev-context`](../../context/harness-dev-context/README.zh.md) 行提供。
#### Token 影响
每个会话一行源码说明和一段提示词,外加两行受管环境变量;每个进程内保持恒定。
两行受管环境变量;每个进程内保持恒定。
#### KV Cache 影响
源码与 Web 段落位于第一方可复用指令之后。工具与配置一致时,不同 checkout 路径或应用 URL 不会改变前置前缀;不保证提供方复用缓存。
无;该插件不贡献系统提示词文本。
## 已知限制与延期工作
+12 -8
View File
@@ -189,14 +189,11 @@
# Web glue owned by this bundle: resolves the built frontend dist (an
# assembly fact of dsh-web-app, never user config), mounts the
# frontend-static fallback owner, registers the web-surface prompt
# section and the bash runtime variable, prints the URL line, and opens the
# canonical URL after the full Loader tree settles and the required-
# entry audit passes. Invocation-only values come from the webStartup
# provider; the advertised application URL is this row's `publicUrl`,
# otherwise the bind-address URL. A complete agent-preset persona
# suppresses the prompt section for that agent while retaining the
# host-owned shell variable.
# frontend-static fallback owner, registers the bash runtime variable,
# prints the URL line, and opens the canonical URL after the full Loader
# tree settles and the required-entry audit passes. Invocation-only values
# come from the webStartup provider; the advertised application URL is
# this row's `publicUrl`, otherwise the bind-address URL.
- id: web-runtime
name: '@deepseek-ai/dsh-web-app'
inject: [webStartup]
@@ -206,6 +203,13 @@
publicUrl: !!js ctx.webStartup.publicUrl
surfaceContext: true
# Model context for an agent that inspects or extends the harness serving
# this GUI: value-free prompt sections plus the current checkout and GUI
# URL as runtime context. A complete agent-preset persona suppresses the
# sections for that agent.
- id: harness-dev-context
name: '@deepseek-ai/dsh-harness-dev-context'
# The client-plugin reload chain, always mounted: it is idle until a
# rebuild watcher (pnpm run dev:web) actually rewrites client bundles. It
# is a row rather than a child of web-runtime because its node half is a
+2 -1
View File
@@ -184,7 +184,8 @@
"@deepseek-ai/dsh-client-ui-shortcuts": "workspace:*",
"@deepseek-ai/dsh-client-product-analytics": "workspace:*",
"@deepseek-ai/dsh-host-product-telemetry-otel": "workspace:*",
"@deepseek-ai/dsh-client-ui-settings-session-log": "workspace:*"
"@deepseek-ai/dsh-client-ui-settings-session-log": "workspace:*",
"@deepseek-ai/dsh-harness-dev-context": "workspace:*"
},
"peerDependencies": {
"@deepseek-ai/cordis": "workspace:~",
+27 -85
View File
@@ -4,7 +4,7 @@
* manifest field). The plugin owns the browser-surface glue: it resolves
* the built frontend dist (workspace knowledge of this bundle, never user
* config), mounts the `frontend-static` fallback owner over it, registers the
* harness-source and web-surface prompt sections, the bash-visible web runtime
* bash-visible web runtime
* variable, the process-token URL line, and the default-browser handoff. An
* advertised `publicUrl` replaces the published bind-address URL. Non-loopback
* HTTP binds trigger an exposure warning. App command-line values arrive
@@ -14,26 +14,30 @@
import { spawn, type ChildProcess } from 'node:child_process'
import { createRequire } from 'node:module'
import { isIP } from 'node:net'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import type { Context } from '@deepseek-ai/cordis'
import z from '@deepseek-ai/schemastery'
import { addHarnessSourceSection, auditStartupEntries } from '@deepseek-ai/dsh-app-boot'
import { auditStartupEntries } from '@deepseek-ai/dsh-app-boot'
import type {} from '@deepseek-ai/dsh-client-connection'
import * as FrontendStatic from '@deepseek-ai/dsh-host-frontend-static'
import { isLoopbackHost, normalizeBindAddress } from '@deepseek-ai/dsh-host-webserver'
import { bindUrlHost, isLoopbackHost } from '@deepseek-ai/dsh-host-webserver'
import { launchedThroughSsh, launchEnvironmentOf } from '@deepseek-ai/dsh-launch-environment'
import { scrubbedParentEnv } from '@deepseek-ai/dsh-subprocess'
import type {} from '@deepseek-ai/cordis-plugin-loader'
import type {} from '@deepseek-ai/dsh-shell-env'
import { parsePublicUrl } from './public-url.ts'
import type { WebStartupValues } from './startup.ts'
declare module '@deepseek-ai/cordis' {
interface Context {
/** Values of this Web invocation, provided by the `web-startup` row; absent when no server starts. */
webStartup: WebStartupValues
}
}
/** Stable Cordis plugin name. */
export const name = 'web-app'
/** This dsh installation's root, from either this package's source or built entry. */
const SOURCE_ROOT = fileURLToPath(new URL('../../../..', import.meta.url))
const ANNOUNCED_ROOTS = new WeakSet<Context>()
/** Services required before the web runtime can mount. */
@@ -46,15 +50,13 @@ export interface Config {
/** Print the URL line on activation; a non-interactive layer can turn it off. */
printUrl: boolean
/**
* Register the model-visible surface context (the `app:web-surface` prompt
* section and the `DSH_WEB_URL` bash variable). A one-shot non-interactive
* layer can turn it off when its user is not in the GUI, so the
* orientation text would be false.
* Register the `DSH_WEB_URL` bash variable naming this GUI. A one-shot
* non-interactive layer can turn it off when its user is not in the GUI.
*/
surfaceContext: boolean
/**
* Canonical HTTP(S) root to advertise in the printed and opened URL,
* `DSH_WEB_URL`, and the web-surface orientation, e.g.
* Canonical HTTP(S) root to advertise in the printed and opened URL and
* `DSH_WEB_URL`, e.g.
* `https://app.example/ui/`, normalized to end in `/`. Configures no routing
* or authentication; see [public deployments](../README.md#public-deployments).
* Absent or YAML `null` advertises the bind-address URL.
@@ -103,65 +105,6 @@ try {
}
`
/**
* Local root URL of the active Web server, using the browser-compatible form
* of its bind address and brackets for IPv6 literals. Non-loopback binds such
* as a container's Pod address advertise that address.
* @throws when the runtime resolves without a bound webServer, or when the bind
* address has no URL form (see {@link advertisedBindHost}).
*/
function localWebUrl(ctx: Context): string {
const webServer = ctx.get('webServer')
const port = webServer?.port
if (webServer === undefined || port === undefined) {
throw new Error('web-app: webServer service missing while resolving Web runtime')
}
const host = advertisedBindHost(webServer.host)
return `${webServer.protocol}//${isIP(host) === 6 ? `[${host}]` : host}:${String(port)}`
}
/**
* Bind address in a URL. Loopback addresses use their canonical address text,
* so browsers treat them as local, trustworthy origins: a genuinely mapped
* literal such as `::ffff:127.0.0.1` reads as `127.0.0.1`, and a dotted-quad
* tail reads as the address it names, so `::0.0.0.1` reads as `::1` rather
* than as `0.0.0.1`. Interface zone IDs cannot appear in a URL; only a
* redundant loopback zone can be dropped.
* @param host - webserver bind address.
* @returns the zone-free URL host.
* @throws when a non-loopback zone requires an explicit public URL.
*/
function advertisedBindHost(host: string): string {
const zoneAt = host.indexOf('%')
const bare = zoneAt === -1 ? host : host.slice(0, zoneAt)
if (isLoopbackHost(bare)) return normalizeBindAddress(bare)
if (zoneAt === -1) return host
throw new Error(
`web-app: bind address ${JSON.stringify(host)} carries an interface zone id, which no URL can express;`
+ ' pass --public-url with the root browsers actually reach it through',
)
}
/** Resolve the advertised root: this plugin's canonical `publicUrl`, or the bind-address URL (loopback when bound to loopback). */
function appRootUrl(ctx: Context, publicUrl: string | undefined): string {
if (publicUrl !== undefined) return publicUrl
return localWebUrl(ctx)
}
/** Model-visible orientation and acceptance boundary for sessions created through `dsh web`. */
function webSurfacePrompt(webUrl: string): string {
const updateContract = 'The client-plugin HMR receiver is active, but client-plugin changes reload without a refresh only while '
+ '`pnpm run dev:web` is also running from this same checkout to rebuild their bundles; verify that watcher before promising automatic updates. '
+ 'Every other change — the apps/web shell and plain packages — requires rebuilding the affected Web artifacts and verifying this existing URL after a page refresh. '
return `You are interacting with the user through the DeepSeek Harness Web GUI at ${webUrl}. `
+ 'When the user refers to "this page", "this GUI", or "this app" without naming another target, they mean this GUI. '
+ 'The browser provides no implicit DOM, route, or screenshot context. '
+ updateContract
+ 'Starting another server does not update this GUI. '
+ 'The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__. '
+ 'Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL.'
}
/**
* Dist location is workspace knowledge of this bundle: anchored on the
* frontend package manifest, not configured. Existence is a request-time
@@ -227,8 +170,8 @@ export const internals: {
} = { resolveDistIndex, openBrowser }
/**
* Mount the Web runtime: dist serving, surface prompt, the bash runtime
* variable, the URL line, and the default-browser handoff.
* Mount the Web runtime: dist serving, the bash runtime variable, the URL
* line, and the default-browser handoff.
* @param ctx - plugin context carrying the webServer service.
* @param config - validated {@link Config}.
*/
@@ -237,30 +180,29 @@ export function apply(ctx: Context, config: Config): void {
// the string transform and reaches here, meaning unset.
const publicUrl = config.publicUrl ?? undefined
const boundHost = ctx.webServer.host
if (publicUrl === undefined) advertisedBindHost(boundHost)
if (publicUrl === undefined && bindUrlHost(boundHost) === undefined) {
throw new Error(
`web-app: bind address ${JSON.stringify(boundHost)} carries an interface zone id, which no URL can express;`
+ ' pass --public-url with the root browsers actually reach it through',
)
}
if (ctx.webServer.protocol === 'http:' && !isLoopbackHost(boundHost)) {
console.warn(`dsh web: listening on ${boundHost} over plain HTTP; restrict this port to a trusted proxy or network`)
}
// The bind URL belongs to this host. Under SSH, the operator reaches it
// through a local forwarding address that this process cannot derive.
const handoffBrowser = config.openBrowser && !launchedThroughSsh(launchEnvironmentOf(ctx))
/** The advertised root: the canonical `publicUrl`, or the listener's own origin. */
const appRootUrl = (): string => publicUrl ?? ctx.webServer.origin
ctx.plugin(FrontendStatic, { distIndex: internals.resolveDistIndex() })
if (config.surfaceContext) {
ctx.inject(['systemPrompt'], (promptCtx) => {
addHarnessSourceSection(promptCtx, SOURCE_ROOT)
promptCtx.systemPrompt.section({
name: 'app:web-surface',
order: promptCtx.systemPrompt.getSectionOrder('WEB_SURFACE'),
text: () => webSurfacePrompt(appRootUrl(promptCtx, publicUrl)),
})
})
ctx.inject(['shellEnv'], (runtimeCtx) => {
runtimeCtx.shellEnv.register({
name: 'web-runtime',
variables: {
[DSH_WEB_URL]: { description: 'Advertised URL of the DeepSeek Harness Web GUI serving this session.' },
},
resolve: () => ({ [DSH_WEB_URL]: appRootUrl(runtimeCtx, publicUrl) }),
resolve: () => ({ [DSH_WEB_URL]: appRootUrl() }),
})
})
}
@@ -273,7 +215,7 @@ export function apply(ctx: Context, config: Config): void {
// hand-built tree without a Loader is already the complete tree.
const announceReady = (): void => {
if (ANNOUNCED_ROOTS.has(connectionCtx.root)) return
const webUrl = appRootUrl(connectionCtx, publicUrl)
const webUrl = appRootUrl()
const authenticatedUrl = connectionCtx.connection.authenticatedUrl(webUrl)
ANNOUNCED_ROOTS.add(connectionCtx.root)
if (config.printUrl) {
+5 -3
View File
@@ -31,7 +31,8 @@ export interface WebStartupValues {
/** `--port`, absent when the invocation did not name one. */
port?: number
/**
* `--public-url`, absent when not specified: the advertised HTTP(S) root.
* `--public-url` as its canonical root ending in `/`, absent when not
* specified: the advertised HTTP(S) root.
* See [public deployments](../README.md#public-deployments).
*/
publicUrl?: string
@@ -104,9 +105,10 @@ export function apply(ctx: Context): void {
} else if (options.tlsCert !== undefined || options.tlsKey !== undefined) {
program.error('error: --tls-cert and --tls-key must be supplied together')
}
let publicUrl: string | undefined
if (options.publicUrl !== undefined) {
try {
parsePublicUrl(options.publicUrl, '--public-url')
publicUrl = parsePublicUrl(options.publicUrl, '--public-url').href
} catch (error) {
program.error(`error: ${(error as Error).message}`)
}
@@ -115,7 +117,7 @@ export function apply(ctx: Context): void {
openBrowser: options.open,
...options.host !== undefined && { host: options.host },
...options.port !== undefined && { port: Number(options.port) },
...options.publicUrl !== undefined && { publicUrl: options.publicUrl },
...publicUrl !== undefined && { publicUrl },
...tls !== undefined && { tls },
trustedHosts: options.trustedHost ?? [],
} satisfies WebStartupValues)
@@ -88,7 +88,7 @@ export const apply = ctx => globalThis.__webStartupApply(ctx)
await ctx.loader.await()
disposers.push(async () => { await ctx.fiber.dispose() })
return {
values: ctx.get(WEB_STARTUP_SERVICE) as WebStartupValues | undefined,
values: ctx.get(WEB_STARTUP_SERVICE),
observed,
}
}
@@ -162,14 +162,14 @@ describe('web command-line provider', () => {
])
expect(values).toEqual({
openBrowser: true,
publicUrl: 'https://web.example/ui',
publicUrl: 'https://web.example/ui/',
trustedHosts: ['lab.internal'],
})
expect(observed.readerConfig).toEqual({
host: '127.0.0.1',
openBrowser: true,
port: 3080,
publicUrl: 'https://web.example/ui',
publicUrl: 'https://web.example/ui/',
trustedHosts: ['lab.internal'],
})
expect(observed.exits).toEqual([])
+4 -41
View File
@@ -11,8 +11,7 @@ import { Context } from '@deepseek-ai/cordis'
import Loader from '@deepseek-ai/cordis-plugin-loader'
import * as AppBoot from '@deepseek-ai/dsh-app-boot'
import { createLaunchEnvironmentSnapshot, DSH_LAUNCH_ENVIRONMENT_KEY } from '@deepseek-ai/dsh-launch-environment'
import SystemPrompt from '@deepseek-ai/dsh-system-prompt'
import type { WebServer } from '@deepseek-ai/dsh-host-webserver'
import { bindUrlHost, type WebServer } from '@deepseek-ai/dsh-host-webserver'
import { apply, Config, internals } from '../src/index.ts'
vi.mock('node:child_process', async importOriginal => ({
@@ -59,10 +58,11 @@ function stageDist(): string {
/** Web carrier without a network listener. */
function fakeHttpServer(host = '127.0.0.1'): { server: WebServer } {
const server: Pick<WebServer, 'host' | 'port' | 'protocol' | 'registerFallback' | 'renderIndex'> = {
const server: Pick<WebServer, 'host' | 'port' | 'protocol' | 'origin' | 'registerFallback' | 'renderIndex'> = {
host,
port: 4567,
protocol: 'http:',
get origin() { return `http://${bindUrlHost(host) ?? ''}:${String(this.port)}` },
registerFallback: () => () => {},
renderIndex: (html: string) => html,
}
@@ -126,7 +126,6 @@ describe('web-app runtime glue', () => {
const openBrowser = vi.fn(async (url: string) => { lifecycle.push(`open:${url}`) })
internals.openBrowser = openBrowser
apply(ctx, new Config({ openBrowser: true, printUrl: true, surfaceContext: true }))
await ctx.plugin(SystemPrompt, { personaPrefix: '' })
await vi.waitFor(() => { expect(openBrowser).toHaveBeenCalled() })
expect(log).toHaveBeenCalledWith('dsh web: http://127.0.0.1:4567/?token=test-token')
@@ -137,13 +136,6 @@ describe('web-app runtime glue', () => {
'dsh web: opening the default browser; pass --no-open to disable',
'open:http://127.0.0.1:4567/?token=test-token',
])
const assembly = await ctx.systemPrompt.assemble()
expect(assembly.sections.find(entry => entry.name === 'harness:source')?.text).toContain('DeepSeek Harness implementation checkout')
const section = assembly.sections.find(entry => entry.name === 'app:web-surface')
expect(section?.text).toContain('http://127.0.0.1:4567')
// The single update contract: the receiver is always on; no-refresh
// reloads additionally need the rebuild watcher.
expect(section?.text).toContain('pnpm run dev:web')
const webRuntime = contributions.find(contribution => contribution.name === 'web-runtime')
expect(webRuntime?.resolve()).toEqual({ DSH_WEB_URL: 'http://127.0.0.1:4567' })
})
@@ -173,7 +165,6 @@ describe('web-app runtime glue', () => {
surfaceContext: true,
publicUrl: 'https://proxy.example:8443/web',
}))
await ctx.plugin(SystemPrompt, { personaPrefix: '' })
await vi.waitFor(() => { expect(openBrowser).toHaveBeenCalled() })
expect(lifecycle).toEqual([
@@ -181,10 +172,6 @@ describe('web-app runtime glue', () => {
'dsh web: opening the default browser; pass --no-open to disable',
'open:https://proxy.example:8443/web/?token=test-token',
])
const assembly = await ctx.systemPrompt.assemble()
const section = assembly.sections.find(entry => entry.name === 'app:web-surface')
expect(section?.text).toContain('https://proxy.example:8443/web/')
expect(section?.text).not.toContain('127.0.0.1')
const urlContribution = contributions.find(contribution => contribution.name === 'web-runtime')
expect(urlContribution?.resolve()).toEqual({ DSH_WEB_URL: 'https://proxy.example:8443/web/' })
})
@@ -198,17 +185,13 @@ describe('web-app runtime glue', () => {
const openBrowser = vi.fn(async () => {})
internals.openBrowser = openBrowser
apply(ctx, new Config({ openBrowser: false, printUrl: false, surfaceContext: true }))
await ctx.plugin(SystemPrompt, { personaPrefix: '' })
await new Promise(resolve => setTimeout(resolve, 0))
expect(log).not.toHaveBeenCalled()
expect(openBrowser).not.toHaveBeenCalled()
const assembly = await ctx.systemPrompt.assemble()
expect(assembly.sections.find(entry => entry.name === 'app:web-surface')?.text)
.toContain('rebuilding the affected Web artifacts')
await ctx.fiber.dispose()
})
it('skips the surface context when disabled (the one-shot layer): no prompt section, no bash variables', async () => {
it('skips the surface context when disabled (the one-shot layer): no bash variables', async () => {
stageDist()
const ctx = new Context()
ctx.provide('webServer', fakeHttpServer().server)
@@ -221,11 +204,7 @@ describe('web-app runtime glue', () => {
},
} as never)
apply(ctx, new Config({ openBrowser: false, printUrl: false, surfaceContext: false }))
await ctx.plugin(SystemPrompt, { personaPrefix: '' })
await new Promise(resolve => setTimeout(resolve, 0))
const assembly = await ctx.systemPrompt.assemble()
expect(assembly.sections.some(entry => entry.name === 'app:web-surface')).toBe(false)
expect(assembly.sections.some(entry => entry.name === 'harness:source')).toBe(false)
expect(contributions).toEqual([])
await ctx.fiber.dispose()
})
@@ -465,22 +444,6 @@ describe('web-app runtime glue', () => {
}
})
it('fails loud when the prompt section resolves against a portless webserver', async () => {
stageDist()
const ctx = new Context()
// A webserver whose bound port is gone (torn down mid-request): the
// section must throw, never render a URL with an undefined port.
const { server } = fakeHttpServer()
Object.defineProperty(server, 'port', { get: () => undefined })
ctx.provide('webServer', server)
provideConnection(ctx)
apply(ctx, new Config({ openBrowser: false, printUrl: false, surfaceContext: true }))
await ctx.plugin(SystemPrompt, { personaPrefix: '' })
await new Promise(resolve => setTimeout(resolve, 0))
await expect(ctx.systemPrompt.assemble()).rejects.toThrow('webServer service missing')
await ctx.fiber.dispose()
})
it('anchors the dist index on the frontend package manifest without requiring a built dist', () => {
// The production resolver (not the test hook): the anchor resolves on any
// checkout, built or not — dist existence is the fallback owner's
+2 -2
View File
@@ -15,8 +15,8 @@
en: 1eb35b015a6c423f
zh: a8a3dceee2c9e943
/context-request-context-plugins/packages:
en: e2fccdf2ec112e9c
zh: 3f6ff79970796bcc
en: 662b691a371ae95f
zh: c03a505eba42eaa2
/context-request-context-plugins/related-documentation:
en: 1d8d028a1ca69991
zh: 32f261bb380e0812
+1
View File
@@ -30,6 +30,7 @@ The context group provides plugins that add model-visible context to each reques
| [`file-reference-local/`](file-reference-local/README.md) | Local-workspace completion provider for `@file` mentions | — |
| [`time-context/`](time-context/README.md) | Current time, browser zone, and elapsed time per step | — |
| [`tmux-context/`](tmux-context/README.md) | The agent's tmux session, window, and pane location | — |
| [`harness-dev-context/`](harness-dev-context/README.md) | The harness checkout and Web GUI URL as runtime context, keeping the system prompt stable across processes | — |
-----
+1
View File
@@ -30,6 +30,7 @@ context 组提供不定义任何工具、为每次请求添加模型可见上下
| [`file-reference-local/`](file-reference-local/README.zh.md) | `@file` 提及的本地工作区补全提供方 | — |
| [`time-context/`](time-context/README.zh.md) | 每个步骤的当前时间、浏览器时区与经过时长 | — |
| [`tmux-context/`](tmux-context/README.zh.md) | agent 所在的 tmux 会话、窗口与窗格位置 | — |
| [`harness-dev-context/`](harness-dev-context/README.zh.md) | 以运行时上下文给出 harness checkout 与 Web GUI URL,使系统提示词跨进程保持稳定 | — |
-----
@@ -0,0 +1,67 @@
# Bilingual-pair consistency record for README.md (docs/i18n/README.md): per heading
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
# After editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write packages/context/harness-dev-context/README.md
/:
en: 8fed567b18e9dfa2
zh: 2ab54db218cc0197
/deepseek-ai-dsh-harness-dev-context:
en: b47701c093269adb
zh: e147a06ec0d6047f
/deepseek-ai-dsh-harness-dev-context/summary:
en: daf618174270461e
zh: 4c5b56fe4380c91f
/deepseek-ai-dsh-harness-dev-context/table-of-contents:
en: d152484eb41ac6b4
zh: 09388d293f9be9cb
/deepseek-ai-dsh-harness-dev-context/use-this-package:
en: c67f75e0f438ea33
zh: 1c06dd9723847326
/deepseek-ai-dsh-harness-dev-context/use-this-package/what-the-model-gets:
en: afe4f50d2850c14a
zh: ff4c3ce913ec5f01
/deepseek-ai-dsh-harness-dev-context/use-this-package/sessions-from-earlier-releases:
en: d810950db5118265
zh: d20e3965fa78e0f8
/deepseek-ai-dsh-harness-dev-context/understand-the-implementation:
en: 2d21fa2aad5a729d
zh: cfbfada0eb647435
/deepseek-ai-dsh-harness-dev-context/understand-the-implementation/design-concept:
en: 401a852a3444aff4
zh: 5288a593f61c168b
/deepseek-ai-dsh-harness-dev-context/understand-the-implementation/source-map:
en: 4696b6c3a1f91f96
zh: 3a56d257ec768a5e
/deepseek-ai-dsh-harness-dev-context/understand-the-implementation/main-flow:
en: 33ca1d14c15fac80
zh: 0ed5e425709ce8e2
/deepseek-ai-dsh-harness-dev-context/further-exploration:
en: 5fb7bdaf03bffde7
zh: f78516fcb25efc6d
/deepseek-ai-dsh-harness-dev-context/model-experience:
en: 215e7ba838619b7b
zh: a311da3843709f90
/deepseek-ai-dsh-harness-dev-context/model-experience/harness-checkout-and-web-gui:
en: ddbe5927f55a6275
zh: 1687795c41c16a8c
/deepseek-ai-dsh-harness-dev-context/model-experience/harness-checkout-and-web-gui/what-the-model-sees:
en: f3236c45cf5bc3a6
zh: 1a3499b2e21f4761
/deepseek-ai-dsh-harness-dev-context/model-experience/harness-checkout-and-web-gui/what-the-model-sees/system-prompt-paragraphs:
en: c6c9fa4caf6f2f30
zh: f501149c17c0ea60
/deepseek-ai-dsh-harness-dev-context/model-experience/harness-checkout-and-web-gui/what-the-model-sees/runtime-context-lines:
en: 37680cbe3eaabef5
zh: 8c1b432ddf7d20b5
/deepseek-ai-dsh-harness-dev-context/model-experience/harness-checkout-and-web-gui/token-effect:
en: 2c629df08d801b36
zh: 437d43a9c5fdc68a
/deepseek-ai-dsh-harness-dev-context/model-experience/harness-checkout-and-web-gui/kv-cache-effect:
en: e8f89a14bd36dae0
zh: bd4ec43e07e234c9
/deepseek-ai-dsh-harness-dev-context/known-limitations-and-deferred-work:
en: 80e76d36432ab935
zh: 76864858d2fbc150
/deepseek-ai-dsh-harness-dev-context/known-limitations-and-deferred-work/dev-note:
en: e67f633dc6fe7773
zh: e88aeb617ffb74ea
@@ -0,0 +1,130 @@
---
description: "Model context for users and maintainers of the Web GUI that names the DeepSeek Harness checkout and GUI URL without letting either change the system prompt."
kind: "package-reference"
---
# @deepseek-ai/dsh-harness-dev-context
English | [中文](README.zh.md)
## Summary
`dsh-harness-dev-context` tells an agent running behind the DeepSeek Harness Web GUI where the harness implementation checkout lives, how the GUI relates to "this page", and which URL serves it. The system prompt carries only value-free guidance; the current checkout path and GUI URL arrive as runtime context, so starting the process from another checkout, port, or installation never rewrites a Session's logged system prompt. Sessions whose prompt still embeds those values from earlier releases keep that text verbatim.
## Table of Contents
- [Use this package](#use-this-package)
- [Understand the implementation](#understand-the-implementation)
- [Further Exploration](#further-exploration)
- [Model Experience](#model-experience)
- [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
- [Dev Note](#dev-note)
-----
<a id="use-this-package"></a>
## Use this package
The shipped Web bundle mounts this plugin as its `harness-dev-context` row. Disable that row in a profile patch when the agent should not learn the harness checkout or GUI URL. The plugin takes no configuration and activates only where every injected service exists: `systemPrompt`, `sessionProjections`, the bound `webServer` listener, and the `webStartup` invocation values, so `--help` and non-Web compositions never mount it.
### What the model gets
Two system-prompt sections explain that the checkout differs from the working directory and that "this page" means this GUI, together with the GUI update contract. Two runtime-context lines state the current values: the installation root four directories above this package, and the advertised `--public-url` root or, without one, the listener's own origin. Runtime context follows the shared snapshot rules: an unchanged value adds nothing, and a changed one appends a snapshot before the step's input instead of rewriting earlier messages.
### Sessions from earlier releases
Earlier releases embedded both values in the system prompt. When a Session's latest nonempty system prompt still contains those exact paragraphs, the sections repeat them verbatim, old values included, so upgrading and later port or checkout changes leave that Session's prompt byte-identical; the runtime-context lines still give the current values. Text that only resembles an earlier paragraph receives the current guidance.
-----
<a id="understand-the-implementation"></a>
## Understand the implementation
<details>
<summary>Implementation internals — click to expand</summary>
This section explains the design of the plugin; the observable behavior is covered in [Use this package](#use-this-package).
### Design concept
A host-only session projection, `harnessDevLegacyPrompt`, folds every committed nonempty `system/message` into the earlier-format paragraphs it contains, matched by their fixed text around the value on one line. The section text providers read that state through `AssembleContext.agent`; assemblies without an agent use the current guidance. The projection is restored with every other unit when a Session resumes, so no historical event is read synchronously.
### Source map
| File | Role |
|---|---|
| [`src/index.ts`](src/index.ts) | Plugin entry: sections, runtime contexts, earlier-format projection |
### Main flow
Activation registers the projection unit, both sections, and both contexts. At each assembly the sections choose the admitted earlier paragraph or the current guidance; at each request admission the contexts read the listener origin and the invocation's public root. Disposing the plugin fiber removes every registration.
</details>
-----
<a id="further-exploration"></a>
## Further Exploration
Read these pages when the package-level contract is not enough. They move from the decision record to the services this plugin reads.
- [Process-specific values as runtime context](../../../.agents/notes/implemented/bug-fix/2026-10-11-process-specific-prompt-values-in-runtime-context.md) — why the values left the system prompt and how earlier Sessions stay stable.
- [Session projections subsystem](../../../docs/subsystems/session-projection.md) — the projection contract the earlier-format state uses.
- [Web server package](../../host/webserver/README.md) — the listener origin this plugin reads.
- [Web app bundle](../../bundle/web-app/README.md) — the `webStartup` service and the row that mounts this plugin.
- [Context group map](../README.md) — sibling request-context packages.
-----
<a id="model-experience"></a>
## Model Experience
### Harness checkout and Web GUI
#### What the model sees
Two system-prompt paragraphs at first-party orders 10000 and 10100, after reusable instructions, and two runtime-context lines at context orders 200 and 210. A Session admitted under an earlier release sees its own earlier paragraphs instead of the two below.
##### System-prompt paragraphs
```markdown
The runtime context names the DeepSeek Harness implementation checkout. The checkout location and current working directory are separate values and may differ; never infer the working directory from the checkout path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend DSH itself.
You are interacting with the user through the DeepSeek Harness Web GUI whose URL the runtime context names. When the user refers to "this page", "this GUI", or "this app" without naming another target, they mean this GUI. The browser provides no implicit DOM, route, or screenshot context. The client-plugin HMR receiver is active, but client-plugin changes reload without a refresh only while `pnpm run dev:web` is also running from this same checkout to rebuild their bundles; verify that watcher before promising automatic updates. Every other change — the apps/web shell and plain packages — requires rebuilding the affected Web artifacts and verifying this existing URL after a page refresh. Starting another server does not update this GUI. The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__. Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL.
```
##### Runtime-context lines
```markdown
Current DeepSeek Harness implementation checkout: "<installation root>".
Current DeepSeek Harness Web GUI URL: "<public root or listener origin>".
```
#### Token effect
Two prompt paragraphs per Session and two lines in each runtime-context snapshot. A changed checkout or URL adds one snapshot.
#### KV Cache effect
The system prompt is identical across checkouts, ports, and installations, so a process started elsewhere leaves the cached prefix intact; a changed value appends one runtime-context snapshot after it.
## Known Limitations and Deferred Work
<a id="known-limitations-and-deferred-work"></a>
These limits describe what the stability guarantee covers. They are current package constraints.
- **Two paragraphs only** — other system-prompt text that changes between releases still rewrites the first system message on routes without in-history prompt updates.
- **Earlier values stay** — an earlier-format Session keeps its old checkout path and URL in the system prompt for its whole lifetime; only the later runtime-context lines are current.
- **Mixed releases** — a release without this package rewrites the first system message of a Session started with it, so every checkout that serves a shared `DSH_HOME` needs this package before they alternate.
<a id="dev-note"></a>
### Dev Note
<details>
<summary>Working context for maintainers — click to expand</summary>
None.
</details>
@@ -0,0 +1,130 @@
---
description: "面向 Web GUI 用户与维护者的模型上下文:给出 DeepSeek Harness checkout 与 GUI URL,且两者都不会改变系统提示词。"
kind: "package-reference"
---
# @deepseek-ai/dsh-harness-dev-context
[English](README.md) | 中文
## 概述
`dsh-harness-dev-context` 告诉运行在 DeepSeek Harness Web GUI 背后的 agent:harness 实现 checkout 在哪里、GUI 与「this page」是什么关系,以及哪个 URL 提供该 GUI。系统提示词只包含不含值的说明;当前 checkout 路径与 GUI URL 以运行时上下文送达,因此从别的 checkout、端口或安装位置启动进程,绝不会改写会话已记录的系统提示词。提示词仍嵌有早期版本这些值的会话会原样保留那段文本。
## 目录
- [使用本包](#use-this-package)
- [理解实现](#understand-the-implementation)
- [进一步探索](#further-exploration)
- [模型体验](#model-experience)
- [已知限制与延期工作](#known-limitations-and-deferred-work)
- [开发备注](#dev-note)
-----
<a id="use-this-package"></a>
## 使用本包
随附的 Web bundle 以 `harness-dev-context` 行挂载此插件。不希望 agent 得知 harness checkout 或 GUI URL 时,在 profile patch 中禁用该行。插件不接受配置,只在每个注入服务都存在时激活:`systemPrompt`、`sessionProjections`、已绑定的 `webServer` 监听器,以及 `webStartup` 调用参数,因此 `--help` 与非 Web 组合永远不会挂载它。
### 模型得到什么
两个系统提示词段落说明 checkout 与工作目录不同、「this page」指此 GUI,并给出 GUI 的更新约定。两行运行时上下文给出当前值:本包上方四层目录处的安装根,以及公告的 `--public-url` 根;没有该参数时为监听器自身的 origin。运行时上下文遵循共享的快照规则:值不变不追加内容,值变化时在本步输入之前追加一份快照,而不是改写更早的消息。
### 早期版本的会话
早期版本把两个值都嵌在系统提示词里。会话最新的非空系统提示词仍含那两段原文时,两个段落会原样重复它们(包括旧值),因此升级以及之后更换端口或 checkout 都不会改变该会话提示词的任何字节;运行时上下文行仍给出当前值。只是看起来像早期段落的文本会得到当前说明。
-----
<a id="understand-the-implementation"></a>
## 理解实现
<details>
<summary>实现细节——点击展开</summary>
本节解释插件的设计;可观察行为见[使用本包](#use-this-package)。
### 设计思路
仅限宿主的会话投影 `harnessDevLegacyPrompt` 把每个已提交的非空 `system/message` 折叠为其中包含的早期格式段落,按值两侧的固定文本在同一行内匹配。段落文本提供函数通过 `AssembleContext.agent` 读取该状态;没有 agent 的组装使用当前说明。会话恢复时该投影与其他单元一起恢复,因此不同步读取任何历史事件。
### 源码地图
| 文件 | 职责 |
|---|---|
| [`src/index.ts`](src/index.ts) | 插件入口:段落、运行时上下文、早期格式投影 |
### 主流程
激活时注册投影单元、两个段落与两个上下文。每次组装时,段落在已提交的早期段落与当前说明之间选择;每次请求准入时,上下文读取监听器 origin 与调用的公开根。销毁插件 fiber 会移除全部注册。
</details>
-----
<a id="further-exploration"></a>
## 进一步探索
包级约定不够用时阅读这些页面。它们从决策记录走到本插件读取的服务。
- [进程相关值改走运行时上下文](../../../.agents/notes/implemented/bug-fix/2026-10-11-process-specific-prompt-values-in-runtime-context.zh.md)——这些值为什么离开系统提示词,以及早期会话如何保持稳定。
- [会话投影子系统](../../../docs/subsystems/session-projection.zh.md)——早期格式状态使用的投影约定。
- [Web server 包](../../host/webserver/README.zh.md)——本插件读取的监听器 origin。
- [Web app bundle](../../bundle/web-app/README.zh.md)——`webStartup` 服务与挂载本插件的行。
- [Context 组地图](../README.zh.md)——同组的请求上下文包。
-----
<a id="model-experience"></a>
## 模型体验
### Harness checkout 与 Web GUI
#### 模型看到什么
两个系统提示词段落,位于可复用指令之后的第一方顺序 10000 与 10100;两行运行时上下文,位于上下文顺序 200 与 210。在早期版本下提交过提示词的会话看到的是自己的早期段落,而不是下面两段。
##### 系统提示词段落
```markdown
The runtime context names the DeepSeek Harness implementation checkout. The checkout location and current working directory are separate values and may differ; never infer the working directory from the checkout path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend DSH itself.
You are interacting with the user through the DeepSeek Harness Web GUI whose URL the runtime context names. When the user refers to "this page", "this GUI", or "this app" without naming another target, they mean this GUI. The browser provides no implicit DOM, route, or screenshot context. The client-plugin HMR receiver is active, but client-plugin changes reload without a refresh only while `pnpm run dev:web` is also running from this same checkout to rebuild their bundles; verify that watcher before promising automatic updates. Every other change — the apps/web shell and plain packages — requires rebuilding the affected Web artifacts and verifying this existing URL after a page refresh. Starting another server does not update this GUI. The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__. Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL.
```
##### 运行时上下文行
```markdown
Current DeepSeek Harness implementation checkout: "<installation root>".
Current DeepSeek Harness Web GUI URL: "<public root or listener origin>".
```
#### Token 影响
每个会话两段提示词,每份运行时上下文快照两行。checkout 或 URL 变化时追加一份快照。
#### KV Cache 影响
系统提示词在不同 checkout、端口与安装位置下完全相同,因此在别处启动的进程不会破坏已缓存的前缀;值变化时在其后追加一份运行时上下文快照。
## 已知限制与延期工作
<a id="known-limitations-and-deferred-work"></a>
这些限制说明稳定性保证覆盖哪些内容。它们是当前包约束。
- **只覆盖两段**——版本之间变化的其他系统提示词文本,在不支持 in-history 提示词更新的路由上仍会改写第一条 system 消息。
- **早期值保留**——早期格式会话在整个生命周期内都在系统提示词里保留旧 checkout 路径与 URL;只有之后的运行时上下文行是当前值。
- **混用版本**——不含本包的版本会改写以本包启动的会话的第一条 system 消息,因此共用同一 `DSH_HOME` 的每个 checkout 都需要先包含本包,才能交替运行。
<a id="dev-note"></a>
### 开发备注
<details>
<summary>维护者工作上下文——点击展开</summary>
无。
</details>
@@ -0,0 +1,52 @@
{
"name": "@deepseek-ai/dsh-harness-dev-context",
"description": "Model context naming the DeepSeek Harness checkout and Web GUI URL without letting either change the system prompt",
"version": "0.2.1-alpha.2",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
"directory": "packages/context/harness-dev-context"
},
"type": "module",
"main": "lib/index.js",
"types": "lib/types/index.d.ts",
"exports": {
".": {
"types": "./lib/types/index.d.ts",
"default": "./lib/index.js"
},
"./src/*": "./src/*",
"./package.json": "./package.json"
},
"files": [
"lib/index.js",
"lib/types/**/*.d.ts"
],
"license": "MIT",
"dependencies": {
"zod": "4.4.3"
},
"peerDependencies": {
"@deepseek-ai/cordis": "workspace:~",
"@deepseek-ai/dsh-agent": "workspace:*",
"@deepseek-ai/dsh-host-webserver": "workspace:*",
"@deepseek-ai/dsh-session": "workspace:*",
"@deepseek-ai/dsh-session-projection": "workspace:*",
"@deepseek-ai/dsh-system-prompt": "workspace:*",
"@deepseek-ai/dsh-web-app": "workspace:*"
},
"devDependencies": {
"@deepseek-ai/cordis": "workspace:~",
"@deepseek-ai/dsh-agent": "workspace:*",
"@deepseek-ai/dsh-agent-loop-testkit": "workspace:*",
"@deepseek-ai/dsh-host-webserver": "workspace:*",
"@deepseek-ai/dsh-llm": "workspace:*",
"@deepseek-ai/dsh-session": "workspace:*",
"@deepseek-ai/dsh-session-projection": "workspace:*",
"@deepseek-ai/dsh-system-prompt": "workspace:*",
"@deepseek-ai/dsh-web-app": "workspace:*"
}
}
@@ -0,0 +1,148 @@
/**
* @deepseek-ai/dsh-harness-dev-context — model context for an agent that can
* inspect and extend the DeepSeek Harness serving its Web GUI. It registers
* path- and URL-free prompt sections and states the current implementation
* checkout and Web GUI URL as runtime context, so a process started from
* another checkout, port, or installation leaves the system prompt unchanged.
* A Session whose admitted prompt holds the paragraphs that embedded those
* values keeps them verbatim, so resuming it never rewrites its logged prompt.
* @module @deepseek-ai/dsh-harness-dev-context
*/
import { fileURLToPath } from 'node:url'
import type { Context } from '@deepseek-ai/cordis'
import { z as zod } from 'zod'
import type {} from '@deepseek-ai/dsh-agent'
import type {} from '@deepseek-ai/dsh-host-webserver'
import type {} from '@deepseek-ai/dsh-web-app'
import type { SessionEvent } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-session-projection'
import type { AssembleContext } from '@deepseek-ai/dsh-system-prompt'
/** Stable Cordis plugin name. */
export const name = 'harness-dev-context'
/** Prompt registries, the projection registry, the bound listener, and the invocation it serves. */
export const inject = ['systemPrompt', 'sessionProjections', 'webServer', 'webStartup']
/** This installation's root, four directories above this package's source or built entry. */
const SOURCE_ROOT = fileURLToPath(new URL('../../../..', import.meta.url))
/** Prompt-section and runtime-context name for the implementation checkout. */
const HARNESS_SOURCE = 'harness:source'
/** Prompt-section and runtime-context name for the Web GUI orientation and its URL. */
const WEB_SURFACE = 'app:web-surface'
const HARNESS_SOURCE_GUIDANCE = 'The checkout location and current working directory are separate values and may differ; '
+ 'never infer the working directory from the checkout path. Use pwd to determine the current working directory. '
+ 'Use this checkout only to inspect or extend DSH itself.'
const HARNESS_SOURCE_PROMPT = `The runtime context names the DeepSeek Harness implementation checkout. ${HARNESS_SOURCE_GUIDANCE}`
const WEB_SURFACE_GUIDANCE = 'When the user refers to "this page", "this GUI", or "this app" without naming another target, they mean this GUI. '
+ 'The browser provides no implicit DOM, route, or screenshot context. '
+ 'The client-plugin HMR receiver is active, but client-plugin changes reload without a refresh only while '
+ '`pnpm run dev:web` is also running from this same checkout to rebuild their bundles; verify that watcher before promising automatic updates. '
+ 'Every other change — the apps/web shell and plain packages — requires rebuilding the affected Web artifacts and verifying this existing URL after a page refresh. '
+ 'Starting another server does not update this GUI. '
+ 'The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__. '
+ 'Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL.'
const WEB_SURFACE_PROMPT = `You are interacting with the user through the DeepSeek Harness Web GUI whose URL the runtime context names. ${WEB_SURFACE_GUIDANCE}`
/**
* Fixed text around the value in each paragraph that embedded it. The source
* suffix keeps its original wording, which differs from the current guidance.
*/
const LEGACY_SOURCE = {
prefix: 'The DeepSeek Harness implementation checkout is at ',
suffix: '. The checkout location and current working directory are separate values and may differ; '
+ 'never infer the working directory from this path. Use pwd to determine the current working directory. '
+ 'Use this checkout only to inspect or extend DSH itself.',
}
const LEGACY_WEB_SURFACE = {
prefix: 'You are interacting with the user through the DeepSeek Harness Web GUI at ',
suffix: `. ${WEB_SURFACE_GUIDANCE}`,
}
/** Host-only projection key of the value-bearing paragraphs a Session admitted. */
const LEGACY_PROMPT = 'harnessDevLegacyPrompt'
const legacyPromptSchema = zod.object({ source: zod.string().nullable(), web: zod.string().nullable() })
/** Value-bearing paragraphs of the latest nonempty system prompt a Session committed; `null` where it has none. */
export type LegacyPrompt = zod.infer<typeof legacyPromptSchema>
declare module '@deepseek-ai/dsh-session-projection/types' {
interface SessionProjectionStateMap {
/** Value-bearing harness-source and Web-surface paragraphs of the latest nonempty admitted system prompt. */
harnessDevLegacyPrompt: LegacyPrompt
}
}
/** The complete single-line paragraph between `prefix` and `suffix`, or `null` when the prompt has none. */
function legacyParagraph(prompt: string, { prefix, suffix }: { prefix: string; suffix: string }): string | null {
const start = prompt.indexOf(prefix)
if (start < 0) return null
const end = prompt.indexOf(suffix, start + prefix.length)
if (end < 0) return null
const paragraph = prompt.slice(start, end + suffix.length)
return paragraph.includes('\n') ? null : paragraph
}
/** Fold one committed event into the admitted paragraphs; empty prompt versions admit nothing. */
function foldLegacyPrompt(state: LegacyPrompt, event: SessionEvent): LegacyPrompt {
if (event.type !== 'system/message') return state
const [block] = event.data.message.content
if (block?.type !== 'text' || block.text === '') return state
const source = legacyParagraph(block.text, LEGACY_SOURCE)
const web = legacyParagraph(block.text, LEGACY_WEB_SURFACE)
return source === state.source && web === state.web ? state : { source, web }
}
const ADMITS_NOTHING: LegacyPrompt = { source: null, web: null }
/**
* Register the two sections, their runtime-context values, and the
* projection that keeps a Session's admitted paragraphs.
* @param ctx - plugin context with every {@link inject} service.
*/
export function apply(ctx: Context): void {
ctx.sessionProjections.register({
key: LEGACY_PROMPT,
stateVersion: 1,
stateSchema: legacyPromptSchema,
init: () => ADMITS_NOTHING,
apply: foldLegacyPrompt,
})
const admitted = (context: AssembleContext): LegacyPrompt => {
const session = context.agent?.session
// This plugin registers the unit above, so its state exists for every Session.
return session === undefined ? ADMITS_NOTHING : ctx.sessionProjections.stateOf(session, LEGACY_PROMPT) as LegacyPrompt
}
ctx.systemPrompt.section({
name: HARNESS_SOURCE,
order: ctx.systemPrompt.getSectionOrder('HARNESS_SOURCE'),
interpolate: false,
text: context => admitted(context).source ?? HARNESS_SOURCE_PROMPT,
})
ctx.systemPrompt.context({
name: HARNESS_SOURCE,
order: ctx.systemPrompt.getContextOrder('HARNESS_SOURCE'),
interpolate: false,
text: `Current DeepSeek Harness implementation checkout: ${JSON.stringify(SOURCE_ROOT)}.`,
})
ctx.systemPrompt.section({
name: WEB_SURFACE,
order: ctx.systemPrompt.getSectionOrder('WEB_SURFACE'),
interpolate: false,
text: context => admitted(context).web ?? WEB_SURFACE_PROMPT,
})
ctx.systemPrompt.context({
name: WEB_SURFACE,
order: ctx.systemPrompt.getContextOrder('WEB_SURFACE'),
interpolate: false,
text: () => `Current DeepSeek Harness Web GUI URL: ${JSON.stringify(ctx.webStartup.publicUrl ?? ctx.webServer.origin)}.`,
})
}
@@ -0,0 +1,234 @@
/** Prompt stability of the harness checkout and Web GUI URL across processes, checkouts, and ports. */
import { describe, expect, it, onTestFinished } from 'vitest'
import { Context } from '@deepseek-ai/cordis'
import type { Agent } from '@deepseek-ai/dsh-agent'
import { mountAgentLoopTestDependencies, mountAgentLoopTestHarness } from '@deepseek-ai/dsh-agent-loop-testkit'
import type { WebServer } from '@deepseek-ai/dsh-host-webserver'
import {
createUserMessage, LlmAdapter,
type GenerateOptions, type LlmResolvedModelInfo, type StreamChunk, type SystemPromptUpdate,
} from '@deepseek-ai/dsh-llm'
import { SessionId, type Session } from '@deepseek-ai/dsh-session'
import { renderContextSnapshot, renderPrompt } from '@deepseek-ai/dsh-system-prompt'
import * as HarnessDevContext from '../src/index.ts'
const SOURCE_PROMPT = 'The runtime context names the DeepSeek Harness implementation checkout. The checkout location and current working directory are separate values and may differ; never infer the working directory from the checkout path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend DSH itself.'
const WEB_GUIDANCE = 'When the user refers to "this page", "this GUI", or "this app" without naming another target, they mean this GUI. '
+ 'The browser provides no implicit DOM, route, or screenshot context. '
+ 'The client-plugin HMR receiver is active, but client-plugin changes reload without a refresh only while '
+ '`pnpm run dev:web` is also running from this same checkout to rebuild their bundles; verify that watcher before promising automatic updates. '
+ 'Every other change — the apps/web shell and plain packages — requires rebuilding the affected Web artifacts and verifying this existing URL after a page refresh. '
+ 'Starting another server does not update this GUI. '
+ 'The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__. '
+ 'Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL.'
const WEB_PROMPT = `You are interacting with the user through the DeepSeek Harness Web GUI whose URL the runtime context names. ${WEB_GUIDANCE}`
/** The value-bearing paragraphs earlier releases rendered. */
const LEGACY_SOURCE = 'The DeepSeek Harness implementation checkout is at /old/checkout/. The checkout location and current working directory are separate values and may differ; never infer the working directory from this path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend DSH itself.'
const LEGACY_WEB = `You are interacting with the user through the DeepSeek Harness Web GUI at http://127.0.0.1:3100. ${WEB_GUIDANCE}`
/** Records every request and answers each with one short text reply. */
class RecordingAdapter extends LlmAdapter {
readonly requests: GenerateOptions[] = []
constructor(private readonly systemPromptUpdate: SystemPromptUpdate | undefined) {
super()
}
override resolveModel(provider: string, model: string): Promise<LlmResolvedModelInfo> {
return Promise.resolve({
provider, id: model, name: model,
...this.systemPromptUpdate === undefined ? {} : { systemPromptUpdate: this.systemPromptUpdate },
})
}
async * stream(options: GenerateOptions): AsyncIterable<StreamChunk> {
this.requests.push(options)
yield { type: 'block-start', index: 0, blockType: 'text' }
yield { type: 'text-delta', index: 0, text: 'ok' }
yield { type: 'block-end', index: 0, block: { type: 'text', text: 'ok' } }
yield { type: 'usage', usage: { inputTokens: 1, outputTokens: 1 } }
yield { type: 'finish', reason: { kind: 'stop' } }
}
}
const ROUTE = { provider: 'route', model: 'model' }
/** The listener and invocation services with a port the test can move, as restarted processes see them. */
function provideWebServices(ctx: Context, startup: { publicUrl?: string } = {}): { port: number } {
const listener = { port: 4567 }
ctx.provide('webServer', {
get origin() { return `http://127.0.0.1:${String(listener.port)}` },
} as Pick<WebServer, 'origin'> as WebServer)
ctx.provide('webStartup', { openBrowser: false, trustedHosts: [], ...startup } satisfies Context['webStartup'])
return listener
}
/** A production AgentLoop with this plugin mounted. */
async function promptLoop(systemPromptUpdate: SystemPromptUpdate | undefined) {
const ctx = new Context()
onTestFinished(() => ctx.fiber.dispose())
const listener = provideWebServices(ctx)
await mountAgentLoopTestDependencies(ctx)
const adapter = new RecordingAdapter(systemPromptUpdate)
ctx.llm.registerAdapter([ROUTE.provider], adapter)
await ctx.plugin(HarnessDevContext)
const harness = await mountAgentLoopTestHarness(ctx)
/** Resume the Session's complete log under a new Agent, as a restarted process does. */
const resume = async (session: Session, id: string): Promise<Agent> => (await ctx.agents.create({
sessionId: SessionId(id), agentOptions: ROUTE, seed: [...session.snapshotEvents()],
})).agent
/** One turn under an earlier release: the given paragraphs and no value contexts. */
const earlierSession = async (source = LEGACY_SOURCE, web = LEGACY_WEB): Promise<Agent> => {
const earlierRelease = ctx.on('system-prompt/assemble', async (_assembly, _context, next) => {
const assembly = await next()
return {
...assembly,
sections: assembly.sections.map(section => section.name === 'harness:source' ? { ...section, text: source }
: section.name === 'app:web-surface' ? { ...section, text: web } : section),
contexts: assembly.contexts.filter(entry => entry.name !== 'harness:source' && entry.name !== 'app:web-surface'),
}
})
const agent = await harness.create(SessionId('earlier'), ROUTE)
await send(agent, 'before the upgrade')
earlierRelease()
return agent
}
return { ctx, listener, adapter, harness, resume, earlierSession }
}
async function send(agent: Agent, text: string): Promise<void> {
agent.followup(createUserMessage({ content: [{ type: 'text', text }], source: { kind: 'user' } }))
await agent.whenIdle()
}
/** Every committed system prompt version in event order; a cleared version is `''`. */
function systemPrompts(session: Session): string[] {
return session.snapshotEvents().flatMap(event => event.type === 'system/message'
? [event.data.message.content.map(block => block.type === 'text' ? block.text : '').join('')]
: [])
}
function latestRuntimeContext(session: Session): string | undefined {
const event = session.snapshotEvents().findLast(entry => entry.type === 'user/message'
&& entry.data.source.kind === 'runtime-context')
const block = event?.type === 'user/message' ? event.data.content[0] : undefined
return block?.type === 'text' ? block.text : undefined
}
function requestSystemPrompts(request: GenerateOptions | undefined): string[] {
return (request?.messages ?? []).filter(message => message.role === 'system')
.flatMap(message => message.content.map(block => block.type === 'text' ? block.text : ''))
}
describe('harness-dev-context', () => {
it('registers value-free sections and reports the checkout and Web GUI URL as runtime context', async () => {
const ctx = new Context()
onTestFinished(() => ctx.fiber.dispose())
provideWebServices(ctx)
await mountAgentLoopTestDependencies(ctx)
const fiber = ctx.plugin(HarnessDevContext)
await fiber
const assembly = await ctx.systemPrompt.assemble()
expect(assembly.sections.filter(entry => entry.name === 'harness:source' || entry.name === 'app:web-surface')
.map(entry => entry.text)).toEqual([SOURCE_PROMPT, WEB_PROMPT])
expect(renderPrompt(assembly)).not.toContain('127.0.0.1')
expect(renderContextSnapshot(assembly).split('\n\n').slice(1)).toEqual([
expect.stringMatching(/^Current DeepSeek Harness implementation checkout: ".+"\.$/u),
'Current DeepSeek Harness Web GUI URL: "http://127.0.0.1:4567".',
])
await fiber.dispose()
const disposed = await ctx.systemPrompt.assemble()
expect(disposed.sections.some(entry => entry.name === 'harness:source' || entry.name === 'app:web-surface')).toBe(false)
expect(disposed.contexts).toEqual([])
})
it('reports the advertised public root instead of the listener origin', async () => {
const ctx = new Context()
onTestFinished(() => ctx.fiber.dispose())
provideWebServices(ctx, { publicUrl: 'https://proxy.example:8443/web/' })
await mountAgentLoopTestDependencies(ctx)
await ctx.plugin(HarnessDevContext)
const assembly = await ctx.systemPrompt.assemble()
expect(assembly.contexts.find(entry => entry.name === 'app:web-surface')?.text)
.toBe('Current DeepSeek Harness Web GUI URL: "https://proxy.example:8443/web/".')
})
it.each([
{ route: 'replace-only', systemPromptUpdate: undefined },
{ route: 'in-history', systemPromptUpdate: 'in-history' as const },
])('resumes an earlier-format Session on other ports without rewriting its system prompt ($route)', async ({ systemPromptUpdate }) => {
const h = await promptLoop(systemPromptUpdate)
const original = await h.earlierSession()
const logged = systemPrompts(original.session)
expect(logged).toHaveLength(1)
expect(logged[0]).toContain(LEGACY_SOURCE)
expect(logged[0]).toContain(LEGACY_WEB)
let session = original.session
for (const port of [4568, 4569]) {
h.listener.port = port
const resumed = await h.resume(session, `earlier-on-${String(port)}`)
await send(resumed, `after the upgrade on ${String(port)}`)
expect(systemPrompts(resumed.session)).toEqual(logged)
expect(requestSystemPrompts(h.adapter.requests.at(-1))).toEqual(logged)
expect(latestRuntimeContext(resumed.session))
.toContain(`Current DeepSeek Harness Web GUI URL: "http://127.0.0.1:${String(port)}".`)
expect(latestRuntimeContext(resumed.session)).toContain('Current DeepSeek Harness implementation checkout: "')
session = resumed.session
}
})
it('keeps earlier paragraphs after a series consolidation empties a later prompt version', async () => {
const h = await promptLoop('in-history')
const resumed = await h.resume((await h.earlierSession()).session, 'earlier-consolidated')
const [earlier] = systemPrompts(resumed.session)
const update = h.ctx.systemPrompt.section({ name: 'test:update', order: 0, text: 'Updated instruction.' })
await send(resumed, 'append the update')
expect(systemPrompts(resumed.session)).toHaveLength(2)
update()
h.ctx.on('agent/pre-step', async (_payload, next) => {
const decision = await next()
return decision.kind === 'enter' ? { ...decision, startsRequestSeries: true } : decision
})
// The head already matches, so consolidation logs only the emptied later version.
await send(resumed, 'start a new series')
expect(systemPrompts(resumed.session)).toEqual([earlier, expect.stringContaining('Updated instruction.'), ''])
await send(resumed, 'continue the series')
expect(systemPrompts(resumed.session)).toHaveLength(3)
expect(requestSystemPrompts(h.adapter.requests.at(-1))).toEqual([earlier])
})
it.each([
{ variant: 'a paragraph without the fixed ending', source: 'The DeepSeek Harness implementation checkout is at /old/checkout/.' },
{ variant: 'a paragraph broken across lines', source: LEGACY_SOURCE.replace('/old/checkout/', '/old/\ncheckout/') },
])('replaces text that only resembles an earlier paragraph: $variant', async ({ source }) => {
const h = await promptLoop(undefined)
const original = await h.earlierSession(source, WEB_PROMPT)
const resumed = await h.resume(original.session, 'resembling')
await send(resumed, 'after the upgrade')
const current = systemPrompts(resumed.session).at(-1)
expect(current).toContain(SOURCE_PROMPT)
expect(current).not.toContain('/old/')
})
it('keeps a new Session system prompt free of process values across ports', async () => {
const h = await promptLoop(undefined)
const agent = await h.harness.create(SessionId('fresh'), ROUTE)
await send(agent, 'first')
const logged = systemPrompts(agent.session)
expect(logged).toHaveLength(1)
expect(logged[0]).toContain(SOURCE_PROMPT)
expect(logged[0]).toContain(WEB_PROMPT)
expect(logged[0]).not.toContain('127.0.0.1')
expect(latestRuntimeContext(agent.session)).toContain('Current DeepSeek Harness Web GUI URL: "http://127.0.0.1:4567".')
h.listener.port = 4568
const resumed = await h.resume(agent.session, 'fresh-on-4568')
await send(resumed, 'second')
expect(systemPrompts(resumed.session)).toEqual(logged)
expect(latestRuntimeContext(resumed.session)).toContain('Current DeepSeek Harness Web GUI URL: "http://127.0.0.1:4568".')
})
})
@@ -0,0 +1,36 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "lib/types"
},
"include": [
"src"
],
"references": [
{
"path": "../../../vendor/cosmokit"
},
{
"path": "../../../vendor/cordis"
},
{
"path": "../../core/agent"
},
{
"path": "../../core/session"
},
{
"path": "../../core/system-prompt"
},
{
"path": "../../host/webserver"
},
{
"path": "../../session/session-projection"
},
{
"path": "../../bundle/web-app"
}
]
}
+3
View File
@@ -172,6 +172,9 @@ const CONTEXT_ORDERS = {
SANDBOX_POLICY: 110,
APPROVAL_POLICY: 115,
SUBAGENT_DELEGATION: 120,
// Process-specific paths and endpoints stay out of the cached system prompt.
HARNESS_SOURCE: 200,
WEB_SURFACE: 210,
} as const
/** Name of a centrally allocated runtime-context position. */
@@ -26,6 +26,7 @@ const SECTION_ORDER_NAMES = [
const CONTEXT_ORDER_NAMES = [
'WORKING_DIRECTORY',
'SANDBOX_POLICY', 'APPROVAL_POLICY', 'SUBAGENT_DELEGATION',
'HARNESS_SOURCE', 'WEB_SURFACE',
] as const satisfies readonly PromptContextOrderName[]
function contributed(assembly: PromptAssembly): PromptAssembly['sections'] {
return assembly.sections.filter(section => !BUILT_IN.includes(section.name))
@@ -3622,6 +3622,43 @@ export const SERVICE_API: readonly ServiceApiEntry[] = [
},
],
},
{
key: 'webStartup',
summary: 'What the web rows read from WEB_STARTUP_SERVICE.',
description: 'What the web rows read from WEB_STARTUP_SERVICE.',
methods: [
{
signature: 'openBrowser: boolean',
description: 'Whether this invocation opens the default browser after startup.',
parameters: [],
},
{
signature: 'host?: string',
description: '`--host`, absent when the invocation did not name one.',
parameters: [],
},
{
signature: 'port?: number',
description: '`--port`, absent when the invocation did not name one.',
parameters: [],
},
{
signature: 'publicUrl?: string',
description: '`--public-url` as its canonical root ending in `/`, absent when not specified: the advertised HTTP(S) root. See [public deployments](../README.md#public-deployments).',
parameters: [],
},
{
signature: 'trustedHosts: string[]',
description: 'Explicit `--trusted-host` authorities, in argument order.',
parameters: [],
},
{
signature: 'tls?: TlsConfig',
description: 'Server certificate chain and unencrypted private key supplied together.',
parameters: [],
},
],
},
{
key: 'workflowEngine',
summary: 'Workflow Service Definition contract.',
@@ -7880,6 +7917,10 @@ export const TYPE_API: readonly TypeApiEntry[] = [
name: 'TimeOutOfRangeError',
declaration: 'export interface TimeOutOfRangeError {\n readonly code: \'time_out_of_range\';\n readonly message: string;\n}',
},
{
name: 'TlsConfig',
declaration: 'export interface TlsConfig {\n certFile: string;\n keyFile: string;\n}',
},
{
name: 'ToastOptions',
declaration: 'export interface ToastOptions {\n timeoutMs?: number;\n}',
+4 -4
View File
@@ -18,8 +18,8 @@
en: 1998834973f7cf17
zh: 63455a2f75d090ad
/deepseek-ai-dsh-host-webserver/use-this-package/minimal-configuration:
en: bbbb5ba69338ca01
zh: 9fb460f1d0742f3a
en: a647f72ef05eeddd
zh: af7d66d892575c42
/deepseek-ai-dsh-host-webserver/use-this-package/serving-https:
en: 90352948bfdc1d99
zh: 35d148bf3bfcf76f
@@ -36,8 +36,8 @@
en: 42b15ac6321706aa
zh: 4ed0861911abaf5d
/deepseek-ai-dsh-host-webserver/understand-the-implementation/design-concept:
en: 830640c170fd3270
zh: d9ef28ef65fbaad3
en: e152e20c9add578c
zh: bacb2e9c31dd1a07
/deepseek-ai-dsh-host-webserver/understand-the-implementation/matching-and-lifecycle:
en: 8589aba0cbaa1c76
zh: babf3b27b0cdb35e
+2 -2
View File
@@ -36,7 +36,7 @@ Compose the webserver as the HTTP transport of a browser-facing host, then let t
port: 3000
```
`host` takes one concrete IPv4 or IPv6 literal of a local interface — for example a container's own Pod address from `hostname -i`. A loopback literal (any address in 127/8, `::1`, or a mapped form of either) keeps the server on this machine; any other literal serves the network that address belongs to, over plain HTTP unless `tls` is set. An unspecified address — including the IPv4-mapped forms Linux reads as IPv4 any — is rejected at load instead of opening the port on every interface at once. `port` 0 requests an OS-assigned port; `ctx.webServer.port` reads the listening port afterwards, and the exported `isLoopbackHost(host)` and `isWildcardHost(host)` classify an address by its parsed value, so a mapped or zoned spelling classifies as the address it names. A dotted-quad IPv6 tail names the address's own low 32 bits, exactly as `listen` reads it, so `::0.0.0.1` is loopback `::1` while `::127.0.0.1` is the non-loopback `::7f00:1`; `normalizeBindAddress(host)` returns that address text — `127.0.0.1` for a genuinely mapped `::ffff:127.0.0.1`, `::1` for `::0.0.0.1` and for `::1%lo` — ready to be a URL host.
`host` takes one concrete IPv4 or IPv6 literal of a local interface — for example a container's own Pod address from `hostname -i`. A loopback literal (any address in 127/8, `::1`, or a mapped form of either) keeps the server on this machine; any other literal serves the network that address belongs to, over plain HTTP unless `tls` is set. An unspecified address — including the IPv4-mapped forms Linux reads as IPv4 any — is rejected at load instead of opening the port on every interface at once. `port` 0 requests an OS-assigned port; `ctx.webServer.port` reads the listening port afterwards, and the exported `isLoopbackHost(host)` and `isWildcardHost(host)` classify an address by its parsed value, so a mapped or zoned spelling classifies as the address it names. A dotted-quad IPv6 tail names the address's own low 32 bits, exactly as `listen` reads it, so `::0.0.0.1` is loopback `::1` while `::127.0.0.1` is the non-loopback `::7f00:1`; `normalizeBindAddress(host)` returns that address text — `127.0.0.1` for a genuinely mapped `::ffff:127.0.0.1`, `::1` for `::0.0.0.1` and for `::1%lo` — ready to be a URL host. `bindUrlHost(host)` writes that text as a URL host, bracketing IPv6, and returns `undefined` for a non-loopback zoned address that no URL can carry; `ctx.webServer.origin` combines it with the protocol and listening port into the root URL local clients reach, and throws before the port is bound or when no URL form exists.
Set `compression: 'gzip'` to wrap eligible socket-backed responses without changing route APIs. The client must accept gzip and the media type must be compressible or `multipart/form-data`; known response lengths below `compressionThresholdBytes` remain uncompressed, while unknown-length streams are eligible immediately. Existing encodings, `Cache-Control: no-transform`, range responses, SSE, ZIP, and the packaged `.gz` Worker image remain unchanged. The shipped Web bundle uses compression level 1 with a 1024-byte threshold; other compositions default to no compression.
@@ -80,7 +80,7 @@ A listen failure (for example EADDRINUSE) rejects plugin initialization with the
### Design concept
The package is a plain route registry with no harness vocabulary: `WebServer` extends Cordis `Service` and holds three route tables plus the fallback slot, the raw index-tap list, and the `webserver/index-inject` event the index renderer gathers rows through. Index rendering composes two layers per response: `renderIndex` renders the fresh injection table, including advisory `script-preload` rows, into the body, then applies the raw taps in registration order; `applyIndexTaps` runs the taps alone. The upgrade handler owns the protocol handshake and connection contents; the webserver only delivers the raw socket and request. `host`, `port`, and `protocol` getters expose composition-time facts other plugins adapt to (for example the directory-picker chooser), and an explicit `tls: null` normalizes to an unset listener, so `protocol` has a single source.
The package is a plain route registry with no harness vocabulary: `WebServer` extends Cordis `Service` and holds three route tables plus the fallback slot, the raw index-tap list, and the `webserver/index-inject` event the index renderer gathers rows through. Index rendering composes two layers per response: `renderIndex` renders the fresh injection table, including advisory `script-preload` rows, into the body, then applies the raw taps in registration order; `applyIndexTaps` runs the taps alone. The upgrade handler owns the protocol handshake and connection contents; the webserver only delivers the raw socket and request. `host`, `port`, `protocol`, and `origin` getters expose composition-time facts other plugins adapt to (for example the directory-picker chooser), and an explicit `tls: null` normalizes to an unset listener, so `protocol` has a single source.
### Matching and lifecycle
+2 -2
View File
@@ -36,7 +36,7 @@ kind: "package-reference"
port: 3000
```
`host` 接受本机某个接口的一个具体 IPv4 或 IPv6 字面量——例如容器自身来自 `hostname -i` 的 Pod 地址。回环字面量(127/8 内的任意地址、`::1`,或二者的 mapped 形式)把服务器留在本机;其他任何字面量都会在该地址所属网络上提供 HTTP,除非设置 `tls`,否则为明文。未指定地址——包括 Linux 视为 IPv4 any 的 IPv4-mapped 形式——会在加载时被拒绝,而不是一次性打开每个网络接口的端口。`port` 为 0 时请求 OS 分配端口;之后用 `ctx.webServer.port` 读取正在监听的端口,导出的 `isLoopbackHost(host)` 与 `isWildcardHost(host)` 按解析后的地址值分类,因此 mapped 或带 zone 的写法会按其指名的地址分类。点分四段式的 IPv6 尾部表示该地址自身的低 32 位,与 `listen` 的读法完全一致:`::0.0.0.1` 是回环 `::1`,而 `::127.0.0.1` 是非回环的 `::7f00:1`;`normalizeBindAddress(host)` 返回该地址的文本——真正 mapped 的 `::ffff:127.0.0.1` 为 `127.0.0.1`,`::0.0.0.1` 与 `::1%lo` 为 `::1`——可直接用作 URL host。
`host` 接受本机某个接口的一个具体 IPv4 或 IPv6 字面量——例如容器自身来自 `hostname -i` 的 Pod 地址。回环字面量(127/8 内的任意地址、`::1`,或二者的 mapped 形式)把服务器留在本机;其他任何字面量都会在该地址所属网络上提供 HTTP,除非设置 `tls`,否则为明文。未指定地址——包括 Linux 视为 IPv4 any 的 IPv4-mapped 形式——会在加载时被拒绝,而不是一次性打开每个网络接口的端口。`port` 为 0 时请求 OS 分配端口;之后用 `ctx.webServer.port` 读取正在监听的端口,导出的 `isLoopbackHost(host)` 与 `isWildcardHost(host)` 按解析后的地址值分类,因此 mapped 或带 zone 的写法会按其指名的地址分类。点分四段式的 IPv6 尾部表示该地址自身的低 32 位,与 `listen` 的读法完全一致:`::0.0.0.1` 是回环 `::1`,而 `::127.0.0.1` 是非回环的 `::7f00:1`;`normalizeBindAddress(host)` 返回该地址的文本——真正 mapped 的 `::ffff:127.0.0.1` 为 `127.0.0.1`,`::0.0.0.1` 与 `::1%lo` 为 `::1`——可直接用作 URL host。`bindUrlHost(host)` 把该文本写成 URL host(IPv6 加方括号),对 URL 无法携带的非回环带 zone 地址返回 `undefined`;`ctx.webServer.origin` 把它与协议、监听端口组合成本机客户端访问的根 URL,在端口绑定之前或没有 URL 形式时抛错。
设置 `compression: 'gzip'` 可以包装符合条件的 socket-backed 响应,而不改变 route API。客户端必须接受 gzip,且媒体类型必须可压缩或为 `multipart/form-data`;已知长度小于 `compressionThresholdBytes` 的响应保持未压缩,未知长度的流则立即符合条件。已有编码、`Cache-Control: no-transform`、range 响应、SSE(Server-Sent Events)、ZIP 与已打包的 `.gz` Worker image 均保持不变。随附 Web bundle 使用 level 1 与 1024 字节阈值;其他组合默认不压缩。
@@ -80,7 +80,7 @@ index 启动输入分两层。`collectIndexInjections()` 收集一张全新的
### 设计理念
本包是一个不带任何 harness 词汇的普通路由注册表:`WebServer` 继承 Cordis `Service`,持有三张路由表、回退 slot、原始 index 转换列表,以及 `webserver/index-inject` 事件,index 渲染器经其收集行。index 渲染每次响应组合两层:`renderIndex` 先把包含提示性 `script-preload` 行的全新注入表渲染进正文,再按注册顺序应用原始转换;`applyIndexTaps` 只运行转换。upgrade handler 拥有协议握手与连接内容;webserver 只交付原始 socket 与 request。`host`、`port` 与 `protocol` getter 暴露其他插件据以自适应的组合期事实(例如 directory-picker 选择器),而显式的 `tls: null` 会归一为未设置监听,使 `protocol` 只有一个来源。
本包是一个不带任何 harness 词汇的普通路由注册表:`WebServer` 继承 Cordis `Service`,持有三张路由表、回退 slot、原始 index 转换列表,以及 `webserver/index-inject` 事件,index 渲染器经其收集行。index 渲染每次响应组合两层:`renderIndex` 先把包含提示性 `script-preload` 行的全新注入表渲染进正文,再按注册顺序应用原始转换;`applyIndexTaps` 只运行转换。upgrade handler 拥有协议握手与连接内容;webserver 只交付原始 socket 与 request。`host`、`port`、`protocol` 与 `origin` getter 暴露其他插件据以自适应的组合期事实(例如 directory-picker 选择器),而显式的 `tls: null` 会归一为未设置监听,使 `protocol` 只有一个来源。
### 匹配与生命周期
+31
View File
@@ -198,6 +198,23 @@ export function normalizeBindAddress(host: string): string {
return parsed.toString()
}
/**
* The URL host form of a bind address. Loopback addresses use their canonical
* text, so browsers treat them as local, trustworthy origins: a mapped literal
* such as `::ffff:127.0.0.1` reads as `127.0.0.1`, and `::0.0.0.1` reads as
* `::1`. A redundant loopback zone is dropped; other addresses keep their text,
* and IPv6 text is bracketed.
* @param host - concrete IPv4 or IPv6 bind literal.
* @returns the URL host, or `undefined` when a non-loopback interface zone id makes the address inexpressible in a URL.
*/
export function bindUrlHost(host: string): string | undefined {
const zoneAt = host.indexOf('%')
const bare = zoneAt === -1 ? host : host.slice(0, zoneAt)
if (!isLoopbackHost(bare) && zoneAt !== -1) return undefined
const text = isLoopbackHost(bare) ? normalizeBindAddress(bare) : host
return isIP(text) === 6 ? `[${text}]` : text
}
function createGzipMiddleware(config: ResolvedConfig): NodeMiddleware {
// `compression` is typed for Express, but its runtime uses only the
// node:http request and response members supplied here.
@@ -325,6 +342,20 @@ export class WebServer extends Service {
return this.tlsConfig === undefined ? 'http:' : 'https:'
}
/**
* The root URL local clients use to reach the bound listener: the protocol,
* the {@link bindUrlHost} form of the bind address, and the listening port.
* Read it after `listen` binds, like {@link port}.
* @throws when the bind address has no URL form.
*/
get origin(): string {
const host = bindUrlHost(this.config.host)
if (host === undefined) {
throw new Error(`webserver: bind address ${JSON.stringify(this.config.host)} carries an interface zone id, which no URL can express`)
}
return `${this.protocol}//${host}:${String(this.listenedPort)}`
}
/**
* Register a named route. Duplicate (kind, path) throws — route patterns are
* a composition-level contract, so a collision is a misconfiguration.
@@ -21,7 +21,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
import { Context, FiberState } from '@deepseek-ai/cordis'
import Loader from '@deepseek-ai/cordis-plugin-loader'
import Include from '@deepseek-ai/cordis-plugin-include'
import HttpServer, { isLoopbackHost, normalizeBindAddress, renderIndexInjections, type TlsConfig } from '../src/index.ts'
import HttpServer, { bindUrlHost, isLoopbackHost, normalizeBindAddress, renderIndexInjections, type TlsConfig } from '../src/index.ts'
import { materializeTlsFixture, type TlsFixture } from './tls-fixture.ts'
/** One-shot barrier for disposal overlapping a pending PEM read. */
@@ -280,6 +280,26 @@ describe('real Loader composition', () => {
expect(() => normalizeBindAddress('localhost')).toThrow(/is not a concrete IPv4 or IPv6 address literal/)
})
it('writes bind addresses in their URL host form', () => {
const rows: [string, string | undefined][] = [
['127.0.0.1', '127.0.0.1'],
['::ffff:127.0.0.1%lo', '127.0.0.1'],
['::1', '[::1]'],
['::0.0.0.1%lo', '[::1]'],
['10.1.2.3', '10.1.2.3'],
['fd00::1', '[fd00::1]'],
// A zone selects an interface and no URL can carry it; only a loopback zone is redundant.
['fe80::1%eth0', undefined],
['::127.0.0.1%lo', undefined],
]
for (const [host, text] of rows) expect(bindUrlHost(host)).toBe(text)
})
it('reports no origin for a bind address that no URL can express', () => {
expect(() => new HttpServer(new Context(), HttpServer.Config({ host: 'fe80::1%eth0', port: 0 })).origin)
.toThrow('webserver: bind address "fe80::1%eth0" carries an interface zone id, which no URL can express')
})
it('applies gzip only to eligible socket-backed HTTP responses', { timeout: 60_000 }, async () => {
expect(HttpServer.Config({ host: '127.0.0.1', port: 0 })).toEqual({
@@ -554,6 +574,7 @@ describe('real Loader composition', () => {
const loaded = await loadComposition(0, false, '127.0.0.1', tls)
const server = loaded.webServer
expect(server.protocol).toBe('https:')
expect(server.origin).toBe(`https://127.0.0.1:${String(server.port)}`)
server.register({
kind: 'exact',
path: '/tls',
@@ -579,6 +600,7 @@ describe('real Loader composition', () => {
const loaded = await loadComposition(0, false, '127.0.0.1', null)
const server = loaded.webServer
expect(server.protocol).toBe('http:')
expect(server.origin).toBe(`http://127.0.0.1:${String(server.port)}`)
server.register({ kind: 'exact', path: '/plain', handler: (_req, res) => { res.writeHead(200); res.end('PLAIN') } })
expect(await request(server.port, '/plain')).toMatchObject({ status: 200, body: 'PLAIN' })
await expect(tlsRequest(server.port, '/plain')).rejects.toThrow()
+37
View File
@@ -2735,6 +2735,9 @@ importers:
'@deepseek-ai/dsh-file-reference-local':
specifier: workspace:*
version: link:../../context/file-reference-local
'@deepseek-ai/dsh-harness-dev-context':
specifier: workspace:*
version: link:../../context/harness-dev-context
'@deepseek-ai/dsh-host-directory-picker-auto':
specifier: workspace:*
version: link:../../host/directory-picker-auto
@@ -6547,6 +6550,40 @@ importers:
specifier: workspace:*
version: link:../../session/working-directory
packages/context/harness-dev-context:
dependencies:
zod:
specifier: 4.4.3
version: 4.4.3
devDependencies:
'@deepseek-ai/cordis':
specifier: workspace:~
version: link:../../../vendor/cordis
'@deepseek-ai/dsh-agent':
specifier: workspace:*
version: link:../../core/agent
'@deepseek-ai/dsh-agent-loop-testkit':
specifier: workspace:*
version: link:../../test-support/agent-loop-testkit
'@deepseek-ai/dsh-host-webserver':
specifier: workspace:*
version: link:../../host/webserver
'@deepseek-ai/dsh-llm':
specifier: workspace:*
version: link:../../llm/llm
'@deepseek-ai/dsh-session':
specifier: workspace:*
version: link:../../core/session
'@deepseek-ai/dsh-session-projection':
specifier: workspace:*
version: link:../../session/session-projection
'@deepseek-ai/dsh-system-prompt':
specifier: workspace:*
version: link:../../core/system-prompt
'@deepseek-ai/dsh-web-app':
specifier: workspace:*
version: link:../../bundle/web-app
packages/context/session-reference:
dependencies:
'@deepseek-ai/dsh-brand':
+1
View File
@@ -95,6 +95,7 @@ export const SERVICE_PAGE: Record<string, string> = {
schedule: 'schedule.md',
inspector: 'extensions.md',
webServer: 'web-server.md',
webStartup: 'web-server.md',
llm: 'llm-streaming.md',
lsp: 'lsp.md',
messageFeedback: 'feedback.md',
@@ -138,6 +138,6 @@ Use subagent_fork in the background by default. Start independent delegations to
When you successfully create or modify files, mention the primary outputs in your final response. Outside commands, configuration expressions, and code blocks, link every mention of an existing file, including repeats and tables, to its full path relative to the working directory or absolute; append #L24 or #L24-L30 to the target for known lines. Use the filename or a clear alias as the label, adding only enough parent directories to distinguish files; keep full paths out of labels. Default to the name alone; when precise locations matter, append :24 or :24–30, with no # or L in the line suffix.
The DeepSeek Harness implementation checkout is at {{sourceRoot}}. The checkout location and current working directory are separate values and may differ; never infer the working directory from this path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend DSH itself.
The runtime context names the DeepSeek Harness implementation checkout. The checkout location and current working directory are separate values and may differ; never infer the working directory from the checkout path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend DSH itself.
You are interacting with the user through the DeepSeek Harness Web GUI at {{webUrl}}. When the user refers to "this page", "this GUI", or "this app" without naming another target, they mean this GUI. The browser provides no implicit DOM, route, or screenshot context. The client-plugin HMR receiver is active, but client-plugin changes reload without a refresh only while `pnpm run dev:web` is also running from this same checkout to rebuild their bundles; verify that watcher before promising automatic updates. Every other change — the apps/web shell and plain packages — requires rebuilding the affected Web artifacts and verifying this existing URL after a page refresh. Starting another server does not update this GUI. The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__. Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL.
You are interacting with the user through the DeepSeek Harness Web GUI whose URL the runtime context names. When the user refers to "this page", "this GUI", or "this app" without naming another target, they mean this GUI. The browser provides no implicit DOM, route, or screenshot context. The client-plugin HMR receiver is active, but client-plugin changes reload without a refresh only while `pnpm run dev:web` is also running from this same checkout to rebuild their bundles; verify that watcher before promising automatic updates. Every other change — the apps/web shell and plain packages — requires rebuilding the affected Web artifacts and verifying this existing URL after a page refresh. Starting another server does not update this GUI. The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__. Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL.
@@ -30,6 +30,6 @@ Start independent delegations with `subagent` or `subagent_fork` together in one
Prefer showing the primary results within your final response alongside a brief explanation. Use ![Description](<path/to/image.png>) when an image supports an explanation or comparison. Use [Description](<path/to/image.png>) when referring to an image or listing files. Enclose Markdown file destinations in angle brackets, especially paths containing spaces. Do not call present just to list edited source files, or run commands to check whether a diff view will appear. Use present when a separate file card helps the user open the complete deliverable, including images, Office documents, spreadsheets, and slide decks. Each presented file adds a card below the reply, with preview and native-open actions. Avoid repeating results already shown inline unless the separate card adds useful access. Outside commands, configuration expressions, and code blocks, link every mention of an existing file, including repeats and tables, to its full path relative to the working directory or absolute; append #L24 or #L24-L30 to the target for known lines. Use the filename or a clear alias as the label, adding only enough parent directories to distinguish files; keep full paths out of labels. Default to the name alone; when precise locations matter, append :24 or :24–30, with no # or L in the line suffix.
The DeepSeek Harness implementation checkout is at {{sourceRoot}}. The checkout location and current working directory are separate values and may differ; never infer the working directory from this path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend DSH itself.
The runtime context names the DeepSeek Harness implementation checkout. The checkout location and current working directory are separate values and may differ; never infer the working directory from the checkout path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend DSH itself.
You are interacting with the user through the DeepSeek Harness Web GUI at {{webUrl}}. When the user refers to "this page", "this GUI", or "this app" without naming another target, they mean this GUI. The browser provides no implicit DOM, route, or screenshot context. The client-plugin HMR receiver is active, but client-plugin changes reload without a refresh only while `pnpm run dev:web` is also running from this same checkout to rebuild their bundles; verify that watcher before promising automatic updates. Every other change — the apps/web shell and plain packages — requires rebuilding the affected Web artifacts and verifying this existing URL after a page refresh. Starting another server does not update this GUI. The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__. Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL.
You are interacting with the user through the DeepSeek Harness Web GUI whose URL the runtime context names. When the user refers to "this page", "this GUI", or "this app" without naming another target, they mean this GUI. The browser provides no implicit DOM, route, or screenshot context. The client-plugin HMR receiver is active, but client-plugin changes reload without a refresh only while `pnpm run dev:web` is also running from this same checkout to rebuild their bundles; verify that watcher before promising automatic updates. Every other change — the apps/web shell and plain packages — requires rebuilding the affected Web artifacts and verifying this existing URL after a page refresh. Starting another server does not update this GUI. The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__. Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL.
@@ -1,3 +1,3 @@
The DeepSeek Harness implementation checkout is at {{sourceRoot}}. The checkout location and current working directory are separate values and may differ; never infer the working directory from this path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend DSH itself.
The runtime context names the DeepSeek Harness implementation checkout. The checkout location and current working directory are separate values and may differ; never infer the working directory from the checkout path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend DSH itself.
You are interacting with the user through the DeepSeek Harness Web GUI at {{webUrl}}. When the user refers to "this page", "this GUI", or "this app" without naming another target, they mean this GUI. The browser provides no implicit DOM, route, or screenshot context. The client-plugin HMR receiver is active, but client-plugin changes reload without a refresh only while `pnpm run dev:web` is also running from this same checkout to rebuild their bundles; verify that watcher before promising automatic updates. Every other change — the apps/web shell and plain packages — requires rebuilding the affected Web artifacts and verifying this existing URL after a page refresh. Starting another server does not update this GUI. The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__. Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL.
You are interacting with the user through the DeepSeek Harness Web GUI whose URL the runtime context names. When the user refers to "this page", "this GUI", or "this app" without naming another target, they mean this GUI. The browser provides no implicit DOM, route, or screenshot context. The client-plugin HMR receiver is active, but client-plugin changes reload without a refresh only while `pnpm run dev:web` is also running from this same checkout to rebuild their bundles; verify that watcher before promising automatic updates. Every other change — the apps/web shell and plain packages — requires rebuilding the affected Web artifacts and verifying this existing URL after a page refresh. Starting another server does not update this GUI. The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__. Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL.
@@ -943,6 +943,6 @@ declare const tools: {
Prefer showing the primary results within your final response alongside a brief explanation. Use ![Description](<path/to/image.png>) when an image supports an explanation or comparison. Use [Description](<path/to/image.png>) when referring to an image or listing files. Enclose Markdown file destinations in angle brackets, especially paths containing spaces. Do not call present just to list edited source files, or run commands to check whether a diff view will appear. Use present when a separate file card helps the user open the complete deliverable, including images, Office documents, spreadsheets, and slide decks. Each presented file adds a card below the reply, with preview and native-open actions. Avoid repeating results already shown inline unless the separate card adds useful access. Outside commands, configuration expressions, and code blocks, link every mention of an existing file, including repeats and tables, to its full path relative to the working directory or absolute; append #L24 or #L24-L30 to the target for known lines. Use the filename or a clear alias as the label, adding only enough parent directories to distinguish files; keep full paths out of labels. Default to the name alone; when precise locations matter, append :24 or :24–30, with no # or L in the line suffix.
The DeepSeek Harness implementation checkout is at {{sourceRoot}}. The checkout location and current working directory are separate values and may differ; never infer the working directory from this path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend DSH itself.
The runtime context names the DeepSeek Harness implementation checkout. The checkout location and current working directory are separate values and may differ; never infer the working directory from the checkout path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend DSH itself.
You are interacting with the user through the DeepSeek Harness Web GUI at {{webUrl}}. When the user refers to "this page", "this GUI", or "this app" without naming another target, they mean this GUI. The browser provides no implicit DOM, route, or screenshot context. The client-plugin HMR receiver is active, but client-plugin changes reload without a refresh only while `pnpm run dev:web` is also running from this same checkout to rebuild their bundles; verify that watcher before promising automatic updates. Every other change — the apps/web shell and plain packages — requires rebuilding the affected Web artifacts and verifying this existing URL after a page refresh. Starting another server does not update this GUI. The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__. Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL.
You are interacting with the user through the DeepSeek Harness Web GUI whose URL the runtime context names. When the user refers to "this page", "this GUI", or "this app" without naming another target, they mean this GUI. The browser provides no implicit DOM, route, or screenshot context. The client-plugin HMR receiver is active, but client-plugin changes reload without a refresh only while `pnpm run dev:web` is also running from this same checkout to rebuild their bundles; verify that watcher before promising automatic updates. Every other change — the apps/web shell and plain packages — requires rebuilding the affected Web artifacts and verifying this existing URL after a page refresh. Starting another server does not update this GUI. The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__. Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL.
@@ -948,6 +948,6 @@ declare const tools: {
Prefer showing the primary results within your final response alongside a brief explanation. Use ![Description](<path/to/image.png>) when an image supports an explanation or comparison. Use [Description](<path/to/image.png>) when referring to an image or listing files. Enclose Markdown file destinations in angle brackets, especially paths containing spaces. Do not call present just to list edited source files, or run commands to check whether a diff view will appear. Use present when a separate file card helps the user open the complete deliverable, including images, Office documents, spreadsheets, and slide decks. Each presented file adds a card below the reply, with preview and native-open actions. Avoid repeating results already shown inline unless the separate card adds useful access. Outside commands, configuration expressions, and code blocks, link every mention of an existing file, including repeats and tables, to its full path relative to the working directory or absolute; append #L24 or #L24-L30 to the target for known lines. Use the filename or a clear alias as the label, adding only enough parent directories to distinguish files; keep full paths out of labels. Default to the name alone; when precise locations matter, append :24 or :24–30, with no # or L in the line suffix.
The DeepSeek Harness implementation checkout is at {{sourceRoot}}. The checkout location and current working directory are separate values and may differ; never infer the working directory from this path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend DSH itself.
The runtime context names the DeepSeek Harness implementation checkout. The checkout location and current working directory are separate values and may differ; never infer the working directory from the checkout path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend DSH itself.
You are interacting with the user through the DeepSeek Harness Web GUI at {{webUrl}}. When the user refers to "this page", "this GUI", or "this app" without naming another target, they mean this GUI. The browser provides no implicit DOM, route, or screenshot context. The client-plugin HMR receiver is active, but client-plugin changes reload without a refresh only while `pnpm run dev:web` is also running from this same checkout to rebuild their bundles; verify that watcher before promising automatic updates. Every other change — the apps/web shell and plain packages — requires rebuilding the affected Web artifacts and verifying this existing URL after a page refresh. Starting another server does not update this GUI. The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__. Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL.
You are interacting with the user through the DeepSeek Harness Web GUI whose URL the runtime context names. When the user refers to "this page", "this GUI", or "this app" without naming another target, they mean this GUI. The browser provides no implicit DOM, route, or screenshot context. The client-plugin HMR receiver is active, but client-plugin changes reload without a refresh only while `pnpm run dev:web` is also running from this same checkout to rebuild their bundles; verify that watcher before promising automatic updates. Every other change — the apps/web shell and plain packages — requires rebuilding the affected Web artifacts and verifying this existing URL after a page refresh. Starting another server does not update this GUI. The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__. Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL.
@@ -930,6 +930,6 @@ declare const tools: {
Prefer showing the primary results within your final response alongside a brief explanation. Use ![Description](<path/to/image.png>) when an image supports an explanation or comparison. Use [Description](<path/to/image.png>) when referring to an image or listing files. Enclose Markdown file destinations in angle brackets, especially paths containing spaces. Do not call present just to list edited source files, or run commands to check whether a diff view will appear. Use present when a separate file card helps the user open the complete deliverable, including images, Office documents, spreadsheets, and slide decks. Each presented file adds a card below the reply, with preview and native-open actions. Avoid repeating results already shown inline unless the separate card adds useful access. Outside commands, configuration expressions, and code blocks, link every mention of an existing file, including repeats and tables, to its full path relative to the working directory or absolute; append #L24 or #L24-L30 to the target for known lines. Use the filename or a clear alias as the label, adding only enough parent directories to distinguish files; keep full paths out of labels. Default to the name alone; when precise locations matter, append :24 or :24–30, with no # or L in the line suffix.
The DeepSeek Harness implementation checkout is at {{sourceRoot}}. The checkout location and current working directory are separate values and may differ; never infer the working directory from this path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend DSH itself.
The runtime context names the DeepSeek Harness implementation checkout. The checkout location and current working directory are separate values and may differ; never infer the working directory from the checkout path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend DSH itself.
You are interacting with the user through the DeepSeek Harness Web GUI at {{webUrl}}. When the user refers to "this page", "this GUI", or "this app" without naming another target, they mean this GUI. The browser provides no implicit DOM, route, or screenshot context. The client-plugin HMR receiver is active, but client-plugin changes reload without a refresh only while `pnpm run dev:web` is also running from this same checkout to rebuild their bundles; verify that watcher before promising automatic updates. Every other change — the apps/web shell and plain packages — requires rebuilding the affected Web artifacts and verifying this existing URL after a page refresh. Starting another server does not update this GUI. The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__. Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL.
You are interacting with the user through the DeepSeek Harness Web GUI whose URL the runtime context names. When the user refers to "this page", "this GUI", or "this app" without naming another target, they mean this GUI. The browser provides no implicit DOM, route, or screenshot context. The client-plugin HMR receiver is active, but client-plugin changes reload without a refresh only while `pnpm run dev:web` is also running from this same checkout to rebuild their bundles; verify that watcher before promising automatic updates. Every other change — the apps/web shell and plain packages — requires rebuilding the affected Web artifacts and verifying this existing URL after a page refresh. Starting another server does not update this GUI. The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__. Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL.
@@ -1,8 +1,8 @@
You are an AI agent powered by DeepSeek Harness.
The DeepSeek Harness implementation checkout is at {{sourceRoot}}. The checkout location and current working directory are separate values and may differ; never infer the working directory from this path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend DSH itself.
The runtime context names the DeepSeek Harness implementation checkout. The checkout location and current working directory are separate values and may differ; never infer the working directory from the checkout path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend DSH itself.
You are interacting with the user through the DeepSeek Harness Web GUI at {{webUrl}}. When the user refers to "this page", "this GUI", or "this app" without naming another target, they mean this GUI. The browser provides no implicit DOM, route, or screenshot context. The client-plugin HMR receiver is active, but client-plugin changes reload without a refresh only while `pnpm run dev:web` is also running from this same checkout to rebuild their bundles; verify that watcher before promising automatic updates. Every other change — the apps/web shell and plain packages — requires rebuilding the affected Web artifacts and verifying this existing URL after a page refresh. Starting another server does not update this GUI. The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__. Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL.
You are interacting with the user through the DeepSeek Harness Web GUI whose URL the runtime context names. When the user refers to "this page", "this GUI", or "this app" without naming another target, they mean this GUI. The browser provides no implicit DOM, route, or screenshot context. The client-plugin HMR receiver is active, but client-plugin changes reload without a refresh only while `pnpm run dev:web` is also running from this same checkout to rebuild their bundles; verify that watcher before promising automatic updates. Every other change — the apps/web shell and plain packages — requires rebuilding the affected Web artifacts and verifying this existing URL after a page refresh. Starting another server does not update this GUI. The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__. Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL.
You are a coding agent powered by the deepseek-v4-flash model. Your working directory is {{cwd}}.
+1
View File
@@ -391,6 +391,7 @@
"@deepseek-ai/dsh-fs-ssh": ["./packages/ssh/fs-ssh/src"],
"@deepseek-ai/dsh-goal": ["./packages/goal/goal/src"],
"@deepseek-ai/dsh-goal-round-driver": ["./packages/goal/goal-round-driver/src"],
"@deepseek-ai/dsh-harness-dev-context": ["./packages/context/harness-dev-context/src"],
"@deepseek-ai/dsh-headless": ["./packages/bundle/headless/src"],
"@deepseek-ai/dsh-home-paths": ["./packages/util/home-paths/src"],
"@deepseek-ai/dsh-hook-protocol": ["./packages/experimental/hook-protocol/src"],
+1
View File
@@ -367,6 +367,7 @@
{ "path": "./packages/context/file-reference-local" },
{ "path": "./packages/context/tmux-context" },
{ "path": "./packages/context/session-reference" },
{ "path": "./packages/context/harness-dev-context" },
{ "path": "./packages/interaction/user-questions" },
{ "path": "./packages/interaction/user-approval" },
{ "path": "./packages/interaction/permission-presets" },