@liberseek/boft-cli-linux-x64 0.8.4 → 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 (39) 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 +129 -28
  5. package/app/console-web.js +336 -78
  6. package/app/desktop-controller.mjs +1741 -60
  7. package/app/host-runtime.mjs +4983 -2002
  8. package/app/plugins/antigravity/plugin.mjs +423 -63
  9. package/app/plugins/claude-code/plugin.mjs +417 -264
  10. package/app/plugins/codebuddy/plugin.mjs +256 -134
  11. package/app/plugins/codex-usage/plugin.mjs +97 -32
  12. package/app/plugins/copilot/plugin.mjs +122 -57
  13. package/app/plugins/cursor-cli/plugin.mjs +236 -139
  14. package/app/plugins/deepseek-harness/plugin.mjs +584 -86
  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 +839 -500
  20. package/app/plugins/hermes/plugin.mjs +522 -200
  21. package/app/plugins/kimi-code/plugin.mjs +134 -22
  22. package/app/plugins/kiro-cli/plugin.mjs +84 -19
  23. package/app/plugins/muse/plugin.mjs +74 -9
  24. package/app/plugins/omp/plugin.mjs +104 -39
  25. package/app/plugins/opencode/plugin.mjs +126 -61
  26. package/app/plugins/pi/plugin.mjs +1769 -468
  27. package/app/plugins/qoder/plugin.mjs +9617 -8682
  28. package/app/plugins/qoder-cn/plugin.mjs +9617 -8682
  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 +256 -134
  33. package/app/plugins/zcode/plugin.mjs +265 -42
  34. package/app/renderer-extension.js +3286 -528
  35. package/bin/boft +0 -0
  36. package/libexec/boft-shim +0 -0
  37. package/libexec/boft-updater +0 -0
  38. package/licenses/Qwen-Code-SDK-LICENSE.txt +203 -0
  39. 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")
@@ -7281,10 +7281,10 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
7281
7281
  const shape = def.shape;
7282
7282
  const propValues = {};
7283
7283
  for (const key in shape) {
7284
- const field = shape[key]._zod;
7285
- if (field.values) {
7284
+ const field2 = shape[key]._zod;
7285
+ if (field2.values) {
7286
7286
  propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
7287
- for (const v of field.values)
7287
+ for (const v of field2.values)
7288
7288
  propValues[key].add(v);
7289
7289
  }
7290
7290
  }
@@ -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
  }
@@ -18924,6 +18924,8 @@ var usageStatisticsTotalsSchema = external_exports.strictObject({
18924
18924
  cachedInputTokens: count,
18925
18925
  cacheWriteInputTokens: count,
18926
18926
  cacheKnownInputTokens: count,
18927
+ cacheHitCachedInputTokens: count,
18928
+ cacheHitInputTokens: count,
18927
18929
  outputTokens: count,
18928
18930
  reasoningOutputTokens: count,
18929
18931
  /** USD at the public price, summed over the priced requests only. */
@@ -19031,6 +19033,51 @@ var hostInteractionIdSchema = opaqueIdSchema.brand();
19031
19033
  var threadPrewarmDiscardParamsSchema = external_exports.object({ threadId: hostThreadIdSchema });
19032
19034
  var threadPrewarmDiscardResultSchema = external_exports.object({ discarded: external_exports.boolean() });
19033
19035
 
19036
+ // ../../shared-contracts/dist/thread-questions.js
19037
+ var field = external_exports.discriminatedUnion("type", [
19038
+ external_exports.object({
19039
+ id: external_exports.string().min(1),
19040
+ type: external_exports.literal("choice"),
19041
+ prompt: external_exports.string(),
19042
+ options: external_exports.array(external_exports.object({
19043
+ value: external_exports.string().min(1),
19044
+ label: external_exports.string(),
19045
+ description: external_exports.string().optional()
19046
+ })).min(1),
19047
+ multiple: external_exports.boolean(),
19048
+ allowOther: external_exports.boolean(),
19049
+ optional: external_exports.boolean()
19050
+ }),
19051
+ external_exports.object({
19052
+ id: external_exports.string().min(1),
19053
+ type: external_exports.literal("text"),
19054
+ prompt: external_exports.string(),
19055
+ multiline: external_exports.boolean(),
19056
+ secret: external_exports.literal(false),
19057
+ optional: external_exports.boolean(),
19058
+ placeholder: external_exports.string().optional(),
19059
+ prefill: external_exports.string().optional()
19060
+ })
19061
+ ]);
19062
+ var threadQuestionSchema = external_exports.object({
19063
+ interactionId: external_exports.string().min(1),
19064
+ turnId: external_exports.string().min(1),
19065
+ title: external_exports.string().optional(),
19066
+ questions: external_exports.array(field).min(1)
19067
+ }).refine(({ questions }) => questions.some((q) => q.type === "choice" && q.multiple), {
19068
+ message: "Shared cards require at least one multi-select question"
19069
+ });
19070
+ var threadQuestionsListParamsSchema = external_exports.strictObject({ threadId: external_exports.string().min(1) });
19071
+ var threadQuestionsResultSchema = external_exports.object({ questions: external_exports.array(threadQuestionSchema) });
19072
+ var threadQuestionRespondParamsSchema = external_exports.strictObject({
19073
+ threadId: external_exports.string().min(1),
19074
+ turnId: external_exports.string().min(1),
19075
+ interactionId: external_exports.string().min(1),
19076
+ answers: external_exports.record(external_exports.string(), external_exports.array(external_exports.string())),
19077
+ cancelled: external_exports.boolean().default(false)
19078
+ });
19079
+ var threadQuestionRespondResultSchema = external_exports.object({ accepted: external_exports.literal(true) });
19080
+
19034
19081
  // ../../shared-contracts/dist/harness-plugins.js
19035
19082
  var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
19036
19083
  var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
@@ -19790,6 +19837,21 @@ var threadSteeringInspectParamsSchema = external_exports.object({
19790
19837
  /** The text about to be steered; a Harness command always stops and restarts. */
19791
19838
  text: external_exports.string().optional()
19792
19839
  }).strict();
19840
+ var threadSteeringContextSchema = external_exports.object({
19841
+ kind: external_exports.literal("application"),
19842
+ value: external_exports.string().transform((text, context) => {
19843
+ try {
19844
+ return JSON.parse(text);
19845
+ } catch {
19846
+ context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
19847
+ return external_exports.NEVER;
19848
+ }
19849
+ }).pipe(external_exports.object({
19850
+ expectedTurnId: hostTurnIdSchema,
19851
+ clientUserMessageId: external_exports.string().min(1),
19852
+ delivery: external_exports.enum(["newTurn", "activeTurn"])
19853
+ }).strict())
19854
+ }).strict().transform((context) => context.value);
19793
19855
  var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
19794
19856
  var threadSteeringInspectResultSchema = external_exports.object({
19795
19857
  delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
@@ -19800,7 +19862,10 @@ var harnessPluginRouteSchema = external_exports.object({
19800
19862
  harnessId: harnessPluginIdSchema,
19801
19863
  model: harnessModelRefSchema.optional(),
19802
19864
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
19803
- permissionModeId: harnessPermissionModeIdSchema.optional()
19865
+ permissionModeId: harnessPermissionModeIdSchema.optional(),
19866
+ /** A draft prewarm create: stays unsubmitted until the user's first Turn.
19867
+ * Desktop forwards only the Model of a main-process prewarm to thread/start. */
19868
+ prewarm: external_exports.literal(true).optional()
19804
19869
  }).strict();
19805
19870
 
19806
19871
  // ../../shared-contracts/dist/harness-launch-settings.js
@@ -20437,26 +20502,26 @@ function parseHostUsage(value) {
20437
20502
  }
20438
20503
  }
20439
20504
  const indicators = value.composerIndicators === void 0 ? {} : { composerIndicators: composerIndicatorsSchema.parse(value.composerIndicators) };
20440
- for (const field of [
20505
+ for (const field2 of [
20441
20506
  "totalCredits",
20442
20507
  "contextUsagePercent",
20443
20508
  "apiOutputTokensPerSecond"
20444
20509
  ]) {
20445
- const candidate = value[field];
20510
+ const candidate = value[field2];
20446
20511
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
20447
- throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
20512
+ throw new Error(`Harness Usage '${field2}' must be a finite non-negative number`);
20448
20513
  }
20449
20514
  }
20450
- for (const field of tokenFields) {
20451
- const candidate = value[field];
20515
+ for (const field2 of tokenFields) {
20516
+ const candidate = value[field2];
20452
20517
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
20453
- throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
20518
+ throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
20454
20519
  }
20455
20520
  }
20456
- for (const field of safeIntegerFields) {
20457
- const candidate = value[field];
20521
+ for (const field2 of safeIntegerFields) {
20522
+ const candidate = value[field2];
20458
20523
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
20459
- throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
20524
+ throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
20460
20525
  }
20461
20526
  }
20462
20527
  if (value.outputTokensPerSecond !== void 0 && (typeof value.outputTokensPerSecond !== "number" || !Number.isFinite(value.outputTokensPerSecond) || value.outputTokensPerSecond < 0)) {
@@ -20465,16 +20530,16 @@ function parseHostUsage(value) {
20465
20530
  if (value.totalCostUsd !== void 0 && (typeof value.totalCostUsd !== "number" || !Number.isFinite(value.totalCostUsd) || value.totalCostUsd < 0)) {
20466
20531
  throw new Error("Harness Usage 'totalCostUsd' must be a finite non-negative number");
20467
20532
  }
20468
- for (const field of ["totalCredits", "contextUsagePercent"]) {
20469
- const candidate = value[field];
20533
+ for (const field2 of ["totalCredits", "contextUsagePercent"]) {
20534
+ const candidate = value[field2];
20470
20535
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
20471
- throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
20536
+ throw new Error(`Harness Usage '${field2}' must be a finite non-negative number`);
20472
20537
  }
20473
20538
  }
20474
- for (const field of percentFields) {
20475
- const candidate = value[field];
20539
+ for (const field2 of percentFields) {
20540
+ const candidate = value[field2];
20476
20541
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0 || candidate > 100)) {
20477
- throw new Error(`Harness Usage '${field}' must be between 0 and 100`);
20542
+ throw new Error(`Harness Usage '${field2}' must be between 0 and 100`);
20478
20543
  }
20479
20544
  }
20480
20545
  if (value.sessionCacheUsage !== void 0) {
@@ -20545,19 +20610,19 @@ function parseHostUsageRequest(value) {
20545
20610
  if (typeof value.requestId !== "string" || value.requestId.length === 0) {
20546
20611
  throw new Error("Harness Usage request 'requestId' must be a non-empty string");
20547
20612
  }
20548
- for (const field of ["model", "provider"]) {
20549
- const candidate = value[field];
20613
+ for (const field2 of ["model", "provider"]) {
20614
+ const candidate = value[field2];
20550
20615
  if (candidate !== void 0 && (typeof candidate !== "string" || candidate.length === 0)) {
20551
- throw new Error(`Harness Usage request '${field}' must be a non-empty string`);
20616
+ throw new Error(`Harness Usage request '${field2}' must be a non-empty string`);
20552
20617
  }
20553
20618
  }
20554
20619
  if (value.historical !== void 0 && typeof value.historical !== "boolean") {
20555
20620
  throw new Error("Harness Usage request 'historical' must be a boolean");
20556
20621
  }
20557
- for (const field of requestTokenFields) {
20558
- const candidate = value[field];
20622
+ for (const field2 of requestTokenFields) {
20623
+ const candidate = value[field2];
20559
20624
  if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
20560
- throw new Error(`Harness Usage request '${field}' must be a non-negative safe integer`);
20625
+ throw new Error(`Harness Usage request '${field2}' must be a non-negative safe integer`);
20561
20626
  }
20562
20627
  }
20563
20628
  if (value.inputTokens === void 0 || value.outputTokens === void 0) {
@@ -20956,16 +21021,16 @@ var Diff = class {
20956
21021
  }
20957
21022
  }
20958
21023
  }
20959
- addToPath(path9, added, removed, oldPosInc, options) {
20960
- const last = path9.lastComponent;
21024
+ addToPath(path11, added, removed, oldPosInc, options) {
21025
+ const last = path11.lastComponent;
20961
21026
  if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
20962
21027
  return {
20963
- oldPos: path9.oldPos + oldPosInc,
21028
+ oldPos: path11.oldPos + oldPosInc,
20964
21029
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
20965
21030
  };
20966
21031
  } else {
20967
21032
  return {
20968
- oldPos: path9.oldPos + oldPosInc,
21033
+ oldPos: path11.oldPos + oldPosInc,
20969
21034
  lastComponent: { count: 1, added, removed, previousComponent: last }
20970
21035
  };
20971
21036
  }
@@ -21372,9 +21437,9 @@ var DEEPSEEK_USAGE_COUNTERS = [
21372
21437
  "reasoningOutputTokens"
21373
21438
  ];
21374
21439
  function mergeDeepSeekUsage(current, next) {
21375
- const counters = Object.fromEntries(DEEPSEEK_USAGE_COUNTERS.flatMap((field) => {
21376
- const value = (current?.[field] ?? 0) + (next[field] ?? 0);
21377
- return current?.[field] !== void 0 || next[field] !== void 0 ? [[field, value]] : [];
21440
+ const counters = Object.fromEntries(DEEPSEEK_USAGE_COUNTERS.flatMap((field2) => {
21441
+ const value = (current?.[field2] ?? 0) + (next[field2] ?? 0);
21442
+ return current?.[field2] !== void 0 || next[field2] !== void 0 ? [[field2, value]] : [];
21378
21443
  }));
21379
21444
  const context = next.contextUsedTokens !== void 0 && next.contextWindowTokens !== void 0 ? {
21380
21445
  contextUsedTokens: next.contextUsedTokens,
@@ -21786,7 +21851,7 @@ function onlyKeys(value, required2, optional2 = []) {
21786
21851
  return required2.every((key) => Object.hasOwn(value, key)) && Reflect.ownKeys(value).every((key) => typeof key === "string" && allowed.has(key));
21787
21852
  }
21788
21853
  function requiredFields(value, fields) {
21789
- if (fields.some((field) => !Object.hasOwn(value, field)))
21854
+ if (fields.some((field2) => !Object.hasOwn(value, field2)))
21790
21855
  throw invalid("required fields");
21791
21856
  }
21792
21857
  function assertJsonValue2(value, label) {
@@ -22110,9 +22175,9 @@ function validateTeamPayload(type, data) {
22110
22175
  identifier(value.id, "team payload id");
22111
22176
  if (key === "member") {
22112
22177
  requiredOptionalKeys(value, ["id", "name", "description", "provider", "context", "phase"], ["error"]);
22113
- for (const field of ["name", "description", "provider"])
22114
- if (typeof value[field] !== "string")
22115
- throw invalid(`team member ${field}`);
22178
+ for (const field2 of ["name", "description", "provider"])
22179
+ if (typeof value[field2] !== "string")
22180
+ throw invalid(`team member ${field2}`);
22116
22181
  if (!["fresh", "fork"].includes(value.context) || !["provisioning", "active", "failed"].includes(value.phase) || value.error !== void 0 && typeof value.error !== "string")
22117
22182
  throw invalid("team member");
22118
22183
  } else if (key === "task") {
@@ -22126,8 +22191,8 @@ function validateTeamPayload(type, data) {
22126
22191
  stringArray(value.writeScopes, "team task writeScopes");
22127
22192
  } else {
22128
22193
  exactKeys(value, ["id", "senderId", "senderName", "targetId", "content"]);
22129
- for (const field of ["senderId", "senderName", "targetId"])
22130
- identifier(value[field], `team message ${field}`);
22194
+ for (const field2 of ["senderId", "senderName", "targetId"])
22195
+ identifier(value[field2], `team message ${field2}`);
22131
22196
  validateBlocks(value.content);
22132
22197
  }
22133
22198
  }
@@ -22572,7 +22637,7 @@ var DeepSeekGenerationProbeError = class extends Error {
22572
22637
  this.stderrTail = options.stderrTail;
22573
22638
  }
22574
22639
  };
22575
- var DEFAULT_TIMEOUT_MS = 5e3;
22640
+ var DEFAULT_TIMEOUT_MS = 15e3;
22576
22641
  var DEFAULT_CLEANUP_TIMEOUT_MS = 1e3;
22577
22642
  var DEFAULT_OUTPUT_LIMIT_BYTES = 16 * 1024;
22578
22643
  var DIAGNOSTIC_RAW_TAIL_BYTES = 16 * 1024;
@@ -22882,7 +22947,7 @@ async function probeDeepSeekExecutableGeneration(options = {}, dependencies = {
22882
22947
 
22883
22948
  // dist/modern/deepseek-harness-adapter.js
22884
22949
  import { randomUUID as randomUUID2 } from "node:crypto";
22885
- import path8 from "node:path";
22950
+ import path10 from "node:path";
22886
22951
 
22887
22952
  // dist/modern/catalog.js
22888
22953
  import { Buffer as Buffer3 } from "node:buffer";
@@ -23003,7 +23068,7 @@ var ModernRemoteConnectionError = class extends Error {
23003
23068
  this.remoteFailure = sanitizeModernRemoteFailure(remoteFailure3);
23004
23069
  }
23005
23070
  };
23006
- var DEFAULT_STARTUP_TIMEOUT_MS = 2e4;
23071
+ var DEFAULT_STARTUP_TIMEOUT_MS = 9e4;
23007
23072
  var DEFAULT_UNARY_TIMEOUT_MS = 1e4;
23008
23073
  var DEFAULT_STREAM_OPEN_TIMEOUT_MS = 1e4;
23009
23074
  var DEFAULT_CLOSE_TIMEOUT_MS = 3e3;
@@ -26309,15 +26374,24 @@ function attachedKnownInvocation(value, sinks) {
26309
26374
  return { event: value.event, eventId: value.eventId, agentId: value.agentId };
26310
26375
  }
26311
26376
  function parseApprovalRequest(value) {
26312
- if (!hasOnlyKeys(value, ["toolName"], ["callId", "reason"]) || !nonBlankString3(value.toolName) || Object.hasOwn(value, "callId") && !nonBlankString3(value.callId) || Object.hasOwn(value, "reason") && !boundedString3(value.reason)) {
26377
+ if (!hasOnlyKeys(value, ["toolName"], ["callId", "reason", "displayReason"]) || !nonBlankString3(value.toolName) || Object.hasOwn(value, "callId") && !nonBlankString3(value.callId) || Object.hasOwn(value, "reason") && !boundedString3(value.reason) || Object.hasOwn(value, "displayReason") && !isApprovalDisplayReason(value.displayReason)) {
26313
26378
  throw invalidFrame();
26314
26379
  }
26315
26380
  return {
26316
26381
  toolName: value.toolName,
26317
26382
  ...typeof value.callId === "string" ? { callId: value.callId } : {},
26318
- ...typeof value.reason === "string" ? { reason: value.reason } : {}
26383
+ ...typeof value.reason === "string" ? { reason: value.reason } : {},
26384
+ ...Object.hasOwn(value, "displayReason") ? { displayReason: value.displayReason } : {}
26319
26385
  };
26320
26386
  }
26387
+ function isApprovalDisplayReason(value) {
26388
+ if (!isPlainRecord6(value))
26389
+ return false;
26390
+ const entries = Object.entries(value);
26391
+ if (entries.length === 0)
26392
+ return false;
26393
+ return entries.every(([locale, text]) => locale.length > 0 && nonBlankString3(text) && boundedString3(text));
26394
+ }
26321
26395
  function parseQuestionRequest(value) {
26322
26396
  if (!hasOnlyKeys(value, ["questions"], ["wait"]) || !Array.isArray(value.questions)) {
26323
26397
  throw invalidFrame();
@@ -27096,8 +27170,369 @@ function invalidInbox() {
27096
27170
  }
27097
27171
 
27098
27172
  // dist/modern/history.js
27173
+ import path8 from "node:path";
27099
27174
  import { isDeepStrictEqual as isDeepStrictEqual5 } from "node:util";
27100
27175
 
27176
+ // ../../harness-adapter/dist/local-media-markdown.js
27177
+ import { existsSync, statSync as statSync2 } from "node:fs";
27178
+ import path7 from "node:path";
27179
+ import { fileURLToPath } from "node:url";
27180
+ var MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
27181
+ ".aac",
27182
+ ".gif",
27183
+ ".jpeg",
27184
+ ".jpg",
27185
+ ".m4a",
27186
+ ".m4v",
27187
+ ".mov",
27188
+ ".mp3",
27189
+ ".mp4",
27190
+ ".ogg",
27191
+ ".png",
27192
+ ".svg",
27193
+ ".wav",
27194
+ ".webm",
27195
+ ".webp"
27196
+ ]);
27197
+ function rewriteLocalMediaMarkdown(text, roots, options = {}) {
27198
+ return projectLocalMedia(text, roots, options.exists ?? mediaFileExists, options.holdIncomplete === true, options.relativeImagesOnly === true).text;
27199
+ }
27200
+ var LocalMediaMarkdownStream = class {
27201
+ #roots;
27202
+ #exists;
27203
+ #relativeImagesOnly;
27204
+ #native = "";
27205
+ #text = "";
27206
+ /** Native text length represented by `#text`; the rest is held. */
27207
+ #consumed = 0;
27208
+ #verbatim = false;
27209
+ constructor(roots, exists = mediaFileExists, options = {}) {
27210
+ this.#roots = [...roots];
27211
+ this.#relativeImagesOnly = options.relativeImagesOnly === true;
27212
+ const known = /* @__PURE__ */ new Map();
27213
+ this.#exists = (absolutePath) => {
27214
+ let found = known.get(absolutePath);
27215
+ if (found === void 0) {
27216
+ found = exists(absolutePath);
27217
+ known.set(absolutePath, found);
27218
+ }
27219
+ return found;
27220
+ };
27221
+ }
27222
+ /** Projected text published so far: every returned delta, concatenated. */
27223
+ get text() {
27224
+ return this.#text;
27225
+ }
27226
+ /** Add native text and return the projected text it makes publishable, possibly empty. */
27227
+ append(text) {
27228
+ this.#native += text;
27229
+ return this.#advance(true);
27230
+ }
27231
+ /** Return the projected text still held at the end of the stream. */
27232
+ flush() {
27233
+ return this.#advance(false);
27234
+ }
27235
+ #advance(holdIncomplete) {
27236
+ const next = this.#verbatim ? void 0 : projectLocalMedia(this.#native, this.#roots, this.#exists, holdIncomplete, this.#relativeImagesOnly);
27237
+ let delta;
27238
+ if (next?.text.startsWith(this.#text)) {
27239
+ delta = next.text.slice(this.#text.length);
27240
+ this.#consumed = next.consumed;
27241
+ } else {
27242
+ this.#verbatim = true;
27243
+ delta = this.#native.slice(this.#consumed);
27244
+ this.#consumed = this.#native.length;
27245
+ }
27246
+ this.#text += delta;
27247
+ return delta;
27248
+ }
27249
+ };
27250
+ function projectLocalMedia(text, roots, exists, holdIncomplete, relativeImagesOnly) {
27251
+ let output = "";
27252
+ let index = 0;
27253
+ let fence = null;
27254
+ while (index < text.length) {
27255
+ if (fence) {
27256
+ const close = closingFenceEnd(text, index, fence.marker, fence.length);
27257
+ if (close === -1)
27258
+ break;
27259
+ output += text.slice(index, close);
27260
+ index = close;
27261
+ fence = null;
27262
+ continue;
27263
+ }
27264
+ const next = earliestIndex([
27265
+ text.indexOf("![", index),
27266
+ text.indexOf("`", index),
27267
+ indexOfLineStartTilde(text, index)
27268
+ ]);
27269
+ if (next === -1)
27270
+ break;
27271
+ output += text.slice(index, next);
27272
+ index = next;
27273
+ const marker = text[next];
27274
+ let markerLength = 1;
27275
+ if (marker === "`" || marker === "~") {
27276
+ let runEnd = next;
27277
+ while (text[runEnd] === marker)
27278
+ runEnd += 1;
27279
+ markerLength = runEnd - next;
27280
+ if (runEnd === text.length && holdIncomplete) {
27281
+ return { text: output, consumed: next };
27282
+ }
27283
+ if (runEnd - next >= 3) {
27284
+ const kind = fenceLineKind(text, next);
27285
+ if (kind === "opaque")
27286
+ break;
27287
+ if (kind === "flat") {
27288
+ fence = { marker, length: runEnd - next };
27289
+ output += text.slice(next, runEnd);
27290
+ index = runEnd;
27291
+ continue;
27292
+ }
27293
+ }
27294
+ if (marker === "~") {
27295
+ output += text.slice(next, runEnd);
27296
+ index = runEnd;
27297
+ continue;
27298
+ }
27299
+ }
27300
+ if (text.startsWith("![", next)) {
27301
+ const image = parseMarkdownImage(text, next);
27302
+ if (image.kind === "text") {
27303
+ output += text.slice(next, image.end);
27304
+ index = image.end;
27305
+ continue;
27306
+ }
27307
+ if (image.kind === "open") {
27308
+ if (!holdIncomplete)
27309
+ break;
27310
+ return { text: output + text.slice(next, image.holdFrom), consumed: image.holdFrom };
27311
+ }
27312
+ const resolved2 = relativeImagesOnly && /^(?:[\\/]|[a-z][a-z\d+.-]*:)/i.test(image.destination.trim()) ? null : resolveLocalMediaPath(image.destination, roots, exists);
27313
+ output += resolved2 === null ? text.slice(next, image.end) : text.slice(next, image.destinationStart) + markdownDestination(resolved2, image.bracketed) + text.slice(image.destinationEnd, image.end);
27314
+ index = image.end;
27315
+ continue;
27316
+ }
27317
+ const code = parseInlineCode(text, next, markerLength);
27318
+ if (code.kind !== "code" || holdIncomplete && code.end === text.length) {
27319
+ if (holdIncomplete && code.kind !== "text")
27320
+ return { text: output, consumed: next };
27321
+ output += text.slice(next, next + markerLength);
27322
+ index = next + markerLength;
27323
+ continue;
27324
+ }
27325
+ const resolved = relativeImagesOnly || markerLength !== 1 || /[\r\n]/u.test(code.content) ? null : resolveLocalMediaPath(code.content, roots, exists);
27326
+ output += resolved === null ? text.slice(next, code.end) : mediaMarkdownImage(resolved);
27327
+ index = code.end;
27328
+ }
27329
+ return { text: output + text.slice(index), consumed: text.length };
27330
+ }
27331
+ function fenceLineKind(text, index) {
27332
+ const prefix = text.slice(text.lastIndexOf("\n", index - 1) + 1, index);
27333
+ if (prefix === "")
27334
+ return "flat";
27335
+ let remaining = prefix.replace(/^[ \t]+/u, "");
27336
+ while (remaining) {
27337
+ const marker = /^(?:>|(?:[-+*]|\d{1,9}[.)])(?=[ \t]))[ \t]*/u.exec(remaining);
27338
+ if (!marker)
27339
+ return null;
27340
+ remaining = remaining.slice(marker[0].length);
27341
+ }
27342
+ return "opaque";
27343
+ }
27344
+ function indexOfLineStartTilde(text, start) {
27345
+ for (let tilde = text.indexOf("~", start); tilde !== -1; tilde = text.indexOf("~", tilde + 1)) {
27346
+ if (fenceLineKind(text, tilde) !== null)
27347
+ return tilde;
27348
+ }
27349
+ return -1;
27350
+ }
27351
+ function closingFenceEnd(text, start, marker, length) {
27352
+ const closing = new RegExp(`^ {0,3}${marker === "`" ? "`" : "~"}{${length},}[ \\t]*\\r?$`, "u");
27353
+ let lineStart = text.indexOf("\n", start);
27354
+ while (lineStart !== -1) {
27355
+ lineStart += 1;
27356
+ const newline = text.indexOf("\n", lineStart);
27357
+ const lineEnd = newline === -1 ? text.length : newline;
27358
+ if (closing.test(text.slice(lineStart, lineEnd)))
27359
+ return lineEnd;
27360
+ lineStart = newline;
27361
+ }
27362
+ return -1;
27363
+ }
27364
+ function earliestIndex(candidates) {
27365
+ let next = -1;
27366
+ for (const candidate of candidates) {
27367
+ if (candidate === -1)
27368
+ continue;
27369
+ if (next === -1 || candidate < next)
27370
+ next = candidate;
27371
+ }
27372
+ return next;
27373
+ }
27374
+ function parseInlineCode(text, start, length) {
27375
+ let index = start + length;
27376
+ while (index < text.length) {
27377
+ const tick = text.indexOf("`", index);
27378
+ if (/\n[^\S\n]*\n/u.test(text.slice(index, tick < 0 ? text.length : tick))) {
27379
+ return { kind: "text" };
27380
+ }
27381
+ if (tick === -1)
27382
+ break;
27383
+ let end = tick + 1;
27384
+ while (text[end] === "`")
27385
+ end += 1;
27386
+ if (end - tick === length) {
27387
+ return { kind: "code", content: text.slice(start + length, tick), end };
27388
+ }
27389
+ index = end;
27390
+ }
27391
+ return { kind: "open" };
27392
+ }
27393
+ function parseMarkdownImage(text, start) {
27394
+ const openLabel = { kind: "open", holdFrom: start + 2 };
27395
+ let index = start + 2;
27396
+ while (index < text.length) {
27397
+ const character = text[index];
27398
+ if (character === "\n")
27399
+ return { kind: "text", end: start + 1 };
27400
+ if (character === "\\") {
27401
+ index += 2;
27402
+ continue;
27403
+ }
27404
+ if (character === "]")
27405
+ break;
27406
+ index += 1;
27407
+ }
27408
+ if (index + 1 >= text.length)
27409
+ return openLabel;
27410
+ if (text[index + 1] !== "(")
27411
+ return { kind: "text", end: start + 1 };
27412
+ const destinationStart = index + 2;
27413
+ const open = { kind: "open", holdFrom: destinationStart };
27414
+ const malformed = { kind: "text", end: destinationStart };
27415
+ index = skipBlanks(text, destinationStart);
27416
+ if (index >= text.length)
27417
+ return open;
27418
+ let destination;
27419
+ let destinationEnd;
27420
+ let bracketed = false;
27421
+ if (text[index] === "<") {
27422
+ bracketed = true;
27423
+ let close = index + 1;
27424
+ while (close < text.length && text[close] !== ">" && text[close] !== "\n")
27425
+ close += 1;
27426
+ if (close >= text.length)
27427
+ return open;
27428
+ if (text[close] === "\n")
27429
+ return malformed;
27430
+ destination = text.slice(index + 1, close);
27431
+ destinationEnd = close + 1;
27432
+ index = destinationEnd;
27433
+ } else {
27434
+ const begin = index;
27435
+ while (index < text.length) {
27436
+ const character = text[index];
27437
+ if (character === "\n" || character === " " || character === " " || character === ")")
27438
+ break;
27439
+ index += character === "\\" ? 2 : 1;
27440
+ }
27441
+ if (index >= text.length)
27442
+ return open;
27443
+ destination = unescapeMarkdown(text.slice(begin, index));
27444
+ destinationEnd = index;
27445
+ }
27446
+ index = skipBlanks(text, index);
27447
+ if (index >= text.length)
27448
+ return open;
27449
+ const opener = text[index];
27450
+ if (opener === '"' || opener === "'" || opener === "(") {
27451
+ const closer = opener === "(" ? ")" : opener;
27452
+ index += 1;
27453
+ while (index < text.length && text[index] !== closer && text[index] !== "\n")
27454
+ index += 1;
27455
+ if (index >= text.length)
27456
+ return open;
27457
+ if (text[index] === "\n")
27458
+ return malformed;
27459
+ index = skipBlanks(text, index + 1);
27460
+ if (index >= text.length)
27461
+ return open;
27462
+ }
27463
+ if (text[index] !== ")")
27464
+ return malformed;
27465
+ return {
27466
+ kind: "image",
27467
+ destination,
27468
+ destinationStart,
27469
+ destinationEnd,
27470
+ end: index + 1,
27471
+ bracketed
27472
+ };
27473
+ }
27474
+ function skipBlanks(text, start) {
27475
+ let index = start;
27476
+ while (text[index] === " " || text[index] === " ")
27477
+ index += 1;
27478
+ return index;
27479
+ }
27480
+ function mediaMarkdownImage(absolutePath) {
27481
+ const name = path7.basename(absolutePath).replaceAll("]", "\\]");
27482
+ return `![${name}](${markdownDestination(absolutePath, false)})`;
27483
+ }
27484
+ function markdownDestination(absolutePath, bracketed) {
27485
+ const encoded = absolutePath.replaceAll("%", "%2525");
27486
+ const destination = /^[A-Za-z]:\\/.test(encoded) ? encoded.replaceAll("\\", "/") : encoded.replaceAll("\\", "\\\\");
27487
+ return bracketed || /[\s()]/.test(destination) ? `<${destination}>` : destination;
27488
+ }
27489
+ function unescapeMarkdown(value) {
27490
+ return value.replace(/\\([\\()])/g, "$1");
27491
+ }
27492
+ function resolveLocalMediaPath(raw, roots, exists = mediaFileExists) {
27493
+ const trimmed = raw.trim();
27494
+ if (trimmed.length === 0 || isRemoteMediaUrl(trimmed))
27495
+ return null;
27496
+ const stripped = stripFileUrl(trimmed);
27497
+ if (stripped === null)
27498
+ return null;
27499
+ if (isAbsoluteMediaPath(stripped)) {
27500
+ const absolute = path7.resolve(stripped);
27501
+ return hasMediaExtension(absolute) && exists(absolute) ? absolute : null;
27502
+ }
27503
+ for (const root of roots) {
27504
+ const absolute = path7.resolve(root, stripped);
27505
+ if (hasMediaExtension(absolute) && exists(absolute))
27506
+ return absolute;
27507
+ }
27508
+ return null;
27509
+ }
27510
+ function isRemoteMediaUrl(value) {
27511
+ return /^(?:https?:|data:|app:|blob:)/i.test(value);
27512
+ }
27513
+ function stripFileUrl(value) {
27514
+ if (!value.toLowerCase().startsWith("file:"))
27515
+ return value;
27516
+ try {
27517
+ return fileURLToPath(value);
27518
+ } catch {
27519
+ return null;
27520
+ }
27521
+ }
27522
+ function isAbsoluteMediaPath(value) {
27523
+ return path7.isAbsolute(value) || /^[a-zA-Z]:[\\/]/.test(value);
27524
+ }
27525
+ function hasMediaExtension(value) {
27526
+ return MEDIA_EXTENSIONS.has(path7.extname(value).toLowerCase());
27527
+ }
27528
+ function mediaFileExists(absolutePath) {
27529
+ try {
27530
+ return existsSync(absolutePath) && statSync2(absolutePath).isFile();
27531
+ } catch {
27532
+ return false;
27533
+ }
27534
+ }
27535
+
27101
27536
  // dist/modern/compaction.js
27102
27537
  var MODERN_CONTEXT_PRESSURE_KEY = "contextPressure";
27103
27538
  function modernCompactionOutcome(data) {
@@ -27715,6 +28150,8 @@ function projectModernHistory(input) {
27715
28150
  let effectiveThinkingOptionId = input.fallbackThinkingOptionId;
27716
28151
  let contextWindowTokens;
27717
28152
  let usage = null;
28153
+ let workingDirectory = input.cwd;
28154
+ const media = input.media ?? input.cwd !== void 0;
27718
28155
  const rawUsageByStep = /* @__PURE__ */ new Map();
27719
28156
  const rebuildUsage = () => {
27720
28157
  usage = null;
@@ -27736,6 +28173,7 @@ function projectModernHistory(input) {
27736
28173
  if (!KNOWN_EVENT_TYPES.has(event.type) || !isRecord4(event.data))
27737
28174
  continue;
27738
28175
  const data = event.data;
28176
+ workingDirectory = modernWorkingDirectory(workingDirectory, event);
27739
28177
  switch (event.type) {
27740
28178
  case "turn/start":
27741
28179
  active = {
@@ -27780,8 +28218,9 @@ function projectModernHistory(input) {
27780
28218
  case "assistant/message":
27781
28219
  if (event.surfaceOp === "append") {
27782
28220
  recordSettlementUsage(data, event.seq);
27783
- if (active)
27784
- projectAssistantMessage(active, input.sessionId, data);
28221
+ if (active) {
28222
+ projectAssistantMessage(active, input.sessionId, data, media ? modernMediaRoots(workingDirectory, input.cwd) : void 0);
28223
+ }
27785
28224
  }
27786
28225
  break;
27787
28226
  case "compaction/start":
@@ -27902,7 +28341,21 @@ function modernCheckpointRef(harnessId, sessionId, seq, profile = DEEPSEEK_V4_PR
27902
28341
  function modernItemId(sessionId, key) {
27903
28342
  return hostItemIdSchema.parse(`dsh-modern:${sessionId}:${key}`);
27904
28343
  }
27905
- function projectAssistantMessage(turn, sessionId, data) {
28344
+ function modernWorkingDirectory(current, event) {
28345
+ if (event.type !== "working-directory/change" || !isRecord4(event.data) || typeof event.data.cwd !== "string") {
28346
+ return current;
28347
+ }
28348
+ const next = event.data.cwd;
28349
+ if (path8.isAbsolute(next))
28350
+ return path8.resolve(next);
28351
+ return current === void 0 ? void 0 : path8.resolve(current, next);
28352
+ }
28353
+ function modernMediaRoots(workingDirectory, sessionDirectory) {
28354
+ return [
28355
+ ...new Set([workingDirectory ?? sessionDirectory, sessionDirectory].filter((root) => root !== void 0))
28356
+ ];
28357
+ }
28358
+ function projectAssistantMessage(turn, sessionId, data, mediaRoots) {
27906
28359
  const message = data.message;
27907
28360
  if (Array.isArray(message.content)) {
27908
28361
  for (const block of message.content) {
@@ -27925,7 +28378,7 @@ function projectAssistantMessage(turn, sessionId, data) {
27925
28378
  const item = {
27926
28379
  type: "agentMessage",
27927
28380
  itemId: modernItemId(sessionId, `turn:${turn.turn}:step:${String(data.step)}:assistant`),
27928
- text
28381
+ text: mediaRoots ? rewriteLocalMediaMarkdown(text, mediaRoots) : text
27929
28382
  };
27930
28383
  turn.items.push({ item, outcome: { status: "succeeded" } });
27931
28384
  }
@@ -28135,7 +28588,7 @@ function validateToolResultMessage(value, profile) {
28135
28588
  return callId;
28136
28589
  }
28137
28590
  function requiredFields2(value, fields) {
28138
- if (fields.some((field) => !Object.hasOwn(value, field))) {
28591
+ if (fields.some((field2) => !Object.hasOwn(value, field2))) {
28139
28592
  fail("Modern history known event omitted a required field");
28140
28593
  }
28141
28594
  }
@@ -28160,7 +28613,7 @@ function validUsage(value) {
28160
28613
  if (!nonNegativeSafeInteger2(value.inputTokens) || !nonNegativeSafeInteger2(value.outputTokens)) {
28161
28614
  return false;
28162
28615
  }
28163
- return fields.slice(2).every((field) => value[field] === void 0 || nonNegativeSafeInteger2(value[field]));
28616
+ return fields.slice(2).every((field2) => value[field2] === void 0 || nonNegativeSafeInteger2(value[field2]));
28164
28617
  }
28165
28618
  function validateTurnReason(value) {
28166
28619
  if (!isRecord4(value) || typeof value.kind !== "string") {
@@ -28275,7 +28728,7 @@ function validateInboxSplice(data, profile) {
28275
28728
  }
28276
28729
  }
28277
28730
  function validateApprovalAsked(data) {
28278
- requiredOptionalKeys(data, ["id", "toolName"], ["callId", "reason"]);
28731
+ requiredOptionalKeys(data, ["id", "toolName"], ["callId", "reason", "displayReason"]);
28279
28732
  requiredString(data.id, "approval/asked id");
28280
28733
  requiredString(data.toolName, "approval/asked toolName");
28281
28734
  if (data.callId !== void 0)
@@ -28283,6 +28736,17 @@ function validateApprovalAsked(data) {
28283
28736
  if (data.reason !== void 0 && typeof data.reason !== "string") {
28284
28737
  fail("Modern history approval/asked reason is malformed");
28285
28738
  }
28739
+ if (data.displayReason !== void 0 && !isApprovalDisplayReason2(data.displayReason)) {
28740
+ fail("Modern history approval/asked displayReason is malformed");
28741
+ }
28742
+ }
28743
+ function isApprovalDisplayReason2(value) {
28744
+ if (!isRecord4(value))
28745
+ return false;
28746
+ const entries = Object.entries(value);
28747
+ if (entries.length === 0)
28748
+ return false;
28749
+ return entries.every(([locale, text]) => locale.length > 0 && typeof text === "string" && text.length > 0 && nonBlankString(text));
28286
28750
  }
28287
28751
  function validateApprovalDecided(data) {
28288
28752
  exactKeys(data, ["id", "outcome"]);
@@ -28733,6 +29197,8 @@ var ModernHarnessSession = class {
28733
29197
  #flushSession;
28734
29198
  #fallbackModel;
28735
29199
  #fallbackThinkingOptionId;
29200
+ #sessionDirectory;
29201
+ #workingDirectory;
28736
29202
  #channel = new HarnessOutputChannel();
28737
29203
  #validator;
28738
29204
  #events;
@@ -28799,8 +29265,12 @@ var ModernHarnessSession = class {
28799
29265
  this.#events = [...options.journal.events];
28800
29266
  this.#historyBytes = journalHistoryBytes(this.#events, this.#maxHistoryBytes);
28801
29267
  this.#validator = new ModernEventValidator(this.#maxEvents, this.#profile);
28802
- for (const event of this.#events)
29268
+ this.#sessionDirectory = options.journal.header.cwd;
29269
+ this.#workingDirectory = this.#sessionDirectory;
29270
+ for (const event of this.#events) {
28803
29271
  this.#validator.accept(event);
29272
+ this.#workingDirectory = modernWorkingDirectory(this.#workingDirectory, event);
29273
+ }
28804
29274
  const projection = projectModernHistory({
28805
29275
  harnessId: this.harnessId,
28806
29276
  sessionId: this.#sessionId,
@@ -28835,12 +29305,18 @@ var ModernHarnessSession = class {
28835
29305
  };
28836
29306
  let resumedAutonomousBuffer;
28837
29307
  if (projection.incompleteTurn) {
29308
+ let workingDirectory = this.#sessionDirectory;
29309
+ const turnStart = this.#events.length - projection.incompleteTurn.events.length;
29310
+ for (const event of this.#events.slice(0, turnStart)) {
29311
+ workingDirectory = modernWorkingDirectory(workingDirectory, event);
29312
+ }
28838
29313
  const buffer = {
28839
29314
  nativeTurn: projection.incompleteTurn.turn,
28840
29315
  events: [...projection.incompleteTurn.events],
28841
29316
  input: [],
28842
29317
  initialResume: true,
28843
29318
  replayed: 0,
29319
+ workingDirectory,
28844
29320
  sawUserMessage: false,
28845
29321
  reachedCorrelationBoundary: false
28846
29322
  };
@@ -28882,7 +29358,7 @@ var ModernHarnessSession = class {
28882
29358
  return Promise.resolve({ ok: false, error: busyError("read history") });
28883
29359
  this.#reading = true;
28884
29360
  try {
28885
- const projection = this.#project();
29361
+ const projection = this.#project(true);
28886
29362
  const configuration = this.#readConfiguration();
28887
29363
  return Promise.resolve({
28888
29364
  ok: true,
@@ -29196,7 +29672,7 @@ var ModernHarnessSession = class {
29196
29672
  type: "approval",
29197
29673
  interactionId,
29198
29674
  turnId: active.turnId,
29199
- title: delivery.request.reason ?? `Allow ${delivery.request.toolName}?`,
29675
+ title: delivery.request.displayReason?.en ?? delivery.request.reason ?? `Allow ${delivery.request.toolName}?`,
29200
29676
  description: delivery.request.callId ? `${delivery.request.toolName} (${delivery.request.callId})` : delivery.request.toolName,
29201
29677
  subject: { type: "nativeAction" },
29202
29678
  actions: [
@@ -29820,6 +30296,7 @@ ${question.detail}` : question.question;
29820
30296
  this.#validator.accept(event);
29821
30297
  this.#observeAssistantSettlement(event);
29822
30298
  this.#events.push(event);
30299
+ this.#workingDirectory = modernWorkingDirectory(this.#workingDirectory, event);
29823
30300
  this.#meterUsage(event);
29824
30301
  this.#historyBytes += bytes;
29825
30302
  this.#receive(event);
@@ -29945,8 +30422,8 @@ ${question.detail}` : question.question;
29945
30422
  const agent = active.agent;
29946
30423
  if (!agent)
29947
30424
  return;
29948
- agent.text += CANCELLED_ASSISTANT_ATTEMPT_SUFFIX;
29949
- agent.item = { ...agent.item, text: agent.text };
30425
+ this.#flushAgent(active, agent);
30426
+ agent.item = { ...agent.item, text: agent.item.text + CANCELLED_ASSISTANT_ATTEMPT_SUFFIX };
29950
30427
  this.#emit({
29951
30428
  type: "item.updated",
29952
30429
  turnId: active.turnId,
@@ -30070,6 +30547,7 @@ ${question.detail}` : question.question;
30070
30547
  input: [],
30071
30548
  initialResume: false,
30072
30549
  replayed: 0,
30550
+ workingDirectory: this.#workingDirectory,
30073
30551
  sawUserMessage: false,
30074
30552
  reachedCorrelationBoundary: false
30075
30553
  };
@@ -30248,6 +30726,7 @@ ${question.detail}` : question.question;
30248
30726
  while (!this.#closed && buffer.replayed < buffer.events.length) {
30249
30727
  const event = buffer.events[buffer.replayed];
30250
30728
  buffer.replayed += 1;
30729
+ buffer.workingDirectory = modernWorkingDirectory(buffer.workingDirectory, event);
30251
30730
  this.#projectLiveEvent(buffer, event, initialReplay);
30252
30731
  }
30253
30732
  this.#projectAssistantLiveChunks();
@@ -30357,16 +30836,28 @@ ${question.detail}` : question.question;
30357
30836
  itemId: modernItemId(this.#sessionId, `turn:${active.nativeTurn}:step:${step}:${attemptId ? `attempt:${attemptId}:` : ""}assistant`),
30358
30837
  text: ""
30359
30838
  };
30360
- active.agent = { item, text: "" };
30839
+ const buffer = this.#buffer;
30840
+ const workingDirectory = buffer?.active === active ? buffer.workingDirectory : this.#workingDirectory;
30841
+ const roots = modernMediaRoots(workingDirectory, this.#sessionDirectory);
30842
+ active.agent = { item, text: "", media: new LocalMediaMarkdownStream(roots) };
30361
30843
  this.#emit({ type: "item.started", turnId: active.turnId, item });
30362
30844
  }
30363
30845
  active.agent.text += text;
30364
- active.agent.item = { ...active.agent.item, text: active.agent.text };
30846
+ this.#publishAgent(active, active.agent, active.agent.media.append(text));
30847
+ }
30848
+ /** Publish text the media projection held for a trailing construct before the Item ends. */
30849
+ #flushAgent(active, agent) {
30850
+ this.#publishAgent(active, agent, agent.media.flush());
30851
+ }
30852
+ #publishAgent(active, agent, delta) {
30853
+ if (!delta)
30854
+ return;
30855
+ agent.item = { ...agent.item, text: agent.media.text };
30365
30856
  this.#emit({
30366
30857
  type: "item.updated",
30367
30858
  turnId: active.turnId,
30368
- itemId: active.agent.item.itemId,
30369
- update: { type: "text.append", text }
30859
+ itemId: agent.item.itemId,
30860
+ update: { type: "text.append", text: delta }
30370
30861
  });
30371
30862
  }
30372
30863
  #startReasoning(active, step, provisional, attemptId) {
@@ -30474,6 +30965,7 @@ ${question.detail}` : question.question;
30474
30965
  }
30475
30966
  if (!current)
30476
30967
  return;
30968
+ this.#flushAgent(active, current);
30477
30969
  delete active.agent;
30478
30970
  this.#completeItem(active, current.item, { status: "succeeded" });
30479
30971
  }
@@ -30615,9 +31107,10 @@ ${question.detail}` : question.question;
30615
31107
  this.#completeItem(active, item, outcome);
30616
31108
  }
30617
31109
  if (active.agent) {
30618
- const item = active.agent.item;
31110
+ const agent = active.agent;
31111
+ this.#flushAgent(active, agent);
30619
31112
  delete active.agent;
30620
- this.#completeItem(active, item, outcome);
31113
+ this.#completeItem(active, agent.item, outcome);
30621
31114
  }
30622
31115
  for (const tool of active.tools.values())
30623
31116
  this.#completeItem(active, tool.item, outcome);
@@ -30644,12 +31137,17 @@ ${question.detail}` : question.question;
30644
31137
  });
30645
31138
  }
30646
31139
  }
30647
- #project() {
31140
+ /** `media` also resolves local media paths, which only displayed history needs. */
31141
+ #project(media = false) {
30648
31142
  return projectModernHistory({
30649
31143
  harnessId: this.harnessId,
30650
31144
  sessionId: this.#sessionId,
30651
31145
  events: this.#events,
30652
31146
  profile: this.#profile,
31147
+ ...media ? {
31148
+ media: true,
31149
+ ...this.#sessionDirectory !== void 0 ? { cwd: this.#sessionDirectory } : {}
31150
+ } : {},
30653
31151
  ...this.#fallbackModel ? { fallbackModel: this.#fallbackModel } : {},
30654
31152
  ...this.#fallbackThinkingOptionId ? { fallbackThinkingOptionId: this.#fallbackThinkingOptionId } : {},
30655
31153
  toolOutputLimit: this.#toolOutputLimit,
@@ -31234,7 +31732,7 @@ function safeTimerDelay(value, name) {
31234
31732
 
31235
31733
  // dist/modern/session-list.js
31236
31734
  import { Buffer as Buffer5 } from "node:buffer";
31237
- import path7 from "node:path";
31735
+ import path9 from "node:path";
31238
31736
  var MAX_SESSION_LIST_BYTES = 32 * 1024 * 1024;
31239
31737
  var MAX_SESSION_LIST_DEPTH = 64;
31240
31738
  var MAX_SESSION_LIST_NODES = 2e5;
@@ -31354,7 +31852,7 @@ function parseSummary(value) {
31354
31852
  };
31355
31853
  }
31356
31854
  function isCanonicalAbsoluteCwd(value) {
31357
- return value !== void 0 && value.trim().length > 0 && !value.includes("\0") && path7.isAbsolute(value) && path7.resolve(value) === value;
31855
+ return value !== void 0 && value.trim().length > 0 && !value.includes("\0") && path9.isAbsolute(value) && path9.resolve(value) === value;
31358
31856
  }
31359
31857
  function parseModernSessionCandidates(value) {
31360
31858
  assertBoundedJson4(value);
@@ -31552,7 +32050,7 @@ var ModernDeepSeekHarnessAdapter = class {
31552
32050
  let session;
31553
32051
  let forkExpectation;
31554
32052
  try {
31555
- const cwd = path8.resolve(input.cwd);
32053
+ const cwd = path10.resolve(input.cwd);
31556
32054
  let forkInput = input.kind === "fork" ? parseModernForkInput(input, this.#profile) : void 0;
31557
32055
  const rollbackSourceSessionId = input.kind === "rollbackLastTurn" ? modernSessionId(input.sourceRef, "roll back") : void 0;
31558
32056
  let rollbackPlan;