@crazx/dsh-agent-default-model 0.1.2-rc.1.zw.2 → 0.1.5-alpha.1.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/README.i18n.yaml CHANGED
@@ -2,5 +2,5 @@
2
2
  # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
3
  # after editing either side, bring the other along and re-record with:
4
4
  # pnpm run verify-translation-pairing --write packages/core/agent-default-model/README.md
5
- README.md: 8b00e02b6e7d6a863299f3f66e63e729ceebd3cb
6
- README.zh.md: faa6d56a94046203fdaf14a2577e3279bdad8375
5
+ README.md: 802b049a08652c13e6cbda2ca40f4ef79dab53b9
6
+ README.zh.md: 0eb0cf85908a969898618eaa9701136019cdd8e6
package/README.md CHANGED
@@ -9,14 +9,7 @@ English | [中文](README.zh.md)
9
9
 
10
10
  ## Summary
11
11
 
12
- `dsh-agent-default-model` supplies the deployment's default model selection — provider, model, and optional reasoning effort — that agent entry points apply when a fresh session has no selection of its own. Direct entry points such as `dsh --profile headless` and Host-backed entry points read `ctx.agentDefaultModel` instead of owning parallel defaults, so one composition entry controls which model new agents start on. A mounted settings provider layers the user's choice over the composition entry, and a saved change is visible on the next read. It is one process-wide default: per-session model selection remains the entry point's responsibility. Choose it when you want a single place to set the model new agents use.
13
-
14
- - `ctx.agentDefaultModel.currentSelection()` returns a detached `{ provider, model, reasoningEffort? }` selection for a newly created Agent.
15
- - `ctx.agentDefaultModel.saveSelection(selection)` saves the complete user selection. Without a settings provider it is a no-op and the composition entry remains current.
16
- - `ctx.agentDefaultModel.recallEffort(provider, model)` returns the reasoning effort the user last explicitly chose on that route, or `undefined`.
17
- - `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.
18
-
19
- 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.
12
+ `dsh-agent-default-model` gives newly created agents a shared default provider and model when their sessions do not specify one. Use it to choose the starting model once for all supported agent entry points, including `dsh --profile headless`. When settings are available, users can override the configured selection, including reasoning effort, and saved changes apply to subsequent reads. The default is process-wide; per-session model selection remains the responsibility of the entry point that creates the agent.
20
13
 
21
14
  ## Table of Contents
22
15
 
@@ -63,6 +56,8 @@ await ctx.agentDefaultModel.saveSelection({ provider, model, reasoningEffort: 'h
63
56
 
64
57
  Without a settings provider, `saveSelection()` is a no-op and the composition entry remains current. The service does not validate catalog membership: a provider route may serve an unadvertised model, and the consumer that opens a model request owns availability diagnostics.
65
58
 
59
+ `recallEffort(provider, model)` reads the last explicit effort for one route. `rememberEffort(provider, model, effort?)` records it or clears it when `effort` is `undefined`; these entries live in the separate `agent-model-efforts` Settings section and never overwrite the default selection. Consumers validate a recalled value against live model capabilities before using it.
60
+
66
61
  -----
67
62
 
68
63
  <a id="understand-the-implementation"></a>
@@ -81,12 +76,12 @@ The service is a composition entry with a settings-backed source. The plugin con
81
76
 
82
77
  | File | Role |
83
78
  |---|---|
84
- | [`src/index.ts`](src/index.ts) | Plugin entry: `AgentDefaultModelConfig` service, settings section install, `currentSelection`/`saveSelection` |
79
+ | [`src/index.ts`](src/index.ts) | Plugin entry: `AgentDefaultModelConfig` service, settings section install, default selection access, and per-route effort memory |
85
80
  | — | No runtime invariant companion is published; settings validation owns the only mutable-value relationship. |
86
81
 
87
82
  ### Behavior notes
88
83
 
89
- Both public methods are thin reads and writes over that source: `currentSelection()` returns a fresh detached object so a caller can hold it without aliasing service state, and `saveSelection()` writes the whole selection through `ctx.settings` when present.
84
+ The four public methods are thin reads and writes over those sources. `currentSelection()` returns a fresh detached object so a caller can hold it without aliasing service state, and `saveSelection()` writes the whole default selection through `ctx.settings` when present. Effort-memory writes serialize their complete read-compute-replace operation; concurrent selections on different routes therefore preserve both entries, and one failed write does not poison later writes.
90
85
 
91
86
  </details>
92
87
 
package/README.zh.md CHANGED
@@ -9,14 +9,7 @@ kind: "package-reference"
9
9
 
10
10
  ## 概述
11
11
 
12
- `dsh-agent-default-model` 提供部署的默认模型选择——提供方、模型与可选的推理(reasoning)强度——agent 入口在全新会话没有自己的选择时应用它。`dsh --profile headless` 这类直接入口与 Host 支撑的入口读取 `ctx.agentDefaultModel`,而不是各自持有平行默认值,因此一个组合配置项就能控制新 agent 从哪个模型开始。挂载的设置提供方会把用户选择叠加在组合配置项之上,保存的更改在下一次读取时可见。它是单一的进程级默认值:按会话的模型选择仍由入口负责。想要为新建 agent 所用模型设置单一位置时,请选择本包。
13
-
14
- - `ctx.agentDefaultModel.currentSelection()` 返回一份分离的 `{ provider, model, reasoningEffort? }` 选择,供新创建的 Agent 使用。
15
- - `ctx.agentDefaultModel.saveSelection(selection)` 保存完整的用户选择。未挂载设置提供方时,此调用不执行任何操作,组合配置项仍为当前值。
16
- - `ctx.agentDefaultModel.recallEffort(provider, model)` 返回用户在该路由上最后一次显式选择的推理强度;没有记忆时返回 `undefined`。
17
- - `ctx.agentDefaultModel.rememberEffort(provider, model, effort?)` 记录——或在 `effort` 为 `undefined` 时清除——该路由的记忆强度。未挂载设置提供方时同样不执行任何操作。
18
-
19
- 被记忆的强度存放在独立的 `agent-model-efforts` Settings 分节(以提供方/模型为键的条目列表),因此切换默认选择不会覆盖它们。该服务只保存被告知的值;咨询记忆的消费方会对照模型的实时能力校验,因为被记住的等级可能比当初提供它的声明活得更久。
12
+ `dsh-agent-default-model` 在会话未指定模型时,为新创建的 agent 提供共享的默认提供方与模型。使用它可以为所有受支持的 agent 入口统一选择起始模型,其中包括 `dsh --profile headless`。设置可用时,用户可以覆盖已配置的选择(包括推理强度),保存的更改会在后续读取中生效。该默认值作用于整个进程;按会话选择模型仍由创建 agent 的入口负责。
20
13
 
21
14
  ## 目录
22
15
 
@@ -63,6 +56,8 @@ await ctx.agentDefaultModel.saveSelection({ provider, model, reasoningEffort: 'h
63
56
 
64
57
  未挂载设置提供方时,`saveSelection()` 不执行任何操作,组合配置项仍为当前值。该服务不校验目录成员关系:提供方路由可以服务未在目录中公布的模型;发起模型请求的消费方负责可用性诊断。
65
58
 
59
+ `recallEffort(provider, model)` 读取一条路由最后一次显式选择的推理等级。`rememberEffort(provider, model, effort?)` 记录它,或在 `effort` 为 `undefined` 时清除;这些条目位于独立的 `agent-model-efforts` Settings 分节,绝不会覆盖默认选择。消费方在使用召回值前对照模型实时能力进行校验。
60
+
66
61
  -----
67
62
 
68
63
  <a id="understand-the-implementation"></a>
@@ -81,12 +76,12 @@ await ctx.agentDefaultModel.saveSelection({ provider, model, reasoningEffort: 'h
81
76
 
82
77
  | 文件 | 职责 |
83
78
  |---|---|
84
- | [`src/index.ts`](src/index.ts) | 插件入口:`AgentDefaultModelConfig` 服务、设置分节安装、`currentSelection`/`saveSelection` |
79
+ | [`src/index.ts`](src/index.ts) | 插件入口:`AgentDefaultModelConfig` 服务、设置分节安装、默认选择访问与按路由推理等级记忆 |
85
80
  | — | 不发布运行时不变式伴生入口;唯一的可变值关系由 settings 校验负责。 |
86
81
 
87
82
  ### 行为说明
88
83
 
89
- 两个公开方法都是对该真源的薄读写:`currentSelection()` 返回全新独立对象,调用方持有它不会别名化服务状态;`saveSelection()` 在存在 `ctx.settings` 时写入完整选择。
84
+ 四个公开方法都是对这些真源的薄读写。`currentSelection()` 返回全新独立对象,调用方持有它不会别名化服务状态;`saveSelection()` 在存在 `ctx.settings` 时写入完整默认选择。推理记忆写入会串行执行完整的“读取、计算、替换”过程,因此不同路由的并发选择会同时保留;单次写入失败也不会阻断后续写入。
90
85
 
91
86
  </details>
92
87
 
package/lib/index.js CHANGED
@@ -46,6 +46,8 @@ var AgentDefaultModelConfig = class extends Service {
46
46
  });
47
47
  source;
48
48
  effortsSource;
49
+ /** Serializes read-compute-replace so concurrent route writes cannot lose one another. */
50
+ effortWriteTail = Promise.resolve();
49
51
  constructor(ctx, config) {
50
52
  super(ctx, "agentDefaultModel");
51
53
  const entry = {
@@ -114,12 +116,19 @@ var AgentDefaultModelConfig = class extends Service {
114
116
  * @param effort - the explicitly chosen effort, or undefined to clear.
115
117
  * @returns fulfillment after the optional settings write settles.
116
118
  */
117
- async rememberEffort(provider, model, effort) {
118
- 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 ? [] : [{
119
- provider,
120
- model,
121
- effort: String(effort)
122
- }]] });
119
+ rememberEffort(provider, model, effort) {
120
+ const operation = async () => {
121
+ const settings = this.ctx.get("settings");
122
+ if (settings === void 0) return;
123
+ await settings.replace(AGENT_MODEL_EFFORTS_SETTINGS_NAMESPACE, { entries: [...this.effortsSource().entries.filter((entry) => entry.provider !== provider || entry.model !== model), ...effort === void 0 ? [] : [{
124
+ provider,
125
+ model,
126
+ effort: String(effort)
127
+ }]] });
128
+ };
129
+ const run = this.effortWriteTail.then(operation, operation);
130
+ this.effortWriteTail = run.then(() => void 0, () => void 0);
131
+ return run;
123
132
  }
124
133
  };
125
134
  //#endregion
@@ -66,6 +66,8 @@ export declare class AgentDefaultModelConfig extends Service {
66
66
  static Config: z<Config>;
67
67
  private source;
68
68
  private effortsSource;
69
+ /** Serializes read-compute-replace so concurrent route writes cannot lose one another. */
70
+ private effortWriteTail;
69
71
  constructor(ctx: Context, config: Config);
70
72
  /**
71
73
  * Read the current default model selection.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@crazx/dsh-agent-default-model",
3
3
  "description": "Default model selection shared by Agent entry points",
4
- "version": "0.1.2-rc.1.zw.2",
4
+ "version": "0.1.5-alpha.1.zw.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -30,15 +30,15 @@
30
30
  "@deepseek-ai/schemastery": "^3.18.2"
31
31
  },
32
32
  "peerDependencies": {
33
- "@deepseek-ai/dsh-agent": "^0.1.2-rc.1",
34
- "@deepseek-ai/dsh-llm": "^0.1.2-rc.1",
35
- "@deepseek-ai/dsh-settings": "^0.1.2-rc.1",
33
+ "@deepseek-ai/dsh-agent": "^0.1.5-alpha.1",
34
+ "@deepseek-ai/dsh-llm": "^0.1.5-alpha.1",
35
+ "@deepseek-ai/dsh-settings": "^0.1.5-alpha.1",
36
36
  "@deepseek-ai/cordis": "^4.0.2"
37
37
  },
38
38
  "devDependencies": {
39
- "@deepseek-ai/dsh-agent": "^0.1.2-rc.1",
40
- "@deepseek-ai/dsh-llm": "^0.1.2-rc.1",
41
- "@deepseek-ai/dsh-settings": "^0.1.2-rc.1",
39
+ "@deepseek-ai/dsh-agent": "^0.1.5-alpha.1",
40
+ "@deepseek-ai/dsh-llm": "^0.1.5-alpha.1",
41
+ "@deepseek-ai/dsh-settings": "^0.1.5-alpha.1",
42
42
  "@deepseek-ai/cordis": "^4.0.2"
43
43
  }
44
44
  }