Files
deepseek-harness/packages/session/session-title-all-messages-llm/tests/provider.spec.ts
imccyu ec601ca13d build(vendor): rescope the vendored Cordis packages into @deepseek-ai
Machine-produced by `pnpm run rescope-vendor --apply` plus the regeneration it
prints: `pnpm install` for the lockfile, `pnpm run gen-third-party-notices`,
`verify-translation-pairing --write` for the touched bilingual pairs,
`gen-doc-graphs`, and one typert snapshot whose ids embed character offsets.
`pnpm run rescope-vendor --check` verifies the result.

Renames nine vendored packages (cordis, cosmokit, schemastery and the six
@cordisjs plugins) and every reference that resolves them: manifest names and
dependency keys, module specifiers including declare-module merges, cordis.yml
plugin names, tsconfig paths, every Markdown fence, and `docs/` prose.
Directory names, upstream versions, and dependency ranges are unchanged, so
vendor/README.md still reads as an upstream snapshot; its manifest table gains
an upstream-name column so THIRD_PARTY_NOTICES keeps MIT attribution pointed
at each fork's origin.

The tutorial tier follows the rename end to end: its yaml fences named plugins
the Loader can no longer resolve, its `ts ignore-check` fences disagreed with
the compiled fences beside them, and its prose quoted both. The contracts that
told readers to keep upstream names — the root convention and the vendoring
cookbook's tree comment and manifest invariant — now say to rescope instead.

Two rules read `@deepseek-ai/` as "another workspace plugin": the client bundle
purity gate now names the vendored libraries a browser bundle inlines, and the
files where a bare `cordis` is an agent-preset id keep that product data.
2026-08-10 22:04:13 +08:00

74 lines
3.1 KiB
TypeScript

import { Context } from '@deepseek-ai/cordis'
import { describe, expect, it } from 'vitest'
import LlmService, { createUserMessage, LlmAdapter } from '@deepseek-ai/dsh-llm'
import type { GenerateOptions, StreamChunk } from '@deepseek-ai/dsh-llm'
import SessionStore, { Session, SessionId } from '@deepseek-ai/dsh-session'
import SessionTitleService from '@deepseek-ai/dsh-session-title'
import * as providerPlugin from '@deepseek-ai/dsh-session-title-all-messages-llm'
class RecordingAdapter extends LlmAdapter {
readonly requests: GenerateOptions[] = []
override async * stream(options: GenerateOptions): AsyncIterable<StreamChunk> {
this.requests.push(options)
yield { type: 'text-delta', index: 0, text: 'All messages model title' }
yield { type: 'finish', reason: { kind: 'stop' } }
}
}
const TITLE_CONFIG = { fallbackMaxWords: 5, fallbackMaxBytes: 40, maxTitleBytes: 80 } as const
const LLM_CONFIG = {
targetWords: 5,
targetCjkCharacters: 10,
maxInputBytes: 1_000,
maxOutputTokens: 32,
timeoutMs: 1_000,
} as const
async function settle(): Promise<void> {
await new Promise(resolve => setTimeout(resolve, 0))
}
describe('all-messages LLM title provider', () => {
it('includes seeded history and the latest prompt while inheriting the logged request route', async () => {
const seeded = Session.create(SessionId('seed-source'))
seeded.append('turn/start', { turn: 1 })
const inherited = seeded.append('user/message', createUserMessage({
content: [{ type: 'text', text: 'inherited prompt' }], source: { kind: 'user' },
}), { surfaceOp: 'append' })
seeded.append('session/title', {
title: 'Inherited fallback', messageSeqs: [inherited.seq], source: { kind: 'fallback' },
})
seeded.append('turn/end', { turn: 1, reason: { kind: 'completed' } })
const ctx = new Context()
await ctx.plugin(LlmService)
await ctx.plugin(SessionStore)
await ctx.plugin(SessionTitleService, TITLE_CONFIG)
const adapter = new RecordingAdapter()
ctx.llm.registerAdapter(['current-route'], adapter)
await ctx.plugin(providerPlugin, LLM_CONFIG)
const session = ctx.sessions.create(SessionId('all-plugin'), {
seed: seeded.events,
meta: { parentSession: seeded.id, seedLength: seeded.seq },
})
session.append('turn/start', { turn: 2 })
const latest = session.append('user/message', createUserMessage({
content: [{ type: 'text', text: 'latest prompt' }], source: { kind: 'user' },
}), { surfaceOp: 'append' })
await settle()
session.append('request/header', {
header: { config: { provider: 'current-route', model: 'current-model' } }, reason: 'resume',
})
await settle()
expect(adapter.requests[0]).toMatchObject({ provider: 'current-route', model: 'current-model' })
const content = adapter.requests[0]?.messages[0]?.content[0]
expect(content?.type === 'text' && content.text).toContain('inherited prompt')
expect(content?.type === 'text' && content.text).toContain('latest prompt')
expect(ctx.sessionTitle.get(session)).toMatchObject({
messageSeqs: [inherited.seq, latest.seq],
})
})
})