@aparte/core 0.2.0-alpha.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 (175) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +53 -0
  3. package/dist/client/aparte-client.d.ts +326 -0
  4. package/dist/client/aparte-client.d.ts.map +1 -0
  5. package/dist/client/stream-adapter.d.ts +197 -0
  6. package/dist/client/stream-adapter.d.ts.map +1 -0
  7. package/dist/components/bubble/aparte-chat-bubble.d.ts +153 -0
  8. package/dist/components/bubble/aparte-chat-bubble.d.ts.map +1 -0
  9. package/dist/components/bubble/bubble-sync.d.ts +44 -0
  10. package/dist/components/bubble/bubble-sync.d.ts.map +1 -0
  11. package/dist/components/bubble/index.d.ts +4 -0
  12. package/dist/components/bubble/index.d.ts.map +1 -0
  13. package/dist/components/chat/aparte-chat.d.ts +49 -0
  14. package/dist/components/chat/aparte-chat.d.ts.map +1 -0
  15. package/dist/components/chat/index.d.ts +2 -0
  16. package/dist/components/chat/index.d.ts.map +1 -0
  17. package/dist/components/composer/aparte-composer-action.d.ts +37 -0
  18. package/dist/components/composer/aparte-composer-action.d.ts.map +1 -0
  19. package/dist/components/composer/aparte-composer-add-attachment.d.ts +27 -0
  20. package/dist/components/composer/aparte-composer-add-attachment.d.ts.map +1 -0
  21. package/dist/components/composer/aparte-composer-attachments.d.ts +26 -0
  22. package/dist/components/composer/aparte-composer-attachments.d.ts.map +1 -0
  23. package/dist/components/composer/aparte-composer-cancel.d.ts +21 -0
  24. package/dist/components/composer/aparte-composer-cancel.d.ts.map +1 -0
  25. package/dist/components/composer/aparte-composer-input.d.ts +63 -0
  26. package/dist/components/composer/aparte-composer-input.d.ts.map +1 -0
  27. package/dist/components/composer/aparte-composer-send.d.ts +25 -0
  28. package/dist/components/composer/aparte-composer-send.d.ts.map +1 -0
  29. package/dist/components/composer/aparte-composer.d.ts +150 -0
  30. package/dist/components/composer/aparte-composer.d.ts.map +1 -0
  31. package/dist/components/composer/index.d.ts +9 -0
  32. package/dist/components/composer/index.d.ts.map +1 -0
  33. package/dist/components/conversation-list/aparte-conversation-list.d.ts +50 -0
  34. package/dist/components/conversation-list/aparte-conversation-list.d.ts.map +1 -0
  35. package/dist/components/conversation-list/index.d.ts +2 -0
  36. package/dist/components/conversation-list/index.d.ts.map +1 -0
  37. package/dist/components/elicitation/aparte-elicitation.d.ts +29 -0
  38. package/dist/components/elicitation/aparte-elicitation.d.ts.map +1 -0
  39. package/dist/components/index.d.ts +10 -0
  40. package/dist/components/index.d.ts.map +1 -0
  41. package/dist/components/status/aparte-chat-status.d.ts +34 -0
  42. package/dist/components/status/aparte-chat-status.d.ts.map +1 -0
  43. package/dist/components/status/index.d.ts +2 -0
  44. package/dist/components/status/index.d.ts.map +1 -0
  45. package/dist/components/viewport/aparte-chat-viewport.d.ts +358 -0
  46. package/dist/components/viewport/aparte-chat-viewport.d.ts.map +1 -0
  47. package/dist/components/viewport/index.d.ts +2 -0
  48. package/dist/components/viewport/index.d.ts.map +1 -0
  49. package/dist/config/action-provider.d.ts +59 -0
  50. package/dist/config/action-provider.d.ts.map +1 -0
  51. package/dist/config/aparte-config.d.ts +490 -0
  52. package/dist/config/aparte-config.d.ts.map +1 -0
  53. package/dist/config/attachment-renderer.d.ts +28 -0
  54. package/dist/config/attachment-renderer.d.ts.map +1 -0
  55. package/dist/config/avatar-provider.d.ts +35 -0
  56. package/dist/config/avatar-provider.d.ts.map +1 -0
  57. package/dist/config/bubble-shell-renderer.d.ts +41 -0
  58. package/dist/config/bubble-shell-renderer.d.ts.map +1 -0
  59. package/dist/config/config-context.d.ts +47 -0
  60. package/dist/config/config-context.d.ts.map +1 -0
  61. package/dist/config/error-renderer.d.ts +26 -0
  62. package/dist/config/error-renderer.d.ts.map +1 -0
  63. package/dist/config/icon-provider.d.ts +63 -0
  64. package/dist/config/icon-provider.d.ts.map +1 -0
  65. package/dist/config/index.d.ts +19 -0
  66. package/dist/config/index.d.ts.map +1 -0
  67. package/dist/config/locale.d.ts +60 -0
  68. package/dist/config/locale.d.ts.map +1 -0
  69. package/dist/config/sanitize.d.ts +31 -0
  70. package/dist/config/sanitize.d.ts.map +1 -0
  71. package/dist/config/sibling-nav-renderer.d.ts +27 -0
  72. package/dist/config/sibling-nav-renderer.d.ts.map +1 -0
  73. package/dist/config/skeleton-provider.d.ts +26 -0
  74. package/dist/config/skeleton-provider.d.ts.map +1 -0
  75. package/dist/config/status-renderer.d.ts +23 -0
  76. package/dist/config/status-renderer.d.ts.map +1 -0
  77. package/dist/conversations/conversation-controller.d.ts +126 -0
  78. package/dist/conversations/conversation-controller.d.ts.map +1 -0
  79. package/dist/conversations/conversation-manager.d.ts +98 -0
  80. package/dist/conversations/conversation-manager.d.ts.map +1 -0
  81. package/dist/conversations/index.d.ts +5 -0
  82. package/dist/conversations/index.d.ts.map +1 -0
  83. package/dist/conversations/types.d.ts +172 -0
  84. package/dist/conversations/types.d.ts.map +1 -0
  85. package/dist/custom-elements.json +15833 -0
  86. package/dist/elicitation/index.d.ts +20 -0
  87. package/dist/elicitation/index.d.ts.map +1 -0
  88. package/dist/elicitation/panel.d.ts +18 -0
  89. package/dist/elicitation/panel.d.ts.map +1 -0
  90. package/dist/elicitation/types.d.ts +98 -0
  91. package/dist/elicitation/types.d.ts.map +1 -0
  92. package/dist/host/aparte-chat-host.d.ts +176 -0
  93. package/dist/host/aparte-chat-host.d.ts.map +1 -0
  94. package/dist/host/index.d.ts +2 -0
  95. package/dist/host/index.d.ts.map +1 -0
  96. package/dist/index-D89k-n2Q.js +6294 -0
  97. package/dist/index-D89k-n2Q.js.map +1 -0
  98. package/dist/index.css +2554 -0
  99. package/dist/index.d.ts +62 -0
  100. package/dist/index.d.ts.map +1 -0
  101. package/dist/index.js +3763 -0
  102. package/dist/index.js.map +1 -0
  103. package/dist/index.node.d.ts +53 -0
  104. package/dist/index.node.d.ts.map +1 -0
  105. package/dist/index.node.js +49 -0
  106. package/dist/index.node.js.map +1 -0
  107. package/dist/interop/element-props.d.ts +23 -0
  108. package/dist/interop/element-props.d.ts.map +1 -0
  109. package/dist/parsers/aparte-event-stream.d.ts +13 -0
  110. package/dist/parsers/aparte-event-stream.d.ts.map +1 -0
  111. package/dist/parsers/aparte-stream-parser.d.ts +137 -0
  112. package/dist/parsers/aparte-stream-parser.d.ts.map +1 -0
  113. package/dist/parsers/index.d.ts +4 -0
  114. package/dist/parsers/index.d.ts.map +1 -0
  115. package/dist/primitives/index.d.ts +8 -0
  116. package/dist/primitives/index.d.ts.map +1 -0
  117. package/dist/primitives/progress-spinner/aparte-progress-spinner.d.ts +25 -0
  118. package/dist/primitives/progress-spinner/aparte-progress-spinner.d.ts.map +1 -0
  119. package/dist/primitives/progress-spinner/index.d.ts +2 -0
  120. package/dist/primitives/progress-spinner/index.d.ts.map +1 -0
  121. package/dist/primitives/select/aparte-optgroup.d.ts +32 -0
  122. package/dist/primitives/select/aparte-optgroup.d.ts.map +1 -0
  123. package/dist/primitives/select/aparte-option.d.ts +30 -0
  124. package/dist/primitives/select/aparte-option.d.ts.map +1 -0
  125. package/dist/primitives/select/aparte-select.d.ts +74 -0
  126. package/dist/primitives/select/aparte-select.d.ts.map +1 -0
  127. package/dist/primitives/select/index.d.ts +9 -0
  128. package/dist/primitives/select/index.d.ts.map +1 -0
  129. package/dist/renderers/index.d.ts +5 -0
  130. package/dist/renderers/index.d.ts.map +1 -0
  131. package/dist/renderers/segment-renderers.d.ts +31 -0
  132. package/dist/renderers/segment-renderers.d.ts.map +1 -0
  133. package/dist/runtime/message-repository.d.ts +111 -0
  134. package/dist/runtime/message-repository.d.ts.map +1 -0
  135. package/dist/transport/backend-handler.d.ts +50 -0
  136. package/dist/transport/backend-handler.d.ts.map +1 -0
  137. package/dist/transport/backend-transport.d.ts +39 -0
  138. package/dist/transport/backend-transport.d.ts.map +1 -0
  139. package/dist/transport/direct-transport.d.ts +36 -0
  140. package/dist/transport/direct-transport.d.ts.map +1 -0
  141. package/dist/transport/index.d.ts +6 -0
  142. package/dist/transport/index.d.ts.map +1 -0
  143. package/dist/transport/types.d.ts +73 -0
  144. package/dist/transport/types.d.ts.map +1 -0
  145. package/dist/types/chat.d.ts +223 -0
  146. package/dist/types/chat.d.ts.map +1 -0
  147. package/dist/types/errors.d.ts +25 -0
  148. package/dist/types/errors.d.ts.map +1 -0
  149. package/dist/types/event-map.d.ts +41 -0
  150. package/dist/types/event-map.d.ts.map +1 -0
  151. package/dist/types/events.d.ts +290 -0
  152. package/dist/types/events.d.ts.map +1 -0
  153. package/dist/types/imperative-api.d.ts +38 -0
  154. package/dist/types/imperative-api.d.ts.map +1 -0
  155. package/dist/types/index.d.ts +22 -0
  156. package/dist/types/index.d.ts.map +1 -0
  157. package/dist/types/model-provider.d.ts +229 -0
  158. package/dist/types/model-provider.d.ts.map +1 -0
  159. package/dist/types/models.d.ts +173 -0
  160. package/dist/types/models.d.ts.map +1 -0
  161. package/dist/types/parsers.d.ts +42 -0
  162. package/dist/types/parsers.d.ts.map +1 -0
  163. package/dist/types/providers.d.ts +93 -0
  164. package/dist/types/providers.d.ts.map +1 -0
  165. package/dist/types/segments.d.ts +221 -0
  166. package/dist/types/segments.d.ts.map +1 -0
  167. package/dist/types/theming.d.ts +44 -0
  168. package/dist/types/theming.d.ts.map +1 -0
  169. package/dist/types/tools.d.ts +98 -0
  170. package/dist/types/tools.d.ts.map +1 -0
  171. package/dist/utils/assert-never.d.ts +9 -0
  172. package/dist/utils/assert-never.d.ts.map +1 -0
  173. package/dist/utils/css-escape.d.ts +15 -0
  174. package/dist/utils/css-escape.d.ts.map +1 -0
  175. package/package.json +68 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-map.d.ts","sourceRoot":"","sources":["../../src/types/event-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACR,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,4BAA4B,EAC5B,+BAA+B,EAC/B,yBAAyB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,EAAE,CAAC"}
@@ -0,0 +1,290 @@
1
+ /**
2
+ * Aparte Events
3
+ * Event interfaces for component communication and control
4
+ */
5
+ import type { AparteStatus, AparteMessage } from './models.js';
6
+ import type { AparteUsage } from './chat.js';
7
+ /**
8
+ * Detail payload for aparte-send custom event
9
+ * Emitted when user sends a message via the input component
10
+ */
11
+ export interface AparteSendEventDetail {
12
+ /** The message content being sent */
13
+ content: string;
14
+ /** Timestamp of the send action */
15
+ timestamp: number;
16
+ /**
17
+ * ID of the host element (e.g. aparte-chat) that should receive the response.
18
+ * Set automatically when the input has a `target` attribute.
19
+ * Used by AparteClient to find the host without DOM traversal.
20
+ */
21
+ targetId?: string;
22
+ /** Files attached to this message (populated by composer attachments) */
23
+ files?: File[];
24
+ }
25
+ /**
26
+ * Detail payload for aparte-token custom event
27
+ * Emitted during streaming when a new token is appended
28
+ */
29
+ export interface AparteTokenEventDetail {
30
+ /** Message ID receiving the token */
31
+ messageId: string;
32
+ /** Token chunk content */
33
+ chunk: string;
34
+ }
35
+ /**
36
+ * Control event for external packages to pilot the Core
37
+ * Allows packages like API adapters or plugins to update message states
38
+ * without direct coupling to the core implementation
39
+ */
40
+ export interface AparteControlEvent {
41
+ /** Target message ID for the control action */
42
+ messageId: string;
43
+ /** New status to apply to the message */
44
+ status: AparteStatus;
45
+ /**
46
+ * Optional metadata for arbitrary context
47
+ * Examples: response time, tokens/sec, error details
48
+ */
49
+ metadata?: Record<string, unknown>;
50
+ }
51
+ /**
52
+ * Event detail for message lifecycle changes
53
+ * Emitted when a message is added, updated, or removed
54
+ */
55
+ export interface AparteMessageEventDetail {
56
+ /** The message that changed */
57
+ messageId: string;
58
+ /** Type of lifecycle event */
59
+ type: 'added' | 'updated' | 'removed' | 'completed';
60
+ /** Optional additional context */
61
+ metadata?: Record<string, unknown>;
62
+ }
63
+ /**
64
+ * Event detail for status changes
65
+ * Emitted when the global or message status changes
66
+ */
67
+ export interface AparteStatusEventDetail {
68
+ /** Previous status */
69
+ previousStatus: AparteStatus;
70
+ /** New status */
71
+ currentStatus: AparteStatus;
72
+ /** Optional message ID if status is message-specific */
73
+ messageId?: string;
74
+ }
75
+ /**
76
+ * Event detail for model selection changes
77
+ * Emitted when user selects a different provider or model
78
+ *
79
+ * @event aparte-model-change
80
+ */
81
+ /**
82
+ * Emitted when a message response completes (aparte-message-done).
83
+ * Carries token usage when the provider reports it.
84
+ */
85
+ export interface AparteMessageDoneEventDetail {
86
+ messageId: string;
87
+ role: string;
88
+ /** Token usage for the completed response, if reported by the provider. */
89
+ usage?: AparteUsage;
90
+ }
91
+ export interface AparteModelChangeEventDetail {
92
+ /** Selected provider ID (e.g., 'openrouter', 'gemini') */
93
+ providerId?: string;
94
+ /** Selected model ID (e.g., 'gpt-4-turbo', 'claude-3-opus') */
95
+ modelId: string;
96
+ /** Previous model ID if changed */
97
+ previousModelId?: string;
98
+ /** Previous provider ID if changed */
99
+ previousProviderId?: string;
100
+ }
101
+ /**
102
+ * Per-message sibling metadata carried by `aparte-path-changed`.
103
+ * `index` is 0-based; UI renders it as `index + 1 / count`.
104
+ */
105
+ export interface AparteSiblingInfo {
106
+ /** Message id */
107
+ id: string;
108
+ /** Total number of siblings (including this one). 1 = no branch picker. */
109
+ count: number;
110
+ /** 0-based position of this message among its siblings. */
111
+ index: number;
112
+ }
113
+ /**
114
+ * Detail payload for `aparte-branch-navigate`.
115
+ * Dispatched by the bubble's branch-picker buttons; the viewport listens
116
+ * (bubbling) and calls `navigateBranch(messageId, direction)` on its repo.
117
+ *
118
+ * @event aparte-branch-navigate
119
+ */
120
+ export interface AparteBranchNavigateEventDetail {
121
+ /** Message id whose siblings should be navigated */
122
+ messageId: string;
123
+ /** 'prev' = move to previous sibling, 'next' = move to next sibling */
124
+ direction: 'prev' | 'next';
125
+ }
126
+ /**
127
+ * Detail payload for `aparte-path-changed`.
128
+ * Dispatched by the viewport in framework-managed mode after the active
129
+ * path of the conversation tree changes (sibling switch, retry, edit, etc.).
130
+ * Consumers (Angular wrapper) reconcile their signal/state from this payload.
131
+ *
132
+ * @event aparte-path-changed
133
+ */
134
+ export interface ApartePathChangedEventDetail {
135
+ /** Messages on the new active path, root → head. */
136
+ messages: AparteMessage[];
137
+ /** Sibling metadata, one entry per message on the path. */
138
+ siblings: AparteSiblingInfo[];
139
+ }
140
+ /**
141
+ * Detail payload for `aparte-retry`.
142
+ * Dispatched by the assistant bubble's "Retry" action. Picked up by the
143
+ * AparteClient, which calls `addSiblingOf` on the target viewport and streams
144
+ * a fresh response into the new sibling.
145
+ *
146
+ * @event aparte-retry
147
+ */
148
+ export interface AparteRetryEventDetail {
149
+ /** Message id of the assistant response being retried (its sibling will be created). */
150
+ messageId: string;
151
+ /** Optional id of the host element (aparte-chat) — used by `scopeToTargetId`. */
152
+ targetId?: string;
153
+ }
154
+ /**
155
+ * Detail payload for `aparte-artifact-start`.
156
+ * Dispatched by the stream loop the moment an opening `<artifact …>` tag is parsed.
157
+ * Apps typically use this to open a side panel and prepare a streaming code view.
158
+ *
159
+ * @event aparte-artifact-start
160
+ */
161
+ export interface AparteArtifactStartEventDetail {
162
+ /** Owning message id */
163
+ messageId: string;
164
+ /** Owning segment id (matches the segment dispatched to the bubble) */
165
+ segmentId: string;
166
+ /** Standard MIME from the `type=` attribute (e.g. `application/vnd.ant.react`) */
167
+ mimeType: string;
168
+ /** Convenience kind ('react'|'html'|'svg'|'js'|'css'|…) derived from `mimeType` */
169
+ artifactType: string;
170
+ /** Optional human title from the `title=` attribute */
171
+ title?: string;
172
+ }
173
+ /**
174
+ * Detail payload for `aparte-artifact-delta`.
175
+ * Dispatched once per chunk routed into an open artifact body.
176
+ * Consumers append to the displayed buffer in real time.
177
+ *
178
+ * @event aparte-artifact-delta
179
+ */
180
+ export interface AparteArtifactDeltaEventDetail {
181
+ /** Owning segment id */
182
+ segmentId: string;
183
+ /** New content fragment to append */
184
+ chunk: string;
185
+ }
186
+ /**
187
+ * Detail payload for `aparte-artifact-ready`.
188
+ * Dispatched when the closing `</artifact>` tag is parsed (or the stream ends with
189
+ * an active artifact segment). The full content is now available; consumers can
190
+ * switch from streaming view to a final preview.
191
+ *
192
+ * @event aparte-artifact-ready
193
+ */
194
+ export interface AparteArtifactReadyEventDetail {
195
+ /** Owning message id */
196
+ messageId: string;
197
+ /** Owning segment id */
198
+ segmentId: string;
199
+ /** MIME type */
200
+ mimeType: string;
201
+ /** Convenience kind */
202
+ artifactType: string;
203
+ /** Optional title */
204
+ title?: string;
205
+ /** Final, complete content */
206
+ content: string;
207
+ }
208
+ /**
209
+ * Detail payload for `aparte-artifact-open`.
210
+ * Dispatched by the artifact pill when a user clicks it (e.g. on a persisted
211
+ * conversation reload). Apps use this to re-open the preview panel for an
212
+ * already-completed artifact.
213
+ *
214
+ * @event aparte-artifact-open
215
+ */
216
+ export interface AparteArtifactOpenEventDetail {
217
+ /** Owning segment id */
218
+ segmentId: string;
219
+ /** MIME type */
220
+ mimeType: string;
221
+ /** Convenience kind */
222
+ artifactType: string;
223
+ /** Optional title */
224
+ title?: string;
225
+ /** Complete content */
226
+ content: string;
227
+ }
228
+ /**
229
+ * Detail payload for `aparte-edit`.
230
+ * Dispatched by the user bubble after the user confirms an inline edit.
231
+ * Picked up by the AparteClient, which truncates the existing responses to
232
+ * this message and re-streams a new one.
233
+ *
234
+ * @event aparte-edit
235
+ */
236
+ export interface AparteEditEventDetail {
237
+ /** Message id of the user message being edited. */
238
+ messageId: string;
239
+ /** New content submitted by the user. */
240
+ content: string;
241
+ /** Optional id of the host element (aparte-chat) — used by `scopeToTargetId`. */
242
+ targetId?: string;
243
+ }
244
+ /**
245
+ * Detail payload for `aparte-feedback`.
246
+ * Dispatched by the assistant bubble's thumbs-up / thumbs-down buttons.
247
+ *
248
+ * @event aparte-feedback
249
+ */
250
+ export interface AparteFeedbackEventDetail {
251
+ /** Message id receiving the feedback. */
252
+ messageId: string;
253
+ /** 'positive' for thumbs-up, 'negative' for thumbs-down. */
254
+ value: 'positive' | 'negative';
255
+ }
256
+ /**
257
+ * Detail payload for `aparte-action`.
258
+ * Dispatched by a custom action button (registered via `AparteConfig.registerAction`)
259
+ * in either the composer or a message-bubble toolbar. Apps listen (bubbling) and
260
+ * dispatch on `actionId`. Mirrors the built-in bubble events (retry/feedback) so
261
+ * custom actions are wired the same way in every framework and in vanilla.
262
+ *
263
+ * @event aparte-action
264
+ */
265
+ export interface AparteActionEventDetail {
266
+ /** The registered action's id (from `AparteAction.id`). */
267
+ actionId: string;
268
+ /** Which zone the action was clicked in. */
269
+ zone: 'composer' | 'bubble';
270
+ /** Message id of the bubble the action was clicked on (bubble zone only). */
271
+ messageId?: string;
272
+ /** Role of that bubble (bubble zone only). */
273
+ role?: 'user' | 'assistant';
274
+ /** Optional host element id (aparte-chat) — same use as retry/edit's targetId. */
275
+ targetId?: string;
276
+ }
277
+ /**
278
+ * Detail payload for `aparte-message-info`.
279
+ * Dispatched by the assistant bubble's info ("i") action button. Apps
280
+ * listen (bubbling) and present a stats popover for the completed response.
281
+ *
282
+ * @event aparte-message-info
283
+ */
284
+ export interface AparteMessageInfoEventDetail {
285
+ /** Message id whose stats should be shown. */
286
+ messageId: string;
287
+ /** Token usage + timing for the message, when available. */
288
+ usage?: AparteUsage;
289
+ }
290
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAM7C;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IAClC,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;IAEhB,mCAAmC;IACnC,SAAS,EAAE,MAAM,CAAC;IAElB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,yEAAyE;IACzE,KAAK,CAAC,EAAE,IAAI,EAAE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,0 +1,38 @@
1
+ import type { AparteMessage } from './models.js';
2
+ import type { AparteSegment } from './segments.js';
3
+ /**
4
+ * The canonical imperative surface a framework `<AparteChat>` exposes (React's
5
+ * ref handle, Vue/Svelte's instance, Angular's component). All four delegate to
6
+ * the framework-agnostic `AparteChatHost`, so this ONE contract is the single
7
+ * source of truth, and each wrapper enforces it against the compiler — React via
8
+ * the ref-handle type on a return-annotated `useImperativeHandle`, Angular via
9
+ * `implements`, Vue via `satisfies` on `defineExpose`, Svelte via a type-checked
10
+ * parity factory — so a missing or mistyped method is a build error in that
11
+ * wrapper, not a silent divergence.
12
+ */
13
+ export interface AparteChatImperativeApi {
14
+ appendMessage: (message: AparteMessage) => void;
15
+ updateMessage: (messageId: string, updates: Partial<AparteMessage>) => void;
16
+ updateLastMessage: (content: string, options?: {
17
+ append?: boolean;
18
+ }) => void;
19
+ addSegment: (segment: AparteSegment) => void;
20
+ updateSegment: (segmentId: string, updates: Partial<AparteSegment>) => void;
21
+ removeSegment: (segmentId: string) => void;
22
+ appendToSegment: (segmentId: string, content: string) => void;
23
+ getMessages: () => AparteMessage[];
24
+ clearMessages: () => void;
25
+ addBranch: (messageId: string) => number;
26
+ addSiblingOf: (existingId: string, message: AparteMessage) => string | null;
27
+ truncateFrom: (messageId: string) => void;
28
+ truncateResponsesAfter: (userMessageId: string) => void;
29
+ injectTokenStream: (messageId: string, tokens: AsyncIterable<string>) => Promise<void>;
30
+ stopTokenStream: () => void;
31
+ setConversationId: (id: string | null) => Promise<void>;
32
+ scrollToBottom: () => void;
33
+ focusInput: () => void;
34
+ isStreaming: () => boolean;
35
+ /** The `<aparte-chat-viewport>` element — same `getViewport()` on all four wrappers. */
36
+ getViewport: () => HTMLElement | null;
37
+ }
38
+ //# sourceMappingURL=imperative-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imperative-api.d.ts","sourceRoot":"","sources":["../../src/types/imperative-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAA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AE,MAAM,IAAI,CAAC;IAE5B,iBAAiB,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAExD,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,WAAW,EAAE,MAAM,OAAO,CAAC;IAC3B,wFAAwF;IACxF,WAAW,EAAE,MAAM,WAAW,GAAG,IAAI,CAAC;CACzC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Aparte Type Definitions
3
+ *
4
+ * Zero-dependency conversation engine types
5
+ * All interfaces are generic and technology-agnostic
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ export type { AparteStatus, AparteBubbleRole, AparteAttachment, AparteMessage, AparteMessageBranch, AparteBubbleActionsConfig, AparteBubbleActionName, AparteViewportConfig, AparteInputConfig } from './models.js';
10
+ export type { AparteSendEventDetail, AparteTokenEventDetail, AparteControlEvent, AparteMessageEventDetail, AparteStatusEventDetail, AparteSiblingInfo, AparteBranchNavigateEventDetail, ApartePathChangedEventDetail, AparteRetryEventDetail, AparteEditEventDetail, AparteFeedbackEventDetail, AparteActionEventDetail } from './events.js';
11
+ export type { AparteContentParser, AparteParserRegistry } from './parsers.js';
12
+ export type { AparteSegmentBase, AparteTextSegment, AparteThinkingSegment, AparteCodeSegment, AparteDiffSegment, AparteDiffHunk, AparteDiffLine, AparteTerminalSegment, AparteFileTreeSegment, AparteFileNode, AparteImageSegment, ApartePreviewSegment, AparteErrorSegment, AparteProgressSegment, AparteSegment, AparteCustomSegment, AparteToolCallSegment, AparteArtifactSegment, AparteSegmentType, AparteSegmentRenderer, AparteSegmentActionEvent, AparteSegmentUpdateEvent } from './segments.js';
13
+ export type { AparteDataProvider, AparteStreamProvider, AparteMessageStore, AparteControlHandler } from './providers.js';
14
+ export type { AparteThemeVariables } from './theming.js';
15
+ export type { AparteAIModel, AparteAIProvider, AparteAIProviderConfigField, AparteAIProviderConfigSchema, AparteModelConfig, ModelStatus, ModelLoadProgress } from './model-provider.js';
16
+ export type { AparteChatRequest, AparteChatResponse, AparteChatMessage, AparteContentPart, AparteTextPart, AparteImagePart, AparteFilePart, AparteStreamEvent, AparteStreamEventMap, AparteUsage } from './chat.js';
17
+ export { contentToText } from './chat.js';
18
+ export type { AparteTool, AparteToolCall, AparteToolResult, AparteToolHandler, AparteToolRenderer, AparteToolDecisionDetail, AparteToolApprovalRequestDetail, AparteToolActionDetail } from './tools.js';
19
+ export { AparteErrorCode, AparteError } from './errors.js';
20
+ export type { AparteModelChangeEventDetail, AparteMessageDoneEventDetail, AparteMessageInfoEventDetail, AparteArtifactStartEventDetail, AparteArtifactDeltaEventDetail, AparteArtifactReadyEventDetail, AparteArtifactOpenEventDetail } from './events.js';
21
+ export type { AparteChatImperativeApi } from './imperative-api.js';
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,YAAY,EACR,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,yBAAyB,EACzB,sBAAsB,EACtB,oBAAoB,EACpB,iBAAiB,EACpB,MAAM,aAAa,CAAC;AAMrB,YAAY,EACR,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,EACvB,iBAAiB,EACjB,+BAA+B,EAC/B,4BAA4B,EAC5B,sBAAsB,EACtB,qBAAqB,EACrB,yBAAyB,EACzB,uBAAuB,EAC1B,MAAM,aAAa,CAAC;AAMrB,YAAY,EACR,mBAAmB,EACnB,oBAAoB,EACvB,MAAM,cAAc,CAAC;AAMtB,YAAY,EACR,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,wBAAwB,EACxB,wBAAwB,EAC3B,MAAM,eAAe,CAAC;AAMvB,YAAY,EACR,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACvB,MAAM,gBAAgB,CAAC;AAMxB,YAAY,EACR,oBAAoB,EACvB,MAAM,cAAc,CAAC;AAMtB,YAAY,EACR,aAAa,EACb,gBAAgB,EAChB,2BAA2B,EAC3B,4BAA4B,EAC5B,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACpB,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EACR,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,WAAW,EACd,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,YAAY,EACR,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,wBAAwB,EACxB,+BAA+B,EAC/B,sBAAsB,EACzB,MAAM,YAAY,CAAC;AAMpB,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE3D,YAAY,EACR,4BAA4B,EAC5B,4BAA4B,EAC5B,4BAA4B,EAC5B,8BAA8B,EAC9B,8BAA8B,EAC9B,8BAA8B,EAC9B,6BAA6B,EAChC,MAAM,aAAa,CAAC;AAGrB,YAAY,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,229 @@
1
+ /**
2
+ * Aparte AI Model Provider Types
3
+ *
4
+ * Interfaces for AI provider and model management.
5
+ * These types enable the BYORK (Bring Your Own Key) pattern,
6
+ * allowing users to plug in their preferred AI providers.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ import { AparteChatRequest, AparteChatResponse, AparteStreamEvent } from './chat.js';
11
+ /**
12
+ * Represents an AI model that can be selected by the user.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const model: AparteAIModel = {
17
+ * id: 'gpt-4-turbo',
18
+ * name: 'GPT-4 Turbo',
19
+ * contextWindow: 128000,
20
+ * capabilities: ['vision', 'function_calling', 'streaming']
21
+ * };
22
+ * ```
23
+ */
24
+ export interface AparteAIModel {
25
+ /** Unique identifier for the model (e.g., 'gpt-4-turbo', 'claude-3-opus') */
26
+ id: string;
27
+ /** Human-readable display name */
28
+ name: string;
29
+ /** Optional context window size in tokens */
30
+ contextWindow?: number;
31
+ /** Optional pricing information (per 1M tokens) */
32
+ pricing?: {
33
+ input: number;
34
+ output: number;
35
+ };
36
+ /** Optional capability flags */
37
+ capabilities?: ('vision' | 'function_calling' | 'streaming' | 'code' | 'reasoning')[];
38
+ /** Optional short description shown in model pickers */
39
+ description?: string;
40
+ /** Optional metadata for custom properties */
41
+ metadata?: Record<string, unknown>;
42
+ }
43
+ /**
44
+ * Availability status of a model, as reported by the provider.
45
+ *
46
+ * Provider-agnostic: Transformers.js checks the Cache API,
47
+ * Ollama checks pulled models, LM Studio checks VRAM, etc.
48
+ */
49
+ export type ModelStatus = 'ready' | 'cached' | 'not-downloaded';
50
+ /**
51
+ * Progress update emitted during model preparation (download + load).
52
+ * Passed to the `onProgress` callback of `AparteAIProvider.prepareModel()`.
53
+ */
54
+ export interface ModelLoadProgress {
55
+ /** Current phase of the preparation */
56
+ status: 'downloading' | 'loading' | 'cached' | 'ready' | 'error';
57
+ /** File currently being processed (e.g. "model.safetensors") */
58
+ file?: string;
59
+ /** Progress percentage 0–100 */
60
+ progress?: number;
61
+ /** Optional human-readable message */
62
+ message?: string;
63
+ }
64
+ /**
65
+ * Brand metadata for an AI provider, used for visual selection and onboarding.
66
+ */
67
+ export interface AparteAIProviderMetadata {
68
+ /** Human-readable display name */
69
+ name: string;
70
+ /** Provider ID */
71
+ id: string;
72
+ /**
73
+ * Brand icon.
74
+ * Can be an SVG string, a data URI, or a key for AparteIconProvider.
75
+ */
76
+ icon?: string;
77
+ /** Brand primary color (hex or CSS variable) */
78
+ color?: string;
79
+ /** Short tag line or description */
80
+ description?: string;
81
+ /** Whether the provider offers free models or Tiers */
82
+ hasFreeModels?: boolean;
83
+ /** Whether the provider runs locally on the user machine */
84
+ isLocal?: boolean;
85
+ /** URL to the provider's API key management page or documentation */
86
+ helpUrl?: string;
87
+ /** Configuration schema for the onboarding UI */
88
+ configSchema?: AparteAIProviderConfigSchema;
89
+ }
90
+ /**
91
+ * Definition of a configuration field for the provider
92
+ */
93
+ export interface AparteAIProviderConfigField {
94
+ /** Unique identifier for the field (e.g., 'apiKey', 'endpoint') */
95
+ id: string;
96
+ /** Basic type for the input field */
97
+ type: 'text' | 'password' | 'url';
98
+ /** Human readable label (e.g., 'API Key', 'Sever URL') */
99
+ label: string;
100
+ /** Placeholder hint */
101
+ placeholder?: string;
102
+ /** Initial value */
103
+ defaultValue?: string;
104
+ /** Whether the field is mandatory to start */
105
+ required?: boolean;
106
+ /** If true, the field is hidden behind an 'Advanced' toggle in UI */
107
+ isAdvanced?: boolean;
108
+ }
109
+ /**
110
+ * Encapsulates all configuration fields for a provider
111
+ */
112
+ export interface AparteAIProviderConfigSchema {
113
+ fields: AparteAIProviderConfigField[];
114
+ }
115
+ /**
116
+ * Represents an AI provider (e.g., OpenRouter, OpenAI, Anthropic).
117
+ *
118
+ * Providers can return a static list of models or fetch them dynamically.
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * const provider: AparteAIProvider = {
123
+ * id: 'openrouter',
124
+ * getMetadata: () => ({
125
+ * name: 'OpenRouter',
126
+ * id: 'openrouter',
127
+ * icon: '<svg>...</svg>',
128
+ * color: '#000000',
129
+ * helpUrl: 'https://openrouter.ai/keys'
130
+ * }),
131
+ * getModels: () => [...]
132
+ * };
133
+ * ```
134
+ */
135
+ export interface AparteAIProvider {
136
+ /** Unique identifier for the provider */
137
+ id: string;
138
+ /**
139
+ * Returns brand metadata for UI rendering.
140
+ */
141
+ getMetadata(): AparteAIProviderMetadata;
142
+ /**
143
+ * Returns the list of available models.
144
+ * Can be synchronous (static list) or async (API fetch).
145
+ */
146
+ getModels(): AparteAIModel[] | Promise<AparteAIModel[]>;
147
+ /**
148
+ * Optional: Fetch models dynamically from an API.
149
+ * Useful for providers like OpenRouter that have evolving model lists.
150
+ *
151
+ * @param config - Optional API key or full configuration object for authenticated requests
152
+ */
153
+ fetchModels?(config?: string | Record<string, string>): Promise<AparteAIModel[]>;
154
+ /**
155
+ * Execute a chat request directly. **Optional** — HTTP providers expose the
156
+ * format-adapter surface below and are driven by an `AparteTransport` instead;
157
+ * providers that own their own I/O (Transformers.js locally, or a bridge
158
+ * wrapping an external SDK) implement `chat`, to which `DirectTransport`
159
+ * delegates.
160
+ *
161
+ * @param request - The chat request options (messages, model, etc.)
162
+ * @param config - Optional API key or full configuration object
163
+ * @param ctx - Transport context (structurally mirrors `AparteTransportContext`;
164
+ * inline to avoid a type cycle with `transport/types`). `signal` aborts the
165
+ * in-flight call — bridges MUST honor it so a user "stop" cancels the
166
+ * underlying request, not just the local read.
167
+ * @returns ReadableStream for streaming or string for full response
168
+ */
169
+ chat?(request: AparteChatRequest, config?: string | Record<string, string>, ctx?: {
170
+ providerId: string;
171
+ signal?: AbortSignal;
172
+ }): Promise<AparteChatResponse>;
173
+ /** Build the vendor HTTP request from an Aparte request (auth injected by the transport). */
174
+ buildRequest?(request: AparteChatRequest): {
175
+ path: string;
176
+ body: unknown;
177
+ headers?: Record<string, string>;
178
+ };
179
+ /** Vendor auth headers for a resolved key (browser-direct only). */
180
+ authHeaders?(key: string): Record<string, string>;
181
+ /** Vendor auth as URL query params for a resolved key (e.g. Gemini `?key=`). */
182
+ authQuery?(key: string): Record<string, string>;
183
+ /** Base URL for browser-direct calls (overridable per request via config). */
184
+ defaultEndpoint?: string;
185
+ /** Parse a streaming vendor response body into unified events. */
186
+ parseStream?(body: ReadableStream<Uint8Array>): ReadableStream<AparteStreamEvent>;
187
+ /** Extract text from a non-streaming vendor JSON response. */
188
+ parseText?(json: unknown): string;
189
+ /**
190
+ * Optional. Returns the availability status of a model.
191
+ *
192
+ * - `'ready'` — loaded in memory, usable immediately
193
+ * - `'cached'` — downloaded / in local cache, needs a few seconds to load
194
+ * - `'not-downloaded'` — not yet downloaded
195
+ *
196
+ * Provider-agnostic: any provider can implement this to surface download/load state.
197
+ * Backward-compatible: providers that do not implement this method are unaffected.
198
+ */
199
+ getModelStatus?(modelId: string): Promise<ModelStatus>;
200
+ /**
201
+ * Optional. Prepare a model for use (download + load) with progress feedback.
202
+ * The returned Promise resolves when the model is ready to accept `chat()` calls.
203
+ *
204
+ * Provider-agnostic: Transformers.js streams download progress, Ollama streams
205
+ * pull progress, any provider can implement this pattern.
206
+ * Backward-compatible: providers that do not implement this method are unaffected.
207
+ */
208
+ prepareModel?(modelId: string, onProgress: (p: ModelLoadProgress) => void): Promise<void>;
209
+ /**
210
+ * Optional. Delete a locally cached/downloaded model.
211
+ * Provider-agnostic: Transformers.js clears the Cache API, Ollama calls /api/delete, etc.
212
+ * Backward-compatible: providers that do not implement this method are unaffected.
213
+ */
214
+ deleteModel?(modelId: string): Promise<void>;
215
+ }
216
+ /**
217
+ * Configuration options for model selection behavior.
218
+ */
219
+ export interface AparteModelConfig {
220
+ /** Which providers to enable (all if omitted) */
221
+ enabledProviders?: string[];
222
+ /** Filter models by provider */
223
+ modelFilters?: Record<string, string[]>;
224
+ /** Default provider ID */
225
+ defaultProvider?: string;
226
+ /** Default model ID */
227
+ defaultModel?: string;
228
+ }
229
+ //# sourceMappingURL=model-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-provider.d.ts","sourceRoot":"","sources":["../../src/types/model-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAA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