acp-kernel 0.0.22 → 0.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/dist/compress.d.ts.map +1 -1
- package/dist/index.js +79 -12
- package/dist/index.js.map +1 -1
- package/dist/prune.d.ts.map +1 -1
- package/dist/reasoning-pairs.d.ts +33 -0
- package/dist/reasoning-pairs.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/prune.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prune.d.ts","sourceRoot":"","sources":["../src/prune.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEhE,eAAO,MAAM,cAAc,sCAAsC,CAAC;AAElE,MAAM,WAAW,YAAY;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,wBAAgB,KAAK,CACnB,QAAQ,EAAE,WAAW,EAAE,EACvB,KAAK,EAAE,gBAAgB,EACvB,OAAO,GAAE,YAAiB,GACzB,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"prune.d.ts","sourceRoot":"","sources":["../src/prune.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEhE,eAAO,MAAM,cAAc,sCAAsC,CAAC;AAElE,MAAM,WAAW,YAAY;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,wBAAgB,KAAK,CACnB,QAAQ,EAAE,WAAW,EAAE,EACvB,KAAK,EAAE,gBAAgB,EACvB,OAAO,GAAE,YAAiB,GACzB,WAAW,EAAE,CAqBf"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { CoreMessage } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Adjust compression range boundaries to keep a `reasoning` message together
|
|
4
|
+
* with the assistant text/tool-call it belongs to.
|
|
5
|
+
*
|
|
6
|
+
* Reasoning models (DeepSeek-R1, GLM-4.6 thinking, Qwen-QwQ, Anthropic
|
|
7
|
+
* thinking) emit a `reasoning_content` / thinking block that strict providers
|
|
8
|
+
* require to be echoed back alongside the response on every subsequent
|
|
9
|
+
* request. In acp-kernel that block is a separate `contentType: "reasoning"`
|
|
10
|
+
* message immediately preceding the assistant text/tool-call of the same turn.
|
|
11
|
+
* If a compression range covers only one half of the pair, the rebuilt
|
|
12
|
+
* conversation ships reasoning without its response (or vice versa) and the
|
|
13
|
+
* provider returns HTTP 400 (DeepSeek: "reasoning_content in the thinking mode
|
|
14
|
+
* must be passed back to the API").
|
|
15
|
+
*
|
|
16
|
+
* This is the reasoning analogue of {@link adjustBoundariesForToolPairs}:
|
|
17
|
+
* before a range is applied, pull the orphan half INTO the range so the pair
|
|
18
|
+
* compresses together — zero information loss. Only MESSAGE-boundary ranges
|
|
19
|
+
* are adjusted (block-boundary ranges are left untouched, like tool pairs).
|
|
20
|
+
*
|
|
21
|
+
* Pairing is adjacency-based — there is no shared id (unlike toolCallId). A
|
|
22
|
+
* `reasoning` message pairs with the assistant text/tool-call immediately
|
|
23
|
+
* following its reasoning run, and an assistant text/tool-call pairs with the
|
|
24
|
+
* reasoning run immediately preceding it. This matches the round-trip contract
|
|
25
|
+
* every adapter relies on when reconstructing reasoning_content.
|
|
26
|
+
*
|
|
27
|
+
* @returns Adjusted { startIndex, endIndex } — may be wider than input.
|
|
28
|
+
*/
|
|
29
|
+
export declare function adjustBoundariesForReasoningPairs(startIndex: number, endIndex: number, messages: CoreMessage[]): {
|
|
30
|
+
startIndex: number;
|
|
31
|
+
endIndex: number;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=reasoning-pairs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reasoning-pairs.d.ts","sourceRoot":"","sources":["../src/reasoning-pairs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,iCAAiC,CAC/C,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,WAAW,EAAE,GACtB;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAwD1C"}
|
package/package.json
CHANGED