@aparte/core 0.19.3 → 0.20.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.
- package/dist/client/aparte-client.d.ts +66 -95
- package/dist/client/aparte-client.d.ts.map +1 -1
- package/dist/client/stream-adapter.d.ts +7 -13
- package/dist/client/stream-adapter.d.ts.map +1 -1
- package/dist/client/wire-history.d.ts +4 -5
- package/dist/client/wire-history.d.ts.map +1 -1
- package/dist/components/bubble/aparte-chat-bubble.d.ts +88 -57
- package/dist/components/bubble/aparte-chat-bubble.d.ts.map +1 -1
- package/dist/components/chat/aparte-chat.d.ts +15 -13
- package/dist/components/chat/aparte-chat.d.ts.map +1 -1
- package/dist/components/chat/glide-gate.d.ts +13 -0
- package/dist/components/chat/glide-gate.d.ts.map +1 -0
- package/dist/components/composer/aparte-composer-action.d.ts +2 -2
- package/dist/components/composer/aparte-composer-add-attachment.d.ts +1 -1
- package/dist/components/composer/aparte-composer-input.d.ts +1 -5
- package/dist/components/composer/aparte-composer-input.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer-send.d.ts +8 -10
- package/dist/components/composer/aparte-composer-send.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer.d.ts +48 -80
- package/dist/components/composer/aparte-composer.d.ts.map +1 -1
- package/dist/components/context/aparte-context.d.ts +9 -4
- package/dist/components/context/aparte-context.d.ts.map +1 -1
- package/dist/components/conversation-list/aparte-conversation-list.d.ts +23 -13
- package/dist/components/conversation-list/aparte-conversation-list.d.ts.map +1 -1
- package/dist/components/elicitation/aparte-elicitation.d.ts +15 -22
- package/dist/components/elicitation/aparte-elicitation.d.ts.map +1 -1
- package/dist/components/scroll-rail/aparte-scroll-rail.d.ts +10 -11
- package/dist/components/scroll-rail/aparte-scroll-rail.d.ts.map +1 -1
- package/dist/components/sidebar/aparte-sidebar.d.ts +16 -3
- package/dist/components/sidebar/aparte-sidebar.d.ts.map +1 -1
- package/dist/components/split/aparte-split.d.ts +12 -3
- package/dist/components/split/aparte-split.d.ts.map +1 -1
- package/dist/components/status/aparte-chat-status.d.ts.map +1 -1
- package/dist/components/suggestions/aparte-suggestions.d.ts +6 -9
- package/dist/components/suggestions/aparte-suggestions.d.ts.map +1 -1
- package/dist/components/viewport/aparte-chat-viewport.d.ts +70 -70
- package/dist/components/viewport/aparte-chat-viewport.d.ts.map +1 -1
- package/dist/config/aparte-config.d.ts +87 -66
- package/dist/config/aparte-config.d.ts.map +1 -1
- package/dist/config/icon-provider.d.ts +19 -2
- package/dist/config/icon-provider.d.ts.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/locale.d.ts +57 -89
- package/dist/config/locale.d.ts.map +1 -1
- package/dist/config/sanitize.d.ts.map +1 -1
- package/dist/conversations/conversation-controller.d.ts +18 -3
- package/dist/conversations/conversation-controller.d.ts.map +1 -1
- package/dist/conversations/conversation-manager.d.ts +3 -3
- package/dist/conversations/conversation-manager.d.ts.map +1 -1
- package/dist/custom-elements.json +13054 -12334
- package/dist/{dialog-triggers-ChnPFG9M.js → dialog-triggers-3Rk7PuZa.js} +444 -287
- package/dist/dialog-triggers-3Rk7PuZa.js.map +1 -0
- package/dist/elicitation/approval-panel.d.ts.map +1 -1
- package/dist/elicitation/index.d.ts +6 -1
- package/dist/elicitation/index.d.ts.map +1 -1
- package/dist/elicitation/panel.d.ts +11 -21
- package/dist/elicitation/panel.d.ts.map +1 -1
- package/dist/elicitation/types.d.ts +19 -27
- package/dist/elicitation/types.d.ts.map +1 -1
- package/dist/generated/element-attributes.d.ts +11 -5
- package/dist/generated/element-attributes.d.ts.map +1 -1
- package/dist/host/aparte-chat-host.d.ts +17 -32
- package/dist/host/aparte-chat-host.d.ts.map +1 -1
- package/dist/icons/extended.d.ts +1 -2
- package/dist/icons/extended.d.ts.map +1 -1
- package/dist/icons.d.ts +6 -8
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +12 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +682 -327
- package/dist/index.js.map +1 -1
- package/dist/index.node.d.ts +6 -3
- package/dist/index.node.d.ts.map +1 -1
- package/dist/index.node.js +2 -2
- package/dist/index.node.js.map +1 -1
- package/dist/interop/dialog-triggers.d.ts +2 -2
- package/dist/interop/element-props.d.ts +16 -27
- package/dist/interop/element-props.d.ts.map +1 -1
- package/dist/primitives/icon/aparte-icon.d.ts.map +1 -1
- package/dist/primitives/select/aparte-option.d.ts +3 -2
- package/dist/primitives/select/aparte-option.d.ts.map +1 -1
- package/dist/primitives/select/aparte-select.d.ts +24 -21
- package/dist/primitives/select/aparte-select.d.ts.map +1 -1
- package/dist/renderers/markdown-stream.d.ts.map +1 -1
- package/dist/renderers/segment-renderers.d.ts +11 -17
- package/dist/renderers/segment-renderers.d.ts.map +1 -1
- package/dist/renderers/segments/code.d.ts.map +1 -1
- package/dist/renderers/segments/error.d.ts.map +1 -1
- package/dist/renderers/segments/text.d.ts.map +1 -1
- package/dist/renderers/segments/tool-call.d.ts.map +1 -1
- package/dist/runtime/message-repository.d.ts +8 -15
- package/dist/runtime/message-repository.d.ts.map +1 -1
- package/dist/transport/backend-handler.d.ts +4 -6
- package/dist/transport/backend-handler.d.ts.map +1 -1
- package/dist/transport/backend-transport.d.ts +14 -0
- package/dist/transport/backend-transport.d.ts.map +1 -1
- package/dist/transport/types.d.ts +7 -10
- package/dist/transport/types.d.ts.map +1 -1
- package/dist/types/chat.d.ts +10 -18
- package/dist/types/chat.d.ts.map +1 -1
- package/dist/types/element-attributes.d.ts +6 -12
- package/dist/types/element-attributes.d.ts.map +1 -1
- package/dist/types/element-map.d.ts +6 -19
- package/dist/types/element-map.d.ts.map +1 -1
- package/dist/types/event-map.d.ts +11 -17
- package/dist/types/event-map.d.ts.map +1 -1
- package/dist/types/events.d.ts +5 -14
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/model-provider.d.ts +7 -9
- package/dist/types/model-provider.d.ts.map +1 -1
- package/dist/types/segments.d.ts +21 -13
- package/dist/types/segments.d.ts.map +1 -1
- package/dist/types/tools.d.ts +20 -22
- package/dist/types/tools.d.ts.map +1 -1
- package/dist/utils/copy-text.d.ts +1 -2
- package/dist/utils/copy-text.d.ts.map +1 -1
- package/dist/utils/css-escape.d.ts +1 -1
- package/dist/utils/escape.d.ts +4 -19
- package/dist/utils/escape.d.ts.map +1 -1
- package/dist/utils/files-to-attachments.d.ts +2 -2
- package/dist/utils/fold-text.d.ts +13 -0
- package/dist/utils/fold-text.d.ts.map +1 -0
- package/dist/utils/is-awaiting-reply.d.ts +2 -5
- package/dist/utils/is-awaiting-reply.d.ts.map +1 -1
- package/dist/utils/presence.d.ts +5 -5
- package/dist/utils/segments.d.ts +54 -78
- package/dist/utils/segments.d.ts.map +1 -1
- package/dist/utils/tool-input.d.ts +1 -1
- package/dist/utils/tool-input.d.ts.map +1 -1
- package/dist/utils/transcript.d.ts +2 -2
- package/dist/utils/uuid.d.ts +0 -11
- package/dist/utils/uuid.d.ts.map +1 -1
- package/package.json +29 -3
- package/dist/dialog-triggers-ChnPFG9M.js.map +0 -1
|
@@ -22,8 +22,8 @@ export type AparteToolApprovalResolver = (call: {
|
|
|
22
22
|
* What the user said to do instead, on a refusal.
|
|
23
23
|
*
|
|
24
24
|
* It becomes the `tool` message the model reads, which is possible at all only
|
|
25
|
-
* because a refusal
|
|
26
|
-
*
|
|
25
|
+
* because a refusal hands the model a turn. Optional: a resolver that returns a
|
|
26
|
+
* bare `{ approved }` is valid.
|
|
27
27
|
*/
|
|
28
28
|
instruction?: string;
|
|
29
29
|
/**
|
|
@@ -91,7 +91,7 @@ export interface AparteClientOptions {
|
|
|
91
91
|
* that cutoff; a turn a host seeded with NO `status` counts
|
|
92
92
|
* as answered, so a restored or server-rendered transcript
|
|
93
93
|
* goes out as history without inventing a status for it.
|
|
94
|
-
* - 'none' — sends only the current message
|
|
94
|
+
* - 'none' — sends only the current message
|
|
95
95
|
* - function — custom: receives viewport messages, returns AparteChatMessage[]
|
|
96
96
|
*/
|
|
97
97
|
history?: 'viewport' | 'none' | ((viewportMessages: AparteMessage[]) => AparteChatMessage[]);
|
|
@@ -133,10 +133,9 @@ export interface AparteClientOptions {
|
|
|
133
133
|
/**
|
|
134
134
|
* Whether a send appends the optimistic USER bubble before the reply streams.
|
|
135
135
|
*
|
|
136
|
-
* Default `true` — and opt-OUT on purpose: the
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
* compiles, it streams, and nothing errors.
|
|
136
|
+
* Default `true` — and opt-OUT on purpose: if the host had to append the bubble,
|
|
137
|
+
* whoever forgot would ship a chat where the person cannot see what they typed.
|
|
138
|
+
* It compiles, it streams, and nothing errors.
|
|
140
139
|
*
|
|
141
140
|
* Pass `false` when the host owns its transcript and appends the user message
|
|
142
141
|
* itself — the four framework wrappers do (their ConversationController is
|
|
@@ -155,8 +154,7 @@ export interface AparteClientOptions {
|
|
|
155
154
|
* types (including images) are routed to the application layer. Used
|
|
156
155
|
* when images go through a captioning pipeline before RAG ingest, so
|
|
157
156
|
* the chat context only ever sees retrieved text — never raw image
|
|
158
|
-
* bytes. Saves bytes on every turn
|
|
159
|
-
* intent (read file once at upload, retrieve text-only forever after).
|
|
157
|
+
* bytes. Saves bytes on every turn.
|
|
160
158
|
*
|
|
161
159
|
* Set `'images-only'` when a `requestInterceptor` retrieves relevant
|
|
162
160
|
* document chunks and injects them as a system message instead, to avoid
|
|
@@ -214,15 +212,13 @@ export declare class AparteClient {
|
|
|
214
212
|
/**
|
|
215
213
|
* Does this window event belong to this client?
|
|
216
214
|
*
|
|
217
|
-
* One rule for all
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
* two paid summarisation calls against whichever chat the DOM scan found
|
|
221
|
-
* first, and a global reset that wiped the other conversation.
|
|
215
|
+
* One rule for all the window-event handlers, so none of them can lack the guard:
|
|
216
|
+
* in a two-client layout an unguarded event would make BOTH clients run — two paid
|
|
217
|
+
* calls against whichever chat the DOM scan found first.
|
|
222
218
|
*
|
|
223
|
-
* A scoped client also answers only events ADDRESSED to it
|
|
224
|
-
*
|
|
225
|
-
*
|
|
219
|
+
* A scoped client also answers only events ADDRESSED to it; an untargeted event is
|
|
220
|
+
* not let through to every scoped client, or one broadcast would act on every chat
|
|
221
|
+
* on the page.
|
|
226
222
|
*/
|
|
227
223
|
private _isForThisInstance;
|
|
228
224
|
/** Aborts the in-flight vendor/transport fetch when the user stops a stream. */
|
|
@@ -239,27 +235,24 @@ export declare class AparteClient {
|
|
|
239
235
|
/**
|
|
240
236
|
* What every fresh user action does before it starts a turn.
|
|
241
237
|
*
|
|
242
|
-
* Clearing the abort flag
|
|
238
|
+
* Clearing the abort flag happens at the START of the action rather than inside
|
|
243
239
|
* `_streamTurn`, which runs after the auth and file-reading awaits — a reset there
|
|
244
|
-
*
|
|
245
|
-
* to be read.
|
|
240
|
+
* would erase an abort that arrived while the user was still waiting for a large
|
|
241
|
+
* attachment to be read.
|
|
246
242
|
*
|
|
247
243
|
* The superseded turn's TOOL handlers are not cancelled here, and do not need a
|
|
248
244
|
* registry of their own: `_streamTurn` aborts the previous `_streamController`, and
|
|
249
245
|
* the engine links every tool handler's controller to that run signal
|
|
250
|
-
* (`invokeToolHandler`), so cutting the stream cuts its tools.
|
|
251
|
-
* used to sit here for that job and was never added to — three lines of loop over an
|
|
252
|
-
* empty set, plus a paragraph describing a cancellation the method did not perform.
|
|
246
|
+
* (`invokeToolHandler`), so cutting the stream cuts its tools.
|
|
253
247
|
*/
|
|
254
248
|
private _beginUserTurn;
|
|
255
249
|
/**
|
|
256
250
|
* Put this client's `keyResolver` on its config, and hold the teardown so
|
|
257
251
|
* `stop()` can take it back off.
|
|
258
252
|
*
|
|
259
|
-
* The
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
* one it meant to replace instead of replacing it. Idempotent, so the usual
|
|
253
|
+
* The teardown means a stopped client stops signing model-list requests, and a
|
|
254
|
+
* remount — the way the wrappers document swapping options — replaces the source
|
|
255
|
+
* instead of adding one behind it. Idempotent, so the usual
|
|
263
256
|
* `new AparteClient({…}).start()` registers once.
|
|
264
257
|
*/
|
|
265
258
|
private _registerKeyResolver;
|
|
@@ -287,27 +280,21 @@ export declare class AparteClient {
|
|
|
287
280
|
/**
|
|
288
281
|
* Ask the human at the COMPOSER, and report what they decided.
|
|
289
282
|
*
|
|
290
|
-
* The default channel
|
|
291
|
-
* that existed only because the buttons lived in a segment renderer with no
|
|
292
|
-
* reference to this client. Routing through `requestUserInput` puts the decision
|
|
283
|
+
* The default channel. Routing through `requestUserInput` puts the decision
|
|
293
284
|
* where every other request for the user already goes, which is the whole point:
|
|
294
285
|
* one queue, one panel slot, one teardown, and the same behaviour whether the
|
|
295
286
|
* request came from a tool handler or from this gate.
|
|
296
287
|
*
|
|
297
288
|
* The tool NAME is the question and its ARGUMENTS are the body, because the
|
|
298
289
|
* arguments are what is being approved — a decision surface that names the act and
|
|
299
|
-
* hides its subject asks for a signature on a blank page.
|
|
300
|
-
*
|
|
301
|
-
* it had always promised what the panel did not do. The transcript row stays the
|
|
302
|
-
* anchor; it is no longer the only place the call can be read. The panel is capped
|
|
290
|
+
* hides its subject asks for a signature on a blank page. The transcript row stays the
|
|
291
|
+
* anchor, but it is not the only place the call can be read. The panel is capped
|
|
303
292
|
* at 50vh and the block inside it scrolls, so a long input cannot push the options
|
|
304
293
|
* off the surface they are asked on.
|
|
305
294
|
*
|
|
306
|
-
* `aparte-tool-decision`
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
* decision are one seam too many, and the ratified elicitation rule already said so
|
|
310
|
-
* — "a typed presenter registered per config instance, never window events". A host
|
|
295
|
+
* There is no `aparte-tool-decision` event and no `document` listener that answers
|
|
296
|
+
* one: a decision is answered by a typed presenter registered per config instance,
|
|
297
|
+
* never by a window event. A host
|
|
311
298
|
* that wants to answer programmatically registers an `approvalResolver` (headless,
|
|
312
299
|
* no DOM) or its own presenter, both strictly more capable than an id on an event.
|
|
313
300
|
*/
|
|
@@ -348,29 +335,21 @@ export declare class AparteClient {
|
|
|
348
335
|
/**
|
|
349
336
|
* The registered tools, unless the current model says it cannot call one.
|
|
350
337
|
*
|
|
351
|
-
* Single source for the gate, so send / retry / edit cannot drift
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
* sets it from a fetched list, and in both cases the model's declared
|
|
360
|
-
* capabilities are commonly unknown. `undefined` capabilities then read as "no
|
|
361
|
-
* function calling", so `tools: []` went on the wire while `getTools()` held
|
|
362
|
-
* the tool the app had explicitly registered. The model answered, correctly,
|
|
363
|
-
* that it had no such tool, and nothing anywhere said why.
|
|
364
|
-
*
|
|
365
|
-
* So the question is now "did this model say it cannot", not "did it say it
|
|
366
|
-
* can". Registering a tool is an explicit act by the app; silently dropping it
|
|
338
|
+
* Single source for the gate, so send / retry / edit cannot drift.
|
|
339
|
+
*
|
|
340
|
+
* The question is "did this model say it cannot", not "did it say it can": the
|
|
341
|
+
* app sets a model id by hand (`setModelConfig`) or a selector sets it from a
|
|
342
|
+
* fetched list, and in both cases the model's declared capabilities are commonly
|
|
343
|
+
* unknown. `undefined` capabilities read as "can", or `tools: []` would go on
|
|
344
|
+
* the wire while `getTools()` held the tool the app had explicitly registered,
|
|
345
|
+
* and the model would answer that it had no such tool. Registering a tool is an explicit act by the app; silently dropping it
|
|
367
346
|
* because a `/models` listing is terse is the library second-guessing the
|
|
368
347
|
* developer. A model that declares its capabilities and omits function calling
|
|
369
348
|
* is still honoured — that is a statement, and it is respected.
|
|
370
349
|
*
|
|
371
350
|
* Failure modes, both ways round: over-sending means a model that cannot use
|
|
372
351
|
* tools does not call one, or its own endpoint rejects the array with an error
|
|
373
|
-
* the developer can read. Under-sending
|
|
352
|
+
* the developer can read. Under-sending would be silent, total, and look like a
|
|
374
353
|
* lying model.
|
|
375
354
|
*/
|
|
376
355
|
private _toolsForCurrentModel;
|
|
@@ -379,10 +358,9 @@ export declare class AparteClient {
|
|
|
379
358
|
* The system messages a turn opens with: the app's own template, then the registered
|
|
380
359
|
* tools' `systemPrompt`s.
|
|
381
360
|
*
|
|
382
|
-
*
|
|
383
|
-
*
|
|
384
|
-
*
|
|
385
|
-
* the abort-flag asymmetry `_beginUserTurn` exists to prevent.
|
|
361
|
+
* One helper for the three turn entry points (send, retry, edit), so the tool half
|
|
362
|
+
* cannot be added to two of them and forgotten in the third — the same shape as the
|
|
363
|
+
* abort-flag asymmetry `_beginUserTurn` exists to prevent.
|
|
386
364
|
*/
|
|
387
365
|
private _systemMessages;
|
|
388
366
|
/**
|
|
@@ -404,11 +382,11 @@ export declare class AparteClient {
|
|
|
404
382
|
* The trees a lookup must search, the one the gesture came from FIRST.
|
|
405
383
|
*
|
|
406
384
|
* `document.getElementById` and `document.querySelectorAll` cannot see into a shadow
|
|
407
|
-
* root, so a chat mounted in one — the arrangement the theming guide endorses —
|
|
408
|
-
* invisible to both: alone, the send
|
|
409
|
-
* holds a chat in the light DOM, the scan
|
|
410
|
-
* person's message AND the model's reply
|
|
411
|
-
* into. Nearest tree first
|
|
385
|
+
* root, so a chat mounted in one — the arrangement the theming guide endorses — is
|
|
386
|
+
* invisible to both: alone, the send would be dropped with a warning; on a page that
|
|
387
|
+
* also holds a chat in the light DOM, the scan would answer with the WRONG chat, and
|
|
388
|
+
* the person's message AND the model's reply would land in a transcript they never
|
|
389
|
+
* typed into. Nearest tree first keeps it from swapping the other way round.
|
|
412
390
|
*/
|
|
413
391
|
private _rootsFor;
|
|
414
392
|
/** The element an id names, looked up in the gesture's own tree before the document. */
|
|
@@ -450,8 +428,8 @@ export declare class AparteClient {
|
|
|
450
428
|
* The SLICE is each caller's own business — retry cuts before the reply it is
|
|
451
429
|
* regenerating, edit cuts after the message being reworded, send cuts at the last
|
|
452
430
|
* answered turn. What a message CONTRIBUTES to the wire is not: send, retry and
|
|
453
|
-
* edit must not disagree about it
|
|
454
|
-
*
|
|
431
|
+
* edit must not disagree about it. A failed turn and a turn stopped before its
|
|
432
|
+
* first token are filtered out rather than sent as
|
|
455
433
|
* `{ role: 'assistant', content: '' }` — a claim the assistant said nothing, which
|
|
456
434
|
* some providers reject outright and the rest read as an empty reply worth
|
|
457
435
|
* imitating.
|
|
@@ -480,12 +458,12 @@ export declare class AparteClient {
|
|
|
480
458
|
* the question the history gates can ask is "is this still in flight?", never
|
|
481
459
|
* "is this completed?".
|
|
482
460
|
*
|
|
483
|
-
* The gates below
|
|
461
|
+
* The gates below ask the first, because a host that SEEDS a transcript
|
|
484
462
|
* — restoring a saved conversation, hydrating a server-rendered one — has no
|
|
485
|
-
* reason to invent a status for turns that are already over.
|
|
486
|
-
*
|
|
487
|
-
* model
|
|
488
|
-
* because the viewport still
|
|
463
|
+
* reason to invent a status for turns that are already over. Asking "is this
|
|
464
|
+
* completed?" would leave the cutoff at 0 and slice away the whole transcript: the
|
|
465
|
+
* model would get the new question with no context, and nothing in the UI would say
|
|
466
|
+
* so, because the viewport still shows every message.
|
|
489
467
|
*/
|
|
490
468
|
private static _inFlight;
|
|
491
469
|
private _toHistoryMessages;
|
|
@@ -500,23 +478,9 @@ export declare class AparteClient {
|
|
|
500
478
|
* What the model is told it said last turn — reconstructed from what was
|
|
501
479
|
* RENDERED, not from the raw-text field.
|
|
502
480
|
*
|
|
503
|
-
* The
|
|
504
|
-
*
|
|
505
|
-
*
|
|
506
|
-
* correct-in-isolation decisions composed into it:
|
|
507
|
-
*
|
|
508
|
-
* 1. the parser withholds an ambiguous prefix (``` ``` ```, `` ` ``, `<`)
|
|
509
|
-
* waiting for the next delta, and creates no active segment while it waits;
|
|
510
|
-
* 2. so `_streamLoop` sees zero segments, concludes the parser produced
|
|
511
|
-
* nothing, and appends the raw delta straight to `message.content`;
|
|
512
|
-
* 3. and this method preferred `content`.
|
|
513
|
-
*
|
|
514
|
-
* The bubble hides its content element as soon as segments exist, so the UI was
|
|
515
|
-
* perfect and only the NEXT request showed it. No unit test, no example and
|
|
516
|
-
* no browser test could see it.
|
|
517
|
-
*
|
|
518
|
-
* `content` stays as the fallback, and that is not vestigial: a non-streaming
|
|
519
|
-
* transport writes the whole reply there and creates no segments at all.
|
|
481
|
+
* The segments are what the reader saw, so they come first. `content` is the
|
|
482
|
+
* fallback, and that is not vestigial: a non-streaming transport writes the whole
|
|
483
|
+
* reply there and creates no segments at all.
|
|
520
484
|
*/
|
|
521
485
|
private _extractText;
|
|
522
486
|
/**
|
|
@@ -529,10 +493,9 @@ export declare class AparteClient {
|
|
|
529
493
|
* A type core does not know — a registered block grammar's (an artifact, a
|
|
530
494
|
* citation, a file), a consumer's custom segment — follows one rule: its
|
|
531
495
|
* `content` if it has one, else its `fallback`, else nothing. Dropping such a
|
|
532
|
-
* segment
|
|
533
|
-
* turn, so it could not be asked to change the thing it had built
|
|
534
|
-
*
|
|
535
|
-
* now that the artifact is a plugin's type like any other.
|
|
496
|
+
* segment would make a document the model had just produced invisible on the very
|
|
497
|
+
* next turn, so it could not be asked to change the thing it had built. An artifact
|
|
498
|
+
* is a plugin's type like any other and follows this rule.
|
|
536
499
|
*
|
|
537
500
|
* `thinking` and `tool_call` stay out on purpose — the first is the model's own
|
|
538
501
|
* scratchpad, and most APIs neither want it back nor bill for it kindly; the
|
|
@@ -605,6 +568,14 @@ export declare class AparteClient {
|
|
|
605
568
|
* resume. A channel that CRASHES fails the turn, as it does for a run in the page.
|
|
606
569
|
*/
|
|
607
570
|
private _answerDeferred;
|
|
571
|
+
/**
|
|
572
|
+
* Whether a browser tool a paused run asked for may run, decided as a run in the page
|
|
573
|
+
* decides it. With a host `approvalResolver`, the tool's own `needsApproval` says whether
|
|
574
|
+
* to ask and the resolver answers; without one, the approval policy and `needsApproval`
|
|
575
|
+
* rule (`ruleOnToolCall`) and the default channel asks. `null` when nothing gates the
|
|
576
|
+
* call, the decision when something did, `undefined` when nobody answered.
|
|
577
|
+
*/
|
|
578
|
+
private _gateBrowserTool;
|
|
608
579
|
/**
|
|
609
580
|
* The ticket is spent the moment the resume leaves: the server answers these calls
|
|
610
581
|
* now, so a pause saved from here on — the conversation manager saves before it cuts a
|
|
@@ -616,8 +587,8 @@ export declare class AparteClient {
|
|
|
616
587
|
* Close the reply's calls that can no longer finish — paused, queued, or running on a
|
|
617
588
|
* server the page stopped listening to: each says it stopped, and forgets the pause.
|
|
618
589
|
* A cut connection carries none of their last events, so nothing else would: the rows
|
|
619
|
-
*
|
|
620
|
-
* server that had moved on. By the reply's id, not the chat's head — a retry during
|
|
590
|
+
* would spin, and a queued call would keep its ticket, which a reload would then
|
|
591
|
+
* resume against a server that had moved on. By the reply's id, not the chat's head — a retry during
|
|
621
592
|
* the wait moves the head. A run in the page ends every call itself: nothing to do.
|
|
622
593
|
*/
|
|
623
594
|
private _closeOpenCalls;
|
|
@@ -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;AAS9E,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;AA8CxG;;;;;;;;GAQG;AACH,MAAM,MAAM,0BAA0B,GAAG,CACrC,IAAI,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,EAClE,MAAM,EAAE,WAAW,KAClB,OAAO,CAAC;IACT,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;OA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c,CAAS;YAEjB,WAAW;IA8LzB;;OAEG;IACH,OAAO,CAAC,cAAc;IAoBtB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,MAAM,CAAC,SAAS;IAIxB,OAAO,CAAC,kBAAkB;IAmB1B;;;;;OAKG;IACH,OAAO,CAAC,SAAS;IAKjB;;;;;;;OAOG;IACH,OAAO,CAAC,YAAY;IAOpB;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,eAAe;IAuBvB;;;;;;;OAOG;IACH,OAAO,CAAC,oBAAoB;IAS5B;;;;;;;OAOG;YACW,oBAAoB;IAiDlC;;;;;;;;;;OAUG;IACH;;;OAGG;IACH,6EAA6E;YAC/D,WAAW;IAoDzB;;;;;;;;OAQG;YACW,mBAAmB;IAoHjC;;;;;;;;;OASG;IACH,OAAO,CAAC,oBAAoB;IAiB5B;;;;;;;OAOG;YACW,eAAe;IA+E7B;;;;;;OAMG;YACW,gBAAgB;IAsB9B;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IAenB;;;;;;;OAOG;IACH,OAAO,CAAC,eAAe;IAgBvB;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAKvB;;;;;;;OAOG;IACH,OAAO,CAAC,WAAW;IAUnB;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAYtB;;;;;;;;;;;;OAYG;IACG,cAAc,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAsCrE,2FAA2F;IAC3F,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqB;IAE/C;;OAEG;IACH,OAAO,CAAC,cAAc;IAMtB;;OAEG;IACH,OAAO,CAAC,qBAAqB;CAuDhC"}
|
|
@@ -3,18 +3,15 @@
|
|
|
3
3
|
*
|
|
4
4
|
* `@aparte/engine`'s `runStreamAgent` is the headless loop: it emits high-level,
|
|
5
5
|
* DOM-free run events. This adapter is the other half — it turns each event into
|
|
6
|
-
* the
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* loop byte-for-byte — and have replaced it (audit 2026-08-28, D1).
|
|
6
|
+
* the `targetElement.*` calls + CustomEvents the transcript needs, using the
|
|
7
|
+
* **real** `AparteStreamParser` and tool renderers. `runStreamAgent` (engine, pure
|
|
8
|
+
* Node) + this adapter (core, DOM) are the one agent loop `AparteClient` runs.
|
|
10
9
|
*
|
|
11
10
|
* DEPENDENCY DIRECTION: `@aparte/core` depends on `@aparte/engine` — first-party, so
|
|
12
11
|
* the zero-third-party-dependency promise is untouched — never the reverse. The
|
|
13
12
|
* run-event contract is engine's: {@link AparteStreamRunEvent} and its siblings below
|
|
14
13
|
* are `StreamRunEvent` & co under core's names, so there is nothing to keep in sync by
|
|
15
|
-
* hand
|
|
16
|
-
* guard in engine that policed it, went with the mirror (audit 2026-08-28, D1). A
|
|
17
|
-
* consumer wires a runner through `AparteClientOptions.streamRunner` — the same
|
|
14
|
+
* hand. A consumer wires a runner through `AparteClientOptions.streamRunner` — the same
|
|
18
15
|
* pattern as `approvalResolver` (HITL).
|
|
19
16
|
*/
|
|
20
17
|
import type { AparteConfig } from '../config/aparte-config.js';
|
|
@@ -24,7 +21,7 @@ import type { StreamRunEvent, StreamRunEmitter, StreamRunOptions, StreamUsage }
|
|
|
24
21
|
/**
|
|
25
22
|
* The DOM-free run events `@aparte/engine`'s `runStreamAgent` emits — engine's
|
|
26
23
|
* `StreamRunEvent`, under core's name. See `packages/engine/src/agent/stream-events.ts`
|
|
27
|
-
* for the per-event
|
|
24
|
+
* for the per-event documentation.
|
|
28
25
|
*/
|
|
29
26
|
export type AparteStreamRunEvent = StreamRunEvent;
|
|
30
27
|
/** Synchronous, ordered event sink — engine's `StreamRunEmitter`. */
|
|
@@ -42,11 +39,8 @@ export type AparteStreamRunOptions = StreamRunOptions;
|
|
|
42
39
|
* — the seam by which a host wraps or replaces the loop `AparteClient` runs,
|
|
43
40
|
* which is `@aparte/engine`'s `runStreamAgent` by default.
|
|
44
41
|
*
|
|
45
|
-
* `runStreamAgent` IS this type — pass it, do not cast it.
|
|
46
|
-
*
|
|
47
|
-
* two packages' message types drifted apart unnoticed and shipped a
|
|
48
|
-
* `streamRunner: runStreamAgent` that did not compile on five docs pages and a
|
|
49
|
-
* README. The alias makes that drift a typecheck error in the composition itself.
|
|
42
|
+
* `runStreamAgent` IS this type — pass it, do not cast it. The alias makes any drift
|
|
43
|
+
* between the two packages' message types a typecheck error in the composition itself.
|
|
50
44
|
*/
|
|
51
45
|
export type AparteStreamRunner = (opts: AparteStreamRunOptions) => Promise<StreamUsage | undefined>;
|
|
52
46
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-adapter.d.ts","sourceRoot":"","sources":["../../src/client/stream-adapter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"stream-adapter.d.ts","sourceRoot":"","sources":["../../src/client/stream-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAKzF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAMtG;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC;AAElD,qEAAqE;AACrE,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;AAEtD;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,sBAAsB,KAAK,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAAC;AAEpG;;;GAGG;AACH,MAA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
*
|
|
8
|
-
* text after them as the next envelope.
|
|
4
|
+
* A reply goes out in the order it was shown, so a tool's result stays in the model's
|
|
5
|
+
* context on later turns: the text before some calls and those calls as an assistant
|
|
6
|
+
* envelope, each call's answer as a `tool` message, the text after them as the next
|
|
7
|
+
* envelope.
|
|
9
8
|
*
|
|
10
9
|
* Every call is answered, because a provider rejects a request that declares a call
|
|
11
10
|
* with no `tool` message after it: a refusal sends its reason, a crash its error line,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire-history.d.ts","sourceRoot":"","sources":["../../src/client/wire-history.ts"],"names":[],"mappings":"AAAA
|
|
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,CAAC,EAAE,OAAO,CAAC;CACrB,GACP,iBAAiB,EAAE,CA2CrB"}
|