antechamber 2.0.2 → 2.0.3
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 +9 -0
- package/dist/routes-v2.js +2 -3
- package/dist/session-store.d.ts +23 -0
- package/dist/session-store.js +26 -0
- package/dist/sessions.d.ts +2 -0
- package/dist/sessions.js +15 -9
- package/dist/subagents.d.ts +1 -0
- package/dist/subagents.js +12 -6
- package/extensions/antechamber/package.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,15 @@ and this project uses [Semantic Versioning](https://semver.org/).
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.0.3] - 2026-11-17
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- A cold session list no longer parses every transcript on disk. With about 1,900 sessions it stalled the adapter for
|
|
15
|
+
27 s and grew it past 9 GB, long enough for OpenChamber to crash and stop it on every launch. The list now reads
|
|
16
|
+
each session's cost and tokens from the registry, and idle subagents load their transcript when first opened.
|
|
17
|
+
Sessions saved by an older version show their usage once they are opened again.
|
|
18
|
+
|
|
10
19
|
## [2.0.2] - 2026-11-11
|
|
11
20
|
|
|
12
21
|
### Added
|
package/dist/routes-v2.js
CHANGED
|
@@ -36,8 +36,7 @@ async function v2Agents(services) {
|
|
|
36
36
|
system: agent.prompt,
|
|
37
37
|
}));
|
|
38
38
|
}
|
|
39
|
-
function v2Session(services, info) {
|
|
40
|
-
const managed = services.sessions.get(info.id);
|
|
39
|
+
function v2Session(services, info, managed = services.sessions.get(info.id)) {
|
|
41
40
|
return toV2Session(info, { model: managed?.model, agent: info.agent ?? getAgentName() });
|
|
42
41
|
}
|
|
43
42
|
const execFileAsync = promisify(execFile);
|
|
@@ -461,7 +460,7 @@ export async function handleV2(services, req, res, url, path, method, directory)
|
|
|
461
460
|
infos = infos.filter((session) => session.parentID === (parentID === "null" ? undefined : parentID));
|
|
462
461
|
if (archived === "true" || archived === "false")
|
|
463
462
|
infos = infos.filter((session) => (session.time.archived !== undefined) === (archived === "true"));
|
|
464
|
-
let sessions = infos.map((info) => v2Session(services, info));
|
|
463
|
+
let sessions = infos.map((info) => v2Session(services, info, services.sessions.peek(info.id)));
|
|
465
464
|
sessions.sort((left, right) => compareSessions(left, right, order));
|
|
466
465
|
const cursor = decodeSessionCursor(url.searchParams.get("cursor"));
|
|
467
466
|
if (cursor !== undefined)
|
package/dist/session-store.d.ts
CHANGED
|
@@ -39,6 +39,27 @@ export interface ScannedSession extends SessionSelection {
|
|
|
39
39
|
updated: number;
|
|
40
40
|
}
|
|
41
41
|
export type TitleSource = "user" | "native" | "fallback" | "generated";
|
|
42
|
+
export interface SessionUsage {
|
|
43
|
+
cost: number;
|
|
44
|
+
tokens: {
|
|
45
|
+
input: number;
|
|
46
|
+
output: number;
|
|
47
|
+
reasoning: number;
|
|
48
|
+
cache: {
|
|
49
|
+
read: number;
|
|
50
|
+
write: number;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
type UsageSource = {
|
|
55
|
+
cost?: number;
|
|
56
|
+
tokens?: SessionUsage["tokens"];
|
|
57
|
+
};
|
|
58
|
+
export declare function emptyTokens(): SessionUsage["tokens"];
|
|
59
|
+
export declare function sessionUsageEntry(info: UsageSource): {
|
|
60
|
+
usage?: SessionUsage;
|
|
61
|
+
};
|
|
62
|
+
export declare function sameUsage(saved: SessionUsage | undefined, info: UsageSource): boolean;
|
|
42
63
|
export interface InstructionEntryState {
|
|
43
64
|
value: unknown;
|
|
44
65
|
removed?: true;
|
|
@@ -80,6 +101,8 @@ export interface SessionRegistryEntry {
|
|
|
80
101
|
message: string;
|
|
81
102
|
at: number;
|
|
82
103
|
};
|
|
104
|
+
/** Spend from the last parsed transcript, so a cold listing does not parse every transcript to show it. */
|
|
105
|
+
usage?: SessionUsage;
|
|
83
106
|
created: number;
|
|
84
107
|
updated: number;
|
|
85
108
|
}
|
package/dist/session-store.js
CHANGED
|
@@ -29,6 +29,16 @@ export function piSessionDir(cwd) {
|
|
|
29
29
|
export function ocIdFor(piSessionId) {
|
|
30
30
|
return `ses_${createHash("md5").update(piSessionId).digest("hex")}`;
|
|
31
31
|
}
|
|
32
|
+
export function emptyTokens() {
|
|
33
|
+
return { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } };
|
|
34
|
+
}
|
|
35
|
+
export function sessionUsageEntry(info) {
|
|
36
|
+
return info.tokens === undefined ? {} : { usage: { cost: info.cost ?? 0, tokens: structuredClone(info.tokens) } };
|
|
37
|
+
}
|
|
38
|
+
export function sameUsage(saved, info) {
|
|
39
|
+
const current = sessionUsageEntry(info).usage;
|
|
40
|
+
return JSON.stringify(saved) === JSON.stringify(current);
|
|
41
|
+
}
|
|
32
42
|
export class SessionPersistenceError extends Error {
|
|
33
43
|
constructor(file, cause) {
|
|
34
44
|
super(`Failed to persist session registry ${file}: ${cause instanceof Error ? cause.message : String(cause)}`, {
|
|
@@ -438,6 +448,20 @@ function childTask(value) {
|
|
|
438
448
|
record(value.details) &&
|
|
439
449
|
(value.terminalAt === undefined || (typeof value.terminalAt === "number" && Number.isFinite(value.terminalAt))));
|
|
440
450
|
}
|
|
451
|
+
function finite(value) {
|
|
452
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
453
|
+
}
|
|
454
|
+
function sessionUsage(value) {
|
|
455
|
+
if (!record(value) || !finite(value.cost) || !record(value.tokens))
|
|
456
|
+
return false;
|
|
457
|
+
const { tokens } = value;
|
|
458
|
+
return (finite(tokens.input) &&
|
|
459
|
+
finite(tokens.output) &&
|
|
460
|
+
finite(tokens.reasoning) &&
|
|
461
|
+
record(tokens.cache) &&
|
|
462
|
+
finite(tokens.cache.read) &&
|
|
463
|
+
finite(tokens.cache.write));
|
|
464
|
+
}
|
|
441
465
|
function titleSource(value) {
|
|
442
466
|
return value === "user" || value === "native" || value === "fallback" || value === "generated";
|
|
443
467
|
}
|
|
@@ -491,6 +515,8 @@ function registryEntry(value) {
|
|
|
491
515
|
typeof value.lastStop.at !== "number" ||
|
|
492
516
|
!Number.isFinite(value.lastStop.at)))
|
|
493
517
|
return false;
|
|
518
|
+
if (value.usage !== undefined && !sessionUsage(value.usage))
|
|
519
|
+
return false;
|
|
494
520
|
return true;
|
|
495
521
|
}
|
|
496
522
|
/**
|
package/dist/sessions.d.ts
CHANGED
|
@@ -150,6 +150,8 @@ export declare class SessionManager {
|
|
|
150
150
|
/** Reuse an already-running agent for directory-scoped catalog reads. Never revives a dormant session. */
|
|
151
151
|
liveClient(directory: string): PiRpcClient | undefined;
|
|
152
152
|
private sessionInfo;
|
|
153
|
+
/** A session `list` already loaded, without reading its history as `get` does. */
|
|
154
|
+
peek(sessionId: string): ManagedSession | undefined;
|
|
153
155
|
get(sessionId: string): ManagedSession | undefined;
|
|
154
156
|
remove(sessionId: string): Promise<boolean>;
|
|
155
157
|
private removeLive;
|
package/dist/sessions.js
CHANGED
|
@@ -22,7 +22,7 @@ import { OmoShells } from "./omo-shells.js";
|
|
|
22
22
|
import { sessionDiff } from "./session-diff.js";
|
|
23
23
|
import { waitForMcpServers } from "./mcp.js";
|
|
24
24
|
import { announceSessionNotice, noticeMessage, skillCommandText, slashTitlePrompt } from "./session-commands.js";
|
|
25
|
-
import { ocIdFor, piSessionDir, piSessionsRootMtime, scanAllPiSessions, scanPiSessions, SessionStore, readSessionFileMeta, } from "./session-store.js";
|
|
25
|
+
import { emptyTokens, ocIdFor, piSessionDir, piSessionsRootMtime, sameUsage, sessionUsageEntry, scanAllPiSessions, scanPiSessions, SessionStore, readSessionFileMeta, } from "./session-store.js";
|
|
26
26
|
import { ADAPTER_VERSION } from "./version.js";
|
|
27
27
|
export { ADAPTER_VERSION } from "./version.js";
|
|
28
28
|
const SESSION_SCAN_CACHE_TTL_MS = 5_000;
|
|
@@ -375,12 +375,10 @@ export class SessionManager {
|
|
|
375
375
|
this.subagents.restoreAll();
|
|
376
376
|
if (directory !== undefined) {
|
|
377
377
|
this.ensureScanned(directory);
|
|
378
|
-
return [...this.sessions.values()]
|
|
379
|
-
.filter((s) => s.info.directory === directory)
|
|
380
|
-
.map((s) => this.sessionInfo(s));
|
|
378
|
+
return [...this.sessions.values()].filter((s) => s.info.directory === directory).map((s) => s.info);
|
|
381
379
|
}
|
|
382
380
|
// Unfiltered: keep the old semantics — live sessions only.
|
|
383
|
-
return [...this.sessions.values()].filter((s) => s.restored === undefined).map((s) =>
|
|
381
|
+
return [...this.sessions.values()].filter((s) => s.restored === undefined).map((s) => s.info);
|
|
384
382
|
});
|
|
385
383
|
}
|
|
386
384
|
/**
|
|
@@ -393,7 +391,8 @@ export class SessionManager {
|
|
|
393
391
|
this.refreshNativeTitles();
|
|
394
392
|
this.ensureAllScanned();
|
|
395
393
|
this.subagents.restoreAll();
|
|
396
|
-
|
|
394
|
+
// Dormant usage comes from the registry: parsing every transcript here stalled startup for minutes.
|
|
395
|
+
return [...this.sessions.values()].map((s) => s.info);
|
|
397
396
|
});
|
|
398
397
|
}
|
|
399
398
|
/** Reuse an already-running agent for directory-scoped catalog reads. Never revives a dormant session. */
|
|
@@ -409,6 +408,10 @@ export class SessionManager {
|
|
|
409
408
|
this.ensureMessages(s);
|
|
410
409
|
return s.info;
|
|
411
410
|
}
|
|
411
|
+
/** A session `list` already loaded, without reading its history as `get` does. */
|
|
412
|
+
peek(sessionId) {
|
|
413
|
+
return this.disposed ? undefined : this.sessions.get(sessionId);
|
|
414
|
+
}
|
|
412
415
|
get(sessionId) {
|
|
413
416
|
return this.store.batch(() => {
|
|
414
417
|
if (this.disposed)
|
|
@@ -1542,9 +1545,10 @@ export class SessionManager {
|
|
|
1542
1545
|
if (fileSize !== undefined)
|
|
1543
1546
|
s.historyFileSize = fileSize;
|
|
1544
1547
|
this.subagents.discover(s, s.messages);
|
|
1545
|
-
|
|
1548
|
+
const costChanged = syncSessionCost(s);
|
|
1549
|
+
if (admissions || !sameUsage(this.store.get(s.info.id)?.usage, s.info))
|
|
1546
1550
|
this.persistMeta(s);
|
|
1547
|
-
if (
|
|
1551
|
+
if (costChanged)
|
|
1548
1552
|
this.emit(s.info.directory, { type: "session.updated", properties: { info: s.info } });
|
|
1549
1553
|
}
|
|
1550
1554
|
return s.messages;
|
|
@@ -1685,7 +1689,8 @@ export class SessionManager {
|
|
|
1685
1689
|
slug: sc.piSessionId,
|
|
1686
1690
|
path: "",
|
|
1687
1691
|
summary: { additions: 0, deletions: 0, files: 0 },
|
|
1688
|
-
tokens:
|
|
1692
|
+
tokens: reg?.usage !== undefined ? structuredClone(reg.usage.tokens) : emptyTokens(),
|
|
1693
|
+
...(reg?.usage !== undefined ? { cost: reg.usage.cost } : {}),
|
|
1689
1694
|
...(reg?.metadata !== undefined ? { metadata: reg.metadata } : {}),
|
|
1690
1695
|
...(reg?.parentID !== undefined ? { parentID: reg.parentID } : {}),
|
|
1691
1696
|
...(reg?.parentMessageID !== undefined ? { parentMessageID: reg.parentMessageID } : {}),
|
|
@@ -1801,6 +1806,7 @@ export class SessionManager {
|
|
|
1801
1806
|
...(s.info.parentMessageID !== undefined ? { parentMessageID: s.info.parentMessageID } : {}),
|
|
1802
1807
|
...(s.model !== undefined ? { model: { providerID: s.model.providerID, modelID: s.model.modelID } } : {}),
|
|
1803
1808
|
...(s.lastStop !== undefined ? { lastStop: s.lastStop } : {}),
|
|
1809
|
+
...sessionUsageEntry(s.info),
|
|
1804
1810
|
created: s.info.time.created,
|
|
1805
1811
|
updated: s.info.time.updated,
|
|
1806
1812
|
});
|
package/dist/subagents.d.ts
CHANGED
|
@@ -92,6 +92,7 @@ export declare class SubagentBridge {
|
|
|
92
92
|
owns(id: string): boolean;
|
|
93
93
|
messages(id: string): OCMessageWithParts[];
|
|
94
94
|
private watch;
|
|
95
|
+
/** `hydrate: false` leaves an idle child's transcript unread until its messages are asked for. */
|
|
95
96
|
private refresh;
|
|
96
97
|
private reconcileTaskRecord;
|
|
97
98
|
private hydrateTranscript;
|
package/dist/subagents.js
CHANGED
|
@@ -4,7 +4,7 @@ import { basename, dirname, join } from "node:path";
|
|
|
4
4
|
import { isDeepStrictEqual } from "node:util";
|
|
5
5
|
import { piAgentDir } from "./agent-dir.js";
|
|
6
6
|
import { syncSessionCost } from "./pi-event-translation.js";
|
|
7
|
-
import { ocIdFor, SessionPersistenceError, SessionStore } from "./session-store.js";
|
|
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";
|
|
10
10
|
// macOS watches directories through FSEvents, which goes live asynchronously after
|
|
@@ -622,7 +622,8 @@ export class SubagentBridge {
|
|
|
622
622
|
}
|
|
623
623
|
}
|
|
624
624
|
create(parent, task, id = taskSessionId(task.id, task.parentPiId, this.store)) {
|
|
625
|
-
const
|
|
625
|
+
const saved = this.store.get(id);
|
|
626
|
+
const archived = saved?.archived;
|
|
626
627
|
const session = this.managedSession({
|
|
627
628
|
id,
|
|
628
629
|
parentID: parent.info.id,
|
|
@@ -631,6 +632,7 @@ export class SubagentBridge {
|
|
|
631
632
|
title: typeof task.input.description === "string" ? task.input.description : task.id,
|
|
632
633
|
version: parent.info.version,
|
|
633
634
|
time: { ...parent.info.time, ...(archived !== undefined ? { archived } : {}) },
|
|
635
|
+
...(saved?.usage !== undefined ? { cost: saved.usage.cost, tokens: structuredClone(saved.usage.tokens) } : {}),
|
|
634
636
|
});
|
|
635
637
|
const child = {
|
|
636
638
|
session,
|
|
@@ -662,7 +664,7 @@ export class SubagentBridge {
|
|
|
662
664
|
return undefined;
|
|
663
665
|
const child = this.create(this.detachedParent(entry.parentID, entry.directory, entry), entry.task, id);
|
|
664
666
|
child.session.info.title = entry.title ?? child.session.info.title;
|
|
665
|
-
this.refresh(child, false);
|
|
667
|
+
this.refresh(child, false, true, false);
|
|
666
668
|
return child.session;
|
|
667
669
|
});
|
|
668
670
|
}
|
|
@@ -690,7 +692,7 @@ export class SubagentBridge {
|
|
|
690
692
|
},
|
|
691
693
|
details: found.data,
|
|
692
694
|
}, id);
|
|
693
|
-
this.refresh(child, false);
|
|
695
|
+
this.refresh(child, false, true, false);
|
|
694
696
|
return child.session;
|
|
695
697
|
}
|
|
696
698
|
/**
|
|
@@ -793,7 +795,8 @@ export class SubagentBridge {
|
|
|
793
795
|
}, FSEVENTS_STARTUP_RECHECK_MS).unref();
|
|
794
796
|
}
|
|
795
797
|
}
|
|
796
|
-
|
|
798
|
+
/** `hydrate: false` leaves an idle child's transcript unread until its messages are asked for. */
|
|
799
|
+
refresh(child, publish, useRecord = true, hydrate = true) {
|
|
797
800
|
const archive = this.archive(child);
|
|
798
801
|
const found = this.reconcileTaskRecord(child, useRecord);
|
|
799
802
|
// OmO stops in-process workers with their parent and leaves them `running` but `persisted_only`
|
|
@@ -805,7 +808,9 @@ export class SubagentBridge {
|
|
|
805
808
|
previousMessages: child.session.messages ?? [],
|
|
806
809
|
previousStatus: child.session.status.type,
|
|
807
810
|
running,
|
|
808
|
-
costChanged:
|
|
811
|
+
costChanged: hydrate || running || child.loaded
|
|
812
|
+
? this.hydrateTranscript(child, archive, running, child.session.status.type)
|
|
813
|
+
: false,
|
|
809
814
|
updatedParts: this.reconcileRuntime(child, running),
|
|
810
815
|
};
|
|
811
816
|
if (state.costChanged)
|
|
@@ -1015,6 +1020,7 @@ export class SubagentBridge {
|
|
|
1015
1020
|
parentID: info.parentID,
|
|
1016
1021
|
...(info.time.archived !== undefined ? { archived: info.time.archived } : {}),
|
|
1017
1022
|
task: child.task,
|
|
1023
|
+
...sessionUsageEntry(info),
|
|
1018
1024
|
created: info.time.created,
|
|
1019
1025
|
updated: info.time.updated,
|
|
1020
1026
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "antechamber-openchamber",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
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",
|