Merge remote-tracking branch 'origin/master' into refactor/tool-errors-agent

Resolves import conflicts with the brand-export split (#8214): value
brand factories are now brandString<T>() calls, and dsh-workflow's
WorkflowRunId is imported from its types entry. Generated persistence
and config catalogs are regenerated.
This commit is contained in:
sjw1231 committed 2026-11-11 15:40:30 +08:00
commit 3524a7a3e5
1236 files changed
+11476 -8314

No files matched your search

@@ -0,0 +1,19 @@
# Bilingual-pair consistency record for 2026-09-21-reject-silent-empty-catch.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/process/2026-09-21-reject-silent-empty-catch.md
/agent-note-reject-silent-empty-catch-clauses:
en: b058c52537202c50
zh: f48d8847967a31a8
/agent-note-reject-silent-empty-catch-clauses/problem:
en: a89b84c7052329b4
zh: 9c511a0b4ee3f1ef
/agent-note-reject-silent-empty-catch-clauses/decision:
en: 0392fb5d5cc3b387
zh: c4219e43bded8ce6
/agent-note-reject-silent-empty-catch-clauses/alternatives-considered:
en: 65d05680072f8797
zh: e160d37d8ece30ad
/agent-note-reject-silent-empty-catch-clauses/consequences:
en: 88a4796188c31922
zh: bfa8efc7944ea12a
@@ -0,0 +1,33 @@
# Agent Note: Reject silent empty catch clauses
Status: implemented
English | [中文](2026-09-21-reject-silent-empty-catch.zh.md)
## Problem
An empty `catch` discards every failure of its `try`, including defects the author did not expect. The root rule requires such a clause to name the error, state why discarding it is safe, and keep its `try` to one statement, so that the clause discards only the failure its author considered. Without a check, new clauses drifted from the rule, and existing clauses broke it across many unrelated package and test owners.
## Decision
The [checker](../../../../scripts/verify-empty-catch.ts), exposed as `pnpm run verify-empty-catch`, parses first-party JavaScript and TypeScript with the TypeScript syntax tree and reports an empty clause, one whose body holds no statement other than `;`, that is unnamed, unexplained, or wraps a multi-statement `try`. A bare `_` counts as unnamed; lint requires an unused binding to start with `_`, so a conforming name such as `_alreadyGone` states the expected failure. A clause body with any other statement is out of scope because syntax cannot show whether it handles the error. The checker establishes the form; review establishes that the name and the reason are true, using the guidance in [dsh-error-handling](../../../skills/dsh-error-handling/SKILL.md#empty-catch-clauses).
Existing clauses have an exact baseline keyed by repository-relative path, a SHA-256 digest of the clause's syntax tokens together with its broken conditions, and occurrence count. Including the broken conditions makes turning a recorded one-statement `try` into a wider one, or deleting a recorded reason, a new finding, while edits inside the `try` that keep its conditions keep the clause's identity. The baseline follows the [unknown-cast inventory](2026-09-19-no-unknown-casts.md), and both checkers share [the inventory module](../../../../scripts/baseline-inventory.ts): baseline edits only delete entries or decrease counts, `--prune` removes retired entries and refuses to write while new findings exist, and no command adds an allowance. Unlike the unknown-cast inventory, which requires resolving an assertion before moving it to an unlisted file, moving a file that holds recorded clauses renames its baseline key in the same change, because narrowing a recorded `try` belongs to its owner rather than to the change that moves the file.
The checker runs in the `hygiene` and `check-all` profiles and the CI static and primary modes of [the gate runner](../../../../scripts/run-gates.ts). Empty Promise rejection handlers such as `.catch(() => {})` are outside this rule and tracked separately in issue #8033.
## Alternatives considered
**Fix every existing clause before enforcing the rule.** Rejected because narrowing a multi-statement `try` changes which failures the clause discards, which only each owner can judge. The baseline lets enforcement start while the existing clauses remain recorded findings for their owners to fix.
**Fingerprint the whole `try` statement.** Rejected because every edit inside a recorded `try` would become a new finding and force its owner to fix the clause during unrelated work. Fingerprinting the clause with its broken conditions rejects a new broken condition on a recorded clause without tying its identity to the statements inside the `try`; a `try` that is already wide can gain statements without a new finding.
**A command that records clauses from a named revision.** Rejected because a local command cannot prove that the revision is the target branch: naming the current branch would record the branch's own clauses. Once the target branch carries the checker, merging it brings that branch's baseline along, so no command is needed.
**Search text for `catch {}`.** Rejected because comments, strings, whitespace, and binding patterns defeat a text pattern, and the rule's conditions depend on the syntax tree.
## Consequences
New and changed empty clauses must conform, and fixing a recorded clause requires pruning its baseline entry. A partial fix, such as adding a name while the `try` stays wide, changes the clause's identity and therefore fails; the owner fixes the clause completely before pruning. The baseline key carries no line number, so a recorded clause can move within its file; identical clauses in one file share one fingerprint whose count covers each of them.
Passing the checker establishes the form of every unrecorded empty clause. It does not establish that a reason is true, that a non-empty handler handles its error, or that a `try` holding one block or compound statement discards only one operation's failures.
@@ -0,0 +1,33 @@
# Agent Note: 拒绝静默的空 catch 子句
Status: implemented
[English](2026-09-21-reject-silent-empty-catch.md) | 中文
## 问题
空 `catch` 会丢弃其 `try` 的所有失败,包括作者未预料到的缺陷。根规则要求此类子句命名错误、说明丢弃该错误为何安全,并将其 `try` 限制为一条语句,使子句只丢弃作者考虑过的失败。没有检查时,新增子句逐渐偏离该规则,而违反规则的现有子句分布在许多互不相关的包和测试所属模块中。
## 决策
[检查器](../../../../scripts/verify-empty-catch.ts)通过 `pnpm run verify-empty-catch` 运行,使用 TypeScript 语法树解析第一方 JavaScript 和 TypeScript,并报告未命名、未说明原因或包裹多语句 `try` 的空子句;空子句指主体中除 `;` 外不含任何语句的子句。单独的 `_` 视为未命名;lint 要求未使用的绑定以 `_` 开头,因此 `_alreadyGone` 这类符合要求的名称可以说明预期的失败。主体含有其他语句的子句不属于此规则的范围,因为语法无法表明它是否处理了错误。检查器确认形式;审查依据 [dsh-error-handling](../../../skills/dsh-error-handling/SKILL.md#empty-catch-clauses) 中的指引确认名称和原因属实。
现有子句使用精确基线记录,键由仓库相对路径、子句语法 token 连同其违反条件的 SHA-256 摘要及出现次数组成。摘要包含违反条件,因此把已记录的单语句 `try` 扩大为多语句 `try`,或删除已记录的原因,都会产生新的检查发现;而在 `try` 内部进行不改变其违反条件的修改,不改变子句的标识。基线沿用 [unknown 类型断言清单](2026-09-19-no-unknown-casts.zh.md)的做法,两个检查器共用[清单模块](../../../../scripts/baseline-inventory.ts):基线修改只能删除条目或减少次数,`--prune` 删除已失效的条目并在存在新发现时拒绝写入,且没有任何命令可以添加放行。unknown 类型断言清单要求先解决断言,才能将其移至未登记的文件;与之不同,移动包含已记录子句的文件时,须在同一变更中重命名其基线键,因为收窄已记录的 `try` 由其所属模块负责,而不属于移动文件的变更。
检查器在[门禁运行器](../../../../scripts/run-gates.ts)的 `hygiene` 和 `check-all` 配置以及 CI 静态模式和主模式中运行。`.catch(() => {})` 等空的 Promise 拒绝处理函数不属于此规则,另由 issue #8033 跟踪。
## 考虑过的替代方案
**先修复所有现有子句,再执行规则。** 不采用,因为收窄多语句 `try` 会改变子句丢弃哪些失败,只有各所属模块才能判断。基线使规则可以立即开始执行,同时现有子句仍作为已记录的检查发现,由其所属模块修复。
**对整个 `try` 语句计算指纹。** 不采用,因为已记录 `try` 内部的每次修改都会产生新的检查发现,迫使所属模块在无关工作中修复该子句。对子句连同其违反条件计算指纹,可以拒绝已记录子句上新增的违反条件,同时不让子句的标识依赖 `try` 内部的语句;已经过宽的 `try` 可以增加语句而不产生新的检查发现。
**提供从指定修订版本记录子句的命令。** 不采用,因为本地命令无法证明该修订版本就是目标分支:指定当前分支会记录该分支自身的子句。目标分支包含检查器后,合并目标分支会一并带入其基线,因此不需要这样的命令。
**在文本中搜索 `catch {}`。** 不采用,因为注释、字符串、空白和绑定模式都会使文本模式失效,而且规则的条件依赖语法树。
## 影响
新增和修改的空子句必须符合规则,修复已记录的子句时须清理其基线条目。部分修复,例如添加名称但 `try` 仍然过宽,会改变子句的标识,因此检查失败;所属模块须先完整修复子句,再清理基线条目。基线键不含行号,因此已记录的子句可以在所在文件内移动;同一文件中相同的子句共用一个指纹,其计数涵盖其中每一个子句。
通过检查器说明每个未记录的空子句都符合规定形式。它不证明原因属实,不证明非空处理代码处理了其错误,也不证明包含一个代码块或复合语句的 `try` 只丢弃一个操作的失败。
@@ -21,5 +21,5 @@
en: 21838e31d29b87fb
zh: c72c81ef53b090e0
/agent-note-api-extractor-reports/why-deferred:
en: e2a8a7c13f4db704
zh: aeae101a9a77d677
en: 7e8a1bd17832ec5c
zh: 3ea8dea04965f676
@@ -30,3 +30,5 @@ The dependency is heavy and finicky — the reason this was deferred — and the
## Why deferred
Deferred when doc-sync landed: low value for an internal monorepo where reviewers already see the source diff, and a heavy, finicky dependency. Revisit if the packages are ever published externally — at that point a stable, diffable public API earns its keep.
The packages are now published to npm, so the revisit condition holds. The [stable API policy](2026-11-05-stable-api-policy.md) proposal replaces the per-package reports with one report covering exports, services, and events, and adds stability levels and per-seam versions; its acceptance criteria apply if it is accepted.
@@ -30,3 +30,5 @@ Status: proposed
## 推迟原因
在 doc-sync 落地时被推迟:对于一个内部 monorepo,评审者已经能看到源码 diff,价值不高;且依赖笨重、难以调教。如果各包将来对外发布,再重新评估——届时一份稳定、可 diff 的公开接口报告才值得其维护成本。
各包现已发布到 npm,重新评估的条件已经满足。[稳定 API 规范](2026-11-05-stable-api-policy.zh.md)提案用一份覆盖导出、服务和事件的报告取代每个包一份的报告,并加入稳定级别和按 seam 划分的版本;该提案被接受后,以其验收标准为准。
@@ -0,0 +1,49 @@
# Bilingual-pair consistency record for 2026-11-05-stable-api-policy.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/proposed/process/2026-11-05-stable-api-policy.md
/agent-note-stable-api-policy:
en: efcff6bc65d1ae54
zh: 2b32885373cb788d
/agent-note-stable-api-policy/problem:
en: b6492a320d28ff1c
zh: 0105277d71fe43ab
/agent-note-stable-api-policy/proposal:
en: 88384462c8232e93
zh: 355ad48f96efc95e
/agent-note-stable-api-policy/proposal/stability-levels:
en: ad9ea5e151e05ac2
zh: baa08299dac43ee4
/agent-note-stable-api-policy/proposal/unit-one-capability-seam:
en: 2d33b23a61c8dae4
zh: 4d781899433069d5
/agent-note-stable-api-policy/proposal/what-stable-covers:
en: 0a637e21cfbabeb3
zh: 76078282bf686e17
/agent-note-stable-api-policy/proposal/api-report-and-ci:
en: 772026ec3f2512b0
zh: d6cf271248e85a0e
/agent-note-stable-api-policy/proposal/plugin-author-warnings:
en: e9bdb925a73e14e4
zh: e04aa39a43407070
/agent-note-stable-api-policy/proposal/plugin-requirements:
en: cce626a0c5dff76f
zh: d85d04d33ddcff48
/agent-note-stable-api-policy/proposal/compatibility-layer:
en: 40445e93d1bb8561
zh: 05a845c5093f4abd
/agent-note-stable-api-policy/proposal/rollout:
en: 16e88b03b3f1bc38
zh: 5628adf979269b92
/agent-note-stable-api-policy/proposal/open-questions:
en: b33cf00ac8a10a94
zh: e0a041a07879d2d5
/agent-note-stable-api-policy/alternatives-considered:
en: 4154f0aadc2f0017
zh: cc1e120f80e7fbb8
/agent-note-stable-api-policy/acceptance-criteria:
en: a858ac77edabe3d3
zh: 63f0872b73eef7f3
/agent-note-stable-api-policy/risks:
en: 16693acc4f57df3a
zh: 96b056ba83bf3c38
@@ -0,0 +1,121 @@
# Agent Note: Stable API policy
Status: proposed
English | [中文](2026-11-05-stable-api-policy.zh.md)
## Problem
Every public DSH API is pre-stable: root `AGENTS.md` tells contributors to update every consumer when an API changes. That rule works inside the repository, but external plugins now install from npm and the plugin market, and their authors cannot tell which APIs they can rely on. All released packages share one lockstep version, so a package version says nothing about which API changed. The only compatibility check, `evaluatePluginCompatibility` in [plugin-compatibility.ts](../../../../packages/boot/app-boot/src/plugin-compatibility.ts), compares a plugin's `engines.dsh` range, or else its `@deepseek-ai/dsh` and `@deepseek-ai/dsh-*` peer ranges, with the whole runtime version; `workspace:` peer ranges count as the running version.
No source marker distinguishes stable from unstable APIs. Exports carry no `@public`, `@beta`, `@stable`, or `@since` tags; `@internal` appears about ten times with differing meanings, and undated `@deprecated` about a dozen times. The only rigorous compatibility rules cover data formats ([Session format status](../../../../docs/session-format-status.md), SQLite schema versions, persistence type acknowledgements) and [upgrade guides](../../../skills/dsh-create-upgrade-guide/SKILL.md).
The policy must start from this state. Contributors must not have to classify every API before the policy takes effect, and code that nobody marks must keep today's workflow.
## Proposal
Stability markers in source are the only input. A generated API report turns them into a versioned list of stable APIs for each release. The unit of versioning is the [capability seam](../../../../docs/glossary.md#capability-seam). Anything not marked stays unstable, so adoption proceeds one member at a time.
### Stability levels
| Level | Marker | Change rule |
|---|---|---|
| unstable (default) | None | Change freely, update every consumer, and record externally perceptible breaks in an upgrade guide |
| stable | `@stable <seam>@<version>`, the seam version that added the member | Backward-compatible additions only; a removal or incompatible change requires a completed deprecation period and a major seam version |
| internal | `@internal` | Used only inside this repository; omitted from the API report; change freely |
Deprecation is a state of a stable member, not a fourth level: a member tagged `@deprecated <replacement or "no replacement">` stays stable until its deprecation period ends. `@internal` and `@deprecated` tags on unstable members keep their current meaning; the policy assigns no new meaning to existing tags.
Packages under [`packages/experimental/`](../../../../packages/experimental/README.md#status) cannot contain stable members; a package is promoted out of the experimental group before any of its members are promoted.
### Unit: one capability seam
Each capability seam has its own API version, independent of the lockstep package version. A stable member belongs to the seam of the Service Definition package that declares it; a member of a declaration-merged interface such as `Context` or `SessionEventMap` belongs to the seam of the package that adds it. Exports that belong to no seam, such as utilities, CLI options, and the SDK wire protocol, stay unstable until a later proposal assigns them. Members reachable only through `./src/*` export subpaths are unstable.
The package that declares a Service Definition records its seam version in the existing `package.json` `dsh` declaration, owned by the [public package manifest](../../implemented/architecture/2026-09-10-public-package-manifest.md) decision. One package can declare several seams, so the member is a list:
```json
{ "dsh": { "apis": [{ "name": "agent", "version": "1.0.0" }] } }
```
The new members are optional and do not change `manifestVersion`; their names are not settled. As that decision requires, the report generator and the compatibility check each validate the members they read.
### What stable covers
Stable covers type signatures, event order, and waterfall calling conventions, including whether a listener must call `next()`. Default config values and config fields are not covered in this proposal. CI detects signature changes from the generated report. Behavior changes cannot be detected reliably; the author declares them in the PR description, and ordinary review checks the declaration. Tests that pin stable event order and waterfall conventions belong to the Service Definition package and run against the shipped Service Provider.
A stable signature can reference types from other seams, such as `SessionId` or `Scoped`. Those referenced types become part of the referencing seam's promise: the report lists them under that seam, and an incompatible change to them fails the same checks as a change to the seam's own members.
### API report and CI
A script generates one checked-in API report covering exports, Cordis services, and events, with each entry's seam, level, and version; it replaces the per-package reports of the deferred [API extractor reports](2026-06-11-api-extractor-reports.md) proposal. Each release archives its report. CI compares stable entries, including referenced types, with the latest released report and fails when:
- a stable entry is removed or changed incompatibly without a major seam version bump and an upgrade guide;
- a removed entry was not deprecated in a released report, or its deprecation period has not elapsed since the first release whose report recorded the deprecation;
- a stable entry is added without a minor seam version bump;
- a stable signature references a member marked `@internal` or an unstable member of its own seam.
Measuring the period from the first release that recorded the deprecation keeps it independent of dates authors write. Changes to unstable entries appear in the report diff without failing CI. CI also posts a summary of stable API changes to the PR. Promotion and breaking changes are approved in ordinary PR review; no dedicated API owner or committee is named.
### Plugin author warnings
A type-aware lint rule reports uses of unstable members by resolving each used symbol and reading its level from the published declarations. Event and waterfall names are string literals passed to `ctx.on()` and similar calls, so the rule resolves them against the event map; `typescript/no-deprecated` in [.oxlintrc.json](../../../../.oxlintrc.json) does not cover this case. Oxlint offers no custom type-aware rules, so the rule ships as a published tool that plugin authors run in their own builds; the repository runs it on stable Service Definition packages. Subpath export isolation (`…/unstable` entry points) was rejected; see [Alternatives considered](#alternatives-considered).
### Plugin requirements
A plugin may declare the seam versions it needs, for example `"dsh": { "requires": { "agent": "^1.0.0" } }`. The seam check is additive: `evaluatePluginCompatibility` still evaluates `engines.dsh` or the DSH peer ranges, and also compares each listed seam range with the seam versions recorded in the running Host's API report. A plugin that declares seam ranges can widen its `engines.dsh` range to every runtime it supports. Plugin market index entries and registry update checks read the same declaration, so discovery, installation, and update reach the same result. By convention the plugin also lists the unstable seams it uses; the Host cannot verify that list, and the plugin manager shows it as a risk. The declaration does not restrict what a plugin can import or access: Cordis plugins run in the Host process and can import any package or reach any service on `ctx`.
### Compatibility layer
Serving an old major seam version to old plugins is deferred. It becomes worthwhile once a stable seam takes a major version bump while external plugins still require the previous major. The Host then keeps one current implementation, and an adapter plugin provides the old Service Definition on top of it for a fixed support period.
### Rollout
1. Policy only: land this note and define the deprecation period. Replace the pre-stable statement with "unmarked APIs are unstable" in root `AGENTS.md`, [packages/README.md](../../../../packages/README.md), [packages/experimental/README.md](../../../../packages/experimental/README.md), [apps/cli/reference/README.md](../../../../apps/cli/reference/README.md), and the generated package reference from [gen-plugin-packages.ts](../../../../scripts/gen-plugin-packages.ts). No code changes.
2. Baseline report: generate and check in the first API report; CI only checks that it is current.
3. Pilot: promote members of the agent seam declared by `dsh-agent`: `ctx.agents`, `AgentHandle`, `Agent`, the `agent/*` events other than the deprecated `agent/request`, and the `agent/pre-step` waterfall. Types they reference from session, scope, and llm packages join the promise as described above. The `dsh-agent-loop` Service Provider and its config stay unstable, so the pilot stabilizes no configuration. The lint tool and the `requires` check ship in this phase; [package-manifest README](../../../../packages/util/package-manifest/README.md) and the public package manifest note are updated to describe the enforced check.
4. Promote further members and seams when the maintainers of a seam choose to; publish the stable API list on the documentation website.
5. Add compatibility adapters for specific seams when the condition above holds.
### Open questions
- Names of the `dsh.apis` and `dsh.requires` members.
- Length of the time-based deprecation period before DSH 1.0.
- Whether the Python SDK methods, the SDK JSON-RPC protocol, and `cordis.yml` config fields join the same levels, and whether the protocol needs its own version.
- Report generator: API Extractor or a dump built on the export walker in [scripts/verify-export-jsdoc.ts](../../../../scripts/verify-export-jsdoc.ts) and the tag parser in [scripts/jsdoc.ts](../../../../scripts/jsdoc.ts).
- Lint tool form: a standalone published checker built on the same export walker, a non-type-aware approximation, or an upstream oxlint rule.
## Alternatives considered
**`@stable` markers without versions.** Cheapest and incremental, but a plugin cannot state which stable API it was built against, the Host cannot check it, and the report cannot tell additions from existing members. Kept as the input format with the adding seam version attached; the generated report supplies the list.
**A hand-maintained versioned list per release.** Gives plugin authors a clear reference, but maintaining it by hand for over a thousand export subpaths and more than a hundred services is not practical, and one version for the whole list forces every plugin to react to any seam's break. Kept as the generated report rather than a maintained artifact.
**One API version for the whole platform** (Android API level, VS Code `engines`). Simplest for plugin authors, but DSH releases often and its seams evolve independently; a single number would either grow with every break or discourage necessary breaks.
**Independent semver per npm package, dropping the lockstep version.** The [npm release sequences](../../implemented/process/2026-08-10-npm-release-sequences.md) decision keeps all DSH packages on one version so releases and peer ranges stay consistent. Package versions would also change for internal refactors that do not touch any API a plugin uses. Seam versions describe API compatibility without changing how packages are released.
**Grouping by package directory instead of seam.** Groups such as `fs/` mix Service Definitions, providers, and tools that evolve separately. The seam is already the unit the architecture uses, so it costs the least to maintain.
**Subpath export isolation for unstable APIs.** Making the import path the opt-in is more explicit than a lint warning, but it restructures the exports of every package and breaks every current consumer at once, which contradicts incremental adoption.
**Shipping a compatibility layer from the start.** Each retained old version needs its own conversion code and tests. Before any seam is stable and before external plugins depend on an old major, that cost buys nothing.
**Counting the deprecation period in releases.** DSH release frequency varies, so a release count gives plugin authors an unpredictable amount of time. Measuring time from the first release that recorded the deprecation is predictable and can be computed from archived reports.
## Acceptance criteria
- Root `AGENTS.md` and the package documentation listed in rollout step 1 state that unmarked APIs are unstable, and the deprecation period is defined.
- A checked-in API report covers exports, services, and events; CI fails when it is stale.
- The pilot members of the agent seam carry `@stable [email protected]`; CI rejects an incompatible change to them or to a type they reference, and posts a stable API change summary on PRs that touch them.
- The lint tool reports a plugin's use of an unstable member, including an unstable event name passed to `ctx.on()`.
- A plugin that declares `requires` is accepted or rejected per seam range in installation, update, and market discovery; a plugin without it behaves as it does today.
## Risks
- Referenced types from other seams join the promise of the referencing seam; promoting the agent seam therefore freezes parts of the session, scope, and llm types before those seams are promoted.
- Behavior changes rely on author declarations, which review can miss.
- Seam versions and the lockstep package version are two numbering systems, which plugin authors may confuse.
- Promoting the agent seam constrains a core part of the loop that still changes often; promotion trades that flexibility for plugin stability.
- The lint tool is new published tooling that the project must maintain alongside the oxlint configuration.
- The manifest declaration cannot stop a plugin from using undeclared APIs; it informs checks and users, not enforcement.
@@ -0,0 +1,121 @@
# Agent Note: 稳定 API 规范
Status: proposed
[English](2026-11-05-stable-api-policy.md) | 中文
## Problem
DSH 的所有公开 API 都处于预稳定(pre-stable)阶段:根目录 `AGENTS.md` 要求 API 变化时同步更新每个消费方。这条规则在仓库内部可行,但外部插件现在从 npm 和插件市场安装,作者无法判断哪些 API 可以依赖。所有发布的包共用一个锁步版本,包版本无法说明哪个 API 变了。唯一的兼容检查是 [plugin-compatibility.ts](../../../../packages/boot/app-boot/src/plugin-compatibility.ts) 中的 `evaluatePluginCompatibility`,它把插件的 `engines.dsh` 范围(没有时改用 `@deepseek-ai/dsh` 和 `@deepseek-ai/dsh-*` peer 范围)与整个运行时版本比较;`workspace:` peer 范围视为当前运行版本。
源码中没有区分 stable 与 unstable API 的标记。导出不带 `@public`、`@beta`、`@stable` 或 `@since` 标签;`@internal` 出现约十次且含义不一,不带日期的 `@deprecated` 出现约十几次。唯一严格的兼容规则针对数据格式([Session 格式状态](../../../../docs/session-format-status.zh.md)、SQLite schema 版本、持久化类型变更确认)和 [upgrade guide](../../../skills/dsh-create-upgrade-guide/SKILL.md)。
规范必须从这一现状起步。贡献者不需要先给所有 API 定级,规范才能生效;没有人标记的代码保持现有工作方式。
## Proposal
源码中的稳定性标记是唯一输入。生成的 API 报告把标记转换为每次发布的带版本稳定 API 列表。版本单位是[能力 seam](../../../../docs/glossary.zh.md#capability-seam)。未标记的内容一律保持 unstable,因此可以逐个成员推进。
### 稳定级别
| 级别 | 标记 | 变更规则 |
|---|---|---|
| unstable(默认) | 无 | 随时修改,更新每个消费方,外部可感知的破坏性变更写入 upgrade guide |
| stable | `@stable <seam>@<version>`,即加入该成员的 seam 版本 | 只允许向后兼容的新增;删除或不兼容修改需要弃用期已满,并升级 seam 主版本 |
| internal | `@internal` | 仅在本仓库内部使用;不进入 API 报告;随时修改 |
弃用是 stable 成员的一种状态,不是第四个级别:带 `@deprecated <替代项或“无替代”>` 的成员在弃用期结束前仍是 stable。unstable 成员上的 `@internal` 和 `@deprecated` 标签保持现有含义;本规范不给现有标签赋予新含义。
[`packages/experimental/`](../../../../packages/experimental/README.zh.md#status) 下的包不能包含 stable 成员;包须先移出 experimental 分组,其中的成员才能晋升。
### 单位:一个能力 seam
每个能力 seam 有自己的 API 版本,与锁步的包版本无关。stable 成员属于声明它的 Service Definition 包所在的 seam;`Context`、`SessionEventMap` 等声明合并接口的成员属于添加该成员的包所在的 seam。不属于任何 seam 的导出(如工具函数、CLI 选项、SDK wire 协议)保持 unstable,留待后续提案归属。只能通过 `./src/*` 导出子路径访问的成员是 unstable。
声明 Service Definition 的包在现有的 `package.json` `dsh` 声明中登记 seam 版本,该声明由[公开包 manifest](../../implemented/architecture/2026-09-10-public-package-manifest.zh.md) 决策负责。一个包可以声明多个 seam,因此该成员是列表:
```json
{ "dsh": { "apis": [{ "name": "agent", "version": "1.0.0" }] } }
```
新成员是可选的,不改变 `manifestVersion`;成员名称尚未确定。按该决策的要求,报告生成器和兼容检查各自校验自己读取的成员。
### stable 覆盖的范围
stable 覆盖类型签名、事件顺序和 waterfall 调用约定(包括 listener 是否必须调用 `next()`)。本提案不覆盖默认配置值和配置字段。CI 根据生成的报告检测签名变化。行为变化无法可靠地自动检测;作者在 PR 描述中声明,由正常评审核对。锁定 stable 事件顺序和 waterfall 约定的测试属于 Service Definition 包,针对随产品发布的 Service Provider 运行。
stable 签名可以引用其他 seam 的类型,例如 `SessionId` 或 `Scoped`。这些被引用的类型成为引用方 seam 承诺的一部分:报告把它们列在该 seam 下,对它们的不兼容修改与修改该 seam 自身成员一样触发检查失败。
### API 报告与 CI
一个脚本生成并提交一份 API 报告,覆盖导出、Cordis 服务和事件,每个条目带有所属 seam、级别和版本;它取代已推迟的 [API extractor 报告](2026-06-11-api-extractor-reports.zh.md)提案中每个包一份的报告。每次发布归档当次报告。CI 把 stable 条目(包括被引用的类型)与最近一次发布的报告比较,以下情况失败:
- stable 条目被删除或不兼容修改,但没有升级 seam 主版本并写 upgrade guide;
- 被删除的条目没有在已发布的报告中标为弃用,或自首次记录该弃用的发布起弃用期未满;
- 新增 stable 条目,但没有升级 seam 次版本;
- stable 签名引用了标为 `@internal` 的成员,或本 seam 的 unstable 成员。
从首次记录弃用的发布开始计算弃用期,使其不依赖作者填写的日期。unstable 条目的变化只出现在报告 diff 中,不会让 CI 失败。CI 还会在 PR 中发布 stable API 变更摘要。晋升和破坏性变更在正常 PR 评审中批准,不指定专门的 API owner 或委员会。
### 插件作者告警
一条类型感知的 lint 规则报告对 unstable 成员的使用:解析每个被使用的符号,并从发布的类型声明中读取其级别。事件和 waterfall 名称是传给 `ctx.on()` 等调用的字符串字面量,因此规则要把它们与事件映射对应起来;[.oxlintrc.json](../../../../.oxlintrc.json) 中的 `typescript/no-deprecated` 不覆盖这种情况。oxlint 不支持自定义的类型感知规则,因此该规则以发布的工具形式提供,插件作者在自己的构建中运行;仓库对 stable 的 Service Definition 包运行该规则。子路径导出隔离(`…/unstable` 入口)已否决,见 [Alternatives considered](#alternatives-considered)。
### 插件依赖声明
插件可以声明所需的 seam 版本,例如 `"dsh": { "requires": { "agent": "^1.0.0" } }`。seam 检查是附加的:`evaluatePluginCompatibility` 仍然检查 `engines.dsh` 或 DSH peer 范围,同时把列出的每个 seam 范围与当前 Host 的 API 报告中记录的 seam 版本比较。声明了 seam 范围的插件可以把 `engines.dsh` 放宽到它支持的所有运行时。插件市场索引条目和 registry 更新检查读取同一声明,使发现、安装和更新得出相同结论。按约定,插件还列出它使用的 unstable seam;Host 无法验证这份列表,插件管理页把它显示为风险。该声明不限制插件能导入或访问什么:Cordis 插件在 Host 进程内运行,可以导入任意包或访问 `ctx` 上的任意服务。
### 兼容层
为旧插件提供旧的 seam 主版本暂缓实现。当某个 stable seam 升级主版本、而外部插件仍依赖上一个主版本时,兼容层才有价值。届时 Host 只保留一份当前实现,由适配插件在其上提供旧的 Service Definition,并设定固定支持期限。
### 落地步骤
1. 仅规范:合入本 Agent Note 并确定弃用期。把根目录 `AGENTS.md`、[packages/README.md](../../../../packages/README.zh.md)、[packages/experimental/README.md](../../../../packages/experimental/README.zh.md)、[apps/cli/reference/README.md](../../../../apps/cli/reference/README.zh.md) 以及由 [gen-plugin-packages.ts](../../../../scripts/gen-plugin-packages.ts) 生成的包参考中的预稳定表述改为“未标记的 API 为 unstable”。不改代码。
2. 基线报告:生成并提交第一份 API 报告;CI 只检查报告是否最新。
3. 试点:晋升 `dsh-agent` 声明的 agent seam 成员:`ctx.agents`、`AgentHandle`、`Agent`、除已弃用的 `agent/request` 之外的 `agent/*` 事件,以及 `agent/pre-step` waterfall。它们引用的 session、scope 和 llm 包类型按上文加入承诺。Service Provider `dsh-agent-loop` 及其配置保持 unstable,因此试点不稳定任何配置。lint 工具和 `requires` 检查在这一阶段交付;同时更新 [package-manifest README](../../../../packages/util/package-manifest/README.zh.md) 和公开包 manifest 决策记录,说明已强制执行的检查。
4. 由各 seam 的维护者按需晋升更多成员和 seam;在文档站发布稳定 API 列表。
5. 满足上述条件时,为特定 seam 增加兼容适配插件。
### 待决问题
- `dsh.apis` 和 `dsh.requires` 成员的名称。
- DSH 1.0 之前按时间计算的弃用期长度。
- Python SDK 方法、SDK JSON-RPC 协议和 `cordis.yml` 配置字段是否纳入同一套级别,以及协议是否需要独立版本。
- 报告生成方式:API Extractor,还是基于 [scripts/verify-export-jsdoc.ts](../../../../scripts/verify-export-jsdoc.ts) 的导出遍历和 [scripts/jsdoc.ts](../../../../scripts/jsdoc.ts) 的标签解析生成的转储。
- lint 工具形式:基于同一导出遍历的独立发布检查器、非类型感知的近似实现,或上游 oxlint 规则。
## Alternatives considered
**不带版本的 `@stable` 标记。** 成本最低且可渐进,但插件无法说明自己基于哪个稳定 API 构建,Host 也无法检查,报告也无法区分新增成员和已有成员。保留为输入格式,并附上加入该成员的 seam 版本;列表由生成的报告提供。
**每次发布手工维护带版本的列表。** 插件作者有明确的参考,但为一千多个导出子路径和一百多个服务手工维护不现实,而且整个列表只有一个版本,任何 seam 的破坏性变更都会波及所有插件。保留为生成的报告,而不是手工维护的产物。
**整个平台一个 API 版本**(Android API level、VS Code `engines`)。对插件作者最简单,但 DSH 发布频繁,各 seam 独立演进;单一版本号要么随每次破坏性变更增长,要么抑制必要的破坏性变更。
**每个 npm 包独立 semver,取消锁步版本。** [npm 发布序列](../../implemented/process/2026-08-10-npm-release-sequences.zh.md)决策让所有 DSH 包使用同一版本,以保持发布和 peer 范围一致。包版本还会因不涉及任何插件所用 API 的内部重构而变化。seam 版本描述 API 兼容性,不改变包的发布方式。
**按包目录而不是 seam 分组。** `fs/` 等分组混合了独立演进的 Service Definition、provider 和工具。seam 本来就是架构使用的单位,维护成本最低。
**用子路径导出隔离 unstable API。** 让导入路径本身成为 opt-in,比 lint 告警更明确,但需要重组每个包的导出,并一次性破坏所有现有消费方,与渐进推进相矛盾。
**一开始就提供兼容层。** 每保留一个旧版本,都需要单独的转换代码和测试。在任何 seam 稳定、且外部插件依赖旧主版本之前,这项成本没有收益。
**按发布次数计算弃用期。** DSH 发布频率不固定,按次数计算给插件作者的时间不可预测。从首次记录弃用的发布开始按时间计算,结果可预测,并且可以从归档的报告中算出。
## Acceptance criteria
- 根目录 `AGENTS.md` 和落地步骤 1 列出的包文档写明未标记的 API 为 unstable,且弃用期已确定。
- 已提交的 API 报告覆盖导出、服务和事件;报告过期时 CI 失败。
- agent seam 的试点成员带有 `@stable [email protected]`;CI 拒绝对它们或它们引用的类型的不兼容修改,并在涉及它们的 PR 中发布 stable API 变更摘要。
- lint 工具报告插件对 unstable 成员的使用,包括传给 `ctx.on()` 的 unstable 事件名。
- 声明了 `requires` 的插件在安装、更新和市场发现中按 seam 范围被接受或拒绝;未声明的插件行为与现在相同。
## Risks
- 其他 seam 中被引用的类型会加入引用方 seam 的承诺;晋升 agent seam 因而会在 session、scope 和 llm 等 seam 晋升之前冻结其部分类型。
- 行为变化依赖作者声明,评审可能遗漏。
- seam 版本与锁步包版本是两套编号,插件作者可能混淆。
- 晋升 agent seam 会约束仍在频繁变化的 loop 核心部分;晋升以这部分灵活性换取插件稳定性。
- lint 工具是新的发布工具,项目需要与 oxlint 配置一起维护。
- manifest 声明无法阻止插件使用未声明的 API;它只为检查和用户提供信息,不是强制手段。
@@ -39,10 +39,10 @@ If an existing record is damaged or its keychain/certificate is missing, setup s
## Configure the source build
Resolve the DSH home used by the developer (`DSH_HOME`, otherwise `~/.dsh`). Merge the two printed values into its `cordis.patch.yml`, targeting the entry that loads `@deepseek-ai/dsh-experimental-cua-macos`. The shipped entry ID is `cua`:
Resolve the DSH home used by the developer (`DSH_HOME`, otherwise `~/.dsh`). Merge the two printed values into its `cordis.patch.yml`, targeting the entry that loads `@deepseek-ai/dsh-cua-macos`. The shipped entry ID is `cua-macos`:
```yaml
- id: cua
- id: cua-macos
config:
sourceSigning:
identity: "<fingerprint printed by setup>"
@@ -34,6 +34,48 @@ For each failure, define handling and reporting owners, containment, and guarant
Catching limits exception propagation, not mutations. Only the affected state's owner can establish safe continuation. Otherwise stop dependent work, discard invalid state or instances, or escalate. Logging alone is not recovery. Retries require safe repetition, cancellation, and an explicit owner; finite operations need budgets, while continuing supervision needs lifecycle ownership and observable degradation.
### Empty catch clauses
An empty `catch` has no statement other than `;` in its block, and it discards every failure its `try` raises. Use one only when every such failure leaves the owner's state valid and no caller could act on it, such as failing to remove a temporary file that nothing reads. A `catch` that logs, reports, rethrows, or returns a fallback is not empty, and the rules below do not apply to it. [`verify-empty-catch`](../../../scripts/verify-empty-catch.ts) checks every `try`/`catch` statement in first-party JavaScript and TypeScript, including tests; it does not check `promise.catch()` callbacks. The checker checks the form; review checks that the name and the reason are true.
**The `try` holds one statement.** One statement means one syntactic statement, such as one call or one assignment, however many lines it spans; it does not mean one line. With several statements, the reason covers one expected failure while the clause also discards the others, including defects such as a `TypeError`, and a failure in an early statement skips the later ones while the caller sees success:
```ts
// Rejected: three statements in one try.
try {
await unlink(tempFile)
registry.delete(id)
emit('removed', id)
} catch (_cleanupFailed) {
// A leftover temporary file holds no state anything reads.
}
// Accepted: only the unlink failure is discarded.
try {
await unlink(tempFile)
} catch (_cleanupFailed) {
// A leftover temporary file holds no state anything reads.
}
registry.delete(id)
emit('removed', id)
```
When several statements each tolerate a failure, give each its own `try` and reason. The checker counts one block or one compound statement, such as one `if`, as one statement; review rejects such a `try` when it contains several operations.
**The binding names the expected failure.** Write `catch (_cleanupFailed)`, not `catch {}` or `catch (_)`. Lint requires an unused binding to start with `_`, and a bare `_` names nothing.
**A comment states why discarding the failure is safe.** Put it in the `catch` block or after the clause's closing `}` on the same line. A comment inside the `try` block or above `try` does not count. `// ignore` and `// expected` restate the empty block; say which failure is expected and why the state stays valid.
**Accept only some failures by testing them.** When only some failures are safe, such as a missing file while a permission error must still surface, write a non-empty `catch` that tests `code` or `name` and rethrows the rest; the checker does not check such a clause.
```ts
try {
await unlink(tempFile)
} catch (error) {
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error
}
```
## Localized, actionable, visible reports
Every final report needs a readable summary, affected operation, and safe next action. Localize through the receiving application's locale mechanism where one exists; other diagnostics use their existing output language. Keep sensitive internal details out of user-facing text.
+1 -1
View File
@@ -149,7 +149,7 @@ Real-API tests/demos read `DEEPSEEK_API_KEY`, optional `DEEPSEEK_BASE_URL`, and
- **Source plane vs artifact plane, never mixed.** Static gates and tests resolve workspace imports through tsconfig `paths` to `src` and pass on a clean tree; gates consuming built `lib/` declare that dependency ([layout](docs/development.md#typescript-project-layout)).
- **Keep compiler faces explicit.** A package with both Host and Client programs exposes face-specific leaf configs and a solution-only root; repo-wide programs seed a face config, never the root solution ([layout](docs/development.md#typescript-project-layout)).
- **Error handling:** use typed, structured failures and localized, actionable reports. Coded errors and expected tool failures use `HarnessError`. Define handling ownership, containment, and failure guarantees; stop dependent work and visibly report untrusted state or unknown outcomes. Follow [dsh-error-handling](.agents/skills/dsh-error-handling/SKILL.md).
- **An empty `catch` names the error** and why; keep its `try` to one statement.
- **An empty `catch` names the error** and why; keep its `try` to one statement ([checker](scripts/verify-empty-catch.ts)).
- **Keep comments local.** Do not restate code, expand unrelated comments, or explain distant behavior without local need ([rationale](.agents/skills/dsh-prose-standard/SKILL.md)).
- **Ban `prove` + `nance`** ([rule](.agents/notes/implemented/process/2026-08-26-ban-ambiguous-origin-label.md)).
- **Prefer symmetry for parallel values**; unexplained asymmetry usually signals a missed extraction.
+1
View File
@@ -120,6 +120,7 @@
"@deepseek-ai/dsh-experimental-forge-bundle": "workspace:*"
},
"devDependencies": {
"@deepseek-ai/dsh-brand": "workspace:*",
"@deepseek-ai/dsh-skill-badge": "workspace:*",
"@deepseek-ai/dsh-webhook-github": "workspace:*",
"@deepseek-ai/dsh-webhook": "workspace:*",
+5 -4
View File
@@ -1,9 +1,10 @@
import { executeToolFixture } from '@deepseek-ai/dsh-tool-testkit'
import { fileURLToPath } from 'node:url'
import { agentEvents, type Agent } from '@deepseek-ai/dsh-agent'
import { ToolCallId } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import type { ToolCallId } from '@deepseek-ai/dsh-llm'
import { boot, loadOverlayPatches } from '@deepseek-ai/dsh-app-boot'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-skill'
import type {} from '@deepseek-ai/dsh-tools'
import { unsupportedModel, unsupportedInbox } from '@deepseek-ai/dsh-agent-loop-testkit'
@@ -25,7 +26,7 @@ const ctx = await boot('dsh-badge-snapshot', rootConfigPath, [
])
try {
const agentId = SessionId('dsh-badge-snapshot')
const agentId = brandString<SessionId>('dsh-badge-snapshot')
const session = ctx.sessions.create(agentId, { meta: { cwd: process.cwd() } })
const agent: Agent = {
ctx,
@@ -54,7 +55,7 @@ try {
: undefined
const summary = (await ctx.skills.list()).find(skill => skill.name === 'dsh-badge')
const result = await executeToolFixture(ctx, {
callId: ToolCallId('dsh-badge-snapshot'),
callId: brandString<ToolCallId>('dsh-badge-snapshot'),
name: 'skill',
arguments: { name: 'dsh-badge' },
signal: new AbortController().signal,
@@ -1,5 +1,5 @@
import z from '@deepseek-ai/schemastery'
import { WebhookRuleId } from '@deepseek-ai/dsh-webhook'
import { brandString } from '@deepseek-ai/dsh-brand'
export const name = 'github-webhook-real-e2e-rule'
export const inject = ['webhookRuntime']
@@ -14,8 +14,10 @@ export const Config = z.object({
})
export function apply(ctx, config) {
/** @type {import('@deepseek-ai/dsh-webhook/types').WebhookRuleId} */
const id = brandString('github-real-e2e')
ctx.effect(() => ctx.webhookRuntime.register({
id: WebhookRuleId('github-real-e2e'),
id,
kind: 'github',
run(delivery, signal) {
+3 -2
View File
@@ -6,7 +6,8 @@ import type {} from '@deepseek-ai/cordis-plugin-loader'
import type {} from '@deepseek-ai/dsh-agent'
import type {} from '@deepseek-ai/dsh-cmdline'
import { createUserMessage } from '@deepseek-ai/dsh-llm'
import { SessionId, type SessionEvent } from '@deepseek-ai/dsh-session'
import type { SessionId, SessionEvent } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
/** Observations from one isolated Agent's run through the shipped headless profile. */
export interface SourceToolEvidence {
@@ -37,7 +38,7 @@ export function apply(ctx: Context, config: { cwd: string }): void {
const run = async (): Promise<void> => {
const handle = await ctx.agents.create({
sessionId: SessionId(randomUUID()),
sessionId: brandString<SessionId>(randomUUID()),
meta: { cwd: config.cwd },
agentOptions: { provider: 'cli-mock', model: 'cli-mock' },
})
@@ -10,9 +10,10 @@ import { fileURLToPath } from 'node:url'
import type { Context } from '@deepseek-ai/cordis'
import type { Agent, AgentHandle } from '@deepseek-ai/dsh-agent'
import type { ProfileContext } from '@deepseek-ai/dsh-app-boot'
import { LlmAdapter, ToolCallId, createUserMessage } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import { LlmAdapter, type ToolCallId, createUserMessage } from '@deepseek-ai/dsh-llm'
import type { GenerateOptions, LlmResolvedModelInfo, StreamChunk } from '@deepseek-ai/dsh-llm'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-agent-preset-registry'
import type {} from '@deepseek-ai/dsh-hmr'
import type {} from '@deepseek-ai/dsh-plugin-manager'
@@ -140,7 +141,7 @@ describe.skipIf(!existsSync(join(root, 'apps/cli/lib/bin.js')))('Official option
async function agent(preset = 'standard', cwd = workspace): Promise<AgentHandle> {
const handle = await ctx.agents.create({
sessionId: SessionId(`optional-${preset}-${randomUUID()}`), meta: { cwd, agentPreset: preset },
sessionId: brandString<SessionId>(`optional-${preset}-${randomUUID()}`), meta: { cwd, agentPreset: preset },
agentOptions: { provider: 'bundle-test', model: 'scripted' },
setup: scoped => ctx.agentPresets.mount(scoped, preset).then(() => undefined),
})
@@ -234,7 +235,7 @@ describe.skipIf(!existsSync(join(root, 'apps/cli/lib/bin.js')))('Official option
it('loads the actual badge asset only while its bundle is selected', async () => {
const owner = await agent()
const load = (callId: string) => executeToolFixture(ctx, {
callId: ToolCallId(callId), name: 'skill', arguments: { name: 'dsh-badge' },
callId: brandString<ToolCallId>(callId), name: 'skill', arguments: { name: 'dsh-badge' },
agent: owner.agent, signal: new AbortController().signal,
})
expect((await load('badge-before')).isError).toBe(true)
@@ -1,10 +1,11 @@
/** Keyless two-model adapter for the generic ACP control-surface conformance test. */
import type { Context } from '@deepseek-ai/cordis'
import { brandString } from '@deepseek-ai/dsh-brand'
import {
ToolCallId,
type ToolCallId,
LlmAdapter,
ReasoningEffortId,
type ReasoningEffortId,
type GenerateOptions,
type LlmResolvedModelInfo,
type StreamChunk,
@@ -34,10 +35,10 @@ class ControlSurfaceAdapter extends LlmAdapter {
context: { contextWindow: 2_048 },
reasoning: {
efforts: [
{ id: ReasoningEffortId('low'), name: 'Low' },
{ id: ReasoningEffortId('high'), name: 'High' },
{ id: brandString<ReasoningEffortId>('low'), name: 'Low' },
{ id: brandString<ReasoningEffortId>('high'), name: 'High' },
],
defaultEffort: ReasoningEffortId('high'),
defaultEffort: brandString<ReasoningEffortId>('high'),
},
})
}
@@ -50,7 +51,7 @@ class ControlSurfaceAdapter extends LlmAdapter {
.join('')
const hasToolResult = current.some(message => message.role === 'tool')
if (!hasToolResult) {
const callId = ToolCallId(userText.includes('cancel') ? 'control-cancel-add' : 'control-add')
const callId = brandString<ToolCallId>(userText.includes('cancel') ? 'control-cancel-add' : 'control-add')
yield { type: 'block-start', index: 0, blockType: 'reasoning' }
yield { type: 'reasoning-delta', index: 0, text: 'checking the attached tool' }
yield { type: 'block-end', index: 0, block: { type: 'reasoning', text: 'checking the attached tool' } }
@@ -6,7 +6,8 @@ import { join } from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'
import type { Context } from '@deepseek-ai/cordis'
import { codingHarness, finalText, SYSTEM_PROMPT, waitForIdle } from './harness.ts'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
/**
* The swebench-style smoke test: a real model fixes a real bug in a temp
@@ -55,7 +56,7 @@ describe.skipIf(!process.env.DEEPSEEK_API_KEY)('coding task: fix a failing test
expect(before.status).not.toBe(0)
ctx = await codingHarness(workdir, { personaPrefix: SYSTEM_PROMPT })
const agent = await ctx.agentLoop.create(SessionId('e2e-task'), { provider: 'deepseek-official', model: 'deepseek-v4-flash' }, { cwd: workdir })
const agent = await ctx.agentLoop.create(brandString<SessionId>('e2e-task'), { provider: 'deepseek-official', model: 'deepseek-v4-flash' }, { cwd: workdir })
agent.followup(createUserMessage({
content: [{
@@ -5,7 +5,8 @@ import { join } from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'
import type { Context } from '@deepseek-ai/cordis'
import { codingHarness, finalText, SYSTEM_PROMPT, waitForIdle } from './harness.ts'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
/**
* Key-gated smoke for mid-session compaction. It verifies the compact event
@@ -49,7 +50,7 @@ describe.skipIf(!process.env.DEEPSEEK_API_KEY)('compaction: a long session compa
},
persistenceRoot: join(workdir, '.sessions'),
})
const agent = await ctx.agentLoop.create(SessionId('e2e-compaction'), { provider: 'deepseek-official', model: 'deepseek-v4-flash' }, { cwd: workdir })
const agent = await ctx.agentLoop.create(brandString<SessionId>('e2e-compaction'), { provider: 'deepseek-official', model: 'deepseek-v4-flash' }, { cwd: workdir })
// Completed read turns cannot collapse into one retained parallel tool group.
for (let i = 1; i <= 4; i++) {
@@ -1,6 +1,7 @@
/** Deterministic keyless Agent Teams adapter shared by profile snapshot and CLI e2e. */
import { ToolCallId, LlmAdapter } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import { LlmAdapter } from '@deepseek-ai/dsh-llm'
let nextCall = 0
@@ -42,7 +43,8 @@ function latestToolText(messages) {
function toolChunks(specs) {
const chunks = []
for (const [index, spec] of specs.entries()) {
const id = ToolCallId(`team-fixture-${++nextCall}`)
/** @type {import('@deepseek-ai/dsh-llm/types').ToolCallId} */
const id = brandString(`team-fixture-${++nextCall}`)
const args = JSON.stringify(spec.args)
chunks.push(
{ type: 'block-start', index, blockType: 'tool-call' },
@@ -5,7 +5,8 @@ import { join } from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'
import type { Context } from '@deepseek-ai/cordis'
import { codingHarness, finalText, SYSTEM_PROMPT, waitForIdle } from './harness.ts'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
/**
* The first place a REAL model meets the REAL bash tool: the cheap canary
@@ -29,7 +30,7 @@ describe.skipIf(!process.env.DEEPSEEK_API_KEY)('full loop: real model + real bas
it('runs a bash command on request and reports its output', async () => {
workdir = await mkdtemp(join(tmpdir(), 'dsh-full-loop-e2e-'))
ctx = await codingHarness(workdir, { personaPrefix: SYSTEM_PROMPT })
const agent = await ctx.agentLoop.create(SessionId('e2e-loop'), { provider: 'deepseek-official', model: 'deepseek-v4-flash' }, { cwd: workdir })
const agent = await ctx.agentLoop.create(brandString<SessionId>('e2e-loop'), { provider: 'deepseek-official', model: 'deepseek-v4-flash' }, { cwd: workdir })
agent.followup(createUserMessage({ content: [{ type: 'text', text: 'Run `echo e2e-ok` with the bash tool and tell me its exact output.' }], source: { kind: 'user' } }))
await waitForIdle(ctx, agent)
@@ -4,8 +4,9 @@ import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, describe, expect, it, onTestFinished, vi } from 'vitest'
import { Context } from '@deepseek-ai/cordis'
import { createUserMessage, ToolCallId, HarnessError } from '@deepseek-ai/dsh-llm'
import SessionStore, { SessionId } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
import { createUserMessage, type ToolCallId, HarnessError } from '@deepseek-ai/dsh-llm'
import SessionStore, { type SessionId } from '@deepseek-ai/dsh-session'
import type { SessionEvent } from '@deepseek-ai/dsh-session'
import { RUN_CODE_NAME, defineTool } from '@deepseek-ai/dsh-tools'
import type { ToolExecutionResult } from '@deepseek-ai/dsh-tools'
@@ -98,7 +99,7 @@ function runCode(
agent?: Agent,
): Promise<ToolExecutionResult> {
return executeModelToolFixture(harness, {
callId: ToolCallId(`keyless-code-${++keylessCall}`),
callId: brandString<ToolCallId>(`keyless-code-${++keylessCall}`),
name: RUN_CODE_NAME,
arguments: { code, description: 'Run the e2e program' },
signal,
@@ -299,8 +300,8 @@ describe('PTC mode typed values: keyless real-process contracts', () => {
await ctx.plugin(ToolCordis)
const agent = {
ctx,
id: SessionId('ptc-cordis'),
session: ctx.sessions.create(SessionId('ptc-cordis'), { meta: { cwd: process.cwd() } }),
id: brandString<SessionId>('ptc-cordis'),
session: ctx.sessions.create(brandString<SessionId>('ptc-cordis'), { meta: { cwd: process.cwd() } }),
} as Agent
const value = completion(await runCode(ctx, `
@@ -331,7 +332,7 @@ describe.skipIf(!process.env.DEEPSEEK_API_KEY)('PTC mode: real model writes a pr
it('collapses the wire tool list to [run_code], bridges sub-calls, and returns curated output', async () => {
workdir = await mkdtemp(join(tmpdir(), 'dsh-ptc-e2e-'))
ctx = await ptcModeHarness(workdir)
const agent = await ctx.agentLoop.create(SessionId('e2e-ptc'), { provider: 'deepseek-official', model: 'deepseek-v4-flash' }, { cwd: workdir })
const agent = await ctx.agentLoop.create(brandString<SessionId>('e2e-ptc'), { provider: 'deepseek-official', model: 'deepseek-v4-flash' }, { cwd: workdir })
agent.followup(createUserMessage({
content: [{
@@ -381,7 +382,7 @@ describe.skipIf(!process.env.DEEPSEEK_API_KEY)('PTC mode: real model writes a pr
await writeFile(join(workdir, 'pkg/deep/task.txt'), 'Touch this file to discover the nested instructions.\n')
ctx = await workspacePtcModeHarness()
const handle = await ctx.agents.create({
sessionId: SessionId('e2e-ptc-workspace-session'),
sessionId: brandString<SessionId>('e2e-ptc-workspace-session'),
meta: { cwd: workdir },
agentOptions: { provider: 'deepseek-official', model: 'deepseek-v4-flash' },
})
@@ -4,8 +4,9 @@ import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'
import type { Context } from '@deepseek-ai/cordis'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import { codingHarness, finalText, SYSTEM_PROMPT, waitForIdle } from './harness.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
/**
* Proves durable conversation continuity end-to-end: run 1 tells the REAL model
@@ -16,7 +17,7 @@ import { codingHarness, finalText, SYSTEM_PROMPT, waitForIdle } from './harness.
*/
const SECRET = 'plum-galaxy-1791'
const SESSION_ID = SessionId('resume-e2e-session')
const SESSION_ID = brandString<SessionId>('resume-e2e-session')
let ctx: Context | undefined
let root: string | undefined
@@ -9,8 +9,9 @@ import {
type NormalizeContext,
} from '@deepseek-ai/dsh-session-snapshot'
import { LOADER_SMOKE_TEST_TIMEOUT_MS, runLoaderSmoke } from '@deepseek-ai/dsh-loader-smoke'
import { createUserMessage, ToolCallId, createMessage } from '@deepseek-ai/dsh-llm'
import { SessionSeq, SESSION_FORMAT_VERSION, SessionId, type SessionEvent, type SessionHeader } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
import { createUserMessage, type ToolCallId, createMessage } from '@deepseek-ai/dsh-llm'
import { SessionSeq, SESSION_FORMAT_VERSION, type SessionId, type SessionEvent, type SessionHeader } from '@deepseek-ai/dsh-session'
import * as JsonlSessionPersistence from '@deepseek-ai/dsh-session-persistence-jsonl'
import { logPath } from '../../../../../../packages/session/session-persistence-jsonl/src/format.ts'
import { describe, expect, it } from 'vitest'
@@ -22,7 +23,7 @@ const sessionExpected = join(fixtureDir, 'session.expected.jsonl')
const configPath = fileURLToPath(new URL('../semantic-checkpoint-snapshot.patch.yml', import.meta.url))
const binScript = fileURLToPath(new URL('../../../../../../packages/test-support/loader-smoke/tests/fixtures/headless-driver.ts', import.meta.url))
const tsconfigPath = fileURLToPath(new URL('../../../../../../tsconfig.json', import.meta.url))
const sessionId = SessionId('semantic-checkpoint-unknown-outcome')
const sessionId = brandString<SessionId>('semantic-checkpoint-unknown-outcome')
const refreshing = process.env.DSH_SNAPSHOT === 'refresh'
const task = 'Continue safely from the interrupted operation.'
@@ -68,7 +69,7 @@ async function seedInterruptedSession(root: string, cwd: string): Promise<string
stream: [],
message: createMessage({
role: 'assistant',
content: [{ type: 'tool-call', id: ToolCallId('unknown-outcome-call'), name: 'write_remote', arguments: '{"value":1}' }],
content: [{ type: 'tool-call', id: brandString<ToolCallId>('unknown-outcome-call'), name: 'write_remote', arguments: '{"value":1}' }],
source: {
kind: 'model',
...{ provider: 'deepseek-official', model: 'deepseek-v4-flash' },
@@ -84,7 +85,7 @@ async function seedInterruptedSession(root: string, cwd: string): Promise<string
data: {
turn: 1,
step: 1,
callId: ToolCallId('unknown-outcome-call'),
callId: brandString<ToolCallId>('unknown-outcome-call'),
name: 'write_remote',
arguments: '{"value":1}',
},
@@ -12,7 +12,7 @@ import { Context } from '@deepseek-ai/cordis'
import { LOADER_SMOKE_TEST_TIMEOUT_MS, runLoaderSmoke } from '@deepseek-ai/dsh-loader-smoke'
import {
SESSION_FORMAT_VERSION,
SessionId,
type SessionId,
SessionSeq,
type SessionEvent,
type SessionHeader,
@@ -24,6 +24,7 @@ import {
logPath,
} from '../../../../../../packages/session/session-persistence-jsonl/src/format.ts'
import { describe, expect, it } from 'vitest'
import { brandString } from '@deepseek-ai/dsh-brand'
const fixtureDir = join(dirname(fileURLToPath(import.meta.url)), 'expected/workspace-context-resume/offline-edit')
const replayFixture = join(fixtureDir, 'replay.jsonl')
@@ -31,7 +32,7 @@ const configPath = fileURLToPath(new URL('../workspace-context-resume-snapshot.p
const binScript = fileURLToPath(new URL('../../../../../../packages/test-support/loader-smoke/tests/fixtures/headless-driver.ts', import.meta.url))
const tsconfigPath = fileURLToPath(new URL('../../../../../../tsconfig.json', import.meta.url))
// The resumed-agent fixture in the shared config resumes exactly this id.
const sessionId = SessionId('workspace-context-resume')
const sessionId = brandString<SessionId>('workspace-context-resume')
const fixtureEnv = {
DSH_SNAPSHOT_FILE: replayFixture,
DSH_LOADER_SMOKE_REQUIRED_ENTRY_ID: 'resumed-agent',
@@ -15,9 +15,10 @@ import {
} from '@deepseek-ai/dsh-session-snapshot'
import { LOADER_SMOKE_TEST_TIMEOUT_MS, runLoaderSmoke } from '@deepseek-ai/dsh-loader-smoke'
import { createMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SessionSeq, SESSION_FORMAT_VERSION, SessionId, type SessionEvent, type SessionHeader } from '@deepseek-ai/dsh-session'
import { SessionSeq, SESSION_FORMAT_VERSION, type SessionId, type SessionEvent, type SessionHeader } from '@deepseek-ai/dsh-session'
import * as JsonlSessionPersistence from '@deepseek-ai/dsh-session-persistence-jsonl'
import { describe, expect, it } from 'vitest'
import { brandString } from '@deepseek-ai/dsh-brand'
const fixtureDir = fileURLToPath(new URL('./expected/subagent-diagnostic', import.meta.url))
const replayOverride = join(fixtureDir, 'replay.override.json')
@@ -25,8 +26,8 @@ const parentExpected = join(fixtureDir, 'parent.expected.jsonl')
const configPath = fileURLToPath(new URL('../subagent-diagnostic-snapshot.patch.yml', import.meta.url))
const binScript = fileURLToPath(new URL('../../../../../../packages/test-support/loader-smoke/tests/fixtures/headless-driver.ts', import.meta.url))
const tsconfigPath = fileURLToPath(new URL('../../../../../../tsconfig.json', import.meta.url))
const parentId = SessionId('subagent-diagnostic-parent')
const childId = SessionId('subagent-diagnostic-child')
const parentId = brandString<SessionId>('subagent-diagnostic-parent')
const childId = brandString<SessionId>('subagent-diagnostic-child')
const refreshing = process.env.DSH_SNAPSHOT === 'refresh'
const task = 'Call list_agents once and report what it shows.'
@@ -15,8 +15,9 @@ import {
type NormalizeContext,
} from '@deepseek-ai/dsh-session-snapshot'
import { LOADER_SMOKE_TEST_TIMEOUT_MS, runLoaderSmoke } from '@deepseek-ai/dsh-loader-smoke'
import { createMessage, createUserMessage, ReasoningEffortId } from '@deepseek-ai/dsh-llm'
import { SessionSeq, SESSION_FORMAT_VERSION, SessionId, type SessionEvent, type SessionHeader } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
import { createMessage, createUserMessage, type ReasoningEffortId } from '@deepseek-ai/dsh-llm'
import { SessionSeq, SESSION_FORMAT_VERSION, type SessionId, type SessionEvent, type SessionHeader } from '@deepseek-ai/dsh-session'
import * as JsonlSessionPersistence from '@deepseek-ai/dsh-session-persistence-jsonl'
import { describe, expect, it } from 'vitest'
@@ -30,7 +31,7 @@ const childExpected = join(fixtureDir, 'child.expected.jsonl')
const configPath = fileURLToPath(new URL('../subagent-inheritance-snapshot.patch.yml', import.meta.url))
const binScript = fileURLToPath(new URL('../../../../../../packages/test-support/loader-smoke/tests/fixtures/headless-driver.ts', import.meta.url))
const tsconfigPath = fileURLToPath(new URL('../../../../../../tsconfig.json', import.meta.url))
const sessionId = SessionId('subagent-inheritance-parent')
const sessionId = brandString<SessionId>('subagent-inheritance-parent')
const refreshing = process.env.DSH_SNAPSHOT === 'refresh'
const task = 'Delegate the write probe to a subagent.'
@@ -75,7 +76,7 @@ async function seedReadOnlyParent(root: string, cwd: string): Promise<void> {
config: {
provider: 'deepseek-official',
model: 'deepseek-v4-flash',
reasoningEffort: ReasoningEffortId('low'),
reasoningEffort: brandString<ReasoningEffortId>('low'),
},
},
reason: 'initial',
@@ -5,7 +5,8 @@ import { join } from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'
import type { Context } from '@deepseek-ai/cordis'
import { codingHarness, TODO_SYSTEM_PROMPT, waitForIdle } from './harness.ts'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
/**
* A REAL model drives the REAL todo_write tool: verify the WORLD (the session
@@ -27,7 +28,7 @@ describe.skipIf(!process.env.DEEPSEEK_API_KEY)('todo_write: real model records a
it('appends a todo/write event with the model-produced task list', async () => {
workdir = await mkdtemp(join(tmpdir(), 'dsh-todo-write-e2e-'))
ctx = await codingHarness(workdir, { personaPrefix: TODO_SYSTEM_PROMPT })
const agent = await ctx.agentLoop.create(SessionId('e2e-todo'), { provider: 'deepseek-official', model: 'deepseek-v4-flash' }, { cwd: workdir })
const agent = await ctx.agentLoop.create(brandString<SessionId>('e2e-todo'), { provider: 'deepseek-official', model: 'deepseek-v4-flash' }, { cwd: workdir })
agent.followup(createUserMessage({
content: [{ type: 'text', text:
@@ -18,7 +18,7 @@ import { LOADER_SMOKE_TEST_TIMEOUT_MS, runLoaderSmoke } from '@deepseek-ai/dsh-l
import { createMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import {
SESSION_FORMAT_VERSION,
SessionId,
type SessionId,
SessionSeq,
type SessionEvent,
type SessionHeader,
@@ -28,6 +28,7 @@ import { logPath } from '../../../../../../packages/session/session-persistence-
import { renderAgentInstructions } from '@deepseek-ai/dsh-agent-instructions'
import { resolveConfig, workspaceBaselineIdentity } from '@deepseek-ai/dsh-agent-instructions/src/config.ts'
import { describe, expect, it } from 'vitest'
import { brandString } from '@deepseek-ai/dsh-brand'
const fixtureDir = join(dirname(fileURLToPath(import.meta.url)), 'expected/workspace-context-resume/offline-edit')
const replayFixture = join(fixtureDir, 'replay.jsonl')
@@ -37,7 +38,7 @@ const precedenceExpected = join(dirname(fixtureDir), 'precedence-change/session.
const configPath = fileURLToPath(new URL('../workspace-context-resume-snapshot.patch.yml', import.meta.url))
const binScript = fileURLToPath(new URL('../../../../../../packages/test-support/loader-smoke/tests/fixtures/headless-driver.ts', import.meta.url))
const tsconfigPath = fileURLToPath(new URL('../../../../../../tsconfig.json', import.meta.url))
const sessionId = SessionId('workspace-context-resume')
const sessionId = brandString<SessionId>('workspace-context-resume')
const refreshing = process.env.DSH_SNAPSHOT === 'refresh'
const oldInstruction = 'Old workspace instruction.'
const newInstruction = 'New workspace instruction after offline edit.'
+56 -55
View File
@@ -18,7 +18,7 @@ import {
type Profile,
} from '@deepseek-ai/dsh-app-boot'
import { provideCmdline } from '@deepseek-ai/dsh-cmdline'
import { SessionId, SessionLogOffset } from '@deepseek-ai/dsh-session'
import { type SessionId, SessionLogOffset } from '@deepseek-ai/dsh-session'
import type { Agent } from '@deepseek-ai/dsh-agent'
import type { PatchOptions } from '@deepseek-ai/cordis-plugin-include'
import { afterAll, beforeAll, describe, expect, it, onTestFinished, vi } from 'vitest'
@@ -28,7 +28,8 @@ import { createPluginProfile } from '../../desktop/src/project-manager.ts'
const SETTINGS_NAMESPACE = 'agent-preset-registry'
const SUBAGENT_MODEL_SELECTION_SETTINGS_NAMESPACE = 'subagent-model-selection-settings'
import { applyChildComposition, childSessionMeta } from '@deepseek-ai/dsh-subagent'
import { ToolCallId, LlmAdapter, createUserMessage } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type ToolCallId, LlmAdapter, createUserMessage } from '@deepseek-ai/dsh-llm'
import type { GenerateOptions, LlmResolvedModelInfo, StreamChunk } from '@deepseek-ai/dsh-llm'
import type {} from '@deepseek-ai/dsh-compaction-basic'
import { codePointLength } from '@deepseek-ai/dsh-compaction-tool-result-pruner'
@@ -87,7 +88,7 @@ class MinimalImageAdapter extends LlmAdapter {
const first = this.requests.length === 1
yield { type: 'block-start', index: 0, blockType: first ? 'tool-call' : 'text' }
yield { type: 'block-end', index: 0, block: first
? { type: 'tool-call', id: ToolCallId('minimal-image-read'), name: 'read_image', arguments: '{"file_path":"red.png"}' }
? { type: 'tool-call', id: brandString<ToolCallId>('minimal-image-read'), name: 'read_image', arguments: '{"file_path":"red.png"}' }
: { type: 'text', text: 'Image inspected.' } }
yield { type: 'finish', reason: { kind: first ? 'tool-calls' : 'stop' } }
}
@@ -268,7 +269,7 @@ describe('the shipped Web composition', () => {
const projections = ctx.get('sessionProjections')
if (projections === undefined) throw new Error('the Web composition must compose a projection registry')
const handle = await ctx.agents.create({
sessionId: SessionId('preset-minimal-meter'),
sessionId: brandString<SessionId>('preset-minimal-meter'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'minimal').then(() => undefined),
})
try {
@@ -291,7 +292,7 @@ describe('the shipped Web composition', () => {
it.each(['standard', 'cordis', 'ptc'] as const)('keeps interruption disabled in %s with Team mode off or on', async (preset) => {
const handle = await ctx.agents.create({
sessionId: SessionId(`preset-interrupt-${preset}`),
sessionId: brandString<SessionId>(`preset-interrupt-${preset}`),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, preset).then(() => undefined),
})
try {
@@ -326,7 +327,7 @@ describe('the shipped Web composition', () => {
}])
try {
const handle = await configured.agents.create({
sessionId: SessionId(`preset-interrupt-enabled-${preset}`),
sessionId: brandString<SessionId>(`preset-interrupt-enabled-${preset}`),
setup: agentCtx => configured.agentPresets.mount(agentCtx, preset).then(() => undefined),
})
try {
@@ -340,7 +341,7 @@ describe('the shipped Web composition', () => {
it('composes the full agent from `standard`', async () => {
const handle = await ctx.agents.create({
sessionId: SessionId('preset-standard'),
sessionId: brandString<SessionId>('preset-standard'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
try {
@@ -369,7 +370,7 @@ describe('the shipped Web composition', () => {
allowedModels: [],
})
const disabled = await ctx.agents.create({
sessionId: SessionId('preset-model-selection-disabled'),
sessionId: brandString<SessionId>('preset-model-selection-disabled'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
await ctx.settings.update(SUBAGENT_MODEL_SELECTION_SETTINGS_NAMESPACE, {
@@ -377,7 +378,7 @@ describe('the shipped Web composition', () => {
allowedModels: [{ provider: 'deepseek-official', model: 'deepseek-v4-flash' }],
})
const enabled = await ctx.agents.create({
sessionId: SessionId('preset-model-selection-enabled'),
sessionId: brandString<SessionId>('preset-model-selection-enabled'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
const policy = await ctx.sessionProjections.register(subagentModelSelectionProjectionDefinition)
@@ -410,13 +411,13 @@ describe('the shipped Web composition', () => {
const unregister = ctx.llm.registerAdapter(['preset-round-trip'], adapter)
onTestFinished(unregister)
const direct = await ctx.agents.create({
sessionId: SessionId(`preset-direct-${target}-${randomUUID()}`),
sessionId: brandString<SessionId>(`preset-direct-${target}-${randomUUID()}`),
agentOptions: { provider: 'preset-round-trip', model: 'preset-round-trip' },
setup: agentCtx => ctx.agentPresets.mount(agentCtx, target).then(() => undefined),
})
onTestFinished(() => direct.dispose())
const handle = await ctx.agents.create({
sessionId: SessionId(`preset-round-trip-${target}-${randomUUID()}`),
sessionId: brandString<SessionId>(`preset-round-trip-${target}-${randomUUID()}`),
agentOptions: { provider: 'preset-round-trip', model: 'preset-round-trip' },
setup: agentCtx => ctx.agentPresets.mount(agentCtx, target).then(() => undefined),
})
@@ -450,7 +451,7 @@ describe('the shipped Web composition', () => {
it('composes the exact RL prompt and persistent shell from `minimal`', async () => {
const handle = await ctx.agents.create({
sessionId: SessionId('preset-minimal'),
sessionId: brandString<SessionId>('preset-minimal'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'minimal').then(() => undefined),
})
try {
@@ -484,7 +485,7 @@ describe('the shipped Web composition', () => {
const unregister = ctx.llm.registerAdapter(['minimal-image-test'], adapter)
onTestFinished(unregister)
const handle = await ctx.agents.create({
sessionId: SessionId('preset-minimal-image'), meta: { cwd },
sessionId: brandString<SessionId>('preset-minimal-image'), meta: { cwd },
agentOptions: { provider: 'minimal-image-test', model: 'minimal-image-test' },
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'minimal').then(() => undefined),
})
@@ -512,7 +513,7 @@ describe('the shipped Web composition', () => {
const unregister = ctx.llm.registerAdapter(['minimal-compaction-test'], adapter)
onTestFinished(unregister)
const handle = await ctx.agents.create({
sessionId: SessionId('preset-minimal-compaction'),
sessionId: brandString<SessionId>('preset-minimal-compaction'),
agentOptions: { provider: 'minimal-compaction-test', model: 'minimal-compaction-test' },
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'minimal').then(() => undefined),
})
@@ -546,7 +547,7 @@ describe('the shipped Web composition', () => {
const unregister = ctx.llm.registerAdapter(['minimal-pressure-test'], adapter)
onTestFinished(unregister)
const handle = await ctx.agents.create({
sessionId: SessionId('preset-minimal-pressure'),
sessionId: brandString<SessionId>('preset-minimal-pressure'),
agentOptions: { provider: 'minimal-pressure-test', model: 'minimal-pressure-test' },
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'minimal').then(() => undefined),
})
@@ -571,11 +572,11 @@ describe('the shipped Web composition', () => {
it('keeps two differently composed sessions independent', async () => {
const full = await ctx.agents.create({
sessionId: SessionId('preset-both-full'),
sessionId: brandString<SessionId>('preset-both-full'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
const minimal = await ctx.agents.create({
sessionId: SessionId('preset-both-minimal'),
sessionId: brandString<SessionId>('preset-both-minimal'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'minimal').then(() => undefined),
})
try {
@@ -596,7 +597,7 @@ describe('the shipped Web composition', () => {
it('composes the cordis agent with its own toolset', async () => {
const handle = await ctx.agents.create({
sessionId: SessionId('preset-cordis'),
sessionId: brandString<SessionId>('preset-cordis'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'cordis').then(() => undefined),
})
try {
@@ -619,7 +620,7 @@ describe('the shipped Web composition', () => {
expect(shipped).toEqual(['dsh-doc'])
expect((await ctx.skills.list()).map(skill => skill.name)).not.toContain('dsh-doc')
const loaded = await executeToolFixture(ctx, {
callId: ToolCallId('preset-cordis-dsh-doc'),
callId: brandString<ToolCallId>('preset-cordis-dsh-doc'),
name: 'skill',
arguments: { name: 'dsh-doc' },
signal: new AbortController().signal,
@@ -636,7 +637,7 @@ describe('the shipped Web composition', () => {
for (const file of readdirSync(references).filter(entry => entry !== 'packages.md')) {
const path = join(references, file)
const result = await executeToolFixture(ctx, {
callId: ToolCallId(`preset-cordis-dsh-doc-${file}`),
callId: brandString<ToolCallId>(`preset-cordis-dsh-doc-${file}`),
name: 'read',
arguments: { file_path: path },
signal: new AbortController().signal,
@@ -650,7 +651,7 @@ describe('the shipped Web composition', () => {
// Creator adds its DSH customization intent to the shared coding persona.
const standard = await ctx.agents.create({
sessionId: SessionId('preset-cordis-standard-persona'),
sessionId: brandString<SessionId>('preset-cordis-standard-persona'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
try {
@@ -674,7 +675,7 @@ describe('the shipped Web composition', () => {
})
try {
const codingOnly = await ctx.agents.create({
sessionId: SessionId('preset-cordis-coding-only'),
sessionId: brandString<SessionId>('preset-cordis-coding-only'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'cordis-coding-only').then(() => undefined),
})
try {
@@ -692,11 +693,11 @@ describe('the shipped Web composition', () => {
it('presents `ptc` as PTC mode without disturbing a native session beside it', async () => {
const coded = await ctx.agents.create({
sessionId: SessionId('preset-ptc'),
sessionId: brandString<SessionId>('preset-ptc'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'ptc').then(() => undefined),
})
const native = await ctx.agents.create({
sessionId: SessionId('preset-ptc-native'),
sessionId: brandString<SessionId>('preset-ptc-native'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
try {
@@ -725,7 +726,7 @@ describe('the shipped Web composition', () => {
it('keeps the self-referential toolset out of every other preset', async () => {
const handle = await ctx.agents.create({
sessionId: SessionId('preset-no-cordis'),
sessionId: brandString<SessionId>('preset-no-cordis'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
try {
@@ -758,7 +759,7 @@ describe('the shipped Web composition', () => {
const handle = await ctx.agents.create({
// Unique per run: the composition persists into the ambient DSH home,
// and a fixed id would collide with a log an earlier run left there.
sessionId: SessionId(`preset-skills-standard-${randomUUID()}`),
sessionId: brandString<SessionId>(`preset-skills-standard-${randomUUID()}`),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
try {
@@ -776,7 +777,7 @@ describe('the shipped Web composition', () => {
// The preset's own loader tool resolves the global-layer skill.
const loaded = await executeToolFixture(ctx, {
callId: ToolCallId('preset-skills-load'),
callId: brandString<ToolCallId>('preset-skills-load'),
name: 'skill',
arguments: { name: 'dsh-badge' },
signal: new AbortController().signal,
@@ -791,7 +792,7 @@ describe('the shipped Web composition', () => {
it('shows a minimal agent the global layer but no loader tool', async () => {
const handle = await ctx.agents.create({
sessionId: SessionId(`preset-skills-minimal-${randomUUID()}`),
sessionId: brandString<SessionId>(`preset-skills-minimal-${randomUUID()}`),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'minimal').then(() => undefined),
})
try {
@@ -813,7 +814,7 @@ describe('the shipped Web composition', () => {
const before = await Promise.all(WEB_PATCHES.map(file => readFile(file, 'utf8')))
const handle = await ctx.agents.create({
sessionId: SessionId('preset-readonly'),
sessionId: brandString<SessionId>('preset-readonly'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
await handle.dispose()
@@ -838,7 +839,7 @@ describe('preset-selected delegation through the Web Loader', () => {
const adapter = new MinimalCompactionAdapter()
configured.llm.registerAdapter(['preset-switch'], adapter)
const { agent } = await configured.agents.create({
sessionId: SessionId(`configured-switch-${randomUUID()}`),
sessionId: brandString<SessionId>(`configured-switch-${randomUUID()}`),
agentOptions: { provider: 'preset-switch', model: 'preset-switch' },
setup: owner => configured.agentPresets.mount(owner, 'delegate-a').then(() => undefined),
})
@@ -879,7 +880,7 @@ describe.each(['web', 'desktop'] as const)('%s native subagent bundles', (surfac
async function presetTools(productCtx: Context, preset: string): Promise<string[]> {
const handle = await productCtx.agents.create({
sessionId: SessionId(`native-${surface}-${preset}-${randomUUID()}`),
sessionId: brandString<SessionId>(`native-${surface}-${preset}-${randomUUID()}`),
setup: owner => productCtx.agentPresets.mount(owner, preset).then(() => undefined),
})
try {
@@ -899,7 +900,7 @@ describe.each(['web', 'desktop'] as const)('%s native subagent bundles', (surfac
expect(await presetTools(productCtx, preset)).toEqual(expected)
}
const handle = await productCtx.agents.create({
sessionId: SessionId(`native-${surface}-params-${randomUUID()}`),
sessionId: brandString<SessionId>(`native-${surface}-params-${randomUUID()}`),
setup: owner => productCtx.agentPresets.mount(owner, 'standard').then(() => undefined),
})
try {
@@ -961,12 +962,12 @@ describe('the standard preset documentation skill', () => {
const adapter = new MinimalCompactionAdapter()
testCtx.llm.registerAdapter(['standard-doc-test'], adapter)
const baseline = await testCtx.agents.create({
sessionId: SessionId('standard-doc-baseline'), meta: { cwd: root },
sessionId: brandString<SessionId>('standard-doc-baseline'), meta: { cwd: root },
agentOptions: { provider: 'standard-doc-test', model: 'standard-doc-test' },
setup: agentCtx => testCtx.agentPresets.mount(agentCtx, 'standard-without-doc').then(() => undefined),
})
const standardAgent = await testCtx.agents.create({
sessionId: SessionId('standard-doc-current'), meta: { cwd: root },
sessionId: brandString<SessionId>('standard-doc-current'), meta: { cwd: root },
agentOptions: { provider: 'standard-doc-test', model: 'standard-doc-test' },
setup: agentCtx => testCtx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
@@ -978,7 +979,7 @@ describe('the standard preset documentation skill', () => {
expect(definition?.path).toBe(await realpath(join(REPO_ROOT, 'packages/preset/agent-preset/skills/dsh-doc/SKILL.md')))
if (definition === undefined) throw new Error('standard has no packaged dsh-doc skill')
const creator = await testCtx.agents.create({
sessionId: SessionId('standard-doc-creator'), meta: { cwd: root },
sessionId: brandString<SessionId>('standard-doc-creator'), meta: { cwd: root },
setup: agentCtx => testCtx.agentPresets.mount(agentCtx, 'cordis').then(() => undefined),
})
expect((await testCtx.skills.get('dsh-doc', { cwd: root, scope: creator.agent }))?.path).toBe(definition.path)
@@ -1023,7 +1024,7 @@ describe('the standard preset documentation skill', () => {
const profileManifest = join(root, 'profiles/spec/package.json')
const before = await readFile(profileManifest, 'utf8')
const loaded = await executeToolFixture(testCtx, {
agent: standardAgent.agent, callId: ToolCallId('standard-doc-load'),
agent: standardAgent.agent, callId: brandString<ToolCallId>('standard-doc-load'),
name: 'skill', arguments: { name: 'dsh-doc' }, signal: new AbortController().signal,
})
expect(loaded.isError).toBe(false)
@@ -1065,7 +1066,7 @@ describe('the standard preset documentation skill', () => {
priorityCtx = await bootWeb(root)
const testCtx = priorityCtx
const handle = await testCtx.agents.create({
sessionId: SessionId('standard-doc-priority'), meta: { cwd: workspace },
sessionId: brandString<SessionId>('standard-doc-priority'), meta: { cwd: workspace },
setup: agentCtx => testCtx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
for (const [cwd, path] of [
@@ -1105,11 +1106,11 @@ describe('a user preset declared from the shipped cordis rows', () => {
}] }])
try {
const shipped = await copyCtx.agents.create({
sessionId: SessionId(`preset-cordis-shipped-${randomUUID()}`),
sessionId: brandString<SessionId>(`preset-cordis-shipped-${randomUUID()}`),
setup: agentCtx => copyCtx.agentPresets.mount(agentCtx, 'cordis').then(() => undefined),
})
const copied = await copyCtx.agents.create({
sessionId: SessionId(`preset-cordis-copy-${randomUUID()}`),
sessionId: brandString<SessionId>(`preset-cordis-copy-${randomUUID()}`),
setup: agentCtx => copyCtx.agentPresets.mount(agentCtx, 'cordis-copy').then(() => undefined),
})
try {
@@ -1120,7 +1121,7 @@ describe('a user preset declared from the shipped cordis rows', () => {
}
const signal = new AbortController().signal
const listed = await executeToolFixture(copyCtx, {
callId: ToolCallId('copied-preset-inspect-list'),
callId: brandString<ToolCallId>('copied-preset-inspect-list'),
name: 'cordis_inspect_list',
arguments: {},
signal,
@@ -1137,7 +1138,7 @@ describe('a user preset declared from the shipped cordis rows', () => {
const spills = vi.spyOn(copyCtx.spillStore, 'saveText')
onTestFinished(() => { spills.mockRestore() })
const queried = await executeToolFixture(copyCtx, {
callId: ToolCallId('copied-preset-inspect-tools'),
callId: brandString<ToolCallId>('copied-preset-inspect-tools'),
name: 'cordis_inspect_query',
arguments: { platform: 'host', provider: 'Tool', method: 'listTools' },
signal,
@@ -1156,7 +1157,7 @@ describe('a user preset declared from the shipped cordis rows', () => {
type ConfigPage = { data: { entries: ConfigRow[]; total: number; nextOffset: number | null } }
const listConfigs = async (input: Record<string, string | number>, callId: string): Promise<ConfigPage['data']> => {
const page = await executeToolFixture(copyCtx, {
callId: ToolCallId(callId),
callId: brandString<ToolCallId>(callId),
name: 'cordis_inspect_query',
arguments: { platform: 'host', provider: 'Config', method: 'listConfigs', input },
signal,
@@ -1175,7 +1176,7 @@ describe('a user preset declared from the shipped cordis rows', () => {
expect(firstPage.entries).toHaveLength(5)
expect(firstPage.nextOffset).toBe(5)
const projected = await executeToolFixture(copyCtx, {
callId: ToolCallId('copied-preset-inspect-config'),
callId: brandString<ToolCallId>('copied-preset-inspect-config'),
name: 'cordis_inspect_query',
arguments: { platform: 'host', provider: 'Config', method: 'listConfigs', input: { entry: toolsRow!.id } },
signal,
@@ -1201,7 +1202,7 @@ describe('a user preset declared from the shipped cordis rows', () => {
describe('a switch survives the session', () => {
it('records the choice so the log states what the agent runs', async () => {
const handle = await ctx.agents.create({
sessionId: SessionId('preset-switch-logged'),
sessionId: brandString<SessionId>('preset-switch-logged'),
meta: { agentPreset: 'standard' },
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
@@ -1225,18 +1226,18 @@ describe('a switch survives the session', () => {
describe('a forked session', () => {
it('inherits the composition its seeded history was produced under', async () => {
const parent = await ctx.agents.create({
sessionId: SessionId('preset-fork-parent'),
sessionId: brandString<SessionId>('preset-fork-parent'),
meta: { agentPreset: 'minimal' },
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'minimal').then(() => undefined),
})
const projection = await ctx.sessionProjections.register(agentPresetProjectionDefinition)
const inherited = projection.stateOf(parent.agent.session) ?? undefined
const child = await ctx.agents.create({
sessionId: SessionId('preset-fork-child'),
sessionId: brandString<SessionId>('preset-fork-child'),
seed: [],
inheritedEventCount: SessionLogOffset(0),
meta: {
parentSession: SessionId('preset-fork-parent'),
parentSession: brandString<SessionId>('preset-fork-parent'),
isSeeded: true,
...inherited === undefined ? {} : { agentPreset: inherited },
},
@@ -1258,13 +1259,13 @@ describe('a forked session', () => {
describe('a delegated child', () => {
it.each([false, true])('inherits preset tools with seeded=%s and refuses child scheduled tasks', async (seeded) => {
const parent = await ctx.agents.create({
sessionId: SessionId(`preset-child-parent-${seeded}`),
sessionId: brandString<SessionId>(`preset-child-parent-${seeded}`),
meta: { agentPreset: 'standard' },
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
// Exactly what an in-process subagent driver's creation window does.
const child = await parent.agent.ctx.agents.create({
sessionId: SessionId(`preset-child-${seeded}`),
sessionId: brandString<SessionId>(`preset-child-${seeded}`),
meta: childSessionMeta(parent.agent, 1, seeded),
...(seeded ? { seed: [], inheritedEventCount: SessionLogOffset(0) } : {}),
setup: (agentCtx) => {
@@ -1288,7 +1289,7 @@ describe('a delegated child', () => {
for (const [name, args] of calls) {
expect(toolNames(ctx, child.agent)).toContain(name)
const result = await executeToolFixture(ctx, {
callId: ToolCallId(`child-${name}`), signal: new AbortController().signal,
callId: brandString<ToolCallId>(`child-${name}`), signal: new AbortController().signal,
name, arguments: args, agent: child.agent,
})
expect(result.value).toEqual({ code: 'subagent_session', message: 'A delegated subagent cannot use scheduled tasks.' })
@@ -1302,13 +1303,13 @@ describe('a delegated child', () => {
it('follows a parent that switched preset while blank', async () => {
const parent = await ctx.agents.create({
sessionId: SessionId('preset-child-switch-parent'),
sessionId: brandString<SessionId>('preset-child-switch-parent'),
meta: { agentPreset: 'standard' },
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
await ctx.agentPresets.recompose(parent.agent.ctx, 'minimal')
const child = await parent.agent.ctx.agents.create({
sessionId: SessionId('preset-child-switch'),
sessionId: brandString<SessionId>('preset-child-switch'),
meta: childSessionMeta(parent.agent, 1, false),
setup: (agentCtx) => {
return applyChildComposition(agentCtx, parent.agent, {})
@@ -1335,7 +1336,7 @@ describe('the default preset as a user setting', () => {
expect(ctx.agentPresets.defaultId).toBe('minimal')
const handle = await ctx.agents.create({
sessionId: SessionId('preset-user-default'),
sessionId: brandString<SessionId>('preset-user-default'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx).then(() => undefined),
})
try {
@@ -1382,7 +1383,7 @@ describe('a profile patch stored before Developer tools owned preset selection',
.toEqual({ selectedDefault: 'minimal' })
const handle = await legacy.agents.create({
sessionId: SessionId('preset-legacy-patch'),
sessionId: brandString<SessionId>('preset-legacy-patch'),
setup: agentCtx => legacy.agentPresets.mount(agentCtx).then(() => undefined),
})
try {
@@ -1396,7 +1397,7 @@ describe('a profile patch stored before Developer tools owned preset selection',
describe('a session keeps the preset it was created with', () => {
it('refuses to adopt a live session under a different preset', async () => {
const handle = await ctx.agents.create({
sessionId: SessionId('preset-locked'),
sessionId: brandString<SessionId>('preset-locked'),
meta: { agentPreset: 'minimal' },
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'minimal').then(() => undefined),
})
+3 -2
View File
@@ -5,10 +5,11 @@ import { join } from 'node:path'
import { Context } from '@deepseek-ai/cordis'
import { LocalFileSystem } from '@deepseek-ai/dsh-fs-local'
import SessionStore from '@deepseek-ai/dsh-session'
import { SessionId } from '@deepseek-ai/dsh-session/types'
import type { SessionId } from '@deepseek-ai/dsh-session/types'
import { sessionFileAddress } from '@deepseek-ai/dsh-util-workspace-path'
import { expect, it, onTestFinished, vi } from 'vitest'
import { localDragResource } from '../src/file-drag.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
async function fixture() {
const root = await mkdtemp(join(tmpdir(), 'dsh-host-drag-'))
@@ -17,7 +18,7 @@ async function fixture() {
await ctx.plugin(LocalFileSystem, { cwd: root })
await ctx.plugin(SessionStore)
ctx.provide('sandboxPolicy', { workspaceRoot: root } as never)
const id = SessionId('file-drag-test')
const id = brandString<SessionId>('file-drag-test')
ctx.sessions.create(id, { meta: { cwd: root, origin: 'subagent' } })
const path = join(root, '报告.pdf')
const bytes = Buffer.from('%PDF-1.4\n原始内容\n%%EOF')
@@ -1,7 +1,8 @@
import { Context } from '@deepseek-ai/cordis'
import { JobId, JobRegistry } from '@deepseek-ai/dsh-jobs'
import { type JobId, JobRegistry } from '@deepseek-ai/dsh-jobs'
import { brandString } from '@deepseek-ai/dsh-brand'
import type { JobStatus, JobView } from '@deepseek-ai/dsh-jobs'
import { SessionId } from '@deepseek-ai/dsh-session/types'
import type { SessionId } from '@deepseek-ai/dsh-session/types'
import type { SessionActivity } from '@deepseek-ai/dsh-workspace'
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
import { installDesktopQuitInspection } from '../src/quit-inspection.ts'
@@ -21,7 +22,7 @@ class RosterOnlyJobRegistry extends JobRegistry {
start(): never { throw new Error('unsupported') }
list(caller?: SessionId): JobView[] {
return (jobs.get(caller) ?? []).map((status, index) => ({
id: JobId(`bash-${index + 1}`),
id: brandString<JobId>(`bash-${index + 1}`),
kind: 'bash',
label: 'sleep 60',
...caller === undefined ? {} : { owner: caller },
@@ -40,7 +41,7 @@ class RosterOnlyJobRegistry extends JobRegistry {
}
function agent(id: string, status: 'idle' | 'running' = 'idle'): AgentState {
return { id: SessionId(id), status, inbox: { nextTurn: [], nextStep: [] } }
return { id: brandString<SessionId>(id), status, inbox: { nextTurn: [], nextStep: [] } }
}
beforeEach(() => {
@@ -60,7 +61,7 @@ afterEach(async () => { await ctx.fiber.dispose() })
describe('Desktop Host quit inspection', () => {
it('reports neither active nor scheduled work for idle loaded sessions', async () => {
agents.push(agent('quiet'))
activity.set(SessionId('quiet'), [{ kind: 'turn' }])
activity.set(brandString<SessionId>('quiet'), [{ kind: 'turn' }])
expect(await inspect()).toEqual({ activeTasks: false, scheduledTasks: false })
})
@@ -77,14 +78,14 @@ describe('Desktop Host quit inspection', () => {
const asked: SessionId[] = []
ctx.on('workspace/session-activity', async ({ sessionId }, next) => { asked.push(sessionId); return next() })
agents.push(agent('first'), agent('second'), agent('third'))
activity.set(SessionId('second'), [{ kind: 'schedule', items: [{ id: 'reminder-1', label: 'stand-up' }] }])
activity.set(brandString<SessionId>('second'), [{ kind: 'schedule', items: [{ id: 'reminder-1', label: 'stand-up' }] }])
expect(await inspect()).toEqual({ activeTasks: false, scheduledTasks: true })
expect(asked).toEqual([SessionId('first'), SessionId('second')])
expect(asked).toEqual([brandString<SessionId>('first'), brandString<SessionId>('second')])
})
it('reports both when a running session also holds a reminder', async () => {
agents.push(agent('both', 'running'))
activity.set(SessionId('both'), [{ kind: 'job', items: [{ id: 'bash-1' }] }, { kind: 'schedule', items: [{ id: 'reminder-2' }] }])
activity.set(brandString<SessionId>('both'), [{ kind: 'job', items: [{ id: 'bash-1' }] }, { kind: 'schedule', items: [{ id: 'reminder-2' }] }])
expect(await inspect()).toEqual({ activeTasks: true, scheduledTasks: true })
})
+1
View File
@@ -55,6 +55,7 @@
"@deepseek-ai/cordis": "workspace:~"
},
"devDependencies": {
"@deepseek-ai/dsh-brand": "workspace:*",
"@deepseek-ai/dsh-app-boot": "workspace:*",
"@deepseek-ai/dsh-client-ui-settings-general": "workspace:*",
"@deepseek-ai/dsh-client-ui-sidebar-browser": "workspace:*",
+2 -2
View File
@@ -45,8 +45,8 @@
en: b42f103358d0dfd7
zh: a534164ad9eb00da
/desktop-packaging/runtime-file-selection-and-installation-checks:
en: a92b8fda03ae3f19
zh: 5b2f0b4e1cad1745
en: da4669b98c79ee48
zh: d007e87f13ff54d3
/desktop-packaging/desktop-runtime-preparation:
en: 84be38ab3136fff7
zh: bb4ed12ee0e1dfa0
+1 -1
View File
@@ -252,7 +252,7 @@ Desktop packs workspace packages locally and installs external dependencies thro
The [Electron shell file list](../scripts/electron-builder-config.mjs) excludes recognized JavaScript/CSS/TypeScript source maps and TypeScript build caches from the separate `resources/app.asar/node_modules` dependency collection. These exclusions preserve runtime code, native modules, WASM, data files (including ordinary `.map` assets), licenses, and notices; [shell archive tests](../tests/shell-file-selection.spec.ts) check retained bytes and exclusions.
The [Office conversion provider](../../../packages/document/office-kit/README.md) is a Host service mounted by web-app, so every application that loads web-app, including `dsh web` and Desktop, provides it together with the [Office tools](../../../packages/document/tool-office/README.md). The provider [resolves the Kit's engine itself](../../../packages/document/office-kit/README.md#understand-the-implementation), including the mapping of native engine manifests to unpacked physical directories. Desktop packaging only carries and unpacks the engine: it carries the target’s declared native engine, or WASM when the kit declares no matching native target, and preparation rejects a missing target engine before packaging. The complete Office dependencies, including the JavaScript libraries and the selected engine’s executables, data, licenses, and notices, are unpacked under `resources/app.asar.unpacked/dsh/node_modules/`. The Desktop shell passes the primary runtime location to the Host in [main.ts](../src/main.ts), and the Host sets it as `DSH_PRIMARY_RUNTIME`; neither passes a Kit location. Office skills are available in every application that loads web-app, and Desktop reads them from the skill package inside `resources/app.asar`; only Desktop mounts the bundled Python environment (`workspace-dependencies`). On macOS, the native helper receives the JIT entitlement required by [LibreOffice’s UNO bridge](https://github.com/LibreOffice/core/blob/master/sysui/desktop/macosx/hardened_runtime.xcent.in). The Computer Use helper applications under `@deepseek-ai/dsh-experimental-cua-macos/native/bin` are also unpacked whole under `resources/app.asar.unpacked/dsh/node_modules/`, and the provider opens that copy.
The [Office conversion provider](../../../packages/document/office-kit/README.md) is a Host service mounted by web-app, so every application that loads web-app, including `dsh web` and Desktop, provides it together with the [Office tools](../../../packages/document/tool-office/README.md). The provider [resolves the Kit's engine itself](../../../packages/document/office-kit/README.md#understand-the-implementation), including the mapping of native engine manifests to unpacked physical directories. Desktop packaging only carries and unpacks the engine: it carries the target’s declared native engine, or WASM when the kit declares no matching native target, and preparation rejects a missing target engine before packaging. The complete Office dependencies, including the JavaScript libraries and the selected engine’s executables, data, licenses, and notices, are unpacked under `resources/app.asar.unpacked/dsh/node_modules/`. The Desktop shell passes the primary runtime location to the Host in [main.ts](../src/main.ts), and the Host sets it as `DSH_PRIMARY_RUNTIME`; neither passes a Kit location. Office skills are available in every application that loads web-app, and Desktop reads them from the skill package inside `resources/app.asar`; only Desktop mounts the bundled Python environment (`workspace-dependencies`). On macOS, the native helper receives the JIT entitlement required by [LibreOffice’s UNO bridge](https://github.com/LibreOffice/core/blob/master/sysui/desktop/macosx/hardened_runtime.xcent.in). The Computer Use helper applications under `@deepseek-ai/dsh-cua-macos/native/bin` are also unpacked whole under `resources/app.asar.unpacked/dsh/node_modules/`, and the provider opens that copy.
The packaged application runs compiled JavaScript and pre-generated Typert metadata; it does not compile TypeScript plugins. Source-level debugger navigation and editor declarations remain available in development packages. [Copy-policy tests](../tests/runtime-file-policy.spec.ts) cover exclusions and retained assets; The [payload smoke](../tests/fixtures/runtime-payload-smoke.mjs) runs under Electron RunAsNode before the Host smoke and final inventory verification. The payload smoke resolves the search tool’s ripgrep executable and verifies text search and file enumeration. Signed Windows builds run these checks after dependency signing; other builds run them during `prepare:dsh`. The [Host smoke](../scripts/smoke-runtime.ts) creates DOCX, XLSX, and PPTX inputs with bundled Python and runs each through the real Office provider: PDF conversion, PNG rendering, conversion to the matching OpenDocument format, and, for XLSX, recalculation, checking each output's signature. Every assembled application, including directory and unsigned builds, repeats the payload and Host checks against ASAR. Archive integrity checks compare the complete archived descriptor with preparation, file bytes and membership in both archive and unpacked trees, recorded executable flags for archived files, and physical permissions for unpacked files. Conversion failures stop packaging before a release record is written; macOS DMG/ZIP builds run these checks before notarization.
+1 -1
View File
@@ -252,7 +252,7 @@ Desktop 在本地打包工作区包,并通过目标捆绑的 Node 和 pnpm 安
[Electron 外壳文件清单](../scripts/electron-builder-config.mjs)从单独收集的 `resources/app.asar/node_modules` 依赖中排除已识别的 JavaScript/CSS/TypeScript source map 和 TypeScript 构建缓存。这些排除规则保留运行时代码、原生模块、WASM、数据文件(包括普通 `.map` 资源)、许可证和 notices;[外壳归档测试](../tests/shell-file-selection.spec.ts)检查保留文件的字节和排除项。
[Office 转换提供方](../../../packages/document/office-kit/README.zh.md)是 web-app 挂载的 Host 服务,因此所有加载 web-app 的应用(包括 `dsh web` 和 Desktop)都提供它以及 [Office 工具](../../../packages/document/tool-office/README.zh.md)。该提供方[自行解析 Kit 的引擎](../../../packages/document/office-kit/README.zh.md#understand-the-implementation),包括把原生引擎清单映射到解包后的实体目录。Desktop 打包只负责携带和解包引擎:携带目标声明的原生引擎;kit 未声明匹配的原生目标时携带 WASM;目标引擎缺失时,准备阶段在打包前拒绝。完整的 Office 依赖(包括 JavaScript 库以及所选引擎的可执行文件、数据、许可证和声明)解包到 `resources/app.asar.unpacked/dsh/node_modules/` 下。Desktop 壳在 [main.ts](../src/main.ts) 中把主运行时位置传给 Host,由 Host 设为 `DSH_PRIMARY_RUNTIME`;两者都不传 Kit 位置。所有加载 web-app 的应用都提供 Office 技能,Desktop 从 `resources/app.asar` 内的技能包读取它们;只有 Desktop 挂载内置 Python 环境(`workspace-dependencies`)。在 macOS 上,原生 helper 获得 [LibreOffice UNO 桥](https://github.com/LibreOffice/core/blob/master/sysui/desktop/macosx/hardened_runtime.xcent.in)所需的 JIT 权限。`@deepseek-ai/dsh-experimental-cua-macos/native/bin` 下的 Computer Use helper 应用也整体解包到 `resources/app.asar.unpacked/dsh/node_modules/` 下,提供方打开该副本。
[Office 转换提供方](../../../packages/document/office-kit/README.zh.md)是 web-app 挂载的 Host 服务,因此所有加载 web-app 的应用(包括 `dsh web` 和 Desktop)都提供它以及 [Office 工具](../../../packages/document/tool-office/README.zh.md)。该提供方[自行解析 Kit 的引擎](../../../packages/document/office-kit/README.zh.md#understand-the-implementation),包括把原生引擎清单映射到解包后的实体目录。Desktop 打包只负责携带和解包引擎:携带目标声明的原生引擎;kit 未声明匹配的原生目标时携带 WASM;目标引擎缺失时,准备阶段在打包前拒绝。完整的 Office 依赖(包括 JavaScript 库以及所选引擎的可执行文件、数据、许可证和声明)解包到 `resources/app.asar.unpacked/dsh/node_modules/` 下。Desktop 壳在 [main.ts](../src/main.ts) 中把主运行时位置传给 Host,由 Host 设为 `DSH_PRIMARY_RUNTIME`;两者都不传 Kit 位置。所有加载 web-app 的应用都提供 Office 技能,Desktop 从 `resources/app.asar` 内的技能包读取它们;只有 Desktop 挂载内置 Python 环境(`workspace-dependencies`)。在 macOS 上,原生 helper 获得 [LibreOffice UNO 桥](https://github.com/LibreOffice/core/blob/master/sysui/desktop/macosx/hardened_runtime.xcent.in)所需的 JIT 权限。`@deepseek-ai/dsh-cua-macos/native/bin` 下的 Computer Use helper 应用也整体解包到 `resources/app.asar.unpacked/dsh/node_modules/` 下,提供方打开该副本。
打包应用运行编译后的 JavaScript 和预生成的 Typert 元数据,不编译 TypeScript 插件。源码级调试导航和编辑器声明仍可从开发包中获取。[复制规则测试](../tests/runtime-file-policy.spec.ts)覆盖排除项和保留资源;[产物 smoke](../tests/fixtures/runtime-payload-smoke.mjs) 在 Host smoke 和最终清单验证之前,使用 Electron RunAsNode 执行。产物 smoke 解析搜索工具使用的 ripgrep 可执行文件,并验证文本搜索和文件枚举。Windows 签名构建在依赖签名后运行这些检查;其他构建在 `prepare:dsh` 中运行。[Host smoke](../scripts/smoke-runtime.ts) 使用捆绑的 Python 创建 DOCX、XLSX 和 PPTX 输入,并通过真实 Office 提供方逐一执行:PDF 转换、PNG 渲染、转换为对应的 OpenDocument 格式,以及针对 XLSX 的重算,检查每个输出的签名。每个组装后的应用(包括目录包和未签名构建)都会针对 ASAR 重复产物和 Host 检查。归档完整性检查将归档内完整描述符与准备结果比对,并核对归档和解包目录中的文件内容与清单、归档内文件记录的执行标志,以及解包文件的物理权限。转换失败会在写入发布记录前终止打包;macOS DMG/ZIP 构建在公证前执行这些检查。
@@ -79,7 +79,7 @@ export function createElectronBuilderConfig(
`**/node_modules/@deepseek-ai/libreoffice-kit-${resolvedPlatform}-${resolvedArch}/**/*`,
// LaunchServices opens the Computer Use helper as an application, so every file of its bundles stays on disk.
// Both architectures ship: they form one notarized payload whose manifest staging verifies as a whole.
'**/node_modules/@deepseek-ai/dsh-experimental-cua-macos/native/bin/**/*']
'**/node_modules/@deepseek-ai/dsh-cua-macos/native/bin/**/*']
const windowsSigner = packagesWindows && !unsigned
? createWindowsTokenSigner({
certificateFile: env.DSH_DESKTOP_WINDOWS_CER_FILE,
+1 -1
View File
@@ -16,7 +16,7 @@ const MACH_O_MAGICS = new Set(['cafebabe', 'cafebabf', 'cefaedfe', 'cffaedfe', '
* `native/bin/darwin-<arch>/<generation>/<name>.app`. Other bundles, such as LibreOffice's unsigned application,
* are not matched and keep per-file runtime signing.
*/
const CUA_HELPER_BUNDLE = /^(node_modules\/@deepseek-ai\/dsh-experimental-cua-macos\/native\/bin\/darwin-[^/]+\/[^/]+\/[^/]+\.app)\//u
const CUA_HELPER_BUNDLE = /^(node_modules\/@deepseek-ai\/dsh-cua-macos\/native\/bin\/darwin-[^/]+\/[^/]+\/[^/]+\.app)\//u
function magic(path: string): string {
const descriptor = openSync(path, 'r')
@@ -9,7 +9,7 @@ import { expect, it, onTestFinished } from 'vitest'
import { pnpmCommand } from '../../../scripts/release/process.ts'
const repository = resolve(import.meta.dirname, '../../..')
const providerName = '@deepseek-ai/dsh-experimental-cua-macos'
const providerName = '@deepseek-ai/dsh-cua-macos'
const windowsProvider = '@deepseek-ai/dsh-cua-windows'
const bundleName = '@deepseek-ai/dsh-cua-bundle'
const readManifest = async (path: string): Promise<Record<string, unknown>> =>
+5 -4
View File
@@ -1,7 +1,8 @@
import { Context } from '@deepseek-ai/cordis'
import { JobId, JobRegistry } from '@deepseek-ai/dsh-jobs'
import { type JobId, JobRegistry } from '@deepseek-ai/dsh-jobs'
import { brandString } from '@deepseek-ai/dsh-brand'
import type { JobStatus, JobView } from '@deepseek-ai/dsh-jobs'
import { SessionId } from '@deepseek-ai/dsh-session/types'
import type { SessionId } from '@deepseek-ai/dsh-session/types'
import { Readable } from 'node:stream'
import type { IncomingMessage, ServerResponse } from 'node:http'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
@@ -20,7 +21,7 @@ class RosterOnlyJobRegistry extends JobRegistry {
start(): never { throw new Error('unsupported') }
list(caller?: SessionId): JobView[] {
return (jobs.get(caller) ?? []).map((status, index) => ({
id: JobId(`bash-${index + 1}`),
id: brandString<JobId>(`bash-${index + 1}`),
kind: 'bash',
label: 'sleep 60',
...caller === undefined ? {} : { owner: caller },
@@ -50,7 +51,7 @@ beforeEach(() => {
afterEach(async () => { await ctx.fiber.dispose() })
function idleAgent(): AgentState { return { id: SessionId('update-task-owner'), status: 'idle', inbox: { nextTurn: [], nextStep: [] } } }
function idleAgent(): AgentState { return { id: brandString<SessionId>('update-task-owner'), status: 'idle', inbox: { nextTurn: [], nextStep: [] } } }
function request(next: () => Promise<void>) {
const incoming = Readable.from([]) as IncomingMessage
+1 -1
View File
@@ -28,7 +28,7 @@ it('signs Mach-O files in their final locations and verifies each signature', as
expect(verifyMacOSRuntimeCode).toHaveBeenCalledWith(join(path, 'addon.node'), identity)
})
const helperBundle = 'node_modules/@deepseek-ai/dsh-experimental-cua-macos/native/bin/darwin-arm64/generation/DSH Computer Use.app'
const helperBundle = 'node_modules/@deepseek-ai/dsh-cua-macos/native/bin/darwin-arm64/generation/DSH Computer Use.app'
function machO(path: string): void {
mkdirSync(join(path, '..'), { recursive: true })
writeFileSync(path, Buffer.from('cffaedfe00000000', 'hex'))
+1 -1
View File
@@ -73,7 +73,7 @@ describe('desktop macOS release signature', () => {
expect(config.asarUnpack).toEqual(expect.arrayContaining([
'**/*.{node,dylib,dll,so,exe}',
'**/@vscode/ripgrep-*/bin/rg',
'**/node_modules/@deepseek-ai/dsh-experimental-cua-macos/native/bin/**/*',
'**/node_modules/@deepseek-ai/dsh-cua-macos/native/bin/**/*',
]))
expect(config).toMatchObject({
appId: RELEASE_ENVIRONMENT.DSH_DESKTOP_APP_ID,
@@ -99,7 +99,7 @@ describe('desktop package-set selection', () => {
})
})
const macProvider = '@deepseek-ai/dsh-experimental-cua-macos'
const macProvider = '@deepseek-ai/dsh-cua-macos'
const cuaBundle = '@deepseek-ai/dsh-cua-bundle'
const targetManifests = () => new Map<string, PackedDesktopPackage>([
['@deepseek-ai/dsh', packed('@deepseek-ai/dsh', { dependencies: { [cuaBundle]: '1.0.0' } })],
@@ -157,8 +157,8 @@ it('copies no macOS tarball into the Windows package set', () => {
}
const output = join(root, 'output')
prepareDesktopPackageSet([inputs], output, { platform: 'win32', arch: 'x64' })
expect(readdirSync(join(output, DESKTOP_PACKAGES_DIR))).not.toContain('dsh-experimental-cua-macos.tgz')
expect(readdirSync(join(output, DESKTOP_PACKAGES_DIR))).not.toContain('dsh-cua-macos.tgz')
prepareDesktopPackageSet([inputs], output, { platform: 'darwin', arch: 'arm64' })
expect(readFileSync(join(output, DESKTOP_PACKAGES_DIR, 'dsh-experimental-cua-macos.tgz')))
.toEqual(readFileSync(join(inputs, 'dsh-experimental-cua-macos.tgz')))
expect(readFileSync(join(output, DESKTOP_PACKAGES_DIR, 'dsh-cua-macos.tgz')))
.toEqual(readFileSync(join(inputs, 'dsh-cua-macos.tgz')))
})
+1
View File
@@ -31,6 +31,7 @@
},
"license": "MIT",
"devDependencies": {
"@deepseek-ai/dsh-brand": "workspace:*",
"@deepseek-ai/cordis-plugin-group": "workspace:~",
"@deepseek-ai/dsh-client-modules": "workspace:*",
"@deepseek-ai/dsh-client-store": "workspace:*",
+3 -2
View File
@@ -16,7 +16,7 @@ import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import {
SESSION_FORMAT_VERSION, SessionId as sessionId, type SessionEvent, type SessionHeader, type SessionId,
SESSION_FORMAT_VERSION, type SessionId as sessionId, type SessionEvent, type SessionHeader, type SessionId,
} from '@deepseek-ai/dsh-session'
import { SUBAGENT_DESCRIPTOR_VERSION } from '@deepseek-ai/dsh-subagent'
import { createSystemMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
@@ -27,6 +27,7 @@ import {
import { openSettings,
connectFreshWorkspace, newEnglishPage, saveFailureShot, writeComposerDraft,
} from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/agent-preset-selection', import.meta.url))
const HERO_EXPECTED = join(SNAPSHOT_DIR, 'hero.expected.md')
@@ -35,7 +36,7 @@ const HEADER_EXPECTED = join(SNAPSHOT_DIR, 'header.expected.md')
const MODE = webSnapshotMode()
const SEED_ID = 'agent-preset-selection-web-e2e'
const SEED_TIME = 1784974100000
const SEEDED_CHILD_ID = sessionId('agent-preset-selection-child')
const SEEDED_CHILD_ID = brandString<sessionId>('agent-preset-selection-child')
const SEEDED_CHILD_CREATED_AT = 1784974100100
/** A project skill only a preset that mounts `skill-filesystem` can discover. */
const SKILL_NAME = 'preset-catalog-demo'
+8 -7
View File
@@ -6,8 +6,9 @@ import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed, onTestFinished, vi } from 'vitest'
import type {} from '@deepseek-ai/dsh-agent-team'
import { SessionId } from '@deepseek-ai/dsh-session'
import { CommandId } from '@deepseek-ai/dsh-commands/brand'
import type { SessionId } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
import type { CommandId } from '@deepseek-ai/dsh-commands/brand'
import { createMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import {
acknowledgeReloadConnectionLoss, assertFixtureInventory, captureStableAria, compareOrRefreshGolden,
@@ -193,7 +194,7 @@ describe('web e2e: agent teamwork panel', () => {
const agent = scaffold.ctx.agents.list()[0]!
expect(scaffold.ctx.commands.list(agent).some(command => command.name === 'team')).toBe(false)
expect(agent.session.ownEvents().filter(event => event.type === 'command/run' || event.type === 'command/done')).toEqual([])
const other = await scaffold.ctx.agents.create({ sessionId: SessionId('other-team-mode'), agentOptions: agent.options })
const other = await scaffold.ctx.agents.create({ sessionId: brandString<SessionId>('other-team-mode'), agentOptions: agent.options })
expect(scaffold.ctx.agentTeams.isEnabled(other.agent)).toBe(false)
await other.dispose()
const beforeReload = tripwire.warnings.length
@@ -268,7 +269,7 @@ describe('web e2e: agent teamwork panel', () => {
const projectionReads = vi.spyOn(scaffold.ctx.sessionController, 'projections')
onTestFinished(() => { projectionReads.mockRestore() })
const agent = scaffold.ctx.agents.list()[0]!
const memberId = SessionId('team-panel-researcher')
const memberId = brandString<SessionId>('team-panel-researcher')
agent.session.append('subagent/catalog', {
version: 2, childId: memberId, childCreatedAt: Date.now(), mode: 'external',
label: RESEARCHER_DESCRIPTION,
@@ -913,12 +914,12 @@ it.each(RECEIPT_LOCALES)('toggles teamwork in $language without command records
// Historical receipts are read-only fixtures, not invocations of a registered command.
for (const args of [' on', ' off']) {
const commandId = CommandId(`historical-team-${args.trim()}`)
const commandId = brandString<CommandId>(`historical-team-${args.trim()}`)
agent.session.append('command/run', { commandId, name: 'team', args, source: { kind: 'user' } })
agent.session.append('command/done', { commandId, kind: 'success', text: 'Team mode saved.' })
}
agent.session.append('command/run', {
commandId: CommandId('historical-team-pending'), name: 'team', args: ' on', source: { kind: 'user' },
commandId: brandString<CommandId>('historical-team-pending'), name: 'team', args: ' on', source: { kind: 'user' },
})
await scaffold.ctx.sessions.flush(agent.session)
const historicalCommands = commandEvents()
@@ -938,7 +939,7 @@ it.each(RECEIPT_LOCALES)('renders historical Team failures in $language without
await withTeamReceiptPage(locale, async (page, scaffold, tripwire) => {
const agent = scaffold.ctx.agents.list()[0]
if (agent === undefined) throw new Error('Team failure fixture has no Agent')
const commandId = CommandId('historical-team-error')
const commandId = brandString<CommandId>('historical-team-error')
agent.session.append('command/run', { commandId, name: 'team', args: ' invalid', source: { kind: 'user' } })
agent.session.append('command/done', { commandId, kind: 'error', text: 'Use /team on or /team off.' })
await scaffold.ctx.sessions.flush(agent.session)
+7 -6
View File
@@ -8,9 +8,10 @@ import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import type { Agent } from '@deepseek-ai/dsh-agent'
import { ToolCallId } from '@deepseek-ai/dsh-llm'
import { SessionId } from '@deepseek-ai/dsh-session'
import { JobId } from '@deepseek-ai/dsh-jobs'
import type { ToolCallId } from '@deepseek-ai/dsh-llm'
import type { SessionId } from '@deepseek-ai/dsh-session'
import type { JobId } from '@deepseek-ai/dsh-jobs'
import { brandString } from '@deepseek-ai/dsh-brand'
import {
assertFixtureInventory, captureStableAria, compareOrRefreshGolden,
launchWebScaffold, seedSession, watchConsole, webSnapshotMode, type WebScaffold,
@@ -72,7 +73,7 @@ describe.skipIf(MODE === 'record')('web e2e: background job list', () => {
// Opening the session drives the Host's ordinary Agent resolution; the
// job owner must be that exact live instance, never a second one.
// `expect.poll` is test-scoped, so this hook polls by hand.
agent = await liveAgent(scaffold, SessionId(SEED_ID))
agent = await liveAgent(scaffold, brandString<SessionId>(SEED_ID))
}, 120_000)
afterAll(async () => {
@@ -90,7 +91,7 @@ describe.skipIf(MODE === 'record')('web e2e: background job list', () => {
const started = await executeToolFixture(scaffold.ctx, {
signal: new AbortController().signal,
callId: ToolCallId('background-job-list-e2e'),
callId: brandString<ToolCallId>('background-job-list-e2e'),
name: 'bash',
arguments: { command: COMMAND, description: 'Hold a background slot open', run_in_background: true },
agent,
@@ -98,7 +99,7 @@ describe.skipIf(MODE === 'record')('web e2e: background job list', () => {
const reported = started.content.map(block => block.type === 'text' ? block.text : '').join('')
const matched = /\bbash-[0-9a-f]{16}\b/.exec(reported)
if (matched === null) throw new Error(`background bash reported no job id: ${reported}`)
const jobId = JobId(matched[0])
const jobId = brandString<JobId>(matched[0])
await trigger.waitFor({ timeout: 15_000 })
expect(await trigger.locator('[data-state="ongoing"]').count()).toBe(1)
+5 -4
View File
@@ -4,10 +4,11 @@ import { mkdir } from 'node:fs/promises'
import { join } from 'node:path'
import { chromium, type Browser, type Page } from 'playwright'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionEvent } from '@deepseek-ai/dsh-session'
import { launchWebScaffold, watchConsole, type WebScaffold } from './scaffold.ts'
import { newEnglishPage } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
/** A preset these blank Sessions recorded that the deployment no longer declares. */
const UNDECLARED = 'liangshen'
@@ -91,7 +92,7 @@ describe('web e2e: blank Session reuse under the requested preset', () => {
}
it('reuses a blank recorded under an undeclared preset under the default when startup connects its Workspace', async () => {
const stale = SessionId('blank-undeclared')
const stale = brandString<SessionId>('blank-undeclared')
await storeBlank(stale, 'undeclared', UNDECLARED)
const page = await openPage()
@@ -105,7 +106,7 @@ describe('web e2e: blank Session reuse under the requested preset', () => {
})
it('restores a saved blank under the preset it recorded', async () => {
const picked = SessionId('blank-picked')
const picked = brandString<SessionId>('blank-picked')
await storeBlank(picked, 'picked', 'minimal')
const page = await openPage(picked)
@@ -115,7 +116,7 @@ describe('web e2e: blank Session reuse under the requested preset', () => {
})
it('restores a saved blank under the default once its recorded preset is undeclared', async () => {
const saved = SessionId('saved-undeclared')
const saved = brandString<SessionId>('saved-undeclared')
await storeBlank(saved, 'saved-undeclared', UNDECLARED)
const page = await openPage(saved)
+5 -4
View File
@@ -2,13 +2,14 @@
import { chromium, type Browser, type Page } from 'playwright'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionHandle } from '@deepseek-ai/dsh-session-persistence'
import { launchWebScaffold, watchConsole, type WebScaffold } from './scaffold.ts'
import { newEnglishPage } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const HELD = SessionId('blank-held')
const FREE = SessionId('blank-free')
const HELD = brandString<SessionId>('blank-held')
const FREE = brandString<SessionId>('blank-free')
describe.each([false, true])('web e2e: selected blank writer held: %s', (held) => {
let scaffold: WebScaffold
@@ -66,7 +67,7 @@ describe.each([false, true])('web e2e: selected blank writer held: %s', (held) =
const id = await selected(first)
return id !== undefined && (!held || id !== HELD)
}).toBe(true)
const selectedId = SessionId((await selected(first))!)
const selectedId = brandString<SessionId>((await selected(first))!)
expect(selectedId).not.toBe(FREE)
await expect.poll(() => scaffold.ctx.agents.get(selectedId)).toBeDefined()
if (!held) {
@@ -9,7 +9,8 @@ import { join } from 'node:path'
import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { ToolCallId, expandAssistantStream, type StreamChunk } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type ToolCallId, expandAssistantStream, type StreamChunk } from '@deepseek-ai/dsh-llm'
import type { ReplayEntry, ReplayOverrideDoc } from '@deepseek-ai/dsh-llm-replay'
import type { SessionEvent, SessionId } from '@deepseek-ai/dsh-session'
import {
@@ -34,7 +35,7 @@ interface TurnSpec {
readonly firstMarker: string
readonly doneMarker: string
readonly deltas: readonly string[]
readonly callId?: ReturnType<typeof ToolCallId>
readonly callId?: ToolCallId
readonly toolResultMarker?: string
}
@@ -83,7 +84,7 @@ function turnSpec(index: number): TurnSpec {
firstMarker,
doneMarker,
deltas,
callId: ToolCallId(`continuous-chat-tool-${id}`),
callId: brandString<ToolCallId>(`continuous-chat-tool-${id}`),
toolResultMarker: `CONTINUOUS_CHAT_TOOL_RESULT_${id}`,
}
}
+3 -2
View File
@@ -19,10 +19,11 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import type { StreamChunk } from '@deepseek-ai/dsh-llm'
import { createAssistantMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import type { ReplayEntry } from '@deepseek-ai/dsh-llm-replay'
import { SessionId, type SessionEvent } from '@deepseek-ai/dsh-session'
import type { SessionId, SessionEvent } from '@deepseek-ai/dsh-session'
import { createChatScrollFixture } from './chat-scroll-fixture.ts'
import { launchWebScaffold, parseSeedFixture, seedSession, watchConsole, webSnapshotMode, type WebScaffold } from './scaffold.ts'
import { newEnglishPage, openSettings } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
declare global {
interface Window {
@@ -248,7 +249,7 @@ async function sendFromOpenedGroup(browser: Browser, id: string, answerParagraph
const tripwire = watchConsole(page)
await page.setViewportSize({ width: 1170, height: 826 })
await page.emulateMedia({ reducedMotion: 'no-preference' })
const session = SessionId(`open-fold-${id}`)
const session = brandString<SessionId>(`open-fold-${id}`)
const { log, search } = seededLog(id, answerParagraphs)
await seedSession(scaffold, log, session)
await page.goto(scaffold.authenticatedUrl, { waitUntil: 'load' })
+4 -3
View File
@@ -10,7 +10,7 @@ import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import type { StreamChunk } from '@deepseek-ai/dsh-llm'
import type { ReplayEntry, ReplayOverrideDoc } from '@deepseek-ai/dsh-llm-replay'
import { SessionId, type SessionEvent } from '@deepseek-ai/dsh-session'
import type { SessionId, SessionEvent } from '@deepseek-ai/dsh-session'
import { createChatScrollFixture } from './chat-scroll-fixture.ts'
import {
launchWebScaffold,
@@ -20,6 +20,7 @@ import {
type WebScaffold,
} from './scaffold.ts'
import { conversationContextKey, expandOwningTurnProcess, loadEarlierChatPage, newEnglishPage, saveFailureShot } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const MODE = webSnapshotMode()
const SESSION_ID = 'chat-long-interactions-e2e'
@@ -174,10 +175,10 @@ describe('web e2e: long Chat interaction contract', () => {
it.skipIf(MODE === 'record')('keeps heterogeneous rows and their actions bound to exact semantic identities', async () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-chat-long-interactions'))
await expect.poll(
() => scaffold.ctx.agents.get(SessionId(SESSION_ID)) !== undefined,
() => scaffold.ctx.agents.get(brandString<SessionId>(SESSION_ID)) !== undefined,
{ timeout: 10_000 },
).toBe(true)
const source = scaffold.ctx.agents.get(SessionId(SESSION_ID))
const source = scaffold.ctx.agents.get(brandString<SessionId>(SESSION_ID))
if (source === undefined) throw new Error('seeded long-history agent is not attached')
const toolUserMarker = FIXTURE.markers.user(TOOL_TURN)
+7 -6
View File
@@ -10,11 +10,12 @@ import type { Browser, Page, Route } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import type { StreamChunk } from '@deepseek-ai/dsh-llm'
import { ToolCallId, createAssistantMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type ToolCallId, createAssistantMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import type { AssistantStreamFrame } from '@deepseek-ai/dsh-agent'
import type { ReplayEntry, ReplayOverrideDoc } from '@deepseek-ai/dsh-llm-replay'
import type { SessionEvent } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, SessionId } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, type SessionId } from '@deepseek-ai/dsh-session'
import { createChatScrollFixture, type ChatScrollFixture } from './chat-scroll-fixture.ts'
import {
launchWebScaffold,
@@ -28,7 +29,7 @@ import { expandOwningTurnProcess, newEnglishPage, openSettings, saveFailureShot
const MODE = webSnapshotMode()
const HISTORY_SESSION_ID = 'chat-scroll-history-e2e'
const TOOL_SESSION_ID = SessionId('chat-scroll-tool-e2e')
const TOOL_SESSION_ID = brandString<SessionId>('chat-scroll-tool-e2e')
const RESTORE_SESSION_A_ID = 'chat-scroll-restore-a-e2e'
const RESTORE_SESSION_B_ID = 'chat-scroll-restore-b-e2e'
const REPLAY_CONTEXT_WINDOW = 10_000_000
@@ -39,7 +40,7 @@ const LIVE_TEXT_PROMPT = 'CHAT_SCROLL_LIVE_USER Continue this long conversation
const LIVE_TEXT_FIRST = 'CHAT_SCROLL_LIVE_FIRST'
const LIVE_TEXT_DONE = 'CHAT_SCROLL_LIVE_DONE'
const LIVE_TOOL_PROMPT = 'CHAT_SCROLL_TOOL_USER Run the requested diagnostic and then summarize it.'
const LIVE_TOOL_CALL_ID = ToolCallId('chat-scroll-live-tool-call')
const LIVE_TOOL_CALL_ID = brandString<ToolCallId>('chat-scroll-live-tool-call')
const LIVE_TOOL_RESULT = 'CHAT_SCROLL_LIVE_TOOL_RESULT'
const LIVE_TOOL_FIRST = 'CHAT_SCROLL_TOOL_STREAM_FIRST'
const LIVE_TOOL_DONE = 'CHAT_SCROLL_TOOL_STREAM_DONE'
@@ -47,7 +48,7 @@ const TOOL_READY_FILE = '.chat-scroll-tool-ready'
const TOOL_RELEASE_FILE = '.chat-scroll-tool-release'
const INPUTS_SESSION_ID = 'chat-scroll-inputs-e2e'
const RAIL_SESSION_ID = 'chat-scroll-rail-e2e'
const FLING_SESSION_ID = SessionId('chat-scroll-fling-e2e')
const FLING_SESSION_ID = brandString<SessionId>('chat-scroll-fling-e2e')
const LIVE_FLING_PROMPT = 'CHAT_SCROLL_FLING_USER Keep streaming while I fling back through older output.'
const LIVE_FLING_FIRST = 'CHAT_SCROLL_FLING_STREAM_FIRST'
const LIVE_FLING_DONE = 'CHAT_SCROLL_FLING_STREAM_DONE'
@@ -749,7 +750,7 @@ describe('web e2e: long Chat scroll contract', () => {
yield chunk
}
})
const resolved = await world.scaffold.ctx.sessionController.resolveAgent(SessionId(`visible-fold-${scenario.name}`))
const resolved = await world.scaffold.ctx.sessionController.resolveAgent(brandString<SessionId>(`visible-fold-${scenario.name}`))
if ('error' in resolved) throw resolved.error
// Maintenance keeps the accepted message in the inbox, so its echo folds the earlier work before the Turn starts.
const promptGate = Promise.withResolvers<undefined>()
+5 -4
View File
@@ -2,8 +2,9 @@
// generated through Session so pagination exercises the same event shapes as
// persisted conversations, while unique markers identify semantic rows
// without depending on CSS-module names or virtualizer DOM positions.
import { brandString } from '@deepseek-ai/dsh-brand'
import {
ToolCallId,
type ToolCallId,
createAssistantMessage,
createSystemMessage,
createToolResultMessage,
@@ -12,7 +13,7 @@ import {
import {
SESSION_FORMAT_VERSION,
Session,
SessionId,
type SessionId,
} from '@deepseek-ai/dsh-session'
// Carries the session/title event declaration into this fixture builder.
import type {} from '@deepseek-ai/dsh-session-title'
@@ -114,7 +115,7 @@ function appendToolStep(
): void {
const calls = [1, 2].map((index) => {
const marker = markers.tool(turn, index)
const callId = ToolCallId(`chat-scroll-${suffix(turn)}-${String(index)}`)
const callId = brandString<ToolCallId>(`chat-scroll-${suffix(turn)}-${String(index)}`)
const args = JSON.stringify({
command: `printf '${marker}\\n'`,
description: marker,
@@ -190,7 +191,7 @@ function fixtureLog(session: Session): string {
export function createChatScrollFixture(options: ChatScrollFixtureOptions): ChatScrollFixture {
const turns = options.turns ?? DEFAULT_TURNS
const markers = markerHelpers(options.markerPrefix)
const session = Session.create(SessionId(`chat-scroll-${options.markerPrefix.toLowerCase()}-template`))
const session = Session.create(brandString<SessionId>(`chat-scroll-${options.markerPrefix.toLowerCase()}-template`))
for (let turn = 1; turn <= turns; turn += 1) {
session.append('turn/start', {
@@ -21,8 +21,9 @@ import { fileURLToPath } from 'node:url'
import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, SessionId } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, type SessionId } from '@deepseek-ai/dsh-session'
import type { JsonValue } from '@deepseek-ai/dsh-util-values'
import type {} from '@deepseek-ai/dsh-session-title'
import {
@@ -210,7 +211,7 @@ const CALLS: GalleryCall[] = [
* the tripwire stays clean; the varying origin is tokenized in the golden).
*/
function galleryFixture(imageUrl: string): string {
const session = Session.create(SessionId('clickable-links-gallery-source'))
const session = Session.create(brandString<SessionId>('clickable-links-gallery-source'))
session.append('turn/start', { turn: 1 })
const user = session.append('user/message', createUserMessage({
content: text('Assemble the link gallery: write the report and styles, inspect the sources, and summarize.'),
@@ -224,7 +225,7 @@ function galleryFixture(imageUrl: string): string {
session.append('step/start', { turn: 1, step: 1 })
const calls = CALLS.map((call, index) => ({
...call,
callId: ToolCallId(`gallery-${String(index)}`),
callId: brandString<ToolCallId>(`gallery-${String(index)}`),
argsJson: JSON.stringify(call.args),
}))
session.append('assistant/message', {
+5 -4
View File
@@ -9,8 +9,9 @@ import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import * as yaml from 'js-yaml'
import { entryListSchema } from '@deepseek-ai/cordis-plugin-include'
import { brandString } from '@deepseek-ai/dsh-brand'
import {
createAssistantMessage, createMessage, createUserMessage, ToolCallId,
createAssistantMessage, createMessage, createUserMessage, type ToolCallId,
type AssistantStreamRecord, type TokenUsage,
} from '@deepseek-ai/dsh-llm'
import {
@@ -100,7 +101,7 @@ describe('web e2e: Statistics view', () => {
agent.session.append('tool/call', {
turn: 1,
step: 1,
callId: ToolCallId('call-1'),
callId: brandString<ToolCallId>('call-1'),
name: 'read',
arguments: JSON.stringify({ file_path: '/work/notes.md' }),
})
@@ -110,8 +111,8 @@ describe('web e2e: Statistics view', () => {
message: createMessage({
role: 'tool',
content: [{ type: 'text', text: 'one\ntwo' }],
source: { kind: 'tool', callId: ToolCallId('call-1') },
toolCallId: ToolCallId('call-1'),
source: { kind: 'tool', callId: brandString<ToolCallId>('call-1') },
toolCallId: brandString<ToolCallId>('call-1'),
}),
}, { surfaceOp: 'append' })
agent.session.append('step/end', { turn: 1, step: 1 })
+5 -4
View File
@@ -2,8 +2,9 @@
import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, SessionId } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, type SessionId } from '@deepseek-ai/dsh-session'
import type { JsonValue } from '@deepseek-ai/dsh-util-values'
import { launchWebScaffold, seedSession, watchConsole, type WebScaffold } from './scaffold.ts'
import { expandTurnProcesses, newEnglishPage, saveFailureShot } from './support.ts'
@@ -28,13 +29,13 @@ function layoutFixture(): string {
name: 'edit', args: { file_path: 'long.txt', old_string: oldText, new_string: newText },
result: 'Edited long.txt', meta: { diffs: [{ path: 'long.txt', oldText, newText }] },
})
const session = Session.create(SessionId('code-card-layout-source'))
const session = Session.create(brandString<SessionId>('code-card-layout-source'))
session.append('turn/start', { turn: 1 })
session.append('user/message', createUserMessage({
content: [{ type: 'text', text: 'Inspect the source windows and edit the long lines.' }], source: { kind: 'user' },
}), { surfaceOp: 'append' })
session.append('step/start', { turn: 1, step: 1 })
const namedCalls = calls.map((call, index) => ({ ...call, id: ToolCallId(`layout-${index}`), arguments: JSON.stringify(call.args) }))
const namedCalls = calls.map((call, index) => ({ ...call, id: brandString<ToolCallId>(`layout-${index}`), arguments: JSON.stringify(call.args) }))
session.append('assistant/message', {
stream: [], turn: 1, step: 1,
message: createAssistantMessage({
+3 -2
View File
@@ -4,14 +4,15 @@ import { fileURLToPath } from 'node:url'
import { chromium, type Browser, type Page } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, SessionId, SessionSeq } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, type SessionId, SessionSeq } from '@deepseek-ai/dsh-session'
import {
captureStableAria, compareOrRefreshGolden, launchWebScaffold,
watchConsole, webSnapshotMode, type WebScaffold,
} from './scaffold.ts'
import { newEnglishPage, saveFailureShot } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SESSION_ID = SessionId('cold-inbox-web-e2e')
const SESSION_ID = brandString<SessionId>('cold-inbox-web-e2e')
const PENDING_TEXT = 'Accepted before the Host restarted'
const EXPECTED = fileURLToPath(new URL('./expected/cold-blank-session/queue.expected.md', import.meta.url))
+4 -3
View File
@@ -7,12 +7,13 @@ import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { deriveReplayScript } from '@deepseek-ai/dsh-llm-replay'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import {
assertFixtureInventory, captureStableAria, compareOrRefreshGolden, fixtureUserPrompts,
launchWebScaffold, parseSeedFixture, readPersistedEvents, seedSession, watchConsole, webSnapshotMode, type WebScaffold,
} from './scaffold.ts'
import { newEnglishPage, openSettings, pinBrowserClock, pinHostClock, saveFailureShot, WEB_FIXTURE_TIME, writeComposerDraft } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('../../../snapshots/web/collapse-timing', import.meta.url))
const SEED = fileURLToPath(new URL('../../../snapshots/web/seeded-history/session.v3.jsonl', import.meta.url))
@@ -146,7 +147,7 @@ describe.skipIf(MODE === 'record')('web e2e: recorded collapse timing', () => {
const input = page.locator('[data-composer-input]').last()
await writeComposerDraft(page, input, prompt)
await expectProcess(1, true)
const resolved = await scaffold.ctx.sessionController.resolveAgent(SessionId(SEED_ID))
const resolved = await scaffold.ctx.sessionController.resolveAgent(brandString<SessionId>(SEED_ID))
if ('error' in resolved) throw resolved.error
// Maintenance keeps the accepted message in the inbox, so its echo stays before the Turn starts.
const release = Promise.withResolvers<undefined>()
@@ -168,7 +169,7 @@ describe.skipIf(MODE === 'record')('web e2e: recorded collapse timing', () => {
await expect.poll(() => page.locator('[data-streaming="true"]').count(), UI_WAIT).toBe(0)
await expectProcess(1, false)
await expectProcess(2, true)
const persisted = await readPersistedEvents(scaffold, SessionId(SEED_ID))
const persisted = await readPersistedEvents(scaffold, brandString<SessionId>(SEED_ID))
expect(persisted.filter(event => event.type === 'turn/end').map(event => event.data)).toEqual([
{ turn: 1, reason: { kind: 'completed' } },
{ turn: 2, reason: { kind: 'completed' } },
+9 -8
View File
@@ -10,8 +10,9 @@ import type { Browser, CDPSession, Locator, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import type { StreamChunk } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import {
ToolCallId,
type ToolCallId,
createAssistantMessage,
createSystemMessage,
createToolResultMessage,
@@ -23,7 +24,7 @@ import type { SessionEvent, SessionSeq } from '@deepseek-ai/dsh-session'
import {
SESSION_FORMAT_VERSION,
Session,
SessionId,
type SessionId,
} from '@deepseek-ai/dsh-session'
// Carries the session/title event declaration into the fixture builder.
import type {} from '@deepseek-ai/dsh-session-title'
@@ -243,7 +244,7 @@ function appendToolStep(
toolCount: number,
): void {
const calls = Array.from({ length: toolCount }, (_, index) => {
const callId = ToolCallId(`perf-call-${String(turn)}-${String(index)}`)
const callId = brandString<ToolCallId>(`perf-call-${String(turn)}-${String(index)}`)
const args = JSON.stringify({
turn,
index,
@@ -332,7 +333,7 @@ function fixtureLog(session: Session): string {
}
function smallSidebarFixture(): string {
const session = Session.create(SessionId('perf-small-template'))
const session = Session.create(brandString<SessionId>('perf-small-template'))
session.append('turn/start', {
turn: 1,
})
@@ -355,7 +356,7 @@ function smallSidebarFixture(): string {
}
function longHistoryFixture(): string {
const session = Session.create(SessionId(LONG_SESSION_ID))
const session = Session.create(brandString<SessionId>(LONG_SESSION_ID))
for (let turn = 1; turn <= LONG_HISTORY_TURNS; turn += 1) {
session.append('turn/start', {
turn,
@@ -482,7 +483,7 @@ function soakTurn(index: number): ConversationTurnSpec {
}
function toolStream(index: number, marker: string): StreamChunk[] {
const callId = ToolCallId(`performance-tool-${marker.toLowerCase()}-${String(index)}`)
const callId = brandString<ToolCallId>(`performance-tool-${marker.toLowerCase()}-${String(index)}`)
const args = JSON.stringify({
command: `printf '${marker}\\n'`,
description: `Emit performance marker ${String(index)}`,
@@ -1342,7 +1343,7 @@ describe('manual web performance: complex workspace and history', () => {
startingTurns: DEFAULT_HISTORY_TURNS,
turnCount: COMPARISON_TURNS,
turnSpec: comparisonTurn,
expectedSessionId: SessionId(LONG_SESSION_ID),
expectedSessionId: brandString<SessionId>(LONG_SESSION_ID),
})
expect(conversation.toolTurns).toBe(2)
console.info(`WEB_PERF_RESULT ${JSON.stringify({
@@ -1388,7 +1389,7 @@ describe('manual web performance: complex workspace and history', () => {
startingTurns: LONG_HISTORY_TURNS,
turnCount: COMPARISON_TURNS,
turnSpec: comparisonTurn,
expectedSessionId: SessionId(LONG_SESSION_ID),
expectedSessionId: brandString<SessionId>(LONG_SESSION_ID),
})
expect(conversation.toolTurns).toBe(2)
console.info(`WEB_PERF_RESULT ${JSON.stringify({
+3 -2
View File
@@ -6,10 +6,11 @@ import { chromium, type Browser, type Locator, type Page } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed, vi } from 'vitest'
import { createLaunchEnvironmentSnapshot } from '@deepseek-ai/dsh-launch-environment'
import { createAssistantMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, SessionId } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, Session, type SessionId } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-session-title'
import { launchWebScaffold, seedSession, watchConsole, type WebScaffold } from './scaffold.ts'
import { saveFailureShot } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const GIF = Buffer.from('R0lGODdhMAAgAIEAAEtu5gAAAAAAAAAAACwAAAAAMAAgAEAIQQABCBxIsKDBgwgTKlzIsKHDhxAjSpxIsaLFixgzatzIsaPHjyBDihxJsqTJkyhTqlzJsqXLlzBjypxJs6bNmQEBADs=', 'base64')
async function menuLabels(menu: Locator): Promise<string[]> {
@@ -20,7 +21,7 @@ async function menuLabels(menu: Locator): Promise<string[]> {
}))
}
function fixture(title: string): string {
const session = Session.create(SessionId('context-menus-source'))
const session = Session.create(brandString<SessionId>('context-menus-source'))
session.append('turn/start', { turn: 1 })
const user = session.append('user/message', createUserMessage({ content: [{ type: 'text', text: 'Show the output.' }], source: { kind: 'user' } }), { surfaceOp: 'append' })
session.append('session/title', { title, messageSeqs: [user.seq], source: { kind: 'fallback' } })
+3 -2
View File
@@ -3,13 +3,14 @@ import { readFile } from 'node:fs/promises'
import { fileURLToPath } from 'node:url'
import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { SessionId } from '@deepseek-ai/dsh-session/types'
import type { SessionId } from '@deepseek-ai/dsh-session/types'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import {
captureStableAria, compareOrRefreshGolden, launchWebScaffold, seedSession, readPersistedEvents, parseSeedFixture, realizeSeedFixture,
watchConsole, webSnapshotMode, type WebScaffold,
} from './scaffold.ts'
import { expandOwningTurnProcess, newEnglishPage } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const FIXTURE = fileURLToPath(new URL('../../../snapshots/web/cordis-tool-round/session.v3.jsonl', import.meta.url))
const UI_EXPECTED = fileURLToPath(new URL('./expected/cordis-history/ui.expected.md', import.meta.url))
@@ -39,7 +40,7 @@ describe.skipIf(MODE === 'record')('web e2e: historical Cordis cards', () => {
})
it('renders recorded definition source and lifecycle results without registering retired tools', async () => {
const persisted = await readPersistedEvents(scaffold, SessionId(SEED_ID))
const persisted = await readPersistedEvents(scaffold, brandString<SessionId>(SEED_ID))
const expected = parseSeedFixture(realizeSeedFixture(scaffold, await readFile(FIXTURE, 'utf8'), SEED_ID)).events
const tools = (events: typeof persisted) => events.filter(event => event.type === 'tool/call' || event.type === 'tool/result')
.map(event => ({ type: event.type, data: event.data }))
+8 -7
View File
@@ -5,13 +5,14 @@ import { join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { chromium, type Browser } from 'playwright'
import { readProfileManifest } from '@deepseek-ai/dsh-app-boot'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-ptc-runtime'
import type {} from '@deepseek-ai/dsh-agent-preset-registry'
import { load } from 'js-yaml'
import { expect, it, vi } from 'vitest'
import { captureStableAria, compareOrRefreshGolden, launchWebScaffold, webSnapshotMode, type WebScaffold } from './scaffold.ts'
import { connectFreshWorkspaceZh, ZH_BROWSER_LOCALE } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
// This fixture exercises the macOS provider’s permission setup.
it.skipIf(process.platform !== 'darwin').each([
@@ -26,7 +27,7 @@ it.skipIf(process.platform !== 'darwin').each([
try {
const patch = join(directory, 'native-fixture.yml')
// Permission inspection fails against this non-helper executable; activation still permits dismissing setup.
await writeFile(patch, JSON.stringify([{ id: 'cua', config: { helperPath: process.execPath } }]))
await writeFile(patch, JSON.stringify([{ id: 'cua-macos', config: { helperPath: process.execPath } }]))
const defaults = join(directory, 'script-defaults')
if (script) {
await mkdir(defaults)
@@ -62,7 +63,7 @@ it.skipIf(process.platform !== 'darwin').each([
let toggle = card.getByRole('switch', { name: '启用 Computer Use', exact: true })
const originalAgent = scaffold.ctx.agents.list()[0]!
const ptcAgent = (await scaffold.ctx.agents.create({
sessionId: SessionId('cua-existing-ptc'),
sessionId: brandString<SessionId>('cua-existing-ptc'),
setup: async (ctx) => { await scaffold.ctx.agentPresets.mount(ctx, 'ptc') },
})).agent
expect(scaffold.ctx.tools.schemas(ptcAgent).some(tool => tool.name === 'cua')).toBe(false)
@@ -136,7 +137,7 @@ it.skipIf(process.platform !== 'darwin').each([
expect(scaffold.ctx.tools.schemas(originalAgent).some(tool => tool.name === 'cua_run_code')).toBe(preset !== 'ptc')
}
const child = await scaffold.ctx.agents.create({
sessionId: SessionId('cua-child'),
sessionId: brandString<SessionId>('cua-child'),
setup: (ctx) => { scaffold.ctx.agentPresets.composeFrom(ctx, ptcAgent.ctx) },
})
expect(scaffold.ctx.tools.schemas(child.agent).some(tool => tool.name === 'cua')).toBe(true)
@@ -161,14 +162,14 @@ it.skipIf(process.platform !== 'darwin').each([
]))
}
const freshDefault = (await scaffold.ctx.agents.create({
sessionId: SessionId('cua-new-default'),
sessionId: brandString<SessionId>('cua-new-default'),
setup: async (ctx) => { await scaffold.ctx.agentPresets.mount(ctx) },
})).agent
expect(scaffold.ctx.agentPresets.composedPreset(freshDefault.ctx)).toBe(initialDefault)
expect(scaffold.ctx.tools.schemas(freshDefault).some(tool => tool.name === 'cua')).toBe(false)
expect(scaffold.ctx.tools.schemas(freshDefault).some(tool => tool.name === 'cua_run_code')).toBe(true)
const fresh = (await scaffold.ctx.agents.create({
sessionId: SessionId('cua-new-ptc'),
sessionId: brandString<SessionId>('cua-new-ptc'),
setup: async (ctx) => { await scaffold.ctx.agentPresets.mount(ctx, 'ptc') },
})).agent
expect(scaffold.ctx.agentPresets.composedPreset(fresh.ctx)).toBe('ptc')
@@ -253,7 +254,7 @@ it.skipIf(process.platform !== 'darwin').each([
expect(scaffold.ctx.agentPresets.composedPreset(originalAgent.ctx)).toBe(initialDefault)
expect(scaffold.ctx.agentPresets.composedPreset(freshDefault.ctx)).toBe(initialDefault)
const confirmed = (await scaffold.ctx.agents.create({
sessionId: SessionId('cua-confirmed-default'),
sessionId: brandString<SessionId>('cua-confirmed-default'),
setup: async (ctx) => { await scaffold.ctx.agentPresets.mount(ctx) },
})).agent
expect(scaffold.ctx.agentPresets.composedPreset(confirmed.ctx)).toBe('ptc')
+4 -3
View File
@@ -3,7 +3,8 @@ import { mkdir, mkdtemp, readFile, readdir, rm, writeFile } from 'node:fs/promis
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { ToolCallId } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import type { ToolCallId } from '@deepseek-ai/dsh-llm'
import type {} from '@deepseek-ai/dsh-user-approval'
import type {} from '@deepseek-ai/dsh-agent-preset-registry'
import { chromium, type Browser } from 'playwright'
@@ -35,7 +36,7 @@ it.skipIf(process.platform !== 'darwin')('keeps system requests pending until fr
await writeFile(join(root, 'observe-helper'), '')
const fixturePatch = join(root, 'native-fixture.yml')
// Keep the external helper override above bundle order changes when CUA is re-enabled.
await writeFile(fixturePatch, JSON.stringify([{ id: 'cua', config: { helperPath: helper } }]))
await writeFile(fixturePatch, JSON.stringify([{ id: 'cua-macos', config: { helperPath: helper } }]))
const scaffold = await launchWebScaffold({
profile: { packages: [{ dir: bundle, enabled: true }] },
extraOverlayPath: fixturePatch,
@@ -54,7 +55,7 @@ it.skipIf(process.platform !== 'darwin')('keeps system requests pending until fr
scaffold.ctx.approval.setPolicy(agent, 'never')
// Application consent remains independent of the session's tool-approval policy.
const grant = scaffold.ctx.tools.execute({ agent, signal: new AbortController().signal,
calls: [{ type: 'tool-call', id: ToolCallId('cua-app-approval'), name: 'run_code',
calls: [{ type: 'tool-call', id: brandString<ToolCallId>('cua-app-approval'), name: 'run_code',
arguments: JSON.stringify({ code: 'return await tools.cua({ method: "getApp", params: { selector: "Fixture" } })',
description: 'Request application access' }) }] })
const approval = page.locator('[data-approval-key]')
+5 -4
View File
@@ -16,9 +16,10 @@ import { join } from 'node:path'
import type { Browser, Locator, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import { launchWebScaffold, watchConsole, captureStableAria, compareOrRefreshGolden, webSnapshotMode, type WebScaffold } from './scaffold.ts'
import { ZH_BROWSER_LOCALE, connectFreshWorkspaceZh, saveFailureShot } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
/** Points the shipped shared Agent default at this scenario's own route. */
const OVERLAY = fileURLToPath(new URL('./default-model.overlay.yml', import.meta.url))
@@ -39,7 +40,7 @@ describe('web e2e: the composer model switch is the default for later sessions',
/** Create one session and its agent through the same wire face the browser uses. */
const createSession = async (sessionId: string): Promise<string> => {
const response = await scaffold.ctx.sessionController.create({
sessionId: SessionId(sessionId),
sessionId: brandString<SessionId>(sessionId),
cwd: scaffold.workspaceCwd,
})
return response.sessionId
@@ -47,7 +48,7 @@ describe('web e2e: the composer model switch is the default for later sessions',
/** The route the Client derives from the Session projection and Host default. */
const currentOf = (sessionId: string): Promise<unknown> => {
const session = scaffold.ctx.sessions.get(SessionId(sessionId))
const session = scaffold.ctx.sessions.get(brandString<SessionId>(sessionId))
if (session === undefined) throw new Error(`session "${sessionId}" is not live`)
return Promise.resolve(
scaffold.ctx.sessionProjections.snapshot(session).values.modelSelection?.next
@@ -473,7 +474,7 @@ describe('web e2e: the composer model switch is the default for later sessions',
// A session that has already run a turn, spelled as the fact a turn
// leaves behind: its own logged route.
const loggedId = await createSession('default-model-logged')
scaffold.ctx.sessions.get(SessionId(loggedId))?.append('request/header', {
scaffold.ctx.sessions.get(brandString<SessionId>(loggedId))?.append('request/header', {
header: { config: { provider: START_ROUTE, model: START_MODEL } },
reason: 'initial',
})
+6 -5
View File
@@ -14,10 +14,11 @@ import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import type { StreamChunk } from '@deepseek-ai/dsh-llm'
import { ToolCallId, createAssistantMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type ToolCallId, createAssistantMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import type { ReplayEntry } from '@deepseek-ai/dsh-llm-replay'
import {
SESSION_FORMAT_VERSION, SessionId, SessionLogOffset, SessionSeq, type SessionEvent, type SessionHeader,
SESSION_FORMAT_VERSION, type SessionId, SessionLogOffset, SessionSeq, type SessionEvent, type SessionHeader,
} from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-system-prompt'
import { sessionFixtureName } from '@deepseek-ai/dsh-session-snapshot'
@@ -277,7 +278,7 @@ function replyEntry(marker: string): ReplayEntry {
function liveLongTurn(prefix: string): ReplayEntry[] {
const entries: ReplayEntry[] = []
for (let step = 1; step <= LIVE_STEPS; step++) {
const id = ToolCallId(`${prefix.toLowerCase()}-read-${step}`)
const id = brandString<ToolCallId>(`${prefix.toLowerCase()}-read-${step}`)
const args = JSON.stringify({ file_path: READ_FILE })
entries.push({ kind: 'chunks', chunks: [
...textChunks(paragraphs(`${prefix}_STEP_${step}`, 10, `${prefix} narration for step ${step}, paragraph`)),
@@ -525,7 +526,7 @@ function sessionKey(scenario: Case): string {
}
async function createChild(scaffold: WebScaffold, parentId: SessionId, scenario: Case): Promise<SessionId> {
const childId = SessionId(`${sessionKey(scenario)}-child`)
const childId = brandString<SessionId>(`${sessionKey(scenario)}-child`)
const createdAt = Date.now() - 30_000
const header: SessionHeader = {
version: SESSION_FORMAT_VERSION, id: childId, createdAt, isSeeded: false, cwd: scaffold.workspaceCwd,
@@ -598,7 +599,7 @@ async function prepareWorld(browser: Browser, scenario: Case, scaffold: WebScaff
await page.addInitScript(installMeasure)
await page.setViewportSize(scenario.surface === 'main' ? { width: 1280, height: 720 } : { width: 1680, height: 900 })
await page.emulateMedia({ reducedMotion: 'no-preference' })
const sessionId = SessionId(sessionKey(scenario))
const sessionId = brandString<SessionId>(sessionKey(scenario))
if (scenario.surface === 'main') {
const fixture = seededFixture(scenario.id, scenario.bodyParagraphs)
await seedSession(scaffold, fixture.log, sessionId)
+3 -2
View File
@@ -9,13 +9,14 @@ import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import type { StreamChunk } from '@deepseek-ai/dsh-llm'
import type { ReplayEntry } from '@deepseek-ai/dsh-llm-replay'
import { SessionId, type SessionEvent } from '@deepseek-ai/dsh-session'
import type { SessionId, SessionEvent } from '@deepseek-ai/dsh-session'
import {
assertFixtureInventory, captureStableAria, compareOrRefreshGolden,
launchWebScaffold, parseSeedFixture, seedSession,
watchConsole, webSnapshotMode, selectedSessionFixture, type WebScaffold,
} from './scaffold.ts'
import { newEnglishPage, saveFailureShot, writeComposerDraft } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/fork-mid-turn', import.meta.url))
// Borrowed read-only from its recorded-session owner.
@@ -110,7 +111,7 @@ describe('web e2e: exact-boundary fork seeds branch closers and continues', () =
expect(response.ok).toBe(true)
const body = await response.json() as { result: { ok: boolean; value?: { sessionId: string } } }
expect(body.result.ok).toBe(true)
childId = SessionId(body.result.value!.sessionId)
childId = brandString<SessionId>(body.result.value!.sessionId)
const child = scaffold.ctx.sessions.get(childId)
if (child === undefined) throw new Error('fork did not publish a live child session')
+7 -6
View File
@@ -7,9 +7,10 @@ import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import type { Agent } from '@deepseek-ai/dsh-agent'
import { ToolCallId } from '@deepseek-ai/dsh-llm'
import { SessionId } from '@deepseek-ai/dsh-session'
import { JobId } from '@deepseek-ai/dsh-jobs'
import type { ToolCallId } from '@deepseek-ai/dsh-llm'
import type { SessionId } from '@deepseek-ai/dsh-session'
import type { JobId } from '@deepseek-ai/dsh-jobs'
import { brandString } from '@deepseek-ai/dsh-brand'
import {
assertFixtureInventory, compareOrRefreshGolden, launchWebScaffold, seedSession,
watchConsole, webSnapshotMode, type WebScaffold,
@@ -19,7 +20,7 @@ import { newEnglishPage, saveFailureShot } from './support.ts'
const FIXTURE = fileURLToPath(new URL('../../../snapshots/web/fresh-round-trip/session.v3.jsonl', import.meta.url))
const EXPECTED_DIR = fileURLToPath(new URL('./expected/jobs-menu-layering', import.meta.url))
const MODE = webSnapshotMode()
const SEED_ID = SessionId('jobs-menu-layering-web-e2e')
const SEED_ID = brandString<SessionId>('jobs-menu-layering-web-e2e')
// The private scaffold cwd owns the barrier; the loop bounds an orphan's lifetime.
const RELEASE = '.jobs-menu-layering.release'
const COMMAND = `printf 'jobs-menu-%s\\n' output; for _ in $(seq 1 3000); do [ -e ${RELEASE} ] && break; sleep 0.2; done`
@@ -120,7 +121,7 @@ describe.skipIf(MODE === 'record')('web e2e: jobs menu layering', () => {
agent = opened
const started = await executeToolFixture(scaffold.ctx, {
signal: new AbortController().signal,
callId: ToolCallId('jobs-menu-layering-e2e'),
callId: brandString<ToolCallId>('jobs-menu-layering-e2e'),
name: 'bash',
arguments: { command: COMMAND, description: 'Emit output and hold the jobs menu fixture', run_in_background: true },
agent,
@@ -128,7 +129,7 @@ describe.skipIf(MODE === 'record')('web e2e: jobs menu layering', () => {
const reported = started.content.map(block => block.type === 'text' ? block.text : '').join('')
const matched = /\bbash-[0-9a-f]{16}\b/.exec(reported)
if (matched === null) throw new Error(`background bash reported no job id: ${reported}`)
const startedJobId = JobId(matched[0])
const startedJobId = brandString<JobId>(matched[0])
jobId = startedJobId
// Registration precedes shell startup; inspect its output before depending on a live row.
await expect.poll(() => {
+7 -6
View File
@@ -10,9 +10,10 @@ import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import type { Agent } from '@deepseek-ai/dsh-agent'
import { ToolCallId } from '@deepseek-ai/dsh-llm'
import { SessionId } from '@deepseek-ai/dsh-session'
import { JobId } from '@deepseek-ai/dsh-jobs'
import type { ToolCallId } from '@deepseek-ai/dsh-llm'
import type { SessionId } from '@deepseek-ai/dsh-session'
import type { JobId } from '@deepseek-ai/dsh-jobs'
import { brandString } from '@deepseek-ai/dsh-brand'
import {
assertFixtureInventory, captureStableAria, compareOrRefreshGolden,
launchWebScaffold, seedSession, watchConsole, webSnapshotMode, type WebScaffold,
@@ -73,7 +74,7 @@ describe.skipIf(MODE === 'record')('web e2e: live job stream', () => {
// Opening the session drives the Host's ordinary Agent resolution; the
// job owner must be that exact live instance, never a second one.
agent = await liveAgent(scaffold, SessionId(SEED_ID))
agent = await liveAgent(scaffold, brandString<SessionId>(SEED_ID))
}, 120_000)
afterAll(async () => {
@@ -90,7 +91,7 @@ describe.skipIf(MODE === 'record')('web e2e: live job stream', () => {
const started = await executeToolFixture(scaffold.ctx, {
signal: new AbortController().signal,
callId: ToolCallId('live-job-stream-e2e'),
callId: brandString<ToolCallId>('live-job-stream-e2e'),
name: 'bash',
arguments: { command: COMMAND, description: 'Emit one live line then hold', run_in_background: true },
agent,
@@ -98,7 +99,7 @@ describe.skipIf(MODE === 'record')('web e2e: live job stream', () => {
const reported = started.content.map(block => block.type === 'text' ? block.text : '').join('')
const matched = /\bbash-[0-9a-f]{16}\b/.exec(reported)
if (matched === null) throw new Error(`background bash reported no job id: ${reported}`)
const jobId = JobId(matched[0])
const jobId = brandString<JobId>(matched[0])
await expect.poll(() => {
const job = scaffold.ctx.jobs.get(jobId, agent.id)
const output = scaffold.ctx.jobs.readAt(jobId, 0, agent.id).chunks.map(chunk => chunk.text).join('')
+3 -2
View File
@@ -3,7 +3,7 @@ import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { createMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, SessionId } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, Session, type SessionId } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-session-title'
import {
assertFixtureInventory,
@@ -16,6 +16,7 @@ import {
type WebScaffold,
} from './scaffold.ts'
import { newEnglishPage, saveFailureShot, WEB_FIXTURE_TIME } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/markdown-cjk-strong', import.meta.url))
const UI_EXPECTED = fileURLToPath(new URL('./expected/markdown-cjk-strong/ui.expected.md', import.meta.url))
@@ -35,7 +36,7 @@ const CASES = [
/** Build one settled assistant reply covering CJK-adjacent strong punctuation boundaries. */
function markdownFixture(): string {
const session = Session.create(SessionId('markdown-cjk-strong-source'))
const session = Session.create(brandString<SessionId>('markdown-cjk-strong-source'))
session.append('turn/start', { turn: 1 })
const user = session.append('user/message', createUserMessage({
content: [{ type: 'text', text: 'Render adjacent CJK strong emphasis.' }],
+6 -5
View File
@@ -4,8 +4,9 @@ import { basename, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { chromium, type Browser, type Locator, type Page } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, SessionId } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, type SessionId } from '@deepseek-ai/dsh-session'
import { sessionFileAddress } from '@deepseek-ai/dsh-util-workspace-path'
import type {} from '@deepseek-ai/dsh-session-title'
import {
@@ -26,14 +27,14 @@ async function reloadPreview(page: Page, column: Locator, absolutePath: string):
/** Build live test input with a parent-path link and a read result naming the same Host file. */
function parentPathFixture(path: string): string {
const session = Session.create(SessionId('parent-file-links-source'))
const session = Session.create(brandString<SessionId>('parent-file-links-source'))
session.append('turn/start', { turn: 1 })
const user = session.append('user/message', createUserMessage({
content: [{ type: 'text', text: 'Read the parent-path file and link lines 24 and 30.' }], source: { kind: 'user' },
}), { surfaceOp: 'append' })
session.append('session/title', { title: 'Parent file links', messageSeqs: [user.seq], source: { kind: 'fallback' } })
session.append('step/start', { turn: 1, step: 1 })
const callId = ToolCallId('parent-file-read')
const callId = brandString<ToolCallId>('parent-file-read')
const args = JSON.stringify({ file_path: path, offset: 24, limit: 7 })
session.append('assistant/message', {
turn: 1, step: 1, stream: [],
@@ -70,7 +71,7 @@ function parentPathFixture(path: string): string {
/** Build a settled turn whose relative link follows a directory change into a nested checkout. */
function changedDirectoryFixture(path: string): string {
const session = Session.create(SessionId('changed-directory-links-source'))
const session = Session.create(brandString<SessionId>('changed-directory-links-source'))
session.append('turn/start', { turn: 1 })
const user = session.append('user/message', createUserMessage({
content: [{ type: 'text', text: 'Enter the worktree and link its notes.' }], source: { kind: 'user' },
+3 -2
View File
@@ -6,10 +6,11 @@ import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { createLaunchEnvironmentSnapshot } from '@deepseek-ai/dsh-launch-environment'
import { createMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, SessionId } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, Session, type SessionId } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-session-title'
import { launchWebScaffold, seedSession, watchConsole, type WebScaffold } from './scaffold.ts'
import { newEnglishPage, saveFailureShot, WEB_FIXTURE_TIME } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const ALT = 'Rewritten chart'
const chart = (width: number, color: string): string =>
@@ -17,7 +18,7 @@ const chart = (width: number, color: string): string =>
/** Build one closed session whose reply shows `{{cwd}}/chart.svg`. */
function chartFixture(title: string): string {
const session = Session.create(SessionId('markdown-image-refresh-source'))
const session = Session.create(brandString<SessionId>('markdown-image-refresh-source'))
session.append('turn/start', { turn: 1 })
const user = session.append('user/message', createUserMessage({
content: [{ type: 'text', text: 'Draw the chart.' }],
+3 -2
View File
@@ -10,7 +10,7 @@ import { createMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import {
SESSION_FORMAT_VERSION,
Session,
SessionId,
type SessionId,
} from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-session-title'
import {
@@ -24,6 +24,7 @@ import {
type WebScaffold,
} from './scaffold.ts'
import { newEnglishPage, pinBrowserClock, saveFailureShot, WEB_FIXTURE_TIME } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/markdown-images', import.meta.url))
const UI_EXPECTED = fileURLToPath(new URL('./expected/markdown-images/ui.expected.md', import.meta.url))
@@ -82,7 +83,7 @@ async function stopServer(server: Server): Promise<void> {
/** Build one closed session fixture with remote and local image Markdown. */
function markdownImageFixture(remoteUrl: string, outsidePath: string): string {
const session = Session.create(SessionId('markdown-image-source'))
const session = Session.create(brandString<SessionId>('markdown-image-source'))
const eventTimeOrigin = new Date().setHours(12, 0, 0, 0)
session.append('turn/start', { turn: 1 })
const user = session.append('user/message', createUserMessage({
@@ -3,7 +3,7 @@ import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { createMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, SessionId } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, Session, type SessionId } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-session-title'
import {
assertFixtureInventory,
@@ -16,6 +16,7 @@ import {
type WebScaffold,
} from './scaffold.ts'
import { newEnglishPage, saveFailureShot, WEB_FIXTURE_TIME } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/markdown-inline-code-links', import.meta.url))
const UI_EXPECTED = fileURLToPath(new URL('./expected/markdown-inline-code-links/ui.expected.md', import.meta.url))
@@ -26,7 +27,7 @@ const LINK_URL = 'http://127.0.0.1:3199/?demo=1'
/** Build a settled assistant reply with linkable URL code and inert code controls. */
function markdownFixture(linkUrl: string): string {
const session = Session.create(SessionId('markdown-inline-code-links-source'))
const session = Session.create(brandString<SessionId>('markdown-inline-code-links-source'))
session.append('turn/start', { turn: 1 })
const user = session.append('user/message', createUserMessage({
content: [{ type: 'text', text: 'Show the local preview URL.' }],
+3 -2
View File
@@ -26,7 +26,7 @@ import { createMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import {
SESSION_FORMAT_VERSION,
Session,
SessionId,
type SessionId,
} from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-session-title'
import {
@@ -39,6 +39,7 @@ import {
type WebScaffold,
} from './scaffold.ts'
import { newEnglishPage, saveFailureShot } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/markdown-wide-table', import.meta.url))
const GEOMETRY_EXPECTED = fileURLToPath(
@@ -113,7 +114,7 @@ function tablesMarkdown(): string {
/** Build one closed session fixture carrying the tables. */
function wideTableFixture(): string {
const session = Session.create(SessionId('markdown-wide-table-source'))
const session = Session.create(brandString<SessionId>('markdown-wide-table-source'))
const eventTimeOrigin = new Date().setHours(12, 0, 0, 0)
session.append('turn/start', { turn: 1 })
const user = session.append('user/message', createUserMessage({
+3 -2
View File
@@ -3,7 +3,7 @@ import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { createMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, SessionId } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, Session, type SessionId } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-session-title'
import {
assertFixtureInventory,
@@ -16,6 +16,7 @@ import {
type WebScaffold,
} from './scaffold.ts'
import { newEnglishPage, saveFailureShot, WEB_FIXTURE_TIME } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/math-rendering', import.meta.url))
const UI_EXPECTED = fileURLToPath(new URL('./expected/math-rendering/ui.expected.md', import.meta.url))
@@ -25,7 +26,7 @@ const DONE = 'MATH_RENDERING_DONE'
/** Build a settled assistant reply that exercises every supported math delimiter. */
function mathFixture(): string {
const session = Session.create(SessionId('math-rendering-source'))
const session = Session.create(brandString<SessionId>('math-rendering-source'))
session.append('turn/start', {
turn: 1,
})
+4 -3
View File
@@ -10,12 +10,13 @@ import { zstdCompressSync } from 'node:zlib'
import type { Browser, Page, Request as BrowserRequest } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { SESSION_FORMAT_VERSION, SessionId } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, type SessionId } from '@deepseek-ai/dsh-session'
import {
acknowledgeReloadConnectionLoss, assertFixtureInventory, captureStableAria, compareOrRefreshGolden, fixtureUserPrompts,
launchWebScaffold, parseSeedFixture, realizeSeedFixture, renderSeedFixture, seedSession, watchConsole, webSnapshotMode, type WebScaffold,
} from './scaffold.ts'
import { openSettings, newEnglishPage, pinBrowserClock, pinHostClock, saveFailureShot, WEB_FIXTURE_TIME } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('../../../snapshots/web/message-actions', import.meta.url))
// Borrowed read-only: this scenario needs any settled user+assistant pair, not
@@ -439,7 +440,7 @@ describe('web e2e: message IconActions and clocks on settled history', () => {
it.skipIf(MODE === 'record')('forks an unopened current-format Session from its sidebar row', async () => {
onTestFailed(() => saveFailureShot(page, 'screenshots/non-migrating-session-reads/current-cold-fork'))
const id = SessionId('message-actions-current-cold')
const id = brandString<SessionId>('message-actions-current-cold')
await seedSession(scaffold, completedTailFixture(await readFile(SEED, 'utf8')), id)
const warningStart = tripwire.warnings.length
await page.reload({ waitUntil: 'load' })
@@ -459,7 +460,7 @@ describe('web e2e: message IconActions and clocks on settled history', () => {
it.skipIf(MODE === 'record')('guides only a migration-required sidebar fork to opening its source', async () => {
onTestFailed(() => saveFailureShot(page, 'screenshots/non-migrating-session-reads/migration-required-fork'))
const id = SessionId('message-actions-needs-migration')
const id = brandString<SessionId>('message-actions-needs-migration')
const [header, ...events] = realizeSeedFixture(scaffold, await readFile(SEED, 'utf8'), id).trimEnd().split('\n')
.map((line): Record<string, unknown> => JSON.parse(line) as Record<string, unknown>)
expect(header?.version).toBe(3)
+4 -3
View File
@@ -5,13 +5,14 @@ import { readFile } from 'node:fs/promises'
import { fileURLToPath } from 'node:url'
import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import {
acknowledgeReloadConnectionLoss, launchWebScaffold,
seedSession, watchConsole, webSnapshotMode, type WebScaffold,
} from './scaffold.ts'
import { newEnglishPage, saveFailureShot, scrollIntoView } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
// Borrowed read-only: this scenario needs any settled assistant message to
// address, not a new recording (message-actions / sidebar-scrollbar pattern).
@@ -121,7 +122,7 @@ describe('web e2e: durable per-message feedback', () => {
await expect.poll(() => restored.getAttribute('aria-pressed'), { timeout: 15_000 }).toBe('true')
// The retract label sits on the Dislike side: the Like stays unpressed.
await expect.poll(() => cold.getAttribute('aria-pressed'), { timeout: 10_000 }).toBe('false')
const agent = scaffold.ctx.agents.get(SessionId(SEED_ID))
const agent = scaffold.ctx.agents.get(brandString<SessionId>(SEED_ID))
if (agent === undefined) throw new Error('seeded session did not attach an agent')
const puts = agent.session.snapshotEvents().filter(event => event.type === 'feedback/message-put')
expect(puts.map(event => event.type === 'feedback/message-put' ? event.data.item : undefined)).toMatchObject([
@@ -148,7 +149,7 @@ describe('web e2e: durable per-message feedback', () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-header-feedback'))
await openSeededSession()
await page.getByText('DONE', { exact: true }).waitFor({ timeout: 30_000 })
const agent = scaffold.ctx.agents.get(SessionId(SEED_ID))
const agent = scaffold.ctx.agents.get(brandString<SessionId>(SEED_ID))
if (agent === undefined) throw new Error('seeded session did not attach an agent')
const feedbackEvents = () => agent.session.snapshotEvents().filter(event => event.type.startsWith('feedback/'))
const before = feedbackEvents().length
+11 -10
View File
@@ -7,9 +7,10 @@ import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import type { AgentHandle } from '@deepseek-ai/dsh-agent'
import type { SessionAttachmentValue } from '@deepseek-ai/dsh-api-session-controller'
import { ToolCallId, createUserMessage } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type ToolCallId, createUserMessage } from '@deepseek-ai/dsh-llm'
import type { GenerateOptions } from '@deepseek-ai/dsh-llm'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import type { Session } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-agent-preset-registry'
import type {} from '@deepseek-ai/dsh-system-prompt'
@@ -57,7 +58,7 @@ describe('minimal agent preset', () => {
text: 'THIS TEXT MUST NOT REACH THE MODEL.',
})
agentHandle = await scaffold.ctx.agents.create({
sessionId: SessionId('minimal-preset-smoke'),
sessionId: brandString<SessionId>('minimal-preset-smoke'),
meta: { cwd: scaffold.workspaceCwd, agentPreset: 'minimal' },
agentOptions: { provider: 'deepseek-official', model: 'deepseek-v4-flash' },
setup: agentCtx => scaffold.ctx.agentPresets.mount(agentCtx, 'minimal').then(() => undefined),
@@ -105,14 +106,14 @@ describe('minimal agent preset', () => {
const signal = new AbortController().signal
await executeToolFixture(scaffold.ctx, {
signal,
callId: ToolCallId('minimal-bash-state-setup'),
callId: brandString<ToolCallId>('minimal-bash-state-setup'),
name: 'bash',
arguments: { command: `cd ${JSON.stringify(stateDir)} && export DSH_MINIMAL_STATE=PERSISTED` },
agent: agentHandle.agent,
})
const bash = await executeToolFixture(scaffold.ctx, {
signal,
callId: ToolCallId('minimal-bash-state-read'),
callId: brandString<ToolCallId>('minimal-bash-state-read'),
name: 'bash',
arguments: { command: 'printf \'%s:%s\n\' "$DSH_MINIMAL_STATE" "$PWD"' },
agent: agentHandle.agent,
@@ -226,7 +227,7 @@ describe('minimal manual compaction', () => {
yield* next()
})
handle = await scaffold.ctx.agents.create({
sessionId: SessionId('minimal-compact-smoke'),
sessionId: brandString<SessionId>('minimal-compact-smoke'),
meta: { cwd: scaffold.workspaceCwd, agentPreset: 'minimal' },
agentOptions: { provider: 'deepseek-official', model: 'deepseek-v4-flash' },
setup: agentCtx => scaffold.ctx.agentPresets.mount(agentCtx, 'minimal').then(() => undefined),
@@ -370,7 +371,7 @@ describe('minimal image reading', () => {
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC', 'base64',
))
handle = await scaffold.ctx.agents.create({
sessionId: SessionId('minimal-image-smoke'),
sessionId: brandString<SessionId>('minimal-image-smoke'),
meta: { cwd: scaffold.workspaceCwd, agentPreset: 'minimal' },
agentOptions: { provider: 'deepseek-official', model: 'deepseek-v4-flash-vision-exp' },
setup: agentCtx => scaffold.ctx.agentPresets.mount(agentCtx, 'minimal').then(() => undefined),
@@ -420,7 +421,7 @@ describe('minimal image reading', () => {
it.skipIf(MODE === 'record')('reads image bytes and preserves the supplied reference with another Session as the gateway scope', async () => {
const image = handle.agent.session.deriveMessages().flatMap(message => message.content).find(block => block.type === 'image')
if (image?.type !== 'image') throw new Error('minimal read_image produced no durable image')
const unrelated = await scaffold.ctx.agents.create({ sessionId: SessionId('minimal-image-unrelated') })
const unrelated = await scaffold.ctx.agents.create({ sessionId: brandString<SessionId>('minimal-image-unrelated') })
try {
expect(unrelated.agent.session.deriveMessages().flatMap(message => message.content).some(block => block.type === 'image')).toBe(false)
const read = async (attachment: unknown, rpcId: string) => {
@@ -473,7 +474,7 @@ describe('minimal image reading', () => {
// User-only interrupted turns move the recorded image beyond the 50-message initial page without inventing model output.
const laterTurns = Array.from({ length: 52 }, (_, index) =>
interruptedTurn(index + 2, `Later image-history message ${index + 2}`))
const historicalId = SessionId('minimal-image-cold')
const historicalId = brandString<SessionId>('minimal-image-cold')
await seedSession(scaffold, `${recorded}${laterTurns[0]}\n`, historicalId, 'minimal')
expect(scaffold.ctx.agents.get(historicalId)).toBeUndefined()
page = await openSession(historicalId)
@@ -500,7 +501,7 @@ describe('minimal image reading', () => {
const body = await response.json() as { result: { ok: boolean; value?: { sessionId: string } } }
expect(body.result.ok).toBe(true)
if (body.result.value === undefined) throw new Error('image fork did not return a Session ID')
page = await openSession(SessionId(body.result.value.sessionId))
page = await openSession(brandString<SessionId>(body.result.value.sessionId))
card = await imageCard(page)
await expect.poll(() => card.locator('img').first().evaluate(img => img instanceof HTMLImageElement && img.naturalWidth)).toBe(1)
})
+13 -12
View File
@@ -13,11 +13,12 @@ import type { Browser, Page, Response } from 'playwright'
import { chromium } from 'playwright'
import { strFromU8, unzipSync } from 'fflate'
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, onTestFailed, onTestFinished } from 'vitest'
import { ToolCallId, createToolResultMessage } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type ToolCallId, createToolResultMessage } from '@deepseek-ai/dsh-llm'
import type SessionToolResults from '@deepseek-ai/dsh-client-ui-trajectory'
import { defineTool } from '@deepseek-ai/dsh-tools'
import { parseSessionLog } from '@deepseek-ai/dsh-llm-replay'
import { SESSION_FORMAT_VERSION, SessionId, type SessionEvent } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, type SessionId, type SessionEvent } from '@deepseek-ai/dsh-session'
import {
assertFixtureInventory, captureStableAria, compareOrRefreshGolden, fixtureUserPrompts,
launchWebScaffold, recordFixture, seedSession, watchConsole, webSnapshotMode, type WebScaffold,
@@ -500,7 +501,7 @@ describe('web e2e: navigation & panes over a rich seeded session', () => {
await page.getByText('Session copied as Markdown.', { exact: true }).waitFor({ timeout: 30_000 })
expect(await page.evaluate(() => Number(Reflect.get(globalThis, '__dshClipboardWrites')))).toBe(1)
const sourcePath = (await scaffold.ctx.sessionPersistence.stat(SessionId(SEED_ID)))?.location?.path
const sourcePath = (await scaffold.ctx.sessionPersistence.stat(brandString<SessionId>(SEED_ID)))?.location?.path
if (sourcePath === undefined) throw new Error('seeded Session has no materialized artifact location')
expect((await stat(sourcePath)).isFile()).toBe(true)
expect(sourcePath.startsWith(`${scaffold.persistenceRoot}/`)).toBe(true)
@@ -678,15 +679,15 @@ describe('web e2e: navigation & panes over a rich seeded session', () => {
})
it.skipIf(MODE === 'record')('inspects a live tool value without adding it to the Session journal', async () => {
await ensureSeedOpen(page)
await expect.poll(() => scaffold.ctx.agents.get(SessionId(SEED_ID)) !== undefined).toBe(true)
const agent = scaffold.ctx.agents.get(SessionId(SEED_ID))!
await expect.poll(() => scaffold.ctx.agents.get(brandString<SessionId>(SEED_ID)) !== undefined).toBe(true)
const agent = scaffold.ctx.agents.get(brandString<SessionId>(SEED_ID))!
const unregister = scaffold.ctx.tools.register(defineTool({
name: 'live_result_probe', description: 'Live result inspection fixture.', parameters: {},
output: { schema: { type: 'json' }, render: () => [{ type: 'text', text: 'LIVE_RESULT_RENDERED' }] },
execute: async () => ({ answer: 42 }),
}))
onTestFinished(unregister)
const callId = ToolCallId('live-result-probe')
const callId = brandString<ToolCallId>('live-result-probe')
let resultEvent: SessionEvent | undefined
const off = scaffold.ctx.on('session/event', (_session, event) => {
if (event.type === 'tool/result' && event.data.message.toolCallId === callId) resultEvent = event
@@ -728,7 +729,7 @@ describe('web e2e: navigation & panes over a rich seeded session', () => {
onTestFinished(unregisterJson)
const jsonBatch = await scaffold.ctx.tools.execute({
agent, signal: new AbortController().signal, log: { turn: 2, step: 1 },
calls: [{ type: 'tool-call', id: ToolCallId('json-result-probe'), name: 'json_result_probe', arguments: '{}' }],
calls: [{ type: 'tool-call', id: brandString<ToolCallId>('json-result-probe'), name: 'json_result_probe', arguments: '{}' }],
})
expect(jsonBatch.results[0]?.result.isError).toBe(false)
await page.locator('tr[data-kind="tool"]').filter({ hasText: 'json_result_probe' }).click()
@@ -767,7 +768,7 @@ describe('web e2e: navigation & panes over a rich seeded session', () => {
const newer = await scaffold.ctx.tools.execute({
agent, signal: new AbortController().signal,
calls: Array.from({ length: 1000 }, (_, index) => ({
type: 'tool-call' as const, id: ToolCallId(`newer-result-${index}`), name: 'live_result_probe', arguments: '{}',
type: 'tool-call' as const, id: brandString<ToolCallId>(`newer-result-${index}`), name: 'live_result_probe', arguments: '{}',
})),
})
expect(newer.results).toHaveLength(1000)
@@ -785,15 +786,15 @@ describe('web e2e: navigation & panes over a rich seeded session', () => {
it.skipIf(MODE === 'record')('keeps long raw strings and PTC output readable in one result scroller', async () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-long-tool-results'))
await ensureSeedOpen(page)
await expect.poll(() => scaffold.ctx.agents.get(SessionId(SEED_ID)) !== undefined).toBe(true)
const agent = scaffold.ctx.agents.get(SessionId(SEED_ID))!
await expect.poll(() => scaffold.ctx.agents.get(brandString<SessionId>(SEED_ID)) !== undefined).toBe(true)
const agent = scaffold.ctx.agents.get(brandString<SessionId>(SEED_ID))!
agent.session.append('turn/start', { turn: 3 })
onTestFinished(() => {
agent.session.append('step/end', { turn: 3, step: 1 })
agent.session.append('turn/end', { turn: 3, reason: { kind: 'completed' } })
})
agent.session.append('step/start', { turn: 3, step: 1 })
const callId = ToolCallId('long-ptc-result')
const callId = brandString<ToolCallId>('long-ptc-result')
const call = agent.session.append('tool/call', {
turn: 3, step: 1, callId, name: 'run_code',
arguments: JSON.stringify({ code: 'inspect("PTC output")', description: 'Long program output' }),
@@ -831,7 +832,7 @@ describe('web e2e: navigation & panes over a rich seeded session', () => {
onTestFinished(unregister)
const batch = await scaffold.ctx.tools.execute({
agent, signal: new AbortController().signal, log: { turn: 3, step: 1 },
calls: [{ type: 'tool-call', id: ToolCallId(probe.name), name: probe.name, arguments: '{}' }],
calls: [{ type: 'tool-call', id: brandString<ToolCallId>(probe.name), name: probe.name, arguments: '{}' }],
})
expect(batch.results[0]?.result.isError).toBe(false)
}
+5 -4
View File
@@ -8,8 +8,9 @@
import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import { ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SessionId } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import type { SessionId } from '@deepseek-ai/dsh-session'
import type { SubagentSettledMessageSource } from '@deepseek-ai/dsh-subagent'
import { launchWebScaffold, watchConsole, type WebScaffold } from './scaffold.ts'
import { connectFreshWorkspace, newEnglishPage } from './support.ts'
@@ -111,7 +112,7 @@ describe('web e2e: notice Turn after a long Detailed Turn', () => {
source: { kind: 'user' },
}), { surfaceOp: 'append' })
for (let step = 1; step <= TOOL_STEPS; step += 1) {
const callId = ToolCallId(`notice-wake-${String(step)}`)
const callId = brandString<ToolCallId>(`notice-wake-${String(step)}`)
const args = JSON.stringify({ command: `diagnose ${String(step)}`, description: `Diagnostic ${String(step)}` })
session.append('assistant/message', {
stream: [],
@@ -171,7 +172,7 @@ describe('web e2e: notice Turn after a long Detailed Turn', () => {
form: 'notice',
summary: 'Background subagent finished.',
stopReason: 'completed',
senderSessionId: SessionId('notice-wake-child'),
senderSessionId: brandString<SessionId>('notice-wake-child'),
}
const notice = createUserMessage({
content: [{ type: 'text', text: 'Background subagent notice-wake-child finished.' }],
+6 -5
View File
@@ -5,13 +5,14 @@ import { dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
import { zstdCompressSync, zstdDecompressSync } from 'node:zlib'
import { describe, expect, it } from 'vitest'
import { SESSION_FORMAT_VERSION, SessionId } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, type SessionId } from '@deepseek-ai/dsh-session'
import { generationLogPath } from '../../../packages/session/session-persistence-jsonl/src/format.ts'
import { scanZstdFrames } from '../../../packages/session/session-persistence-jsonl/src/zstd.ts'
import type {} from '@deepseek-ai/dsh-agent-preset-registry'
import type {} from '@deepseek-ai/dsh-api-session-controller'
import { normalizeSessionSnapshots } from '@deepseek-ai/dsh-session-snapshot'
import { launchWebScaffold, webSnapshotMode } from './scaffold.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const childFixturePath = fileURLToPath(new URL('../../../snapshots/web/preset-migration/session.1.v2.jsonl', import.meta.url))
const fixturePath = fileURLToPath(new URL('../../../snapshots/web/preset-migration/session.v2.jsonl', import.meta.url))
@@ -20,7 +21,7 @@ describe.skipIf(webSnapshotMode() === 'record')('historical preset restoration t
it.each([false, true])('resumes code as PTC (selection events=%s)', async (withSelections) => {
const scaffold = await launchWebScaffold()
try {
const id = SessionId('preset-migration')
const id = brandString<SessionId>('preset-migration')
const fixture = await readFile(fixturePath, 'utf8')
const [fixtureHeader, ...fixtureEvents] = fixture.trimEnd().split('\n')
.map((line): Record<string, unknown> => JSON.parse(line) as Record<string, unknown>)
@@ -33,8 +34,8 @@ describe.skipIf(webSnapshotMode() === 'record')('historical preset restoration t
await mkdir(dirname(predecessor), { recursive: true })
await writeFile(predecessor, source)
const childId = SessionId('preset-migration-child')
const brokenId = SessionId('preset-migration-broken-child')
const childId = brandString<SessionId>('preset-migration-child')
const brokenId = brandString<SessionId>('preset-migration-broken-child')
const childFixture = (await readFile(childFixturePath, 'utf8')).trimEnd().split('\n')
.map((line): Record<string, unknown> => JSON.parse(line) as Record<string, unknown>)
const childRows: Record<string, unknown>[] = childFixture.slice(1).map((row, seq) => ({ ...row, seq, time: seq + 3 }))
@@ -51,7 +52,7 @@ describe.skipIf(webSnapshotMode() === 'record')('historical preset restoration t
data: { turn: 1, reason: { kind: 'completed' } } }) + '\n')),
]))
const brokenSource = await readFile(brokenPath)
const corruptHeaderId = SessionId('preset-migration-corrupt-header')
const corruptHeaderId = brandString<SessionId>('preset-migration-corrupt-header')
const corruptHeaderPath = generationLogPath(scaffold.persistenceRoot, scaffold.workspaceCwd, corruptHeaderId, 2, 'zstd')
const corruptHeaderSource = Buffer.from('invalid Zstandard header frame')
await mkdir(dirname(corruptHeaderPath), { recursive: true })
+6 -5
View File
@@ -4,8 +4,9 @@ import { join } from 'node:path'
import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, SessionId } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, type SessionId } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-session-title'
import {
launchWebScaffold, seedSession, watchConsole, webSnapshotMode, type WebScaffold,
@@ -26,7 +27,7 @@ const WRITES = ['site/report.html', 'a/style.css', 'b/style.css', 'report.txt']
/** Build a settled write turn whose closing prose mentions files in inline code. */
function mentionFixture(): string {
const session = Session.create(SessionId('produced-file-mentions-source'))
const session = Session.create(brandString<SessionId>('produced-file-mentions-source'))
const eventTimeOrigin = new Date().setHours(12, 0, 0, 0)
session.append('turn/start', { turn: 1 })
const user = session.append('user/message', createUserMessage({
@@ -41,7 +42,7 @@ function mentionFixture(): string {
session.append('step/start', { turn: 1, step: 1 })
const calls = WRITES.map((path, index) => ({
path,
callId: ToolCallId(`file-mention-${String(index)}`),
callId: brandString<ToolCallId>(`file-mention-${String(index)}`),
args: JSON.stringify({ file_path: path, content: `content of ${path}\n` }),
}))
session.append('assistant/message', {
@@ -79,7 +80,7 @@ function mentionFixture(): string {
}, { surfaceOp: 'append', sourceEventSeqs: [source.seq] })
}
session.append('working-directory/change', { cwd: '{{cwd}}' })
session.append('deliverables/presented', { turn: 1, callId: ToolCallId('present-child'), files: [{ path: '{{cwd}}/child/report.txt' }] })
session.append('deliverables/presented', { turn: 1, callId: brandString<ToolCallId>('present-child'), files: [{ path: '{{cwd}}/child/report.txt' }] })
session.append('step/end', { turn: 1, step: 1 })
session.append('step/start', { turn: 1, step: 2 })
session.append('assistant/message', {
+4 -3
View File
@@ -5,7 +5,8 @@ import { join } from 'node:path'
import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import { ToolCallId } from '@deepseek-ai/dsh-llm/brand'
import { brandString } from '@deepseek-ai/dsh-brand'
import type { ToolCallId } from '@deepseek-ai/dsh-llm/brand'
import type { ReplayEntry } from '@deepseek-ai/dsh-llm-replay'
import type {} from '@deepseek-ai/dsh-tool-executor-ptc/types'
import type { SessionEvent } from '@deepseek-ai/dsh-session'
@@ -22,8 +23,8 @@ const args = JSON.stringify({
const script: ReplayEntry[] = [
{ kind: 'chunks', chunks: [
{ type: 'block-start', index: 0, blockType: 'tool-call' },
{ type: 'tool-call-delta', index: 0, id: ToolCallId('ptc-question'), name: 'run_code', argumentsDelta: args },
{ type: 'block-end', index: 0, block: { type: 'tool-call', id: ToolCallId('ptc-question'), name: 'run_code', arguments: args } },
{ type: 'tool-call-delta', index: 0, id: brandString<ToolCallId>('ptc-question'), name: 'run_code', argumentsDelta: args },
{ type: 'block-end', index: 0, block: { type: 'tool-call', id: brandString<ToolCallId>('ptc-question'), name: 'run_code', arguments: args } },
{ type: 'finish', reason: { kind: 'tool-calls' } },
] },
{ kind: 'chunks', chunks: [
+5 -4
View File
@@ -13,7 +13,7 @@ import { abbreviateHomePath } from '@deepseek-ai/dsh-util-workspace-path'
import {
SESSION_FORMAT_VERSION,
Session,
SessionId,
type SessionId,
SessionSeq,
} from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-session-reference/types'
@@ -30,6 +30,7 @@ import {
type WebScaffold,
} from './scaffold.ts'
import { connectFreshWorkspace, newEnglishPage, pinBrowserClock, saveFailureShot, WEB_FIXTURE_TIME, writeComposerDraft } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/reference-composer', import.meta.url))
const MENU_EXPECTED = join(SNAPSHOT_DIR, 'menu.expected.md')
@@ -59,7 +60,7 @@ async function replaceReferenceQuery(page: Page, input: Locator, text: string):
/** Build one closed source session with a stable title for reference discovery. */
function sourceSessionFixture(): string {
const session = Session.create(SessionId(SOURCE_SESSION_ID))
const session = Session.create(brandString<SessionId>(SOURCE_SESSION_ID))
session.append('turn/start', {
turn: 1,
})
@@ -90,7 +91,7 @@ function sourceSessionFixture(): string {
/** Build one target log with the direct message durably before its recalled context. */
function targetSessionFixture(): string {
const session = Session.create(SessionId(TARGET_SESSION_ID))
const session = Session.create(brandString<SessionId>(TARGET_SESSION_ID))
session.append('turn/start', { turn: 1 })
const user = session.append('user/message', createUserMessage({
content: [{ type: 'text', text: '@Research notes what changed?' }],
@@ -405,7 +406,7 @@ describe.skipIf(MODE === 'record')('web e2e: file and session references through
await target.waitFor({ timeout: 15_000 })
await target.click()
await page.locator('[data-chat-flow-kind="user"]').filter({ hasText: 'Research notes' }).waitFor({ timeout: 15_000 })
const events = await readPersistedEvents(scaffold, SessionId(TARGET_SESSION_ID))
const events = await readPersistedEvents(scaffold, brandString<SessionId>(TARGET_SESSION_ID))
const inputs = events.filter(event => event.type === 'user/message')
expect(inputs.map(event => event.data.source.kind)).toEqual(['user', 'session-reference'])
expect(inputs[0]?.seq).toBeLessThan(inputs[1]!.seq)
+5 -4
View File
@@ -19,8 +19,8 @@ import { fileURLToPath } from 'node:url'
import type { Browser, Page, Route, WebSocketRoute } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { ToolCallId, expandAssistantStream } from '@deepseek-ai/dsh-llm'
import { SessionId, type Session, type SessionEvent } from '@deepseek-ai/dsh-session'
import { type ToolCallId, expandAssistantStream } from '@deepseek-ai/dsh-llm'
import type { SessionId, Session, SessionEvent } from '@deepseek-ai/dsh-session'
import type { SessionListValue } from '@deepseek-ai/dsh-api-session-controller/types'
import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol'
import {
@@ -31,6 +31,7 @@ import {
import {
connectFreshWorkspace, expandTurnProcesses, newEnglishPage, REPO_ROOT, saveFailureShot,
} from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('../../../snapshots/web/fresh-round-trip', import.meta.url))
const FIXTURE = fileURLToPath(new URL('../../../snapshots/web/fresh-round-trip/session.v3.jsonl', import.meta.url))
@@ -263,13 +264,13 @@ describe('web e2e: fresh round trip through the real assembly', () => {
const probe = await launchWebScaffold()
try {
const handle = await probe.ctx.agents.create({
sessionId: SessionId('web-url-probe'),
sessionId: brandString<SessionId>('web-url-probe'),
setup: agentCtx => probe.ctx.agentPresets.mount(agentCtx).then(() => undefined),
})
try {
const result = await executeToolFixture(probe.ctx, {
signal: AbortSignal.timeout(5_000),
callId: ToolCallId('web-url-probe'),
callId: brandString<ToolCallId>('web-url-probe'),
name: 'bash',
arguments: {
command: 'printf \'%s\\n\' "$DSH_WEB_URL"',
+4 -3
View File
@@ -7,7 +7,7 @@ import type { Browser, Locator, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import type { ReplayOverrideDoc } from '@deepseek-ai/dsh-llm-replay'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import { formatSessionReferenceMention } from '@deepseek-ai/dsh-session-reference'
import { formatQuoteText } from '@deepseek-ai/dsh-client-ui-primitives'
import {
@@ -16,6 +16,7 @@ import {
type WebScaffold,
} from './scaffold.ts'
import { newEnglishPage, pinBrowserClock, pinHostClock, saveFailureShot } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('../../../snapshots/web/rich-text-quotes', import.meta.url))
const BORROWED = fileURLToPath(new URL('../../../snapshots/web/seeded-history/session.jsonl', import.meta.url))
@@ -29,7 +30,7 @@ const LEGACY_DRAFT = JSON.stringify({ draft: 'Imported plain draft', view: 'chat
const SOURCE_TEXT = 'Durable source phrase selected from an earlier message and preserved as structured quote metadata.'
const THINKING_TEXT = 'Settled reasoning source'
const LITERAL_CREDENTIAL = 'sk-1234567890abcdefghijklmnopqrstuvwxyz'
const SESSION_MENTION = formatSessionReferenceMention({ sessionId: SessionId(OTHER_ID), label: 'Quote source' })
const SESSION_MENTION = formatSessionReferenceMention({ sessionId: brandString<SessionId>(OTHER_ID), label: 'Quote source' })
const DIRECT_SYNTAX_TEXT = [
`/quoted-demo ${SESSION_MENTION} ${LITERAL_CREDENTIAL} **literal Markdown**`,
...Array.from({ length: 80 }, (_, index) => `Quote line ${String(index + 1)} contains preserved text.`),
@@ -559,7 +560,7 @@ describe.skipIf(MODE === 'record')('web e2e: rich-text quotes', () => {
} finally {
await page.setViewportSize(viewport)
}
const beforeOffset = scaffold.ctx.agents.get(SessionId(SESSION_ID))!.session.seq
const beforeOffset = scaffold.ctx.agents.get(brandString<SessionId>(SESSION_ID))!.session.seq
const settled = scaffold.whenTurnSettled()
await page.getByRole('button', { name: 'Send message' }).click()
const settledSessionId = await settled
+3 -2
View File
@@ -3,9 +3,10 @@ import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { expect, it } from 'vitest'
import type {} from '@deepseek-ai/dsh-skill'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-agent-preset-registry'
import { launchWebScaffold, type WebScaffold } from './scaffold.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
async function writeSkill(root: string, name: string): Promise<void> {
const bundle = join(root, name)
@@ -45,7 +46,7 @@ it('isolates replay skill discovery from every ambient host root', async () => {
// agent's view — the same scope the `skills/list` Remote resolves for a
// browser request about a session.
const handle = await ctx.agents.create({
sessionId: SessionId('hermetic-skills'),
sessionId: brandString<SessionId>('hermetic-skills'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx).then(() => undefined),
})
try {
+3 -2
View File
@@ -75,7 +75,7 @@ import type { SessionFormatEvent } from '@deepseek-ai/dsh-session-format'
import { sessionFormatCatalog } from '@deepseek-ai/dsh-session-format-catalog'
import {
SESSION_FORMAT_VERSION,
SessionId,
type SessionId,
type Session,
type SessionEvent,
type SessionHeader,
@@ -87,6 +87,7 @@ import type {} from '@deepseek-ai/dsh-agent'
import { provideCmdline } from '@deepseek-ai/dsh-cmdline'
import { startPrefixProxy, type PrefixProxy } from './prefix-proxy.ts'
import { REPO_ROOT, requireBuilt, requireDist } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
type AppBoot = typeof import('@deepseek-ai/dsh-app-boot')
let builtAppBoot: AppBoot | undefined
@@ -1483,7 +1484,7 @@ export async function seedSession(
const createdAt = options.createdAt ?? Date.now() - 60_000
const meta: SessionHeader = {
version: SESSION_FORMAT_VERSION,
id: SessionId(id),
id: brandString<SessionId>(id),
createdAt,
isSeeded: false,
cwd: scaffold.workspaceCwd,
+22 -21
View File
@@ -13,18 +13,19 @@ import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import type { Agent, AgentHandle } from '@deepseek-ai/dsh-agent'
import { entryListSchema } from '@deepseek-ai/cordis-plugin-include'
import { bundlePatchPaths, composeEntries, loadOverlayPatches } from '@deepseek-ai/dsh-app-boot'
import { MessageId, ToolCallId, createUserMessage, LlmAdapter } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type MessageId, type ToolCallId, createUserMessage, LlmAdapter } from '@deepseek-ai/dsh-llm'
import { appendDelivery } from '../../../packages/schedule/schedule/src/delivery-history.ts'
import type { ScheduleTask } from '@deepseek-ai/dsh-schedule'
import type { ContextFormed, GenerateOptions, StreamChunk } from '@deepseek-ai/dsh-llm'
import { SessionId, type SessionEvent } from '@deepseek-ai/dsh-session'
import type { SessionId, SessionEvent } from '@deepseek-ai/dsh-session'
import {
ScheduleId,
createAfterScheduleRecord,
createEveryScheduleRecord,
type EveryScheduleRecord,
type ScheduleRecord,
} from '@deepseek-ai/dsh-schedule'
import type { ScheduleId } from '@deepseek-ai/dsh-schedule/client'
import {
assertFixtureInventory,
captureStableAria,
@@ -105,7 +106,7 @@ async function writeEveryStepOverlay(dir: string): Promise<string> {
}
const CATALOG_NOW = Date.parse('2099-08-25T12:00:00.000Z')
const CATALOG_SESSION_ID = SessionId('schedule-catalog-web-e2e')
const CATALOG_SESSION_ID = brandString<SessionId>('schedule-catalog-web-e2e')
const CATALOG_TITLE = 'Active schedule catalog'
/**
* Task name seeded for each recorded catalog task.
@@ -219,7 +220,7 @@ class BrowserZoneAtAdapter extends LlmAdapter {
this.selectedAt = localAt(target, AT_BROWSER_ZONE)
this.scheduledAt = new Date(target).toISOString()
const argumentsJson = JSON.stringify({ prompt: AT_PROMPT, title: AT_PROMPT, rrule: oneOccurrence(this.selectedAt), target: 'this_session' })
const callId = ToolCallId('schedule-at-browser-zone')
const callId = brandString<ToolCallId>('schedule-at-browser-zone')
yield { type: 'block-start', index: 0, blockType: 'tool-call' }
yield {
type: 'tool-call-delta',
@@ -360,7 +361,7 @@ describe.skipIf(MODE === 'record')('web e2e: conversational reminders', () => {
if (workspace === undefined) throw new Error('connected Web workspace was not registered')
afterHandle = await scaffold.ctx.agents.create({
sessionId: SessionId('schedule-after-web-e2e'),
sessionId: brandString<SessionId>('schedule-after-web-e2e'),
meta: { cwd },
agentOptions: { provider: AFTER_PROVIDER, model: MODEL },
// The reminder tools are preset-level Consumers, so a directly created Agent
@@ -375,7 +376,7 @@ describe.skipIf(MODE === 'record')('web e2e: conversational reminders', () => {
await workspace.attachSession(afterHandle.agent.id)
const afterCreated = await executeToolFixture(scaffold.ctx, {
signal: AbortSignal.timeout(10_000),
callId: ToolCallId('schedule-after-create'),
callId: brandString<ToolCallId>('schedule-after-create'),
name: 'schedule_create',
arguments: { prompt: AFTER_PROMPT, title: AFTER_PROMPT,
rrule: oneOccurrence(localAt(Math.ceil((Date.now() + 5_000) / 1_000) * 1_000, 'UTC')), target: 'this_session' },
@@ -398,7 +399,7 @@ describe.skipIf(MODE === 'record')('web e2e: conversational reminders', () => {
await expect(scaffold.ctx.sessions.flush(afterHandle.agent.session)).resolves.toBe(true)
everyHandle = await scaffold.ctx.agents.create({
sessionId: SessionId('schedule-every-web-e2e'),
sessionId: brandString<SessionId>('schedule-every-web-e2e'),
meta: { cwd },
agentOptions: { provider: EVERY_PROVIDER, model: MODEL },
// The reminder tools are preset-level Consumers, so a directly created Agent
@@ -413,14 +414,14 @@ describe.skipIf(MODE === 'record')('web e2e: conversational reminders', () => {
const seededAt = Date.now()
everyRecords = [
createEveryScheduleRecord(
ScheduleId('schedule-every-primary'),
brandString<ScheduleId>('schedule-every-primary'),
EVERY_PROMPTS[0],
EVERY_INTERVAL_SECONDS,
seededAt - EVERY_FIXTURE_AGE_MS,
'Every primary',
),
createEveryScheduleRecord(
ScheduleId('schedule-every-secondary'),
brandString<ScheduleId>('schedule-every-secondary'),
EVERY_PROMPTS[1],
EVERY_INTERVAL_SECONDS,
seededAt - EVERY_FIXTURE_AGE_MS,
@@ -437,7 +438,7 @@ describe.skipIf(MODE === 'record')('web e2e: conversational reminders', () => {
await workspace.attachSession(everyHandle.agent.id)
const everyListed = await executeToolFixture(scaffold.ctx, {
signal: AbortSignal.timeout(10_000),
callId: ToolCallId('schedule-every-list'),
callId: brandString<ToolCallId>('schedule-every-list'),
name: 'schedule_list',
arguments: {},
agent: everyHandle.agent,
@@ -448,7 +449,7 @@ describe.skipIf(MODE === 'record')('web e2e: conversational reminders', () => {
await expect(scaffold.ctx.sessions.flush(everyHandle.agent.session)).resolves.toBe(true)
atHandle = await scaffold.ctx.agents.create({
sessionId: SessionId('schedule-at-web-e2e'),
sessionId: brandString<SessionId>('schedule-at-web-e2e'),
meta: { cwd },
agentOptions: { provider: AT_PROVIDER, model: MODEL },
// The reminder tools are preset-level Consumers, so a directly created Agent
@@ -843,7 +844,7 @@ describe.skipIf(MODE === 'record')('web e2e: active Schedule catalog', () => {
})
it('manages cross-Session tasks from the sidebar without activating their Sessions', async () => {
const otherSessionId = SessionId('schedule-manager-other-session')
const otherSessionId = brandString<SessionId>('schedule-manager-other-session')
await seedSession(scaffold, await readFile(CATALOG_FIXTURE, 'utf8'), otherSessionId, 'standard')
const other = await scaffold.ctx.schedule.create({ prompt: 'Inspect the second workspace deployment', title: 'Second workspace deployment', timing: { kind: 'at', at: '2099-08-25T12:08:00.000Z' }, target: { kind: 'session', sessionId: otherSessionId } }, otherSessionId)
await page.getByRole('button', { name: 'Automation tasks', exact: true }).click()
@@ -1181,7 +1182,7 @@ describe.skipIf(MODE === 'record')('web e2e: active Schedule catalog', () => {
const domain = scaffold.ctx.storageDomain.get('schedule')
if (domain === undefined) throw new Error('Schedule domain was not opened')
const instant = new Date().toISOString()
const receipt = { scheduledAt: instant, deliveredAt: instant, messageId: MessageId('retention-legacy'), targetSessionId: CATALOG_SESSION_ID }
const receipt = { scheduledAt: instant, deliveredAt: instant, messageId: brandString<MessageId>('retention-legacy'), targetSessionId: CATALOG_SESSION_ID }
await rulesTab.click()
await domain.table('tasks').put(record.id, {
...hostTask(record, CATALOG_SESSION_ID), status: 'ended', lastDelivery: receipt,
@@ -1202,7 +1203,7 @@ describe.skipIf(MODE === 'record')('web e2e: active Schedule catalog', () => {
for (let index = 0; index < 23; index++) {
const time = new Date(Date.now() - (index === 0 ? 40 * 86_400_000 : (23 - index) * 3_600_000)).toISOString()
task = { ...task, ...appendDelivery(task, {
scheduledAt: time, deliveredAt: time, messageId: MessageId(`retention-${index}`), targetSessionId: CATALOG_SESSION_ID,
scheduledAt: time, deliveredAt: time, messageId: brandString<MessageId>(`retention-${index}`), targetSessionId: CATALOG_SESSION_ID,
}, { days: 30, records: 200 }) }
}
expect(task.deliveryHistory?.records).toHaveLength(22)
@@ -1255,7 +1256,7 @@ describe.skipIf(MODE === 'record')('web e2e: active Schedule catalog', () => {
const rrule = `DTSTART;TZID=${timeZone}:${at.date.replaceAll('-', '')}T${time.replaceAll(':', '')}\nRRULE:FREQ=DAILY`
const prompt = 'Inspect the daily calendar rule'
const result = await executeToolFixture(scaffold.ctx, {
signal: AbortSignal.timeout(10_000), callId: ToolCallId('schedule-daily-catalog-create'),
signal: AbortSignal.timeout(10_000), callId: brandString<ToolCallId>('schedule-daily-catalog-create'),
name: 'schedule_create', arguments: { prompt, title: prompt, rrule, target: 'this_session' }, agent,
})
const created = (await scaffold.ctx.schedule.catalog()).find(task => (
@@ -1332,8 +1333,8 @@ describe.skipIf(MODE === 'record')('web e2e: active Schedule catalog', () => {
}, 60_000)
it('restores the latest linked Session after reviewing a concurrent destination change', async () => {
const before = SessionId('schedule-destination-before')
const after = SessionId('schedule-destination-after')
const before = brandString<SessionId>('schedule-destination-before')
const after = brandString<SessionId>('schedule-destination-after')
const fixture = await readFile(CATALOG_FIXTURE, 'utf8')
for (const id of [before, after]) await seedSession(scaffold, fixture, id, 'standard')
const created = await scaffold.ctx.schedule.create({ title: 'Destination recovery', prompt: 'Review the destination',
@@ -1366,10 +1367,10 @@ describe.skipIf(MODE === 'record')('web e2e: active Schedule catalog', () => {
it('removes every ended task from the page and keeps the active ones', async () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-schedule-clear-ended'))
const endedSession = SessionId('schedule-manager-ended-clear')
const endedSession = brandString<SessionId>('schedule-manager-ended-clear')
const domain = scaffold.ctx.storageDomain.get('schedule')
if (domain === undefined) throw new Error('Schedule domain was not opened')
const endedIds = [ScheduleId('schedule-ended-first'), ScheduleId('schedule-ended-second')]
const endedIds = [brandString<ScheduleId>('schedule-ended-first'), brandString<ScheduleId>('schedule-ended-second')]
const endedTitles = ['Ended release check', 'Ended metrics check'] as const
// An earlier scenario may leave an ended row behind; the confirmation states
// the whole ended set, so the lane starts from an empty one.
@@ -1380,7 +1381,7 @@ describe.skipIf(MODE === 'record')('web e2e: active Schedule catalog', () => {
const receipt = {
scheduledAt: record.scheduledAt,
deliveredAt: new Date(Date.parse(record.scheduledAt) + 1_000).toISOString(),
messageId: MessageId(`${id}-delivery`),
messageId: brandString<MessageId>(`${id}-delivery`),
targetSessionId: endedSession,
}
await domain.table('tasks').put(record.id, {
+11 -10
View File
@@ -18,7 +18,7 @@ import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { createLaunchEnvironmentSnapshot } from '@deepseek-ai/dsh-launch-environment'
import { createMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import type { ContentBlock, ContextFormed, Message, MessageSource } from '@deepseek-ai/dsh-llm'
import { deriveEventMessage, SessionId } from '@deepseek-ai/dsh-session'
import { deriveEventMessage, type SessionId } from '@deepseek-ai/dsh-session'
import type { SessionEvent } from '@deepseek-ai/dsh-session'
import type { TokenMeter } from '@deepseek-ai/dsh-token-meter'
import type {} from '@deepseek-ai/dsh-api-terminal-controller'
@@ -30,6 +30,7 @@ import {
webSnapshotMode, type WebScaffold,
} from './scaffold.ts'
import { expandOwningTurnProcess, newEnglishPage, pinBrowserClock, pinHostClock, saveFailureShot, WEB_FIXTURE_TIME } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
declare module '@deepseek-ai/dsh-llm' {
interface MessageSourceMap {
@@ -325,7 +326,7 @@ describe('web e2e: seeded history renders through cold resume', () => {
// production Session Controller against the booted real host.
const controller = new AbortController()
const stream = scaffold.ctx.sessionController.follow({
address: { kind: 'session', sessionId: SessionId(SEED_ID) },
address: { kind: 'session', sessionId: brandString<SessionId>(SEED_ID) },
}, controller.signal)[Symbol.asyncIterator]()
const first = await stream.next()
controller.abort()
@@ -399,10 +400,10 @@ describe('web e2e: seeded history renders through cold resume', () => {
expect(await page.getByText(PROMPT, { exact: true }).count()).toBe(1)
await expect.poll(
() => scaffold.ctx.agents.get(SessionId(SEED_ID)) !== undefined,
() => scaffold.ctx.agents.get(brandString<SessionId>(SEED_ID)) !== undefined,
{ timeout: 10_000 },
).toBe(true)
const agent = scaffold.ctx.agents.get(SessionId(SEED_ID))
const agent = scaffold.ctx.agents.get(brandString<SessionId>(SEED_ID))
if (agent === undefined) throw new Error('seeded session did not attach an agent')
const injected = agent.session.append('user/message', createUserMessage({
content: [{
@@ -488,7 +489,7 @@ describe('web e2e: seeded history renders through cold resume', () => {
})
it.skipIf(MODE === 'record')('shows ordinary instructions as one collapsed Context row that expands to their logged content', async () => {
const session = scaffold.ctx.sessions.get(SessionId(SEED_ID))
const session = scaffold.ctx.sessions.get(brandString<SessionId>(SEED_ID))
if (session === undefined) throw new Error('seeded session is unavailable')
const instructions = session.snapshotEvents().filter(event => event.type === 'user/message'
&& event.data.source.kind === 'agent-instructions')
@@ -763,7 +764,7 @@ describe('web e2e: seeded history renders through cold resume', () => {
await expect.poll(() => access.isEnabled(), { timeout: 10_000 }).toBe(true)
const row = page.locator('[data-variant="others"]').filter({ hasText: 'preset read-only' })
expect(await row.count()).toBe(0)
const agent = scaffold.ctx.agents.get(SessionId(SEED_ID))
const agent = scaffold.ctx.agents.get(brandString<SessionId>(SEED_ID))
if (agent === undefined) throw new Error('seeded session did not attach an agent')
const events = agent.session.snapshotEvents()
const run = events.findLast(event => event.type === 'command/run' && event.data.name === 'permission')
@@ -792,7 +793,7 @@ describe('web e2e: seeded history renders through cold resume', () => {
await disclosure.click()
await expect.poll(() => disclosure.getAttribute('aria-expanded')).toBe('true')
const agent = scaffold.ctx.agents.get(SessionId(SEED_ID))
const agent = scaffold.ctx.agents.get(brandString<SessionId>(SEED_ID))
if (agent === undefined) throw new Error('seeded session did not attach an agent')
const done = agent.session.snapshotEvents().filter(event => event.type === 'command/done').at(-1)
if (done?.type !== 'command/done') throw new Error('feedback command did not settle')
@@ -817,7 +818,7 @@ describe('web e2e: seeded history renders through cold resume', () => {
}, 60_000)
it.skipIf(MODE === 'record')('shows short injected context as a collapsed Context row without dropping the event', async () => {
const agent = scaffold.ctx.agents.get(SessionId(SEED_ID))
const agent = scaffold.ctx.agents.get(brandString<SessionId>(SEED_ID))
if (agent === undefined) throw new Error('seeded session did not attach an agent')
const contextRows = page.locator('[data-chat-flow-kind="context"]')
const before = await contextRows.count()
@@ -863,7 +864,7 @@ describe('web e2e: seeded history renders through cold resume', () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-seeded-terminal-unavailable'))
await page.locator('[data-dockkit-add-tab]').click()
await page.locator('[data-sidebar-right-guide-entry="terminal"]').getByRole('button', { name: /^New terminal/u }).click()
const sessionId = SessionId(SEED_ID)
const sessionId = brandString<SessionId>(SEED_ID)
const terminals = () => scaffold.ctx.terminalController.list(sessionId)
await expect.poll(() => terminals().length).toBe(1)
const previous = terminals()[0]!.id
@@ -889,7 +890,7 @@ describe('web e2e: seeded history renders through cold resume', () => {
it.skipIf(MODE === 'record')('omits blank reasoning rows around recorded text in an appended fixture turn', async () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-seeded-blank-reasoning'))
const session = scaffold.ctx.sessions.get(SessionId(SEED_ID))
const session = scaffold.ctx.sessions.get(brandString<SessionId>(SEED_ID))
if (session === undefined) throw new Error('seeded session is unavailable')
const events = session.snapshotEvents()
const recorded = events.flatMap(event => event.type === 'assistant/message' ? event.data.message.content : [])
+3 -2
View File
@@ -13,7 +13,8 @@ import { fileURLToPath } from 'node:url'
import type { Browser, Locator, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { ToolCallId, type StreamChunk } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import type { ToolCallId, StreamChunk } from '@deepseek-ai/dsh-llm'
import type { ReplayEntry } from '@deepseek-ai/dsh-llm-replay'
import type { SessionEvent, SessionId } from '@deepseek-ai/dsh-session'
import {
@@ -43,7 +44,7 @@ const WAIT_COMMAND = `node -e "const fs=require('node:fs'); fs.writeFileSync('st
*/
function script(): ReplayEntry[] {
const args = JSON.stringify({ command: WAIT_COMMAND, description: 'Wait a long time' })
const callId = ToolCallId('call_wait')
const callId = brandString<ToolCallId>('call_wait')
const first: StreamChunk[] = [
{ type: 'block-start', index: 0, blockType: 'tool-call' },
{ type: 'tool-call-delta', index: 0, id: callId, name: 'bash', argumentsDelta: args },
+5 -4
View File
@@ -5,11 +5,12 @@ import { fileURLToPath } from 'node:url'
import type { Browser, Locator, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import {
acknowledgeReloadConnectionLoss, launchWebScaffold, seedSession, watchConsole, type WebScaffold,
} from './scaffold.ts'
import { newEnglishPage, saveFailureShot } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
// The seed is another scenario's committed fixture, reused read-only: this
// spec needs any one cold Session row, not new recorded content.
@@ -83,7 +84,7 @@ describe('web e2e: archived sessions are restored from the sidebar filter', () =
await seededRow.click()
await expect.poll(() => seededRow.getAttribute('aria-selected'), { timeout: 10_000 }).toBe('true')
const { title } = await scaffold.ctx.sessionController.rename({
sessionId: SessionId(SEED_ID), title: `Unarchive target ${SEED_ID}`,
sessionId: brandString<SessionId>(SEED_ID), title: `Unarchive target ${SEED_ID}`,
})
const sessionRow = page.getByRole('treeitem').filter({ has: page.getByText(title, { exact: true }) })
await expect.poll(() => sessionRow.count(), { timeout: 10_000 }).toBe(1)
@@ -97,9 +98,9 @@ describe('web e2e: archived sessions are restored from the sidebar filter', () =
await expect.poll(() => page.getByText('Ungrouped', { exact: true }).count(), { timeout: 10_000 }).toBe(0)
// Durable on the host: the registry-global set carries the id while the
// Session log itself stays in persistence untouched.
expect([...scaffold.ctx.workspaceRegistry.archivedSessionIds]).toEqual([SessionId(SEED_ID)])
expect([...scaffold.ctx.workspaceRegistry.archivedSessionIds]).toEqual([brandString<SessionId>(SEED_ID)])
expect((await scaffold.ctx.sessionPersistence.list()).map(snapshot => snapshot.header.id))
.toContain(SessionId(SEED_ID))
.toContain(brandString<SessionId>(SEED_ID))
await page.getByRole('button', { name: 'View options' }).click()
await page.getByRole('menuitem', { name: 'All conversations (show archived)', exact: true }).click()
+3 -2
View File
@@ -14,12 +14,13 @@ import type { Browser, Locator, Page, Request } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed, onTestFinished } from 'vitest'
import { basename, join } from 'node:path'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import {
acknowledgeReloadConnectionLoss, assertFixtureInventory, captureStableAria, compareOrRefreshGolden,
launchWebScaffold, watchConsole, webSnapshotMode, type WebScaffold,
} from './scaffold.ts'
import { openSettings, ZH_BROWSER_LOCALE, saveFailureShot } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/settings-chrome', import.meta.url))
const DIALOG_EXPECTED = join(SNAPSHOT_DIR, 'dialog.expected.md')
@@ -367,7 +368,7 @@ describe('web e2e: settings modal and General preferences', () => {
it('stores Permission as the default for future sessions without changing an existing session', async () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-settings-permission'))
const createSession = async (id: string) => {
const handle = await scaffold.ctx.agents.create({ sessionId: SessionId(id) })
const handle = await scaffold.ctx.agents.create({ sessionId: brandString<SessionId>(id) })
onTestFinished(() => handle.dispose())
return handle.agent.session
}
+6 -5
View File
@@ -1,8 +1,9 @@
import { fileURLToPath } from 'node:url'
import { chromium } from 'playwright'
import { expect, it } from 'vitest'
import { ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, SessionId } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, type SessionId } from '@deepseek-ai/dsh-session'
import {
captureStableAria, compareOrRefreshGolden, launchWebScaffold,
seedSession, watchConsole, webSnapshotMode,
@@ -17,8 +18,8 @@ const LONG_ARGS = { ...ARGS, command: `${COMMAND} --token=${'x'.repeat(1024)}` }
/** A settled shell call rendered from durable arguments and its original result. */
function shellFixture(arguments_: typeof ARGS, output: string): string {
const session = Session.create(SessionId('shell-command-details-source'))
const callId = ToolCallId('shell-command-details-background')
const session = Session.create(brandString<SessionId>('shell-command-details-source'))
const callId = brandString<ToolCallId>('shell-command-details-background')
const args = JSON.stringify(arguments_)
session.append('turn/start', { turn: 1 })
session.append('user/message', createUserMessage({
@@ -162,7 +163,7 @@ it.each([
const resolved = await scaffold.ctx.sessionController.resolveAgent(id)
if ('error' in resolved) throw resolved.error
const session = resolved.agent.session
const callId = ToolCallId(`status-dot-${name}-${background ? 'background' : 'foreground'}`)
const callId = brandString<ToolCallId>(`status-dot-${name}-${background ? 'background' : 'foreground'}`)
const args = JSON.stringify({ command: LONG_ARGS.command, description: `Long ${name} command`, run_in_background: background })
session.append('turn/start', { turn: 2 })
session.append('user/message', createUserMessage({
+17 -16
View File
@@ -10,10 +10,11 @@ import { join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { afterEach, expect, it } from 'vitest'
import type { Agent } from '@deepseek-ai/dsh-agent'
import { LlmAdapter, ToolCallId } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import { LlmAdapter, type ToolCallId } from '@deepseek-ai/dsh-llm'
import type { GenerateOptions, LlmResolvedModelInfo, StreamChunk } from '@deepseek-ai/dsh-llm'
import { canonicalPath, writableRoots } from '@deepseek-ai/dsh-sandbox'
import { SESSION_FORMAT_VERSION, SessionId, type SessionEvent } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, type SessionId, type SessionEvent } from '@deepseek-ai/dsh-session'
import { auditStartupEntries, composeEntries, loadOverlayPatches } from '@deepseek-ai/dsh-app-boot'
// These imports carry the tools/sandboxPolicy/approval Context merges.
import { RUN_CODE_NAME } from '@deepseek-ai/dsh-tools'
@@ -35,7 +36,7 @@ const BASE_PATCH_PATH = join(REPO_ROOT, 'packages/bundle/base/cordis.patch.yml')
const HEADLESS_PATCH_PATH = join(REPO_ROOT, 'packages/bundle/headless/cordis.patch.yml')
const AUTO_PROVIDER = 'shipped-auto-review-test'
const AUTO_MODEL = 'same-route'
const AUTO_CALL_ID = ToolCallId('shipped-auto-review-denied-delete')
const AUTO_CALL_ID = brandString<ToolCallId>('shipped-auto-review-denied-delete')
const AUTO_RAW_REASON = ` direct user authorized inspection only\nTEST_ONLY_SECRET_${'x'.repeat(16_384)} `
const AUTO_FINAL_TEXT = 'SHIPPED_AUTO_REVIEW_REJECTION_OBSERVED'
const AUTO_CHILD_AUTHORIZED = 'AUTO_CHILD_AUTHORIZED'
@@ -173,7 +174,7 @@ function toolChunks(
name: string,
args: Readonly<Record<string, unknown>>,
): StreamChunk[] {
const callId = ToolCallId(id)
const callId = brandString<ToolCallId>(id)
const argumentsJson = JSON.stringify(args)
return [
{ type: 'block-start', index: 0, blockType: 'tool-call' },
@@ -604,7 +605,7 @@ it('assembles the shipped Web transport, catalog, guidance, and defaults', async
'working_directory', 'team_task_create', 'team_task_list', 'team_task_get', 'team_task_update',
])
const handle = await ctx.agents.create({
sessionId: SessionId('shipped-composition'),
sessionId: brandString<SessionId>('shipped-composition'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx).then(() => undefined),
})
try {
@@ -642,7 +643,7 @@ it('assembles the shipped Web transport, catalog, guidance, and defaults', async
expect(headlessRows.some(row => row.id === 'auto-review')).toBe(false)
const commandHandle = await scaffold.ctx.agents.create({
sessionId: SessionId('shipped-command-catalog'),
sessionId: brandString<SessionId>('shipped-command-catalog'),
meta: { cwd: scaffold.workspaceCwd },
agentOptions: { provider: 'deepseek-official', model: 'deepseek-v4-flash' },
})
@@ -662,7 +663,7 @@ it('ships PTC with run_code but without the general workflow SDK binding', async
scaffold = await launchWebScaffold({ deepSeekMissingCredential: true })
const ctx = scaffold.ctx
const handle = await ctx.agents.create({
sessionId: SessionId('shipped-ptc-composition'),
sessionId: brandString<SessionId>('shipped-ptc-composition'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'ptc').then(() => undefined),
})
try {
@@ -680,7 +681,7 @@ it('lets a preset producer reach the background-job registry', async () => {
scaffold = await launchWebScaffold()
const ctx = scaffold.ctx
const handle = await ctx.agents.create({
sessionId: SessionId('shipped-background-job'),
sessionId: brandString<SessionId>('shipped-background-job'),
meta: { cwd: scaffold.workspaceCwd },
setup: agentCtx => ctx.agentPresets.mount(agentCtx).then(() => undefined),
})
@@ -691,7 +692,7 @@ it('lets a preset producer reach the background-job registry', async () => {
// fails here — with every task control still listed in the catalog above.
const started = await executeModelToolFixture(ctx, {
signal,
callId: ToolCallId('shipped-bash-background'),
callId: brandString<ToolCallId>('shipped-bash-background'),
name: 'bash',
arguments: {
command: 'printf SHIPPED_BACKGROUND_OK',
@@ -713,7 +714,7 @@ it('lets a preset producer reach the background-job registry', async () => {
// owner. A per-preset registry would list nothing here even on success.
const listed = await executeToolFixture(ctx, {
signal,
callId: ToolCallId('shipped-task-list'),
callId: brandString<ToolCallId>('shipped-task-list'),
name: 'job_list',
arguments: {},
agent: handle.agent,
@@ -726,7 +727,7 @@ it('lets a preset producer reach the background-job registry', async () => {
// through a preset-plane control, which is the linkage the realm severed.
const collected = await executeToolFixture(ctx, {
signal,
callId: ToolCallId('shipped-task-output'),
callId: brandString<ToolCallId>('shipped-task-output'),
name: 'job_output',
arguments: { job_id: jobId, wait: true },
agent: handle.agent,
@@ -759,7 +760,7 @@ it('routes one browser-authored Auto request through the same model and asks the
const created = await remote<{ sessionId: string }>(scaffold, 'session/create', {
request: { cwd: scaffold.workspaceCwd },
})
const sessionId = SessionId(created.sessionId)
const sessionId = brandString<SessionId>(created.sessionId)
await remote(scaffold, 'session/selectModel', {
request: { sessionId, provider: AUTO_PROVIDER, model: AUTO_MODEL },
})
@@ -857,7 +858,7 @@ it('reviews initially authorized, restricted, and cold-resumed child calls indep
const created = await remote<{ sessionId: string }>(scaffold, 'session/create', {
request: { cwd: scaffold.workspaceCwd },
})
const parentId = SessionId(created.sessionId)
const parentId = brandString<SessionId>(created.sessionId)
adapter.setParent(parentId)
await remote(scaffold, 'session/selectModel', {
request: { sessionId: parentId, provider: AUTO_PROVIDER, model: AUTO_MODEL },
@@ -1035,7 +1036,7 @@ it('rolls back a failed shipped Auto initialization before publishing or interce
expect(warnings.join('\n')).toContain('preset "auto" is already registered')
const handle = await ctx.agents.create({
sessionId: SessionId('shipped-auto-init-rollback'),
sessionId: brandString<SessionId>('shipped-auto-init-rollback'),
meta: { cwd: scaffold.workspaceCwd },
setup: agentCtx => ctx.agentPresets.mount(agentCtx).then(() => undefined),
})
@@ -1048,7 +1049,7 @@ it('rolls back a failed shipped Auto initialization before publishing or interce
// Auto execution behavior.
const result = await executeToolFixture(ctx, {
signal: new AbortController().signal,
callId: ToolCallId('shipped-auto-init-rollback-write'),
callId: brandString<ToolCallId>('shipped-auto-init-rollback-write'),
name: 'write',
arguments: { file_path: targetPath, content: 'INITIALIZATION_ROLLED_BACK\n' },
agent: handle.agent,
@@ -1076,7 +1077,7 @@ it('withdraws Auto on shipped Loader unload and does not restore migrated live s
const autoEntry = [...ctx.loader.entries()].find(entry => entry.options.id === 'auto-review')
if (autoEntry === undefined) throw new Error('shipped Auto review Loader entry is missing')
const handle = await ctx.agents.create({
sessionId: SessionId('shipped-auto-hot-plug'),
sessionId: brandString<SessionId>('shipped-auto-hot-plug'),
meta: { cwd: scaffold.workspaceCwd, agentPreset: 'minimal' },
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'minimal').then(() => undefined),
})
+3 -2
View File
@@ -5,12 +5,13 @@ import { join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { chromium } from 'playwright'
import { expect, it } from 'vitest'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import { initialShortcutConfig, parseShortcutDefinitions, parseShortcutEdit } from '@deepseek-ai/dsh-client-shortcuts/protocol'
import type { DesktopShortcutInput, DesktopShortcutsApi, ShortcutCommandId, ShortcutRevision } from '@deepseek-ai/dsh-client-shortcuts/protocol'
import { desktopKeybindings } from '../../desktop/src/keybindings.ts'
import { acknowledgeReloadConnectionLoss, compareOrRefreshGolden, launchWebScaffold, seedSession, watchConsole, webSnapshotMode } from './scaffold.ts'
import { writeComposerDraft } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
declare global {
interface Window {
@@ -34,7 +35,7 @@ it.each([
try {
const scaffold = await launchWebScaffold({ developerTools: false })
try {
await seedSession(scaffold, await readFile(seed, 'utf8'), SessionId('desktop-shortcuts-source'))
await seedSession(scaffold, await readFile(seed, 'utf8'), brandString<SessionId>('desktop-shortcuts-source'))
const browser = await chromium.launch()
try {
const page = await browser.newPage({ locale: 'en-US', viewport: { width: 1440, height: 1000 } })
+4 -3
View File
@@ -4,7 +4,7 @@ import { basename, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { chromium, type Browser, type Page } from 'playwright'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import { createLaunchEnvironmentSnapshot } from '@deepseek-ai/dsh-launch-environment'
import { createUserMessage } from '@deepseek-ai/dsh-llm'
import {
@@ -12,10 +12,11 @@ import {
seedSession, watchConsole, webSnapshotMode, type WebScaffold,
} from './scaffold.ts'
import { connectFreshWorkspace } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const root = fileURLToPath(new URL('./expected/shortcuts-workspace', import.meta.url))
const seed = fileURLToPath(new URL('../../../snapshots/web/seeded-history/session.v3.jsonl', import.meta.url))
const sourceId = SessionId('shortcuts-workspace-source')
const sourceId = brandString<SessionId>('shortcuts-workspace-source')
const mode = webSnapshotMode()
describe.skipIf(mode === 'record')('web e2e: workspace shortcuts', () => {
@@ -285,7 +286,7 @@ it.skipIf(mode === 'record').each([
const scaffold = await launchWebScaffold({ developerTools: false })
let browser: Browser | undefined
try {
await seedSession(scaffold, await readFile(seed, 'utf8'), SessionId('shortcut-defaults-source'))
await seedSession(scaffold, await readFile(seed, 'utf8'), brandString<SessionId>('shortcut-defaults-source'))
browser = await chromium.launch()
const context = await browser.newContext({ locale: 'en-US', viewport: { width: 1440, height: 1000 } })
await context.addInitScript((value) => { Object.defineProperty(navigator, 'platform', { value }) }, platform)
@@ -7,7 +7,7 @@ import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import type { AgentHandle } from '@deepseek-ai/dsh-agent'
import { createUserMessage, LlmAdapter } from '@deepseek-ai/dsh-llm'
import type { GenerateOptions, StreamChunk } from '@deepseek-ai/dsh-llm'
import { SessionId, type SessionId as SessionIdValue } from '@deepseek-ai/dsh-session'
import type { SessionId, SessionId as SessionIdValue } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-subagent'
import type {} from '@deepseek-ai/dsh-workspace'
import {
@@ -20,6 +20,7 @@ import {
type WebScaffold,
} from './scaffold.ts'
import { connectFreshWorkspace, newEnglishPage, saveFailureShot } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/sidebar-subagent-activity', import.meta.url))
const RUNNING_OWNER_EXPECTED = join(SNAPSHOT_DIR, 'owner-running.expected.md')
@@ -87,7 +88,7 @@ describe('web e2e: sidebar subagent activity', () => {
const cwd = join(scaffold.workspaceCwd, 'workspace')
await mkdir(cwd)
parentHandle = await scaffold.ctx.agents.create({
sessionId: SessionId('sidebar-activity-owner'),
sessionId: brandString<SessionId>('sidebar-activity-owner'),
meta: { cwd },
agentOptions: { provider: HOLD_PROVIDER, model: HOLD_MODEL },
})
Loaded 100 of 1236 files, more files were not shown because too many files have changed in this diff. Show more