@retaw106/mmc-oc 2.5.0 → 2.6.0
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/dist/{context-xx09sh1g.js → context-cfbjrr0n.js} +418 -166
- package/dist/features/magic-context/compaction-marker.d.ts +34 -6
- package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
- package/dist/features/magic-context/message-index.d.ts +1 -24
- package/dist/features/magic-context/message-index.d.ts.map +1 -1
- package/dist/features/magic-context/session-decision-calibration.d.ts.map +1 -1
- package/dist/features/magic-context/session-retention.fixture.d.ts +4 -0
- package/dist/features/magic-context/session-retention.fixture.d.ts.map +1 -0
- package/dist/features/magic-context/storage-meta-persisted.d.ts +21 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/features/magic-context/storage-native-replay.d.ts +2 -0
- package/dist/features/magic-context/storage-native-replay.d.ts.map +1 -1
- package/dist/features/magic-context/storage-session-tables.d.ts +4 -11
- package/dist/features/magic-context/storage-session-tables.d.ts.map +1 -1
- package/dist/features/magic-context/tool-definition-tokens.d.ts +113 -58
- package/dist/features/magic-context/tool-definition-tokens.d.ts.map +1 -1
- package/dist/features/magic-context/work-metrics.d.ts +5 -3
- package/dist/features/magic-context/work-metrics.d.ts.map +1 -1
- package/dist/hooks/magic-context/apply-operations.d.ts +32 -0
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/ask-answer-notice.d.ts +25 -0
- package/dist/hooks/magic-context/ask-answer-notice.d.ts.map +1 -0
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts +5 -5
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-marker-publication.d.ts +14 -0
- package/dist/hooks/magic-context/compaction-marker-publication.d.ts.map +1 -0
- package/dist/hooks/magic-context/compaction-off-transition.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts +11 -0
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +11 -3
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
- package/dist/hooks/magic-context/historian-history-wait.d.ts +16 -0
- package/dist/hooks/magic-context/historian-history-wait.d.ts.map +1 -0
- package/dist/hooks/magic-context/history-boundary-repair.d.ts +1 -1
- package/dist/hooks/magic-context/history-boundary-repair.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-measured-request.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-recovery-prefix.d.ts +3 -1
- package/dist/hooks/magic-context/lkg-recovery-prefix.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-replay-fit.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-slot.d.ts +2 -0
- package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-db.d.ts +8 -2
- package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-raw.d.ts +20 -0
- package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
- package/dist/hooks/magic-context/signed-thinking-fit-snapshot.d.ts +42 -0
- package/dist/hooks/magic-context/signed-thinking-fit-snapshot.d.ts.map +1 -0
- package/dist/hooks/magic-context/tag-messages.d.ts +2 -0
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/todo-view.d.ts +2 -2
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-mjf0p7yq.js → index-1np16gxq.js} +1 -1
- package/dist/{index-bpjjcdy9.js → index-8rmt6s4f.js} +77 -31
- package/dist/{index-k25thxq7.js → index-s3ebcy63.js} +1 -1
- package/dist/{index-1vxffj5j.js → index-t0zx3tgz.js} +408 -89
- package/dist/{index-0d40b4q8.js → index-xk1dz6q9.js} +9322 -9215
- package/dist/index.js +2 -2
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/{read-session-chunk-eb3fy45y.js → read-session-chunk-2s8x6xps.js} +2 -2
- package/dist/{recomp-orchestrator-mmpy5cb7.js → recomp-orchestrator-51xyaexp.js} +5 -5
- package/dist/{send-session-notification-zpqs213d.js → send-session-notification-vdppp5x6.js} +2 -2
- package/dist/shared/tag-transcript.d.ts +2 -0
- package/dist/shared/tag-transcript.d.ts.map +1 -1
- package/dist/shared/transcript.d.ts +3 -1
- package/dist/shared/transcript.d.ts.map +1 -1
- package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
- package/dist/tools/ctx-note/tools.d.ts.map +1 -1
- package/dist/tools/parameter-descriptions.d.ts +6 -6
- package/dist/tools/parameter-descriptions.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts +5 -1
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/store.d.ts.map +1 -1
- package/dist/v2/message-times.d.ts +17 -0
- package/dist/v2/message-times.d.ts.map +1 -0
- package/dist/v2/server.js +12923 -12197
- package/dist/v2/store-reader.d.ts +14 -4
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/web/main.js +85 -11
- package/dist/{wrapup-orchestrator-jq589pgr.js → wrapup-orchestrator-g0mww1h4.js} +5 -5
- package/package.json +1 -1
- package/src/config/latch-permanence-guard.test.ts +0 -5
- package/src/shared/prompt-surface-a1-golden.md +6 -7
- package/src/shared/sqlite-transaction-mode-guard.test.ts +2 -0
- package/src/shared/tag-transcript.ts +47 -4
- package/src/shared/transcript.ts +1 -1
- package/src/shared/write-transaction-attribution.test.ts +1 -6
- package/dist/features/magic-context/message-index-sweep.d.ts +0 -11
- package/dist/features/magic-context/message-index-sweep.d.ts.map +0 -1
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
withReadOnlySessionDb,
|
|
29
29
|
getRawSessionMessageCountFromDb,
|
|
30
30
|
getMessageTimesFromOpenCodeDb
|
|
31
|
-
} from "./index-
|
|
31
|
+
} from "./index-8rmt6s4f.js";
|
|
32
32
|
|
|
33
33
|
// src/shared/protected-tools-policy.ts
|
|
34
34
|
var DEFAULT_PROTECTED_TOOLS = {
|
|
@@ -4690,6 +4690,70 @@ function expandToolPart(part, overrides, legacyPreview = false) {
|
|
|
4690
4690
|
return renderToolTemplate(template, input, state?.output ?? state?.error, legacyPreview);
|
|
4691
4691
|
}
|
|
4692
4692
|
|
|
4693
|
+
// src/hooks/magic-context/ask-answer-notice.ts
|
|
4694
|
+
var ANSWER_HEADER_PREFIX = /^Inbox [^\n]* notice from user via user_answer \(user_answer\)/;
|
|
4695
|
+
var ANSWER_TRAILER = /\n([\s\S]*?)\nThis ask is now closed; no dismiss is needed\. Continue accordingly\.$/;
|
|
4696
|
+
var ANSWER_ANSWER_LINE = /^The user answered your parked question (\S+)\.\nQuestion: ([^\n]+)\nAnswer: /;
|
|
4697
|
+
var ANSWER_QUESTION_LINE = /^Question: ([^\n]+)\nAnswer: /;
|
|
4698
|
+
var reminderEnvelopePattern = /<system-reminder>([\s\S]*?)<\/system-reminder>/gi;
|
|
4699
|
+
function reminderBodies(text) {
|
|
4700
|
+
reminderEnvelopePattern.lastIndex = 0;
|
|
4701
|
+
const bodies = [];
|
|
4702
|
+
for (const match of text.matchAll(reminderEnvelopePattern)) {
|
|
4703
|
+
const body = match[1];
|
|
4704
|
+
if (body !== undefined)
|
|
4705
|
+
bodies.push(body);
|
|
4706
|
+
}
|
|
4707
|
+
return bodies;
|
|
4708
|
+
}
|
|
4709
|
+
function parseAnswerBody(body) {
|
|
4710
|
+
const lines = body.replace(/\r\n/g, `
|
|
4711
|
+
`).replace(/^\n+|\n+$/g, "");
|
|
4712
|
+
if (!ANSWER_HEADER_PREFIX.test(lines))
|
|
4713
|
+
return null;
|
|
4714
|
+
if (lines.includes("The user dismissed this question"))
|
|
4715
|
+
return null;
|
|
4716
|
+
const framed = ANSWER_TRAILER.exec(lines);
|
|
4717
|
+
if (framed === null)
|
|
4718
|
+
return null;
|
|
4719
|
+
const content = framed[1] ?? "";
|
|
4720
|
+
const narrated = ANSWER_ANSWER_LINE.exec(content);
|
|
4721
|
+
if (narrated !== null) {
|
|
4722
|
+
const question = narrated[2] ?? "";
|
|
4723
|
+
const answer = content.slice(narrated[0].length);
|
|
4724
|
+
return closedAnswer(question, answer);
|
|
4725
|
+
}
|
|
4726
|
+
const bare = ANSWER_QUESTION_LINE.exec(content);
|
|
4727
|
+
if (bare !== null) {
|
|
4728
|
+
const question = bare[1] ?? "";
|
|
4729
|
+
const answer = content.slice(bare[0].length);
|
|
4730
|
+
return closedAnswer(question, answer);
|
|
4731
|
+
}
|
|
4732
|
+
return null;
|
|
4733
|
+
}
|
|
4734
|
+
function closedAnswer(question, answer) {
|
|
4735
|
+
if (question.trim().length === 0)
|
|
4736
|
+
return null;
|
|
4737
|
+
if (answer.trim().length === 0)
|
|
4738
|
+
return null;
|
|
4739
|
+
return { question, answer };
|
|
4740
|
+
}
|
|
4741
|
+
function extractAskAnswerNotices(text) {
|
|
4742
|
+
const notices = [];
|
|
4743
|
+
for (const body of reminderBodies(text)) {
|
|
4744
|
+
const notice = parseAnswerBody(body);
|
|
4745
|
+
if (notice !== null)
|
|
4746
|
+
notices.push(notice);
|
|
4747
|
+
}
|
|
4748
|
+
return notices;
|
|
4749
|
+
}
|
|
4750
|
+
function formatAskAnswerNotice(notice) {
|
|
4751
|
+
return `U (answered "${notice.question}"): ${notice.answer}`;
|
|
4752
|
+
}
|
|
4753
|
+
function askAnswerLines(text) {
|
|
4754
|
+
return extractAskAnswerNotices(text).map(formatAskAnswerNotice);
|
|
4755
|
+
}
|
|
4756
|
+
|
|
4693
4757
|
// src/hooks/magic-context/host-served-rows.ts
|
|
4694
4758
|
var HOST_UNSERVED_ROW = "hostUnservedRow";
|
|
4695
4759
|
function markHostUnservedRow(target) {
|
|
@@ -5631,114 +5695,355 @@ function applyEditMarkerToInput(input) {
|
|
|
5631
5695
|
|
|
5632
5696
|
// src/features/magic-context/tool-definition-tokens.ts
|
|
5633
5697
|
import { createHash as createHash2 } from "node:crypto";
|
|
5634
|
-
|
|
5635
|
-
|
|
5698
|
+
|
|
5699
|
+
// src/shared/bounded-session-map.ts
|
|
5700
|
+
class BoundedSessionMap {
|
|
5701
|
+
maxEntries;
|
|
5702
|
+
store = new Map;
|
|
5703
|
+
constructor(maxEntries) {
|
|
5704
|
+
if (!Number.isFinite(maxEntries) || maxEntries < 1) {
|
|
5705
|
+
throw new Error(`BoundedSessionMap: maxEntries must be >= 1, got ${maxEntries}`);
|
|
5706
|
+
}
|
|
5707
|
+
this.maxEntries = maxEntries;
|
|
5708
|
+
}
|
|
5709
|
+
get(sessionId) {
|
|
5710
|
+
const value = this.store.get(sessionId);
|
|
5711
|
+
if (value === undefined)
|
|
5712
|
+
return;
|
|
5713
|
+
this.store.delete(sessionId);
|
|
5714
|
+
this.store.set(sessionId, value);
|
|
5715
|
+
return value;
|
|
5716
|
+
}
|
|
5717
|
+
peek(sessionId) {
|
|
5718
|
+
return this.store.get(sessionId);
|
|
5719
|
+
}
|
|
5720
|
+
has(sessionId) {
|
|
5721
|
+
return this.store.has(sessionId);
|
|
5722
|
+
}
|
|
5723
|
+
set(sessionId, value) {
|
|
5724
|
+
if (this.store.has(sessionId)) {
|
|
5725
|
+
this.store.delete(sessionId);
|
|
5726
|
+
} else if (this.store.size >= this.maxEntries) {
|
|
5727
|
+
const oldest = this.store.keys().next().value;
|
|
5728
|
+
if (oldest !== undefined)
|
|
5729
|
+
this.store.delete(oldest);
|
|
5730
|
+
}
|
|
5731
|
+
this.store.set(sessionId, value);
|
|
5732
|
+
}
|
|
5733
|
+
delete(sessionId) {
|
|
5734
|
+
return this.store.delete(sessionId);
|
|
5735
|
+
}
|
|
5736
|
+
clear() {
|
|
5737
|
+
this.store.clear();
|
|
5738
|
+
}
|
|
5739
|
+
get size() {
|
|
5740
|
+
return this.store.size;
|
|
5741
|
+
}
|
|
5742
|
+
}
|
|
5743
|
+
|
|
5744
|
+
// src/features/magic-context/tool-definition-tokens.ts
|
|
5745
|
+
var ACTIVITY_WINDOW_MS = 10 * 60000;
|
|
5746
|
+
var MAX_ACTIVITY_GAP_MS = 60000;
|
|
5747
|
+
var RETIRED_CACHE_LIMIT = 64;
|
|
5748
|
+
var WRITE_RETRY_MS = 5000;
|
|
5749
|
+
var WINDOWED_SINCE_KEY = "tool_definition_measurements:windowed_since";
|
|
5750
|
+
var routes = new Map;
|
|
5751
|
+
var sessionFlights = new BoundedSessionMap(1000);
|
|
5636
5752
|
var persistenceDb = null;
|
|
5753
|
+
var windowedSince;
|
|
5754
|
+
var boundAt = 0;
|
|
5637
5755
|
var cachedInsertStmt = null;
|
|
5756
|
+
var cachedDeleteStmt = null;
|
|
5757
|
+
function agentKey(agentName) {
|
|
5758
|
+
return agentName && agentName.length > 0 ? agentName : "default";
|
|
5759
|
+
}
|
|
5638
5760
|
function keyFor(providerID, modelID, agentName) {
|
|
5639
|
-
|
|
5640
|
-
return `${providerID}/${modelID}/${agent}`;
|
|
5761
|
+
return `${providerID}/${modelID}/${agentKey(agentName)}`;
|
|
5641
5762
|
}
|
|
5642
5763
|
function fingerprintFor(description, parameters) {
|
|
5643
5764
|
return createHash2("sha256").update(description).update("\x00").update(stableStringify(parameters)).digest("hex");
|
|
5644
5765
|
}
|
|
5645
|
-
function
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5766
|
+
function measure(description, parameters) {
|
|
5767
|
+
let paramsText = "";
|
|
5768
|
+
try {
|
|
5769
|
+
paramsText = parameters === undefined ? "" : JSON.stringify(parameters);
|
|
5770
|
+
} catch {
|
|
5771
|
+
paramsText = "";
|
|
5772
|
+
}
|
|
5773
|
+
return estimateTokens(description) + estimateTokens(paramsText);
|
|
5652
5774
|
}
|
|
5653
|
-
function
|
|
5775
|
+
function routeFor(providerID, modelID, agentName) {
|
|
5654
5776
|
const key = keyFor(providerID, modelID, agentName);
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5777
|
+
let route = routes.get(key);
|
|
5778
|
+
if (!route) {
|
|
5779
|
+
route = {
|
|
5780
|
+
providerID,
|
|
5781
|
+
modelID,
|
|
5782
|
+
agentName: agentKey(agentName),
|
|
5783
|
+
tools: new Map,
|
|
5784
|
+
live: false,
|
|
5785
|
+
clock: 0,
|
|
5786
|
+
lastWallAt: Date.now(),
|
|
5787
|
+
oldestFireAt: Number.POSITIVE_INFINITY,
|
|
5788
|
+
retired: new Map,
|
|
5789
|
+
legacyRows: new Set
|
|
5790
|
+
};
|
|
5791
|
+
routes.set(key, route);
|
|
5792
|
+
}
|
|
5793
|
+
return { key, route };
|
|
5660
5794
|
}
|
|
5661
|
-
function
|
|
5662
|
-
|
|
5663
|
-
|
|
5795
|
+
function advanceClock(route) {
|
|
5796
|
+
const now = Date.now();
|
|
5797
|
+
const gap = Math.min(Math.max(now - route.lastWallAt, 0), MAX_ACTIVITY_GAP_MS);
|
|
5798
|
+
route.clock += gap;
|
|
5799
|
+
route.lastWallAt = Math.max(route.lastWallAt, now);
|
|
5800
|
+
return route.clock;
|
|
5664
5801
|
}
|
|
5665
|
-
function
|
|
5666
|
-
|
|
5802
|
+
function counts(route, slot) {
|
|
5803
|
+
if (!route.live)
|
|
5804
|
+
return true;
|
|
5805
|
+
if (slot.legacy)
|
|
5806
|
+
return false;
|
|
5807
|
+
return slot.lastFireAt >= route.clock - ACTIVITY_WINDOW_MS;
|
|
5808
|
+
}
|
|
5809
|
+
function currentTools(route) {
|
|
5810
|
+
return [...route.tools.entries()].filter(([, slot]) => counts(route, slot));
|
|
5811
|
+
}
|
|
5812
|
+
function summarize(entries, live) {
|
|
5813
|
+
let total = 0;
|
|
5814
|
+
for (const [, slot] of entries)
|
|
5815
|
+
total += slot.tokens;
|
|
5816
|
+
const ids = entries.map(([id]) => id).sort();
|
|
5817
|
+
const fingerprints = new Map(entries.map(([id, slot]) => [
|
|
5818
|
+
id,
|
|
5819
|
+
slot.fingerprint ?? (live ? `stored:${slot.tokens}` : undefined)
|
|
5820
|
+
]));
|
|
5821
|
+
const complete = ids.every((id) => fingerprints.get(id) !== undefined);
|
|
5822
|
+
return {
|
|
5823
|
+
total,
|
|
5824
|
+
signature: complete ? createHash2("sha256").update(JSON.stringify(ids.map((id) => [id, fingerprints.get(id)]))).digest("hex") : undefined,
|
|
5825
|
+
hash: ids.length === 0 ? "" : createHash2("sha256").update(ids.join("\x00")).digest("hex")
|
|
5826
|
+
};
|
|
5827
|
+
}
|
|
5828
|
+
function resolve2(providerID, modelID, agentName, sessionId) {
|
|
5829
|
+
if (!providerID || !modelID)
|
|
5830
|
+
return;
|
|
5831
|
+
const key = keyFor(providerID, modelID, agentName);
|
|
5832
|
+
if (sessionId) {
|
|
5833
|
+
const flight = sessionFlights.peek(sessionId);
|
|
5834
|
+
if (flight?.key === key && flight.exact)
|
|
5835
|
+
return flight.exact;
|
|
5836
|
+
}
|
|
5837
|
+
const route = routes.get(key);
|
|
5838
|
+
if (!route)
|
|
5839
|
+
return;
|
|
5840
|
+
const entries = currentTools(route);
|
|
5841
|
+
if (!route.live && entries.length === 0)
|
|
5842
|
+
return;
|
|
5843
|
+
return summarize(entries, route.live);
|
|
5844
|
+
}
|
|
5845
|
+
function readWindowedSince(db) {
|
|
5667
5846
|
try {
|
|
5668
|
-
|
|
5847
|
+
const row = db.prepare("SELECT value FROM schema_migrations_meta WHERE key = ?").get(WINDOWED_SINCE_KEY);
|
|
5848
|
+
if (!row)
|
|
5849
|
+
return;
|
|
5850
|
+
const value = Number(row.value);
|
|
5851
|
+
return Number.isFinite(value) ? value : undefined;
|
|
5669
5852
|
} catch {
|
|
5670
5853
|
return;
|
|
5671
5854
|
}
|
|
5672
|
-
for (const row of rows) {
|
|
5673
|
-
const key = keyFor(row.provider_id, row.model_id, row.agent_name);
|
|
5674
|
-
let inner = measurements.get(key);
|
|
5675
|
-
if (!inner) {
|
|
5676
|
-
inner = new Map;
|
|
5677
|
-
measurements.set(key, inner);
|
|
5678
|
-
}
|
|
5679
|
-
inner.set(row.tool_id, row.token_count);
|
|
5680
|
-
}
|
|
5681
5855
|
}
|
|
5682
|
-
function
|
|
5683
|
-
if (
|
|
5856
|
+
function markWindowed() {
|
|
5857
|
+
if (windowedSince !== undefined || !persistenceDb)
|
|
5684
5858
|
return;
|
|
5685
|
-
const key = keyFor(providerID, modelID, agentName);
|
|
5686
|
-
const fp = fingerprintFor(description ?? "", parameters);
|
|
5687
|
-
let innerFp = fingerprints.get(key);
|
|
5688
|
-
if (innerFp && innerFp.get(toolID) === fp)
|
|
5689
|
-
return;
|
|
5690
|
-
let paramsText = "";
|
|
5691
5859
|
try {
|
|
5692
|
-
|
|
5860
|
+
persistenceDb.prepare("INSERT OR IGNORE INTO schema_migrations_meta (key, value) VALUES (?, ?)").run(WINDOWED_SINCE_KEY, String(boundAt));
|
|
5861
|
+
windowedSince = readWindowedSince(persistenceDb);
|
|
5862
|
+
} catch {}
|
|
5863
|
+
}
|
|
5864
|
+
function persistInsert(route, toolID, tokens) {
|
|
5865
|
+
if (!persistenceDb)
|
|
5866
|
+
return false;
|
|
5867
|
+
try {
|
|
5868
|
+
cachedInsertStmt ??= persistenceDb.prepare(`INSERT OR REPLACE INTO tool_definition_measurements
|
|
5869
|
+
(provider_id, model_id, agent_name, tool_id, token_count, recorded_at)
|
|
5870
|
+
VALUES (?, ?, ?, ?, ?, ?)`);
|
|
5871
|
+
cachedInsertStmt.run(route.providerID, route.modelID, route.agentName, toolID, tokens, Date.now());
|
|
5693
5872
|
} catch {
|
|
5694
|
-
|
|
5873
|
+
cachedInsertStmt = null;
|
|
5874
|
+
return false;
|
|
5875
|
+
}
|
|
5876
|
+
if (route.legacyRows.delete(toolID) && route.legacyRows.size === 0)
|
|
5877
|
+
markWindowed();
|
|
5878
|
+
return true;
|
|
5879
|
+
}
|
|
5880
|
+
function persistDelete(route, toolIDs) {
|
|
5881
|
+
if (!persistenceDb)
|
|
5882
|
+
return false;
|
|
5883
|
+
try {
|
|
5884
|
+
cachedDeleteStmt ??= persistenceDb.prepare(`DELETE FROM tool_definition_measurements
|
|
5885
|
+
WHERE provider_id = ? AND model_id = ? AND agent_name = ?
|
|
5886
|
+
AND tool_id IN (SELECT value FROM json_each(?))`);
|
|
5887
|
+
cachedDeleteStmt.run(route.providerID, route.modelID, route.agentName, JSON.stringify(toolIDs));
|
|
5888
|
+
} catch {
|
|
5889
|
+
cachedDeleteStmt = null;
|
|
5890
|
+
return false;
|
|
5695
5891
|
}
|
|
5696
|
-
|
|
5697
|
-
|
|
5698
|
-
|
|
5699
|
-
|
|
5700
|
-
|
|
5892
|
+
for (const id of toolIDs)
|
|
5893
|
+
route.legacyRows.delete(id);
|
|
5894
|
+
markWindowed();
|
|
5895
|
+
return true;
|
|
5896
|
+
}
|
|
5897
|
+
function writeSlot(route, toolID, slot) {
|
|
5898
|
+
if (slot.persisted || !persistenceDb)
|
|
5899
|
+
return;
|
|
5900
|
+
const now = Date.now();
|
|
5901
|
+
if (slot.writeFailedAt !== undefined && now - slot.writeFailedAt < WRITE_RETRY_MS)
|
|
5902
|
+
return;
|
|
5903
|
+
if (persistInsert(route, toolID, slot.tokens)) {
|
|
5904
|
+
slot.persisted = true;
|
|
5905
|
+
slot.writeFailedAt = undefined;
|
|
5906
|
+
} else {
|
|
5907
|
+
slot.writeFailedAt = now;
|
|
5701
5908
|
}
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
|
|
5909
|
+
}
|
|
5910
|
+
function retire(route, toolID, slot, rowDeleted) {
|
|
5911
|
+
if (slot.fingerprint === undefined)
|
|
5912
|
+
return;
|
|
5913
|
+
route.retired.delete(toolID);
|
|
5914
|
+
route.retired.set(toolID, {
|
|
5915
|
+
fingerprint: slot.fingerprint,
|
|
5916
|
+
tokens: slot.tokens,
|
|
5917
|
+
rowKept: slot.persisted && !rowDeleted
|
|
5918
|
+
});
|
|
5919
|
+
if (route.retired.size > RETIRED_CACHE_LIMIT) {
|
|
5920
|
+
const oldest = route.retired.keys().next().value;
|
|
5921
|
+
if (oldest !== undefined)
|
|
5922
|
+
route.retired.delete(oldest);
|
|
5706
5923
|
}
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5924
|
+
}
|
|
5925
|
+
function freshSlot(route, toolID, description, parameters, fingerprint, now) {
|
|
5926
|
+
const retired = route.retired.get(toolID);
|
|
5927
|
+
if (retired)
|
|
5928
|
+
route.retired.delete(toolID);
|
|
5929
|
+
const reuse = retired?.fingerprint === fingerprint ? retired : undefined;
|
|
5930
|
+
return {
|
|
5931
|
+
tokens: reuse ? reuse.tokens : measure(description, parameters),
|
|
5932
|
+
fingerprint,
|
|
5933
|
+
lastFireAt: now,
|
|
5934
|
+
legacy: false,
|
|
5935
|
+
persisted: reuse?.rowKept === true
|
|
5936
|
+
};
|
|
5937
|
+
}
|
|
5938
|
+
function setDatabase(db) {
|
|
5939
|
+
const rebound = persistenceDb !== null && persistenceDb !== db;
|
|
5940
|
+
persistenceDb = db;
|
|
5941
|
+
boundAt = Date.now();
|
|
5942
|
+
cachedInsertStmt = null;
|
|
5943
|
+
cachedDeleteStmt = null;
|
|
5944
|
+
if (rebound) {
|
|
5945
|
+
for (const route of routes.values()) {
|
|
5946
|
+
for (const slot of route.tools.values()) {
|
|
5947
|
+
slot.persisted = false;
|
|
5948
|
+
slot.writeFailedAt = undefined;
|
|
5715
5949
|
}
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5950
|
+
for (const retired of route.retired.values())
|
|
5951
|
+
retired.rowKept = false;
|
|
5952
|
+
route.legacyRows.clear();
|
|
5719
5953
|
}
|
|
5720
5954
|
}
|
|
5955
|
+
windowedSince = readWindowedSince(db);
|
|
5956
|
+
if (windowedSince !== undefined)
|
|
5957
|
+
return;
|
|
5958
|
+
try {
|
|
5959
|
+
if (!db.prepare("SELECT 1 FROM tool_definition_measurements LIMIT 1").get())
|
|
5960
|
+
markWindowed();
|
|
5961
|
+
} catch {}
|
|
5721
5962
|
}
|
|
5722
|
-
function
|
|
5723
|
-
let
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
|
|
5963
|
+
function loadToolDefinitionMeasurements(db) {
|
|
5964
|
+
let rows = [];
|
|
5965
|
+
try {
|
|
5966
|
+
rows = db.prepare("SELECT provider_id, model_id, agent_name, tool_id, token_count, recorded_at FROM tool_definition_measurements").all();
|
|
5967
|
+
} catch {
|
|
5968
|
+
return;
|
|
5969
|
+
}
|
|
5970
|
+
const since = readWindowedSince(db);
|
|
5971
|
+
const loadedAt = new Map;
|
|
5972
|
+
for (const row of rows) {
|
|
5973
|
+
const { route } = routeFor(row.provider_id, row.model_id, row.agent_name);
|
|
5974
|
+
if (route.live)
|
|
5975
|
+
continue;
|
|
5976
|
+
let now = loadedAt.get(route);
|
|
5977
|
+
if (now === undefined) {
|
|
5978
|
+
now = advanceClock(route);
|
|
5979
|
+
loadedAt.set(route, now);
|
|
5980
|
+
}
|
|
5981
|
+
const legacy = since === undefined || !(Number(row.recorded_at) >= since);
|
|
5982
|
+
route.tools.set(row.tool_id, {
|
|
5983
|
+
tokens: row.token_count,
|
|
5984
|
+
fingerprint: undefined,
|
|
5985
|
+
lastFireAt: now,
|
|
5986
|
+
legacy,
|
|
5987
|
+
persisted: !legacy
|
|
5988
|
+
});
|
|
5989
|
+
route.oldestFireAt = Math.min(route.oldestFireAt, now);
|
|
5990
|
+
if (legacy)
|
|
5991
|
+
route.legacyRows.add(row.tool_id);
|
|
5992
|
+
else
|
|
5993
|
+
route.legacyRows.delete(row.tool_id);
|
|
5729
5994
|
}
|
|
5730
|
-
return largest > 0 ? largest : undefined;
|
|
5731
5995
|
}
|
|
5732
|
-
function
|
|
5996
|
+
function recordToolDefinitionSet(providerID, modelID, agentName, tools, sessionId) {
|
|
5733
5997
|
if (!providerID || !modelID)
|
|
5734
5998
|
return;
|
|
5735
|
-
const
|
|
5736
|
-
|
|
5999
|
+
const { key, route } = routeFor(providerID, modelID, agentName);
|
|
6000
|
+
const now = advanceClock(route);
|
|
6001
|
+
route.live = true;
|
|
6002
|
+
const next = new Map;
|
|
6003
|
+
for (const tool of tools) {
|
|
6004
|
+
if (!tool.id)
|
|
6005
|
+
continue;
|
|
6006
|
+
const fingerprint = fingerprintFor(tool.description ?? "", tool.parameters);
|
|
6007
|
+
const previous = route.tools.get(tool.id);
|
|
6008
|
+
if (previous && previous.fingerprint === fingerprint) {
|
|
6009
|
+
previous.lastFireAt = now;
|
|
6010
|
+
next.set(tool.id, previous);
|
|
6011
|
+
continue;
|
|
6012
|
+
}
|
|
6013
|
+
next.set(tool.id, freshSlot(route, tool.id, tool.description ?? "", tool.parameters, fingerprint, now));
|
|
6014
|
+
}
|
|
6015
|
+
const removed = [...route.tools].filter(([id]) => !next.has(id));
|
|
6016
|
+
route.tools = next;
|
|
6017
|
+
route.oldestFireAt = now;
|
|
6018
|
+
if (removed.length > 0) {
|
|
6019
|
+
const deleted = persistDelete(route, removed.map(([id]) => id));
|
|
6020
|
+
for (const [id, slot] of removed)
|
|
6021
|
+
retire(route, id, slot, deleted);
|
|
6022
|
+
}
|
|
6023
|
+
for (const [toolID, slot] of next)
|
|
6024
|
+
writeSlot(route, toolID, slot);
|
|
6025
|
+
if (sessionId)
|
|
6026
|
+
sessionFlights.set(sessionId, { key, exact: summarize([...next.entries()], true) });
|
|
6027
|
+
}
|
|
6028
|
+
function getCurrentToolSetHash(providerID, modelID, agentName, sessionId) {
|
|
6029
|
+
return resolve2(providerID, modelID, agentName, sessionId)?.hash ?? "";
|
|
6030
|
+
}
|
|
6031
|
+
function getToolDefinitionMeasurementSignature(providerID, modelID, agentName, sessionId) {
|
|
6032
|
+
return resolve2(providerID, modelID, agentName, sessionId)?.signature;
|
|
6033
|
+
}
|
|
6034
|
+
function getMeasuredToolDefinitionTokens(providerID, modelID, agentName, sessionId) {
|
|
6035
|
+
return resolve2(providerID, modelID, agentName, sessionId)?.total;
|
|
6036
|
+
}
|
|
6037
|
+
function getSessionToolDefinitionTokens(sessionId) {
|
|
6038
|
+
if (!sessionId)
|
|
6039
|
+
return;
|
|
6040
|
+
const flight = sessionFlights.peek(sessionId);
|
|
6041
|
+
if (!flight)
|
|
5737
6042
|
return;
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
return total;
|
|
6043
|
+
if (flight.exact)
|
|
6044
|
+
return flight.exact.total;
|
|
6045
|
+
const route = routes.get(flight.key);
|
|
6046
|
+
return route ? summarize(currentTools(route), route.live).total : undefined;
|
|
5742
6047
|
}
|
|
5743
6048
|
|
|
5744
6049
|
// src/hooks/magic-context/final-wire-token-estimate.ts
|
|
@@ -5883,7 +6188,7 @@ function createFinalWireUsageTracker() {
|
|
|
5883
6188
|
const envelopeFor = (input) => {
|
|
5884
6189
|
if (!input.providerID || !input.modelID || !input.systemPromptHash)
|
|
5885
6190
|
return;
|
|
5886
|
-
const tools = getToolDefinitionMeasurementSignature(input.providerID, input.modelID, input.agentName);
|
|
6191
|
+
const tools = getToolDefinitionMeasurementSignature(input.providerID, input.modelID, input.agentName, input.sessionId);
|
|
5887
6192
|
if (!tools)
|
|
5888
6193
|
return;
|
|
5889
6194
|
return JSON.stringify([
|
|
@@ -5896,7 +6201,8 @@ function createFinalWireUsageTracker() {
|
|
|
5896
6201
|
]);
|
|
5897
6202
|
};
|
|
5898
6203
|
return {
|
|
5899
|
-
estimate(sessionId,
|
|
6204
|
+
estimate(sessionId, request, limit) {
|
|
6205
|
+
const input = { ...request, sessionId: request.sessionId ?? sessionId };
|
|
5900
6206
|
let measuredPrefix;
|
|
5901
6207
|
try {
|
|
5902
6208
|
const previous = served.get(sessionId);
|
|
@@ -5918,7 +6224,8 @@ function createFinalWireUsageTracker() {
|
|
|
5918
6224
|
} catch {}
|
|
5919
6225
|
return estimateOutgoingWireForRefusal({ ...input, measuredPrefix }, limit);
|
|
5920
6226
|
},
|
|
5921
|
-
capture(sessionId,
|
|
6227
|
+
capture(sessionId, request) {
|
|
6228
|
+
const input = { ...request, sessionId: request.sessionId ?? sessionId };
|
|
5922
6229
|
served.delete(sessionId);
|
|
5923
6230
|
try {
|
|
5924
6231
|
const envelope = envelopeFor(input);
|
|
@@ -5948,7 +6255,7 @@ function estimateOutgoingWireForRefusal(input, limit) {
|
|
|
5948
6255
|
if (bytes) {
|
|
5949
6256
|
const lower = baseline + Math.ceil(bytes.bytes / 4);
|
|
5950
6257
|
const calibration = resolveDecisionCalibration(input.providerID, input.modelID);
|
|
5951
|
-
const tools = input.providerID && input.modelID ? getMeasuredToolDefinitionTokens(input.providerID, input.modelID, input.agentName) : undefined;
|
|
6258
|
+
const tools = input.providerID && input.modelID ? getMeasuredToolDefinitionTokens(input.providerID, input.modelID, input.agentName, input.sessionId) : undefined;
|
|
5952
6259
|
const envelope = measured ? baseline : tools !== undefined && Number.isFinite(input.systemPromptTokens) && input.systemPromptTokens > 0 ? providerMass({ system: input.systemPromptTokens, tools }, calibration, true) : undefined;
|
|
5953
6260
|
const upper = envelope === undefined ? undefined : envelope + Math.ceil(bytes.bytes * Math.max(UNKNOWN_FIT_RATIO, calibration.toolsRatio, calibration.proseRatio));
|
|
5954
6261
|
if (bytes.aborted || lower > limit || upper !== undefined && upper <= limit) {
|
|
@@ -5976,10 +6283,10 @@ function estimateFinalWireInputTokens(input) {
|
|
|
5976
6283
|
total.toolCall += next.toolCall;
|
|
5977
6284
|
return total;
|
|
5978
6285
|
}, { conversation: 0, toolCall: 0 });
|
|
5979
|
-
const measuredToolDefinitions = input.toolDefinitionTokens ?? (input.providerID && input.modelID ? getMeasuredToolDefinitionTokens(input.providerID, input.modelID, input.agentName) : undefined);
|
|
6286
|
+
const measuredToolDefinitions = input.toolDefinitionTokens ?? (input.providerID && input.modelID ? getMeasuredToolDefinitionTokens(input.providerID, input.modelID, input.agentName, input.sessionId) : undefined);
|
|
5980
6287
|
const calibration = resolveDecisionCalibration(input.providerID, input.modelID);
|
|
5981
|
-
const
|
|
5982
|
-
const toolDefinitions = measuredToolDefinitions ?? (
|
|
6288
|
+
const borrowedToolDefinitions = measuredToolDefinitions === undefined ? getSessionToolDefinitionTokens(input.sessionId) : undefined;
|
|
6289
|
+
const toolDefinitions = measuredToolDefinitions ?? (borrowedToolDefinitions === undefined ? undefined : Math.ceil(borrowedToolDefinitions * UNKNOWN_FIT_RATIO / (calibration.seeded ? calibration.toolsRatio : UNKNOWN_FIT_RATIO)));
|
|
5983
6290
|
const rawComponents = {
|
|
5984
6291
|
system: input.systemPromptTokens,
|
|
5985
6292
|
tools: (toolDefinitions ?? 0) + messageTokens.toolCall,
|
|
@@ -6953,6 +7260,9 @@ function setBoundedRawMessageProvider2(sessionId, provider) {
|
|
|
6953
7260
|
function cleanUserText2(text) {
|
|
6954
7261
|
return stripOutsideSteeringWrappers(text, (segment) => removeSystemReminders(segment).replace(OMO_INTERNAL_INITIATOR_MARKER, "")).trim();
|
|
6955
7262
|
}
|
|
7263
|
+
function answerLineParts(rawText) {
|
|
7264
|
+
return askAnswerLines(rawText).map(normalizeText).filter((value) => value.length > 0);
|
|
7265
|
+
}
|
|
6956
7266
|
function hasMeaningfulChunkUserText(parts) {
|
|
6957
7267
|
for (const part of parts) {
|
|
6958
7268
|
if (part === null || typeof part !== "object")
|
|
@@ -6969,7 +7279,7 @@ function hasMeaningfulChunkUserText(parts) {
|
|
|
6969
7279
|
continue;
|
|
6970
7280
|
return true;
|
|
6971
7281
|
}
|
|
6972
|
-
return
|
|
7282
|
+
return parts.some((part) => part !== null && typeof part === "object" && part.type === "text" && typeof part.text === "string" && part.ignored !== true && askAnswerLines(part.text).length > 0);
|
|
6973
7283
|
}
|
|
6974
7284
|
function withRawSessionMessageCache2(fn) {
|
|
6975
7285
|
const outerCache = activeRawMessageCache;
|
|
@@ -7575,6 +7885,10 @@ function readSessionChunk2(sessionId, tokenBudget, offset = 1, eligibleEndOrdina
|
|
|
7575
7885
|
const meta = { ordinal: msg.ordinal, messageId: msg.id };
|
|
7576
7886
|
if (isHostUnservedRow(msg))
|
|
7577
7887
|
markHostUnservedRow(meta);
|
|
7888
|
+
if (msg.role === "system") {
|
|
7889
|
+
recordFilteredNoise(meta);
|
|
7890
|
+
continue;
|
|
7891
|
+
}
|
|
7578
7892
|
if (msg.role === "user" && !hasMeaningfulChunkUserText(msg.parts)) {
|
|
7579
7893
|
const tcSummaries = msg.parts.flatMap((part) => {
|
|
7580
7894
|
if (expandedResults.has(part))
|
|
@@ -7621,8 +7935,10 @@ function readSessionChunk2(sessionId, tokenBudget, offset = 1, eligibleEndOrdina
|
|
|
7621
7935
|
}
|
|
7622
7936
|
const role = compactRole(msg.role);
|
|
7623
7937
|
const textParts = extractTexts2(msg.parts).map((t) => msg.role === "user" ? cleanUserText2(t) : t).map(normalizeText).filter((value) => value.length > 0);
|
|
7938
|
+
const answerParts = msg.role === "user" ? extractTexts2(msg.parts).flatMap((text) => answerLineParts(text)) : [];
|
|
7939
|
+
const userParts = answerParts.length > 0 ? [...textParts, ...answerParts] : textParts;
|
|
7624
7940
|
const allParts = options.expand === false ? [
|
|
7625
|
-
...
|
|
7941
|
+
...userParts,
|
|
7626
7942
|
...textParts.length === 0 ? extractToolCallSummaries(msg.parts) : []
|
|
7627
7943
|
] : msg.parts.flatMap((part) => {
|
|
7628
7944
|
if (expandedResults.has(part))
|
|
@@ -7631,6 +7947,9 @@ function readSessionChunk2(sessionId, tokenBudget, offset = 1, eligibleEndOrdina
|
|
|
7631
7947
|
if (expansion !== null)
|
|
7632
7948
|
return [`TC: ${expansion}`];
|
|
7633
7949
|
const texts = extractTexts2([part]).map((t) => msg.role === "user" ? cleanUserText2(t) : t).map(normalizeText).filter(Boolean);
|
|
7950
|
+
if (msg.role === "user") {
|
|
7951
|
+
texts.push(...extractTexts2([part]).flatMap((text) => answerLineParts(text)));
|
|
7952
|
+
}
|
|
7634
7953
|
return texts.length ? texts : textParts.length === 0 ? extractToolCallSummaries([part]) : [];
|
|
7635
7954
|
});
|
|
7636
7955
|
const compacted = compactTextForSummary(allParts.join(" / "), msg.role);
|
|
@@ -7639,7 +7958,7 @@ function readSessionChunk2(sessionId, tokenBudget, offset = 1, eligibleEndOrdina
|
|
|
7639
7958
|
recordFilteredNoise(meta);
|
|
7640
7959
|
continue;
|
|
7641
7960
|
}
|
|
7642
|
-
const msgHasNarrative =
|
|
7961
|
+
const msgHasNarrative = userParts.length > 0;
|
|
7643
7962
|
if (currentBlock && currentBlock.role === role) {
|
|
7644
7963
|
currentBlock.endOrdinal = msg.ordinal;
|
|
7645
7964
|
currentBlock.parts.push(text);
|
|
@@ -7721,4 +8040,4 @@ function readSessionChunk2(sessionId, tokenBudget, offset = 1, eligibleEndOrdina
|
|
|
7721
8040
|
toolResultBoundaries
|
|
7722
8041
|
};
|
|
7723
8042
|
}
|
|
7724
|
-
export { toolTemplateError, DEFAULT_PROTECTED_TOOLS, normalizeProtectedToolName, mergeProtectedTools, detectLatestTurnThinkingMismatch, isPrefixBoundThinkingModel, detectOverflow, stripWellFormedLeadingTagPrefix, stripPersistedAssistantText, byteSize, stripTagPrefix, peelLeadingMcTagNotation, prependTag, isThinkingPart, isRecord, protectedToolTagNumbers, protectedToolTokenCount, textMentionsRecentCommit, removeSystemReminders, removeNestedBlocks, hasMeaningfulUserText2, extractTexts2, getTokenizerNativeMemoryStats, preloadTokenizer, estimateTokens, estimateFixedPromptTokens, currentReclaimableToolOutputCount, stableStringify, contentTagOwnerMessageId, estimateImageTokensFromDataUrl, estimateToolAttachmentImageTokens, providerVisibleMessage, normalizeTodoStateJson, buildSyntheticTodoPart, isSyntheticTodoPart, countRealUserMessages, tailHygieneStructuralSignature, sameTailHygieneStructuralSignature, formatTailHygienePrefixMismatch, refreshTailHygieneBaseline, effectiveTailHygiene, assertTailHygieneContentUnchangedIfEnabled, CHANNEL1_SENTINEL, CHANNEL1_FLOOR_TOKENS, isDroppedToolOutput, toolOutputTokens, decideChannel1, evaluateChannel2, formatChannel1Evaluation, formatChannel2Evaluation, reclaimableToolOutputCount, buildChannel2Reminder, buildChannel1Reminder, estimateEmergencyDropReclaimTokens, planEmergencyDrop, measureEmergencyTag, installV3PerfSchema, queuePendingOp, queuePendingDropForUnchangedTag, getPendingOps, getPendingOpsCount, clearPendingOps, removePendingOp,
|
|
8043
|
+
export { toolTemplateError, DEFAULT_PROTECTED_TOOLS, normalizeProtectedToolName, mergeProtectedTools, detectLatestTurnThinkingMismatch, isPrefixBoundThinkingModel, detectOverflow, stripWellFormedLeadingTagPrefix, stripPersistedAssistantText, byteSize, stripTagPrefix, peelLeadingMcTagNotation, prependTag, isThinkingPart, isRecord, protectedToolTagNumbers, protectedToolTokenCount, textMentionsRecentCommit, removeSystemReminders, removeNestedBlocks, hasMeaningfulUserText2, extractTexts2, getTokenizerNativeMemoryStats, preloadTokenizer, estimateTokens, estimateFixedPromptTokens, currentReclaimableToolOutputCount, stableStringify, contentTagOwnerMessageId, estimateImageTokensFromDataUrl, estimateToolAttachmentImageTokens, providerVisibleMessage, normalizeTodoStateJson, buildSyntheticTodoPart, isSyntheticTodoPart, countRealUserMessages, tailHygieneStructuralSignature, sameTailHygieneStructuralSignature, formatTailHygienePrefixMismatch, refreshTailHygieneBaseline, effectiveTailHygiene, assertTailHygieneContentUnchangedIfEnabled, CHANNEL1_SENTINEL, CHANNEL1_FLOOR_TOKENS, isDroppedToolOutput, toolOutputTokens, decideChannel1, evaluateChannel2, formatChannel1Evaluation, formatChannel2Evaluation, reclaimableToolOutputCount, buildChannel2Reminder, buildChannel1Reminder, estimateEmergencyDropReclaimTokens, planEmergencyDrop, measureEmergencyTag, installV3PerfSchema, queuePendingOp, queuePendingDropForUnchangedTag, getPendingOps, getPendingOpsCount, clearPendingOps, removePendingOp, tagTombstoneOwnerRange, tagTombstoneOwnerKey, tagRevisionKey, tagIdentityRevisionKey, installTagIdentityRevisionTrigger, deleteTagIdentityRevisions, getRecentTagOwnerMessageIds, AGE_RECLAIM_MIN_TOKENS, getOldestActiveUnprotectedToolTags, getActiveToolTagsForAgeReclaim, getTriggerTagTokenUpperBound, getActiveTagTokenTotalsByMessage, getAllStatusTagTokenTotalsFlat, getReasoningTokenEstimatesByMessage, tryGetReasoningTokenEstimatesByMessage, getMaxTagNumberByOwnerMessage, scanTagOwnerSummary, isTagOwnerSummaryReady, tagTokenCountIsNull, backfillTagTokenCounts, insertTag, updateTagStatus, markTagDropped, markWhitespaceAssistantTagInert, getInertWhitespaceAssistantTags, getInertWhitespaceAssistantTagsByNumbers, updateTagDropMode, updateCavemanDepth, updateTagMessageId, foldShrunkPartTags, markTagsCompactedByMessageIds, getMaxTagNumberBySession, getTagNumberByMessageId, getAssignableTagNumberByMessageId, deriveTagLoadFloor, TAG_SELECT_COLUMNS, getTagsBySession, getActiveTagsBySession, getTailHygieneTags, getTagsByNumbers, getNewestToolTagNumbers, getDroppedTagsByNumbers, getMaxDroppedTagNumber, getTagById, getToolTagNumberByOwner, getNullOwnerToolTag, adoptNullOwnerToolTag, getCandidateToolOwners, pickNearestPriorOwner, expandToolPart, markHostUnservedRow, retreatPastHostUnservedRows, snapTerminalCompartmentToServedRow, isHostRenderedSystemMessage, markCoveredInstructionRow, isCoveredInstructionRow, takeCoveredInstructionRows, cloneKeepingCoveredInstructionMarks, completedToolArcCrossesBoundary, estimateTrueRawMessageTokens, buildToolArcs, fenceBoundaryForCompletedToolArcs, fenceBoundaryForToolArcs, buildTrueRawTokenIndex, computeRawRangeFingerprint, stripSystemInjection, isTextPart, isToolPartWithOutput, isFilePart, toolPartHasUserAnswer, recordToolParameters, createDroppedInputGuard, assertExecutableToolInput, isEditTool, BoundedSessionMap, setDatabase, loadToolDefinitionMeasurements, recordToolDefinitionSet, getCurrentToolSetHash, getMeasuredToolDefinitionTokens, describeFinalWireTail, estimatePartImageTokens, estimateMessageTokens, wireContentBytes, createFinalWireUsageTracker, estimateFinalWireInputTokens, modelAcceptsEmptyContent, isAnthropicFamilyRoute, neutralizeDroppedReasoningPart, restoreNeutralizedReasoningPart, isNeutralizedReasoningPart, neutralizedReasoningSource, variantChangeBustsProviderCache, makeSentinel, makeWholeMessageSentinel, neutralizeWholeMessage, isSentinel, replaySentinelByMessageIds, SKELETON_REAL_INPUT_MAX_BYTES, partHasCompletedResult, extractToolCallObservation, ToolMutationBatch, createToolDropTarget, resolveHostServedBoundaryId2, hasRawMessageProvider2, setBoundedRawMessageProvider2, cleanUserText2, withRawSessionMessageCache2, readRawSessionMessages2, readRawSessionMessagePage2, getRawSessionMessageOrdinalCount2, visitRawSessionMessages2, readRawSessionMessageRange2, prepareRawSessionOrdinals2, primeTailRawMessageCache2, getCachedAbsoluteMessageCount2, primeInMemoryTailRawMessageCache2, readRawSessionMessageIdOrdinalsForRange2, hasRawSessionMessageById2, readRawSessionMessageOrdinalById2, compareRawSessionMessageOrder2, readRawSessionMessageById2, getRawSessionMessageCount2, getRawSessionTagKeysThrough2, getLegacyProtectedTailStartOrdinal2, readSessionChunk2 };
|