dsh-talk-map 0.1.69 → 0.1.70

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.
package/client/client.js CHANGED
@@ -375,11 +375,18 @@ var zh = {
375
375
  "spawn.mode.none": "不继承",
376
376
  "spawn.mode.digest": "摘要注入",
377
377
  "spawn.mode.context": "当前上下文",
378
- "spawn.contextHint": "注入这段对话「当前」发给模型的上下文(已经被压缩掉的历史不在里面)。可以编辑后再开:",
378
+ "spawn.contextBudget": "注入体积",
379
+ "spawn.budget.40k": "4 万字符",
380
+ "spawn.budget.100k": "10 万",
381
+ "spawn.budget.300k": "30 万",
382
+ "spawn.budget.600k": "60 万",
383
+ "spawn.budget.all": "完整(不截断)",
384
+ "spawn.contextAvailable": "本次会话可注入约 {a} 个字符(≈{t} tokens,按 4 字符/token 粗估)。",
385
+ "spawn.contextHint": "把这段对话当前携带的上下文整份注入(含已压缩历史的检查点摘要;系统提示词与工具定义不注入,新会话有自己的)。可以编辑后再开:",
379
386
  "spawn.contextLoading": "正在读取当前上下文……",
380
387
  "spawn.contextEmpty": "这段对话暂时没有可注入的内容(可能刚压缩完,或还没有消息)。",
381
- "spawn.contextLoaded": "已读取 {n} 个字符、{m} 条记录。",
382
- "spawn.contextTruncated": "内容过长,只保留最近 {n} 个字符。",
388
+ "spawn.contextLoaded": "已注入 {n} 个字符、{m} 条记录(人机 {e} 字符,工具 {u} 字符)。",
389
+ "spawn.contextTruncated": "超出所选的注入体积,只保留最近 {n} 个字符(可注入总量 {a} 字符:人机 {e}、工具 {u})。",
383
390
  "inject.contextHeader": "【上下文注入 · 当前上下文 · 来自】",
384
391
  "inject.contextNote": "(以上是母对话当前仍在上下文里的内容;更早的部分已被压缩,不在其中。)",
385
392
  "spawn.mode.full": "完整对话",
@@ -480,7 +487,7 @@ var zh = {
480
487
  "digest.empty": "这条对话还没有摘要,先刷新摘要再来看。",
481
488
  "digest.copy": "复制",
482
489
  "digest.close": "关闭",
483
- "global.searchPlaceholder": "b69 · 搜地图上的卡片(标题/正文)",
490
+ "global.searchPlaceholder": "b70 · 搜地图上的卡片(标题/正文)",
484
491
  "global.searchRun": "搜索",
485
492
  "global.searchTitle": "搜索地图",
486
493
  "font.group": "文字大小",
@@ -558,11 +565,18 @@ var en = {
558
565
  "spawn.mode.none": "No context",
559
566
  "spawn.mode.digest": "Inject digest",
560
567
  "spawn.mode.context": "Current context",
561
- "spawn.contextHint": "Inject the context this conversation is currently given (already-compressed history is excluded). Edit it before you start:",
568
+ "spawn.contextBudget": "Injection size",
569
+ "spawn.budget.40k": "40k chars",
570
+ "spawn.budget.100k": "100k",
571
+ "spawn.budget.300k": "300k",
572
+ "spawn.budget.600k": "600k",
573
+ "spawn.budget.all": "Everything",
574
+ "spawn.contextAvailable": "This session carries about {a} characters (≈{t} tokens at a rough 4 chars/token).",
575
+ "spawn.contextHint": "Inject the whole context this conversation currently carries (compacted history arrives as its checkpoint summaries; system prompt and tool definitions are not injected — the new session has its own). Edit it before you start:",
562
576
  "spawn.contextLoading": "Reading the current context…",
563
577
  "spawn.contextEmpty": "Nothing to inject right now (freshly compacted, or no messages yet).",
564
- "spawn.contextLoaded": "Read {n} characters across {m} records.",
565
- "spawn.contextTruncated": "Too long: kept the most recent {n} characters.",
578
+ "spawn.contextLoaded": "Injected {n} characters across {m} records ({e} human, {u} tool).",
579
+ "spawn.contextTruncated": "Over the chosen size: kept the most recent {n} characters (available {a}: {e} human, {u} tool).",
566
580
  "inject.contextHeader": "[Context injection · current context · from]",
567
581
  "inject.contextNote": "(The above is what the parent still has in context; earlier parts were compacted away.)",
568
582
  "spawn.mode.full": "Full history",
@@ -656,7 +670,7 @@ var en = {
656
670
  "menu.noGroup": "Remove from group (free card)",
657
671
  "menu.open": "Open conversation",
658
672
  "menu.markUnread": "Mark as unread",
659
- "global.searchPlaceholder": "b69 · Search cards on the map",
673
+ "global.searchPlaceholder": "b70 · Search cards on the map",
660
674
  "global.searchRun": "Search",
661
675
  "global.searchTitle": "Search the map",
662
676
  "font.group": "Text size",
@@ -12748,6 +12762,8 @@ function SpawnPreview(props) {
12748
12762
  const [firstMessage, setFirstMessage] = (0, import_react9.useState)("");
12749
12763
  const [contextBusy, setContextBusy] = (0, import_react9.useState)(false);
12750
12764
  const [contextNote, setContextNote] = (0, import_react9.useState)(void 0);
12765
+ const [contextBudget, setContextBudget] = (0, import_react9.useState)(0);
12766
+ const [contextStats, setContextStats] = (0, import_react9.useState)(void 0);
12751
12767
  const [busy, setBusy] = (0, import_react9.useState)(false);
12752
12768
  const [error, setError] = (0, import_react9.useState)(void 0);
12753
12769
  (0, import_react9.useEffect)(() => {
@@ -12769,7 +12785,7 @@ function SpawnPreview(props) {
12769
12785
  let alive = true;
12770
12786
  setContextBusy(true);
12771
12787
  setContextNote(void 0);
12772
- void talkMapApi.contextWindow(pending.parent.sessionId).then((page) => {
12788
+ void talkMapApi.contextWindow(pending.parent.sessionId, contextBudget).then((page) => {
12773
12789
  if (!alive) return;
12774
12790
  const body = page.text.trim();
12775
12791
  setText(body === "" ? "" : `${t("inject.contextHeader")}「${pending.parent.title}」
@@ -12777,7 +12793,14 @@ function SpawnPreview(props) {
12777
12793
  ${body}
12778
12794
 
12779
12795
  ${t("inject.contextNote")}`);
12780
- setContextNote(body === "" ? t("spawn.contextEmpty") : page.truncated ? t("spawn.contextTruncated", { n: String(page.chars) }) : t("spawn.contextLoaded", { n: String(page.chars), m: String(page.entries) }));
12796
+ setContextStats({ available: page.availableChars, kept: page.chars, tokens: page.approxTokens });
12797
+ setContextNote(body === "" ? t("spawn.contextEmpty") : t(page.truncated ? "spawn.contextTruncated" : "spawn.contextLoaded", {
12798
+ n: String(page.chars),
12799
+ m: String(page.entries),
12800
+ a: String(page.availableChars),
12801
+ e: String(page.essentialChars),
12802
+ u: String(page.toolChars)
12803
+ }));
12781
12804
  }).catch((error2) => {
12782
12805
  if (alive) setContextNote(String(error2?.message ?? error2));
12783
12806
  }).finally(() => {
@@ -12786,7 +12809,7 @@ ${t("inject.contextNote")}`);
12786
12809
  return () => {
12787
12810
  alive = false;
12788
12811
  };
12789
- }, [mode, pending.parent.sessionId]);
12812
+ }, [mode, pending.parent.sessionId, contextBudget]);
12790
12813
  const addCardAndEdge = (sessionId, kind, injectedText) => {
12791
12814
  const cardId = newCardId();
12792
12815
  const card = {
@@ -12912,7 +12935,26 @@ ${t("inject.contextNote")}`);
12912
12935
  )
12913
12936
  ] }) : mode === "context" ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
12914
12937
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: talk_map_default["spawnHint"], children: t("spawn.contextHint") }),
12938
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: talk_map_default["spawnModes"], role: "group", "aria-label": t("spawn.contextBudget"), children: [
12939
+ { chars: 0, label: t("spawn.budget.all") },
12940
+ { chars: 4e4, label: t("spawn.budget.40k") },
12941
+ { chars: 1e5, label: t("spawn.budget.100k") },
12942
+ { chars: 3e5, label: t("spawn.budget.300k") },
12943
+ { chars: 6e5, label: t("spawn.budget.600k") }
12944
+ ].map((option) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
12945
+ "button",
12946
+ {
12947
+ type: "button",
12948
+ className: `${talk_map_default["spawnModeBtn"]}${contextBudget === option.chars ? ` ${talk_map_default["spawnModeActive"]}` : ""}`,
12949
+ onClick: () => {
12950
+ setContextBudget(option.chars);
12951
+ },
12952
+ children: option.label
12953
+ },
12954
+ option.chars
12955
+ )) }),
12915
12956
  contextNote !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: talk_map_default["spawnHint"], children: contextNote }) : null,
12957
+ contextStats !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: talk_map_default["spawnHint"], children: t("spawn.contextAvailable", { a: String(contextStats.available), t: String(contextStats.tokens) }) }) : null,
12916
12958
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
12917
12959
  "textarea",
12918
12960
  {
package/lib/index.js CHANGED
@@ -526,7 +526,7 @@ async function openTalkMapStore(storageDomain) {
526
526
  return store;
527
527
  }
528
528
  // src/host/routes.ts
529
- const MAX_BODY_BYTES = 1048576;
529
+ const MAX_BODY_BYTES = 67108864;
530
530
  /** Concatenate the text blocks of a message payload (tool results have none). */
531
531
  function textOfBlocks(content) {
532
532
  if (!Array.isArray(content)) return "";
@@ -840,8 +840,8 @@ function mountTalkMapRoutes(services, storeReady, runtime) {
840
840
  sendJson(response, 400, { error: "sessionId is required" });
841
841
  return;
842
842
  }
843
- const requested = typeof body?.maxChars === "number" ? Math.round(body.maxChars) : 4e4;
844
- const maxChars = Math.min(Math.max(requested, 4e3), 4e5);
843
+ const requested = typeof body?.maxChars === "number" ? Math.round(body.maxChars) : 0;
844
+ const maxChars = requested <= 0 ? 0 : Math.min(Math.max(requested, 4e3), 3e6);
845
845
  const query = runtime.sessionQuery;
846
846
  if (query === void 0) {
847
847
  sendJson(response, 503, { error: "session surface unavailable" });
@@ -863,7 +863,9 @@ function mountTalkMapRoutes(services, storeReady, runtime) {
863
863
  if (pruned.has(seq)) continue;
864
864
  if (event.type === "user/message") {
865
865
  const said = textOfBlocks(event.data?.content);
866
- if (said !== "") lines.push(`USER: ${said}`);
866
+ const kind = event.data?.source?.kind;
867
+ const label = kind === "compact-checkpoint" ? "COMPACTED HISTORY (summary)" : typeof kind === "string" && kind !== "user" ? `USER/${kind}` : "USER";
868
+ if (said !== "") lines.push(`${label}: ${said}`);
867
869
  } else if (event.type === "assistant/message") {
868
870
  const said = textOfBlocks(event.data?.message?.content);
869
871
  if (said !== "") lines.push(`ASSISTANT: ${said}`);
@@ -886,12 +888,13 @@ function mountTalkMapRoutes(services, storeReady, runtime) {
886
888
  const tooling = lines.filter((line) => line.startsWith("TOOL ") || line.startsWith("RESULT: "));
887
889
  let text = essential.join("\n\n");
888
890
  let truncated = false;
889
- if (text.length > maxChars) {
891
+ if (maxChars === 0) text = lines.join("\n\n");
892
+ else if (text.length > maxChars) {
890
893
  text = text.slice(text.length - maxChars);
891
894
  const cut = text.indexOf("\n\n");
892
895
  if (cut > 0 && cut < 400) text = text.slice(cut + 2);
893
896
  truncated = true;
894
- } else {
897
+ } else if (maxChars > 0) {
895
898
  const room = maxChars - text.length;
896
899
  const kept = [];
897
900
  let used = 0;
@@ -910,13 +913,21 @@ function mountTalkMapRoutes(services, storeReady, runtime) {
910
913
  }
911
914
  if (kept.length < tooling.length) truncated = true;
912
915
  }
916
+ const essentialChars = essential.join("\n\n").length;
917
+ const toolChars = tooling.join("\n\n").length;
913
918
  sendJson(response, 200, {
914
919
  sessionId,
915
920
  text,
916
921
  chars: text.length,
917
922
  entries: lines.length,
918
923
  prunedRecords: pruned.size,
919
- truncated
924
+ truncated,
925
+ availableChars: essentialChars + toolChars,
926
+ essentialChars,
927
+ toolChars,
928
+ essentialEntries: essential.length,
929
+ toolEntries: tooling.length,
930
+ approxTokens: Math.round((essentialChars + toolChars) / 4)
920
931
  });
921
932
  return;
922
933
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-talk-map",
3
- "version": "0.1.69",
3
+ "version": "0.1.70",
4
4
  "description": "Visual conversation map for DeepSeek Harness: an infinite whiteboard where every session is a card — drag to arrange, double-click to start a chat in place, draw an edge to fork a new session with injected context. Built for ADHD-friendly spatial memory. · DSH 可视化对话地图:会话即卡片,双击即聊,连线分叉带上下文的新对话。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",