@ponythewhite/base-context 1.0.8 → 1.0.10
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 +13 -0
- package/dist/base-context-runtime/pyproject.toml +1 -1
- package/dist/base-context-runtime/uv.lock +1 -1
- package/dist/build-info.json +1 -1
- package/dist/bundle/{bundled-modules-IGMJH2MU.js → bundled-modules-MX6YNAM2.js} +2 -2
- package/dist/bundle/{chunk-EXEFSSF4.js → chunk-CDXQNS5P.js} +176 -37
- package/dist/bundle/{chunk-RVJVXZCS.js → chunk-UHLGPYMI.js} +20 -40
- package/dist/bundle/{cli-main-BUK7QTHO.js → cli-main-D7W3WWCV.js} +2 -2
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/{main-2FWHT2WZ.js → main-5J3QBZ5Y.js} +2 -2
- package/dist/core/agent-session.d.ts +3 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +48 -5
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/canonical-context.d.ts.map +1 -1
- package/dist/core/canonical-context.js +115 -30
- package/dist/core/canonical-context.js.map +1 -1
- package/dist/core/context-epoch.d.ts +14 -3
- package/dist/core/context-epoch.d.ts.map +1 -1
- package/dist/core/context-epoch.js +5 -1
- package/dist/core/context-epoch.js.map +1 -1
- package/dist/core/inference-coordinator.d.ts +1 -1
- package/dist/core/inference-coordinator.d.ts.map +1 -1
- package/dist/core/inference-coordinator.js +2 -2
- package/dist/core/inference-coordinator.js.map +1 -1
- package/dist/core/public-context.d.ts.map +1 -1
- package/dist/core/public-context.js +20 -8
- package/dist/core/public-context.js.map +1 -1
- package/dist/core/request-view-selection.d.ts +4 -2
- package/dist/core/request-view-selection.d.ts.map +1 -1
- package/dist/core/request-view-selection.js +7 -4
- package/dist/core/request-view-selection.js.map +1 -1
- package/dist/core/session-manager.d.ts +2 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +38 -13
- package/dist/core/session-manager.js.map +1 -1
- package/dist/modes/daemon/daemon-mode.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-mode.js +15 -30
- package/dist/modes/daemon/daemon-mode.js.map +1 -1
- package/dist/modes/daemon/daemon-socket.d.ts +5 -0
- package/dist/modes/daemon/daemon-socket.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-socket.js +19 -0
- package/dist/modes/daemon/daemon-socket.js.map +1 -1
- package/dist/modes/daemon/daemon-supervisor.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-supervisor.js +6 -7
- package/dist/modes/daemon/daemon-supervisor.js.map +1 -1
- package/dist/modes/daemon/daemon-worker-client.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-worker-client.js +5 -5
- package/dist/modes/daemon/daemon-worker-client.js.map +1 -1
- package/package.json +4 -4
|
@@ -15,7 +15,7 @@ import { captureEpochCopyEntry, readCopiedEpochSource, rebuildCopiedContextEpoch
|
|
|
15
15
|
import { GOAL_STATE_CUSTOM_TYPE } from "./goals.js";
|
|
16
16
|
import { HistoryIndex, HistoryIndexUnsupportedError } from "./history-index.js";
|
|
17
17
|
import { decodeJournalFrame, encodeJournalFrame, INITIAL_JOURNAL_CURSOR, } from "./journal-frame.js";
|
|
18
|
-
import { createCompactionSummaryMessage } from "./messages.js";
|
|
18
|
+
import { COMPACTION_OUTCOME_CUSTOM_TYPE, createCompactionSummaryMessage, } from "./messages.js";
|
|
19
19
|
import { SELECTED_SKILL_CUSTOM_TYPE, SELECTED_SKILL_DETAIL, selectedSkillBlock, selectedSkillCapture, } from "./selected-skills.js";
|
|
20
20
|
import { DEFAULT_NATIVE_RECOVERY_LIMITS } from "./selective-recovery.js";
|
|
21
21
|
import { orderContextToolResults, sessionEntryMessage } from "./session-context-messages.js";
|
|
@@ -30,6 +30,17 @@ import { taskStateReadLimits } from "./task-state-reducer.js";
|
|
|
30
30
|
import { addAssistantUsage, cloneUsage, emptyUsage, sessionUsageSummaryFrom, subtractAssistantUsage, } from "./usage.js";
|
|
31
31
|
export const CURRENT_SESSION_VERSION = 3;
|
|
32
32
|
const SESSION_ASYNC_PARSE_YIELD_BYTES = 4 * 1024 * 1024;
|
|
33
|
+
// These records advance the journal leaf without changing the captured compaction input.
|
|
34
|
+
const COMPACTION_BOOKKEEPING_ENTRY_TYPES = new Set([
|
|
35
|
+
"session_state",
|
|
36
|
+
"agent_status",
|
|
37
|
+
"git_state",
|
|
38
|
+
"child_usage_attributed",
|
|
39
|
+
]);
|
|
40
|
+
function isCompactionBookkeeping(entry) {
|
|
41
|
+
return (COMPACTION_BOOKKEEPING_ENTRY_TYPES.has(entry.type) ||
|
|
42
|
+
(entry.type === "custom_message" && entry.customType === COMPACTION_OUTCOME_CUSTOM_TYPE));
|
|
43
|
+
}
|
|
33
44
|
// Entry types that can represent user intent (vs. daemon bookkeeping like
|
|
34
45
|
// session_state/agent_status/git_state/child_usage_attributed). Used by
|
|
35
46
|
// hasUserContent to decide whether a message-less draft is safe to discard.
|
|
@@ -971,6 +982,7 @@ function newSessionWriteState() {
|
|
|
971
982
|
reservedLeaf: null,
|
|
972
983
|
leafId: null,
|
|
973
984
|
branchSelectionRevision: 0,
|
|
985
|
+
compactionRevision: 0,
|
|
974
986
|
pins: 0,
|
|
975
987
|
retired: false,
|
|
976
988
|
closed: false,
|
|
@@ -1745,8 +1757,11 @@ export class SessionManager {
|
|
|
1745
1757
|
}
|
|
1746
1758
|
Object.assign(state, metadata);
|
|
1747
1759
|
state.metadataRefs = undefined;
|
|
1748
|
-
if (advanceLeaf)
|
|
1760
|
+
if (advanceLeaf) {
|
|
1749
1761
|
state.leafId = snapshot.id;
|
|
1762
|
+
if (!isCompactionBookkeeping(snapshot))
|
|
1763
|
+
state.compactionRevision++;
|
|
1764
|
+
}
|
|
1750
1765
|
state.reservedLeaf = state.leafId;
|
|
1751
1766
|
if (this.writeState === state)
|
|
1752
1767
|
this.leafId = state.leafId;
|
|
@@ -1838,6 +1853,8 @@ export class SessionManager {
|
|
|
1838
1853
|
target.message.usage = cloneUsage(snapshot.aggregateUsage);
|
|
1839
1854
|
}
|
|
1840
1855
|
state.leafId = snapshot.id;
|
|
1856
|
+
if (!isCompactionBookkeeping(snapshot))
|
|
1857
|
+
state.compactionRevision++;
|
|
1841
1858
|
if (this.writeState === state) {
|
|
1842
1859
|
this.leafId = snapshot.id;
|
|
1843
1860
|
this._notifyPersistListeners();
|
|
@@ -1911,8 +1928,21 @@ export class SessionManager {
|
|
|
1911
1928
|
let capturedSource;
|
|
1912
1929
|
let captureFailure;
|
|
1913
1930
|
let selectionRevision;
|
|
1931
|
+
let compactionRevision;
|
|
1932
|
+
let currentRevision;
|
|
1933
|
+
const isCurrent = (revision) => capturedSource !== undefined &&
|
|
1934
|
+
this.writeState === state &&
|
|
1935
|
+
state.owner === owner &&
|
|
1936
|
+
!state.retired &&
|
|
1937
|
+
!state.closed &&
|
|
1938
|
+
this.sessionId === sessionId &&
|
|
1939
|
+
this.sessionFile === sessionFile &&
|
|
1940
|
+
state.branchSelectionRevision === selectionRevision &&
|
|
1941
|
+
state.compactionRevision === revision;
|
|
1914
1942
|
const sink = this._bindHistorySource((index, source, query) => createSessionHistoryReadScope(index, source, query, "source"), (source) => {
|
|
1915
1943
|
selectionRevision = state.branchSelectionRevision;
|
|
1944
|
+
compactionRevision = state.compactionRevision;
|
|
1945
|
+
currentRevision = compactionRevision;
|
|
1916
1946
|
if (!indexed)
|
|
1917
1947
|
residentBranch = this._readResidentBranches([source.leafId], capturedLimits, byId).branches[0];
|
|
1918
1948
|
capturedSource = source;
|
|
@@ -1941,15 +1971,7 @@ export class SessionManager {
|
|
|
1941
1971
|
if (JSON.stringify(epoch.source) !== JSON.stringify(capturedSource))
|
|
1942
1972
|
throw new Error("Context epoch does not match the bound source capture");
|
|
1943
1973
|
}
|
|
1944
|
-
if (!
|
|
1945
|
-
this.writeState !== state ||
|
|
1946
|
-
state.owner !== owner ||
|
|
1947
|
-
state.retired ||
|
|
1948
|
-
state.closed ||
|
|
1949
|
-
this.sessionId !== sessionId ||
|
|
1950
|
-
this.sessionFile !== sessionFile ||
|
|
1951
|
-
state.branchSelectionRevision !== selectionRevision ||
|
|
1952
|
-
state.leafId !== capturedSource.leafId)
|
|
1974
|
+
if (!isCurrent(compactionRevision))
|
|
1953
1975
|
throw new Error("Compaction source or branch changed");
|
|
1954
1976
|
};
|
|
1955
1977
|
// Admission is synchronous; this append queues behind the capture before release can drain it.
|
|
@@ -1963,12 +1985,15 @@ export class SessionManager {
|
|
|
1963
1985
|
snapshot.usage,
|
|
1964
1986
|
assertCurrent,
|
|
1965
1987
|
];
|
|
1966
|
-
|
|
1988
|
+
const entryId = await (qualification || snapshot.requestOutputs
|
|
1967
1989
|
? this._appendCompaction(...args, qualification, snapshot.requestOutputs)
|
|
1968
|
-
: this.appendCompaction(...args);
|
|
1990
|
+
: this.appendCompaction(...args));
|
|
1991
|
+
currentRevision = compactionRevision + 1;
|
|
1992
|
+
return entryId;
|
|
1969
1993
|
};
|
|
1970
1994
|
const bound = {
|
|
1971
1995
|
...sink,
|
|
1996
|
+
isCurrent: () => isCurrent(currentRevision),
|
|
1972
1997
|
readHistory: (read) => sink.readHistory((history) => read(history.branchContext)),
|
|
1973
1998
|
[readCopiedEpochSource]: (read) => sink.readHistory(read),
|
|
1974
1999
|
readBranch: async () => {
|