@liberseek/boft-cli-win32-arm64 0.8.5 → 0.8.6

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 +70 -20
  5. package/app/console-web.js +61 -18
  6. package/app/desktop-controller.mjs +1142 -69
  7. package/app/host-runtime.mjs +3804 -1949
  8. package/app/plugins/antigravity/plugin.mjs +77 -9
  9. package/app/plugins/claude-code/plugin.mjs +27 -6
  10. package/app/plugins/codebuddy/plugin.mjs +25 -0
  11. package/app/plugins/codex-usage/plugin.mjs +15 -0
  12. package/app/plugins/copilot/plugin.mjs +15 -0
  13. package/app/plugins/cursor-cli/plugin.mjs +43 -8
  14. package/app/plugins/deepseek-harness/plugin.mjs +472 -44
  15. package/app/plugins/devin/assets/icon.svg +1 -0
  16. package/app/plugins/devin/manifest.json +30 -0
  17. package/app/plugins/devin/plugin.mjs +23425 -0
  18. package/app/plugins/enabled.json +2 -0
  19. package/app/plugins/grok/plugin.mjs +470 -387
  20. package/app/plugins/hermes/plugin.mjs +468 -196
  21. package/app/plugins/kimi-code/plugin.mjs +65 -3
  22. package/app/plugins/kiro-cli/plugin.mjs +15 -0
  23. package/app/plugins/muse/plugin.mjs +15 -0
  24. package/app/plugins/omp/plugin.mjs +15 -0
  25. package/app/plugins/opencode/plugin.mjs +15 -0
  26. package/app/plugins/pi/plugin.mjs +1595 -411
  27. package/app/plugins/qoder/plugin.mjs +9539 -8654
  28. package/app/plugins/qoder-cn/plugin.mjs +9539 -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 +29366 -0
  32. package/app/plugins/workbuddy/plugin.mjs +25 -0
  33. package/app/plugins/zcode/plugin.mjs +157 -9
  34. package/app/renderer-extension.js +727 -274
  35. package/bin/boft.exe +0 -0
  36. package/libexec/boft-node-repl.exe +0 -0
  37. package/libexec/boft-shim.exe +0 -0
  38. package/libexec/boft-updater.exe +0 -0
  39. package/licenses/Qwen-Code-SDK-LICENSE.txt +203 -0
  40. package/package.json +2 -2
@@ -603,7 +603,7 @@ async function readGrokCredentials(environment) {
603
603
  }
604
604
 
605
605
  // dist/grok-adapter.js
606
- import path15 from "node:path";
606
+ import path16 from "node:path";
607
607
 
608
608
  // ../../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
609
609
  var AGENT_METHODS = {
@@ -1423,10 +1423,10 @@ function mergeDefs(...defs) {
1423
1423
  function cloneDef(schema) {
1424
1424
  return mergeDefs(schema._zod.def);
1425
1425
  }
1426
- function getElementAtPath(obj, path16) {
1427
- if (!path16)
1426
+ function getElementAtPath(obj, path17) {
1427
+ if (!path17)
1428
1428
  return obj;
1429
- return path16.reduce((acc, key) => acc?.[key], obj);
1429
+ return path17.reduce((acc, key) => acc?.[key], obj);
1430
1430
  }
1431
1431
  function promiseAllObject(promisesObj) {
1432
1432
  const keys = Object.keys(promisesObj);
@@ -1835,11 +1835,11 @@ function explicitlyAborted(x, startIndex = 0) {
1835
1835
  }
1836
1836
  return false;
1837
1837
  }
1838
- function prefixIssues(path16, issues) {
1838
+ function prefixIssues(path17, issues) {
1839
1839
  return issues.map((iss) => {
1840
1840
  var _a3;
1841
1841
  (_a3 = iss).path ?? (_a3.path = []);
1842
- iss.path.unshift(path16);
1842
+ iss.path.unshift(path17);
1843
1843
  return iss;
1844
1844
  });
1845
1845
  }
@@ -1986,16 +1986,16 @@ function flattenError(error53, mapper = (issue2) => issue2.message) {
1986
1986
  }
1987
1987
  function formatError(error53, mapper = (issue2) => issue2.message) {
1988
1988
  const fieldErrors = { _errors: [] };
1989
- const processError = (error54, path16 = []) => {
1989
+ const processError = (error54, path17 = []) => {
1990
1990
  for (const issue2 of error54.issues) {
1991
1991
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1992
- issue2.errors.map((issues) => processError({ issues }, [...path16, ...issue2.path]));
1992
+ issue2.errors.map((issues) => processError({ issues }, [...path17, ...issue2.path]));
1993
1993
  } else if (issue2.code === "invalid_key") {
1994
- processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
1994
+ processError({ issues: issue2.issues }, [...path17, ...issue2.path]);
1995
1995
  } else if (issue2.code === "invalid_element") {
1996
- processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
1996
+ processError({ issues: issue2.issues }, [...path17, ...issue2.path]);
1997
1997
  } else {
1998
- const fullpath = [...path16, ...issue2.path];
1998
+ const fullpath = [...path17, ...issue2.path];
1999
1999
  if (fullpath.length === 0) {
2000
2000
  fieldErrors._errors.push(mapper(issue2));
2001
2001
  } else {
@@ -2022,17 +2022,17 @@ function formatError(error53, mapper = (issue2) => issue2.message) {
2022
2022
  }
2023
2023
  function treeifyError(error53, mapper = (issue2) => issue2.message) {
2024
2024
  const result = { errors: [] };
2025
- const processError = (error54, path16 = []) => {
2025
+ const processError = (error54, path17 = []) => {
2026
2026
  var _a3, _b;
2027
2027
  for (const issue2 of error54.issues) {
2028
2028
  if (issue2.code === "invalid_union" && issue2.errors.length) {
2029
- issue2.errors.map((issues) => processError({ issues }, [...path16, ...issue2.path]));
2029
+ issue2.errors.map((issues) => processError({ issues }, [...path17, ...issue2.path]));
2030
2030
  } else if (issue2.code === "invalid_key") {
2031
- processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
2031
+ processError({ issues: issue2.issues }, [...path17, ...issue2.path]);
2032
2032
  } else if (issue2.code === "invalid_element") {
2033
- processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
2033
+ processError({ issues: issue2.issues }, [...path17, ...issue2.path]);
2034
2034
  } else {
2035
- const fullpath = [...path16, ...issue2.path];
2035
+ const fullpath = [...path17, ...issue2.path];
2036
2036
  if (fullpath.length === 0) {
2037
2037
  result.errors.push(mapper(issue2));
2038
2038
  continue;
@@ -2064,8 +2064,8 @@ function treeifyError(error53, mapper = (issue2) => issue2.message) {
2064
2064
  }
2065
2065
  function toDotPath(_path) {
2066
2066
  const segs = [];
2067
- const path16 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
2068
- for (const seg of path16) {
2067
+ const path17 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
2068
+ for (const seg of path17) {
2069
2069
  if (typeof seg === "number")
2070
2070
  segs.push(`[${seg}]`);
2071
2071
  else if (typeof seg === "symbol")
@@ -14757,13 +14757,13 @@ function resolveRef(ref, ctx) {
14757
14757
  if (!ref.startsWith("#")) {
14758
14758
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14759
14759
  }
14760
- const path16 = ref.slice(1).split("/").filter(Boolean);
14761
- if (path16.length === 0) {
14760
+ const path17 = ref.slice(1).split("/").filter(Boolean);
14761
+ if (path17.length === 0) {
14762
14762
  return ctx.rootSchema;
14763
14763
  }
14764
14764
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14765
- if (path16[0] === defsKey) {
14766
- const key = path16[1];
14765
+ if (path17[0] === defsKey) {
14766
+ const key = path17[1];
14767
14767
  if (!key || !ctx.defs[key]) {
14768
14768
  throw new Error(`Reference not found: ${ref}`);
14769
14769
  }
@@ -20351,6 +20351,21 @@ var threadSteeringInspectParamsSchema = external_exports.object({
20351
20351
  /** The text about to be steered; a Harness command always stops and restarts. */
20352
20352
  text: external_exports.string().optional()
20353
20353
  }).strict();
20354
+ var threadSteeringContextSchema = external_exports.object({
20355
+ kind: external_exports.literal("application"),
20356
+ value: external_exports.string().transform((text, context) => {
20357
+ try {
20358
+ return JSON.parse(text);
20359
+ } catch {
20360
+ context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
20361
+ return external_exports.NEVER;
20362
+ }
20363
+ }).pipe(external_exports.object({
20364
+ expectedTurnId: hostTurnIdSchema,
20365
+ clientUserMessageId: external_exports.string().min(1),
20366
+ delivery: external_exports.enum(["newTurn", "activeTurn"])
20367
+ }).strict())
20368
+ }).strict().transform((context) => context.value);
20354
20369
  var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
20355
20370
  var threadSteeringInspectResultSchema = external_exports.object({
20356
20371
  delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
@@ -21191,11 +21206,371 @@ function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
21191
21206
  return harnessCommandCatalogSchema.parse({ commands: [...builtIns.commands, ...dynamic] });
21192
21207
  }
21193
21208
 
21209
+ // ../../harness-adapter/dist/local-media-markdown.js
21210
+ import { existsSync, statSync } from "node:fs";
21211
+ import path7 from "node:path";
21212
+ import { fileURLToPath } from "node:url";
21213
+ var MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
21214
+ ".aac",
21215
+ ".gif",
21216
+ ".jpeg",
21217
+ ".jpg",
21218
+ ".m4a",
21219
+ ".m4v",
21220
+ ".mov",
21221
+ ".mp3",
21222
+ ".mp4",
21223
+ ".ogg",
21224
+ ".png",
21225
+ ".svg",
21226
+ ".wav",
21227
+ ".webm",
21228
+ ".webp"
21229
+ ]);
21230
+ function rewriteLocalMediaMarkdown(text, roots, options = {}) {
21231
+ return projectLocalMedia(text, roots, options.exists ?? mediaFileExists, options.holdIncomplete === true, options.relativeImagesOnly === true).text;
21232
+ }
21233
+ var LocalMediaMarkdownStream = class {
21234
+ #roots;
21235
+ #exists;
21236
+ #relativeImagesOnly;
21237
+ #native = "";
21238
+ #text = "";
21239
+ /** Native text length represented by `#text`; the rest is held. */
21240
+ #consumed = 0;
21241
+ #verbatim = false;
21242
+ constructor(roots, exists = mediaFileExists, options = {}) {
21243
+ this.#roots = [...roots];
21244
+ this.#relativeImagesOnly = options.relativeImagesOnly === true;
21245
+ const known = /* @__PURE__ */ new Map();
21246
+ this.#exists = (absolutePath) => {
21247
+ let found = known.get(absolutePath);
21248
+ if (found === void 0) {
21249
+ found = exists(absolutePath);
21250
+ known.set(absolutePath, found);
21251
+ }
21252
+ return found;
21253
+ };
21254
+ }
21255
+ /** Projected text published so far: every returned delta, concatenated. */
21256
+ get text() {
21257
+ return this.#text;
21258
+ }
21259
+ /** Add native text and return the projected text it makes publishable, possibly empty. */
21260
+ append(text) {
21261
+ this.#native += text;
21262
+ return this.#advance(true);
21263
+ }
21264
+ /** Return the projected text still held at the end of the stream. */
21265
+ flush() {
21266
+ return this.#advance(false);
21267
+ }
21268
+ #advance(holdIncomplete) {
21269
+ const next = this.#verbatim ? void 0 : projectLocalMedia(this.#native, this.#roots, this.#exists, holdIncomplete, this.#relativeImagesOnly);
21270
+ let delta;
21271
+ if (next?.text.startsWith(this.#text)) {
21272
+ delta = next.text.slice(this.#text.length);
21273
+ this.#consumed = next.consumed;
21274
+ } else {
21275
+ this.#verbatim = true;
21276
+ delta = this.#native.slice(this.#consumed);
21277
+ this.#consumed = this.#native.length;
21278
+ }
21279
+ this.#text += delta;
21280
+ return delta;
21281
+ }
21282
+ };
21283
+ function projectLocalMedia(text, roots, exists, holdIncomplete, relativeImagesOnly) {
21284
+ let output = "";
21285
+ let index = 0;
21286
+ let fence = null;
21287
+ while (index < text.length) {
21288
+ if (fence) {
21289
+ const close = closingFenceEnd(text, index, fence.marker, fence.length);
21290
+ if (close === -1)
21291
+ break;
21292
+ output += text.slice(index, close);
21293
+ index = close;
21294
+ fence = null;
21295
+ continue;
21296
+ }
21297
+ const next = earliestIndex([
21298
+ text.indexOf("![", index),
21299
+ text.indexOf("`", index),
21300
+ indexOfLineStartTilde(text, index)
21301
+ ]);
21302
+ if (next === -1)
21303
+ break;
21304
+ output += text.slice(index, next);
21305
+ index = next;
21306
+ const marker = text[next];
21307
+ let markerLength = 1;
21308
+ if (marker === "`" || marker === "~") {
21309
+ let runEnd = next;
21310
+ while (text[runEnd] === marker)
21311
+ runEnd += 1;
21312
+ markerLength = runEnd - next;
21313
+ if (runEnd === text.length && holdIncomplete) {
21314
+ return { text: output, consumed: next };
21315
+ }
21316
+ if (runEnd - next >= 3) {
21317
+ const kind = fenceLineKind(text, next);
21318
+ if (kind === "opaque")
21319
+ break;
21320
+ if (kind === "flat") {
21321
+ fence = { marker, length: runEnd - next };
21322
+ output += text.slice(next, runEnd);
21323
+ index = runEnd;
21324
+ continue;
21325
+ }
21326
+ }
21327
+ if (marker === "~") {
21328
+ output += text.slice(next, runEnd);
21329
+ index = runEnd;
21330
+ continue;
21331
+ }
21332
+ }
21333
+ if (text.startsWith("![", next)) {
21334
+ const image = parseMarkdownImage(text, next);
21335
+ if (image.kind === "text") {
21336
+ output += text.slice(next, image.end);
21337
+ index = image.end;
21338
+ continue;
21339
+ }
21340
+ if (image.kind === "open") {
21341
+ if (!holdIncomplete)
21342
+ break;
21343
+ return { text: output + text.slice(next, image.holdFrom), consumed: image.holdFrom };
21344
+ }
21345
+ const resolved2 = relativeImagesOnly && /^(?:[\\/]|[a-z][a-z\d+.-]*:)/i.test(image.destination.trim()) ? null : resolveLocalMediaPath(image.destination, roots, exists);
21346
+ output += resolved2 === null ? text.slice(next, image.end) : text.slice(next, image.destinationStart) + markdownDestination(resolved2, image.bracketed) + text.slice(image.destinationEnd, image.end);
21347
+ index = image.end;
21348
+ continue;
21349
+ }
21350
+ const code = parseInlineCode(text, next, markerLength);
21351
+ if (code.kind !== "code" || holdIncomplete && code.end === text.length) {
21352
+ if (holdIncomplete && code.kind !== "text")
21353
+ return { text: output, consumed: next };
21354
+ output += text.slice(next, next + markerLength);
21355
+ index = next + markerLength;
21356
+ continue;
21357
+ }
21358
+ const resolved = relativeImagesOnly || markerLength !== 1 || /[\r\n]/u.test(code.content) ? null : resolveLocalMediaPath(code.content, roots, exists);
21359
+ output += resolved === null ? text.slice(next, code.end) : mediaMarkdownImage(resolved);
21360
+ index = code.end;
21361
+ }
21362
+ return { text: output + text.slice(index), consumed: text.length };
21363
+ }
21364
+ function fenceLineKind(text, index) {
21365
+ const prefix = text.slice(text.lastIndexOf("\n", index - 1) + 1, index);
21366
+ if (prefix === "")
21367
+ return "flat";
21368
+ let remaining = prefix.replace(/^[ \t]+/u, "");
21369
+ while (remaining) {
21370
+ const marker = /^(?:>|(?:[-+*]|\d{1,9}[.)])(?=[ \t]))[ \t]*/u.exec(remaining);
21371
+ if (!marker)
21372
+ return null;
21373
+ remaining = remaining.slice(marker[0].length);
21374
+ }
21375
+ return "opaque";
21376
+ }
21377
+ function indexOfLineStartTilde(text, start) {
21378
+ for (let tilde = text.indexOf("~", start); tilde !== -1; tilde = text.indexOf("~", tilde + 1)) {
21379
+ if (fenceLineKind(text, tilde) !== null)
21380
+ return tilde;
21381
+ }
21382
+ return -1;
21383
+ }
21384
+ function closingFenceEnd(text, start, marker, length) {
21385
+ const closing = new RegExp(`^ {0,3}${marker === "`" ? "`" : "~"}{${length},}[ \\t]*\\r?$`, "u");
21386
+ let lineStart = text.indexOf("\n", start);
21387
+ while (lineStart !== -1) {
21388
+ lineStart += 1;
21389
+ const newline2 = text.indexOf("\n", lineStart);
21390
+ const lineEnd = newline2 === -1 ? text.length : newline2;
21391
+ if (closing.test(text.slice(lineStart, lineEnd)))
21392
+ return lineEnd;
21393
+ lineStart = newline2;
21394
+ }
21395
+ return -1;
21396
+ }
21397
+ function earliestIndex(candidates) {
21398
+ let next = -1;
21399
+ for (const candidate of candidates) {
21400
+ if (candidate === -1)
21401
+ continue;
21402
+ if (next === -1 || candidate < next)
21403
+ next = candidate;
21404
+ }
21405
+ return next;
21406
+ }
21407
+ function parseInlineCode(text, start, length) {
21408
+ let index = start + length;
21409
+ while (index < text.length) {
21410
+ const tick = text.indexOf("`", index);
21411
+ if (/\n[^\S\n]*\n/u.test(text.slice(index, tick < 0 ? text.length : tick))) {
21412
+ return { kind: "text" };
21413
+ }
21414
+ if (tick === -1)
21415
+ break;
21416
+ let end = tick + 1;
21417
+ while (text[end] === "`")
21418
+ end += 1;
21419
+ if (end - tick === length) {
21420
+ return { kind: "code", content: text.slice(start + length, tick), end };
21421
+ }
21422
+ index = end;
21423
+ }
21424
+ return { kind: "open" };
21425
+ }
21426
+ function parseMarkdownImage(text, start) {
21427
+ const openLabel = { kind: "open", holdFrom: start + 2 };
21428
+ let index = start + 2;
21429
+ while (index < text.length) {
21430
+ const character = text[index];
21431
+ if (character === "\n")
21432
+ return { kind: "text", end: start + 1 };
21433
+ if (character === "\\") {
21434
+ index += 2;
21435
+ continue;
21436
+ }
21437
+ if (character === "]")
21438
+ break;
21439
+ index += 1;
21440
+ }
21441
+ if (index + 1 >= text.length)
21442
+ return openLabel;
21443
+ if (text[index + 1] !== "(")
21444
+ return { kind: "text", end: start + 1 };
21445
+ const destinationStart = index + 2;
21446
+ const open = { kind: "open", holdFrom: destinationStart };
21447
+ const malformed = { kind: "text", end: destinationStart };
21448
+ index = skipBlanks(text, destinationStart);
21449
+ if (index >= text.length)
21450
+ return open;
21451
+ let destination;
21452
+ let destinationEnd;
21453
+ let bracketed = false;
21454
+ if (text[index] === "<") {
21455
+ bracketed = true;
21456
+ let close = index + 1;
21457
+ while (close < text.length && text[close] !== ">" && text[close] !== "\n")
21458
+ close += 1;
21459
+ if (close >= text.length)
21460
+ return open;
21461
+ if (text[close] === "\n")
21462
+ return malformed;
21463
+ destination = text.slice(index + 1, close);
21464
+ destinationEnd = close + 1;
21465
+ index = destinationEnd;
21466
+ } else {
21467
+ const begin = index;
21468
+ while (index < text.length) {
21469
+ const character = text[index];
21470
+ if (character === "\n" || character === " " || character === " " || character === ")")
21471
+ break;
21472
+ index += character === "\\" ? 2 : 1;
21473
+ }
21474
+ if (index >= text.length)
21475
+ return open;
21476
+ destination = unescapeMarkdown(text.slice(begin, index));
21477
+ destinationEnd = index;
21478
+ }
21479
+ index = skipBlanks(text, index);
21480
+ if (index >= text.length)
21481
+ return open;
21482
+ const opener = text[index];
21483
+ if (opener === '"' || opener === "'" || opener === "(") {
21484
+ const closer = opener === "(" ? ")" : opener;
21485
+ index += 1;
21486
+ while (index < text.length && text[index] !== closer && text[index] !== "\n")
21487
+ index += 1;
21488
+ if (index >= text.length)
21489
+ return open;
21490
+ if (text[index] === "\n")
21491
+ return malformed;
21492
+ index = skipBlanks(text, index + 1);
21493
+ if (index >= text.length)
21494
+ return open;
21495
+ }
21496
+ if (text[index] !== ")")
21497
+ return malformed;
21498
+ return {
21499
+ kind: "image",
21500
+ destination,
21501
+ destinationStart,
21502
+ destinationEnd,
21503
+ end: index + 1,
21504
+ bracketed
21505
+ };
21506
+ }
21507
+ function skipBlanks(text, start) {
21508
+ let index = start;
21509
+ while (text[index] === " " || text[index] === " ")
21510
+ index += 1;
21511
+ return index;
21512
+ }
21513
+ function mediaMarkdownImage(absolutePath) {
21514
+ const name = path7.basename(absolutePath).replaceAll("]", "\\]");
21515
+ return `![${name}](${markdownDestination(absolutePath, false)})`;
21516
+ }
21517
+ function markdownDestination(absolutePath, bracketed) {
21518
+ const encoded = absolutePath.replaceAll("%", "%2525");
21519
+ const destination = /^[A-Za-z]:\\/.test(encoded) ? encoded.replaceAll("\\", "/") : encoded.replaceAll("\\", "\\\\");
21520
+ return bracketed || /[\s()]/.test(destination) ? `<${destination}>` : destination;
21521
+ }
21522
+ function unescapeMarkdown(value) {
21523
+ return value.replace(/\\([\\()])/g, "$1");
21524
+ }
21525
+ function resolveLocalMediaPath(raw, roots, exists = mediaFileExists) {
21526
+ const trimmed = raw.trim();
21527
+ if (trimmed.length === 0 || isRemoteMediaUrl(trimmed))
21528
+ return null;
21529
+ const stripped = stripFileUrl(trimmed);
21530
+ if (stripped === null)
21531
+ return null;
21532
+ if (isAbsoluteMediaPath(stripped)) {
21533
+ const absolute = path7.resolve(stripped);
21534
+ return hasMediaExtension(absolute) && exists(absolute) ? absolute : null;
21535
+ }
21536
+ for (const root of roots) {
21537
+ const absolute = path7.resolve(root, stripped);
21538
+ if (hasMediaExtension(absolute) && exists(absolute))
21539
+ return absolute;
21540
+ }
21541
+ return null;
21542
+ }
21543
+ function isRemoteMediaUrl(value) {
21544
+ return /^(?:https?:|data:|app:|blob:)/i.test(value);
21545
+ }
21546
+ function stripFileUrl(value) {
21547
+ if (!value.toLowerCase().startsWith("file:"))
21548
+ return value;
21549
+ try {
21550
+ return fileURLToPath(value);
21551
+ } catch {
21552
+ return null;
21553
+ }
21554
+ }
21555
+ function isAbsoluteMediaPath(value) {
21556
+ return path7.isAbsolute(value) || /^[a-zA-Z]:[\\/]/.test(value);
21557
+ }
21558
+ function hasMediaExtension(value) {
21559
+ return MEDIA_EXTENSIONS.has(path7.extname(value).toLowerCase());
21560
+ }
21561
+ function mediaFileExists(absolutePath) {
21562
+ try {
21563
+ return existsSync(absolutePath) && statSync(absolutePath).isFile();
21564
+ } catch {
21565
+ return false;
21566
+ }
21567
+ }
21568
+
21194
21569
  // dist/acp-transport.js
21195
21570
  import { spawn, spawnSync } from "node:child_process";
21196
21571
  import { readdir, readFile as readFile3 } from "node:fs/promises";
21197
21572
  import os5 from "node:os";
21198
- import path12 from "node:path";
21573
+ import path13 from "node:path";
21199
21574
  import { Readable, Writable } from "node:stream";
21200
21575
 
21201
21576
  // dist/grok-slash-commands.js
@@ -21222,8 +21597,8 @@ function parseGrokAvailableCommands(value) {
21222
21597
  });
21223
21598
  }
21224
21599
  function isGrokSkill(command) {
21225
- const path16 = command.meta?.path;
21226
- return typeof path16 === "string" && /(^|[\\/])SKILL\.md$/u.test(path16) || typeof command.meta?.qualifiedName === "string";
21600
+ const path17 = command.meta?.path;
21601
+ return typeof path17 === "string" && /(^|[\\/])SKILL\.md$/u.test(path17) || typeof command.meta?.qualifiedName === "string";
21227
21602
  }
21228
21603
  function grokLiveCommands(native) {
21229
21604
  return native.map((command) => ({
@@ -21234,7 +21609,7 @@ function grokLiveCommands(native) {
21234
21609
  }
21235
21610
 
21236
21611
  // dist/command.js
21237
- import path7 from "node:path";
21612
+ import path8 from "node:path";
21238
21613
  var GrokExecutableError = class extends Error {
21239
21614
  code = "GROK_NOT_FOUND";
21240
21615
  };
@@ -21263,7 +21638,7 @@ function resolveGrokExecutable(input = {}) {
21263
21638
  });
21264
21639
  if (!resolution)
21265
21640
  throw new GrokExecutableError("Grok CLI is not installed");
21266
- return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path7.resolve(resolution.executable);
21641
+ return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path8.resolve(resolution.executable);
21267
21642
  }
21268
21643
  function grokInvocation(command, platform = process.platform, modelId) {
21269
21644
  const arguments_ = ["agent", "--no-leader"];
@@ -21275,11 +21650,11 @@ function grokInvocation(command, platform = process.platform, modelId) {
21275
21650
 
21276
21651
  // dist/grok-fork.js
21277
21652
  import { isDeepStrictEqual } from "node:util";
21278
- import path10 from "node:path";
21653
+ import path11 from "node:path";
21279
21654
 
21280
21655
  // dist/grok-file-change.js
21281
21656
  import { Buffer as Buffer2 } from "node:buffer";
21282
- import path8 from "node:path";
21657
+ import path9 from "node:path";
21283
21658
 
21284
21659
  // ../../../node_modules/diff/libesm/diff/base.js
21285
21660
  var Diff = class {
@@ -21381,16 +21756,16 @@ var Diff = class {
21381
21756
  }
21382
21757
  }
21383
21758
  }
21384
- addToPath(path16, added, removed, oldPosInc, options) {
21385
- const last = path16.lastComponent;
21759
+ addToPath(path17, added, removed, oldPosInc, options) {
21760
+ const last = path17.lastComponent;
21386
21761
  if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
21387
21762
  return {
21388
- oldPos: path16.oldPos + oldPosInc,
21763
+ oldPos: path17.oldPos + oldPosInc,
21389
21764
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
21390
21765
  };
21391
21766
  } else {
21392
21767
  return {
21393
- oldPos: path16.oldPos + oldPosInc,
21768
+ oldPos: path17.oldPos + oldPosInc,
21394
21769
  lastComponent: { count: 1, added, removed, previousComponent: last }
21395
21770
  };
21396
21771
  }
@@ -21703,13 +22078,13 @@ function isRecord5(value) {
21703
22078
  return typeof value === "object" && value !== null && !Array.isArray(value);
21704
22079
  }
21705
22080
  function validAbsolutePath(value) {
21706
- return typeof value === "string" && path8.isAbsolute(value) && value.trim().length > 0 && !value.includes("\0") && !value.includes("\n") && !value.includes("\r");
22081
+ return typeof value === "string" && path9.isAbsolute(value) && value.trim().length > 0 && !value.includes("\0") && !value.includes("\n") && !value.includes("\r");
21707
22082
  }
21708
22083
  function displayPath(nativePath, cwd) {
21709
- const resolvedCwd = path8.resolve(cwd);
21710
- const resolvedPath = path8.resolve(nativePath);
21711
- const relative = path8.relative(resolvedCwd, resolvedPath);
21712
- const inside = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path8.sep}`);
22084
+ const resolvedCwd = path9.resolve(cwd);
22085
+ const resolvedPath = path9.resolve(nativePath);
22086
+ const relative = path9.relative(resolvedCwd, resolvedPath);
22087
+ const inside = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path9.sep}`);
21713
22088
  const selected = inside ? relative : resolvedPath;
21714
22089
  const normalized = selected.replaceAll("\\", "/");
21715
22090
  if (normalized.length === 0 || normalized === ".")
@@ -21770,299 +22145,19 @@ function projectGrokFileChanges(content, cwd, textLimit = DEFAULT_GROK_FILE_CHAN
21770
22145
  }
21771
22146
 
21772
22147
  // dist/local-media-markdown.js
21773
- import { existsSync, statSync } from "node:fs";
21774
22148
  import os4 from "node:os";
21775
- import path9 from "node:path";
21776
- var MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
21777
- ".aac",
21778
- ".gif",
21779
- ".jpeg",
21780
- ".jpg",
21781
- ".m4a",
21782
- ".m4v",
21783
- ".mov",
21784
- ".mp3",
21785
- ".mp4",
21786
- ".ogg",
21787
- ".png",
21788
- ".svg",
21789
- ".wav",
21790
- ".webm",
21791
- ".webp"
21792
- ]);
22149
+ import path10 from "node:path";
21793
22150
  function grokMediaResolveRoots(cwd, sessionDirectory) {
21794
- const roots = [path9.resolve(cwd)];
22151
+ const roots = [path10.resolve(cwd)];
21795
22152
  if (sessionDirectory) {
21796
- const session = path9.resolve(sessionDirectory);
21797
- roots.push(session, path9.join(session, "videos"), path9.join(session, "images"));
22153
+ const session = path10.resolve(sessionDirectory);
22154
+ roots.push(session, path10.join(session, "videos"), path10.join(session, "images"));
21798
22155
  }
21799
22156
  const home = process.env.HOME ?? process.env.USERPROFILE ?? os4.homedir();
21800
22157
  if (home)
21801
- roots.push(path9.join(home, "Downloads"));
22158
+ roots.push(path10.join(home, "Downloads"));
21802
22159
  return roots;
21803
22160
  }
21804
- function rewriteLocalMediaMarkdown(text, roots, options = {}) {
21805
- const exists = options.exists ?? mediaFileExists;
21806
- const holdIncomplete = options.holdIncomplete === true;
21807
- let output = "";
21808
- let index = 0;
21809
- let fence = false;
21810
- while (index < text.length) {
21811
- if (fence) {
21812
- const fenceEnd = text.indexOf("```", index);
21813
- if (fenceEnd === -1) {
21814
- output += text.slice(index);
21815
- break;
21816
- }
21817
- output += text.slice(index, fenceEnd + 3);
21818
- index = fenceEnd + 3;
21819
- fence = false;
21820
- continue;
21821
- }
21822
- const fenceStart = text.indexOf("```", index);
21823
- const imageStart = text.indexOf("![", index);
21824
- const tickStart = indexOfInlineTick(text, index);
21825
- const next = earliestIndex([fenceStart, imageStart, tickStart]);
21826
- if (next === -1) {
21827
- output += text.slice(index);
21828
- break;
21829
- }
21830
- output += text.slice(index, next);
21831
- if (next === fenceStart) {
21832
- output += "```";
21833
- index = fenceStart + 3;
21834
- fence = true;
21835
- continue;
21836
- }
21837
- if (next === imageStart) {
21838
- const parsed = parseMarkdownImage(text, imageStart);
21839
- if (!parsed) {
21840
- output += "!";
21841
- index = imageStart + 1;
21842
- continue;
21843
- }
21844
- if (!parsed.closed) {
21845
- output += holdIncomplete ? text.slice(imageStart, parsed.destinationStart) : text.slice(imageStart);
21846
- break;
21847
- }
21848
- const resolved2 = resolveLocalMediaPath(parsed.destination, roots, exists);
21849
- output += text.slice(imageStart, parsed.destinationStart) + formatMarkdownDestination(resolved2 ?? parsed.destination, parsed.bracketed) + text.slice(parsed.destinationEnd, parsed.end);
21850
- index = parsed.end;
21851
- continue;
21852
- }
21853
- const inline = parseInlineCode(text, tickStart);
21854
- if (!inline.closed) {
21855
- if (!holdIncomplete)
21856
- output += text.slice(tickStart);
21857
- break;
21858
- }
21859
- const resolved = resolveLocalMediaPath(inline.content, roots, exists);
21860
- output += resolved ? mediaMarkdownImage(resolved) : text.slice(tickStart, inline.end);
21861
- index = inline.end;
21862
- }
21863
- return output;
21864
- }
21865
- function indexOfInlineTick(text, start) {
21866
- let index = start;
21867
- while (index < text.length) {
21868
- const tick = text.indexOf("`", index);
21869
- if (tick === -1)
21870
- return -1;
21871
- if (text.startsWith("```", tick)) {
21872
- index = tick + 3;
21873
- continue;
21874
- }
21875
- return tick;
21876
- }
21877
- return -1;
21878
- }
21879
- function earliestIndex(candidates) {
21880
- let next = -1;
21881
- for (const candidate of candidates) {
21882
- if (candidate === -1)
21883
- continue;
21884
- if (next === -1 || candidate < next)
21885
- next = candidate;
21886
- }
21887
- return next;
21888
- }
21889
- function parseInlineCode(text, start) {
21890
- let index = start + 1;
21891
- while (index < text.length) {
21892
- const character = text[index];
21893
- if (character === "\n")
21894
- return { closed: false, content: text.slice(start + 1, index), end: index };
21895
- if (character === "`")
21896
- return { closed: true, content: text.slice(start + 1, index), end: index + 1 };
21897
- index += 1;
21898
- }
21899
- return { closed: false, content: text.slice(start + 1), end: text.length };
21900
- }
21901
- function mediaMarkdownImage(absolutePath) {
21902
- const name = path9.basename(absolutePath).replaceAll("]", "\\]");
21903
- return `![${name}](${formatMarkdownDestination(absolutePath, false)})`;
21904
- }
21905
- function parseMarkdownImage(text, start) {
21906
- if (text.slice(start, start + 2) !== "![")
21907
- return null;
21908
- let index = start + 2;
21909
- while (index < text.length) {
21910
- const character = text[index];
21911
- if (character === "\n")
21912
- return null;
21913
- if (character === "\\" && index + 1 < text.length) {
21914
- index += 2;
21915
- continue;
21916
- }
21917
- if (character === "]")
21918
- break;
21919
- index += 1;
21920
- }
21921
- if (text[index] !== "]" || text[index + 1] !== "(")
21922
- return null;
21923
- const destinationStart = index + 2;
21924
- index = destinationStart;
21925
- while (text[index] === " " || text[index] === " ")
21926
- index += 1;
21927
- if (index >= text.length) {
21928
- return {
21929
- closed: false,
21930
- destination: "",
21931
- destinationStart,
21932
- destinationEnd: index,
21933
- end: text.length,
21934
- bracketed: false
21935
- };
21936
- }
21937
- let destination;
21938
- let destinationEnd;
21939
- let bracketed = false;
21940
- if (text[index] === "<") {
21941
- bracketed = true;
21942
- const close = text.indexOf(">", index + 1);
21943
- if (close === -1 || text.slice(index, close).includes("\n")) {
21944
- return {
21945
- closed: false,
21946
- destination: text.slice(index + 1),
21947
- destinationStart,
21948
- destinationEnd: text.length,
21949
- end: text.length,
21950
- bracketed: true
21951
- };
21952
- }
21953
- destination = text.slice(index + 1, close);
21954
- destinationEnd = close + 1;
21955
- index = destinationEnd;
21956
- } else {
21957
- const begin = index;
21958
- while (index < text.length) {
21959
- const character = text[index];
21960
- if (character === "\n" || character === " " || character === " " || character === ")")
21961
- break;
21962
- if (character === "\\" && index + 1 < text.length) {
21963
- index += 2;
21964
- continue;
21965
- }
21966
- index += 1;
21967
- }
21968
- destination = unescapeMarkdown(text.slice(begin, index));
21969
- destinationEnd = index;
21970
- }
21971
- while (text[index] === " " || text[index] === " ")
21972
- index += 1;
21973
- if (text[index] === '"' || text[index] === "'" || text[index] === "(") {
21974
- const closer = text[index] === "(" ? ")" : text[index];
21975
- index += 1;
21976
- while (index < text.length && text[index] !== closer && text[index] !== "\n")
21977
- index += 1;
21978
- if (text[index] !== closer) {
21979
- return {
21980
- closed: false,
21981
- destination,
21982
- destinationStart,
21983
- destinationEnd,
21984
- end: text.length,
21985
- bracketed
21986
- };
21987
- }
21988
- index += 1;
21989
- while (text[index] === " " || text[index] === " ")
21990
- index += 1;
21991
- }
21992
- if (text[index] !== ")") {
21993
- return {
21994
- closed: false,
21995
- destination,
21996
- destinationStart,
21997
- destinationEnd,
21998
- end: text.length,
21999
- bracketed
22000
- };
22001
- }
22002
- return {
22003
- closed: true,
22004
- destination,
22005
- destinationStart,
22006
- destinationEnd,
22007
- end: index + 1,
22008
- bracketed
22009
- };
22010
- }
22011
- function formatMarkdownDestination(destination, bracketed) {
22012
- if (bracketed || /[\s()]/.test(destination))
22013
- return `<${destination}>`;
22014
- return destination.replaceAll(" ", "%20");
22015
- }
22016
- function unescapeMarkdown(value) {
22017
- return value.replace(/\\([\\()])/g, "$1");
22018
- }
22019
- function resolveLocalMediaPath(raw, roots, exists = mediaFileExists) {
22020
- const trimmed = raw.trim();
22021
- if (trimmed.length === 0 || isRemoteMediaUrl(trimmed))
22022
- return null;
22023
- const stripped = stripFileUrl(trimmed);
22024
- if (!hasMediaExtension(stripped))
22025
- return null;
22026
- if (isAbsoluteMediaPath(stripped)) {
22027
- const absolute = path9.resolve(stripped);
22028
- return exists(absolute) ? absolute : null;
22029
- }
22030
- for (const root of roots) {
22031
- const absolute = path9.resolve(root, stripped);
22032
- if (exists(absolute))
22033
- return absolute;
22034
- }
22035
- return null;
22036
- }
22037
- function isRemoteMediaUrl(value) {
22038
- return /^(?:https?:|data:|app:|blob:)/i.test(value);
22039
- }
22040
- function stripFileUrl(value) {
22041
- if (!value.toLowerCase().startsWith("file:"))
22042
- return value;
22043
- try {
22044
- const url2 = new URL(value);
22045
- if (url2.protocol !== "file:")
22046
- return value;
22047
- return decodeURIComponent(url2.pathname);
22048
- } catch {
22049
- return value.replace(/^file:\/\//i, "");
22050
- }
22051
- }
22052
- function isAbsoluteMediaPath(value) {
22053
- return path9.isAbsolute(value) || /^[a-zA-Z]:[\\/]/.test(value);
22054
- }
22055
- function hasMediaExtension(value) {
22056
- const pathname = value.split(/[?#]/, 1)[0] ?? value;
22057
- return MEDIA_EXTENSIONS.has(path9.extname(pathname).toLowerCase());
22058
- }
22059
- function mediaFileExists(absolutePath) {
22060
- try {
22061
- return existsSync(absolutePath) && statSync(absolutePath).isFile();
22062
- } catch {
22063
- return false;
22064
- }
22065
- }
22066
22161
 
22067
22162
  // dist/grok-tool-output.js
22068
22163
  var DEFAULT_GROK_TOOL_OUTPUT_LIMIT = 64e3;
@@ -23063,11 +23158,11 @@ function parseGrokForkResponse(value) {
23063
23158
  }
23064
23159
  function projectRelativePath(value, cwds) {
23065
23160
  const normalized = value.replaceAll("\\", "/");
23066
- if (!path10.isAbsolute(value))
23161
+ if (!path11.isAbsolute(value))
23067
23162
  return normalized;
23068
23163
  for (const cwd of cwds) {
23069
- const relative = path10.relative(path10.resolve(cwd), path10.resolve(value));
23070
- if (relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path10.sep}`)) {
23164
+ const relative = path11.relative(path11.resolve(cwd), path11.resolve(value));
23165
+ if (relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path11.sep}`)) {
23071
23166
  return relative.replaceAll("\\", "/");
23072
23167
  }
23073
23168
  }
@@ -23132,8 +23227,8 @@ async function forkGrokSession(input) {
23132
23227
  error: error51("sessionNotFound", "Grok Native Session is unavailable")
23133
23228
  };
23134
23229
  }
23135
- const sourceCwd = path10.resolve(located.cwd);
23136
- const targetCwd = path10.resolve(input.cwd);
23230
+ const sourceCwd = path11.resolve(located.cwd);
23231
+ const targetCwd = path11.resolve(input.cwd);
23137
23232
  const source = await readSnapshot({ ...input, cwd: sourceCwd }, sourceRef.data.nativeSessionId);
23138
23233
  if (!source.ok)
23139
23234
  return source;
@@ -23316,7 +23411,7 @@ function parseGrokCompactResult(value, cancelled = false) {
23316
23411
  }
23317
23412
 
23318
23413
  // dist/grok-rewind.js
23319
- import path11 from "node:path";
23414
+ import path12 from "node:path";
23320
23415
  var GROK_REWIND_EXECUTE_METHOD = "_x.ai/rewind/execute";
23321
23416
  function error52(code, message, retryable = false) {
23322
23417
  return { code, message, retryable };
@@ -23389,8 +23484,8 @@ async function rewindGrokLastTurn(input) {
23389
23484
  error: error52("sessionNotFound", "Grok Native Session is unavailable")
23390
23485
  };
23391
23486
  }
23392
- const sourceCwd = path11.resolve(located.cwd);
23393
- const targetCwd = path11.resolve(input.cwd);
23487
+ const sourceCwd = path12.resolve(located.cwd);
23488
+ const targetCwd = path12.resolve(input.cwd);
23394
23489
  if (sourceCwd !== targetCwd) {
23395
23490
  return {
23396
23491
  ok: false,
@@ -24006,8 +24101,14 @@ function signalProcessTree(child, signal) {
24006
24101
  try {
24007
24102
  process.kill(-child.pid, signal);
24008
24103
  } catch (error53) {
24009
- if (!isRecord15(error53) || error53.code !== "ESRCH")
24010
- throw error53;
24104
+ if (!isRecord15(error53) || error53.code === "ESRCH")
24105
+ return;
24106
+ try {
24107
+ child.kill(signal);
24108
+ } catch (fallback) {
24109
+ if (!isRecord15(fallback) || fallback.code !== "ESRCH")
24110
+ throw fallback;
24111
+ }
24011
24112
  }
24012
24113
  }
24013
24114
  function transportEvent(update, metadata) {
@@ -24101,13 +24202,13 @@ function transportEvent(update, metadata) {
24101
24202
  function grokHomeDir(options) {
24102
24203
  const environment = { ...process.env, ...options.environment };
24103
24204
  const home = environment.HOME ?? environment.USERPROFILE ?? os5.homedir();
24104
- return environment.GROK_HOME ?? path12.join(home, ".grok");
24205
+ return environment.GROK_HOME ?? path13.join(home, ".grok");
24105
24206
  }
24106
24207
  function grokNativeSessionDirectory(options, sessionId) {
24107
- return path12.join(grokHomeDir(options), "sessions", encodeURIComponent(path12.resolve(options.cwd)), sessionId);
24208
+ return path13.join(grokHomeDir(options), "sessions", encodeURIComponent(path13.resolve(options.cwd)), sessionId);
24108
24209
  }
24109
24210
  function nativeSessionFile(options, sessionId, fileName) {
24110
- return path12.join(grokNativeSessionDirectory(options, sessionId), fileName);
24211
+ return path13.join(grokNativeSessionDirectory(options, sessionId), fileName);
24111
24212
  }
24112
24213
  function nativeHistoryPath(options, sessionId) {
24113
24214
  return nativeSessionFile(options, sessionId, "updates.jsonl");
@@ -24127,7 +24228,7 @@ async function locateGrokNativeSession(options, sessionId) {
24127
24228
  return null;
24128
24229
  let entries;
24129
24230
  try {
24130
- entries = await readdir(path12.join(grokHomeDir(options), "sessions"), { withFileTypes: true });
24231
+ entries = await readdir(path13.join(grokHomeDir(options), "sessions"), { withFileTypes: true });
24131
24232
  } catch (error53) {
24132
24233
  if (isMissingFile(error53))
24133
24234
  return null;
@@ -24141,7 +24242,7 @@ async function locateGrokNativeSession(options, sessionId) {
24141
24242
  continue;
24142
24243
  let summaryRaw;
24143
24244
  try {
24144
- summaryRaw = await readFile3(path12.join(grokHomeDir(options), "sessions", entry.name, sessionId, "summary.json"), "utf8");
24245
+ summaryRaw = await readFile3(path13.join(grokHomeDir(options), "sessions", entry.name, sessionId, "summary.json"), "utf8");
24145
24246
  } catch (error53) {
24146
24247
  if (isMissingFile(error53) || isRecord15(error53) && error53.code === "ENOTDIR")
24147
24248
  continue;
@@ -24158,8 +24259,8 @@ async function locateGrokNativeSession(options, sessionId) {
24158
24259
  if (!isRecord15(parsed))
24159
24260
  continue;
24160
24261
  const info = parsed.info;
24161
- const cwd = isRecord15(info) && typeof info.cwd === "string" && info.cwd.length > 0 ? path12.resolve(info.cwd) : path12.resolve(decodeURIComponent(entry.name));
24162
- const sourceWorkspaceDir = typeof parsed.source_workspace_dir === "string" && parsed.source_workspace_dir.length > 0 ? path12.resolve(parsed.source_workspace_dir) : void 0;
24262
+ const cwd = isRecord15(info) && typeof info.cwd === "string" && info.cwd.length > 0 ? path13.resolve(info.cwd) : path13.resolve(decodeURIComponent(entry.name));
24263
+ const sourceWorkspaceDir = typeof parsed.source_workspace_dir === "string" && parsed.source_workspace_dir.length > 0 ? path13.resolve(parsed.source_workspace_dir) : void 0;
24163
24264
  matches.push({
24164
24265
  cwd,
24165
24266
  ...sourceWorkspaceDir ? { sourceWorkspaceDir } : {}
@@ -24169,7 +24270,7 @@ async function locateGrokNativeSession(options, sessionId) {
24169
24270
  }
24170
24271
  async function readGrokNativeHistory(options, sessionId) {
24171
24272
  try {
24172
- return parseNativeHistory(await readFile3(nativeHistoryPath({ ...options, cwd: path12.resolve(options.cwd) }, sessionId), "utf8"), sessionId);
24273
+ return parseNativeHistory(await readFile3(nativeHistoryPath({ ...options, cwd: path13.resolve(options.cwd) }, sessionId), "utf8"), sessionId);
24173
24274
  } catch (error53) {
24174
24275
  if (isMissingFile(error53))
24175
24276
  return [];
@@ -24690,7 +24791,7 @@ var GrokAcpTransport = class {
24690
24791
  // dist/session-import.js
24691
24792
  import { createReadStream as createReadStream2 } from "node:fs";
24692
24793
  import { opendir as opendir2, readFile as readFile4, stat } from "node:fs/promises";
24693
- import path13 from "node:path";
24794
+ import path14 from "node:path";
24694
24795
  import { createInterface as createInterface2 } from "node:readline";
24695
24796
 
24696
24797
  // ../../harness-adapter/dist/session-import.js
@@ -24911,7 +25012,7 @@ var GrokSessionImport = class {
24911
25012
  const active = /* @__PURE__ */ new Set();
24912
25013
  let entries;
24913
25014
  try {
24914
- entries = await readJson(path13.join(this.#home(), "active_sessions.json"), signal);
25015
+ entries = await readJson(path14.join(this.#home(), "active_sessions.json"), signal);
24915
25016
  } catch (error53) {
24916
25017
  signal.throwIfAborted();
24917
25018
  if (isStorageAccessError(error53))
@@ -24928,7 +25029,7 @@ var GrokSessionImport = class {
24928
25029
  }
24929
25030
  /** Session ID to every directory claiming it. Enumerated links are not followed. */
24930
25031
  async #sessionDirectories(signal) {
24931
- const root = path13.join(this.#home(), "sessions");
25032
+ const root = path14.join(this.#home(), "sessions");
24932
25033
  const found = /* @__PURE__ */ new Map();
24933
25034
  const info = await optionalLstat(root);
24934
25035
  if (!info)
@@ -24939,7 +25040,7 @@ var GrokSessionImport = class {
24939
25040
  signal.throwIfAborted();
24940
25041
  if (!workspace.isDirectory())
24941
25042
  continue;
24942
- const workspaceDirectory = path13.join(root, workspace.name);
25043
+ const workspaceDirectory = path14.join(root, workspace.name);
24943
25044
  const sessions = await opendir2(workspaceDirectory).catch((error53) => {
24944
25045
  if (isMissingFileError(error53))
24945
25046
  return null;
@@ -24952,7 +25053,7 @@ var GrokSessionImport = class {
24952
25053
  if (!session.isDirectory())
24953
25054
  continue;
24954
25055
  const directories = found.get(session.name) ?? [];
24955
- directories.push(path13.join(workspaceDirectory, session.name));
25056
+ directories.push(path14.join(workspaceDirectory, session.name));
24956
25057
  found.set(session.name, directories);
24957
25058
  }
24958
25059
  }
@@ -24960,10 +25061,10 @@ var GrokSessionImport = class {
24960
25061
  }
24961
25062
  async #candidate(sessionDirectory, active, signal) {
24962
25063
  signal.throwIfAborted();
24963
- const nativeSessionId = path13.basename(sessionDirectory);
25064
+ const nativeSessionId = path14.basename(sessionDirectory);
24964
25065
  const files = [
24965
- path13.join(sessionDirectory, "summary.json"),
24966
- path13.join(sessionDirectory, "updates.jsonl")
25066
+ path14.join(sessionDirectory, "summary.json"),
25067
+ path14.join(sessionDirectory, "updates.jsonl")
24967
25068
  ];
24968
25069
  return readStableFiles(files, async ([summaryInfo, updates]) => {
24969
25070
  if (!summaryInfo?.isFile() || !updates?.isFile() || summaryInfo.size > MAX_METADATA_BYTES)
@@ -24975,10 +25076,10 @@ var GrokSessionImport = class {
24975
25076
  if (typeof summary.session_kind === "string" && SUBAGENT_SESSION_KINDS.has(summary.session_kind))
24976
25077
  return null;
24977
25078
  const nativeCwd = summary.info.cwd;
24978
- if (typeof nativeCwd !== "string" || !path13.isAbsolute(nativeCwd) || nativeCwd.includes("\0"))
25079
+ if (typeof nativeCwd !== "string" || !path14.isAbsolute(nativeCwd) || nativeCwd.includes("\0"))
24979
25080
  return null;
24980
- const cwd = path13.resolve(nativeCwd);
24981
- if (encodeURIComponent(cwd) !== path13.basename(path13.dirname(sessionDirectory)))
25081
+ const cwd = path14.resolve(nativeCwd);
25082
+ if (encodeURIComponent(cwd) !== path14.basename(path14.dirname(sessionDirectory)))
24982
25083
  return null;
24983
25084
  if (!(await stat(cwd)).isDirectory())
24984
25085
  return null;
@@ -25321,7 +25422,7 @@ function stateForGrokModel(modelState, nativeState, model2 = modelState.currentM
25321
25422
  // dist/grok-credits.js
25322
25423
  import { readFile as readFile5 } from "node:fs/promises";
25323
25424
  import os6 from "node:os";
25324
- import path14 from "node:path";
25425
+ import path15 from "node:path";
25325
25426
  var GROK_CREDITS_ENDPOINT = "https://cli-chat-proxy.grok.com/v1/billing?format=credits";
25326
25427
  var GROK_SETTINGS_ENDPOINT = "https://cli-chat-proxy.grok.com/v1/settings";
25327
25428
  var REQUEST_TIMEOUT_MS = 15e3;
@@ -25349,7 +25450,7 @@ function nonNegativeCentValue(value) {
25349
25450
  return amount;
25350
25451
  }
25351
25452
  function grokHome2(environment) {
25352
- return environment.GROK_HOME ?? path14.join(environment.HOME ?? environment.USERPROFILE ?? os6.homedir(), ".grok");
25453
+ return environment.GROK_HOME ?? path15.join(environment.HOME ?? environment.USERPROFILE ?? os6.homedir(), ".grok");
25353
25454
  }
25354
25455
  function periodTypeFrom(value) {
25355
25456
  if (typeof value !== "string")
@@ -25441,7 +25542,7 @@ async function fetchGrokAccount(input = {}) {
25441
25542
  if ([environment.XAI_API_KEY, environment.GROK_API_KEY, environment.GROK_TOKEN].some((value) => value?.trim()))
25442
25543
  return null;
25443
25544
  const now = input.now ?? /* @__PURE__ */ new Date();
25444
- const authPath = path14.join(grokHome2(environment), "auth.json");
25545
+ const authPath = path15.join(grokHome2(environment), "auth.json");
25445
25546
  const raw = input.readAuthFile ? await input.readAuthFile(authPath) : await readFile5(authPath, "utf8");
25446
25547
  const token = selectAccessToken(JSON.parse(raw), now);
25447
25548
  if (!token)
@@ -25999,8 +26100,7 @@ var GrokHarnessSession = class {
25999
26100
  usage: new GrokTurnUsage(this.#usage, this.#snapshot.turns.length === 0),
26000
26101
  agent: null,
26001
26102
  agentMessageId: null,
26002
- rawAgentText: "",
26003
- projectedAgentText: "",
26103
+ agentMedia: null,
26004
26104
  reasoning: null,
26005
26105
  reasoningMessageId: null,
26006
26106
  compactionItem: null,
@@ -26090,8 +26190,7 @@ var GrokHarnessSession = class {
26090
26190
  questions: new GrokQuestions(command.turnId, this.#randomUUID, (output) => this.#channel.emit(output)),
26091
26191
  agent: null,
26092
26192
  agentMessageId: null,
26093
- rawAgentText: "",
26094
- projectedAgentText: "",
26193
+ agentMedia: null,
26095
26194
  reasoning: null,
26096
26195
  reasoningMessageId: null,
26097
26196
  compactionItem: null,
@@ -26545,19 +26644,16 @@ var GrokHarnessSession = class {
26545
26644
  itemId: hostItemIdSchema.parse(this.#randomUUID()),
26546
26645
  text: ""
26547
26646
  };
26548
- active.rawAgentText = "";
26549
- active.projectedAgentText = "";
26647
+ active.agentMedia = new LocalMediaMarkdownStream(this.#mediaRoots);
26550
26648
  this.#event({ type: "item.started", turnId: active.command.turnId, item: active.agent });
26551
26649
  }
26552
- active.rawAgentText += text;
26553
- const projected = rewriteLocalMediaMarkdown(active.rawAgentText, this.#mediaRoots, {
26554
- holdIncomplete: true
26555
- });
26556
- const delta = projected.startsWith(active.projectedAgentText) ? projected.slice(active.projectedAgentText.length) : text;
26557
- if (delta.length === 0)
26650
+ const delta = active.agentMedia?.append(text) ?? "";
26651
+ this.#publishAgent(active, delta);
26652
+ }
26653
+ #publishAgent(active, delta) {
26654
+ if (!active.agent || !active.agentMedia || !delta)
26558
26655
  return;
26559
- active.projectedAgentText += delta;
26560
- active.agent = { ...active.agent, text: active.projectedAgentText };
26656
+ active.agent = { ...active.agent, text: active.agentMedia.text };
26561
26657
  this.#event({
26562
26658
  type: "item.updated",
26563
26659
  turnId: active.command.turnId,
@@ -26778,25 +26874,12 @@ var GrokHarnessSession = class {
26778
26874
  }
26779
26875
  #completeAgent(active, outcome) {
26780
26876
  const item = active.agent;
26781
- if (item && active.rawAgentText.length > 0) {
26782
- const flushed = rewriteLocalMediaMarkdown(active.rawAgentText, this.#mediaRoots);
26783
- const delta = flushed.startsWith(item.text) ? flushed.slice(item.text.length) : "";
26784
- if (delta.length > 0) {
26785
- active.projectedAgentText = flushed;
26786
- active.agent = { ...item, text: flushed };
26787
- this.#event({
26788
- type: "item.updated",
26789
- turnId: active.command.turnId,
26790
- itemId: item.itemId,
26791
- update: { type: "text.append", text: delta }
26792
- });
26793
- }
26794
- }
26877
+ if (item && active.agentMedia)
26878
+ this.#publishAgent(active, active.agentMedia.flush());
26795
26879
  const completed = active.agent ?? item;
26796
26880
  active.agent = null;
26797
26881
  active.agentMessageId = null;
26798
- active.rawAgentText = "";
26799
- active.projectedAgentText = "";
26882
+ active.agentMedia = null;
26800
26883
  if (completed)
26801
26884
  this.#completeItem(active, completed, outcome);
26802
26885
  }
@@ -27039,7 +27122,7 @@ var GrokAdapter = class {
27039
27122
  async inspect(input = {}) {
27040
27123
  if (this.#closePromise)
27041
27124
  return { status: "unavailable", error: invalidState("Grok Adapter is closed") };
27042
- const cwd = path15.resolve(input.cwd ?? process.cwd());
27125
+ const cwd = path16.resolve(input.cwd ?? process.cwd());
27043
27126
  if (!input.refresh) {
27044
27127
  const cached2 = this.#inspectionCache.get(cwd);
27045
27128
  if (cached2)
@@ -27101,7 +27184,7 @@ var GrokAdapter = class {
27101
27184
  }
27102
27185
  };
27103
27186
  }
27104
- const cwd = path15.resolve(input.cwd);
27187
+ const cwd = path16.resolve(input.cwd);
27105
27188
  const parsedRef = input.kind === "resume" ? nativeSessionRefSchema.safeParse(input.nativeRef) : null;
27106
27189
  if (parsedRef && (!parsedRef.success || parsedRef.data.harnessId !== this.harnessId)) {
27107
27190
  return {