@aparte/core 0.25.0 → 0.26.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.
Files changed (69) hide show
  1. package/dist/client/agent-runner.d.ts.map +1 -1
  2. package/dist/client/aparte-client.d.ts +35 -76
  3. package/dist/client/aparte-client.d.ts.map +1 -1
  4. package/dist/client/stream-adapter.d.ts.map +1 -1
  5. package/dist/client/wire-history.d.ts +78 -0
  6. package/dist/client/wire-history.d.ts.map +1 -1
  7. package/dist/components/bubble/aparte-chat-bubble.d.ts +88 -2
  8. package/dist/components/bubble/aparte-chat-bubble.d.ts.map +1 -1
  9. package/dist/components/bubble/bubble-sync.d.ts +5 -1
  10. package/dist/components/bubble/bubble-sync.d.ts.map +1 -1
  11. package/dist/components/bubble/checkpoint-separator.d.ts +40 -0
  12. package/dist/components/bubble/checkpoint-separator.d.ts.map +1 -0
  13. package/dist/components/context/aparte-context.d.ts +157 -25
  14. package/dist/components/context/aparte-context.d.ts.map +1 -1
  15. package/dist/components/viewport/aparte-chat-viewport.d.ts +7 -0
  16. package/dist/components/viewport/aparte-chat-viewport.d.ts.map +1 -1
  17. package/dist/config/aparte-config.d.ts +17 -0
  18. package/dist/config/aparte-config.d.ts.map +1 -1
  19. package/dist/config/locale.d.ts +62 -4
  20. package/dist/config/locale.d.ts.map +1 -1
  21. package/dist/context/checkpoint-state.d.ts +70 -0
  22. package/dist/context/checkpoint-state.d.ts.map +1 -0
  23. package/dist/context/checkpoint.d.ts +28 -0
  24. package/dist/context/checkpoint.d.ts.map +1 -0
  25. package/dist/context/measure.d.ts +148 -0
  26. package/dist/context/measure.d.ts.map +1 -0
  27. package/dist/context/restore.d.ts +24 -0
  28. package/dist/context/restore.d.ts.map +1 -0
  29. package/dist/conversations/conversation-controller.d.ts +13 -4
  30. package/dist/conversations/conversation-controller.d.ts.map +1 -1
  31. package/dist/conversations/conversation-manager.d.ts +6 -0
  32. package/dist/conversations/conversation-manager.d.ts.map +1 -1
  33. package/dist/custom-elements.json +13734 -12139
  34. package/dist/{defer-hydration-BwMqeRHq.js → defer-hydration-8vI8xNNx.js} +683 -250
  35. package/dist/defer-hydration-8vI8xNNx.js.map +1 -0
  36. package/dist/generated/element-attributes.d.ts +8 -2
  37. package/dist/generated/element-attributes.d.ts.map +1 -1
  38. package/dist/host/aparte-chat-host.d.ts +19 -2
  39. package/dist/host/aparte-chat-host.d.ts.map +1 -1
  40. package/dist/index.css +1 -1
  41. package/dist/index.d.ts +5 -1
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +819 -81
  44. package/dist/index.js.map +1 -1
  45. package/dist/index.node.d.ts +4 -1
  46. package/dist/index.node.d.ts.map +1 -1
  47. package/dist/index.node.js +33 -29
  48. package/dist/index.node.js.map +1 -1
  49. package/dist/transport/agent-handler.d.ts.map +1 -1
  50. package/dist/transport/backend-handler.d.ts.map +1 -1
  51. package/dist/transport/types.d.ts +24 -4
  52. package/dist/transport/types.d.ts.map +1 -1
  53. package/dist/types/chat.d.ts +16 -1
  54. package/dist/types/chat.d.ts.map +1 -1
  55. package/dist/types/compactor.d.ts +104 -0
  56. package/dist/types/compactor.d.ts.map +1 -0
  57. package/dist/types/errors.d.ts +2 -0
  58. package/dist/types/errors.d.ts.map +1 -1
  59. package/dist/types/events.d.ts +50 -3
  60. package/dist/types/events.d.ts.map +1 -1
  61. package/dist/types/index.d.ts +3 -2
  62. package/dist/types/index.d.ts.map +1 -1
  63. package/dist/types/model-provider.d.ts +3 -0
  64. package/dist/types/model-provider.d.ts.map +1 -1
  65. package/dist/types/models.d.ts +43 -3
  66. package/dist/types/models.d.ts.map +1 -1
  67. package/dist/types/segments.d.ts +1 -1
  68. package/package.json +2 -2
  69. package/dist/defer-hydration-BwMqeRHq.js.map +0 -1
@@ -0,0 +1,28 @@
1
+ import type { AparteMessage } from '../types/models.js';
2
+ /**
3
+ * The part of a path the model reads, and the summary that stands for the rest.
4
+ *
5
+ * A checkpoint is `contextSummary` on a message: from it on the model reads the summary
6
+ * in place of everything before. The LAST message carrying one wins — a later
7
+ * checkpoint was written over the earlier summary (it asked for an update of it), so
8
+ * the earlier one is already inside it. Everything before the winner is dropped from
9
+ * the result, a legacy `compaction: true` message included: that notice is itself part
10
+ * of what the checkpoint summarised, and sending it beside the summary would say the
11
+ * same thing twice.
12
+ *
13
+ * With no checkpoint the path comes back unchanged and no summary is returned, so a
14
+ * caller can use it unconditionally. Nothing is deleted from the transcript — this
15
+ * reads a path and returns a view of it.
16
+ *
17
+ * Call it on the FULL path, the unanswered user message at its end included: the
18
+ * checkpoint can sit on that very message (a turn retried after an overflow), and the
19
+ * summary still has to go out before it.
20
+ *
21
+ * `AparteClient` applies it to every history it builds. A `history` function handed to
22
+ * the client receives the whole transcript and can call this itself.
23
+ */
24
+ export declare function historyFromCheckpoint(path: AparteMessage[]): {
25
+ summary?: string;
26
+ messages: AparteMessage[];
27
+ };
28
+ //# sourceMappingURL=checkpoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkpoint.d.ts","sourceRoot":"","sources":["../../src/context/checkpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,aAAa,EAAE,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,aAAa,EAAE,CAAA;CAAE,CAM5G"}
@@ -0,0 +1,148 @@
1
+ import type { AparteConfig } from '../config/aparte-config.js';
2
+ import { type AparteChatMessage, type AparteUsage } from '../types/chat.js';
3
+ import type { AparteMessage } from '../types/models.js';
4
+ import type { AparteTool } from '../types/tools.js';
5
+ /**
6
+ * Token heuristic (FR ~3.5 chars/tok, EN ~4 chars/tok).
7
+ *
8
+ * Accurate to ±10% — enough for budgeting, and it avoids a tokenizer, which costs ~5ms
9
+ * per message × N (too slow to run on every turn) and is one more dependency per model
10
+ * family. It is the ONE estimate: the compaction plugin's budget and selector, the
11
+ * gauge, and the number the client records on a reply all read it, so the figures they
12
+ * show and the decisions they take cannot disagree about what a message costs.
13
+ */
14
+ export declare function estimateTokens(text: string | null | undefined): number;
15
+ /**
16
+ * The estimate of a request's messages as the WIRE carries them: each message's text, and
17
+ * for an assistant envelope the calls it declares. Parts other than text (an image's
18
+ * bytes) are not counted — a character heuristic has nothing honest to say about them.
19
+ *
20
+ * Exported for the code that holds the request already built, where `estimateWireTokens`
21
+ * would serialise the transcript a second time.
22
+ */
23
+ export declare function estimateChatTokens(messages: AparteChatMessage[]): number;
24
+ /**
25
+ * Whether the heuristic could see the whole request: false when a message carries a part
26
+ * other than text (an image), which {@link estimateChatTokens} counts as nothing. An
27
+ * estimate of such a request is a floor, not a reading, and must not be set beside the
28
+ * provider's real count as if it were one.
29
+ */
30
+ export declare function carriesNonTextParts(messages: AparteChatMessage[]): boolean;
31
+ /**
32
+ * The estimate of a whole request as it is about to be sent: its messages (the system
33
+ * prompts and a checkpoint's summary among them) and the tool definitions beside them —
34
+ * the same four things {@link measureContext} adds up, so a figure recorded here at send
35
+ * time and the measure's own reading of the same view are one currency, which is what lets
36
+ * the one calibrate the other.
37
+ */
38
+ export declare function estimateRequestTokens(request: {
39
+ messages: AparteChatMessage[];
40
+ tools?: AparteTool[] | undefined;
41
+ }): number;
42
+ /**
43
+ * The estimate of what the wire sends for these messages: the same serialisation the
44
+ * client builds its history with (`wireMessages`) — a reply's thinking is not sent, its
45
+ * text is, and a tool call and its result count as the envelope and the `tool` message
46
+ * the wire carries. A failed turn and one still in flight send nothing.
47
+ *
48
+ * Not `estimateTokens(message.content)`: assistant replies keep their text in
49
+ * `segments` with `content` empty, so that sum would read a whole conversation as free.
50
+ */
51
+ export declare function estimateWireTokens(messages: AparteMessage[]): number;
52
+ /** Tokens one turn reports as used: the provider's total, else the prompt plus the reply. */
53
+ export declare const usageTokens: (usage: AparteUsage) => number;
54
+ /**
55
+ * The registered tools, unless the current model says it cannot call one.
56
+ *
57
+ * Single source for the gate, so send / retry / edit — and the measure of what they send —
58
+ * cannot drift.
59
+ *
60
+ * The question is "did this model say it cannot", not "did it say it can": the app sets a
61
+ * model id by hand (`setModelConfig`) or a selector sets it from a fetched list, and in both
62
+ * cases the model's declared capabilities are commonly unknown. `undefined` capabilities
63
+ * read as "can", or `tools: []` would go on the wire while `getTools()` held the tool the
64
+ * app had explicitly registered, and the model would answer that it had no such tool.
65
+ * Registering a tool is an explicit act by the app; silently dropping it because a
66
+ * `/models` listing is terse is the library second-guessing the developer. A model that
67
+ * declares its capabilities and omits function calling is still honoured — that is a
68
+ * statement, and it is respected.
69
+ *
70
+ * Failure modes, both ways round: over-sending means a model that cannot use tools does
71
+ * not call one, or its own endpoint rejects the array with an error the developer can
72
+ * read. Under-sending would be silent, total, and look like a lying model.
73
+ */
74
+ export declare function toolsForCurrentModel(config: AparteConfig): AparteTool[];
75
+ /**
76
+ * What fills the model's window, as one reading. `used` is the total the gauge draws;
77
+ * `parts` say where it goes.
78
+ *
79
+ * The parts are RAW estimates (the character heuristic, uncalibrated), so they are
80
+ * labelled as estimates wherever they are shown and need not add up to `used`: the
81
+ * difference, `other`, is what the heuristic cannot see — a server loop's own system
82
+ * prompt and tools, the chat template's tokens, the heuristic's own error.
83
+ */
84
+ export interface AparteContextMeasure {
85
+ /** The window `used` is measured against, when one is known. */
86
+ window?: number;
87
+ /** Tokens in use: the last reply's reported usage, or an estimate of the request the next turn would send. */
88
+ used: number;
89
+ /** `true` when `used` is an estimate — something changed in what the model reads since the last reply reported. */
90
+ estimated: boolean;
91
+ /** Raw estimates, in tokens, of what the model reads: the system prompts, the tool definitions, the checkpoint's summary, the messages after it. */
92
+ parts: {
93
+ system: number;
94
+ tools: number;
95
+ summary: number;
96
+ messages: number;
97
+ };
98
+ /** `used` less the parts, never below zero. */
99
+ other: number;
100
+ }
101
+ /** What {@link measureContext} reads. */
102
+ export interface AparteContextMeasureInput {
103
+ /** The ACTIVE path of the conversation, checkpoint and all — not the view after it. */
104
+ messages: AparteMessage[];
105
+ /** The config that resolves the system prompt, the tools and the current model. */
106
+ config: AparteConfig;
107
+ /** A window that wins over the current model's, for a page that knows better (the gauge's `window` attribute). */
108
+ windowOverride?: number | null | undefined;
109
+ /**
110
+ * The caller knows what the model reads has changed since the last reply although the
111
+ * messages cannot say so — a Restore takes checkpoints off, and nothing is left on the
112
+ * path to date it. Forces an estimate.
113
+ */
114
+ viewChanged?: boolean;
115
+ }
116
+ /** The model's window as the measure reads it: the override, else the current model's. */
117
+ export declare function windowOf(config: AparteConfig, windowOverride?: number | null): number | undefined;
118
+ /**
119
+ * The one measure of the context window, for the gauge and for the compaction plugin.
120
+ *
121
+ * `used` is the last reply's REAL usage while nothing the model reads has changed since
122
+ * it: the reply is the last message of the path, and no checkpoint was written after it.
123
+ * Once something has (a message was added, a compaction ran), the real number describes a
124
+ * request that will not be sent again, so `used` becomes an estimate of the request that
125
+ * WOULD be sent — the system prompts, the tool definitions, the checkpoint's summary and
126
+ * the messages after it — scaled by `k`, how far the heuristic was off on the last reply:
127
+ * its real input tokens over the estimate recorded when it was sent
128
+ * (`AparteMessage.contextEstimate`), clamped to [0.5, 3] so one odd reply cannot throw the
129
+ * reading, and 1 when the reply has no estimate. After a compaction the reading is
130
+ * therefore the size of the new, smaller view, never the stale one from before it, and
131
+ * never a `k` computed against a history the reply did not see.
132
+ *
133
+ * `k` compares like with like or it is 1. The estimate is of the FIRST request a turn sent
134
+ * and the usage is of its LAST call, which also read the calls and their results, so a
135
+ * reply that called tools says nothing about the heuristic's error and counts as 1. A
136
+ * request the heuristic could not read whole (an image) records no estimate at all.
137
+ *
138
+ * While nothing has changed, `used` is what the NEXT request will carry: the input the
139
+ * provider reported, plus the reply as it goes back on the wire. A provider's output count
140
+ * includes the reasoning it generated, and a reply's thinking is not sent again, so for a
141
+ * reply that thought the answer is read from the transcript (the part after its last call,
142
+ * which is all the final call added to what it read) and not from the output count.
143
+ *
144
+ * The parts are not scaled: they stay the raw estimates, so a reader can see what the
145
+ * measure is made of.
146
+ */
147
+ export declare function measureContext(input: AparteContextMeasureInput): AparteContextMeasure;
148
+ //# sourceMappingURL=measure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"measure.d.ts","sourceRoot":"","sources":["../../src/context/measure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAiB,KAAK,iBAAiB,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC3F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAIpD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAGtE;AAWD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAOxE;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAE1E;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE;IAAE,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAAC,KAAK,CAAC,EAAE,UAAU,EAAE,GAAG,SAAS,CAAA;CAAE,GAAG,MAAM,CAG1H;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,MAAM,CAEpE;AAED,6FAA6F;AAC7F,eAAO,MAAM,WAAW,UAAW,WAAW,KAAG,MAAuE,CAAC;AAEzH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,GAAG,UAAU,EAAE,CAIvE;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,oBAAoB;IACjC,gEAAgE;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8GAA8G;IAC9G,IAAI,EAAE,MAAM,CAAC;IACb,mHAAmH;IACnH,SAAS,EAAE,OAAO,CAAC;IACnB,oJAAoJ;IACpJ,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5E,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,yCAAyC;AACzC,MAAM,WAAW,yBAAyB;IACtC,uFAAuF;IACvF,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,mFAAmF;IACnF,MAAM,EAAE,YAAY,CAAC;IACrB,kHAAkH;IAClH,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC3C;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,0FAA0F;AAC1F,wBAAgB,QAAQ,CAAC,MAAM,EAAE,YAAY,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAIjG;AAkCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,yBAAyB,GAAG,oBAAoB,CAiCrF"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Restore: take every checkpoint off the transcript `from` belongs to, so the model reads
3
+ * the original messages again, and say so on `window`.
4
+ *
5
+ * EVERY checkpoint of the active path, not the one Restore was pressed on. A path that was
6
+ * summarised twice carries two (the second summary was written over the first), and
7
+ * removing only the newer would put the older summary back in front of messages the reader
8
+ * asked to have restored — a partial restore that looks like a complete one.
9
+ *
10
+ * Each removal goes through the chat's own `updateMessage`, which is what makes it reach
11
+ * the framework's list and the saved conversation as well as the bubble on screen; the
12
+ * `aparte-compact-done` that follows is what the conversation controller saves on and the
13
+ * gauge measures again on. A `restored: true` detail carries no summary: nothing was
14
+ * summarised, something was undone.
15
+ *
16
+ * Returns how many checkpoints were removed. Nothing is dispatched when the bubble belongs
17
+ * to no transcript that can be written — a restore that claimed to have happened would be
18
+ * the worse answer.
19
+ */
20
+ export declare function restoreContext(from: Element, detail: {
21
+ messageId?: string;
22
+ targetId?: string;
23
+ }): number;
24
+ //# sourceMappingURL=restore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restore.d.ts","sourceRoot":"","sources":["../../src/context/restore.ts"],"names":[],"mappings":"AA+BA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAUvG"}
@@ -189,10 +189,19 @@ export declare class AparteConversationController {
189
189
  * that was partially written before a switch or component destruction.
190
190
  */
191
191
  /**
192
- * Save once the binding holds the summary a compaction announced. A transcript kept in
193
- * a framework store reaches the binding only when that framework renders, so a save on
194
- * the microtask wrote the conversation as it stood before the compaction. Bounded: a
195
- * run with no summary (skipped), or a binding that never shows it, is saved as it is.
192
+ * Save once the binding holds what a compaction (or a Restore) announced. A transcript
193
+ * kept in a framework store reaches the binding only when that framework renders, so a
194
+ * save on the microtask wrote the conversation as it stood before the change. Bounded:
195
+ * a run that changed nothing (skipped), or a binding that never shows the change, is
196
+ * saved as it is.
197
+ *
198
+ * What "holds" means follows what the run said it did:
199
+ * - a checkpoint — `messageId` names the message carrying it, and it holds once that
200
+ * message carries a `contextSummary` with its `createdAt` (a summary without the
201
+ * stamp is a half-written one);
202
+ * - a Restore — it holds once no message of the path carries a checkpoint any more;
203
+ * - an older host's summary MESSAGE (`compaction: true`, ending with the summary).
204
+ * A run that names none of these has nothing to wait for.
196
205
  */
197
206
  private _persistOnceSummarised;
198
207
  private _persistActive;
@@ -1 +1 @@
1
- {"version":3,"file":"conversation-controller.d.ts","sourceRoot":"","sources":["../../src/conversations/conversation-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAoB,MAAM,mBAAmB,CAAC;AACzE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAE3E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAQlF;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAC9B,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,+EAA+E;IAC/E,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,2EAA2E;IAC3E,WAAW,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC;IAC7C,0EAA0E;IAC1E,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;IAC5C,qCAAqC;IACrC,WAAW,IAAI,aAAa,EAAE,CAAC;IAC/B,kEAAkE;IAClE,aAAa,CAAC,OAAO,CAAC,EAAE;QAAE,iBAAiB,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAC/D;;;OAGG;IACH,UAAU,CAAC,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACpC;;;;OAIG;IACH,UAAU,CAAC,IAAI,yBAAyB,GAAG,SAAS,CAAC;IACrD;;;;;OAKG;IACH,UAAU,CAAC,CAAC,IAAI,EAAE,yBAAyB,GAAG,IAAI,CAAC;IACnD;;;;;OAKG;IACH,WAAW,CAAC,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;CACtC;AAKD,MAAM,WAAW,mCAAmC;IAChD;;;OAGG;IACH,OAAO,CAAC,EAAE,yBAAyB,CAAC;IACpC;;;OAGG;IACH,qBAAqB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK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AAS;IAE3B;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAuBhC;gBAEU,OAAO,EAAE,iBAAiB,EAAE,OAAO,GAAE,mCAAwC;IAKzF,oEAAoE;IACpE,IAAI,QAAQ,IAAI,MAAM,GAAG,IAAI,CAE5B;IAED;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ;IAqBhB;;;;;;;;;OASG;IACH,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,4BAA4B;IAWpC;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ;IAgBhB;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAKnB;;OAEG;IACH,IAAI,IAAI,MAAM,IAAI;IAkJlB,8BAA8B;IAC9B,mFAAmF;IACnF,OAAO,CAAC,mBAAmB,CAA6B;IAExD,MAAM,IAAI,IAAI;IAoEd;;;;;;;;;;OAUG;IACG,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAqLzD;;;;;OAKG;IACH,OAAO,CAAC,SAAS;IAUjB;;;;;;;;;OASG;IACH;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,sBAAsB;IAsB9B,OAAO,CAAC,cAAc;YA+BR,6BAA6B;CAmE9C"}
@@ -35,6 +35,12 @@ export interface ConversationManagerOptions {
35
35
  *
36
36
  * Keeps the subtree rooted at the new-oldest kept message (so recent history AND
37
37
  * recent branches survive) and drops everything before it. Exported for testing.
38
+ *
39
+ * A checkpoint (`contextSummary`) the cut falls after is not lost with the messages it
40
+ * sat among: the new first message inherits it — the same summary and date, its count
41
+ * raised by the messages the cut takes after the checkpoint's own position. Without it
42
+ * a trimmed conversation would send the model no summary of what came before and no
43
+ * originals either, which is how retention would quietly undo a compaction.
38
44
  */
39
45
  export declare function applyRetention(messages: AparteMessage[], tree: ExportedMessageRepository | undefined, maxMessages: number): {
40
46
  messages: AparteMessage[];
@@ -1 +1 @@
1
- {"version":3,"file":"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