mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
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.
91 lines
3.5 KiB
TypeScript
91 lines
3.5 KiB
TypeScript
/**
|
|
* Wire-to-typed-event bridge: host/commands-changed
|
|
* → ctx 'commands/changed'; host/session-preset-changed →
|
|
* ctx 'session/preset-changed'; each established connection generation →
|
|
* ctx 'connection/reset' (the forced cache-invalidation broadcast).
|
|
*/
|
|
import { Context } from '@deepseek-ai/cordis'
|
|
import { describe, expect, it } from 'vitest'
|
|
import type { ConnectionHandle, ConnectionSinks } from '@deepseek-ai/dsh-client-connection/client'
|
|
import TypertRegistry from '@deepseek-ai/dsh-typert-registry'
|
|
import * as RuntimeClient from '../src/client/index.ts'
|
|
import { FakeApiClient } from './fake-api.ts'
|
|
|
|
interface Bench {
|
|
ctx: Context
|
|
sinks: ConnectionSinks | undefined
|
|
}
|
|
|
|
async function mount(): Promise<Bench> {
|
|
const ctx = new Context()
|
|
await ctx.plugin(TypertRegistry)
|
|
const api = new FakeApiClient()
|
|
const bench: Bench = { ctx, sinks: undefined }
|
|
const handle: ConnectionHandle = {
|
|
api,
|
|
isLoopback: true,
|
|
rpc: {
|
|
call: () => Promise.reject(new Error('unexpected generic RPC call')),
|
|
},
|
|
start: (sinks) => {
|
|
bench.sinks = sinks
|
|
return { stop: () => {} }
|
|
},
|
|
}
|
|
ctx.reflect.provide('connection', handle)
|
|
ctx.reflect.provide('remote', {})
|
|
await ctx.plugin(RuntimeClient).await()
|
|
return bench
|
|
}
|
|
|
|
describe('wire event bridge', () => {
|
|
it('broadcasts commands/changed on a host/commands-changed frame, not on other host frames', async () => {
|
|
const bench = await mount()
|
|
let changed = 0
|
|
bench.ctx.on('commands/changed', () => { changed++ })
|
|
bench.sinks?.onHostEnvelope?.({ rpcId: 'r1' as never, payload: { type: 'host/commands-changed' } })
|
|
expect(changed).toBe(1)
|
|
bench.sinks?.onHostEnvelope?.({
|
|
rpcId: 'r2' as never,
|
|
payload: { type: 'host/session-status', sessionId: 's1' as never, running: true },
|
|
})
|
|
expect(changed).toBe(1)
|
|
})
|
|
|
|
it('broadcasts the settings/credentials/models invalidations with their frame payloads', async () => {
|
|
const bench = await mount()
|
|
const seen: unknown[][] = []
|
|
bench.ctx.on('settings/changed', ns => seen.push(['settings', ns]))
|
|
bench.ctx.on('credentials/changed', ref => seen.push(['credentials', ref]))
|
|
bench.ctx.on('models/changed', () => seen.push(['models']))
|
|
bench.sinks?.onHostEnvelope?.({ rpcId: 'r3' as never, payload: { type: 'host/settings-changed', ns: 'llm-pi-ai' } })
|
|
bench.sinks?.onHostEnvelope?.({ rpcId: 'r4' as never, payload: { type: 'host/credentials-changed', ref: 'OPENAI_API_KEY' } })
|
|
bench.sinks?.onHostEnvelope?.({ rpcId: 'r5' as never, payload: { type: 'host/models-changed' } })
|
|
expect(seen).toEqual([
|
|
['settings', 'llm-pi-ai'],
|
|
['credentials', 'OPENAI_API_KEY'],
|
|
['models'],
|
|
])
|
|
})
|
|
|
|
it('broadcasts session/preset-changed with the recomposed session and its new preset', async () => {
|
|
const bench = await mount()
|
|
const seen: Array<[string, string]> = []
|
|
bench.ctx.on('session/preset-changed', (sessionId, agentPreset) => { seen.push([sessionId, agentPreset]) })
|
|
bench.sinks?.onHostEnvelope?.({
|
|
rpcId: 'r1' as never,
|
|
payload: { type: 'host/session-preset-changed', sessionId: 's1' as never, agentPreset: 'minimal' },
|
|
})
|
|
expect(seen).toEqual([['s1', 'minimal']])
|
|
})
|
|
|
|
it('broadcasts connection/reset on every established generation (reconnect invalidation)', async () => {
|
|
const bench = await mount()
|
|
let resets = 0
|
|
bench.ctx.on('connection/reset', () => { resets++ })
|
|
bench.sinks?.onConnected?.()
|
|
bench.sinks?.onConnected?.() // second generation after a reconnect
|
|
expect(resets).toBe(2)
|
|
})
|
|
})
|