@deepseek-ai/dsh-llm-deepseek-api-key 0.2.2-rc.1 → 0.2.2-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.i18n.yaml CHANGED
@@ -18,8 +18,8 @@
18
18
  en: 007427bed9bd469b
19
19
  zh: 5089b5781746357f
20
20
  /deepseek-ai-dsh-llm-deepseek-api-key/understand-the-implementation:
21
- en: d614c1ea3a9eb382
22
- zh: 5ca070349bb22d56
21
+ en: 1b9584855817eddb
22
+ zh: feb2c883ca355d31
23
23
  /deepseek-ai-dsh-llm-deepseek-api-key/further-exploration:
24
24
  en: 347659458510940c
25
25
  zh: ccfb03e18b356a39
package/README.md CHANGED
@@ -55,7 +55,7 @@ The settings namespace is the Cordis entry id, or the plugin name without an ent
55
55
  <a id="understand-the-implementation"></a>
56
56
  ## Understand the implementation
57
57
 
58
- Registrations and listeners dispose with the plugin, and disposal aborts an in-flight listing request. Shared Host wiring supplies attachments, request extensions, anonymous identity, and atomic retry-policy updates; this plugin registers only its own route and uses the transport's `connect` and `admit` hooks for the listed catalog and the gate. The listing request, its cache, and catalog resolution come from the shared transport; the cache lives in memory and is keyed by endpoint and a SHA-256 of the key, so another key loads its own listing. A `loader/volatile-update` listener discards the cached listing whenever the route starts or stops following it.
58
+ API-key lookup calls `resolveDeepSeekApiKey` from the [shared credential module](../llm-deepseek/src/credential.ts). Registrations and listeners dispose with the plugin, and disposal aborts an in-flight listing request. Shared Host wiring supplies attachments, request extensions, anonymous identity, and atomic retry-policy updates; this plugin registers only its own route and uses the transport's `connect` and `admit` hooks for the listed catalog and the gate. The listing request, its cache, and catalog resolution come from the shared transport; the cache lives in memory and is keyed by endpoint and a SHA-256 of the key, so another key loads its own listing. A `loader/volatile-update` listener discards the cached listing whenever the route starts or stops following it.
59
59
 
60
60
  <a id="further-exploration"></a>
61
61
  ## Further Exploration
package/README.zh.md CHANGED
@@ -55,7 +55,7 @@ kind: "package-reference"
55
55
  <a id="understand-the-implementation"></a>
56
56
  ## 理解实现
57
57
 
58
- 注册和监听随插件生命周期释放,释放时会中止进行中的列表请求。共享 Host 绑定提供附件访问、请求扩展、匿名标识和重试策略的原子更新;本包只注册自己的路由,并通过传输层的 `connect` 与 `admit` 钩子接入列表目录和门控。列表请求、缓存和目录解析来自共享传输包;缓存只在内存中,以端点和 API key 的 SHA-256 为键,因此换一个 key 会加载它自己的列表。一个 `loader/volatile-update` 监听器在路由开始或停止使用列表时丢弃缓存的列表。
58
+ API key 读取调用[共享凭据模块](../llm-deepseek/src/credential.ts)的 `resolveDeepSeekApiKey`。注册和监听随插件生命周期释放,释放时会中止进行中的列表请求。共享 Host 绑定提供附件访问、请求扩展、匿名标识和重试策略的原子更新;本包只注册自己的路由,并通过传输层的 `connect` 与 `admit` 钩子接入列表目录和门控。列表请求、缓存和目录解析来自共享传输包;缓存只在内存中,以端点和 API key 的 SHA-256 为键,因此换一个 key 会加载它自己的列表。一个 `loader/volatile-update` 监听器在路由开始或停止使用列表时丢弃缓存的列表。
59
59
 
60
60
  <a id="further-exploration"></a>
61
61
  ## 进一步探索
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { APP_IDENTITY, LlmError, assertUsableApiKey } from "@deepseek-ai/dsh-llm";
1
+ import { APP_IDENTITY, LlmError } from "@deepseek-ai/dsh-llm";
2
2
  import { launchEnvironmentOf } from "@deepseek-ai/dsh-launch-environment";
3
- import { PUBLIC_BASE_URL, catalogModelInfo, createModelListingCache, deepSeekConfigFields, isBuiltInCatalog, modelListingConfigFields, modelListingURL, plainOptions as plainOptions$1, refuseListedModel, registerDeepSeekProvider, requestModelListing, resolveAdapterOptions as resolveAdapterOptions$1, resolveListedCatalog, resolveListingTiming } from "@deepseek-ai/dsh-llm-deepseek";
3
+ import { PUBLIC_BASE_URL, catalogModelInfo, createModelListingCache, deepSeekConfigFields, isBuiltInCatalog, modelListingConfigFields, modelListingURL, plainOptions as plainOptions$1, refuseListedModel, registerDeepSeekProvider, requestModelListing, resolveAdapterOptions as resolveAdapterOptions$1, resolveDeepSeekApiKey, resolveListedCatalog, resolveListingTiming } from "@deepseek-ai/dsh-llm-deepseek";
4
4
  import z from "@deepseek-ai/schemastery";
5
5
  import { credentialRef } from "@deepseek-ai/dsh-credentials";
6
6
  //#region lib/types/config.js
@@ -52,14 +52,8 @@ function apply(ctx, config) {
52
52
  options();
53
53
  const resolveApiKey = async (connection) => {
54
54
  const ref = connection.apiKeyEnv;
55
- const credentials = ctx.get("credentials");
56
- if (credentials !== void 0) {
57
- const hit = await credentials.resolve(ref);
58
- if (hit !== void 0) return assertUsableApiKey(hit.value, "llm-deepseek", ref);
59
- } else {
60
- const ambient = launchEnvironmentOf(ctx).get(ref);
61
- if (ambient !== void 0 && ambient.value.length > 0) return assertUsableApiKey(ambient.value, "llm-deepseek", ref);
62
- }
55
+ const key = await resolveDeepSeekApiKey(ctx, ref);
56
+ if (key !== void 0) return key;
63
57
  throw new LlmError(`llm-deepseek: no API key for provider route "${PROVIDER}"; store ${ref} through the credentials service (the web Models page writes it), or export ${ref} in the launching environment`, "MISSING_CREDENTIAL");
64
58
  };
65
59
  /** The API key, or `undefined` when none is configured; other credential failures propagate. */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AACxC,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAChF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAA;AAKpF,OAAO,KAAK,EACV,MAAM,IAAI,cAAc,EAAE,yBAAyB,EAAE,eAAe,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,OAAO,IAAI,eAAe,EAC1I,MAAM,+BAA+B,CAAA;AAKtC,mEAAmE;AAC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M,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAA;YAC1E,CAAC;YACD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;YACpD,IAAI,CAAC,IAAI,CAAC,aAAa;gBAAE,OAAO,EAAE,CAAA;YAClC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;YAC1D,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;QACtF,CAAC;KACF,CAAC,CAAA;IACF,oFAAoF;IACpF,wEAAwE;IACxE,IAAI,SAAS,GAAG,OAAO,EAAE,CAAC,OAAO,KAAK,SAAS,CAAA;IAC/C,GAAG,CAAC,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE;QACpC,IAAI,IAAa,CAAA;QACjB,4EAA4E;QAC5E,IAAI,CAAC;YAAC,IAAI,GAAG,OAAO,EAAE,CAAC,OAAO,KAAK,SAAS,CAAA;QAAC,CAAC;QAC9C,OAAO,sBAAsB,EAAE,CAAC;YAAC,OAAM;QAAC,CAAC;QACzC,IAAI,IAAI,KAAK,SAAS;YAAE,QAAQ,CAAC,UAAU,EAAE,CAAA;QAC7C,SAAS,GAAG,IAAI,CAAA;IAClB,CAAC,CAAC,CAAA;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-llm-deepseek-api-key",
3
3
  "description": "DeepSeek api-key provider authentication and discovery",
4
- "version": "0.2.2-rc.1",
4
+ "version": "0.2.2-rc.3",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -25,23 +25,26 @@
25
25
  "files": [
26
26
  "locale/*.json",
27
27
  "lib/index.js",
28
- "lib/types/**/*.d.ts"
28
+ "lib/types/**/*.d.ts",
29
+ "lib/types/**/*.d.ts.map",
30
+ "lib/**/*.js.map",
31
+ "src"
29
32
  ],
30
33
  "license": "MIT",
31
34
  "peerDependencies": {
32
35
  "@deepseek-ai/cordis": "~4.1.0",
33
- "@deepseek-ai/dsh-llm": "0.2.2-rc.1",
34
- "@deepseek-ai/dsh-llm-deepseek": "0.2.2-rc.1",
35
- "@deepseek-ai/dsh-launch-environment": "0.2.2-rc.1",
36
- "@deepseek-ai/dsh-credentials": "0.2.2-rc.1",
36
+ "@deepseek-ai/dsh-llm": "0.2.2-rc.3",
37
+ "@deepseek-ai/dsh-llm-deepseek": "0.2.2-rc.3",
38
+ "@deepseek-ai/dsh-launch-environment": "0.2.2-rc.3",
39
+ "@deepseek-ai/dsh-credentials": "0.2.2-rc.3",
37
40
  "@deepseek-ai/cordis-plugin-loader": "~1.1.0"
38
41
  },
39
42
  "devDependencies": {
40
43
  "@deepseek-ai/cordis": "~4.1.0",
41
- "@deepseek-ai/dsh-llm": "0.2.2-rc.1",
42
- "@deepseek-ai/dsh-llm-deepseek": "0.2.2-rc.1",
43
- "@deepseek-ai/dsh-launch-environment": "0.2.2-rc.1",
44
- "@deepseek-ai/dsh-credentials": "0.2.2-rc.1",
44
+ "@deepseek-ai/dsh-llm": "0.2.2-rc.3",
45
+ "@deepseek-ai/dsh-llm-deepseek": "0.2.2-rc.3",
46
+ "@deepseek-ai/dsh-launch-environment": "0.2.2-rc.3",
47
+ "@deepseek-ai/dsh-credentials": "0.2.2-rc.3",
45
48
  "@deepseek-ai/cordis-plugin-loader": "~1.1.0"
46
49
  },
47
50
  "peerDependenciesMeta": {
package/src/config.ts ADDED
@@ -0,0 +1,61 @@
1
+ /** API-key configuration resolved together with one Messages endpoint generation and its model listing. */
2
+ import type { Volatile } from '@deepseek-ai/cordis'
3
+ import z from '@deepseek-ai/schemastery'
4
+ import { credentialRef, type CredentialRef } from '@deepseek-ai/dsh-credentials'
5
+ import type { LaunchEnvironmentSnapshot } from '@deepseek-ai/dsh-launch-environment'
6
+ import {
7
+ deepSeekConfigFields, isBuiltInCatalog, modelListingConfigFields, modelListingURL, plainOptions as protocolOptions, PUBLIC_BASE_URL,
8
+ resolveAdapterOptions as resolveProtocolOptions, resolveListingTiming,
9
+ } from '@deepseek-ai/dsh-llm-deepseek'
10
+ import type {
11
+ Config as ProtocolConfig, DeepSeekConnectionOptions, ListingSettings, ModelListingConfig, ModelListingOptions, Options as ProtocolOptions,
12
+ } from '@deepseek-ai/dsh-llm-deepseek'
13
+
14
+ /** Origin of the official API, the only endpoint whose `/models` listing this route follows. */
15
+ const OFFICIAL_ORIGIN = new URL(PUBLIC_BASE_URL).origin
16
+
17
+ /** Messages configuration with a per-request API-key reference. */
18
+ export interface Config extends ProtocolConfig, ModelListingConfig {
19
+ /** Credential reference resolved per request; defaults to DEEPSEEK_API_KEY. */
20
+ apiKeyEnv: Volatile<string>
21
+ }
22
+ export const Config = z.object({
23
+ ...deepSeekConfigFields,
24
+ ...modelListingConfigFields,
25
+ apiKeyEnv: z.string().role('credential-ref').default('DEEPSEEK_API_KEY').volatile(),
26
+ })
27
+ /** Plain deployment inputs for the API-key provider. */
28
+ export type Options = ProtocolOptions & ModelListingOptions & { apiKeyEnv?: string }
29
+ /** Endpoint and credential reference captured from the same configuration generation. */
30
+ export interface ResolvedDeepSeekOptions extends DeepSeekConnectionOptions {
31
+ /** Credential reference used only for this connection snapshot. */
32
+ apiKeyEnv: CredentialRef
33
+ /**
34
+ * The official `/models` listing this generation follows; absent when `models`
35
+ * differs from the built-in catalog or the endpoint is not the official API.
36
+ */
37
+ listing?: ListingSettings
38
+ }
39
+ /** Read one validated provider configuration.
40
+ * @param config - live plugin configuration.
41
+ * @returns detached resolver inputs.
42
+ */
43
+ export function plainOptions(config: Config): Options {
44
+ return { ...protocolOptions(config), apiKeyEnv: config.apiKeyEnv.get() }
45
+ }
46
+ /** Resolve API-key, listing, and protocol settings together.
47
+ * @param config - raw deployment settings.
48
+ * @param environment - application launch environment.
49
+ * @returns validated endpoint facts, the matching credential reference, and the listing the catalog follows.
50
+ */
51
+ export function resolveAdapterOptions(config: Options, environment?: LaunchEnvironmentSnapshot): ResolvedDeepSeekOptions {
52
+ const { modelsTimeoutMs: _timeout, modelsMaxAgeMs: _maxAge, apiKeyEnv, ...messages } = config
53
+ const timing = resolveListingTiming(config, 'llm-deepseek-api-key')
54
+ const connection = resolveProtocolOptions(messages, environment)
55
+ const listed = new URL(connection.baseURL).origin === OFFICIAL_ORIGIN && isBuiltInCatalog(connection.models)
56
+ return {
57
+ ...connection,
58
+ apiKeyEnv: credentialRef(apiKeyEnv ?? 'DEEPSEEK_API_KEY'),
59
+ ...listed ? { listing: { url: modelListingURL(connection.baseURL), ...timing } } : {},
60
+ }
61
+ }
package/src/index.ts ADDED
@@ -0,0 +1,124 @@
1
+ /** API-key authentication, credential-gated discovery, and the official model listing for the official DeepSeek route. */
2
+ import type { Context } from '@deepseek-ai/cordis'
3
+ import { APP_IDENTITY, LlmError } from '@deepseek-ai/dsh-llm'
4
+ import type { LlmModelBadge } from '@deepseek-ai/dsh-llm'
5
+ import type {} from '@deepseek-ai/cordis-plugin-loader'
6
+ import { launchEnvironmentOf } from '@deepseek-ai/dsh-launch-environment'
7
+ import {
8
+ catalogModelInfo, createModelListingCache, refuseListedModel, registerDeepSeekProvider, requestModelListing, resolveListedCatalog,
9
+ resolveDeepSeekApiKey,
10
+ } from '@deepseek-ai/dsh-llm-deepseek'
11
+ import type { CatalogRefusal, DeepSeekCatalogModel, ListingView, ModelListing } from '@deepseek-ai/dsh-llm-deepseek'
12
+ import { Config, plainOptions, resolveAdapterOptions } from './config.ts'
13
+ import type { ResolvedDeepSeekOptions } from './config.ts'
14
+
15
+ export { Config, plainOptions, resolveAdapterOptions } from './config.ts'
16
+ export type { Options, ResolvedDeepSeekOptions } from './config.ts'
17
+ export const name = 'llm-deepseek-api-key'
18
+ export const inject = ['llm']
19
+
20
+ const PROVIDER = 'deepseek-official'
21
+ /** Console tag of listing diagnostics; product profiles mount no console exporter for `ctx.logger`. */
22
+ const LOG_TAG = '[llm-deepseek-api-key]'
23
+
24
+ /** Connection facts of one operation: protocol settings plus the catalog resolved with them. */
25
+ interface OfficialConnection extends ResolvedDeepSeekOptions {
26
+ /** Selectable models: the configured catalog, or the offered part of the followed listing. */
27
+ readonly offered: readonly DeepSeekCatalogModel[]
28
+ /** Listed models refused before network I/O, by id. */
29
+ readonly refusals: ReadonlyMap<string, CatalogRefusal>
30
+ /** Listed badges of offered models, by id; empty without a followed listing. */
31
+ readonly badges: ReadonlyMap<string, LlmModelBadge>
32
+ }
33
+
34
+ export function apply(ctx: Context, config: Config): void {
35
+ const options = () => resolveAdapterOptions(plainOptions(config), launchEnvironmentOf(ctx))
36
+ options()
37
+ const resolveApiKey = async (connection: ResolvedDeepSeekOptions): Promise<string> => {
38
+ const ref = connection.apiKeyEnv
39
+ const key = await resolveDeepSeekApiKey(ctx, ref)
40
+ if (key !== undefined) return key
41
+ throw new LlmError(
42
+ `llm-deepseek: no API key for provider route "${PROVIDER}"; store ${ref} through the credentials`
43
+ + ` service (the web Models page writes it), or export ${ref} in the launching environment`,
44
+ 'MISSING_CREDENTIAL',
45
+ )
46
+ }
47
+ /** The API key, or `undefined` when none is configured; other credential failures propagate. */
48
+ const presentApiKey = async (connection: ResolvedDeepSeekOptions): Promise<string | undefined> => {
49
+ try { return await resolveApiKey(connection) }
50
+ catch (error) {
51
+ if (error instanceof LlmError && error.code === 'MISSING_CREDENTIAL') return undefined
52
+ throw error
53
+ }
54
+ }
55
+ const listings = createModelListingCache(ctx, name, PROVIDER, {
56
+ settings: () => options().listing,
57
+ credential: async () => presentApiKey(options()),
58
+ load: (url, apiKey, signal) => requestModelListing(url, { 'x-api-key': apiKey }, signal),
59
+ })
60
+ let reportedListing: ModelListing | undefined
61
+ /** Resolve the catalog, reporting each listing's hidden entries and dropped badges once. */
62
+ const connectionOf = (connection: ResolvedDeepSeekOptions, view: ListingView | undefined): OfficialConnection => {
63
+ if (view === undefined) return { ...connection, offered: connection.models, refusals: new Map(), badges: new Map() }
64
+ const catalog = resolveListedCatalog({
65
+ listing: view.listing?.entries,
66
+ supported: connection.models,
67
+ overrides: {},
68
+ routeMaxTokens: connection.maxTokens,
69
+ clientVersion: APP_IDENTITY.version,
70
+ })
71
+ if (view.listing !== reportedListing) {
72
+ reportedListing = view.listing
73
+ for (const problem of catalog.problems) console.warn(LOG_TAG, problem)
74
+ }
75
+ return { ...connection, models: catalog.resolution, offered: catalog.offered, refusals: catalog.refusals, badges: catalog.badges }
76
+ }
77
+ ctx.llm.registerConfigurableProviders([
78
+ { provider: PROVIDER, displayName: 'DeepSeek', settingsNs: ctx.fiber.entry?.options.id ?? name, settingsPath: [] },
79
+ ])
80
+ registerDeepSeekProvider<OfficialConnection>(ctx, PROVIDER, {
81
+ providerName: 'DeepSeek',
82
+ options: () => {
83
+ const connection = options()
84
+ return connectionOf(connection, connection.listing === undefined ? undefined : listings.current())
85
+ },
86
+ connect: async (signal) => {
87
+ const connection = options()
88
+ if (connection.listing === undefined) return connectionOf(connection, undefined)
89
+ let view: ListingView
90
+ try { view = await listings.view(connection.listing, signal) }
91
+ catch (error) {
92
+ if (signal?.aborted === true) throw error
93
+ // The cache keeps the previous credential's listing when this lookup fails, so gate nothing;
94
+ // `resolveAuth` reports the failure on the model request, after the turn records the prompt.
95
+ return connectionOf(connection, undefined)
96
+ }
97
+ return connectionOf(connection, view)
98
+ },
99
+ resolveAuth: async connection => ({ headers: { 'x-api-key': await resolveApiKey(connection) } }),
100
+ admit: (connection, model) => { refuseListedModel(model, connection.refusals.get(model)) },
101
+ discoverModels: async (provider) => {
102
+ const connection = options()
103
+ if (connection.listing === undefined) {
104
+ if (await presentApiKey(connection) === undefined) return []
105
+ return connection.models.map(model => catalogModelInfo(provider, model))
106
+ }
107
+ const view = await listings.view(connection.listing)
108
+ if (!view.authenticated) return []
109
+ const { offered, badges } = connectionOf(connection, view)
110
+ return offered.map(model => catalogModelInfo(provider, model, badges.get(model.id)))
111
+ },
112
+ })
113
+ // Starting or stopping to follow the listing discards it, so restoring the built-in
114
+ // catalog after a customization reloads the listing on the next access.
115
+ let following = options().listing !== undefined
116
+ ctx.on('loader/volatile-update', () => {
117
+ let next: boolean
118
+ // The transport's own listener reports a configuration the adapter rejects.
119
+ try { next = options().listing !== undefined }
120
+ catch (_rejectedConfiguration) { return }
121
+ if (next !== following) listings.invalidate()
122
+ following = next
123
+ })
124
+ }