@deepseek-ai/dsh-tmux-context 0.2.0-rc.1 → 0.2.1-alpha.1
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 +0 -1
- package/README.zh.md +0 -1
- package/lib/index.js +626 -8
- package/package.json +15 -15
package/README.i18n.yaml
CHANGED
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
en: 1902de51becf7c7d
|
|
34
34
|
zh: 130e673b471c38c4
|
|
35
35
|
/deepseek-ai-dsh-tmux-context/understand-the-implementation/source-map:
|
|
36
|
-
en:
|
|
37
|
-
zh:
|
|
36
|
+
en: 14bc5e3279f9da27
|
|
37
|
+
zh: 90953dfbf892033a
|
|
38
38
|
/deepseek-ai-dsh-tmux-context/understand-the-implementation/main-flow:
|
|
39
39
|
en: 2d5768fe44120780
|
|
40
40
|
zh: cd601c59d9604e6e
|
package/README.md
CHANGED
|
@@ -70,7 +70,6 @@ The plugin prepends an `agent/pre-step` listener that runs only on the first ste
|
|
|
70
70
|
| File | Role |
|
|
71
71
|
|---|---|
|
|
72
72
|
| [`src/index.ts`](src/index.ts) | Plugin entry: first-step listener, shell query, change suppression, scheduling |
|
|
73
|
-
| — | No runtime invariant companion is published; a reading is a per-turn snapshot of external tmux state, so the session holds no cross-event relation to check; scheduling and format are owned by pipeline tests. |
|
|
74
73
|
|
|
75
74
|
### Main flow
|
|
76
75
|
|
package/README.zh.md
CHANGED
package/lib/index.js
CHANGED
|
@@ -163,6 +163,630 @@ function validateName(subject, value) {
|
|
|
163
163
|
if (!isTypertRemoteSegment(value)) throw new TypeError(`typert-protocol: ${subject} must contain only RPC endpoint segment characters`);
|
|
164
164
|
}
|
|
165
165
|
//#endregion
|
|
166
|
+
//#region ../../util/values/src/partial-json.ts
|
|
167
|
+
/**
|
|
168
|
+
* Lazily scanned view of one JSON object's top-level fields, built from text
|
|
169
|
+
* that may still be streaming or from an already parsed object. Nothing is
|
|
170
|
+
* scanned until a reader asks; the view remembers every question it answered
|
|
171
|
+
* and reports changed answers when the owner refreshes for publication.
|
|
172
|
+
* Used for model tool-call arguments: a row reads the fields it
|
|
173
|
+
* cares about at whatever granularity it displays, at every stage of the call.
|
|
174
|
+
* @module @deepseek-ai/dsh-util-values/src/partial-json
|
|
175
|
+
*/
|
|
176
|
+
const SIMPLE_ESCAPES = {
|
|
177
|
+
"\"": "\"",
|
|
178
|
+
"\\": "\\",
|
|
179
|
+
"/": "/",
|
|
180
|
+
b: "\b",
|
|
181
|
+
f: "\f",
|
|
182
|
+
n: "\n",
|
|
183
|
+
r: "\r",
|
|
184
|
+
t: " "
|
|
185
|
+
};
|
|
186
|
+
const CONTENT_ESCAPE = /[\\\u0000-\u001f]/u;
|
|
187
|
+
function isWhitespace(c) {
|
|
188
|
+
return c === " " || c === "\n" || c === "\r" || c === " ";
|
|
189
|
+
}
|
|
190
|
+
function isHex(c) {
|
|
191
|
+
return c >= "0" && c <= "9" || c >= "a" && c <= "f" || c >= "A" && c <= "F";
|
|
192
|
+
}
|
|
193
|
+
(class PartialArguments {
|
|
194
|
+
/** The view of a call with no arguments available. */
|
|
195
|
+
static EMPTY = PartialArguments.fromObject({});
|
|
196
|
+
/**
|
|
197
|
+
* View finished argument text without scanning it until a reader asks.
|
|
198
|
+
* @param text - the complete argument JSON text.
|
|
199
|
+
* @returns a sealed view.
|
|
200
|
+
*/
|
|
201
|
+
static fromText(text) {
|
|
202
|
+
const view = new PartialArguments();
|
|
203
|
+
view.append(text);
|
|
204
|
+
view.sealed = true;
|
|
205
|
+
return view;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* View an already parsed argument payload, such as a PTC dispatch object.
|
|
209
|
+
* @param value - the parsed argument value.
|
|
210
|
+
* @returns a sealed view; a non-object payload has no fields.
|
|
211
|
+
*/
|
|
212
|
+
static fromObject(value) {
|
|
213
|
+
const view = new PartialArguments();
|
|
214
|
+
view.object = typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
|
|
215
|
+
view.sealed = true;
|
|
216
|
+
return view;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* The source: text so far or a parsed object, plus whether it can still grow.
|
|
220
|
+
* These are the only enumerable fields, so two views over the same source
|
|
221
|
+
* compare equal structurally however far each has been read.
|
|
222
|
+
*/
|
|
223
|
+
chunks = [];
|
|
224
|
+
object;
|
|
225
|
+
sealed = false;
|
|
226
|
+
#ends = [];
|
|
227
|
+
#size = 0;
|
|
228
|
+
#consumed = 0;
|
|
229
|
+
#mode = "root";
|
|
230
|
+
#escape = false;
|
|
231
|
+
#keyStart = 0;
|
|
232
|
+
#keyEscaped = false;
|
|
233
|
+
#key = "";
|
|
234
|
+
#current = null;
|
|
235
|
+
#nestedEnds = [];
|
|
236
|
+
#nestedInString = false;
|
|
237
|
+
#invalidAt;
|
|
238
|
+
#invalidValue = false;
|
|
239
|
+
#entries = /* @__PURE__ */ new Map();
|
|
240
|
+
#order = [];
|
|
241
|
+
#reads = /* @__PURE__ */ new Map();
|
|
242
|
+
/** Whether this view rejects further appends; does not scan text or register reads. */
|
|
243
|
+
get isSealed() {
|
|
244
|
+
return this.sealed;
|
|
245
|
+
}
|
|
246
|
+
/** Whether indexing or a content read found invalid JSON; unread value contents are not validated. */
|
|
247
|
+
get invalid() {
|
|
248
|
+
this.scan();
|
|
249
|
+
return this.#mode === "invalid" || this.#invalidValue;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Retain streamed argument text without scanning or comparing observed answers.
|
|
253
|
+
* @param fragment - the text following every fragment appended before.
|
|
254
|
+
*/
|
|
255
|
+
append(fragment) {
|
|
256
|
+
if (this.sealed) throw new Error("PartialArguments: cannot append to a sealed view");
|
|
257
|
+
if (fragment.length === 0) return;
|
|
258
|
+
this.chunks.push(fragment);
|
|
259
|
+
this.#size += fragment.length;
|
|
260
|
+
this.#ends.push(this.#size);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Reconcile a streamed prefix with authoritative complete text without joining the fragments.
|
|
264
|
+
* @param text - the final argument text, which replaces missing or conflicting deltas.
|
|
265
|
+
* @returns this view sealed with its caches retained when every character matches; otherwise a new sealed view.
|
|
266
|
+
*/
|
|
267
|
+
settle(text) {
|
|
268
|
+
if (this.object !== void 0 || text.length !== this.#size) return PartialArguments.fromText(text);
|
|
269
|
+
let offset = 0;
|
|
270
|
+
for (const chunk of this.chunks) {
|
|
271
|
+
if (!text.startsWith(chunk, offset)) return PartialArguments.fromText(text);
|
|
272
|
+
offset += chunk.length;
|
|
273
|
+
}
|
|
274
|
+
this.chunks = text.length === 0 ? [] : [text];
|
|
275
|
+
this.#ends = text.length === 0 ? [] : [text.length];
|
|
276
|
+
this.sealed = true;
|
|
277
|
+
return this;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Compare observed answers and advance their publication baseline. Unread views remain unscanned.
|
|
281
|
+
* @returns whether any observed answer changed since its first read or the preceding refresh.
|
|
282
|
+
*/
|
|
283
|
+
refresh() {
|
|
284
|
+
if (this.#reads.size === 0) return false;
|
|
285
|
+
this.scan();
|
|
286
|
+
let changed = false;
|
|
287
|
+
let completions = false;
|
|
288
|
+
for (const read of this.#reads.values()) {
|
|
289
|
+
if (read.completion) {
|
|
290
|
+
completions = true;
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
changed = this.refreshRead(read) || changed;
|
|
294
|
+
}
|
|
295
|
+
if (completions) {
|
|
296
|
+
for (const read of this.#reads.values()) if (read.completion) changed = this.refreshRead(read) || changed;
|
|
297
|
+
}
|
|
298
|
+
if (this.sealed) this.#reads.clear();
|
|
299
|
+
return changed;
|
|
300
|
+
}
|
|
301
|
+
refreshRead(read) {
|
|
302
|
+
const now = read.answer();
|
|
303
|
+
if (Object.is(now, read.last)) return false;
|
|
304
|
+
read.last = now;
|
|
305
|
+
return true;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Check whether no further fields can arrive.
|
|
309
|
+
* @returns whether the outer object closed, indexing failed, or the view is sealed; unread values are not validated.
|
|
310
|
+
*/
|
|
311
|
+
closed() {
|
|
312
|
+
return this.remember("closed", "", () => this.closedNow());
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* List discovered fields in first-appearance order.
|
|
316
|
+
* @returns top-level keys seen so far, in first-appearance order.
|
|
317
|
+
*/
|
|
318
|
+
keys() {
|
|
319
|
+
return this.remember("keys", "", () => this.keysNow(), (keys) => keys.length);
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Check whether a top-level field has appeared.
|
|
323
|
+
* @param key - argument name.
|
|
324
|
+
* @returns whether the field has appeared (a string opened or another value began).
|
|
325
|
+
*/
|
|
326
|
+
has(key) {
|
|
327
|
+
return this.remember("has", key, () => this.hasNow(key));
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Check whether a field's closing delimiter has arrived, without validating its contents.
|
|
331
|
+
* @param key - argument name.
|
|
332
|
+
* @returns whether its delimiter arrived and no content reader has reported an error for this value.
|
|
333
|
+
*/
|
|
334
|
+
complete(key) {
|
|
335
|
+
return this.remember("complete", key, () => this.completeNow(key));
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Read string length without materializing its text.
|
|
339
|
+
* @param key - argument name.
|
|
340
|
+
* @param options - change granularity for a streaming string.
|
|
341
|
+
* @returns decoded UTF-16 length of the string field so far; undefined when absent or not a string.
|
|
342
|
+
*/
|
|
343
|
+
stringLength(key, options) {
|
|
344
|
+
const step = Math.max(1, Math.floor(options?.step ?? 1));
|
|
345
|
+
const offset = options?.offset ?? 0;
|
|
346
|
+
return this.remember(`length:${step}:${offset}`, key, () => this.lengthNow(key), (length) => length === void 0 ? void 0 : Math.ceil((length + offset) / step));
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Check a string against a decoded UTF-16 length limit without materializing it.
|
|
350
|
+
* @param key - argument name.
|
|
351
|
+
* @param maxLength - decoded UTF-16 limit, floored to at least zero.
|
|
352
|
+
* @returns whether the string is longer than the limit; false when absent or not a string.
|
|
353
|
+
*/
|
|
354
|
+
stringExceeds(key, maxLength) {
|
|
355
|
+
const limit = Math.max(0, Math.floor(maxLength));
|
|
356
|
+
return this.remember(`exceeds:${limit}`, key, () => (this.lengthNow(key, limit + 1) ?? 0) > limit);
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Read a decoded string, including a streaming prefix.
|
|
360
|
+
* @param key - argument name.
|
|
361
|
+
* @returns the string field's decoded text so far; undefined when absent or not a string.
|
|
362
|
+
*/
|
|
363
|
+
text(key) {
|
|
364
|
+
return this.remember("text", key, () => this.textNow(key));
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Read at most the first decoded UTF-16 units of a string.
|
|
368
|
+
* @param key - argument name.
|
|
369
|
+
* @param maxLength - maximum decoded UTF-16 length, floored to at least one.
|
|
370
|
+
* @returns the bounded string prefix; undefined when absent or not a string.
|
|
371
|
+
*/
|
|
372
|
+
textPrefix(key, maxLength) {
|
|
373
|
+
const limit = Math.max(1, Math.floor(maxLength));
|
|
374
|
+
return this.remember(`prefix:${limit}`, key, () => this.textPrefixNow(key, limit));
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Read a completed non-string argument.
|
|
378
|
+
* @param key - argument name.
|
|
379
|
+
* @returns the parsed non-string value once it closed; undefined while open, absent, or a string.
|
|
380
|
+
*/
|
|
381
|
+
value(key) {
|
|
382
|
+
return this.remember("value", key, () => this.valueNow(key));
|
|
383
|
+
}
|
|
384
|
+
/** Answer a question and, on a streaming view, remember it for change detection. */
|
|
385
|
+
remember(kind, key, read, comparison) {
|
|
386
|
+
this.scan();
|
|
387
|
+
const result = read();
|
|
388
|
+
if (!this.sealed) {
|
|
389
|
+
const id = `${kind}/${key}`;
|
|
390
|
+
if (!this.#reads.has(id)) this.#reads.set(id, {
|
|
391
|
+
completion: kind === "complete",
|
|
392
|
+
answer: comparison === void 0 ? read : () => comparison(read()),
|
|
393
|
+
last: comparison === void 0 ? result : comparison(result)
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
return result;
|
|
397
|
+
}
|
|
398
|
+
closedNow() {
|
|
399
|
+
return this.sealed || this.#mode === "closed" || this.#mode === "invalid";
|
|
400
|
+
}
|
|
401
|
+
keysNow() {
|
|
402
|
+
return this.object === void 0 ? this.#order : Object.keys(this.object);
|
|
403
|
+
}
|
|
404
|
+
hasNow(key) {
|
|
405
|
+
return this.object === void 0 ? this.#entries.has(key) : Object.hasOwn(this.object, key);
|
|
406
|
+
}
|
|
407
|
+
completeNow(key) {
|
|
408
|
+
if (this.object !== void 0) return Object.hasOwn(this.object, key);
|
|
409
|
+
const entry = this.#entries.get(key);
|
|
410
|
+
return entry !== void 0 && entry.end >= 0 && (entry.kind === "string" ? entry.invalidAt === void 0 : !entry.invalid);
|
|
411
|
+
}
|
|
412
|
+
lengthNow(key, limit = Number.POSITIVE_INFINITY) {
|
|
413
|
+
if (this.object !== void 0) {
|
|
414
|
+
const field = Object.hasOwn(this.object, key) ? this.object[key] : void 0;
|
|
415
|
+
return typeof field === "string" ? field.length : void 0;
|
|
416
|
+
}
|
|
417
|
+
const entry = this.#entries.get(key);
|
|
418
|
+
if (entry?.kind !== "string") return void 0;
|
|
419
|
+
if (entry.text !== void 0 && entry.text.at === entry.end) return entry.text.length;
|
|
420
|
+
const read = entry.length ??= {
|
|
421
|
+
at: entry.start,
|
|
422
|
+
length: 0,
|
|
423
|
+
text: ""
|
|
424
|
+
};
|
|
425
|
+
this.readString(entry, read, limit, false);
|
|
426
|
+
return read.length;
|
|
427
|
+
}
|
|
428
|
+
textNow(key) {
|
|
429
|
+
if (this.object !== void 0) {
|
|
430
|
+
const field = Object.hasOwn(this.object, key) ? this.object[key] : void 0;
|
|
431
|
+
return typeof field === "string" ? field : void 0;
|
|
432
|
+
}
|
|
433
|
+
const entry = this.#entries.get(key);
|
|
434
|
+
if (entry?.kind !== "string") return void 0;
|
|
435
|
+
if (entry.text === void 0 && entry.end >= 0 && entry.needsDecoding && entry.invalidAt === void 0) {
|
|
436
|
+
let text;
|
|
437
|
+
try {
|
|
438
|
+
text = JSON.parse(`"${this.slice(entry.start, entry.end)}"`);
|
|
439
|
+
} catch (_error) {}
|
|
440
|
+
if (text !== void 0) entry.text = {
|
|
441
|
+
at: entry.end,
|
|
442
|
+
length: text.length,
|
|
443
|
+
text
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
const read = entry.text ??= {
|
|
447
|
+
at: entry.start,
|
|
448
|
+
length: 0,
|
|
449
|
+
text: ""
|
|
450
|
+
};
|
|
451
|
+
this.readString(entry, read, Number.POSITIVE_INFINITY, true);
|
|
452
|
+
return read.text;
|
|
453
|
+
}
|
|
454
|
+
textPrefixNow(key, maxLength) {
|
|
455
|
+
if (this.object !== void 0) {
|
|
456
|
+
const field = Object.hasOwn(this.object, key) ? this.object[key] : void 0;
|
|
457
|
+
return typeof field === "string" ? field.slice(0, maxLength) : void 0;
|
|
458
|
+
}
|
|
459
|
+
const entry = this.#entries.get(key);
|
|
460
|
+
if (entry?.kind !== "string") return void 0;
|
|
461
|
+
const prefixes = entry.prefixes ??= /* @__PURE__ */ new Map();
|
|
462
|
+
let read = prefixes.get(maxLength);
|
|
463
|
+
if (read === void 0) {
|
|
464
|
+
read = {
|
|
465
|
+
at: entry.start,
|
|
466
|
+
length: 0,
|
|
467
|
+
text: ""
|
|
468
|
+
};
|
|
469
|
+
prefixes.set(maxLength, read);
|
|
470
|
+
}
|
|
471
|
+
this.readString(entry, read, maxLength, true);
|
|
472
|
+
return read.text;
|
|
473
|
+
}
|
|
474
|
+
valueNow(key) {
|
|
475
|
+
if (this.object !== void 0) {
|
|
476
|
+
if (!Object.hasOwn(this.object, key)) return void 0;
|
|
477
|
+
const field = this.object[key];
|
|
478
|
+
return typeof field === "string" ? void 0 : field;
|
|
479
|
+
}
|
|
480
|
+
const entry = this.#entries.get(key);
|
|
481
|
+
if (entry?.kind !== "value" || entry.end < 0 || entry.invalid) return void 0;
|
|
482
|
+
if (entry.parsed === void 0) try {
|
|
483
|
+
entry.parsed = JSON.parse(this.slice(entry.start, entry.end));
|
|
484
|
+
} catch (_error) {
|
|
485
|
+
entry.invalid = true;
|
|
486
|
+
this.#invalidValue = true;
|
|
487
|
+
}
|
|
488
|
+
return entry.parsed;
|
|
489
|
+
}
|
|
490
|
+
chunkAt(at) {
|
|
491
|
+
let low = 0;
|
|
492
|
+
let high = this.#ends.length;
|
|
493
|
+
while (low < high) {
|
|
494
|
+
const mid = low + high >>> 1;
|
|
495
|
+
if (this.#ends[mid] <= at) low = mid + 1;
|
|
496
|
+
else high = mid;
|
|
497
|
+
}
|
|
498
|
+
return low;
|
|
499
|
+
}
|
|
500
|
+
/** Materialize only a requested range, never the cumulative source. */
|
|
501
|
+
slice(start, end) {
|
|
502
|
+
if (start >= end) return "";
|
|
503
|
+
const first = this.chunkAt(start);
|
|
504
|
+
const last = this.chunkAt(end - 1);
|
|
505
|
+
const base = first === 0 ? 0 : this.#ends[first - 1];
|
|
506
|
+
if (first === last) return this.chunks[first].slice(start - base, end - base);
|
|
507
|
+
const parts = [this.chunks[first].slice(start - base)];
|
|
508
|
+
for (let i = first + 1; i < last; i++) parts.push(this.chunks[i]);
|
|
509
|
+
parts.push(this.chunks[last].slice(0, end - this.#ends[last - 1]));
|
|
510
|
+
return parts.join("");
|
|
511
|
+
}
|
|
512
|
+
readString(entry, read, limit, materialize) {
|
|
513
|
+
const end = Math.min(entry.end < 0 ? this.#consumed : entry.end, entry.invalidAt ?? Number.POSITIVE_INFINITY, this.#invalidAt ?? Number.POSITIVE_INFINITY);
|
|
514
|
+
if (!entry.needsDecoding) {
|
|
515
|
+
const length = Math.min(end - read.at, limit - read.length);
|
|
516
|
+
if (length <= 0) return;
|
|
517
|
+
if (materialize) read.text += this.slice(read.at, read.at + length);
|
|
518
|
+
read.at += length;
|
|
519
|
+
read.length += length;
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
let chunkIndex = this.chunkAt(read.at);
|
|
523
|
+
while (read.at < end && read.length < limit) {
|
|
524
|
+
const base = chunkIndex === 0 ? 0 : this.#ends[chunkIndex - 1];
|
|
525
|
+
const chunk = this.chunks[chunkIndex];
|
|
526
|
+
const remaining = chunk.slice(read.at - base, Math.min(chunk.length, end - base));
|
|
527
|
+
const boundary = remaining.search(CONTENT_ESCAPE);
|
|
528
|
+
const length = Math.min(boundary < 0 ? remaining.length : boundary, limit - read.length);
|
|
529
|
+
if (length > 0) {
|
|
530
|
+
if (materialize) read.text += remaining.slice(0, length);
|
|
531
|
+
read.at += length;
|
|
532
|
+
read.length += length;
|
|
533
|
+
if (read.at === base + chunk.length) chunkIndex++;
|
|
534
|
+
continue;
|
|
535
|
+
}
|
|
536
|
+
const type = remaining.length > 1 ? remaining[1] : read.at + 1 < end ? this.chunks[chunkIndex + 1][0] : void 0;
|
|
537
|
+
let decoded;
|
|
538
|
+
let width = 2;
|
|
539
|
+
if (remaining[0] === "\\" && type === void 0 && entry.end < 0) return;
|
|
540
|
+
if (remaining[0] === "\\" && type === "u") {
|
|
541
|
+
const hex = this.slice(read.at + 2, Math.min(end, read.at + 6));
|
|
542
|
+
let valid = true;
|
|
543
|
+
for (let i = 0; i < hex.length; i++) if (!isHex(hex[i])) valid = false;
|
|
544
|
+
if (valid) {
|
|
545
|
+
if (hex.length < 4 && entry.end < 0) return;
|
|
546
|
+
if (hex.length === 4) decoded = String.fromCharCode(Number.parseInt(hex, 16));
|
|
547
|
+
}
|
|
548
|
+
width = 6;
|
|
549
|
+
} else if (remaining[0] === "\\" && type !== void 0) decoded = SIMPLE_ESCAPES[type];
|
|
550
|
+
if (decoded === void 0) {
|
|
551
|
+
entry.invalidAt = read.at;
|
|
552
|
+
this.#invalidValue = true;
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
if (materialize) read.text += decoded;
|
|
556
|
+
read.length++;
|
|
557
|
+
read.at += width;
|
|
558
|
+
while (chunkIndex < this.chunks.length && read.at >= this.#ends[chunkIndex]) chunkIndex++;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
/** Locate new field ranges without decoding or parsing their contents. */
|
|
562
|
+
scan() {
|
|
563
|
+
if (this.object !== void 0 || this.#consumed === this.#size) return;
|
|
564
|
+
for (let i = this.chunkAt(this.#consumed); i < this.chunks.length && this.#invalidAt === void 0; i++) {
|
|
565
|
+
const pending = this.chunks[i];
|
|
566
|
+
const base = i === 0 ? 0 : this.#ends[i - 1];
|
|
567
|
+
for (let index = this.#consumed - base; index < pending.length && this.#mode !== "invalid"; index++) {
|
|
568
|
+
if (this.#mode === "string" || this.#mode === "nested" && this.#nestedInString) {
|
|
569
|
+
const end = this.stringBoundary(pending, index);
|
|
570
|
+
this.#consumed += end - index;
|
|
571
|
+
index = end;
|
|
572
|
+
if (index === pending.length) break;
|
|
573
|
+
}
|
|
574
|
+
this.step(pending[index], this.#consumed);
|
|
575
|
+
this.#consumed++;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
/** Only raw quotes and their preceding backslash runs can terminate a string. */
|
|
580
|
+
stringBoundary(fragment, start) {
|
|
581
|
+
let at = start;
|
|
582
|
+
while (true) {
|
|
583
|
+
const quote = fragment.indexOf("\"", at);
|
|
584
|
+
const end = quote < 0 ? fragment.length : quote;
|
|
585
|
+
if (this.#mode === "string") {
|
|
586
|
+
const entry = this.#current;
|
|
587
|
+
if (!entry.needsDecoding && CONTENT_ESCAPE.test(fragment.slice(at, end))) entry.needsDecoding = true;
|
|
588
|
+
}
|
|
589
|
+
let slashStart = end;
|
|
590
|
+
while (slashStart > at && fragment[slashStart - 1] === "\\") slashStart--;
|
|
591
|
+
const escaped = (end - slashStart) % 2 === 1 !== (slashStart === at && this.#escape);
|
|
592
|
+
this.#escape = quote < 0 && escaped;
|
|
593
|
+
if (quote < 0 || !escaped) return end;
|
|
594
|
+
at = quote + 1;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
step(c, at) {
|
|
598
|
+
switch (this.#mode) {
|
|
599
|
+
case "root":
|
|
600
|
+
if (isWhitespace(c)) return;
|
|
601
|
+
if (c === "{") {
|
|
602
|
+
this.#mode = "key-or-end";
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
this.fail();
|
|
606
|
+
return;
|
|
607
|
+
case "key-or-end":
|
|
608
|
+
if (isWhitespace(c)) return;
|
|
609
|
+
if (c === "}") {
|
|
610
|
+
this.#mode = "closed";
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
if (c === "\"") {
|
|
614
|
+
this.beginKey(at);
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
this.fail();
|
|
618
|
+
return;
|
|
619
|
+
case "key-only":
|
|
620
|
+
if (isWhitespace(c)) return;
|
|
621
|
+
if (c === "\"") {
|
|
622
|
+
this.beginKey(at);
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
this.fail();
|
|
626
|
+
return;
|
|
627
|
+
case "key":
|
|
628
|
+
this.stepKey(c, at);
|
|
629
|
+
return;
|
|
630
|
+
case "colon":
|
|
631
|
+
if (isWhitespace(c)) return;
|
|
632
|
+
if (c === ":") {
|
|
633
|
+
this.#mode = "value";
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
this.fail();
|
|
637
|
+
return;
|
|
638
|
+
case "value":
|
|
639
|
+
this.beginValue(c, at);
|
|
640
|
+
return;
|
|
641
|
+
case "string": {
|
|
642
|
+
const entry = this.#current;
|
|
643
|
+
entry.end = at;
|
|
644
|
+
this.#current = null;
|
|
645
|
+
this.#mode = "comma-or-end";
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
case "scalar":
|
|
649
|
+
this.stepScalar(c, at);
|
|
650
|
+
return;
|
|
651
|
+
case "nested":
|
|
652
|
+
this.stepNested(c, at);
|
|
653
|
+
return;
|
|
654
|
+
case "comma-or-end":
|
|
655
|
+
if (isWhitespace(c)) return;
|
|
656
|
+
if (c === ",") {
|
|
657
|
+
this.#mode = "key-only";
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
if (c === "}") {
|
|
661
|
+
this.#mode = "closed";
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
this.fail();
|
|
665
|
+
return;
|
|
666
|
+
case "closed":
|
|
667
|
+
if (isWhitespace(c)) return;
|
|
668
|
+
this.fail();
|
|
669
|
+
return;
|
|
670
|
+
/* v8 ignore next 2 -- scan() stops stepping once the view is invalid. */
|
|
671
|
+
case "invalid": return;
|
|
672
|
+
/* v8 ignore next 2 -- Every scanner mode has a handler above. */
|
|
673
|
+
default: assertNever(this.#mode);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
fail() {
|
|
677
|
+
this.#invalidAt = this.#consumed;
|
|
678
|
+
this.#mode = "invalid";
|
|
679
|
+
this.#current = null;
|
|
680
|
+
}
|
|
681
|
+
beginKey(at) {
|
|
682
|
+
this.#mode = "key";
|
|
683
|
+
this.#keyStart = at + 1;
|
|
684
|
+
this.#keyEscaped = false;
|
|
685
|
+
this.#escape = false;
|
|
686
|
+
}
|
|
687
|
+
stepKey(c, at) {
|
|
688
|
+
if (c < " ") {
|
|
689
|
+
this.fail();
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
if (this.#escape) {
|
|
693
|
+
this.#escape = false;
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
if (c === "\\") {
|
|
697
|
+
this.#escape = true;
|
|
698
|
+
this.#keyEscaped = true;
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
if (c !== "\"") return;
|
|
702
|
+
const raw = this.slice(this.#keyStart, at);
|
|
703
|
+
if (this.#keyEscaped) try {
|
|
704
|
+
this.#key = JSON.parse(`"${raw}"`);
|
|
705
|
+
} catch (_error) {
|
|
706
|
+
this.fail();
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
else this.#key = raw;
|
|
710
|
+
this.#mode = "colon";
|
|
711
|
+
}
|
|
712
|
+
open(entry) {
|
|
713
|
+
if (!this.#entries.has(this.#key)) this.#order.push(this.#key);
|
|
714
|
+
this.#entries.set(this.#key, entry);
|
|
715
|
+
this.#current = entry;
|
|
716
|
+
}
|
|
717
|
+
beginValue(c, at) {
|
|
718
|
+
if (isWhitespace(c)) return;
|
|
719
|
+
if (c === "\"") {
|
|
720
|
+
this.open({
|
|
721
|
+
kind: "string",
|
|
722
|
+
start: at + 1,
|
|
723
|
+
end: -1,
|
|
724
|
+
needsDecoding: false,
|
|
725
|
+
invalidAt: void 0,
|
|
726
|
+
length: void 0,
|
|
727
|
+
text: void 0,
|
|
728
|
+
prefixes: void 0
|
|
729
|
+
});
|
|
730
|
+
this.#escape = false;
|
|
731
|
+
this.#mode = "string";
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
if (c === "}" || c === "," || c === ":" || c === "]") {
|
|
735
|
+
this.fail();
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
this.open({
|
|
739
|
+
kind: "value",
|
|
740
|
+
start: at,
|
|
741
|
+
end: -1,
|
|
742
|
+
parsed: void 0,
|
|
743
|
+
invalid: false
|
|
744
|
+
});
|
|
745
|
+
if (c === "{" || c === "[") {
|
|
746
|
+
this.#mode = "nested";
|
|
747
|
+
this.#nestedEnds = [c === "{" ? "}" : "]"];
|
|
748
|
+
this.#nestedInString = false;
|
|
749
|
+
this.#escape = false;
|
|
750
|
+
return;
|
|
751
|
+
}
|
|
752
|
+
this.#mode = "scalar";
|
|
753
|
+
}
|
|
754
|
+
stepScalar(c, at) {
|
|
755
|
+
if (c !== "," && c !== "}" && !isWhitespace(c)) return;
|
|
756
|
+
this.closeValue(at);
|
|
757
|
+
this.#mode = c === "," ? "key-only" : c === "}" ? "closed" : "comma-or-end";
|
|
758
|
+
}
|
|
759
|
+
stepNested(c, at) {
|
|
760
|
+
if (this.#nestedInString) {
|
|
761
|
+
this.#nestedInString = false;
|
|
762
|
+
return;
|
|
763
|
+
}
|
|
764
|
+
if (c === "\"") {
|
|
765
|
+
this.#nestedInString = true;
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
if (c === "{" || c === "[") {
|
|
769
|
+
this.#nestedEnds.push(c === "{" ? "}" : "]");
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
772
|
+
if (c === "}" || c === "]") {
|
|
773
|
+
if (this.#nestedEnds.pop() !== c) {
|
|
774
|
+
this.fail();
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
if (this.#nestedEnds.length === 0) {
|
|
778
|
+
this.closeValue(at + 1);
|
|
779
|
+
this.#mode = "comma-or-end";
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
closeValue(end) {
|
|
784
|
+
const entry = this.#current;
|
|
785
|
+
entry.end = end;
|
|
786
|
+
this.#current = null;
|
|
787
|
+
}
|
|
788
|
+
});
|
|
789
|
+
//#endregion
|
|
166
790
|
//#region ../../util/values/src/index.ts
|
|
167
791
|
/**
|
|
168
792
|
* Mark an unreachable closed-union branch.
|
|
@@ -285,7 +909,7 @@ const MAX_TIMER_DELAY_MS = 2147483647;
|
|
|
285
909
|
*/
|
|
286
910
|
/**
|
|
287
911
|
* Base class for all harness errors. Carries a `code` (stable, programmatic —
|
|
288
|
-
* e.g. `NO_ADAPTER`, `INVALID_ARGS
|
|
912
|
+
* e.g. `NO_ADAPTER`, `INVALID_ARGS`) distinct from the
|
|
289
913
|
* human-readable `message`, and supports `cause` chaining via the standard
|
|
290
914
|
* `ErrorOptions`. `name` defaults to the subclass constructor name.
|
|
291
915
|
*/
|
|
@@ -708,7 +1332,7 @@ function projectToolUpdates(messages, tools, toolUpdate, history) {
|
|
|
708
1332
|
/**
|
|
709
1333
|
* Centralize the non-secret product identity every provider request sends as `User-Agent`, keeping
|
|
710
1334
|
* adapters from drifting. See
|
|
711
|
-
*
|
|
1335
|
+
* `docs/subsystems/llm-streaming.md#appidentity--app-attribution`.
|
|
712
1336
|
*
|
|
713
1337
|
* App-attribution vocabulary for provider requests.
|
|
714
1338
|
* @module @deepseek-ai/dsh-llm/attribution
|
|
@@ -851,20 +1475,14 @@ var LlmError = class extends HarnessError {
|
|
|
851
1475
|
}
|
|
852
1476
|
/** Notify topology observers without letting one broken listener veto the commit. */
|
|
853
1477
|
emitAdaptersUpdated() {
|
|
854
|
-
let invariantFailure;
|
|
855
1478
|
for (const listener of this.ctx.events.dispatch("emit", ["llm/adapters-updated"])) try {
|
|
856
1479
|
const returned = listener();
|
|
857
1480
|
if (returned != null && typeof returned.then === "function") Promise.resolve(returned).then(void 0, (error) => {
|
|
858
1481
|
this.warnAdaptersListenerFailure(error);
|
|
859
1482
|
});
|
|
860
1483
|
} catch (error) {
|
|
861
|
-
if (error?.code === "INVARIANT") {
|
|
862
|
-
invariantFailure ??= error;
|
|
863
|
-
continue;
|
|
864
|
-
}
|
|
865
1484
|
this.warnAdaptersListenerFailure(error);
|
|
866
1485
|
}
|
|
867
|
-
if (invariantFailure !== void 0) throw invariantFailure;
|
|
868
1486
|
}
|
|
869
1487
|
/** Contained-listener diagnostic shared by the sync and async failure paths. */
|
|
870
1488
|
warnAdaptersListenerFailure(error) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-tmux-context",
|
|
3
3
|
"description": "Opt-in durable per-step context with this agent's tmux pane and window location",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.1-alpha.1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -28,23 +28,23 @@
|
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"zod": "^4.4.3",
|
|
31
|
-
"@deepseek-ai/schemastery": "~3.18.
|
|
31
|
+
"@deepseek-ai/schemastery": "~3.18.5-alpha.1"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@deepseek-ai/dsh-
|
|
35
|
-
"@deepseek-ai/dsh-
|
|
36
|
-
"@deepseek-ai/
|
|
37
|
-
"@deepseek-ai/
|
|
38
|
-
"@deepseek-ai/dsh-session-projection": "0.2.
|
|
34
|
+
"@deepseek-ai/dsh-agent": "0.2.1-alpha.1",
|
|
35
|
+
"@deepseek-ai/dsh-shell": "0.2.1-alpha.1",
|
|
36
|
+
"@deepseek-ai/dsh-session": "0.2.1-alpha.1",
|
|
37
|
+
"@deepseek-ai/cordis": "~4.0.5-alpha.1",
|
|
38
|
+
"@deepseek-ai/dsh-session-projection": "0.2.1-alpha.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@deepseek-ai/dsh-agent": "0.2.
|
|
42
|
-
"@deepseek-ai/dsh-agent-loop-testkit": "0.2.
|
|
43
|
-
"@deepseek-ai/dsh-shell": "0.2.
|
|
44
|
-
"@deepseek-ai/dsh-llm": "0.2.
|
|
45
|
-
"@deepseek-ai/dsh-
|
|
46
|
-
"@deepseek-ai/dsh-
|
|
47
|
-
"@deepseek-ai/dsh-session
|
|
48
|
-
"@deepseek-ai/cordis": "~4.0.
|
|
41
|
+
"@deepseek-ai/dsh-agent": "0.2.1-alpha.1",
|
|
42
|
+
"@deepseek-ai/dsh-agent-loop-testkit": "0.2.1-alpha.1",
|
|
43
|
+
"@deepseek-ai/dsh-shell": "0.2.1-alpha.1",
|
|
44
|
+
"@deepseek-ai/dsh-llm": "0.2.1-alpha.1",
|
|
45
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.1",
|
|
46
|
+
"@deepseek-ai/dsh-session-projection": "0.2.1-alpha.1",
|
|
47
|
+
"@deepseek-ai/dsh-session": "0.2.1-alpha.1",
|
|
48
|
+
"@deepseek-ai/cordis": "~4.0.5-alpha.1"
|
|
49
49
|
}
|
|
50
50
|
}
|