Files
deepseek-harness/packages/api
Tianyi Cui 165cc31eb8 perf(llm,host): read embedded Assistant streams per compact record
Session format v2 embeds each attempt's compact stream in
assistant/message and assistant/attempt, but Host and client consumers
still expanded it into per-member TimedStreamChunk arrays and did
per-member work; expandAssistantStream materializes the full array before
find/toReversed/break can answer. Session Stats (the projection phase of
every Session open), the token meter's usage and provider-assembly folds,
the subagent output fold, and the Session Controller image lookup still
paid O(members) allocation and time per settlement.

The Chat and Trajectory definitions were already settled from
message.content on master; the remaining per-member folds stay.

dsh-llm now exports record-level readers (first token, visible content,
visible text, last raw chunk of a type, raw chunks of a type, joined
text, run-aware assembly, per-run first-token/first-visible times) that
scan the compact records once with early exit. Session Stats reads
assistantStreamFirstTokenTime, the token meter reads
lastAssistantStreamChunk(stream, 'usage') and assembles through
assembleAssistantStream, the subagent output fold appends
joinAssistantStreamText, and the Session Controller scans
assistantStreamChunks(stream, 'block-end').

expandAssistantStream is deliberately not memoized: retaining expansions
costs roughly ten times the compact stream for the Session's lifetime.
It remains the validating path at durable boundaries.

Synthetic 200-turn v0 migration benchmark, median of five: first-open
projection 28.0 ms -> 5.4 ms, first-open total 76.9 -> 50.0 ms, peak RSS
137.2 -> 94.9 MB; reopen projection 17.8 -> 5.6 ms; all phase budgets and
the 128 MB heap constraint keep passing.
2026-09-06 12:41:25 +08:00
..

description, kind
description kind
Package map for the application's Remote layer: typed Client-to-Host capability calls, results, and forwarded events, for users and maintainers navigating the group. package-group

api/ — Remote API layers

English | 中文

Summary

The api/ group provides the application's Remote layer: a Client environment can call the business capabilities running on the Host — manage goals, run commands, list the plugin inventory, discover file and session references — as typed method calls, and receive the results or forwarded Host events. remotes decides which capabilities are exposed and how each call reaches the right session's agent; gateway carries the calls and their results between Client and Host. The stack runs over the application's shared Connection; streaming session data is deliberately outside it.

Table of Contents


Packages

The packages below provide the Remote layer; the package READMEs own the exhaustive contracts.

Package Role ctx key
remotes/ Chooses which Host capabilities and events the Client can consume.
gateway/ Carries typed unary calls, multiplexed streams, and forwarded Host events. ctx.typertGateway / ctx.remote
session-controller/ Owns Session commands, history streams, live control state, and Agent/Session identity policy. ctx.sessionController / ctx.remote.session
settings-controller/ Owns the configuration-surface reads and writes over the settings-domain seams. ctx.settingsController, ctx.credentialsController / ctx.remote.settings, ctx.remote.credentials
workspace-controller/ Owns Workspace mutations and the complete Client Workspace projection. ctx.workspaceController / ctx.remote.workspace

Remote calls run Client → Host over the application's shared Connection. API Gateway owns Remote transport, while the controller packages own Session, configuration-surface, and Workspace behavior. Feature packages register exact Connection Fetch routes for responses that do not fit Remote invocation, such as streamed downloads.


Start with the API Gateway reference to see the Remote model end to end, then the Typert subsystem page for the shared definitions and Connection for the physical carrier.

  • API Gateway reference — the current-state reference for the Typert API Gateway: programming model, generation pipeline, and runtime invocation.
  • Typert subsystem reference — the public contracts shared by protocol, Gateway, and consumer assemblies.
  • Connection — the RPC carrier, /api trust fence, and response envelopes behind every Remote call.

Dev Note

Working context for maintainers — click to expand

None.