@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
@@ -1 +1 @@
1
- {"version":3,"file":"agent-runner.d.ts","sourceRoot":"","sources":["../../src/client/agent-runner.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,MAAM,WAAW,wBAAwB;IACrC,2EAA2E;IAC3E,QAAQ,EAAE,MAAM,CAAC;IACjB,2FAA2F;IAC3F,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IACpG,kCAAkC;IAClC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,gEAAgE;IAChE,WAAW,CAAC,EAAE,kBAAkB,CAAC;CACpC;AAID;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,wBAAwB,GAAG,kBAAkB,CAuD7F"}
1
+ {"version":3,"file":"agent-runner.d.ts","sourceRoot":"","sources":["../../src/client/agent-runner.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,MAAM,WAAW,wBAAwB;IACrC,2EAA2E;IAC3E,QAAQ,EAAE,MAAM,CAAC;IACjB,2FAA2F;IAC3F,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IACpG,kCAAkC;IAClC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,gEAAgE;IAChE,WAAW,CAAC,EAAE,kBAAkB,CAAC;CACpC;AAID;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,wBAAwB,GAAG,kBAAkB,CA8D7F"}
@@ -76,6 +76,13 @@ export interface AparteClientOptions {
76
76
  * goes out as history without inventing a status for it.
77
77
  * - 'none' — sends only the current message
78
78
  * - function — custom: receives viewport messages, returns AparteChatMessage[]
79
+ *
80
+ * With 'viewport', a checkpoint (`AparteMessage.contextSummary`, written by
81
+ * `@aparte/plugin-compaction`) shortens what goes out: the summary, then the messages
82
+ * from the checkpoint on. A function receives the WHOLE transcript, checkpoint and
83
+ * everything before it — what to send is its call. To honour the checkpoint, pass
84
+ * the messages through `historyFromCheckpoint` and send its `summary` first.
85
+ * Retry and edit rebuild the history themselves and do not call this function.
79
86
  */
80
87
  history?: 'viewport' | 'none' | ((viewportMessages: AparteMessage[]) => AparteChatMessage[]);
81
88
  /**
@@ -195,6 +202,19 @@ export declare class AparteClient {
195
202
  private _boundEditHandler;
196
203
  private _releaseKeyResolver;
197
204
  private _isAborted;
205
+ /** Provider and model pairs whose window was already read again after a turn (see `_readWindowAfterTurn`). */
206
+ private readonly _windowReadFor;
207
+ /**
208
+ * The current model's window, read again once after a turn when it had none.
209
+ *
210
+ * A local server that loads a model on its first request — LM Studio's just-in-time
211
+ * loading, Ollama — has no loaded window to report when the model list is fetched at
212
+ * start-up, so the model comes without one, and the gauge and the compaction have
213
+ * nothing to measure against. After a reply the model is loaded, and the provider's
214
+ * own probe finds it. Once per provider and model: a server that never says costs one
215
+ * request, not one per turn. The config announces the window when it appears.
216
+ */
217
+ private _readWindowAfterTurn;
198
218
  /**
199
219
  * Does this window event belong to this client?
200
220
  *
@@ -324,24 +344,9 @@ export declare class AparteClient {
324
344
  * using the same conversation history minus the retried reply.
325
345
  */
326
346
  /**
327
- * The registered tools, unless the current model says it cannot call one.
328
- *
329
- * Single source for the gate, so send / retry / edit cannot drift.
330
- *
331
- * The question is "did this model say it cannot", not "did it say it can": the
332
- * app sets a model id by hand (`setModelConfig`) or a selector sets it from a
333
- * fetched list, and in both cases the model's declared capabilities are commonly
334
- * unknown. `undefined` capabilities read as "can", or `tools: []` would go on
335
- * the wire while `getTools()` held the tool the app had explicitly registered,
336
- * and the model would answer that it had no such tool. Registering a tool is an explicit act by the app; silently dropping it
337
- * because a `/models` listing is terse is the library second-guessing the
338
- * developer. A model that declares its capabilities and omits function calling
339
- * is still honoured — that is a statement, and it is respected.
340
- *
341
- * Failure modes, both ways round: over-sending means a model that cannot use
342
- * tools does not call one, or its own endpoint rejects the array with an error
343
- * the developer can read. Under-sending would be silent, total, and look like a
344
- * lying model.
347
+ * The registered tools, unless the current model says it cannot call one — the gate
348
+ * lives in `toolsForCurrentModel` (with its reasoning), where the context measure reads
349
+ * the same rule, so send / retry / edit and the gauge cannot drift.
345
350
  */
346
351
  private _toolsForCurrentModel;
347
352
  private _handleRetry;
@@ -359,6 +364,13 @@ export declare class AparteClient {
359
364
  * messages, then re-stream a fresh assistant response.
360
365
  */
361
366
  private _handleEdit;
367
+ /**
368
+ * These messages as the transcript holds them NOW. A retry or an edit slices the path
369
+ * before it streams; a compaction that runs during the turn writes its checkpoint onto
370
+ * one of those messages in the transcript, and the slice still holds the objects as they
371
+ * were. Looked up by id, tree-wide, because a retry has moved the path since.
372
+ */
373
+ private _current;
362
374
  /**
363
375
  * The chain the gesture really came up, nearest node first.
364
376
  *
@@ -427,16 +439,12 @@ export declare class AparteClient {
427
439
  */
428
440
  private _messagesToChatMessages;
429
441
  /**
430
- * The one rule for what a message contributes to the wire.
431
- *
432
- * Not the slice — the contribution: a role the wire has (`user`/`assistant`), a
433
- * turn that neither failed nor is still in flight, and text that is not empty.
434
- *
435
- * `_wireText` (not `m.content`): assistant replies stream their text into
436
- * `segments`, leaving `content` as '', so without flattening every reply would be
437
- * empty here and the drop below would swallow the whole transcript.
442
+ * What the model reads in place of everything before a checkpoint: the summary, as a
443
+ * `user` message under the same preamble a legacy compaction message gets, so it is
444
+ * context and not something the person said. It may sit right before a user turn;
445
+ * `mergeAdjacentUserMessages` joins the two where the history is assembled.
438
446
  */
439
- private _wireHistory;
447
+ private _summaryMessage;
440
448
  /** The "no model selected" warning is said once per client, not once per dropped send. */
441
449
  private _warnedNoModel;
442
450
  private _handleSend;
@@ -444,56 +452,7 @@ export declare class AparteClient {
444
452
  * Build the initial messages array, prepending system prompts and conversation history.
445
453
  */
446
454
  private _buildMessages;
447
- /**
448
- * A turn that has not finished yet. `status` is OPTIONAL on `AparteMessage`, so
449
- * the question the history gates can ask is "is this still in flight?", never
450
- * "is this completed?".
451
- *
452
- * The gates below ask the first, because a host that SEEDS a transcript
453
- * — restoring a saved conversation, hydrating a server-rendered one — has no
454
- * reason to invent a status for turns that are already over. Asking "is this
455
- * completed?" would leave the cutoff at 0 and slice away the whole transcript: the
456
- * model would get the new question with no context, and nothing in the UI would say
457
- * so, because the viewport still shows every message.
458
- */
459
- private static _inFlight;
460
455
  private _toHistoryMessages;
461
- /**
462
- * A message's text as the MODEL should read it — the one mapper both history
463
- * paths use, so the compaction preamble cannot be applied on retry and edit and
464
- * forgotten on the ordinary send, which is what the first review of this feature
465
- * caught: the summary went out on every normal turn as something the user said.
466
- */
467
- private _wireText;
468
- /**
469
- * What the model is told it said last turn — reconstructed from what was
470
- * RENDERED, not from the raw-text field.
471
- *
472
- * The segments are what the reader saw, so they come first. `content` is the
473
- * fallback, and that is not vestigial: a non-streaming transport writes the whole
474
- * reply there and creates no segments at all.
475
- */
476
- private _extractText;
477
- /**
478
- * Segments → the text a model can read back.
479
- *
480
- * Fences and the language tag are kept. Without them the model re-reads its own
481
- * code as prose — which is how it starts explaining a snippet it believes it
482
- * wrote in English.
483
- *
484
- * A type core does not know — a registered block grammar's (an artifact, a
485
- * citation, a file), a consumer's custom segment — follows one rule: its
486
- * `content` if it has one, else its `fallback`, else nothing. Dropping such a
487
- * segment would make a document the model had just produced invisible on the very
488
- * next turn, so it could not be asked to change the thing it had built. An artifact
489
- * is a plugin's type like any other and follows this rule.
490
- *
491
- * `thinking` and `tool_call` stay out on purpose — the first is the model's own
492
- * scratchpad, and most APIs neither want it back nor bill for it kindly; the
493
- * second is not text: `_wireHistory` sends a reply's calls as the assistant's
494
- * `toolCalls` and the `tool` messages answering them (`wire-history.ts`).
495
- */
496
- private _segmentsToText;
497
456
  /**
498
457
  * Which of the send's pending files get inlined into the request: the
499
458
  * `rawFileInject` mode first —
@@ -1 +1 @@
1
- {"version":3,"file":"aparte-client.d.ts","sourceRoot":"","sources":["../../src/client/aparte-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG9E,OAAO,KAAK,EAAE,sBAAsB,EAAkF,MAAM,gBAAgB,CAAC;AAM7I,OAAO,KAAK,EAAE,kBAAkB,EAA+C,MAAM,qBAAqB,CAAC;AAC3G,OAAO,KAAK,EAAoC,aAAa,EAA6C,MAAM,mBAAmB,CAAC;AAGpI,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAkC,MAAM,kBAAkB,CAAC;AA+CxG;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,0BAA0B,GAAG,sBAAsB,CAAC;AAahE;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC;IAEvJ;;;;;;;;;;;;;;;;OAgBG;IACH,gBAAgB,CAAC,EAAE,0BAA0B,CAAC;IAE9C;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAElC;;OAEG;IACH,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAEpG;;;;;;;;;OASG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,CAAC,CAAC,gBAAgB,EAAE,aAAa,EAAE,KAAK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,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC;CACxC;AAED,MAAM,WAAW,0BAA0B;IACvC,4DAA4D;IAC5D,MAAM,EAAE,mBAAmB,CAAC;IAC5B,kEAAkE;IAClE,MAAM,EAAE,YAAY,CAAC;IACrB,qEAAqE;IACrE,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,0BAA0B,GAAG,sBAAsB,CA6O5F;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACnC,MAAM,EAAE,cAAc,CAAC,iBAAiB,CAAC,EACzC,MAAM,EAAE,WAAW,GACpB,aAAa,CAAC,iBAAiB,CAAC,CAkClC"}
@@ -11,6 +11,27 @@
11
11
  * and a call that never finished — stopped, still pending — a fixed sentence saying so.
12
12
  */
13
13
  import type { AparteChatMessage, AparteMessage, AparteSegment, AparteToolCallSegment } from '../types/index.js';
14
+ /** What a compaction summary goes out under, so the model reads it as context and not as the user's words. */
15
+ export declare const COMPACTION_PREAMBLE = "The earlier part of this conversation was compacted. This is a summary of what came before; continue from it.";
16
+ /** A summary as the model reads it: the preamble, then the text. */
17
+ export declare const underPreamble: (text: string) => string;
18
+ /**
19
+ * Merge ADJACENT `user` messages into one, so the roles a model receives alternate.
20
+ *
21
+ * Strict chat templates (Gemma 2/3, Mistral, llama.cpp with `--jinja`, vLLM) reject two
22
+ * `user` turns in a row, and once one is in the history every following turn fails the
23
+ * same way. Two ordinary situations produce it: a compaction (the summary is a `user`
24
+ * message and the turns kept after it usually start with one), and a failed turn (its
25
+ * user message stays in the transcript, its error reply is not sent, and the user writes
26
+ * again).
27
+ *
28
+ * Only `user` is merged. A `system`, `assistant` or `tool` message carries structure
29
+ * (tool calls and the ids that answer them) that concatenating would destroy. Text joins
30
+ * with a blank line; parts concatenate with a text separator between them; a string
31
+ * beside parts becomes a text part, so an image keeps its place. A history that already
32
+ * alternates comes back as the same messages.
33
+ */
34
+ export declare function mergeAdjacentUserMessages(messages: AparteChatMessage[]): AparteChatMessage[];
14
35
  /** The answer a call that never finished gives the model. */
15
36
  export declare const STOPPED_TOOL_TEXT = "The tool call was stopped before it ran.";
16
37
  /** The answer a call that ran and returned nothing gives the model — not "stopped", or it tries again. */
@@ -29,4 +50,61 @@ export declare function wireTurns(message: AparteMessage, textOf: (segments: Apa
29
50
  */
30
51
  openDeferred?: boolean;
31
52
  }): AparteChatMessage[];
53
+ /**
54
+ * A turn that has not finished yet. `status` is OPTIONAL on `AparteMessage`, so
55
+ * the question the history gates can ask is "is this still in flight?", never
56
+ * "is this completed?".
57
+ *
58
+ * The gates ask the first, because a host that SEEDS a transcript
59
+ * — restoring a saved conversation, hydrating a server-rendered one — has no
60
+ * reason to invent a status for turns that are already over. Asking "is this
61
+ * completed?" would leave the cutoff at 0 and slice away the whole transcript: the
62
+ * model would get the new question with no context, and nothing in the UI would say
63
+ * so, because the viewport still shows every message.
64
+ */
65
+ export declare const isInFlight: (m: AparteMessage) => boolean;
66
+ /**
67
+ * Segments → the text a model can read back.
68
+ *
69
+ * Fences and the language tag are kept. Without them the model re-reads its own
70
+ * code as prose — which is how it starts explaining a snippet it believes it
71
+ * wrote in English.
72
+ *
73
+ * A type core does not know — a registered block grammar's (an artifact, a
74
+ * citation, a file), a consumer's custom segment — follows one rule: its
75
+ * `content` if it has one, else its `fallback`, else nothing. Dropping such a
76
+ * segment would make a document the model had just produced invisible on the very
77
+ * next turn, so it could not be asked to change the thing it had built. An artifact
78
+ * is a plugin's type like any other and follows this rule.
79
+ *
80
+ * `thinking` and `tool_call` stay out on purpose — the first is the model's own
81
+ * scratchpad, and most APIs neither want it back nor bill for it kindly; the
82
+ * second is not text: `wireMessages` sends a reply's calls as the assistant's
83
+ * `toolCalls` and the `tool` messages answering them (`wireTurns`).
84
+ */
85
+ export declare function segmentsToWireText(segments: AparteMessage['segments']): string;
86
+ /**
87
+ * A message's text as the MODEL should read it — the one mapper both history
88
+ * paths use, so the compaction preamble cannot be applied on retry and edit and
89
+ * forgotten on the ordinary send, which is what the first review of this feature
90
+ * caught: the summary went out on every normal turn as something the user said.
91
+ */
92
+ export declare function messageWireText(message: AparteMessage): string;
93
+ /**
94
+ * The one rule for what a list of messages contributes to the wire.
95
+ *
96
+ * Not the slice — the contribution: a role the wire has (`user`/`assistant`), a
97
+ * turn that neither failed nor is still in flight, and text that is not empty. A reply
98
+ * that called tools goes out as the calls and their answers, in the order it showed
99
+ * them (`wireTurns`); every other message keeps its one text, compaction preamble
100
+ * included.
101
+ *
102
+ * `messageWireText` (not `m.content`): assistant replies stream their text into
103
+ * `segments`, leaving `content` as '', so without flattening every reply would be
104
+ * empty here and the drop below would swallow the whole transcript.
105
+ *
106
+ * Pure, so the client that SENDS this history and the measure that ESTIMATES it
107
+ * (`estimateWireTokens`) read the same serialisation and cannot drift.
108
+ */
109
+ export declare function wireMessages(messages: AparteMessage[]): AparteChatMessage[];
32
110
  //# sourceMappingURL=wire-history.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wire-history.d.ts","sourceRoot":"","sources":["../../src/client/wire-history.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAEhH,6DAA6D;AAC7D,eAAO,MAAM,iBAAiB,6CAA6C,CAAC;AAE5E,0GAA0G;AAC1G,eAAO,MAAM,eAAe,iCAAiC,CAAC;AAU9D,gGAAgG;AAChG,eAAO,MAAM,cAAc,YAAa,aAAa,KAAG,OAAO,IAAI,qBAGkE,CAAC;AAEtI;;;;GAIG;AACH,wBAAgB,SAAS,CACrB,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,MAAM,EAC7C,OAAO,GAAE;IACL;;;OAGG;IACH,YAAY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AgB,YAAY,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,iBAAiB,EAAE,CAa3E"}
@@ -1,4 +1,4 @@
1
- import type { AparteSegment, AparteAttachment, AparteUsage, AparteMessage } from '../../types/index.js';
1
+ import type { AparteSegment, AparteAttachment, AparteUsage, AparteFinishReason, AparteMessage, AparteContextSummary } from '../../types/index.js';
2
2
  import { type AparteConfigAware } from '../../config/config-context.js';
3
3
  /**
4
4
  * One message: plain content or a list of rich segments, in light DOM.
@@ -53,6 +53,8 @@ import { type AparteConfigAware } from '../../config/config-context.js';
53
53
  * @attr {number | string} timestamp - Epoch milliseconds or a date string; a numeric string is read as milliseconds.
54
54
  * @attr {string} message-id - How streaming and the action bar address this bubble.
55
55
  * @attr {boolean} streaming - Hides the action bar and shows the caret while a reply is in flight.
56
+ * @attr {string} data-checkpoint - `pending` or `failed`: what a compaction is doing to this message, which it will carry as a checkpoint. The viewport and the framework host set it from `aparte-compact-start` / `-error` and take it off again; the bubble draws the separator's "Summarising the context…" or Retry from it. Read it, do not write it.
57
+ * @attr {string} data-checkpoint-reason - Why the compaction failed, beside `data-checkpoint="failed"`: the separator gives it as the failure's tooltip and to screen readers. Set and cleared with `data-checkpoint`; read it, do not write it.
56
58
  * @attr {string} name - Who wrote the message: shown in the header, and the message's accessible name ("Message from {name}"). Leave it out for the reader and the assistant, whose names come from the locale.
57
59
  *
58
60
  * @fires {CustomEvent<AparteActionEventDetail>} aparte-action - A custom action-bar button was pressed.
@@ -62,6 +64,8 @@ import { type AparteConfigAware } from '../../config/config-context.js';
62
64
  * @fires {CustomEvent<AparteMessageInfoEventDetail>} aparte-message-info - The info affordance was pressed.
63
65
  * @fires {CustomEvent<AparteBranchNavigateEventDetail>} aparte-branch-navigate - The `‹1/2›` picker moved between sibling versions.
64
66
  * @fires {CustomEvent<AparteAttachmentPreviewEventDetail>} aparte-attachment-preview - An attached image was clicked, asking the app to open it full-size.
67
+ * @fires {CustomEvent<AparteCompactEventDetail>} aparte-compact - Retry was pressed on a summary that failed: asks whatever answers compaction (`@aparte/plugin-compaction`) to try again for this chat. Dispatched on `window`.
68
+ * @fires {CustomEvent<AparteCompactDoneEventDetail>} aparte-compact-done - Restore was confirmed: every checkpoint was removed and the model reads the original messages again. `detail.restored` is `true`. Dispatched on `window`.
65
69
  * @fires {CustomEvent<AparteLinkClickEventDetail>} aparte-link-click - A link in the message body is about to be followed. Cancelable: `preventDefault()` keeps the browser from navigating, so a host can route the link itself.
66
70
  *
67
71
  * @cssprop [--aparte-message-gap=var(--aparte-space-6)] - Gap between the avatar column and the body (the viewport reuses it between messages).
@@ -164,6 +168,23 @@ export declare class AparteChatBubble extends HTMLElement implements AparteConfi
164
168
  private _role;
165
169
  private _attachments;
166
170
  private _usage;
171
+ private _finishReason;
172
+ /** The checkpoint this message carries: the separator above it is drawn from it. */
173
+ private _contextSummary;
174
+ /**
175
+ * This message is one an older compaction wrote (`compaction: true`), as the host told
176
+ * us. `null` until told: the `data-kind="compaction"` attribute the viewport and the
177
+ * wrappers stamp from the same flag answers meanwhile.
178
+ */
179
+ private _legacyCompaction;
180
+ /** The summary panel under the separator is open. Kept here, not in the DOM, because a redraw rebuilds the DOM. */
181
+ private _checkpointOpen;
182
+ /** Restore asked for confirmation and has not been answered. */
183
+ private _confirmingRestore;
184
+ /** What the separator was last drawn from, so a re-sync that changes nothing leaves it (and a focused button) alone. */
185
+ private _checkpointDrawn;
186
+ /** Names the separator's panel for `aria-controls`, unique on the page without needing a message id. */
187
+ private readonly _checkpointId;
167
188
  /** Cleanup returned by the avatar provider — called on disconnect/re-render. */
168
189
  private _avatarCleanup;
169
190
  /** Whether the avatar slot holds what a provider drew, which goes when the provider does. */
@@ -368,6 +389,29 @@ export declare class AparteChatBubble extends HTMLElement implements AparteConfi
368
389
  * there is nothing to show, so the button never renders either way.
369
390
  */
370
391
  setUsage(usage: AparteUsage | null | undefined): void;
392
+ /**
393
+ * Say why the model stopped writing this reply (assistant only).
394
+ *
395
+ * Only `'length'` draws anything: a quiet note after the content that the reply was cut
396
+ * off, because otherwise a truncated answer reads as a finished one. Every other reason
397
+ * is the ordinary end of a turn and says nothing. The note waits for the turn to settle.
398
+ */
399
+ setFinishReason(reason: AparteFinishReason | null | undefined): void;
400
+ /**
401
+ * Say that the messages before this one were summarised for the model, or that they no
402
+ * longer are (`null`).
403
+ *
404
+ * Draws, or removes, the separator above the message: "{n} messages summarised for the
405
+ * model", with Show summary and Restore. The separator sits OUTSIDE `.aparte-message`
406
+ * and inside this element, so it is not part of the message's frame and survives the
407
+ * frame being drawn again. `legacy: true` says the message is itself the summary an
408
+ * older compaction wrote (`compaction: true`): it is replaced by the separator, which
409
+ * then has no count and no Restore. Omit `legacy` to leave what the host last said (or
410
+ * the `data-kind="compaction"` attribute) in force.
411
+ */
412
+ setContextSummary(summary: AparteContextSummary | null | undefined, options?: {
413
+ legacy?: boolean;
414
+ }): void;
371
415
  /**
372
416
  * Update the branch picker UI for tree-based navigation.
373
417
  * The viewport calls this after a branch switch or re-render.
@@ -379,6 +423,48 @@ export declare class AparteChatBubble extends HTMLElement implements AparteConfi
379
423
  * Atomic update for the message
380
424
  */
381
425
  updateMessage(updates: Partial<AparteMessage>): void;
426
+ /**
427
+ * Draw, or remove, the note under a reply cut off at the model's length limit.
428
+ *
429
+ * Created here rather than in the shell markup: a custom shell written from the contract
430
+ * has no such region, and the note is only ever wanted next to the content it qualifies.
431
+ * A shell with no content region simply shows none (the same null-guarded degradation as
432
+ * the other regions).
433
+ */
434
+ private _updateFinishNote;
435
+ /** This message was written by an older compaction, as the host said or as its `data-kind` stamp says. */
436
+ private _isLegacyCompaction;
437
+ /**
438
+ * What the separator should say, or `null` for none. A compaction in progress or
439
+ * failed outranks what the message already carries: it is what is happening now.
440
+ */
441
+ private _checkpointKind;
442
+ /** The text the summary panel shows: the checkpoint's summary, or the older compaction message itself. */
443
+ private _checkpointSummaryText;
444
+ /**
445
+ * Draw the separator above the message, or take it off.
446
+ *
447
+ * Written into the light DOM as the FIRST child of the bubble, outside `.aparte-message`:
448
+ * a custom shell roots at that class and is free to be anything, and the separator is not
449
+ * its to carry. Drawn from `_render` (so every frame gets it) and from every setter that
450
+ * changes what it says. A re-sync that changes nothing — the framework host calls this on
451
+ * every render of every bubble — finds the same signature and the element in place and
452
+ * leaves both alone, so a keyboard user's focus and a scrolled summary are not lost to a
453
+ * rebuild; one that does change something rebuilds it and puts the focus back on the
454
+ * button that had it (or on `focus`, which a click that swaps the buttons names).
455
+ *
456
+ * A message an older compaction wrote is marked `data-superseded` on its own row: it
457
+ * stays in the DOM and does not paint (bubble.css), the separator speaking for it.
458
+ */
459
+ private _updateCheckpoint;
460
+ /**
461
+ * The separator's buttons. One delegated listener on the bubble, for the reason the branch
462
+ * picker has one: the separator is rebuilt on every change, and a listener per button would
463
+ * be lost with it.
464
+ */
465
+ private _onCheckpointClick;
466
+ /** Escape withdraws Restore's question, the way it closes every other inline prompt here. */
467
+ private _onCheckpointKeydown;
382
468
  private _appendSegmentEl;
383
469
  private _applySegmentUpdate;
384
470
  private _getDisplayName;
@@ -491,7 +577,7 @@ export declare class AparteChatBubble extends HTMLElement implements AparteConfi
491
577
  /**
492
578
  * What the copy action copies: the reply, not the reasoning. A `thinking` segment is
493
579
  * the model's scratchpad, and the client already keeps it out of the history it sends
494
- * back (`_segmentsToText`) for the same reason — copying it along with the answer
580
+ * back (`segmentsToWireText`) for the same reason — copying it along with the answer
495
581
  * pasted a paragraph of deliberation above every reply, which no assistant on the
496
582
  * market does. Segments with no `content` (a tool call) contribute nothing, so a
497
583
  * turn made only of those copies as `''` — and the action bar reads this to decide
@@ -1 +1 @@
1
- {"version":3,"file":"aparte-chat-bubble.d.ts","sourceRoot":"","sources":["../../../src/components/bubble/aparte-chat-bubble.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EACb,gBAAgB,EAQhB,WAAW,EACX,aAAa,EAId,MAAM,sBAAsB,CAAC;AAkB9B,OAAO,EAAgC,KAAK,iBAAiB,EAAE,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CAAC,gBAAgB;CA6CzB"}
@@ -1,4 +1,4 @@
1
- import type { AparteAttachment, AparteMessage, AparteSegment, AparteSiblingInfo, AparteUsage } from '../../types/index.js';
1
+ import type { AparteAttachment, AparteMessage, AparteSegment, AparteSiblingInfo, AparteUsage, AparteFinishReason, AparteContextSummary } from '../../types/index.js';
2
2
  /**
3
3
  * Minimal structural type representing the imperative slice of `AparteChatBubble`
4
4
  * needed to reconcile a message into a bubble. Declared loosely so framework
@@ -14,6 +14,10 @@ export interface SyncableBubble {
14
14
  setAttachments?: (attachments: AparteAttachment[]) => void;
15
15
  setSiblings?: (count: number, index: number) => void;
16
16
  setUsage?: (usage: AparteUsage | null | undefined) => void;
17
+ setFinishReason?: (reason: AparteFinishReason | null | undefined) => void;
18
+ setContextSummary?: (summary: AparteContextSummary | null | undefined, options?: {
19
+ legacy?: boolean;
20
+ }) => void;
17
21
  }
18
22
  /**
19
23
  * Reconcile a bubble element with a message and optional sibling metadata.
@@ -1 +1 @@
1
- {"version":3,"file":"bubble-sync.d.ts","sourceRoot":"","sources":["../../../src/components/bubble/bubble-sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,WAAW,EACd,MAAM,sBAAsB,CAAC;AAG9B;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC3B,WAAW,CAAC,EAAE,MAAM,aAAa,EAAE,CAAC;IACpC,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,IAAI,CAAC;IAClD,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;IAC7E,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,cAAc,CAAC,EAAE,CAAC,WAAW,EAAE,gBAAgB,EAAE,KAAK,IAAI,CAAC;IAC3D,WAAW,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S,KAAK,IAAI,CAAC;IAC1E,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI,GAAG,SAAS,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;CAClH;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,yBAAyB,CACrC,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,aAAa,EACtB,WAAW,CAAC,EAAE,iBAAiB,GAChC,IAAI,CAmDN"}
@@ -0,0 +1,40 @@
1
+ import type { AparteLocale } from '../../config/locale.js';
2
+ /** What the separator is saying: a summary written, an older one with no count, one being written, or one that failed. */
3
+ export type CheckpointKind = 'done' | 'legacy' | 'pending' | 'failed';
4
+ /** What {@link buildCheckpointSeparator} draws from. Plain data, so the bubble owns every decision. */
5
+ export interface CheckpointSeparatorOptions {
6
+ kind: CheckpointKind;
7
+ /** How many messages the summary stands for (`done` only). */
8
+ count?: number;
9
+ /** Why the summary could not be written (`failed` only). */
10
+ reason?: string;
11
+ /** The summary panel is open. */
12
+ open: boolean;
13
+ /** Restore asked "Send the original messages to the model again?" and waits for the answer. */
14
+ confirming: boolean;
15
+ /** The id the Show/Hide button points `aria-controls` at; unique on the page. */
16
+ summaryId: string;
17
+ locale: Partial<AparteLocale>;
18
+ }
19
+ /**
20
+ * The separator a bubble draws above the first message the model still reads verbatim.
21
+ *
22
+ * `<div role="group" aria-label>` holding a labelled divider (the hairline, the sentence,
23
+ * the actions) and, below it, the panel the summary opens into. The panel is built empty:
24
+ * the bubble fills it through the configured Markdown renderer when it is opened, because
25
+ * what the summary looks like is the same decision the bubble makes for its own content.
26
+ *
27
+ * - `done` "{n} messages summarised for the model", Show/Hide summary, Restore (or, once
28
+ * Restore was pressed, the question and its two answers in the actions' place).
29
+ * - `legacy` "Earlier messages were summarised": no count and no Restore — a message
30
+ * written by an older compaction replaced the turns, so there is nothing to
31
+ * restore them from.
32
+ * - `pending` "Summarising the context…" under the shimmer recipe, no actions.
33
+ * - `failed` "Couldn't summarise the context" and Retry; the reason is the sentence's
34
+ * `title` and, for a reader of the accessible tree, visually hidden text.
35
+ *
36
+ * Every string comes from the locale with the English default beside it, the way the rest
37
+ * of core reads its own: a locale written before these keys existed keeps working.
38
+ */
39
+ export declare function buildCheckpointSeparator(options: CheckpointSeparatorOptions): HTMLElement;
40
+ //# sourceMappingURL=checkpoint-separator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkpoint-separator.d.ts","sourceRoot":"","sources":["../../../src/components/bubble/checkpoint-separator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,0HAA0H;AAC1H,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEtE,uGAAuG;AACvG,MAAM,WAAW,0BAA0B;IACvC,IAAI,EAAE,cAAc,CAAC;IACrB,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iCAAiC;IACjC,IAAI,EAAE,OAAO,CAAC;IACd,+FAA+F;IAC/F,UAAU,EAAE,OAAO,CAAC;IACpB,iFAAiF;IACjF,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;CACjC;AAkBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,0BAA0B,GAAG,WAAW,CAuEzF"}