dsh-workspace-pulse 0.0.0-stage → 0.1.0

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.md CHANGED
@@ -1,3 +1,7 @@
1
- # Temporary Holding Version
1
+ # DSH Workspace Pulse
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 在 DeepSeek Harness Web 侧栏中,折叠的 Workspace 会显示正在运行的会话数。计数归零时自动隐藏。工作区树视图中的父 Workspace 也会汇总子 Workspace 的运行会话。
4
+
5
+ 已在 DeepSeek Harness Web `0.2.3-alpha.2` 验证。
6
+
7
+ [安装指南](manual/README.md)
@@ -0,0 +1,3 @@
1
+ - insert:
2
+ - id: dsh-workspace-pulse
3
+ name: dsh-workspace-pulse
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DeepSeek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/client.js ADDED
@@ -0,0 +1,1154 @@
1
+ window.__ModuleLoader__.load({ id: "dsh-workspace-pulse", factory: (require) => { const module = { exports: {} };
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/client.js
21
+ var client_exports = {};
22
+ __export(client_exports, {
23
+ apply: () => apply,
24
+ inject: () => inject
25
+ });
26
+ module.exports = __toCommonJS(client_exports);
27
+
28
+ // node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/client/sessions/directories.js
29
+ function projectedString(values, key) {
30
+ if (values === void 0)
31
+ return void 0;
32
+ const value = Reflect.get(values, key);
33
+ return typeof value === "string" ? value : void 0;
34
+ }
35
+ function selectSessionDirectory(state, sessionId) {
36
+ return projectedString(state.projectionsBySession[sessionId]?.values, "workingDirectory") ?? projectedString(state.byId[sessionId]?.projectionValues, "workingDirectory") ?? state.byId[sessionId]?.cwd;
37
+ }
38
+
39
+ // node_modules/fuzzysort/fuzzysort.js
40
+ function highlight(result, open = "<b>", close = "</b>", threshold = 0.5) {
41
+ let callback = typeof open === "function" ? open : null;
42
+ let target = result.target;
43
+ if (result._bestKeyScore !== void 0 && normalizeScore(result._score) < normalizeScore(result._bestKeyScore) * threshold) return callback ? [target] : target;
44
+ let raw = result._indexes;
45
+ let indexes = raw === void 0 ? result.indexes : raw.slice(0, raw.len ?? raw.length).sort((a, b) => a - b);
46
+ if (!indexes.length) return callback ? [target] : target;
47
+ let output = callback ? [] : "";
48
+ let lastIndex = 0;
49
+ let matchI = 0;
50
+ for (let i = 0; i < indexes.length; ) {
51
+ let start = indexes[i++];
52
+ let end = start + 1;
53
+ while (indexes[i] === end) {
54
+ i++;
55
+ end++;
56
+ }
57
+ let before = target.slice(lastIndex, start);
58
+ let match = target.slice(start, end);
59
+ if (callback) output.push(before, callback(match, matchI++));
60
+ else output += before + open + match + close;
61
+ lastIndex = end;
62
+ }
63
+ if (callback) output.push(target.slice(lastIndex));
64
+ else output += target.slice(lastIndex);
65
+ return output;
66
+ }
67
+ function prepTarget(target) {
68
+ if (isPrepared(target)) target = target.target;
69
+ else if (typeof target === "number") target = "" + target;
70
+ else if (typeof target !== "string") target = "";
71
+ let info = lowerInfo(target);
72
+ return newResult(target, -INF, null, info._lower, info.lowerCodes, info.bitflags);
73
+ }
74
+ function remapCharacter(char) {
75
+ let remapped = remappings[char];
76
+ if (remapped !== void 0) return remapped;
77
+ if (char.charCodeAt(0) < 128) return char;
78
+ remapped = char.normalize("NFKD").replace(/[\u0300-\u036f]/g, "");
79
+ return remapped.length === 1 ? remapped : char;
80
+ }
81
+ function remapChars(value) {
82
+ if (customAsciiRemappings) return value.replace(/[\s\S]/g, remapCharacter);
83
+ return /[^\x00-\x7F]|[\\"`]/.test(value) ? value.replace(/[^\x00-\x7F]|[\\"`]/g, remapCharacter) : value;
84
+ }
85
+ function lowerInfo(value) {
86
+ return lowerInfoRemapped(remapChars(value));
87
+ }
88
+ function lowerInfoRemapped(value) {
89
+ let lower = value.toLowerCase();
90
+ let lowerCodes = [];
91
+ let bitflags = 0;
92
+ let hasSpace = false;
93
+ for (let i = 0; i < lower.length; i++) {
94
+ let code = lowerCodes[i] = lower.charCodeAt(i);
95
+ if (code === 32) {
96
+ hasSpace = true;
97
+ bitflags |= SPACE_BIT;
98
+ continue;
99
+ }
100
+ let bit = code >= 97 && code <= 122 ? code - 97 : code >= 48 && code <= 57 ? 26 : code <= 127 ? 30 : 31;
101
+ bitflags |= 1 << bit;
102
+ }
103
+ return { lowerCodes, bitflags, hasSpace, _lower: lower };
104
+ }
105
+ var Result = class {
106
+ get ["indexes"]() {
107
+ return this._indexes.slice(0, this._indexes.len).sort((a, b) => a - b);
108
+ }
109
+ set ["indexes"](value) {
110
+ this._indexes = value;
111
+ }
112
+ ["highlight"](open, close, threshold) {
113
+ return highlight(this, open, close, threshold);
114
+ }
115
+ get ["score"]() {
116
+ return normalizeScore(this._score);
117
+ }
118
+ };
119
+ function newResult(target, score = -INF, obj = null, lower = "", lowerCodes = null, bitflags = 0) {
120
+ let result = new Result();
121
+ result.target = target;
122
+ result.obj = obj;
123
+ result._score = score;
124
+ result._indexes = [];
125
+ result._targetLower = lower;
126
+ result._targetLowerCodes = lowerCodes;
127
+ result._nextBeginningIndexes = null;
128
+ result._beginnings = null;
129
+ result._beginningsLen = 0;
130
+ result._singleMatchCode = result._singleMatchIndex = -1;
131
+ result._singleMatchStrict = false;
132
+ result._bitflags = bitflags;
133
+ return result;
134
+ }
135
+ var normalizeScore = (value) => value === -INF ? 0 : value > 1 ? value : Math.E ** (((-value + 1) ** 0.04307 - 1) * -2);
136
+ var denormalizeScore = (value) => value === 0 ? -INF : value > 1 ? value : 1 - Math.pow(Math.log(value) / -2 + 1, 1 / 0.04307);
137
+ var GOOD_PART_SCORE = denormalizeScore(0.5);
138
+ var isPrepared = (value) => typeof value === "object" && typeof value?._bitflags === "number";
139
+ function createHeap() {
140
+ let items = [];
141
+ let length = 0;
142
+ function down() {
143
+ let index = 0;
144
+ let item = items[0];
145
+ for (let child = 1; child < length; child = 1 + index * 2) {
146
+ let right = child + 1;
147
+ index = right < length && items[right]._score < items[child]._score ? right : child;
148
+ items[index - 1 >> 1] = items[index];
149
+ }
150
+ for (let parent = index - 1 >> 1; index > 0 && item._score < items[parent]._score; parent = (index = parent) - 1 >> 1) {
151
+ items[index] = items[parent];
152
+ }
153
+ items[index] = item;
154
+ }
155
+ return {
156
+ add(item) {
157
+ let index = length++;
158
+ for (let parent = index - 1 >> 1; index > 0 && item._score < items[parent]._score; parent = (index = parent) - 1 >> 1) {
159
+ items[index] = items[parent];
160
+ }
161
+ items[index] = item;
162
+ },
163
+ poll() {
164
+ if (!length) return;
165
+ let root = items[0];
166
+ let last = items[--length];
167
+ items[length] = void 0;
168
+ if (length) {
169
+ items[0] = last;
170
+ down();
171
+ }
172
+ return root;
173
+ },
174
+ peek() {
175
+ return length ? items[0] : void 0;
176
+ },
177
+ replaceTop(item) {
178
+ items[0] = item;
179
+ down();
180
+ },
181
+ clear() {
182
+ items.length = length = 0;
183
+ }
184
+ };
185
+ }
186
+ var INF = Infinity;
187
+ var SPACE_BIT = 1 << 27;
188
+ var noResults = [];
189
+ noResults.total = 0;
190
+ var remappings = {};
191
+ var remapFrom = '\\"`\u2018\u2019\u201A\u201B\u201C\u201D\u201E\u201F\xAB\xBB\u2039\u203A\u2010\u2013\u2014\u2212\u2044\u2215\u2026\xF8\xD8\u0142\u0141\u0111\u0110\xF0\xD0\u0131\u0127\u0126\u0167\u0166';
192
+ var remapTo = "/''''''''''''''----//.oOlLdDdDihHtT";
193
+ for (let i = 0; i < remapFrom.length; i++) remappings[remapFrom[i]] = remapTo[i];
194
+ var customAsciiRemappings = false;
195
+ var heap = createHeap();
196
+ var noTarget = prepTarget("");
197
+
198
+ // node_modules/@deepseek-ai/dsh-util-values/lib/index.js
199
+ var SIMPLE_ESCAPES = {
200
+ '"': '"',
201
+ "\\": "\\",
202
+ "/": "/",
203
+ b: "\b",
204
+ f: "\f",
205
+ n: "\n",
206
+ r: "\r",
207
+ t: " "
208
+ };
209
+ var CONTENT_ESCAPE = /[\\\u0000-\u001f]/u;
210
+ function isWhitespace(c) {
211
+ return c === " " || c === "\n" || c === "\r" || c === " ";
212
+ }
213
+ function isHex(c) {
214
+ return c >= "0" && c <= "9" || c >= "a" && c <= "f" || c >= "A" && c <= "F";
215
+ }
216
+ var PartialArguments = class PartialArguments2 {
217
+ /** The view of a call with no arguments available. */
218
+ static EMPTY = PartialArguments2.fromObject({});
219
+ /**
220
+ * View finished argument text without scanning it until a reader asks.
221
+ * @param text - the complete argument JSON text.
222
+ * @returns a sealed view.
223
+ */
224
+ static fromText(text) {
225
+ const view = new PartialArguments2();
226
+ view.append(text);
227
+ view.sealed = true;
228
+ return view;
229
+ }
230
+ /**
231
+ * View an already parsed argument payload, such as a PTC dispatch object.
232
+ * @param value - the parsed argument value.
233
+ * @returns a sealed view; a non-object payload has no fields.
234
+ */
235
+ static fromObject(value) {
236
+ const view = new PartialArguments2();
237
+ view.object = typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
238
+ view.sealed = true;
239
+ return view;
240
+ }
241
+ /**
242
+ * The source: text so far or a parsed object, plus whether it can still grow.
243
+ * These are the only enumerable fields, so two views over the same source
244
+ * compare equal structurally however far each has been read.
245
+ */
246
+ chunks = [];
247
+ object;
248
+ sealed = false;
249
+ #ends = [];
250
+ #size = 0;
251
+ #consumed = 0;
252
+ #mode = "root";
253
+ #escape = false;
254
+ #keyStart = 0;
255
+ #keyEscaped = false;
256
+ #key = "";
257
+ #current = null;
258
+ #nestedEnds = [];
259
+ #nestedInString = false;
260
+ #invalidAt;
261
+ #invalidValue = false;
262
+ #entries = /* @__PURE__ */ new Map();
263
+ #order = [];
264
+ #reads = /* @__PURE__ */ new Map();
265
+ /** Whether this view rejects further appends; does not scan text or register reads. */
266
+ get isSealed() {
267
+ return this.sealed;
268
+ }
269
+ /** Whether indexing or a content read found invalid JSON; unread value contents are not validated. */
270
+ get invalid() {
271
+ this.scan();
272
+ return this.#mode === "invalid" || this.#invalidValue;
273
+ }
274
+ /**
275
+ * Retain streamed argument text without scanning or comparing observed answers.
276
+ * @param fragment - the text following every fragment appended before.
277
+ */
278
+ append(fragment) {
279
+ if (this.sealed) throw new Error("PartialArguments: cannot append to a sealed view");
280
+ if (fragment.length === 0) return;
281
+ this.chunks.push(fragment);
282
+ this.#size += fragment.length;
283
+ this.#ends.push(this.#size);
284
+ }
285
+ /**
286
+ * Reconcile a streamed prefix with authoritative complete text without joining the fragments.
287
+ * @param text - the final argument text, which replaces missing or conflicting deltas.
288
+ * @returns this view sealed with its caches retained when every character matches; otherwise a new sealed view.
289
+ */
290
+ settle(text) {
291
+ if (this.object !== void 0 || text.length !== this.#size) return PartialArguments2.fromText(text);
292
+ let offset = 0;
293
+ for (const chunk of this.chunks) {
294
+ if (!text.startsWith(chunk, offset)) return PartialArguments2.fromText(text);
295
+ offset += chunk.length;
296
+ }
297
+ this.chunks = text.length === 0 ? [] : [text];
298
+ this.#ends = text.length === 0 ? [] : [text.length];
299
+ this.sealed = true;
300
+ return this;
301
+ }
302
+ /**
303
+ * Compare observed answers and advance their publication baseline. Unread views remain unscanned.
304
+ * @returns whether any observed answer changed since its first read or the preceding refresh.
305
+ */
306
+ refresh() {
307
+ if (this.#reads.size === 0) return false;
308
+ this.scan();
309
+ let changed = false;
310
+ let completions = false;
311
+ for (const read of this.#reads.values()) {
312
+ if (read.completion) {
313
+ completions = true;
314
+ continue;
315
+ }
316
+ changed = this.refreshRead(read) || changed;
317
+ }
318
+ if (completions) {
319
+ for (const read of this.#reads.values()) if (read.completion) changed = this.refreshRead(read) || changed;
320
+ }
321
+ if (this.sealed) this.#reads.clear();
322
+ return changed;
323
+ }
324
+ refreshRead(read) {
325
+ const now = read.answer();
326
+ if (Object.is(now, read.last)) return false;
327
+ read.last = now;
328
+ return true;
329
+ }
330
+ /**
331
+ * Check whether no further fields can arrive.
332
+ * @returns whether the outer object closed, indexing failed, or the view is sealed; unread values are not validated.
333
+ */
334
+ closed() {
335
+ return this.remember("closed", "", () => this.closedNow());
336
+ }
337
+ /**
338
+ * List discovered fields in first-appearance order.
339
+ * @returns top-level keys seen so far, in first-appearance order.
340
+ */
341
+ keys() {
342
+ return this.remember("keys", "", () => this.keysNow(), (keys) => keys.length);
343
+ }
344
+ /**
345
+ * Check whether a top-level field has appeared.
346
+ * @param key - argument name.
347
+ * @returns whether the field has appeared (a string opened or another value began).
348
+ */
349
+ has(key) {
350
+ return this.remember("has", key, () => this.hasNow(key));
351
+ }
352
+ /**
353
+ * Check whether a field's closing delimiter has arrived, without validating its contents.
354
+ * @param key - argument name.
355
+ * @returns whether its delimiter arrived and no content reader has reported an error for this value.
356
+ */
357
+ complete(key) {
358
+ return this.remember("complete", key, () => this.completeNow(key));
359
+ }
360
+ /**
361
+ * Read string length without materializing its text.
362
+ * @param key - argument name.
363
+ * @param options - change granularity for a streaming string.
364
+ * @returns decoded UTF-16 length of the string field so far; undefined when absent or not a string.
365
+ */
366
+ stringLength(key, options) {
367
+ const step = Math.max(1, Math.floor(options?.step ?? 1));
368
+ const offset = options?.offset ?? 0;
369
+ return this.remember(`length:${step}:${offset}`, key, () => this.lengthNow(key), (length) => length === void 0 ? void 0 : Math.ceil((length + offset) / step));
370
+ }
371
+ /**
372
+ * Check a string against a decoded UTF-16 length limit without materializing it.
373
+ * @param key - argument name.
374
+ * @param maxLength - decoded UTF-16 limit, floored to at least zero.
375
+ * @returns whether the string is longer than the limit; false when absent or not a string.
376
+ */
377
+ stringExceeds(key, maxLength) {
378
+ const limit = Math.max(0, Math.floor(maxLength));
379
+ return this.remember(`exceeds:${limit}`, key, () => (this.lengthNow(key, limit + 1) ?? 0) > limit);
380
+ }
381
+ /**
382
+ * Read a decoded string, including a streaming prefix.
383
+ * @param key - argument name.
384
+ * @returns the string field's decoded text so far; undefined when absent or not a string.
385
+ */
386
+ text(key) {
387
+ return this.remember("text", key, () => this.textNow(key));
388
+ }
389
+ /**
390
+ * Read at most the first decoded UTF-16 units of a string.
391
+ * @param key - argument name.
392
+ * @param maxLength - maximum decoded UTF-16 length, floored to at least one.
393
+ * @returns the bounded string prefix; undefined when absent or not a string.
394
+ */
395
+ textPrefix(key, maxLength) {
396
+ const limit = Math.max(1, Math.floor(maxLength));
397
+ return this.remember(`prefix:${limit}`, key, () => this.textPrefixNow(key, limit));
398
+ }
399
+ /**
400
+ * Read a completed non-string argument.
401
+ * @param key - argument name.
402
+ * @returns the parsed non-string value once it closed; undefined while open, absent, or a string.
403
+ */
404
+ value(key) {
405
+ return this.remember("value", key, () => this.valueNow(key));
406
+ }
407
+ /** Answer a question and, on a streaming view, remember it for change detection. */
408
+ remember(kind, key, read, comparison) {
409
+ this.scan();
410
+ const result = read();
411
+ if (!this.sealed) {
412
+ const id = `${kind}/${key}`;
413
+ if (!this.#reads.has(id)) this.#reads.set(id, {
414
+ completion: kind === "complete",
415
+ answer: comparison === void 0 ? read : () => comparison(read()),
416
+ last: comparison === void 0 ? result : comparison(result)
417
+ });
418
+ }
419
+ return result;
420
+ }
421
+ closedNow() {
422
+ return this.sealed || this.#mode === "closed" || this.#mode === "invalid";
423
+ }
424
+ keysNow() {
425
+ return this.object === void 0 ? this.#order : Object.keys(this.object);
426
+ }
427
+ hasNow(key) {
428
+ return this.object === void 0 ? this.#entries.has(key) : Object.hasOwn(this.object, key);
429
+ }
430
+ completeNow(key) {
431
+ if (this.object !== void 0) return Object.hasOwn(this.object, key);
432
+ const entry = this.#entries.get(key);
433
+ return entry !== void 0 && entry.end >= 0 && (entry.kind === "string" ? entry.invalidAt === void 0 : !entry.invalid);
434
+ }
435
+ lengthNow(key, limit = Number.POSITIVE_INFINITY) {
436
+ if (this.object !== void 0) {
437
+ const field = Object.hasOwn(this.object, key) ? this.object[key] : void 0;
438
+ return typeof field === "string" ? field.length : void 0;
439
+ }
440
+ const entry = this.#entries.get(key);
441
+ if (entry?.kind !== "string") return void 0;
442
+ if (entry.text !== void 0 && entry.text.at === entry.end) return entry.text.length;
443
+ const read = entry.length ??= {
444
+ at: entry.start,
445
+ length: 0,
446
+ text: ""
447
+ };
448
+ this.readString(entry, read, limit, false);
449
+ return read.length;
450
+ }
451
+ textNow(key) {
452
+ if (this.object !== void 0) {
453
+ const field = Object.hasOwn(this.object, key) ? this.object[key] : void 0;
454
+ return typeof field === "string" ? field : void 0;
455
+ }
456
+ const entry = this.#entries.get(key);
457
+ if (entry?.kind !== "string") return void 0;
458
+ if (entry.text === void 0 && entry.end >= 0 && entry.needsDecoding && entry.invalidAt === void 0) {
459
+ let text;
460
+ try {
461
+ text = JSON.parse(`"${this.slice(entry.start, entry.end)}"`);
462
+ } catch (_error) {
463
+ }
464
+ if (text !== void 0) entry.text = {
465
+ at: entry.end,
466
+ length: text.length,
467
+ text
468
+ };
469
+ }
470
+ const read = entry.text ??= {
471
+ at: entry.start,
472
+ length: 0,
473
+ text: ""
474
+ };
475
+ this.readString(entry, read, Number.POSITIVE_INFINITY, true);
476
+ return read.text;
477
+ }
478
+ textPrefixNow(key, maxLength) {
479
+ if (this.object !== void 0) {
480
+ const field = Object.hasOwn(this.object, key) ? this.object[key] : void 0;
481
+ return typeof field === "string" ? field.slice(0, maxLength) : void 0;
482
+ }
483
+ const entry = this.#entries.get(key);
484
+ if (entry?.kind !== "string") return void 0;
485
+ const prefixes = entry.prefixes ??= /* @__PURE__ */ new Map();
486
+ let read = prefixes.get(maxLength);
487
+ if (read === void 0) {
488
+ read = {
489
+ at: entry.start,
490
+ length: 0,
491
+ text: ""
492
+ };
493
+ prefixes.set(maxLength, read);
494
+ }
495
+ this.readString(entry, read, maxLength, true);
496
+ return read.text;
497
+ }
498
+ valueNow(key) {
499
+ if (this.object !== void 0) {
500
+ if (!Object.hasOwn(this.object, key)) return void 0;
501
+ const field = this.object[key];
502
+ return typeof field === "string" ? void 0 : field;
503
+ }
504
+ const entry = this.#entries.get(key);
505
+ if (entry?.kind !== "value" || entry.end < 0 || entry.invalid) return void 0;
506
+ if (entry.parsed === void 0) try {
507
+ entry.parsed = JSON.parse(this.slice(entry.start, entry.end));
508
+ } catch (_error) {
509
+ entry.invalid = true;
510
+ this.#invalidValue = true;
511
+ }
512
+ return entry.parsed;
513
+ }
514
+ chunkAt(at) {
515
+ let low = 0;
516
+ let high = this.#ends.length;
517
+ while (low < high) {
518
+ const mid = low + high >>> 1;
519
+ if (this.#ends[mid] <= at) low = mid + 1;
520
+ else high = mid;
521
+ }
522
+ return low;
523
+ }
524
+ /** Materialize only a requested range, never the cumulative source. */
525
+ slice(start, end) {
526
+ if (start >= end) return "";
527
+ const first = this.chunkAt(start);
528
+ const last = this.chunkAt(end - 1);
529
+ const base = first === 0 ? 0 : this.#ends[first - 1];
530
+ if (first === last) return this.chunks[first].slice(start - base, end - base);
531
+ const parts = [this.chunks[first].slice(start - base)];
532
+ for (let i = first + 1; i < last; i++) parts.push(this.chunks[i]);
533
+ parts.push(this.chunks[last].slice(0, end - this.#ends[last - 1]));
534
+ return parts.join("");
535
+ }
536
+ readString(entry, read, limit, materialize) {
537
+ const end = Math.min(entry.end < 0 ? this.#consumed : entry.end, entry.invalidAt ?? Number.POSITIVE_INFINITY, this.#invalidAt ?? Number.POSITIVE_INFINITY);
538
+ if (!entry.needsDecoding) {
539
+ const length = Math.min(end - read.at, limit - read.length);
540
+ if (length <= 0) return;
541
+ if (materialize) read.text += this.slice(read.at, read.at + length);
542
+ read.at += length;
543
+ read.length += length;
544
+ return;
545
+ }
546
+ let chunkIndex = this.chunkAt(read.at);
547
+ while (read.at < end && read.length < limit) {
548
+ const base = chunkIndex === 0 ? 0 : this.#ends[chunkIndex - 1];
549
+ const chunk = this.chunks[chunkIndex];
550
+ const remaining = chunk.slice(read.at - base, Math.min(chunk.length, end - base));
551
+ const boundary = remaining.search(CONTENT_ESCAPE);
552
+ const length = Math.min(boundary < 0 ? remaining.length : boundary, limit - read.length);
553
+ if (length > 0) {
554
+ if (materialize) read.text += remaining.slice(0, length);
555
+ read.at += length;
556
+ read.length += length;
557
+ if (read.at === base + chunk.length) chunkIndex++;
558
+ continue;
559
+ }
560
+ const type = remaining.length > 1 ? remaining[1] : read.at + 1 < end ? this.chunks[chunkIndex + 1][0] : void 0;
561
+ let decoded;
562
+ let width = 2;
563
+ if (remaining[0] === "\\" && type === void 0 && entry.end < 0) return;
564
+ if (remaining[0] === "\\" && type === "u") {
565
+ const hex = this.slice(read.at + 2, Math.min(end, read.at + 6));
566
+ let valid = true;
567
+ for (let i = 0; i < hex.length; i++) if (!isHex(hex[i])) valid = false;
568
+ if (valid) {
569
+ if (hex.length < 4 && entry.end < 0) return;
570
+ if (hex.length === 4) decoded = String.fromCharCode(Number.parseInt(hex, 16));
571
+ }
572
+ width = 6;
573
+ } else if (remaining[0] === "\\" && type !== void 0) decoded = SIMPLE_ESCAPES[type];
574
+ if (decoded === void 0) {
575
+ entry.invalidAt = read.at;
576
+ this.#invalidValue = true;
577
+ return;
578
+ }
579
+ if (materialize) read.text += decoded;
580
+ read.length++;
581
+ read.at += width;
582
+ while (chunkIndex < this.chunks.length && read.at >= this.#ends[chunkIndex]) chunkIndex++;
583
+ }
584
+ }
585
+ /** Locate new field ranges without decoding or parsing their contents. */
586
+ scan() {
587
+ if (this.object !== void 0 || this.#consumed === this.#size) return;
588
+ for (let i = this.chunkAt(this.#consumed); i < this.chunks.length && this.#invalidAt === void 0; i++) {
589
+ const pending = this.chunks[i];
590
+ const base = i === 0 ? 0 : this.#ends[i - 1];
591
+ for (let index = this.#consumed - base; index < pending.length && this.#mode !== "invalid"; index++) {
592
+ if (this.#mode === "string" || this.#mode === "nested" && this.#nestedInString) {
593
+ const end = this.stringBoundary(pending, index);
594
+ this.#consumed += end - index;
595
+ index = end;
596
+ if (index === pending.length) break;
597
+ }
598
+ this.step(pending[index], this.#consumed);
599
+ this.#consumed++;
600
+ }
601
+ }
602
+ }
603
+ /** Only raw quotes and their preceding backslash runs can terminate a string. */
604
+ stringBoundary(fragment, start) {
605
+ let at = start;
606
+ while (true) {
607
+ const quote = fragment.indexOf('"', at);
608
+ const end = quote < 0 ? fragment.length : quote;
609
+ if (this.#mode === "string") {
610
+ const entry = this.#current;
611
+ if (!entry.needsDecoding && CONTENT_ESCAPE.test(fragment.slice(at, end))) entry.needsDecoding = true;
612
+ }
613
+ let slashStart = end;
614
+ while (slashStart > at && fragment[slashStart - 1] === "\\") slashStart--;
615
+ const escaped = (end - slashStart) % 2 === 1 !== (slashStart === at && this.#escape);
616
+ this.#escape = quote < 0 && escaped;
617
+ if (quote < 0 || !escaped) return end;
618
+ at = quote + 1;
619
+ }
620
+ }
621
+ step(c, at) {
622
+ switch (this.#mode) {
623
+ case "root":
624
+ if (isWhitespace(c)) return;
625
+ if (c === "{") {
626
+ this.#mode = "key-or-end";
627
+ return;
628
+ }
629
+ this.fail();
630
+ return;
631
+ case "key-or-end":
632
+ if (isWhitespace(c)) return;
633
+ if (c === "}") {
634
+ this.#mode = "closed";
635
+ return;
636
+ }
637
+ if (c === '"') {
638
+ this.beginKey(at);
639
+ return;
640
+ }
641
+ this.fail();
642
+ return;
643
+ case "key-only":
644
+ if (isWhitespace(c)) return;
645
+ if (c === '"') {
646
+ this.beginKey(at);
647
+ return;
648
+ }
649
+ this.fail();
650
+ return;
651
+ case "key":
652
+ this.stepKey(c, at);
653
+ return;
654
+ case "colon":
655
+ if (isWhitespace(c)) return;
656
+ if (c === ":") {
657
+ this.#mode = "value";
658
+ return;
659
+ }
660
+ this.fail();
661
+ return;
662
+ case "value":
663
+ this.beginValue(c, at);
664
+ return;
665
+ case "string": {
666
+ const entry = this.#current;
667
+ entry.end = at;
668
+ this.#current = null;
669
+ this.#mode = "comma-or-end";
670
+ return;
671
+ }
672
+ case "scalar":
673
+ this.stepScalar(c, at);
674
+ return;
675
+ case "nested":
676
+ this.stepNested(c, at);
677
+ return;
678
+ case "comma-or-end":
679
+ if (isWhitespace(c)) return;
680
+ if (c === ",") {
681
+ this.#mode = "key-only";
682
+ return;
683
+ }
684
+ if (c === "}") {
685
+ this.#mode = "closed";
686
+ return;
687
+ }
688
+ this.fail();
689
+ return;
690
+ case "closed":
691
+ if (isWhitespace(c)) return;
692
+ this.fail();
693
+ return;
694
+ /* v8 ignore next 2 -- scan() stops stepping once the view is invalid. */
695
+ case "invalid":
696
+ return;
697
+ /* v8 ignore next 2 -- Every scanner mode has a handler above. */
698
+ default:
699
+ assertNever(this.#mode);
700
+ }
701
+ }
702
+ fail() {
703
+ this.#invalidAt = this.#consumed;
704
+ this.#mode = "invalid";
705
+ this.#current = null;
706
+ }
707
+ beginKey(at) {
708
+ this.#mode = "key";
709
+ this.#keyStart = at + 1;
710
+ this.#keyEscaped = false;
711
+ this.#escape = false;
712
+ }
713
+ stepKey(c, at) {
714
+ if (c < " ") {
715
+ this.fail();
716
+ return;
717
+ }
718
+ if (this.#escape) {
719
+ this.#escape = false;
720
+ return;
721
+ }
722
+ if (c === "\\") {
723
+ this.#escape = true;
724
+ this.#keyEscaped = true;
725
+ return;
726
+ }
727
+ if (c !== '"') return;
728
+ const raw = this.slice(this.#keyStart, at);
729
+ if (this.#keyEscaped) try {
730
+ this.#key = JSON.parse(`"${raw}"`);
731
+ } catch (_error) {
732
+ this.fail();
733
+ return;
734
+ }
735
+ else this.#key = raw;
736
+ this.#mode = "colon";
737
+ }
738
+ open(entry) {
739
+ if (!this.#entries.has(this.#key)) this.#order.push(this.#key);
740
+ this.#entries.set(this.#key, entry);
741
+ this.#current = entry;
742
+ }
743
+ beginValue(c, at) {
744
+ if (isWhitespace(c)) return;
745
+ if (c === '"') {
746
+ this.open({
747
+ kind: "string",
748
+ start: at + 1,
749
+ end: -1,
750
+ needsDecoding: false,
751
+ invalidAt: void 0,
752
+ length: void 0,
753
+ text: void 0,
754
+ prefixes: void 0
755
+ });
756
+ this.#escape = false;
757
+ this.#mode = "string";
758
+ return;
759
+ }
760
+ if (c === "}" || c === "," || c === ":" || c === "]") {
761
+ this.fail();
762
+ return;
763
+ }
764
+ this.open({
765
+ kind: "value",
766
+ start: at,
767
+ end: -1,
768
+ parsed: void 0,
769
+ invalid: false
770
+ });
771
+ if (c === "{" || c === "[") {
772
+ this.#mode = "nested";
773
+ this.#nestedEnds = [c === "{" ? "}" : "]"];
774
+ this.#nestedInString = false;
775
+ this.#escape = false;
776
+ return;
777
+ }
778
+ this.#mode = "scalar";
779
+ }
780
+ stepScalar(c, at) {
781
+ if (c !== "," && c !== "}" && !isWhitespace(c)) return;
782
+ this.closeValue(at);
783
+ this.#mode = c === "," ? "key-only" : c === "}" ? "closed" : "comma-or-end";
784
+ }
785
+ stepNested(c, at) {
786
+ if (this.#nestedInString) {
787
+ this.#nestedInString = false;
788
+ return;
789
+ }
790
+ if (c === '"') {
791
+ this.#nestedInString = true;
792
+ return;
793
+ }
794
+ if (c === "{" || c === "[") {
795
+ this.#nestedEnds.push(c === "{" ? "}" : "]");
796
+ return;
797
+ }
798
+ if (c === "}" || c === "]") {
799
+ if (this.#nestedEnds.pop() !== c) {
800
+ this.fail();
801
+ return;
802
+ }
803
+ if (this.#nestedEnds.length === 0) {
804
+ this.closeValue(at + 1);
805
+ this.#mode = "comma-or-end";
806
+ }
807
+ }
808
+ }
809
+ closeValue(end) {
810
+ const entry = this.#current;
811
+ entry.end = end;
812
+ this.#current = null;
813
+ }
814
+ };
815
+ function assertNever(value, context) {
816
+ const rendered = JSON.stringify(value) ?? String(value);
817
+ throw new Error(`unreachable variant${context ? ` in ${context}` : ""}: ${rendered}`);
818
+ }
819
+
820
+ // node_modules/@deepseek-ai/dsh-client-ui-workspace/src/client/tree.ts
821
+ var UNGROUPED_KEY = "";
822
+ function owningGroupKey(workspaces, sessionId) {
823
+ return workspaces.find((workspace) => workspace.sessionIds.includes(sessionId))?.workspaceId ?? UNGROUPED_KEY;
824
+ }
825
+ function mainSessionId(list) {
826
+ return Object.values(list.byId).find((session) => (session.retainedBy.mainView ?? 0) > 0)?.id;
827
+ }
828
+ function orderByRecency(sessionIds, summaries) {
829
+ return sessionIds.flatMap((id) => {
830
+ const summary = summaries[id];
831
+ if (summary === void 0) return [];
832
+ return [{ id, rank: summary.updatedAt }];
833
+ }).sort((a, b) => {
834
+ if (a.rank !== b.rank) return b.rank - a.rank;
835
+ return a.id < b.id ? -1 : 1;
836
+ }).map((member) => member.id);
837
+ }
838
+ function reconcileManualOrder(memberIds, savedOrder, summaries, rowState) {
839
+ const members = new Map(memberIds.map((id) => [id, id]));
840
+ const included = /* @__PURE__ */ new Set();
841
+ const ordered = [];
842
+ for (const key of savedOrder ?? []) {
843
+ const id = members.get(key);
844
+ if (id === void 0 || included.has(key)) continue;
845
+ ordered.push(id);
846
+ included.add(key);
847
+ }
848
+ const archived = new Set(rowState?.archivedSessionIds);
849
+ const pins = [];
850
+ for (const sessionId of rowState?.pinnedSessionIds ?? []) {
851
+ const id = members.get(sessionId);
852
+ if (id === void 0 || included.has(id) || archived.has(id) || summaries[id] === void 0) continue;
853
+ pins.push(id);
854
+ included.add(id);
855
+ }
856
+ const ordinary = [];
857
+ const archives = [];
858
+ for (const id of orderByRecency([...members.values()].filter((id2) => !included.has(id2)), summaries)) {
859
+ if (archived.has(id)) archives.push(id);
860
+ else ordinary.push(id);
861
+ }
862
+ return [...pins, ...ordered, ...ordinary, ...archives];
863
+ }
864
+ function sessionVisible(session, current, archived, archivedFilter) {
865
+ if (session.origin === "subagent") return false;
866
+ if (session.blank && session.id !== current) return false;
867
+ switch (archivedFilter) {
868
+ case "default":
869
+ return !archived.has(session.id);
870
+ case "show":
871
+ return true;
872
+ case "only":
873
+ return archived.has(session.id);
874
+ /* v8 ignore next 2 -- closed-union backstop; only reached if the filter is forged */
875
+ default:
876
+ return assertNever(archivedFilter);
877
+ }
878
+ }
879
+ function sectionMembers(members, pinned, archived) {
880
+ const placeholders = [];
881
+ const leading = [];
882
+ const rest = [];
883
+ for (const member of members) {
884
+ if (member.blank) placeholders.push(member);
885
+ else if (!archived.has(member.id) && pinned.has(member.id)) leading.push(member);
886
+ else rest.push(member);
887
+ }
888
+ return [...placeholders, ...leading, ...rest];
889
+ }
890
+ function sessionTitle(session) {
891
+ return session.blank ? "" : session.title?.trim() ?? "";
892
+ }
893
+ function buildGroup(key, workspaceId, cwd, createdAt, label, members) {
894
+ return { key, workspaceId, cwd, createdAt, label, sessions: [...members] };
895
+ }
896
+ function orderedUngrouped(members, stored, summaries) {
897
+ const byId = new Map(members.map((session) => [session.id, session]));
898
+ const ids = stored === void 0 ? orderByRecency(members.map((session) => session.id), summaries) : reconcileManualOrder(members.map((session) => session.id), stored, summaries);
899
+ return ids.flatMap((id) => {
900
+ const session = byId.get(id);
901
+ return session === void 0 ? [] : [session];
902
+ });
903
+ }
904
+ function groupByWorkspace(list, workspaces, archived, archivedFilter, ungroupedOrder) {
905
+ const current = mainSessionId(list);
906
+ const groups = [];
907
+ const accounted = /* @__PURE__ */ new Set();
908
+ for (const workspace of workspaces) {
909
+ const members = [];
910
+ for (const id of workspace.sessionIds) {
911
+ const summary = list.byId[id];
912
+ if (summary === void 0) continue;
913
+ accounted.add(id);
914
+ if (!sessionVisible(summary, current, archived, archivedFilter)) continue;
915
+ members.push(summary);
916
+ }
917
+ if (archivedFilter === "only" && members.length === 0) continue;
918
+ groups.push(buildGroup(
919
+ workspace.workspaceId,
920
+ workspace.workspaceId,
921
+ workspace.path,
922
+ Date.parse(workspace.createdAt),
923
+ workspace.title,
924
+ members
925
+ ));
926
+ }
927
+ const stray = list.ids.map((id) => list.byId[id]).filter((s) => s !== void 0 && !accounted.has(s.id) && sessionVisible(s, current, archived, archivedFilter));
928
+ if (stray.length > 0) {
929
+ groups.push(buildGroup(
930
+ UNGROUPED_KEY,
931
+ void 0,
932
+ void 0,
933
+ void 0,
934
+ "",
935
+ orderedUngrouped(stray, ungroupedOrder, list.byId)
936
+ ));
937
+ }
938
+ return groups;
939
+ }
940
+ function visiblePendingKind(kind) {
941
+ switch (kind) {
942
+ case "approval":
943
+ case "plan-review":
944
+ case "question":
945
+ return kind;
946
+ default:
947
+ return void 0;
948
+ }
949
+ }
950
+ function runningChildCount(list, parentId, statuses) {
951
+ return list.projectionsBySession[parentId]?.values.subagentCatalog?.reduce(
952
+ (count, child) => count + ((statuses.get(child.id)?.running ?? list.byId[child.id]?.running) === true ? 1 : 0),
953
+ 0
954
+ ) ?? 0;
955
+ }
956
+ function sessionNode(s, list, statuses, pinned, archived) {
957
+ const status = statuses.get(s.id);
958
+ const pendingInteraction = visiblePendingKind(status?.pendingInteraction?.kind);
959
+ const root = selectSessionDirectory(list, s.id);
960
+ return {
961
+ id: s.id,
962
+ title: sessionTitle(s),
963
+ blank: s.blank,
964
+ running: status?.running ?? s.running,
965
+ runningSubagentCount: runningChildCount(list, s.id, statuses),
966
+ completed: status?.completionUnread === true,
967
+ failed: status?.completionFailed === true,
968
+ pinned: !archived.has(s.id) && pinned.has(s.id),
969
+ archived: archived.has(s.id),
970
+ updatedAt: s.updatedAt,
971
+ ...root === void 0 || root === "" ? {} : { cwd: root },
972
+ ...pendingInteraction === void 0 ? {} : { pendingInteraction }
973
+ };
974
+ }
975
+ function deriveGroups(list, workspaces, rowState, statuses, view) {
976
+ const archived = new Set(rowState.archivedSessionIds);
977
+ const pinned = new Set(rowState.pinnedSessionIds);
978
+ const expandedGroups = new Set(view.expandedGroups);
979
+ const current = mainSessionId(list);
980
+ const currentGroup = current === void 0 ? void 0 : owningGroupKey(workspaces, current);
981
+ const groups = [];
982
+ for (const g of groupByWorkspace(list, workspaces, archived, rowState.archivedFilter, view.ungroupedOrder)) {
983
+ const expanded = expandedGroups.has(g.key);
984
+ groups.push({
985
+ key: g.key,
986
+ workspaceId: g.workspaceId,
987
+ cwd: g.cwd,
988
+ createdAt: g.createdAt,
989
+ label: g.label,
990
+ sessionCount: g.sessions.length,
991
+ expanded,
992
+ containsCurrent: g.key === currentGroup,
993
+ sessions: expanded ? sectionMembers(g.sessions, pinned, archived).map((session) => sessionNode(session, list, statuses, pinned, archived)) : []
994
+ });
995
+ }
996
+ return groups;
997
+ }
998
+ function folderPath(path) {
999
+ const windows = /^[A-Za-z]:[/\\]/.test(path) || path.startsWith("\\\\");
1000
+ return (windows ? path.replaceAll("\\", "/") : path).replace(/\/+$/, "");
1001
+ }
1002
+ function owningParentFolder(path, parents) {
1003
+ const child = folderPath(path);
1004
+ let owner;
1005
+ let length = -1;
1006
+ for (const parent of parents) {
1007
+ const root = folderPath(parent);
1008
+ if (root.length > length && child !== root && child.startsWith(`${root}/`)) {
1009
+ owner = parent;
1010
+ length = root.length;
1011
+ }
1012
+ }
1013
+ return owner;
1014
+ }
1015
+
1016
+ // src/activity.js
1017
+ function runningCounts(workspaces, sessions, statuses, view) {
1018
+ const counts = /* @__PURE__ */ new Map();
1019
+ if (view.groupBy === "flat") return counts;
1020
+ const groups = deriveGroups(sessions, workspaces.items, {
1021
+ archivedSessionIds: workspaces.archivedSessionIds,
1022
+ pinnedSessionIds: workspaces.pinnedSessionIds,
1023
+ archivedFilter: view.archivedFilter
1024
+ }, statuses, { expandedGroups: workspaces.items.map((workspace) => workspace.workspaceId) });
1025
+ const nested = view.groupBy === "workspace-tree";
1026
+ const idsByPath = new Map(nested ? workspaces.items.map(({ path, workspaceId }) => [path, workspaceId]) : []);
1027
+ const paths = [...idsByPath.keys()];
1028
+ for (const group of groups) {
1029
+ if (group.workspaceId === void 0) continue;
1030
+ const count = group.sessions.filter((session) => session.running || session.runningSubagentCount > 0).length;
1031
+ if (!count) continue;
1032
+ counts.set(group.workspaceId, (counts.get(group.workspaceId) ?? 0) + count);
1033
+ if (nested) {
1034
+ for (let path = owningParentFolder(group.cwd, paths); path !== void 0; path = owningParentFolder(path, paths)) {
1035
+ const id = idsByPath.get(path);
1036
+ counts.set(id, (counts.get(id) ?? 0) + count);
1037
+ }
1038
+ }
1039
+ }
1040
+ return counts;
1041
+ }
1042
+
1043
+ // src/badges.css
1044
+ var badges_default = "[data-dsh-workspace-pulse] {\n display: inline-flex;\n flex: none;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n min-inline-size: 18px;\n block-size: 18px;\n padding-inline: 5px;\n border-radius: 999px;\n color: var(--dsw-alias-state-business-primary, currentColor);\n background: color-mix(in srgb, currentColor 12%, transparent);\n font-size: 11px;\n font-variant-numeric: tabular-nums;\n font-weight: 600;\n line-height: 1;\n}\n";
1045
+
1046
+ // src/badges.js
1047
+ var listSelector = "[data-sidebar-list-area]";
1048
+ var rowSelector = '[role="treeitem"][data-row-key^="workspace:"]';
1049
+ var badgeSelector = "[data-dsh-workspace-pulse]";
1050
+ function observeBadges(document2, labelFor) {
1051
+ const style = document2.createElement("style");
1052
+ style.textContent = badges_default;
1053
+ document2.head.append(style);
1054
+ let counts = /* @__PURE__ */ new Map();
1055
+ let queued = false;
1056
+ let disposed = false;
1057
+ function render() {
1058
+ queued = false;
1059
+ if (disposed) return;
1060
+ for (const row of document2.querySelectorAll(`${listSelector} ${rowSelector}`)) {
1061
+ const id = row.getAttribute("data-row-key").slice("workspace:".length);
1062
+ const count = counts.get(id);
1063
+ let badge = row.querySelector(`:scope > ${badgeSelector}`);
1064
+ if (count === void 0 || row.getAttribute("aria-expanded") !== "false") {
1065
+ badge?.remove();
1066
+ continue;
1067
+ }
1068
+ if (!badge) {
1069
+ badge = document2.createElement("span");
1070
+ badge.setAttribute("data-dsh-workspace-pulse", "");
1071
+ badge.setAttribute("role", "img");
1072
+ row.insertBefore(badge, row.lastElementChild);
1073
+ }
1074
+ const text = String(count);
1075
+ const label = labelFor(count);
1076
+ if (badge.textContent !== text) badge.textContent = text;
1077
+ if (badge.title !== label) {
1078
+ badge.title = label;
1079
+ badge.setAttribute("aria-label", label);
1080
+ }
1081
+ }
1082
+ observer.takeRecords();
1083
+ }
1084
+ function refresh() {
1085
+ if (queued || disposed) return;
1086
+ queued = true;
1087
+ queueMicrotask(render);
1088
+ }
1089
+ const observer = new document2.defaultView.MutationObserver((records) => {
1090
+ const relevant = records.some(({ target, addedNodes }) => target.closest(listSelector) || Array.from(addedNodes).some((node) => node.nodeType === 1 && (node.matches(listSelector) || node.querySelector(listSelector))));
1091
+ if (relevant) refresh();
1092
+ });
1093
+ observer.observe(document2.body, { subtree: true, childList: true, attributes: true, attributeFilter: ["aria-expanded", "data-row-key"] });
1094
+ return {
1095
+ refresh,
1096
+ update(next) {
1097
+ counts = next;
1098
+ refresh();
1099
+ },
1100
+ dispose() {
1101
+ disposed = true;
1102
+ observer.disconnect();
1103
+ for (const badge of document2.querySelectorAll(badgeSelector)) badge.remove();
1104
+ style.remove();
1105
+ }
1106
+ };
1107
+ }
1108
+
1109
+ // src/client.js
1110
+ var namespace = "dsh-workspace-pulse";
1111
+ var sidebar = "sidebar.workspaces";
1112
+ var strings = {
1113
+ zh: { one: "{count} \u4E2A\u4F1A\u8BDD\u6B63\u5728\u8FD0\u884C", many: "{count} \u4E2A\u4F1A\u8BDD\u6B63\u5728\u8FD0\u884C" },
1114
+ en: { one: "{count} session running", many: "{count} sessions running" }
1115
+ };
1116
+ var inject = ["sessions", "workspaces", "uiSession", "uiSession.sessionStatus", "slots", "locale"];
1117
+ function apply(ctx) {
1118
+ ctx.effect(() => ctx.locale.register(namespace, strings));
1119
+ ctx.effect(() => {
1120
+ const t = ctx.locale.bind(namespace);
1121
+ const status = ctx.uiSession.sessionStatus;
1122
+ const sessions = ctx.sessions.list;
1123
+ const workspaces = ctx.workspaces.list;
1124
+ const badges = observeBadges(document, (count) => t(count === 1 ? "one" : "many", { count }));
1125
+ let view;
1126
+ let stopView;
1127
+ function refreshCounts() {
1128
+ const settings = view?.getSnapshot();
1129
+ badges.update(settings ? runningCounts(workspaces.getSnapshot(), sessions.getSnapshot(), status.getSnapshot(), settings) : /* @__PURE__ */ new Map());
1130
+ }
1131
+ function followView() {
1132
+ const next = ctx.slots.entries(sidebar).find((entry) => entry.locale === "workspace")?.store?.create();
1133
+ if (next === view) return;
1134
+ stopView?.();
1135
+ view = next;
1136
+ stopView = view?.subscribe(refreshCounts);
1137
+ refreshCounts();
1138
+ }
1139
+ const stop = [
1140
+ sessions.subscribe(refreshCounts),
1141
+ workspaces.subscribe(refreshCounts),
1142
+ status.subscribe(refreshCounts),
1143
+ ctx.locale.subscribe(badges.refresh),
1144
+ ctx.slots.subscribe(sidebar, followView)
1145
+ ];
1146
+ followView();
1147
+ return () => {
1148
+ stopView?.();
1149
+ for (const dispose of stop) dispose();
1150
+ badges.dispose();
1151
+ };
1152
+ }, "workspace-pulse: collapsed workspace badges");
1153
+ }
1154
+ return module.exports; } });
@@ -0,0 +1,22 @@
1
+ # 安装指南
2
+
3
+ ## 安装
4
+
5
+ 已在 DeepSeek Harness Web 0.2.3-alpha.2 验证。将下方路径替换为 `.tgz` 安装包的实际路径。
6
+
7
+ ```sh
8
+ dsh plugin --profile web add /绝对路径/dsh-workspace-pulse-0.1.0.tgz
9
+ ```
10
+
11
+ 打开 DSH Web,折叠 Workspace 即可查看计数。要停用插件,在「设置 → 插件」中关闭 `dsh-workspace-pulse`。
12
+
13
+ ## 从源码打包
14
+
15
+ 使用 Node.js 22 或更新版本,在仓库根目录运行以下命令。
16
+
17
+ ```sh
18
+ npm ci
19
+ npm run package:plugin
20
+ ```
21
+
22
+ 生成的安装包位于 `artifacts/`。
package/package.json CHANGED
@@ -1,6 +1,38 @@
1
1
  {
2
2
  "name": "dsh-workspace-pulse",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "DeepSeek Harness Web 折叠工作区的运行会话计数",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/lingsamuel/dsh-workspace-pulse.git"
8
+ },
9
+ "type": "module",
10
+ "engines": { "node": ">=22" },
11
+ "exports": {
12
+ ".": "./src/host.js",
13
+ "./client": "./dist/client.js",
14
+ "./cordis.patch.yml": "./cordis.patch.yml",
15
+ "./package.json": "./package.json"
16
+ },
17
+ "files": ["src/host.js", "dist/", "cordis.patch.yml", "manual/"],
18
+ "keywords": ["dsh-plugin", "deepseek-harness", "workspace"],
19
+ "dsh": {
20
+ "bundle": { "patch": "./cordis.patch.yml" },
21
+ "client": { "platform": "web" }
22
+ },
23
+ "scripts": {
24
+ "build": "node scripts/build.mjs",
25
+ "test": "esbuild test/activity.test.js --bundle --platform=node --format=esm --outfile=.runtime/activity.test.mjs && node --test .runtime/activity.test.mjs",
26
+ "test:web": "node test/web.mjs",
27
+ "package:plugin": "npm run build && node scripts/package.mjs"
28
+ },
29
+ "devDependencies": {
30
+ "@deepseek-ai/dsh-api-session-controller": "0.2.3-alpha.2",
31
+ "@deepseek-ai/dsh-client-ui-workspace": "0.2.3-alpha.2",
32
+ "@deepseek-ai/dsh-util-text-search": "0.2.3-alpha.2",
33
+ "@deepseek-ai/dsh-util-values": "0.2.3-alpha.2",
34
+ "@deepseek-ai/dsh-util-workspace-path": "0.2.3-alpha.2",
35
+ "esbuild": "0.27.4",
36
+ "playwright-core": "1.64.1"
37
+ }
38
+ }
package/src/host.js ADDED
@@ -0,0 +1 @@
1
+ export function apply() {}