antechamber 2.0.21 → 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 +21 -0
- package/dist/pi-event-translation.d.ts +14 -0
- package/dist/pi-event-translation.js +21 -0
- package/dist/routes-v2.js +16 -2
- package/dist/sessions.js +4 -16
- package/dist/subagents.js +32 -13
- package/dist/types.d.ts +2 -0
- package/dist/v2.d.ts +24 -1
- package/dist/v2.js +78 -25
- package/extensions/antechamber/package.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,27 @@ 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
|
+
|
|
14
|
+
## [2.0.22] - 2026-11-30
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- OpenChamber 2.8 shows the real context usage, the model picker and the thinking-effort control again. It loads no
|
|
19
|
+
model catalog while the backend lists no plugins, so the context gauge fell back to a 200k limit (a 1M-token model
|
|
20
|
+
showed 130%), the picker stayed on "Loading...", and the UI polled the plugin list every 25 ms. antechamber now
|
|
21
|
+
lists itself as the one active builtin plugin.
|
|
22
|
+
- Finished background subagents no longer pile up as "Subagent finished" rows at the end of the conversation. Their
|
|
23
|
+
reports are now kept in the message history where each child ended, and a history reload (after a compaction, for
|
|
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.
|
|
30
|
+
|
|
10
31
|
## [2.0.21] - 2026-11-30
|
|
11
32
|
|
|
12
33
|
### Changed
|
|
@@ -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/routes-v2.js
CHANGED
|
@@ -14,7 +14,7 @@ import { formQuestionAnswer, questionFormID, toQuestionForm } from "./question-f
|
|
|
14
14
|
import { getAgentName } from "./agent-name.js";
|
|
15
15
|
import { vcsRead, VcsError } from "./vcs.js";
|
|
16
16
|
import { announceSessionError, compactSession, unsupportedShare } from "./session-commands.js";
|
|
17
|
-
import { defaultV2Model, flattenModels, toV2Message, toV2Session } from "./v2.js";
|
|
17
|
+
import { defaultV2Model, flattenModels, subagentReportMessage, toV2Message, toV2Session, } from "./v2.js";
|
|
18
18
|
import { SHELL_CANCELLATION_KEY } from "./omo-shells.js";
|
|
19
19
|
import { WorkStatusError } from "./work-status.js";
|
|
20
20
|
import { FileWatchError } from "./file-watch.js";
|
|
@@ -252,10 +252,15 @@ export async function handleV2(services, req, res, url, path, method, directory)
|
|
|
252
252
|
json(res, 400, errorBody("UnsupportedError", "Integration connections are not available; configure providers in OmO"));
|
|
253
253
|
return;
|
|
254
254
|
}
|
|
255
|
+
// OpenCode 2.4 lists its builtin plugins once a location has activated, and OpenChamber 2.8 reads an empty list as
|
|
256
|
+
// "still activating": it polls every 25 ms for 5 s and keeps an empty model catalog (location-plugins.ts
|
|
257
|
+
// `waitForLocationPlugins`, `plugins.length > 0`; OpenChamber 2.8.1). antechamber's catalog is ready at once, so it
|
|
258
|
+
// lists itself as the one active builtin. The Plugins settings page only matches configured package and local
|
|
259
|
+
// plugins (pluginLoadState.ts), so this entry shows nowhere.
|
|
255
260
|
if ((path === "/api/plugin" && method === "GET") || (path === "/api/plugin/check" && method === "POST")) {
|
|
256
261
|
if (method === "POST")
|
|
257
262
|
await services.body(req);
|
|
258
|
-
json(res, 200, withLocation([]));
|
|
263
|
+
json(res, 200, withLocation([{ id: "antechamber", source: { type: "builtin" }, features: {}, state: { status: "active" } }]));
|
|
259
264
|
return;
|
|
260
265
|
}
|
|
261
266
|
if (path === "/api/plugin/update" && method === "POST") {
|
|
@@ -725,6 +730,15 @@ export async function handleV2(services, req, res, url, path, method, directory)
|
|
|
725
730
|
if (item !== undefined)
|
|
726
731
|
messagesWithTurns.push(item);
|
|
727
732
|
}
|
|
733
|
+
// Each finished background subagent's report, where its child ended (see `subagentReportMessage`).
|
|
734
|
+
for (const message of history)
|
|
735
|
+
for (const part of message.parts) {
|
|
736
|
+
const report = part.type === "tool" ? subagentReportMessage(part) : undefined;
|
|
737
|
+
if (report === undefined)
|
|
738
|
+
continue;
|
|
739
|
+
const before = messagesWithTurns.findLastIndex((item) => item.time.created <= report.time.created);
|
|
740
|
+
messagesWithTurns.splice(before + 1, 0, report);
|
|
741
|
+
}
|
|
728
742
|
let messages = messagesWithTurns;
|
|
729
743
|
if (order !== "asc")
|
|
730
744
|
messages = messages.reverse(); // v2 default is newest-first
|
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
|
|
578
|
-
|
|
579
|
-
|
|
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
|
-
|
|
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(
|
|
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 (
|
|
1004
|
-
|
|
1005
|
-
|
|
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
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* assistant message — exactly how the UI rebuilds a fetched message's `content`
|
|
22
22
|
* array (index-CgR5rJq_ `Zh`).
|
|
23
23
|
*/
|
|
24
|
-
import type { OCAssistantMessage, OCMessageWithParts, OCModelRef, OCSession, OCEvent } from "./types.js";
|
|
24
|
+
import type { OCAssistantMessage, OCMessageWithParts, OCModelRef, OCPart, OCSession, OCEvent } from "./types.js";
|
|
25
25
|
interface V2Tokens {
|
|
26
26
|
input: number;
|
|
27
27
|
output: number;
|
|
@@ -172,6 +172,15 @@ export interface V2Message {
|
|
|
172
172
|
tokens?: V2Tokens;
|
|
173
173
|
error?: OCAssistantMessage["error"];
|
|
174
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* The report as the message list holds it: OpenCode 2.x keeps a finished background subagent's report in history as
|
|
177
|
+
* a synthetic message at the time the child ended. OpenChamber 2.8 adds a live report it does not hold yet at the end
|
|
178
|
+
* of the conversation, whatever its `created` (message-ordering.ts `insertMessageInEventOrder`), so a report missing
|
|
179
|
+
* from the list lands below the last reply.
|
|
180
|
+
*/
|
|
181
|
+
export declare function subagentReportMessage(part: Extract<OCPart, {
|
|
182
|
+
type: "tool";
|
|
183
|
+
}>): V2Message | undefined;
|
|
175
184
|
export declare function toV2Message(info: OCMessageWithParts): V2Message;
|
|
176
185
|
export interface V2Envelope {
|
|
177
186
|
durable?: {
|
|
@@ -195,6 +204,20 @@ export interface V2Envelope {
|
|
|
195
204
|
export declare class V2EventTranslator {
|
|
196
205
|
private sessions;
|
|
197
206
|
private sequences;
|
|
207
|
+
/**
|
|
208
|
+
* Per session, the background tasks this translator saw running, with the report last sent for each (its data and
|
|
209
|
+
* end time, as JSON; undefined until one is sent). Unlike `sessions` it outlives the turn: a history reload
|
|
210
|
+
* re-emits every old card, and a report sent again for a task that ended earlier is a new row at the end of the
|
|
211
|
+
* conversation in OpenChamber 2.8 (see `subagentReportMessage`).
|
|
212
|
+
*/
|
|
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;
|
|
198
221
|
translate(directory: string, ev: OCEvent): V2Envelope[];
|
|
199
222
|
private onStatus;
|
|
200
223
|
private onMessageUpdated;
|
package/dist/v2.js
CHANGED
|
@@ -243,6 +243,15 @@ function backgroundTask(part) {
|
|
|
243
243
|
return undefined;
|
|
244
244
|
return { output: "", metadata: { ...st.metadata, status: "running", sessionID } };
|
|
245
245
|
}
|
|
246
|
+
/** A background `task` call: its child is reported by `subagentReport` once it ends. */
|
|
247
|
+
function isBackgroundTask(part) {
|
|
248
|
+
return part.tool === "task" && part.state.status !== "pending" && part.state.input.background === true;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* The report's id without its prefix: the live frame is `evt_<id>`, and OpenChamber 2.x files it as the message
|
|
252
|
+
* `msg_<id>` (events.ts `session.synthetic`), which is the id the message list gives it.
|
|
253
|
+
*/
|
|
254
|
+
const subagentReportID = (part) => `subagent_${part.id}`;
|
|
246
255
|
/** OpenCode 2.x's report of a finished background subagent, which OpenChamber 2.x puts on the call's row. */
|
|
247
256
|
function subagentReport(part) {
|
|
248
257
|
const st = part.state;
|
|
@@ -266,6 +275,26 @@ function subagentReport(part) {
|
|
|
266
275
|
metadata: { source: "subagent", childID, state, ...(typeof agent === "string" ? { agent } : {}) },
|
|
267
276
|
};
|
|
268
277
|
}
|
|
278
|
+
/**
|
|
279
|
+
* The report as the message list holds it: OpenCode 2.x keeps a finished background subagent's report in history as
|
|
280
|
+
* a synthetic message at the time the child ended. OpenChamber 2.8 adds a live report it does not hold yet at the end
|
|
281
|
+
* of the conversation, whatever its `created` (message-ordering.ts `insertMessageInEventOrder`), so a report missing
|
|
282
|
+
* from the list lands below the last reply.
|
|
283
|
+
*/
|
|
284
|
+
export function subagentReportMessage(part) {
|
|
285
|
+
const report = subagentReport(part);
|
|
286
|
+
if (report === undefined || part.state.status === "pending" || part.state.status === "running")
|
|
287
|
+
return undefined;
|
|
288
|
+
const { text, description, metadata } = report;
|
|
289
|
+
return {
|
|
290
|
+
id: `msg_${subagentReportID(part)}`,
|
|
291
|
+
time: { created: part.state.time.end },
|
|
292
|
+
type: "synthetic",
|
|
293
|
+
text: String(text),
|
|
294
|
+
...(typeof description === "string" ? { description } : {}),
|
|
295
|
+
metadata: metadata,
|
|
296
|
+
};
|
|
297
|
+
}
|
|
269
298
|
/**
|
|
270
299
|
* A card whose call left OmO work running (background-results.ts `backgroundShellID`), as OpenCode 2.x settles a
|
|
271
300
|
* call it moved to the background: completed at once with `{status: "running", shellID}` in its metadata, so
|
|
@@ -368,10 +397,26 @@ export function toV2Message(info) {
|
|
|
368
397
|
export class V2EventTranslator {
|
|
369
398
|
sessions = new Map();
|
|
370
399
|
sequences = new Map();
|
|
400
|
+
/**
|
|
401
|
+
* Per session, the background tasks this translator saw running, with the report last sent for each (its data and
|
|
402
|
+
* end time, as JSON; undefined until one is sent). Unlike `sessions` it outlives the turn: a history reload
|
|
403
|
+
* re-emits every old card, and a report sent again for a task that ended earlier is a new row at the end of the
|
|
404
|
+
* conversation in OpenChamber 2.8 (see `subagentReportMessage`).
|
|
405
|
+
*/
|
|
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();
|
|
371
414
|
translate(directory, ev) {
|
|
372
415
|
switch (ev.type) {
|
|
373
416
|
case "session.inbox.enqueued":
|
|
374
|
-
case "session.inbox.delivered":
|
|
417
|
+
case "session.inbox.delivered":
|
|
418
|
+
case "session.compaction.started":
|
|
419
|
+
case "session.compaction.ended": {
|
|
375
420
|
const { created, ...data } = ev.properties;
|
|
376
421
|
return [this.frame(directory, ev.type, data, created)];
|
|
377
422
|
}
|
|
@@ -383,9 +428,7 @@ export class V2EventTranslator {
|
|
|
383
428
|
case "session.revert.staged":
|
|
384
429
|
case "session.revert.cleared":
|
|
385
430
|
case "session.revert.committed":
|
|
386
|
-
case "session.compaction.started":
|
|
387
431
|
case "session.compaction.delta":
|
|
388
|
-
case "session.compaction.ended":
|
|
389
432
|
case "session.compaction.failed":
|
|
390
433
|
case "shell.created":
|
|
391
434
|
case "shell.exited":
|
|
@@ -435,6 +478,8 @@ export class V2EventTranslator {
|
|
|
435
478
|
case "session.deleted": {
|
|
436
479
|
const info = ev.properties.info;
|
|
437
480
|
this.sessions.delete(info.id);
|
|
481
|
+
this.reports.delete(info.id);
|
|
482
|
+
this.summaries.delete(info.id);
|
|
438
483
|
return [this.frame(directory, "session.deleted", { sessionID: info.id })];
|
|
439
484
|
}
|
|
440
485
|
case "session.status":
|
|
@@ -547,6 +592,9 @@ export class V2EventTranslator {
|
|
|
547
592
|
const st = this.state(sessionID);
|
|
548
593
|
if (status.type === "busy" && !st.executionStarted) {
|
|
549
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;
|
|
550
598
|
frames.push(this.frame(directory, "session.execution.started", { sessionID }));
|
|
551
599
|
}
|
|
552
600
|
return frames;
|
|
@@ -554,6 +602,13 @@ export class V2EventTranslator {
|
|
|
554
602
|
onMessageUpdated(directory, info) {
|
|
555
603
|
if (info.role === "user")
|
|
556
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
|
+
}
|
|
557
612
|
const st = this.state(info.sessionID);
|
|
558
613
|
const frames = [];
|
|
559
614
|
const isNew = st.step === undefined || st.step.messageID !== info.id;
|
|
@@ -625,18 +680,11 @@ export class V2EventTranslator {
|
|
|
625
680
|
];
|
|
626
681
|
}
|
|
627
682
|
onPartUpdated(directory, part, delta) {
|
|
628
|
-
if (part.type === "file" ||
|
|
683
|
+
if (part.type === "file" ||
|
|
684
|
+
part.type === "agent" ||
|
|
685
|
+
part.type === "compaction" ||
|
|
686
|
+
this.summaries.get(part.sessionID)?.has(part.messageID))
|
|
629
687
|
return [];
|
|
630
|
-
if (part.type === "compaction")
|
|
631
|
-
// Like shell turns, the server creates this user turn; there is no optimistic prompt.
|
|
632
|
-
return [
|
|
633
|
-
this.frame(directory, "session.prompted", {
|
|
634
|
-
sessionID: part.sessionID,
|
|
635
|
-
messageID: part.messageID,
|
|
636
|
-
prompt: { text: "/compact" },
|
|
637
|
-
delivery: "queue",
|
|
638
|
-
}),
|
|
639
|
-
];
|
|
640
688
|
return part.type === "tool" ? this.onToolPart(directory, part) : this.onTextPart(directory, part, delta);
|
|
641
689
|
}
|
|
642
690
|
onTextPart(directory, part, delta) {
|
|
@@ -742,6 +790,12 @@ export class V2EventTranslator {
|
|
|
742
790
|
ts.called = true;
|
|
743
791
|
frames.push(this.frame(directory, "session.tool.called", { ...base, input: state.input, executed: false }));
|
|
744
792
|
}
|
|
793
|
+
let reports = this.reports.get(part.sessionID);
|
|
794
|
+
if (isBackgroundTask(part) && state.status === "running" && !reports?.has(part.id)) {
|
|
795
|
+
if (reports === undefined)
|
|
796
|
+
this.reports.set(part.sessionID, (reports = new Map()));
|
|
797
|
+
reports.set(part.id, undefined);
|
|
798
|
+
}
|
|
745
799
|
const task = backgroundTask(part);
|
|
746
800
|
if (task !== undefined) {
|
|
747
801
|
if (!ts.ended) {
|
|
@@ -755,19 +809,18 @@ export class V2EventTranslator {
|
|
|
755
809
|
}
|
|
756
810
|
return frames;
|
|
757
811
|
}
|
|
758
|
-
//
|
|
759
|
-
//
|
|
760
|
-
//
|
|
761
|
-
//
|
|
762
|
-
//
|
|
763
|
-
//
|
|
764
|
-
// ended, not in a new row at the end.
|
|
812
|
+
// A background task this translator saw running reports when it ends, and again when its outcome changes (a
|
|
813
|
+
// revived task ends anew): OpenChamber 2.x finishes the row from the last report it holds (subagent-run.ts
|
|
814
|
+
// `findSubagentRun`). A card first seen finished (a history reload, an adapter restart) does not: its report is
|
|
815
|
+
// in the message list (`subagentReportMessage`), which OpenChamber 2.x reads again after a reconnect
|
|
816
|
+
// (event-reducer.ts `server.connected`). The frame keeps the task's end time and the list's id, so a report sent
|
|
817
|
+
// again replaces itself where the task ended.
|
|
765
818
|
const report = subagentReport(part);
|
|
766
|
-
if (report !== undefined && state.status !== "running") {
|
|
819
|
+
if (report !== undefined && state.status !== "running" && reports?.has(part.id)) {
|
|
767
820
|
const reported = safeJson([report, state.time.end]);
|
|
768
|
-
if (reported !==
|
|
769
|
-
|
|
770
|
-
frames.push(this.frame(directory, "session.synthetic", report, state.time.end, `
|
|
821
|
+
if (reported !== reports.get(part.id)) {
|
|
822
|
+
reports.set(part.id, reported);
|
|
823
|
+
frames.push(this.frame(directory, "session.synthetic", report, state.time.end, `evt_${subagentReportID(part)}`));
|
|
771
824
|
}
|
|
772
825
|
}
|
|
773
826
|
const background = backgroundShell(part);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "antechamber-openchamber",
|
|
3
|
-
"version": "2.0.
|
|
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",
|