@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.
- package/cordis.patch.yml +9 -0
- package/docs/compatibility.md +10 -0
- package/docs/releasing.md +25 -65
- package/docs/roadmap.md +44 -2
- package/lib/client/ChildPermissions.d.ts +43 -0
- package/lib/client/ChildPermissions.js +100 -0
- package/lib/client/ChildrenPanel.d.ts +4 -1
- package/lib/client/ChildrenPanel.js +3 -3
- package/lib/client/DeploymentFields.d.ts +6 -2
- package/lib/client/DeploymentFields.js +8 -6
- package/lib/client/DeploymentPage.d.ts +4 -1
- package/lib/client/DeploymentPage.js +5 -4
- package/lib/client/HistoryContinuation.d.ts +7 -0
- package/lib/client/HistoryContinuation.js +22 -0
- package/lib/client/PermissionPanelEntry.d.ts +8 -0
- package/lib/client/PermissionPanelEntry.js +11 -0
- package/lib/client/PermissionsPanel.d.ts +3 -1
- package/lib/client/PermissionsPanel.js +3 -2
- package/lib/client/ProfilesSection.js +3 -3
- package/lib/client/RoleAvailability.js +1 -1
- package/lib/client/SessionProfiles.js +21 -18
- package/lib/client/TemporaryPermissions.d.ts +21 -0
- package/lib/client/TemporaryPermissions.js +94 -0
- package/lib/client/children-locales.d.ts +4 -4
- package/lib/client/controller.d.ts +17 -0
- package/lib/client/controller.js +101 -18
- package/lib/client/deployment-locales.js +26 -26
- package/lib/client/history-controller.d.ts +29 -0
- package/lib/client/history-controller.js +111 -0
- package/lib/client/history-entry.d.ts +11 -0
- package/lib/client/history-entry.js +106 -0
- package/lib/client/history-locales.d.ts +95 -0
- package/lib/client/history-locales.js +41 -0
- package/lib/client/index.js +16 -3
- package/lib/client/locales.d.ts +6 -0
- package/lib/client/locales.js +104 -92
- package/lib/client/permission-locales.d.ts +26 -0
- package/lib/client/permission-locales.js +55 -35
- package/lib/client/temporary-permission-client.d.ts +20 -0
- package/lib/client/temporary-permission-client.js +52 -0
- package/lib/client/temporary-permission-entry.d.ts +6 -0
- package/lib/client/temporary-permission-entry.js +56 -0
- package/lib/client.js +3881 -1981
- package/lib/history-candidates.d.ts +30 -0
- package/lib/history-candidates.js +176 -0
- package/lib/history-codec.d.ts +11 -0
- package/lib/history-codec.js +102 -0
- package/lib/history-contract.d.ts +44 -0
- package/lib/history-contract.js +2 -0
- package/lib/history-controller.d.ts +42 -0
- package/lib/history-controller.js +329 -0
- package/lib/history-policy.d.ts +4 -0
- package/lib/history-policy.js +8 -0
- package/lib/history-remote.d.ts +28 -0
- package/lib/history-remote.js +17 -0
- package/lib/history-rpc.d.ts +24 -0
- package/lib/history-rpc.js +136 -0
- package/lib/history-support.d.ts +15 -0
- package/lib/history-support.js +21 -0
- package/lib/history-types.d.ts +67 -0
- package/lib/history-types.js +2 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +24 -6
- package/lib/native-admission.d.ts +21 -0
- package/lib/native-admission.js +206 -16
- package/lib/permission-child-control.d.ts +36 -0
- package/lib/permission-child-control.js +164 -0
- package/lib/permission-control.d.ts +2 -0
- package/lib/permission-control.js +7 -0
- package/lib/permission-controller.js +2 -2
- package/lib/permission-exec-argv.d.ts +32 -0
- package/lib/permission-exec-argv.js +171 -0
- package/lib/permission-fs-search.js +2 -1
- package/lib/permission-fs.js +2 -1
- package/lib/permission-native-rules.js +3 -3
- package/lib/permission-temporary-files.d.ts +19 -0
- package/lib/permission-temporary-files.js +248 -0
- package/lib/permission-temporary-grants.d.ts +106 -0
- package/lib/permission-temporary-grants.js +198 -0
- package/lib/permission-temporary-install.d.ts +25 -0
- package/lib/permission-temporary-install.js +86 -0
- package/lib/permission-temporary-remote.d.ts +19 -0
- package/lib/permission-temporary-remote.js +75 -0
- package/lib/permission-temporary-rpc.d.ts +37 -0
- package/lib/permission-temporary-rpc.js +154 -0
- package/lib/permission-temporary-types.d.ts +47 -0
- package/lib/permission-temporary-types.js +2 -0
- package/lib/permission-temporary-web.d.ts +11 -0
- package/lib/permission-temporary-web.js +154 -0
- package/lib/permission-web.js +2 -1
- package/lib/preset-skills.d.ts +1 -1
- package/lib/preset-skills.js +2 -2
- package/lib/profile-rpc.js +2 -0
- package/lib/profile-runtime.d.ts +12 -1
- package/lib/profile-runtime.js +122 -10
- package/lib/profile-store.d.ts +2 -2
- package/lib/profile-store.js +8 -1
- package/lib/profile-types.d.ts +1 -0
- package/lib/role-invocation.d.ts +1 -1
- package/lib/role-invocation.js +2 -2
- package/lib/role-subagents.js +16 -3
- package/lib/skills.d.ts +1 -0
- package/lib/skills.js +5 -1
- package/package.json +41 -33
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-api-gateway@0.2.1-rc.2.patch +13291 -0
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-api-remotes@0.2.1-rc.2.patch +9133 -0
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-client-ui-approval@0.2.1-rc.2.patch +156 -0
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-subagent@0.2.1-rc.2.patch +3546 -0
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-user-approval@0.2.1-rc.2.patch +431 -0
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-web@0.2.1-rc.2.patch +119 -0
- package/patches/dsh-approval-settlement/README.md +41 -0
- package/patches/dsh-approval-settlement/metadata.json +10 -0
- package/patches/dsh-session-activation/@deepseek-ai__dsh-agent-loop@0.2.1-rc.2.patch +383 -0
- package/patches/dsh-session-activation/@deepseek-ai__dsh-agent-preset-registry@0.2.1-rc.2.patch +55 -0
- package/patches/dsh-session-activation/@deepseek-ai__dsh-api-session-controller@0.2.1-rc.2.patch +16673 -0
- package/patches/dsh-session-activation/@deepseek-ai__dsh-client-ui-subagent@0.2.1-rc.2.patch +29 -0
- package/patches/dsh-session-activation/@deepseek-ai__dsh-client-ui-workspace@0.2.1-rc.2.patch +196 -0
- package/patches/dsh-session-activation/@deepseek-ai__dsh-session-persistence-jsonl@0.2.1-rc.2.patch +35 -0
- package/patches/dsh-session-activation/@deepseek-ai__dsh-session-persistence@0.2.1-rc.2.patch +40 -0
package/lib/client/controller.js
CHANGED
|
@@ -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
|
|
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,
|
|
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
|
-
|
|
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
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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
|
|
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: "
|
|
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: "
|
|
23
|
-
unsetGroup: "
|
|
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
|
|
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: "
|
|
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: "
|
|
41
|
-
unconfirmed: "
|
|
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: "
|
|
48
|
+
profile: "当前 DSH 配置覆盖", profileHint: "仅影响此 DSH 配置。未设置字段使用全局与宿主默认值;原生运行时使用宿主默认值。",
|
|
49
49
|
profileUnavailable: "不可用",
|
|
50
|
-
unavailableForm: "
|
|
50
|
+
unavailableForm: "此 DSH 配置只读,请重连并刷新以检查编辑权限。",
|
|
51
51
|
ceiling: "Deepwork 总开关仅全局可改;配置和会话模式不能突破已捕获上限。",
|
|
52
52
|
hostUnknown: "宿主整包状态:未知(独立开关)。",
|
|
53
|
-
boundaries: "
|
|
53
|
+
boundaries: "保存的设置供新会话使用。标注「需重启」的更改需另行重启宿主,可能取消会话。",
|
|
54
54
|
core: "Core 核心配置", coreHint: "Core 所有的 desired 意图配置。模型参数透传为普通配置,非子插件;权限控制 enabled 仅启动时捕获。保存不改变当前会话准入;下方可检查意图、启动与准入值,不可用的准入仍为未知。",
|
|
55
|
-
modelParametersHint: "
|
|
55
|
+
modelParametersHint: "关闭后停止发送自定义参数,并使用原生推理默认值;已保存的值和所选模型不变。",
|
|
56
56
|
permissionControlHint: "权限控制挂载仅启动时捕获。保存配置不证明运行时覆盖,也不移除当前保护;Root 规则在权限模块内保持独立权限。",
|
|
57
|
-
modules: "配置模块", scope: "
|
|
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: "
|
|
60
|
+
noModuleFields: "此范围内没有可编辑的设置。",
|
|
61
61
|
leaveDraft: "仍有未保存或无效草稿,请选择离开方式;不会自动保存或丢弃。", continueEditing: "继续编辑", keepDraft: "保留草稿并返回", discardDraft: "放弃草稿并离开",
|
|
62
|
-
rootRules: "
|
|
62
|
+
rootRules: "会话权限规则", rootRulesHint: "规则单独保存。请选择已打开的主会话,并确认有编辑权限且权限已同步。", rootRulesUnavailable: "权限规则不可用,请重连后刷新。",
|
|
63
63
|
nativeRuntimeHint: "原生默认开启,Host base 固定值仍适用;挂载仅启动时捕获。保存只设置 desired,不会启动/停止提供商或取消当前会话;独立 Host 重启可能取消会话。",
|
|
64
|
-
nativeRuntimeReadinessHint: "
|
|
65
|
-
unsetGroup: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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
|