antechamber 2.0.22 → 2.0.23

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/CHANGELOG.md CHANGED
@@ -7,6 +7,10 @@ and this project uses [Semantic Versioning](https://semver.org/).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.0.23] - 2026-12-03
11
+
12
+ - fix(compaction): show a compaction to v2 clients only as its record (#114)
13
+
10
14
  ## [2.0.22] - 2026-11-30
11
15
 
12
16
  ### Fixed
@@ -18,6 +22,11 @@ and this project uses [Semantic Versioning](https://semver.org/).
18
22
  - Finished background subagents no longer pile up as "Subagent finished" rows at the end of the conversation. Their
19
23
  reports are now kept in the message history where each child ended, and a history reload (after a compaction, for
20
24
  example) no longer sends the reports of tasks that ended long before.
25
+ - A compaction's summary no longer shows up in OpenChamber 2.8 as an extra assistant reply, which could stay below
26
+ newer messages. The live events announced the compaction's `/compact` turn and summary reply as ordinary messages
27
+ that the message list never holds, so OpenChamber kept the reply beside the listed messages. The compaction now
28
+ reaches v2 clients only as its `compaction` record, as the list shows it, including a compaction a running subagent
29
+ writes. A manual compaction after a failed turn no longer reports that turn's failure.
21
30
 
22
31
  ## [2.0.21] - 2026-11-30
23
32
 
@@ -38,6 +38,20 @@ export declare function syncSessionCost(s: ManagedSession): boolean;
38
38
  * multiple compactions can retain the same entry.
39
39
  */
40
40
  export declare function compactionMessages(s: ManagedSession, key: string, summary: string, created: number, model: OCModelRef | undefined, thinkingLevel: string | undefined): [OCMessageWithParts, OCMessageWithParts];
41
+ /**
42
+ * The v2 `compaction` record of the completed compaction whose marker is `history[index]`, as the message list shows
43
+ * it: the admitted ID when a compact request named one, else the marker's own.
44
+ */
45
+ export declare function compactionRecord(s: ManagedSession, history: OCMessageWithParts[], index: number): {
46
+ id: string;
47
+ type: "compaction";
48
+ time: {
49
+ created: number;
50
+ };
51
+ status: "completed";
52
+ reason: "auto" | "manual";
53
+ summary: string;
54
+ } | undefined;
41
55
  interface PiEventServices {
42
56
  readonly emit: (directory: string, event: OCEvent | TodoUpdated) => void;
43
57
  readonly subagents: SubagentBridge;
@@ -151,6 +151,27 @@ export function compactionMessages(s, key, summary, created, model, thinkingLeve
151
151
  },
152
152
  ];
153
153
  }
154
+ /**
155
+ * The v2 `compaction` record of the completed compaction whose marker is `history[index]`, as the message list shows
156
+ * it: the admitted ID when a compact request named one, else the marker's own.
157
+ */
158
+ export function compactionRecord(s, history, index) {
159
+ const message = history[index];
160
+ const summary = history[index + 1];
161
+ if (message === undefined || summary?.info.role !== "assistant" || !summary.info.summary)
162
+ return undefined;
163
+ const entryID = message.info.id.replace(/^msg_compaction_/, "");
164
+ const admittedID = Object.keys(s.tree.messageEntries).find((key) => key !== message.info.id && s.tree.messageEntries[key] === entryID) ?? message.info.id;
165
+ const content = summary.parts.find((part) => part.type === "text");
166
+ return {
167
+ id: admittedID,
168
+ type: "compaction",
169
+ time: { created: s.tree.compactionAdmissions?.[admittedID] ?? message.info.time.created },
170
+ status: "completed",
171
+ reason: s.tree.compactionReasons?.[entryID] ?? "manual",
172
+ summary: content?.type === "text" ? content.text : "",
173
+ };
174
+ }
154
175
  /**
155
176
  * Events after which OmO's background work may have started or ended: monitor and wake-source snapshots,
156
177
  * tool results that launch work, and the custom messages OmO sends when a background session finishes.
package/dist/sessions.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * Session registry: one OpenCode session maps to one `pi --mode rpc` process.
3
3
  * Composes the live event bridge and restored-session history reconstruction.
4
4
  */
5
- import { id, PiEventTranslator, syncSessionCost } from "./pi-event-translation.js";
5
+ import { compactionRecord, id, PiEventTranslator, syncSessionCost } from "./pi-event-translation.js";
6
6
  import { parsePiSessionFile, parsePiSessionText } from "./session-history.js";
7
7
  import { CONTEXT_MESSAGE_TYPE, nativePromptInput, v2PromptAttachments } from "./prompt-parts.js";
8
8
  import { deliveredInstructions, INSTRUCTIONS_CUSTOM_TYPE, instructionDelivery } from "./instructions.js";
@@ -574,21 +574,9 @@ export class SessionManager {
574
574
  const index = history.findIndex((message) => message.parts.some((part) => part.type === "compaction") &&
575
575
  (message.info.id === messageID ||
576
576
  s.tree.messageEntries[messageID] === message.info.id.replace(/^msg_compaction_/, "")));
577
- const message = history[index];
578
- const summary = history[index + 1];
579
- if (message !== undefined && summary?.info.role === "assistant" && summary.info.summary) {
580
- const entryID = message.info.id.replace(/^msg_compaction_/, "");
581
- const admittedID = Object.keys(s.tree.messageEntries).find((key) => key !== message.info.id && s.tree.messageEntries[key] === entryID) ?? message.info.id;
582
- const content = summary.parts.find((part) => part.type === "text");
583
- return {
584
- id: admittedID,
585
- type: "compaction",
586
- time: { created: s.tree.compactionAdmissions?.[admittedID] ?? message.info.time.created },
587
- status: "completed",
588
- reason: s.tree.compactionReasons?.[entryID] ?? "manual",
589
- summary: content?.type === "text" ? content.text : "",
590
- };
591
- }
577
+ const completed = compactionRecord(s, history, index);
578
+ if (completed !== undefined)
579
+ return completed;
592
580
  if (s.compactionID !== messageID)
593
581
  return undefined;
594
582
  return {
package/dist/subagents.js CHANGED
@@ -3,7 +3,7 @@ import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readSync, rea
3
3
  import { basename, dirname, join } from "node:path";
4
4
  import { isDeepStrictEqual } from "node:util";
5
5
  import { piAgentDir } from "./agent-dir.js";
6
- import { syncSessionCost } from "./pi-event-translation.js";
6
+ import { compactionRecord, syncSessionCost } from "./pi-event-translation.js";
7
7
  import { ocIdFor, SessionPersistenceError, SessionStore, sessionUsageEntry } from "./session-store.js";
8
8
  import { mapTool, resultText, toolMappers } from "./tool-map.js";
9
9
  import { ADAPTER_VERSION } from "./version.js";
@@ -683,6 +683,7 @@ export class SubagentBridge {
683
683
  livePath: undefined,
684
684
  recordPath: undefined,
685
685
  loaded: false,
686
+ transcriptRead: false,
686
687
  live: false,
687
688
  };
688
689
  this.children.set(session.info.id, child);
@@ -869,6 +870,7 @@ export class SubagentBridge {
869
870
  const state = {
870
871
  previousMessages: child.session.messages ?? [],
871
872
  previousStatus: child.session.status.type,
873
+ transcriptRead: child.transcriptRead,
872
874
  running,
873
875
  costChanged: hydrate || running || child.loaded
874
876
  ? this.hydrateTranscript(child, archive, running, child.session.status.type)
@@ -964,6 +966,7 @@ export class SubagentBridge {
964
966
  child.session.messages = this.fallback(child);
965
967
  }
966
968
  child.loaded = true;
969
+ child.transcriptRead = raw !== undefined;
967
970
  // Each child reports only its own spend; OpenChamber sums the subtree by parentID.
968
971
  return syncSessionCost(child.session);
969
972
  }
@@ -990,26 +993,42 @@ export class SubagentBridge {
990
993
  return parts;
991
994
  }
992
995
  publishRefresh(child, state, publish) {
996
+ const directory = child.session.info.directory;
997
+ const sessionID = child.session.info.id;
998
+ const status = () => this.emit(directory, { type: "session.status", properties: { sessionID, status: child.session.status } });
999
+ const changed = state.previousStatus !== child.session.status.type;
1000
+ // As for a root turn, the execution starts before the steps it runs, so v2 judges its outcome by them.
1001
+ if (changed && state.running)
1002
+ status();
993
1003
  if (publish) {
994
1004
  const before = new Map(state.previousMessages.map((message) => [message.info.id, JSON.stringify(message)]));
995
- for (const message of child.session.messages ?? []) {
1005
+ const messages = child.session.messages ?? [];
1006
+ for (const [index, message] of messages.entries()) {
996
1007
  if (before.get(message.info.id) === JSON.stringify(message))
997
1008
  continue;
998
- this.emit(child.session.info.directory, { type: "message.updated", properties: { info: message.info } });
1009
+ this.emit(directory, { type: "message.updated", properties: { info: message.info } });
999
1010
  for (const part of message.parts)
1000
1011
  this.emitPart(child.session, part);
1012
+ // v2 shows a compaction only as its record; announce one the child wrote after its transcript was read.
1013
+ const record = state.transcriptRead && !before.has(message.info.id)
1014
+ ? compactionRecord(child.session, messages, index)
1015
+ : undefined;
1016
+ if (record === undefined)
1017
+ continue;
1018
+ const { id: inputID, reason, summary: text, time } = record;
1019
+ this.emit(directory, {
1020
+ type: "session.compaction.started",
1021
+ properties: { sessionID, inputID, reason, created: time.created },
1022
+ });
1023
+ this.emit(directory, {
1024
+ type: "session.compaction.ended",
1025
+ properties: { sessionID, inputID, reason, text, recent: "", created: time.created },
1026
+ });
1001
1027
  }
1002
1028
  }
1003
- if (state.previousStatus !== child.session.status.type) {
1004
- this.emit(child.session.info.directory, {
1005
- type: "session.status",
1006
- properties: { sessionID: child.session.info.id, status: child.session.status },
1007
- });
1008
- if (!state.running)
1009
- this.emit(child.session.info.directory, {
1010
- type: "session.idle",
1011
- properties: { sessionID: child.session.info.id },
1012
- });
1029
+ if (changed && !state.running) {
1030
+ status();
1031
+ this.emit(directory, { type: "session.idle", properties: { sessionID } });
1013
1032
  }
1014
1033
  }
1015
1034
  saveArchive(path, raw) {
package/dist/types.d.ts CHANGED
@@ -383,6 +383,7 @@ export type OCEvent = {
383
383
  sessionID: string;
384
384
  reason: string;
385
385
  inputID: string;
386
+ created?: number;
386
387
  };
387
388
  } | {
388
389
  type: "session.compaction.delta";
@@ -398,6 +399,7 @@ export type OCEvent = {
398
399
  inputID: string;
399
400
  text: string;
400
401
  recent: string;
402
+ created?: number;
401
403
  };
402
404
  } | {
403
405
  type: "session.compaction.failed";
package/dist/v2.d.ts CHANGED
@@ -211,6 +211,13 @@ export declare class V2EventTranslator {
211
211
  * conversation in OpenChamber 2.8 (see `subagentReportMessage`).
212
212
  */
213
213
  private reports;
214
+ /**
215
+ * Compaction summary replies (`summary: true`), whose parts are not forwarded. v2 shows a compaction as one
216
+ * `compaction` record (the `session.compaction.*` frames and the list item), and the list omits the v1 `/compact`
217
+ * turn and its reply. OpenChamber 2.8 keeps a message it learned from events but cannot find in the list beside the
218
+ * listed ones, so forwarding them drew an extra summary reply that could stay below newer messages.
219
+ */
220
+ private summaries;
214
221
  translate(directory: string, ev: OCEvent): V2Envelope[];
215
222
  private onStatus;
216
223
  private onMessageUpdated;
package/dist/v2.js CHANGED
@@ -404,10 +404,19 @@ export class V2EventTranslator {
404
404
  * conversation in OpenChamber 2.8 (see `subagentReportMessage`).
405
405
  */
406
406
  reports = new Map();
407
+ /**
408
+ * Compaction summary replies (`summary: true`), whose parts are not forwarded. v2 shows a compaction as one
409
+ * `compaction` record (the `session.compaction.*` frames and the list item), and the list omits the v1 `/compact`
410
+ * turn and its reply. OpenChamber 2.8 keeps a message it learned from events but cannot find in the list beside the
411
+ * listed ones, so forwarding them drew an extra summary reply that could stay below newer messages.
412
+ */
413
+ summaries = new Map();
407
414
  translate(directory, ev) {
408
415
  switch (ev.type) {
409
416
  case "session.inbox.enqueued":
410
- case "session.inbox.delivered": {
417
+ case "session.inbox.delivered":
418
+ case "session.compaction.started":
419
+ case "session.compaction.ended": {
411
420
  const { created, ...data } = ev.properties;
412
421
  return [this.frame(directory, ev.type, data, created)];
413
422
  }
@@ -419,9 +428,7 @@ export class V2EventTranslator {
419
428
  case "session.revert.staged":
420
429
  case "session.revert.cleared":
421
430
  case "session.revert.committed":
422
- case "session.compaction.started":
423
431
  case "session.compaction.delta":
424
- case "session.compaction.ended":
425
432
  case "session.compaction.failed":
426
433
  case "shell.created":
427
434
  case "shell.exited":
@@ -472,6 +479,7 @@ export class V2EventTranslator {
472
479
  const info = ev.properties.info;
473
480
  this.sessions.delete(info.id);
474
481
  this.reports.delete(info.id);
482
+ this.summaries.delete(info.id);
475
483
  return [this.frame(directory, "session.deleted", { sessionID: info.id })];
476
484
  }
477
485
  case "session.status":
@@ -584,6 +592,9 @@ export class V2EventTranslator {
584
592
  const st = this.state(sessionID);
585
593
  if (status.type === "busy" && !st.executionStarted) {
586
594
  st.executionStarted = true;
595
+ // A history reload while idle re-announces finished replies; the last one must not decide this outcome.
596
+ if (st.step?.ended)
597
+ delete st.step;
587
598
  frames.push(this.frame(directory, "session.execution.started", { sessionID }));
588
599
  }
589
600
  return frames;
@@ -591,6 +602,13 @@ export class V2EventTranslator {
591
602
  onMessageUpdated(directory, info) {
592
603
  if (info.role === "user")
593
604
  return []; // the UI inserts user messages optimistically
605
+ if (info.summary === true) {
606
+ let summaries = this.summaries.get(info.sessionID);
607
+ if (summaries === undefined)
608
+ this.summaries.set(info.sessionID, (summaries = new Set()));
609
+ summaries.add(info.id);
610
+ return [];
611
+ }
594
612
  const st = this.state(info.sessionID);
595
613
  const frames = [];
596
614
  const isNew = st.step === undefined || st.step.messageID !== info.id;
@@ -662,18 +680,11 @@ export class V2EventTranslator {
662
680
  ];
663
681
  }
664
682
  onPartUpdated(directory, part, delta) {
665
- if (part.type === "file" || part.type === "agent")
683
+ if (part.type === "file" ||
684
+ part.type === "agent" ||
685
+ part.type === "compaction" ||
686
+ this.summaries.get(part.sessionID)?.has(part.messageID))
666
687
  return [];
667
- if (part.type === "compaction")
668
- // Like shell turns, the server creates this user turn; there is no optimistic prompt.
669
- return [
670
- this.frame(directory, "session.prompted", {
671
- sessionID: part.sessionID,
672
- messageID: part.messageID,
673
- prompt: { text: "/compact" },
674
- delivery: "queue",
675
- }),
676
- ];
677
688
  return part.type === "tool" ? this.onToolPart(directory, part) : this.onTextPart(directory, part, delta);
678
689
  }
679
690
  onTextPart(directory, part, delta) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antechamber-openchamber",
3
- "version": "2.0.22",
3
+ "version": "2.0.23",
4
4
  "description": "OpenChamber extension for antechamber: installs and pins the antechamber server and OmO, draws the OmO Graph and the OmO Work section, and titles OmO tool cards",
5
5
  "private": true,
6
6
  "type": "module",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antechamber",
3
- "version": "2.0.22",
3
+ "version": "2.0.23",
4
4
  "description": "OpenCode-compatible HTTP/SSE server that lets OpenChamber drive the pi coding agent (and OmO) over RPC",
5
5
  "type": "module",
6
6
  "license": "MIT",