Files
deepseek-harness/packages/experimental/timeline/tests/host-process.mjs
T
MagolorandZiyaZhang d997173e45 feat(timeline): integrate Timeline as an experimental plugin (#7973)
* Add Timeline as an experimental Harness plugin

* fix(timeline): align prompt counters and release inactive views

* fix(timeline): refine frontend motion and document features

* test(timeline): refresh recorded context after upstream update

* fix(timeline): satisfy UI locale and module graph checks

* test(timeline): align integration checks with CI test lanes

* docs(timeline): document exported locale dictionaries

* fix(timeline): use session records and native client interfaces

* fix(timeline): mount edit RPC and align integration checks

* fix(timeline): follow Harness theme rules

* test(timeline): cover session recovery and client interactions

* fix(timeline): address integration review findings

* fix(timeline): isolate forked plan continuation

* docs(timeline): record the 0.4.0 integration changes

* docs(timeline): clarify the plugin description

* test(timeline): cover integration behavior and recovery edges

* fix(timeline): align dependency metadata and test lint

* fix(timeline): isolate scoped work and harden replay

* docs(timeline): refresh persistence catalog source links

* docs(timeline): document planning ownership predicate

* test(timeline): refresh the recommendation description snapshot

* build(timeline): classify Host dependency exports

* test(web): pace the Goal queue snapshot replay

* feat(timeline): make sidebar auto-open configurable

* docs(timeline): clarify sibling task weights

* fix(timeline): harden report updates and checkpoint recovery

* refactor(timeline): share detail view props

* fix(timeline): clarify progress, reports, and sidebar settings (#8347)

* fix(timeline): align the integration with current Harness contracts

* fix(timeline): preserve navigation when removing a task tree

* Reduce Timeline report replay allocations

Reuse the discussion list when report retention leaves its targets intact.
Clarify that the integrated package follows the Harness release version.

Node 24.21.0 on macOS arm64, median of three measured replays after warmup.
With 17,640 reports, replay took 5650 ms before and 804 ms after.
Peak RSS fell from 343 MiB to 288 MiB. Retained heap stayed near 33 MiB.
The serialized view stayed at 5,297,849 bytes.

---------

Co-authored-by: ZiyaZhang <[email protected]>
2026-11-13 11:54:22 +08:00

77 lines
2.9 KiB
JavaScript

import { executeTool } from './execute-tool.ts'
// Independent Host process: use the shipped entry and published SDK, with no network or provider key.
import { Context } from '@deepseek-ai/cordis'
import { LlmAdapter, ToolCallId } from '@deepseek-ai/dsh-llm'
import { SessionId } from '@deepseek-ai/dsh-session'
import { SessionAlreadyOwnedError } from '@deepseek-ai/dsh-session-persistence'
import * as Jsonl from '@deepseek-ai/dsh-session-persistence-jsonl'
import {
mountAgentLoopTestDependencies,
mountAgentLoopTestHarness,
} from '@deepseek-ai/dsh-agent-loop-testkit'
import * as Timeline from '@deepseek-ai/dsh-timeline'
const [mode, root, id] = process.argv.slice(2)
const ctx = new Context()
await mountAgentLoopTestDependencies(ctx)
await ctx.plugin(Jsonl, { root, compression: 'none' })
try {
if (mode === 'compete') {
try {
const handle = await ctx.sessionPersistence.open(SessionId(id), 'write')
await handle.close()
throw new Error('A second process acquired write ownership')
} catch (error) {
if (!(error instanceof SessionAlreadyOwnedError)) throw error
process.stdout.write('owned\n')
}
} else {
class Adapter extends LlmAdapter {
resolveModel(provider, model) {
return Promise.resolve({ provider, id: model, name: model })
}
async *stream() {
throw new Error('This process must not query a model')
}
}
ctx.llm.registerAdapter(['fixture'], new Adapter())
await ctx.plugin(Timeline, { intervalMs: 86400000, rollupFactors: [] })
await mountAgentLoopTestHarness(ctx)
const { agent } = await ctx.agents.create({
sessionId: SessionId(id),
meta: { cwd: process.cwd() },
agentOptions: { provider: 'fixture', model: 'timeline' },
})
let sequence = 0
const call = async (name, args) => {
const result = await executeTool(ctx, {
name,
arguments: args,
agent,
callId: ToolCallId(`process-${sequence++}`),
signal: new AbortController().signal,
})
if (result.isError) throw new Error(JSON.stringify(result.content))
}
await call('timeline_tree', { action: 'start', title: 'Process recovery' })
await call('timeline_tasks', {
tasks: [{ id: 'check', title: 'Check recovery', status: 'active', done: [2, 3] }],
})
const tree = ctx.timeline.stateOf(agent.session).view.activeTreeId
await ctx.timeline.edit({
action: 'annotate',
sessionId: id,
id: 'note-0123456789abcdef',
target: { kind: 'task', tree, task: 'check' },
text: 'Retain the completed checks.',
})
await call('timeline_reply', { id: 'note-0123456789abcdef', text: 'Two checks are saved.' })
process.stdout.write('committed\n')
// The test kills this process after acknowledged saves, before any cleanup can run.
process.stdin.resume()
await new Promise(() => {})
}
} finally {
await ctx.fiber.dispose()
}