@karlorz/codexhost-cli-win32-x64 0.16.1-2 → 0.17.0-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.
Files changed (40) hide show
  1. package/README.md +2 -2
  2. package/THIRD_PARTY_NOTICES.txt +6 -2
  3. package/app/codexhost-distribution.json +1 -1
  4. package/app/console-server.mjs +86 -20
  5. package/app/console-web.js +76 -17
  6. package/app/cpa-live-voice-hook.js +62 -8
  7. package/app/desktop-controller.mjs +107 -31
  8. package/app/host-runtime.mjs +2560 -1634
  9. package/app/plugins/antigravity/plugin.mjs +66 -2
  10. package/app/plugins/claude-code/plugin.mjs +43 -6
  11. package/app/plugins/codebuddy/plugin.mjs +41 -0
  12. package/app/plugins/codex-usage/plugin.mjs +31 -0
  13. package/app/plugins/copilot/plugin.mjs +31 -0
  14. package/app/plugins/cursor-cli/plugin.mjs +40 -5
  15. package/app/plugins/deepseek-harness/plugin.mjs +490 -46
  16. package/app/plugins/devin/assets/icon.svg +1 -0
  17. package/app/plugins/devin/manifest.json +30 -0
  18. package/app/plugins/devin/plugin.mjs +23536 -0
  19. package/app/plugins/enabled.json +2 -0
  20. package/app/plugins/grok/plugin.mjs +1615 -495
  21. package/app/plugins/hermes/plugin.mjs +484 -196
  22. package/app/plugins/kimi-code/plugin.mjs +31 -0
  23. package/app/plugins/kiro-cli/plugin.mjs +31 -0
  24. package/app/plugins/omp/plugin.mjs +31 -0
  25. package/app/plugins/opencode/plugin.mjs +31 -0
  26. package/app/plugins/pi/plugin.mjs +1491 -411
  27. package/app/plugins/qoder/plugin.mjs +9555 -8654
  28. package/app/plugins/qoder-cn/plugin.mjs +9555 -8654
  29. package/app/plugins/qwen-code/assets/icon.svg +1 -0
  30. package/app/plugins/qwen-code/manifest.json +29 -0
  31. package/app/plugins/qwen-code/plugin.mjs +29471 -0
  32. package/app/plugins/workbuddy/plugin.mjs +41 -0
  33. package/app/plugins/zcode/plugin.mjs +31 -0
  34. package/app/renderer-extension.js +966 -233
  35. package/bin/codexhost.exe +0 -0
  36. package/libexec/codexhost-node-repl.exe +0 -0
  37. package/libexec/codexhost-shim.exe +0 -0
  38. package/libexec/codexhost-updater.exe +0 -0
  39. package/licenses/Qwen-Code-SDK-LICENSE.txt +203 -0
  40. package/package.json +2 -2
@@ -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
  }
@@ -20389,6 +20389,37 @@ var voiceSettingsStateSchema = external_exports.strictObject({
20389
20389
  })
20390
20390
  });
20391
20391
 
20392
+ // ../../shared-contracts/dist/background-activity.js
20393
+ var backgroundActivitySchema = external_exports.strictObject({
20394
+ id: external_exports.string().min(1),
20395
+ kind: external_exports.enum(["task", "monitor", "loop", "subagent"]),
20396
+ label: external_exports.string(),
20397
+ status: external_exports.enum(["running", "scheduled", "completed", "failed", "cancelled", "unknown"]),
20398
+ canStop: external_exports.boolean(),
20399
+ /** Existing detached command Item presented by Desktop's native process UI. */
20400
+ commandItemId: hostItemIdSchema.optional(),
20401
+ schedule: external_exports.string().optional(),
20402
+ nextRunAt: external_exports.string().datetime({ offset: true }).optional(),
20403
+ relatedActivityId: external_exports.string().optional(),
20404
+ threadId: hostThreadIdSchema.optional()
20405
+ });
20406
+ var backgroundActivityDetailSchema = external_exports.strictObject({
20407
+ activity: backgroundActivitySchema,
20408
+ output: external_exports.string(),
20409
+ truncated: external_exports.boolean()
20410
+ });
20411
+ var threadActivityParamsSchema = external_exports.strictObject({ threadId: hostThreadIdSchema });
20412
+ var threadActivityItemParamsSchema = threadActivityParamsSchema.extend({
20413
+ activityId: external_exports.string().min(1)
20414
+ });
20415
+ var threadActivityListResultSchema = external_exports.strictObject({
20416
+ supported: external_exports.boolean(),
20417
+ activities: external_exports.array(backgroundActivitySchema)
20418
+ });
20419
+ var threadActivityStopResultSchema = external_exports.strictObject({
20420
+ outcome: external_exports.enum(["stopped", "alreadyStopped", "notFound"])
20421
+ });
20422
+
20392
20423
  // ../../shared-contracts/dist/index.js
20393
20424
  var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
20394
20425
 
@@ -21095,16 +21126,16 @@ var Diff = class {
21095
21126
  }
21096
21127
  }
21097
21128
  }
21098
- addToPath(path9, added, removed, oldPosInc, options) {
21099
- const last = path9.lastComponent;
21129
+ addToPath(path11, added, removed, oldPosInc, options) {
21130
+ const last = path11.lastComponent;
21100
21131
  if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
21101
21132
  return {
21102
- oldPos: path9.oldPos + oldPosInc,
21133
+ oldPos: path11.oldPos + oldPosInc,
21103
21134
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
21104
21135
  };
21105
21136
  } else {
21106
21137
  return {
21107
- oldPos: path9.oldPos + oldPosInc,
21138
+ oldPos: path11.oldPos + oldPosInc,
21108
21139
  lastComponent: { count: 1, added, removed, previousComponent: last }
21109
21140
  };
21110
21141
  }
@@ -22711,7 +22742,7 @@ var DeepSeekGenerationProbeError = class extends Error {
22711
22742
  this.stderrTail = options.stderrTail;
22712
22743
  }
22713
22744
  };
22714
- var DEFAULT_TIMEOUT_MS = 5e3;
22745
+ var DEFAULT_TIMEOUT_MS = 15e3;
22715
22746
  var DEFAULT_CLEANUP_TIMEOUT_MS = 1e3;
22716
22747
  var DEFAULT_OUTPUT_LIMIT_BYTES = 16 * 1024;
22717
22748
  var DIAGNOSTIC_RAW_TAIL_BYTES = 16 * 1024;
@@ -23021,7 +23052,7 @@ async function probeDeepSeekExecutableGeneration(options = {}, dependencies = {
23021
23052
 
23022
23053
  // dist/modern/deepseek-harness-adapter.js
23023
23054
  import { randomUUID as randomUUID2 } from "node:crypto";
23024
- import path8 from "node:path";
23055
+ import path10 from "node:path";
23025
23056
 
23026
23057
  // dist/modern/catalog.js
23027
23058
  import { Buffer as Buffer3 } from "node:buffer";
@@ -23142,7 +23173,7 @@ var ModernRemoteConnectionError = class extends Error {
23142
23173
  this.remoteFailure = sanitizeModernRemoteFailure(remoteFailure3);
23143
23174
  }
23144
23175
  };
23145
- var DEFAULT_STARTUP_TIMEOUT_MS = 2e4;
23176
+ var DEFAULT_STARTUP_TIMEOUT_MS = 9e4;
23146
23177
  var DEFAULT_UNARY_TIMEOUT_MS = 1e4;
23147
23178
  var DEFAULT_STREAM_OPEN_TIMEOUT_MS = 1e4;
23148
23179
  var DEFAULT_CLOSE_TIMEOUT_MS = 3e3;
@@ -27238,8 +27269,369 @@ function invalidInbox() {
27238
27269
  }
27239
27270
 
27240
27271
  // dist/modern/history.js
27272
+ import path8 from "node:path";
27241
27273
  import { isDeepStrictEqual as isDeepStrictEqual5 } from "node:util";
27242
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
+
27243
27635
  // dist/modern/compaction.js
27244
27636
  var MODERN_CONTEXT_PRESSURE_KEY = "contextPressure";
27245
27637
  function modernCompactionOutcome(data) {
@@ -27857,6 +28249,8 @@ function projectModernHistory(input) {
27857
28249
  let effectiveThinkingOptionId = input.fallbackThinkingOptionId;
27858
28250
  let contextWindowTokens;
27859
28251
  let usage = null;
28252
+ let workingDirectory = input.cwd;
28253
+ const media = input.media ?? input.cwd !== void 0;
27860
28254
  const rawUsageByStep = /* @__PURE__ */ new Map();
27861
28255
  const rebuildUsage = () => {
27862
28256
  usage = null;
@@ -27878,6 +28272,7 @@ function projectModernHistory(input) {
27878
28272
  if (!KNOWN_EVENT_TYPES.has(event.type) || !isRecord4(event.data))
27879
28273
  continue;
27880
28274
  const data = event.data;
28275
+ workingDirectory = modernWorkingDirectory(workingDirectory, event);
27881
28276
  switch (event.type) {
27882
28277
  case "turn/start":
27883
28278
  active = {
@@ -27922,8 +28317,9 @@ function projectModernHistory(input) {
27922
28317
  case "assistant/message":
27923
28318
  if (event.surfaceOp === "append") {
27924
28319
  recordSettlementUsage(data, event.seq);
27925
- if (active)
27926
- projectAssistantMessage(active, input.sessionId, data);
28320
+ if (active) {
28321
+ projectAssistantMessage(active, input.sessionId, data, media ? modernMediaRoots(workingDirectory, input.cwd) : void 0);
28322
+ }
27927
28323
  }
27928
28324
  break;
27929
28325
  case "compaction/start":
@@ -28044,7 +28440,21 @@ function modernCheckpointRef(harnessId, sessionId, seq, profile = DEEPSEEK_V4_PR
28044
28440
  function modernItemId(sessionId, key) {
28045
28441
  return hostItemIdSchema.parse(`dsh-modern:${sessionId}:${key}`);
28046
28442
  }
28047
- 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) {
28048
28458
  const message = data.message;
28049
28459
  if (Array.isArray(message.content)) {
28050
28460
  for (const block of message.content) {
@@ -28067,7 +28477,7 @@ function projectAssistantMessage(turn, sessionId, data) {
28067
28477
  const item = {
28068
28478
  type: "agentMessage",
28069
28479
  itemId: modernItemId(sessionId, `turn:${turn.turn}:step:${String(data.step)}:assistant`),
28070
- text
28480
+ text: mediaRoots ? rewriteLocalMediaMarkdown(text, mediaRoots) : text
28071
28481
  };
28072
28482
  turn.items.push({ item, outcome: { status: "succeeded" } });
28073
28483
  }
@@ -28886,6 +29296,8 @@ var ModernHarnessSession = class {
28886
29296
  #flushSession;
28887
29297
  #fallbackModel;
28888
29298
  #fallbackThinkingOptionId;
29299
+ #sessionDirectory;
29300
+ #workingDirectory;
28889
29301
  #channel = new HarnessOutputChannel();
28890
29302
  #validator;
28891
29303
  #events;
@@ -28952,8 +29364,12 @@ var ModernHarnessSession = class {
28952
29364
  this.#events = [...options.journal.events];
28953
29365
  this.#historyBytes = journalHistoryBytes(this.#events, this.#maxHistoryBytes);
28954
29366
  this.#validator = new ModernEventValidator(this.#maxEvents, this.#profile);
28955
- 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) {
28956
29370
  this.#validator.accept(event);
29371
+ this.#workingDirectory = modernWorkingDirectory(this.#workingDirectory, event);
29372
+ }
28957
29373
  const projection = projectModernHistory({
28958
29374
  harnessId: this.harnessId,
28959
29375
  sessionId: this.#sessionId,
@@ -28988,12 +29404,18 @@ var ModernHarnessSession = class {
28988
29404
  };
28989
29405
  let resumedAutonomousBuffer;
28990
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
+ }
28991
29412
  const buffer = {
28992
29413
  nativeTurn: projection.incompleteTurn.turn,
28993
29414
  events: [...projection.incompleteTurn.events],
28994
29415
  input: [],
28995
29416
  initialResume: true,
28996
29417
  replayed: 0,
29418
+ workingDirectory,
28997
29419
  sawUserMessage: false,
28998
29420
  reachedCorrelationBoundary: false
28999
29421
  };
@@ -29035,7 +29457,7 @@ var ModernHarnessSession = class {
29035
29457
  return Promise.resolve({ ok: false, error: busyError("read history") });
29036
29458
  this.#reading = true;
29037
29459
  try {
29038
- const projection = this.#project();
29460
+ const projection = this.#project(true);
29039
29461
  const configuration = this.#readConfiguration();
29040
29462
  return Promise.resolve({
29041
29463
  ok: true,
@@ -29969,6 +30391,7 @@ ${question.detail}` : question.question;
29969
30391
  this.#validator.accept(event);
29970
30392
  this.#observeAssistantSettlement(event);
29971
30393
  this.#events.push(event);
30394
+ this.#workingDirectory = modernWorkingDirectory(this.#workingDirectory, event);
29972
30395
  this.#meterUsage(event);
29973
30396
  this.#historyBytes += bytes;
29974
30397
  this.#receive(event);
@@ -30094,8 +30517,8 @@ ${question.detail}` : question.question;
30094
30517
  const agent = active.agent;
30095
30518
  if (!agent)
30096
30519
  return;
30097
- agent.text += CANCELLED_ASSISTANT_ATTEMPT_SUFFIX;
30098
- 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 };
30099
30522
  this.#emit({
30100
30523
  type: "item.updated",
30101
30524
  turnId: active.turnId,
@@ -30218,6 +30641,7 @@ ${question.detail}` : question.question;
30218
30641
  input: [],
30219
30642
  initialResume: false,
30220
30643
  replayed: 0,
30644
+ workingDirectory: this.#workingDirectory,
30221
30645
  sawUserMessage: false,
30222
30646
  reachedCorrelationBoundary: false
30223
30647
  };
@@ -30396,6 +30820,7 @@ ${question.detail}` : question.question;
30396
30820
  while (!this.#closed && buffer.replayed < buffer.events.length) {
30397
30821
  const event = buffer.events[buffer.replayed];
30398
30822
  buffer.replayed += 1;
30823
+ buffer.workingDirectory = modernWorkingDirectory(buffer.workingDirectory, event);
30399
30824
  this.#projectLiveEvent(buffer, event, initialReplay);
30400
30825
  }
30401
30826
  this.#projectAssistantLiveChunks();
@@ -30500,16 +30925,28 @@ ${question.detail}` : question.question;
30500
30925
  itemId: modernItemId(this.#sessionId, `turn:${active.nativeTurn}:step:${step}:${attemptId ? `attempt:${attemptId}:` : ""}assistant`),
30501
30926
  text: ""
30502
30927
  };
30503
- 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) };
30504
30932
  this.#emit({ type: "item.started", turnId: active.turnId, item });
30505
30933
  }
30506
30934
  active.agent.text += text;
30507
- 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 };
30508
30945
  this.#emit({
30509
30946
  type: "item.updated",
30510
30947
  turnId: active.turnId,
30511
- itemId: active.agent.item.itemId,
30512
- update: { type: "text.append", text }
30948
+ itemId: agent.item.itemId,
30949
+ update: { type: "text.append", text: delta }
30513
30950
  });
30514
30951
  }
30515
30952
  #startReasoning(active, step, provisional, attemptId) {
@@ -30597,6 +31034,7 @@ ${question.detail}` : question.question;
30597
31034
  }
30598
31035
  if (!current)
30599
31036
  return;
31037
+ this.#flushAgent(active, current);
30600
31038
  delete active.agent;
30601
31039
  this.#completeItem(active, current.item, { status: "succeeded" });
30602
31040
  }
@@ -30738,9 +31176,10 @@ ${question.detail}` : question.question;
30738
31176
  this.#completeItem(active, item, outcome);
30739
31177
  }
30740
31178
  if (active.agent) {
30741
- const item = active.agent.item;
31179
+ const agent = active.agent;
31180
+ this.#flushAgent(active, agent);
30742
31181
  delete active.agent;
30743
- this.#completeItem(active, item, outcome);
31182
+ this.#completeItem(active, agent.item, outcome);
30744
31183
  }
30745
31184
  for (const tool of active.tools.values())
30746
31185
  this.#completeItem(active, tool.item, outcome);
@@ -30767,12 +31206,17 @@ ${question.detail}` : question.question;
30767
31206
  });
30768
31207
  }
30769
31208
  }
30770
- #project() {
31209
+ /** `media` also resolves local media paths, which only displayed history needs. */
31210
+ #project(media = false) {
30771
31211
  return projectModernHistory({
30772
31212
  harnessId: this.harnessId,
30773
31213
  sessionId: this.#sessionId,
30774
31214
  events: this.#events,
30775
31215
  profile: this.#profile,
31216
+ ...media ? {
31217
+ media: true,
31218
+ ...this.#sessionDirectory !== void 0 ? { cwd: this.#sessionDirectory } : {}
31219
+ } : {},
30776
31220
  ...this.#fallbackModel ? { fallbackModel: this.#fallbackModel } : {},
30777
31221
  ...this.#fallbackThinkingOptionId ? { fallbackThinkingOptionId: this.#fallbackThinkingOptionId } : {},
30778
31222
  toolOutputLimit: this.#toolOutputLimit,
@@ -31351,7 +31795,7 @@ function safeTimerDelay(value, name) {
31351
31795
 
31352
31796
  // dist/modern/session-list.js
31353
31797
  import { Buffer as Buffer5 } from "node:buffer";
31354
- import path7 from "node:path";
31798
+ import path9 from "node:path";
31355
31799
  var MAX_SESSION_LIST_BYTES = 32 * 1024 * 1024;
31356
31800
  var MAX_SESSION_LIST_DEPTH = 64;
31357
31801
  var MAX_SESSION_LIST_NODES = 2e5;
@@ -31471,7 +31915,7 @@ function parseSummary(value) {
31471
31915
  };
31472
31916
  }
31473
31917
  function isCanonicalAbsoluteCwd(value) {
31474
- 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;
31475
31919
  }
31476
31920
  function parseModernSessionCandidates(value) {
31477
31921
  assertBoundedJson4(value);
@@ -31669,7 +32113,7 @@ var ModernDeepSeekHarnessAdapter = class {
31669
32113
  let session;
31670
32114
  let forkExpectation;
31671
32115
  try {
31672
- const cwd = path8.resolve(input.cwd);
32116
+ const cwd = path10.resolve(input.cwd);
31673
32117
  let forkInput = input.kind === "fork" ? parseModernForkInput(input, this.#profile) : void 0;
31674
32118
  const rollbackSourceSessionId = input.kind === "rollbackLastTurn" ? modernSessionId(input.sourceRef, "roll back") : void 0;
31675
32119
  let rollbackPlan;