feat(dsh): adapt to DSH 0.1.5-alpha.1
Move the plugin onto the DSH 0.1.5-alpha.1 baseline (peer floor ^0.1.5-alpha.1, CI pinned to the alpha dist-tag) and fix the two host contract changes that alpha line introduced. Baseline: - all @deepseek-ai/dsh-* peer/dev deps -> 0.1.5-alpha.1; optional peer @deepseek-ai/dsh-client-ui-sidebar-right (declared, unused until the native-surface phase); devDep @deepseek-ai/dsh-agent-loop (inbox fold) - dsh.plugin.json engines >=0.1.5-alpha.1; version 0.19.0-alpha.0; SIDEBAR_SERVICE_VERSION follows Live assistant stream (assistant/chunk is gone): - 0.1.5 publishes in-flight model deltas as process-local agent/assistant-stream frames instead of durable assistant/chunk events and embeds the settled stream in assistant/message / assistant/attempt. src/assistant-live.ts folds the frames into a bounded per-session buffer; sidechat.events serves the current attempt as `live` rows (replaced every poll, never a delta) and the transcript renders them; the inherited in-progress snapshot reads message content / attempt stream / live frames. Cold session reads (persistence.inspect is gone): - 0.1.5 reads a stored session through an explicit read handle (open(id,'read') -> handle.read() -> close()). src/session-store.ts owns that protocol; every cold read (sidechat transcript, cold-resume preset, session.cwd, changes replay) goes through it. Dead code and docs: - drop the remote.session.openWorkspacePath interception: 0.1.5's chat opens files through ctx.sidebarRight.openResource instead, so the wrapper had no caller and would hijack the host's "open in app" gesture; the interceptOpenPath pref, its settings row and its locale keys go with it - AGENTS.md §3 + external-plugin-guide.md describe the new baseline - vitest setup bridges Node's localStorage accessor to jsdom's store (the pre-existing 26 failures on Node >= 22) - desktop-layout e2e seeds through host RPC and types into the Lexical composer (0.1.5 replaced the textarea) instead of driving the directory picker Verified: pnpm typecheck / lint / build / test (124 files, 1327 tests) / check:consumer-types, plus pnpm test:mount against a real @deepseek-ai/dsh@0.1.5-alpha.1 host (18/18).
This commit is contained in:
@@ -10,9 +10,9 @@
|
||||
* not a mock, so the class of bug cannot silently return.
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { Session, SessionLogOffset } from '@deepseek-ai/dsh-session'
|
||||
import { Session, SessionLogOffset, SESSION_FORMAT_VERSION } from '@deepseek-ai/dsh-session'
|
||||
import type { SessionId } from '@deepseek-ai/dsh-session'
|
||||
import { Inbox } from '@deepseek-ai/dsh-agent'
|
||||
import type { InboxState } from '@deepseek-ai/dsh-agent'
|
||||
import { snapshotSubagentDescriptor } from '@deepseek-ai/dsh-subagent'
|
||||
import type { SidebarSessionEvent } from '../src/context-types.ts'
|
||||
import { buildSidechatInheritance } from '../src/sidechat-core.ts'
|
||||
@@ -42,19 +42,20 @@ function assistantMessage(text: string): Record<string, unknown> {
|
||||
}
|
||||
|
||||
/** A parent log with a completed turn, a pending question, and an open
|
||||
* in-progress turn (the exact shape a mid-stream thread creation sees). */
|
||||
* in-progress turn (the exact shape a mid-stream thread creation sees).
|
||||
* DSH 0.1.5 logs nothing for the in-flight step: its deltas are
|
||||
* process-local `agent/assistant-stream` frames, not session events. */
|
||||
function parentLog(): SidebarSessionEvent[] {
|
||||
return [
|
||||
ev('user/message', 0, userMessage('first question')),
|
||||
ev('turn/start', 1, { turn: 1 }),
|
||||
ev('step/start', 2, { turn: 1, step: 1 }),
|
||||
ev('assistant/message', 3, { turn: 1, step: 1, message: assistantMessage('first answer') }),
|
||||
ev('assistant/message', 3, { turn: 1, step: 1, message: assistantMessage('first answer'), stream: [] }),
|
||||
ev('step/end', 4, { turn: 1, step: 1 }),
|
||||
ev('turn/end', 5, { turn: 1, reason: { kind: 'completed' } }),
|
||||
ev('user/message', 6, userMessage('pending question')),
|
||||
ev('turn/start', 7, { turn: 2 }),
|
||||
ev('step/start', 8, { turn: 2, step: 1 }),
|
||||
ev('assistant/chunk', 9, { turn: 2, step: 1, chunk: { type: 'text-delta', index: 0, text: 'in-progress' } }),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -68,7 +69,7 @@ describe('sidechat seed against the real dsh-session validator', () => {
|
||||
const types = child.snapshotEvents().map(event => event.type)
|
||||
expect(types).toEqual([
|
||||
'user/message', 'turn/start', 'step/start', 'assistant/message', 'step/end', 'turn/end',
|
||||
'user/message', 'turn/start', 'step/start', 'assistant/chunk', 'step/end', 'turn/end',
|
||||
'user/message', 'turn/start', 'step/start', 'step/end', 'turn/end',
|
||||
'session/end-seed',
|
||||
])
|
||||
// The synthetic close is honest: the frozen turn ends interrupted.
|
||||
@@ -113,18 +114,24 @@ describe('sidechat seed against the real dsh-session validator', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('sidechat seed fork markers vs the real dsh-agent Inbox replay', () => {
|
||||
describe('sidechat seed fork markers vs the reconstructed inbox', () => {
|
||||
/**
|
||||
* Regression: the thread-create call originally passed `seed` WITHOUT the
|
||||
* fork-marker pair (`meta.isSeeded: true` + `inheritedEventCount`). A seed
|
||||
* without them is REPLAY history, not an inherited prefix, so the child's
|
||||
* ownEvents() includes the whole seed and its Inbox constructor replays the
|
||||
* ownEvents() includes the whole seed and its inbox fold replays the
|
||||
* parent's `agent/inbox/spliced` events — inheriting whatever input sat
|
||||
* UNCLAIMED in the parent at the click moment (a queued follow-up, or a
|
||||
* tool-result context spliced into next-step between step boundaries of a
|
||||
* long-running turn). The first side prompt then claimed and SENT that stale
|
||||
* message before the boundary + question. These tests run the REAL
|
||||
* dsh-session Session and dsh-agent Inbox.
|
||||
* message before the boundary + question.
|
||||
*
|
||||
* The fold below is the standard inbox projection's rule
|
||||
* (`inboxProjectionDefinition` in `@deepseek-ai/dsh-agent-loop/inbox`,
|
||||
* which 0.1.5 does not re-export from the package root): pending input is
|
||||
* reconstructed from the session's OWN splice events, so the
|
||||
* `inheritedEventCount` the marker pair supplies is exactly what keeps the
|
||||
* inherited prefix out of it.
|
||||
*/
|
||||
const pendingMessage = (id: string, kind: string, text: string) => ({
|
||||
id,
|
||||
@@ -133,15 +140,24 @@ describe('sidechat seed fork markers vs the real dsh-agent Inbox replay', () =>
|
||||
source: { kind },
|
||||
})
|
||||
const inboxOver = (session: Session): { nextTurn: number; nextStep: number } => {
|
||||
const inbox = new Inbox(session, { inserted() {}, discarded() {}, claimed() {} })
|
||||
return { nextTurn: inbox.nextTurn.length, nextStep: inbox.nextStep.length }
|
||||
let state: InboxState = { 'next-turn': [], 'next-step': [] }
|
||||
for (const event of session.ownEvents()) {
|
||||
if (event.type !== 'agent/inbox/spliced') continue
|
||||
const splice = event.data
|
||||
const list = state[splice.target]
|
||||
state = {
|
||||
...state,
|
||||
[splice.target]: list.toSpliced(splice.start, splice.removedCount ?? 0, ...splice.inserted),
|
||||
}
|
||||
}
|
||||
return { nextTurn: state['next-turn'].length, nextStep: state['next-step'].length }
|
||||
}
|
||||
/** The shape the routes pass since the fix: isSeeded + inheritedEventCount. */
|
||||
const forkMarkedSession = (id: string, seed: readonly SidebarSessionEvent[]): Session =>
|
||||
Session.create(
|
||||
id as SessionId,
|
||||
seed as never,
|
||||
{ version: 0, id: id as SessionId, createdAt: Date.now(), isSeeded: true },
|
||||
{ version: SESSION_FORMAT_VERSION, id: id as SessionId, createdAt: Date.now(), isSeeded: true },
|
||||
SessionLogOffset(seed.length),
|
||||
)
|
||||
/** Real loop order: inbox insert → turn/start → claim deletion → step/start
|
||||
@@ -152,7 +168,7 @@ describe('sidechat seed fork markers vs the real dsh-agent Inbox replay', () =>
|
||||
ev('agent/inbox/spliced', 2, { target: 'next-turn', start: 0, removedCount: 1, inserted: [] }),
|
||||
ev('step/start', 3, { turn: 1, step: 1 }),
|
||||
ev('user/message', 4, pendingMessage('m-q', 'user', 'q')),
|
||||
ev('assistant/message', 5, { turn: 1, step: 1, message: assistantMessage('a') }),
|
||||
ev('assistant/message', 5, { turn: 1, step: 1, message: assistantMessage('a'), stream: [] }),
|
||||
ev('step/end', 6, { turn: 1, step: 1 }),
|
||||
ev('turn/end', 7, { turn: 1, reason: { kind: 'completed' } }),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user