acp-kernel 0.0.21 → 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.
@@ -1,9 +1,10 @@
1
1
  import type { NudgeDecision, CompressibleRange, ProtectedRange } from "./types.js";
2
+ import type { Prompts } from "./prompts.js";
2
3
  export type NudgeVoice = "gentle" | "emergency";
3
4
  export interface RenderedNudge {
4
5
  voice: NudgeVoice;
5
6
  text: string;
6
7
  }
7
8
  export declare function formatRanges(compressible: CompressibleRange[], protectedRanges: ProtectedRange[]): string;
8
- export declare function renderNudgeText(decision: NudgeDecision): RenderedNudge;
9
+ export declare function renderNudgeText(decision: NudgeDecision, prompts?: Prompts): RenderedNudge;
9
10
  //# sourceMappingURL=nudge-text.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nudge-text.d.ts","sourceRoot":"","sources":["../src/nudge-text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,cAAc,EAAsC,MAAM,YAAY,CAAC;AAGvH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEhD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,UAAU,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AAqCD,wBAAgB,YAAY,CAAC,YAAY,EAAE,iBAAiB,EAAE,EAAE,eAAe,EAAE,cAAc,EAAE,GAAG,MAAM,CAsEzG;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,aAAa,GAAG,aAAa,CAiEtE"}
1
+ {"version":3,"file":"nudge-text.d.ts","sourceRoot":"","sources":["../src/nudge-text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,cAAc,EAAsC,MAAM,YAAY,CAAC;AAEvH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEhD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,UAAU,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AAyCD,wBAAgB,YAAY,CAAC,YAAY,EAAE,iBAAiB,EAAE,EAAE,eAAe,EAAE,cAAc,EAAE,GAAG,MAAM,CAsEzG;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,aAAa,EAAE,OAAO,GAAE,OAAwB,GAAG,aAAa,CAiEzG"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Overridable prompt text consumed by the kernel's nudge renderer and, via the
3
+ * adapter, the system prompt. Every field here is LOAD-BEARING: these rules
4
+ * were tuned over months of production use and are quality-critical. Overriding
5
+ * them can degrade summary quality (loss of paths / signatures / decisions →
6
+ * broken retrieval), so {@link resolvePrompts} requires `{ acknowledgeRisk: true }`.
7
+ *
8
+ * Surface-level text (summary section headers, status-report chrome, tool
9
+ * descriptions) is intentionally NOT part of this interface — it is owned by
10
+ * the adapter or a later "prompt-set format" layer and is safe to customize
11
+ * freely. See DESIGN.md for the load-bearing vs surface classification.
12
+ */
13
+ export interface Prompts {
14
+ /** Core compression philosophy. Embedded in the system prompt + every nudge. */
15
+ compressPhilosophy: string;
16
+ /** Rules the model follows when writing a tier-1 summary. */
17
+ howToCompressRules: string;
18
+ /** Rules for tier-2 distillation of existing summaries. */
19
+ tier2DistillRules: string;
20
+ /** Rules for tier-3 ultra-condensation of distilled summaries. */
21
+ tier3CondenseRules: string;
22
+ }
23
+ /**
24
+ * The kernel's canonical prompt values (verbatim from compression-rules.ts).
25
+ * Frozen so a buggy caller cannot mutate the shared singleton and corrupt
26
+ * every other consumer of {@link defaultPrompts}.
27
+ */
28
+ export declare const defaultPrompts: Prompts;
29
+ export interface ResolvePromptsOptions {
30
+ /**
31
+ * Must be `true` to override any prompt field. Every {@link Prompts} field is
32
+ * load-bearing; overriding without acknowledging the quality risk is a
33
+ * programming error and throws.
34
+ */
35
+ acknowledgeRisk?: boolean;
36
+ }
37
+ /**
38
+ * Merge prompt overrides onto the kernel defaults. All fields are load-bearing,
39
+ * so ANY override requires `{ acknowledgeRisk: true }`.
40
+ *
41
+ * Only `string`-valued overrides take effect: an explicit `undefined`/`null` or
42
+ * a wrong type is silently dropped (never clobbers a good default), so a
43
+ * malformed partial never degrades the canonical rules. Resolve once at host
44
+ * startup, then pass the resulting {@link Prompts} to {@link renderNudgeText}
45
+ * and to the adapter's system-prompt composition so both layers stay consistent.
46
+ */
47
+ export declare function resolvePrompts(overrides?: Partial<Prompts>, options?: ResolvePromptsOptions): Prompts;
48
+ //# sourceMappingURL=prompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,OAAO;IACtB,gFAAgF;IAChF,kBAAkB,EAAE,MAAM,CAAC;IAC3B,6DAA6D;IAC7D,kBAAkB,EAAE,MAAM,CAAC;IAC3B,2DAA2D;IAC3D,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kEAAkE;IAClE,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,OAKhB,CAAC;AAEd,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,SAAS,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EAC5B,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAkBT"}
@@ -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,CAmBf"}
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "acp-kernel",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "description": "Framework-agnostic context-compression engine (model-driven, 3-tier LSM). Pure core: no host dependency.",
5
5
  "license": "MIT",
6
6
  "author": "ranxianglei",