@deepseek-ai/dsh-api-session-controller 0.1.7-rc.1 → 0.2.0-rc.1

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
@@ -1,6 +1,40 @@
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:
1
+ # Bilingual-pair consistency record for README.md (docs/i18n/README.md): per heading
2
+ # section, a hash of its English and Chinese blocks outside code blocks and generated regions.
3
+ # After editing either side, bring the other along and re-record with:
4
4
  # pnpm run verify-translation-pairing --write packages/api/session-controller/README.md
5
- README.md: 728d98b90aa96829a878b071c03af3ec961c839e
6
- README.zh.md: 9a2c54b6865302e69daa5f67ec9baa17255f8100
5
+ /:
6
+ en: 82789442228fc62a
7
+ zh: f1d511ad838187de
8
+ /session-controller:
9
+ en: c7a4c58ea6d3437b
10
+ zh: 45c2b472a074bb1b
11
+ /session-controller/summary:
12
+ en: 4914824c347fdab5
13
+ zh: 684a7b7fa970c39f
14
+ /session-controller/table-of-contents:
15
+ en: 1fdf707322fb6996
16
+ zh: 0204f7e9d4aa3cce
17
+ /session-controller/use-this-package:
18
+ en: b1a66e01de414924
19
+ zh: 7c01f66b94b01ff9
20
+ /session-controller/client-references:
21
+ en: 41bdda1ac32df558
22
+ zh: aa5d0e325924066b
23
+ /session-controller/session-media-references:
24
+ en: 266ab2b1e2fec542
25
+ zh: b3450ae28a1e0baf
26
+ /session-controller/configuration:
27
+ en: 5c4c4224074e38a8
28
+ zh: e0b0edac65c88ff4
29
+ /session-controller/model-experience:
30
+ en: 30b917bf822bb4df
31
+ zh: b0b023b5b526c317
32
+ /session-controller/model-experience/kv-cache-effect:
33
+ en: 22fc0c9dbedd3bb6
34
+ zh: fad040ca55fd0e0a
35
+ /session-controller/known-limitations-and-deferred-work:
36
+ en: e896bfcaf38b4f6c
37
+ zh: 55a4eba838f166de
38
+ /session-controller/known-limitations-and-deferred-work/dev-note:
39
+ en: 68e0dfe4588c5b88
40
+ zh: db51b435611bded1
package/README.md CHANGED
@@ -6,6 +6,8 @@ kind: "package-reference"
6
6
 
7
7
  English | [中文](README.zh.md)
8
8
 
9
+ Desktop analytics follows the [product collection policy](../../client/product-analytics/README.md), including its launch-time switch. Web usage is excluded.
10
+
9
11
  ## Summary
10
12
 
11
13
  `@deepseek-ai/dsh-api-session-controller` owns the Host `ctx.sessionController` service and the generated Client `session`, `skills`, and `fileReferences` Remote namespaces. It serves Session lifecycle and history, the Host-generation model catalog, human background-job kill, workspace-path opening, user-invocable skill discovery, and Agent-scoped file references. Use it through API Gateway when a Client needs operations addressed by a Session.
@@ -78,7 +80,9 @@ References keep local Session data, scoped Contexts, and history streams alive,
78
80
 
79
81
  `SessionMediaReferences` mounts `GET|HEAD /api/file?path=<absolute path>` on the authenticated `connection.fetch` channel when `connection`, `fs`, and `attachments` are composed. It reads ordinary files through `ctx.fs`, including temporary paths outside registered workspaces and files in remote providers. Neither directory containment nor MIME categories restrict access; `mime-types` supplies the response type, with `application/octet-stream` for unknown extensions. GET reuses `readBytes` for preflight and ongoing byte limits; HEAD reads metadata only. All files use `ctx.attachments.imageLimits.maxImageBytes` (normally 20 MiB); exceeding this limit returns 413. Responses contain the complete file, ignore Range, and carry `private, no-store`, `nosniff`, and a sandbox CSP so directly opened HTML/SVG cannot execute with the API origin. The Client rewrite lives in `ui-chat` (`AssistantMarkdown`); audio/video responses are available, while Markdown audio/video player nodes remain separate work.
80
82
 
81
- `workspacePathApplications({ path })` returns the serving desktop’s file handlers after the same filesystem mapping check used by `openWorkspacePath`. An optional `application` in the open request selects a currently registered handler without changing the system default. Application names, default selection, icons, and platform coverage come from [native-command](../../util/native-command/README.md). These operations do not activate an Agent or append Session events. Native failures return bounded messages; original command errors remain Host-side causes.
83
+ GUI model selection requires the exact provider/model pair in the available catalog; unavailable choices reject with `session/model-unavailable`. Prompt admission retains the saved route without a catalog availability gate, so request execution reports missing credentials or unavailable models. `initializeDefaultModel()` saves the first available account model after login when no other provider has a configured API key; credential checks use configured references independently of model availability. A provider with no available models rejects initialization with `session/provider-models-unavailable`. Availability never substitutes another model or rewrites a Session selection.
84
+
85
+ A successful `selectModel` response acknowledges the Session-local selection without waiting for the default profile setting to save. Default saves run in the background in submission order; a failure logs a warning and leaves the Session selection intact. New Sessions read the last successfully saved default.
82
86
 
83
87
  -----
84
88
 
package/README.zh.md CHANGED
@@ -6,6 +6,8 @@ kind: "package-reference"
6
6
 
7
7
  [English](README.md) | 中文
8
8
 
9
+ 桌面埋点遵循[产品采集策略](../../client/product-analytics/README.zh.md)及其启动时开关,不包含 Web 使用情况。
10
+
9
11
  ## 概述
10
12
 
11
13
  `@deepseek-ai/dsh-api-session-controller` 拥有 Host 的 `ctx.sessionController` 服务,以及生成的 Client `session`、`skills` 和 `fileReferences` Remote namespace。它提供 Session 生命周期与历史、Host generation 模型目录、人工后台任务终止、工作区路径打开、用户可调用 skill(技能)发现和 Agent(智能体)范围的文件引用。当 Client 需要按 Session 寻址的操作时,请通过 API Gateway 使用它。
@@ -78,7 +80,9 @@ Client 的首次 `follow`、重连首屏与 `loadOlder()` 至少请求 50 条以
78
80
 
79
81
  当 `connection`、`fs` 与 `attachments` 均被组合时,`SessionMediaReferences` 在鉴权 `connection.fetch` 通道上挂载 `GET|HEAD /api/file?path=<绝对路径>`。它通过 `ctx.fs` 读取普通文件,包括已注册工作区之外的临时路径与远程提供方中的文件。目录包含关系与 MIME 类别均不限制访问;`mime-types` 提供响应类型,未知扩展名使用 `application/octet-stream`。GET 复用 `readBytes` 执行读取前及读取中的字节限制;HEAD 只读取元数据。所有文件均使用 `ctx.attachments.imageLimits.maxImageBytes`(通常为 20 MiB);超过此上限返回 413。响应包含完整文件,忽略 Range,并携带 `private, no-store`、`nosniff` 与沙箱 CSP,使直接打开的 HTML/SVG 无法以 API 源身份执行脚本。客户端重写位于 `ui-chat`(`AssistantMarkdown`);音视频文件响应已可用,Markdown 音视频播放器节点仍是独立工作。
80
82
 
81
- `workspacePathApplications({ path })` 使用与 `openWorkspacePath` 相同的文件系统映射校验,返回服务端桌面上该文件的关联应用。打开请求中的可选 `application` 指定当前关联的应用,不修改系统默认应用。应用名称、默认项、图标和平台支持范围由 [native-command](../../util/native-command/README.zh.md) 提供。这些操作不激活 Agent,也不追加会话事件。原生操作失败时返回简短消息,原始命令异常作为 Host 端原因保留。
83
+ GUI 模型选择要求确切提供方/模型对出现在可用目录中;不可用的选择以 `session/model-unavailable` 拒绝。提示词准入保留已保存的路由,不按目录可用性阻断发送,由请求执行报告凭据缺失或模型不可用。`initializeDefaultModel()` 在账号登录后、其他提供方均未配置 API key 时,将第一个可用账号模型保存为默认模型;凭据检查使用已配置的引用,不依赖模型是否可用。提供方没有可用模型时,初始化以 `session/provider-models-unavailable` 拒绝。可用性变化不会替换模型或改写会话选择。
84
+
85
+ `selectModel` 成功返回表示会话级模型选择已生效,不等待默认 profile 设置保存。默认设置在后台按提交顺序保存;保存失败会记录警告,并保留会话选择。新会话读取最近一次成功保存的默认值。
82
86
 
83
87
  -----
84
88
 
package/lib/client.js CHANGED
@@ -591,12 +591,12 @@ window.__ModuleLoader__.load({
591
591
  const rendered = JSON.stringify(value) ?? String(value);
592
592
  throw new Error(`unreachable variant${context ? ` in ${context}` : ""}: ${rendered}`);
593
593
  }
594
- /** Whether a realm-owned intrinsic prototype is backed by its native constructor. */
594
+ /** Whether a realm-owned intrinsic prototype has a native constructor matching this engine's representation. */
595
595
  function hasIntrinsicConstructor(prototype, name) {
596
596
  const constructor = Object.getOwnPropertyDescriptor(prototype, "constructor")?.value;
597
597
  if (typeof constructor !== "function") return false;
598
598
  try {
599
- return constructor.name === name && constructor.prototype === prototype && Function.prototype.toString.call(constructor) === `function ${name}() { [native code] }`;
599
+ return constructor.name === name && constructor.prototype === prototype && Function.prototype.toString.call(constructor) === Function.prototype.toString.call(name === "Array" ? Array : Object);
600
600
  } catch {
601
601
  return false;
602
602
  }
@@ -3349,6 +3349,7 @@ window.__ModuleLoader__.load({
3349
3349
  if (!result.ok) throw new SessionForkError(result.error, opts.sessionId);
3350
3350
  this.projectList();
3351
3351
  const childId = result.value.sessionId;
3352
+ opts.onCreated?.(childId);
3352
3353
  if (sourceTitle !== void 0) {
3353
3354
  const renamed = await this.manager.rename(childId, increasedForkTitle(sourceTitle));
3354
3355
  if (!renamed.ok) throw new Error(`fork child rename failed: ${renamed.error.code}: ${renamed.error.message}`);
package/lib/index.js CHANGED
@@ -7,6 +7,7 @@ import { SessionQueryError } from "@deepseek-ai/dsh-session-query";
7
7
  import { Remote, RemoteError, TypertRemoteService, remoteErrorOf } from "@deepseek-ai/dsh-typert-protocol";
8
8
  import { mkdir } from "node:fs/promises";
9
9
  import { installModelSelection } from "@deepseek-ai/dsh-agent";
10
+ import { credentialRef } from "@deepseek-ai/dsh-credentials";
10
11
  import { randomUUID } from "node:crypto";
11
12
  import { brandString } from "@deepseek-ai/dsh-brand";
12
13
  import { AttachmentError } from "@deepseek-ai/dsh-attachment";
@@ -488,6 +489,103 @@ function agentModelSelection(selection) {
488
489
  };
489
490
  }
490
491
  //#endregion
492
+ //#region lib/types/catalog.js
493
+ /** Shared projection of the live LLM registry into the browser model catalog. */
494
+ /**
495
+ * Build the browser model catalog without requiring a Session.
496
+ * @param ctx - Host context carrying the live LLM registry.
497
+ * @param defaultSelection - deployment default used before a Session selects a model.
498
+ * @returns successful non-empty provider groups and isolated provider failures.
499
+ */
500
+ async function buildModelCatalog(ctx, defaultSelection = ctx.agentDefaultModel.currentSelection()) {
501
+ const providers = ctx.llm.listProviders();
502
+ const catalog = await Promise.all(providers.map(async (provider) => {
503
+ try {
504
+ const models = await ctx.llm.listModels(provider.id);
505
+ const entries = await Promise.all(models.map(async (model) => {
506
+ const resolved = await ctx.llm.resolveModelInfo(provider.id, model.id);
507
+ const reasoning = resolved.reasoning === void 0 ? void 0 : {
508
+ efforts: resolved.reasoning.efforts.map((effort) => ({
509
+ id: effort.id,
510
+ name: effort.name,
511
+ ...effort.description === void 0 ? {} : { description: effort.description }
512
+ })),
513
+ ...resolved.reasoning.defaultEffort === void 0 ? {} : { defaultEffort: resolved.reasoning.defaultEffort }
514
+ };
515
+ return {
516
+ id: model.id,
517
+ name: model.name,
518
+ ...model.description === void 0 ? {} : { description: model.description },
519
+ ...reasoning === void 0 ? {} : { reasoning }
520
+ };
521
+ }));
522
+ return {
523
+ kind: "group",
524
+ group: {
525
+ id: provider.id,
526
+ name: provider.name,
527
+ models: entries
528
+ }
529
+ };
530
+ } catch (error) {
531
+ return {
532
+ kind: "failure",
533
+ failure: {
534
+ id: provider.id,
535
+ name: provider.name,
536
+ message: error instanceof Error ? error.message : String(error)
537
+ }
538
+ };
539
+ }
540
+ }));
541
+ const groups = catalog.flatMap((item) => item.kind === "group" ? [item.group] : []).filter((group) => group.models.length > 0);
542
+ return {
543
+ default: { ...defaultSelection },
544
+ routableProviders: groups.map((group) => group.id),
545
+ groups,
546
+ failures: catalog.flatMap((item) => item.kind === "failure" ? [item.failure] : [])
547
+ };
548
+ }
549
+ /**
550
+ * Check a GUI selection against the current available provider catalog.
551
+ * @param ctx - Host LLM registry.
552
+ * @param selection - stored or explicitly requested selection.
553
+ * @returns whether the exact model is currently advertised as available.
554
+ */
555
+ async function modelAvailable(ctx, selection) {
556
+ if (!ctx.llm.listProviders().some((provider) => provider.id === selection.provider)) return false;
557
+ let models;
558
+ try {
559
+ models = await ctx.llm.listModels(selection.provider);
560
+ } catch (error) {
561
+ throw new RemoteError("session/model-unavailable", error instanceof Error ? error.message : String(error), {
562
+ provider: selection.provider,
563
+ model: selection.model
564
+ });
565
+ }
566
+ return models.some((model) => model.id === selection.model);
567
+ }
568
+ /**
569
+ * Check configured provider API-key references independently of model availability.
570
+ * @param ctx - Host registry, settings, and credential services.
571
+ * @returns whether any API-key provider has a configured credential.
572
+ */
573
+ async function hasProviderApiKey(ctx) {
574
+ const settings = ctx.get("settings");
575
+ const credentials = ctx.get("credentials");
576
+ if (settings === void 0 || credentials === void 0) throw new RemoteError("session/provider-credentials-unavailable", "provider credentials are unavailable", {});
577
+ const namespaces = settings.describe({ redactSecrets: true });
578
+ for (const provider of ctx.llm.listConfigurableProviders()) {
579
+ if (provider.provider === "deepseek-account") continue;
580
+ let profile = namespaces.find((namespace) => namespace.ns === provider.settingsNs)?.value;
581
+ for (const key of provider.settingsPath) profile = typeof profile === "object" && profile !== null ? Reflect.get(profile, key) : void 0;
582
+ if (typeof profile !== "object" || profile === null) continue;
583
+ const ref = Reflect.get(profile, "apiKeyEnv");
584
+ if (typeof ref === "string" && ref.length > 0 && (await credentials.describe(credentialRef(ref))).configured) return true;
585
+ }
586
+ return false;
587
+ }
588
+ //#endregion
491
589
  //#region lib/types/commands.js
492
590
  /** Session commands whose activation policy is explicit at each Remote method. */
493
591
  var __addDisposableResource$3 = function(env, value, async) {
@@ -615,14 +713,15 @@ var SessionCommandController = class {
615
713
  };
616
714
  }
617
715
  /**
618
- * Validate and install one Session-local model selection.
716
+ * Validate and install one Session-local model selection; save the default in the background.
619
717
  * @param request - Session identity and requested model selection.
620
- * @returns the normalized selection installed for the Session.
718
+ * @returns the normalized selection installed for the Session, without waiting for default persistence.
621
719
  */
622
720
  async selectModel(request) {
623
721
  const agent = await this.resolveAgent(request.sessionId);
624
722
  return this.agents.serializeImageAdmission(agent, async () => {
625
723
  try {
724
+ await this.requireModel(request);
626
725
  const resolved = await this.ctx.llm.resolveCallConfig({
627
726
  provider: request.provider,
628
727
  model: request.model,
@@ -634,11 +733,9 @@ var SessionCommandController = class {
634
733
  ...resolved.reasoningEffort === void 0 ? {} : { reasoningEffort: resolved.reasoningEffort }
635
734
  };
636
735
  this.agents.selectForNextRequest(agent, selected);
637
- try {
638
- await this.ctx.agentDefaultModel.saveSelection(selected);
639
- } catch (error) {
736
+ this.ctx.agentDefaultModel.saveSelection(selected).catch((error) => {
640
737
  this.ctx.logger.warn(`session-controller: model selection changed for the Session but the default was not saved: ${String(error)}`);
641
- }
738
+ });
642
739
  return { selected: { ...selected } };
643
740
  } catch (error) {
644
741
  if (remoteErrorOf(error) !== void 0) throw error;
@@ -756,11 +853,6 @@ var SessionCommandController = class {
756
853
  if (request.clientTimeZone !== void 0 && clientTimeZone === void 0) throw new RemoteError("session/invalid-time-zone", "clientTimeZone must be UTC or a valid IANA Area/Location name", { value: request.clientTimeZone });
757
854
  const agent = await this.resolveAgent(request.sessionId);
758
855
  if (hasPromptRequest(agent, request.requestId)) return { accepted: true };
759
- const selection = this.agents.selectionFor(agent).current;
760
- if (!routeServed(this.ctx, selection.provider)) throw new RemoteError("session/model-unavailable", `no adapter serves provider "${selection.provider}"; select a model for this session`, {
761
- provider: selection.provider,
762
- model: selection.model
763
- });
764
856
  const source = {
765
857
  kind: "user",
766
858
  rpcId: request.requestId,
@@ -805,6 +897,12 @@ var SessionCommandController = class {
805
897
  };
806
898
  return hasImage ? this.agents.serializeImageAdmission(agent, admit) : admit();
807
899
  }
900
+ async requireModel(selection) {
901
+ if (!await modelAvailable(this.ctx, selection)) throw new RemoteError("session/model-unavailable", "Select an available model before sending a message.", {
902
+ provider: selection.provider,
903
+ model: selection.model
904
+ });
905
+ }
808
906
  /**
809
907
  * Read one durable image after proving the Session log references it.
810
908
  * @param request - Session and attachment identities used for authorization.
@@ -1026,9 +1124,6 @@ function referencedImage(events, attachmentId) {
1026
1124
  if (found !== void 0) return found;
1027
1125
  }
1028
1126
  }
1029
- function routeServed(ctx, provider) {
1030
- return ctx.llm.listProviders().some((entry) => entry.id === provider);
1031
- }
1032
1127
  //#endregion
1033
1128
  //#region lib/types/control.js
1034
1129
  /** Live Session projection state with reconnect baselines. */
@@ -1953,63 +2048,6 @@ function listFields(header) {
1953
2048
  };
1954
2049
  }
1955
2050
  //#endregion
1956
- //#region lib/types/catalog.js
1957
- /** Shared projection of the live LLM registry into the browser model catalog. */
1958
- /**
1959
- * Build the browser model catalog without requiring a Session.
1960
- * @param ctx - Host context carrying the live LLM registry.
1961
- * @param defaultSelection - deployment default used before a Session selects a model.
1962
- * @returns successful non-empty provider groups and isolated provider failures.
1963
- */
1964
- async function buildModelCatalog(ctx, defaultSelection = ctx.agentDefaultModel.currentSelection()) {
1965
- const providers = ctx.llm.listProviders();
1966
- const catalog = await Promise.all(providers.map(async (provider) => {
1967
- try {
1968
- const models = await ctx.llm.listModels(provider.id);
1969
- const entries = await Promise.all(models.map(async (model) => {
1970
- const resolved = await ctx.llm.resolveModelInfo(provider.id, model.id);
1971
- const reasoning = resolved.reasoning === void 0 ? void 0 : {
1972
- efforts: resolved.reasoning.efforts.map((effort) => ({
1973
- id: effort.id,
1974
- name: effort.name,
1975
- ...effort.description === void 0 ? {} : { description: effort.description }
1976
- })),
1977
- ...resolved.reasoning.defaultEffort === void 0 ? {} : { defaultEffort: resolved.reasoning.defaultEffort }
1978
- };
1979
- return {
1980
- id: model.id,
1981
- name: model.name,
1982
- ...model.description === void 0 ? {} : { description: model.description },
1983
- ...reasoning === void 0 ? {} : { reasoning }
1984
- };
1985
- }));
1986
- return {
1987
- kind: "group",
1988
- group: {
1989
- id: provider.id,
1990
- name: provider.name,
1991
- models: entries
1992
- }
1993
- };
1994
- } catch (error) {
1995
- return {
1996
- kind: "failure",
1997
- failure: {
1998
- id: provider.id,
1999
- name: provider.name,
2000
- message: error instanceof Error ? error.message : String(error)
2001
- }
2002
- };
2003
- }
2004
- }));
2005
- return {
2006
- default: { ...defaultSelection },
2007
- routableProviders: providers.map((provider) => provider.id),
2008
- groups: catalog.flatMap((item) => item.kind === "group" ? [item.group] : []).filter((group) => group.models.length > 0),
2009
- failures: catalog.flatMap((item) => item.kind === "failure" ? [item.failure] : [])
2010
- };
2011
- }
2012
- //#endregion
2013
2051
  //#region lib/types/model-selection-projection.js
2014
2052
  /** Durable model-selection intent and request-use projection. */
2015
2053
  const modelSelectionSchema = z$1.object({
@@ -2522,6 +2560,7 @@ let SessionController = (() => {
2522
2560
  let _search_decorators;
2523
2561
  let _create_decorators;
2524
2562
  let _selectModel_decorators;
2563
+ let _initializeDefaultModel_decorators;
2525
2564
  let _modelCatalog_decorators;
2526
2565
  let _canOpenWorkspacePath_decorators;
2527
2566
  let _openWorkspacePath_decorators;
@@ -2543,6 +2582,7 @@ let SessionController = (() => {
2543
2582
  _search_decorators = [Remote("search")];
2544
2583
  _create_decorators = [Remote("create")];
2545
2584
  _selectModel_decorators = [Remote("selectModel")];
2585
+ _initializeDefaultModel_decorators = [Remote];
2546
2586
  _modelCatalog_decorators = [Remote("modelCatalog")];
2547
2587
  _canOpenWorkspacePath_decorators = [Remote];
2548
2588
  _openWorkspacePath_decorators = [Remote("openWorkspacePath")];
@@ -2601,6 +2641,17 @@ let SessionController = (() => {
2601
2641
  },
2602
2642
  metadata: _metadata
2603
2643
  }, null, _instanceExtraInitializers);
2644
+ __esDecorate(this, null, _initializeDefaultModel_decorators, {
2645
+ kind: "method",
2646
+ name: "initializeDefaultModel",
2647
+ static: false,
2648
+ private: false,
2649
+ access: {
2650
+ has: (obj) => "initializeDefaultModel" in obj,
2651
+ get: (obj) => obj.initializeDefaultModel
2652
+ },
2653
+ metadata: _metadata
2654
+ }, null, _instanceExtraInitializers);
2604
2655
  __esDecorate(this, null, _modelCatalog_decorators, {
2605
2656
  kind: "method",
2606
2657
  name: "modelCatalog",
@@ -2921,14 +2972,30 @@ let SessionController = (() => {
2921
2972
  return this.commands.create(request);
2922
2973
  }
2923
2974
  /**
2924
- * Select one Session-local model after explicitly resuming the Session.
2975
+ * Select one Session-local model after explicitly resuming the Session; save the default in the background.
2925
2976
  * @param request - Session identity and requested model selection.
2926
- * @returns the normalized selection installed for the Session.
2977
+ * @returns the normalized selection installed for the Session, without waiting for default persistence.
2927
2978
  */
2928
2979
  selectModel(request) {
2929
2980
  return this.commands.selectModel(request);
2930
2981
  }
2931
2982
  /**
2983
+ * Select the first available account model after login when no provider API key is configured.
2984
+ * @returns after saving the first available model or retaining the existing default.
2985
+ */
2986
+ async initializeDefaultModel() {
2987
+ const provider = "deepseek-account";
2988
+ if (await hasProviderApiKey(this.ctx)) return;
2989
+ const model = (await buildModelCatalog(this.ctx)).groups.find((group) => group.id === provider)?.models[0];
2990
+ if (model === void 0) throw new RemoteError("session/provider-models-unavailable", `provider "${provider}" has no available models`, { provider });
2991
+ const selection = {
2992
+ provider,
2993
+ model: model.id,
2994
+ ...model.reasoning?.defaultEffort === void 0 ? {} : { reasoningEffort: ReasoningEffortId(model.reasoning.defaultEffort) }
2995
+ };
2996
+ await this.ctx.agentDefaultModel.saveSelection(selection);
2997
+ }
2998
+ /**
2932
2999
  * Describe every currently routable model for Host-generation selectors.
2933
3000
  * @returns provider-grouped models, the deployment default, and isolated provider failures.
2934
3001
  */