refactor(commands): move the command service to Remote

`CommandService.list` and `execute` carry the wire contract directly through
`@Remote`, and the Client assembly mounts the generated commands
contribution. The legacy API Proxy route, its schemas, the map rows, the
generated client methods and the fixture's command domain are removed, so the
catalog and the admission call have one owner again.

`Session.command()` keeps a result-shaped public face for parity with the
prompt, cancel and attachment neighbours it sits beside, and reads the
generated namespace through one `SessionRemotes` parameter. The Session
cluster declares that face against the owning business package rather than the
generated contribution: the Host compiler aggregate builds this package, and
it runs before any contribution is emitted.

Migrated calls lose the `title-invalid` class of protocol-only error codes and
report `internal`; no production caller branched on them.
This commit is contained in:
imccyu
2026-08-11 19:10:31 +08:00
parent a2981207b0
commit 070a2a7f1e
71 changed files with 648 additions and 1129 deletions
@@ -9,7 +9,7 @@
import { afterEach, describe, expect, it, vi } from 'vitest'
import type { SessionEvent } from '@deepseek-ai/dsh-session/types'
import type {} from '@deepseek-ai/dsh-commands/types'
import type { SessionId } from '@deepseek-ai/dsh-client-connection/client'
import type { SessionId } from '@deepseek-ai/dsh-api-remotes/client'
import { Session } from '../src/client/sessions/session.ts'
import type {
ChatConversationViewNode, ChatLocationNodeIndex, ChatNodeStore, ChatSnapshot,
@@ -17,7 +17,7 @@ import type {
ConversationRuntime, ConversationSnapshot, ConversationTimelineSnapshot,
ConversationViewDefinition,
} from '../src/client/index.ts'
import { FakeApiClient, deferred, err, ok } from './fake-api.ts'
import { FakeApiClient, deferred, err, fakeRemote, ok } from './fake-api.ts'
import { entries, ev, plainTurn } from './event-script.ts'
const SID = 'fk-s1' as SessionId
@@ -159,7 +159,7 @@ const TEST_CONVERSATION: ConversationRuntime = {
}
function makeSession(api = new FakeApiClient()): { api: FakeApiClient; session: Session } {
return { api, session: new Session(SID, api, { conversation: TEST_CONVERSATION }) }
return { api, session: new Session(SID, api, fakeRemote(), { conversation: TEST_CONVERSATION }) }
}
function chatEvents(snapshot: ConversationSnapshot): readonly TestEventState[] {
@@ -343,7 +343,7 @@ describe('live event path', () => {
entries: () => [testViewDefinition()],
} as unknown as ConversationRuntime['views'],
}
const session = new Session(SID, api, { conversation })
const session = new Session(SID, api, fakeRemote(), { conversation })
await session.open()
const snapshots: ConversationSnapshot[] = []
session.subscribe(() => { snapshots.push(session.getSnapshot()) })
@@ -448,7 +448,7 @@ describe('paging', () => {
describe('prompt and cancel errors', () => {
it('routes an addressed child through non-activating history, continuation prompt, and interrupt only', async () => {
const api = new FakeApiClient()
const session = new Session(SID, api, {
const session = new Session(SID, api, fakeRemote(), {
address: { parentSessionId: PARENT, childSessionId: SID, mode: 'continuable' },
parentAvailable: true,
})
@@ -487,7 +487,7 @@ describe('prompt and cancel errors', () => {
api.onSubagentInterrupt = () => Promise.resolve(err({
code: 'subagent-unauthorized', message: 'nope', details: { childSessionId: SID },
}) as never)
const session = new Session(SID, api, {
const session = new Session(SID, api, fakeRemote(), {
address: { parentSessionId: PARENT, childSessionId: SID, mode: 'continuable' },
parentAvailable: true,
})
@@ -501,7 +501,7 @@ describe('prompt and cancel errors', () => {
it('keeps one-shot history readable without exposing prompt or cancel transport', async () => {
const api = new FakeApiClient()
const session = new Session(SID, api, {
const session = new Session(SID, api, fakeRemote(), {
address: { parentSessionId: PARENT, childSessionId: SID, mode: 'one-shot' },
})
await session.open()