@dsmm/dsmm 0.3.12 → 0.3.14

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 (48) hide show
  1. package/README.md +2 -2
  2. package/docs/agent-presets.md +1 -1
  3. package/docs/compatibility.md +8 -2
  4. package/docs/deferred-native-approval-risk.md +4 -4
  5. package/docs/design.md +1 -1
  6. package/docs/lsp.md +1 -1
  7. package/docs/maintenance.md +9 -3
  8. package/docs/model-routing.md +1 -1
  9. package/docs/native-permissions.md +12 -2
  10. package/docs/profiles.md +32 -13
  11. package/docs/roadmap.md +67 -30
  12. package/docs/runtime-recovery.md +1 -1
  13. package/docs/safety-guards.md +1 -1
  14. package/docs/settings-status.md +1 -1
  15. package/docs/testing.md +85 -0
  16. package/lib/client/DeploymentPage.js +31 -2
  17. package/lib/client/PermissionsPanel.js +1 -1
  18. package/lib/client/ProfileModelsDialog.d.ts +24 -0
  19. package/lib/client/ProfileModelsDialog.js +353 -0
  20. package/lib/client/ProfilesSection.js +209 -37
  21. package/lib/client/RoleToolView-data.d.ts +7 -0
  22. package/lib/client/RoleToolView-data.js +45 -0
  23. package/lib/client/RoleToolView-locales.d.ts +5 -0
  24. package/lib/client/RoleToolView-locales.js +2 -0
  25. package/lib/client/RoleToolView.js +33 -8
  26. package/lib/client/SessionProfiles.js +24 -6
  27. package/lib/client/StructuredEditor.d.ts +32 -4
  28. package/lib/client/StructuredEditor.js +12 -40
  29. package/lib/client/children-locales.d.ts +1 -1
  30. package/lib/client/controller.d.ts +23 -1
  31. package/lib/client/controller.js +289 -8
  32. package/lib/client/diagnostics.d.ts +1 -0
  33. package/lib/client/diagnostics.js +9 -0
  34. package/lib/client/index.js +10 -2
  35. package/lib/client/locales.d.ts +29 -0
  36. package/lib/client/locales.js +54 -2
  37. package/lib/client/profile-blank.d.ts +43 -0
  38. package/lib/client/profile-blank.js +19 -0
  39. package/lib/client/styles.d.ts +1 -1
  40. package/lib/client/styles.js +96 -32
  41. package/lib/client.js +2411 -1040
  42. package/lib/command-approval.d.ts +2 -0
  43. package/lib/command-approval.js +4 -1
  44. package/lib/index.js +2 -1
  45. package/lib/native-admission.d.ts +10 -3
  46. package/lib/native-admission.js +129 -28
  47. package/lib/profile-runtime.js +3 -5
  48. package/package.json +7 -2
@@ -28,12 +28,15 @@ export function canReconcileSelection(snapshot) {
28
28
  export class ProfilesController {
29
29
  remote;
30
30
  current = { snapshot: null, editor: null, dirty: false, busy: null, issue: null, notice: null, pendingEditor: null,
31
- catalog: null, catalogBusy: false, catalogUnavailable: true, currentSessionId: null, sessionViewEpoch: 0, sessionUnconfirmed: false, session: null, sessionChoice: null, sessionBusy: null, sessionIssue: null, sessionNotice: null, invalidFields: [], editorEpoch: 0, validationEpoch: 0 };
31
+ catalog: null, catalogBusy: false, catalogUnavailable: true, currentSessionId: null, sessionViewEpoch: 0, sessionUnconfirmed: false, session: null, sessionChoice: null, sessionWorkspaces: [], sessionWorkspaceId: null, sessionPreparationAvailable: false, sessionPreparationPending: false, sessionBusy: null, sessionIssue: null, sessionNotice: null, invalidFields: [], editorEpoch: 0, validationEpoch: 0 };
32
32
  accepted = null;
33
33
  listeners = new Set();
34
34
  generation = 0;
35
35
  disposed = false;
36
36
  sessionGeneration = 0;
37
+ blankNative = null;
38
+ stopWorkspaces = null;
39
+ preparation = null;
37
40
  pendingSessionSelections = new Set();
38
41
  connection = null;
39
42
  connectionBaseline;
@@ -56,6 +59,9 @@ export class ProfilesController {
56
59
  modelEventsWatermark = -1;
57
60
  modeEventsWatermark = -1;
58
61
  modeRefreshPending = false;
62
+ sessionSource = null;
63
+ sessionSourceId = null;
64
+ stopSessionSource = null;
59
65
  stopModelEvents = null;
60
66
  modelInteraction = null;
61
67
  modelInteractionSessionId = null;
@@ -80,6 +86,7 @@ export class ProfilesController {
80
86
  refreshCatalog: () => this.refreshCatalog(), refreshSession: () => this.refreshSession(),
81
87
  chooseSessionProfile: (id) => { if (!this.disposed && this.connectionCurrent() && !this.current.sessionUnconfirmed && this.current.sessionBusy === null && this.current.busy === null && !this.current.dirty && this.current.pendingEditor === null && this.current.invalidFields.length === 0)
82
88
  this.publish({ sessionChoice: id, sessionNotice: null }); },
89
+ chooseSessionWorkspace: id => this.chooseSessionWorkspace(id),
83
90
  applySession: (options) => this.selectSession(false, options), resetSession: () => this.selectSession(true),
84
91
  setDeepwork: (active) => this.setDeepwork(active), useSessionProfileModel: () => this.selectSession(false, { useProfileModel: true }, true),
85
92
  setFieldInvalid: (field, invalid) => {
@@ -107,7 +114,7 @@ export class ProfilesController {
107
114
  constructor(remote) {
108
115
  this.remote = remote;
109
116
  }
110
- dispose() { this.releaseComposerBlock(); this.numberDrafts.clear(); this.stopConnection?.(); this.disposed = true; this.generation += 1; this.sessionGeneration += 1; this.catalogGeneration += 1; this.modelSelectorGeneration += 1; this.modelSelectionGeneration += 1; this.stopModelSelection?.(); this.stopModelEvents?.(); this.stopModelInteraction?.(); this.stopModelSelection = null; this.stopModelEvents = null; this.stopModelInteraction = null; this.modelSelectionSource = null; this.modelEvents = null; this.modelInteraction = null; this.catalogRemote = null; this.modelSelector = null; this.listeners.clear(); }
117
+ dispose() { this.releasePreparation(); this.stopWorkspaces?.(); this.releaseComposerBlock(); this.numberDrafts.clear(); this.stopConnection?.(); this.stopSessionSource?.(); this.sessionSource = null; this.disposed = true; this.generation += 1; this.sessionGeneration += 1; this.catalogGeneration += 1; this.modelSelectorGeneration += 1; this.modelSelectionGeneration += 1; this.stopModelSelection?.(); this.stopModelEvents?.(); this.stopModelInteraction?.(); this.stopModelSelection = null; this.stopModelEvents = null; this.stopModelInteraction = null; this.modelSelectionSource = null; this.modelEvents = null; this.modelInteraction = null; this.catalogRemote = null; this.modelSelector = null; this.listeners.clear(); }
111
118
  bindConnection(source) {
112
119
  if (this.disposed)
113
120
  return;
@@ -117,15 +124,17 @@ export class ProfilesController {
117
124
  this.connectionBound = true;
118
125
  this.connectionBaseline = source?.getSnapshot();
119
126
  const invalidate = () => {
127
+ this.releasePreparation();
120
128
  this.connectionBaseline = source?.getSnapshot();
121
129
  this.generation += 1;
122
130
  this.sessionGeneration += 1;
131
+ this.modeRefreshPending = false;
123
132
  this.modelSelectorGeneration += 1;
124
133
  // A replaced connection only discards what it observed. It never records a
125
134
  // durable refusal for the session: an unread configuration is read again
126
135
  // by the next refresh, and typing stays available in the meantime.
127
136
  this.publish({ session: null, sessionBusy: null, sessionNotice: null, sessionUnconfirmed: false,
128
- sessionViewEpoch: this.current.sessionViewEpoch + 1, busy: null, issue: { kind: "transport", code: "unavailable" } });
137
+ sessionViewEpoch: this.current.sessionViewEpoch + 1, sessionWorkspaceId: null, sessionPreparationPending: false, busy: null, issue: { kind: "transport", code: "unavailable" } });
129
138
  };
130
139
  if (replacement || source === null || this.connectionBaseline === undefined)
131
140
  invalidate();
@@ -140,13 +149,229 @@ export class ProfilesController {
140
149
  connectionCurrent() {
141
150
  return !this.connectionBound || this.connectionBaseline !== undefined && this.connection?.getSnapshot() === this.connectionBaseline;
142
151
  }
152
+ attachBlankNative(native) {
153
+ if (this.disposed)
154
+ return;
155
+ this.cancelPreparation();
156
+ this.stopWorkspaces?.();
157
+ this.blankNative = native;
158
+ const update = () => {
159
+ const sessionWorkspaces = native?.workspaces.getSnapshot() ?? [];
160
+ const sessionWorkspaceId = sessionWorkspaces.some(item => item.id === this.current.sessionWorkspaceId) ? this.current.sessionWorkspaceId : null;
161
+ if (this.preparation !== null && sessionWorkspaceId !== this.preparation.workspaceId)
162
+ this.cancelPreparation();
163
+ this.publish({ sessionWorkspaces, sessionWorkspaceId, sessionPreparationAvailable: native !== null && this.composerBlocks !== null });
164
+ };
165
+ this.stopWorkspaces = native?.workspaces.subscribe(update) ?? null;
166
+ update();
167
+ }
168
+ releasePreparation() {
169
+ const task = this.preparation;
170
+ this.preparation = null;
171
+ if (task === null)
172
+ return;
173
+ task.stop();
174
+ const held = task.held;
175
+ if (held !== null && task.id !== null && held.blocks.storeFor(task.id) === held.store && held.store.getSnapshot() === held.block)
176
+ held.blocks.set(task.id, undefined);
177
+ task.reference?.release();
178
+ }
179
+ cancelPreparation() {
180
+ if (this.preparation === null)
181
+ return;
182
+ this.releasePreparation();
183
+ this.sessionGeneration += 1;
184
+ this.publish({ sessionBusy: null, sessionUnconfirmed: false, sessionPreparationPending: false, sessionNotice: null });
185
+ }
186
+ async chooseSessionWorkspace(id) {
187
+ if (this.disposed || !this.connectionCurrent() || this.current.currentSessionId !== null || !this.current.sessionWorkspaces.some(item => item.id === id)
188
+ || this.current.dirty || this.current.invalidFields.length > 0 || this.current.pendingEditor !== null || this.current.busy !== null)
189
+ return;
190
+ const pending = this.current.sessionPreparationPending;
191
+ if (id !== this.current.sessionWorkspaceId)
192
+ this.cancelPreparation();
193
+ this.publish({ sessionWorkspaceId: id, sessionIssue: null });
194
+ if (pending)
195
+ await this.prepareSession();
196
+ }
197
+ preparationOwned(task) {
198
+ return !this.disposed && this.connectionCurrent() && this.preparation === task
199
+ && this.current.currentSessionId === null && this.current.sessionWorkspaceId === task.workspaceId;
200
+ }
201
+ preparationCurrent(task) {
202
+ return this.preparationOwned(task) && !task.navigation.aborted;
203
+ }
204
+ preparationConfirmed(task, session) {
205
+ const selection = session.admittedSelection;
206
+ return selection !== undefined && !selection.refreshRequired && session.sessionId === task.id && !session.refreshRequired && !session.selection.refreshRequired
207
+ && writableSelectionVersion(session.selection.selectionRevision) && selection.selectedId === task.selectedId && selection.appliedRevision === task.revision
208
+ && session.selection.selectedId === task.selectedId && session.selection.appliedRevision === task.revision;
209
+ }
210
+ openPrepared(task, explicit = false) {
211
+ if (!this.preparationOwned(task) || !explicit && task.navigation.aborted || task.id === null || this.current.busy !== null || this.current.dirty || this.current.invalidFields.length > 0 || this.current.pendingEditor !== null)
212
+ return;
213
+ task.opening = true;
214
+ try {
215
+ this.publish({ sessionUnconfirmed: true });
216
+ if (this.preparationOwned(task))
217
+ task.native.openSession(task.id);
218
+ }
219
+ finally {
220
+ task.opening = false;
221
+ }
222
+ }
223
+ async prepareSession(refreshOnly = false) {
224
+ const { sessionWorkspaceId: workspaceId, sessionChoice: selectedId, snapshot } = this.current;
225
+ const native = this.blankNative;
226
+ if (this.disposed || !this.connectionCurrent() || native === null || this.composerBlocks === null || this.composerReason === null
227
+ || this.current.currentSessionId !== null || this.current.sessionBusy !== null || this.current.busy !== null
228
+ || this.current.dirty || this.current.invalidFields.length > 0 || this.current.pendingEditor !== null || snapshot === null)
229
+ return;
230
+ if (workspaceId === null) {
231
+ if (!refreshOnly)
232
+ this.publish({ sessionPreparationPending: true });
233
+ return;
234
+ }
235
+ if (this.current.sessionUnconfirmed && !refreshOnly)
236
+ return;
237
+ const profile = snapshot.profiles.find(item => item.id === selectedId), revision = selectedId === null ? null : profile?.revision;
238
+ if (!refreshOnly && selectedId !== null && (!isConfigRevision(revision) || profile?.error !== undefined))
239
+ return;
240
+ let task = this.preparation;
241
+ const openOnly = !refreshOnly && task?.confirmed === true && task.selectedId === selectedId && task.revision === (revision ?? null);
242
+ if (task === null) {
243
+ if (refreshOnly)
244
+ return;
245
+ const navigation = native.beginNavigation();
246
+ task = { native, navigation, workspaceId, selectedId, revision: revision ?? null, id: null, reference: null, held: null, confirmed: false, opening: false, stop: () => { } };
247
+ this.preparation = task;
248
+ }
249
+ else if (!refreshOnly && !openOnly) {
250
+ task.selectedId = selectedId;
251
+ task.revision = revision ?? null;
252
+ task.confirmed = false;
253
+ }
254
+ if (!refreshOnly && !openOnly) {
255
+ task.stop();
256
+ if (task.navigation.aborted)
257
+ task.navigation = native.beginNavigation();
258
+ const navigation = task.navigation;
259
+ const owned = task;
260
+ const abort = () => { if (this.preparation === owned && !owned.opening)
261
+ this.cancelPreparation(); };
262
+ navigation.addEventListener("abort", abort, { once: true });
263
+ task.stop = () => navigation.removeEventListener("abort", abort);
264
+ }
265
+ const owned = task;
266
+ const live = () => refreshOnly ? this.preparationOwned(owned) : this.preparationCurrent(owned);
267
+ this.publish({ sessionBusy: refreshOnly ? "read" : "apply", sessionPreparationPending: false, sessionIssue: null, sessionNotice: null });
268
+ try {
269
+ if (openOnly) {
270
+ this.openPrepared(task, true);
271
+ return;
272
+ }
273
+ if (!live())
274
+ return;
275
+ if (task.id === null) {
276
+ if (refreshOnly)
277
+ throw { kind: "transport", code: "unavailable" };
278
+ const id = await native.connectWorkspace(workspaceId);
279
+ if (!live())
280
+ return;
281
+ task.id = id;
282
+ }
283
+ const id = task.id;
284
+ if (task.reference === null) {
285
+ task.reference = native.retain(id);
286
+ if (!live()) {
287
+ task.reference.release();
288
+ return;
289
+ }
290
+ if (task.reference.sessionId !== id)
291
+ throw { kind: "assembly", code: "unavailable" };
292
+ }
293
+ if (task.held === null) {
294
+ // Occupy the empty native seat synchronously, before awaiting readiness.
295
+ const blocks = this.composerBlocks, store = blocks.storeFor(id);
296
+ if (store.getSnapshot() !== undefined)
297
+ throw { kind: "domain", code: "busy" };
298
+ const block = { reason: this.composerReason() };
299
+ task.held = { blocks, store, block };
300
+ blocks.set(id, block);
301
+ }
302
+ const binding = await task.reference.ready;
303
+ if (!live())
304
+ return;
305
+ if (binding.sessionId !== id)
306
+ throw { kind: "assembly", code: "unavailable" };
307
+ const session = await this.unwrap(this.remote.describeSession(id));
308
+ if (!live())
309
+ return;
310
+ if (session.sessionId !== id)
311
+ throw { kind: "assembly", code: "unavailable" };
312
+ if (refreshOnly) {
313
+ task.confirmed = this.preparationConfirmed(task, session);
314
+ if (task.confirmed) {
315
+ this.publish({ sessionUnconfirmed: false });
316
+ this.openPrepared(task);
317
+ return;
318
+ }
319
+ const uncertain = session.refreshRequired === true || session.selection.refreshRequired === true;
320
+ this.publish({ sessionUnconfirmed: uncertain, sessionIssue: { kind: "domain", code: uncertain ? "unavailable" : "conflict" } });
321
+ return;
322
+ }
323
+ if (session.refreshRequired || session.selection.refreshRequired || !writableSelectionVersion(session.selection.selectionRevision))
324
+ throw { kind: "domain", code: "conflict" };
325
+ if (session.canApplyOverlay !== true || session.applyOverlayUnavailableReason === "new-session-required")
326
+ throw { kind: "domain", code: session.applyOverlayUnavailableReason ?? "unavailable" };
327
+ const held = task.held;
328
+ if (held === null || held.blocks.storeFor(id) !== held.store || held.store.getSnapshot() !== held.block)
329
+ throw { kind: "domain", code: "busy" };
330
+ if (this.current.dirty || this.current.invalidFields.length > 0 || this.current.pendingEditor !== null)
331
+ throw { kind: "domain", code: "conflict" };
332
+ this.pendingSessionSelections.add(id);
333
+ const accepted = await this.unwrap(this.remote.selectSession(id, { sessionId: id, id: task.selectedId,
334
+ ...(task.selectedId === null ? {} : { expectedRevision: task.revision }), expectedSelectionRevision: session.selection.selectionRevision, expectedAdmissionEpoch: session.admissionEpoch }));
335
+ if (!live())
336
+ return;
337
+ if (!this.preparationConfirmed(task, accepted)) {
338
+ this.publish({ sessionUnconfirmed: true });
339
+ return;
340
+ }
341
+ task.confirmed = true;
342
+ this.openPrepared(task);
343
+ }
344
+ catch (error) {
345
+ if (this.preparationOwned(task)) {
346
+ const issue = this.issue(error), uncertain = task.confirmed || issue.kind !== "domain" || issue.code === "cancelled";
347
+ this.publish({ sessionIssue: task.id === null && uncertain ? { kind: "assembly", code: "blank-identity-unconfirmed" } : issue, sessionUnconfirmed: uncertain });
348
+ // A definite pre-commit refusal needs no task-owned send block or retain.
349
+ if (!uncertain)
350
+ this.releasePreparation();
351
+ }
352
+ }
353
+ finally {
354
+ if (task.id !== null)
355
+ this.pendingSessionSelections.delete(task.id);
356
+ if (this.preparationOwned(task))
357
+ this.publish({ sessionBusy: null });
358
+ else if (!this.disposed && this.current.currentSessionId === null && this.preparation === null)
359
+ this.publish({ sessionBusy: null });
360
+ else if (!this.disposed && this.connectionCurrent() && task.id === this.current.currentSessionId) {
361
+ this.modeRefreshPending = true;
362
+ this.refreshObservedMode();
363
+ }
364
+ }
365
+ }
143
366
  attachComposerBlocks(blocks, reason) {
144
367
  if (this.disposed)
145
368
  return;
369
+ if (blocks !== this.composerBlocks && this.preparation !== null)
370
+ this.cancelPreparation();
146
371
  this.releaseComposerBlock();
147
372
  this.composerBlocks = blocks;
148
373
  this.composerReason = reason ?? null;
149
- this.syncComposerBlock();
374
+ this.publish({ sessionPreparationAvailable: this.blankNative !== null && blocks !== null });
150
375
  }
151
376
  releaseComposerBlock() {
152
377
  const held = this.composerBlock;
@@ -185,6 +410,33 @@ export class ProfilesController {
185
410
  this.modelSelectionSource = source;
186
411
  this.stopModelSelection = source?.subscribe(() => { this.modelSelectionGeneration += 1; }) ?? null;
187
412
  }
413
+ attachSessionSource(sessionId, source) {
414
+ if (this.disposed || sessionId === this.sessionSourceId && source === this.sessionSource)
415
+ return;
416
+ this.stopSessionSource?.();
417
+ this.sessionSourceId = sessionId;
418
+ this.sessionSource = source;
419
+ let running = source?.getSnapshot().running;
420
+ const current = () => !this.disposed && sessionId !== null && sessionId === this.current.currentSessionId && source === this.sessionSource;
421
+ this.stopSessionSource = source?.subscribe(() => {
422
+ if (!current())
423
+ return;
424
+ const next = source.getSnapshot().running;
425
+ if (next === running)
426
+ return;
427
+ running = next;
428
+ // Running is an invalidation signal, never permission to apply an overlay.
429
+ this.modeRefreshPending = true;
430
+ this.refreshObservedMode();
431
+ }) ?? null;
432
+ if (current()) {
433
+ this.sessionGeneration += 1;
434
+ this.modeRefreshPending = source !== null;
435
+ this.publish({ session: null, sessionBusy: null, sessionNotice: null, sessionViewEpoch: this.current.sessionViewEpoch + 1,
436
+ sessionUnconfirmed: this.pendingSessionSelections.has(sessionId) });
437
+ this.refreshObservedMode();
438
+ }
439
+ }
188
440
  attachModelEventSource(sessionId, source) {
189
441
  if (this.disposed || (sessionId === this.modelEventsSessionId && source === this.modelEvents))
190
442
  return;
@@ -241,15 +493,26 @@ export class ProfilesController {
241
493
  setSession(id) {
242
494
  if (this.disposed || id === this.current.currentSessionId)
243
495
  return;
496
+ const task = this.preparation;
497
+ const preparationUnconfirmed = task?.id === id && this.current.sessionUnconfirmed;
498
+ if (task?.id === id && task.held !== null && id !== null) {
499
+ // The native current binding has retained this exact target. Transfer our
500
+ // block to the ordinary current-session lifecycle without an empty seat.
501
+ this.composerBlock = { id: id, store: task.held.store, block: task.held.block };
502
+ task.held = null;
503
+ }
504
+ this.releasePreparation();
244
505
  this.sessionGeneration += 1;
245
506
  this.modeRefreshPending = false;
507
+ if (id !== this.sessionSourceId)
508
+ this.attachSessionSource(null, null);
246
509
  if (id !== this.modelSelectionSessionId)
247
510
  this.attachModelSelectionSource(null, null);
248
511
  if (id !== this.modelEventsSessionId)
249
512
  this.attachModelEventSource(null, null);
250
513
  if (id !== this.modelInteractionSessionId)
251
514
  this.attachModelInteractionSource(null, null);
252
- this.publish({ currentSessionId: id, sessionViewEpoch: this.current.sessionViewEpoch + 1, sessionUnconfirmed: id !== null && this.pendingSessionSelections.has(id), session: null, sessionChoice: null, sessionBusy: null, sessionIssue: null, sessionNotice: null });
515
+ this.publish({ currentSessionId: id, sessionViewEpoch: this.current.sessionViewEpoch + 1, sessionPreparationPending: false, sessionUnconfirmed: id !== null && (preparationUnconfirmed || this.pendingSessionSelections.has(id)), session: null, sessionChoice: null, sessionBusy: null, sessionIssue: null, sessionNotice: null });
253
516
  if (id !== null)
254
517
  void this.refreshSession();
255
518
  }
@@ -278,7 +541,11 @@ export class ProfilesController {
278
541
  }
279
542
  async refreshSession(preserveFeedback = false) {
280
543
  const id = this.current.currentSessionId;
281
- if (this.disposed || !this.connectionCurrent() || id === null || this.current.sessionBusy !== null)
544
+ if (id === null && this.preparation !== null) {
545
+ await this.prepareSession(true);
546
+ return;
547
+ }
548
+ if (this.disposed || !this.connectionCurrent() || id === null || this.current.sessionBusy !== null || this.sessionSourceId === id && this.sessionSource === null)
282
549
  return;
283
550
  this.modeRefreshPending = false;
284
551
  const generation = ++this.sessionGeneration;
@@ -321,18 +588,30 @@ export class ProfilesController {
321
588
  this.publish({ session: accepted, sessionNotice: active ? "mode-on" : "mode-off" });
322
589
  }
323
590
  catch (error) {
324
- if (live())
325
- this.publish({ sessionIssue: this.issue(error) });
591
+ if (live()) {
592
+ const issue = this.issue(error);
593
+ if (["busy", "maintenance", "conflict"].includes(issue.code))
594
+ this.modeRefreshPending = true;
595
+ this.publish({ sessionIssue: issue });
596
+ }
326
597
  }
327
598
  finally {
328
599
  if (live()) {
329
600
  this.publish({ sessionBusy: null });
330
601
  this.refreshObservedMode();
331
602
  }
603
+ else if (!this.disposed && this.connectionCurrent() && id === this.current.currentSessionId) {
604
+ this.modeRefreshPending = true;
605
+ this.refreshObservedMode();
606
+ }
332
607
  }
333
608
  }
334
609
  async selectSession(reset, options, modelOnly = false) {
335
610
  const { currentSessionId: id, session, sessionChoice, snapshot } = this.current;
611
+ if (id === null && !reset && !modelOnly && options?.useProfileModel !== true) {
612
+ await this.prepareSession();
613
+ return;
614
+ }
336
615
  if (this.disposed || !this.connectionCurrent() || this.current.sessionUnconfirmed || id === null || session === null || session.refreshRequired || session.selection.refreshRequired || !writableSelectionVersion(session.selection.selectionRevision)
337
616
  || (modelOnly ? session.canSelectModel !== true : session.canApplyOverlay !== true || session.applyOverlayUnavailableReason === "new-session-required") || this.current.sessionBusy !== null
338
617
  || this.current.busy !== null || this.current.dirty || this.current.invalidFields.length > 0 || this.current.pendingEditor !== null)
@@ -426,6 +705,8 @@ export class ProfilesController {
426
705
  catch (error) {
427
706
  if (live()) {
428
707
  const issue = this.issue(error);
708
+ if (["busy", "maintenance", "conflict"].includes(issue.code))
709
+ this.modeRefreshPending = true;
429
710
  this.publish({ sessionIssue: issue, sessionUnconfirmed: !modelOnly && (issue.kind !== "domain" || issue.code === "cancelled") });
430
711
  }
431
712
  }
@@ -5,6 +5,7 @@ import type { ProfilesIssue } from "./controller.js";
5
5
  export declare function safeIssue(info: unknown): ProfilesIssue;
6
6
  export declare function profileWarnings(warnings: ProfileDiagnostic[] | undefined): ProfileDiagnostic[];
7
7
  export declare function draftWarnings(content: string): ProfileDiagnostic[];
8
+ export declare function issueKey(issue: ProfilesIssue): "unavailable" | "transport" | "conflict" | "validation" | "io" | "selectionConflict" | "appliedInvalid";
8
9
  export declare function ProfileWarnings({ warnings, t }: PropsLocale<"settings.dsmm-profiles"> & {
9
10
  warnings?: ProfileDiagnostic[];
10
11
  }): import("react").JSX.Element;
@@ -37,6 +37,15 @@ export function draftWarnings(content) {
37
37
  return [];
38
38
  return [diagnostic("blank-label", "label", fieldLocation(content, tree, "label"))];
39
39
  }
40
+ export function issueKey(issue) {
41
+ if (issue.source === "selection")
42
+ return issue.code === "conflict" ? "selectionConflict" : "appliedInvalid";
43
+ if (issue.kind === "assembly")
44
+ return "unavailable";
45
+ if (issue.kind === "transport")
46
+ return "transport";
47
+ return issue.code === "conflict" || issue.code === "validation" ? issue.code : "io";
48
+ }
40
49
  export function ProfileWarnings({ warnings, t }) {
41
50
  return _jsx(_Fragment, { children: profileWarnings(warnings).map(warning => _jsxs("div", { className: "dsmm-warning", "data-dsmm-warning": true, children: [_jsx("p", { children: t("warningMarker", { code: warning.code, field: warning.field }) }), _jsxs("details", { children: [_jsx("summary", { children: t("details") }), _jsx("p", { children: t("blankLabelWarning") })] })] }, `${warning.code}:${warning.field}`)) });
42
51
  }
@@ -15,6 +15,7 @@ import { bindPermissionSession } from "./permission-session.js";
15
15
  import { PermissionController } from "./permission-controller.js";
16
16
  import { PERMISSIONS_NS, permissionEn, permissionZh } from "./permission-locales.js";
17
17
  import { registerRoleToolViews } from "./RoleToolView.js";
18
+ import { profileBlankNative } from "./profile-blank.js";
18
19
  export { ProfilesController, NEW_PROFILE_CONTENT } from "./controller.js";
19
20
  export { ProfilesSection } from "./ProfilesSection.js";
20
21
  export { NS, en, zh } from "./locales.js";
@@ -81,6 +82,7 @@ export async function apply(ctx) {
81
82
  void profileCtx.inject(["connection"], connectionCtx => {
82
83
  controller.bindConnection(connectionCtx.connection.generation);
83
84
  void controller.refresh();
85
+ void controller.refreshSession();
84
86
  connectionCtx.effect(() => () => controller.bindConnection(null), "dsmm: profile connection withdrawal");
85
87
  });
86
88
  profiles = controller;
@@ -100,6 +102,10 @@ export async function apply(ctx) {
100
102
  controller.attachComposerBlocks(conversationCtx.conversation.blocks, () => t("sessionSelectionBlock"));
101
103
  conversationCtx.effect(() => () => controller.attachComposerBlocks(null), "dsmm: profile composer block lifetime");
102
104
  });
105
+ void profileCtx.inject(["uiWorkspace", "workspaces", "layout", "sessions", "uiSession"], blankCtx => {
106
+ controller.attachBlankNative(profileBlankNative(blankCtx));
107
+ blankCtx.effect(() => () => controller.attachBlankNative(null), "dsmm: native blank preparation lifetime");
108
+ });
103
109
  profileCtx.slots.inject("settings.section", () => profileCtx.slots.register({
104
110
  name: "settings.section", id: "dsmm-profiles", order: 30,
105
111
  label: () => t("title"), locale: NS,
@@ -125,13 +131,15 @@ export async function apply(ctx) {
125
131
  const nativeSessions = sessionCtx.sessions;
126
132
  const update = () => {
127
133
  const binding = source.getSnapshot();
134
+ const nativeBinding = binding.key === undefined ? undefined : nativeSessions.binding(binding.key);
135
+ controller.attachSessionSource(binding.key ?? null, nativeBinding?.session ?? null);
128
136
  controller.setSession(binding.key ?? null);
129
137
  controller.attachModelSelectionSource(binding.key ?? null, binding.key === undefined ? null : binding.keyedHooks.projection?.("modelSelection") ?? null);
130
- controller.attachModelEventSource(binding.key ?? null, binding.key === undefined ? null : nativeSessions.binding(binding.key)?.eventSource ?? null);
138
+ controller.attachModelEventSource(binding.key ?? null, nativeBinding?.eventSource ?? null);
131
139
  };
132
140
  update();
133
141
  sessionCtx.effect(() => source.subscribe(update), "dsmm: current native session");
134
- sessionCtx.effect(() => () => { controller.attachModelSelectionSource(null, null); controller.attachModelEventSource(null, null); controller.attachModelInteractionSource(null, null); controller.setSession(null); }, "dsmm: native session withdrawal");
142
+ sessionCtx.effect(() => () => { controller.attachModelSelectionSource(null, null); controller.attachModelEventSource(null, null); controller.attachModelInteractionSource(null, null); controller.setSession(null); controller.attachSessionSource(null, null); }, "dsmm: native session withdrawal");
135
143
  void sessionCtx.inject(["modelDirectories", "remote.session"], (modelCtx) => {
136
144
  const updateInteraction = () => {
137
145
  const id = source.getSnapshot().key;
@@ -1,6 +1,14 @@
1
1
  export declare const NS = "settings.dsmm-profiles";
2
2
  export declare const en: {
3
3
  sessionChooseWorkspace: string;
4
+ sessionWorkspace: string;
5
+ sessionWorkspacePlaceholder: string;
6
+ sessionPrepare: string;
7
+ sessionPrepareHint: string;
8
+ sessionPendingProfile: string;
9
+ sessionNoWorkspaces: string;
10
+ sessionPreparationUnavailable: string;
11
+ sessionPreparationUnknown: string;
4
12
  sessionSelectionBlock: string;
5
13
  sessionCommittedRefresh: string;
6
14
  sessionUnconfirmedRefresh: string;
@@ -276,6 +284,27 @@ export declare const en: {
276
284
  advanced: string;
277
285
  rawInvalid: string;
278
286
  invalidNumber: string;
287
+ configureAllAgentModels: string;
288
+ modelsDialogTitle: string;
289
+ modelsDialogDesc: string;
290
+ searchRolesPlaceholder: string;
291
+ filterExplicitOverrides: string;
292
+ orchestratorNoLevelsHint: string;
293
+ noMatchingRoles: string;
294
+ fallbackCountSummary: string;
295
+ fallbackExplicitEmptySummary: string;
296
+ levelsSummary: string;
297
+ levelsInherited: string;
298
+ fallbackInherited: string;
299
+ roleSettingsSummary: string;
300
+ roleSettingsInherited: string;
301
+ roleSettingsOverridden: string;
302
+ saveLockedReason: string;
303
+ jumpToField: string;
304
+ jumpToJsonc: string;
305
+ jumpToRole: string;
306
+ roleNonModelSettings: string;
307
+ inheritRouteDesc: string;
279
308
  };
280
309
  export type ProfilesLocaleKey = keyof typeof en;
281
310
  export declare const zh: Record<ProfilesLocaleKey, string>;
@@ -1,6 +1,11 @@
1
1
  export const NS = "settings.dsmm-profiles";
2
2
  export const en = {
3
- sessionChooseWorkspace: "Choose a workspace to start a session, then choose its configuration before sending.",
3
+ sessionChooseWorkspace: "Choose a workspace and profile here. A blank session is prepared only when you confirm a profile choice.",
4
+ sessionWorkspace: "Workspace", sessionWorkspacePlaceholder: "Choose a workspace…",
5
+ sessionPrepare: "Open with this profile", sessionPrepareHint: "Choose a profile to prepare and open a blank session. The native model stays unchanged.",
6
+ sessionPendingProfile: "Choose a workspace for: {profile}", sessionNoWorkspaces: "No workspaces available. Add or reconnect a workspace using native workspace navigation, then refresh.",
7
+ sessionPreparationUnavailable: "Native workspace preparation is unavailable. Open a workspace using native navigation, then choose this session's profile.",
8
+ sessionPreparationUnknown: "The Host did not return a session ID. Inspect the workspace using native navigation; this action will not automatically create or select again.",
4
9
  sessionSelectionBlock: "Finish choosing this session's configuration to continue typing.",
5
10
  sessionCommittedRefresh: "Saved. Refresh to confirm it.",
6
11
  sessionUnconfirmedRefresh: "The result is unknown. Refresh before choosing or sending again.",
@@ -90,9 +95,35 @@ export const en = {
90
95
  routeProvider: "{name} provider", routeModel: "{name} model", routeEffort: "{name} effort", manualProvider: "{name} provider (typed)", manualModel: "{name} model (typed)", manualEffort: "{name} effort (typed)", manual: "Type an identifier", manualValue: "Not listed: {value}", unset: "not set", effortDefault: "Default (no explicit effort)", effortChangeHint: "Changing the provider or model clears this route's reasoning effort.",
91
96
  naturalProvider: "Provider", naturalModel: "Model", naturalEffort: "Reasoning Effort",
92
97
  advanced: "Advanced JSONC", rawInvalid: "Fix the invalid draft in Advanced JSONC to use these controls. Your draft was kept.", invalidNumber: "Enter a whole number within the limits.",
98
+ configureAllAgentModels: "Configure all Agent models…",
99
+ modelsDialogTitle: "Agent models and routing",
100
+ modelsDialogDesc: "Configure primary routes, calling levels, fallback models, and execution policies for each Agent role.",
101
+ searchRolesPlaceholder: "Search by role name or ID…",
102
+ filterExplicitOverrides: "Explicit model overrides only",
103
+ orchestratorNoLevelsHint: "Orchestrator uses primary route only; calling levels are not applicable.",
104
+ noMatchingRoles: "No matching roles found.",
105
+ fallbackCountSummary: "{count} fallback route(s)",
106
+ fallbackExplicitEmptySummary: "Explicit empty ([])",
107
+ levelsSummary: "Levels: {levels}",
108
+ levelsInherited: "Inherited",
109
+ fallbackInherited: "Inherited",
110
+ roleSettingsSummary: "Status: {status} · Retry: {retry}",
111
+ roleSettingsInherited: "Inherit",
112
+ roleSettingsOverridden: "Explicit override",
113
+ saveLockedReason: "Save locked: {count} invalid field(s)",
114
+ jumpToField: "Locate error field",
115
+ jumpToJsonc: "Locate in JSONC",
116
+ jumpToRole: "Locate in Agent models dialog",
117
+ roleNonModelSettings: "Non-model settings",
118
+ inheritRouteDesc: "Inherit defaults",
93
119
  };
94
120
  export const zh = {
95
- sessionChooseWorkspace: "请先选择工作区新建会话,发送前再选择本次会话的配置。",
121
+ sessionChooseWorkspace: "在此选择工作区与方案;仅明确确认方案选择时才会准备空白会话。",
122
+ sessionWorkspace: "工作区", sessionWorkspacePlaceholder: "请选择工作区…",
123
+ sessionPrepare: "使用此方案打开", sessionPrepareHint: "选择方案后将准备并打开空白会话,保留原生模型。",
124
+ sessionPendingProfile: "请为「{profile}」选择工作区", sessionNoWorkspaces: "暂无可用工作区。请通过原生工作区导航添加或重新连接工作区,然后刷新。",
125
+ sessionPreparationUnavailable: "当前无法准备原生空白会话。请通过原生导航打开工作区,再选择本次会话方案。",
126
+ sessionPreparationUnknown: "Host 未返回会话 ID。请通过原生导航检查工作区;本入口不会自动重复创建或提交选择。",
96
127
  sessionSelectionBlock: "请先完成本次会话的配置选择,然后即可继续输入。",
97
128
  sessionCommittedRefresh: "已保存,请刷新确认。",
98
129
  sessionUnconfirmedRefresh: "结果未知,请刷新后再选择或发送。",
@@ -182,6 +213,27 @@ export const zh = {
182
213
  routeProvider: "{name} 提供商", routeModel: "{name} 模型", routeEffort: "{name} 强度", manualProvider: "{name} 提供商(手动)", manualModel: "{name} 模型(手动)", manualEffort: "{name} 强度(手动)", manual: "输入标识", manualValue: "未列出:{value}", unset: "未设置", effortDefault: "默认(不指定强度)", effortChangeHint: "更改提供商或模型会清除该路由的推理强度。",
183
214
  naturalProvider: "提供商", naturalModel: "模型", naturalEffort: "推理强度",
184
215
  advanced: "高级 JSONC", rawInvalid: "请先在高级 JSONC 中修正草稿,再使用这些控件。草稿已保留。", invalidNumber: "请输入范围内的整数。",
216
+ configureAllAgentModels: "配置全部 Agent 模型…",
217
+ modelsDialogTitle: "Agent 模型与路由配置",
218
+ modelsDialogDesc: "为每个 Agent 角色配置主路由、调用档位、备用模型及执行策略。",
219
+ searchRolesPlaceholder: "按角色名称或 ID 搜索…",
220
+ filterExplicitOverrides: "仅显式模型覆盖",
221
+ orchestratorNoLevelsHint: "主协调角色仅使用主路由,不适用调用档位。",
222
+ noMatchingRoles: "未找到匹配的角色。",
223
+ fallbackCountSummary: "{count} 个备用路由",
224
+ fallbackExplicitEmptySummary: "显式清空([])",
225
+ levelsSummary: "档位:{levels}",
226
+ levelsInherited: "继承",
227
+ fallbackInherited: "继承",
228
+ roleSettingsSummary: "状态:{status} · 重试:{retry}",
229
+ roleSettingsInherited: "继承",
230
+ roleSettingsOverridden: "显式覆盖",
231
+ saveLockedReason: "保存已锁定:{count} 处字段无效",
232
+ jumpToField: "定位错误字段",
233
+ jumpToJsonc: "在 JSONC 中定位",
234
+ jumpToRole: "在 Agent 模型弹窗中定位",
235
+ roleNonModelSettings: "非模型设置",
236
+ inheritRouteDesc: "继承默认",
185
237
  };
186
238
  export const RETRY_FIELD_LABEL_KEYS = {
187
239
  maxRetries: "retryCount", initialDelayMs: "initialDelay", maxDelayMs: "maxDelay",
@@ -0,0 +1,43 @@
1
+ import type { ISessions, SessionBinding } from "@deepseek-ai/dsh-api-session-controller/client";
2
+ import type { SessionId } from "@deepseek-ai/dsh-session/types";
3
+ import type { HostObservable } from "@deepseek-ai/dsh-client-ui-slots";
4
+ type WorkspaceId = NonNullable<NonNullable<Parameters<ISessions["create"]>[0]>["workspaceId"]>;
5
+ export interface ProfileWorkspace {
6
+ id: string;
7
+ label: string;
8
+ }
9
+ export interface ProfileBlankNative {
10
+ readonly workspaces: HostObservable<readonly ProfileWorkspace[]>;
11
+ beginNavigation(): AbortSignal;
12
+ connectWorkspace(id: string): Promise<SessionId>;
13
+ retain(id: SessionId): {
14
+ readonly sessionId: SessionId;
15
+ readonly ready: Promise<Pick<SessionBinding, "sessionId">>;
16
+ release(): void;
17
+ };
18
+ openSession(id: SessionId): void;
19
+ }
20
+ /** Public native service subsets; these optional packages are not runtime imports. */
21
+ export interface ProfileBlankServices {
22
+ workspaces: {
23
+ readonly list: HostObservable<{
24
+ readonly phase: string;
25
+ readonly items: readonly {
26
+ readonly workspaceId: WorkspaceId;
27
+ readonly title: string;
28
+ readonly path: string;
29
+ }[];
30
+ }>;
31
+ };
32
+ uiWorkspace: {
33
+ connectWorkspace(id: WorkspaceId): Promise<SessionId>;
34
+ openSession(id: SessionId): void;
35
+ };
36
+ layout: {
37
+ beginNavigation(): AbortSignal;
38
+ };
39
+ sessions: Pick<ISessions, "retain">;
40
+ }
41
+ export declare function profileBlankNative(services: ProfileBlankServices): ProfileBlankNative;
42
+ export {};
43
+ //# sourceMappingURL=profile-blank.d.ts.map