@storvia/sdk 0.6.1 → 0.7.0

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/dist/index.d.mts CHANGED
@@ -385,13 +385,6 @@ interface State {
385
385
  dormant: DormantState;
386
386
  }
387
387
 
388
- interface GameSettings {
389
- temperature: number;
390
- replyLength: string;
391
- replyLanguage: string;
392
- playerNote: string;
393
- }
394
-
395
388
  declare class ChatModule {
396
389
  private http;
397
390
  private getGameId;
@@ -399,9 +392,8 @@ declare class ChatModule {
399
392
  private getModelId;
400
393
  private isPreview;
401
394
  private previewConfig?;
402
- private getSettings?;
403
395
  private getModelName?;
404
- constructor(http: HttpClient, getGameId: () => string, getConversationId: () => string, getModelId: () => string, isPreview?: boolean, previewConfig?: Record<string, unknown>, getSettings?: () => GameSettings | null | undefined, getModelName?: () => string | undefined);
396
+ constructor(http: HttpClient, getGameId: () => string, getConversationId: () => string, getModelId: () => string, isPreview?: boolean, previewConfig?: Record<string, unknown>, getModelName?: () => string | undefined);
405
397
  /** 构造 http 层的元信息(用于 debug 日志标题显示) */
406
398
  private reqMeta;
407
399
  /** 更新预览配置(由父页面 postMessage 触发) */
@@ -691,10 +683,11 @@ declare class MemoryModule {
691
683
  interface DevConfig {
692
684
  apiKey: string;
693
685
  gameId: string;
686
+ /** 本地预览/dev:指定初始模型的展示名(display name)。不传则用第一个可用模型。 */
687
+ model?: string;
694
688
  }
695
689
  declare class StorviaSDK {
696
690
  private http;
697
- private settingsSheet;
698
691
  private baseUrl;
699
692
  private gameId;
700
693
  private conversationId;
@@ -716,18 +709,18 @@ declare class StorviaSDK {
716
709
  state: StateModule;
717
710
  memory: MemoryModule;
718
711
  init(): Promise<void>;
712
+ /**
713
+ * 监听宿主运行时下发的模型切换(envelope 'set-model')。
714
+ * 正式模式用:宿主已接管模型选择,用户在宿主 FAB 改模型时实时同步到 SDK。
715
+ * (预览模式的 set-model 在 listenForPreviewMessages 内单独处理。)
716
+ */
717
+ private listenForModelChange;
719
718
  /**
720
719
  * 监听父页面 token 刷新(envelope 'token-update')。
721
720
  * Supabase JWT 默认 1h 过期,父页面 session 自动刷新后转发新 token 进来,
722
721
  * 否则 SDK 会一直用旧 token 请求被服务端 401。
723
722
  */
724
723
  private listenForTokenUpdate;
725
- /**
726
- * 用户在 SDK 内置选择器里切换模型时统一入口:
727
- * 更新内部 modelId,并把选择回传给宿主(主站/App),实现双向同步与持久化。
728
- * dev 模式没有 bus(无父页面),此时仅更新本地。
729
- */
730
- private handleLocalModelChange;
731
724
  /** 监听父页面发来的预览模式动态更新(envelope 'config-update' / 'set-model') */
732
725
  private listenForPreviewMessages;
733
726
  /**
@@ -739,13 +732,8 @@ declare class StorviaSDK {
739
732
  private fetchPreviewSnapshot;
740
733
  /** 重新拉 snapshot 并把结果灌进每个 module 的 mem(用于 update-config 后同步) */
741
734
  private refreshPreviewSnapshot;
742
- /** 保存设置到后端 */
743
- private saveSettings;
744
- /** 同步最新游戏设定到当前存档 */
745
- syncSettings(): Promise<void>;
746
735
  private fetchModels;
747
736
  private authenticate;
748
- private getSavedModelId;
749
737
  initDev(devConfig: DevConfig): Promise<void>;
750
738
  getAssets(type: 'avatar' | 'icon', category?: string): Promise<AssetItem[]>;
751
739
  }
@@ -793,6 +781,12 @@ interface InitPayload {
793
781
  * 待主站 / App 全部升级后改为必填,以彻底消除 /auth 端选错存档的漂移。
794
782
  */
795
783
  conversationId?: string;
784
+ /**
785
+ * 宿主(主站/App)已选中的模型 UUID。宿主已接管模型选择 → 正式模式优先用它,
786
+ * 盖过 SDK 自己的 localStorage / 列表首项。随 init 一起下发,避免「init 后单独发 set-model」
787
+ * 在 SDK 注册监听前到达而丢失的竞态。运行时切换仍走 envelope 'set-model'。
788
+ */
789
+ selectedModelId?: string;
796
790
  debug?: boolean;
797
791
  }
798
792
  interface PreviewConfig {