acp-kernel 0.0.27 → 0.0.28
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/README.md +23 -1
- package/dist/compress.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -3
- package/dist/index.js.map +1 -1
- package/dist/recommend.d.ts +8 -0
- package/dist/recommend.d.ts.map +1 -1
- package/dist/transform-channel.d.ts +9 -0
- package/dist/transform-channel.d.ts.map +1 -0
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/wire/formats.d.ts +10 -0
- package/dist/wire/formats.d.ts.map +1 -0
- package/dist/wire/index.d.ts +1 -0
- package/dist/wire/index.d.ts.map +1 -1
- package/dist/wire/index.js +52 -8
- package/dist/wire/index.js.map +1 -1
- package/dist/wire/responses.d.ts +15 -0
- package/dist/wire/responses.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -85,6 +85,14 @@ processTurn({ messages, state, config, tokenCount, renderTags: "none" });
|
|
|
85
85
|
`renderTags` is optional and defaults to `"all"`, so existing call sites keep
|
|
86
86
|
working unchanged.
|
|
87
87
|
|
|
88
|
+
**Token counts in rendered tags are snapshots.** Each message's
|
|
89
|
+
`<acp tokens="N">` attribute is frozen at the tag's first render (the
|
|
90
|
+
per-message `tokenSnapshot` in state) and is not recomputed when the message
|
|
91
|
+
text is later filtered, truncated, or edited by the host — the number always
|
|
92
|
+
describes what the model originally saw. Nudge/pressure *decisions* are
|
|
93
|
+
unaffected: they recount live text every turn. If you need the legacy
|
|
94
|
+
live-recomputed tags, use `renderVisibleRefs` directly.
|
|
95
|
+
|
|
88
96
|
### Standalone modules
|
|
89
97
|
|
|
90
98
|
| Module | Purpose |
|
|
@@ -95,6 +103,7 @@ working unchanged.
|
|
|
95
103
|
| `mergeMarkedBlocks` / `collectOldGenBlocks` | Batch merge old-gen blocks into one summary |
|
|
96
104
|
| `rebuildCompressionState` | Fork-recovery: replay historical compress calls |
|
|
97
105
|
| `applyMessageFilters` | Pluggable message-filter framework |
|
|
106
|
+
| `resolveTransformChannel` | Channel-selection policy: an explicit preference wins; the default is the wire channel only when the caller reports it viable |
|
|
98
107
|
|
|
99
108
|
### Nudge system
|
|
100
109
|
|
|
@@ -106,9 +115,22 @@ The nudge system tells the model *when* to compress. It implements:
|
|
|
106
115
|
- **Compressible-range computation**: reports the actual compressible ranges (excluding covered + preserved-recent messages) so the model knows what to target.
|
|
107
116
|
- **Baseline reset on compress**: `applyCompression` clears the growth baseline on success, preventing the feedback-loop bug where the nudge re-fires post-compress.
|
|
108
117
|
|
|
118
|
+
## Wire codec (`acp-kernel/wire`)
|
|
119
|
+
|
|
120
|
+
The `acp-kernel/wire` subpath ships the provider wire-body codecs (lossless
|
|
121
|
+
round-trip via the `BiliMessage` sidecar): `anthropicToCore`/`coreToAnthropic`,
|
|
122
|
+
`openaiToCore`/`coreToOpenai`, `responsesToCore`/`coreToResponses`, plus
|
|
123
|
+
`deriveMessageId` (content-hash message identity), conversation signals and the
|
|
124
|
+
subagent-namespace helpers. `WIRE_FORMATS` / `detectWireFormat` classify a
|
|
125
|
+
request body by the codec that can parse it — `undefined` means the body is
|
|
126
|
+
unparseable and must be passed through untransformed. Adapters map their
|
|
127
|
+
host's model/API ids to formats and use `resolveTransformChannel` (with
|
|
128
|
+
`wireViable` = body parseable AND the host applies the payload replacement)
|
|
129
|
+
to decide between message-level and wire-level surgery.
|
|
130
|
+
|
|
109
131
|
## Status
|
|
110
132
|
|
|
111
|
-
✅ **Engine complete** — 23 source modules,
|
|
133
|
+
✅ **Engine complete** — 23 source modules, full suite green (`npm test`), typecheck + build clean. 3-tier compression, growth-gated nudges, emergency truncation, fork-recovery, batch merge, composable node pipeline. Ready for adapter authoring.
|
|
112
134
|
|
|
113
135
|
> **Protected tool messages:** protected tool calls (per `config.protectedTools`) and their paired tool-results are hard-excluded from compression — they are dropped from the compressible set and from the new block's `effectiveMessageIds`, so they stay fully visible and are never folded into a summary. This matches opencode-acp's Bug 39 fix. The soft-protected recent zone (`preserveRecentMessages` / last user message) is handled separately: messages there are excluded from the range but do not fail it (an entirely-protected range fails with a clear error).
|
|
114
136
|
|
package/dist/compress.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compress.d.ts","sourceRoot":"","sources":["../src/compress.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAapB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AASvD,OAAO,EAGL,KAAK,YAAY,EAElB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,EAEhB,MAAM,EAEN,WAAW,EAGX,iBAAiB,EAEjB,YAAY,EACb,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,KAAK;IACpB,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CACxC;AAED,MAAM,WAAW,eAAe;IAC9B,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,iBAAiB,CAAC;IACxD,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,sBAAsB,CAAC;IACvE,YAAY,IAAI,YAAY,EAAE,CAAC;IAC/B,UAAU,CACR,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,gBAAgB,GACtB,gBAAgB,GAAG,SAAS,CAAC;IAChC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,GAAG,gBAAgB,EAAE,CAAC;IACnE,MAAM,CACJ,KAAK,EAAE,gBAAgB,EACvB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GACb,YAAY,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,KAAK,EAAE,gBAAg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AC;IACvE,YAAY,IAAI,YAAY,EAAE,CAAC;IAC/B,UAAU,CACR,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,gBAAgB,GACtB,gBAAgB,GAAG,SAAS,CAAC;IAChC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,GAAG,gBAAgB,EAAE,CAAC;IACnE,MAAM,CACJ,KAAK,EAAE,gBAAgB,EACvB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GACb,YAAY,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,KAAK,EAAE,gBAAgB,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE;QACN,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,EAAE,CAAC;IACJ,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,KAAK,EAAE,gBAAgB,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACnC;AAsBD,wBAAgB,UAAU,CAAC,KAAK,GAAE,KAAU,GAAG,eAAe,CAwQ7D;AAqxBD,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ export { rebuildCompressionState } from "./rebuild.js";
|
|
|
26
26
|
export type { RebuildResult, RebuildPorts } from "./rebuild.js";
|
|
27
27
|
export { renderVisibleRefs, renderRefsNode, createRenderRefsNode } from "./render-refs.js";
|
|
28
28
|
export type { RenderStrategy } from "./render-refs.js";
|
|
29
|
+
export { resolveTransformChannel } from "./transform-channel.js";
|
|
30
|
+
export type { TransformChannel } from "./transform-channel.js";
|
|
29
31
|
export { searchBlocks, searchBlocksAsync, blockDocs, messageDocs } from "./search.js";
|
|
30
32
|
export type { SearchResult, SearchOptions, SearchAlgorithm, AsyncSearchAlgorithm, AnySearchAlgorithm, SearchDoc, SearchDocKind, ScoredBlock, MessageRole, RoleWeights, MessageInput } from "./search.js";
|
|
31
33
|
export { DEFAULT_ALGORITHM, DEFAULT_ROLE_WEIGHTS, registerSearchAlgorithm, getSearchAlgorithm, listSearchAlgorithms } from "./search.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EACV,KAAK,EACL,eAAe,EACf,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,WAAW,GACZ,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,iBA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,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC3F,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtF,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACzM,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACzI,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EACL,WAAW,EACX,MAAM,EACN,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,WAAW,GACjB,MAAM,eAAe,CAAC;AACvB,cAAc,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1050,6 +1050,7 @@ function buildCompressibleRanges(messages, state, config, protectedZoneRefs, cou
|
|
|
1050
1050
|
ref,
|
|
1051
1051
|
refNum: rn,
|
|
1052
1052
|
tokens: countTokens(msg.text ?? ""),
|
|
1053
|
+
chars: (msg.text ?? "").length,
|
|
1053
1054
|
isTool: isToolMessage(msg),
|
|
1054
1055
|
isUser: msg.role === "user"
|
|
1055
1056
|
});
|
|
@@ -1070,6 +1071,7 @@ function buildCompressibleRanges(messages, state, config, protectedZoneRefs, cou
|
|
|
1070
1071
|
endRef: info.ref,
|
|
1071
1072
|
count: 1,
|
|
1072
1073
|
tokens: info.tokens,
|
|
1074
|
+
chars: info.chars,
|
|
1073
1075
|
toolPct: info.isTool ? 100 : 0,
|
|
1074
1076
|
textPct: info.isTool ? 0 : 100
|
|
1075
1077
|
};
|
|
@@ -1077,6 +1079,7 @@ function buildCompressibleRanges(messages, state, config, protectedZoneRefs, cou
|
|
|
1077
1079
|
cur.endRef = info.ref;
|
|
1078
1080
|
cur.count++;
|
|
1079
1081
|
cur.tokens += info.tokens;
|
|
1082
|
+
cur.chars = (cur.chars ?? 0) + info.chars;
|
|
1080
1083
|
if (info.isTool) {
|
|
1081
1084
|
cur.toolPct = Math.round((cur.toolPct * (cur.count - 1) + 100) / cur.count);
|
|
1082
1085
|
} else {
|
|
@@ -1124,6 +1127,7 @@ function mergeBatch(batch) {
|
|
|
1124
1127
|
const last = batch[batch.length - 1];
|
|
1125
1128
|
const count = batch.reduce((s, r) => s + r.count, 0);
|
|
1126
1129
|
const tokens = batch.reduce((s, r) => s + r.tokens, 0);
|
|
1130
|
+
const chars = batch.reduce((s, r) => s + rangeChars(r), 0);
|
|
1127
1131
|
const toolPct = Math.round(
|
|
1128
1132
|
batch.reduce((s, r) => s + r.toolPct * r.count, 0) / count
|
|
1129
1133
|
);
|
|
@@ -1132,6 +1136,7 @@ function mergeBatch(batch) {
|
|
|
1132
1136
|
endRef: last.endRef,
|
|
1133
1137
|
count,
|
|
1134
1138
|
tokens,
|
|
1139
|
+
chars,
|
|
1135
1140
|
toolPct,
|
|
1136
1141
|
textPct: 100 - toolPct
|
|
1137
1142
|
};
|
|
@@ -1140,16 +1145,21 @@ function mergeBatch(batch) {
|
|
|
1140
1145
|
}
|
|
1141
1146
|
return merged;
|
|
1142
1147
|
}
|
|
1148
|
+
function rangeChars(r) {
|
|
1149
|
+
return r.chars ?? r.tokens * 4;
|
|
1150
|
+
}
|
|
1143
1151
|
function mergeRangesToThreshold(ranges, minChars) {
|
|
1144
1152
|
if (minChars <= 0 || ranges.length === 0) return ranges;
|
|
1145
1153
|
const result = [];
|
|
1146
1154
|
let batch = [];
|
|
1155
|
+
let batchChars = 0;
|
|
1147
1156
|
for (const r of ranges) {
|
|
1148
1157
|
batch.push(r);
|
|
1149
|
-
|
|
1150
|
-
if (
|
|
1158
|
+
batchChars += rangeChars(r);
|
|
1159
|
+
if (batchChars >= minChars) {
|
|
1151
1160
|
result.push(mergeBatch(batch));
|
|
1152
1161
|
batch = [];
|
|
1162
|
+
batchChars = 0;
|
|
1153
1163
|
}
|
|
1154
1164
|
}
|
|
1155
1165
|
if (batch.length > 0) {
|
|
@@ -1744,7 +1754,7 @@ function resolveAdaptiveGrowth(modelContextLimit, nudge) {
|
|
|
1744
1754
|
function pendingByTier(state, recommendation, countTokens, minCompressRange) {
|
|
1745
1755
|
const out = {};
|
|
1746
1756
|
const merged = recommendation?.recommendedRanges ?? [];
|
|
1747
|
-
const effective = minCompressRange > 0 ? merged.filter((r) => r.tokens * 4 >= minCompressRange) : merged;
|
|
1757
|
+
const effective = minCompressRange > 0 ? merged.filter((r) => (r.chars ?? r.tokens * 4) >= minCompressRange) : merged;
|
|
1748
1758
|
out[1] = { pending: effective.reduce((s, r) => s + r.tokens, 0), targetBlocks: [] };
|
|
1749
1759
|
const active = activeBlocks(state);
|
|
1750
1760
|
const t1 = active.filter((b) => b.tier === 1);
|
|
@@ -2690,6 +2700,11 @@ function extractRanges(input, callId) {
|
|
|
2690
2700
|
return ranges;
|
|
2691
2701
|
}
|
|
2692
2702
|
|
|
2703
|
+
// src/transform-channel.ts
|
|
2704
|
+
function resolveTransformChannel(explicit, wireViable) {
|
|
2705
|
+
return explicit ?? (wireViable ? "wire" : "message");
|
|
2706
|
+
}
|
|
2707
|
+
|
|
2693
2708
|
// src/search/algorithms/substring.ts
|
|
2694
2709
|
var substringAlgorithm = {
|
|
2695
2710
|
name: "substring",
|
|
@@ -3033,6 +3048,7 @@ export {
|
|
|
3033
3048
|
renderVisibleRefs,
|
|
3034
3049
|
resolveBoundaries,
|
|
3035
3050
|
resolvePrompts,
|
|
3051
|
+
resolveTransformChannel,
|
|
3036
3052
|
runPipeline,
|
|
3037
3053
|
searchBlocks,
|
|
3038
3054
|
searchBlocksAsync,
|