@dsmm/dsmm 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/cordis.patch.yml +9 -0
  2. package/docs/compatibility.md +10 -0
  3. package/docs/releasing.md +25 -65
  4. package/docs/roadmap.md +44 -2
  5. package/lib/client/ChildPermissions.d.ts +43 -0
  6. package/lib/client/ChildPermissions.js +100 -0
  7. package/lib/client/ChildrenPanel.d.ts +4 -1
  8. package/lib/client/ChildrenPanel.js +3 -3
  9. package/lib/client/DeploymentFields.d.ts +6 -2
  10. package/lib/client/DeploymentFields.js +8 -6
  11. package/lib/client/DeploymentPage.d.ts +4 -1
  12. package/lib/client/DeploymentPage.js +5 -4
  13. package/lib/client/HistoryContinuation.d.ts +7 -0
  14. package/lib/client/HistoryContinuation.js +22 -0
  15. package/lib/client/PermissionPanelEntry.d.ts +8 -0
  16. package/lib/client/PermissionPanelEntry.js +11 -0
  17. package/lib/client/PermissionsPanel.d.ts +3 -1
  18. package/lib/client/PermissionsPanel.js +3 -2
  19. package/lib/client/ProfilesSection.js +3 -3
  20. package/lib/client/RoleAvailability.js +1 -1
  21. package/lib/client/SessionProfiles.js +21 -18
  22. package/lib/client/TemporaryPermissions.d.ts +21 -0
  23. package/lib/client/TemporaryPermissions.js +94 -0
  24. package/lib/client/children-locales.d.ts +4 -4
  25. package/lib/client/controller.d.ts +17 -0
  26. package/lib/client/controller.js +101 -18
  27. package/lib/client/deployment-locales.js +26 -26
  28. package/lib/client/history-controller.d.ts +29 -0
  29. package/lib/client/history-controller.js +111 -0
  30. package/lib/client/history-entry.d.ts +11 -0
  31. package/lib/client/history-entry.js +106 -0
  32. package/lib/client/history-locales.d.ts +95 -0
  33. package/lib/client/history-locales.js +41 -0
  34. package/lib/client/index.js +16 -3
  35. package/lib/client/locales.d.ts +6 -0
  36. package/lib/client/locales.js +104 -92
  37. package/lib/client/permission-locales.d.ts +26 -0
  38. package/lib/client/permission-locales.js +55 -35
  39. package/lib/client/temporary-permission-client.d.ts +20 -0
  40. package/lib/client/temporary-permission-client.js +52 -0
  41. package/lib/client/temporary-permission-entry.d.ts +6 -0
  42. package/lib/client/temporary-permission-entry.js +56 -0
  43. package/lib/client.js +3881 -1981
  44. package/lib/history-candidates.d.ts +30 -0
  45. package/lib/history-candidates.js +176 -0
  46. package/lib/history-codec.d.ts +11 -0
  47. package/lib/history-codec.js +102 -0
  48. package/lib/history-contract.d.ts +44 -0
  49. package/lib/history-contract.js +2 -0
  50. package/lib/history-controller.d.ts +42 -0
  51. package/lib/history-controller.js +329 -0
  52. package/lib/history-policy.d.ts +4 -0
  53. package/lib/history-policy.js +8 -0
  54. package/lib/history-remote.d.ts +28 -0
  55. package/lib/history-remote.js +17 -0
  56. package/lib/history-rpc.d.ts +24 -0
  57. package/lib/history-rpc.js +136 -0
  58. package/lib/history-support.d.ts +15 -0
  59. package/lib/history-support.js +21 -0
  60. package/lib/history-types.d.ts +67 -0
  61. package/lib/history-types.js +2 -0
  62. package/lib/index.d.ts +2 -0
  63. package/lib/index.js +24 -6
  64. package/lib/native-admission.d.ts +21 -0
  65. package/lib/native-admission.js +206 -16
  66. package/lib/permission-child-control.d.ts +36 -0
  67. package/lib/permission-child-control.js +164 -0
  68. package/lib/permission-control.d.ts +2 -0
  69. package/lib/permission-control.js +7 -0
  70. package/lib/permission-controller.js +2 -2
  71. package/lib/permission-exec-argv.d.ts +32 -0
  72. package/lib/permission-exec-argv.js +171 -0
  73. package/lib/permission-fs-search.js +2 -1
  74. package/lib/permission-fs.js +2 -1
  75. package/lib/permission-native-rules.js +3 -3
  76. package/lib/permission-temporary-files.d.ts +19 -0
  77. package/lib/permission-temporary-files.js +248 -0
  78. package/lib/permission-temporary-grants.d.ts +106 -0
  79. package/lib/permission-temporary-grants.js +198 -0
  80. package/lib/permission-temporary-install.d.ts +25 -0
  81. package/lib/permission-temporary-install.js +86 -0
  82. package/lib/permission-temporary-remote.d.ts +19 -0
  83. package/lib/permission-temporary-remote.js +75 -0
  84. package/lib/permission-temporary-rpc.d.ts +37 -0
  85. package/lib/permission-temporary-rpc.js +154 -0
  86. package/lib/permission-temporary-types.d.ts +47 -0
  87. package/lib/permission-temporary-types.js +2 -0
  88. package/lib/permission-temporary-web.d.ts +11 -0
  89. package/lib/permission-temporary-web.js +154 -0
  90. package/lib/permission-web.js +2 -1
  91. package/lib/preset-skills.d.ts +1 -1
  92. package/lib/preset-skills.js +2 -2
  93. package/lib/profile-rpc.js +2 -0
  94. package/lib/profile-runtime.d.ts +12 -1
  95. package/lib/profile-runtime.js +122 -10
  96. package/lib/profile-store.d.ts +2 -2
  97. package/lib/profile-store.js +8 -1
  98. package/lib/profile-types.d.ts +1 -0
  99. package/lib/role-invocation.d.ts +1 -1
  100. package/lib/role-invocation.js +2 -2
  101. package/lib/role-subagents.js +16 -3
  102. package/lib/skills.d.ts +1 -0
  103. package/lib/skills.js +5 -1
  104. package/package.json +41 -33
  105. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-api-gateway@0.2.1-rc.2.patch +13291 -0
  106. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-api-remotes@0.2.1-rc.2.patch +9133 -0
  107. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-client-ui-approval@0.2.1-rc.2.patch +156 -0
  108. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-subagent@0.2.1-rc.2.patch +3546 -0
  109. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-user-approval@0.2.1-rc.2.patch +431 -0
  110. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-web@0.2.1-rc.2.patch +119 -0
  111. package/patches/dsh-approval-settlement/README.md +41 -0
  112. package/patches/dsh-approval-settlement/metadata.json +10 -0
  113. package/patches/dsh-session-activation/@deepseek-ai__dsh-agent-loop@0.2.1-rc.2.patch +383 -0
  114. package/patches/dsh-session-activation/@deepseek-ai__dsh-agent-preset-registry@0.2.1-rc.2.patch +55 -0
  115. package/patches/dsh-session-activation/@deepseek-ai__dsh-api-session-controller@0.2.1-rc.2.patch +16673 -0
  116. package/patches/dsh-session-activation/@deepseek-ai__dsh-client-ui-subagent@0.2.1-rc.2.patch +29 -0
  117. package/patches/dsh-session-activation/@deepseek-ai__dsh-client-ui-workspace@0.2.1-rc.2.patch +196 -0
  118. package/patches/dsh-session-activation/@deepseek-ai__dsh-session-persistence-jsonl@0.2.1-rc.2.patch +35 -0
  119. package/patches/dsh-session-activation/@deepseek-ai__dsh-session-persistence@0.2.1-rc.2.patch +40 -0
@@ -28,12 +28,20 @@ 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, 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, 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
+ pendingSessionSelections = new Set();
38
+ connection = null;
39
+ connectionBaseline;
40
+ connectionBound = false;
41
+ stopConnection = null;
42
+ composerBlocks = null;
43
+ composerReason = null;
44
+ composerBlock = null;
37
45
  catalogGeneration = 0;
38
46
  catalogRemote = null;
39
47
  modelSelectorGeneration = 0;
@@ -69,7 +77,7 @@ export class ProfilesController {
69
77
  editPath: (path, value) => this.editPath(path, value), moveFallback: (role, from, to) => this.editFallbackOrder(role, from, to),
70
78
  editRoute: (path, provider, model) => this.editRoute(path, provider, model),
71
79
  refreshCatalog: () => this.refreshCatalog(), refreshSession: () => this.refreshSession(),
72
- chooseSessionProfile: (id) => { if (!this.disposed && this.current.sessionBusy === null && this.current.busy === null && !this.current.dirty)
80
+ 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)
73
81
  this.publish({ sessionChoice: id, sessionNotice: null }); },
74
82
  applySession: (options) => this.selectSession(false, options), resetSession: () => this.selectSession(true),
75
83
  setDeepwork: (active) => this.setDeepwork(active), useSessionProfileModel: () => this.selectSession(false, { useProfileModel: true }, true),
@@ -86,7 +94,66 @@ export class ProfilesController {
86
94
  constructor(remote) {
87
95
  this.remote = remote;
88
96
  }
89
- dispose() { 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(); }
97
+ dispose() { this.releaseComposerBlock(); 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(); }
98
+ bindConnection(source) {
99
+ if (this.disposed)
100
+ return;
101
+ const replacement = this.connectionBound && (source !== this.connection || source?.getSnapshot() !== this.connectionBaseline);
102
+ this.stopConnection?.();
103
+ this.connection = source;
104
+ this.connectionBound = true;
105
+ this.connectionBaseline = source?.getSnapshot();
106
+ const invalidate = () => {
107
+ this.connectionBaseline = source?.getSnapshot();
108
+ this.generation += 1;
109
+ this.sessionGeneration += 1;
110
+ this.modelSelectorGeneration += 1;
111
+ this.publish({ session: null, sessionBusy: null, sessionNotice: null, sessionUnconfirmed: this.current.currentSessionId !== null,
112
+ sessionViewEpoch: this.current.sessionViewEpoch + 1, busy: null, issue: { kind: "transport", code: "unavailable" } });
113
+ };
114
+ if (replacement || source === null || this.connectionBaseline === undefined)
115
+ invalidate();
116
+ this.stopConnection = source?.subscribe(() => {
117
+ invalidate();
118
+ if (this.connectionCurrent()) {
119
+ void this.refresh();
120
+ void this.refreshSession();
121
+ }
122
+ }) ?? null;
123
+ }
124
+ connectionCurrent() {
125
+ return !this.connectionBound || this.connectionBaseline !== undefined && this.connection?.getSnapshot() === this.connectionBaseline;
126
+ }
127
+ attachComposerBlocks(blocks, reason) {
128
+ if (this.disposed)
129
+ return;
130
+ this.releaseComposerBlock();
131
+ this.composerBlocks = blocks;
132
+ this.composerReason = reason ?? null;
133
+ this.syncComposerBlock();
134
+ }
135
+ releaseComposerBlock() {
136
+ const held = this.composerBlock;
137
+ this.composerBlock = null;
138
+ // Native blocks have no owner token. Only release the exact object and
139
+ // store we installed into an empty seat; never forget or clear another owner.
140
+ if (held !== null && this.composerBlocks?.storeFor(held.id) === held.store && held.store.getSnapshot() === held.block)
141
+ this.composerBlocks.set(held.id, undefined);
142
+ }
143
+ syncComposerBlock() {
144
+ const { currentSessionId, sessionBusy, sessionUnconfirmed, session } = this.current;
145
+ const wanted = currentSessionId !== null && (sessionBusy === "apply" || sessionBusy === "reset" || sessionUnconfirmed || session?.refreshRequired || session?.selection.refreshRequired);
146
+ if (!wanted || this.composerBlock?.id !== currentSessionId)
147
+ this.releaseComposerBlock();
148
+ if (!wanted || this.composerBlock !== null || this.composerBlocks === null || this.composerReason === null)
149
+ return;
150
+ const id = currentSessionId, store = this.composerBlocks.storeFor(id);
151
+ if (store.getSnapshot() !== undefined)
152
+ return;
153
+ const block = { reason: this.composerReason() };
154
+ this.composerBlock = { id, store, block };
155
+ this.composerBlocks.set(id, block);
156
+ }
90
157
  attachModelSelector(remote) {
91
158
  if (this.disposed)
92
159
  return;
@@ -166,7 +233,7 @@ export class ProfilesController {
166
233
  this.attachModelEventSource(null, null);
167
234
  if (id !== this.modelInteractionSessionId)
168
235
  this.attachModelInteractionSource(null, null);
169
- this.publish({ currentSessionId: id, session: null, sessionChoice: null, sessionBusy: null, sessionIssue: null, sessionNotice: null });
236
+ 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 });
170
237
  if (id !== null)
171
238
  void this.refreshSession();
172
239
  }
@@ -195,18 +262,18 @@ export class ProfilesController {
195
262
  }
196
263
  async refreshSession(preserveFeedback = false) {
197
264
  const id = this.current.currentSessionId;
198
- if (this.disposed || id === null || this.current.sessionBusy !== null)
265
+ if (this.disposed || !this.connectionCurrent() || id === null || this.current.sessionBusy !== null)
199
266
  return;
200
267
  this.modeRefreshPending = false;
201
268
  const generation = ++this.sessionGeneration;
202
- const live = () => !this.disposed && generation === this.sessionGeneration && id === this.current.currentSessionId;
269
+ const live = () => !this.disposed && this.connectionCurrent() && generation === this.sessionGeneration && id === this.current.currentSessionId;
203
270
  this.publish({ sessionBusy: "read", ...(preserveFeedback ? {} : { sessionIssue: null, sessionNotice: null }) });
204
271
  try {
205
272
  const session = await this.unwrap(this.remote.describeSession(id));
206
273
  if (session.sessionId !== id)
207
274
  throw { kind: "assembly", code: "unavailable" };
208
275
  if (live())
209
- this.publish({ session, sessionChoice: session.selection.selectedId });
276
+ this.publish({ session, sessionChoice: (session.admittedSelection ?? session.selection).selectedId, sessionUnconfirmed: this.pendingSessionSelections.has(id) });
210
277
  }
211
278
  catch (error) {
212
279
  if (live())
@@ -221,13 +288,15 @@ export class ProfilesController {
221
288
  }
222
289
  async setDeepwork(active) {
223
290
  const { currentSessionId: id, session } = this.current;
224
- if (this.disposed || id === null || session?.deepwork === undefined || session.refreshRequired || session.selection.refreshRequired || session.deepwork.locked || session.canToggleMode !== true
291
+ if (this.disposed || !this.connectionCurrent() || this.current.sessionUnconfirmed || id === null || session?.deepwork === undefined || session.refreshRequired || session.selection.refreshRequired || session.deepwork.locked || session.canToggleMode !== true
225
292
  || this.current.sessionBusy !== null || this.current.busy !== null || this.remote.selectMode === undefined)
226
293
  return;
227
294
  const generation = ++this.sessionGeneration;
228
- const live = () => !this.disposed && generation === this.sessionGeneration && id === this.current.currentSessionId;
295
+ const live = () => !this.disposed && this.connectionCurrent() && generation === this.sessionGeneration && id === this.current.currentSessionId;
229
296
  this.publish({ sessionBusy: "mode", sessionIssue: null, sessionNotice: null });
230
297
  try {
298
+ if (!live())
299
+ return;
231
300
  const accepted = await this.unwrap(this.remote.selectMode(id, { sessionId: id, active,
232
301
  expectedModeRevision: session.deepwork.revision, expectedAdmissionEpoch: session.admissionEpoch }));
233
302
  if (accepted.sessionId !== id || accepted.deepwork?.active !== active || !accepted.deepwork.explicit)
@@ -248,13 +317,13 @@ export class ProfilesController {
248
317
  }
249
318
  async selectSession(reset, options, modelOnly = false) {
250
319
  const { currentSessionId: id, session, sessionChoice, snapshot } = this.current;
251
- if (this.disposed || id === null || session === null || session.refreshRequired || session.selection.refreshRequired || !writableSelectionVersion(session.selection.selectionRevision)
320
+ if (this.disposed || !this.connectionCurrent() || this.current.sessionUnconfirmed || id === null || session === null || session.refreshRequired || session.selection.refreshRequired || !writableSelectionVersion(session.selection.selectionRevision)
252
321
  || (modelOnly ? session.canSelectModel !== true : session.canApplyOverlay !== true || session.applyOverlayUnavailableReason === "new-session-required") || this.current.sessionBusy !== null
253
322
  || this.current.busy !== null || this.current.dirty || this.current.invalidFields.length > 0 || this.current.pendingEditor !== null)
254
323
  return;
255
324
  const selectedId = reset ? null : sessionChoice;
256
- const revision = snapshot?.profiles.find((profile) => profile.id === selectedId)?.revision;
257
- if (!modelOnly && selectedId !== null && !isConfigRevision(revision))
325
+ const profile = snapshot?.profiles.find((profile) => profile.id === selectedId), revision = profile?.revision;
326
+ if (!modelOnly && selectedId !== null && (!isConfigRevision(revision) || profile?.error !== undefined))
258
327
  return;
259
328
  const generation = ++this.sessionGeneration;
260
329
  const useProfileModel = !reset && options?.useProfileModel === true;
@@ -266,10 +335,14 @@ export class ProfilesController {
266
335
  const modeWatermark = eventSource === null ? -1 : modeIntentWatermark(eventSource.getSnapshot());
267
336
  const interaction = this.modelInteraction, interactionGeneration = this.modelInteractionGeneration;
268
337
  const pendingNativeChoice = interaction?.getSnapshot().status === "selecting";
269
- const live = () => !this.disposed && generation === this.sessionGeneration && id === this.current.currentSessionId;
338
+ const live = () => !this.disposed && this.connectionCurrent() && generation === this.sessionGeneration && id === this.current.currentSessionId;
270
339
  const selectorLive = () => live() && selector !== null && selector === this.modelSelector && selectorGeneration === this.modelSelectorGeneration;
340
+ if (!modelOnly)
341
+ this.pendingSessionSelections.add(id);
271
342
  this.publish({ sessionBusy: reset ? "reset" : "apply", sessionIssue: null, sessionNotice: null });
272
343
  try {
344
+ if (!live())
345
+ return;
273
346
  const accepted = await this.unwrap(modelOnly ? this.remote.describeSession(id) : this.remote.selectSession(id, {
274
347
  sessionId: id, id: selectedId, ...(selectedId === null ? {} : { expectedRevision: revision }),
275
348
  expectedSelectionRevision: session.selection.selectionRevision, expectedAdmissionEpoch: session.admissionEpoch,
@@ -280,7 +353,8 @@ export class ProfilesController {
280
353
  throw { kind: "domain", code: "conflict" };
281
354
  if (!live())
282
355
  return;
283
- this.publish({ session: accepted, sessionChoice: accepted.selection.selectedId, sessionNotice: useProfileModel ? null : reset ? "reset" : "applied" });
356
+ this.publish({ session: accepted, sessionChoice: (accepted.admittedSelection ?? accepted.selection).selectedId,
357
+ sessionNotice: useProfileModel || accepted.refreshRequired || accepted.selection.refreshRequired ? null : reset ? "reset" : "applied" });
284
358
  if (!useProfileModel || accepted.refreshRequired || accepted.selection.refreshRequired || !live())
285
359
  return;
286
360
  if (accepted.canSelectModel !== true || !writableSelectionVersion(accepted.selection.selectionRevision)) {
@@ -334,20 +408,29 @@ export class ProfilesController {
334
408
  }
335
409
  }
336
410
  catch (error) {
337
- if (live())
338
- this.publish({ sessionIssue: this.issue(error) });
411
+ if (live()) {
412
+ const issue = this.issue(error);
413
+ this.publish({ sessionIssue: issue, sessionUnconfirmed: !modelOnly && (issue.kind !== "domain" || issue.code === "cancelled") });
414
+ }
339
415
  }
340
416
  finally {
417
+ if (!modelOnly)
418
+ this.pendingSessionSelections.delete(id);
341
419
  if (live()) {
342
420
  this.publish({ sessionBusy: null });
343
421
  this.refreshObservedMode();
344
422
  }
423
+ else if (!modelOnly && !this.disposed && this.connectionCurrent() && id === this.current.currentSessionId) {
424
+ this.modeRefreshPending = true;
425
+ this.refreshObservedMode();
426
+ }
345
427
  }
346
428
  }
347
429
  publish(patch) {
348
430
  if (this.disposed)
349
431
  return;
350
432
  this.current = { ...this.current, ...patch };
433
+ this.syncComposerBlock();
351
434
  for (const listener of this.listeners)
352
435
  listener();
353
436
  }
@@ -373,10 +456,10 @@ export class ProfilesController {
373
456
  return { kind: "assembly", code: "unavailable" };
374
457
  }
375
458
  async perform(busy, operation) {
376
- if (this.disposed || this.current.busy !== null || this.current.sessionBusy === "apply" || this.current.sessionBusy === "reset" || this.current.pendingEditor !== null)
459
+ if (this.disposed || !this.connectionCurrent() || this.current.busy !== null || this.current.sessionBusy === "apply" || this.current.sessionBusy === "reset" || this.current.pendingEditor !== null)
377
460
  return;
378
461
  const generation = ++this.generation;
379
- const live = () => !this.disposed && generation === this.generation;
462
+ const live = () => !this.disposed && this.connectionCurrent() && generation === this.generation;
380
463
  this.publish({ busy, issue: null, notice: null });
381
464
  try {
382
465
  await operation(live);
@@ -3,27 +3,27 @@ export const deploymentEn = {
3
3
  title: "DSMM", summary: "Global config and profile overrides",
4
4
  description: "Layers save independently; native models and running sessions stay unchanged.",
5
5
  global: "DSMM Global config", globalHint: "Shared by this Home’s DSH profiles. Unset fields use built-in defaults.",
6
- profile: "Current DSH profile overrides", profileHint: "This native entry only. Ordinary Unset fields inherit Global plus Host base pins. Native runtime uses Host base/native defaults, never Global.",
6
+ profile: "Current DSH profile overrides", profileHint: "This DSH profile only. Unset fields use Global and Host defaults; native runtime uses Host defaults.",
7
7
  profileUnavailable: "Unavailable",
8
- unavailableForm: "Current profile is read-only: no verified writable native form at this connection, namespace and revision. Global configuration remains a separate authority.",
8
+ unavailableForm: "This DSH profile is read-only. Reconnect and refresh to check editing access.",
9
9
  ceiling: "Deepwork master is Global-only; profiles and session modes cannot lift its captured ceiling.",
10
10
  hostUnknown: "Host bundle status: unknown (separate switch).",
11
- boundaries: "New roots capture saved settings within startup capabilities. Save does not restart the Host; startup-only changes require a separate Host restart, which may cancel sessions.",
11
+ boundaries: "Saved settings apply to new sessions. Changes marked restart required need a separate Host restart, which may cancel sessions.",
12
12
  core: "Core", coreHint: "Core-owned desired settings. Model-parameter passthrough is ordinary config, not a subplugin. The permission-control enabled flag is startup-pinned. Save does not change current-session admission; inspect desired, startup and admitted values below. Unavailable admission stays unknown.",
13
- modelParametersHint: "Default On. Off retains saved custom/opaque model parameters without forwarding them, and DSMM reasoningEffort / reasoning_effort aliases use native defaults. Standard SDK parameters and explicit native root choices remain intact. Raw JSON and exact effort values remain editable; saving desired settings does not verify provider transport readiness.",
13
+ modelParametersHint: "Off stops sending custom parameters and uses native reasoning defaults. Saved values and your selected model stay unchanged.",
14
14
  permissionControlHint: "Permission-control mounting is startup-pinned. Saved configuration does not prove runtime coverage or remove current protections. Root rules keep their independent authority inside Permissions.",
15
- modules: "Configuration modules", scope: "Configuration scope", close: "Close module", loading: "Loading configuration…", unset: "Unset — inherit",
15
+ modules: "Configuration modules", scope: "Configuration scope", close: "Close module", loading: "Loading configuration…", unset: "Use default configuration",
16
16
  "module:run": "Run and modules", "module:routes": "Model routes and recovery", "module:workflow": "Workflow, roles and skills", "module:subagents": "Subagent settings", "module:permissions": "Permissions and guards", "module:other": "Other settings", "module:state": "Configuration state",
17
17
  saveScope: "Save selected configuration scope", pendingModules: "Pending modules in this scope", savedRefreshRequired: "Saved — refresh required before further edits", sessionObserved: "Current-session admission observed",
18
- noModuleFields: "No editable schema fields for this module in the selected scope.",
18
+ noModuleFields: "No editable settings in this scope.",
19
19
  leaveDraft: "Unsaved or invalid draft. Choose how to leave; nothing is saved or discarded automatically.", continueEditing: "Continue editing", keepDraft: "Keep draft and return", discardDraft: "Discard draft and leave",
20
- rootRules: "Current Root rules", rootRulesHint: "This transaction is separate from Global/native configuration Save. It requires an open trusted Root, writable operator authority and synchronized runtime. It never borrows Global authority to bypass a refusal.", rootRulesUnavailable: "Root rules service unavailable. No session or authority is inferred.",
20
+ rootRules: "Session permission rules", rootRulesHint: "Rules save separately. Select an open main session with editing access and synchronized permissions.", rootRulesUnavailable: "Permission rules unavailable. Reconnect and refresh.",
21
21
  nativeRuntimeHint: "Native default On; Host base pins still apply. Mounting is captured at startup. Saving stages desired configuration only; it does not start/stop providers or cancel running sessions. A separate Host restart may cancel sessions.",
22
- nativeRuntimeReadinessHint: "Official Host services own execution and JSONL storage. This snapshot reports native execution admission readiness, not guaranteed inbox acceptance or completion. Storage is configured on the native JSONL service, not DSMM.",
23
- unsetGroup: "Unset this group — restore inheritance",
22
+ nativeRuntimeReadinessHint: "Task progress is available in the session.",
23
+ unsetGroup: "Use defaults for this group",
24
24
  nativeRuntimeState: "Observed native runtime", nativeRuntimeBinding: "Observed runtime composition", nativeRuntimeFence: "Execution admission ready", nativeRuntimeRestart: "Restart required", nativeRuntimeStock: "Official Host runtime", nativeRuntimeUnavailable: "Unavailable / unknown",
25
25
  "nativeRuntimeReason-explicit-composition-required": "The Host requires an explicit native runtime composition.", "nativeRuntimeReason-duplicate-provider": "More than one native provider is present; readiness is not confirmed.", "nativeRuntimeReason-authority-not-ready": "Native execution authority is not ready.", "nativeRuntimeReason-disabled": "The saved native runtime is disabled.", "nativeRuntimeReason-pending-restart": "Saved desired state differs from the mounted native composition; restart is pending.", "nativeRuntimeReason-scope-conflict": "Native scope ownership conflicts; readiness is not confirmed.",
26
- saveGlobal: "Save Global config", saveProfile: "Save profile overrides", saving: "Saving…", refresh: "Refresh", discard: "Discard and reload", dirty: "Unsaved changes", saved: "Saved",
26
+ saveGlobal: "Save", saveProfile: "Save", saving: "Saving…", refresh: "Refresh", discard: "Discard and reload", dirty: "Unsaved changes", saved: "Saved",
27
27
  inherit: "Inherit", explicit: "Override", defaultPin: "Built-in default pinned", hostPin: "Host pin remains when cleared",
28
28
  globalSource: "Global", profileSource: "DSH profile", defaultsSource: "Built-in default", namedSource: "Named/session", startupSource: "Startup capture", deploymentCapture: "Deployment capture",
29
29
  desired: "Merged desired", startup: "Startup mounted / captured", next: "Next root", session: "Current-session admitted", noSession: "No active session: admission is unknown.",
@@ -31,41 +31,41 @@ export const deploymentEn = {
31
31
  absent: "Absent", mixedSource: "Mixed sources", inspectorStale: "Saved state, not draft",
32
32
  pending: "Pending independent restart", unknown: "Unknown", on: "On", off: "Off", state: "Field sources and effective state", module: "Deepwork module",
33
33
  versionObserved: "Metadata observed", versionAbsent: "Not stored", versionUnknown: "Version unavailable",
34
- advanced: "Advanced JSON", advancedHint: "Schema keys only; omit to inherit. Arrays replace. No credentials or scripts; use existing providers.",
34
+ advanced: "Advanced JSON", advancedHint: "Use supported fields; omit to inherit. Arrays replace inherited values. Do not enter credentials or scripts.",
35
35
  invalid: "Invalid field. Check type, bounds and keys; draft retained.",
36
36
  conflict: "Revision conflict; draft retained. Review changes, then discard and reload. Refresh does not merge.",
37
37
  unavailable: "Scope unavailable; draft retained. Reconnect and refresh.",
38
38
  "not-owned": "Read-only: requires an authenticated local Host operator.",
39
39
  validation: "Host rejected configuration; draft retained. Check fields and merged constraints.",
40
- transport: "Disconnected; draft retained. Reconnect and refresh.",
41
- unconfirmed: "The native form did not confirm Save. The Host may have committed; refresh the affected source before deciding to retry. Draft retained; no automatic replay.",
40
+ transport: "Connection lost; result unknown. Draft kept. Reconnect and refresh before retrying.",
41
+ unconfirmed: "Save result unknown. Draft kept. Refresh before retrying.",
42
42
  namedIndependent: "Deepwork Profiles is a separate named JSONC runtime-resource editor in Settings. Saving here does not apply a named profile or select its model.",
43
43
  };
44
44
  export const deploymentZh = {
45
45
  title: "DSMM", summary: "全局配置与当前配置覆盖",
46
46
  description: "两层独立保存,不改原生模型或运行中会话。",
47
47
  global: "DSMM 全局配置", globalHint: "同一 Home 的 DSH 配置共用;未设置字段使用内建默认值。",
48
- profile: "当前 DSH 配置覆盖", profileHint: "仅此原生实例。普通字段 Unset 后继承 Global 与 Host base 固定值;原生 runtime 仅取 Host base/原生默认值,不继承 Global。",
48
+ profile: "当前 DSH 配置覆盖", profileHint: "仅影响此 DSH 配置。未设置字段使用全局与宿主默认值;原生运行时使用宿主默认值。",
49
49
  profileUnavailable: "不可用",
50
- unavailableForm: "当前配置只读:连接、namespace 与版本尚无已核验的可写原生表单;Global 配置仍使用独立权限。",
50
+ unavailableForm: "此 DSH 配置只读,请重连并刷新以检查编辑权限。",
51
51
  ceiling: "Deepwork 总开关仅全局可改;配置和会话模式不能突破已捕获上限。",
52
52
  hostUnknown: "宿主整包状态:未知(独立开关)。",
53
- boundaries: "新根会话在启动能力内采用已保存设置。保存不重启宿主;仅启动时生效的更改需另行重启宿主,可能取消会话。",
53
+ boundaries: "保存的设置供新会话使用。标注「需重启」的更改需另行重启宿主,可能取消会话。",
54
54
  core: "Core 核心配置", coreHint: "Core 所有的 desired 意图配置。模型参数透传为普通配置,非子插件;权限控制 enabled 仅启动时捕获。保存不改变当前会话准入;下方可检查意图、启动与准入值,不可用的准入仍为未知。",
55
- modelParametersHint: "默认开启。关闭后仍保存 custom/opaque 模型参数但不发送;DSMM reasoningEffort/reasoning_effort 两种别名采用原生默认值。标准 SDK 参数与根会话原生显式选择保留。仍可编辑原始 JSON 和精确 effort 值;保存意图不代表提供商传输已就绪。",
55
+ modelParametersHint: "关闭后停止发送自定义参数,并使用原生推理默认值;已保存的值和所选模型不变。",
56
56
  permissionControlHint: "权限控制挂载仅启动时捕获。保存配置不证明运行时覆盖,也不移除当前保护;Root 规则在权限模块内保持独立权限。",
57
- modules: "配置模块", scope: "配置作用域", close: "关闭模块", loading: "正在加载配置…", unset: "Unset——继承",
57
+ modules: "配置模块", scope: "配置范围", close: "关闭模块", loading: "正在加载配置…", unset: "使用默认配置",
58
58
  "module:run": "运行与模块", "module:routes": "模型路由与恢复", "module:workflow": "工作流、角色与技能", "module:subagents": "子 Agent 设置", "module:permissions": "权限与保护", "module:other": "其他设置", "module:state": "配置状态",
59
59
  saveScope: "保存所选配置作用域", pendingModules: "此作用域的待保存模块", savedRefreshRequired: "已保存——需刷新后继续编辑", sessionObserved: "已观测当前会话准入",
60
- noModuleFields: "所选作用域中,此模块没有可编辑的 schema 字段。",
60
+ noModuleFields: "此范围内没有可编辑的设置。",
61
61
  leaveDraft: "仍有未保存或无效草稿,请选择离开方式;不会自动保存或丢弃。", continueEditing: "继续编辑", keepDraft: "保留草稿并返回", discardDraft: "放弃草稿并离开",
62
- rootRules: "当前 Root 规则", rootRulesHint: "此事务与 Global/native 配置保存分开,需要已打开的可信 Root、可写 operator 权限及已同步运行时;不会借 Global 权限绕过拒绝。", rootRulesUnavailable: "Root 规则服务不可用,不推断或创建会话和权限。",
62
+ rootRules: "会话权限规则", rootRulesHint: "规则单独保存。请选择已打开的主会话,并确认有编辑权限且权限已同步。", rootRulesUnavailable: "权限规则不可用,请重连后刷新。",
63
63
  nativeRuntimeHint: "原生默认开启,Host base 固定值仍适用;挂载仅启动时捕获。保存只设置 desired,不会启动/停止提供商或取消当前会话;独立 Host 重启可能取消会话。",
64
- nativeRuntimeReadinessHint: "执行和 JSONL 存储由官方 Host 服务负责。此快照只报告原生执行准入就绪,不保证收件箱接受或任务完成。存储配置属于原生 JSONL 服务,不属于 DSMM。",
65
- unsetGroup: "Unset 整组——恢复继承",
64
+ nativeRuntimeReadinessHint: "任务进度可在会话中查看。",
65
+ unsetGroup: "整组使用默认配置",
66
66
  nativeRuntimeState: "已观测原生运行时", nativeRuntimeBinding: "已观测运行时组合", nativeRuntimeFence: "执行准入已就绪", nativeRuntimeRestart: "需要重启", nativeRuntimeStock: "官方 Host 运行时", nativeRuntimeUnavailable: "不可用/未知",
67
67
  "nativeRuntimeReason-explicit-composition-required": "Host 需要显式的原生运行时组合。", "nativeRuntimeReason-duplicate-provider": "存在重复原生 provider,无法确认就绪状态。", "nativeRuntimeReason-authority-not-ready": "原生执行权限尚未就绪。", "nativeRuntimeReason-disabled": "已保存的原生运行时为关闭。", "nativeRuntimeReason-pending-restart": "已保存 desired 与已挂载原生组合不同,等待独立重启。", "nativeRuntimeReason-scope-conflict": "原生 scope 所有权冲突,无法确认就绪状态。",
68
- saveGlobal: "保存全局配置", saveProfile: "保存当前配置覆盖", saving: "正在保存…", refresh: "刷新", discard: "丢弃并重载", dirty: "未保存", saved: "已保存",
68
+ saveGlobal: "保存", saveProfile: "保存", saving: "正在保存…", refresh: "刷新", discard: "丢弃并重载", dirty: "未保存", saved: "已保存",
69
69
  inherit: "继承", explicit: "覆盖", defaultPin: "固定为内建默认值", hostPin: "清除后仍有宿主固定值",
70
70
  globalSource: "全局", profileSource: "DSH 配置", defaultsSource: "内建默认", namedSource: "具名/会话", startupSource: "启动捕获", deploymentCapture: "部署捕获",
71
71
  desired: "合并后意图", startup: "启动挂载/捕获", next: "下一个根会话", session: "当前会话准入", noSession: "没有活动会话:准入状态未知。",
@@ -73,14 +73,14 @@ export const deploymentZh = {
73
73
  absent: "不存在", mixedSource: "混合来源", inspectorStale: "已保存状态,非草稿",
74
74
  pending: "等待独立重启", unknown: "未知", on: "开启", off: "关闭", state: "字段来源与实际生效状态", module: "Deepwork 子模块",
75
75
  versionObserved: "已观测元数据", versionAbsent: "未存储", versionUnknown: "版本不可用",
76
- advanced: "高级 JSON", advancedHint: "仅 schema 声明的键;省略为继承,数组整项替换。不填凭据或脚本,仅用已有提供商。",
76
+ advanced: "高级 JSON", advancedHint: "仅使用支持的字段,省略表示继承;数组整体替换继承值。请勿填写凭据或脚本。",
77
77
  invalid: "字段无效,请核对类型、范围与键;草稿保留。",
78
78
  conflict: "版本冲突,草稿保留。核对后丢弃并重载;刷新不自动合并。",
79
79
  unavailable: "作用域不可用,草稿保留;重连后刷新。",
80
80
  "not-owned": "只读:需要本地宿主已认证 operator 权限。",
81
81
  validation: "宿主拒绝配置,草稿保留;核对字段及合并约束。",
82
- transport: "连接中断,草稿保留;重连后刷新。",
83
- unconfirmed: "原生表单未确认保存结果,Host 可能已提交。请先刷新受影响的来源再决定是否重试;草稿已保留,不会自动重放。",
82
+ transport: "连接中断,结果未知,草稿已保留。请重连并刷新后再重试。",
83
+ unconfirmed: "保存结果未知,草稿已保留。请刷新后再重试。",
84
84
  namedIndependent: "设置中的 Deepwork Profiles 是独立的具名 JSONC 运行时资源编辑器。在此保存不会应用具名配置或选择其模型。",
85
85
  };
86
86
  /** Stable public field names stay visible alongside localized context. */
@@ -0,0 +1,29 @@
1
+ import type { DsmmHistoryRemote } from "../history-remote.js";
2
+ import type { HistoryChoices, HistoryFailure, HistoryPreview, HistoryStatus } from "../history-types.js";
3
+ export interface HistoryClientSnapshot {
4
+ sessionId: string | null;
5
+ phase: "disconnected" | "loading" | "ready" | "previewing" | "confirming" | "unknown";
6
+ status: HistoryStatus | null;
7
+ choices: HistoryChoices | null;
8
+ preview: HistoryPreview | null;
9
+ issue: HistoryFailure | null;
10
+ }
11
+ /** Connection/session generation fences for continuation only; native history and composer stay authoritative. */
12
+ export declare class HistoryContinuationController {
13
+ private scope;
14
+ private state;
15
+ private request;
16
+ private disposed;
17
+ private readonly listeners;
18
+ readonly getSnapshot: () => HistoryClientSnapshot;
19
+ readonly subscribe: (listener: () => void) => (() => void);
20
+ private publish;
21
+ bind(remote: DsmmHistoryRemote | undefined, connection: object | undefined, sessionId: string | null, owner?: object): void;
22
+ /** Observed compatibility only, never a pre-follow navigation or write-admission guard. */
23
+ get historyBrowsingAllowed(): boolean;
24
+ dispose(): void;
25
+ refresh(expected: HistoryClientSnapshot): Promise<void>;
26
+ preview(expected: HistoryClientSnapshot, preset: string, profileId: string | null): Promise<void>;
27
+ confirm(expected: HistoryClientSnapshot, processPending: boolean, acceptMigration: boolean): Promise<void>;
28
+ }
29
+ //# sourceMappingURL=history-controller.d.ts.map
@@ -0,0 +1,111 @@
1
+ import { parseHistoryChoices, parseHistoryFailure, parseHistoryPreview, parseHistoryResult, parseHistoryStatus } from "../history-codec.js";
2
+ function initial(sessionId = null) { return { sessionId, phase: sessionId === null ? "disconnected" : "loading", status: null, choices: null, preview: null, issue: null }; }
3
+ function value(result, parse) { if (result.ok)
4
+ return parse(result.value); throw result.error; }
5
+ function failure(error, confirming = false) {
6
+ if (error && typeof error === "object" && Reflect.get(error, "code") === "dsmm-history/refused") {
7
+ try {
8
+ return parseHistoryFailure(Reflect.get(error, "details"));
9
+ }
10
+ catch { /* Unknown wire errors cannot authorize a retry. */ }
11
+ }
12
+ return { code: "unavailable", storageEffects: confirming ? "may-have-committed" : "none" };
13
+ }
14
+ /** Connection/session generation fences for continuation only; native history and composer stay authoritative. */
15
+ export class HistoryContinuationController {
16
+ scope;
17
+ state = initial();
18
+ request;
19
+ disposed = false;
20
+ listeners = new Set();
21
+ getSnapshot = () => this.state;
22
+ subscribe = (listener) => { this.listeners.add(listener); return () => this.listeners.delete(listener); };
23
+ publish(next) { this.state = next; for (const listener of this.listeners)
24
+ listener(); }
25
+ bind(remote, connection, sessionId, owner) {
26
+ if (this.disposed)
27
+ return;
28
+ if (this.scope?.remote === remote && this.scope?.connection === connection && this.scope?.sessionId === sessionId && this.scope?.owner === owner)
29
+ return;
30
+ if (!this.scope && (!remote || !connection || !sessionId) && this.state.sessionId === sessionId && this.state.phase === "disconnected")
31
+ return;
32
+ this.scope = remote && connection && sessionId ? { remote, connection, sessionId, owner } : undefined;
33
+ const scope = this.scope;
34
+ this.request = undefined;
35
+ this.publish({ ...initial(sessionId), phase: this.scope ? "loading" : "disconnected" });
36
+ if (scope && this.scope === scope)
37
+ void this.refresh(this.state);
38
+ }
39
+ /** Observed compatibility only, never a pre-follow navigation or write-admission guard. */
40
+ get historyBrowsingAllowed() { return this.state.status?.compatibleHost === true; }
41
+ dispose() { this.scope = undefined; this.request = undefined; this.disposed = true; this.listeners.clear(); }
42
+ async refresh(expected) {
43
+ const scope = this.scope;
44
+ if (!scope || this.state !== expected || this.state.phase === "confirming")
45
+ return;
46
+ const request = this.request = {};
47
+ this.publish({ ...this.state, phase: "loading", preview: null, issue: null });
48
+ if (this.scope !== scope || this.request !== request)
49
+ return;
50
+ try {
51
+ const status = value(await scope.remote.describe(scope.sessionId), parseHistoryStatus);
52
+ if (this.scope !== scope || this.request !== request)
53
+ return;
54
+ if (status.sessionId !== scope.sessionId)
55
+ throw new TypeError("Mismatched history response");
56
+ const choices = status.execution === "authorization-required" ? value(await scope.remote.choices(), parseHistoryChoices) : null;
57
+ if (this.scope !== scope || this.request !== request)
58
+ return;
59
+ this.publish({ sessionId: scope.sessionId, phase: "ready", status, choices, preview: null, issue: null });
60
+ }
61
+ catch (error) {
62
+ if (this.scope === scope && this.request === request)
63
+ this.publish({ ...this.state, phase: "ready", issue: failure(error), preview: null });
64
+ }
65
+ }
66
+ async preview(expected, preset, profileId) {
67
+ const scope = this.scope;
68
+ if (!scope || this.state !== expected || expected.phase !== "ready" || expected.status?.execution !== "authorization-required" || !expected.status.compatibleHost)
69
+ return;
70
+ const request = this.request = {};
71
+ this.publish({ ...this.state, phase: "previewing", preview: null, issue: null });
72
+ if (this.scope !== scope || this.request !== request)
73
+ return;
74
+ try {
75
+ const preview = value(await scope.remote.preview(scope.sessionId, { sessionId: scope.sessionId, preset, profileId }), parseHistoryPreview);
76
+ if (this.scope !== scope || this.request !== request)
77
+ return;
78
+ if (preview.sessionId !== scope.sessionId || preview.candidate.preset.id !== preset || (preview.candidate.profile?.id ?? null) !== profileId)
79
+ throw new TypeError("Mismatched continuation proposal");
80
+ this.publish({ ...this.state, phase: "ready", preview });
81
+ }
82
+ catch (error) {
83
+ if (this.scope === scope && this.request === request)
84
+ this.publish({ ...this.state, phase: "ready", issue: failure(error), preview: null });
85
+ }
86
+ }
87
+ async confirm(expected, processPending, acceptMigration) {
88
+ const scope = this.scope, preview = expected.preview;
89
+ if (!scope || this.state !== expected || expected.phase !== "ready" || !preview || !processPending || preview.migrationRequired && !acceptMigration)
90
+ return;
91
+ const request = this.request = {};
92
+ this.publish({ ...this.state, phase: "confirming", issue: null });
93
+ if (this.scope !== scope || this.request !== request)
94
+ return;
95
+ try {
96
+ const receipt = value(await scope.remote.confirm(scope.sessionId, { sessionId: scope.sessionId, intentId: preview.intentId, processPending, acceptMigration }), parseHistoryResult);
97
+ if (this.scope !== scope || this.request !== request)
98
+ return;
99
+ if (receipt.sessionId !== scope.sessionId)
100
+ throw new TypeError("Mismatched continuation receipt");
101
+ this.publish({ ...this.state, phase: "ready", preview: null, status: { sessionId: scope.sessionId, readable: "readable", compatibleHost: true, execution: "active" } });
102
+ }
103
+ catch (error) {
104
+ if (this.scope !== scope || this.request !== request)
105
+ return;
106
+ const issue = failure(error, true);
107
+ this.publish({ ...this.state, phase: issue.storageEffects === "may-have-committed" ? "unknown" : "ready", preview: null, issue });
108
+ }
109
+ }
110
+ }
111
+ //# sourceMappingURL=history-controller.js.map
@@ -0,0 +1,11 @@
1
+ import type { Context } from "@deepseek-ai/cordis";
2
+ import type { LocaleRuntime } from "@deepseek-ai/dsh-client-locale/client";
3
+ import { HistoryContinuationController } from "./history-controller.js";
4
+ export declare function HistoryContinuationEntry({ controller, locale, sessionId }: {
5
+ controller: HistoryContinuationController;
6
+ locale: LocaleRuntime;
7
+ sessionId: string;
8
+ }): import("react").JSX.Element | null;
9
+ /** Read-only native binding observer; Host admission owns all history activation. */
10
+ export declare function registerHistoryContinuation(ctx: Context): void;
11
+ //# sourceMappingURL=history-entry.d.ts.map
@@ -0,0 +1,106 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useSyncExternalStore } from "react";
3
+ import { HistoryContinuation } from "./HistoryContinuation.js";
4
+ import { HistoryContinuationController } from "./history-controller.js";
5
+ import { historyLocales } from "./history-locales.js";
6
+ export function HistoryContinuationEntry({ controller, locale, sessionId }) {
7
+ const state = useSyncExternalStore(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
8
+ const language = useSyncExternalStore(listener => locale.subscribe(listener), () => locale.getSnapshot());
9
+ if (state.sessionId !== sessionId || state.status?.execution === "active" || state.phase === "loading" && state.status === null && state.issue === null)
10
+ return null;
11
+ return _jsx(HistoryContinuation, { controller: controller, locale: language.active === "zh" ? "zh" : "en" });
12
+ }
13
+ /** Read-only native binding observer; Host admission owns all history activation. */
14
+ export function registerHistoryContinuation(ctx) {
15
+ void ctx.inject(["remote.dsmmHistory"], historyCtx => {
16
+ const controller = new HistoryContinuationController(), remote = historyCtx.remote.dsmmHistory;
17
+ let disposed = false;
18
+ let connection, selected;
19
+ let blocks;
20
+ let held;
21
+ let watched, stopBlock;
22
+ const release = () => {
23
+ const owned = held;
24
+ held = undefined;
25
+ if (owned && blocks?.storeFor(owned.id) === owned.store && owned.store.getSnapshot() === owned.block)
26
+ blocks.set(owned.id, undefined);
27
+ };
28
+ const syncBlock = () => {
29
+ const state = controller.getSnapshot(), id = state.sessionId;
30
+ if (disposed || id === null || state.status?.execution === "active") {
31
+ stopBlock?.();
32
+ stopBlock = undefined;
33
+ watched = undefined;
34
+ release();
35
+ return;
36
+ }
37
+ if (held && held.id !== id)
38
+ release();
39
+ const text = historyLocales[historyCtx.locale.getLocale().active === "zh" ? "zh" : "en"];
40
+ const reason = state.phase === "disconnected" ? text.disconnected : state.phase === "unknown" ? text.unknown
41
+ : state.phase === "confirming" || state.status?.execution === "activating" ? text.confirming : text.reasons[state.issue?.code ?? (state.status?.compatibleHost === false ? "unsupported-host" : state.status?.reason) ?? "authorization-required"];
42
+ const store = blocks?.storeFor(id);
43
+ if (watched !== store) {
44
+ stopBlock?.();
45
+ watched = store;
46
+ stopBlock = store?.subscribe(syncBlock);
47
+ }
48
+ if (held && (held.store !== store || held.store.getSnapshot() !== held.block))
49
+ held = undefined;
50
+ if (held && (held.id !== id || held.block.reason !== reason))
51
+ release();
52
+ if (!blocks || !store || held)
53
+ return;
54
+ if (store.getSnapshot() !== undefined)
55
+ return;
56
+ const block = { reason };
57
+ held = { id, store, block };
58
+ blocks.set(id, block);
59
+ };
60
+ const update = () => {
61
+ if (disposed)
62
+ return;
63
+ const state = selected?.session.getSnapshot();
64
+ const id = selected && state?.sessionId === selected.sessionId && !state.removed ? selected.sessionId : null;
65
+ controller.bind(remote, connection?.generation.getSnapshot(), id, selected);
66
+ syncBlock();
67
+ };
68
+ historyCtx.effect(() => controller.subscribe(syncBlock));
69
+ historyCtx.effect(() => historyCtx.locale.subscribe(syncBlock));
70
+ historyCtx.effect(() => () => { disposed = true; stopBlock?.(); release(); controller.dispose(); }, "dsmm: history continuation owner");
71
+ historyCtx.slots.inject("conversation.input.dock", () => historyCtx.slots.register({
72
+ name: "conversation.input.dock", id: "dsmm-history-continuation", order: 10, inject: () => ({ controller, locale: historyCtx.locale }),
73
+ }, HistoryContinuationEntry));
74
+ void historyCtx.inject(["conversation"], conversationCtx => {
75
+ blocks = conversationCtx.conversation.blocks;
76
+ syncBlock();
77
+ conversationCtx.effect(() => () => { stopBlock?.(); stopBlock = undefined; watched = undefined; release(); blocks = undefined; }, "dsmm: history composer lifetime");
78
+ });
79
+ void historyCtx.inject(["connection"], connectionCtx => {
80
+ connection = connectionCtx.connection;
81
+ update();
82
+ connectionCtx.effect(() => connection.generation.subscribe(update));
83
+ connectionCtx.effect(() => () => { connection = undefined; update(); }, "dsmm: history connection lifetime");
84
+ });
85
+ void historyCtx.inject(["uiSession", "sessions"], sessionCtx => {
86
+ const source = sessionCtx.uiSession.adapter.current, sessions = sessionCtx.sessions;
87
+ let stop;
88
+ const observe = () => {
89
+ const id = source.getSnapshot().key;
90
+ const candidate = id === undefined ? undefined : sessions.binding(id);
91
+ const binding = candidate?.sessionId === id ? candidate : undefined;
92
+ if (binding !== selected) {
93
+ stop?.();
94
+ selected = binding;
95
+ stop = binding?.session.subscribe(update);
96
+ }
97
+ update();
98
+ };
99
+ observe();
100
+ sessionCtx.effect(() => source.subscribe(observe));
101
+ sessionCtx.effect(() => sessions.list.subscribe(observe));
102
+ sessionCtx.effect(() => () => { stop?.(); selected = undefined; update(); }, "dsmm: history native scope lifetime");
103
+ });
104
+ });
105
+ }
106
+ //# sourceMappingURL=history-entry.js.map