@linxin666/dsh-remote-bridge 0.4.7 → 0.4.9
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/README.i18n.yaml +2 -2
- package/README.md +93 -26
- package/README.zh.md +91 -26
- package/icon.svg +3 -0
- package/lib/client.js +274 -253
- package/lib/client.js.map +1 -1
- package/lib/index.js +8891 -2433
- package/lib/types/client/PairEntry.d.ts +2 -2
- package/lib/types/client/PairPanel.d.ts +10 -2
- package/lib/types/client/icons.d.ts +5 -13
- package/lib/types/client/locales.d.ts +10 -14
- package/lib/types/client/semantic.d.ts +9 -5
- package/lib/types/core/approvals.d.ts +24 -0
- package/lib/types/core/commands.d.ts +59 -0
- package/lib/types/core/connection.d.ts +124 -5
- package/lib/types/core/delta.d.ts +101 -0
- package/lib/types/core/devices.d.ts +98 -2
- package/lib/types/core/dsh-frames.d.ts +155 -4
- package/lib/types/core/envelope.d.ts +34 -0
- package/lib/types/core/extension.d.ts +144 -0
- package/lib/types/core/hub.d.ts +96 -20
- package/lib/types/core/jobs.d.ts +204 -0
- package/lib/types/core/liveactivity.d.ts +324 -0
- package/lib/types/core/protocol.d.ts +491 -2
- package/lib/types/core/push.d.ts +178 -0
- package/lib/types/core/questions.d.ts +109 -9
- package/lib/types/core/session-meta.d.ts +55 -1
- package/lib/types/core/squads.d.ts +130 -0
- package/lib/types/core/usage-stats.d.ts +160 -0
- package/lib/types/core/usage.d.ts +294 -0
- package/lib/types/core/wire.d.ts +1 -1
- package/lib/types/core/ws-frames.d.ts +11 -0
- package/lib/types/host/apns.d.ts +151 -0
- package/lib/types/host/squads-ledger.d.ts +39 -0
- package/lib/types/host/squads.d.ts +77 -0
- package/lib/types/host/usage-stats.d.ts +75 -0
- package/lib/types/host/watchers.d.ts +88 -0
- package/lib/types/host/websocket.d.ts +8 -1
- package/lib/types/index.d.ts +34 -3
- package/lib/types/mount-once.d.ts +55 -0
- package/locale/en.json +6 -0
- package/locale/ru.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +20 -14
- package/src/client/PairEntry.tsx +58 -31
- package/src/client/PairPanel.tsx +181 -97
- package/src/client/icons.tsx +17 -60
- package/src/client/locales.ts +15 -23
- package/src/client/panel.module.css +239 -186
- package/src/client/semantic.ts +10 -6
- package/src/core/approvals.ts +32 -1
- package/src/core/commands.ts +95 -0
- package/src/core/connection.ts +1483 -31
- package/src/core/delta.ts +204 -0
- package/src/core/devices.ts +221 -3
- package/src/core/dsh-frames.ts +365 -8
- package/src/core/envelope.ts +46 -0
- package/src/core/extension.ts +197 -0
- package/src/core/hub.ts +441 -49
- package/src/core/jobs.ts +372 -0
- package/src/core/liveactivity.ts +833 -0
- package/src/core/protocol.ts +556 -2
- package/src/core/push.ts +354 -0
- package/src/core/questions.ts +264 -17
- package/src/core/session-meta.ts +73 -1
- package/src/core/squads.ts +345 -0
- package/src/core/usage-stats.ts +424 -0
- package/src/core/usage.ts +937 -0
- package/src/core/wire.ts +13 -1
- package/src/core/ws-frames.ts +14 -0
- package/src/host/apns.ts +320 -0
- package/src/host/squads-ledger.ts +105 -0
- package/src/host/squads.ts +206 -0
- package/src/host/usage-stats.ts +155 -0
- package/src/host/watchers.ts +272 -0
- package/src/host/websocket.ts +37 -3
- package/src/index.ts +310 -9
- package/src/mount-once.ts +142 -0
package/src/core/push.ts
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What this bridge tells a phone that is not listening.
|
|
3
|
+
*
|
|
4
|
+
* Every fact a phone needs already has a read on the wire — a roster, a
|
|
5
|
+
* baseline, a question list — and a notification is not one of them. It is the
|
|
6
|
+
* `turn ended` or `something is waiting` event, delivered by APNs to a device
|
|
7
|
+
* whose socket is closed, and nothing else: this module deliberately holds no
|
|
8
|
+
* session state, publishes no topic, and answers no method. A client that acts
|
|
9
|
+
* on a notification still has to read the fact behind it (protocol §28).
|
|
10
|
+
*
|
|
11
|
+
* Three rules live here, so the sender beside it cannot disagree about them:
|
|
12
|
+
*
|
|
13
|
+
* - the payload carries a session's NAME, its workspace's short name, the state
|
|
14
|
+
* and one deep link. Never a message, a tool output, a file name or a
|
|
15
|
+
* question's body — a notification crosses Apple's servers and sits on a lock
|
|
16
|
+
* screen, which is the last place session content should be;
|
|
17
|
+
* - the same `(sessionId, event)` inside {@link PUSH_DEDUPE_MS} is one
|
|
18
|
+
* notification, because two phones following one session both see the same
|
|
19
|
+
* turn end and the user has one lock screen;
|
|
20
|
+
* - a failed delivery is logged and dropped. Nothing here is awaited by the
|
|
21
|
+
* delta path, so a broken APNs connection cannot delay, reorder or suppress a
|
|
22
|
+
* frame that a connected phone is waiting for.
|
|
23
|
+
* @module dsh-remote-bridge/core/push
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { basename } from 'node:path'
|
|
27
|
+
|
|
28
|
+
/** One thing a notification can be about. */
|
|
29
|
+
export type PushEvent = 'turn-end' | 'turn-error' | 'question' | 'approval'
|
|
30
|
+
|
|
31
|
+
/** Window inside which the same `(sessionId, event)` is one notification. */
|
|
32
|
+
export const PUSH_DEDUPE_MS = 30_000
|
|
33
|
+
/** Shortest gap between two notifications about the same session. */
|
|
34
|
+
export const PUSH_SESSION_INTERVAL_MS = 10_000
|
|
35
|
+
/** Most notifications this bridge sends in any rolling minute. */
|
|
36
|
+
export const PUSH_GLOBAL_PER_MINUTE = 30
|
|
37
|
+
/** Sessions whose workspace short name is remembered for the payload. */
|
|
38
|
+
export const PUSH_WORKSPACE_LIMIT = 512
|
|
39
|
+
/** The only deep-link form this channel emits. */
|
|
40
|
+
export const PUSH_DEEP_LINK_PREFIX = 'whale://session/'
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The status line each event carries.
|
|
44
|
+
*
|
|
45
|
+
* Fixed strings on purpose: a body built out of host text would be session
|
|
46
|
+
* content wearing a notification's clothes, and the whole point of this channel
|
|
47
|
+
* is that it carries none.
|
|
48
|
+
*/
|
|
49
|
+
const PUSH_BODY: Readonly<Record<PushEvent, string>> = {
|
|
50
|
+
'turn-end': '回合结束',
|
|
51
|
+
'turn-error': '回合异常结束',
|
|
52
|
+
question: '有待回答的问题',
|
|
53
|
+
approval: '有待确认的审批',
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** One device a notification can be addressed to. */
|
|
57
|
+
export interface PushAddress {
|
|
58
|
+
readonly deviceToken: string
|
|
59
|
+
readonly environment: 'sandbox' | 'production'
|
|
60
|
+
readonly bundle: string
|
|
61
|
+
readonly locale?: string
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** The request body one APNs delivery carries (protocol §28.4). */
|
|
65
|
+
export interface PushNotification {
|
|
66
|
+
readonly aps: {
|
|
67
|
+
readonly alert: { readonly title: string; readonly body: string }
|
|
68
|
+
readonly sound: 'default'
|
|
69
|
+
}
|
|
70
|
+
/** Workspace short name; absent when this bridge cannot resolve one. */
|
|
71
|
+
readonly w?: string
|
|
72
|
+
readonly s: string
|
|
73
|
+
readonly st: PushEvent
|
|
74
|
+
readonly url: string
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** What one delivery attempt reported. */
|
|
78
|
+
export interface PushSendResult {
|
|
79
|
+
readonly ok: boolean
|
|
80
|
+
/** The status APNs answered, when it answered at all. */
|
|
81
|
+
readonly status?: number
|
|
82
|
+
/** The reason APNs named, or this bridge's own note. */
|
|
83
|
+
readonly reason?: string
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** One delivery a sender refused, in the words the bridge needs to read it. */
|
|
87
|
+
export interface PushDeliveryFailure {
|
|
88
|
+
/** The registration APNs refused: the roster row holding it is a device that no longer exists. */
|
|
89
|
+
readonly deviceToken: string
|
|
90
|
+
/** The status APNs answered, when it answered at all. */
|
|
91
|
+
readonly status?: number
|
|
92
|
+
/** The reason APNs named, or this bridge's own note. */
|
|
93
|
+
readonly reason?: string
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** What one {@link PushNotifier.notify} ended up doing, once every attempt settled. */
|
|
97
|
+
export interface PushDeliveryReport {
|
|
98
|
+
/** How many devices took the notification. */
|
|
99
|
+
readonly delivered: number
|
|
100
|
+
/** Every attempt that did not land, in target order. */
|
|
101
|
+
readonly failures: readonly PushDeliveryFailure[]
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @param failure - one refused delivery.
|
|
106
|
+
* @returns whether the registration behind it is dead for good.
|
|
107
|
+
*
|
|
108
|
+
* APNs says a token will never work again in three ways: 410 with
|
|
109
|
+
* `Unregistered`, and 400 with `Unregistered` or `BadDeviceToken`. All three are
|
|
110
|
+
* final facts about the registration — the app was removed, or this token belongs
|
|
111
|
+
* to another environment or bundle — so it is cleaned up instead of retried, and
|
|
112
|
+
* a claim held for it is a claim held for a phone that cannot come back.
|
|
113
|
+
*/
|
|
114
|
+
export function isDeadPushToken(failure: PushDeliveryFailure): boolean {
|
|
115
|
+
const reason = failure.reason ?? ''
|
|
116
|
+
if (reason === 'Unregistered' || reason === 'BadDeviceToken') return true
|
|
117
|
+
return failure.status === 410
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Whatever actually reaches a device; the APNs client implements this. */
|
|
121
|
+
export interface PushSender {
|
|
122
|
+
send(target: PushAddress, notification: PushNotification): Promise<PushSendResult>
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** What the payload builder may say about one session. */
|
|
126
|
+
export interface PushLabels {
|
|
127
|
+
readonly title?: string
|
|
128
|
+
readonly workspace?: string
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface PushNotifierOptions {
|
|
132
|
+
/** The devices that asked to be notified, read per event. */
|
|
133
|
+
readonly targets: () => readonly PushAddress[]
|
|
134
|
+
/** The sender; absent is a bridge with no signing key, and then nothing happens. */
|
|
135
|
+
readonly sender?: PushSender
|
|
136
|
+
/** The session's own title (§26's source), read per event. */
|
|
137
|
+
readonly titles?: (sessionId: string) => string | undefined
|
|
138
|
+
readonly now?: () => number
|
|
139
|
+
readonly log?: (message: string) => void
|
|
140
|
+
readonly dedupeMs?: number
|
|
141
|
+
readonly sessionIntervalMs?: number
|
|
142
|
+
readonly globalPerMinute?: number
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The notification the channel sends for one event (protocol §28.4).
|
|
147
|
+
*
|
|
148
|
+
* Pure, and exported so the shape can be asserted without a sender: the keys
|
|
149
|
+
* are the contract, and the absence of any body text is the property that
|
|
150
|
+
* matters most.
|
|
151
|
+
* @param event - what happened.
|
|
152
|
+
* @param sessionId - the session it happened to.
|
|
153
|
+
* @param labels - the name and workspace short name, when the bridge holds them.
|
|
154
|
+
* @returns the exact payload an APNs delivery carries.
|
|
155
|
+
*/
|
|
156
|
+
export function buildPushNotification(event: PushEvent, sessionId: string, labels: PushLabels = {}): PushNotification {
|
|
157
|
+
const named = labels.title !== undefined && labels.title !== ''
|
|
158
|
+
return {
|
|
159
|
+
aps: {
|
|
160
|
+
alert: { title: named ? labels.title as string : PUSH_BODY[event], body: PUSH_BODY[event] },
|
|
161
|
+
sound: 'default',
|
|
162
|
+
},
|
|
163
|
+
...(labels.workspace === undefined || labels.workspace === '' ? {} : { w: labels.workspace }),
|
|
164
|
+
s: sessionId,
|
|
165
|
+
st: event,
|
|
166
|
+
url: `${PUSH_DEEP_LINK_PREFIX}${sessionId}`,
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Which event one `turn-end` delta is.
|
|
172
|
+
* @param reason - the host's own reason for ending the turn.
|
|
173
|
+
* @returns the normal end for `completed`, the abnormal one for every other
|
|
174
|
+
* value — including `unknown`, which is what an unreadable reason reports.
|
|
175
|
+
*/
|
|
176
|
+
export function pushEventOfTurnEnd(reason: string): PushEvent {
|
|
177
|
+
return reason === 'completed' ? 'turn-end' : 'turn-error'
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* The bridge's outbound notification path.
|
|
182
|
+
*
|
|
183
|
+
* Deliberately inert when no sender is configured: {@link enabled} is false, no
|
|
184
|
+
* target is ever read and no clock is ever consulted, so an unconfigured bridge
|
|
185
|
+
* behaves — byte for byte, frame for frame — exactly as it did before this
|
|
186
|
+
* channel existed.
|
|
187
|
+
*/
|
|
188
|
+
export class PushNotifier {
|
|
189
|
+
readonly #options: PushNotifierOptions
|
|
190
|
+
readonly #now: () => number
|
|
191
|
+
readonly #log: (message: string) => void
|
|
192
|
+
/** Last send per `(sessionId, event)`. */
|
|
193
|
+
readonly #dedupe = new Map<string, number>()
|
|
194
|
+
/** Last send per session, whatever the event. */
|
|
195
|
+
readonly #sessions = new Map<string, number>()
|
|
196
|
+
/** Send timestamps inside the rolling minute. */
|
|
197
|
+
#recent: number[] = []
|
|
198
|
+
/** Session id to workspace short name, as the roster rows this bridge served reported it. */
|
|
199
|
+
readonly #workspaces = new Map<string, string>()
|
|
200
|
+
|
|
201
|
+
constructor(options: PushNotifierOptions) {
|
|
202
|
+
this.#options = options
|
|
203
|
+
this.#now = options.now ?? (() => Date.now())
|
|
204
|
+
this.#log = options.log ?? (() => undefined)
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** @returns whether this bridge will actually deliver anything. */
|
|
208
|
+
get enabled(): boolean {
|
|
209
|
+
return this.#options.sender !== undefined
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Remember the workspace each session belongs to, from a roster this bridge
|
|
214
|
+
* just served.
|
|
215
|
+
*
|
|
216
|
+
* A notification's `w` is the only label the bridge cannot read from the
|
|
217
|
+
* title service, and asking the host for a roster on every turn end would put
|
|
218
|
+
* a gateway call on the notification path. The rows are already in hand when a
|
|
219
|
+
* phone lists them, so the short name is picked up there and kept bounded; a
|
|
220
|
+
* session never listed simply gets a payload without `w`.
|
|
221
|
+
* @param rows - the roster rows that were just built for a client.
|
|
222
|
+
*/
|
|
223
|
+
noteSessions(rows: readonly { readonly id: string; readonly cwd?: string }[]): void {
|
|
224
|
+
if (!this.enabled) return
|
|
225
|
+
for (const row of rows) {
|
|
226
|
+
if (row.cwd === undefined || row.cwd === '') continue
|
|
227
|
+
const short = basename(row.cwd)
|
|
228
|
+
if (short === '') continue
|
|
229
|
+
this.#workspaces.delete(row.id)
|
|
230
|
+
this.#workspaces.set(row.id, short)
|
|
231
|
+
}
|
|
232
|
+
while (this.#workspaces.size > PUSH_WORKSPACE_LIMIT) {
|
|
233
|
+
const oldest = this.#workspaces.keys().next()
|
|
234
|
+
if (oldest.done === true) break
|
|
235
|
+
this.#workspaces.delete(oldest.value)
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Announce one event to every registered device.
|
|
241
|
+
*
|
|
242
|
+
* Returns before anything is sent: delivery starts on a fresh microtask, so a
|
|
243
|
+
* caller on the delta path never awaits an APNs round trip and a sender that
|
|
244
|
+
* throws cannot reach it.
|
|
245
|
+
* @param event - what happened.
|
|
246
|
+
* @param sessionId - the session it happened to.
|
|
247
|
+
* @param onReport - receives how the announcement ended, once every attempt has
|
|
248
|
+
* settled. A caller that held something for a phone — an offline claim (§32) —
|
|
249
|
+
* needs to know whether any phone was actually told, and may not block the
|
|
250
|
+
* caller's own path on an APNs round trip to find out. Not called when nothing
|
|
251
|
+
* was attempted: no sender, no target, or a rate limit that dropped this event.
|
|
252
|
+
*/
|
|
253
|
+
notify(event: PushEvent, sessionId: string, onReport?: (report: PushDeliveryReport) => void): void {
|
|
254
|
+
if (this.#options.sender === undefined) return
|
|
255
|
+
try {
|
|
256
|
+
this.#announce(event, sessionId, onReport)
|
|
257
|
+
} catch (error) {
|
|
258
|
+
// The caller is a frame path — a delta broadcast or a claim — and a
|
|
259
|
+
// notification that cannot even be built must not end a follow stream.
|
|
260
|
+
this.#log(`push ${event} for ${sessionId} could not be prepared: ${String(error)}`)
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** Build and start one event's deliveries. */
|
|
265
|
+
#announce(event: PushEvent, sessionId: string, onReport?: (report: PushDeliveryReport) => void): void {
|
|
266
|
+
const sender = this.#options.sender
|
|
267
|
+
if (sender === undefined) return
|
|
268
|
+
const targets = this.#options.targets()
|
|
269
|
+
if (targets.length === 0) return
|
|
270
|
+
const now = this.#now()
|
|
271
|
+
if (!this.#admit(event, sessionId, now)) return
|
|
272
|
+
const notification = buildPushNotification(event, sessionId, this.#labelsOf(sessionId))
|
|
273
|
+
const failures: PushDeliveryFailure[] = []
|
|
274
|
+
let delivered = 0
|
|
275
|
+
let pending = targets.length
|
|
276
|
+
// One report per announcement, after the last attempt settled: a half-read
|
|
277
|
+
// count is worse than none, because the caller acts on it.
|
|
278
|
+
const settleOne = (failure: PushDeliveryFailure | undefined): void => {
|
|
279
|
+
if (failure === undefined) delivered += 1
|
|
280
|
+
else failures.push(failure)
|
|
281
|
+
pending -= 1
|
|
282
|
+
if (pending > 0 || onReport === undefined) return
|
|
283
|
+
try {
|
|
284
|
+
onReport({ delivered, failures })
|
|
285
|
+
} catch (error) {
|
|
286
|
+
this.#log(`push ${event} for ${sessionId} could not be reported: ${String(error)}`)
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
for (const target of targets) {
|
|
290
|
+
void Promise.resolve()
|
|
291
|
+
.then(async () => await sender.send(target, notification))
|
|
292
|
+
.then((result) => {
|
|
293
|
+
if (result.ok) {
|
|
294
|
+
settleOne(undefined)
|
|
295
|
+
return
|
|
296
|
+
}
|
|
297
|
+
this.#log(`push ${event} for ${sessionId} was not delivered (${result.status ?? '-'} ${result.reason ?? 'no reason'})`)
|
|
298
|
+
settleOne({
|
|
299
|
+
deviceToken: target.deviceToken,
|
|
300
|
+
...(result.status === undefined ? {} : { status: result.status }),
|
|
301
|
+
...(result.reason === undefined ? {} : { reason: result.reason }),
|
|
302
|
+
})
|
|
303
|
+
})
|
|
304
|
+
.catch((error: unknown) => {
|
|
305
|
+
this.#log(`push ${event} for ${sessionId} failed: ${String(error)}`)
|
|
306
|
+
settleOne({ deviceToken: target.deviceToken })
|
|
307
|
+
})
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** @returns whether this event may be sent now; records the send when it may. */
|
|
312
|
+
#admit(event: PushEvent, sessionId: string, now: number): boolean {
|
|
313
|
+
const dedupeMs = this.#options.dedupeMs ?? PUSH_DEDUPE_MS
|
|
314
|
+
const sessionMs = this.#options.sessionIntervalMs ?? PUSH_SESSION_INTERVAL_MS
|
|
315
|
+
const perMinute = this.#options.globalPerMinute ?? PUSH_GLOBAL_PER_MINUTE
|
|
316
|
+
this.#prune(now, dedupeMs)
|
|
317
|
+
const key = `${sessionId}|${event}`
|
|
318
|
+
const lastSame = this.#dedupe.get(key)
|
|
319
|
+
if (lastSame !== undefined && now - lastSame < dedupeMs) return false
|
|
320
|
+
const lastSession = this.#sessions.get(sessionId)
|
|
321
|
+
if (lastSession !== undefined && now - lastSession < sessionMs) return false
|
|
322
|
+
this.#recent = this.#recent.filter(at => now - at < 60_000)
|
|
323
|
+
if (this.#recent.length >= perMinute) return false
|
|
324
|
+
this.#dedupe.set(key, now)
|
|
325
|
+
this.#sessions.set(sessionId, now)
|
|
326
|
+
this.#recent.push(now)
|
|
327
|
+
return true
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/** Forget entries that can no longer suppress anything. */
|
|
331
|
+
#prune(now: number, dedupeMs: number): void {
|
|
332
|
+
if (this.#dedupe.size > 256) {
|
|
333
|
+
for (const [key, at] of this.#dedupe) if (now - at >= dedupeMs) this.#dedupe.delete(key)
|
|
334
|
+
}
|
|
335
|
+
if (this.#sessions.size > 256) {
|
|
336
|
+
const sessionMs = this.#options.sessionIntervalMs ?? PUSH_SESSION_INTERVAL_MS
|
|
337
|
+
for (const [id, at] of this.#sessions) if (now - at >= sessionMs) this.#sessions.delete(id)
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
#labelsOf(sessionId: string): PushLabels {
|
|
342
|
+
let title: string | undefined
|
|
343
|
+
try {
|
|
344
|
+
title = this.#options.titles?.(sessionId)
|
|
345
|
+
} catch {
|
|
346
|
+
title = undefined
|
|
347
|
+
}
|
|
348
|
+
const workspace = this.#workspaces.get(sessionId)
|
|
349
|
+
return {
|
|
350
|
+
...(title === undefined || title === '' ? {} : { title }),
|
|
351
|
+
...(workspace === undefined ? {} : { workspace }),
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|