dsh-talk-map 0.1.69 → 0.1.71
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 +56 -12
- package/lib/index.js +19 -7
- package/package.json +1 -1
package/client/client.js
CHANGED
|
@@ -365,6 +365,7 @@ var zh = {
|
|
|
365
365
|
"time.d": " 天前",
|
|
366
366
|
"card.refresh": "重新生成摘要",
|
|
367
367
|
"edge.injected": "注入",
|
|
368
|
+
"edge.context": "注入 · 当前上下文",
|
|
368
369
|
"spawn.heading": "连线分叉:开一个带上下文的新对话",
|
|
369
370
|
"spawn.from": "来源",
|
|
370
371
|
"spawn.hint": "以下内容将注入新对话作为背景,可以编辑:",
|
|
@@ -375,11 +376,18 @@ var zh = {
|
|
|
375
376
|
"spawn.mode.none": "不继承",
|
|
376
377
|
"spawn.mode.digest": "摘要注入",
|
|
377
378
|
"spawn.mode.context": "当前上下文",
|
|
378
|
-
"spawn.
|
|
379
|
+
"spawn.contextBudget": "注入体积",
|
|
380
|
+
"spawn.budget.40k": "4 万字符",
|
|
381
|
+
"spawn.budget.100k": "10 万",
|
|
382
|
+
"spawn.budget.300k": "30 万",
|
|
383
|
+
"spawn.budget.600k": "60 万",
|
|
384
|
+
"spawn.budget.all": "完整(不截断)",
|
|
385
|
+
"spawn.contextAvailable": "本次会话可注入约 {a} 个字符(≈{t} tokens,按 4 字符/token 粗估)。",
|
|
386
|
+
"spawn.contextHint": "把这段对话当前携带的上下文整份注入(含已压缩历史的检查点摘要;系统提示词与工具定义不注入,新会话有自己的)。可以编辑后再开:",
|
|
379
387
|
"spawn.contextLoading": "正在读取当前上下文……",
|
|
380
388
|
"spawn.contextEmpty": "这段对话暂时没有可注入的内容(可能刚压缩完,或还没有消息)。",
|
|
381
|
-
"spawn.contextLoaded": "
|
|
382
|
-
"spawn.contextTruncated": "
|
|
389
|
+
"spawn.contextLoaded": "已注入 {n} 个字符、{m} 条记录(人机 {e} 字符,工具 {u} 字符)。",
|
|
390
|
+
"spawn.contextTruncated": "超出所选的注入体积,只保留最近 {n} 个字符(可注入总量 {a} 字符:人机 {e}、工具 {u})。",
|
|
383
391
|
"inject.contextHeader": "【上下文注入 · 当前上下文 · 来自】",
|
|
384
392
|
"inject.contextNote": "(以上是母对话当前仍在上下文里的内容;更早的部分已被压缩,不在其中。)",
|
|
385
393
|
"spawn.mode.full": "完整对话",
|
|
@@ -480,7 +488,7 @@ var zh = {
|
|
|
480
488
|
"digest.empty": "这条对话还没有摘要,先刷新摘要再来看。",
|
|
481
489
|
"digest.copy": "复制",
|
|
482
490
|
"digest.close": "关闭",
|
|
483
|
-
"global.searchPlaceholder": "
|
|
491
|
+
"global.searchPlaceholder": "b71 · 搜地图上的卡片(标题/正文)",
|
|
484
492
|
"global.searchRun": "搜索",
|
|
485
493
|
"global.searchTitle": "搜索地图",
|
|
486
494
|
"font.group": "文字大小",
|
|
@@ -548,6 +556,7 @@ var en = {
|
|
|
548
556
|
"time.d": "d ago",
|
|
549
557
|
"card.refresh": "Regenerate digest",
|
|
550
558
|
"edge.injected": "injected",
|
|
559
|
+
"edge.context": "injected · current context",
|
|
551
560
|
"spawn.heading": "Fork with context",
|
|
552
561
|
"spawn.from": "From",
|
|
553
562
|
"spawn.hint": "This text will be injected into the new session as background — edit freely:",
|
|
@@ -558,11 +567,18 @@ var en = {
|
|
|
558
567
|
"spawn.mode.none": "No context",
|
|
559
568
|
"spawn.mode.digest": "Inject digest",
|
|
560
569
|
"spawn.mode.context": "Current context",
|
|
561
|
-
"spawn.
|
|
570
|
+
"spawn.contextBudget": "Injection size",
|
|
571
|
+
"spawn.budget.40k": "40k chars",
|
|
572
|
+
"spawn.budget.100k": "100k",
|
|
573
|
+
"spawn.budget.300k": "300k",
|
|
574
|
+
"spawn.budget.600k": "600k",
|
|
575
|
+
"spawn.budget.all": "Everything",
|
|
576
|
+
"spawn.contextAvailable": "This session carries about {a} characters (≈{t} tokens at a rough 4 chars/token).",
|
|
577
|
+
"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
578
|
"spawn.contextLoading": "Reading the current context…",
|
|
563
579
|
"spawn.contextEmpty": "Nothing to inject right now (freshly compacted, or no messages yet).",
|
|
564
|
-
"spawn.contextLoaded": "
|
|
565
|
-
"spawn.contextTruncated": "
|
|
580
|
+
"spawn.contextLoaded": "Injected {n} characters across {m} records ({e} human, {u} tool).",
|
|
581
|
+
"spawn.contextTruncated": "Over the chosen size: kept the most recent {n} characters (available {a}: {e} human, {u} tool).",
|
|
566
582
|
"inject.contextHeader": "[Context injection · current context · from]",
|
|
567
583
|
"inject.contextNote": "(The above is what the parent still has in context; earlier parts were compacted away.)",
|
|
568
584
|
"spawn.mode.full": "Full history",
|
|
@@ -656,7 +672,7 @@ var en = {
|
|
|
656
672
|
"menu.noGroup": "Remove from group (free card)",
|
|
657
673
|
"menu.open": "Open conversation",
|
|
658
674
|
"menu.markUnread": "Mark as unread",
|
|
659
|
-
"global.searchPlaceholder": "
|
|
675
|
+
"global.searchPlaceholder": "b71 · Search cards on the map",
|
|
660
676
|
"global.searchRun": "Search",
|
|
661
677
|
"global.searchTitle": "Search the map",
|
|
662
678
|
"font.group": "Text size",
|
|
@@ -12748,6 +12764,8 @@ function SpawnPreview(props) {
|
|
|
12748
12764
|
const [firstMessage, setFirstMessage] = (0, import_react9.useState)("");
|
|
12749
12765
|
const [contextBusy, setContextBusy] = (0, import_react9.useState)(false);
|
|
12750
12766
|
const [contextNote, setContextNote] = (0, import_react9.useState)(void 0);
|
|
12767
|
+
const [contextBudget, setContextBudget] = (0, import_react9.useState)(0);
|
|
12768
|
+
const [contextStats, setContextStats] = (0, import_react9.useState)(void 0);
|
|
12751
12769
|
const [busy, setBusy] = (0, import_react9.useState)(false);
|
|
12752
12770
|
const [error, setError] = (0, import_react9.useState)(void 0);
|
|
12753
12771
|
(0, import_react9.useEffect)(() => {
|
|
@@ -12769,7 +12787,7 @@ function SpawnPreview(props) {
|
|
|
12769
12787
|
let alive = true;
|
|
12770
12788
|
setContextBusy(true);
|
|
12771
12789
|
setContextNote(void 0);
|
|
12772
|
-
void talkMapApi.contextWindow(pending.parent.sessionId).then((page) => {
|
|
12790
|
+
void talkMapApi.contextWindow(pending.parent.sessionId, contextBudget).then((page) => {
|
|
12773
12791
|
if (!alive) return;
|
|
12774
12792
|
const body = page.text.trim();
|
|
12775
12793
|
setText(body === "" ? "" : `${t("inject.contextHeader")}「${pending.parent.title}」
|
|
@@ -12777,7 +12795,14 @@ function SpawnPreview(props) {
|
|
|
12777
12795
|
${body}
|
|
12778
12796
|
|
|
12779
12797
|
${t("inject.contextNote")}`);
|
|
12780
|
-
|
|
12798
|
+
setContextStats({ available: page.availableChars, kept: page.chars, tokens: page.approxTokens });
|
|
12799
|
+
setContextNote(body === "" ? t("spawn.contextEmpty") : t(page.truncated ? "spawn.contextTruncated" : "spawn.contextLoaded", {
|
|
12800
|
+
n: String(page.chars),
|
|
12801
|
+
m: String(page.entries),
|
|
12802
|
+
a: String(page.availableChars),
|
|
12803
|
+
e: String(page.essentialChars),
|
|
12804
|
+
u: String(page.toolChars)
|
|
12805
|
+
}));
|
|
12781
12806
|
}).catch((error2) => {
|
|
12782
12807
|
if (alive) setContextNote(String(error2?.message ?? error2));
|
|
12783
12808
|
}).finally(() => {
|
|
@@ -12786,7 +12811,7 @@ ${t("inject.contextNote")}`);
|
|
|
12786
12811
|
return () => {
|
|
12787
12812
|
alive = false;
|
|
12788
12813
|
};
|
|
12789
|
-
}, [mode, pending.parent.sessionId]);
|
|
12814
|
+
}, [mode, pending.parent.sessionId, contextBudget]);
|
|
12790
12815
|
const addCardAndEdge = (sessionId, kind, injectedText) => {
|
|
12791
12816
|
const cardId = newCardId();
|
|
12792
12817
|
const card = {
|
|
@@ -12912,7 +12937,26 @@ ${t("inject.contextNote")}`);
|
|
|
12912
12937
|
)
|
|
12913
12938
|
] }) : mode === "context" ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
12914
12939
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: talk_map_default["spawnHint"], children: t("spawn.contextHint") }),
|
|
12940
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: talk_map_default["spawnModes"], role: "group", "aria-label": t("spawn.contextBudget"), children: [
|
|
12941
|
+
{ chars: 0, label: t("spawn.budget.all") },
|
|
12942
|
+
{ chars: 4e4, label: t("spawn.budget.40k") },
|
|
12943
|
+
{ chars: 1e5, label: t("spawn.budget.100k") },
|
|
12944
|
+
{ chars: 3e5, label: t("spawn.budget.300k") },
|
|
12945
|
+
{ chars: 6e5, label: t("spawn.budget.600k") }
|
|
12946
|
+
].map((option) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
12947
|
+
"button",
|
|
12948
|
+
{
|
|
12949
|
+
type: "button",
|
|
12950
|
+
className: `${talk_map_default["spawnModeBtn"]}${contextBudget === option.chars ? ` ${talk_map_default["spawnModeActive"]}` : ""}`,
|
|
12951
|
+
onClick: () => {
|
|
12952
|
+
setContextBudget(option.chars);
|
|
12953
|
+
},
|
|
12954
|
+
children: option.label
|
|
12955
|
+
},
|
|
12956
|
+
option.chars
|
|
12957
|
+
)) }),
|
|
12915
12958
|
contextNote !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: talk_map_default["spawnHint"], children: contextNote }) : null,
|
|
12959
|
+
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
12960
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
12917
12961
|
"textarea",
|
|
12918
12962
|
{
|
|
@@ -15007,7 +15051,7 @@ function CanvasInner(props) {
|
|
|
15007
15051
|
},
|
|
15008
15052
|
// Pure association lines: no label, lighter than injection edges.
|
|
15009
15053
|
...kind === "link" ? { style: { opacity: 0.45 } } : {
|
|
15010
|
-
label: kind === "none" ? t("edge.none") : kind === "full" ? t("edge.full") : t("edge.injected"),
|
|
15054
|
+
label: kind === "none" ? t("edge.none") : kind === "full" ? t("edge.full") : kind === "context" ? t("edge.context") : t("edge.injected"),
|
|
15011
15055
|
...kind === "none" ? { style: { opacity: 0.45 } } : {}
|
|
15012
15056
|
}
|
|
15013
15057
|
});
|
package/lib/index.js
CHANGED
|
@@ -414,6 +414,7 @@ const edgeInjectionSchema = z.object({
|
|
|
414
414
|
* spawn, no text); 'none' = a fork edge whose child inherited nothing. */
|
|
415
415
|
kind: z.enum([
|
|
416
416
|
"digest",
|
|
417
|
+
"context",
|
|
417
418
|
"full",
|
|
418
419
|
"selection",
|
|
419
420
|
"none",
|
|
@@ -526,7 +527,7 @@ async function openTalkMapStore(storageDomain) {
|
|
|
526
527
|
return store;
|
|
527
528
|
}
|
|
528
529
|
// src/host/routes.ts
|
|
529
|
-
const MAX_BODY_BYTES =
|
|
530
|
+
const MAX_BODY_BYTES = 67108864;
|
|
530
531
|
/** Concatenate the text blocks of a message payload (tool results have none). */
|
|
531
532
|
function textOfBlocks(content) {
|
|
532
533
|
if (!Array.isArray(content)) return "";
|
|
@@ -840,8 +841,8 @@ function mountTalkMapRoutes(services, storeReady, runtime) {
|
|
|
840
841
|
sendJson(response, 400, { error: "sessionId is required" });
|
|
841
842
|
return;
|
|
842
843
|
}
|
|
843
|
-
const requested = typeof body?.maxChars === "number" ? Math.round(body.maxChars) :
|
|
844
|
-
const maxChars = Math.min(Math.max(requested, 4e3),
|
|
844
|
+
const requested = typeof body?.maxChars === "number" ? Math.round(body.maxChars) : 0;
|
|
845
|
+
const maxChars = requested <= 0 ? 0 : Math.min(Math.max(requested, 4e3), 3e6);
|
|
845
846
|
const query = runtime.sessionQuery;
|
|
846
847
|
if (query === void 0) {
|
|
847
848
|
sendJson(response, 503, { error: "session surface unavailable" });
|
|
@@ -863,7 +864,9 @@ function mountTalkMapRoutes(services, storeReady, runtime) {
|
|
|
863
864
|
if (pruned.has(seq)) continue;
|
|
864
865
|
if (event.type === "user/message") {
|
|
865
866
|
const said = textOfBlocks(event.data?.content);
|
|
866
|
-
|
|
867
|
+
const kind = event.data?.source?.kind;
|
|
868
|
+
const label = kind === "compact-checkpoint" ? "COMPACTED HISTORY (summary)" : typeof kind === "string" && kind !== "user" ? `USER/${kind}` : "USER";
|
|
869
|
+
if (said !== "") lines.push(`${label}: ${said}`);
|
|
867
870
|
} else if (event.type === "assistant/message") {
|
|
868
871
|
const said = textOfBlocks(event.data?.message?.content);
|
|
869
872
|
if (said !== "") lines.push(`ASSISTANT: ${said}`);
|
|
@@ -886,12 +889,13 @@ function mountTalkMapRoutes(services, storeReady, runtime) {
|
|
|
886
889
|
const tooling = lines.filter((line) => line.startsWith("TOOL ") || line.startsWith("RESULT: "));
|
|
887
890
|
let text = essential.join("\n\n");
|
|
888
891
|
let truncated = false;
|
|
889
|
-
if (text
|
|
892
|
+
if (maxChars === 0) text = lines.join("\n\n");
|
|
893
|
+
else if (text.length > maxChars) {
|
|
890
894
|
text = text.slice(text.length - maxChars);
|
|
891
895
|
const cut = text.indexOf("\n\n");
|
|
892
896
|
if (cut > 0 && cut < 400) text = text.slice(cut + 2);
|
|
893
897
|
truncated = true;
|
|
894
|
-
} else {
|
|
898
|
+
} else if (maxChars > 0) {
|
|
895
899
|
const room = maxChars - text.length;
|
|
896
900
|
const kept = [];
|
|
897
901
|
let used = 0;
|
|
@@ -910,13 +914,21 @@ function mountTalkMapRoutes(services, storeReady, runtime) {
|
|
|
910
914
|
}
|
|
911
915
|
if (kept.length < tooling.length) truncated = true;
|
|
912
916
|
}
|
|
917
|
+
const essentialChars = essential.join("\n\n").length;
|
|
918
|
+
const toolChars = tooling.join("\n\n").length;
|
|
913
919
|
sendJson(response, 200, {
|
|
914
920
|
sessionId,
|
|
915
921
|
text,
|
|
916
922
|
chars: text.length,
|
|
917
923
|
entries: lines.length,
|
|
918
924
|
prunedRecords: pruned.size,
|
|
919
|
-
truncated
|
|
925
|
+
truncated,
|
|
926
|
+
availableChars: essentialChars + toolChars,
|
|
927
|
+
essentialChars,
|
|
928
|
+
toolChars,
|
|
929
|
+
essentialEntries: essential.length,
|
|
930
|
+
toolEntries: tooling.length,
|
|
931
|
+
approxTokens: Math.round((essentialChars + toolChars) / 4)
|
|
920
932
|
});
|
|
921
933
|
return;
|
|
922
934
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-talk-map",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.71",
|
|
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",
|