`LlmAdapter.routeCredential(provider)` publishes the credential a route currently sends: kind, resolved base URL, optional reference, a value-free presence check, and per-endpoint grants carrying protocol headers, the bare value, and an optional 401 invalidation. `LlmRuntime.routeCredential()` forwards to the owning adapter. `dsh-llm-deepseek` reads no credential: `resolveAuth(connection, endpoint)` returns a grant or `undefined`, `missingCredential` names the failure, and `credential` declares the publication. The route plugins own their credentials through the new `dsh-credentials` reference helpers and the account service's `resolveRequestCredential()`; the account route also owns sign-out cancellation and registers a running-task report. The account service inspects no Agents, drops its `dsh-agent` and `dsh-llm` peers, and moves to `packages/account/`. The web providers consume route publications and drop their dependencies on `dsh-llm-deepseek`, the route plugins, and the Loader. Documented in the Agent Note and the `llm-route-credential` upgrade guide.
32 lines
1.7 KiB
TypeScript
32 lines
1.7 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { credentialRef } from '@deepseek-ai/dsh-credentials'
|
|
import { DeepSeekFetchApiProvider, DeepSeekSearchApiProvider } from '@deepseek-ai/dsh-web-deepseek-api'
|
|
import { customGuidance } from './guidance.ts'
|
|
|
|
/** Real Search and Fetch API probes; the base names the deployment the key authenticates. */
|
|
const apiKey = process.env.DEEPSEEK_API_KEY
|
|
const baseURL = process.env.DEEPSEEK_SEARCH_API_TEST_BASE_URL ?? ''
|
|
const auth = { sources: [{
|
|
kind: 'api-key', baseURL,
|
|
key: { ref: credentialRef('DEEPSEEK_API_KEY'), configured: async () => apiKey !== undefined, resolve: async () => apiKey },
|
|
}] } as const
|
|
const maybe = apiKey !== undefined && apiKey.length > 0 && baseURL.length > 0 ? describe : describe.skip
|
|
|
|
maybe('DeepSeek Search and Fetch real API', () => {
|
|
it('returns citeable sources from the Search API', async () => {
|
|
const provider = new DeepSeekSearchApiProvider(() => ({ auth, count: 10, requestsPerSecond: 5, guidance: customGuidance('search') }))
|
|
const result = await provider.search({ query: 'DeepSeek', maxResults: 3 }, AbortSignal.timeout(30_000))
|
|
expect(result.sources.length).toBeGreaterThan(0)
|
|
expect(result.sources.length).toBeLessThanOrEqual(3)
|
|
for (const source of result.sources) expect(source.url).toMatch(/^https?:\/\//)
|
|
}, 40_000)
|
|
|
|
it('returns Markdown from the Fetch API', async () => {
|
|
const provider = new DeepSeekFetchApiProvider(() => ({ auth, guidance: customGuidance('fetch') }))
|
|
const result = await provider.fetch({ url: 'https://example.com' }, AbortSignal.timeout(30_000))
|
|
expect(result.body.kind).toBe('text')
|
|
expect(result.body.content.length).toBeGreaterThan(0)
|
|
expect(result.statusCode).toBe(200)
|
|
}, 40_000)
|
|
})
|