@dsmm/dsmm 0.3.15 → 0.3.16

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.
Files changed (53) hide show
  1. package/README.md +11 -5
  2. package/docs/agent-presets.md +1 -1
  3. package/docs/compatibility.md +3 -3
  4. package/docs/deferred-native-approval-risk.md +1 -1
  5. package/docs/design.md +1 -1
  6. package/docs/lsp.md +1 -1
  7. package/docs/model-routing.md +13 -6
  8. package/docs/native-permissions.md +1 -1
  9. package/docs/profiles.md +3 -1
  10. package/docs/roadmap.md +2 -2
  11. package/docs/runtime-recovery.md +4 -4
  12. package/docs/safety-guards.md +1 -1
  13. package/docs/settings-status.md +4 -2
  14. package/docs/tui.md +53 -0
  15. package/dsh-plugin.json +41 -0
  16. package/lib/client/ProfilesSection.js +1 -1
  17. package/lib/client/SessionProfiles.js +8 -7
  18. package/lib/client/children-locales.d.ts +1 -1
  19. package/lib/client/controller.d.ts +13 -1
  20. package/lib/client/controller.js +114 -20
  21. package/lib/client/deployment-locales.js +3 -2
  22. package/lib/client/deployment-modules.js +1 -1
  23. package/lib/client/index.js +22 -4
  24. package/lib/client/locales.d.ts +1 -0
  25. package/lib/client/locales.js +2 -0
  26. package/lib/client.js +144 -29
  27. package/lib/commands.d.ts +7 -3
  28. package/lib/commands.js +20 -11
  29. package/lib/host-llm.js +6 -1
  30. package/lib/index.d.ts +1 -1
  31. package/lib/index.js +2 -6
  32. package/lib/model-routing.js +43 -19
  33. package/lib/profile-diagnostics.js +1 -0
  34. package/lib/profile-runtime.js +1 -1
  35. package/lib/request-routing.d.ts +27 -0
  36. package/lib/request-routing.js +69 -0
  37. package/lib/role-llm-runtime.js +15 -2
  38. package/lib/role-routing.d.ts +4 -3
  39. package/lib/role-routing.js +17 -10
  40. package/lib/runtime-recovery.js +56 -16
  41. package/lib/settings.d.ts +3 -0
  42. package/lib/settings.js +9 -0
  43. package/lib/state.d.ts +2 -2
  44. package/lib/state.js +13 -4
  45. package/lib/status.d.ts +5 -0
  46. package/lib/status.js +18 -7
  47. package/lib/tui-actions.d.ts +21 -0
  48. package/lib/tui-actions.js +301 -0
  49. package/lib/tui-adapter.d.ts +25 -0
  50. package/lib/tui-adapter.js +422 -0
  51. package/lib/tui-types.d.ts +98 -0
  52. package/lib/tui-types.js +2 -0
  53. package/package.json +3 -1
package/lib/client.js CHANGED
@@ -2692,6 +2692,7 @@ var roleRouting = { primary: route, fallbackRoutes: [route], strategy: null, rat
2692
2692
  var configFields = {
2693
2693
  permissionControl: schemaFieldShape(permissionControlSchema),
2694
2694
  modelParameters: { passthrough: null },
2695
+ rootModelPolicy: null,
2695
2696
  locale: null,
2696
2697
  modeName: null,
2697
2698
  section: null,
@@ -3550,6 +3551,7 @@ var ProfilesController = class {
3550
3551
  currentSessionId: null,
3551
3552
  sessionViewEpoch: 0,
3552
3553
  sessionUnconfirmed: false,
3554
+ sessionReadinessPending: false,
3553
3555
  session: null,
3554
3556
  sessionChoice: null,
3555
3557
  sessionWorkspaces: [],
@@ -3595,6 +3597,13 @@ var ProfilesController = class {
3595
3597
  modeRefreshPending = false;
3596
3598
  sessionSource = null;
3597
3599
  sessionSourceId = null;
3600
+ sessionBinding = null;
3601
+ agentAvailable;
3602
+ availabilityEpoch = 0;
3603
+ availabilityReadSucceeded = false;
3604
+ initialSessionRead = true;
3605
+ sessionReadIssue = null;
3606
+ readinessTimer = null;
3598
3607
  stopSessionSource = null;
3599
3608
  stopModelEvents = null;
3600
3609
  modelInteraction = null;
@@ -3655,6 +3664,7 @@ var ProfilesController = class {
3655
3664
  };
3656
3665
  numberDrafts = /* @__PURE__ */ new Map();
3657
3666
  dispose() {
3667
+ this.endReadiness();
3658
3668
  this.releasePreparation();
3659
3669
  this.stopWorkspaces?.();
3660
3670
  this.releaseComposerBlock();
@@ -3689,6 +3699,7 @@ var ProfilesController = class {
3689
3699
  this.connectionBound = true;
3690
3700
  this.connectionBaseline = source?.getSnapshot();
3691
3701
  const invalidate = () => {
3702
+ this.resetReadiness();
3692
3703
  this.releasePreparation();
3693
3704
  this.connectionBaseline = source?.getSnapshot();
3694
3705
  this.generation += 1;
@@ -3698,6 +3709,7 @@ var ProfilesController = class {
3698
3709
  this.publish({
3699
3710
  session: null,
3700
3711
  sessionBusy: null,
3712
+ sessionIssue: null,
3701
3713
  sessionNotice: null,
3702
3714
  sessionUnconfirmed: false,
3703
3715
  sessionViewEpoch: this.current.sessionViewEpoch + 1,
@@ -3710,10 +3722,7 @@ var ProfilesController = class {
3710
3722
  if (replacement || source === null || this.connectionBaseline === void 0) invalidate();
3711
3723
  this.stopConnection = source?.subscribe(() => {
3712
3724
  invalidate();
3713
- if (this.connectionCurrent()) {
3714
- void this.refresh();
3715
- void this.refreshSession();
3716
- }
3725
+ if (this.connectionCurrent()) void this.refresh();
3717
3726
  }) ?? null;
3718
3727
  }
3719
3728
  connectionCurrent() {
@@ -3933,18 +3942,22 @@ var ProfilesController = class {
3933
3942
  this.modelSelectionGeneration += 1;
3934
3943
  }) ?? null;
3935
3944
  }
3936
- attachSessionSource(sessionId2, source) {
3937
- if (this.disposed || sessionId2 === this.sessionSourceId && source === this.sessionSource) return;
3945
+ attachSessionSource(sessionId2, source, binding = source) {
3946
+ if (this.disposed || sessionId2 === this.sessionSourceId && source === this.sessionSource && binding === this.sessionBinding) return;
3947
+ this.resetReadiness();
3938
3948
  this.stopSessionSource?.();
3939
3949
  this.sessionSourceId = sessionId2;
3940
3950
  this.sessionSource = source;
3951
+ this.sessionBinding = binding;
3941
3952
  let running = source?.getSnapshot().running;
3942
- const current = () => !this.disposed && sessionId2 !== null && sessionId2 === this.current.currentSessionId && source === this.sessionSource;
3953
+ const current = () => !this.disposed && sessionId2 !== null && sessionId2 === this.current.currentSessionId && source === this.sessionSource && binding === this.sessionBinding;
3943
3954
  this.stopSessionSource = source?.subscribe(() => {
3944
3955
  if (!current()) return;
3956
+ if (this.connectionCurrent() && this.sessionSourceFailed()) return;
3945
3957
  const next = source.getSnapshot().running;
3946
3958
  if (next === running) return;
3947
3959
  running = next;
3960
+ if (!this.connectionCurrent()) return;
3948
3961
  this.modeRefreshPending = true;
3949
3962
  this.refreshObservedMode();
3950
3963
  }) ?? null;
@@ -3954,6 +3967,7 @@ var ProfilesController = class {
3954
3967
  this.publish({
3955
3968
  session: null,
3956
3969
  sessionBusy: null,
3970
+ sessionIssue: null,
3957
3971
  sessionNotice: null,
3958
3972
  sessionViewEpoch: this.current.sessionViewEpoch + 1,
3959
3973
  sessionUnconfirmed: this.pendingSessionSelections.has(sessionId2)
@@ -3961,6 +3975,53 @@ var ProfilesController = class {
3961
3975
  this.refreshObservedMode();
3962
3976
  }
3963
3977
  }
3978
+ endReadiness() {
3979
+ if (this.readinessTimer !== null) clearTimeout(this.readinessTimer);
3980
+ this.readinessTimer = null;
3981
+ if (this.current.sessionReadinessPending) this.publish({ sessionReadinessPending: false });
3982
+ }
3983
+ resetReadiness() {
3984
+ this.endReadiness();
3985
+ this.agentAvailable = void 0;
3986
+ this.availabilityEpoch += 1;
3987
+ this.availabilityReadSucceeded = false;
3988
+ this.initialSessionRead = true;
3989
+ this.sessionReadIssue = null;
3990
+ }
3991
+ sessionSourceFailed() {
3992
+ const source = this.sessionSource?.getSnapshot();
3993
+ if (source === void 0 || !source.removed && source.openError === null) return false;
3994
+ this.endReadiness();
3995
+ this.initialSessionRead = false;
3996
+ this.availabilityEpoch += 1;
3997
+ this.availabilityReadSucceeded = false;
3998
+ this.sessionGeneration += 1;
3999
+ this.modeRefreshPending = false;
4000
+ const issue = source.removed ? { kind: "domain", code: "disposed", field: "sessionId" } : { kind: "transport", code: source.openError.code };
4001
+ this.sessionReadIssue = issue;
4002
+ const { currentSessionId: id2, session, sessionUnconfirmed } = this.current;
4003
+ this.publish({
4004
+ session: null,
4005
+ sessionBusy: null,
4006
+ sessionIssue: issue,
4007
+ sessionUnconfirmed: sessionUnconfirmed || id2 !== null && this.pendingSessionSelections.has(id2) || session?.refreshRequired === true || session?.selection.refreshRequired === true
4008
+ });
4009
+ return true;
4010
+ }
4011
+ observeSessionAvailability(id2, source, available) {
4012
+ if (this.disposed || !this.connectionCurrent() || id2 !== this.current.currentSessionId || id2 !== this.sessionSourceId || source !== this.sessionSource || this.sessionSourceFailed()) return;
4013
+ const changed = available !== this.agentAvailable;
4014
+ this.agentAvailable = available;
4015
+ if (!available) {
4016
+ this.availabilityEpoch += 1;
4017
+ this.availabilityReadSucceeded = false;
4018
+ return;
4019
+ }
4020
+ if (changed || !this.availabilityReadSucceeded) {
4021
+ this.modeRefreshPending = true;
4022
+ this.refreshObservedMode();
4023
+ }
4024
+ }
3964
4025
  attachModelEventSource(sessionId2, source) {
3965
4026
  if (this.disposed || sessionId2 === this.modelEventsSessionId && source === this.modelEvents) return;
3966
4027
  this.modelEventsGeneration += 1;
@@ -4008,6 +4069,7 @@ var ProfilesController = class {
4008
4069
  }
4009
4070
  setSession(id2) {
4010
4071
  if (this.disposed || id2 === this.current.currentSessionId) return;
4072
+ this.resetReadiness();
4011
4073
  const task = this.preparation;
4012
4074
  const preparationUnconfirmed = task?.id === id2 && this.current.sessionUnconfirmed;
4013
4075
  if (task?.id === id2 && task.held !== null && id2 !== null) {
@@ -4047,16 +4109,46 @@ var ProfilesController = class {
4047
4109
  return;
4048
4110
  }
4049
4111
  if (this.disposed || !this.connectionCurrent() || id2 === null || this.current.sessionBusy !== null || this.sessionSourceId === id2 && this.sessionSource === null) return;
4112
+ if (this.sessionSourceFailed()) return;
4113
+ const initial = this.initialSessionRead;
4114
+ const availabilityEpoch = this.availabilityEpoch;
4115
+ this.initialSessionRead = false;
4050
4116
  this.modeRefreshPending = false;
4051
4117
  const generation = ++this.sessionGeneration;
4052
4118
  const live = () => !this.disposed && this.connectionCurrent() && generation === this.sessionGeneration && id2 === this.current.currentSessionId;
4053
- this.publish({ sessionBusy: "read", ...preserveFeedback ? {} : { sessionIssue: null, sessionNotice: null } });
4119
+ this.publish({ sessionBusy: "read" });
4054
4120
  try {
4055
4121
  const session = await this.unwrap(this.remote.describeSession(id2));
4056
4122
  if (session.sessionId !== id2) throw { kind: "assembly", code: "unavailable" };
4057
- if (live()) this.publish({ session, sessionChoice: (session.admittedSelection ?? session.selection).selectedId, sessionUnconfirmed: this.pendingSessionSelections.has(id2) });
4123
+ if (live()) {
4124
+ if (availabilityEpoch === this.availabilityEpoch && this.agentAvailable !== false) this.availabilityReadSucceeded = true;
4125
+ this.endReadiness();
4126
+ this.publish({
4127
+ session,
4128
+ sessionChoice: (session.admittedSelection ?? session.selection).selectedId,
4129
+ sessionUnconfirmed: this.pendingSessionSelections.has(id2),
4130
+ ...this.current.sessionIssue === this.sessionReadIssue ? { sessionIssue: null } : {}
4131
+ });
4132
+ this.sessionReadIssue = null;
4133
+ }
4058
4134
  } catch (error) {
4059
- if (live()) this.publish({ sessionIssue: this.issue(error) });
4135
+ if (live()) {
4136
+ const issue = this.issue(error);
4137
+ const waiting = (initial || this.current.sessionReadinessPending) && this.sessionSourceId === id2 && this.sessionSource !== null && this.current.session === null && this.sessionSource.getSnapshot().sessionId === id2 && issue.kind === "domain" && issue.code === "unavailable" && issue.field === "sessionId";
4138
+ if (!waiting) this.endReadiness();
4139
+ if (!preserveFeedback || this.current.sessionIssue === null || this.current.sessionIssue === this.sessionReadIssue) this.publish({ sessionIssue: issue });
4140
+ this.sessionReadIssue = issue;
4141
+ if (waiting && this.readinessTimer === null) {
4142
+ const source = this.sessionSource, connection = this.connectionBaseline;
4143
+ const timer = setTimeout(() => {
4144
+ if (this.readinessTimer !== timer || this.disposed || source !== this.sessionSource || id2 !== this.current.currentSessionId || connection !== this.connectionBaseline) return;
4145
+ this.readinessTimer = null;
4146
+ this.publish({ sessionReadinessPending: false });
4147
+ }, 1e4);
4148
+ this.readinessTimer = timer;
4149
+ this.publish({ sessionReadinessPending: true });
4150
+ }
4151
+ }
4060
4152
  } finally {
4061
4153
  if (live()) {
4062
4154
  this.publish({ sessionBusy: null });
@@ -4238,10 +4330,11 @@ var ProfilesController = class {
4238
4330
  }
4239
4331
  }
4240
4332
  async refresh() {
4241
- await this.perform("refresh", async (live) => {
4333
+ const session = this.refreshSession();
4334
+ await Promise.all([session, this.perform("refresh", async (live) => {
4242
4335
  const snapshot4 = await this.unwrap(this.remote.describe());
4243
4336
  if (live()) this.publish({ snapshot: snapshot4 });
4244
- });
4337
+ })]);
4245
4338
  }
4246
4339
  async open(id2) {
4247
4340
  if (this.disposed || this.current.busy !== null || this.current.pendingEditor !== null) return;
@@ -4401,6 +4494,7 @@ var en = {
4401
4494
  sessionSelectionBlock: "Finish choosing this session's configuration to continue typing.",
4402
4495
  sessionCommittedRefresh: "Saved. Refresh to confirm it.",
4403
4496
  sessionUnconfirmedRefresh: "The result is unknown. Refresh before choosing or sending again.",
4497
+ sessionWaitingReady: "Waiting for the session to be ready…",
4404
4498
  technicalDetails: "Details",
4405
4499
  diagnosticJsonc: "Fix the JSONC syntax at the marked location.",
4406
4500
  diagnosticDuplicate: "Remove the duplicate field.",
@@ -4708,6 +4802,7 @@ var zh = {
4708
4802
  sessionSelectionBlock: "请先完成本次会话的配置选择,然后即可继续输入。",
4709
4803
  sessionCommittedRefresh: "已保存,请刷新确认。",
4710
4804
  sessionUnconfirmedRefresh: "结果未知,请刷新后再选择或发送。",
4805
+ sessionWaitingReady: "正在等待会话就绪…",
4711
4806
  technicalDetails: "详情",
4712
4807
  diagnosticJsonc: "请修正标记位置的 JSONC 语法。",
4713
4808
  diagnosticDuplicate: "请删除重复字段。",
@@ -6094,7 +6189,8 @@ function SessionScopeFeedback({ state, t }) {
6094
6189
  state.dirty && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "dsmm-hint", children: t("sessionDirty") }),
6095
6190
  (session?.refreshRequired || session?.selection.refreshRequired) && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { role: "status", children: t("sessionCommittedRefresh") }),
6096
6191
  state.sessionUnconfirmed && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { role: "status", children: t(state.sessionIssue?.code === "blank-identity-unconfirmed" ? "sessionPreparationUnknown" : "sessionUnconfirmedRefresh") }),
6097
- state.sessionIssue !== null && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
6192
+ state.sessionReadinessPending && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { role: "status", children: t("sessionWaitingReady") }),
6193
+ state.sessionIssue !== null && !state.sessionReadinessPending && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
6098
6194
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { role: "alert", children: state.sessionIssue.source === "profile-model" ? t(state.sessionIssue.code === "model-unconfigured" ? "headerNoProfileModel" : state.sessionIssue.code === "model-choice-changed" ? "headerModelChoiceChanged" : "headerModelUnconfirmed") : state.sessionIssue.code === "conflict" ? t("sessionConflict") : ["busy", "maintenance", "disposed", "not-owned"].includes(state.sessionIssue.code) ? t("sessionBusy", { reason: state.sessionIssue.code }) : t(state.sessionIssue.code === "validation" ? "validation" : "sessionUnavailable") }),
6099
6195
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(IssueDetails, { issue: state.sessionIssue, t })
6100
6196
  ] }),
@@ -6154,7 +6250,7 @@ function SessionScope({ state, actions: actions3, t, compact = false, showFeedba
6154
6250
  ] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
6155
6251
  labels !== null && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { "data-dsmm-session-state": true, children: labels.admitted }),
6156
6252
  labels !== null && !compact && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "dsmm-hint", "data-dsmm-session-future-default": true, children: labels.futureDefault }),
6157
- session === null && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "dsmm-hint", id: `${prefix}-overlay-reason`, children: t("sessionUnavailable") }),
6253
+ session === null && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "dsmm-hint", id: `${prefix}-overlay-reason`, children: t(state.sessionReadinessPending ? "sessionWaitingReady" : "sessionUnavailable") }),
6158
6254
  session !== null && !allowed && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "dsmm-hint", id: `${prefix}-overlay-reason`, children: capabilityReason(session.applyOverlayUnavailableReason, t) }),
6159
6255
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "dsmm-field", children: [
6160
6256
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("label", { htmlFor: `${prefix}-choice`, children: t("sessionSelect") }),
@@ -6230,6 +6326,7 @@ function SessionProfiles(props) {
6230
6326
  let feedback = "";
6231
6327
  if (state.sessionUnconfirmed) feedback = t(state.sessionIssue?.code === "blank-identity-unconfirmed" ? "sessionPreparationUnknown" : "sessionUnconfirmedRefresh");
6232
6328
  else if (session?.refreshRequired || session?.selection.refreshRequired) feedback = t("sessionCommittedRefresh");
6329
+ else if (state.sessionReadinessPending) feedback = t("sessionWaitingReady");
6233
6330
  else if (state.sessionIssue !== null) feedback = t(state.sessionIssue.source === "profile-model" ? state.sessionIssue.code === "model-unconfigured" ? "headerNoProfileModel" : state.sessionIssue.code === "model-choice-changed" ? "headerModelChoiceChanged" : "headerModelUnconfirmed" : state.sessionIssue.code === "conflict" ? "headerConflict" : state.sessionIssue.code === "activation" ? "headerActivationRefused" : state.sessionIssue.code === "maintenance" ? "headerMaintenanceRefused" : state.sessionIssue.code === "busy" ? "headerBusyRefused" : state.sessionIssue.code === "cancelled" ? "headerCancelledRefused" : state.sessionIssue.code === "unavailable" || state.sessionIssue.kind === "assembly" ? "headerUnavailableRefused" : "headerSelectionRefused");
6234
6331
  else if (committing || state.busy !== null) feedback = t(state.sessionBusy === "apply" || state.sessionBusy === "reset" ? "headerApplying" : "headerLoading");
6235
6332
  else if (state.dirty || state.invalidFields.length > 0 || state.pendingEditor !== null) feedback = t("headerDraft");
@@ -6237,7 +6334,7 @@ function SessionProfiles(props) {
6237
6334
  else if (session === null || state.snapshot === null) feedback = t("headerUnavailable");
6238
6335
  else if (state.sessionNotice !== null) feedback = t(state.sessionNotice === "mode-on" ? "headerModeOn" : state.sessionNotice === "mode-off" ? "headerModeOff" : state.sessionNotice === "applied-with-model" ? "headerAppliedWithModel" : "headerApplied");
6239
6336
  const profileName = unknownCaptured ? t("headerCaptured") : admission !== void 0 && sourceRelationship(admission, currentSaved?.revision) === "current" && currentSaved?.label?.trim() ? currentSaved.label : admission?.selectedId ?? t("sessionBaseline");
6240
- const currentLabel = t("headerCurrentProfile", { profile: session === null ? t("headerUnavailable") : profileName });
6337
+ const currentLabel = t("headerCurrentProfile", { profile: session === null ? t(state.sessionReadinessPending ? "sessionWaitingReady" : "headerUnavailable") : profileName });
6241
6338
  const entries = [{ type: "label", id: "@current", text: currentLabel }];
6242
6339
  for (const warning of profileWarnings(session?.warnings)) entries.push({ type: "label", id: `@warning:${warning.code}`, text: t("warningMarker", { code: warning.code, field: warning.field }) });
6243
6340
  if ((id2 === null || session?.canApplyOverlay === true) && state.snapshot !== null) entries.push({ type: "label", id: "@future", text: t("sessionFutureDefault", { profile: state.snapshot.profiles.find((profile) => profile.id === state.snapshot.selectedId)?.label?.trim() || state.snapshot.selectedId || t("sessionBaseline") }) });
@@ -6249,7 +6346,7 @@ function SessionProfiles(props) {
6249
6346
  disabled: unavailable || session?.canToggleMode !== true || mode === void 0 || mode.locked
6250
6347
  });
6251
6348
  if (session !== null && session.canToggleMode !== true) entries.push({ type: "label", id: "@mode-reason", text: capabilityReason(session.toggleModeUnavailableReason, t) });
6252
- const diagnostic2 = state.sessionIssue === null ? null : menuIssue(state.sessionIssue);
6349
+ const diagnostic2 = state.sessionIssue === null || state.sessionReadinessPending ? null : menuIssue(state.sessionIssue);
6253
6350
  const diagnosticText = diagnostic2 === null ? "" : t("headerIssueCode", { code: diagnostic2.code }) + (diagnostic2.field === void 0 ? "" : ` ${t("headerIssueField", { field: diagnostic2.field })}`);
6254
6351
  const retryHint = t(state.sessionUnconfirmed ? "sessionUnconfirmedRefresh" : diagnostic2?.code === "maintenance" || diagnostic2?.code === "busy" ? "headerWaitRetryHint" : "headerRetryHint");
6255
6352
  if (diagnostic2 !== null) entries.push({ type: "label", id: "@diagnostic", text: diagnosticText }, { type: "label", id: "@retry", text: retryHint });
@@ -6286,10 +6383,7 @@ function SessionProfiles(props) {
6286
6383
  if (live.currentSessionId !== id2 || live.sessionViewEpoch !== state.sessionViewEpoch || live.session !== session) return;
6287
6384
  if (value === "@refresh") {
6288
6385
  if (committing || state.busy !== null) return;
6289
- void (async () => {
6290
- await props.refresh();
6291
- if (props.readProfileView().currentSessionId === id2 && props.readProfileView().sessionViewEpoch === state.sessionViewEpoch) await props.refreshSession();
6292
- })();
6386
+ void props.refresh();
6293
6387
  } else {
6294
6388
  const row = entries.find((entry) => entry.id === value && !("type" in entry));
6295
6389
  if (row === void 0 || !("disabled" in row) || row.disabled) return;
@@ -6310,7 +6404,7 @@ function SessionProfiles(props) {
6310
6404
  }
6311
6405
  }
6312
6406
  ),
6313
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "dsmm-profile-announcement", id: `${prefix}-feedback`, role: state.sessionIssue === null ? "status" : "alert", "aria-live": "polite", "aria-atomic": "true", children: [
6407
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "dsmm-profile-announcement", id: `${prefix}-feedback`, role: state.sessionIssue === null || state.sessionReadinessPending ? "status" : "alert", "aria-live": "polite", "aria-atomic": "true", children: [
6314
6408
  feedback || currentLabel,
6315
6409
  diagnostic2 === null ? "" : ` ${diagnosticText} ${retryHint}`
6316
6410
  ] })
@@ -6576,7 +6670,7 @@ function ProfilesSection(props) {
6576
6670
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
6577
6671
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "dsmm-summary-label", children: t("currentSessionSummary") }),
6578
6672
  " ",
6579
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "dsmm-summary-val", children: state.session === null ? t("sessionUnavailable") : sessionProfileLabels(state.session, t).admitted })
6673
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "dsmm-summary-val", children: state.session === null ? t(state.sessionReadinessPending ? "sessionWaitingReady" : "sessionUnavailable") : sessionProfileLabels(state.session, t).admitted })
6580
6674
  ] }),
6581
6675
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_dsh_client_ui_primitives5.Button, { type: "button", variant: "outline", size: "sm", onClick: () => {
6582
6676
  if (moreActionsRef.current !== null) {
@@ -7537,7 +7631,7 @@ var moduleTitle = (module2) => `module:${module2}`;
7537
7631
  function moduleFor(path) {
7538
7632
  const key = path.split(".")[0];
7539
7633
  if (["defaultActive", "modules", "modelParameters", "runtime"].includes(key)) return "run";
7540
- if (["roleRouting", "runtimePolicy", "runtimeRecovery"].includes(key)) return "routes";
7634
+ if (["rootModelPolicy", "roleRouting", "runtimePolicy", "runtimeRecovery"].includes(key)) return "routes";
7541
7635
  if (["workflow", "roles", "skills", "presets", "businessLocale", "locale", "promptOrder", "subagents"].includes(key)) return "workflow";
7542
7636
  if (["permissionControl", "guards"].includes(key)) return "permissions";
7543
7637
  return "other";
@@ -7718,7 +7812,7 @@ var DEPLOYMENT_NS = "plugins.dsmm";
7718
7812
  var deploymentEn = {
7719
7813
  title: "DSMM",
7720
7814
  summary: "Global config and profile overrides",
7721
- description: "Layers save independently; native models and running sessions stay unchanged.",
7815
+ description: "Layers save independently; running sessions retain their admitted settings.",
7722
7816
  global: "DSMM Global config",
7723
7817
  globalHint: "Shared by this Home. Unset fields use built-in defaults.",
7724
7818
  profile: "Current DSH profile overrides",
@@ -7823,7 +7917,7 @@ var deploymentEn = {
7823
7917
  var deploymentZh = {
7824
7918
  title: "DSMM",
7825
7919
  summary: "全局配置与当前配置覆盖",
7826
- description: "两层独立保存,不改原生模型或运行中会话。",
7920
+ description: "两层独立保存,运行中会话保留已准入设置。",
7827
7921
  global: "DSMM 全局配置",
7828
7922
  globalHint: "同一 Home 共用;未设置字段使用内建默认值。",
7829
7923
  profile: "当前 DSH 配置覆盖",
@@ -7926,6 +8020,7 @@ var deploymentZh = {
7926
8020
  namedIndependent: "设置中的 Deepwork Profiles 是独立的具名 JSONC 运行时资源编辑器。在此保存不会应用具名配置或选择其模型。"
7927
8021
  };
7928
8022
  var deploymentFieldLabels = {
8023
+ rootModelPolicy: ["Root model policy (native: user model; configured: admitted routes, all clients)", "根模型策略(native:用户模型;configured:准入路由,所有客户端)"],
7929
8024
  modelParameters: ["Model parameters", "模型参数"],
7930
8025
  passthrough: ["Model parameter passthrough", "模型参数透传"],
7931
8026
  locale: ["Agent business language", "Agent 业务语言"],
@@ -10948,7 +11043,6 @@ async function apply(ctx) {
10948
11043
  void profileCtx.inject(["connection"], (connectionCtx) => {
10949
11044
  controller.bindConnection(connectionCtx.connection.generation);
10950
11045
  void controller.refresh();
10951
- void controller.refreshSession();
10952
11046
  connectionCtx.effect(() => () => controller.bindConnection(null), "dsmm: profile connection withdrawal");
10953
11047
  });
10954
11048
  profiles = controller;
@@ -10999,19 +11093,40 @@ async function apply(ctx) {
10999
11093
  controller.attachCatalog(null);
11000
11094
  }, "dsmm: native catalog/selector lifetime");
11001
11095
  });
11002
- void profileCtx.inject(["uiSession", "sessions"], (sessionCtx) => {
11096
+ void profileCtx.inject(["uiSession", "sessions", "connection"], (sessionCtx) => {
11003
11097
  const source = sessionCtx.uiSession.adapter.current;
11004
11098
  const nativeSessions = sessionCtx.sessions;
11099
+ const connection = sessionCtx.connection.generation;
11100
+ let attached;
11101
+ sessionCtx.effect(() => {
11102
+ let stopReady;
11103
+ const subscribe = () => {
11104
+ stopReady?.();
11105
+ const generation = connection.getSnapshot();
11106
+ stopReady = generation === void 0 ? void 0 : sessionCtx.remote.$on("api-session/added", (summary) => {
11107
+ const binding = source.getSnapshot();
11108
+ if (connection.getSnapshot() !== generation || binding.key !== summary.sessionId || attached === void 0 || nativeSessions.binding(summary.sessionId) !== attached) return;
11109
+ controller.observeSessionAvailability(summary.sessionId, attached.session, summary.agentAvailable);
11110
+ });
11111
+ };
11112
+ subscribe();
11113
+ const stopConnection = connection.subscribe(subscribe);
11114
+ return () => {
11115
+ stopConnection();
11116
+ stopReady?.();
11117
+ };
11118
+ }, "dsmm: native Agent readiness");
11005
11119
  const update = () => {
11006
11120
  const binding = source.getSnapshot();
11007
11121
  const nativeBinding = binding.key === void 0 ? void 0 : nativeSessions.binding(binding.key);
11008
- controller.attachSessionSource(binding.key ?? null, nativeBinding?.session ?? null);
11122
+ attached = nativeBinding;
11123
+ controller.attachSessionSource(binding.key ?? null, nativeBinding?.session ?? null, nativeBinding ?? null);
11009
11124
  controller.setSession(binding.key ?? null);
11010
11125
  controller.attachModelSelectionSource(binding.key ?? null, binding.key === void 0 ? null : binding.keyedHooks.projection?.("modelSelection") ?? null);
11011
11126
  controller.attachModelEventSource(binding.key ?? null, nativeBinding?.eventSource ?? null);
11012
11127
  };
11013
- update();
11014
11128
  sessionCtx.effect(() => source.subscribe(update), "dsmm: current native session");
11129
+ update();
11015
11130
  sessionCtx.effect(() => () => {
11016
11131
  controller.attachModelSelectionSource(null, null);
11017
11132
  controller.attachModelEventSource(null, null);
package/lib/commands.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { DshContext } from "./dsh-types.js";
1
+ import type { DshCommandInvocation, DshCommandResult, DshCommandsRegistry, DshContext } from "./dsh-types.js";
2
2
  import { DSMM_STATUS_COMMAND } from "./settings.js";
3
3
  import type { DsmmSettingsGetter } from "./settings.js";
4
4
  import type { DeepworkModeController } from "./state.js";
@@ -7,7 +7,11 @@ export interface DeepworkCommandInput {
7
7
  action: "on" | "off";
8
8
  message: string;
9
9
  }
10
+ export type DsmmCommandDefinition = Parameters<DshCommandsRegistry["register"]>[0];
10
11
  export declare function parseDeepworkCommandInput(rawInput: string): DeepworkCommandInput;
11
- export declare function registerDeepworkCommand(readyCtx: DshContext, controller: DeepworkModeController, getSettings: DsmmSettingsGetter): void;
12
- export declare function registerDsmmStatusCommand(readyCtx: DshContext, controller: DeepworkModeController, getSettings: DsmmSettingsGetter): void;
12
+ export declare function handleDsmmStatusCommand(controller: DeepworkModeController, getSettings: DsmmSettingsGetter, invocation: DshCommandInvocation): DshCommandResult;
13
+ export declare function createDeepworkCommandDefinition(controller: DeepworkModeController, getSettings: DsmmSettingsGetter, handler?: DsmmCommandDefinition["handler"]): DsmmCommandDefinition;
14
+ export declare function createDsmmStatusCommandDefinition(controller: DeepworkModeController, getSettings: DsmmSettingsGetter): DsmmCommandDefinition;
15
+ export declare function registerDeepworkCommand(readyCtx: DshContext, controller: DeepworkModeController, getSettings: DsmmSettingsGetter): () => void;
16
+ export declare function registerDsmmStatusCommand(readyCtx: DshContext, controller: DeepworkModeController, getSettings: DsmmSettingsGetter): () => void;
13
17
  //# sourceMappingURL=commands.d.ts.map
package/lib/commands.js CHANGED
@@ -23,7 +23,7 @@ async function handleDeepworkCommand(controller, getSettings, invocation) {
23
23
  ? { kind: "success", text: "Entering deepwork mode." }
24
24
  : { kind: "success", text: "Leaving deepwork mode." };
25
25
  }
26
- function handleDsmmStatusCommand(controller, getSettings, invocation) {
26
+ export function handleDsmmStatusCommand(controller, getSettings, invocation) {
27
27
  const input = invocation.rawInput.trim();
28
28
  if (input !== "" && input !== "json")
29
29
  return { kind: "error", text: "Usage: /dsmm-status [json]" };
@@ -40,22 +40,31 @@ function handleDsmmStatusCommand(controller, getSettings, invocation) {
40
40
  text: input === "json" ? JSON.stringify(snapshot, null, 2) : formatDsmmStatus(snapshot)
41
41
  };
42
42
  }
43
- export function registerDeepworkCommand(readyCtx, controller, getSettings) {
44
- const commands = readyCtx.get?.("commands") ?? readyCtx.commands;
45
- commands?.register({
43
+ export function createDeepworkCommandDefinition(controller, getSettings, handler = invocation => handleDeepworkCommand(controller, getSettings, invocation)) {
44
+ return {
46
45
  name: getSettings().modeName,
47
46
  description: "Enter or leave Deepwork mode",
48
47
  input: { hint: "[off|message]" },
49
- handler: (invocation) => handleDeepworkCommand(controller, getSettings, invocation)
50
- });
48
+ handler
49
+ };
51
50
  }
52
- export function registerDsmmStatusCommand(readyCtx, controller, getSettings) {
53
- const commands = readyCtx.get?.("commands") ?? readyCtx.commands;
54
- commands?.register({
51
+ export function createDsmmStatusCommandDefinition(controller, getSettings) {
52
+ return {
55
53
  name: DSMM_STATUS_COMMAND,
56
54
  description: "Show Deepwork status",
57
55
  input: { hint: "[json]" },
58
- handler: (invocation) => handleDsmmStatusCommand(controller, getSettings, invocation)
59
- });
56
+ handler: invocation => handleDsmmStatusCommand(controller, getSettings, invocation)
57
+ };
58
+ }
59
+ function commandDisposer(value) {
60
+ return typeof value === "function" ? value : () => { };
61
+ }
62
+ export function registerDeepworkCommand(readyCtx, controller, getSettings) {
63
+ const commands = readyCtx.get?.("commands") ?? readyCtx.commands;
64
+ return commands === undefined ? () => { } : commandDisposer(commands.register(createDeepworkCommandDefinition(controller, getSettings)));
65
+ }
66
+ export function registerDsmmStatusCommand(readyCtx, controller, getSettings) {
67
+ const commands = readyCtx.get?.("commands") ?? readyCtx.commands;
68
+ return commands === undefined ? () => { } : commandDisposer(commands.register(createDsmmStatusCommandDefinition(controller, getSettings)));
60
69
  }
61
70
  //# sourceMappingURL=commands.js.map
package/lib/host-llm.js CHANGED
@@ -283,7 +283,12 @@ export class DsmmAwareLlmRuntime extends LlmRuntime {
283
283
  runtime.assertCaptured(captured);
284
284
  const providerSignal = AbortSignal.any([captured.frame.signal, captured.admission.signal,
285
285
  ...captured.generation === undefined ? [] : [captured.generation.signal], captured.revocation.signal, runtime.lifetime.signal]);
286
- yield* dispatchPrepared(request, providerSignal);
286
+ for await (const chunk of dispatchPrepared(request, providerSignal)) {
287
+ runtime.assertCaptured(captured);
288
+ yield chunk;
289
+ runtime.assertCaptured(captured);
290
+ }
291
+ runtime.assertCaptured(captured);
287
292
  }
288
293
  finally {
289
294
  runtime.finishCaptured(captured);
package/lib/index.d.ts CHANGED
@@ -23,7 +23,7 @@ export { DSMM_STATUS_VERSION, createDsmmStatusSnapshot, formatDsmmStatus } from
23
23
  export type { DsmmStatusSnapshot } from "./status.js";
24
24
  export type * from "./dsh-types.js";
25
25
  export { DSMM_SKILL_NAMES, DSMM_SETTINGS_SCHEMA, DEFAULT_DSMM_SETTINGS, MVP_SKILL_NAMES, deploymentEditorSchema, isRoleEnabled, resolveConfig, resolveDeployment, resolveRoleRouting, registerSettings, validateNativeConfig } from "./settings.js";
26
- export type { DsmmFinalReviewPolicy, DsmmGitWritePolicy, DsmmGitWriteScope, DsmmGuardScope, DsmmGuardSettings, DsmmPluginConfig, DsmmNativeConfig, DsmmModelRoute, DsmmRoleRoutingConfig, DsmmRoleRouting, DsmmRecoveryRoute, DsmmRuntimeRecoverySettings, DsmmSettings, DsmmSettingsGetter, DsmmSkillName, DsmmWorkflowSettings, MvpSkillName, DsmmSubagentSettings, DsmmDeploymentSnapshot } from "./settings.js";
26
+ export type { DsmmFinalReviewPolicy, DsmmGitWritePolicy, DsmmGitWriteScope, DsmmGuardScope, DsmmGuardSettings, DsmmPluginConfig, DsmmNativeConfig, DsmmModelRoute, DsmmRootModelPolicy, DsmmRoleRoutingConfig, DsmmRoleRouting, DsmmRecoveryRoute, DsmmRuntimeRecoverySettings, DsmmSettings, DsmmSettingsGetter, DsmmSkillName, DsmmWorkflowSettings, MvpSkillName, DsmmSubagentSettings, DsmmDeploymentSnapshot } from "./settings.js";
27
27
  export { createProfileRuntime, DsmmProfileRuntime } from "./profile-runtime.js";
28
28
  export type { DsmmProfileRuntimeStore, DsmmProfileRuntimeOptions } from "./profile-runtime.js";
29
29
  export { resolveDshHome } from "./dsh-home.js";
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Context, symbols } from "@deepseek-ai/cordis";
2
- import { registerDeepworkCommand, registerDsmmStatusCommand } from "./commands.js";
2
+ import { registerDsmmTuiAdapter } from "./tui-adapter.js";
3
3
  import { registerSafetyGuards } from "./guards.js";
4
4
  import { registerDeepworkPrompt } from "./mode.js";
5
5
  import { registerAgentSkills } from "./preset-skills.js";
@@ -155,11 +155,7 @@ export async function apply(input, config = {}, startupOptions = {}) {
155
155
  }
156
156
  installed.add(agent);
157
157
  });
158
- ctx.inject(["commands"], scope => {
159
- registerDsmmStatusCommand(scope, controller, getSettings);
160
- if (startup.settings.modules.deepwork.enabled)
161
- registerDeepworkCommand(scope, controller, getSettings);
162
- });
158
+ registerDsmmTuiAdapter(ctx, { controller, getSettings, profiles, deployment });
163
159
  ctx.inject(["typert"], scope => { registerConfigRpc(scope, deployment, startup.settings, () => profiles, startup.sources, mountedPermission); new DsmmProfilesHost(scope, profiles); registerRoleControlRpc(scope, nativeAdmission); });
164
160
  const permissions = createCorePermissionAuthority(ctx, { getSettings, rolePolicy: policy, signal: lifetime.signal });
165
161
  const installPermissions = () => ctx.inject(["tools", ...(ctx.fiber.entry === undefined ? [] : ["settings"])], scope => {