@crazx/dsh-agent-default-model 0.1.0-rc.7.zw.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) 2026 DeepSeek
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.
@@ -0,0 +1,6 @@
1
+ # Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each
2
+ # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
+ # after editing either side, bring the other along and re-record with:
4
+ # pnpm run verify-translation-pairing --write packages/core/agent-default-model/README.md
5
+ README.md: b2f077fc82924b1f47ca6e202501fb81a0319af1
6
+ README.zh.md: d6ab00a036fefcc9e8ffa6eab194f94da475938d
package/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # @deepseek-ai/dsh-agent-default-model
2
+
3
+ English | [中文](README.zh.md)
4
+
5
+ The deployment default used when an entry point creates an Agent that has no session-local model selection. `AgentDefaultModelConfig` provides `ctx.agentDefaultModel`; direct entry points such as `dsh --profile headless` and Host-backed entry points such as ApiProxy read the same service instead of owning parallel provider/model defaults.
6
+
7
+ The plugin config requires `{ provider, model }`. That composition entry is the base of the `agent-default-model` Settings section; a mounted settings provider layers the user's choice over it and changes are visible on the next `currentSelection()` read. `reasoningEffort` belongs to the Settings section but deliberately not to plugin config: a complete saved selection can clear an effort when the next selected model has none, while a composition value would be inherited again.
8
+
9
+ - `ctx.agentDefaultModel.currentSelection()` returns a detached `{ provider, model, reasoningEffort? }` selection for a newly created Agent.
10
+ - `ctx.agentDefaultModel.saveSelection(selection)` saves the complete user selection. Without a settings provider it is a no-op and the composition entry remains current.
11
+ - `ctx.agentDefaultModel.recallEffort(provider, model)` returns the reasoning effort the user last explicitly chose on that route, or `undefined`.
12
+ - `ctx.agentDefaultModel.rememberEffort(provider, model, effort?)` records — or, when `effort` is `undefined`, clears — that route's remembered effort. Without a settings provider it is a no-op.
13
+
14
+ The remembered efforts live in the separate `agent-model-efforts` Settings section (an entry list keyed by provider/model), so switching the default selection never overwrites them. The service stores what it is told; the consumer that consults a memory validates it against the live model capability, because a remembered level can outlive the declaration that offered it.
15
+
16
+ The service does not validate catalog membership. A provider route may serve an unadvertised model, and the consumer that actually opens a model request owns availability diagnostics.
17
+
18
+ ## Model Experience
19
+
20
+ Indirectly, through the provider/model selection supplied to an entry point; request assembly and adapters own the model-visible request.
21
+
22
+ #### KV Cache effect
23
+
24
+ Changing the default affects only Agents that subsequently resolve from it. An existing session whose request log already names a selection keeps that selection, so this service does not invalidate its established prefix.
25
+
26
+ ## Known Limitations and Deferred Work
27
+
28
+ - The service owns one process-wide default; per-session selection remains the entry point's responsibility.
29
+ - Without a settings provider, `saveSelection()` cannot retain a selection and `rememberEffort()` cannot retain a level for a later Agent.
30
+ - The effort memory grows one entry per route the user has explicitly tuned; it is never pruned automatically (a stale entry is dropped at consult time instead).
package/README.zh.md ADDED
@@ -0,0 +1,30 @@
1
+ # @deepseek-ai/dsh-agent-default-model
2
+
3
+ [English](README.md) | 中文
4
+
5
+ 该部署默认值供入口在创建尚无会话级模型选择的 Agent 时使用。`AgentDefaultModelConfig` 提供 `ctx.agentDefaultModel`;`dsh --profile headless` 这类直接入口与 ApiProxy 这类由 Host 支撑的入口读取同一服务,而不是分别持有平行的提供方/模型默认值。
6
+
7
+ 插件配置必须提供 `{ provider, model }`。该组合配置项构成 Settings 中 `agent-default-model` 分节的基础层;挂载的设置提供方在其上叠加用户选择,更改会在下一次调用 `currentSelection()` 时可见。`reasoningEffort` 属于该 Settings 分节,但特意不属于插件配置:完整保存的选择必须能在下一个选定模型没有推理(reasoning)强度时清除旧值,而组合配置值会再次被继承。
8
+
9
+ - `ctx.agentDefaultModel.currentSelection()` 返回一份独立的 `{ provider, model, reasoningEffort? }` 选择,供新创建的 Agent 使用。
10
+ - `ctx.agentDefaultModel.saveSelection(selection)` 保存完整的用户选择。未挂载设置提供方时,此调用不执行任何操作,组合配置项仍为当前值。
11
+ - `ctx.agentDefaultModel.recallEffort(provider, model)` 返回用户在该路由上最后一次显式选择的推理强度;没有记忆时返回 `undefined`。
12
+ - `ctx.agentDefaultModel.rememberEffort(provider, model, effort?)` 记录——或在 `effort` 为 `undefined` 时清除——该路由的记忆强度。未挂载设置提供方时同样不执行任何操作。
13
+
14
+ 被记忆的强度存放在独立的 `agent-model-efforts` Settings 分节(以提供方/模型为键的条目列表),因此切换默认选择不会覆盖它们。该服务只保存被告知的值;咨询记忆的消费方会对照模型的实时能力校验,因为被记住的等级可能比当初提供它的声明活得更久。
15
+
16
+ 该服务不校验目录成员关系。提供方路由可以服务未在目录中公布的模型;实际发起模型请求的消费方负责可用性诊断。
17
+
18
+ ## 模型体验
19
+
20
+ 通过提供给入口的提供方/模型选择间接影响;模型可见请求由请求组装与适配器负责。
21
+
22
+ #### KV Cache 影响
23
+
24
+ 更改默认值只影响之后从该默认值解析选择的 Agent。请求日志已经指明选择的现有会话仍沿用该选择,因此本服务不会使其已建立的前缀失效。
25
+
26
+ ## 已知限制与暂缓事项
27
+
28
+ - 该服务只拥有一项进程级默认值;每个会话的选择仍由入口负责。
29
+ - 未挂载设置提供方时,`saveSelection()` 无法保留选择,`rememberEffort()` 也无法为后续 Agent 保留等级。
30
+ - 强度记忆按用户显式调过的路由各存一条,永不自动清理(陈旧条目在咨询时丢弃)。
package/lib/index.js ADDED
@@ -0,0 +1,123 @@
1
+ import { Service } from "@deepseek-ai/cordis";
2
+ import z from "@deepseek-ai/schemastery";
3
+ import { ReasoningEffortId } from "@deepseek-ai/dsh-llm";
4
+ import { installSettingsSection, settingsNamespace } from "@deepseek-ai/dsh-settings";
5
+ //#region lib/types/index.js
6
+ /**
7
+ * Default model selection for an Agent without a session-specific selection,
8
+ * plus the per-route reasoning-effort memory that restores the effort the user
9
+ * last explicitly chose when a model is selected again.
10
+ *
11
+ * @module @deepseek-ai/dsh-agent-default-model
12
+ */
13
+ /** Settings namespace carrying the default model selection for future Agents. */
14
+ const AGENT_DEFAULT_MODEL_SETTINGS_NAMESPACE = settingsNamespace("agent-default-model");
15
+ /** Settings namespace carrying the per-route reasoning-effort memory. */
16
+ const AGENT_MODEL_EFFORTS_SETTINGS_NAMESPACE = settingsNamespace("agent-model-efforts");
17
+ /** Schema of the default Agent model settings section. */
18
+ const AGENT_DEFAULT_MODEL_SETTINGS_SCHEMA = z.object({
19
+ provider: z.string().required(),
20
+ model: z.string().required(),
21
+ reasoningEffort: z.string()
22
+ });
23
+ /** Schema of the per-route reasoning-effort memory section. */
24
+ const AGENT_MODEL_EFFORTS_SETTINGS_SCHEMA = z.object({ entries: z.array(z.object({
25
+ provider: z.string().required(),
26
+ model: z.string().required(),
27
+ effort: z.string().required()
28
+ })).default([]) });
29
+ /** Project stored settings onto the Agent-facing selection type. */
30
+ function selection(settings) {
31
+ return {
32
+ provider: settings.provider,
33
+ model: settings.model,
34
+ ...settings.reasoningEffort === void 0 ? {} : { reasoningEffort: ReasoningEffortId(settings.reasoningEffort) }
35
+ };
36
+ }
37
+ /**
38
+ * Owns the default model selection and the per-route reasoning-effort memory,
39
+ * each independently of any Host or transport. The composition entries remain
40
+ * usable without a settings provider; when one is mounted, the user layer of
41
+ * each namespace is read live.
42
+ */
43
+ var AgentDefaultModelConfig = class extends Service {
44
+ static Config = z.object({
45
+ provider: z.string().required(),
46
+ model: z.string().required()
47
+ });
48
+ source;
49
+ effortsSource;
50
+ constructor(ctx, config) {
51
+ super(ctx, "agentDefaultModel");
52
+ const entry = {
53
+ provider: config.provider,
54
+ model: config.model
55
+ };
56
+ this.source = () => entry;
57
+ installSettingsSection(ctx, AGENT_DEFAULT_MODEL_SETTINGS_NAMESPACE, AGENT_DEFAULT_MODEL_SETTINGS_SCHEMA, entry, {
58
+ setSource: (current) => {
59
+ this.source = current;
60
+ },
61
+ onChange: () => {}
62
+ });
63
+ const effortsEntry = { entries: [] };
64
+ this.effortsSource = () => effortsEntry;
65
+ installSettingsSection(ctx, AGENT_MODEL_EFFORTS_SETTINGS_NAMESPACE, AGENT_MODEL_EFFORTS_SETTINGS_SCHEMA, effortsEntry, {
66
+ setSource: (current) => {
67
+ this.effortsSource = current;
68
+ },
69
+ onChange: () => {}
70
+ });
71
+ }
72
+ /**
73
+ * Read the current default model selection.
74
+ * @returns a detached provider, model, and optional reasoning selection.
75
+ */
76
+ currentSelection() {
77
+ return selection(this.source());
78
+ }
79
+ /**
80
+ * Save the complete default model selection. A deployment without a settings
81
+ * provider keeps its composition entry.
82
+ * @param next - resolved selection accepted by an entry point.
83
+ * @returns fulfillment after the optional settings write settles.
84
+ */
85
+ async saveSelection(next) {
86
+ await this.ctx.get("settings")?.replace(AGENT_DEFAULT_MODEL_SETTINGS_NAMESPACE, {
87
+ provider: next.provider,
88
+ model: next.model,
89
+ ...next.reasoningEffort === void 0 ? {} : { reasoningEffort: String(next.reasoningEffort) }
90
+ });
91
+ }
92
+ /**
93
+ * Recall the effort last explicitly chosen on one provider/model route.
94
+ * A hand-edited document may carry duplicate entries; the last match wins,
95
+ * matching the append order {@link rememberEffort} maintains.
96
+ * @param provider - registered provider route.
97
+ * @param model - provider-owned model id.
98
+ * @returns the remembered effort, or undefined when the route has none.
99
+ */
100
+ recallEffort(provider, model) {
101
+ let found;
102
+ for (const entry of this.effortsSource().entries) if (entry.provider === provider && entry.model === model) found = entry.effort;
103
+ return found === void 0 ? void 0 : ReasoningEffortId(found);
104
+ }
105
+ /**
106
+ * Record the remembered effort for one route, or clear it when `effort` is
107
+ * undefined. A deployment without a settings provider keeps its composition
108
+ * entry, so the call fulfills with no stored effect.
109
+ * @param provider - registered provider route.
110
+ * @param model - provider-owned model id.
111
+ * @param effort - the explicitly chosen effort, or undefined to clear.
112
+ * @returns fulfillment after the optional settings write settles.
113
+ */
114
+ async rememberEffort(provider, model, effort) {
115
+ await this.ctx.get("settings")?.replace(AGENT_MODEL_EFFORTS_SETTINGS_NAMESPACE, { entries: [...this.effortsSource().entries.filter((entry) => entry.provider !== provider || entry.model !== model), ...effort === void 0 ? [] : [{
116
+ provider,
117
+ model,
118
+ effort: String(effort)
119
+ }]] });
120
+ }
121
+ };
122
+ //#endregion
123
+ export { AGENT_DEFAULT_MODEL_SETTINGS_NAMESPACE, AGENT_DEFAULT_MODEL_SETTINGS_SCHEMA, AGENT_MODEL_EFFORTS_SETTINGS_NAMESPACE, AGENT_MODEL_EFFORTS_SETTINGS_SCHEMA, AgentDefaultModelConfig, AgentDefaultModelConfig as default };
@@ -0,0 +1,25 @@
1
+ //#region lib/types/invariant.js
2
+ /**
3
+ * Package-owned invariant companion for the default Agent model selection.
4
+ *
5
+ * The service owns no independent event relationship: settings registration
6
+ * already validates every mutable value before `currentSelection()` can observe it.
7
+ * The empty installer keeps that absence explicit in composed invariant sets.
8
+ *
9
+ * @module @deepseek-ai/dsh-agent-default-model/invariant
10
+ */
11
+ const PACKAGE_NAME = "@deepseek-ai/dsh-agent-default-model";
12
+ /** Cordis companion plugin name. */
13
+ const name = "agent-default-model-invariant";
14
+ /** Services required before the companion can register. */
15
+ const inject = ["invariants"];
16
+ /** No runtime invariant: settings validation owns the only mutable-value relationship. */
17
+ const install = () => {};
18
+ /**
19
+ * Register the intentionally empty invariant contribution.
20
+ * @param ctx - Cordis context carrying the invariant service.
21
+ * @returns the installed registration's disposer after setup succeeds.
22
+ */
23
+ const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
24
+ //#endregion
25
+ export { apply, inject, name };
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Default model selection for an Agent without a session-specific selection,
3
+ * plus the per-route reasoning-effort memory that restores the effort the user
4
+ * last explicitly chose when a model is selected again.
5
+ *
6
+ * @module @deepseek-ai/dsh-agent-default-model
7
+ */
8
+ import { Context, Service } from '@deepseek-ai/cordis';
9
+ import z from '@deepseek-ai/schemastery';
10
+ import type { ModelSelection } from '@deepseek-ai/dsh-agent';
11
+ import { ReasoningEffortId } from '@deepseek-ai/dsh-llm';
12
+ declare module '@deepseek-ai/cordis' {
13
+ interface Context {
14
+ /**
15
+ * Default model selection for Agents created without an explicit model,
16
+ * plus the per-route reasoning-effort memory for model switches.
17
+ */
18
+ agentDefaultModel: AgentDefaultModelConfig;
19
+ }
20
+ }
21
+ /** Settings namespace carrying the default model selection for future Agents. */
22
+ export declare const AGENT_DEFAULT_MODEL_SETTINGS_NAMESPACE: import("@deepseek-ai/dsh-settings").SettingsNamespace;
23
+ /** Settings namespace carrying the per-route reasoning-effort memory. */
24
+ export declare const AGENT_MODEL_EFFORTS_SETTINGS_NAMESPACE: import("@deepseek-ai/dsh-settings").SettingsNamespace;
25
+ /** Stored and composed default model selection. */
26
+ export interface AgentDefaultModelSettings {
27
+ /** Registered provider route. */
28
+ provider: string;
29
+ /** Provider-owned model id. */
30
+ model: string;
31
+ /** Adapter-owned reasoning effort, or provider/default behavior when absent. */
32
+ reasoningEffort?: string;
33
+ }
34
+ /** Schema of the default Agent model settings section. */
35
+ export declare const AGENT_DEFAULT_MODEL_SETTINGS_SCHEMA: z<AgentDefaultModelSettings>;
36
+ /** One remembered per-route effort: the level the user last explicitly chose. */
37
+ export interface AgentModelEffortEntry {
38
+ /** Registered provider route. */
39
+ provider: string;
40
+ /** Provider-owned model id. */
41
+ model: string;
42
+ /** Adapter-owned effort id as it was when the choice was made. */
43
+ effort: string;
44
+ }
45
+ /** Stored per-route reasoning-effort memory; the service is its only writer. */
46
+ export interface AgentModelEffortsSettings {
47
+ /** Remembered choices; at most one entry per provider/model route. */
48
+ entries: AgentModelEffortEntry[];
49
+ }
50
+ /** Schema of the per-route reasoning-effort memory section. */
51
+ export declare const AGENT_MODEL_EFFORTS_SETTINGS_SCHEMA: z<AgentModelEffortsSettings>;
52
+ /** Composition entry for the default model selection. */
53
+ export interface Config {
54
+ /** Registered provider route. */
55
+ provider: string;
56
+ /** Provider-owned model id. */
57
+ model: string;
58
+ }
59
+ /**
60
+ * Owns the default model selection and the per-route reasoning-effort memory,
61
+ * each independently of any Host or transport. The composition entries remain
62
+ * usable without a settings provider; when one is mounted, the user layer of
63
+ * each namespace is read live.
64
+ */
65
+ export declare class AgentDefaultModelConfig extends Service {
66
+ static Config: z<Config>;
67
+ private source;
68
+ private effortsSource;
69
+ constructor(ctx: Context, config: Config);
70
+ /**
71
+ * Read the current default model selection.
72
+ * @returns a detached provider, model, and optional reasoning selection.
73
+ */
74
+ currentSelection(): ModelSelection;
75
+ /**
76
+ * Save the complete default model selection. A deployment without a settings
77
+ * provider keeps its composition entry.
78
+ * @param next - resolved selection accepted by an entry point.
79
+ * @returns fulfillment after the optional settings write settles.
80
+ */
81
+ saveSelection(next: ModelSelection): Promise<void>;
82
+ /**
83
+ * Recall the effort last explicitly chosen on one provider/model route.
84
+ * A hand-edited document may carry duplicate entries; the last match wins,
85
+ * matching the append order {@link rememberEffort} maintains.
86
+ * @param provider - registered provider route.
87
+ * @param model - provider-owned model id.
88
+ * @returns the remembered effort, or undefined when the route has none.
89
+ */
90
+ recallEffort(provider: string, model: string): ReasoningEffortId | undefined;
91
+ /**
92
+ * Record the remembered effort for one route, or clear it when `effort` is
93
+ * undefined. A deployment without a settings provider keeps its composition
94
+ * entry, so the call fulfills with no stored effect.
95
+ * @param provider - registered provider route.
96
+ * @param model - provider-owned model id.
97
+ * @param effort - the explicitly chosen effort, or undefined to clear.
98
+ * @returns fulfillment after the optional settings write settles.
99
+ */
100
+ rememberEffort(provider: string, model: string, effort: ReasoningEffortId | undefined): Promise<void>;
101
+ }
102
+ export default AgentDefaultModelConfig;
103
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Package-owned invariant companion for the default Agent model selection.
3
+ *
4
+ * The service owns no independent event relationship: settings registration
5
+ * already validates every mutable value before `currentSelection()` can observe it.
6
+ * The empty installer keeps that absence explicit in composed invariant sets.
7
+ *
8
+ * @module @deepseek-ai/dsh-agent-default-model/invariant
9
+ */
10
+ import type { Context } from '@deepseek-ai/cordis';
11
+ /** Cordis companion plugin name. */
12
+ export declare const name = "agent-default-model-invariant";
13
+ /** Services required before the companion can register. */
14
+ export declare const inject: string[];
15
+ /**
16
+ * Register the intentionally empty invariant contribution.
17
+ * @param ctx - Cordis context carrying the invariant service.
18
+ * @returns the installed registration's disposer after setup succeeds.
19
+ */
20
+ export declare const apply: (ctx: Context) => Promise<() => void>;
21
+ //# sourceMappingURL=invariant.d.ts.map
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@crazx/dsh-agent-default-model",
3
+ "description": "Default model selection shared by Agent entry points",
4
+ "version": "0.1.0-rc.7.zw.2",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/aka-danielZhang/deepseek-harness.git",
11
+ "directory": "packages/core/agent-default-model"
12
+ },
13
+ "type": "module",
14
+ "main": "lib/index.js",
15
+ "types": "lib/types/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./lib/types/index.d.ts",
19
+ "default": "./lib/index.js"
20
+ },
21
+ "./invariant": {
22
+ "types": "./lib/types/invariant.d.ts",
23
+ "default": "./lib/invariant.js"
24
+ },
25
+ "./src/*": "./src/*",
26
+ "./package.json": "./package.json"
27
+ },
28
+ "files": [
29
+ "lib/index.js",
30
+ "lib/invariant.js",
31
+ "lib/types/**/*.d.ts"
32
+ ],
33
+ "license": "MIT",
34
+ "dependencies": {
35
+ "@deepseek-ai/schemastery": "^0.1.0-rc.7"
36
+ },
37
+ "peerDependencies": {
38
+ "@deepseek-ai/dsh-agent": "^0.1.0-rc.7",
39
+ "@deepseek-ai/dsh-invariants": "^0.1.0-rc.7",
40
+ "@deepseek-ai/dsh-llm": "^0.1.0-rc.7",
41
+ "@deepseek-ai/dsh-settings": "^0.1.0-rc.7",
42
+ "@deepseek-ai/cordis": "^0.1.0-rc.7"
43
+ },
44
+ "devDependencies": {
45
+ "@deepseek-ai/dsh-agent": "^0.1.0-rc.7",
46
+ "@deepseek-ai/dsh-invariants": "^0.1.0-rc.7",
47
+ "@deepseek-ai/dsh-llm": "^0.1.0-rc.7",
48
+ "@deepseek-ai/dsh-settings": "^0.1.0-rc.7",
49
+ "@deepseek-ai/cordis": "^0.1.0-rc.7"
50
+ }
51
+ }