Files
deepseek-harness/packages/api/job-controller
Yichen Jiang 7ec142a325 refactor(jobs): move job observation into api-job-controller
Review asked for the observation wire and its client service to leave
session-controller: a job should reach the Host only through its own
Remote namespace, and the session plugin's apply had to materialize
{ $stream, session } for a service that is not session state.

@deepseek-ai/dsh-api-job-controller now owns the Host JobController
(job.observe over ctx.jobs, requiring the agent and job registries) and
the client ClientJobOutput (ctx.jobOutput) over ClientJobOutputModel,
resolving both Remote faces in its own apply. The remotes assembly
mounts the job namespace; ui-jobs injects the new package; the wire
types drop their Session prefix and spell the status union out so the
client face pulls no Host declaration merges into browser programs.
session-controller keeps the jobsBySession roster and loses observe-job,
job-output, and the observe cadence config.

ui-chat's slots and snapshot-builder import CommandNode and friends from
the declaring package: the typert analyzer's cross-package rule trips on
the snapshot re-export as soon as another client face joins the root
Client program (the new controller does), which is why this branch
carried the change before. JobPumpSource documents why it is an offset
snapshot reader rather than a Node.js Readable.
2026-09-02 22:53:36 +08:00
..

description, kind
description kind
Host and Client job observation: stream one background job's output record to the browser without touching the model's consuming cursor. package-reference

Job Controller

English | 中文

Summary

@deepseek-ai/dsh-api-job-controller owns the Host ctx.jobController service and the generated Client ctx.remote.job namespace. Its one Remote stream, job.observe, delivers a record-declaring job's retained output from an absolute byte offset; the Client half installs ctx.jobOutput, the reference-counted per-job observation service whose accumulated views the session-header job list renders. The roster itself is not here: SessionJob rows still ride the session control stream owned by dsh-api-session-controller, and a row's outputTotal says whether this controller has anything to stream for it.

Table of Contents


Use this package

The Host controller requires the live Agent registry and the job registry (dsh-jobs-local in the shipped compositions) and fails to load without them. job.observe({ sessionId?, jobId, from? }) resolves the fenced-read caller from the request's session — an unowned job needs no session — and yields one opened anchor, coalesced output frames, then one terminal status once the job has settled and its record is drained, after which the stream closes normally. Record reads are non-consuming: the model-facing job_output cursor and completion-notice state never observe them. A job the session does not own, a job without a record, or an unknown job rejects the stream. Reconnecting callers resume by passing the last frame's next as from; a from below the oldest retained byte gets a lossy first frame instead of an error.

The Client entry provides ClientJobOutput (ctx.jobOutput) over ClientJobOutputModel. observe(sessionId, jobId) opens one Gateway stream per job however many viewers expand it, keeps a bounded render tail per job with gapBefore marking eviction or resume gaps, records the terminal status or a stream failure on the view, and drops the view after the last viewer releases. The plugin resolves the Gateway stream factory and the job namespace while its own context is current, because observation (re)opens run on caller stacks that have not declared remote.job.

Config

Field Default Meaning
observeFlushMs 100 Coalescing window after new record output before an observation read, in milliseconds
observeMaxFrameBytes 65,536 Soft byte budget per observation output frame; one larger chunk ships whole

The generated configuration catalog is the exhaustive source for accepted fields and their JSDoc.


Model Experience

None, as job observation is browser and Host control state; it registers no prompt, tool, or session event. The model's own view of the same work stays with dsh-tool-jobs.

KV Cache effect

No direct effect; observation reads never touch model requests.

Known Limitations and Deferred Work

  • The stream is process-local: a Host restart loses every record, and a resumed observation then anchors on an empty registry.
  • Per-session fencing is enforced by the registry read; the Remote layer itself serves any connected browser, matching the session control stream's jobsBySession broadcast.

Dev Note

Working context for maintainers — click to expand

None.

Runtime invariant: No companion is published. The controller is a stateless projection of ctx.jobs reads; the registry's own @deepseek-ai/dsh-jobs/invariant owns the offset relations this stream forwards.