gm surface: home flow, run identity, full-assembly editor, notepad, wrap replay; sigils and dateless rings

This commit is contained in:
2026-11-14 09:04:13 +00:00
parent ba72d2ed1f
commit 9f85adc3c6
20 changed files with 2014 additions and 433 deletions
+21 -7
View File
@@ -101,8 +101,10 @@ export function openWindow(runId, override = false) {
}
const system = { role: 'system', content: assembleSystem(runId) };
const bundle = assembleBundle(runId, fresh);
const partNames = ['backdrop', 'character', 'ring-b', 'ring-a', ...(fresh ? ['turn-0'] : [])];
const bundle = assembleBundle(runId);
// turn-0 is not a bundle part: the opening beat is sent as the
// first GM turn (POST /api/runs/<id>/turn0) when play starts
const partNames = ['backdrop', 'character', 'ring-b', 'ring-a'];
const s = makeSession(runId, stamp());
s.fresh = fresh;
fs.mkdirSync(sessionsDir(runId), { recursive: true });
@@ -131,6 +133,10 @@ export function loadSession(runId, st) {
}
}
derive(s);
// fresh survives a restart: this window is the run's first iff no
// earlier session log exists (derive() can't know — it sees one log)
const files = fs.readdirSync(sessionsDir(runId)).filter((f) => f.endsWith('.jsonl')).sort();
s.fresh = files.length === 1 && files[0] === `${st}.jsonl`;
return s;
}
@@ -164,10 +170,14 @@ const STRIP_BLOCKS = /\n?<(status|conflict)>[\s\S]*?<\/\1>\n?/g;
export function renderView(s, keepToolResults = 4) {
const toolIdx = [];
s.lines.forEach((e, i) => { if (e.t === 'tool') toolIdx.push(i); });
let lastGmIdx = -1;
s.lines.forEach((e, i) => {
if (e.t === 'tool') toolIdx.push(i);
if (e.t === 'msg' && e.m.role === 'user') lastGmIdx = i;
});
const keep = new Set(toolIdx.slice(-keepToolResults));
const msgs = [];
for (const e of s.lines) {
for (const [i, e] of s.lines.entries()) {
if (e.t === 'bundle') {
msgs.push({ role: e.m.role, content: e.m.content });
} else if (e.t === 'msg') {
@@ -176,13 +186,17 @@ export function renderView(s, keepToolResults = 4) {
const m = { role: 'assistant', content: e.m.content ?? null };
if (e.m.tool_calls?.length) m.tool_calls = e.m.tool_calls;
msgs.push(m);
} else if (i === lastGmIdx) {
// the newest GM turn keeps its blocks as-sent: the current
// paper rides it, and a pending conflict rides it — the
// model must see both
msgs.push({ role: e.m.role, content: e.m.content.trim() });
} else {
// GM-side: old status/conflict blocks elide — the current
// paper rides the newest GM turn
// older GM turns: status/conflict blocks elide
msgs.push({ role: e.m.role, content: e.m.content.replace(STRIP_BLOCKS, '').trim() });
}
} else if (e.t === 'tool') {
if (e.ask || keep.has(s.lines.indexOf(e))) {
if (e.ask || keep.has(i)) {
msgs.push({ role: 'tool', tool_call_id: e.m.tool_call_id, content: e.m.content });
} else {
msgs.push({ role: 'tool', tool_call_id: e.m.tool_call_id, content: '[elided: earlier tool result]' });