@morlay/dsh-llm-openai-compatible 0.0.1 → 0.0.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 morlay
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -12,15 +12,6 @@ DeepSeek Harness 的 **OpenAI 兼容 LLM 适配器**插件。与内置 `llm-pi-a
12
12
  harness 消息 → AI SDK prompt 转换、采样默认合并、stream part → `StreamChunk`
13
13
  翻译、错误归一化与凭据策略。
14
14
 
15
- ## 安装
16
-
17
- ```sh
18
- dsh plugin --profile web add "@morlay/dsh-llm-openai-compatible"
19
- ```
20
-
21
- 插件默认休眠(空 `providers`):不声明任何 provider 路由,直到你在
22
- `settings.yaml` 中配置。
23
-
24
15
  ## 配置
25
16
 
26
17
  `providers` 是 dict:**key 就是 provider 路由键**(选择器与
package/cordis.patch.yml CHANGED
@@ -6,7 +6,7 @@
6
6
  ollama:
7
7
  apiKeyEnv: OLLAMA_API_KEY
8
8
  baseURL: https://ollama.com/v1
9
- displayName: Ollama Gateway
9
+ displayName: Ollama Cloud
10
10
  temperature: 1 # 0..2
11
11
  topP: 0.95
12
12
  reasoning: high
@@ -14,11 +14,11 @@
14
14
  defaultMaxTokens: 65535
15
15
  models:
16
16
  - id: deepseek-v4-flash:0731
17
- name: "DeepSeek V4 Flash: 0731"
17
+ name: "DeepSeek V4 Flash @ Ollama Cloud"
18
18
  contextWindow: 1000000
19
19
  maxTokens: 65535
20
20
  inputModalities: [text]
21
21
  reasoningEfforts:
22
- off: # off 空值 = 不发送 reasoning_effort
22
+ off:
23
23
  high: high
24
24
  max: max
@@ -0,0 +1,109 @@
1
+ import z from "@deepseek-ai/schemastery";
2
+ import { GenerateOptions, LlmAdapter, LlmModelInfo, LlmProviderInfo, LlmResolvedModelInfo, ModelModality, ResolvedRetryPolicy, RetryPolicyConfig, StreamChunk } from "@deepseek-ai/dsh-llm";
3
+ import { CredentialRef } from "@deepseek-ai/dsh-credentials";
4
+ import "@ai-sdk/provider";
5
+ import { AttachmentStore } from "@deepseek-ai/dsh-attachment";
6
+ import { Context } from "@deepseek-ai/cordis";
7
+ //#region src/adapter.d.ts
8
+ declare const DEFAULT_STREAM_IDLE_TIMEOUT_MS = 300000;
9
+ declare const DEFAULT_CONTEXT_WINDOW = 262144;
10
+ declare const DEFAULT_MAX_TOKENS = 32768;
11
+ declare const DEFAULT_MAX_REQUEST_IMAGE_BYTES: number;
12
+ type ReasoningEffort = "off" | "low" | "high" | "max";
13
+ interface ResolvedModelProfile {
14
+ id: string;
15
+ name?: string;
16
+ description?: string;
17
+ contextWindow?: number;
18
+ maxTokens?: number;
19
+ inputModalities: readonly ModelModality[];
20
+ reasoningEfforts?: false | Partial<Record<ReasoningEffort, string | null>>;
21
+ }
22
+ interface ResolvedProviderProfile {
23
+ provider: string;
24
+ displayName: string;
25
+ apiKeyEnv?: CredentialRef;
26
+ baseURL: string;
27
+ headers?: Readonly<Record<string, string>>;
28
+ temperature?: number;
29
+ topP?: number;
30
+ topK?: number;
31
+ presencePenalty?: number;
32
+ frequencyPenalty?: number;
33
+ seed?: number;
34
+ reasoning?: ReasoningEffort;
35
+ models: readonly ResolvedModelProfile[];
36
+ defaultContextWindow: number;
37
+ defaultMaxTokens: number;
38
+ maxRequestImageBytes: number;
39
+ streamIdleTimeoutMs: number;
40
+ timeoutMs?: number;
41
+ retryPolicy: ResolvedRetryPolicy;
42
+ }
43
+ interface OpenAICompatibleAdapterOptions {
44
+ profiles: () => ReadonlyMap<string, ResolvedProviderProfile>;
45
+ resolveApiKey: (provider: string, profile: ResolvedProviderProfile) => Promise<string | undefined>;
46
+ resolveUserId: () => string;
47
+ resolveAttachments?: () => AttachmentStore | undefined;
48
+ }
49
+ declare class OpenAICompatibleAdapter extends LlmAdapter {
50
+ private readonly config;
51
+ private readonly sdkProviders;
52
+ constructor(config: OpenAICompatibleAdapterOptions);
53
+ private profileOf;
54
+ private modelOf;
55
+ private sdkModel;
56
+ providerInfo(provider: string): LlmProviderInfo;
57
+ providerRetryPolicy(provider: string): ResolvedRetryPolicy | undefined;
58
+ listModels(provider: string): Promise<readonly LlmModelInfo[]>;
59
+ resolveModel(provider: string, model: string, _signal?: AbortSignal): Promise<LlmResolvedModelInfo>;
60
+ stream(options: GenerateOptions): AsyncGenerator<StreamChunk>;
61
+ private normalizeTransportError;
62
+ }
63
+ //#endregion
64
+ //#region src/index.d.ts
65
+ declare const name = "llm-openai-compatible";
66
+ declare const inject: string[];
67
+ declare const NS = "llm-openai-compatible";
68
+ declare const REASONING_LEVELS: readonly ["off", "low", "high", "max"];
69
+ declare const MODEL_MODALITIES: readonly ["text", "image"];
70
+ interface ModelProfileSource {
71
+ id: string;
72
+ name?: string;
73
+ description?: string;
74
+ contextWindow?: number;
75
+ maxTokens?: number;
76
+ inputModalities?: ModelModality[];
77
+ reasoningEfforts?: false | Partial<Record<ReasoningEffort, string | null>>;
78
+ }
79
+ interface ProviderProfileSource {
80
+ apiKeyEnv?: string;
81
+ displayName?: string;
82
+ baseURL: string;
83
+ headers?: Record<string, string>;
84
+ temperature?: number;
85
+ topP?: number;
86
+ topK?: number;
87
+ presencePenalty?: number;
88
+ frequencyPenalty?: number;
89
+ seed?: number;
90
+ reasoning?: ReasoningEffort;
91
+ models?: ModelProfileSource[];
92
+ defaultContextWindow?: number;
93
+ defaultMaxTokens?: number;
94
+ maxRequestImageBytes?: number;
95
+ streamIdleTimeoutMs?: number;
96
+ timeoutMs?: number;
97
+ retryPolicy?: RetryPolicyConfig;
98
+ }
99
+ interface Config {
100
+ providers?: Record<string, ProviderProfileSource>;
101
+ }
102
+ declare const Config: z<Config>;
103
+ declare function resolveAdapterOptions(provider: string, source: ProviderProfileSource): ResolvedProviderProfile;
104
+ declare function resolveProfiles(providers: Readonly<Record<string, ProviderProfileSource>> | undefined): Map<string, ResolvedProviderProfile>;
105
+ declare function assertServiceable(config: Config): void;
106
+ declare function apply(ctx: Context, config: Config): void;
107
+ //#endregion
108
+ export { Config, DEFAULT_CONTEXT_WINDOW, DEFAULT_MAX_REQUEST_IMAGE_BYTES, DEFAULT_MAX_TOKENS, DEFAULT_STREAM_IDLE_TIMEOUT_MS, MODEL_MODALITIES, ModelProfileSource, NS, OpenAICompatibleAdapter, type OpenAICompatibleAdapterOptions, ProviderProfileSource, REASONING_LEVELS, type ReasoningEffort, type ResolvedModelProfile, type ResolvedProviderProfile, apply, assertServiceable, inject, name, resolveAdapterOptions, resolveProfiles };
109
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/adapter.ts","../src/index.ts"],"mappings":";;;;;;;cA8Ba;cAEA;cAEA;cAEA;KAQD;UAEK;EACf;EACA;EACA;EACA;EACA;EACA,0BAA0B;EAE1B,2BAA2B,QAAQ,OAAO;;UAG3B;EACf;EACA;EAEA,YAAY;EAEZ;EACA,UAAU,SAAS;EAEnB;EACA;EACA;EACA;EACA;EACA;EAEA,YAAY;EAEZ,iBAAiB;EACjB;EACA;EAEA;EACA;EAEA;EACA,aAAa;;UAGE;EACf,gBAAgB,oBAAoB;EAEpC,gBACE,kBACA,SAAS,4BACN;EAEL;EAEA,2BAA2B;;cA8GhB,gCAAgC;mBAC1B;mBACA;EAEjB,YAAY,QAAQ;UAKZ;UAUA;UAOA;EAqBR,aAAa,mBAAmB;EAOhC,oBAAoB,mBAAmB;EAIvC,WAAW,mBAAmB,iBAAiB;EAK/C,aACE,kBACA,eACA,UAAU,cACT,QAAQ;EAeJ,OAAO,SAAS,kBAAkB,eAAe;UAmHhD;;;;cC9WG;cACA;cACA;cAEA;cAEA;UAEI;EACf;EACA;EACA;EACA;EACA;EACA,kBAAkB;EAClB,2BAA2B,QAAQ,OAAO;;UAG3B;EACf;EAEA;EAEA;EAEA,UAAU;EAEV;EACA;EACA;EACA;EACA;EACA;EAEA,YAAY;EAEZ,SAAS;EACT;EACA;EACA;EACA;EAEA;EACA,cAAc;;UAGC;EACf,YAAY,eAAe;;cAsChB,QAAQ,EAAE;iBAkHP,sBACd,kBACA,QAAQ,wBACP;iBAwGa,gBACd,WAAW,SAAS,eAAe,sCAClC,YAAY;iBAYC,kBAAkB,QAAQ;iBA2C1B,MAAM,KAAK,SAAS,QAAQ"}