@lincyaw/dsh 0.2.0-rc.4 → 0.2.0-rc.41
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/build/client.mjs +0 -2
- package/build/dist/client.js +298 -297
- package/build/dist/client.json +47 -36
- package/package.json +8 -8
- package/src/client/agent-requests.ts +47 -0
- package/src/client/contract.ts +0 -6
- package/src/client/dsh.d.ts +12 -0
- package/src/client/index.tsx +0 -2
- package/src/client/messages.ts +2 -10
- package/src/client/styles.css +0 -42
- package/src/node/bindings.ts +88 -6
- package/src/node/context.ts +5 -4
- package/src/node/dsh-types.ts +31 -1
- package/src/node/launch.ts +10 -5
- package/src/node/policy.ts +5 -0
- package/src/node/routes.ts +7 -1
- package/src/node/service.ts +3 -0
- package/src/node/tools.ts +49 -5
- package/src/node/turns.ts +11 -8
- package/src/client/mascot.tsx +0 -37
package/build/dist/client.json
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"inputs": [
|
|
3
|
-
"../design/src/assets/mascot/cat.png",
|
|
4
|
-
"../design/src/assets/mascot/cat-light.png",
|
|
5
|
-
"../design/src/assets/mascot/sheet.ts",
|
|
6
|
-
"../design/src/assets/mascot.ts",
|
|
7
|
-
"../design/src/icons.ts",
|
|
8
|
-
"../design/src/tokens.ts",
|
|
9
|
-
"../design/src/assets/brand.ts",
|
|
10
|
-
"../design/src/index.ts",
|
|
11
|
-
"../workbench/src/base-controls.tsx",
|
|
12
|
-
"../workbench/src/mascot-preference.ts",
|
|
13
|
-
"../workbench/src/sortable-list.tsx",
|
|
14
|
-
"../workbench/src/components.tsx",
|
|
15
3
|
"../kernel/src/contracts/service.ts",
|
|
16
4
|
"../kernel/src/contracts/agent.ts",
|
|
17
5
|
"../kernel/src/contracts/authoring.ts",
|
|
6
|
+
"../kernel/src/contracts/capture.ts",
|
|
18
7
|
"../kernel/src/contracts/document-reads.ts",
|
|
19
8
|
"../kernel/src/contracts/anchors.ts",
|
|
20
9
|
"../kernel/src/contracts/checks.ts",
|
|
@@ -49,17 +38,21 @@
|
|
|
49
38
|
"../kernel/src/contracts/projects.ts",
|
|
50
39
|
"../kernel/src/contracts/document-image.ts",
|
|
51
40
|
"../kernel/src/contracts.ts",
|
|
41
|
+
"../kernel/src/random-uuid.ts",
|
|
42
|
+
"../kernel/src/access.ts",
|
|
43
|
+
"../kernel/src/document-places.ts",
|
|
44
|
+
"../kernel/src/document-comments.ts",
|
|
52
45
|
"../kernel/src/document-operations.ts",
|
|
53
46
|
"../kernel/src/document-schema.ts",
|
|
47
|
+
"../kernel/src/document-narrations.ts",
|
|
54
48
|
"../kernel/src/authoring.ts",
|
|
55
49
|
"../kernel/src/document-pages.ts",
|
|
56
50
|
"../kernel/src/fingerprint.ts",
|
|
57
51
|
"../kernel/src/document-reads.ts",
|
|
58
52
|
"../kernel/src/document-voices.ts",
|
|
59
53
|
"../kernel/src/document-colors.ts",
|
|
60
|
-
"../kernel/src/access.ts",
|
|
61
|
-
"../kernel/src/document-comments.ts",
|
|
62
54
|
"../kernel/src/document-caption-timings.ts",
|
|
55
|
+
"../kernel/src/document-caption-scale.ts",
|
|
63
56
|
"../kernel/src/parameters.ts",
|
|
64
57
|
"../kernel/src/document.ts",
|
|
65
58
|
"../kernel/src/document-components.ts",
|
|
@@ -74,6 +67,7 @@
|
|
|
74
67
|
"../kernel/src/events.ts",
|
|
75
68
|
"../kernel/src/execution.ts",
|
|
76
69
|
"../kernel/src/git.ts",
|
|
70
|
+
"../kernel/src/escape-html.ts",
|
|
77
71
|
"../kernel/src/html.ts",
|
|
78
72
|
"../kernel/src/requests.ts",
|
|
79
73
|
"../kernel/src/step-keys.ts",
|
|
@@ -83,9 +77,13 @@
|
|
|
83
77
|
"../kernel/src/kernel.ts",
|
|
84
78
|
"../kernel/src/locale.ts",
|
|
85
79
|
"../kernel/src/lock.ts",
|
|
80
|
+
"../kernel/src/myst-marks.ts",
|
|
86
81
|
"../kernel/src/lower-myst.ts",
|
|
87
|
-
"../kernel/src/keyboard.ts",
|
|
88
82
|
"../kernel/src/preview-frame.ts",
|
|
83
|
+
"../kernel/src/keyboard.ts",
|
|
84
|
+
"../kernel/src/preview-frame-connect.ts",
|
|
85
|
+
"../kernel/src/stale-module.ts",
|
|
86
|
+
"../kernel/src/embed.ts",
|
|
89
87
|
"../kernel/src/preview-edit.ts",
|
|
90
88
|
"../kernel/src/props.ts",
|
|
91
89
|
"../kernel/src/reading.ts",
|
|
@@ -108,44 +106,55 @@
|
|
|
108
106
|
"../kernel/src/jupyter-kernel.ts",
|
|
109
107
|
"../kernel/src/preview-events.ts",
|
|
110
108
|
"../kernel/src/index.ts",
|
|
109
|
+
"../workbench/src/workbench-state.ts",
|
|
110
|
+
"../workbench/src/document-return-point.ts",
|
|
111
|
+
"../workbench/src/document-editor/table-identities.ts",
|
|
112
|
+
"../workbench/src/document-editor/selection.ts",
|
|
113
|
+
"../workbench/src/shortcuts.ts",
|
|
114
|
+
"../workbench/src/messages.ts",
|
|
115
|
+
"../workbench/src/document-editing.ts",
|
|
116
|
+
"../workbench/src/workspace-client.ts",
|
|
117
|
+
"../workbench/src/sha256.ts",
|
|
118
|
+
"../workbench/src/recording-adoption.ts",
|
|
119
|
+
"../workbench/src/document-voices.ts",
|
|
120
|
+
"../workbench/src/component-properties.ts",
|
|
121
|
+
"../workbench/src/caption-timing.ts",
|
|
122
|
+
"../workbench/src/step-production.ts",
|
|
123
|
+
"../workbench/src/document-timing-drafts.ts",
|
|
124
|
+
"../workbench/src/caption-timing-drafts.ts",
|
|
125
|
+
"../workbench/src/document-production.ts",
|
|
126
|
+
"../design/src/icons.ts",
|
|
127
|
+
"../design/src/tokens.ts",
|
|
128
|
+
"../design/src/assets/brand.ts",
|
|
129
|
+
"../design/src/index.ts",
|
|
130
|
+
"../workbench/src/base-controls.tsx",
|
|
131
|
+
"../workbench/src/sortable-list.tsx",
|
|
132
|
+
"../workbench/src/components.tsx",
|
|
111
133
|
"../workbench/src/schema-form/context.ts",
|
|
112
134
|
"../workbench/src/schema-form/fields.tsx",
|
|
113
135
|
"../workbench/src/schema-form/templates.tsx",
|
|
114
136
|
"../workbench/src/schema-form/widgets.tsx",
|
|
115
137
|
"../workbench/src/schema-form/validator.ts",
|
|
116
138
|
"../workbench/src/schema-form/PmSchemaForm.tsx",
|
|
117
|
-
"../workbench/src/step-production.ts",
|
|
118
139
|
"../workbench/src/StepProductionEditor.tsx",
|
|
119
140
|
"../workbench/src/media-messages.ts",
|
|
120
141
|
"../workbench/src/media-time.ts",
|
|
121
142
|
"../workbench/src/MediaClipEditor.tsx",
|
|
122
|
-
"../workbench/src/shortcuts.ts",
|
|
123
|
-
"../workbench/src/messages.ts",
|
|
124
143
|
"../workbench/src/context.tsx",
|
|
125
144
|
"../workbench/src/places.ts",
|
|
126
145
|
"../workbench/src/preview.ts",
|
|
127
|
-
"../workbench/src/caption-timing.ts",
|
|
128
146
|
"../workbench/src/document-draft-store.ts",
|
|
129
147
|
"../workbench/src/document-editor/comment-drafts.ts",
|
|
130
148
|
"../workbench/src/component-property-drafts.ts",
|
|
131
|
-
"../workbench/src/component-properties.ts",
|
|
132
149
|
"../workbench/src/authoring-draft-fragment.ts",
|
|
133
150
|
"../workbench/src/document-editor/comment-draft-inspection.ts",
|
|
134
151
|
"../workbench/src/document-editor/comment-draft-actions.ts",
|
|
135
152
|
"../workbench/src/component-draft-inspection.ts",
|
|
136
153
|
"../workbench/src/component-draft-actions.ts",
|
|
137
|
-
"../workbench/src/workspace-client.ts",
|
|
138
154
|
"../workbench/src/document-drafts.ts",
|
|
139
155
|
"../workbench/src/document-session.ts",
|
|
140
|
-
"../workbench/src/recording-adoption.ts",
|
|
141
156
|
"../workbench/src/transcription-session.ts",
|
|
142
157
|
"../workbench/src/audio-recording.ts",
|
|
143
|
-
"../workbench/src/document-return-point.ts",
|
|
144
|
-
"../workbench/src/document-editor/table-identities.ts",
|
|
145
|
-
"../workbench/src/document-editor/selection.ts",
|
|
146
|
-
"../workbench/src/document-voices.ts",
|
|
147
|
-
"../workbench/src/document-timing-drafts.ts",
|
|
148
|
-
"../workbench/src/caption-timing-drafts.ts",
|
|
149
158
|
"../workbench/src/document-preview.ts",
|
|
150
159
|
"../workbench/src/diagnostics.ts",
|
|
151
160
|
"../workbench/src/history.ts",
|
|
@@ -159,10 +168,6 @@
|
|
|
159
168
|
"../workbench/src/panels/ExportPanel.tsx",
|
|
160
169
|
"../workbench/src/panels/HistoryPanel.tsx",
|
|
161
170
|
"../workbench/src/preview-pool.ts",
|
|
162
|
-
"../workbench/src/document-editor/inline.ts",
|
|
163
|
-
"../workbench/src/document-editor/rich-text.ts",
|
|
164
|
-
"../workbench/src/document-editor/projection.ts",
|
|
165
|
-
"../workbench/src/panels/ChangeTrail.tsx",
|
|
166
171
|
"../workbench/src/panels/PreviewPanel.tsx",
|
|
167
172
|
"../workbench/src/document-editor/blocknote-messages.ts",
|
|
168
173
|
"../workbench/src/document-editor/colors.ts",
|
|
@@ -172,15 +177,19 @@
|
|
|
172
177
|
"../workbench/src/document-editor/schema.tsx",
|
|
173
178
|
"../workbench/src/document-editor/file-input.ts",
|
|
174
179
|
"../workbench/src/document-editor/clipboard.ts",
|
|
180
|
+
"../workbench/src/document-editor/page-body.ts",
|
|
175
181
|
"../workbench/src/document-editor/authoring.tsx",
|
|
182
|
+
"../workbench/src/document-editor/inline.ts",
|
|
183
|
+
"../workbench/src/document-editor/rich-text.ts",
|
|
176
184
|
"../workbench/src/document-editor/comments.ts",
|
|
185
|
+
"../workbench/src/document-editor/component-label.ts",
|
|
177
186
|
"../workbench/src/document-editor/DocumentComments.tsx",
|
|
178
187
|
"../workbench/src/document-editor/NewCommentDrafts.tsx",
|
|
179
188
|
"../workbench/src/document-editor/BlockNoteSurface.tsx",
|
|
180
|
-
"../workbench/src/document-editor/focus.ts",
|
|
181
|
-
"../workbench/src/document-editor/narration.ts",
|
|
182
189
|
"../workbench/src/document-editor/narration-schema.tsx",
|
|
183
190
|
"../workbench/src/document-editor/NarrationEditor.tsx",
|
|
191
|
+
"../workbench/src/document-editor/focus.ts",
|
|
192
|
+
"../workbench/src/document-editor/narration.ts",
|
|
184
193
|
"../workbench/src/document-editor/DocumentStepNarration.tsx",
|
|
185
194
|
"../workbench/src/production-messages.ts",
|
|
186
195
|
"../workbench/src/voice-drafts.ts",
|
|
@@ -196,6 +205,7 @@
|
|
|
196
205
|
"../workbench/src/panels/DocumentVoiceDialog.tsx",
|
|
197
206
|
"../workbench/src/panels/DocumentVoiceField.tsx",
|
|
198
207
|
"../workbench/src/panels/VoiceoverDialog.tsx",
|
|
208
|
+
"../workbench/src/panels/ProductionCaptionSize.tsx",
|
|
199
209
|
"../workbench/src/caption-timing-messages.ts",
|
|
200
210
|
"../workbench/src/panels/ProductionCaptionTiming.tsx",
|
|
201
211
|
"../workbench/src/audio-waveform.ts",
|
|
@@ -212,6 +222,8 @@
|
|
|
212
222
|
"../workbench/src/panels/ProductionPanel.tsx",
|
|
213
223
|
"../workbench/src/panels/PageRenameDialog.tsx",
|
|
214
224
|
"../workbench/src/panels/PageDeleteDialog.tsx",
|
|
225
|
+
"../workbench/src/document-editor/projection.ts",
|
|
226
|
+
"../workbench/src/document-editor/insertion-place.ts",
|
|
215
227
|
"../workbench/src/document-editor/DocumentEditor.tsx",
|
|
216
228
|
"../workbench/src/document-editor/block-preview-messages.ts",
|
|
217
229
|
"../workbench/src/document-editor/DocumentBlockFallback.tsx",
|
|
@@ -219,13 +231,13 @@
|
|
|
219
231
|
"../workbench/src/component-property-messages.ts",
|
|
220
232
|
"../workbench/src/document-editor/ComponentMaterials.tsx",
|
|
221
233
|
"../workbench/src/document-editor/ComponentPropertiesDialog.tsx",
|
|
234
|
+
"../workbench/src/document-editor/PlaceComment.tsx",
|
|
222
235
|
"../workbench/src/document-editor/DocumentBlockPreview.tsx",
|
|
223
236
|
"../workbench/src/panels/SourceDocumentPanel.tsx",
|
|
224
237
|
"../workbench/src/panels/DocumentNarrationPanel.tsx",
|
|
225
238
|
"../workbench/src/panels/DocumentView.tsx",
|
|
226
239
|
"../workbench/src/panels/HomePanel.tsx",
|
|
227
240
|
"../workbench/src/approvals.tsx",
|
|
228
|
-
"../workbench/src/assistant-mascot.ts",
|
|
229
241
|
"../workbench/src/speech-settings-messages.ts",
|
|
230
242
|
"../workbench/src/panels/SpeechSettingsPanel.tsx",
|
|
231
243
|
"../workbench/src/authoring-client.ts",
|
|
@@ -238,7 +250,6 @@
|
|
|
238
250
|
"src/client/settings-opener.ts",
|
|
239
251
|
"src/client/messages.ts",
|
|
240
252
|
"src/client/brand.tsx",
|
|
241
|
-
"src/client/mascot.tsx",
|
|
242
253
|
"src/client/document-context.ts",
|
|
243
254
|
"src/client/observable.ts",
|
|
244
255
|
"src/client/runtime-diagnostics.tsx",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lincyaw/dsh",
|
|
3
|
-
"version": "0.2.0-rc.
|
|
3
|
+
"version": "0.2.0-rc.41",
|
|
4
4
|
"description": "Presmium's bundle for DeepSeek Harness: the workbench of presmium studio, its host side (Presmium's tools, approvals, document context, skills and routes) and its client side (the root layout and the workbench's panels, precompiled) (experimental)",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -73,7 +73,6 @@
|
|
|
73
73
|
"skills": [
|
|
74
74
|
"presmium-animate",
|
|
75
75
|
"presmium-author",
|
|
76
|
-
"presmium-present",
|
|
77
76
|
"presmium-develop"
|
|
78
77
|
],
|
|
79
78
|
"generated": [
|
|
@@ -83,12 +82,13 @@
|
|
|
83
82
|
"dependencies": {
|
|
84
83
|
"eventsource": "3.0.7",
|
|
85
84
|
"jiti": "^2.7.0",
|
|
85
|
+
"node-addon-require-builtin": "0.1.9",
|
|
86
86
|
"ws": "8.22.0",
|
|
87
87
|
"zod": "4.4.3",
|
|
88
|
-
"@lincyaw/cli": "1.0.0-rc.
|
|
89
|
-
"@lincyaw/
|
|
90
|
-
"@lincyaw/
|
|
91
|
-
"@lincyaw/
|
|
88
|
+
"@lincyaw/cli": "1.0.0-rc.42",
|
|
89
|
+
"@lincyaw/kernel": "1.0.0-rc.42",
|
|
90
|
+
"@lincyaw/skills": "1.0.0-rc.42",
|
|
91
|
+
"@lincyaw/mcp": "1.0.0-rc.42"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
94
|
"@deepseek-ai/dsh": "0.2.1-alpha.4"
|
|
@@ -104,8 +104,8 @@
|
|
|
104
104
|
"react": "18.3.1",
|
|
105
105
|
"react-dom": "18.3.1",
|
|
106
106
|
"react-resizable-panels": "^4.14.5",
|
|
107
|
-
"@lincyaw/design": "1.0.0-rc.
|
|
108
|
-
"@lincyaw/workbench": "0.2.0-rc.
|
|
107
|
+
"@lincyaw/design": "1.0.0-rc.42",
|
|
108
|
+
"@lincyaw/workbench": "0.2.0-rc.42"
|
|
109
109
|
},
|
|
110
110
|
"scripts": {}
|
|
111
111
|
}
|
|
@@ -9,6 +9,9 @@ import { CLIENT_MESSAGES } from './messages.ts'
|
|
|
9
9
|
* the repair of the selected document's diagnostics. Each is prompted on the session after its document context is
|
|
10
10
|
* set, and the conversation is shown. Without a usable model nothing is sent: the conversation is shown, where the
|
|
11
11
|
* composer offers to set one up, and the request answers with that in the author's terms.
|
|
12
|
+
*
|
|
13
|
+
* Drafts (the slash menu's animation request) go into the session's composer instead, for the author to finish and
|
|
14
|
+
* send. Without a model the composer's takeover shows over the draft, which waits beneath it.
|
|
12
15
|
*/
|
|
13
16
|
export function registerAgentRequests(ctx: DshClientContext, workbench: Workbench, setup: AssistantSetup): void {
|
|
14
17
|
ctx.inject(['sessions', 'layout'], inner => inner.effect(() => {
|
|
@@ -61,4 +64,48 @@ export function registerAgentRequests(ctx: DshClientContext, workbench: Workbenc
|
|
|
61
64
|
update()
|
|
62
65
|
return () => { off(); offRequests?.() }
|
|
63
66
|
}, 'presmium: hand the author\'s requests to the current session'))
|
|
67
|
+
|
|
68
|
+
ctx.inject(['sessions', 'layout', 'conversation'], inner => inner.effect(() => {
|
|
69
|
+
let offDrafts: (() => void) | undefined
|
|
70
|
+
let active: DshSessionBinding | undefined
|
|
71
|
+
const update = () => {
|
|
72
|
+
const row = mainViewAgentSession(inner.sessions.list.getSnapshot().byId)
|
|
73
|
+
const binding = row && inner.sessions.binding(row.id)
|
|
74
|
+
if (binding === active) return
|
|
75
|
+
offDrafts?.()
|
|
76
|
+
offDrafts = undefined
|
|
77
|
+
active = binding
|
|
78
|
+
if (!row || !binding) return
|
|
79
|
+
// Whatever the author wrote stays above the draft; a draft put here and not changed since is replaced by the next.
|
|
80
|
+
let last: { kept: string, text: string } | undefined
|
|
81
|
+
offDrafts = workbench.onAgentDraft(draft => {
|
|
82
|
+
if (active !== binding || inner.sessions.binding(row.id) !== binding) throw new Error('no-conversation')
|
|
83
|
+
const input = inner.conversation.input.for(binding.ctx)
|
|
84
|
+
const { draft: current, phase } = input.state.getSnapshot()
|
|
85
|
+
if (phase !== 'plain') throw new Error('no-conversation')
|
|
86
|
+
const kept = last && current.trim() === (last.kept + last.text).trim() ? last.kept : current.trim() ? `${current.trimEnd()}\n` : ''
|
|
87
|
+
const text = kept + draft.text
|
|
88
|
+
last = { kept, text: draft.text }
|
|
89
|
+
input.setDraft(text)
|
|
90
|
+
inner.layout.selectPanel(null)
|
|
91
|
+
// The composer takes the keyboard once the conversation is shown (under the takeover it stays where it was).
|
|
92
|
+
// Focus brings back the caret the composer last held, which the draft does not move: the browser's selection
|
|
93
|
+
// goes to the end of the focused editor, and the composer's editor follows it.
|
|
94
|
+
const frame = (then: () => void) => requestAnimationFrame(() => requestAnimationFrame(then))
|
|
95
|
+
if (setup.readiness.getSnapshot() !== 'missing') frame(() => {
|
|
96
|
+
input.focus()
|
|
97
|
+
frame(() => {
|
|
98
|
+
const editor = document.activeElement
|
|
99
|
+
if (!(editor instanceof HTMLElement) || !editor.isContentEditable || input.state.getSnapshot().draft !== text) return
|
|
100
|
+
const selection = getSelection()
|
|
101
|
+
selection?.selectAllChildren(editor)
|
|
102
|
+
selection?.collapseToEnd()
|
|
103
|
+
})
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
const off = inner.sessions.list.subscribe(update)
|
|
108
|
+
update()
|
|
109
|
+
return () => { off(); offDrafts?.() }
|
|
110
|
+
}, 'presmium: put the author\'s drafts in the current session\'s composer'))
|
|
64
111
|
}
|
package/src/client/contract.ts
CHANGED
|
@@ -23,12 +23,6 @@ export const ONBOARDING = { slot: 'settings.onboarding', steps: ['welcome-notice
|
|
|
23
23
|
*/
|
|
24
24
|
export const ASSISTANT_SLOTS = ['conversation.composer', { name: 'conversation.chat.node', key: 'turn-error' }] as const
|
|
25
25
|
|
|
26
|
-
/** Where the kitten sits beside the conversation: an added entry (its own id) among the session header's actions. */
|
|
27
|
-
export const MASCOT_SLOT = { name: 'conversation.session.header.actions', id: 'presmium-mascot' } as const
|
|
28
|
-
|
|
29
|
-
/** Where the author turns the kitten on or off: an added row (its own id) in Settings → General. */
|
|
30
|
-
export const MASCOT_SETTING = { name: 'settings.general.item', id: 'presmium-mascot' } as const
|
|
31
|
-
|
|
32
26
|
/**
|
|
33
27
|
* Settings → Models, and when the model catalog is read again: on the Host's events that change what can be routed,
|
|
34
28
|
* whenever the window regains focus, and on a slow poll while no model is usable (Settings is a modal over this page,
|
package/src/client/dsh.d.ts
CHANGED
|
@@ -125,6 +125,17 @@ interface DshSessionBinding {
|
|
|
125
125
|
beginSubmission(input: { mode: 'queue', text: string, attachments: [] }): { requestId: string, abandon(): void }
|
|
126
126
|
prompt(content: { type: 'text', text: string }[], mode: 'queue', signal: AbortSignal | undefined, requestId: string): Promise<{ ok: true, value: { accepted: true } } | { ok: false, error: { code: string, message: string } }>
|
|
127
127
|
}
|
|
128
|
+
/** The session's scope, which addresses its composer through `conversation.input`. */
|
|
129
|
+
ctx: unknown
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** A session's composer (`SessionInput` of `@deepseek-ai/dsh-client-ui-conversation`), as far as it is used here. */
|
|
133
|
+
interface DshSessionInput {
|
|
134
|
+
/** Replaces the whole draft with plain text; the caret lands at its end. */
|
|
135
|
+
setDraft(text: string): void
|
|
136
|
+
/** Gives the keyboard back to the composer, with the caret it last held. */
|
|
137
|
+
focus(): void
|
|
138
|
+
readonly state: DshObservable<{ draft: string, phase: 'plain' | 'adjudicating' | 'claimed' | 'submitting' }>
|
|
128
139
|
}
|
|
129
140
|
|
|
130
141
|
interface DshClientContext {
|
|
@@ -141,6 +152,7 @@ interface DshClientContext {
|
|
|
141
152
|
sidebarRight: { active(): { id: string, kind: string, contentId: string } | undefined, close(id: string): void, isExpanded(): boolean, toggleExpanded(): void }
|
|
142
153
|
layout: { selectPanel(id: string | null): void }
|
|
143
154
|
sessions: { list: DshObservable<{ byId: Record<string, { id: string, cwd?: string, retainedBy: { mainView?: number } }> }>, binding(id: string): DshSessionBinding | undefined }
|
|
155
|
+
conversation: { input: { for(scope: unknown): DshSessionInput } }
|
|
144
156
|
uiWorkspace: { openWorkspace(id: string, beforeOpen?: (sessionId: string) => void): Promise<void>, startSession(id?: string): void }
|
|
145
157
|
workspaces: { list: DshObservable<{ items: readonly { workspaceId: string, path: string }[] }> }
|
|
146
158
|
configForms: {
|
package/src/client/index.tsx
CHANGED
|
@@ -5,7 +5,6 @@ import { registerAuthorSettings } from './author-settings.ts'
|
|
|
5
5
|
import { registerSpeechSettings } from './speech-settings.tsx'
|
|
6
6
|
import { openSpeechSettings } from './settings-opener.ts'
|
|
7
7
|
import { registerBrand } from './brand.tsx'
|
|
8
|
-
import { registerMascot } from './mascot.tsx'
|
|
9
8
|
import { CLIENT_ID, isBootEntryLoaded, ROOT_CHILDREN, UI_LAYOUT, UI_SIDEBAR } from './contract.ts'
|
|
10
9
|
import { syncDocumentContext } from './document-context.ts'
|
|
11
10
|
import { FALLBACK_PANEL, registerFallbackLayout } from './fallback.tsx'
|
|
@@ -148,7 +147,6 @@ export function apply(ctx: DshClientContext): void {
|
|
|
148
147
|
}, 'presmium: the root layout and ctx.layout')
|
|
149
148
|
}
|
|
150
149
|
registerBrand(ctx, workbench)
|
|
151
|
-
registerMascot(ctx, workbench)
|
|
152
150
|
registerAuthorSettings(ctx)
|
|
153
151
|
registerSpeechSettings(ctx, workbench)
|
|
154
152
|
ctx.inject(['layout'], inner => inner.effect(() => connectLaunchTarget(workbench,
|
package/src/client/messages.ts
CHANGED
|
@@ -18,10 +18,6 @@ const zh = {
|
|
|
18
18
|
history: '版本历史',
|
|
19
19
|
settings: '设置',
|
|
20
20
|
help: '帮助',
|
|
21
|
-
mascot: '小猫',
|
|
22
|
-
mascotHint: 'AI 助手工作时,对话和文稿旁的小猫会演示它在做什么:思考、阅读、修改或等你确认。',
|
|
23
|
-
mascotShow: '显示',
|
|
24
|
-
mascotHide: '隐藏',
|
|
25
21
|
close: '关闭',
|
|
26
22
|
toggleSide: '显示或隐藏对话记录',
|
|
27
23
|
keys: {
|
|
@@ -41,7 +37,7 @@ const zh = {
|
|
|
41
37
|
models: '设置模型',
|
|
42
38
|
helpItems: [
|
|
43
39
|
'直接在文稿中输入即可修改。修改自动保存,文稿上方显示“已保存”。',
|
|
44
|
-
'
|
|
40
|
+
'选中文字会出现格式工具栏:段落样式、加粗、对齐、颜色、“插入链接”与“新建批注”。“新建批注”在选中的文字上留下批注,“批注”窗格列出全部批注。动画、图表的预览工具栏里有“本步批注”,可以对整个内容块或其中一步批注。',
|
|
45
41
|
'鼠标移到一段内容上,旁边的“插入内容块”可插入标题、列表、表格、图片等内容,“打开内容块菜单”可删除这一段或修改它的颜色。',
|
|
46
42
|
'“导航窗格”列出全部页面:“新建页面”添加一页,页面旁的“更多”可以重命名、复制、上移、下移或删除这一页。',
|
|
47
43
|
'“撤消”({undo})与“恢复”({redo})逐步撤消或恢复修改。“版本历史”列出保存过的每次修改,“撤消此更改”单独撤消其中一次。',
|
|
@@ -94,10 +90,6 @@ const en: ClientMessages = {
|
|
|
94
90
|
history: 'Version History',
|
|
95
91
|
settings: 'Settings',
|
|
96
92
|
help: 'Help',
|
|
97
|
-
mascot: 'Kitten',
|
|
98
|
-
mascotHint: 'While the AI Assistant works, a kitten beside the chat and the document acts out what it is doing: thinking, reading, changing the document, or waiting for you.',
|
|
99
|
-
mascotShow: 'Show',
|
|
100
|
-
mascotHide: 'Hide',
|
|
101
93
|
close: 'Close',
|
|
102
94
|
toggleSide: 'Show or Hide Chat History',
|
|
103
95
|
keys: {
|
|
@@ -117,7 +109,7 @@ const en: ClientMessages = {
|
|
|
117
109
|
models: 'Set Up a Model',
|
|
118
110
|
helpItems: [
|
|
119
111
|
'Type directly in the document to change it. Changes save automatically, and the top of the document shows Saved.',
|
|
120
|
-
'Select text to show the formatting toolbar: paragraph style, Bold, alignment, Colors, Insert Link, and New Comment. New Comment leaves a comment on the selected text; the Comments pane lists them all.',
|
|
112
|
+
'Select text to show the formatting toolbar: paragraph style, Bold, alignment, Colors, Insert Link, and New Comment. New Comment leaves a comment on the selected text; the Comments pane lists them all. An animation or chart preview also has Comment on step, for the whole content block or one step.',
|
|
121
113
|
'Point at a paragraph: Insert Block, beside it, inserts a heading, list, table, picture, and more; Open Block Menu deletes the paragraph or changes its colors.',
|
|
122
114
|
'The Navigation Pane lists the pages: New Page adds one, and More beside a page renames, duplicates, moves, or deletes it.',
|
|
123
115
|
'Undo ({undo}) and Redo ({redo}) step back and forth through your changes. Version History lists every saved change; Undo This Change reverses one of them.',
|
package/src/client/styles.css
CHANGED
|
@@ -1,45 +1,3 @@
|
|
|
1
1
|
@import '@lincyaw/design/design.css';
|
|
2
2
|
@import '@lincyaw/workbench/styles.css';
|
|
3
3
|
@import './frame.css';
|
|
4
|
-
|
|
5
|
-
/* The kitten among the conversation header's actions. */
|
|
6
|
-
.pmw-conversation-mascot {
|
|
7
|
-
display: inline-flex;
|
|
8
|
-
align-items: center;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/* The kitten's row in Settings → General, laid out as Harness's own rows: its name and note, then its choice. */
|
|
12
|
-
.pmw-mascot-setting {
|
|
13
|
-
display: flex;
|
|
14
|
-
align-items: center;
|
|
15
|
-
justify-content: space-between;
|
|
16
|
-
gap: var(--pm-space-4);
|
|
17
|
-
padding-block: var(--pm-space-4);
|
|
18
|
-
border-top: var(--pm-size-hairline) solid var(--pm-color-line);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.pmw-mascot-setting__copy {
|
|
22
|
-
display: grid;
|
|
23
|
-
gap: var(--pm-space-1);
|
|
24
|
-
min-width: 0;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.pmw-mascot-setting__title {
|
|
28
|
-
margin: 0;
|
|
29
|
-
color: var(--pm-color-ink);
|
|
30
|
-
font-size: var(--pm-text-sm);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.pmw-mascot-setting__hint {
|
|
34
|
-
margin: 0;
|
|
35
|
-
color: var(--pm-color-muted);
|
|
36
|
-
font-size: var(--pm-text-xs);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.pmw-mascot-setting .pm-ui-segmented {
|
|
40
|
-
flex: none;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
@media (max-width: 767px) {
|
|
44
|
-
.pmw-mascot-setting { flex-wrap: wrap; }
|
|
45
|
-
}
|
package/src/node/bindings.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { realpathSync } from 'node:fs'
|
|
2
2
|
import { relative, resolve, sep } from 'node:path'
|
|
3
|
+
import { isInside } from '@lincyaw/kernel/node'
|
|
3
4
|
import { connectPresmiumMcp } from '@lincyaw/mcp/client'
|
|
4
5
|
import { errorMessage, isRecord } from '@lincyaw/kernel'
|
|
5
6
|
import type { DiagnosticSnapshot, DocumentSummary } from '@lincyaw/kernel'
|
|
@@ -7,6 +8,8 @@ import type { ListedTool, PresmiumMcpClient } from '@lincyaw/mcp/client'
|
|
|
7
8
|
import type { DshAgent, DshContext, DshLogger } from './dsh-types.ts'
|
|
8
9
|
import { SERVER_ROUTES } from './server-routes.ts'
|
|
9
10
|
import type { WorkspaceServerClient } from './service.ts'
|
|
11
|
+
import { WorkspaceServerClient as CandidateServer } from './service.ts'
|
|
12
|
+
import { WORKSPACE_ROUTES } from './server-routes.ts'
|
|
10
13
|
|
|
11
14
|
/** The document an agent session works on: an MCP client with a session token for it, its tools and its diagnostics. */
|
|
12
15
|
export interface DocumentBinding {
|
|
@@ -14,6 +17,8 @@ export interface DocumentBinding {
|
|
|
14
17
|
document: DocumentSummary
|
|
15
18
|
dir: string
|
|
16
19
|
client: PresmiumMcpClient
|
|
20
|
+
authorClient: PresmiumMcpClient
|
|
21
|
+
workspaceRoot: string
|
|
17
22
|
readonly tools: ListedTool[]
|
|
18
23
|
toolChanges: BindingTools
|
|
19
24
|
diagnostics: BindingDiagnostics
|
|
@@ -154,7 +159,7 @@ async function closeBinding(binding: DocumentBinding): Promise<void> {
|
|
|
154
159
|
try {
|
|
155
160
|
await Promise.all([binding.diagnostics.close(), binding.toolChanges.close()])
|
|
156
161
|
} finally {
|
|
157
|
-
await binding.client.close()
|
|
162
|
+
await Promise.all([binding.client.close(), binding.authorClient.close()])
|
|
158
163
|
}
|
|
159
164
|
}
|
|
160
165
|
|
|
@@ -189,6 +194,54 @@ export class DocumentBindings {
|
|
|
189
194
|
readonly #selectionListeners = new Map<string, SelectionListener>()
|
|
190
195
|
readonly #selected = new Map<string, string | null>()
|
|
191
196
|
#closed = false
|
|
197
|
+
readonly #candidates = new Map<string, Promise<WorkspaceServerClient>>()
|
|
198
|
+
readonly #parents = new Map<string, string>()
|
|
199
|
+
readonly #candidateRoots = new Map<string, string>()
|
|
200
|
+
readonly #candidateOwners = new Map<string, Set<string>>()
|
|
201
|
+
|
|
202
|
+
rootSessionOf(agent: DshAgent): string {
|
|
203
|
+
const header = agent.session.header as { origin?: string, parentSession?: string } | undefined
|
|
204
|
+
if (header?.origin === 'subagent' && header.parentSession) this.#parents.set(agent.session.id, header.parentSession)
|
|
205
|
+
let id = agent.session.id
|
|
206
|
+
for (let depth = 0; depth < 32 && this.#parents.has(id); depth++) id = this.#parents.get(id)!
|
|
207
|
+
return id
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
async candidateOf(agent: DshAgent): Promise<WorkspaceServerClient> {
|
|
211
|
+
const id = this.rootSessionOf(agent)
|
|
212
|
+
let owners = this.#candidateOwners.get(id)
|
|
213
|
+
if (!owners) this.#candidateOwners.set(id, owners = new Set())
|
|
214
|
+
owners.add(agent.session.id)
|
|
215
|
+
let pending = this.#candidates.get(id)
|
|
216
|
+
if (!pending) {
|
|
217
|
+
pending = (async () => {
|
|
218
|
+
const { root } = await this.#server.requestJson<{ root: string }>(`${WORKSPACE_ROUTES}review/workspace`, { body: { session: id } })
|
|
219
|
+
const candidate = new CandidateServer({ root, candidate: true }, this.#log)
|
|
220
|
+
await candidate.ready
|
|
221
|
+
return candidate
|
|
222
|
+
})()
|
|
223
|
+
this.#candidates.set(id, pending)
|
|
224
|
+
void pending.catch(() => { if (this.#candidates.get(id) === pending) this.#candidates.delete(id) })
|
|
225
|
+
}
|
|
226
|
+
const candidate = await pending
|
|
227
|
+
const directory = await candidate.ready
|
|
228
|
+
this.#candidateRoots.set(id, directory.root)
|
|
229
|
+
const workingDirectory = this.#ctx.get('workingDirectory') as { set(agent: DshAgent, path: string): Promise<string> } | undefined
|
|
230
|
+
if (!workingDirectory) throw new Error('Presmium needs the workingDirectory service for concurrent authoring')
|
|
231
|
+
if (!isInside(this.workingDirectoryOf(agent), directory.root)) await workingDirectory.set(agent, directory.root)
|
|
232
|
+
return candidate
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
candidateRootOf(agent: DshAgent | undefined): string | undefined {
|
|
236
|
+
return agent ? this.#candidateRoots.get(this.rootSessionOf(agent)) : undefined
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
async refreshCandidate(agent: DshAgent): Promise<void> {
|
|
240
|
+
const { root } = await this.#server.ready
|
|
241
|
+
if (!isInside(this.workingDirectoryOf(agent), root)) return
|
|
242
|
+
await this.candidateOf(agent)
|
|
243
|
+
await this.#server.requestJson(`${WORKSPACE_ROUTES}review/workspace`, { body: { session: this.rootSessionOf(agent), refresh: true } })
|
|
244
|
+
}
|
|
192
245
|
|
|
193
246
|
constructor(ctx: DshContext, server: WorkspaceServerClient, log: DshLogger) {
|
|
194
247
|
this.#ctx = ctx
|
|
@@ -228,18 +281,26 @@ export class DocumentBindings {
|
|
|
228
281
|
const id = agent.session.id
|
|
229
282
|
const documents = await this.#server.readDocuments()
|
|
230
283
|
const selected = this.#selected.get(id)
|
|
231
|
-
const
|
|
284
|
+
const cwd = this.workingDirectoryOf(agent)
|
|
285
|
+
if (!isInside(cwd, root)) return undefined
|
|
286
|
+
const document = selected === undefined ? documentAt(root, agent.session.header?.cwd ?? root, documents) ?? (documents.length === 1 ? documents[0] : undefined) : documents.find(doc => doc.dir === selected)
|
|
232
287
|
if (!current()) return undefined
|
|
233
288
|
if (!document) {
|
|
234
289
|
this.#failures.delete(id)
|
|
235
290
|
return undefined
|
|
236
291
|
}
|
|
237
|
-
const
|
|
292
|
+
const candidate = await this.candidateOf(agent)
|
|
293
|
+
const [grant, authorGrant] = await Promise.all([
|
|
294
|
+
candidate.requestJson<{ url: string, token: string }>(`${SERVER_ROUTES}tokens`, { body: { document: document.dir, session: id } }),
|
|
295
|
+
this.#server.requestJson<{ url: string, token: string }>(`${SERVER_ROUTES}tokens`, { body: { document: document.dir, session: id } }),
|
|
296
|
+
])
|
|
238
297
|
const client = await connectPresmiumMcp(grant.url, grant.token)
|
|
239
|
-
const
|
|
298
|
+
const authorClient = await connectPresmiumMcp(authorGrant.url, authorGrant.token)
|
|
299
|
+
const diagnostics = new BindingDiagnostics(authorClient, document.dir)
|
|
240
300
|
const toolChanges = new BindingTools(client, this.#log)
|
|
241
301
|
try {
|
|
242
|
-
const
|
|
302
|
+
const workspaceRoot = (await candidate.ready).root
|
|
303
|
+
const binding: DocumentBinding = { agentSessionId: id, document, dir: resolve(workspaceRoot, document.dir), workspaceRoot, client, authorClient, get tools() { return toolChanges.snapshot }, toolChanges, diagnostics }
|
|
243
304
|
await toolChanges.start()
|
|
244
305
|
await diagnostics.start()
|
|
245
306
|
if (current()) {
|
|
@@ -250,9 +311,10 @@ export class DocumentBindings {
|
|
|
250
311
|
} catch (error) {
|
|
251
312
|
await Promise.all([diagnostics.close(), toolChanges.close()]).catch(() => undefined)
|
|
252
313
|
await client.close().catch(() => undefined)
|
|
314
|
+
await authorClient.close().catch(() => undefined)
|
|
253
315
|
throw error
|
|
254
316
|
}
|
|
255
|
-
await Promise.all([diagnostics.close(), toolChanges.close()]).finally(() => client.close())
|
|
317
|
+
await Promise.all([diagnostics.close(), toolChanges.close()]).finally(() => Promise.all([client.close(), authorClient.close()]))
|
|
256
318
|
return undefined
|
|
257
319
|
}
|
|
258
320
|
|
|
@@ -315,6 +377,8 @@ export class DocumentBindings {
|
|
|
315
377
|
|
|
316
378
|
/** Closes the session's binding and revokes its session token; `forget` drops its selection too. */
|
|
317
379
|
async unbind(agentSessionId: string, forget = true): Promise<void> {
|
|
380
|
+
let ownerId = agentSessionId
|
|
381
|
+
for (let depth = 0; depth < 32 && this.#parents.has(ownerId); depth++) ownerId = this.#parents.get(ownerId)!
|
|
318
382
|
if (forget) {
|
|
319
383
|
this.#selectionVersions.delete(agentSessionId)
|
|
320
384
|
this.#selected.delete(agentSessionId)
|
|
@@ -327,6 +391,19 @@ export class DocumentBindings {
|
|
|
327
391
|
this.#failures.delete(agentSessionId)
|
|
328
392
|
if (binding) await closeBinding(binding).catch(error => this.#log.warn(`presmium-service: closing session ${agentSessionId}: ${errorMessage(error)}`))
|
|
329
393
|
else await request
|
|
394
|
+
if (forget) {
|
|
395
|
+
this.#parents.delete(agentSessionId)
|
|
396
|
+
const owners = this.#candidateOwners.get(ownerId)
|
|
397
|
+
owners?.delete(agentSessionId)
|
|
398
|
+
if (owners?.size === 0) {
|
|
399
|
+
this.#candidateOwners.delete(ownerId)
|
|
400
|
+
this.#candidateRoots.delete(ownerId)
|
|
401
|
+
const candidate = this.#candidates.get(ownerId)
|
|
402
|
+
this.#candidates.delete(ownerId)
|
|
403
|
+
if (candidate) await (await candidate).close()
|
|
404
|
+
await this.#server.requestJson(`${WORKSPACE_ROUTES}review/workspace`, { body: { session: ownerId, close: true } })
|
|
405
|
+
}
|
|
406
|
+
}
|
|
330
407
|
if (!binding && !request) return
|
|
331
408
|
await this.#server.request(`${SERVER_ROUTES}tokens`, { method: 'DELETE', body: { session: agentSessionId } }).then(r => r.body?.cancel(), () => undefined)
|
|
332
409
|
}
|
|
@@ -341,5 +418,10 @@ export class DocumentBindings {
|
|
|
341
418
|
this.#selected.clear()
|
|
342
419
|
this.#selectionVersions.clear()
|
|
343
420
|
this.#selectionListeners.clear()
|
|
421
|
+
await Promise.all([...this.#candidates.values()].map(async candidate => (await candidate).close()))
|
|
422
|
+
this.#candidates.clear()
|
|
423
|
+
this.#candidateRoots.clear()
|
|
424
|
+
this.#candidateOwners.clear()
|
|
425
|
+
this.#parents.clear()
|
|
344
426
|
}
|
|
345
427
|
}
|