Files
deepseek-harness/packages/session/session-title
Turtle 38c7a9fbf4 feat(release): publish package source, declaration maps, and documentation (#5884)
* feat(release): publish package source, declaration maps, and documentation

Every release member publishes its TypeScript source and the declaration
maps that resolve into it, and @deepseek-ai/dsh publishes the repository
Markdown documentation staged from docs/ at prepack time.

The ./src/* export most members already declared now resolves for an
installed consumer, and a consumer editor follows a declaration to the
implementation. Bundled JavaScript maps stay unpublished; the vendored
family and the Desktop runtime file policy are unchanged.

Rationale: .agents/notes/implemented/process/2026-10-08-published-source-and-docs.md

* feat(release): publish JavaScript maps and compress bundles

Every emitted JavaScript map ships beside the bundle it describes, and the
workspace build and the client preset compress bundles without mangling
identifiers.

The documentation payload now mirrors the website publication manifest and
is removed again by `postpack`; Desktop and the Python executable exclude
the published source, documentation, and maps; `clean` removes a staged
copy. Typert's publication contract gains the Remote declaration map.

* fix(release): keep node bundles readable for the worker image

The browser worker image lowers `yield*` only as a whole statement and
rewrites `for await` loops by their source layout, so compressed node-side
entries either fail that lowering or lower to unparseable code. Only the
browser bundles keep compression, which removes about a third of their text.

The bundle-purity assertion now matches the module-loader call regardless of
the quote style compression picks, and the release-pack fixture exercises
the installed package's new documentation requirement.

* feat(release): publish the whole documentation tree

`@deepseek-ai/dsh` copies `docs/` in full instead of the website's page
set: the maintainer documents, the generated migration records, the
translation guidelines, and the `*.i18n.yaml` consistency records ship
with the installed package, so the documentation's own links resolve
without a checkout.

* feat(release): publish the upgrade guides with the documentation

The staged documentation keeps the website's page set and adds every
`docs/upgrade-guide/` document, which is what an installed reader consults
when a released change breaks something. The rest of the maintainer tree
stays out.

* test(release): expect source and maps in master's new payload cases

* feat(release): keep installed docs and source readable in Desktop

Desktop keeps the published src/ and docs/ trees inside app.asar, and
every model shell call receives DSH_INSTALL_DIR and DSH_NODE_EXECUTABLE
so an agent can read them through Electron's Node mode. Staging also
generates docs/upgrade-guide/README.md, an index of the upgrade guides
grouped by the release they upgrade from.

Minified client bundles print string literals with backticks: the
worker image packer now recognizes those chunk requests, client license
banners are prepended after minification so their text survives, and
the affected artifact tests accept either quote.

* test(desktop): read archived docs through the Windows PowerShell form

Regenerate the config catalog for the shifted shell-env source line.

* test(desktop): wait for the GUI-subsystem Electron process from PowerShell

* build(release): publish source and maps from the message-quotes package

* build(release): publish source and maps from packages new on master

* build(release): publish source and maps from the tool-office package
2026-11-05 00:22:36 +08:00
..

description, kind
description kind
Log-backed session titles for users and maintainers choosing a title source, configuring the service, or debugging title state. package-reference

@deepseek-ai/dsh-session-title

English | 中文

Summary

Use dsh-session-title to give each session a client-visible title from the first eligible human message, an optional asynchronous generator, or an explicit user rename. Accepted titles persist through replay, resume, and paging but never enter model input. Automatic generation never delays the main agent response, and newer title requests supersede older work. Choose the package when clients need durable titles with configurable length limits and a deliberate refresh() path for regenerating them.

Table of Contents


Use this package

Mount the service to give sessions titles that clients can display and that never reach the model. The common path is explicit: load the session store, mount the service with its required limits, and optionally mount one provider plugin.

Choosing a title source

Titles come from three sources, newest wins. The built-in fallback derives from the first eligible human message's leading words within the configured caps; a registered provider generates a title over eligible messages; an explicit rename() accepts a user-supplied title. Only text blocks from human user/message events are eligible, and empty or non-text prompts wait for later eligible input. A user-sourced latest title pins the session — later user messages schedule no automatic revision, and an explicit refresh() remains the deliberate unpin.

Minimal configuration

All limits are required; the library supplies no defaults. Mount the service with the three bounds:

- name: '@deepseek-ai/dsh-session'
- name: '@deepseek-ai/dsh-session-title'
  config:
    fallbackMaxWords: 8
    fallbackMaxBytes: 96
    maxTitleBytes: 120
Field Default Meaning
fallbackMaxWords required Maximum whitespace-delimited words in the deterministic fallback
fallbackMaxBytes required Maximum UTF-8 bytes in the fallback; must not exceed maxTitleBytes
maxTitleBytes required Maximum UTF-8 bytes accepted from any source

The generated configuration catalog is the exhaustive source for every accepted field and its JSDoc.

Adding a provider

One optional asynchronous provider may be registered through ctx.sessionTitle.register(provider); a second registration throws until the first provider's disposal starts, so a replacement can activate while the previous provider drains, and the previous provider's late results never commit. The shipped model-backed providers are first-prompt and all-prompts, both using the shared LLM execution module. Immediately before each call the service captures the latest accepted title snapshot, including the fallback it just ensured, and passes it as request.currentTitle; the provider owns whether and how to use it. A provider starts only after a marked loop-built request's exact route matches the logged request/header, and a newer revision supersedes and aborts older work. For unchanged routes, an active marked request starts pending automatic generation without a new header event; accepted human messages may follow the current step/start. First-prompt generation excludes seeded Sessions and subagent-origin Sessions; an independent fork does not become eligible when its source relationship is absent.

Reading titles

get(session) reads the latest folded title from one live or replayed session, and foldSessionTitle(events) is the pure fold over a log. The service requires ctx.sessionProjections and registers two units: the client-visible title unit (the accepted title string for client list rows) and the host-only titleInput unit, which folds the first and latest eligible messages plus their count so scheduling and fallback reads are O(1) through stateOf(); the full eligible prefix for one provider generation is scanned from the session log at execution time. An explicit refresh(session) materializes the fallback when needed, then explicitly runs the registered provider over the current eligible messages.

Failures and recovery

Automatic failures warn and retain the latest title; explicit refresh() rejects on provider error or caller cancellation, and cancellation does not roll back an already accepted fallback event. Automatic work never delays the main agent response, its late completion appends a standalone log-only event without opening a turn, and a stale completion cannot append. Forks inherit title events in their seed unchanged.


Understand the implementation

Implementation internals — click to expand

This section explains the title design; the observable behavior is fully covered in Use this package.

Design concept

Titles are durable, log-only state: every accepted revision is a session/title event, and foldSessionTitle() selects the latest, so a title survives replay, resume, and paging exactly like any other session event. The service owns scheduling, supersession, and acceptance; providers own generation.

Source map

File Role
src/index.ts Service: config, fold, fallback scheduling, provider registry, concurrency, title projection unit
src/normalize.ts Title-text cleaning, UTF-8-safe truncation, and the deterministic fallback
src/types.ts One home of the title projection-key declaration

Lifecycle and concurrency

Messages received during activation wait for the service to become ready and request the built-in fallback. Providers register after service readiness; earlier messages and requests do not trigger them retroactively. Activation failure, service disposal, or Session removal prevents the deferred fallback from writing.

Per-session work state tracks a revision counter, an in-flight fallback, and pending and active provider work. A newer user message, provider disposal, session disposal, or explicit refresh aborts older work through an AbortController; a completion whose provider, revision, session, or signal is stale cannot append. Explicit refreshes reserve their revision before provider work; overlapping automatic and explicit fallback requests share one session-local in-flight append. Service teardown cancels queued work and drains calls that ignore cancellation before unloading completes.

Normalization

Accepted titles are cleaned of terminal control sequences, directional and invisible controls, and non-whitespace C0/C1 controls; whitespace is normalized, and truncation to the byte caps never splits a Unicode code point. The deterministic fallback takes the first eligible message's leading words within fallbackMaxWords and fallbackMaxBytes.


Further Exploration

Read these pages when the service contract is not enough. They move from the subsystem reference to the model-backed providers that plug in here.


Model Experience

Session title state

What the model sees

Nothing. session/title is log-only and never enters the session surface, deriveMessages(), system prompt, tool schemas, or request prefix.

Token effect

The fallback and accepted provider revisions add zero tokens to the main agent request. An optional provider's separate auxiliary request is documented by that provider package.

KV Cache effect

None for the main request; title events do not change its reconstructed content or cache key.

Known Limitations and Deferred Work

These limits define what the title service does not provide. They are current package constraints.

  • No title deletion, search, or list indexing — unpinning back to automatic titles without an explicit refresh, search, and list indexing are outside this service.
  • At most one provider — the registry deliberately accepts a single implementation, so a deployment cannot compose competing title strategies without writing one provider that owns their precedence.

Dev Note

Working context for maintainers — click to expand

None.