@karlorz/codexhost-cli-win32-x64 0.16.1-3 → 0.17.0-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.
@@ -5018,10 +5018,10 @@ function mergeDefs(...defs) {
5018
5018
  function cloneDef(schema) {
5019
5019
  return mergeDefs(schema._zod.def);
5020
5020
  }
5021
- function getElementAtPath(obj, path9) {
5022
- if (!path9)
5021
+ function getElementAtPath(obj, path11) {
5022
+ if (!path11)
5023
5023
  return obj;
5024
- return path9.reduce((acc, key) => acc?.[key], obj);
5024
+ return path11.reduce((acc, key) => acc?.[key], obj);
5025
5025
  }
5026
5026
  function promiseAllObject(promisesObj) {
5027
5027
  const keys = Object.keys(promisesObj);
@@ -5430,11 +5430,11 @@ function explicitlyAborted(x, startIndex = 0) {
5430
5430
  }
5431
5431
  return false;
5432
5432
  }
5433
- function prefixIssues(path9, issues) {
5433
+ function prefixIssues(path11, issues) {
5434
5434
  return issues.map((iss) => {
5435
5435
  var _a3;
5436
5436
  (_a3 = iss).path ?? (_a3.path = []);
5437
- iss.path.unshift(path9);
5437
+ iss.path.unshift(path11);
5438
5438
  return iss;
5439
5439
  });
5440
5440
  }
@@ -5581,16 +5581,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
5581
5581
  }
5582
5582
  function formatError(error51, mapper = (issue2) => issue2.message) {
5583
5583
  const fieldErrors = { _errors: [] };
5584
- const processError = (error52, path9 = []) => {
5584
+ const processError = (error52, path11 = []) => {
5585
5585
  for (const issue2 of error52.issues) {
5586
5586
  if (issue2.code === "invalid_union" && issue2.errors.length) {
5587
- issue2.errors.map((issues) => processError({ issues }, [...path9, ...issue2.path]));
5587
+ issue2.errors.map((issues) => processError({ issues }, [...path11, ...issue2.path]));
5588
5588
  } else if (issue2.code === "invalid_key") {
5589
- processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
5589
+ processError({ issues: issue2.issues }, [...path11, ...issue2.path]);
5590
5590
  } else if (issue2.code === "invalid_element") {
5591
- processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
5591
+ processError({ issues: issue2.issues }, [...path11, ...issue2.path]);
5592
5592
  } else {
5593
- const fullpath = [...path9, ...issue2.path];
5593
+ const fullpath = [...path11, ...issue2.path];
5594
5594
  if (fullpath.length === 0) {
5595
5595
  fieldErrors._errors.push(mapper(issue2));
5596
5596
  } else {
@@ -5617,17 +5617,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
5617
5617
  }
5618
5618
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
5619
5619
  const result = { errors: [] };
5620
- const processError = (error52, path9 = []) => {
5620
+ const processError = (error52, path11 = []) => {
5621
5621
  var _a3, _b;
5622
5622
  for (const issue2 of error52.issues) {
5623
5623
  if (issue2.code === "invalid_union" && issue2.errors.length) {
5624
- issue2.errors.map((issues) => processError({ issues }, [...path9, ...issue2.path]));
5624
+ issue2.errors.map((issues) => processError({ issues }, [...path11, ...issue2.path]));
5625
5625
  } else if (issue2.code === "invalid_key") {
5626
- processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
5626
+ processError({ issues: issue2.issues }, [...path11, ...issue2.path]);
5627
5627
  } else if (issue2.code === "invalid_element") {
5628
- processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
5628
+ processError({ issues: issue2.issues }, [...path11, ...issue2.path]);
5629
5629
  } else {
5630
- const fullpath = [...path9, ...issue2.path];
5630
+ const fullpath = [...path11, ...issue2.path];
5631
5631
  if (fullpath.length === 0) {
5632
5632
  result.errors.push(mapper(issue2));
5633
5633
  continue;
@@ -5659,8 +5659,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
5659
5659
  }
5660
5660
  function toDotPath(_path) {
5661
5661
  const segs = [];
5662
- const path9 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
5663
- for (const seg of path9) {
5662
+ const path11 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
5663
+ for (const seg of path11) {
5664
5664
  if (typeof seg === "number")
5665
5665
  segs.push(`[${seg}]`);
5666
5666
  else if (typeof seg === "symbol")
@@ -18352,13 +18352,13 @@ function resolveRef(ref, ctx) {
18352
18352
  if (!ref.startsWith("#")) {
18353
18353
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
18354
18354
  }
18355
- const path9 = ref.slice(1).split("/").filter(Boolean);
18356
- if (path9.length === 0) {
18355
+ const path11 = ref.slice(1).split("/").filter(Boolean);
18356
+ if (path11.length === 0) {
18357
18357
  return ctx.rootSchema;
18358
18358
  }
18359
18359
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
18360
- if (path9[0] === defsKey) {
18361
- const key = path9[1];
18360
+ if (path11[0] === defsKey) {
18361
+ const key = path11[1];
18362
18362
  if (!key || !ctx.defs[key]) {
18363
18363
  throw new Error(`Reference not found: ${ref}`);
18364
18364
  }
@@ -21126,16 +21126,16 @@ var Diff = class {
21126
21126
  }
21127
21127
  }
21128
21128
  }
21129
- addToPath(path9, added, removed, oldPosInc, options) {
21130
- const last = path9.lastComponent;
21129
+ addToPath(path11, added, removed, oldPosInc, options) {
21130
+ const last = path11.lastComponent;
21131
21131
  if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
21132
21132
  return {
21133
- oldPos: path9.oldPos + oldPosInc,
21133
+ oldPos: path11.oldPos + oldPosInc,
21134
21134
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
21135
21135
  };
21136
21136
  } else {
21137
21137
  return {
21138
- oldPos: path9.oldPos + oldPosInc,
21138
+ oldPos: path11.oldPos + oldPosInc,
21139
21139
  lastComponent: { count: 1, added, removed, previousComponent: last }
21140
21140
  };
21141
21141
  }
@@ -22742,7 +22742,7 @@ var DeepSeekGenerationProbeError = class extends Error {
22742
22742
  this.stderrTail = options.stderrTail;
22743
22743
  }
22744
22744
  };
22745
- var DEFAULT_TIMEOUT_MS = 5e3;
22745
+ var DEFAULT_TIMEOUT_MS = 15e3;
22746
22746
  var DEFAULT_CLEANUP_TIMEOUT_MS = 1e3;
22747
22747
  var DEFAULT_OUTPUT_LIMIT_BYTES = 16 * 1024;
22748
22748
  var DIAGNOSTIC_RAW_TAIL_BYTES = 16 * 1024;
@@ -23052,7 +23052,7 @@ async function probeDeepSeekExecutableGeneration(options = {}, dependencies = {
23052
23052
 
23053
23053
  // dist/modern/deepseek-harness-adapter.js
23054
23054
  import { randomUUID as randomUUID2 } from "node:crypto";
23055
- import path8 from "node:path";
23055
+ import path10 from "node:path";
23056
23056
 
23057
23057
  // dist/modern/catalog.js
23058
23058
  import { Buffer as Buffer3 } from "node:buffer";
@@ -23173,7 +23173,7 @@ var ModernRemoteConnectionError = class extends Error {
23173
23173
  this.remoteFailure = sanitizeModernRemoteFailure(remoteFailure3);
23174
23174
  }
23175
23175
  };
23176
- var DEFAULT_STARTUP_TIMEOUT_MS = 2e4;
23176
+ var DEFAULT_STARTUP_TIMEOUT_MS = 9e4;
23177
23177
  var DEFAULT_UNARY_TIMEOUT_MS = 1e4;
23178
23178
  var DEFAULT_STREAM_OPEN_TIMEOUT_MS = 1e4;
23179
23179
  var DEFAULT_CLOSE_TIMEOUT_MS = 3e3;
@@ -27269,8 +27269,369 @@ function invalidInbox() {
27269
27269
  }
27270
27270
 
27271
27271
  // dist/modern/history.js
27272
+ import path8 from "node:path";
27272
27273
  import { isDeepStrictEqual as isDeepStrictEqual5 } from "node:util";
27273
27274
 
27275
+ // ../../harness-adapter/dist/local-media-markdown.js
27276
+ import { existsSync, statSync as statSync2 } from "node:fs";
27277
+ import path7 from "node:path";
27278
+ import { fileURLToPath } from "node:url";
27279
+ var MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
27280
+ ".aac",
27281
+ ".gif",
27282
+ ".jpeg",
27283
+ ".jpg",
27284
+ ".m4a",
27285
+ ".m4v",
27286
+ ".mov",
27287
+ ".mp3",
27288
+ ".mp4",
27289
+ ".ogg",
27290
+ ".png",
27291
+ ".svg",
27292
+ ".wav",
27293
+ ".webm",
27294
+ ".webp"
27295
+ ]);
27296
+ function rewriteLocalMediaMarkdown(text, roots, options = {}) {
27297
+ return projectLocalMedia(text, roots, options.exists ?? mediaFileExists, options.holdIncomplete === true, options.relativeImagesOnly === true).text;
27298
+ }
27299
+ var LocalMediaMarkdownStream = class {
27300
+ #roots;
27301
+ #exists;
27302
+ #relativeImagesOnly;
27303
+ #native = "";
27304
+ #text = "";
27305
+ /** Native text length represented by `#text`; the rest is held. */
27306
+ #consumed = 0;
27307
+ #verbatim = false;
27308
+ constructor(roots, exists = mediaFileExists, options = {}) {
27309
+ this.#roots = [...roots];
27310
+ this.#relativeImagesOnly = options.relativeImagesOnly === true;
27311
+ const known = /* @__PURE__ */ new Map();
27312
+ this.#exists = (absolutePath) => {
27313
+ let found = known.get(absolutePath);
27314
+ if (found === void 0) {
27315
+ found = exists(absolutePath);
27316
+ known.set(absolutePath, found);
27317
+ }
27318
+ return found;
27319
+ };
27320
+ }
27321
+ /** Projected text published so far: every returned delta, concatenated. */
27322
+ get text() {
27323
+ return this.#text;
27324
+ }
27325
+ /** Add native text and return the projected text it makes publishable, possibly empty. */
27326
+ append(text) {
27327
+ this.#native += text;
27328
+ return this.#advance(true);
27329
+ }
27330
+ /** Return the projected text still held at the end of the stream. */
27331
+ flush() {
27332
+ return this.#advance(false);
27333
+ }
27334
+ #advance(holdIncomplete) {
27335
+ const next = this.#verbatim ? void 0 : projectLocalMedia(this.#native, this.#roots, this.#exists, holdIncomplete, this.#relativeImagesOnly);
27336
+ let delta;
27337
+ if (next?.text.startsWith(this.#text)) {
27338
+ delta = next.text.slice(this.#text.length);
27339
+ this.#consumed = next.consumed;
27340
+ } else {
27341
+ this.#verbatim = true;
27342
+ delta = this.#native.slice(this.#consumed);
27343
+ this.#consumed = this.#native.length;
27344
+ }
27345
+ this.#text += delta;
27346
+ return delta;
27347
+ }
27348
+ };
27349
+ function projectLocalMedia(text, roots, exists, holdIncomplete, relativeImagesOnly) {
27350
+ let output = "";
27351
+ let index = 0;
27352
+ let fence = null;
27353
+ while (index < text.length) {
27354
+ if (fence) {
27355
+ const close = closingFenceEnd(text, index, fence.marker, fence.length);
27356
+ if (close === -1)
27357
+ break;
27358
+ output += text.slice(index, close);
27359
+ index = close;
27360
+ fence = null;
27361
+ continue;
27362
+ }
27363
+ const next = earliestIndex([
27364
+ text.indexOf("![", index),
27365
+ text.indexOf("`", index),
27366
+ indexOfLineStartTilde(text, index)
27367
+ ]);
27368
+ if (next === -1)
27369
+ break;
27370
+ output += text.slice(index, next);
27371
+ index = next;
27372
+ const marker = text[next];
27373
+ let markerLength = 1;
27374
+ if (marker === "`" || marker === "~") {
27375
+ let runEnd = next;
27376
+ while (text[runEnd] === marker)
27377
+ runEnd += 1;
27378
+ markerLength = runEnd - next;
27379
+ if (runEnd === text.length && holdIncomplete) {
27380
+ return { text: output, consumed: next };
27381
+ }
27382
+ if (runEnd - next >= 3) {
27383
+ const kind = fenceLineKind(text, next);
27384
+ if (kind === "opaque")
27385
+ break;
27386
+ if (kind === "flat") {
27387
+ fence = { marker, length: runEnd - next };
27388
+ output += text.slice(next, runEnd);
27389
+ index = runEnd;
27390
+ continue;
27391
+ }
27392
+ }
27393
+ if (marker === "~") {
27394
+ output += text.slice(next, runEnd);
27395
+ index = runEnd;
27396
+ continue;
27397
+ }
27398
+ }
27399
+ if (text.startsWith("![", next)) {
27400
+ const image = parseMarkdownImage(text, next);
27401
+ if (image.kind === "text") {
27402
+ output += text.slice(next, image.end);
27403
+ index = image.end;
27404
+ continue;
27405
+ }
27406
+ if (image.kind === "open") {
27407
+ if (!holdIncomplete)
27408
+ break;
27409
+ return { text: output + text.slice(next, image.holdFrom), consumed: image.holdFrom };
27410
+ }
27411
+ const resolved2 = relativeImagesOnly && /^(?:[\\/]|[a-z][a-z\d+.-]*:)/i.test(image.destination.trim()) ? null : resolveLocalMediaPath(image.destination, roots, exists);
27412
+ output += resolved2 === null ? text.slice(next, image.end) : text.slice(next, image.destinationStart) + markdownDestination(resolved2, image.bracketed) + text.slice(image.destinationEnd, image.end);
27413
+ index = image.end;
27414
+ continue;
27415
+ }
27416
+ const code = parseInlineCode(text, next, markerLength);
27417
+ if (code.kind !== "code" || holdIncomplete && code.end === text.length) {
27418
+ if (holdIncomplete && code.kind !== "text")
27419
+ return { text: output, consumed: next };
27420
+ output += text.slice(next, next + markerLength);
27421
+ index = next + markerLength;
27422
+ continue;
27423
+ }
27424
+ const resolved = relativeImagesOnly || markerLength !== 1 || /[\r\n]/u.test(code.content) ? null : resolveLocalMediaPath(code.content, roots, exists);
27425
+ output += resolved === null ? text.slice(next, code.end) : mediaMarkdownImage(resolved);
27426
+ index = code.end;
27427
+ }
27428
+ return { text: output + text.slice(index), consumed: text.length };
27429
+ }
27430
+ function fenceLineKind(text, index) {
27431
+ const prefix = text.slice(text.lastIndexOf("\n", index - 1) + 1, index);
27432
+ if (prefix === "")
27433
+ return "flat";
27434
+ let remaining = prefix.replace(/^[ \t]+/u, "");
27435
+ while (remaining) {
27436
+ const marker = /^(?:>|(?:[-+*]|\d{1,9}[.)])(?=[ \t]))[ \t]*/u.exec(remaining);
27437
+ if (!marker)
27438
+ return null;
27439
+ remaining = remaining.slice(marker[0].length);
27440
+ }
27441
+ return "opaque";
27442
+ }
27443
+ function indexOfLineStartTilde(text, start) {
27444
+ for (let tilde = text.indexOf("~", start); tilde !== -1; tilde = text.indexOf("~", tilde + 1)) {
27445
+ if (fenceLineKind(text, tilde) !== null)
27446
+ return tilde;
27447
+ }
27448
+ return -1;
27449
+ }
27450
+ function closingFenceEnd(text, start, marker, length) {
27451
+ const closing = new RegExp(`^ {0,3}${marker === "`" ? "`" : "~"}{${length},}[ \\t]*\\r?$`, "u");
27452
+ let lineStart = text.indexOf("\n", start);
27453
+ while (lineStart !== -1) {
27454
+ lineStart += 1;
27455
+ const newline = text.indexOf("\n", lineStart);
27456
+ const lineEnd = newline === -1 ? text.length : newline;
27457
+ if (closing.test(text.slice(lineStart, lineEnd)))
27458
+ return lineEnd;
27459
+ lineStart = newline;
27460
+ }
27461
+ return -1;
27462
+ }
27463
+ function earliestIndex(candidates) {
27464
+ let next = -1;
27465
+ for (const candidate of candidates) {
27466
+ if (candidate === -1)
27467
+ continue;
27468
+ if (next === -1 || candidate < next)
27469
+ next = candidate;
27470
+ }
27471
+ return next;
27472
+ }
27473
+ function parseInlineCode(text, start, length) {
27474
+ let index = start + length;
27475
+ while (index < text.length) {
27476
+ const tick = text.indexOf("`", index);
27477
+ if (/\n[^\S\n]*\n/u.test(text.slice(index, tick < 0 ? text.length : tick))) {
27478
+ return { kind: "text" };
27479
+ }
27480
+ if (tick === -1)
27481
+ break;
27482
+ let end = tick + 1;
27483
+ while (text[end] === "`")
27484
+ end += 1;
27485
+ if (end - tick === length) {
27486
+ return { kind: "code", content: text.slice(start + length, tick), end };
27487
+ }
27488
+ index = end;
27489
+ }
27490
+ return { kind: "open" };
27491
+ }
27492
+ function parseMarkdownImage(text, start) {
27493
+ const openLabel = { kind: "open", holdFrom: start + 2 };
27494
+ let index = start + 2;
27495
+ while (index < text.length) {
27496
+ const character = text[index];
27497
+ if (character === "\n")
27498
+ return { kind: "text", end: start + 1 };
27499
+ if (character === "\\") {
27500
+ index += 2;
27501
+ continue;
27502
+ }
27503
+ if (character === "]")
27504
+ break;
27505
+ index += 1;
27506
+ }
27507
+ if (index + 1 >= text.length)
27508
+ return openLabel;
27509
+ if (text[index + 1] !== "(")
27510
+ return { kind: "text", end: start + 1 };
27511
+ const destinationStart = index + 2;
27512
+ const open = { kind: "open", holdFrom: destinationStart };
27513
+ const malformed = { kind: "text", end: destinationStart };
27514
+ index = skipBlanks(text, destinationStart);
27515
+ if (index >= text.length)
27516
+ return open;
27517
+ let destination;
27518
+ let destinationEnd;
27519
+ let bracketed = false;
27520
+ if (text[index] === "<") {
27521
+ bracketed = true;
27522
+ let close = index + 1;
27523
+ while (close < text.length && text[close] !== ">" && text[close] !== "\n")
27524
+ close += 1;
27525
+ if (close >= text.length)
27526
+ return open;
27527
+ if (text[close] === "\n")
27528
+ return malformed;
27529
+ destination = text.slice(index + 1, close);
27530
+ destinationEnd = close + 1;
27531
+ index = destinationEnd;
27532
+ } else {
27533
+ const begin = index;
27534
+ while (index < text.length) {
27535
+ const character = text[index];
27536
+ if (character === "\n" || character === " " || character === " " || character === ")")
27537
+ break;
27538
+ index += character === "\\" ? 2 : 1;
27539
+ }
27540
+ if (index >= text.length)
27541
+ return open;
27542
+ destination = unescapeMarkdown(text.slice(begin, index));
27543
+ destinationEnd = index;
27544
+ }
27545
+ index = skipBlanks(text, index);
27546
+ if (index >= text.length)
27547
+ return open;
27548
+ const opener = text[index];
27549
+ if (opener === '"' || opener === "'" || opener === "(") {
27550
+ const closer = opener === "(" ? ")" : opener;
27551
+ index += 1;
27552
+ while (index < text.length && text[index] !== closer && text[index] !== "\n")
27553
+ index += 1;
27554
+ if (index >= text.length)
27555
+ return open;
27556
+ if (text[index] === "\n")
27557
+ return malformed;
27558
+ index = skipBlanks(text, index + 1);
27559
+ if (index >= text.length)
27560
+ return open;
27561
+ }
27562
+ if (text[index] !== ")")
27563
+ return malformed;
27564
+ return {
27565
+ kind: "image",
27566
+ destination,
27567
+ destinationStart,
27568
+ destinationEnd,
27569
+ end: index + 1,
27570
+ bracketed
27571
+ };
27572
+ }
27573
+ function skipBlanks(text, start) {
27574
+ let index = start;
27575
+ while (text[index] === " " || text[index] === " ")
27576
+ index += 1;
27577
+ return index;
27578
+ }
27579
+ function mediaMarkdownImage(absolutePath) {
27580
+ const name = path7.basename(absolutePath).replaceAll("]", "\\]");
27581
+ return `![${name}](${markdownDestination(absolutePath, false)})`;
27582
+ }
27583
+ function markdownDestination(absolutePath, bracketed) {
27584
+ const encoded = absolutePath.replaceAll("%", "%2525");
27585
+ const destination = /^[A-Za-z]:\\/.test(encoded) ? encoded.replaceAll("\\", "/") : encoded.replaceAll("\\", "\\\\");
27586
+ return bracketed || /[\s()]/.test(destination) ? `<${destination}>` : destination;
27587
+ }
27588
+ function unescapeMarkdown(value) {
27589
+ return value.replace(/\\([\\()])/g, "$1");
27590
+ }
27591
+ function resolveLocalMediaPath(raw, roots, exists = mediaFileExists) {
27592
+ const trimmed = raw.trim();
27593
+ if (trimmed.length === 0 || isRemoteMediaUrl(trimmed))
27594
+ return null;
27595
+ const stripped = stripFileUrl(trimmed);
27596
+ if (stripped === null)
27597
+ return null;
27598
+ if (isAbsoluteMediaPath(stripped)) {
27599
+ const absolute = path7.resolve(stripped);
27600
+ return hasMediaExtension(absolute) && exists(absolute) ? absolute : null;
27601
+ }
27602
+ for (const root of roots) {
27603
+ const absolute = path7.resolve(root, stripped);
27604
+ if (hasMediaExtension(absolute) && exists(absolute))
27605
+ return absolute;
27606
+ }
27607
+ return null;
27608
+ }
27609
+ function isRemoteMediaUrl(value) {
27610
+ return /^(?:https?:|data:|app:|blob:)/i.test(value);
27611
+ }
27612
+ function stripFileUrl(value) {
27613
+ if (!value.toLowerCase().startsWith("file:"))
27614
+ return value;
27615
+ try {
27616
+ return fileURLToPath(value);
27617
+ } catch {
27618
+ return null;
27619
+ }
27620
+ }
27621
+ function isAbsoluteMediaPath(value) {
27622
+ return path7.isAbsolute(value) || /^[a-zA-Z]:[\\/]/.test(value);
27623
+ }
27624
+ function hasMediaExtension(value) {
27625
+ return MEDIA_EXTENSIONS.has(path7.extname(value).toLowerCase());
27626
+ }
27627
+ function mediaFileExists(absolutePath) {
27628
+ try {
27629
+ return existsSync(absolutePath) && statSync2(absolutePath).isFile();
27630
+ } catch {
27631
+ return false;
27632
+ }
27633
+ }
27634
+
27274
27635
  // dist/modern/compaction.js
27275
27636
  var MODERN_CONTEXT_PRESSURE_KEY = "contextPressure";
27276
27637
  function modernCompactionOutcome(data) {
@@ -27888,6 +28249,8 @@ function projectModernHistory(input) {
27888
28249
  let effectiveThinkingOptionId = input.fallbackThinkingOptionId;
27889
28250
  let contextWindowTokens;
27890
28251
  let usage = null;
28252
+ let workingDirectory = input.cwd;
28253
+ const media = input.media ?? input.cwd !== void 0;
27891
28254
  const rawUsageByStep = /* @__PURE__ */ new Map();
27892
28255
  const rebuildUsage = () => {
27893
28256
  usage = null;
@@ -27909,6 +28272,7 @@ function projectModernHistory(input) {
27909
28272
  if (!KNOWN_EVENT_TYPES.has(event.type) || !isRecord4(event.data))
27910
28273
  continue;
27911
28274
  const data = event.data;
28275
+ workingDirectory = modernWorkingDirectory(workingDirectory, event);
27912
28276
  switch (event.type) {
27913
28277
  case "turn/start":
27914
28278
  active = {
@@ -27953,8 +28317,9 @@ function projectModernHistory(input) {
27953
28317
  case "assistant/message":
27954
28318
  if (event.surfaceOp === "append") {
27955
28319
  recordSettlementUsage(data, event.seq);
27956
- if (active)
27957
- projectAssistantMessage(active, input.sessionId, data);
28320
+ if (active) {
28321
+ projectAssistantMessage(active, input.sessionId, data, media ? modernMediaRoots(workingDirectory, input.cwd) : void 0);
28322
+ }
27958
28323
  }
27959
28324
  break;
27960
28325
  case "compaction/start":
@@ -28075,7 +28440,21 @@ function modernCheckpointRef(harnessId, sessionId, seq, profile = DEEPSEEK_V4_PR
28075
28440
  function modernItemId(sessionId, key) {
28076
28441
  return hostItemIdSchema.parse(`dsh-modern:${sessionId}:${key}`);
28077
28442
  }
28078
- function projectAssistantMessage(turn, sessionId, data) {
28443
+ function modernWorkingDirectory(current, event) {
28444
+ if (event.type !== "working-directory/change" || !isRecord4(event.data) || typeof event.data.cwd !== "string") {
28445
+ return current;
28446
+ }
28447
+ const next = event.data.cwd;
28448
+ if (path8.isAbsolute(next))
28449
+ return path8.resolve(next);
28450
+ return current === void 0 ? void 0 : path8.resolve(current, next);
28451
+ }
28452
+ function modernMediaRoots(workingDirectory, sessionDirectory) {
28453
+ return [
28454
+ ...new Set([workingDirectory ?? sessionDirectory, sessionDirectory].filter((root) => root !== void 0))
28455
+ ];
28456
+ }
28457
+ function projectAssistantMessage(turn, sessionId, data, mediaRoots) {
28079
28458
  const message = data.message;
28080
28459
  if (Array.isArray(message.content)) {
28081
28460
  for (const block of message.content) {
@@ -28098,7 +28477,7 @@ function projectAssistantMessage(turn, sessionId, data) {
28098
28477
  const item = {
28099
28478
  type: "agentMessage",
28100
28479
  itemId: modernItemId(sessionId, `turn:${turn.turn}:step:${String(data.step)}:assistant`),
28101
- text
28480
+ text: mediaRoots ? rewriteLocalMediaMarkdown(text, mediaRoots) : text
28102
28481
  };
28103
28482
  turn.items.push({ item, outcome: { status: "succeeded" } });
28104
28483
  }
@@ -28917,6 +29296,8 @@ var ModernHarnessSession = class {
28917
29296
  #flushSession;
28918
29297
  #fallbackModel;
28919
29298
  #fallbackThinkingOptionId;
29299
+ #sessionDirectory;
29300
+ #workingDirectory;
28920
29301
  #channel = new HarnessOutputChannel();
28921
29302
  #validator;
28922
29303
  #events;
@@ -28983,8 +29364,12 @@ var ModernHarnessSession = class {
28983
29364
  this.#events = [...options.journal.events];
28984
29365
  this.#historyBytes = journalHistoryBytes(this.#events, this.#maxHistoryBytes);
28985
29366
  this.#validator = new ModernEventValidator(this.#maxEvents, this.#profile);
28986
- for (const event of this.#events)
29367
+ this.#sessionDirectory = options.journal.header.cwd;
29368
+ this.#workingDirectory = this.#sessionDirectory;
29369
+ for (const event of this.#events) {
28987
29370
  this.#validator.accept(event);
29371
+ this.#workingDirectory = modernWorkingDirectory(this.#workingDirectory, event);
29372
+ }
28988
29373
  const projection = projectModernHistory({
28989
29374
  harnessId: this.harnessId,
28990
29375
  sessionId: this.#sessionId,
@@ -29019,12 +29404,18 @@ var ModernHarnessSession = class {
29019
29404
  };
29020
29405
  let resumedAutonomousBuffer;
29021
29406
  if (projection.incompleteTurn) {
29407
+ let workingDirectory = this.#sessionDirectory;
29408
+ const turnStart = this.#events.length - projection.incompleteTurn.events.length;
29409
+ for (const event of this.#events.slice(0, turnStart)) {
29410
+ workingDirectory = modernWorkingDirectory(workingDirectory, event);
29411
+ }
29022
29412
  const buffer = {
29023
29413
  nativeTurn: projection.incompleteTurn.turn,
29024
29414
  events: [...projection.incompleteTurn.events],
29025
29415
  input: [],
29026
29416
  initialResume: true,
29027
29417
  replayed: 0,
29418
+ workingDirectory,
29028
29419
  sawUserMessage: false,
29029
29420
  reachedCorrelationBoundary: false
29030
29421
  };
@@ -29066,7 +29457,7 @@ var ModernHarnessSession = class {
29066
29457
  return Promise.resolve({ ok: false, error: busyError("read history") });
29067
29458
  this.#reading = true;
29068
29459
  try {
29069
- const projection = this.#project();
29460
+ const projection = this.#project(true);
29070
29461
  const configuration = this.#readConfiguration();
29071
29462
  return Promise.resolve({
29072
29463
  ok: true,
@@ -30000,6 +30391,7 @@ ${question.detail}` : question.question;
30000
30391
  this.#validator.accept(event);
30001
30392
  this.#observeAssistantSettlement(event);
30002
30393
  this.#events.push(event);
30394
+ this.#workingDirectory = modernWorkingDirectory(this.#workingDirectory, event);
30003
30395
  this.#meterUsage(event);
30004
30396
  this.#historyBytes += bytes;
30005
30397
  this.#receive(event);
@@ -30125,8 +30517,8 @@ ${question.detail}` : question.question;
30125
30517
  const agent = active.agent;
30126
30518
  if (!agent)
30127
30519
  return;
30128
- agent.text += CANCELLED_ASSISTANT_ATTEMPT_SUFFIX;
30129
- agent.item = { ...agent.item, text: agent.text };
30520
+ this.#flushAgent(active, agent);
30521
+ agent.item = { ...agent.item, text: agent.item.text + CANCELLED_ASSISTANT_ATTEMPT_SUFFIX };
30130
30522
  this.#emit({
30131
30523
  type: "item.updated",
30132
30524
  turnId: active.turnId,
@@ -30249,6 +30641,7 @@ ${question.detail}` : question.question;
30249
30641
  input: [],
30250
30642
  initialResume: false,
30251
30643
  replayed: 0,
30644
+ workingDirectory: this.#workingDirectory,
30252
30645
  sawUserMessage: false,
30253
30646
  reachedCorrelationBoundary: false
30254
30647
  };
@@ -30427,6 +30820,7 @@ ${question.detail}` : question.question;
30427
30820
  while (!this.#closed && buffer.replayed < buffer.events.length) {
30428
30821
  const event = buffer.events[buffer.replayed];
30429
30822
  buffer.replayed += 1;
30823
+ buffer.workingDirectory = modernWorkingDirectory(buffer.workingDirectory, event);
30430
30824
  this.#projectLiveEvent(buffer, event, initialReplay);
30431
30825
  }
30432
30826
  this.#projectAssistantLiveChunks();
@@ -30531,16 +30925,28 @@ ${question.detail}` : question.question;
30531
30925
  itemId: modernItemId(this.#sessionId, `turn:${active.nativeTurn}:step:${step}:${attemptId ? `attempt:${attemptId}:` : ""}assistant`),
30532
30926
  text: ""
30533
30927
  };
30534
- active.agent = { item, text: "" };
30928
+ const buffer = this.#buffer;
30929
+ const workingDirectory = buffer?.active === active ? buffer.workingDirectory : this.#workingDirectory;
30930
+ const roots = modernMediaRoots(workingDirectory, this.#sessionDirectory);
30931
+ active.agent = { item, text: "", media: new LocalMediaMarkdownStream(roots) };
30535
30932
  this.#emit({ type: "item.started", turnId: active.turnId, item });
30536
30933
  }
30537
30934
  active.agent.text += text;
30538
- active.agent.item = { ...active.agent.item, text: active.agent.text };
30935
+ this.#publishAgent(active, active.agent, active.agent.media.append(text));
30936
+ }
30937
+ /** Publish text the media projection held for a trailing construct before the Item ends. */
30938
+ #flushAgent(active, agent) {
30939
+ this.#publishAgent(active, agent, agent.media.flush());
30940
+ }
30941
+ #publishAgent(active, agent, delta) {
30942
+ if (!delta)
30943
+ return;
30944
+ agent.item = { ...agent.item, text: agent.media.text };
30539
30945
  this.#emit({
30540
30946
  type: "item.updated",
30541
30947
  turnId: active.turnId,
30542
- itemId: active.agent.item.itemId,
30543
- update: { type: "text.append", text }
30948
+ itemId: agent.item.itemId,
30949
+ update: { type: "text.append", text: delta }
30544
30950
  });
30545
30951
  }
30546
30952
  #startReasoning(active, step, provisional, attemptId) {
@@ -30628,6 +31034,7 @@ ${question.detail}` : question.question;
30628
31034
  }
30629
31035
  if (!current)
30630
31036
  return;
31037
+ this.#flushAgent(active, current);
30631
31038
  delete active.agent;
30632
31039
  this.#completeItem(active, current.item, { status: "succeeded" });
30633
31040
  }
@@ -30769,9 +31176,10 @@ ${question.detail}` : question.question;
30769
31176
  this.#completeItem(active, item, outcome);
30770
31177
  }
30771
31178
  if (active.agent) {
30772
- const item = active.agent.item;
31179
+ const agent = active.agent;
31180
+ this.#flushAgent(active, agent);
30773
31181
  delete active.agent;
30774
- this.#completeItem(active, item, outcome);
31182
+ this.#completeItem(active, agent.item, outcome);
30775
31183
  }
30776
31184
  for (const tool of active.tools.values())
30777
31185
  this.#completeItem(active, tool.item, outcome);
@@ -30798,12 +31206,17 @@ ${question.detail}` : question.question;
30798
31206
  });
30799
31207
  }
30800
31208
  }
30801
- #project() {
31209
+ /** `media` also resolves local media paths, which only displayed history needs. */
31210
+ #project(media = false) {
30802
31211
  return projectModernHistory({
30803
31212
  harnessId: this.harnessId,
30804
31213
  sessionId: this.#sessionId,
30805
31214
  events: this.#events,
30806
31215
  profile: this.#profile,
31216
+ ...media ? {
31217
+ media: true,
31218
+ ...this.#sessionDirectory !== void 0 ? { cwd: this.#sessionDirectory } : {}
31219
+ } : {},
30807
31220
  ...this.#fallbackModel ? { fallbackModel: this.#fallbackModel } : {},
30808
31221
  ...this.#fallbackThinkingOptionId ? { fallbackThinkingOptionId: this.#fallbackThinkingOptionId } : {},
30809
31222
  toolOutputLimit: this.#toolOutputLimit,
@@ -31382,7 +31795,7 @@ function safeTimerDelay(value, name) {
31382
31795
 
31383
31796
  // dist/modern/session-list.js
31384
31797
  import { Buffer as Buffer5 } from "node:buffer";
31385
- import path7 from "node:path";
31798
+ import path9 from "node:path";
31386
31799
  var MAX_SESSION_LIST_BYTES = 32 * 1024 * 1024;
31387
31800
  var MAX_SESSION_LIST_DEPTH = 64;
31388
31801
  var MAX_SESSION_LIST_NODES = 2e5;
@@ -31502,7 +31915,7 @@ function parseSummary(value) {
31502
31915
  };
31503
31916
  }
31504
31917
  function isCanonicalAbsoluteCwd(value) {
31505
- return value !== void 0 && value.trim().length > 0 && !value.includes("\0") && path7.isAbsolute(value) && path7.resolve(value) === value;
31918
+ return value !== void 0 && value.trim().length > 0 && !value.includes("\0") && path9.isAbsolute(value) && path9.resolve(value) === value;
31506
31919
  }
31507
31920
  function parseModernSessionCandidates(value) {
31508
31921
  assertBoundedJson4(value);
@@ -31700,7 +32113,7 @@ var ModernDeepSeekHarnessAdapter = class {
31700
32113
  let session;
31701
32114
  let forkExpectation;
31702
32115
  try {
31703
- const cwd = path8.resolve(input.cwd);
32116
+ const cwd = path10.resolve(input.cwd);
31704
32117
  let forkInput = input.kind === "fork" ? parseModernForkInput(input, this.#profile) : void 0;
31705
32118
  const rollbackSourceSessionId = input.kind === "rollbackLastTurn" ? modernSessionId(input.sourceRef, "roll back") : void 0;
31706
32119
  let rollbackPlan;