@aparte/core 0.15.0 → 0.16.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 (138) hide show
  1. package/dist/client/aparte-client.d.ts +53 -51
  2. package/dist/client/aparte-client.d.ts.map +1 -1
  3. package/dist/client/lifecycle-events.d.ts +0 -12
  4. package/dist/client/lifecycle-events.d.ts.map +1 -1
  5. package/dist/client/stream-adapter.d.ts +2 -12
  6. package/dist/client/stream-adapter.d.ts.map +1 -1
  7. package/dist/components/bubble/aparte-chat-bubble.d.ts +45 -1
  8. package/dist/components/bubble/aparte-chat-bubble.d.ts.map +1 -1
  9. package/dist/components/composer/aparte-composer-attachments.d.ts +0 -1
  10. package/dist/components/composer/aparte-composer-attachments.d.ts.map +1 -1
  11. package/dist/components/composer/aparte-composer-send.d.ts +11 -11
  12. package/dist/components/composer/aparte-composer-send.d.ts.map +1 -1
  13. package/dist/components/composer/aparte-composer.d.ts +20 -11
  14. package/dist/components/composer/aparte-composer.d.ts.map +1 -1
  15. package/dist/components/context/aparte-context.d.ts +31 -8
  16. package/dist/components/context/aparte-context.d.ts.map +1 -1
  17. package/dist/components/conversation-list/aparte-conversation-list.d.ts +93 -36
  18. package/dist/components/conversation-list/aparte-conversation-list.d.ts.map +1 -1
  19. package/dist/components/conversation-list/index.d.ts +1 -1
  20. package/dist/components/conversation-list/index.d.ts.map +1 -1
  21. package/dist/components/elicitation/aparte-elicitation.d.ts +19 -1
  22. package/dist/components/elicitation/aparte-elicitation.d.ts.map +1 -1
  23. package/dist/components/index.d.ts +7 -1
  24. package/dist/components/index.d.ts.map +1 -1
  25. package/dist/components/scroll-rail/aparte-scroll-rail.d.ts +105 -0
  26. package/dist/components/scroll-rail/aparte-scroll-rail.d.ts.map +1 -0
  27. package/dist/components/scroll-rail/index.d.ts +3 -0
  28. package/dist/components/scroll-rail/index.d.ts.map +1 -0
  29. package/dist/components/sidebar/aparte-sidebar.d.ts +186 -0
  30. package/dist/components/sidebar/aparte-sidebar.d.ts.map +1 -0
  31. package/dist/components/sidebar/index.d.ts +3 -0
  32. package/dist/components/sidebar/index.d.ts.map +1 -0
  33. package/dist/components/split/aparte-split.d.ts +354 -0
  34. package/dist/components/split/aparte-split.d.ts.map +1 -0
  35. package/dist/components/split/geometry.d.ts +65 -0
  36. package/dist/components/split/geometry.d.ts.map +1 -0
  37. package/dist/components/split/index.d.ts +3 -0
  38. package/dist/components/split/index.d.ts.map +1 -0
  39. package/dist/components/suggestions/aparte-suggestions.d.ts +7 -1
  40. package/dist/components/suggestions/aparte-suggestions.d.ts.map +1 -1
  41. package/dist/components/viewport/aparte-chat-viewport.d.ts +52 -2
  42. package/dist/components/viewport/aparte-chat-viewport.d.ts.map +1 -1
  43. package/dist/config/aparte-config.d.ts +95 -33
  44. package/dist/config/aparte-config.d.ts.map +1 -1
  45. package/dist/config/icon-provider.d.ts +6 -0
  46. package/dist/config/icon-provider.d.ts.map +1 -1
  47. package/dist/config/index.d.ts +2 -2
  48. package/dist/config/index.d.ts.map +1 -1
  49. package/dist/config/locale.d.ts +140 -27
  50. package/dist/config/locale.d.ts.map +1 -1
  51. package/dist/config/sanitize.d.ts +9 -0
  52. package/dist/config/sanitize.d.ts.map +1 -1
  53. package/dist/conversations/conversation-controller.d.ts +13 -1
  54. package/dist/conversations/conversation-controller.d.ts.map +1 -1
  55. package/dist/conversations/conversation-manager.d.ts +9 -0
  56. package/dist/conversations/conversation-manager.d.ts.map +1 -1
  57. package/dist/custom-elements.json +9838 -7333
  58. package/dist/{is-awaiting-reply-BZ_iJ3s3.js → dialog-triggers-CVCxqKg3.js} +718 -1182
  59. package/dist/dialog-triggers-CVCxqKg3.js.map +1 -0
  60. package/dist/elicitation/approval-panel.d.ts +1 -1
  61. package/dist/elicitation/approval-panel.d.ts.map +1 -1
  62. package/dist/elicitation/panel.d.ts +24 -16
  63. package/dist/elicitation/panel.d.ts.map +1 -1
  64. package/dist/elicitation/types.d.ts +31 -0
  65. package/dist/elicitation/types.d.ts.map +1 -1
  66. package/dist/generated/element-attributes.d.ts +47 -1
  67. package/dist/generated/element-attributes.d.ts.map +1 -1
  68. package/dist/{glyphs-B3BZ2TIb.js → glyphs-DQTeOj4w.js} +22 -13
  69. package/dist/{glyphs-B3BZ2TIb.js.map → glyphs-DQTeOj4w.js.map} +1 -1
  70. package/dist/host/aparte-chat-host.d.ts +10 -2
  71. package/dist/host/aparte-chat-host.d.ts.map +1 -1
  72. package/dist/icons/extended.d.ts +4 -2
  73. package/dist/icons/extended.d.ts.map +1 -1
  74. package/dist/icons/glyphs.d.ts +9 -0
  75. package/dist/icons/glyphs.d.ts.map +1 -1
  76. package/dist/icons.js +16 -15
  77. package/dist/icons.js.map +1 -1
  78. package/dist/index.css +1217 -396
  79. package/dist/index.d.ts +26 -15
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +2097 -295
  82. package/dist/index.js.map +1 -1
  83. package/dist/index.node.d.ts +21 -5
  84. package/dist/index.node.d.ts.map +1 -1
  85. package/dist/index.node.js +39 -34
  86. package/dist/index.node.js.map +1 -1
  87. package/dist/interop/dialog-triggers.d.ts +27 -0
  88. package/dist/interop/dialog-triggers.d.ts.map +1 -0
  89. package/dist/interop/element-props.d.ts +16 -8
  90. package/dist/interop/element-props.d.ts.map +1 -1
  91. package/dist/parsers/aparte-stream-parser.d.ts +52 -22
  92. package/dist/parsers/aparte-stream-parser.d.ts.map +1 -1
  93. package/dist/parsers/index.d.ts +1 -1
  94. package/dist/parsers/index.d.ts.map +1 -1
  95. package/dist/primitives/select/aparte-select.d.ts.map +1 -1
  96. package/dist/renderers/segment-renderers.d.ts.map +1 -1
  97. package/dist/renderers/segments/code.d.ts.map +1 -1
  98. package/dist/renderers/segments/tool-call.d.ts.map +1 -1
  99. package/dist/runtime/message-repository.d.ts.map +1 -1
  100. package/dist/transport/backend-handler.d.ts.map +1 -1
  101. package/dist/transport/backend-transport.d.ts +6 -1
  102. package/dist/transport/backend-transport.d.ts.map +1 -1
  103. package/dist/types/chat.d.ts +8 -14
  104. package/dist/types/chat.d.ts.map +1 -1
  105. package/dist/types/element-map.d.ts +54 -4
  106. package/dist/types/element-map.d.ts.map +1 -1
  107. package/dist/types/event-map.d.ts +16 -10
  108. package/dist/types/event-map.d.ts.map +1 -1
  109. package/dist/types/events.d.ts +59 -117
  110. package/dist/types/events.d.ts.map +1 -1
  111. package/dist/types/imperative-api.d.ts +3 -1
  112. package/dist/types/imperative-api.d.ts.map +1 -1
  113. package/dist/types/index.d.ts +5 -4
  114. package/dist/types/index.d.ts.map +1 -1
  115. package/dist/types/models.d.ts +11 -31
  116. package/dist/types/models.d.ts.map +1 -1
  117. package/dist/types/segments.d.ts +11 -47
  118. package/dist/types/segments.d.ts.map +1 -1
  119. package/dist/types/stream-blocks.d.ts +57 -0
  120. package/dist/types/stream-blocks.d.ts.map +1 -0
  121. package/dist/types/tools.d.ts +57 -0
  122. package/dist/types/tools.d.ts.map +1 -1
  123. package/dist/utils/copy-text.d.ts +24 -0
  124. package/dist/utils/copy-text.d.ts.map +1 -0
  125. package/dist/utils/css-escape.d.ts +5 -0
  126. package/dist/utils/css-escape.d.ts.map +1 -1
  127. package/dist/utils/tool-input.d.ts +20 -0
  128. package/dist/utils/tool-input.d.ts.map +1 -0
  129. package/package.json +10 -3
  130. package/dist/is-awaiting-reply-BZ_iJ3s3.js.map +0 -1
  131. package/dist/renderers/segments/artifact/binary-file.d.ts +0 -45
  132. package/dist/renderers/segments/artifact/binary-file.d.ts.map +0 -1
  133. package/dist/renderers/segments/artifact/card.d.ts +0 -3
  134. package/dist/renderers/segments/artifact/card.d.ts.map +0 -1
  135. package/dist/renderers/segments/artifact/preview-document.d.ts +0 -27
  136. package/dist/renderers/segments/artifact/preview-document.d.ts.map +0 -1
  137. package/dist/renderers/segments/artifact/shared.d.ts +0 -29
  138. package/dist/renderers/segments/artifact/shared.d.ts.map +0 -1
@@ -114,9 +114,8 @@ export interface AparteBubbleActionsConfig {
114
114
  * aparteGlobalConfig.setHostHandlers({ attachmentPreview: true }); // you open a lightbox
115
115
  * ```
116
116
  *
117
- * These are declarations, not callbacks: the events (`aparte-attachment-preview`,
118
- * `aparte-artifact-redownload`) are unchanged, and you keep
119
- * listening for them wherever you already do.
117
+ * These are declarations, not callbacks: the event (`aparte-attachment-preview`)
118
+ * is unchanged, and you keep listening for it wherever you already do.
120
119
  */
121
120
  export interface AparteHostHandlersConfig {
122
121
  /**
@@ -125,34 +124,6 @@ export interface AparteHostHandlersConfig {
125
124
  * tile is inert and is not signalled as a button. Default: false
126
125
  */
127
126
  attachmentPreview?: boolean;
128
- /**
129
- * The download button on a **binary** artifact, which asks the app to
130
- * re-generate the file (`aparte-artifact-redownload`). Text artifacts keep
131
- * their button: core writes those out itself. Default: false
132
- */
133
- artifactRedownload?: boolean;
134
- /**
135
- * Re-running the generation of a **persisted binary artifact** when a saved
136
- * conversation is re-opened (`aparte-artifact-ready`, dispatched from
137
- * `setup()` rather than from a stream). Default: false
138
- *
139
- * Why this is off unless declared, and why it is separate from
140
- * `artifactRedownload`: that flag guards a BUTTON, and a button is a request.
141
- * This guards an automatic dispatch on mount — nobody asked for it, and the
142
- * payload is model-authored content the receiving app is expected to run in a
143
- * sandbox. Reloading a conversation would therefore re-execute whatever a
144
- * prompt injection had persuaded the model to emit, on every reload, forever.
145
- *
146
- * Core cannot honour it end to end either: it owns no sandbox and no file
147
- * generator, so a dispatch with nothing listening leaves the card stuck at
148
- * "generating" — the same reasoning that made the artifact preview require a
149
- * click. Declare it when your app really does listen for
150
- * `aparte-artifact-ready` and can regenerate the file safely.
151
- *
152
- * Not affected: the dispatch at the END of a live stream, which follows a turn
153
- * the user asked for. This flag is only about mount-time rehydration.
154
- */
155
- artifactRehydrate?: boolean;
156
127
  }
157
128
  /**
158
129
  * Core message structure for the chat
@@ -183,6 +154,15 @@ export interface AparteMessage {
183
154
  attachments?: AparteAttachment[];
184
155
  /** Token usage + timing reported by the provider for assistant messages. */
185
156
  usage?: import('./chat.js').AparteUsage;
157
+ /**
158
+ * This message is the summary `@aparte/plugin-compaction` injected in place of the
159
+ * turns it summarised (a host that summarises by other means sets the flag too). Its role is `user` — the summary is context handed to the
160
+ * model, and a `system` message mid-conversation is refused by some providers —
161
+ * but it is not something the user said: the viewport renders it as a notice
162
+ * (`data-kind="compaction"` on the bubble: centred, no avatar, no actions) and
163
+ * the history sends it under a fixed preamble saying what it is.
164
+ */
165
+ compaction?: true;
186
166
  /**
187
167
  * Alternative responses generated by retrying.
188
168
  *
@@ -1 +1 @@
1
- {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/types/models.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAMnD;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,WAAW,GAAG,OAAO,GAAG,SAAS,CAAC;AAMhG,mDAAmD;AACnD,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,WAAW,CAAC;AAMpD;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC7B,2CAA2C;IAC3C,EAAE,EAAE,MAAM,CAAC;IAEX,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IAEb,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IAEb,+CAA+C;IAC/C,GAAG,EAAE,MAAM,CAAC;IAEZ,kCAAkC;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,0CAA0C;IAC1C,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEnC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,IAAI,CAAC;CACf;AAUD;;;;;;;;GAQG;AACH,MAAM,WAAW,mBAAmB;IAChC,wCAAwC;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,kCAAkC;IACl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AW,CAAC,EAAE,MAAM,CAAC;IAErB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,+BAA+B;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB"}
@@ -176,11 +176,14 @@ export interface AparteToolCallSegment extends AparteSegmentBase {
176
176
  type: 'tool_call';
177
177
  toolCall: import('./tools.js').AparteToolCall;
178
178
  /**
179
- * `awaiting-approval` — paused for a human decision (needsApproval tools);
180
- * `rejected` — the human declined to run it.
179
+ * `awaiting-approval` — paused for a human decision; `rejected` — the human (or a
180
+ * policy) declined to run it; `aborted` — stopped, timed out, or nothing could run
181
+ * it; `failed` — the handler threw, and `result` carries the crash's one line.
181
182
  */
182
- status: 'pending' | 'resolved' | 'aborted' | 'awaiting-approval' | 'rejected';
183
+ status: 'pending' | 'resolved' | 'aborted' | 'awaiting-approval' | 'rejected' | 'failed';
183
184
  result?: string;
185
+ /** The handler's `structuredContent`, when it returned one — the value behind `result`'s prose. */
186
+ structuredResult?: unknown;
184
187
  }
185
188
  /**
186
189
  * Custom segment - for framework-specific views (Onboarding, Tools, etc.)
@@ -206,51 +209,12 @@ export interface AparteCustomSegment extends AparteSegmentBase {
206
209
  fallback?: string;
207
210
  }
208
211
  /**
209
- * Artifact segment a structured payload (React/HTML/SVG/JS/CSS, etc.) embedded in the
210
- * assistant's reply. The payload is delimited in the stream by `<artifact type="...">…</artifact>`.
211
- *
212
- * The core only models the data and emits lifecycle events (`aparte-artifact-start|delta|ready`).
213
- * Apps decide how to render the rich preview (typically a side panel with an iframe/code view).
214
- *
215
- * `mimeType` follows standard MIME conventions, with the Anthropic vendor namespace for
216
- * framework-specific kinds:
217
- * - `application/vnd.ant.react` (or `application/vnd.ant.html`, etc.)
218
- * - `text/html`, `text/css`, `application/javascript`
219
- * - `image/svg+xml`
220
- *
221
- * @example
222
- * {
223
- * id: 's1',
224
- * type: 'artifact',
225
- * mimeType: 'image/svg+xml',
226
- * artifactType: 'svg',
227
- * title: 'Brass mark',
228
- * content: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><circle cx="24" cy="24" r="18" fill="#d9a24b"/></svg>',
229
- * }
212
+ * All built-in segment types. An `artifact` is not one of them any more: it is a
213
+ * convention an app teaches its model, and `@aparte/plugin-artifacts` registers its
214
+ * segment — a `type` of its own, through `registerSegmentRenderer` and
215
+ * `registerStreamBlock` the way any consumer registers a `chart` or a `citation`.
230
216
  */
231
- export interface AparteArtifactSegment extends AparteSegmentBase {
232
- type: 'artifact';
233
- /** Standard MIME type (verbatim from the `type="…"` attribute on the opening tag) */
234
- mimeType: string;
235
- /**
236
- * Short kind identifier derived from `mimeType` (e.g. 'react', 'html', 'svg').
237
- * Convenience for UIs that want to switch on a stable enum-like string.
238
- */
239
- artifactType: string;
240
- /** Optional human title (from the `title="…"` attribute on the opening tag) */
241
- title?: string;
242
- /** Body content between the opening and closing tag — accumulates while streaming. */
243
- content: string;
244
- /**
245
- * When true, the renderer displays the artifact inline as a code block
246
- * instead of a clickable pill that opens the side panel.
247
- * Set by the client after the stream ends, based on content line count.
248
- * Defaults to false (pill) while streaming.
249
- */
250
- inline?: boolean;
251
- }
252
- /** All built-in segment types */
253
- export type AparteSegment = AparteTextSegment | AparteThinkingSegment | AparteCodeSegment | AparteErrorSegment | AparteCustomSegment | AparteToolCallSegment | AparteArtifactSegment;
217
+ export type AparteSegment = AparteTextSegment | AparteThinkingSegment | AparteCodeSegment | AparteErrorSegment | AparteCustomSegment | AparteToolCallSegment;
254
218
  /** Segment type discriminator values */
255
219
  export type AparteSegmentType = AparteSegment['type'];
256
220
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"segments.d.ts","sourceRoot":"","sources":["../../src/types/segments.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,wDAAwD;AACxD,MAAM,WAAW,iBAAiB;IAC9B,gCAAgC;IAChC,EAAE,EAAE,MAAM,CAAC;IAEX,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IAEb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EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC;IAEhD;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,OAAO,CAAC,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC;IAEjD;;;OAGG;IACH,OAAO,CAAC,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;CACxC;AAMD,6DAA6D;AAC7D,MAAM,WAAW,8BAA8B;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Stream blocks — a tagged block the stream parser learns from a consumer.
3
+ *
4
+ * Models write conventions into their prose: `<think>…</think>` for reasoning,
5
+ * `<artifact type="…">…</artifact>` for a document, `<file path="…">` for a patch,
6
+ * `<tool_call>` for a model without function calling, `<cite>` for a source. Every one
7
+ * is the same shape — an opening tag with attributes, a body that streams, a closing
8
+ * tag — and until this seam existed each one was a branch hard-wired into the parser,
9
+ * which is how the artifact ended up in core while being an app convention.
10
+ *
11
+ * A block is registered on the config (`registerStreamBlock`) and read by the
12
+ * parser the stream adapter builds; the parser does the streaming work once for all
13
+ * of them — the earliest opening tag wins the race against a code fence and a
14
+ * reasoning delimiter, a tag cut at a chunk boundary is held back, attributes are
15
+ * parsed whether quoted or bare, deltas accumulate into the segment's `content`,
16
+ * and the segment is closed at the closing tag or at `finalize()`.
17
+ *
18
+ * @packageDocumentation
19
+ */
20
+ import type { AparteSegmentBase } from './segments.js';
21
+ /** What the parser hands to {@link AparteStreamBlock.toSegment} when a block opens. */
22
+ export interface AparteStreamBlockMatch {
23
+ /**
24
+ * The opening tag's attributes, as written: `type="text/html"`, `title='Notes'`
25
+ * and `lang=fr` all parse; the values are verbatim, never trimmed or decoded.
26
+ * The model wrote them — treat them as untrusted, like every segment field.
27
+ */
28
+ attrs: Record<string, string>;
29
+ /** The id the parser generated for the segment (its usual prefix + uuid). */
30
+ id: string;
31
+ }
32
+ /**
33
+ * A block grammar: the tag, and the segment its body becomes.
34
+ *
35
+ * The parser owns everything after {@link toSegment} returns: it appends each delta
36
+ * to `segment.content`, sets `isStreaming` while the block is open and clears it at
37
+ * `</tag>` (or at the end of the stream). So the segment MUST carry a `content`
38
+ * string — the one field core touches — and the rest of its shape is yours:
39
+ * a `type` of your own, registered with `registerSegmentRenderer`, or a built-in
40
+ * one if the block is merely another way of spelling it.
41
+ */
42
+ export interface AparteStreamBlock {
43
+ /**
44
+ * The tag name without brackets: `artifact` recognises `<artifact …>` … `</artifact>`.
45
+ * Matched exactly and case-sensitively, and only as a whole name — `<artifacts>`
46
+ * does not open an `artifact` block. Letters, digits, `-` and `_`.
47
+ */
48
+ tag: string;
49
+ /**
50
+ * Build the segment at the opening tag, with an empty `content`. Called once per
51
+ * block; the parser fills the body in afterwards.
52
+ */
53
+ toSegment: (match: AparteStreamBlockMatch) => AparteSegmentBase & {
54
+ content: string;
55
+ };
56
+ }
57
+ //# sourceMappingURL=stream-blocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream-blocks.d.ts","sourceRoot":"","sources":["../../src/types/stream-blocks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,uFAAuF;AACvF,MAAM,WAAW,sBAAsB;IACnC;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,6EAA6E;IAC7E,EAAE,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB;IAC9B;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,SAAS,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,iBAAiB,GAAG;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACzF"}
@@ -63,10 +63,44 @@ export interface AparteToolCall {
63
63
  name: string;
64
64
  input: Record<string, unknown>;
65
65
  }
66
+ /**
67
+ * What an approval policy says about one call.
68
+ *
69
+ * `allow` runs it without asking; `ask` puts it to the person the way a
70
+ * `needsApproval` tool is put to them; `deny` refuses it on the spot, and `reason` is
71
+ * the sentence the model reads about that refusal — verbatim, because nobody said
72
+ * anything ("Plan mode: `write_file` changes files; only read-only tools run.").
73
+ */
74
+ export interface AparteApprovalRuling {
75
+ verdict: 'allow' | 'ask' | 'deny';
76
+ reason?: string;
77
+ }
78
+ /**
79
+ * Decides, per CALL, whether a tool runs, asks, or is refused.
80
+ *
81
+ * A tool's own `needsApproval` is a declaration about the tool; a policy is a decision
82
+ * about the call — the same `run_command` can be a read (`ls`) or an execution, and a
83
+ * mode ("plan": read-only, "auto": never ask) is a policy the host switches, not a
84
+ * flag on twenty definitions. Registered with `setApprovalPolicy()`; the client's
85
+ * default approval channel consults it before asking. Return `undefined` to have no
86
+ * opinion, in which case the tool's `needsApproval` decides as before.
87
+ *
88
+ * Pure and synchronous: it is evaluated once to decide whether the call pauses at all
89
+ * (so an allowed call never flashes "awaiting approval") and once to answer.
90
+ */
91
+ export type AparteApprovalPolicy = (call: AparteToolCall, tool: AparteTool | undefined) => AparteApprovalRuling | undefined;
66
92
  /** Result returned after a tool handler resolves */
67
93
  export interface AparteToolResult {
68
94
  toolCallId: string;
95
+ /** What the model reads. */
69
96
  content: string;
97
+ /**
98
+ * The same result as a value, for a renderer or the host — MCP's name for exactly
99
+ * this field, beside `content`. Optional and additive: a handler that returns prose
100
+ * alone behaves as before, and the model never sees this. It lands on the
101
+ * transcript's segment as `AparteToolCallSegment.structuredResult`.
102
+ */
103
+ structuredContent?: unknown;
70
104
  }
71
105
  /**
72
106
  * Handler function for a registered tool.
@@ -138,10 +172,33 @@ export interface AparteToolRenderer {
138
172
  *
139
173
  * Return an empty string to render nothing (e.g. a UI-only tool like
140
174
  * `ask_user`).
175
+ *
176
+ * The root you return is the segment's element in the bubble: core stamps
177
+ * `data-segment-id="<segment.id>"` on it if you did not, so an update to the
178
+ * call (its result landing, an approval decision) is patched into that element
179
+ * rather than rebuilding every segment of the bubble — a rebuild destroys a
180
+ * mounted artifact preview, collapses an opened reasoning block and drops the
181
+ * focus. Keep your markup's root a single element for that reason.
141
182
  */
142
183
  render: (segment: AparteToolCallSegment) => string | HTMLElement;
143
184
  /** Optional DOM setup (event listeners etc.) called after HTML is injected */
144
185
  setup?: (element: HTMLElement, segment: AparteToolCallSegment) => void;
186
+ /**
187
+ * Patch the element in place when the call changes — its result landing, an
188
+ * approval decided, a `failed` status. Without it core rebuilds your markup from
189
+ * `render()` on every change, which is right for a receipt and wrong for anything
190
+ * with state: a mounted preview, an opened disclosure, a focused control are all
191
+ * lost in a rebuild. Same contract as `AparteSegmentRenderer.update`: never
192
+ * re-render, never touch what the reader opened.
193
+ */
194
+ update?: (element: HTMLElement, segment: AparteToolCallSegment) => void;
195
+ /**
196
+ * Re-read the locale and the icon provider without touching the DOM shape —
197
+ * called on every config change (`setLocale`, `setIconProvider`, `reset()`), for
198
+ * as long as the element is on the page. Add or remove no child node; replace
199
+ * text and glyphs only.
200
+ */
201
+ relabel?: (element: HTMLElement, segment: AparteToolCallSegment) => void;
145
202
  /** Optional CSS to inject once into document.head */
146
203
  getStyles?: () => string;
147
204
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/types/tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE3D,2CAA2C;AAC3C,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;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IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,4BAA4B;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAC5B,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE,WAAW,EACnB,OAAO,CAAC,EAAE,iBAAiB,KAC1B,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAE/B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,iBAAiB;IAC9B;;;;OAIG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IAC/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,MAAM,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,MAAM,GAAG,WAAW,CAAC;IACjE,8EAA8E;IAC9E,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACvE;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACxE;;;;;OAKG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACzE,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,MAAM,CAAC;CAC5B"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copy text to the clipboard, in every context the library actually runs in.
3
+ *
4
+ * `navigator.clipboard` is **secure-context only** — the same wall `uuid.ts` documents
5
+ * for `crypto.randomUUID`. On `http://192.168.1.x`, the archetypal deployment for this
6
+ * library's own audience, the property is `undefined`, so
7
+ * `navigator.clipboard.writeText(text)` throws a TypeError synchronously — before any
8
+ * `.catch()` can see it. The three copy buttons core renders (the bubble's action bar, a
9
+ * code block, the artifact card) each had a `.catch()` for a REJECTED write and nothing
10
+ * for a missing API: on plain http they threw in the click handler and gave no feedback
11
+ * at all, not even a failed one.
12
+ *
13
+ * The fallback is `document.execCommand('copy')` — deprecated, but every engine still
14
+ * honours it from a user gesture and it needs no secure context. The text goes into an
15
+ * off-screen textarea, is selected, copied, and the textarea is removed; focus is handed
16
+ * back to where it was, so a keyboard user does not lose their place on the button. It is
17
+ * the path clipboard.js and copy-to-clipboard take, for the same reason.
18
+ *
19
+ * Rejects when neither path could copy, so a caller's "copied" confirmation can stay
20
+ * honest. `pnpm check:secure-context` refuses a bare `navigator.clipboard` anywhere but
21
+ * here, so the sweep cannot come undone one call site at a time.
22
+ */
23
+ export declare function copyText(text: string): Promise<void>;
24
+ //# sourceMappingURL=copy-text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy-text.d.ts","sourceRoot":"","sources":["../../src/utils/copy-text.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgCpD"}
@@ -10,6 +10,11 @@
10
10
  * defense-in-depth: a hostile, stream-supplied id containing `"` (e.g. a tool-call
11
11
  * id) can no longer break out of the selector into a `SyntaxError` or a
12
12
  * selector-list that mis-targets another element.
13
+ *
14
+ * A raw newline (or CR / form feed) is not allowed inside a CSS string either — it
15
+ * ends the string and the selector throws the same `SyntaxError`. Escaped as its
16
+ * code point followed by a space, the form the CSS Syntax spec gives for exactly
17
+ * this (`\a `), so an id a provider minted with a line break still matches.
13
18
  */
14
19
  export declare function cssEscape(value: string): string;
15
20
  //# sourceMappingURL=css-escape.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"css-escape.d.ts","sourceRoot":"","sources":["../../src/utils/css-escape.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/C"}
1
+ {"version":3,"file":"css-escape.d.ts","sourceRoot":"","sources":["../../src/utils/css-escape.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAI/C"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * A tool call's arguments, as text — one implementation, two surfaces.
3
+ *
4
+ * The transcript row and the approval panel both show the arguments the model chose,
5
+ * and they must show the SAME text: the row is the anchor that says a call is waiting,
6
+ * the panel is where the person decides. Two renderings of one value drift, and here
7
+ * the drift would be a person approving a call they read differently from the one that
8
+ * runs. So it is a function in `utils/`, not a copy in each renderer.
9
+ *
10
+ * Pretty-printed JSON, because that is what the model actually sent and what every
11
+ * reference implementation shows — a prose summary would be core inventing a reading
12
+ * of arguments it knows nothing about. `JSON.stringify` can throw on a cyclic value,
13
+ * which a tool input should never be but a hand-built segment can be, so a failure
14
+ * degrades to no input rather than to a broken bubble.
15
+ *
16
+ * The return is TEXT and never markup: both call sites put it on screen through
17
+ * `textContent` or an escaped interpolation, because the arguments are model-authored.
18
+ */
19
+ export declare function describeToolInput(input: unknown): string;
20
+ //# sourceMappingURL=tool-input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-input.d.ts","sourceRoot":"","sources":["../../src/utils/tool-input.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAOxD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aparte/core",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "AI chat in Web Components, with the agent loop inside — zero third-party dependencies",
5
5
  "type": "module",
6
6
  "//sideEffects": "The BROWSER entry defines the custom elements and imports CSS at module scope, so it must never be tree-shaken; the Node entry (`index.node`) and every other module are pure. Listing them explicitly is what lets a bundler drop the rest — the whole package was implicitly side-effectful before, the only one of the 14 without this field.",
@@ -13,7 +13,7 @@
13
13
  "module": "./dist/index.js",
14
14
  "types": "./dist/index.d.ts",
15
15
  "customElements": "dist/custom-elements.json",
16
- "//exports": "READ THE ORDER: `@aparte-workspace/source` comes FIRST, but it only resolves for tooling configured with that custom condition (this repo's docs dev server + tsconfig.base). It is NOT what a consumer gets. Node resolves the `node` condition -> `dist/index.node.js`, the DOM-free entry; a bundler/browser gets `dist/index.js`. Reading `src/index.ts` because it sits at the top of this map means reading the BROWSER entry and concluding, wrongly, that the package needs a DOM in Node.",
16
+ "//exports": "READ THE ORDER: `@aparte-workspace/source` comes FIRST, but it only resolves for tooling configured with that custom condition (this repo's docs dev server + tsconfig.base). It is NOT what a consumer gets. Node resolves the `node` condition -> `dist/index.node.js`, the DOM-free entry; a bundler/browser gets `dist/index.js`. Reading `src/index.ts` because it sits at the top of this map means reading the BROWSER entry and concluding, wrongly, that the package needs a DOM in Node. `./browser` is the browser entry BY NAME, and the `.` map must keep resolving `node` first -- that is what makes `import @aparte/core` safe in Next.js, Nuxt, SvelteKit and Angular Universal. A test runner, though, is Node WITH a DOM (vitest + jsdom resolves the `node` condition), so it got the DOM-free entry, no <aparte-*> element upgraded, and there was no supported specifier to escape to: every wrapper in this repo had to alias @aparte/core at ../../core/src/index.ts, reaching into another package source. `./browser` is that specifier; do NOT reorder `.` instead. `./package.json` is exported because require.resolve(@aparte/core/package.json) throws without it, which is how a test config computes the path of a package it wants to alias.",
17
17
  "exports": {
18
18
  ".": {
19
19
  "@aparte-workspace/source": "./src/index.ts",
@@ -25,6 +25,13 @@
25
25
  "import": "./dist/index.js",
26
26
  "default": "./dist/index.js"
27
27
  },
28
+ "./browser": {
29
+ "@aparte-workspace/source": "./src/index.ts",
30
+ "types": "./dist/index.d.ts",
31
+ "import": "./dist/index.js",
32
+ "default": "./dist/index.js"
33
+ },
34
+ "./package.json": "./package.json",
28
35
  "./icons": {
29
36
  "@aparte-workspace/source": "./src/icons.ts",
30
37
  "types": "./dist/icons.d.ts",
@@ -45,7 +52,7 @@
45
52
  "node": ">=18"
46
53
  },
47
54
  "dependencies": {
48
- "@aparte/engine": "0.15.0"
55
+ "@aparte/engine": "0.16.0"
49
56
  },
50
57
  "devDependencies": {
51
58
  "@custom-elements-manifest/analyzer": "^0.11.0",