@lincyaw/dsh 0.2.0-rc.49 → 0.2.0-rc.50
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/dist/client.json
CHANGED
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"../kernel/src/contracts/authoring-actions.ts",
|
|
39
39
|
"../kernel/src/contracts/document-history.ts",
|
|
40
40
|
"../kernel/src/contracts/authoring-clients.ts",
|
|
41
|
+
"../kernel/src/contracts/authoring-windows.ts",
|
|
41
42
|
"../kernel/src/contracts/projects.ts",
|
|
42
43
|
"../kernel/src/contracts/document-image.ts",
|
|
43
44
|
"../kernel/src/contracts.ts",
|
|
@@ -245,6 +246,7 @@
|
|
|
245
246
|
"../workbench/src/speech-settings-messages.ts",
|
|
246
247
|
"../workbench/src/panels/SpeechSettingsPanel.tsx",
|
|
247
248
|
"../workbench/src/authoring-client.ts",
|
|
249
|
+
"../workbench/src/authoring-window.ts",
|
|
248
250
|
"../workbench/src/index.ts",
|
|
249
251
|
"src/workspace-events.ts",
|
|
250
252
|
"src/client/workspace-events.ts",
|
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.50",
|
|
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": {
|
|
@@ -85,10 +85,10 @@
|
|
|
85
85
|
"node-addon-require-builtin": "0.1.9",
|
|
86
86
|
"ws": "8.22.0",
|
|
87
87
|
"zod": "4.4.3",
|
|
88
|
-
"@lincyaw/
|
|
89
|
-
"@lincyaw/
|
|
90
|
-
"@lincyaw/mcp": "1.0.0-rc.
|
|
91
|
-
"@lincyaw/
|
|
88
|
+
"@lincyaw/kernel": "1.0.0-rc.51",
|
|
89
|
+
"@lincyaw/cli": "1.0.0-rc.51",
|
|
90
|
+
"@lincyaw/mcp": "1.0.0-rc.51",
|
|
91
|
+
"@lincyaw/skills": "1.0.0-rc.51"
|
|
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.51",
|
|
108
|
+
"@lincyaw/workbench": "0.2.0-rc.51"
|
|
109
109
|
},
|
|
110
110
|
"scripts": {}
|
|
111
111
|
}
|
package/src/client/index.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { connectAuthoringClient, localeOf, Workbench, workspaceClient } from '@lincyaw/workbench'
|
|
1
|
+
import { connectAuthoringClient, connectAuthoringWindow, localeOf, Workbench, workspaceClient } from '@lincyaw/workbench'
|
|
2
2
|
import type { Locale } from '@lincyaw/workbench'
|
|
3
3
|
import { workspaceSubscriptions } from './workspace-events.ts'
|
|
4
4
|
import { registerAuthorSettings } from './author-settings.ts'
|
|
@@ -55,6 +55,7 @@ export function apply(ctx: DshClientContext): void {
|
|
|
55
55
|
const workbench = new Workbench({ client: workspaceClient('api/presmium/', workspaceSubscriptions(ctx)), locale: workbenchLocale(ctx.locale.getLocale().active) })
|
|
56
56
|
workbench.client.openSpeechSettings = openSpeechSettings
|
|
57
57
|
ctx.effect(() => connectAuthoringClient(workbench), 'presmium: authoring client control')
|
|
58
|
+
ctx.effect(() => connectAuthoringWindow(workbench), 'presmium: authoring window control')
|
|
58
59
|
ctx.effect(() => runtimeDiagnostics(workbench).start(), 'presmium: runtime diagnostics')
|
|
59
60
|
let showEditor = (layout: DshClientContext['layout']) => layout.selectPanel(FALLBACK_PANEL)
|
|
60
61
|
registerSourceLinks(ctx, workbench, layout => showEditor(layout))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WebSocket } from 'partysocket'
|
|
2
2
|
import type { WorkspaceSubscription } from '@lincyaw/workbench'
|
|
3
|
-
import type {
|
|
3
|
+
import type { AuthoringClientEvent, AuthoringWindowEvent } from '@lincyaw/kernel'
|
|
4
4
|
import { AUTHORING_CLIENT_REQUEST_TIMEOUT_MS } from '@lincyaw/kernel'
|
|
5
5
|
import { WORKSPACE_EVENTS_PATH, workspaceEventMessage } from '../workspace-events.ts'
|
|
6
6
|
import type { WorkspaceEventTopic, WorkspaceEventCommand } from '../workspace-events.ts'
|
|
@@ -89,7 +89,7 @@ export function workspaceSubscriptions(ctx: Pick<DshClientContext, 'effect'>): W
|
|
|
89
89
|
const topic = TOPICS[name]
|
|
90
90
|
const query = new URL(address).searchParams
|
|
91
91
|
const document = query.get('document')
|
|
92
|
-
if (!topic || topic === 'authoring-client' || document === null) throw new Error('Invalid workspace event subscription.')
|
|
92
|
+
if (!topic || topic === 'authoring-client' || topic === 'authoring-window' || document === null) throw new Error('Invalid workspace event subscription.')
|
|
93
93
|
const request: Subscription['request'] = topic === 'viewer-site'
|
|
94
94
|
? { type: 'subscribe', id: '', topic, document, app: query.get('app') ?? '', lang: query.get('lang') ?? '', form: query.get('form') === 'slides' ? 'slides' : 'web' }
|
|
95
95
|
: topic === 'viewer-control' ? { type: 'subscribe', id: '', topic, document, window: query.get('window') ?? '' }
|
|
@@ -97,18 +97,20 @@ export function workspaceSubscriptions(ctx: Pick<DshClientContext, 'effect'>): W
|
|
|
97
97
|
const reader: Subscription = { request, received, failed, ready }
|
|
98
98
|
return add(reader)
|
|
99
99
|
}
|
|
100
|
-
|
|
101
|
-
const reader: Subscription = { request
|
|
102
|
-
received(raw) { let event:
|
|
100
|
+
const openControl = <Event extends { type: string }>(request: Subscription['request'], received: (event: Event) => void, failed: () => void) => {
|
|
101
|
+
const reader: Subscription = { request, pending: new Map(), failed,
|
|
102
|
+
received(raw) { let event: Event; try { event = JSON.parse(raw) } catch { return }; if (event.type === 'connected') rejectPublications(reader); received(event) } }
|
|
103
103
|
const close = add(reader)
|
|
104
|
-
const publish = (kind: 'state' | 'ack', connectionId: string, report:
|
|
104
|
+
const publish = (kind: 'state' | 'ack', connectionId: string, report: { sequence: number }) => new Promise<void>((resolve, reject) => {
|
|
105
105
|
if (closed || !readers.has(reader) || !reader.id || socket.readyState !== WebSocket.OPEN || reader.pending!.has(report.sequence)) { reject(new Error('client-transport-disconnected')); return }
|
|
106
106
|
// A lost publication receipt must release the queue without authorizing a repeated action.
|
|
107
107
|
const timer = setTimeout(() => { reader.pending!.delete(report.sequence); reject(new Error('client-publication-timeout')) }, AUTHORING_CLIENT_REQUEST_TIMEOUT_MS / 2)
|
|
108
108
|
reader.pending!.set(report.sequence, { resolve, reject, timer })
|
|
109
109
|
socket.send(JSON.stringify({ type: 'authoring-client-publish', id: reader.id, connectionId, sequence: report.sequence, kind, value: report }))
|
|
110
110
|
})
|
|
111
|
-
return { close, publish: (connectionId, report) => publish('state', connectionId, report), acknowledge: (connectionId, report) => publish('ack', connectionId, report) }
|
|
111
|
+
return { close, publish: (connectionId: string, report: { sequence: number }) => publish('state', connectionId, report), acknowledge: (connectionId: string, report: { sequence: number }) => publish('ack', connectionId, report) }
|
|
112
112
|
}
|
|
113
|
+
subscription.openAuthoringClient = (document, open, received, failed) => openControl<AuthoringClientEvent>({ type: 'subscribe', id: '', topic: 'authoring-client', document, ...open }, received, failed)
|
|
114
|
+
subscription.openAuthoringWindow = (open, received, failed) => openControl<AuthoringWindowEvent>({ type: 'subscribe', id: '', topic: 'authoring-window', ...open }, received, failed)
|
|
113
115
|
return subscription
|
|
114
116
|
}
|
|
@@ -94,13 +94,15 @@ export function apply(ctx: EventContext): void {
|
|
|
94
94
|
const current = () => !closed && !controller.signal.aborted && subscriptions.get(command.id) === entry
|
|
95
95
|
void ctx.presmium.server.ready.then(endpoint => {
|
|
96
96
|
if (!current()) return
|
|
97
|
-
if (command.topic === 'authoring-client') {
|
|
97
|
+
if (command.topic === 'authoring-client' || command.topic === 'authoring-window') {
|
|
98
|
+
const resource = command.topic === 'authoring-window' ? 'authoring-windows' : 'authoring-clients'
|
|
99
|
+
const documentQuery: Record<string, string> = command.topic === 'authoring-client' ? { document: command.document } : {}
|
|
98
100
|
// Keep the client credential on the trusted host, off browser messages and MCP reads.
|
|
99
101
|
let lease: AuthoringClientLease | undefined
|
|
100
102
|
let publication: Promise<void> = Promise.resolve()
|
|
101
103
|
let publications = 0
|
|
102
104
|
const post = async (kind: string, value: unknown) => {
|
|
103
|
-
const path = `${WORKSPACE_ROUTES}
|
|
105
|
+
const path = `${WORKSPACE_ROUTES}${resource}/${kind}?${new URLSearchParams(documentQuery)}`
|
|
104
106
|
const response = await ctx.presmium.server.request(path, { method: 'POST', body: value, signal: controller.signal })
|
|
105
107
|
if (!response.ok) throw new Error('client-publication-refused')
|
|
106
108
|
return response.json() as Promise<unknown>
|
|
@@ -120,8 +122,8 @@ export function apply(ctx: EventContext): void {
|
|
|
120
122
|
if (!current()) return
|
|
121
123
|
if (!validateAuthoringClientLease(value)) throw new Error('client-registration-invalid')
|
|
122
124
|
lease = value
|
|
123
|
-
const query = new URLSearchParams({
|
|
124
|
-
const path = `${WORKSPACE_ROUTES}
|
|
125
|
+
const query = new URLSearchParams({ ...documentQuery, clientId: lease.clientId, epoch: lease.epoch, connectionId: lease.connectionId })
|
|
126
|
+
const path = `${WORKSPACE_ROUTES}${resource}/events?${query}`
|
|
125
127
|
source = new EventSource(new URL(path, endpoint.url), {
|
|
126
128
|
fetch: (_address, init) => ctx.presmium.server.request(path, { headers: { ...Object.fromEntries(new Headers(init?.headers)), 'X-Presmium-Authoring-Client': value.credential }, signal: init?.signal ? AbortSignal.any([controller.signal, init.signal]) : controller.signal }),
|
|
127
129
|
})
|
package/src/workspace-events.ts
CHANGED
|
@@ -12,6 +12,7 @@ const approvals = z.strictObject({ type: z.literal('subscribe'), id: subscriptio
|
|
|
12
12
|
|
|
13
13
|
export const workspaceEventCommand = z.union([
|
|
14
14
|
z.strictObject({ type: z.literal('subscribe'), id: subscriptionId, topic: z.literal('authoring-client'), document: z.string().max(1024), clientId: subscriptionId, epoch: subscriptionId, snapshot: z.unknown() }),
|
|
15
|
+
z.strictObject({ type: z.literal('subscribe'), id: subscriptionId, topic: z.literal('authoring-window'), clientId: subscriptionId, epoch: subscriptionId, snapshot: z.unknown() }),
|
|
15
16
|
z.strictObject({ type: z.literal('authoring-client-publish'), id: subscriptionId, connectionId: subscriptionId, sequence: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER), kind: z.enum(['state', 'ack']), value: z.unknown() }),
|
|
16
17
|
viewerSite, viewerControl, approvals,
|
|
17
18
|
z.strictObject({ type: z.literal('subscribe'), id: subscriptionId, topic: z.enum(WORKSPACE_EVENT_TOPICS), document: z.string().max(1024) }),
|
|
@@ -26,6 +27,6 @@ export const workspaceEventMessage = z.discriminatedUnion('type', [
|
|
|
26
27
|
z.strictObject({ type: z.literal('event'), id: subscriptionId, event: z.string().max(40).optional(), data: z.string() }),
|
|
27
28
|
])
|
|
28
29
|
|
|
29
|
-
export type WorkspaceEventTopic = typeof WORKSPACE_EVENT_TOPICS[number] | 'viewer-site' | 'viewer-control' | 'approvals' | 'authoring-client'
|
|
30
|
+
export type WorkspaceEventTopic = typeof WORKSPACE_EVENT_TOPICS[number] | 'viewer-site' | 'viewer-control' | 'approvals' | 'authoring-client' | 'authoring-window'
|
|
30
31
|
export type WorkspaceEventCommand = z.infer<typeof workspaceEventCommand>
|
|
31
32
|
export type WorkspaceEventMessage = z.infer<typeof workspaceEventMessage>
|