dsh-reference-anything 0.5.0 → 0.5.2

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 (72) hide show
  1. package/LICENSE +22 -22
  2. package/NOTICE.md +110 -110
  3. package/README.md +470 -451
  4. package/cordis.patch.yml +136 -134
  5. package/docs/release/0.4.4/README.md +75 -0
  6. package/{release-notes → docs/release}/0.4.4/features.json +1 -1
  7. package/docs/release/0.5.0/README.md +148 -0
  8. package/docs/release/0.5.1/README.md +33 -0
  9. package/docs/release/0.5.2/README.md +51 -0
  10. package/docs/release/0.5.2/features.json +29 -0
  11. package/{release-notes → docs/release}/README.md +12 -6
  12. package/images/agents/LICENSE +22 -22
  13. package/images/agents/README.md +7 -3
  14. package/images/agents/antigravity.svg +1 -1
  15. package/images/agents/cline.svg +1 -1
  16. package/images/agents/continue.svg +1 -1
  17. package/images/agents/copilot.svg +27 -0
  18. package/images/agents/crush.svg +1 -1
  19. package/images/agents/doubao.svg +1 -0
  20. package/images/agents/goose.svg +1 -1
  21. package/images/agents/omp.svg +1 -0
  22. package/images/agents/reasonix.svg +5 -5
  23. package/images/agents/teleagent.svg +1 -1
  24. package/images/agents/trae.svg +1 -1
  25. package/images/agents/vibe.svg +1 -1
  26. package/images/agents/workbuddy.svg +37 -37
  27. package/images/agents/zed.svg +1 -1
  28. package/lib/chat-import-compatibility.js +8 -5
  29. package/lib/client.js +36526 -4
  30. package/lib/contract.d.ts +4 -0
  31. package/lib/host.d.ts +2 -2
  32. package/lib/host.js +4 -1
  33. package/lib/local-conversation-reader.js +16 -11
  34. package/lib/render.js +21 -21
  35. package/lib/store/spec.d.ts +9 -1
  36. package/lib/tool.js +3 -2
  37. package/lib/wire.d.ts +13 -1
  38. package/lib/wire.js +5 -4
  39. package/locale/en.json +6 -6
  40. package/locale/zh.json +6 -6
  41. package/opencli-plugin/chatgpt.js +128 -128
  42. package/opencli-plugin/claude.js +138 -138
  43. package/opencli-plugin/common.js +452 -452
  44. package/opencli-plugin/deepseek.js +155 -155
  45. package/opencli-plugin/gemini.js +169 -169
  46. package/opencli-plugin/grok.js +124 -124
  47. package/opencli-plugin/kimi.js +126 -126
  48. package/opencli-plugin/opencli-plugin.json +6 -6
  49. package/opencli-plugin/package.json +8 -8
  50. package/opencli-plugin/since-guard.js +45 -45
  51. package/package.json +263 -262
  52. package/vendor/chat-import-reader/LICENSE +22 -22
  53. package/vendor/chat-import-reader/README.md +54 -48
  54. package/vendor/chat-import-reader/availability-worker.mjs +5 -0
  55. package/vendor/chat-import-reader/parsers.d.mts +6 -6
  56. package/vendor/chat-import-reader/parsers.mjs +2248 -347
  57. package/vendor/chat-import-reader/scanners.mjs +1316 -79
  58. package/vendor/chat-import-reader/upstream-sha256.json +35 -22
  59. package/release-notes/0.4.4/commands.png +0 -0
  60. package/release-notes/0.4.4/demos/agent-import.gif +0 -0
  61. package/release-notes/0.4.4/demos/chat-import-upgrade.gif +0 -0
  62. package/release-notes/0.4.4/demos/folders.gif +0 -0
  63. package/release-notes/0.4.4/demos/local-plugins.gif +0 -0
  64. package/release-notes/0.4.4/demos/shortcuts.gif +0 -0
  65. package/release-notes/0.4.4/files.png +0 -0
  66. package/release-notes/0.5.0/demos/agent-import.gif +0 -0
  67. package/release-notes/0.5.0/demos/chat-import-upgrade.gif +0 -0
  68. package/release-notes/0.5.0/demos/folders.gif +0 -0
  69. package/release-notes/0.5.0/demos/local-plugins.gif +0 -0
  70. package/release-notes/0.5.0/demos/local-references.gif +0 -0
  71. package/release-notes/0.5.0/demos/shortcuts.gif +0 -0
  72. /package/{release-notes → docs/release}/0.5.0/features.json +0 -0
@@ -1,5 +1,5 @@
1
1
  // Generated by scripts/vendor-chat-import-reader.mjs; see adjacent licenses.
2
- // .codex-tmp/vendor-pagination-upstream/lib/convert/trim.mjs
2
+ // .codex-tmp/chat-import-0263/package/lib/convert/trim.mjs
3
3
  function estimateTokens(text) {
4
4
  if (typeof text !== "string" || text.length === 0) return 0;
5
5
  let cjk = 0;
@@ -214,7 +214,7 @@ function applyBudgetTrim(turns, budget) {
214
214
  return { turns: out, trimmed: engaged ? trimmed : null };
215
215
  }
216
216
 
217
- // .codex-tmp/vendor-pagination-upstream/lib/convert/inject.mjs
217
+ // .codex-tmp/chat-import-0263/package/lib/convert/inject.mjs
218
218
  var INJECT_MARKERS = [
219
219
  "<environment_context>",
220
220
  "<system-reminder>",
@@ -257,6 +257,9 @@ var SYSTEM_REMINDER_CLOSE = "</system-reminder>";
257
257
  function isSystemContextBlock(text) {
258
258
  return String(text ?? "").trimStart().startsWith("<system");
259
259
  }
260
+ function isNotificationBlock(text) {
261
+ return String(text ?? "").trimStart().toLowerCase().startsWith("<notification");
262
+ }
260
263
  function stripSystemReminders(text) {
261
264
  return String(text ?? "").replace(/<system-reminder[\s\S]*?<\/system-reminder>/gi, "");
262
265
  }
@@ -273,7 +276,7 @@ function stripUserQueryWrapper(text) {
273
276
  return parts.join("\n");
274
277
  }
275
278
 
276
- // .codex-tmp/vendor-pagination-upstream/lib/convert/events.mjs
279
+ // .codex-tmp/chat-import-0263/package/lib/convert/events.mjs
277
280
  function contextInjectionText(provider, systemPrompt) {
278
281
  const src = String(systemPrompt ?? "").trim();
279
282
  const label = typeof provider === "string" && provider ? provider : "unknown";
@@ -283,7 +286,7 @@ function contextInjectionText(provider, systemPrompt) {
283
286
  }
284
287
  return [SYSTEM_REMINDER_OPEN, body.replaceAll(SYSTEM_REMINDER_CLOSE, "<\\/system-reminder>"), SYSTEM_REMINDER_CLOSE].join("\n");
285
288
  }
286
- function synthesizeSession({ meta, turns, title, provider, model, skipped, records, skippedLines = [], secrets = [], permissionCount = 0, systemPrompt }) {
289
+ function synthesizeSession({ meta, turns, title, provider, model, skipped, records, skippedLines = [], secrets = [], permissionCount = 0, systemPrompt, resultOrder = "call" }) {
287
290
  const events = [];
288
291
  let seq = 0;
289
292
  let turn = 0;
@@ -370,7 +373,7 @@ function synthesizeSession({ meta, turns, title, provider, model, skipped, recor
370
373
  id: "import:" + meta.id + ":u" + turn,
371
374
  role: "user",
372
375
  content: Array.isArray(t.promptBlocks) && t.promptBlocks.length > 0 ? t.promptBlocks : [{ type: "text", text: t.prompt }],
373
- source: { kind: "user" }
376
+ source: t.promptSource || { kind: "user" }
374
377
  });
375
378
  };
376
379
  const pushSystemHead = (turn2, step) => {
@@ -459,7 +462,23 @@ function synthesizeSession({ meta, turns, title, provider, model, skipped, recor
459
462
  });
460
463
  callSeqs.push(ev.seq);
461
464
  }
462
- for (let ci = 0; ci < step.toolCalls.length; ci++) {
465
+ const callIndex = new Map(step.toolCalls.map((tc, i2) => [tc.id, i2]));
466
+ const orderedCallIndexes = [];
467
+ if (resultOrder === "source") {
468
+ const seenCall = /* @__PURE__ */ new Set();
469
+ for (const tr of step.toolResults) {
470
+ const ci = callIndex.get(tr.toolCallId);
471
+ if (ci === void 0 || seenCall.has(tr.toolCallId)) continue;
472
+ seenCall.add(tr.toolCallId);
473
+ orderedCallIndexes.push(ci);
474
+ }
475
+ for (let ci = 0; ci < step.toolCalls.length; ci++) {
476
+ if (!seenCall.has(step.toolCalls[ci].id)) orderedCallIndexes.push(ci);
477
+ }
478
+ } else {
479
+ for (let ci = 0; ci < step.toolCalls.length; ci++) orderedCallIndexes.push(ci);
480
+ }
481
+ for (const ci of orderedCallIndexes) {
463
482
  const tc = step.toolCalls[ci];
464
483
  const tr = resultByCallId.get(tc.id);
465
484
  advance(tr?.time);
@@ -524,7 +543,7 @@ function sanitizeUsage(usage) {
524
543
  return out;
525
544
  }
526
545
 
527
- // .codex-tmp/vendor-pagination-upstream/lib/convert/shape.mjs
546
+ // .codex-tmp/chat-import-0263/package/lib/convert/shape.mjs
528
547
  var ENV_INJECTION_EVENT_ID_SUFFIX = ":env";
529
548
  function isEnvInjectionEvent(ev) {
530
549
  if (!ev || ev.type !== "user/message") return false;
@@ -536,7 +555,7 @@ function isEnvInjectionEvent(ev) {
536
555
  return typeof data.id === "string" && data.id.endsWith(ENV_INJECTION_EVENT_ID_SUFFIX);
537
556
  }
538
557
 
539
- // .codex-tmp/vendor-pagination-upstream/lib/convert/image.mjs
558
+ // .codex-tmp/chat-import-0263/package/lib/convert/image.mjs
540
559
  var IMAGE_MEDIA_TYPES = ["image/png", "image/jpeg", "image/webp", "image/gif"];
541
560
  var MAX_IMAGE_BASE64_CHARS = 24 * 1024 * 1024;
542
561
  var IMAGE_PLACEHOLDER = "[image]";
@@ -613,7 +632,7 @@ function imageBlockFromSource(block) {
613
632
  return null;
614
633
  }
615
634
 
616
- // .codex-tmp/vendor-pagination-upstream/lib/convert/validate.mjs
635
+ // .codex-tmp/chat-import-0263/package/lib/convert/validate.mjs
617
636
  var SESSION_EVENT_TYPES = [
618
637
  // 本插件自产 / 客户端流事件(宿主词汇表外,见上)
619
638
  "session/imported",
@@ -687,7 +706,7 @@ var SESSION_EVENT_TYPES = [
687
706
  ];
688
707
  var SESSION_EVENT_TYPES_SET = new Set(SESSION_EVENT_TYPES);
689
708
 
690
- // .codex-tmp/vendor-pagination-upstream/lib/convert/core.mjs
709
+ // .codex-tmp/chat-import-0263/package/lib/convert/core.mjs
691
710
  var SESSION_FORMAT_VERSION = 3;
692
711
  function parseTimeMs(value, { truncSeconds = false } = {}) {
693
712
  if (typeof value === "number") {
@@ -786,7 +805,7 @@ function parseJsonlLines(raw, { requireObject = false } = {}) {
786
805
  return { recs, skipped, skippedLines, secrets };
787
806
  }
788
807
 
789
- // .codex-tmp/vendor-pagination-upstream/lib/convert/util.mjs
808
+ // .codex-tmp/chat-import-0263/package/lib/convert/util.mjs
790
809
  import { posix, win32 } from "node:path";
791
810
  function joinForPlatform(platform, ...parts) {
792
811
  return platform === "win32" ? win32.join(...parts) : posix.join(...parts);
@@ -835,7 +854,7 @@ function contentText(content, { types = TEXT_BLOCK_TYPES, sep = "\n", skipEmpty
835
854
  return trim ? text.trim() : text;
836
855
  }
837
856
 
838
- // .codex-tmp/vendor-pagination-upstream/lib/convert/ir.mjs
857
+ // .codex-tmp/chat-import-0263/package/lib/convert/ir.mjs
839
858
  function shadowTurns(turns, from = 0) {
840
859
  for (let i = from; i < turns.length; i++) turns[i].shadowed = true;
841
860
  return turns.length;
@@ -928,7 +947,7 @@ function dropDeadRetrySteps(turns) {
928
947
  return dropped;
929
948
  }
930
949
 
931
- // .codex-tmp/vendor-pagination-upstream/lib/convert/claude.mjs
950
+ // .codex-tmp/chat-import-0263/package/lib/convert/claude.mjs
932
951
  var TOOL_USE_RESULT_BULK_KEYS = /* @__PURE__ */ new Set(["originalFile", "content", "stdout", "stderr"]);
933
952
  var TOOL_USE_RESULT_SCALAR_KEYS = [
934
953
  "interrupted",
@@ -1296,7 +1315,7 @@ function convertClaudeJsonl(raw, args = {}) {
1296
1315
  });
1297
1316
  }
1298
1317
 
1299
- // .codex-tmp/vendor-pagination-upstream/lib/convert/codex-external-agent.mjs
1318
+ // .codex-tmp/chat-import-0263/package/lib/convert/codex-external-agent.mjs
1300
1319
  var EXT_CALL_HEAD = /^\[external_agent_tool_call:\s*([^\]]*?)\s*\]$/;
1301
1320
  var EXT_CALL_TAIL = "[/external_agent_tool_call]";
1302
1321
  var EXT_RESULT_HEAD = /^\[external_agent_tool_result(?::\s*([^\]]*?))?\s*\]$/;
@@ -1403,7 +1422,7 @@ function externalAgentKeyValuePairs(lines) {
1403
1422
  return key === null ? null : out;
1404
1423
  }
1405
1424
 
1406
- // .codex-tmp/vendor-pagination-upstream/lib/convert/codex.mjs
1425
+ // .codex-tmp/chat-import-0263/package/lib/convert/codex.mjs
1407
1426
  function codexSubagentMarker(payload) {
1408
1427
  if (!payload || typeof payload !== "object") return null;
1409
1428
  if (payload.thread_source === "subagent") return "thread_source=subagent";
@@ -2016,7 +2035,7 @@ function jsObjectLiteralToJson(src) {
2016
2035
  }
2017
2036
  }
2018
2037
 
2019
- // .codex-tmp/vendor-pagination-upstream/lib/convert/chatgpt.mjs
2038
+ // .codex-tmp/chat-import-0263/package/lib/convert/chatgpt.mjs
2020
2039
  function convertChatgptJson(raw, args = {}) {
2021
2040
  let parsed;
2022
2041
  try {
@@ -2230,7 +2249,7 @@ function buildTurns(thread, importSystemPrompt) {
2230
2249
  return { turns, systemPrompt };
2231
2250
  }
2232
2251
 
2233
- // .codex-tmp/vendor-pagination-upstream/lib/convert/cursor.mjs
2252
+ // .codex-tmp/chat-import-0263/package/lib/convert/cursor.mjs
2234
2253
  function parseCursorEmbeddedTimestamp(text) {
2235
2254
  const m = String(text ?? "").match(/<timestamp>\s*([^<]+?)\s*<\/timestamp>/i);
2236
2255
  if (!m) return void 0;
@@ -2304,7 +2323,7 @@ function cursorText(text) {
2304
2323
  return cleaned;
2305
2324
  }
2306
2325
 
2307
- // .codex-tmp/vendor-pagination-upstream/lib/convert/gemini.mjs
2326
+ // .codex-tmp/chat-import-0263/package/lib/convert/gemini.mjs
2308
2327
  function convertGeminiJson(raw, args = {}) {
2309
2328
  let chat;
2310
2329
  try {
@@ -2392,7 +2411,7 @@ function geminiToolResultText(tc) {
2392
2411
  return null;
2393
2412
  }
2394
2413
 
2395
- // .codex-tmp/vendor-pagination-upstream/lib/convert/antigravity.mjs
2414
+ // .codex-tmp/chat-import-0263/package/lib/convert/antigravity.mjs
2396
2415
  var RESULT_TOOL_NAMES = {
2397
2416
  LIST_DIRECTORY: ["list_dir"],
2398
2417
  VIEW_FILE: ["view_file"],
@@ -2619,7 +2638,7 @@ function convertAntigravityJsonl(raw, args = {}) {
2619
2638
  }, { title: finalTitle });
2620
2639
  }
2621
2640
 
2622
- // .codex-tmp/vendor-pagination-upstream/lib/convert/reasonix.mjs
2641
+ // .codex-tmp/chat-import-0263/package/lib/convert/reasonix.mjs
2623
2642
  function reasonixStemTime(stem) {
2624
2643
  const m = String(stem || "").match(/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/);
2625
2644
  if (!m) return null;
@@ -2742,16 +2761,16 @@ function finishReasonix(recs, args, skipped, skippedLines, secrets, walMerged, w
2742
2761
  });
2743
2762
  }
2744
2763
 
2745
- // .codex-tmp/vendor-pagination-upstream/lib/convert/pi.mjs
2746
- function convertPiJsonl(raw, args = {}) {
2764
+ // .codex-tmp/chat-import-0263/package/lib/convert/pi-family.mjs
2765
+ function convertPiFamilyJsonl(raw, args = {}, profile) {
2747
2766
  const { recs, skipped, skippedLines, secrets } = parseJsonlLines(raw);
2748
2767
  const header = recs.find((r) => r && typeof r === "object" && r.type === "session") || null;
2749
2768
  if (!header) {
2750
- return skipResult("not a Pi Coding Agent session (no session header)", { skipped: 1, records: recs.length });
2769
+ return skipResult(profile.skipReason, { skipped: 1, records: recs.length });
2751
2770
  }
2752
2771
  const entries = [];
2753
2772
  for (const rec of recs) {
2754
- if (!rec || typeof rec !== "object" || rec.type === "session") continue;
2773
+ if (!rec || typeof rec !== "object" || rec.type === "session" || rec.type === "title") continue;
2755
2774
  const id = typeof rec.id === "string" && rec.id ? rec.id : "e" + entries.length;
2756
2775
  const parentId2 = typeof rec.parentId === "string" ? rec.parentId : entries.length > 0 ? entries[entries.length - 1].id : null;
2757
2776
  entries.push({ ...rec, _id: id, _parentId: parentId2 });
@@ -2770,20 +2789,31 @@ function convertPiJsonl(raw, args = {}) {
2770
2789
  }
2771
2790
  }
2772
2791
  path.reverse();
2792
+ let startIndex = 0;
2793
+ let resetBoundaries = 0;
2794
+ if (profile.honorsResetBoundary && args.fullHistory !== true) {
2795
+ for (let i = 0; i < path.length; i++) {
2796
+ const item = path[i];
2797
+ if (item && item.type === "reset_boundary") {
2798
+ startIndex = i + 1;
2799
+ resetBoundaries += 1;
2800
+ }
2801
+ }
2802
+ }
2773
2803
  const boundaries = /* @__PURE__ */ new Map();
2774
2804
  const consumedCompactions = /* @__PURE__ */ new Set();
2775
2805
  if (args.fullHistory !== true) {
2776
- for (let i = 0; i < path.length; i++) {
2777
- const c = path[i];
2778
- if (!c || c.type !== "compaction") continue;
2779
- const summary = typeof c.summary === "string" ? c.summary.trim() : "";
2806
+ for (let i = startIndex; i < path.length; i++) {
2807
+ const cut = profile.compactOf(path[i]);
2808
+ if (!cut) continue;
2809
+ const summary = typeof cut.summary === "string" ? cut.summary.trim() : "";
2780
2810
  if (!summary) continue;
2781
2811
  let from = -1;
2782
- if (typeof c.firstKeptEntryId === "string") from = path.findIndex((e) => e._id === c.firstKeptEntryId);
2783
- if (from < 0 && Array.isArray(c.retainedTail) && c.retainedTail.length > 0) from = i - c.retainedTail.length;
2812
+ if (typeof cut.firstKeptEntryId === "string") from = path.findIndex((e) => e._id === cut.firstKeptEntryId);
2813
+ if (from < 0 && Array.isArray(cut.retainedTail) && cut.retainedTail.length > 0) from = i - cut.retainedTail.length;
2784
2814
  if (from < 0) from = i;
2785
- boundaries.set(Math.max(0, from), summary);
2786
- consumedCompactions.add(c._id);
2815
+ boundaries.set(Math.max(startIndex, from), summary);
2816
+ consumedCompactions.add(path[i]._id);
2787
2817
  }
2788
2818
  }
2789
2819
  const turnQueue = createTurns();
@@ -2792,19 +2822,19 @@ function convertPiJsonl(raw, args = {}) {
2792
2822
  let cur = null;
2793
2823
  let model = null;
2794
2824
  let lastModelChange = null;
2795
- let title;
2825
+ let title = profile.initialTitle ? profile.initialTitle(header, recs) : void 0;
2796
2826
  const callSteps = /* @__PURE__ */ new Map();
2797
2827
  let droppedToolResults = 0;
2798
- let droppedBash = 0;
2828
+ let droppedInjected = 0;
2799
2829
  const pendingBlocks = [];
2800
2830
  let imagesDegraded = 0;
2801
2831
  const processMessage = (m) => {
2802
2832
  if (!m || typeof m !== "object") return;
2803
2833
  if (m.role === "user") {
2804
- const prompt = piUserText(m.content);
2834
+ const prompt = familyUserText(m.content);
2805
2835
  if (prompt) {
2806
2836
  cur = turnQueue.open(prompt);
2807
- const userImages = piUserImageBlocks(m.content);
2837
+ const userImages = familyUserImageBlocks(m.content);
2808
2838
  if (userImages.length > 0) cur.promptBlocks = [{ type: "text", text: prompt }, ...userImages];
2809
2839
  }
2810
2840
  } else if (m.role === "assistant") {
@@ -2830,7 +2860,7 @@ function convertPiJsonl(raw, args = {}) {
2830
2860
  step.content.push({ type: "text", text: "[image: " + (typeof block.mimeType === "string" ? block.mimeType : "image") + "]" });
2831
2861
  }
2832
2862
  } else if (block.type === "toolCall") {
2833
- const mapped = piToolCall(block, turns.length, cur.steps.length + 1);
2863
+ const mapped = familyToolCall(block, profile.toolCallIdPrefix, turns.length, cur.steps.length + 1);
2834
2864
  step.content.push({ type: "tool-call", ...mapped });
2835
2865
  step.toolCalls.push(mapped);
2836
2866
  }
@@ -2843,7 +2873,7 @@ function convertPiJsonl(raw, args = {}) {
2843
2873
  droppedToolResults++;
2844
2874
  return;
2845
2875
  }
2846
- const inner = (Array.isArray(m.content) ? m.content : []).map((b) => piContentBlock(b, () => {
2876
+ const inner = familyToolResultContent(m).map((b) => familyContentBlock(b, () => {
2847
2877
  imagesDegraded++;
2848
2878
  })).filter(Boolean);
2849
2879
  step.toolResults.push({
@@ -2854,47 +2884,63 @@ function convertPiJsonl(raw, args = {}) {
2854
2884
  } else if (m.role === "bashExecution") {
2855
2885
  if (m.excludeFromContext === true) return;
2856
2886
  if (!cur) {
2857
- droppedBash++;
2887
+ droppedInjected++;
2888
+ return;
2889
+ }
2890
+ const step = cur.steps.length > 0 ? cur.steps[cur.steps.length - 1] : null;
2891
+ if (step) step.content.push({ type: "text", text: familyBashText(m) });
2892
+ else droppedInjected++;
2893
+ } else if (m.role === "pythonExecution") {
2894
+ if (m.excludeFromContext === true) return;
2895
+ if (!cur) {
2896
+ droppedInjected++;
2858
2897
  return;
2859
2898
  }
2860
2899
  const step = cur.steps.length > 0 ? cur.steps[cur.steps.length - 1] : null;
2861
- if (step) step.content.push({ type: "text", text: piBashText(m) });
2862
- else droppedBash++;
2900
+ if (step) step.content.push({ type: "text", text: familyPythonText(m) });
2901
+ else droppedInjected++;
2902
+ } else if (m.role === "fileMention") {
2903
+ for (const b of familyFileMentionBlocks(m, () => {
2904
+ imagesDegraded++;
2905
+ })) pendingBlocks.push(b);
2863
2906
  } else if (m.role === "branchSummary" || m.role === "compactionSummary") {
2864
2907
  if (typeof m.summary === "string" && m.summary.trim()) {
2865
2908
  pendingBlocks.push({
2866
2909
  type: "reasoning",
2867
- text: (m.role === "branchSummary" ? PI_BRANCH_SUMMARY_PREFIX : PI_COMPACTION_SUMMARY_PREFIX) + m.summary.trim() + PI_SUMMARY_SUFFIX
2910
+ text: m.role === "branchSummary" ? profile.renderSummary.branch(m.summary.trim()) : m.method === "handoff" && profile.renderSummary.handoff ? profile.renderSummary.handoff(m.summary.trim()) : profile.renderSummary.compaction(m.summary.trim())
2868
2911
  });
2869
2912
  }
2870
- } else if (m.role === "custom") {
2871
- for (const b of piCustomBlocks(m.content)) pendingBlocks.push(b);
2913
+ } else if (m.role === "custom" || m.role === "hookMessage" || m.role === "developer") {
2914
+ for (const b of familyCustomBlocks(m.content)) pendingBlocks.push(b);
2872
2915
  }
2873
2916
  };
2874
- for (let i = 0; i < path.length; i++) {
2917
+ for (let i = startIndex; i < path.length; i++) {
2875
2918
  const item = path[i];
2876
2919
  if (boundaries.has(i)) {
2877
2920
  shadowedTurns = shadowTurns(turns, shadowedTurns);
2878
2921
  cur = null;
2879
- turnQueue.setCompaction({ summary: boundaries.get(i), provider: "pi-coding-agent", model: model || void 0 });
2922
+ turnQueue.setCompaction({ summary: boundaries.get(i), provider: profile.provider, model: model || void 0 });
2880
2923
  }
2881
2924
  if (!item || typeof item !== "object") continue;
2882
- if (item.type === "compaction") {
2883
- if (!consumedCompactions.has(item._id) && typeof item.summary === "string" && item.summary.trim()) {
2884
- pendingBlocks.push({ type: "reasoning", text: PI_COMPACTION_SUMMARY_PREFIX + item.summary.trim() + PI_SUMMARY_SUFFIX });
2925
+ const cut = profile.compactOf(item);
2926
+ if (cut) {
2927
+ if (!consumedCompactions.has(item._id) && typeof cut.summary === "string" && cut.summary.trim()) {
2928
+ const wrapped = item.method === "handoff" && profile.renderSummary.handoff ? profile.renderSummary.handoff(cut.summary.trim()) : profile.renderSummary.compaction(cut.summary.trim());
2929
+ pendingBlocks.push({ type: "reasoning", text: wrapped });
2885
2930
  }
2886
2931
  } else if (item.type === "branch_summary") {
2887
2932
  if (typeof item.summary === "string" && item.summary.trim()) {
2888
- pendingBlocks.push({ type: "reasoning", text: PI_BRANCH_SUMMARY_PREFIX + item.summary.trim() + PI_SUMMARY_SUFFIX });
2933
+ pendingBlocks.push({ type: "reasoning", text: profile.renderSummary.branch(item.summary.trim()) });
2934
+ }
2935
+ } else {
2936
+ const t = profile.titleOf ? profile.titleOf(item) : void 0;
2937
+ if (t) title = t;
2938
+ const mid = profile.modelOf ? profile.modelOf(item) : null;
2939
+ if (mid) lastModelChange = mid;
2940
+ if (item.type === "message") processMessage(item.message);
2941
+ else if (item.type === "custom_message") {
2942
+ for (const b of familyCustomBlocks(item.content)) pendingBlocks.push(b);
2889
2943
  }
2890
- } else if (item.type === "session_info") {
2891
- if (typeof item.name === "string" && item.name.trim()) title = item.name.trim();
2892
- } else if (item.type === "model_change") {
2893
- if (typeof item.modelId === "string" && item.modelId) lastModelChange = item.modelId;
2894
- } else if (item.type === "message") {
2895
- processMessage(item.message);
2896
- } else if (item.type === "custom_message") {
2897
- for (const b of piCustomBlocks(item.content)) pendingBlocks.push(b);
2898
2944
  }
2899
2945
  }
2900
2946
  turnQueue.flush();
@@ -2906,7 +2952,7 @@ function convertPiJsonl(raw, args = {}) {
2906
2952
  if (turns.length === 0) {
2907
2953
  return skipResult(null, { skipped: 1, records: recs.length });
2908
2954
  }
2909
- const sourceId = typeof header.id === "string" && header.id ? header.id : args.piId;
2955
+ const sourceId = typeof header.id === "string" && header.id ? header.id : args[profile.idArg];
2910
2956
  const finalId = args.sessionId || mintSessionId(sourceId);
2911
2957
  const meta = { version: SESSION_FORMAT_VERSION, id: finalId, createdAt: parseTime(header.timestamp) };
2912
2958
  if (sourceId) meta.sourceId = sourceId;
@@ -2914,7 +2960,7 @@ function convertPiJsonl(raw, args = {}) {
2914
2960
  return finishSession(turns, args.budget, {
2915
2961
  meta,
2916
2962
  title,
2917
- provider: "pi-coding-agent",
2963
+ provider: profile.provider,
2918
2964
  model: lastModelChange || model,
2919
2965
  skipped,
2920
2966
  records: recs.length,
@@ -2922,12 +2968,28 @@ function convertPiJsonl(raw, args = {}) {
2922
2968
  secrets
2923
2969
  }, {
2924
2970
  droppedToolResults,
2925
- ...droppedBash > 0 ? { droppedBash } : {},
2971
+ ...droppedInjected > 0 ? { droppedInjected } : {},
2926
2972
  // 图片降级数(>0 才占键):拿不到字节、以 [image: <mime>] 文本占位导入的图片张数
2927
- ...imagesDegraded > 0 ? { imagesDegraded } : {}
2973
+ ...imagesDegraded > 0 ? { imagesDegraded } : {},
2974
+ // 源侧 /clear 次数(>0 才占键):清空点之前的内容未进日志,fullHistory:true 可保留
2975
+ ...resetBoundaries > 0 ? { resetBoundaries } : {}
2928
2976
  });
2929
2977
  }
2930
- function piUserText(content) {
2978
+ function familyToolResultContent(m) {
2979
+ const content = Array.isArray(m.content) ? m.content : [];
2980
+ if (m.prunedAt === void 0) return content;
2981
+ const text = content.filter((b) => b && b.type === "text" && typeof b.text === "string").map((b) => b.text).join("") || "[Output truncated]";
2982
+ const firstText = content.findIndex((b) => b && b.type === "text");
2983
+ if (firstText < 0) return [{ type: "text", text }, ...content];
2984
+ const out = [];
2985
+ for (let i = 0; i < content.length; i++) {
2986
+ const b = content[i];
2987
+ if (!b || b.type !== "text") out.push(b);
2988
+ else if (i === firstText) out.push({ type: "text", text });
2989
+ }
2990
+ return out;
2991
+ }
2992
+ function familyUserText(content) {
2931
2993
  if (typeof content === "string") return content;
2932
2994
  if (!Array.isArray(content)) return "";
2933
2995
  const texts = [];
@@ -2938,7 +3000,7 @@ function piUserText(content) {
2938
3000
  }
2939
3001
  return texts.join("\n");
2940
3002
  }
2941
- function piUserImageBlocks(content) {
3003
+ function familyUserImageBlocks(content) {
2942
3004
  const out = [];
2943
3005
  if (!Array.isArray(content)) return out;
2944
3006
  for (const block of content) {
@@ -2948,7 +3010,7 @@ function piUserImageBlocks(content) {
2948
3010
  }
2949
3011
  return out;
2950
3012
  }
2951
- function piContentBlock(block, onDegrade) {
3013
+ function familyContentBlock(block, onDegrade) {
2952
3014
  if (!block || typeof block !== "object") return null;
2953
3015
  if (block.type === "text" && typeof block.text === "string") return { type: "text", text: block.text };
2954
3016
  if (block.type === "image") {
@@ -2959,15 +3021,15 @@ function piContentBlock(block, onDegrade) {
2959
3021
  }
2960
3022
  return null;
2961
3023
  }
2962
- function piToolCall(block, turnNum, stepNum) {
2963
- const id = typeof block.id === "string" && block.id ? block.id : "pi-" + turnNum + "-" + stepNum;
3024
+ function familyToolCall(block, prefix, turnNum, stepNum) {
3025
+ const id = typeof block.id === "string" && block.id ? block.id : prefix + "-" + turnNum + "-" + stepNum;
2964
3026
  return {
2965
3027
  id,
2966
3028
  name: typeof block.name === "string" && block.name ? block.name : "unknown",
2967
3029
  arguments: typeof block.arguments === "string" ? block.arguments : JSON.stringify(block.arguments ?? {})
2968
3030
  };
2969
3031
  }
2970
- function piCustomBlocks(content) {
3032
+ function familyCustomBlocks(content) {
2971
3033
  if (typeof content === "string") return content.trim() ? [{ type: "text", text: content.trim() }] : [];
2972
3034
  if (!Array.isArray(content)) return [];
2973
3035
  const blocks = [];
@@ -2981,10 +3043,25 @@ function piCustomBlocks(content) {
2981
3043
  }
2982
3044
  return blocks;
2983
3045
  }
2984
- var PI_COMPACTION_SUMMARY_PREFIX = "The conversation history before this point was compacted into the following summary:\n\n<summary>\n";
2985
- var PI_BRANCH_SUMMARY_PREFIX = "The following is a summary of a branch that this conversation came back from:\n\n<summary>\n";
2986
- var PI_SUMMARY_SUFFIX = "\n</summary>";
2987
- function piBashText(m) {
3046
+ function familyFileMentionBlocks(m, onDegrade) {
3047
+ const blocks = [];
3048
+ for (const file of Array.isArray(m.files) ? m.files : []) {
3049
+ if (!file || typeof file !== "object") continue;
3050
+ const inner = file.content ? "\n" + file.content + "\n" : "\n";
3051
+ const text = '<file path="' + (typeof file.path === "string" ? file.path : "") + '">' + inner + "</file>";
3052
+ blocks.push({ type: "text", text });
3053
+ if (file.image) {
3054
+ const img = imageBlockFromSource(file.image);
3055
+ if (img) blocks.push(img);
3056
+ else if (typeof onDegrade === "function") {
3057
+ onDegrade();
3058
+ blocks.push({ type: "text", text: "[image: " + (typeof file.image.mimeType === "string" ? file.image.mimeType : "image") + "]" });
3059
+ }
3060
+ }
3061
+ }
3062
+ return blocks;
3063
+ }
3064
+ function familyBashText(m) {
2988
3065
  let text = "Ran `" + (typeof m.command === "string" ? m.command : "") + "`\n";
2989
3066
  if (typeof m.output === "string" && m.output) text += "```\n" + m.output + "\n```";
2990
3067
  else text += "(no output)";
@@ -2993,8 +3070,88 @@ function piBashText(m) {
2993
3070
  if (m.truncated === true && typeof m.fullOutputPath === "string") text += "\n\n[Output truncated. Full output: " + m.fullOutputPath + "]";
2994
3071
  return text;
2995
3072
  }
3073
+ function familyPythonText(m) {
3074
+ let text = "Ran Python:\n```python\n" + (typeof m.code === "string" ? m.code : "") + "\n```\n";
3075
+ if (typeof m.output === "string" && m.output) text += "Output:\n```\n" + m.output + "\n```";
3076
+ else text += "(no output)";
3077
+ if (m.cancelled === true) text += "\n\n(execution cancelled)";
3078
+ else if (m.exitCode !== null && m.exitCode !== void 0 && m.exitCode !== 0) text += "\n\nExecution failed with code " + m.exitCode;
3079
+ return text;
3080
+ }
3081
+
3082
+ // .codex-tmp/chat-import-0263/package/lib/convert/pi.mjs
3083
+ var PI_COMPACTION_SUMMARY_PREFIX = "The conversation history before this point was compacted into the following summary:\n\n<summary>\n";
3084
+ var PI_BRANCH_SUMMARY_PREFIX = "The following is a summary of a branch that this conversation came back from:\n\n<summary>\n";
3085
+ var PI_SUMMARY_SUFFIX = "\n</summary>";
3086
+ var PI_PROFILE = {
3087
+ provider: "pi-coding-agent",
3088
+ skipReason: "not a Pi Coding Agent session (no session header)",
3089
+ idArg: "piId",
3090
+ toolCallIdPrefix: "pi",
3091
+ // 标题:活动路径上最后一个 session_info.name
3092
+ titleOf: (item) => item.type === "session_info" && typeof item.name === "string" && item.name.trim() ? item.name.trim() : void 0,
3093
+ // 模型切换条目:pi 写 modelId
3094
+ modelOf: (item) => item.type === "model_change" && typeof item.modelId === "string" && item.modelId ? item.modelId : null,
3095
+ // 压缩边界:pi 的 compaction 条目(retainedTail 为现代格式的保留窗口)
3096
+ compactOf: (item) => {
3097
+ if (!item || item.type !== "compaction") return null;
3098
+ return {
3099
+ summary: item.summary,
3100
+ ...typeof item.firstKeptEntryId === "string" ? { firstKeptEntryId: item.firstKeptEntryId } : {},
3101
+ ...Array.isArray(item.retainedTail) ? { retainedTail: item.retainedTail } : {}
3102
+ };
3103
+ },
3104
+ honorsResetBoundary: false,
3105
+ renderSummary: {
3106
+ compaction: (s) => PI_COMPACTION_SUMMARY_PREFIX + s + PI_SUMMARY_SUFFIX,
3107
+ branch: (s) => PI_BRANCH_SUMMARY_PREFIX + s + PI_SUMMARY_SUFFIX
3108
+ }
3109
+ };
3110
+ function convertPiJsonl(raw, args = {}) {
3111
+ return convertPiFamilyJsonl(raw, args, PI_PROFILE);
3112
+ }
2996
3113
 
2997
- // .codex-tmp/vendor-pagination-upstream/lib/convert/opencode.mjs
3114
+ // .codex-tmp/chat-import-0263/package/lib/convert/omp.mjs
3115
+ var OMP_COMPACTION_PREFIX = "Prior model work/tool state available.\nMUST build on prior work; NEVER duplicate prior work.\n\n<summary>\n";
3116
+ var OMP_BRANCH_PREFIX = "Branch-return summary:\n\n<summary>\n";
3117
+ var OMP_SUMMARY_SUFFIX = "\n</summary>";
3118
+ var OMP_HANDOFF_PREFIX = 'Context replaced. The <handoff> below is a handoff document a prior instance of you wrote from the full conversation. It is your own working memory, not user input.\n- First person inside it refers to you (the prior instance).\n- "Next Steps" is your own resumed plan; re-check it against the latest user message before acting.\n- The handoff already exists and is complete: NEVER write another handoff document unless the user explicitly asks.\nMUST build on prior work; NEVER duplicate prior work.\n\n<handoff>\n';
3119
+ var OMP_HANDOFF_SUFFIX = "\n</handoff>";
3120
+ function ompTitleSlot(recs) {
3121
+ const slot = recs.find((r) => r && typeof r === "object" && r.type === "title" && r.v === 1 && typeof r.title === "string");
3122
+ return slot && slot.title.trim() ? slot.title.trim() : void 0;
3123
+ }
3124
+ var OMP_PROFILE = {
3125
+ provider: "oh-my-pi",
3126
+ skipReason: "not an oh-my-pi session (no session header)",
3127
+ idArg: "ompId",
3128
+ toolCallIdPrefix: "omp",
3129
+ // 标题:定宽标题槽(源侧列表用的就是它)> header.title(旧文件无槽)
3130
+ initialTitle: (header, recs) => ompTitleSlot(recs) || (typeof header.title === "string" && header.title.trim() ? header.title.trim() : void 0),
3131
+ // 活动路径上的改名审计条目:取最后一个(标题槽缺席时的兜底)
3132
+ titleOf: (item) => item.type === "title_change" && typeof item.title === "string" && item.title.trim() ? item.title.trim() : void 0,
3133
+ // 模型切换条目:omp 写 model("provider/modelId")
3134
+ modelOf: (item) => item.type === "model_change" && typeof item.model === "string" && item.model ? item.model : null,
3135
+ // 压缩边界:firstKeptEntryId 指定保留窗口起点(omp 没有 pi 的 retainedTail)
3136
+ compactOf: (item) => {
3137
+ if (!item || item.type !== "compaction") return null;
3138
+ return {
3139
+ summary: item.summary,
3140
+ ...typeof item.firstKeptEntryId === "string" ? { firstKeptEntryId: item.firstKeptEntryId } : {}
3141
+ };
3142
+ },
3143
+ honorsResetBoundary: true,
3144
+ renderSummary: {
3145
+ compaction: (s) => OMP_COMPACTION_PREFIX + s + OMP_SUMMARY_SUFFIX,
3146
+ branch: (s) => OMP_BRANCH_PREFIX + s + OMP_SUMMARY_SUFFIX,
3147
+ handoff: (s) => OMP_HANDOFF_PREFIX + s + OMP_HANDOFF_SUFFIX
3148
+ }
3149
+ };
3150
+ function convertOmpJsonl(raw, args = {}) {
3151
+ return convertPiFamilyJsonl(raw, args, OMP_PROFILE);
3152
+ }
3153
+
3154
+ // .codex-tmp/chat-import-0263/package/lib/convert/opencode.mjs
2998
3155
  var OPENCODE_TOOL_ALIASES = {
2999
3156
  websearch: "web_search",
3000
3157
  webfetch: "web_fetch",
@@ -3155,17 +3312,17 @@ function opencodeSessionModel(chat) {
3155
3312
  return void 0;
3156
3313
  }
3157
3314
 
3158
- // .codex-tmp/vendor-pagination-upstream/lib/convert/mimocode.mjs
3315
+ // .codex-tmp/chat-import-0263/package/lib/convert/mimocode.mjs
3159
3316
  function convertMimocodeJson(raw, args = {}) {
3160
3317
  return convertOpencodeJson(raw, { ...args, provider: "mimocode" });
3161
3318
  }
3162
3319
 
3163
- // .codex-tmp/vendor-pagination-upstream/lib/convert/teleagent.mjs
3320
+ // .codex-tmp/chat-import-0263/package/lib/convert/teleagent.mjs
3164
3321
  function convertTeleagentJson(raw, args = {}) {
3165
3322
  return convertOpencodeJson(raw, { ...args, provider: "teleagent" });
3166
3323
  }
3167
3324
 
3168
- // .codex-tmp/vendor-pagination-upstream/lib/convert/trae.mjs
3325
+ // .codex-tmp/chat-import-0263/package/lib/convert/trae.mjs
3169
3326
  var MESSAGE_TEXT_KEYS = ["content", "text", "message", "body", "prompt", "response", "output", "result"];
3170
3327
  var SESSION_MESSAGE_KEYS = ["messages", "chatMessages", "history", "messageList", "entries"];
3171
3328
  var SESSION_ID_KEYS = ["sessionId", "id", "uuid", "session_id"];
@@ -3311,12 +3468,12 @@ function convertTraeJson(raw, args = {}) {
3311
3468
  return convertOpencodeSession(session, { ...args, provider: "trae" });
3312
3469
  }
3313
3470
 
3314
- // .codex-tmp/vendor-pagination-upstream/lib/convert/kilocode.mjs
3471
+ // .codex-tmp/chat-import-0263/package/lib/convert/kilocode.mjs
3315
3472
  function convertKilocodeJson(raw, args = {}) {
3316
3473
  return convertOpencodeJson(raw, { ...args, provider: "kilocode" });
3317
3474
  }
3318
3475
 
3319
- // .codex-tmp/vendor-pagination-upstream/lib/convert/zcode.mjs
3476
+ // .codex-tmp/chat-import-0263/package/lib/convert/zcode.mjs
3320
3477
  function convertZcodeJson(raw, args = {}) {
3321
3478
  let chat;
3322
3479
  try {
@@ -3436,7 +3593,7 @@ function zcodeMessageModel(msg) {
3436
3593
  return void 0;
3437
3594
  }
3438
3595
 
3439
- // .codex-tmp/vendor-pagination-upstream/lib/convert/grokbuild.mjs
3596
+ // .codex-tmp/chat-import-0263/package/lib/convert/grokbuild.mjs
3440
3597
  function firstValidTime(...values) {
3441
3598
  for (const v of values) {
3442
3599
  if (v === void 0 || v === null || v === "") continue;
@@ -3734,7 +3891,7 @@ function convertGrokbuildJson(summaryJsonText, chatHistoryText, args = {}) {
3734
3891
  });
3735
3892
  }
3736
3893
 
3737
- // .codex-tmp/vendor-pagination-upstream/lib/convert/openclaw.mjs
3894
+ // .codex-tmp/chat-import-0263/package/lib/convert/openclaw.mjs
3738
3895
  function stripMessageIdSuffix(text) {
3739
3896
  const pos = text.lastIndexOf("\n[message_id:");
3740
3897
  return pos === -1 ? text : text.slice(0, pos).trimEnd();
@@ -3912,10 +4069,35 @@ function convertOpenclawJson(raw, args = {}) {
3912
4069
  }, { title: finalTitle, droppedToolResults });
3913
4070
  }
3914
4071
 
3915
- // .codex-tmp/vendor-pagination-upstream/lib/convert/hermes.mjs
4072
+ // .codex-tmp/chat-import-0263/package/lib/convert/hermes.mjs
3916
4073
  function parseHermesTime(value) {
3917
4074
  return parseTimeMs(value, { truncSeconds: true }) ?? void 0;
3918
4075
  }
4076
+ function normalizeHermesToolCalls(raw) {
4077
+ let arr = raw;
4078
+ if (raw === null || raw === void 0) return void 0;
4079
+ if (typeof raw === "string") {
4080
+ const trimmed = raw.trim();
4081
+ if (!trimmed) return void 0;
4082
+ try {
4083
+ arr = JSON.parse(trimmed);
4084
+ } catch {
4085
+ return void 0;
4086
+ }
4087
+ }
4088
+ if (!Array.isArray(arr) || arr.length === 0) return void 0;
4089
+ const out = [];
4090
+ for (const t of arr) {
4091
+ if (!t || typeof t !== "object") continue;
4092
+ const fn = t.function && typeof t.function === "object" && !Array.isArray(t.function) ? t.function : null;
4093
+ const id = typeof t.id === "string" ? t.id : typeof t.tool_call_id === "string" ? t.tool_call_id : void 0;
4094
+ const name = typeof t.name === "string" ? t.name : typeof t.tool_name === "string" ? t.tool_name : fn && typeof fn.name === "string" ? fn.name : void 0;
4095
+ if (!id || !name) continue;
4096
+ const input = t.arguments ?? t.input ?? (fn ? fn.arguments : void 0);
4097
+ out.push({ id, name, input });
4098
+ }
4099
+ return out.length > 0 ? out : void 0;
4100
+ }
3919
4101
  function convertHermesJson(raw, args = {}) {
3920
4102
  let chat = null;
3921
4103
  try {
@@ -3948,8 +4130,8 @@ function convertHermesJson(raw, args = {}) {
3948
4130
  role: m.role,
3949
4131
  content: m.content,
3950
4132
  ts: m.ts,
3951
- toolCalls: m.toolCalls ?? m.tool_calls,
3952
- toolCallId: m.toolCallId ?? m.tool_call_id,
4133
+ ...Array.isArray(m.toolCalls) ? { toolCalls: m.toolCalls } : {},
4134
+ ...typeof m.toolCallId === "string" && m.toolCallId ? { toolCallId: m.toolCallId } : {},
3953
4135
  ...typeof m.reasoning === "string" && m.reasoning ? { reasoning: m.reasoning } : {}
3954
4136
  });
3955
4137
  }
@@ -3983,7 +4165,15 @@ function convertHermesJson(raw, args = {}) {
3983
4165
  }
3984
4166
  const ts = parseHermesTime(rec.timestamp ?? rec.ts ?? msg.timestamp ?? msg.ts);
3985
4167
  if (firstTs === null && ts !== void 0) firstTs = ts;
3986
- messages.push({ role, content: msg.content, ts, toolCalls: msg.toolCalls ?? msg.tool_calls, toolCallId: msg.toolCallId ?? msg.tool_call_id });
4168
+ const toolCalls = normalizeHermesToolCalls(msg.tool_calls ?? msg.toolCalls);
4169
+ const toolCallId = typeof msg.tool_call_id === "string" && msg.tool_call_id ? msg.tool_call_id : void 0;
4170
+ messages.push({
4171
+ role,
4172
+ content: msg.content,
4173
+ ts,
4174
+ ...toolCalls ? { toolCalls } : {},
4175
+ ...toolCallId ? { toolCallId } : {}
4176
+ });
3987
4177
  }
3988
4178
  if (createdAt === null) createdAt = firstTs;
3989
4179
  }
@@ -3995,10 +4185,7 @@ function convertHermesJson(raw, args = {}) {
3995
4185
  const callSteps = /* @__PURE__ */ new Map();
3996
4186
  let droppedToolResults = 0;
3997
4187
  let systemPrompt = null;
3998
- for (const message of messages) {
3999
- const m = message.role === "tool" ? { ...message, role: "user", content: [
4000
- { type: "tool_result", tool_call_id: message.toolCallId, content: message.content }
4001
- ] } : message;
4188
+ for (const m of messages) {
4002
4189
  if (m.role === "system") {
4003
4190
  if (args.importSystemPrompt === true) {
4004
4191
  const text = contentText(m.content, { types: null, trim: true });
@@ -4064,16 +4251,13 @@ function convertHermesJson(raw, args = {}) {
4064
4251
  }
4065
4252
  if (Array.isArray(m.toolCalls)) {
4066
4253
  for (const tc of m.toolCalls) {
4067
- if (!tc || typeof tc !== "object") continue;
4068
- const id = tc.id ?? tc.tool_call_id ?? tc.call_id;
4069
- const name = tc.name ?? tc.tool_name ?? tc.function?.name;
4070
- const input = tc.input ?? tc.arguments ?? tc.function?.arguments;
4071
- if (typeof id !== "string" || !id || typeof name !== "string" || !name) continue;
4254
+ if (!tc || typeof tc !== "object" || typeof tc.id !== "string" || typeof tc.name !== "string") continue;
4255
+ const rawArgs = tc.input ?? tc.arguments;
4072
4256
  const block = {
4073
4257
  type: "tool-call",
4074
- id,
4075
- name,
4076
- arguments: typeof input === "string" ? input : JSON.stringify(input ?? {})
4258
+ id: tc.id,
4259
+ name: tc.name,
4260
+ arguments: typeof rawArgs === "string" ? rawArgs : JSON.stringify(rawArgs ?? {})
4077
4261
  };
4078
4262
  step.content.push(block);
4079
4263
  step.toolCalls.push(block);
@@ -4082,6 +4266,20 @@ function convertHermesJson(raw, args = {}) {
4082
4266
  if (step.content.length === 0 && step.toolCalls.length === 0) continue;
4083
4267
  cur.steps.push(step);
4084
4268
  for (const tc of step.toolCalls) callSteps.set(tc.id, step);
4269
+ } else if (m.role === "tool") {
4270
+ const callId = typeof m.toolCallId === "string" && m.toolCallId ? m.toolCallId : typeof m.tool_call_id === "string" && m.tool_call_id ? m.tool_call_id : null;
4271
+ const step = callId !== null ? callSteps.get(callId) : void 0;
4272
+ if (!step) {
4273
+ droppedToolResults++;
4274
+ continue;
4275
+ }
4276
+ const inner = (typeof m.content === "string" ? [{ type: "text", text: m.content }] : Array.isArray(m.content) ? m.content : []).map((block) => typeof block === "string" ? { type: "text", text: block } : mapContentBlock(block)).filter(Boolean);
4277
+ step.toolResults.push({
4278
+ toolCallId: callId,
4279
+ ...typeof m.ts === "number" ? { time: m.ts } : {},
4280
+ content: inner,
4281
+ isError: m.isError === true
4282
+ });
4085
4283
  }
4086
4284
  }
4087
4285
  alignStepResults(turns);
@@ -4103,8 +4301,15 @@ function convertHermesJson(raw, args = {}) {
4103
4301
  }, { title: finalTitle, droppedToolResults });
4104
4302
  }
4105
4303
 
4106
- // .codex-tmp/vendor-pagination-upstream/lib/convert/kimi.mjs
4304
+ // .codex-tmp/chat-import-0263/package/lib/convert/kimi.mjs
4107
4305
  var kimiUserInputText = (input) => contentText(input, { types: null, sep: "", trim: true });
4306
+ function kimiPromptSource(message) {
4307
+ const origin = message && typeof message === "object" ? message.origin : null;
4308
+ const kind = origin && typeof origin === "object" && typeof origin.kind === "string" ? origin.kind : "";
4309
+ if (!kind || kind === "user") return null;
4310
+ return { kind: "plugin", plugin: "chat-import" };
4311
+ }
4312
+ var kimiProvisionalPromptSource = (text) => isSystemContextBlock(text) || isNotificationBlock(text) ? { kind: "plugin", plugin: "chat-import" } : null;
4108
4313
  function mapToolOutput(output, onMedia) {
4109
4314
  if (typeof output === "string") {
4110
4315
  const text = output.trim();
@@ -4159,6 +4364,7 @@ function convertKimiWire(raw, args = {}) {
4159
4364
  const turns = [];
4160
4365
  let cur = null;
4161
4366
  let step = null;
4367
+ let pendingPair = null;
4162
4368
  const callSteps = /* @__PURE__ */ new Map();
4163
4369
  const unresolved = [];
4164
4370
  const resolved = /* @__PURE__ */ new Set();
@@ -4205,22 +4411,34 @@ function convertKimiWire(raw, args = {}) {
4205
4411
  const prompt = kimiUserInputText(rec.input);
4206
4412
  if (!prompt) continue;
4207
4413
  cur = { prompt, steps: [] };
4414
+ const promptSource = kimiProvisionalPromptSource(prompt);
4415
+ if (promptSource) cur.promptSource = promptSource;
4208
4416
  if (recTime !== null) cur.time = recTime;
4209
4417
  turns.push(cur);
4210
4418
  step = null;
4211
- if (firstUserText === null) firstUserText = prompt;
4419
+ pendingPair = { turn: cur, prompt };
4212
4420
  } else if (type2 === "context.append_message") {
4213
4421
  const message = rec.message && typeof rec.message === "object" ? rec.message : {};
4214
4422
  if (message.role !== "user") continue;
4215
4423
  const prompt = kimiUserInputText(message.content);
4216
4424
  if (!prompt) continue;
4217
- if (cur && cur.prompt === prompt) continue;
4425
+ const promptSource = kimiPromptSource(message);
4426
+ if (pendingPair && pendingPair.turn === cur && pendingPair.prompt === prompt) {
4427
+ if (promptSource) cur.promptSource = promptSource;
4428
+ else delete cur.promptSource;
4429
+ if (!promptSource && firstUserText === null) firstUserText = prompt;
4430
+ pendingPair = null;
4431
+ continue;
4432
+ }
4433
+ if (!promptSource) pendingPair = null;
4218
4434
  cur = { prompt, steps: [] };
4435
+ if (promptSource) cur.promptSource = promptSource;
4219
4436
  if (recTime !== null) cur.time = recTime;
4220
4437
  turns.push(cur);
4221
4438
  step = null;
4222
- if (firstUserText === null) firstUserText = prompt;
4439
+ if (!promptSource && firstUserText === null) firstUserText = prompt;
4223
4440
  } else if (type2 === "context.append_loop_event") {
4441
+ pendingPair = null;
4224
4442
  const event = rec.event && typeof rec.event === "object" ? rec.event : {};
4225
4443
  const et = event.type;
4226
4444
  if (et === "step.begin") {
@@ -4289,9 +4507,11 @@ function convertKimiWire(raw, args = {}) {
4289
4507
  step = null;
4290
4508
  }
4291
4509
  } else if (type2 === "context.apply_compaction") {
4510
+ pendingPair = null;
4292
4511
  markCompactionCut(compactionSummaryText(rec), recTime);
4293
4512
  } else if (type2 === "turn.ended") {
4294
4513
  step = null;
4514
+ pendingPair = null;
4295
4515
  }
4296
4516
  continue;
4297
4517
  }
@@ -4432,7 +4652,8 @@ function convertKimiWire(raw, args = {}) {
4432
4652
  if (srcId) meta.sourceId = srcId;
4433
4653
  if (typeof args.cwd === "string" && args.cwd) meta.cwd = args.cwd;
4434
4654
  const customTitle = typeof args.title === "string" && args.title.trim() ? args.title.trim() : null;
4435
- const finalTitle = normalizeTitle(customTitle || firstUserText);
4655
+ const firstRealPrompt = firstUserText || turns.find((t) => !t.promptSource && String(t.prompt ?? "").trim())?.prompt;
4656
+ const finalTitle = normalizeTitle(customTitle || firstRealPrompt);
4436
4657
  return finishSession(turns, args.budget, {
4437
4658
  meta,
4438
4659
  title: customTitle ? finalTitle : void 0,
@@ -4441,7 +4662,10 @@ function convertKimiWire(raw, args = {}) {
4441
4662
  skipped,
4442
4663
  records: recs.length,
4443
4664
  skippedLines,
4444
- secrets
4665
+ secrets,
4666
+ // 并行工具结果在 Kimi wire 里按完成顺序落盘:按源顺序发射,模型可见消息序列
4667
+ // 才与源一致(前缀缓存),而不是被重排成 toolCalls 声明顺序。
4668
+ resultOrder: "source"
4445
4669
  }, {
4446
4670
  title: finalTitle,
4447
4671
  droppedToolResults,
@@ -4453,7 +4677,7 @@ function convertKimiWire(raw, args = {}) {
4453
4677
  });
4454
4678
  }
4455
4679
 
4456
- // .codex-tmp/vendor-pagination-upstream/lib/convert/qoder.mjs
4680
+ // .codex-tmp/chat-import-0263/package/lib/convert/qoder.mjs
4457
4681
  function toolResultCallId(block) {
4458
4682
  if (block && typeof block === "object") {
4459
4683
  if (typeof block.tool_use_id === "string" && block.tool_use_id) return block.tool_use_id;
@@ -4469,11 +4693,23 @@ function convertQoderJsonl(raw, args = {}) {
4469
4693
  let cwd = null;
4470
4694
  let createdAt = null;
4471
4695
  let model = null;
4472
- const turns = [];
4473
4696
  let cur = null;
4697
+ let shadowedTurns = 0;
4698
+ const turnQueue = createTurns();
4699
+ const turns = turnQueue.turns;
4474
4700
  const callSteps = /* @__PURE__ */ new Map();
4475
4701
  const unresolved = [];
4476
4702
  let droppedToolResults = 0;
4703
+ const setCompaction = (summary, time) => {
4704
+ shadowedTurns = shadowTurns(turns, shadowedTurns);
4705
+ cur = null;
4706
+ turnQueue.setCompaction({
4707
+ summary,
4708
+ provider: "qoder",
4709
+ ...model ? { model } : {},
4710
+ ...time !== void 0 && time !== null ? { time } : {}
4711
+ });
4712
+ };
4477
4713
  for (const rec of recs) {
4478
4714
  if (rec && typeof rec.sessionId === "string" && !sourceId) sourceId = rec.sessionId;
4479
4715
  if (rec && typeof rec.cwd === "string" && !cwd) cwd = rec.cwd;
@@ -4483,14 +4719,25 @@ function convertQoderJsonl(raw, args = {}) {
4483
4719
  if (rec && rec.type === "last-prompt" && typeof rec.lastPrompt === "string" && !lastPrompt) lastPrompt = rec.lastPrompt;
4484
4720
  const recModel = rec ? rec.message?.model ?? rec.model : void 0;
4485
4721
  if (typeof recModel === "string" && !model) model = recModel;
4722
+ if (rec && rec.type === "system" && rec.subtype === "compact_boundary") {
4723
+ const ownText = contentText(rec.message?.content, { trim: true });
4724
+ if (ownText) setCompaction(ownText, recTime);
4725
+ continue;
4726
+ }
4727
+ if (rec && rec.type === "user" && rec.isCompactSummary === true && args.fullHistory !== true) {
4728
+ const text = contentText(rec.message?.content, { trim: true });
4729
+ if (text) setCompaction(text, recTime);
4730
+ continue;
4731
+ }
4486
4732
  const userBlocks = rec && rec.type === "user" && Array.isArray(rec.message?.content) ? rec.message.content : null;
4487
4733
  const isToolResultRec = userBlocks !== null && userBlocks.some((b) => b && b.type === "tool_result");
4488
4734
  if (rec && rec.type === "user" && rec.message && (typeof rec.message.content === "string" || userBlocks !== null && !isToolResultRec)) {
4489
4735
  const prompt = contentText(rec.message.content);
4490
- cur = { prompt, steps: [] };
4491
- if (recTime !== null) cur.time = recTime;
4492
- turns.push(cur);
4493
- } else if (rec && rec.type === "assistant" && cur) {
4736
+ cur = turnQueue.open(prompt, recTime);
4737
+ } else if (rec && rec.type === "assistant" && (cur || turnQueue.hasCompaction())) {
4738
+ if (!cur) {
4739
+ cur = turnQueue.flush();
4740
+ }
4494
4741
  const step = { content: [], toolCalls: [], toolResults: [] };
4495
4742
  if (recTime !== null) step.time = recTime;
4496
4743
  if (Array.isArray(rec.message?.content)) {
@@ -4534,6 +4781,7 @@ function convertQoderJsonl(raw, args = {}) {
4534
4781
  }
4535
4782
  }
4536
4783
  }
4784
+ turnQueue.flush();
4537
4785
  const fileStem2 = typeof args.fileStem === "string" ? args.fileStem : null;
4538
4786
  if (fileStem2 && sourceId && fileStem2 !== sourceId) {
4539
4787
  return skipResult('auxiliary/subagent transcript (file "' + fileStem2 + '" does not match sessionId "' + sourceId + '"); only the main <sessionId>.jsonl becomes a session', { records: recs.length });
@@ -4556,7 +4804,7 @@ function convertQoderJsonl(raw, args = {}) {
4556
4804
  }, { title: finalTitle, droppedToolResults });
4557
4805
  }
4558
4806
 
4559
- // .codex-tmp/vendor-pagination-upstream/lib/convert/workbuddy.mjs
4807
+ // .codex-tmp/chat-import-0263/package/lib/convert/workbuddy.mjs
4560
4808
  function extractWorkbuddyUserQuery(content) {
4561
4809
  const joined = Array.isArray(content) ? contentText(content, { types: null }) : "";
4562
4810
  const m = /<user_query>([\s\S]*?)<\/user_query>/.exec(joined);
@@ -4702,7 +4950,7 @@ function workbuddyResultText(output, providerData) {
4702
4950
  return null;
4703
4951
  }
4704
4952
 
4705
- // .codex-tmp/vendor-pagination-upstream/lib/convert/qwen.mjs
4953
+ // .codex-tmp/chat-import-0263/package/lib/convert/qwen.mjs
4706
4954
  function realWorkspaceDir(directories) {
4707
4955
  if (!Array.isArray(directories)) return null;
4708
4956
  for (const d of directories) {
@@ -4814,7 +5062,7 @@ function convertQwenJsonl(raw, args = {}) {
4814
5062
  });
4815
5063
  }
4816
5064
 
4817
- // .codex-tmp/vendor-pagination-upstream/lib/convert/continue.mjs
5065
+ // .codex-tmp/chat-import-0263/package/lib/convert/continue.mjs
4818
5066
  var DEFAULT_TITLE = "New Session";
4819
5067
  var messageText2 = (content) => contentText(content, { types: null, skipEmpty: true });
4820
5068
  function toolCallArguments(fn) {
@@ -5042,7 +5290,7 @@ function readContinueIndex(raw) {
5042
5290
  return out;
5043
5291
  }
5044
5292
 
5045
- // .codex-tmp/vendor-pagination-upstream/lib/convert/cline.mjs
5293
+ // .codex-tmp/chat-import-0263/package/lib/convert/cline.mjs
5046
5294
  function clineLegacyTaskHistoryPath(globalStorageDir) {
5047
5295
  const sep = String(globalStorageDir).includes("\\") ? "\\" : "/";
5048
5296
  return String(globalStorageDir).replace(/[\\/]+$/, "") + sep + "state" + sep + "taskHistory.json";
@@ -5229,7 +5477,7 @@ function convertClineJson(raw, args = {}) {
5229
5477
  }, { title: finalTitle, droppedToolResults, droppedDuplicateCalls });
5230
5478
  }
5231
5479
 
5232
- // .codex-tmp/vendor-pagination-upstream/lib/convert/goose.mjs
5480
+ // .codex-tmp/chat-import-0263/package/lib/convert/goose.mjs
5233
5481
  function gooseDataDir(home, env = process.env, platform = process.platform) {
5234
5482
  const root = env.GOOSE_PATH_ROOT;
5235
5483
  if (root && isAbsoluteLike(root)) return joinForPlatform(platform, String(root), "data");
@@ -5400,7 +5648,7 @@ function convertGooseJson(raw, args = {}) {
5400
5648
  }, { title: finalTitle, droppedToolResults, droppedDuplicateCalls, skippedBlocks });
5401
5649
  }
5402
5650
 
5403
- // .codex-tmp/vendor-pagination-upstream/lib/convert/zed.mjs
5651
+ // .codex-tmp/chat-import-0263/package/lib/convert/zed.mjs
5404
5652
  function zedDataDir(home, env = process.env, platform = process.platform) {
5405
5653
  if (platform === "win32" && env.LOCALAPPDATA) return joinForPlatform(platform, String(env.LOCALAPPDATA), "Zed");
5406
5654
  if (platform === "darwin") return joinForPlatform(platform, String(home), "Library", "Application Support", "Zed");
@@ -5651,7 +5899,7 @@ function convertZedJson(raw, args = {}) {
5651
5899
  }, { title: finalTitle, droppedToolResults, droppedDuplicateCalls, skippedBlocks, compactionSummaries });
5652
5900
  }
5653
5901
 
5654
- // .codex-tmp/vendor-pagination-upstream/lib/convert/crush.mjs
5902
+ // .codex-tmp/chat-import-0263/package/lib/convert/crush.mjs
5655
5903
  function crushUserDataDir(home, env = process.env, platform = process.platform) {
5656
5904
  const override = env.CRUSH_GLOBAL_DATA;
5657
5905
  if (override && isAbsoluteLike(override)) return String(override);
@@ -5756,7 +6004,7 @@ function convertCrushJson(raw, args = {}) {
5756
6004
  isError: isError === true
5757
6005
  });
5758
6006
  };
5759
- const textOf = (parts) => {
6007
+ const textOf2 = (parts) => {
5760
6008
  const out = [];
5761
6009
  for (const part of Array.isArray(parts) ? parts : []) {
5762
6010
  if (!part || typeof part !== "object") continue;
@@ -5774,7 +6022,7 @@ function convertCrushJson(raw, args = {}) {
5774
6022
  if (!model && typeof msg.model === "string" && msg.model) model = msg.model;
5775
6023
  const msgTime = msg.role === "assistant" ? parseTimeMs(msg.finishedAt) ?? parseTimeMs(msg.createdAt) : parseTimeMs(msg.createdAt);
5776
6024
  if (msg.isSummaryMessage === 1 || msg.isSummaryMessage === true) {
5777
- const text = textOf(parts).join("\n").trim();
6025
+ const text = textOf2(parts).join("\n").trim();
5778
6026
  if (text) {
5779
6027
  compactionSummaries++;
5780
6028
  if (args.fullHistory === true) {
@@ -5794,7 +6042,7 @@ function convertCrushJson(raw, args = {}) {
5794
6042
  continue;
5795
6043
  }
5796
6044
  if (msg.role === "user") {
5797
- const prompt = textOf(parts).join("\n");
6045
+ const prompt = textOf2(parts).join("\n");
5798
6046
  if (prompt.trim()) openTurn(prompt, msgTime);
5799
6047
  } else if (msg.role === "assistant") {
5800
6048
  const step = openStep(msgTime);
@@ -5846,7 +6094,7 @@ function convertCrushJson(raw, args = {}) {
5846
6094
  }
5847
6095
  }
5848
6096
  } else if (msg.role === "system") {
5849
- const text = textOf(parts).join("\n\n");
6097
+ const text = textOf2(parts).join("\n\n");
5850
6098
  if (text) systemPrompt = systemPrompt ? systemPrompt + "\n\n" + text : text;
5851
6099
  }
5852
6100
  }
@@ -5877,7 +6125,7 @@ function convertCrushJson(raw, args = {}) {
5877
6125
  }, { title: finalTitle, droppedToolResults, droppedDuplicateCalls, skippedBlocks, compactionSummaries });
5878
6126
  }
5879
6127
 
5880
- // .codex-tmp/vendor-pagination-upstream/lib/convert/vibe.mjs
6128
+ // .codex-tmp/chat-import-0263/package/lib/convert/vibe.mjs
5881
6129
  function parseVibeTime(value) {
5882
6130
  return parseTimeMs(value, { truncSeconds: true }) ?? void 0;
5883
6131
  }
@@ -6102,7 +6350,202 @@ function convertVibeJson(raw, args = {}) {
6102
6350
  }, { title: finalTitle, droppedToolResults });
6103
6351
  }
6104
6352
 
6105
- // .codex-tmp/vendor-pagination-upstream/lib/convert/dsh.mjs
6353
+ // .codex-tmp/chat-import-0263/package/lib/convert/doubao.mjs
6354
+ var DOUBAO_TEXT_BLOCK = 1e4;
6355
+ var DOUBAO_PROTOCOL_KEY = "default-chat-im-protocol-store";
6356
+ var DOUBAO_LIST_SCHEMA_PREFIX = "conversation-list-data-";
6357
+ function doubaoTime(value) {
6358
+ if (typeof value === "number") return parseTimeMs(value);
6359
+ if (typeof value === "string" && value.trim()) {
6360
+ const numeric = Number(value);
6361
+ if (Number.isFinite(numeric)) return parseTimeMs(numeric);
6362
+ return parseTimeMs(value);
6363
+ }
6364
+ return null;
6365
+ }
6366
+ function textOfBlocks(blocks, stats) {
6367
+ const out = [];
6368
+ for (const block of Array.isArray(blocks) ? blocks : []) {
6369
+ if (!block || typeof block !== "object") continue;
6370
+ if (block.block_type !== DOUBAO_TEXT_BLOCK) {
6371
+ stats.skippedBlocks++;
6372
+ continue;
6373
+ }
6374
+ const text = block.content && block.content.text_block && block.content.text_block.text;
6375
+ if (typeof text === "string" && text) out.push(text);
6376
+ else stats.emptyBlocks++;
6377
+ }
6378
+ return out.join("\n");
6379
+ }
6380
+ function normalizeDoubaoTask(taskId, task, stats) {
6381
+ if (!task || typeof task !== "object") return null;
6382
+ const sync = task.requestQuery && task.requestQuery.syncTask;
6383
+ const meta = sync && sync.client_meta;
6384
+ const conversationId = meta && typeof meta.conversation_id === "string" && meta.conversation_id ? meta.conversation_id : null;
6385
+ if (!conversationId) return null;
6386
+ const prompt = textOfBlocks(
6387
+ (Array.isArray(sync.messages) ? sync.messages : []).flatMap((m) => m && Array.isArray(m.content_block) ? m.content_block : []),
6388
+ stats
6389
+ );
6390
+ const replies = [];
6391
+ let replyTime = null;
6392
+ for (const id of Object.keys(task.receivedMessages ?? {})) {
6393
+ const received = task.receivedMessages[id];
6394
+ const extra = received && received.extra;
6395
+ if (!extra) continue;
6396
+ const text = textOfBlocks(extra.content_blocks_v2, stats);
6397
+ if (text) replies.push(text);
6398
+ if (replyTime === null) replyTime = doubaoTime(extra.create_time);
6399
+ }
6400
+ const reply = replies.join("\n");
6401
+ if (!prompt && !reply) return null;
6402
+ const option = sync && sync.option;
6403
+ return {
6404
+ conversationId,
6405
+ taskId: typeof taskId === "string" ? taskId : String(taskId),
6406
+ prompt,
6407
+ reply,
6408
+ promptTime: doubaoTime(option && option.create_time_ms) ?? doubaoTime(task.createTime),
6409
+ replyTime
6410
+ };
6411
+ }
6412
+ function collectDoubaoTasks(records, stats) {
6413
+ const best = /* @__PURE__ */ new Map();
6414
+ let restarted = 0;
6415
+ for (const record of records) {
6416
+ const snapshots = Array.isArray(record && record.versions) ? record.versions : [record && record.value];
6417
+ for (const snapshot of snapshots) {
6418
+ const tasks = snapshot && snapshot.state && snapshot.state.mainTaskDataMap;
6419
+ if (!tasks || typeof tasks !== "object") continue;
6420
+ for (const [taskId, task] of Object.entries(tasks)) {
6421
+ const normalized = normalizeDoubaoTask(taskId, task, stats);
6422
+ if (!normalized) continue;
6423
+ const key = normalized.taskId;
6424
+ const prev = best.get(key);
6425
+ if (!prev) {
6426
+ best.set(key, normalized);
6427
+ continue;
6428
+ }
6429
+ if (normalized.reply.length > prev.reply.length) {
6430
+ if (prev.reply && normalized.reply && !normalized.reply.startsWith(prev.reply)) restarted++;
6431
+ best.set(key, { ...normalized, prompt: normalized.prompt || prev.prompt });
6432
+ } else if (normalized.prompt && !prev.prompt) {
6433
+ prev.prompt = normalized.prompt;
6434
+ }
6435
+ }
6436
+ }
6437
+ }
6438
+ return { turns: [...best.values()], restarted };
6439
+ }
6440
+ function collectDoubaoConversations(records) {
6441
+ const conversations = /* @__PURE__ */ new Map();
6442
+ for (const record of records) {
6443
+ const value = record && record.value;
6444
+ if (!value || typeof value !== "object") continue;
6445
+ if (typeof value.schema !== "string" || !value.schema.startsWith(DOUBAO_LIST_SCHEMA_PREFIX)) continue;
6446
+ const list = value.data && Array.isArray(value.data.conversations) ? value.data.conversations : [];
6447
+ for (const item of list) {
6448
+ if (!item || typeof item !== "object") continue;
6449
+ const id = typeof item.conversation_id === "string" && item.conversation_id ? item.conversation_id : null;
6450
+ if (!id) continue;
6451
+ const title = typeof item.name === "string" ? item.name.trim() : "";
6452
+ const createdAt = doubaoTime(item.create_time);
6453
+ const updatedAt = doubaoTime(item.update_time);
6454
+ const prev = conversations.get(id);
6455
+ if (!prev) {
6456
+ conversations.set(id, { id, title, createdAt, updatedAt });
6457
+ continue;
6458
+ }
6459
+ if (!prev.title && title) prev.title = title;
6460
+ if (prev.createdAt === null && createdAt !== null) prev.createdAt = createdAt;
6461
+ else if (createdAt !== null && prev.createdAt !== null && createdAt < prev.createdAt) prev.createdAt = createdAt;
6462
+ if (updatedAt !== null && (prev.updatedAt === null || updatedAt > prev.updatedAt)) prev.updatedAt = updatedAt;
6463
+ }
6464
+ }
6465
+ return conversations;
6466
+ }
6467
+ function extractDoubaoSessions(db) {
6468
+ const stats = { skippedBlocks: 0, emptyBlocks: 0, restarted: 0, emptyConversations: 0, orphanConversations: 0 };
6469
+ const records = Array.isArray(db && db.records) ? db.records : [];
6470
+ const conversations = collectDoubaoConversations(records);
6471
+ const protocolRecords = records.filter((r) => r && r.key === DOUBAO_PROTOCOL_KEY);
6472
+ const { turns, restarted } = collectDoubaoTasks(protocolRecords, stats);
6473
+ stats.restarted = restarted;
6474
+ const byConversation = /* @__PURE__ */ new Map();
6475
+ for (const turn of turns) {
6476
+ const list = byConversation.get(turn.conversationId) ?? [];
6477
+ list.push(turn);
6478
+ byConversation.set(turn.conversationId, list);
6479
+ }
6480
+ const sessions = [];
6481
+ for (const [conversationId, list] of byConversation) {
6482
+ const usable = list.filter((t) => t.prompt || t.reply);
6483
+ if (usable.length === 0) {
6484
+ stats.emptyConversations++;
6485
+ continue;
6486
+ }
6487
+ usable.sort((a, b) => (a.promptTime ?? a.replyTime ?? Number.MAX_SAFE_INTEGER) - (b.promptTime ?? b.replyTime ?? Number.MAX_SAFE_INTEGER));
6488
+ const meta = conversations.get(conversationId);
6489
+ if (!meta) stats.orphanConversations++;
6490
+ const times = usable.flatMap((t) => [t.promptTime, t.replyTime]).filter((t) => t !== null && t !== void 0);
6491
+ sessions.push({
6492
+ id: conversationId,
6493
+ title: meta && meta.title ? meta.title : "",
6494
+ createdAt: meta && meta.createdAt !== null ? meta.createdAt : times.length ? Math.min(...times) : null,
6495
+ updatedAt: meta && meta.updatedAt !== null ? meta.updatedAt : times.length ? Math.max(...times) : null,
6496
+ turns: usable
6497
+ });
6498
+ }
6499
+ sessions.sort((a, b) => (b.updatedAt ?? b.createdAt ?? 0) - (a.updatedAt ?? a.createdAt ?? 0));
6500
+ return { sessions, stats };
6501
+ }
6502
+ function convertDoubaoSession(session, args = {}) {
6503
+ if (!session || typeof session !== "object" || !Array.isArray(session.turns)) {
6504
+ return skipResult("not a Doubao session (no turns)", { skipped: 1 });
6505
+ }
6506
+ const sourceId = typeof session.id === "string" && session.id ? session.id : null;
6507
+ if (!sourceId) return skipResult("Doubao session without conversation id", { skipped: 1 });
6508
+ const queue = createTurns();
6509
+ const turns = queue.turns;
6510
+ let messages = 0;
6511
+ for (const turn of session.turns) {
6512
+ const prompt = typeof turn.prompt === "string" ? turn.prompt : "";
6513
+ const reply = typeof turn.reply === "string" ? turn.reply : "";
6514
+ const promptTime = turn.promptTime ?? turn.replyTime ?? null;
6515
+ if (!prompt && !reply) continue;
6516
+ const irTurn = queue.open(prompt, promptTime);
6517
+ if (reply) {
6518
+ const step = { content: [{ type: "text", text: reply }], toolCalls: [], toolResults: [] };
6519
+ const replyTime = turn.replyTime ?? turn.promptTime ?? null;
6520
+ if (replyTime !== null) step.time = replyTime;
6521
+ irTurn.steps.push(step);
6522
+ messages += 2;
6523
+ } else {
6524
+ messages += 1;
6525
+ }
6526
+ }
6527
+ dropDuplicateCalls(turns);
6528
+ if (turns.length === 0) {
6529
+ return skipResult("Doubao session has no readable content (" + sourceId + ")", { skipped: 1 });
6530
+ }
6531
+ const sessionId = args.sessionId || mintSessionId(sourceId);
6532
+ const createdAt = session.createdAt ?? session.updatedAt ?? (turns[0].time ?? Date.now());
6533
+ const meta = { version: SESSION_FORMAT_VERSION, id: sessionId, createdAt };
6534
+ meta.sourceId = sourceId;
6535
+ if (typeof args.cwd === "string" && args.cwd) meta.cwd = args.cwd;
6536
+ const explicit = typeof session.title === "string" ? session.title.trim() : "";
6537
+ const finalTitle = normalizeTitle(explicit || turns[0].prompt);
6538
+ return finishSession(turns, args.budget, {
6539
+ meta,
6540
+ title: explicit ? finalTitle : void 0,
6541
+ provider: "doubao",
6542
+ model: null,
6543
+ skipped: 0,
6544
+ records: session.turns.length
6545
+ }, { title: finalTitle, messages });
6546
+ }
6547
+
6548
+ // .codex-tmp/chat-import-0263/package/lib/convert/dsh.mjs
6106
6549
  var DURABLE = /* @__PURE__ */ new Set([
6107
6550
  "turn/start",
6108
6551
  "step/start",
@@ -6402,86 +6845,615 @@ function convertDshJsonl(raw, args = {}) {
6402
6845
  };
6403
6846
  }
6404
6847
 
6405
- // .codex-tmp/vendor-pagination-upstream/lib/convert/generic.mjs
6406
- var INTERCHANGE_MARKER = "dsh-chat-import";
6407
- var INTERCHANGE_VERSION = 1;
6408
- var MARKER_RE = /"(interchange|bundle)"\s*:\s*"dsh-chat-import"/;
6409
- function sniffInterchangeMarker(raw) {
6410
- if (typeof raw !== "string") return null;
6411
- const m = MARKER_RE.exec(raw.slice(0, 65536));
6412
- if (!m) return null;
6413
- return m[1] === "bundle" ? "bundle" : "generic";
6848
+ // .codex-tmp/chat-import-0263/package/lib/convert/copilot-vscode.mjs
6849
+ import { fileURLToPath } from "node:url";
6850
+ function readCopilotVscodeSession(raw) {
6851
+ let session;
6852
+ try {
6853
+ session = JSON.parse(raw);
6854
+ } catch {
6855
+ return null;
6856
+ }
6857
+ return session && session.version === 3 && typeof session.sessionId === "string" && session.sessionId.trim() && Array.isArray(session.requests) ? session : null;
6414
6858
  }
6415
- function sanitizeBlocks(input, collectToolResults = false) {
6416
- const blocks = [];
6417
- const toolResults = [];
6418
- let skipped = 0;
6419
- let imagesDegraded = 0;
6420
- for (const b of Array.isArray(input) ? input : []) {
6421
- if (!b || typeof b !== "object") {
6422
- skipped += 1;
6423
- continue;
6424
- }
6425
- if (b.type === "text" && typeof b.text === "string") {
6426
- blocks.push({ type: "text", text: b.text });
6427
- continue;
6428
- }
6429
- if (b.type === "reasoning" && typeof b.text === "string") {
6430
- blocks.push({ type: "reasoning", text: b.text });
6431
- continue;
6432
- }
6433
- if (b.type === "image") {
6434
- const mapped = imageBlockFromSource(b);
6435
- if (mapped) blocks.push(mapped);
6436
- else {
6437
- blocks.push({ type: "text", text: IMAGE_PLACEHOLDER });
6438
- imagesDegraded += 1;
6439
- }
6440
- continue;
6441
- }
6442
- if (b.type === "tool-call" && typeof b.id === "string" && b.id && typeof b.name === "string" && b.name) {
6443
- const args = typeof b.arguments === "string" ? b.arguments : b.arguments === void 0 || b.arguments === null ? "{}" : JSON.stringify(b.arguments);
6444
- blocks.push({ type: "tool-call", id: b.id, name: b.name, arguments: args });
6445
- continue;
6446
- }
6447
- if (b.type === "tool-result") {
6448
- if (!collectToolResults || typeof b.toolCallId !== "string" || !b.toolCallId) {
6449
- skipped += 1;
6450
- continue;
6451
- }
6452
- const inner = sanitizeBlocks(b.content);
6453
- skipped += inner.skipped;
6454
- imagesDegraded += inner.imagesDegraded;
6455
- toolResults.push({ toolCallId: b.toolCallId, content: inner.blocks, isError: b.isError === true });
6456
- continue;
6859
+ function copilotVscodeCwd(value) {
6860
+ if (typeof value !== "string" || !value) return null;
6861
+ if (isAbsoluteLike(value)) return value;
6862
+ try {
6863
+ const uri = new URL(value);
6864
+ if (uri.protocol !== "file:") return null;
6865
+ const windows = /^\/[a-z]:/i.test(decodeURIComponent(uri.pathname)) || !!(uri.hostname && uri.hostname !== "localhost");
6866
+ return fileURLToPath(uri, { windows });
6867
+ } catch {
6868
+ return null;
6869
+ }
6870
+ }
6871
+ function promptText(message) {
6872
+ if (typeof message === "string") return message;
6873
+ if (!message || typeof message !== "object") return "";
6874
+ return typeof message.text === "string" ? message.text : contentText(message.parts, { types: null, sep: "", skipEmpty: true });
6875
+ }
6876
+ function copilotVscodeMetadata(session) {
6877
+ const times = [];
6878
+ for (const request of session.requests) {
6879
+ if (!request || typeof request !== "object") continue;
6880
+ times.push(request.timestamp, request.responseTimestamp);
6881
+ for (const part of Array.isArray(request.response) ? request.response : []) {
6882
+ if (part && typeof part === "object") times.push(part.startedAt, part.completedAt);
6457
6883
  }
6458
- skipped += 1;
6459
6884
  }
6460
- return { blocks, toolResults, skipped, imagesDegraded };
6885
+ const valid = [session.creationDate, session.lastMessageDate, ...times].map((v) => parseTimeMs(v)).filter((v) => v !== null);
6886
+ return {
6887
+ id: session.sessionId,
6888
+ title: normalizeTitle(typeof session.customTitle === "string" && session.customTitle.trim() ? session.customTitle : promptText(session.requests.find((r) => r?.message)?.message)),
6889
+ cwd: copilotVscodeCwd(session.workingDirectory),
6890
+ createdAt: parseTimeMs(session.creationDate) ?? valid[0],
6891
+ lastActiveAt: valid.length ? valid.reduce((latest, time) => Math.max(latest, time)) : void 0
6892
+ };
6461
6893
  }
6462
- function convertGenericJson(raw, args = {}) {
6463
- let doc = raw;
6464
- if (typeof raw === "string") {
6894
+ var UI_PARTS = /* @__PURE__ */ new Set([
6895
+ "inlineReference",
6896
+ "codeblockUri",
6897
+ "undoStop",
6898
+ "textEditGroup",
6899
+ "notebookEditGroup",
6900
+ "mcpServersStarting",
6901
+ "mcpServersStartingSerialized",
6902
+ "progressMessage",
6903
+ "progressTask",
6904
+ "progressTaskSerialized",
6905
+ "reference",
6906
+ "treeData",
6907
+ "confirmation",
6908
+ "codeCitation",
6909
+ "autoModeResolution",
6910
+ "hook",
6911
+ "warning",
6912
+ "info",
6913
+ "toolResources"
6914
+ ]);
6915
+ var savedText = (value) => typeof value === "string" ? value : value && typeof value.value === "string" ? value.value : "";
6916
+ var callIdOf = (part) => typeof part.toolCallId === "string" ? part.toolCallId : typeof part.id === "string" ? part.id : "";
6917
+ function toolInput(part, prepared) {
6918
+ const data = part.toolSpecificData || prepared?.toolSpecificData;
6919
+ if (data && data.kind === "input" && data.rawInput !== void 0) return JSON.stringify(data.rawInput);
6920
+ if (typeof part.resultDetails?.input === "string") {
6465
6921
  try {
6466
- doc = JSON.parse(raw);
6467
- } catch (err2) {
6468
- return skipResult("generic: \u6587\u6863\u4E0D\u662F\u5408\u6CD5 JSON\uFF08" + sanitizeParseError(err2) + "\uFF09");
6922
+ return JSON.stringify(JSON.parse(part.resultDetails.input));
6923
+ } catch {
6924
+ return JSON.stringify(part.resultDetails.input);
6469
6925
  }
6470
6926
  }
6471
- if (!doc || typeof doc !== "object" || Array.isArray(doc)) return skipResult("generic: \u9876\u5C42\u4E0D\u662F\u5BF9\u8C61");
6472
- if (doc.bundle === INTERCHANGE_MARKER) {
6473
- return skipResult('generic: \u8FD9\u662F .dshbundle \u4FBF\u643A\u5305\uFF08"bundle" \u6807\u8BB0\uFF09\uFF0C\u8BF7\u7528 restore_bundle \u8FD8\u539F');
6927
+ return null;
6928
+ }
6929
+ function toolOutput(part, counts) {
6930
+ const details = part.resultDetails;
6931
+ if (typeof details?.output === "string") {
6932
+ return details.output ? [{ type: "text", text: details.output }] : [];
6474
6933
  }
6475
- if (doc.interchange !== void 0 && doc.interchange !== INTERCHANGE_MARKER) {
6476
- return skipResult("generic: \u672A\u77E5\u5185\u5BB9\u6807\u8BB0 interchange=" + JSON.stringify(doc.interchange));
6934
+ if (Array.isArray(details?.output)) {
6935
+ const content = [];
6936
+ for (const item of details.output) {
6937
+ if (item?.type === "embed" && item.isText === true && typeof item.value === "string") {
6938
+ if (item.value) content.push({ type: "text", text: item.value });
6939
+ } else {
6940
+ counts.droppedToolResultBlocks++;
6941
+ }
6942
+ }
6943
+ return content;
6477
6944
  }
6478
- if (doc.interchange === INTERCHANGE_MARKER && Number(doc.version) !== INTERCHANGE_VERSION) {
6479
- return skipResult("generic: \u4E0D\u652F\u6301\u7684 interchange \u7248\u672C " + JSON.stringify(doc.version) + "\uFF08\u672C\u63D2\u4EF6\u53EA\u8BA4 v" + INTERCHANGE_VERSION + "\uFF09");
6945
+ const terminal = part.toolSpecificData?.terminalCommandOutput;
6946
+ if (terminal && typeof terminal.text === "string") {
6947
+ return terminal.text ? [{ type: "text", text: terminal.text }] : [];
6480
6948
  }
6481
- let malformedTurns = 0;
6482
- let malformedSteps = 0;
6483
- let skippedBlocks = 0;
6484
- let imagesDegraded = 0;
6949
+ return null;
6950
+ }
6951
+ function convertCopilotVscodeJson(raw, args = {}) {
6952
+ const session = readCopilotVscodeSession(raw);
6953
+ if (!session) return skipResult("not a Copilot VS Code v3 session", { skipped: 1 });
6954
+ const info = copilotVscodeMetadata(session);
6955
+ const queue = createTurns();
6956
+ const counts = {
6957
+ metaMessages: 0,
6958
+ droppedMalformedOutputs: 0,
6959
+ droppedToolResultBlocks: 0,
6960
+ missingToolInputs: 0,
6961
+ missingToolOutputs: 0
6962
+ };
6963
+ let skipped = 0;
6964
+ let model = null;
6965
+ for (const request of session.requests) {
6966
+ if (!request || typeof request !== "object" || request.message === null || request.message === void 0) {
6967
+ skipped++;
6968
+ continue;
6969
+ }
6970
+ const turn = queue.open(promptText(request.message), parseTimeMs(request.timestamp));
6971
+ let step = null;
6972
+ const parts = Array.isArray(request.response) ? request.response : [];
6973
+ if (request.response !== null && request.response !== void 0 && !Array.isArray(request.response)) counts.droppedMalformedOutputs++;
6974
+ const prepared = /* @__PURE__ */ new Map();
6975
+ const lastCall = /* @__PURE__ */ new Map();
6976
+ for (const part of parts) {
6977
+ if (!part || typeof part !== "object") continue;
6978
+ if (part.kind === "prepareToolInvocation") prepared.set(callIdOf(part), part);
6979
+ if (part.kind === "toolInvocationSerialized") lastCall.set(callIdOf(part), part);
6980
+ }
6981
+ const newStep = (time) => {
6982
+ step = { content: [], toolCalls: [], toolResults: [] };
6983
+ const stamp = parseTimeMs(time ?? request.responseTimestamp);
6984
+ if (stamp !== null) step.time = stamp;
6985
+ if (typeof request.modelId === "string" && request.modelId) step.model = model = request.modelId;
6986
+ turn.steps.push(step);
6987
+ return step;
6988
+ };
6989
+ const text = (type, value, time) => {
6990
+ if (!value) return;
6991
+ if (!step || step.toolCalls.length) newStep(time);
6992
+ const previous = step.content.at(-1);
6993
+ if (previous?.type === type) previous.text += value;
6994
+ else step.content.push({ type, text: value });
6995
+ };
6996
+ for (const part of parts) {
6997
+ if (typeof part === "string") {
6998
+ text("text", part);
6999
+ continue;
7000
+ }
7001
+ if (!part || typeof part !== "object") {
7002
+ counts.droppedMalformedOutputs++;
7003
+ continue;
7004
+ }
7005
+ if (!part.kind || part.kind === "markdownContent" || part.kind === "markdownVuln") {
7006
+ const payload = part.kind ? part.content : part;
7007
+ const value = savedText(payload);
7008
+ if (value) text("text", value);
7009
+ else if (!(typeof payload === "string" || typeof payload?.value === "string")) counts.droppedMalformedOutputs++;
7010
+ } else if (part.kind === "thinking") {
7011
+ const value = typeof part.value === "string" ? part.value : Array.isArray(part.value) ? part.value.filter((v) => typeof v === "string").join("\n") : "";
7012
+ text("reasoning", value, part.reasoningStartedAt);
7013
+ } else if (part.kind === "toolInvocationSerialized") {
7014
+ const id = callIdOf(part);
7015
+ if (!id || typeof part.toolId !== "string" || !part.toolId) {
7016
+ counts.droppedMalformedOutputs++;
7017
+ continue;
7018
+ }
7019
+ if (lastCall.get(id) !== part) {
7020
+ counts.metaMessages++;
7021
+ continue;
7022
+ }
7023
+ const input = toolInput(part, prepared.get(id));
7024
+ if (input === null) {
7025
+ counts.missingToolInputs++;
7026
+ const command = part.toolSpecificData?.commandLine;
7027
+ text("text", command ? JSON.stringify(command) : savedText(part.invocationMessage), part.startedAt);
7028
+ }
7029
+ if (!step) newStep(part.startedAt);
7030
+ const call = { id, name: part.toolId, arguments: input ?? "{}" };
7031
+ step.content.push({ type: "tool-call", ...call });
7032
+ step.toolCalls.push(call);
7033
+ const output = toolOutput(part, counts);
7034
+ if (output === null) counts.missingToolOutputs++;
7035
+ step.toolResults.push({
7036
+ toolCallId: id,
7037
+ content: output ?? [],
7038
+ isError: !!(part.resultError || part.resultDetails?.isError),
7039
+ ...parseTimeMs(part.completedAt) !== null ? { time: parseTimeMs(part.completedAt) } : {}
7040
+ });
7041
+ } else if (part.kind === "prepareToolInvocation" || UI_PARTS.has(part.kind)) {
7042
+ counts.metaMessages++;
7043
+ } else {
7044
+ counts.droppedMalformedOutputs++;
7045
+ }
7046
+ }
7047
+ if (step && request.promptTokens !== void 0 && request.completionTokens !== void 0) {
7048
+ step.usage = { inputTokens: request.promptTokens, outputTokens: request.completionTokens };
7049
+ }
7050
+ if (!turn.prompt.trim() && !turn.steps.length) queue.turns.pop();
7051
+ }
7052
+ if (!queue.turns.length) return skipResult("Copilot session has no conversation", { records: session.requests.length, skipped: skipped || 1 });
7053
+ counts.metaMessages += dropDuplicateCalls(queue.turns);
7054
+ const meta = {
7055
+ version: SESSION_FORMAT_VERSION,
7056
+ id: args.sessionId || mintSessionId(info.id),
7057
+ sourceId: info.id,
7058
+ createdAt: args.createdAt ?? info.createdAt ?? Date.now()
7059
+ };
7060
+ if (info.cwd || args.cwd) meta.cwd = info.cwd || args.cwd;
7061
+ const explicitTitle = typeof session.customTitle === "string" && session.customTitle.trim();
7062
+ return finishSession(queue.turns, args.budget, {
7063
+ meta,
7064
+ title: explicitTitle ? info.title : void 0,
7065
+ provider: "copilot-vscode",
7066
+ model,
7067
+ skipped,
7068
+ records: session.requests.length
7069
+ }, { title: info.title, ...counts });
7070
+ }
7071
+
7072
+ // .codex-tmp/chat-import-0263/package/lib/convert/copilot-cli.mjs
7073
+ var META_EVENT_TYPES = /* @__PURE__ */ new Set([
7074
+ "system.message",
7075
+ "assistant.turn_start",
7076
+ "assistant.turn_end",
7077
+ "session.task_complete",
7078
+ "session.plan_changed",
7079
+ "session.mode_changed",
7080
+ "session.resume",
7081
+ "session.error",
7082
+ "session.info",
7083
+ "session.usage_record",
7084
+ "session.usage_checkpoint",
7085
+ "session.context_changed",
7086
+ "session.compaction_start",
7087
+ "session.shutdown"
7088
+ ]);
7089
+ var META_EVENT_PREFIXES = ["hook.", "permission.", "model.", "subagent.", "skill."];
7090
+ function messageBody(content) {
7091
+ if (typeof content === "string") return content;
7092
+ if (content === null || content === void 0) return "";
7093
+ return contentText(content, { types: null, skipEmpty: true });
7094
+ }
7095
+ function toolArguments(value) {
7096
+ if (typeof value === "string") return value;
7097
+ if (value === null || value === void 0) return "{}";
7098
+ try {
7099
+ return JSON.stringify(value);
7100
+ } catch {
7101
+ return "{}";
7102
+ }
7103
+ }
7104
+ function toolResultContent2(result, counts) {
7105
+ if (!result || typeof result !== "object") return { content: [], malformed: 0 };
7106
+ const raw = result.content !== void 0 ? result.content : result.detailedContent;
7107
+ if (typeof raw === "string") return { content: raw ? [{ type: "text", text: raw }] : [], malformed: 0 };
7108
+ if (Array.isArray(raw)) {
7109
+ const content = [];
7110
+ let malformed = 0;
7111
+ for (const block of raw) {
7112
+ if (block && typeof block === "object" && typeof block.text === "string") {
7113
+ if (block.text) content.push({ type: "text", text: block.text });
7114
+ } else {
7115
+ malformed++;
7116
+ }
7117
+ }
7118
+ return { content, malformed };
7119
+ }
7120
+ if (raw === null || raw === void 0) return { content: [], malformed: 0 };
7121
+ counts.droppedMalformedOutputs++;
7122
+ return { content: [], malformed: 0 };
7123
+ }
7124
+ function reasoningTextOf(data, counts) {
7125
+ if (typeof data.reasoningText === "string" && data.reasoningText.trim()) return data.reasoningText;
7126
+ if (!Array.isArray(data.reasoningBlocks)) {
7127
+ if (data.reasoningBlocks !== null && data.reasoningBlocks !== void 0) counts.droppedMalformedOutputs++;
7128
+ return "";
7129
+ }
7130
+ const parts = [];
7131
+ for (const block of data.reasoningBlocks) {
7132
+ if (block && typeof block === "object" && typeof block.text === "string" && block.text) {
7133
+ parts.push(block.text);
7134
+ } else if (block) {
7135
+ counts.droppedMalformedOutputs++;
7136
+ }
7137
+ }
7138
+ return parts.join("\n");
7139
+ }
7140
+ function convertCopilotCliJsonl(raw, args = {}) {
7141
+ const { recs, skipped, skippedLines, secrets } = parseJsonlLines(raw, { requireObject: true });
7142
+ const counts = {
7143
+ metaMessages: 0,
7144
+ unknownEvents: 0,
7145
+ droppedAttachments: 0,
7146
+ droppedMalformedOutputs: 0,
7147
+ missingToolOutputs: 0,
7148
+ unannouncedToolCalls: 0,
7149
+ orphanResults: 0
7150
+ };
7151
+ let sourceId = null;
7152
+ let cwd = null;
7153
+ let createdAt = null;
7154
+ let model = null;
7155
+ let currentModel = null;
7156
+ let titleTopic = null;
7157
+ const callSteps = /* @__PURE__ */ new Map();
7158
+ const turnQueue = createTurns();
7159
+ const turns = turnQueue.turns;
7160
+ let shadowedTurns = 0;
7161
+ let cur = null;
7162
+ let lastStep = null;
7163
+ const openTurn = (prompt, time) => {
7164
+ cur = turnQueue.open(prompt, time);
7165
+ lastStep = null;
7166
+ };
7167
+ const openStep = (time) => {
7168
+ const step = { content: [], toolCalls: [], toolResults: [] };
7169
+ if (time !== null && time !== void 0) step.time = time;
7170
+ if (currentModel) step.model = currentModel;
7171
+ cur.steps.push(step);
7172
+ lastStep = step;
7173
+ return step;
7174
+ };
7175
+ const markCompaction = (text, time) => {
7176
+ shadowedTurns = shadowTurns(turns, shadowedTurns);
7177
+ cur = null;
7178
+ lastStep = null;
7179
+ turnQueue.setCompaction({
7180
+ summary: text,
7181
+ provider: "copilot-cli",
7182
+ model: model || void 0,
7183
+ ...time !== null && time !== void 0 ? { time } : {}
7184
+ });
7185
+ };
7186
+ for (const rec of recs) {
7187
+ const type = rec && typeof rec.type === "string" ? rec.type : null;
7188
+ const data = rec && rec.data && typeof rec.data === "object" ? rec.data : null;
7189
+ const recTime = parseTimeMs(rec && rec.timestamp);
7190
+ if (!type) {
7191
+ counts.unknownEvents++;
7192
+ continue;
7193
+ }
7194
+ if (type === "session.start") {
7195
+ if (data) {
7196
+ if (!sourceId && typeof data.sessionId === "string" && data.sessionId) sourceId = data.sessionId;
7197
+ if (!cwd && typeof data.context?.cwd === "string" && data.context.cwd) cwd = data.context.cwd;
7198
+ if (createdAt === null) createdAt = parseTime(rec.timestamp ?? data.startTime);
7199
+ if (!model && typeof data.selectedModel === "string" && data.selectedModel) model = data.selectedModel;
7200
+ }
7201
+ counts.metaMessages++;
7202
+ continue;
7203
+ }
7204
+ if (type === "session.model_change") {
7205
+ if (data && typeof data.newModel === "string" && data.newModel) {
7206
+ if (!model) model = data.newModel;
7207
+ currentModel = data.newModel;
7208
+ }
7209
+ counts.metaMessages++;
7210
+ continue;
7211
+ }
7212
+ if (type === "session.compaction_complete") {
7213
+ const text = args.fullHistory === true || !data || typeof data.summaryContent !== "string" ? "" : data.summaryContent.trim();
7214
+ if (text) markCompaction(text, recTime);
7215
+ else counts.metaMessages++;
7216
+ continue;
7217
+ }
7218
+ if (type === "user.message") {
7219
+ const prompt = data ? messageBody(data.content) : "";
7220
+ if (Array.isArray(data?.attachments) && data.attachments.length) counts.droppedAttachments++;
7221
+ if (!prompt.trim()) {
7222
+ counts.metaMessages++;
7223
+ continue;
7224
+ }
7225
+ if (titleTopic === null) titleTopic = prompt;
7226
+ openTurn(prompt, recTime);
7227
+ continue;
7228
+ }
7229
+ if (type === "assistant.message") {
7230
+ if (!cur) {
7231
+ if (!turnQueue.hasCompaction()) {
7232
+ counts.metaMessages++;
7233
+ continue;
7234
+ }
7235
+ openTurn("", recTime);
7236
+ }
7237
+ const step = openStep(recTime);
7238
+ const reasoning = data ? reasoningTextOf(data, counts) : "";
7239
+ if (reasoning) step.content.push({ type: "reasoning", text: reasoning });
7240
+ const body = data ? messageBody(data.content) : "";
7241
+ if (body) step.content.push({ type: "text", text: body });
7242
+ const requests = data && Array.isArray(data.toolRequests) ? data.toolRequests : [];
7243
+ for (const request of requests) {
7244
+ if (!request || typeof request !== "object") {
7245
+ counts.droppedMalformedOutputs++;
7246
+ continue;
7247
+ }
7248
+ const id = typeof request.toolCallId === "string" ? request.toolCallId : "";
7249
+ if (!id) {
7250
+ counts.droppedMalformedOutputs++;
7251
+ continue;
7252
+ }
7253
+ const mapped = {
7254
+ id,
7255
+ name: typeof request.name === "string" && request.name ? request.name : "unknown",
7256
+ arguments: toolArguments(request.arguments)
7257
+ };
7258
+ step.content.push({ type: "tool-call", ...mapped });
7259
+ step.toolCalls.push(mapped);
7260
+ callSteps.set(id, step);
7261
+ }
7262
+ if (!step.content.length) {
7263
+ cur.steps.pop();
7264
+ if (lastStep === step) lastStep = null;
7265
+ }
7266
+ continue;
7267
+ }
7268
+ if (type === "tool.execution_start") {
7269
+ if (!data || typeof data.toolCallId !== "string" || !data.toolCallId) {
7270
+ counts.droppedMalformedOutputs++;
7271
+ continue;
7272
+ }
7273
+ if (callSteps.has(data.toolCallId)) {
7274
+ counts.metaMessages++;
7275
+ continue;
7276
+ }
7277
+ if (!cur) {
7278
+ if (turnQueue.hasCompaction()) openTurn("", recTime);
7279
+ else {
7280
+ counts.orphanResults++;
7281
+ continue;
7282
+ }
7283
+ }
7284
+ counts.unannouncedToolCalls++;
7285
+ const step = lastStep || openStep(recTime);
7286
+ const mapped = {
7287
+ id: data.toolCallId,
7288
+ name: typeof data.toolName === "string" && data.toolName ? data.toolName : "unknown",
7289
+ arguments: toolArguments(data.arguments)
7290
+ };
7291
+ step.content.push({ type: "tool-call", ...mapped });
7292
+ step.toolCalls.push(mapped);
7293
+ callSteps.set(data.toolCallId, step);
7294
+ continue;
7295
+ }
7296
+ if (type === "tool.execution_complete") {
7297
+ if (!data || typeof data.toolCallId !== "string" || !data.toolCallId) {
7298
+ counts.droppedMalformedOutputs++;
7299
+ continue;
7300
+ }
7301
+ let step = callSteps.get(data.toolCallId);
7302
+ if (!step) {
7303
+ if (!cur) {
7304
+ counts.orphanResults++;
7305
+ continue;
7306
+ }
7307
+ counts.orphanResults++;
7308
+ step = lastStep || openStep(recTime);
7309
+ }
7310
+ const { content, malformed } = toolResultContent2(data.result, counts);
7311
+ counts.droppedMalformedOutputs += malformed;
7312
+ if (!content.length) {
7313
+ const errorText = data.error && typeof data.error === "object" && typeof data.error.message === "string" ? data.error.message.trim() : "";
7314
+ if (errorText) content.push({ type: "text", text: errorText });
7315
+ }
7316
+ if (!content.length) counts.missingToolOutputs++;
7317
+ step.toolResults.push({
7318
+ toolCallId: data.toolCallId,
7319
+ ...recTime !== null ? { time: recTime } : {},
7320
+ content,
7321
+ isError: data.success === false || !!(data.error && typeof data.error === "object")
7322
+ });
7323
+ continue;
7324
+ }
7325
+ if (type === "abort") {
7326
+ if (cur) cur.aborted = true;
7327
+ counts.metaMessages++;
7328
+ continue;
7329
+ }
7330
+ if (META_EVENT_TYPES.has(type) || META_EVENT_PREFIXES.some((p) => type.startsWith(p))) {
7331
+ counts.metaMessages++;
7332
+ } else {
7333
+ counts.unknownEvents++;
7334
+ }
7335
+ }
7336
+ turnQueue.flush();
7337
+ if (!turns.length) {
7338
+ return skipResult("Copilot session has no conversation", {
7339
+ records: recs.length,
7340
+ skipped,
7341
+ skippedLines,
7342
+ secrets
7343
+ });
7344
+ }
7345
+ if (!recs.some((r) => r && r.type === "session.start")) {
7346
+ return skipResult("Not a Copilot CLI event stream (no session.start)", {
7347
+ records: recs.length,
7348
+ skipped,
7349
+ skippedLines,
7350
+ secrets
7351
+ });
7352
+ }
7353
+ counts.metaMessages += dropDuplicateCalls(turns);
7354
+ if (!sourceId && recs.length && typeof recs[0].id === "string" && recs[0].id) sourceId = recs[0].id;
7355
+ const meta = {
7356
+ version: SESSION_FORMAT_VERSION,
7357
+ id: args.sessionId || mintSessionId(sourceId),
7358
+ createdAt: args.createdAt ?? createdAt ?? Date.now()
7359
+ };
7360
+ if (sourceId) meta.sourceId = sourceId;
7361
+ if (cwd || args.cwd) meta.cwd = cwd || args.cwd;
7362
+ const finalTitle = normalizeTitle(titleTopic || (turns.length > 0 ? turns[0].prompt : ""));
7363
+ return finishSession(turns, args.budget, {
7364
+ meta,
7365
+ provider: "copilot-cli",
7366
+ model,
7367
+ skipped,
7368
+ records: recs.length,
7369
+ skippedLines,
7370
+ secrets
7371
+ }, {
7372
+ title: finalTitle,
7373
+ ...counts
7374
+ });
7375
+ }
7376
+
7377
+ // .codex-tmp/chat-import-0263/package/lib/convert/generic.mjs
7378
+ var INTERCHANGE_MARKER = "dsh-chat-import";
7379
+ var INTERCHANGE_VERSION = 1;
7380
+ var MARKER_RE = /"(interchange|bundle)"\s*:\s*"dsh-chat-import"/;
7381
+ function sniffInterchangeMarker(raw) {
7382
+ if (typeof raw !== "string") return null;
7383
+ const m = MARKER_RE.exec(raw.slice(0, 65536));
7384
+ if (!m) return null;
7385
+ return m[1] === "bundle" ? "bundle" : "generic";
7386
+ }
7387
+ function sanitizeBlocks(input, collectToolResults = false) {
7388
+ const blocks = [];
7389
+ const toolResults = [];
7390
+ let skipped = 0;
7391
+ let imagesDegraded = 0;
7392
+ for (const b of Array.isArray(input) ? input : []) {
7393
+ if (!b || typeof b !== "object") {
7394
+ skipped += 1;
7395
+ continue;
7396
+ }
7397
+ if (b.type === "text" && typeof b.text === "string") {
7398
+ blocks.push({ type: "text", text: b.text });
7399
+ continue;
7400
+ }
7401
+ if (b.type === "reasoning" && typeof b.text === "string") {
7402
+ blocks.push({ type: "reasoning", text: b.text });
7403
+ continue;
7404
+ }
7405
+ if (b.type === "image") {
7406
+ const mapped = imageBlockFromSource(b);
7407
+ if (mapped) blocks.push(mapped);
7408
+ else {
7409
+ blocks.push({ type: "text", text: IMAGE_PLACEHOLDER });
7410
+ imagesDegraded += 1;
7411
+ }
7412
+ continue;
7413
+ }
7414
+ if (b.type === "tool-call" && typeof b.id === "string" && b.id && typeof b.name === "string" && b.name) {
7415
+ const args = typeof b.arguments === "string" ? b.arguments : b.arguments === void 0 || b.arguments === null ? "{}" : JSON.stringify(b.arguments);
7416
+ blocks.push({ type: "tool-call", id: b.id, name: b.name, arguments: args });
7417
+ continue;
7418
+ }
7419
+ if (b.type === "tool-result") {
7420
+ if (!collectToolResults || typeof b.toolCallId !== "string" || !b.toolCallId) {
7421
+ skipped += 1;
7422
+ continue;
7423
+ }
7424
+ const inner = sanitizeBlocks(b.content);
7425
+ skipped += inner.skipped;
7426
+ imagesDegraded += inner.imagesDegraded;
7427
+ toolResults.push({ toolCallId: b.toolCallId, content: inner.blocks, isError: b.isError === true });
7428
+ continue;
7429
+ }
7430
+ skipped += 1;
7431
+ }
7432
+ return { blocks, toolResults, skipped, imagesDegraded };
7433
+ }
7434
+ function convertGenericJson(raw, args = {}) {
7435
+ let doc = raw;
7436
+ if (typeof raw === "string") {
7437
+ try {
7438
+ doc = JSON.parse(raw);
7439
+ } catch (err2) {
7440
+ return skipResult("generic: \u6587\u6863\u4E0D\u662F\u5408\u6CD5 JSON\uFF08" + sanitizeParseError(err2) + "\uFF09");
7441
+ }
7442
+ }
7443
+ if (!doc || typeof doc !== "object" || Array.isArray(doc)) return skipResult("generic: \u9876\u5C42\u4E0D\u662F\u5BF9\u8C61");
7444
+ if (doc.bundle === INTERCHANGE_MARKER) {
7445
+ return skipResult('generic: \u8FD9\u662F .dshbundle \u4FBF\u643A\u5305\uFF08"bundle" \u6807\u8BB0\uFF09\uFF0C\u8BF7\u7528 restore_bundle \u8FD8\u539F');
7446
+ }
7447
+ if (doc.interchange !== void 0 && doc.interchange !== INTERCHANGE_MARKER) {
7448
+ return skipResult("generic: \u672A\u77E5\u5185\u5BB9\u6807\u8BB0 interchange=" + JSON.stringify(doc.interchange));
7449
+ }
7450
+ if (doc.interchange === INTERCHANGE_MARKER && Number(doc.version) !== INTERCHANGE_VERSION) {
7451
+ return skipResult("generic: \u4E0D\u652F\u6301\u7684 interchange \u7248\u672C " + JSON.stringify(doc.version) + "\uFF08\u672C\u63D2\u4EF6\u53EA\u8BA4 v" + INTERCHANGE_VERSION + "\uFF09");
7452
+ }
7453
+ let malformedTurns = 0;
7454
+ let malformedSteps = 0;
7455
+ let skippedBlocks = 0;
7456
+ let imagesDegraded = 0;
6485
7457
  let droppedToolResults = 0;
6486
7458
  let usageDropped = 0;
6487
7459
  const turns = [];
@@ -6611,8 +7583,8 @@ function convertGenericJson(raw, args = {}) {
6611
7583
  }, { title, malformedTurns, malformedSteps, skippedBlocks, imagesDegraded, droppedToolResults, usageDropped });
6612
7584
  }
6613
7585
 
6614
- // .codex-tmp/vendor-pagination-upstream/lib/convert/local-jsonl.mjs
6615
- var LOCAL_JSONL_FORMATS = ["dsh", "claude", "codex", "cursor", "reasonix", "pi", "openclaw", "hermes", "qoder", "vibe", "generic"];
7586
+ // .codex-tmp/chat-import-0263/package/lib/convert/local-jsonl.mjs
7587
+ var LOCAL_JSONL_FORMATS = ["dsh", "claude", "codex", "cursor", "reasonix", "pi", "openclaw", "hermes", "qoder", "vibe", "generic", "copilot-vscode", "copilot-cli"];
6616
7588
  var CONVERTERS = {
6617
7589
  dsh: convertDshJsonl,
6618
7590
  claude: convertClaudeJsonl,
@@ -6624,10 +7596,14 @@ var CONVERTERS = {
6624
7596
  hermes: convertHermesJson,
6625
7597
  qoder: convertQoderJsonl,
6626
7598
  vibe: convertVibeJson,
6627
- generic: convertGenericJson
7599
+ generic: convertGenericJson,
7600
+ "copilot-vscode": convertCopilotVscodeJson,
7601
+ "copilot-cli": convertCopilotCliJsonl
6628
7602
  };
6629
7603
  function pathPriority(sourcePath) {
6630
7604
  const lower = String(sourcePath || "").toLowerCase();
7605
+ if (/[\\/]chatsessions[\\/][^\\/]+\.json$/.test(lower)) return ["copilot-vscode"];
7606
+ if (/(^|[\\/])session-state[\\/][^\\/]+[\\/]events\.jsonl$/.test(lower)) return ["copilot-cli"];
6631
7607
  if (/[\\/]session\.jsonl(\.zstd)?$/.test(lower)) return ["dsh"];
6632
7608
  if (/\bagent-transcripts\b/.test(lower)) return ["cursor"];
6633
7609
  if (/(^|[\\/])rollout-/.test(lower)) return ["codex"];
@@ -6636,7 +7612,7 @@ function pathPriority(sourcePath) {
6636
7612
  if (/\bagents\b.*\bsessions\b/.test(lower)) return ["openclaw"];
6637
7613
  if (/\.hermes[\\/]/.test(lower)) return ["hermes"];
6638
7614
  if (/\.claude[\\/]/.test(lower)) return ["claude"];
6639
- if (/\.qoder[\\/]projects[\\/]/.test(lower)) return ["qoder"];
7615
+ if (/\.qoder(?:-cn)?[\\/]projects[\\/]/.test(lower)) return ["qoder"];
6640
7616
  if (/(\.vibe[\\/]logs[\\/]session|messages\.jsonl$)/.test(lower)) return ["vibe"];
6641
7617
  return LOCAL_JSONL_FORMATS;
6642
7618
  }
@@ -6715,7 +7691,7 @@ function convertLocalJsonl(raw, args = {}) {
6715
7691
  };
6716
7692
  }
6717
7693
 
6718
- // .codex-tmp/vendor-pagination-upstream/lib/sources/vibe.mjs
7694
+ // .codex-tmp/chat-import-0263/package/lib/sources/vibe.mjs
6719
7695
  import { join as join3 } from "node:path";
6720
7696
 
6721
7697
  // vendor/chat-import-reader/conversation-content.mjs
@@ -6848,10 +7824,10 @@ function structuredContent(out) {
6848
7824
  };
6849
7825
  }
6850
7826
 
6851
- // .codex-tmp/vendor-pagination-upstream/lib/import-core.mjs
7827
+ // .codex-tmp/chat-import-0263/package/lib/import-core.mjs
6852
7828
  import { isAbsolute, join as join2 } from "node:path";
6853
7829
 
6854
- // .codex-tmp/vendor-pagination-upstream/lib/budget.mjs
7830
+ // .codex-tmp/chat-import-0263/package/lib/budget.mjs
6855
7831
  function markTrimmedSource(out, args) {
6856
7832
  if (out && out.trimmed && typeof args.budgetSource === "string") {
6857
7833
  out.trimmed = { ...out.trimmed, source: args.budgetSource };
@@ -6859,16 +7835,16 @@ function markTrimmedSource(out, args) {
6859
7835
  return out;
6860
7836
  }
6861
7837
 
6862
- // .codex-tmp/vendor-pagination-upstream/lib/ignore.mjs
7838
+ // .codex-tmp/chat-import-0263/package/lib/ignore.mjs
6863
7839
  var IGNORE_VERSION = 1;
6864
- var IGNORE_REASONS = Object.freeze(["archived", "retracted", "workspace-deleted"]);
7840
+ var IGNORE_REASONS = Object.freeze(["archived", "retracted", "workspace-deleted", "hidden"]);
6865
7841
  function emptyIgnores() {
6866
7842
  return { version: IGNORE_VERSION, sources: {}, workspaces: {} };
6867
7843
  }
6868
7844
  var lastIgnoreSnapshot = emptyIgnores();
6869
7845
  var writeChain = Promise.resolve();
6870
7846
 
6871
- // .codex-tmp/vendor-pagination-upstream/lib/cwd-map.mjs
7847
+ // .codex-tmp/chat-import-0263/package/lib/cwd-map.mjs
6872
7848
  import { homedir } from "node:os";
6873
7849
  import { join } from "node:path";
6874
7850
  import { readFile, readdir } from "node:fs/promises";
@@ -7042,7 +8018,57 @@ async function resolveCursorSlugPath(ctx, slug) {
7042
8018
  return greedyDecodeCursorSlugPath(ctx, slug);
7043
8019
  }
7044
8020
 
7045
- // .codex-tmp/vendor-pagination-upstream/lib/import-batch.mjs
8021
+ // .codex-tmp/chat-import-0263/package/lib/preview-sample.mjs
8022
+ var PREVIEW_SAMPLE_LIMIT = 200;
8023
+ var PREVIEW_TEXT_MAX = 4e3;
8024
+ var textOf = (content) => {
8025
+ if (typeof content === "string") return content;
8026
+ if (!Array.isArray(content)) return "";
8027
+ return content.filter((p) => p && p.type === "text" && typeof p.text === "string").map((p) => p.text).join("\n");
8028
+ };
8029
+ var injected = (data, message) => {
8030
+ const source = message && message.source || data && data.source;
8031
+ return !!source && source.kind === "plugin";
8032
+ };
8033
+ var clip = (text, max) => text.length > max ? text.slice(0, max) + " \u2026" : text;
8034
+ function previewSample(events, { limit = PREVIEW_SAMPLE_LIMIT, textMax = PREVIEW_TEXT_MAX } = {}) {
8035
+ const messages = [];
8036
+ let total = 0;
8037
+ let tools = null;
8038
+ const flushTools = () => {
8039
+ if (!tools) return;
8040
+ const parts = [...tools.counts].map(([name, n]) => n > 1 ? name + " \xD7" + n : name);
8041
+ messages.push({ role: "tool", text: parts.join(", "), ...tools.time ? { time: tools.time } : {} });
8042
+ tools = null;
8043
+ };
8044
+ for (const e of Array.isArray(events) ? events : []) {
8045
+ if (!e || typeof e.type !== "string") continue;
8046
+ const data = e.data || {};
8047
+ if (e.type === "tool/call") {
8048
+ const name = typeof data.name === "string" && data.name ? data.name : "tool";
8049
+ if (!tools) tools = { counts: /* @__PURE__ */ new Map(), time: e.time };
8050
+ tools.counts.set(name, (tools.counts.get(name) || 0) + 1);
8051
+ continue;
8052
+ }
8053
+ if (e.type !== "user/message" && e.type !== "assistant/message") continue;
8054
+ const message = e.type === "assistant/message" ? data.message : data;
8055
+ if (!message || injected(data, message)) continue;
8056
+ const text = textOf(message.content).trim();
8057
+ if (!text) continue;
8058
+ flushTools();
8059
+ total++;
8060
+ if (messages.length >= limit) continue;
8061
+ messages.push({
8062
+ role: e.type === "user/message" ? "user" : "assistant",
8063
+ text: clip(text, textMax),
8064
+ ...typeof e.time === "number" ? { time: e.time } : {}
8065
+ });
8066
+ }
8067
+ if (messages.length < limit) flushTools();
8068
+ return { messages: messages.slice(0, limit), total, truncated: total > messages.filter((m) => m.role !== "tool").length };
8069
+ }
8070
+
8071
+ // .codex-tmp/chat-import-0263/package/lib/import-batch.mjs
7046
8072
  async function collectFiles(ctx, dirTarget, out, recursive, accept) {
7047
8073
  for (const entry of await ctx.fs.listDir(dirTarget)) {
7048
8074
  if (entry.type === "directory") {
@@ -7075,7 +8101,7 @@ function failedItem(path, err2) {
7075
8101
  return { path, status: "failed", error: String(err2 && err2.message || err2) };
7076
8102
  }
7077
8103
 
7078
- // .codex-tmp/vendor-pagination-upstream/lib/host-session.mjs
8104
+ // .codex-tmp/chat-import-0263/package/lib/host-session.mjs
7079
8105
  var SYSTEM_PROMPT_PLUGIN = "@deepseek-ai/dsh-system-prompt";
7080
8106
  var RENAMED_PRODUCERS = {
7081
8107
  compact: "compact-checkpoint",
@@ -7085,10 +8111,10 @@ var RENAMED_PRODUCERS = {
7085
8111
  [SYSTEM_PROMPT_PLUGIN]: "runtime-context"
7086
8112
  };
7087
8113
 
7088
- // .codex-tmp/vendor-pagination-upstream/lib/imports.mjs
8114
+ // .codex-tmp/chat-import-0263/package/lib/imports.mjs
7089
8115
  var writeChain2 = Promise.resolve();
7090
8116
 
7091
- // .codex-tmp/vendor-pagination-upstream/lib/import-state.mjs
8117
+ // .codex-tmp/chat-import-0263/package/lib/import-state.mjs
7092
8118
  function sessionSelection(args) {
7093
8119
  return Array.isArray(args.sessionIds) && args.sessionIds.length > 0 ? args.sessionIds : null;
7094
8120
  }
@@ -7102,7 +8128,7 @@ function combineStats(stats) {
7102
8128
  return { type: "file", size, version: versions.join("|") };
7103
8129
  }
7104
8130
 
7105
- // .codex-tmp/vendor-pagination-upstream/lib/sourced-title.mjs
8131
+ // .codex-tmp/chat-import-0263/package/lib/sourced-title.mjs
7106
8132
  var SOURCE_LABEL_BY_KEY = {
7107
8133
  "claude-code": "Claude",
7108
8134
  claude: "Claude",
@@ -7120,14 +8146,20 @@ var SOURCE_LABEL_BY_KEY = {
7120
8146
  grokbuild: "Grok",
7121
8147
  openclaw: "OpenClaw",
7122
8148
  pi: "Pi",
8149
+ omp: "omp",
8150
+ // 事件里的 provider 名(转换器写入)→ 同一个短标签
8151
+ "oh-my-pi": "omp",
7123
8152
  hermes: "Hermes",
7124
8153
  kimi: "Kimi",
7125
8154
  qoder: "Qoder",
7126
8155
  workbuddy: "WorkBuddy",
7127
8156
  trae: "Trae Work",
8157
+ doubao: "Doubao",
7128
8158
  vibe: "Mistral Vibe",
7129
8159
  qwen: "\u5343\u95EE\u529E\u516C",
7130
8160
  continue: "Continue",
8161
+ "copilot-vscode": "Copilot VS Code",
8162
+ "copilot-cli": "Copilot CLI",
7131
8163
  cline: "Cline",
7132
8164
  goose: "Goose",
7133
8165
  zed: "Zed",
@@ -7210,7 +8242,7 @@ function pinSourcedSessionTitle(converted, sourceLabel) {
7210
8242
  return converted;
7211
8243
  }
7212
8244
 
7213
- // .codex-tmp/vendor-pagination-upstream/lib/import-core.mjs
8245
+ // .codex-tmp/chat-import-0263/package/lib/import-core.mjs
7214
8246
  var CWD_TRAILING_SEP = /[\\/]+$/;
7215
8247
  var CWD_LEADING_SEP = /^[\\/]+/;
7216
8248
  function cwdRemapRules(args) {
@@ -7245,6 +8277,7 @@ function applyCwdRemap(out, args) {
7245
8277
  }
7246
8278
  return out;
7247
8279
  }
8280
+ var DESTINATION_FINGERPRINT_KEYS = Object.freeze(["workspaceMode", "workspaceDir", "restamp"]);
7248
8281
  function finalizeConvertedSession(out, args, sourceLabel) {
7249
8282
  const label = sourceLabel || args.sourceLabel || sourceLabelFromImportedEvents(out.events);
7250
8283
  if (label && out.turns && out.turns.length > 0) pinSourcedSessionTitle(out, label);
@@ -7271,10 +8304,16 @@ function previewEntry(out, args = {}) {
7271
8304
  if (out.meta && typeof out.meta.cwd === "string" && out.meta.cwd) entry.cwd = out.meta.cwd;
7272
8305
  if (out.meta && typeof out.meta.createdAt === "number") entry.createdAt = out.meta.createdAt;
7273
8306
  if (out.skipReason) entry.skipReason = out.skipReason;
8307
+ for (const key of ["missingToolInputs", "missingToolOutputs", "droppedToolResultBlocks"]) {
8308
+ if (out[key] > 0) entry[key] = out[key];
8309
+ }
7274
8310
  if (typeof out.detectedFormat === "string" && out.detectedFormat) entry.detectedFormat = out.detectedFormat;
7275
8311
  if (typeof out.detectedBy === "string" && out.detectedBy) entry.detectedBy = out.detectedBy;
7276
8312
  if (Array.isArray(out.failures) && out.failures.length > 0) entry.failures = out.failures;
7277
8313
  if (out.bundle === true) entry.bundle = true;
8314
+ if (args && Number.isFinite(args.previewSample) && args.previewSample > 0) {
8315
+ entry.sample = previewSample(out.events, { limit: Math.trunc(args.previewSample) });
8316
+ }
7278
8317
  if (args[READ_CONTENT]) entry.conversation = conversationContent(out, args[READ_CONTENT]);
7279
8318
  return entry;
7280
8319
  }
@@ -7323,7 +8362,7 @@ function previewSessionSet(sessions, { path, args, wanted, convertOne, sourceLab
7323
8362
  return results;
7324
8363
  }
7325
8364
 
7326
- // .codex-tmp/vendor-pagination-upstream/lib/sources/vibe.mjs
8365
+ // .codex-tmp/chat-import-0263/package/lib/sources/vibe.mjs
7327
8366
  var VIBE_SESSION_FILE = "messages.jsonl";
7328
8367
  var VIBE_META_FILE = "meta.json";
7329
8368
  function vibeUserDataDirs(home) {
@@ -7399,7 +8438,7 @@ async function previewVibeDirectory(ctx, dirTarget, args) {
7399
8438
  return previewEach(ctx, sessions, (target) => previewVibeSession(ctx, target, args));
7400
8439
  }
7401
8440
 
7402
- // .codex-tmp/vendor-pagination-upstream/lib/sources/sqlite.mjs
8441
+ // .codex-tmp/chat-import-0263/package/lib/sources/sqlite.mjs
7403
8442
  import { join as join4 } from "node:path";
7404
8443
  var DatabaseSync = null;
7405
8444
  function loadDatabaseSync() {
@@ -7474,7 +8513,7 @@ async function locateDbInDirectory(ctx, dirTarget, candidates, fallback = candid
7474
8513
  return ctx.fs.resolve(join4(dirPath, ...fallback));
7475
8514
  }
7476
8515
 
7477
- // .codex-tmp/vendor-pagination-upstream/lib/sources/goose.mjs
8516
+ // .codex-tmp/chat-import-0263/package/lib/sources/goose.mjs
7478
8517
  function gooseTextTime(v) {
7479
8518
  if (typeof v !== "string" || !v) return null;
7480
8519
  const iso = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(v) ? v.replace(" ", "T") + "Z" : v;
@@ -7603,10 +8642,10 @@ async function previewGooseDirectory(ctx, dirTarget, args) {
7603
8642
  return previewGooseFile(ctx, await resolveDbInDirectory(ctx, dirTarget, "sessions.db"), args);
7604
8643
  }
7605
8644
 
7606
- // .codex-tmp/vendor-pagination-upstream/lib/sources/zed.mjs
8645
+ // .codex-tmp/chat-import-0263/package/lib/sources/zed.mjs
7607
8646
  import { Buffer as Buffer2 } from "node:buffer";
7608
8647
 
7609
- // .codex-tmp/vendor-pagination-upstream/node_modules/fzstd/esm/index.mjs
8648
+ // .codex-tmp/chat-import-0263/package/node_modules/fzstd/esm/index.mjs
7610
8649
  var ab = ArrayBuffer;
7611
8650
  var u8 = Uint8Array;
7612
8651
  var u16 = Uint16Array;
@@ -8227,7 +9266,7 @@ function decompress(dat, buf) {
8227
9266
  return cct(bufs, ol);
8228
9267
  }
8229
9268
 
8230
- // .codex-tmp/vendor-pagination-upstream/lib/sources/zed.mjs
9269
+ // .codex-tmp/chat-import-0263/package/lib/sources/zed.mjs
8231
9270
  function zedRows(db) {
8232
9271
  const tables = tableNames(db);
8233
9272
  if (tables.size !== 1 || !tables.has("threads")) return null;
@@ -8317,7 +9356,7 @@ async function previewZedDirectory(ctx, dirTarget, args) {
8317
9356
  return previewZedFile(ctx, await locateDbInDirectory(ctx, dirTarget, ZED_DB_CANDIDATES), args);
8318
9357
  }
8319
9358
 
8320
- // .codex-tmp/vendor-pagination-upstream/lib/sources/codex.mjs
9359
+ // .codex-tmp/chat-import-0263/package/lib/sources/codex.mjs
8321
9360
  function codexThreadIdFromName(name) {
8322
9361
  const m = String(name).match(/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/);
8323
9362
  return m ? m[0] : void 0;
@@ -8563,7 +9602,7 @@ async function collectAllRollouts(ctx, dirPath) {
8563
9602
  return out;
8564
9603
  }
8565
9604
 
8566
- // .codex-tmp/vendor-pagination-upstream/lib/sources/crush.mjs
9605
+ // .codex-tmp/chat-import-0263/package/lib/sources/crush.mjs
8567
9606
  import { dirname } from "node:path";
8568
9607
  import { homedir as homedir2 } from "node:os";
8569
9608
  function crushRows(db) {
@@ -8677,7 +9716,7 @@ async function previewCrushDirectory(ctx, dirTarget, args) {
8677
9716
  return previewCrushFile(ctx, await locateDbInDirectory(ctx, dirTarget, CRUSH_DB_CANDIDATES, ["crush.db"]), args);
8678
9717
  }
8679
9718
 
8680
- // .codex-tmp/vendor-pagination-upstream/lib/sources/opencode.mjs
9719
+ // .codex-tmp/chat-import-0263/package/lib/sources/opencode.mjs
8681
9720
  function readOpencodeDb(dbPath, options = {}) {
8682
9721
  return withReadOnlyDb(dbPath, (db) => {
8683
9722
  const generation = opencodeSchemaGeneration(db);
@@ -8896,7 +9935,7 @@ async function previewOpencodeDirectory(ctx, dirTarget, args, options = {}) {
8896
9935
  return previewOpencodeFile(ctx, await resolveDbInDirectory(ctx, dirTarget, "opencode.db"), args, options);
8897
9936
  }
8898
9937
 
8899
- // .codex-tmp/vendor-pagination-upstream/lib/sources/mimocode.mjs
9938
+ // .codex-tmp/chat-import-0263/package/lib/sources/mimocode.mjs
8900
9939
  var MIMOCODE_DB_NAME = "mimocode.db";
8901
9940
  var MIMOCODE_BG_TITLE = /^(checkpoint[-_ ]?writer|auto[-_ ]?(dream|distill))\b/i;
8902
9941
  var MIMOCODE_BG_AGENTS = /* @__PURE__ */ new Set(["checkpoint-writer", "dream", "distill"]);
@@ -8929,7 +9968,7 @@ async function previewMimocodeDirectory(ctx, dirTarget, args) {
8929
9968
  return previewMimocodeFile(ctx, await resolveDbInDirectory(ctx, dirTarget, MIMOCODE_DB_NAME), args);
8930
9969
  }
8931
9970
 
8932
- // .codex-tmp/vendor-pagination-upstream/lib/sources/teleagent.mjs
9971
+ // .codex-tmp/chat-import-0263/package/lib/sources/teleagent.mjs
8933
9972
  var TELEAGENT_DB_NAME = "teleagent.db";
8934
9973
  var TELEAGENT_OPTIONS = { convert: convertTeleagentJson, sourceLabel: "teleagent", importFormat: "teleagent" };
8935
9974
  async function previewTeleagentFile(ctx, target, args) {
@@ -8939,7 +9978,7 @@ async function previewTeleagentDirectory(ctx, dirTarget, args) {
8939
9978
  return previewTeleagentFile(ctx, await resolveDbInDirectory(ctx, dirTarget, TELEAGENT_DB_NAME), args);
8940
9979
  }
8941
9980
 
8942
- // .codex-tmp/vendor-pagination-upstream/lib/sources/kilocode.mjs
9981
+ // .codex-tmp/chat-import-0263/package/lib/sources/kilocode.mjs
8943
9982
  var KILOCODE_DB_NAME = "kilo.db";
8944
9983
  function readKilocodeDb(dbPath, options = {}) {
8945
9984
  const skipIds = readOptionalDb(dbPath, (db) => {
@@ -8963,7 +10002,7 @@ async function previewKilocodeDirectory(ctx, dirTarget, args) {
8963
10002
  return previewKilocodeFile(ctx, await resolveDbInDirectory(ctx, dirTarget, KILOCODE_DB_NAME), args);
8964
10003
  }
8965
10004
 
8966
- // .codex-tmp/vendor-pagination-upstream/lib/sources/zcode.mjs
10005
+ // .codex-tmp/chat-import-0263/package/lib/sources/zcode.mjs
8967
10006
  import { homedir as homedir3 } from "node:os";
8968
10007
  import { basename, dirname as dirname2, join as join5 } from "node:path";
8969
10008
  import { existsSync, readFileSync } from "node:fs";
@@ -9216,7 +10255,7 @@ async function previewZcodeDirectory(ctx, dirTarget, args) {
9216
10255
  return previewZcodeFile(ctx, await resolveDbInDirectory(ctx, dirTarget, "db.sqlite"), args);
9217
10256
  }
9218
10257
 
9219
- // .codex-tmp/vendor-pagination-upstream/lib/sources/trae.mjs
10258
+ // .codex-tmp/chat-import-0263/package/lib/sources/trae.mjs
9220
10259
  import { join as join6 } from "node:path";
9221
10260
  import { TextDecoder } from "node:util";
9222
10261
  var TRAE_DB_NAME = "state.vscdb";
@@ -9227,6 +10266,10 @@ var TRAE_FALLBACK_KEYS = [
9227
10266
  "memento/icube-ai-chat-storage-7467774676505887760",
9228
10267
  "memento/icube-ai-ng-chat-storage-7467774676505887760"
9229
10268
  ];
10269
+ var TRAE_KEY_LIKE = [
10270
+ "%icube-ai-chat-storage-%",
10271
+ "%icube-ai-ng-chat-storage-%"
10272
+ ];
9230
10273
  function decodeSqlValue(value) {
9231
10274
  if (typeof value === "string") return value;
9232
10275
  if (value instanceof Uint8Array) return new TextDecoder().decode(value);
@@ -9254,6 +10297,12 @@ function sessionRows(db) {
9254
10297
  }
9255
10298
  const statement = db.prepare("SELECT value FROM ItemTable WHERE key = ?");
9256
10299
  const keys = [TRAE_STORAGE_KEY, ...TRAE_FALLBACK_KEYS];
10300
+ const family = db.prepare(
10301
+ "SELECT key FROM ItemTable WHERE " + TRAE_KEY_LIKE.map(() => "key LIKE ?").join(" OR ")
10302
+ );
10303
+ for (const row of family.all(...TRAE_KEY_LIKE)) {
10304
+ if (typeof row?.key === "string" && !keys.includes(row.key)) keys.push(row.key);
10305
+ }
9257
10306
  const seen = /* @__PURE__ */ new Set();
9258
10307
  const sessions = [];
9259
10308
  let entries = 0;
@@ -9373,8 +10422,739 @@ async function previewTraeDirectory(ctx, dirTarget, args) {
9373
10422
  return { total, results };
9374
10423
  }
9375
10424
 
9376
- // .codex-tmp/vendor-pagination-upstream/lib/sources/cline.mjs
9377
- import { dirname as dirname3, join as join7 } from "node:path";
10425
+ // .codex-tmp/chat-import-0263/package/lib/sources/doubao.mjs
10426
+ import { join as join8 } from "node:path";
10427
+
10428
+ // .codex-tmp/chat-import-0263/package/lib/sources/chromium-indexeddb.mjs
10429
+ import { lstatSync } from "node:fs";
10430
+ import { readFileSync as readFileSync2, readdirSync, statSync } from "node:fs";
10431
+ import { join as join7 } from "node:path";
10432
+ var BLOCK_SIZE = 32768;
10433
+ var SNAPPY_MAX_OUTPUT = 512 * 1024 * 1024;
10434
+ var CRC_TABLE = (() => {
10435
+ const table = new Uint32Array(256);
10436
+ for (let i = 0; i < 256; i++) {
10437
+ let c = i;
10438
+ for (let k = 0; k < 8; k++) c = c & 1 ? 2197175160 ^ c >>> 1 : c >>> 1;
10439
+ table[i] = c >>> 0;
10440
+ }
10441
+ return table;
10442
+ })();
10443
+ function crc32c(buf) {
10444
+ let c = 4294967295;
10445
+ for (let i = 0; i < buf.length; i++) c = CRC_TABLE[(c ^ buf[i]) & 255] ^ c >>> 8;
10446
+ return (c ^ 4294967295) >>> 0;
10447
+ }
10448
+ function unmaskCrc(masked) {
10449
+ const rot = masked - 2726488792 >>> 0;
10450
+ return (rot >>> 17 | rot << 15) >>> 0;
10451
+ }
10452
+ function snappyUncompress(input) {
10453
+ let pos = 0;
10454
+ let outLen = 0;
10455
+ let shift = 0;
10456
+ for (; ; ) {
10457
+ if (pos >= input.length) throw new Error("snappy: \u957F\u5EA6\u524D\u7F00\u622A\u65AD");
10458
+ const b = input[pos++];
10459
+ outLen += (b & 127) * 2 ** shift;
10460
+ if (b < 128) break;
10461
+ shift += 7;
10462
+ if (shift > 35) throw new Error("snappy: \u957F\u5EA6\u524D\u7F00\u8FC7\u957F");
10463
+ }
10464
+ if (outLen > SNAPPY_MAX_OUTPUT) throw new Error("snappy: \u89E3\u538B\u957F\u5EA6\u5F02\u5E38 " + outLen);
10465
+ const out = Buffer.alloc(outLen);
10466
+ let opos = 0;
10467
+ while (pos < input.length && opos < outLen) {
10468
+ const tag = input[pos++];
10469
+ const type = tag & 3;
10470
+ if (type === 0) {
10471
+ let len = tag >> 2;
10472
+ if (len >= 60) {
10473
+ const extra = len - 59;
10474
+ if (pos + extra > input.length) throw new Error("snappy: literal \u957F\u5EA6\u622A\u65AD");
10475
+ len = 0;
10476
+ for (let i = 0; i < extra; i++) len += input[pos + i] * 2 ** (8 * i);
10477
+ pos += extra;
10478
+ }
10479
+ len += 1;
10480
+ if (pos + len > input.length || opos + len > outLen) throw new Error("snappy: literal \u8D8A\u754C");
10481
+ input.copy(out, opos, pos, pos + len);
10482
+ pos += len;
10483
+ opos += len;
10484
+ } else {
10485
+ let len;
10486
+ let offset;
10487
+ if (type === 1) {
10488
+ if (pos >= input.length) throw new Error("snappy: copy1 \u622A\u65AD");
10489
+ len = (tag >> 2 & 7) + 4;
10490
+ offset = tag >> 5 << 8 | input[pos++];
10491
+ } else if (type === 2) {
10492
+ if (pos + 1 >= input.length) throw new Error("snappy: copy2 \u622A\u65AD");
10493
+ len = (tag >> 2) + 1;
10494
+ offset = input[pos] | input[pos + 1] << 8;
10495
+ pos += 2;
10496
+ } else {
10497
+ if (pos + 3 >= input.length) throw new Error("snappy: copy4 \u622A\u65AD");
10498
+ len = (tag >> 2) + 1;
10499
+ offset = input[pos] | input[pos + 1] << 8 | input[pos + 2] << 16 | input[pos + 3] << 24;
10500
+ pos += 4;
10501
+ }
10502
+ if (offset === 0 || offset > opos || opos + len > outLen) throw new Error("snappy: copy \u8D8A\u754C");
10503
+ for (let i = 0; i < len; i++) {
10504
+ out[opos] = out[opos - offset];
10505
+ opos++;
10506
+ }
10507
+ }
10508
+ }
10509
+ if (opos !== outLen) throw new Error(`snappy: \u89E3\u538B\u957F\u5EA6\u4E0D\u7B26 ${opos} != ${outLen}`);
10510
+ return out;
10511
+ }
10512
+ function readVarint(buf, pos) {
10513
+ let result = 0;
10514
+ let shift = 0;
10515
+ let byte;
10516
+ do {
10517
+ if (pos >= buf.length) throw new Error("varint \u8D8A\u754C");
10518
+ byte = buf[pos++];
10519
+ result += (byte & 127) * 2 ** shift;
10520
+ shift += 7;
10521
+ if (shift > 63) throw new Error("varint \u8FC7\u957F");
10522
+ } while (byte >= 128);
10523
+ return [result, pos];
10524
+ }
10525
+ function readBlock(buf, offset, size) {
10526
+ if (offset < 0 || size < 0 || offset + size + 1 > buf.length) return null;
10527
+ const raw = buf.subarray(offset, offset + size);
10528
+ const type = buf[offset + size];
10529
+ if (type === 0) return raw;
10530
+ if (type === 1) {
10531
+ try {
10532
+ return snappyUncompress(raw);
10533
+ } catch {
10534
+ return null;
10535
+ }
10536
+ }
10537
+ return null;
10538
+ }
10539
+ function blockEntries(block) {
10540
+ const entries = [];
10541
+ let pos = 0;
10542
+ let key = Buffer.alloc(0);
10543
+ while (pos < block.length) {
10544
+ let shared;
10545
+ let nonShared;
10546
+ let vlen;
10547
+ try {
10548
+ ;
10549
+ [shared, pos] = readVarint(block, pos);
10550
+ [nonShared, pos] = readVarint(block, pos);
10551
+ [vlen, pos] = readVarint(block, pos);
10552
+ } catch {
10553
+ break;
10554
+ }
10555
+ if (shared === 0 && nonShared === 0 && vlen === 0) break;
10556
+ if (pos + nonShared + vlen > block.length) break;
10557
+ key = Buffer.concat([key.subarray(0, shared), block.subarray(pos, pos + nonShared)]);
10558
+ pos += nonShared;
10559
+ entries.push({ key, value: block.subarray(pos, pos + vlen) });
10560
+ pos += vlen;
10561
+ }
10562
+ return entries;
10563
+ }
10564
+ function sstEntries(buf) {
10565
+ if (buf.length < 48) return [];
10566
+ const footer = buf.subarray(buf.length - 48);
10567
+ let p = 0;
10568
+ let indexOff;
10569
+ let indexSize;
10570
+ try {
10571
+ ;
10572
+ [, p] = readVarint(footer, p);
10573
+ [, p] = readVarint(footer, p);
10574
+ [indexOff, p] = readVarint(footer, p);
10575
+ [indexSize] = readVarint(footer, p);
10576
+ } catch {
10577
+ return [];
10578
+ }
10579
+ const indexBlock = readBlock(buf, indexOff, indexSize);
10580
+ if (!indexBlock) return [];
10581
+ const out = [];
10582
+ for (const handle of blockEntries(indexBlock)) {
10583
+ let r = 0;
10584
+ let dataOff;
10585
+ let dataSize;
10586
+ try {
10587
+ ;
10588
+ [dataOff, r] = readVarint(handle.value, r);
10589
+ [dataSize] = readVarint(handle.value, r);
10590
+ } catch {
10591
+ continue;
10592
+ }
10593
+ const dataBlock = readBlock(buf, dataOff, dataSize);
10594
+ if (dataBlock) out.push(...blockEntries(dataBlock));
10595
+ }
10596
+ return out;
10597
+ }
10598
+ function logRecords(buf, stats) {
10599
+ const records = [];
10600
+ let pos = 0;
10601
+ let pending = null;
10602
+ while (pos + 7 <= buf.length) {
10603
+ const inBlock = pos % BLOCK_SIZE;
10604
+ if (inBlock > BLOCK_SIZE - 7) {
10605
+ pos += BLOCK_SIZE - inBlock;
10606
+ continue;
10607
+ }
10608
+ const masked = buf.readUInt32LE(pos);
10609
+ const len = buf.readUInt16LE(pos + 4);
10610
+ const type = buf[pos + 6];
10611
+ if (type === 0) {
10612
+ pos += 7 + len;
10613
+ continue;
10614
+ }
10615
+ if (pos + 7 + len > buf.length) break;
10616
+ const payload = buf.subarray(pos + 7, pos + 7 + len);
10617
+ if (unmaskCrc(masked) === crc32c(buf.subarray(pos + 6, pos + 7 + len))) {
10618
+ stats.goodFrames++;
10619
+ } else if (stats) {
10620
+ stats.badFrames++;
10621
+ }
10622
+ pos += 7 + len;
10623
+ if (type === 1) records.push(Buffer.from(payload));
10624
+ else if (type === 2) pending = Buffer.from(payload);
10625
+ else if (type === 3) pending = pending ? Buffer.concat([pending, payload]) : null;
10626
+ else if (type === 4) {
10627
+ if (pending) {
10628
+ records.push(Buffer.concat([pending, payload]));
10629
+ pending = null;
10630
+ }
10631
+ }
10632
+ }
10633
+ return records;
10634
+ }
10635
+ function batchEntries(record) {
10636
+ const out = [];
10637
+ if (record.length < 12) return out;
10638
+ let pos = 12;
10639
+ const count = record.readUInt32LE(8);
10640
+ for (let i = 0; i < count; i++) {
10641
+ if (pos >= record.length) break;
10642
+ const type = record[pos++];
10643
+ let klen;
10644
+ try {
10645
+ ;
10646
+ [klen, pos] = readVarint(record, pos);
10647
+ if (pos + klen > record.length) break;
10648
+ const key = record.subarray(pos, pos + klen);
10649
+ pos += klen;
10650
+ if (type === 0) {
10651
+ out.push({ type, key, value: null });
10652
+ continue;
10653
+ }
10654
+ let vlen;
10655
+ [vlen, pos] = readVarint(record, pos);
10656
+ if (pos + vlen > record.length) break;
10657
+ const value = record.subarray(pos, pos + vlen);
10658
+ pos += vlen;
10659
+ out.push({ type, key, value });
10660
+ } catch {
10661
+ break;
10662
+ }
10663
+ }
10664
+ return out;
10665
+ }
10666
+ function stripInternalKey(key) {
10667
+ return key.length > 8 ? key.subarray(0, key.length - 8) : key;
10668
+ }
10669
+ function readLevelDbHistory(dir) {
10670
+ const names = (() => {
10671
+ try {
10672
+ return readdirSync(dir).sort();
10673
+ } catch {
10674
+ return [];
10675
+ }
10676
+ })();
10677
+ for (const name of names.filter((n) => /\.(ldb|log)$/.test(n))) {
10678
+ if (!lstatSync(join7(dir, name)).isFile()) throw new Error("LevelDB entries must be regular files");
10679
+ }
10680
+ const versions = /* @__PURE__ */ new Map();
10681
+ const push = (key, value, seq) => {
10682
+ const k = key.toString("base64");
10683
+ const list = versions.get(k);
10684
+ if (list) list.push({ key, value, seq });
10685
+ else versions.set(k, [{ key, value, seq }]);
10686
+ };
10687
+ const stats = { goodFrames: 0, badFrames: 0 };
10688
+ for (const name of names.filter((n) => n.endsWith(".ldb"))) {
10689
+ let buf;
10690
+ try {
10691
+ buf = readFileSync2(join7(dir, name));
10692
+ } catch {
10693
+ continue;
10694
+ }
10695
+ for (const e of sstEntries(buf)) {
10696
+ const seq = e.key.length > 8 ? Number(e.key.readBigUInt64LE(e.key.length - 8) >> 8n) : 0;
10697
+ push(stripInternalKey(e.key), e.value, seq);
10698
+ }
10699
+ }
10700
+ for (const name of names.filter((n) => n.endsWith(".log"))) {
10701
+ let buf;
10702
+ try {
10703
+ buf = readFileSync2(join7(dir, name));
10704
+ } catch {
10705
+ continue;
10706
+ }
10707
+ for (const rec of logRecords(buf, stats)) {
10708
+ if (rec.length < 12) continue;
10709
+ const base = Number(rec.readBigUInt64LE(0) >> 8n);
10710
+ for (const e of batchEntries(rec)) {
10711
+ push(e.key, e.type === 0 ? null : e.value, base);
10712
+ }
10713
+ }
10714
+ }
10715
+ for (const list of versions.values()) {
10716
+ if (list.length > 1) list.sort((a, b) => a.seq - b.seq);
10717
+ }
10718
+ return versions;
10719
+ }
10720
+ var OBJECT_STORE_DATA_INDEX_ID = 1;
10721
+ function decodeKeyPrefix(key) {
10722
+ if (key.length < 4) return null;
10723
+ const first = key[0];
10724
+ const dbBytes = (first >> 5 & 7) + 1;
10725
+ const osBytes = (first >> 2 & 7) + 1;
10726
+ const indexBytes = (first & 3) + 1;
10727
+ if (1 + dbBytes + osBytes + indexBytes > key.length) return null;
10728
+ let pos = 1;
10729
+ const readInt = (n) => {
10730
+ let v = 0n;
10731
+ for (let i = n - 1; i >= 0; i--) v = v << 8n | BigInt(key[pos + i]);
10732
+ pos += n;
10733
+ return Number(v);
10734
+ };
10735
+ const databaseId = readInt(dbBytes);
10736
+ const objectStoreId = readInt(osBytes);
10737
+ const indexId = readInt(indexBytes);
10738
+ return { databaseId, objectStoreId, indexId, end: pos };
10739
+ }
10740
+ function decodeIdbKey(buf, pos = 0) {
10741
+ const type = buf[pos++];
10742
+ switch (type) {
10743
+ case 0:
10744
+ return { value: null, pos };
10745
+ case 1: {
10746
+ const [len, p] = readVarint(buf, pos);
10747
+ if (p + len * 2 > buf.length) throw new Error("IndexedDB \u5B57\u7B26\u4E32\u952E\u8D8A\u754C");
10748
+ let text = "";
10749
+ for (let i = 0; i < len; i++) text += String.fromCharCode(buf.readUInt16BE(p + i * 2));
10750
+ return { value: text, pos: p + len * 2 };
10751
+ }
10752
+ case 2:
10753
+ case 3:
10754
+ return { value: buf.readDoubleLE(pos), pos: pos + 8 };
10755
+ case 4: {
10756
+ const [len, p] = readVarint(buf, pos);
10757
+ const items = [];
10758
+ let at = p;
10759
+ for (let i = 0; i < len; i++) {
10760
+ const r = decodeIdbKey(buf, at);
10761
+ items.push(r.value);
10762
+ at = r.pos;
10763
+ }
10764
+ return { value: items, pos: at };
10765
+ }
10766
+ case 5:
10767
+ return { value: null, pos };
10768
+ case 6: {
10769
+ const [len, p] = readVarint(buf, pos);
10770
+ return { value: buf.subarray(p, p + len), pos: p + len };
10771
+ }
10772
+ default:
10773
+ throw new Error("\u672A\u77E5 IndexedDB \u952E\u7C7B\u578B " + type);
10774
+ }
10775
+ }
10776
+ function unwrapIdbValue(value) {
10777
+ for (let off = 0; off < Math.min(8, value.length - 2); off++) {
10778
+ if (value[off] !== 255 || value[off + 1] !== 17) continue;
10779
+ const kind = value[off + 2];
10780
+ if (kind === 2) {
10781
+ try {
10782
+ return snappyUncompress(value.subarray(off + 3));
10783
+ } catch {
10784
+ return null;
10785
+ }
10786
+ }
10787
+ if (kind === 1) return null;
10788
+ }
10789
+ return value;
10790
+ }
10791
+ function ssvPayloadOffset(buf) {
10792
+ for (let i = 0; i + 2 < buf.length && i < 8; i++) {
10793
+ if (buf[i] !== 255) continue;
10794
+ let pos = i + 1;
10795
+ try {
10796
+ let [, p] = readVarint(buf, pos);
10797
+ if (buf[p] === 254) {
10798
+ const end = p + 1 + 8 + 4;
10799
+ return end <= buf.length ? end : -1;
10800
+ }
10801
+ return p;
10802
+ } catch {
10803
+ return -1;
10804
+ }
10805
+ }
10806
+ return -1;
10807
+ }
10808
+ var V8_VERSION = 255;
10809
+ var V8_PADDING = 0;
10810
+ var V8_VERIFY_COUNT = 63;
10811
+ var V8_THE_HOLE = 45;
10812
+ var V8_UNDEFINED = 95;
10813
+ var V8_NULL = 48;
10814
+ var V8_TRUE = 84;
10815
+ var V8_FALSE = 70;
10816
+ var V8_INT32 = 73;
10817
+ var V8_UINT32 = 85;
10818
+ var V8_DOUBLE = 78;
10819
+ var V8_BIGINT = 90;
10820
+ var V8_UTF8_STRING = 83;
10821
+ var V8_ONE_BYTE_STRING = 34;
10822
+ var V8_TWO_BYTE_STRING = 99;
10823
+ var V8_OBJECT_REFERENCE = 94;
10824
+ var V8_BEGIN_OBJECT = 111;
10825
+ var V8_END_OBJECT = 123;
10826
+ var V8_BEGIN_SPARSE_ARRAY = 97;
10827
+ var V8_END_SPARSE_ARRAY = 64;
10828
+ var V8_BEGIN_DENSE_ARRAY = 65;
10829
+ var V8_END_DENSE_ARRAY = 36;
10830
+ var V8_DATE = 68;
10831
+ var V8_TRUE_OBJECT = 121;
10832
+ var V8_FALSE_OBJECT = 120;
10833
+ var V8_NUMBER_OBJECT = 110;
10834
+ var V8_STRING_OBJECT = 115;
10835
+ var V8_BIGINT_OBJECT = 122;
10836
+ var V8_REGEXP = 82;
10837
+ var V8_BEGIN_MAP = 59;
10838
+ var V8_END_MAP = 58;
10839
+ var V8_BEGIN_SET = 39;
10840
+ var V8_END_SET = 44;
10841
+ var V8_ARRAY_BUFFER = 66;
10842
+ var V8_IMMUTABLE_ARRAY_BUFFER = 67;
10843
+ var V8_RESIZABLE_ARRAY_BUFFER = 126;
10844
+ var V8_ERROR = 114;
10845
+ var V8_HOST_OBJECT = 92;
10846
+ var V8_SHARED_OBJECT = 112;
10847
+ function deserializeV8(buf, start = 0) {
10848
+ let pos = start;
10849
+ let nextId = 0;
10850
+ const table = [];
10851
+ const varint = () => {
10852
+ const [v, p] = readVarint(buf, pos);
10853
+ pos = p;
10854
+ return v;
10855
+ };
10856
+ const dbl = () => {
10857
+ if (pos + 8 > buf.length) throw new Error("V8: double \u8D8A\u754C");
10858
+ const v = buf.readDoubleLE(pos);
10859
+ pos += 8;
10860
+ return v;
10861
+ };
10862
+ const stringOf = (encoding, length) => {
10863
+ const bytes = encoding === "utf16" ? length * 2 : length;
10864
+ if (pos + bytes > buf.length) throw new Error("V8: \u5B57\u7B26\u4E32\u8D8A\u754C");
10865
+ const s = encoding === "utf16" ? buf.toString("utf16le", pos, pos + bytes) : buf.toString(encoding, pos, pos + bytes);
10866
+ pos += bytes;
10867
+ return s;
10868
+ };
10869
+ const read = () => {
10870
+ if (pos >= buf.length) throw new Error("V8: \u6D41\u622A\u65AD");
10871
+ const tag = buf[pos++];
10872
+ switch (tag) {
10873
+ case V8_VERSION:
10874
+ varint();
10875
+ return read();
10876
+ case V8_PADDING:
10877
+ return read();
10878
+ case V8_VERIFY_COUNT:
10879
+ varint();
10880
+ return read();
10881
+ case V8_UNDEFINED:
10882
+ case V8_THE_HOLE:
10883
+ return void 0;
10884
+ case V8_NULL:
10885
+ return null;
10886
+ case V8_TRUE:
10887
+ return true;
10888
+ case V8_FALSE:
10889
+ return false;
10890
+ case V8_INT32: {
10891
+ const v = varint();
10892
+ return v >>> 1 ^ -(v & 1);
10893
+ }
10894
+ case V8_UINT32:
10895
+ return varint();
10896
+ case V8_DOUBLE:
10897
+ return dbl();
10898
+ case V8_BIGINT: {
10899
+ const bitfield = varint();
10900
+ pos += Math.ceil((bitfield >>> 2 || 1) / 8) * 8;
10901
+ return null;
10902
+ }
10903
+ case V8_UTF8_STRING:
10904
+ return stringOf("utf8", varint());
10905
+ case V8_ONE_BYTE_STRING:
10906
+ return stringOf("latin1", varint());
10907
+ case V8_TWO_BYTE_STRING: {
10908
+ if (buf[pos] === V8_PADDING) pos++;
10909
+ const bytes = varint();
10910
+ return stringOf("utf16", bytes / 2);
10911
+ }
10912
+ case V8_OBJECT_REFERENCE:
10913
+ return table[varint()];
10914
+ case V8_BEGIN_OBJECT: {
10915
+ const obj = {};
10916
+ table[nextId++] = obj;
10917
+ for (; ; ) {
10918
+ if (pos >= buf.length) throw new Error("V8: \u5BF9\u8C61\u672A\u95ED\u5408");
10919
+ if (buf[pos] === V8_END_OBJECT) {
10920
+ pos++;
10921
+ varint();
10922
+ return obj;
10923
+ }
10924
+ const key = read();
10925
+ obj[String(key)] = read();
10926
+ }
10927
+ }
10928
+ case V8_BEGIN_DENSE_ARRAY: {
10929
+ const len = varint();
10930
+ const arr = new Array(len);
10931
+ table[nextId++] = arr;
10932
+ for (let i = 0; i < len; i++) arr[i] = read();
10933
+ if (buf[pos] === V8_END_DENSE_ARRAY) {
10934
+ pos++;
10935
+ varint();
10936
+ varint();
10937
+ }
10938
+ return arr;
10939
+ }
10940
+ case V8_BEGIN_SPARSE_ARRAY: {
10941
+ const len = varint();
10942
+ const arr = new Array(len);
10943
+ table[nextId++] = arr;
10944
+ for (; ; ) {
10945
+ if (pos >= buf.length) throw new Error("V8: \u7A00\u758F\u6570\u7EC4\u672A\u95ED\u5408");
10946
+ if (buf[pos] === V8_END_SPARSE_ARRAY) {
10947
+ pos++;
10948
+ varint();
10949
+ varint();
10950
+ return arr;
10951
+ }
10952
+ const key = read();
10953
+ arr[Number(key)] = read();
10954
+ }
10955
+ }
10956
+ case V8_DATE:
10957
+ table[nextId++] = new Date(dbl());
10958
+ return table[nextId - 1];
10959
+ case V8_TRUE_OBJECT:
10960
+ table[nextId] = true;
10961
+ return table[nextId++];
10962
+ case V8_FALSE_OBJECT:
10963
+ table[nextId] = false;
10964
+ return table[nextId++];
10965
+ case V8_NUMBER_OBJECT:
10966
+ table[nextId++] = dbl();
10967
+ return table[nextId - 1];
10968
+ case V8_BIGINT_OBJECT: {
10969
+ const bitfield = varint();
10970
+ pos += Math.ceil((bitfield >>> 2 || 1) / 8) * 8;
10971
+ return null;
10972
+ }
10973
+ case V8_STRING_OBJECT:
10974
+ return read();
10975
+ case V8_REGEXP: {
10976
+ const pattern = read();
10977
+ varint();
10978
+ return pattern instanceof RegExp ? pattern : new RegExp(String(pattern));
10979
+ }
10980
+ case V8_BEGIN_MAP: {
10981
+ const map = /* @__PURE__ */ new Map();
10982
+ table[nextId++] = map;
10983
+ for (; ; ) {
10984
+ if (pos >= buf.length) throw new Error("V8: Map \u672A\u95ED\u5408");
10985
+ if (buf[pos] === V8_END_MAP) {
10986
+ pos++;
10987
+ varint();
10988
+ return map;
10989
+ }
10990
+ const key = read();
10991
+ map.set(key, read());
10992
+ }
10993
+ }
10994
+ case V8_BEGIN_SET: {
10995
+ const set = /* @__PURE__ */ new Set();
10996
+ table[nextId++] = set;
10997
+ for (; ; ) {
10998
+ if (pos >= buf.length) throw new Error("V8: Set \u672A\u95ED\u5408");
10999
+ if (buf[pos] === V8_END_SET) {
11000
+ pos++;
11001
+ varint();
11002
+ return set;
11003
+ }
11004
+ set.add(read());
11005
+ }
11006
+ }
11007
+ case V8_ARRAY_BUFFER:
11008
+ case V8_IMMUTABLE_ARRAY_BUFFER: {
11009
+ const len = varint();
11010
+ if (pos + len > buf.length) throw new Error("V8: ArrayBuffer \u8D8A\u754C");
11011
+ const bytes = buf.subarray(pos, pos + len);
11012
+ pos += len;
11013
+ table[nextId++] = bytes;
11014
+ return bytes;
11015
+ }
11016
+ case V8_RESIZABLE_ARRAY_BUFFER: {
11017
+ const len = varint();
11018
+ varint();
11019
+ if (pos + len > buf.length) throw new Error("V8: \u53EF\u53D8 ArrayBuffer \u8D8A\u754C");
11020
+ const bytes = buf.subarray(pos, pos + len);
11021
+ pos += len;
11022
+ table[nextId++] = bytes;
11023
+ return bytes;
11024
+ }
11025
+ case V8_ERROR: {
11026
+ const err2 = { name: "Error", message: "", stack: "" };
11027
+ table[nextId++] = err2;
11028
+ let sub = buf[pos++];
11029
+ for (; ; ) {
11030
+ if (sub === 46) break;
11031
+ if (sub === 109) err2.message = String(read());
11032
+ else if (sub === 115) err2.stack = String(read());
11033
+ else if (sub === 99) err2.cause = read();
11034
+ else if (sub >= 69 && sub <= 85) err2.name = "Error";
11035
+ sub = buf[pos++];
11036
+ }
11037
+ return err2;
11038
+ }
11039
+ case V8_HOST_OBJECT:
11040
+ return "[host object]";
11041
+ case V8_SHARED_OBJECT:
11042
+ varint();
11043
+ return "[shared object]";
11044
+ default:
11045
+ throw new Error(`V8: \u672A\u77E5 tag 0x${tag.toString(16)} @${pos - 1}`);
11046
+ }
11047
+ };
11048
+ const value = read();
11049
+ return { value, consumed: pos - start, total: buf.length - start };
11050
+ }
11051
+ function decodeIdbValue(value) {
11052
+ const body = unwrapIdbValue(value);
11053
+ if (!body) return void 0;
11054
+ const start = ssvPayloadOffset(body);
11055
+ const candidates = start >= 0 ? [start] : [];
11056
+ for (let i = 0; i < 8; i++) if (!candidates.includes(i)) candidates.push(i);
11057
+ for (const off of candidates) {
11058
+ try {
11059
+ return deserializeV8(body, off).value;
11060
+ } catch {
11061
+ }
11062
+ }
11063
+ return void 0;
11064
+ }
11065
+ function readIndexedDb(dir) {
11066
+ const history = readLevelDbHistory(dir);
11067
+ const data = [];
11068
+ let undecodable2 = 0;
11069
+ let rawCount = 0;
11070
+ for (const versions of history.values()) {
11071
+ const first = versions[0];
11072
+ rawCount += versions.length;
11073
+ const prefix = decodeKeyPrefix(first.key);
11074
+ if (!prefix || prefix.indexId !== OBJECT_STORE_DATA_INDEX_ID) continue;
11075
+ let userKey;
11076
+ try {
11077
+ ;
11078
+ ({ value: userKey } = decodeIdbKey(first.key, prefix.end));
11079
+ } catch {
11080
+ undecodable2++;
11081
+ continue;
11082
+ }
11083
+ const decoded = [];
11084
+ for (const v of versions) {
11085
+ if (v.value === null) continue;
11086
+ const value = decodeIdbValue(v.value);
11087
+ if (value !== void 0) decoded.push(value);
11088
+ }
11089
+ if (decoded.length === 0) {
11090
+ undecodable2++;
11091
+ continue;
11092
+ }
11093
+ data.push({
11094
+ databaseId: prefix.databaseId,
11095
+ objectStoreId: prefix.objectStoreId,
11096
+ key: userKey,
11097
+ value: decoded[decoded.length - 1],
11098
+ versions: decoded,
11099
+ versionCount: versions.length
11100
+ });
11101
+ }
11102
+ return { records: data, undecodable: undecodable2, rawCount };
11103
+ }
11104
+
11105
+ // .codex-tmp/chat-import-0263/package/lib/sources/doubao.mjs
11106
+ function doubaoUserDataDirs(home, env = process.env, platform = process.platform) {
11107
+ if (platform === "win32") {
11108
+ const local = env.LOCALAPPDATA || (home ? join8(home, "AppData", "Local") : null);
11109
+ if (!local) return [];
11110
+ return [join8(local, "Doubao", "User Data")];
11111
+ }
11112
+ if (platform === "darwin") {
11113
+ return home ? [join8(home, "Library", "Application Support", "Doubao")] : [];
11114
+ }
11115
+ return home ? [join8(home, ".config", "Doubao")] : [];
11116
+ }
11117
+ function readDoubaoDb(dir) {
11118
+ let db;
11119
+ try {
11120
+ db = readIndexedDb(dir);
11121
+ } catch {
11122
+ return null;
11123
+ }
11124
+ if (!db || db.rawCount === 0) return null;
11125
+ const { sessions, stats } = extractDoubaoSessions(db);
11126
+ return { sessions, stats, undecodable: db.undecodable, rawCount: db.rawCount };
11127
+ }
11128
+ var NOT_DOUBAO_DB = "\u4E0D\u662F\u8C46\u5305\u4F1A\u8BDD\u5E93\uFF08\u6CA1\u6709\u53EF\u89E3\u7801\u7684 IndexedDB \u8BB0\u5F55\uFF09: ";
11129
+ function readDoubaoDbOrThrow(dir) {
11130
+ const read = readDoubaoDb(dir);
11131
+ if (!read) throw new Error(NOT_DOUBAO_DB + dir);
11132
+ return read;
11133
+ }
11134
+ var doubaoConvertOne = (args, path) => (session) => convertDoubaoSession(session, { ...args, sourcePath: path });
11135
+ function assertHasSessions(read, dir) {
11136
+ if (read.sessions.length > 0) return;
11137
+ const details = read.undecodable > 0 ? `\uFF0C${read.undecodable} \u6761\u8BB0\u5F55\u89E3\u4E0D\u5F00` : "";
11138
+ throw new Error(
11139
+ `\u8C46\u5305\u5E93\u91CC\u6CA1\u6709\u53EF\u5BFC\u5165\u7684\u4F1A\u8BDD\u6B63\u6587\uFF08\u672C\u5730\u53EA\u7F13\u5B58\u6700\u8FD1\u6253\u5F00\u8FC7\u7684\u5BF9\u8BDD\uFF09: ${dir}${details}`
11140
+ );
11141
+ }
11142
+ async function previewDoubaoDirectory(ctx, dirTarget, args) {
11143
+ const path = dirTarget.displayPath || ctx.fs.processPath(dirTarget);
11144
+ const read = readDoubaoDbOrThrow(path);
11145
+ assertHasSessions(read, path);
11146
+ const results = previewSessionSet(read.sessions, {
11147
+ path,
11148
+ args,
11149
+ wanted: selectionSet(sessionSelection(args)),
11150
+ sourceLabel: "Doubao",
11151
+ convertOne: doubaoConvertOne(args, path)
11152
+ });
11153
+ return { total: read.sessions.length, results };
11154
+ }
11155
+
11156
+ // .codex-tmp/chat-import-0263/package/lib/sources/cline.mjs
11157
+ import { dirname as dirname3, join as join9 } from "node:path";
9378
11158
  var timeOf = (v) => parseTimeMs(v, { truncSeconds: true });
9379
11159
  function metadataTitle(raw) {
9380
11160
  if (typeof raw !== "string" || !raw) return "";
@@ -9400,7 +11180,7 @@ function readClineDb(dbPath) {
9400
11180
  const cols = columnsOf(db, "sessions");
9401
11181
  if (!cols.has("session_id")) return null;
9402
11182
  const pick = (row, name) => cols.has(name) ? row[name] : void 0;
9403
- const sessionsDir = join7(dirname3(dirname3(dbPath)), "sessions");
11183
+ const sessionsDir = join9(dirname3(dirname3(dbPath)), "sessions");
9404
11184
  const out = [];
9405
11185
  for (const row of db.prepare("SELECT * FROM sessions ORDER BY rowid DESC").all()) {
9406
11186
  const id = typeof row.session_id === "string" && row.session_id ? row.session_id : null;
@@ -9452,7 +11232,7 @@ async function clineDeriveArgs(ctx, target) {
9452
11232
  const dirName = String(dir).split(/[\\/]/).pop() || "";
9453
11233
  const id = stem || dirName;
9454
11234
  const derived = { clineId: id };
9455
- const rows = readClineDb(join7(dir, "..", "..", "db", "sessions.db"));
11235
+ const rows = readClineDb(join9(dir, "..", "..", "db", "sessions.db"));
9456
11236
  const row = rows ? rows.find((s) => s.id === id) : null;
9457
11237
  if (row) {
9458
11238
  if (row.cwd) derived.cwd = row.cwd;
@@ -9462,7 +11242,7 @@ async function clineDeriveArgs(ctx, target) {
9462
11242
  if (!derived.title || !derived.cwd || derived.createdAt === void 0) {
9463
11243
  let man = null;
9464
11244
  try {
9465
- man = readClineManifest(await ctx.fs.readText(await ctx.fs.resolve(join7(dir, id + ".json"))));
11245
+ man = readClineManifest(await ctx.fs.readText(await ctx.fs.resolve(join9(dir, id + ".json"))));
9466
11246
  } catch {
9467
11247
  }
9468
11248
  if (man) {
@@ -9477,7 +11257,7 @@ async function clineDeriveArgs(ctx, target) {
9477
11257
  if (!legacyId) {
9478
11258
  let sidecar = null;
9479
11259
  try {
9480
- sidecar = JSON.parse(await ctx.fs.readText(await ctx.fs.resolve(join7(dir, id + ".compaction.json"))));
11260
+ sidecar = JSON.parse(await ctx.fs.readText(await ctx.fs.resolve(join9(dir, id + ".compaction.json"))));
9481
11261
  } catch {
9482
11262
  }
9483
11263
  const state = sidecar && typeof sidecar === "object" && !Array.isArray(sidecar) ? sidecar : null;
@@ -9498,9 +11278,43 @@ async function clineDeriveArgs(ctx, target) {
9498
11278
  return derived;
9499
11279
  }
9500
11280
 
9501
- // .codex-tmp/vendor-pagination-upstream/lib/sources/dsh.mjs
11281
+ // .codex-tmp/chat-import-0263/package/lib/sources/copilot-vscode.mjs
11282
+ function copilotVscodeWorkspacePath(path) {
11283
+ const match = String(path).match(/^(.*)[\\/]chatSessions[\\/][^\\/]+\.json$/i);
11284
+ if (!match) return null;
11285
+ const sep = match[1].includes("\\") ? "\\" : "/";
11286
+ return match[1] + sep + "workspace.json";
11287
+ }
11288
+ function readCopilotVscodeWorkspace(raw) {
11289
+ try {
11290
+ return copilotVscodeCwd(JSON.parse(raw)?.folder);
11291
+ } catch {
11292
+ return null;
11293
+ }
11294
+ }
11295
+ async function copilotVscodeDeriveArgs(ctx, target) {
11296
+ const path = target.displayPath || target.targetKey;
11297
+ const workspace = copilotVscodeWorkspacePath(path);
11298
+ if (!workspace) return {};
11299
+ try {
11300
+ const cwd = readCopilotVscodeWorkspace(await ctx.fs.readText(await ctx.fs.resolve(workspace)));
11301
+ return cwd ? { cwd } : {};
11302
+ } catch {
11303
+ return {};
11304
+ }
11305
+ }
11306
+ function collectCopilotVscodeFiles(ctx, target, out, recursive) {
11307
+ return collectFiles(ctx, target, out, recursive, (entry) => /[\\/]chatSessions[\\/][^\\/]+\.json$/i.test(entry.target.displayPath || entry.target.targetKey));
11308
+ }
11309
+
11310
+ // .codex-tmp/chat-import-0263/package/lib/sources/copilot-cli.mjs
11311
+ function collectCopilotCliFiles(ctx, target, out, recursive) {
11312
+ return collectFiles(ctx, target, out, recursive, (entry) => /^events\.jsonl$/i.test(entry.name));
11313
+ }
11314
+
11315
+ // .codex-tmp/chat-import-0263/package/lib/sources/dsh.mjs
9502
11316
  import { Buffer as Buffer3 } from "node:buffer";
9503
- import { readFileSync as readFileSync2 } from "node:fs";
11317
+ import { readFileSync as readFileSync3 } from "node:fs";
9504
11318
  var DSH_SESSION_LOG = /^session(?:\.v([1-9][0-9]*))?\.jsonl(?:\.zstd)?$/i;
9505
11319
  function dshSessionLogVersion(name) {
9506
11320
  const m = DSH_SESSION_LOG.exec(String(name || ""));
@@ -9518,7 +11332,7 @@ function dshPath(target) {
9518
11332
  async function readDshText(ctx, target) {
9519
11333
  const path = dshPath(target);
9520
11334
  if (/\.zstd$/i.test(path)) {
9521
- return decodeZstdText(readFileSync2(path));
11335
+ return decodeZstdText(readFileSync3(path));
9522
11336
  }
9523
11337
  return ctx.fs.readText(target);
9524
11338
  }
@@ -9526,10 +11340,10 @@ function collectDshFiles(ctx, dirTarget, out, recursive, versionOk) {
9526
11340
  return collectFiles(ctx, dirTarget, out, recursive, (entry) => isDshSessionFile(entry.name) && (versionOk === void 0 || versionOk(dshSessionLogVersion(entry.name) ?? 0)));
9527
11341
  }
9528
11342
 
9529
- // .codex-tmp/vendor-pagination-upstream/lib/discovery/session-dirs.mjs
9530
- import { join as join8 } from "node:path";
11343
+ // .codex-tmp/chat-import-0263/package/lib/discovery/session-dirs.mjs
11344
+ import { join as join10 } from "node:path";
9531
11345
 
9532
- // .codex-tmp/vendor-pagination-upstream/lib/discovery/common.mjs
11346
+ // .codex-tmp/chat-import-0263/package/lib/discovery/common.mjs
9533
11347
  var HEAD_MAX_BYTES = 256 * 1024;
9534
11348
  var TAIL_MAX_BYTES = 64 * 1024;
9535
11349
  function pathSegments(p) {
@@ -9563,7 +11377,7 @@ async function emitEach(emit, entries) {
9563
11377
  for (const e of entries) await emit(e);
9564
11378
  }
9565
11379
 
9566
- // .codex-tmp/vendor-pagination-upstream/lib/discovery/scan-cache.mjs
11380
+ // .codex-tmp/chat-import-0263/package/lib/discovery/scan-cache.mjs
9567
11381
  var SCAN_TTL_MS = 3e4;
9568
11382
  function createScanCache({ ttlMs = SCAN_TTL_MS, now = () => Date.now() } = {}) {
9569
11383
  const map = /* @__PURE__ */ new Map();
@@ -9604,9 +11418,9 @@ async function probeSource(bm, format, sourcePath, fp, probe, patchHit) {
9604
11418
  return entries;
9605
11419
  }
9606
11420
 
9607
- // .codex-tmp/vendor-pagination-upstream/lib/discovery/session-dirs.mjs
11421
+ // .codex-tmp/chat-import-0263/package/lib/discovery/session-dirs.mjs
9608
11422
  async function grokbuildIsSessionDir(statOf, dir) {
9609
- const st = await statOf(join8(String(dir), "summary.json"));
11423
+ const st = await statOf(join10(String(dir), "summary.json"));
9610
11424
  return !!(st && st.type === "file");
9611
11425
  }
9612
11426
  function fsStatOf(ctx) {
@@ -9623,15 +11437,15 @@ function grokbuildLayoutProject(sourcePath) {
9623
11437
  }
9624
11438
  var kimiSource = {
9625
11439
  format: "kimi",
9626
- roots: (home) => [join8(home, ".kimi", "sessions"), join8(home, ".kimi-code", "sessions")],
11440
+ roots: (home) => [join10(home, ".kimi", "sessions"), join10(home, ".kimi-code", "sessions")],
9627
11441
  matchFile: (lower) => lower.endsWith(".jsonl") && /(\.kimi|\.kimi-code)[\\/]sessions[\\/]/.test(lower)
9628
11442
  };
9629
11443
  var grokbuildSource = {
9630
11444
  format: "grokbuild",
9631
11445
  // sessions + archived_sessions 双根;GROK_HOME 非空时替代 ~/.grok
9632
11446
  roots: (home, env) => {
9633
- const grokHome = env.GROK_HOME || join8(home, ".grok");
9634
- return [join8(grokHome, "sessions"), join8(grokHome, "archived_sessions")];
11447
+ const grokHome = env.GROK_HOME || join10(home, ".grok");
11448
+ return [join10(grokHome, "sessions"), join10(grokHome, "archived_sessions")];
9635
11449
  },
9636
11450
  layoutProject: grokbuildLayoutProject
9637
11451
  };
@@ -9641,11 +11455,11 @@ var vibeSource = {
9641
11455
  matchFile: (lower) => lower.endsWith(".jsonl") && /(\.vibe[\\/]logs[\\/]session|messages\.jsonl$)/.test(lower)
9642
11456
  };
9643
11457
 
9644
- // .codex-tmp/vendor-pagination-upstream/lib/import-variants.mjs
11458
+ // .codex-tmp/chat-import-0263/package/lib/import-variants.mjs
9645
11459
  import { createHash as createHash2 } from "node:crypto";
9646
- import { join as join9 } from "node:path";
11460
+ import { join as join11 } from "node:path";
9647
11461
 
9648
- // .codex-tmp/vendor-pagination-upstream/lib/sources/hermes.mjs
11462
+ // .codex-tmp/chat-import-0263/package/lib/sources/hermes.mjs
9649
11463
  function readHermesDb(dbPath) {
9650
11464
  return readOptionalDb(dbPath, (db) => {
9651
11465
  if (!hasTable(db, "sessions")) return null;
@@ -9658,10 +11472,9 @@ function readHermesDb(dbPath) {
9658
11472
  const timeCol = pickCol(mCols, "created_at", "timestamp");
9659
11473
  const toolCallsCol = pickCol(mCols, "tool_calls", "tool_call");
9660
11474
  const reasoningCol = pickCol(mCols, "reasoning");
9661
- const toolCallIdCol = pickCol(mCols, "tool_call_id", "call_id");
9662
11475
  const order = (timeCol || "rowid") + (mCols.has("id") ? ", id" : "");
9663
11476
  const messagesOf = mCols.has("session_id") && mCols.has("role") ? db.prepare(
9664
- `SELECT role, ${mCols.has("content") ? "content" : "'' AS content"}, ${timeCol ? `${timeCol} AS ts` : "NULL AS ts"}, ${toolCallsCol ? `${toolCallsCol} AS tool_calls` : "NULL AS tool_calls"}, ${reasoningCol ? `${reasoningCol} AS reasoning` : "NULL AS reasoning"} , ${toolCallIdCol ? `${toolCallIdCol} AS tool_call_id` : "NULL AS tool_call_id"} FROM messages WHERE session_id = ? ORDER BY ${order}`
11477
+ `SELECT role, ${mCols.has("content") ? "content" : "'' AS content"}, ${timeCol ? `${timeCol} AS ts` : "NULL AS ts"}, ${toolCallsCol ? `${toolCallsCol} AS tool_calls` : "NULL AS tool_calls"}, ${reasoningCol ? `${reasoningCol} AS reasoning` : "NULL AS reasoning"}, ${mCols.has("tool_call_id") ? "tool_call_id AS tool_call_id" : "NULL AS tool_call_id"} FROM messages WHERE session_id = ? ORDER BY ${order}`
9665
11478
  ) : null;
9666
11479
  const sessions = [];
9667
11480
  for (const row of db.prepare("SELECT * FROM sessions ORDER BY rowid DESC").all()) {
@@ -9676,11 +11489,12 @@ function readHermesDb(dbPath) {
9676
11489
  if (!role) continue;
9677
11490
  const content = hermesContent(m.content);
9678
11491
  const toolCalls = hermesToolCalls(m.tool_calls);
9679
- if (content === void 0 && !toolCalls && role !== "tool") continue;
9680
- const msg = { role, content: content ?? "", toolCallId: m.tool_call_id, ts: timeCol ? parseHermesTime(m.ts) : void 0 };
11492
+ if (content === void 0 && toolCalls === void 0) continue;
11493
+ const msg = { role, content, ts: timeCol ? parseHermesTime(m.ts) : void 0 };
9681
11494
  const reasoning = hermesReasoning(m.reasoning);
9682
11495
  if (toolCalls !== void 0) msg.toolCalls = toolCalls;
9683
11496
  if (reasoning !== void 0) msg.reasoning = reasoning;
11497
+ if (typeof m.tool_call_id === "string" && m.tool_call_id) msg.toolCallId = m.tool_call_id;
9684
11498
  messages.push(msg);
9685
11499
  }
9686
11500
  }
@@ -9718,27 +11532,7 @@ function hermesContent(raw) {
9718
11532
  return void 0;
9719
11533
  }
9720
11534
  function hermesToolCalls(raw) {
9721
- let arr = raw;
9722
- if (raw === null || raw === void 0) return void 0;
9723
- if (typeof raw === "string") {
9724
- const trimmed = raw.trim();
9725
- if (!trimmed) return void 0;
9726
- try {
9727
- arr = JSON.parse(trimmed);
9728
- } catch {
9729
- return void 0;
9730
- }
9731
- }
9732
- if (!Array.isArray(arr) || arr.length === 0) return void 0;
9733
- const out = [];
9734
- for (const t of arr) {
9735
- if (!t || typeof t !== "object") continue;
9736
- const id = typeof t.id === "string" ? t.id : typeof t.tool_call_id === "string" ? t.tool_call_id : t.call_id;
9737
- const name = typeof t.name === "string" ? t.name : typeof t.tool_name === "string" ? t.tool_name : t.function?.name;
9738
- if (typeof id !== "string" || !id || typeof name !== "string" || !name) continue;
9739
- out.push({ id, name, input: t.arguments ?? t.input ?? t.function?.arguments });
9740
- }
9741
- return out.length > 0 ? out : void 0;
11535
+ return normalizeHermesToolCalls(raw);
9742
11536
  }
9743
11537
  function hermesReasoning(raw) {
9744
11538
  if (raw === null || raw === void 0) return void 0;
@@ -9765,7 +11559,7 @@ function hermesReasoning(raw) {
9765
11559
  return void 0;
9766
11560
  }
9767
11561
 
9768
- // .codex-tmp/vendor-pagination-upstream/lib/import-variants.mjs
11562
+ // .codex-tmp/chat-import-0263/package/lib/import-variants.mjs
9769
11563
  function collectGrokbuildSessions(ctx, dirTarget, out, recursive) {
9770
11564
  return collectSessionDirs(ctx, dirTarget, out, recursive, (sub) => grokbuildIsSessionDir(fsStatOf(ctx), sub.targetKey));
9771
11565
  }
@@ -9798,10 +11592,10 @@ function parentOf2(p) {
9798
11592
  }
9799
11593
  async function kimiWireTarget(ctx, dir) {
9800
11594
  const dirPath = typeof dir === "string" ? dir : dir.displayPath || ctx.fs.processPath(dir);
9801
- const root = await ctx.fs.resolve(join9(dirPath, "wire.jsonl"));
11595
+ const root = await ctx.fs.resolve(join11(dirPath, "wire.jsonl"));
9802
11596
  const rootStat = await ctx.fs.stat(root);
9803
11597
  if (rootStat && rootStat.type === "file") return root;
9804
- const agent = await ctx.fs.resolve(join9(dirPath, "agents", "main", "wire.jsonl"));
11598
+ const agent = await ctx.fs.resolve(join11(dirPath, "agents", "main", "wire.jsonl"));
9805
11599
  const agentStat = await ctx.fs.stat(agent);
9806
11600
  if (agentStat && agentStat.type === "file") return agent;
9807
11601
  return root;
@@ -9815,7 +11609,7 @@ async function kimiWorkDirByHash(ctx, startPath, hashDirName) {
9815
11609
  if (!hashDirName) return null;
9816
11610
  let dir = parentOf2(startPath);
9817
11611
  for (let i = 0; i < 6; i++) {
9818
- const metaTarget = await ctx.fs.resolve(join9(dir, "kimi.json"));
11612
+ const metaTarget = await ctx.fs.resolve(join11(dir, "kimi.json"));
9819
11613
  const st = await ctx.fs.stat(metaTarget);
9820
11614
  if (st && st.type === "file") {
9821
11615
  try {
@@ -9845,7 +11639,7 @@ async function kimiCodeWorkDirById(ctx, startPath, workspaceId) {
9845
11639
  const afterMarker = rawPath[marker + ".kimi-code".length];
9846
11640
  if (marker < 0 || beforeMarker && !/[\\/]/.test(beforeMarker) || afterMarker && !/[\\/]/.test(afterMarker)) return null;
9847
11641
  const home = rawPath.slice(0, marker + ".kimi-code".length);
9848
- const metaTarget = await ctx.fs.resolve(join9(home, "workspaces.json"));
11642
+ const metaTarget = await ctx.fs.resolve(join11(home, "workspaces.json"));
9849
11643
  const st = await ctx.fs.stat(metaTarget);
9850
11644
  if (!st || st.type !== "file") return null;
9851
11645
  try {
@@ -9884,7 +11678,7 @@ async function kimiDeriveArgs(ctx, target) {
9884
11678
  hashDirName = segs[segs.length - 2] || "";
9885
11679
  }
9886
11680
  if (sessionDirName) derived.kimiId = sessionDirName;
9887
- const stateTarget = await ctx.fs.resolve(join9(sessionDirPath, "state.json"));
11681
+ const stateTarget = await ctx.fs.resolve(join11(sessionDirPath, "state.json"));
9888
11682
  let state = null;
9889
11683
  try {
9890
11684
  state = JSON.parse(await ctx.fs.readText(stateTarget));
@@ -9931,8 +11725,8 @@ async function previewChatgptDirectory(ctx, dirTarget, args) {
9931
11725
  }
9932
11726
  async function previewGrokbuildSession(ctx, target, args) {
9933
11727
  const sourcePath = target.displayPath || ctx.fs.processPath(target);
9934
- const summaryTarget = await ctx.fs.resolve(join9(sourcePath, "summary.json"));
9935
- const chatTarget = await ctx.fs.resolve(join9(sourcePath, "chat_history.jsonl"));
11728
+ const summaryTarget = await ctx.fs.resolve(join11(sourcePath, "summary.json"));
11729
+ const chatTarget = await ctx.fs.resolve(join11(sourcePath, "chat_history.jsonl"));
9936
11730
  return previewConverted(convertGrokbuildJson(await ctx.fs.readText(summaryTarget), await readGrokHistory(ctx, chatTarget), { ...args, sourcePath }), args);
9937
11731
  }
9938
11732
  async function previewGrokbuildDirectory(ctx, dirTarget, args) {
@@ -9953,7 +11747,7 @@ async function previewHermesFile(ctx, target, args) {
9953
11747
  }
9954
11748
  async function previewHermesDirectory(ctx, dirTarget, args) {
9955
11749
  const dirPath = dirTarget.displayPath || ctx.fs.processPath(dirTarget);
9956
- const dbPath = join9(dirPath, "state.db");
11750
+ const dbPath = join11(dirPath, "state.db");
9957
11751
  const dbTarget = await ctx.fs.resolve(dbPath);
9958
11752
  const dbSessions = readHermesDb(dbPath);
9959
11753
  if (dbSessions !== null) return previewHermesDbFile(ctx, dbTarget, args, { sessions: dbSessions });
@@ -9975,10 +11769,10 @@ async function previewKimiDirectory(ctx, dirTarget, args) {
9975
11769
  return previewEach(ctx, sessions, (target) => previewKimiSession(ctx, target, args));
9976
11770
  }
9977
11771
 
9978
- // .codex-tmp/vendor-pagination-upstream/lib/tools/source-derive.mjs
9979
- import { join as join10 } from "node:path";
11772
+ // .codex-tmp/chat-import-0263/package/lib/tools/source-derive.mjs
11773
+ import { join as join12 } from "node:path";
9980
11774
 
9981
- // .codex-tmp/vendor-pagination-upstream/lib/convert/reasonix-lineage.mjs
11775
+ // .codex-tmp/chat-import-0263/package/lib/convert/reasonix-lineage.mjs
9982
11776
  import { createHash as createHash3 } from "node:crypto";
9983
11777
  var VOLATILE_KEYS = /* @__PURE__ */ new Set([
9984
11778
  "id",
@@ -10154,7 +11948,7 @@ function selectReasonixMaximalBranches(candidates) {
10154
11948
  return { selected, covered, groups };
10155
11949
  }
10156
11950
 
10157
- // .codex-tmp/vendor-pagination-upstream/lib/tools/source-derive.mjs
11951
+ // .codex-tmp/chat-import-0263/package/lib/tools/source-derive.mjs
10158
11952
  function targetPath(ctx, target) {
10159
11953
  return target.displayPath || ctx.fs.processPath(target);
10160
11954
  }
@@ -10189,20 +11983,20 @@ async function antigravityDeriveArgs(ctx, target) {
10189
11983
  const antigravityId = m[2];
10190
11984
  const derived = { antigravityId };
10191
11985
  try {
10192
- const annoTarget = await ctx.fs.resolve(join10(brainDir, "..", "..", "annotations", antigravityId + ".pbtxt"));
11986
+ const annoTarget = await ctx.fs.resolve(join12(brainDir, "..", "..", "annotations", antigravityId + ".pbtxt"));
10193
11987
  const annoTitle = parseAnnotationTitle(await ctx.fs.readText(annoTarget));
10194
11988
  if (annoTitle) derived.annotationTitle = annoTitle;
10195
11989
  } catch {
10196
11990
  }
10197
11991
  try {
10198
- const msgTarget = await ctx.fs.resolve(join10(brainDir, ".system_generated", "messages"));
11992
+ const msgTarget = await ctx.fs.resolve(join12(brainDir, ".system_generated", "messages"));
10199
11993
  const names = await ctx.fs.listDir(msgTarget);
10200
11994
  if (Array.isArray(names) && names.length > 0) {
10201
11995
  const recs = [];
10202
11996
  for (const entry of names) {
10203
11997
  const name = typeof entry === "string" ? entry : entry && entry.name;
10204
11998
  if (!name || !name.endsWith(".json")) continue;
10205
- const raw = await ctx.fs.readText(await ctx.fs.resolve(join10(brainDir, ".system_generated", "messages", name)));
11999
+ const raw = await ctx.fs.readText(await ctx.fs.resolve(join12(brainDir, ".system_generated", "messages", name)));
10206
12000
  if (raw === null || raw === "") continue;
10207
12001
  try {
10208
12002
  recs.push(JSON.parse(raw));
@@ -10311,7 +12105,7 @@ function reasonixDesktopLayout(path) {
10311
12105
  return { slug: segs[sessionsIdx - 1], sessionsDir: value.slice(0, end) };
10312
12106
  }
10313
12107
  async function readReasonixTitle(ctx, sessionsDir, stem) {
10314
- const titlesPath = join10(sessionsDir, ".titles.json");
12108
+ const titlesPath = join12(sessionsDir, ".titles.json");
10315
12109
  try {
10316
12110
  const target = await ctx.fs.resolve(titlesPath);
10317
12111
  const st = await ctx.fs.stat(target);
@@ -10372,7 +12166,7 @@ async function openclawDeriveArgs(ctx, target) {
10372
12166
  const derived = { openclawId: stem };
10373
12167
  try {
10374
12168
  const dirPath = String(p).replace(/[\\/][^\\/]*\.jsonl$/i, "");
10375
- const indexTarget = await ctx.fs.resolve(join10(dirPath, "sessions.json"));
12169
+ const indexTarget = await ctx.fs.resolve(join12(dirPath, "sessions.json"));
10376
12170
  const name = openclawDisplayNames(await ctx.fs.readText(indexTarget)).get(stem);
10377
12171
  if (name) derived.displayName = name;
10378
12172
  } catch {
@@ -10385,7 +12179,7 @@ async function continueDeriveArgs(ctx, target) {
10385
12179
  const derived = { continueId: stem };
10386
12180
  try {
10387
12181
  const dirPath = String(p).replace(/[\\/][^\\/]*\.json$/i, "");
10388
- const indexTarget = await ctx.fs.resolve(join10(dirPath, "sessions.json"));
12182
+ const indexTarget = await ctx.fs.resolve(join12(dirPath, "sessions.json"));
10389
12183
  const known = readContinueIndex(await ctx.fs.readText(indexTarget)).get(stem);
10390
12184
  if (known && Number.isFinite(known.createdAt)) derived.createdAt = known.createdAt;
10391
12185
  } catch {
@@ -10393,7 +12187,7 @@ async function continueDeriveArgs(ctx, target) {
10393
12187
  return derived;
10394
12188
  }
10395
12189
 
10396
- // .codex-tmp/vendor-pagination-upstream/lib/tools/import-sources.mjs
12190
+ // .codex-tmp/chat-import-0263/package/lib/tools/import-sources.mjs
10397
12191
  var FULL_HISTORY_KEYS = Object.freeze(["fullHistory"]);
10398
12192
  var SESSION_LABEL = Object.freeze({ batch: "\u4F1A\u8BDD", skipped: "\u65E0\u7528\u6237\u56DE\u5408" });
10399
12193
  function sourceIo([importFile, importDir, previewFile, previewDir], opts, extra = {}) {
@@ -10404,10 +12198,11 @@ function sourceIo([importFile, importDir, previewFile, previewDir], opts, extra
10404
12198
  };
10405
12199
  }
10406
12200
  function buildImportSources(ctx, registryDir) {
10407
- const registry = Object.freeze({ dir: registryDir });
10408
- const fullHistoryRegistry = Object.freeze({ dir: registryDir, fingerprintKeys: FULL_HISTORY_KEYS });
10409
- const hostOpts = Object.freeze({ registryDir });
10410
- const fullHistoryOpts = Object.freeze({ ...hostOpts, fingerprintKeys: FULL_HISTORY_KEYS });
12201
+ const destinationKeys = DESTINATION_FINGERPRINT_KEYS;
12202
+ const registry = Object.freeze({ dir: registryDir, fingerprintKeys: destinationKeys });
12203
+ const fullHistoryRegistry = Object.freeze({ dir: registryDir, fingerprintKeys: [...FULL_HISTORY_KEYS, ...destinationKeys] });
12204
+ const hostOpts = Object.freeze({ registryDir, fingerprintKeys: destinationKeys });
12205
+ const fullHistoryOpts = Object.freeze({ ...hostOpts, fingerprintKeys: [...FULL_HISTORY_KEYS, ...destinationKeys] });
10411
12206
  const stemArgs = (key) => (target) => ({ [key]: fileStem(targetPath(ctx, target)) });
10412
12207
  return [
10413
12208
  // claude:文件名 stem 传给转换器做「主 transcript」判定(subagent/workflow 辅助
@@ -10421,7 +12216,7 @@ function buildImportSources(ctx, registryDir) {
10421
12216
  fullHistory: true,
10422
12217
  sourceLabel: "Claude Code",
10423
12218
  convert: convertClaudeJsonl,
10424
- registry: { dir: registryDir, fingerprintKeys: [...FULL_HISTORY_KEYS, "includeToolUseResult"] },
12219
+ registry: { dir: registryDir, fingerprintKeys: [...FULL_HISTORY_KEYS, "includeToolUseResult", ...DESTINATION_FINGERPRINT_KEYS] },
10425
12220
  derive: { args: stemArgs("fileStem") }
10426
12221
  },
10427
12222
  // codex:rollout 文件(新版会把一个会话拆成多个分页文件)——任意一页都解析整链一次
@@ -10541,6 +12336,22 @@ function buildImportSources(ctx, registryDir) {
10541
12336
  label: SESSION_LABEL,
10542
12337
  multiSession: true
10543
12338
  },
12339
+ // 豆包桌面版:库是 Chromium IndexedDB 的 LevelDB **目录**(不是单文件),一库多会话恒批量。
12340
+ // 目录模式接受「用户数据根 / profile / IndexedDB 目录 / 具体库目录」;只有本地确实缓存了
12341
+ // 正文的会话会被列出与导入(豆包的历史正文留在服务端),见 lib/sources/doubao.mjs。
12342
+ {
12343
+ format: "doubao",
12344
+ sourceLabel: "Doubao",
12345
+ convert: convertDoubaoSession,
12346
+ io: sourceIo(
12347
+ [void 0, void 0, previewDoubaoDirectory, previewDoubaoDirectory],
12348
+ hostOpts,
12349
+ { alwaysBatch: true }
12350
+ ),
12351
+ registry,
12352
+ label: SESSION_LABEL,
12353
+ multiSession: true
12354
+ },
10544
12355
  // Mistral Vibe CLI:~/.vibe/logs/session/<session_dir>/(messages.jsonl + meta.json);
10545
12356
  // 会话目录本身是一个会话(dirSingle)
10546
12357
  {
@@ -10621,6 +12432,16 @@ function buildImportSources(ctx, registryDir) {
10621
12432
  registry: fullHistoryRegistry,
10622
12433
  derive: { args: stemArgs("piId") }
10623
12434
  },
12435
+ // omp(oh-my-pi):与 pi 同族(转换共用 lib/convert/pi-family.mjs)。除压缩检查点外,
12436
+ // fullHistory 还决定要不要按 reset_boundary(/clear)切掉清空点之前的内容。
12437
+ {
12438
+ format: "omp",
12439
+ fullHistory: true,
12440
+ sourceLabel: "oh-my-pi",
12441
+ convert: convertOmpJsonl,
12442
+ registry: fullHistoryRegistry,
12443
+ derive: { args: stemArgs("ompId") }
12444
+ },
10624
12445
  // kimi:会话目录(旧 wire.jsonl 或新 agents/main/wire.jsonl)视作单源(dirSingle,
10625
12446
  // 单会话导入器内部派生 kimiId/cwd/title),sessions 根走批量;subagents/ 子代理
10626
12447
  // wire 不并入主线程。单 wire.jsonl 文件由 derive.args 预先派生。
@@ -10641,7 +12462,15 @@ function buildImportSources(ctx, registryDir) {
10641
12462
  },
10642
12463
  // qoder:文件名 stem 传给转换器做「主 transcript」判定(<sessionId>/subagents/*.jsonl
10643
12464
  // 辅助 transcript 记录携带父 sessionId)
10644
- { format: "qoder", sourceLabel: "Qoder CLI", convert: convertQoderJsonl, registry, derive: { args: stemArgs("fileStem") } },
12465
+ {
12466
+ format: "qoder",
12467
+ // 压缩感知来源:fullHistory 改变转换产物(写不写原生压缩检查点),进参数指纹
12468
+ fullHistory: true,
12469
+ sourceLabel: "Qoder CLI",
12470
+ convert: convertQoderJsonl,
12471
+ registry: fullHistoryRegistry,
12472
+ derive: { args: stemArgs("fileStem") }
12473
+ },
10645
12474
  // workbuddy:文件名 stem(session-uuid)作稳定源 id 兜底(事件内 sessionId 优先)
10646
12475
  { format: "workbuddy", sourceLabel: "WorkBuddy", convert: convertWorkbuddyJsonl, registry, derive: { args: stemArgs("workbuddyId") } },
10647
12476
  // qwen(千问办公):文件名 stem 与记录 sessionId 的一致性由转换器校验(双 slug 副本
@@ -10656,6 +12485,26 @@ function buildImportSources(ctx, registryDir) {
10656
12485
  registry: fullHistoryRegistry,
10657
12486
  derive: { args: (target) => continueDeriveArgs(ctx, target) }
10658
12487
  },
12488
+ {
12489
+ format: "copilot-vscode",
12490
+ sourceLabel: "Copilot VS Code",
12491
+ convert: convertCopilotVscodeJson,
12492
+ registry,
12493
+ derive: {
12494
+ args: (target) => copilotVscodeDeriveArgs(ctx, target),
12495
+ collect: collectCopilotVscodeFiles
12496
+ }
12497
+ },
12498
+ // copilot-cli:events.jsonl 一流一会话(cwd / 会话 id 在 session.start 里,无需旁读派生);
12499
+ // 压缩感知来源:fullHistory 改变转换产物(写不写原生压缩检查点),进参数指纹
12500
+ {
12501
+ format: "copilot-cli",
12502
+ fullHistory: true,
12503
+ sourceLabel: "Copilot CLI",
12504
+ convert: convertCopilotCliJsonl,
12505
+ registry: fullHistoryRegistry,
12506
+ derive: { collect: collectCopilotCliFiles }
12507
+ },
10659
12508
  // cline:元数据 DB 优先(<dataDir>/db/sessions.db 的 sessions 表:cwd/started_at/
10660
12509
  // metadata_json.title),manifest 的 metadata.title 补齐权威标题;现代目录导入只收
10661
12510
  // <sessionId>.messages.json,legacy VS Code globalStorage 目录则收
@@ -10736,11 +12585,11 @@ function buildImportSources(ctx, registryDir) {
10736
12585
  ];
10737
12586
  }
10738
12587
 
10739
- // .codex-tmp/vendor-pagination-upstream/lib/discovery/registry.mjs
12588
+ // .codex-tmp/chat-import-0263/package/lib/discovery/registry.mjs
10740
12589
  import { homedir as homedir4 } from "node:os";
10741
12590
 
10742
- // .codex-tmp/vendor-pagination-upstream/lib/discovery/claude.mjs
10743
- import { join as join11 } from "node:path";
12591
+ // .codex-tmp/chat-import-0263/package/lib/discovery/claude.mjs
12592
+ import { join as join13 } from "node:path";
10744
12593
  function claudeLayoutProject(sourcePath) {
10745
12594
  const m = slashPath(sourcePath).match(/\/projects\/([^/]+)\/[^/]+\.jsonl$/i);
10746
12595
  return m ? m[1] : null;
@@ -10760,8 +12609,8 @@ var claudeSource = {
10760
12609
  format: "claude",
10761
12610
  // Claude-3p 新端(Windows LOCALAPPDATA)元数据根与 ~/.claude/projects 并列
10762
12611
  roots: (home, env) => {
10763
- const projects = join11(home, ".claude", "projects");
10764
- return env.LOCALAPPDATA ? [projects, join11(env.LOCALAPPDATA, "Claude-3p", "claude-code-sessions")] : projects;
12612
+ const projects = join13(home, ".claude", "projects");
12613
+ return env.LOCALAPPDATA ? [projects, join13(env.LOCALAPPDATA, "Claude-3p", "claude-code-sessions")] : projects;
10765
12614
  },
10766
12615
  layoutProject: claudeLayoutProject,
10767
12616
  matchFile: (lower) => isJsonl(lower) && /\.claude[\\/]/.test(lower),
@@ -10769,24 +12618,26 @@ var claudeSource = {
10769
12618
  };
10770
12619
  var qoderSource = {
10771
12620
  format: "qoder",
10772
- roots: (home) => join11(home, ".qoder", "projects"),
12621
+ // Qoder CN 的根与 intl 根并列(缺失的根由 walkFiles 静默落空):两版安装可并存,
12622
+ // 会话各自落在自己的根下,一并扫才对得齐用户侧看到的「Qoder 会话」。
12623
+ roots: (home) => [join13(home, ".qoder", "projects"), join13(home, ".qoder-cn", "projects")],
10773
12624
  layoutProject: qoderLayoutProject,
10774
- matchFile: (lower) => isJsonl(lower) && /\.qoder[\\/]projects[\\/]/.test(lower)
12625
+ matchFile: (lower) => isJsonl(lower) && /\.qoder(?:-cn)?[\\/]projects[\\/]/.test(lower)
10775
12626
  };
10776
12627
  var workbuddySource = {
10777
12628
  format: "workbuddy",
10778
- roots: (home) => join11(home, ".workbuddy", "projects"),
12629
+ roots: (home) => join13(home, ".workbuddy", "projects"),
10779
12630
  layoutProject: workbuddyLayoutProject,
10780
12631
  matchFile: (lower) => isJsonl(lower) && /\.workbuddy[\\/]projects[\\/]/.test(lower)
10781
12632
  };
10782
12633
  var qwenSource = {
10783
12634
  format: "qwen",
10784
- roots: (home) => join11(home, ".qwenworkcn", "projects"),
12635
+ roots: (home) => join13(home, ".qwenworkcn", "projects"),
10785
12636
  matchFile: (lower) => isJsonl(lower) && /\.qwenworkcn[\\/]projects[\\/]/.test(lower)
10786
12637
  };
10787
12638
 
10788
- // .codex-tmp/vendor-pagination-upstream/lib/discovery/jsonl.mjs
10789
- import { join as join12 } from "node:path";
12639
+ // .codex-tmp/chat-import-0263/package/lib/discovery/jsonl.mjs
12640
+ import { join as join14 } from "node:path";
10790
12641
  function codexLayoutProject(sourcePath) {
10791
12642
  const m = slashPath(sourcePath).match(/\/sessions\/(\d{4})\/(\d{2})\//);
10792
12643
  return m ? m[1] + "/" + m[2] : null;
@@ -10807,14 +12658,14 @@ var isJsonl2 = (lower) => lower.endsWith(".jsonl");
10807
12658
  var codexSource = {
10808
12659
  format: "codex",
10809
12660
  // sessions/YYYY/MM/DD/ 与扁平的 archived_sessions/ 双根
10810
- roots: (home) => [join12(home, ".codex", "sessions"), join12(home, ".codex", "archived_sessions")],
12661
+ roots: (home) => [join14(home, ".codex", "sessions"), join14(home, ".codex", "archived_sessions")],
10811
12662
  layoutProject: codexLayoutProject,
10812
12663
  matchFile: (lower) => isJsonl2(lower) && /(^|[\\/])rollout-/.test(lower),
10813
12664
  fileFallback: ["jsonl"]
10814
12665
  };
10815
12666
  var cursorSource = {
10816
12667
  format: "cursor",
10817
- roots: (home) => join12(home, ".cursor", "projects"),
12668
+ roots: (home) => join14(home, ".cursor", "projects"),
10818
12669
  layoutProject: cursorLayoutProject,
10819
12670
  matchFile: (lower) => isJsonl2(lower) && /\bagent-transcripts\b/.test(lower),
10820
12671
  fileFallback: ["jsonl"]
@@ -10823,8 +12674,8 @@ var reasonixSource = {
10823
12674
  format: "reasonix",
10824
12675
  // CLI 会话目录 + 桌面版状态根(Windows APPDATA;无此变量的平台只扫 CLI 根)
10825
12676
  roots: (home, env) => {
10826
- const cli = join12(home, ".reasonix", "sessions");
10827
- return env.APPDATA ? [cli, join12(env.APPDATA, "reasonix")] : cli;
12677
+ const cli = join14(home, ".reasonix", "sessions");
12678
+ return env.APPDATA ? [cli, join14(env.APPDATA, "reasonix")] : cli;
10828
12679
  },
10829
12680
  layoutProject: reasonixLayoutProject,
10830
12681
  matchFile: (lower) => isJsonl2(lower) && /(^|[\\/])(desktop|subagent)-/.test(lower),
@@ -10832,20 +12683,26 @@ var reasonixSource = {
10832
12683
  };
10833
12684
  var openclawSource = {
10834
12685
  format: "openclaw",
10835
- roots: (home) => join12(home, ".openclaw", "agents"),
12686
+ roots: (home) => join14(home, ".openclaw", "agents"),
10836
12687
  layoutProject: openclawLayoutProject,
10837
12688
  matchFile: (lower) => isJsonl2(lower) && /\bagents\b.*\bsessions\b/.test(lower),
10838
12689
  fileFallback: ["jsonl"]
10839
12690
  };
10840
12691
  var piSource = {
10841
12692
  format: "pi",
10842
- roots: (home) => join12(home, ".pi", "agent", "sessions"),
12693
+ roots: (home) => join14(home, ".pi", "agent", "sessions"),
10843
12694
  // 无路径特征时不进通用 JSONL 回退(会话头签名与 hermes/openclaw 的 session 头相近)
10844
12695
  matchFile: (lower) => isJsonl2(lower) && /\.pi[\\/]agent[\\/]sessions[\\/]/.test(lower)
10845
12696
  };
12697
+ var ompSource = {
12698
+ format: "omp",
12699
+ roots: (home) => join14(home, ".omp", "agent", "sessions"),
12700
+ // 同上:头签名与 pi/hermes/openclaw 相近,只认路径特征(.omp/agent/sessions/)
12701
+ matchFile: (lower) => isJsonl2(lower) && /\.omp[\\/]agent[\\/]sessions[\\/]/.test(lower)
12702
+ };
10846
12703
 
10847
- // .codex-tmp/vendor-pagination-upstream/lib/discovery/gemini.mjs
10848
- import { join as join13 } from "node:path";
12704
+ // .codex-tmp/chat-import-0263/package/lib/discovery/gemini.mjs
12705
+ import { join as join15 } from "node:path";
10849
12706
  function geminiLayoutProject(sourcePath) {
10850
12707
  const m = slashPath(sourcePath).match(/\/history\/([^/]+)\/chats\//);
10851
12708
  return m ? m[1] : null;
@@ -10855,7 +12712,7 @@ function antigravityLayoutProject(sourcePath) {
10855
12712
  }
10856
12713
  var geminiSource = {
10857
12714
  format: "gemini",
10858
- roots: (home) => join13(home, ".gemini", "history"),
12715
+ roots: (home) => join15(home, ".gemini", "history"),
10859
12716
  layoutProject: geminiLayoutProject,
10860
12717
  fileFallback: ["json"]
10861
12718
  };
@@ -10864,26 +12721,26 @@ var antigravitySource = {
10864
12721
  // 根随产品版本分化(2.0 / 部分 IDE 用 antigravity、旧 CLI 用 antigravity-cli、另一些 IDE
10865
12722
  // 发行用 antigravity-ide),内层布局相同,三根并列扫——缺失的根由 walkFiles 静默落空。
10866
12723
  roots: (home) => [
10867
- join13(home, ".gemini", "antigravity"),
10868
- join13(home, ".gemini", "antigravity-cli"),
10869
- join13(home, ".gemini", "antigravity-ide")
12724
+ join15(home, ".gemini", "antigravity"),
12725
+ join15(home, ".gemini", "antigravity-cli"),
12726
+ join15(home, ".gemini", "antigravity-ide")
10870
12727
  ],
10871
12728
  layoutProject: antigravityLayoutProject
10872
12729
  };
10873
12730
 
10874
- // .codex-tmp/vendor-pagination-upstream/lib/discovery/sqlite.mjs
10875
- import { join as join14 } from "node:path";
12731
+ // .codex-tmp/chat-import-0263/package/lib/discovery/sqlite.mjs
12732
+ import { join as join16 } from "node:path";
10876
12733
  function traeUserDataDirs(home, env = process.env) {
10877
12734
  const names = ["Trae", "Trae CN", "TRAE SOLO CN", "TRAE SOLO"];
10878
12735
  if (process.platform === "win32") {
10879
12736
  if (!env.APPDATA) return [];
10880
- return names.map((name) => join14(env.APPDATA, name, "User"));
12737
+ return names.map((name) => join16(env.APPDATA, name, "User"));
10881
12738
  }
10882
12739
  if (process.platform === "darwin") {
10883
- return names.map((name) => join14(home, "Library", "Application Support", name, "User"));
12740
+ return names.map((name) => join16(home, "Library", "Application Support", name, "User"));
10884
12741
  }
10885
- const configHome = env.XDG_CONFIG_HOME || join14(home, ".config");
10886
- return names.map((name) => join14(configHome, name, "User"));
12742
+ const configHome = env.XDG_CONFIG_HOME || join16(home, ".config");
12743
+ return names.map((name) => join16(configHome, name, "User"));
10887
12744
  }
10888
12745
  async function sqliteFingerprint(host, dbStat, dbPath) {
10889
12746
  const side = [];
@@ -10898,7 +12755,7 @@ async function scanSqlite(host, format, target, dbName, { bm, emit }) {
10898
12755
  if (!st) return [];
10899
12756
  let dbPath = target;
10900
12757
  if (st.type === "directory") {
10901
- const candidate = join14(target, dbName);
12758
+ const candidate = join16(target, dbName);
10902
12759
  const cst = await host.stat(candidate);
10903
12760
  if (!cst || cst.type !== "file") return [];
10904
12761
  dbPath = candidate;
@@ -10932,26 +12789,26 @@ var isDb = (lower) => lower.endsWith(".db");
10932
12789
  var opencodeSource = {
10933
12790
  format: "opencode",
10934
12791
  sessionsFromHost: true,
10935
- roots: (home) => join14(home, ".local", "share", "opencode", "opencode.db"),
12792
+ roots: (home) => join16(home, ".local", "share", "opencode", "opencode.db"),
10936
12793
  matchFile: (lower) => /opencode\.db$/.test(lower),
10937
12794
  fileFallback: ["db"]
10938
12795
  };
10939
12796
  var mimocodeSource = {
10940
12797
  format: "mimocode",
10941
12798
  sessionsFromHost: true,
10942
- roots: (home) => join14(home, ".local", "share", "mimocode", "mimocode.db"),
12799
+ roots: (home) => join16(home, ".local", "share", "mimocode", "mimocode.db"),
10943
12800
  matchFile: (lower) => /mimocode\.db$/.test(lower)
10944
12801
  };
10945
12802
  var kilocodeSource = {
10946
12803
  format: "kilocode",
10947
12804
  sessionsFromHost: true,
10948
- roots: (home) => join14(home, ".local", "share", "kilo", "kilo.db"),
12805
+ roots: (home) => join16(home, ".local", "share", "kilo", "kilo.db"),
10949
12806
  matchFile: (lower) => /kilo\.db$/.test(lower)
10950
12807
  };
10951
12808
  var zcodeSource = {
10952
12809
  format: "zcode",
10953
12810
  sessionsFromHost: true,
10954
- roots: (home) => join14(home, ".zcode", "cli", "db", "db.sqlite"),
12811
+ roots: (home) => join16(home, ".zcode", "cli", "db", "db.sqlite"),
10955
12812
  matchFile: (lower) => /db\.sqlite$/.test(lower),
10956
12813
  fileFallback: ["db"]
10957
12814
  };
@@ -10960,7 +12817,7 @@ var teleagentSource = {
10960
12817
  sessionsFromHost: true,
10961
12818
  // XDG 风格多账户目录(Windows 上同样在 ~/.local/share):根给到 users/ 层,扫描器枚举
10962
12819
  // 账户目录取各库(<账户>/teleagent.db)
10963
- roots: (home) => join14(home, ".local", "share", "TeleAgent", "users"),
12820
+ roots: (home) => join16(home, ".local", "share", "TeleAgent", "users"),
10964
12821
  matchFile: (lower) => /teleagent\.db$/.test(lower)
10965
12822
  };
10966
12823
  var gooseSource = {
@@ -10996,20 +12853,20 @@ var traeSource = {
10996
12853
  var hermesSource = {
10997
12854
  format: "hermes",
10998
12855
  sessionsFromHost: true,
10999
- roots: (home, env = process.env) => process.platform === "win32" ? [join14(env.LOCALAPPDATA || join14(home, "AppData", "Local"), "hermes"), join14(home, ".hermes")] : join14(home, ".hermes"),
12856
+ roots: (home, env = process.env) => process.platform === "win32" ? [join16(env.LOCALAPPDATA || join16(home, "AppData", "Local"), "hermes"), join16(home, ".hermes")] : join16(home, ".hermes"),
11000
12857
  matchFile: (lower) => lower.endsWith(".jsonl") && /\.hermes[\\/]/.test(lower) || isDb(lower) && /state\.db$/.test(lower),
11001
12858
  fileFallback: ["jsonl", "db"]
11002
12859
  };
11003
12860
 
11004
- // .codex-tmp/vendor-pagination-upstream/lib/discovery/cline.mjs
11005
- import { join as join15 } from "node:path";
12861
+ // .codex-tmp/chat-import-0263/package/lib/discovery/cline.mjs
12862
+ import { join as join17 } from "node:path";
11006
12863
  function clineDataDir(home, env) {
11007
12864
  if (env.CLINE_DATA_DIR) return env.CLINE_DATA_DIR;
11008
- const clineDir = env.CLINE_DIR || join15(home, ".cline");
11009
- return join15(clineDir, "data");
12865
+ const clineDir = env.CLINE_DIR || join17(home, ".cline");
12866
+ return join17(clineDir, "data");
11010
12867
  }
11011
12868
  function clineSessionsDir(home, env) {
11012
- return env.CLINE_SESSION_DATA_DIR || join15(clineDataDir(home, env), "sessions");
12869
+ return env.CLINE_SESSION_DATA_DIR || join17(clineDataDir(home, env), "sessions");
11013
12870
  }
11014
12871
  function clineLegacyStorageDirs(home, env = process.env) {
11015
12872
  const override = env.CLINE_LEGACY_GLOBAL_STORAGE_DIR || env.CLINE_VSCODE_GLOBAL_STORAGE_DIR;
@@ -11017,13 +12874,13 @@ function clineLegacyStorageDirs(home, env = process.env) {
11017
12874
  const names = ["Code", "Code - Insiders", "VSCodium"];
11018
12875
  if (process.platform === "win32") {
11019
12876
  if (!env.APPDATA) return [];
11020
- return names.map((name) => join15(env.APPDATA, name, "User", "globalStorage", "saoudrizwan.claude-dev"));
12877
+ return names.map((name) => join17(env.APPDATA, name, "User", "globalStorage", "saoudrizwan.claude-dev"));
11021
12878
  }
11022
12879
  if (process.platform === "darwin") {
11023
- return names.map((name) => join15(home, "Library", "Application Support", name, "User", "globalStorage", "saoudrizwan.claude-dev"));
12880
+ return names.map((name) => join17(home, "Library", "Application Support", name, "User", "globalStorage", "saoudrizwan.claude-dev"));
11024
12881
  }
11025
- const configHome = env.XDG_CONFIG_HOME || join15(home, ".config");
11026
- return names.map((name) => join15(configHome, name, "User", "globalStorage", "saoudrizwan.claude-dev"));
12882
+ const configHome = env.XDG_CONFIG_HOME || join17(home, ".config");
12883
+ return names.map((name) => join17(configHome, name, "User", "globalStorage", "saoudrizwan.claude-dev"));
11027
12884
  }
11028
12885
  var clineSource = {
11029
12886
  format: "cline",
@@ -11038,13 +12895,24 @@ var clineSource = {
11038
12895
  }
11039
12896
  };
11040
12897
 
11041
- // .codex-tmp/vendor-pagination-upstream/lib/discovery/documents.mjs
11042
- import { join as join16 } from "node:path";
12898
+ // .codex-tmp/chat-import-0263/package/lib/discovery/indexeddb.mjs
12899
+ var doubaoSource = {
12900
+ format: "doubao",
12901
+ // 摘要读取器在 host 侧(lib/discovery-host.mjs 的 DB_SUMMARY_FORMATS)
12902
+ sessionsFromHost: true,
12903
+ // 默认根:Windows %LOCALAPPDATA%\Doubao\User Data;macOS/Linux 按 Electron 默认 appData
12904
+ roots: (home, env) => doubaoUserDataDirs(home, env)
12905
+ // 单文件形态不存在(库是目录),所以不给 matchFile / fileFallback:显式传某库目录或
12906
+ // IndexedDB 目录即可发现。
12907
+ };
12908
+
12909
+ // .codex-tmp/chat-import-0263/package/lib/discovery/documents.mjs
12910
+ import { join as join18 } from "node:path";
11043
12911
  var continueSource = {
11044
12912
  format: "continue",
11045
12913
  // 全局单一会话目录(VS Code / JetBrains / CLI 三端共用);与 Continue core 同序:
11046
12914
  // $CONTINUE_GLOBAL_DIR 优先、否则 ~/.continue
11047
- roots: (home, env) => env.CONTINUE_GLOBAL_DIR ? join16(env.CONTINUE_GLOBAL_DIR, "sessions") : join16(home, ".continue", "sessions"),
12915
+ roots: (home, env) => env.CONTINUE_GLOBAL_DIR ? join18(env.CONTINUE_GLOBAL_DIR, "sessions") : join18(home, ".continue", "sessions"),
11048
12916
  // 会话文件是单个 JSON 对象且路径特征唯一 → 独占,不落到 gemini/chatgpt 探测
11049
12917
  matchFile: (lower) => lower.endsWith(".json") && /(^|[\\/])\.continue[\\/]sessions[\\/]/.test(lower) ? "only" : false
11050
12918
  };
@@ -11055,8 +12923,8 @@ var chatgptSource = {
11055
12923
  fileFallback: ["json"]
11056
12924
  };
11057
12925
 
11058
- // .codex-tmp/vendor-pagination-upstream/lib/discovery/dsh.mjs
11059
- import { join as join17 } from "node:path";
12926
+ // .codex-tmp/chat-import-0263/package/lib/discovery/dsh.mjs
12927
+ import { join as join19 } from "node:path";
11060
12928
  function decodeDshProjectKey(encoded) {
11061
12929
  return String(encoded).replace(/~([0-9A-Fa-f]{4})/g, (_, hex) => String.fromCharCode(parseInt(hex, 16)));
11062
12930
  }
@@ -11069,7 +12937,7 @@ function dshLayoutProject(sourcePath) {
11069
12937
  function dshFormatOf(fileName) {
11070
12938
  return (dshSessionLogVersion(fileName) ?? 0) >= 4 ? "dsh4" : "dsh";
11071
12939
  }
11072
- var dshRoots = (home, env) => join17(env.DSH_HOME || join17(home, ".dsh"), "sessions");
12940
+ var dshRoots = (home, env) => join19(env.DSH_HOME || join19(home, ".dsh"), "sessions");
11073
12941
  var dshMatchFile = (format) => (lower, base) => /(^|[\\/])sessions[\\/]/.test(lower) && isDshSessionFile(base) && dshFormatOf(base) === format ? "only" : false;
11074
12942
  var dshSource = {
11075
12943
  format: "dsh",
@@ -11084,7 +12952,36 @@ var dsh4Source = {
11084
12952
  matchFile: dshMatchFile("dsh4")
11085
12953
  };
11086
12954
 
11087
- // .codex-tmp/vendor-pagination-upstream/lib/discovery/registry.mjs
12955
+ // .codex-tmp/chat-import-0263/package/lib/discovery/copilot-vscode.mjs
12956
+ function copilotVscodeRoots(home, env = {}, platform = process.platform) {
12957
+ if (isAbsoluteLike(env.COPILOT_VSCODE_STORAGE_DIR || "")) return [env.COPILOT_VSCODE_STORAGE_DIR];
12958
+ const path = (...parts) => joinForPlatform(platform, ...parts);
12959
+ let base;
12960
+ if (platform === "win32") base = env.APPDATA || path(home, "AppData", "Roaming");
12961
+ else if (platform === "darwin") base = path(home, "Library", "Application Support");
12962
+ else base = isAbsoluteLike(env.XDG_CONFIG_HOME || "") ? env.XDG_CONFIG_HOME : path(home, ".config");
12963
+ return ["Code", "Code - Insiders", "VSCodium"].map((name) => path(base, name, "User", "workspaceStorage"));
12964
+ }
12965
+ var copilotVscodeSource = {
12966
+ format: "copilot-vscode",
12967
+ roots: copilotVscodeRoots,
12968
+ matchFile: (lower) => /[\\/]chatsessions[\\/][^\\/]+\.json$/.test(lower) ? "only" : false,
12969
+ fileFallback: ["json"]
12970
+ };
12971
+
12972
+ // .codex-tmp/chat-import-0263/package/lib/discovery/copilot-cli.mjs
12973
+ function copilotCliRoots(home, env = {}, platform = process.platform) {
12974
+ if (isAbsoluteLike(env.COPILOT_HOME || "")) return [joinForPlatform(platform, env.COPILOT_HOME, "session-state")];
12975
+ return [joinForPlatform(platform, home, ".copilot", "session-state")];
12976
+ }
12977
+ var copilotCliSource = {
12978
+ format: "copilot-cli",
12979
+ roots: copilotCliRoots,
12980
+ matchFile: (lower) => /(^|[\\/])session-state[\\/][^\\/]+[\\/]events\.jsonl$/.test(lower) ? "only" : false,
12981
+ fileFallback: ["jsonl"]
12982
+ };
12983
+
12984
+ // .codex-tmp/chat-import-0263/package/lib/discovery/registry.mjs
11088
12985
  var SOURCES = Object.freeze([
11089
12986
  claudeSource,
11090
12987
  codexSource,
@@ -11098,6 +12995,7 @@ var SOURCES = Object.freeze([
11098
12995
  grokbuildSource,
11099
12996
  openclawSource,
11100
12997
  piSource,
12998
+ ompSource,
11101
12999
  hermesSource,
11102
13000
  kimiSource,
11103
13001
  kilocodeSource,
@@ -11113,8 +13011,11 @@ var SOURCES = Object.freeze([
11113
13011
  crushSource,
11114
13012
  teleagentSource,
11115
13013
  traeSource,
13014
+ doubaoSource,
11116
13015
  vibeSource,
11117
- dshSource
13016
+ dshSource,
13017
+ copilotVscodeSource,
13018
+ copilotCliSource
11118
13019
  ]);
11119
13020
  var FORMATS = SOURCES.map((s) => s.format);
11120
13021
  var BY_FORMAT = new Map(SOURCES.map((s) => [s.format, s]));
@@ -11131,7 +13032,7 @@ async function readConversation(fs, input, signal) {
11131
13032
  const target = await fs.resolve(input.path);
11132
13033
  const info = await fs.stat(target);
11133
13034
  if (!info) throw new Error("Conversation source not found: " + input.path);
11134
- if (info.type === "directory" && !await spec.io?.dirSingle?.(ctx, target)) {
13035
+ if (info.type === "directory" && !await spec.io?.dirSingle?.(ctx, target) && !(input.format === "doubao" && input.path.endsWith(".indexeddb.leveldb"))) {
11135
13036
  throw new Error("Select one conversation, not a source directory");
11136
13037
  }
11137
13038
  const args = {