@aparte/core 0.25.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/agent-runner.d.ts.map +1 -1
- package/dist/client/aparte-client.d.ts +35 -76
- package/dist/client/aparte-client.d.ts.map +1 -1
- package/dist/client/stream-adapter.d.ts.map +1 -1
- package/dist/client/wire-history.d.ts +78 -0
- package/dist/client/wire-history.d.ts.map +1 -1
- package/dist/components/bubble/aparte-chat-bubble.d.ts +88 -2
- package/dist/components/bubble/aparte-chat-bubble.d.ts.map +1 -1
- package/dist/components/bubble/bubble-sync.d.ts +5 -1
- package/dist/components/bubble/bubble-sync.d.ts.map +1 -1
- package/dist/components/bubble/checkpoint-separator.d.ts +40 -0
- package/dist/components/bubble/checkpoint-separator.d.ts.map +1 -0
- package/dist/components/context/aparte-context.d.ts +157 -25
- package/dist/components/context/aparte-context.d.ts.map +1 -1
- package/dist/components/viewport/aparte-chat-viewport.d.ts +7 -0
- package/dist/components/viewport/aparte-chat-viewport.d.ts.map +1 -1
- package/dist/config/aparte-config.d.ts +17 -0
- package/dist/config/aparte-config.d.ts.map +1 -1
- package/dist/config/locale.d.ts +62 -4
- package/dist/config/locale.d.ts.map +1 -1
- package/dist/context/checkpoint-state.d.ts +70 -0
- package/dist/context/checkpoint-state.d.ts.map +1 -0
- package/dist/context/checkpoint.d.ts +28 -0
- package/dist/context/checkpoint.d.ts.map +1 -0
- package/dist/context/measure.d.ts +148 -0
- package/dist/context/measure.d.ts.map +1 -0
- package/dist/context/restore.d.ts +24 -0
- package/dist/context/restore.d.ts.map +1 -0
- package/dist/conversations/conversation-controller.d.ts +13 -4
- package/dist/conversations/conversation-controller.d.ts.map +1 -1
- package/dist/conversations/conversation-manager.d.ts +6 -0
- package/dist/conversations/conversation-manager.d.ts.map +1 -1
- package/dist/custom-elements.json +13734 -12139
- package/dist/{defer-hydration-BwMqeRHq.js → defer-hydration-8vI8xNNx.js} +683 -250
- package/dist/defer-hydration-8vI8xNNx.js.map +1 -0
- package/dist/generated/element-attributes.d.ts +8 -2
- package/dist/generated/element-attributes.d.ts.map +1 -1
- package/dist/host/aparte-chat-host.d.ts +19 -2
- package/dist/host/aparte-chat-host.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +819 -81
- package/dist/index.js.map +1 -1
- package/dist/index.node.d.ts +4 -1
- package/dist/index.node.d.ts.map +1 -1
- package/dist/index.node.js +33 -29
- package/dist/index.node.js.map +1 -1
- package/dist/transport/agent-handler.d.ts.map +1 -1
- package/dist/transport/backend-handler.d.ts.map +1 -1
- package/dist/transport/types.d.ts +24 -4
- package/dist/transport/types.d.ts.map +1 -1
- package/dist/types/chat.d.ts +16 -1
- package/dist/types/chat.d.ts.map +1 -1
- package/dist/types/compactor.d.ts +104 -0
- package/dist/types/compactor.d.ts.map +1 -0
- package/dist/types/errors.d.ts +2 -0
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/events.d.ts +50 -3
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/model-provider.d.ts +3 -0
- package/dist/types/model-provider.d.ts.map +1 -1
- package/dist/types/models.d.ts +43 -3
- package/dist/types/models.d.ts.map +1 -1
- package/dist/types/segments.d.ts +1 -1
- package/package.json +2 -2
- package/dist/defer-hydration-BwMqeRHq.js.map +0 -1
package/dist/index.node.d.ts
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* TypeScript consumers fully typed on the server; `registerAllComponents()` is a
|
|
19
19
|
* no-op here (there is nothing to register without a DOM).
|
|
20
20
|
*/
|
|
21
|
-
export type { AparteBubbleRole, AparteMessage, AparteContentParser, AparteStreamBlock, AparteStreamBlockMatch, AparteSendEventDetail, AparteViewportConfig, AparteInputConfig, AparteThemeVariables, AparteStatus, AparteAttachment, AparteMessageBranch, AparteBubbleActionsConfig, AparteBubbleActionName, AparteSegment, AparteSegmentTypes, AparteSegmentType, AparteTextSegment, AparteThinkingSegment, AparteCodeSegment, AparteSegmentRenderer, AparteSegmentMount, AparteCustomSegment, AparteToolCallSegment, AparteSegmentBase, AparteSegmentDefaults, AparteSegmentTiming, AparteErrorSegment, AparteSegmentUpdateEventDetail, AparteAIProvider, AparteAIModel, AparteAIProviderConfigField, AparteAIProviderMetadata, AparteAIProviderConfigSchema, AparteModelConfig, ModelStatus, ModelLoadProgress, AparteModelChangeEventDetail, AparteApprovalModeChangeEventDetail, AparteMessageDoneEventDetail, AparteMessageStartEventDetail, AparteMessageErrorEventDetail, AparteMessageAbortedEventDetail, AparteMessagePausedEventDetail, AparteMessageResumedEventDetail, AparteAbortEventDetail, AparteCompactEventDetail, AparteCompactDoneEventDetail, AparteCompactStartEventDetail, AparteCompactErrorEventDetail, AparteAttachmentPreviewEventDetail, AparteLinkClickEventDetail, AparteMessageInfoEventDetail, AparteSiblingInfo, AparteBranchNavigateEventDetail, ApartePathChangedEventDetail, AparteRetryEventDetail, AparteEditEventDetail, AparteFeedbackEventDetail, AparteActionEventDetail, AparteChatRequest, AparteRequestMeta, AparteChatResponse, AparteChatMessage, AparteContentPart, AparteTextPart, AparteImagePart, AparteStreamEvent, AparteStreamEventMap, AparteUsage, AparteTool, AparteToolCall, AparteApprovalPolicy, AparteApprovalRuling, AparteToolResult, AparteToolHandler, AparteToolContext, AparteToolRenderer, AparteToolSummary, AparteToolInputFormatter, AparteToolMatcher, AparteToolDisplay, AparteToolDetails, AparteToolCallView, AparteMountedView, AparteToolMount, AparteToolApprovalRequestDetail, AparteChatImperativeApi, AparteUiHandle, AparteElementAttributes, AparteElementTagName, AparteAttrValue, AparteTemplateAttrs, AparteNoAttributes, AparteChatAttributes, AparteChatViewportAttributes, AparteChatBubbleAttributes, AparteChatStatusAttributes, AparteComposerAttributes, AparteComposerInputAttributes, AparteComposerActionAttributes, AparteComposerAddAttachmentAttributes, AparteComposerToolbarAttributes, AparteConversationListAttributes, AparteSelectAttributes, AparteOptionAttributes, AparteOptgroupAttributes, AparteProgressSpinnerAttributes, AparteContextAttributes, AparteIconAttributes, AparteScrollRailAttributes, AparteSidebarAttributes, AparteSplitAttributes, AparteSuggestionsAttributes, } from './types/index.js';
|
|
21
|
+
export type { AparteBubbleRole, AparteMessage, AparteContextSummary, AparteCompactor, AparteCompactorRequest, AparteCompactorOutcome, AparteCompactorReason, AparteContentParser, AparteStreamBlock, AparteStreamBlockMatch, AparteSendEventDetail, AparteViewportConfig, AparteInputConfig, AparteThemeVariables, AparteStatus, AparteAttachment, AparteMessageBranch, AparteBubbleActionsConfig, AparteBubbleActionName, AparteSegment, AparteSegmentTypes, AparteSegmentType, AparteTextSegment, AparteThinkingSegment, AparteCodeSegment, AparteSegmentRenderer, AparteSegmentMount, AparteCustomSegment, AparteToolCallSegment, AparteSegmentBase, AparteSegmentDefaults, AparteSegmentTiming, AparteErrorSegment, AparteSegmentUpdateEventDetail, AparteAIProvider, AparteAIModel, AparteAIProviderConfigField, AparteAIProviderMetadata, AparteAIProviderConfigSchema, AparteModelConfig, ModelStatus, ModelLoadProgress, AparteModelChangeEventDetail, AparteApprovalModeChangeEventDetail, AparteMessageDoneEventDetail, AparteMessageStartEventDetail, AparteMessageErrorEventDetail, AparteMessageAbortedEventDetail, AparteMessagePausedEventDetail, AparteMessageResumedEventDetail, AparteAbortEventDetail, AparteCompactEventDetail, AparteCompactDoneEventDetail, AparteCompactStartEventDetail, AparteCompactErrorEventDetail, AparteAttachmentPreviewEventDetail, AparteLinkClickEventDetail, AparteMessageInfoEventDetail, AparteSiblingInfo, AparteBranchNavigateEventDetail, ApartePathChangedEventDetail, AparteRetryEventDetail, AparteEditEventDetail, AparteFeedbackEventDetail, AparteActionEventDetail, AparteChatRequest, AparteRequestMeta, AparteChatResponse, AparteChatMessage, AparteContentPart, AparteTextPart, AparteImagePart, AparteStreamEvent, AparteStreamEventMap, AparteUsage, AparteFinishReason, AparteTool, AparteToolCall, AparteApprovalPolicy, AparteApprovalRuling, AparteToolResult, AparteToolHandler, AparteToolContext, AparteToolRenderer, AparteToolSummary, AparteToolInputFormatter, AparteToolMatcher, AparteToolDisplay, AparteToolDetails, AparteToolCallView, AparteMountedView, AparteToolMount, AparteToolApprovalRequestDetail, AparteChatImperativeApi, AparteUiHandle, AparteElementAttributes, AparteElementTagName, AparteAttrValue, AparteTemplateAttrs, AparteNoAttributes, AparteChatAttributes, AparteChatViewportAttributes, AparteChatBubbleAttributes, AparteChatStatusAttributes, AparteComposerAttributes, AparteComposerInputAttributes, AparteComposerActionAttributes, AparteComposerAddAttachmentAttributes, AparteComposerToolbarAttributes, AparteConversationListAttributes, AparteSelectAttributes, AparteOptionAttributes, AparteOptgroupAttributes, AparteProgressSpinnerAttributes, AparteContextAttributes, AparteIconAttributes, AparteScrollRailAttributes, AparteSidebarAttributes, AparteSplitAttributes, AparteSuggestionsAttributes, } from './types/index.js';
|
|
22
22
|
export { AparteErrorCode, AparteError, contentToText } from './types/index.js';
|
|
23
23
|
export type { AparteChat, AparteChatBubble, AparteChatViewport, AparteChatStatus, AparteComposer, AparteComposerInput, AparteComposerSend, AparteComposerCancel, AparteComposerAttachments, AparteComposerAddAttachment, AparteComposerAction, AparteComposerToolbar, AparteSuggestions, AparteContext, AparteConversationList, AparteScrollRail, AparteSidebar, AparteSplit, } from './components/index.js';
|
|
24
24
|
export type { AparteScrollRailJumpDetail, AparteScrollRailEvery, AparteSidebarToggleDetail } from './components/index.js';
|
|
@@ -49,6 +49,9 @@ export type { AparteConfigAware } from './config/index.js';
|
|
|
49
49
|
export type { AparteMarkdownProvider, AparteStreamingMarkdownProvider, AparteStreamingMarkdownRenderer, AparteHighlightProvider, AparteSystemPromptVarsProvider, AparteLocale, AparteLocaleExtensions, AparteAction, AparteActionZone, AparteIconProvider, AparteIconName, AparteCoreIconName, AparteAvatarProvider, AparteStatusRenderer, AparteErrorRenderer, AparteAttachmentRenderer, AparteElicitationFieldRenderer, AparteElicitationFieldContext, AparteElicitationFieldControl, AparteSiblingNavRenderer, AparteBubbleShellRenderer, AparteModelPreference, AparteModelPreferenceProvider, AparteSanitizer, } from './config/index.js';
|
|
50
50
|
export { APARTE_DEFAULT_ICON_FALLBACKS, APARTE_DEFAULT_LOCALE, defaultSanitizer, isSafeUrl } from './config/index.js';
|
|
51
51
|
export { AparteClient } from './client/aparte-client.js';
|
|
52
|
+
export { historyFromCheckpoint } from './context/checkpoint.js';
|
|
53
|
+
export { estimateTokens, estimateWireTokens, measureContext } from './context/measure.js';
|
|
54
|
+
export type { AparteContextMeasure, AparteContextMeasureInput } from './context/measure.js';
|
|
52
55
|
export type { AparteClientOptions, AparteToolApprovalResolver } from './client/aparte-client.js';
|
|
53
56
|
export { createStreamAdapter, readableToAsyncIterable } from './client/stream-adapter.js';
|
|
54
57
|
export { toolRefusal } from './client/stream-adapter.js';
|
package/dist/index.node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.node.d.ts","sourceRoot":"","sources":["../src/index.node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,YAAY,EACR,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EACzB,sBAAsB,EACtB,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EAOrB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAIlB,8BAA8B,EAC9B,gBAAgB,EAChB,aAAa,EACb,2BAA2B,EAC3B,wBAAwB,EACxB,4BAA4B,EAC5B,iBAAiB,EACjB,W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AE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAIvF,YAAY,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAClE,YAAY,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAGnE,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAClI,YAAY,EACR,uBAAuB,EACvB,sBAAsB,EACtB,0BAA0B,EAC1B,6BAA6B,EAC7B,4BAA4B,EAC5B,6BAA6B,EAC7B,wBAAwB,EACxB,uBAAuB,EACvB,0BAA0B,EAC1B,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,GACxB,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAY5C;AAED,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC"}
|
package/dist/index.node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, _, $, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab, ac, ad, ae, af } from "./defer-hydration-
|
|
1
|
+
import { A, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, _, $, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab, ac, ad, ae, af, ag, ah, ai, aj } from "./defer-hydration-8vI8xNNx.js";
|
|
2
2
|
function registerAllComponents() {
|
|
3
3
|
if (typeof customElements !== "undefined") {
|
|
4
4
|
console.warn(
|
|
@@ -49,34 +49,38 @@ export {
|
|
|
49
49
|
N as detachConfig,
|
|
50
50
|
O as escapeAttr,
|
|
51
51
|
P as escapeHtml,
|
|
52
|
-
Q as
|
|
53
|
-
R as
|
|
54
|
-
S as
|
|
55
|
-
T as
|
|
56
|
-
U as
|
|
57
|
-
V as
|
|
58
|
-
W as
|
|
59
|
-
X as
|
|
60
|
-
Y as
|
|
61
|
-
Z as
|
|
62
|
-
_ as
|
|
63
|
-
$ as
|
|
64
|
-
a0 as
|
|
65
|
-
a1 as
|
|
52
|
+
Q as estimateTokens,
|
|
53
|
+
R as estimateWireTokens,
|
|
54
|
+
S as filesToAttachments,
|
|
55
|
+
T as getAllRenderers,
|
|
56
|
+
U as getSegmentRenderer,
|
|
57
|
+
V as historyFromCheckpoint,
|
|
58
|
+
W as installDefaultRenderersOnce,
|
|
59
|
+
X as installDialogTriggersOnce,
|
|
60
|
+
Y as isAwaitingReply,
|
|
61
|
+
Z as isFormatAdapter,
|
|
62
|
+
_ as isSafeUrl,
|
|
63
|
+
$ as isSegmentSettled,
|
|
64
|
+
a0 as measureContext,
|
|
65
|
+
a1 as overrideSegmentRenderer,
|
|
66
|
+
a2 as parseAparteEventStream,
|
|
67
|
+
a3 as parseMarkdownToSegments,
|
|
68
|
+
a4 as populateBubbleFromMessage,
|
|
69
|
+
a5 as readableToAsyncIterable,
|
|
66
70
|
registerAllComponents,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
71
|
+
a6 as registerDefaultRenderers,
|
|
72
|
+
a7 as registerSegmentRenderer,
|
|
73
|
+
a8 as releaseDeferredHydration,
|
|
74
|
+
a9 as requestUserInput,
|
|
75
|
+
aa as resolveConfig,
|
|
76
|
+
ab as revokeAttachmentUrls,
|
|
77
|
+
ac as runWithConfig,
|
|
78
|
+
ad as segmentDuration,
|
|
79
|
+
ae as segmentTiming,
|
|
80
|
+
af as subscribeConfigChange,
|
|
81
|
+
ag as toToolCallView,
|
|
82
|
+
ah as toolRefusal,
|
|
83
|
+
ai as unregisterSegmentRenderer,
|
|
84
|
+
aj as uuid
|
|
81
85
|
};
|
|
82
86
|
//# sourceMappingURL=index.node.js.map
|
package/dist/index.node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.node.js","sources":["../src/index.node.ts"],"sourcesContent":["/**\n * @aparte/core — Node.js / SSR-safe entry point.\n *\n * Resolved via the `node` export condition, so `import '@aparte/core'` in Node\n * (Next.js / Nuxt / Angular Universal / SvelteKit server, tsx, CLI tools) loads\n * THIS module instead of the browser entry — and via `worker`, `workerd`,\n * `edge-light`, `deno` and `bun` for a Cloudflare Worker, an edge route or a\n * `target: 'webworker'` build. A worker built with the page's conditions imports it\n * by name, as `@aparte/core/headless`. It exposes the same public API\n * surface MINUS the Web Components and CSS side-effects — importing the real\n * `index.ts` in Node throws `HTMLElement is not defined` because the custom\n * elements extend `HTMLElement` at module scope.\n *\n * Everything re-exported here is DOM-free at import time. Custom-element CLASSES\n * (AparteChatBubble, AparteComposer*, AparteSelect, …) are intentionally NOT exported\n * as runtime values — they only exist in the browser build. Their TYPES are\n * re-exported (types are erased, so they never pull DOM at runtime), which keeps\n * TypeScript consumers fully typed on the server; `registerAllComponents()` is a\n * no-op here (there is nothing to register without a DOM).\n */\n\n// ── Types (erased at runtime — always safe, mirror index.ts) ────────────────\nexport type {\n AparteBubbleRole,\n AparteMessage,\n AparteContentParser,\n AparteStreamBlock,\n AparteStreamBlockMatch,\n AparteSendEventDetail,\n AparteViewportConfig,\n AparteInputConfig,\n AparteThemeVariables,\n AparteStatus,\n AparteAttachment,\n AparteMessageBranch,\n AparteBubbleActionsConfig,\n AparteBubbleActionName,\n AparteSegment,\n AparteSegmentTypes,\n AparteSegmentType,\n AparteTextSegment,\n AparteThinkingSegment,\n AparteCodeSegment,\n AparteSegmentRenderer,\n AparteSegmentMount,\n AparteCustomSegment,\n AparteToolCallSegment,\n // The same five the browser barrel gained, and they belong here for the same reason:\n // a type has no DOM. `AparteSegmentBase` is the constraint on the exported\n // `AparteSegmentRenderer<T>`, so an SSR consumer writing a renderer for a segment type\n // of its own could not name what it extends. `check:node-barrel-types` is what caught\n // the omission — the browser barrel alone would have compiled fine and failed on the\n // `node` condition only.\n AparteSegmentBase,\n AparteSegmentDefaults,\n AparteSegmentTiming,\n AparteErrorSegment,\n // The detail of the `aparte-segment-update` event. It reached types/index.ts and\n // stopped there — and types/index.ts is not an entry point, so a consumer could\n // bind the event (it is in the published event table) and never name its detail.\n AparteSegmentUpdateEventDetail,\n AparteAIProvider,\n AparteAIModel,\n AparteAIProviderConfigField,\n AparteAIProviderMetadata,\n AparteAIProviderConfigSchema,\n AparteModelConfig,\n ModelStatus,\n ModelLoadProgress,\n AparteModelChangeEventDetail,\n AparteApprovalModeChangeEventDetail,\n AparteMessageDoneEventDetail,\n AparteMessageStartEventDetail,\n AparteMessageErrorEventDetail,\n AparteMessageAbortedEventDetail,\n AparteMessagePausedEventDetail,\n AparteMessageResumedEventDetail,\n AparteAbortEventDetail,\n AparteCompactEventDetail,\n AparteCompactDoneEventDetail,\n AparteCompactStartEventDetail,\n AparteCompactErrorEventDetail,\n AparteAttachmentPreviewEventDetail,\n AparteLinkClickEventDetail,\n AparteMessageInfoEventDetail,\n AparteSiblingInfo,\n AparteBranchNavigateEventDetail,\n ApartePathChangedEventDetail,\n AparteRetryEventDetail,\n AparteEditEventDetail,\n AparteFeedbackEventDetail,\n AparteActionEventDetail,\n AparteChatRequest,\n AparteRequestMeta,\n AparteChatResponse,\n AparteChatMessage,\n AparteContentPart,\n AparteTextPart,\n AparteImagePart,\n AparteStreamEvent,\n AparteStreamEventMap,\n AparteUsage,\n AparteTool,\n AparteToolCall,\n AparteApprovalPolicy,\n AparteApprovalRuling,\n AparteToolResult,\n AparteToolHandler,\n AparteToolContext,\n AparteToolRenderer,\n AparteToolSummary,\n AparteToolInputFormatter,\n AparteToolMatcher,\n AparteToolDisplay,\n AparteToolDetails,\n AparteToolCallView,\n AparteMountedView,\n AparteToolMount,\n AparteToolApprovalRequestDetail,\n AparteChatImperativeApi,\n AparteUiHandle,\n AparteElementAttributes,\n AparteElementTagName,\n AparteAttrValue,\n AparteTemplateAttrs,\n AparteNoAttributes,\n AparteChatAttributes,\n AparteChatViewportAttributes,\n AparteChatBubbleAttributes,\n AparteChatStatusAttributes,\n AparteComposerAttributes,\n AparteComposerInputAttributes,\n AparteComposerActionAttributes,\n AparteComposerAddAttachmentAttributes,\n AparteComposerToolbarAttributes,\n AparteConversationListAttributes,\n AparteSelectAttributes,\n AparteOptionAttributes,\n AparteOptgroupAttributes,\n AparteProgressSpinnerAttributes,\n AparteContextAttributes,\n AparteIconAttributes,\n AparteScrollRailAttributes,\n AparteSidebarAttributes,\n AparteSplitAttributes,\n AparteSuggestionsAttributes,\n} from './types/index.js';\nexport { AparteErrorCode, AparteError, contentToText } from './types/index.js';\n\n// Custom-element TYPES (erased) — keep server consumers fully typed.\n//\n// The element CLASSES too, as types: `frameworks/elements.md` promises the `node`\n// condition keeps \"every type\", and a server-side consumer typing a ref\n// (`ref: AparteChat`) or a wrapper's imperative surface needs the class's instance\n// type without its `HTMLElement` runtime. `export type` erases the value, so nothing\n// here touches the DOM at import.\nexport type {\n AparteChat, AparteChatBubble, AparteChatViewport, AparteChatStatus,\n AparteComposer, AparteComposerInput, AparteComposerSend, AparteComposerCancel,\n AparteComposerAttachments, AparteComposerAddAttachment, AparteComposerAction, AparteComposerToolbar,\n AparteSuggestions, AparteContext, AparteConversationList, AparteScrollRail, AparteSidebar,\n AparteSplit,\n} from './components/index.js';\nexport type { AparteScrollRailJumpDetail, AparteScrollRailEvery, AparteSidebarToggleDetail } from './components/index.js';\nexport type { AparteSplitResizeDetail } from './components/index.js';\nexport type { AparteElicitation } from './components/elicitation/aparte-elicitation.js';\nexport type { AparteSelect, AparteOption, AparteOptgroup, AparteIcon, AparteProgressSpinner } from './primitives/index.js';\nexport type { AparteSelectChangeDetail, AparteOptgroupToggleEventDetail } from './primitives/index.js';\nexport type { SyncableBubble, AparteComposerEventMap, AparteComposerEventType, AparteComposerState, AparteComposerChangeEventDetail, AparteComposerPanelMode, AparteActionClickEventDetail } from './components/index.js';\nexport type { AparteConversationListItem, AparteConversationSelectDetail, AparteConversationDeleteDetail, AparteConversationArchiveDetail, AparteConversationPinDetail, AparteConversationRenameDetail, AparteConversationStatus, AparteConversationStatusDetail } from './components/index.js';\nexport type { AparteSuggestion, AparteSuggestionEventDetail } from './components/index.js';\nexport type { AparteContextLevel, AparteContextThresholdEventDetail } from './components/index.js';\n\n// ── Renderers (produce HTML strings; DOM-free at import) ────────────────────\nexport {\n registerSegmentRenderer,\n unregisterSegmentRenderer,\n getSegmentRenderer,\n collectRendererStyles,\n registerDefaultRenderers,\n installDefaultRenderersOnce,\n declineDefaultRenderers,\n getAllRenderers,\n overrideSegmentRenderer,\n defineMountedToolRenderer,\n defineMountedSegmentRenderer,\n toToolCallView,\n} from './renderers/index.js';\n\n// `populateBubbleFromMessage` is a plain helper — import it from its own module,\n// NOT the components barrel (which would pull in the HTMLElement classes).\nexport { populateBubbleFromMessage } from './components/bubble/bubble-sync.js';\n\n// ── Conversations (types, adapter contract, manager, controller) ────────────\nexport type {\n AparteConversation,\n AparteConversationMeta,\n AparteStorageAdapter,\n AparteAttachmentRow,\n AparteConversationLoadedDetail,\n} from './conversations/index.js';\nexport { APARTE_CONVERSATION_SCHEMA_VERSION } from './conversations/index.js';\nexport {\n AparteConversationManager,\n type ConversationManagerOptions,\n type AparteConversationsListener,\n type AparteConversationTitleProvider,\n} from './conversations/index.js';\nexport {\n AparteConversationController,\n type AparteChatBinding,\n type AparteConversationControllerOptions,\n} from './conversations/index.js';\n\n// ── Framework-agnostic chat-host orchestrator (every wrapper binds to it) ───\nexport {\n AparteChatHost,\n type AparteChatHostBinding,\n type AparteChatHostOptions,\n} from './host/index.js';\n\n// ── Parsers ─────────────────────────────────────────────────────────────────\nexport { AparteStreamParser, parseMarkdownToSegments, parseAparteEventStream } from './parsers/index.js';\nexport type { AparteStreamParserOptions, AparteThinkingDelimiterPair, AparteParserState, AparteParserResult } from './parsers/index.js';\n\n// Transport seam — DOM-free (fetch-based), so the whole seam is SSR-safe. The\n// server-side `/api/chat` handler AND both client transports live here; a browser\n// never runs the handler, and the transports touch no DOM at import. Mirrored in\n// full so a wrapper barrel re-exporting a transport can't crash under SSR.\nexport { AparteDirectTransport, AparteBackendTransport, createAparteChatHandler, createAparteAgentHandler, isFormatAdapter } from './transport/index.js';\nexport type {\n AparteTransport,\n AparteTransportContext,\n AparteFormatAdapter,\n AparteVendorRequest,\n BackendTransportOptions,\n DirectTransportOptions,\n AparteChatHandlerOptions,\n AparteAgentHandlerOptions,\n AparteAgentTool,\n AparteAgentRequestBody,\n} from './transport/index.js';\n\n// ── Config ──────────────────────────────────────────────────────────────────\nexport { aparteGlobalConfig, AparteConfig, APARTE_DEFAULT_BUBBLE_ACTIONS, APARTE_DEFAULT_HOST_HANDLERS } from './config/index.js';\nexport type { AparteConfigChangeEventDetail } from './config/index.js';\nexport { resolveConfig, attachConfig, detachConfig, runWithConfig, contextConfig, APARTE_HOST_ATTR } from './config/index.js';\nexport { subscribeConfigChange, APARTE_CONFIG_CHANGE } from './config/index.js';\nexport type { AparteConfigAware } from './config/index.js';\nexport type {\n AparteMarkdownProvider,\n AparteStreamingMarkdownProvider,\n AparteStreamingMarkdownRenderer,\n AparteHighlightProvider,\n AparteSystemPromptVarsProvider,\n AparteLocale,\n AparteLocaleExtensions,\n AparteAction,\n AparteActionZone,\n AparteIconProvider,\n AparteIconName,\n AparteCoreIconName,\n AparteAvatarProvider,\n AparteStatusRenderer,\n AparteErrorRenderer,\n AparteAttachmentRenderer,\n AparteElicitationFieldRenderer,\n AparteElicitationFieldContext,\n AparteElicitationFieldControl,\n AparteSiblingNavRenderer,\n AparteBubbleShellRenderer,\n AparteModelPreference,\n AparteModelPreferenceProvider,\n AparteSanitizer,\n} from './config/index.js';\nexport { APARTE_DEFAULT_ICON_FALLBACKS, APARTE_DEFAULT_LOCALE, defaultSanitizer, isSafeUrl } from './config/index.js';\n\n// ── Client + runtime ─────────────────────────────────────────────────────────\nexport { AparteClient } from './client/aparte-client.js';\nexport type { AparteClientOptions, AparteToolApprovalResolver } from './client/aparte-client.js';\nexport { createStreamAdapter, readableToAsyncIterable } from './client/stream-adapter.js';\nexport { toolRefusal } from './client/stream-adapter.js';\nexport { createAgentStreamRunner, type AgentStreamRunnerOptions } from './client/agent-runner.js';\nexport type { AparteStreamRunEvent, AparteStreamRunEmitter, StreamAdapterTarget, CreateStreamAdapterOptions, AparteStreamRunner, AparteStreamRunOptions } from './client/stream-adapter.js';\nexport { AparteMessageRepository } from './runtime/message-repository.js';\nexport type { ExportedMessageRepository } from './runtime/message-repository.js';\n\n// ── Wrapper interop (DOM-free helpers the four wrappers' AparteUi value-imports) ─\n// `applyElementProps`/`APARTE_DEFAULT_UI_EVENTS` are pure (a string array + a function that\n// only touches its `HTMLElement` argument when CALLED, never at import). They MUST be\n// on the Node surface: every wrapper barrel re-exports `AparteUi`, which value-imports\n// these two — omit them here and any SSR toolchain resolving the `node` condition\n// crashes the whole barrel with \"does not provide an export named 'applyElementProps'\".\nexport { applyElementProps, APARTE_DEFAULT_UI_EVENTS } from './interop/element-props.js';\n// A type, so it costs nothing here and its absence WAS a compile error for an SSR\n// consumer — `check:node-barrel-types` caught it the moment the browser barrel gained it.\nexport type { AparteUiEventName } from './interop/element-props.js';\n// Same rule: DOM-free at import (it only reaches for `URL.createObjectURL` when\n// CALLED, which is a browser-side concern), so it belongs on the SSR surface too.\nexport { filesToAttachments, revokeAttachmentUrls } from './utils/files-to-attachments.js';\n\n/*\n * The global type augmentations, which only the BROWSER entry pulled in.\n *\n * TypeScript applies the `node` export condition under `moduleResolution: node16`\n * / `nodenext`, so a consumer in that mode resolves `index.node.d.ts` — and\n * silently lost typed `e.detail` on every aparté event and typed\n * `querySelector('aparte-…')`. Not a runtime concern and not an SSR hazard: both\n * modules are `import type` throughout, so nothing is emitted and no DOM global is\n * touched. `check:node-barrel-types` diffed export NAMES, which an augmentation\n * has none of, so it saw nothing.\n */\nimport './types/event-map.js';\nimport './types/element-map.js';\n// Is a message waiting for a reply? Shared by the viewport, the four wrappers and\n// any consumer rendering its own bubble — one rule, so they can't disagree.\nexport { isAwaitingReply } from './utils/is-awaiting-reply.js';\nexport { escapeHtml, escapeAttr } from './utils/escape.js';\n// Same reasoning as the browser barrel: the gate script and the customization\n// guide both tell a renderer author to use `cssEscape` for a selector, so it has to\n// be importable. It touches no DOM, so the SSR barrel carries it too.\nexport { cssEscape } from './utils/css-escape.js';\nexport { uuid } from './utils/uuid.js';\nexport { copyText } from './utils/copy-text.js';\n// Pure and DOM-free, so the SSR barrel carries it too — and that is the point: a\n// consumer can assert their own duration logic in Node, with no browser.\nexport { isSegmentSettled, segmentTiming, segmentDuration } from './utils/segments.js';\n// The PARAMETER types of two documented setters. They existed and were the declared\n// argument types, but were not exported — so anyone typing a settings layer over\n// `setHostHandlers` / `setKeyProvider` had to re-declare the shape by hand.\nexport type { AparteHostHandlersConfig } from './types/models.js';\nexport type { AparteKeyProvider } from './config/aparte-config.js';\n\n// Elicitation (human-in-the-loop typed input) — DOM-free at import.\nexport { requestUserInput, buildElicitationPanel, buildApprovalPanel, AparteElicitationAbortError } from './elicitation/index.js';\nexport type {\n AparteElicitationSchema,\n AparteElicitationField,\n AparteElicitationEnumField,\n AparteElicitationBooleanField,\n AparteElicitationStringField,\n AparteElicitationObjectSchema,\n AparteElicitationRequest,\n AparteElicitationResult,\n AparteElicitationPresenter,\n AparteApprovalOption,\n AparteApprovalAnswer,\n BuiltApprovalPanel,\n BuiltElicitationPanel,\n} from './elicitation/index.js';\n\n/**\n * No-op on the server: custom elements only exist in the browser, where the\n * real `index.ts` registers them at import time. Wrappers can call this\n * unconditionally without a `typeof window` guard.\n *\n * With ONE thing to say. A `customElements` here means a DOM is present and this\n * DOM-free entry was still the one that resolved — which is a test runner: vitest,\n * jest and friends run on Node, so they take the `node` export condition, and jsdom\n * then supplies the registry. Nothing upgrades, `<aparte-chat>` stays an\n * `HTMLElement`, and every assertion about an element's own properties fails for a\n * reason nothing on the page explains. The escape is `@aparte/core/browser`, which is\n * why that entry exists; before it, the only way out was to reach into this package's\n * `src/`. One warning, not a throw: the environment is legal, only surprising.\n */\nexport function registerAllComponents(): void {\n if (typeof customElements !== 'undefined') {\n console.warn(\n \"[aparte] A DOM is present but '@aparte/core' resolved to its DOM-free Node entry, \"\n + 'so no <aparte-*> element will upgrade. Test runners hit this: they run on Node, '\n + \"so they take the 'node' export condition. Point your runner at '@aparte/core/browser', \"\n // The bare specifier only: a string alias is a PREFIX, and would send\n // '@aparte/core/icons' to '@aparte/core/browser/icons', which does not exist.\n + \"matching the bare specifier only (vitest: test.alias \"\n + \"[{ find: /^@aparte\\\\/core$/, replacement: '@aparte/core/browser' }]).\",\n );\n }\n}\n// Pure until called; the browser entry calls it at import.\nexport { installDialogTriggersOnce } from './interop/dialog-triggers.js';\n// A wrapper imports the release on the server too, and calls it only once mounted in a browser.\nexport { deferHydrationOf, releaseDeferredHydration } from './interop/defer-hydration.js';\n"],"names":[],"mappings":";AA6WO,SAAS,wBAA8B;AAC1C,MAAI,OAAO,mBAAmB,aAAa;AACvC,YAAQ;AAAA,MACJ;AAAA,IAAA;AAAA,EAQR;AACJ;"}
|
|
1
|
+
{"version":3,"file":"index.node.js","sources":["../src/index.node.ts"],"sourcesContent":["/**\n * @aparte/core — Node.js / SSR-safe entry point.\n *\n * Resolved via the `node` export condition, so `import '@aparte/core'` in Node\n * (Next.js / Nuxt / Angular Universal / SvelteKit server, tsx, CLI tools) loads\n * THIS module instead of the browser entry — and via `worker`, `workerd`,\n * `edge-light`, `deno` and `bun` for a Cloudflare Worker, an edge route or a\n * `target: 'webworker'` build. A worker built with the page's conditions imports it\n * by name, as `@aparte/core/headless`. It exposes the same public API\n * surface MINUS the Web Components and CSS side-effects — importing the real\n * `index.ts` in Node throws `HTMLElement is not defined` because the custom\n * elements extend `HTMLElement` at module scope.\n *\n * Everything re-exported here is DOM-free at import time. Custom-element CLASSES\n * (AparteChatBubble, AparteComposer*, AparteSelect, …) are intentionally NOT exported\n * as runtime values — they only exist in the browser build. Their TYPES are\n * re-exported (types are erased, so they never pull DOM at runtime), which keeps\n * TypeScript consumers fully typed on the server; `registerAllComponents()` is a\n * no-op here (there is nothing to register without a DOM).\n */\n\n// ── Types (erased at runtime — always safe, mirror index.ts) ────────────────\nexport type {\n AparteBubbleRole,\n AparteMessage,\n AparteContextSummary,\n AparteCompactor,\n AparteCompactorRequest,\n AparteCompactorOutcome,\n AparteCompactorReason,\n AparteContentParser,\n AparteStreamBlock,\n AparteStreamBlockMatch,\n AparteSendEventDetail,\n AparteViewportConfig,\n AparteInputConfig,\n AparteThemeVariables,\n AparteStatus,\n AparteAttachment,\n AparteMessageBranch,\n AparteBubbleActionsConfig,\n AparteBubbleActionName,\n AparteSegment,\n AparteSegmentTypes,\n AparteSegmentType,\n AparteTextSegment,\n AparteThinkingSegment,\n AparteCodeSegment,\n AparteSegmentRenderer,\n AparteSegmentMount,\n AparteCustomSegment,\n AparteToolCallSegment,\n // The same five the browser barrel gained, and they belong here for the same reason:\n // a type has no DOM. `AparteSegmentBase` is the constraint on the exported\n // `AparteSegmentRenderer<T>`, so an SSR consumer writing a renderer for a segment type\n // of its own could not name what it extends. `check:node-barrel-types` is what caught\n // the omission — the browser barrel alone would have compiled fine and failed on the\n // `node` condition only.\n AparteSegmentBase,\n AparteSegmentDefaults,\n AparteSegmentTiming,\n AparteErrorSegment,\n // The detail of the `aparte-segment-update` event. It reached types/index.ts and\n // stopped there — and types/index.ts is not an entry point, so a consumer could\n // bind the event (it is in the published event table) and never name its detail.\n AparteSegmentUpdateEventDetail,\n AparteAIProvider,\n AparteAIModel,\n AparteAIProviderConfigField,\n AparteAIProviderMetadata,\n AparteAIProviderConfigSchema,\n AparteModelConfig,\n ModelStatus,\n ModelLoadProgress,\n AparteModelChangeEventDetail,\n AparteApprovalModeChangeEventDetail,\n AparteMessageDoneEventDetail,\n AparteMessageStartEventDetail,\n AparteMessageErrorEventDetail,\n AparteMessageAbortedEventDetail,\n AparteMessagePausedEventDetail,\n AparteMessageResumedEventDetail,\n AparteAbortEventDetail,\n AparteCompactEventDetail,\n AparteCompactDoneEventDetail,\n AparteCompactStartEventDetail,\n AparteCompactErrorEventDetail,\n AparteAttachmentPreviewEventDetail,\n AparteLinkClickEventDetail,\n AparteMessageInfoEventDetail,\n AparteSiblingInfo,\n AparteBranchNavigateEventDetail,\n ApartePathChangedEventDetail,\n AparteRetryEventDetail,\n AparteEditEventDetail,\n AparteFeedbackEventDetail,\n AparteActionEventDetail,\n AparteChatRequest,\n AparteRequestMeta,\n AparteChatResponse,\n AparteChatMessage,\n AparteContentPart,\n AparteTextPart,\n AparteImagePart,\n AparteStreamEvent,\n AparteStreamEventMap,\n AparteUsage,\n AparteFinishReason,\n AparteTool,\n AparteToolCall,\n AparteApprovalPolicy,\n AparteApprovalRuling,\n AparteToolResult,\n AparteToolHandler,\n AparteToolContext,\n AparteToolRenderer,\n AparteToolSummary,\n AparteToolInputFormatter,\n AparteToolMatcher,\n AparteToolDisplay,\n AparteToolDetails,\n AparteToolCallView,\n AparteMountedView,\n AparteToolMount,\n AparteToolApprovalRequestDetail,\n AparteChatImperativeApi,\n AparteUiHandle,\n AparteElementAttributes,\n AparteElementTagName,\n AparteAttrValue,\n AparteTemplateAttrs,\n AparteNoAttributes,\n AparteChatAttributes,\n AparteChatViewportAttributes,\n AparteChatBubbleAttributes,\n AparteChatStatusAttributes,\n AparteComposerAttributes,\n AparteComposerInputAttributes,\n AparteComposerActionAttributes,\n AparteComposerAddAttachmentAttributes,\n AparteComposerToolbarAttributes,\n AparteConversationListAttributes,\n AparteSelectAttributes,\n AparteOptionAttributes,\n AparteOptgroupAttributes,\n AparteProgressSpinnerAttributes,\n AparteContextAttributes,\n AparteIconAttributes,\n AparteScrollRailAttributes,\n AparteSidebarAttributes,\n AparteSplitAttributes,\n AparteSuggestionsAttributes,\n} from './types/index.js';\nexport { AparteErrorCode, AparteError, contentToText } from './types/index.js';\n\n// Custom-element TYPES (erased) — keep server consumers fully typed.\n//\n// The element CLASSES too, as types: `frameworks/elements.md` promises the `node`\n// condition keeps \"every type\", and a server-side consumer typing a ref\n// (`ref: AparteChat`) or a wrapper's imperative surface needs the class's instance\n// type without its `HTMLElement` runtime. `export type` erases the value, so nothing\n// here touches the DOM at import.\nexport type {\n AparteChat, AparteChatBubble, AparteChatViewport, AparteChatStatus,\n AparteComposer, AparteComposerInput, AparteComposerSend, AparteComposerCancel,\n AparteComposerAttachments, AparteComposerAddAttachment, AparteComposerAction, AparteComposerToolbar,\n AparteSuggestions, AparteContext, AparteConversationList, AparteScrollRail, AparteSidebar,\n AparteSplit,\n} from './components/index.js';\nexport type { AparteScrollRailJumpDetail, AparteScrollRailEvery, AparteSidebarToggleDetail } from './components/index.js';\nexport type { AparteSplitResizeDetail } from './components/index.js';\nexport type { AparteElicitation } from './components/elicitation/aparte-elicitation.js';\nexport type { AparteSelect, AparteOption, AparteOptgroup, AparteIcon, AparteProgressSpinner } from './primitives/index.js';\nexport type { AparteSelectChangeDetail, AparteOptgroupToggleEventDetail } from './primitives/index.js';\nexport type { SyncableBubble, AparteComposerEventMap, AparteComposerEventType, AparteComposerState, AparteComposerChangeEventDetail, AparteComposerPanelMode, AparteActionClickEventDetail } from './components/index.js';\nexport type { AparteConversationListItem, AparteConversationSelectDetail, AparteConversationDeleteDetail, AparteConversationArchiveDetail, AparteConversationPinDetail, AparteConversationRenameDetail, AparteConversationStatus, AparteConversationStatusDetail } from './components/index.js';\nexport type { AparteSuggestion, AparteSuggestionEventDetail } from './components/index.js';\nexport type { AparteContextLevel, AparteContextThresholdEventDetail } from './components/index.js';\n\n// ── Renderers (produce HTML strings; DOM-free at import) ────────────────────\nexport {\n registerSegmentRenderer,\n unregisterSegmentRenderer,\n getSegmentRenderer,\n collectRendererStyles,\n registerDefaultRenderers,\n installDefaultRenderersOnce,\n declineDefaultRenderers,\n getAllRenderers,\n overrideSegmentRenderer,\n defineMountedToolRenderer,\n defineMountedSegmentRenderer,\n toToolCallView,\n} from './renderers/index.js';\n\n// `populateBubbleFromMessage` is a plain helper — import it from its own module,\n// NOT the components barrel (which would pull in the HTMLElement classes).\nexport { populateBubbleFromMessage } from './components/bubble/bubble-sync.js';\n\n// ── Conversations (types, adapter contract, manager, controller) ────────────\nexport type {\n AparteConversation,\n AparteConversationMeta,\n AparteStorageAdapter,\n AparteAttachmentRow,\n AparteConversationLoadedDetail,\n} from './conversations/index.js';\nexport { APARTE_CONVERSATION_SCHEMA_VERSION } from './conversations/index.js';\nexport {\n AparteConversationManager,\n type ConversationManagerOptions,\n type AparteConversationsListener,\n type AparteConversationTitleProvider,\n} from './conversations/index.js';\nexport {\n AparteConversationController,\n type AparteChatBinding,\n type AparteConversationControllerOptions,\n} from './conversations/index.js';\n\n// ── Framework-agnostic chat-host orchestrator (every wrapper binds to it) ───\nexport {\n AparteChatHost,\n type AparteChatHostBinding,\n type AparteChatHostOptions,\n} from './host/index.js';\n\n// ── Parsers ─────────────────────────────────────────────────────────────────\nexport { AparteStreamParser, parseMarkdownToSegments, parseAparteEventStream } from './parsers/index.js';\nexport type { AparteStreamParserOptions, AparteThinkingDelimiterPair, AparteParserState, AparteParserResult } from './parsers/index.js';\n\n// Transport seam — DOM-free (fetch-based), so the whole seam is SSR-safe. The\n// server-side `/api/chat` handler AND both client transports live here; a browser\n// never runs the handler, and the transports touch no DOM at import. Mirrored in\n// full so a wrapper barrel re-exporting a transport can't crash under SSR.\nexport { AparteDirectTransport, AparteBackendTransport, createAparteChatHandler, createAparteAgentHandler, isFormatAdapter } from './transport/index.js';\nexport type {\n AparteTransport,\n AparteTransportContext,\n AparteFormatAdapter,\n AparteVendorRequest,\n BackendTransportOptions,\n DirectTransportOptions,\n AparteChatHandlerOptions,\n AparteAgentHandlerOptions,\n AparteAgentTool,\n AparteAgentRequestBody,\n} from './transport/index.js';\n\n// ── Config ──────────────────────────────────────────────────────────────────\nexport { aparteGlobalConfig, AparteConfig, APARTE_DEFAULT_BUBBLE_ACTIONS, APARTE_DEFAULT_HOST_HANDLERS } from './config/index.js';\nexport type { AparteConfigChangeEventDetail } from './config/index.js';\nexport { resolveConfig, attachConfig, detachConfig, runWithConfig, contextConfig, APARTE_HOST_ATTR } from './config/index.js';\nexport { subscribeConfigChange, APARTE_CONFIG_CHANGE } from './config/index.js';\nexport type { AparteConfigAware } from './config/index.js';\nexport type {\n AparteMarkdownProvider,\n AparteStreamingMarkdownProvider,\n AparteStreamingMarkdownRenderer,\n AparteHighlightProvider,\n AparteSystemPromptVarsProvider,\n AparteLocale,\n AparteLocaleExtensions,\n AparteAction,\n AparteActionZone,\n AparteIconProvider,\n AparteIconName,\n AparteCoreIconName,\n AparteAvatarProvider,\n AparteStatusRenderer,\n AparteErrorRenderer,\n AparteAttachmentRenderer,\n AparteElicitationFieldRenderer,\n AparteElicitationFieldContext,\n AparteElicitationFieldControl,\n AparteSiblingNavRenderer,\n AparteBubbleShellRenderer,\n AparteModelPreference,\n AparteModelPreferenceProvider,\n AparteSanitizer,\n} from './config/index.js';\nexport { APARTE_DEFAULT_ICON_FALLBACKS, APARTE_DEFAULT_LOCALE, defaultSanitizer, isSafeUrl } from './config/index.js';\n\n// ── Client + runtime ─────────────────────────────────────────────────────────\nexport { AparteClient } from './client/aparte-client.js';\nexport { historyFromCheckpoint } from './context/checkpoint.js';\nexport { estimateTokens, estimateWireTokens, measureContext } from './context/measure.js';\nexport type { AparteContextMeasure, AparteContextMeasureInput } from './context/measure.js';\nexport type { AparteClientOptions, AparteToolApprovalResolver } from './client/aparte-client.js';\nexport { createStreamAdapter, readableToAsyncIterable } from './client/stream-adapter.js';\nexport { toolRefusal } from './client/stream-adapter.js';\nexport { createAgentStreamRunner, type AgentStreamRunnerOptions } from './client/agent-runner.js';\nexport type { AparteStreamRunEvent, AparteStreamRunEmitter, StreamAdapterTarget, CreateStreamAdapterOptions, AparteStreamRunner, AparteStreamRunOptions } from './client/stream-adapter.js';\nexport { AparteMessageRepository } from './runtime/message-repository.js';\nexport type { ExportedMessageRepository } from './runtime/message-repository.js';\n\n// ── Wrapper interop (DOM-free helpers the four wrappers' AparteUi value-imports) ─\n// `applyElementProps`/`APARTE_DEFAULT_UI_EVENTS` are pure (a string array + a function that\n// only touches its `HTMLElement` argument when CALLED, never at import). They MUST be\n// on the Node surface: every wrapper barrel re-exports `AparteUi`, which value-imports\n// these two — omit them here and any SSR toolchain resolving the `node` condition\n// crashes the whole barrel with \"does not provide an export named 'applyElementProps'\".\nexport { applyElementProps, APARTE_DEFAULT_UI_EVENTS } from './interop/element-props.js';\n// A type, so it costs nothing here and its absence WAS a compile error for an SSR\n// consumer — `check:node-barrel-types` caught it the moment the browser barrel gained it.\nexport type { AparteUiEventName } from './interop/element-props.js';\n// Same rule: DOM-free at import (it only reaches for `URL.createObjectURL` when\n// CALLED, which is a browser-side concern), so it belongs on the SSR surface too.\nexport { filesToAttachments, revokeAttachmentUrls } from './utils/files-to-attachments.js';\n\n/*\n * The global type augmentations, which only the BROWSER entry pulled in.\n *\n * TypeScript applies the `node` export condition under `moduleResolution: node16`\n * / `nodenext`, so a consumer in that mode resolves `index.node.d.ts` — and\n * silently lost typed `e.detail` on every aparté event and typed\n * `querySelector('aparte-…')`. Not a runtime concern and not an SSR hazard: both\n * modules are `import type` throughout, so nothing is emitted and no DOM global is\n * touched. `check:node-barrel-types` diffed export NAMES, which an augmentation\n * has none of, so it saw nothing.\n */\nimport './types/event-map.js';\nimport './types/element-map.js';\n// Is a message waiting for a reply? Shared by the viewport, the four wrappers and\n// any consumer rendering its own bubble — one rule, so they can't disagree.\nexport { isAwaitingReply } from './utils/is-awaiting-reply.js';\nexport { escapeHtml, escapeAttr } from './utils/escape.js';\n// Same reasoning as the browser barrel: the gate script and the customization\n// guide both tell a renderer author to use `cssEscape` for a selector, so it has to\n// be importable. It touches no DOM, so the SSR barrel carries it too.\nexport { cssEscape } from './utils/css-escape.js';\nexport { uuid } from './utils/uuid.js';\nexport { copyText } from './utils/copy-text.js';\n// Pure and DOM-free, so the SSR barrel carries it too — and that is the point: a\n// consumer can assert their own duration logic in Node, with no browser.\nexport { isSegmentSettled, segmentTiming, segmentDuration } from './utils/segments.js';\n// The PARAMETER types of two documented setters. They existed and were the declared\n// argument types, but were not exported — so anyone typing a settings layer over\n// `setHostHandlers` / `setKeyProvider` had to re-declare the shape by hand.\nexport type { AparteHostHandlersConfig } from './types/models.js';\nexport type { AparteKeyProvider } from './config/aparte-config.js';\n\n// Elicitation (human-in-the-loop typed input) — DOM-free at import.\nexport { requestUserInput, buildElicitationPanel, buildApprovalPanel, AparteElicitationAbortError } from './elicitation/index.js';\nexport type {\n AparteElicitationSchema,\n AparteElicitationField,\n AparteElicitationEnumField,\n AparteElicitationBooleanField,\n AparteElicitationStringField,\n AparteElicitationObjectSchema,\n AparteElicitationRequest,\n AparteElicitationResult,\n AparteElicitationPresenter,\n AparteApprovalOption,\n AparteApprovalAnswer,\n BuiltApprovalPanel,\n BuiltElicitationPanel,\n} from './elicitation/index.js';\n\n/**\n * No-op on the server: custom elements only exist in the browser, where the\n * real `index.ts` registers them at import time. Wrappers can call this\n * unconditionally without a `typeof window` guard.\n *\n * With ONE thing to say. A `customElements` here means a DOM is present and this\n * DOM-free entry was still the one that resolved — which is a test runner: vitest,\n * jest and friends run on Node, so they take the `node` export condition, and jsdom\n * then supplies the registry. Nothing upgrades, `<aparte-chat>` stays an\n * `HTMLElement`, and every assertion about an element's own properties fails for a\n * reason nothing on the page explains. The escape is `@aparte/core/browser`, which is\n * why that entry exists; before it, the only way out was to reach into this package's\n * `src/`. One warning, not a throw: the environment is legal, only surprising.\n */\nexport function registerAllComponents(): void {\n if (typeof customElements !== 'undefined') {\n console.warn(\n \"[aparte] A DOM is present but '@aparte/core' resolved to its DOM-free Node entry, \"\n + 'so no <aparte-*> element will upgrade. Test runners hit this: they run on Node, '\n + \"so they take the 'node' export condition. Point your runner at '@aparte/core/browser', \"\n // The bare specifier only: a string alias is a PREFIX, and would send\n // '@aparte/core/icons' to '@aparte/core/browser/icons', which does not exist.\n + \"matching the bare specifier only (vitest: test.alias \"\n + \"[{ find: /^@aparte\\\\/core$/, replacement: '@aparte/core/browser' }]).\",\n );\n }\n}\n// Pure until called; the browser entry calls it at import.\nexport { installDialogTriggersOnce } from './interop/dialog-triggers.js';\n// A wrapper imports the release on the server too, and calls it only once mounted in a browser.\nexport { deferHydrationOf, releaseDeferredHydration } from './interop/defer-hydration.js';\n"],"names":[],"mappings":";AAsXO,SAAS,wBAA8B;AAC1C,MAAI,OAAO,mBAAmB,aAAa;AACvC,YAAQ;AAAA,MACJ;AAAA,IAAA;AAAA,EAQR;AACJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-handler.d.ts","sourceRoot":"","sources":["../../src/transport/agent-handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAqB,qBAAqB,EAAkB,MAAM,gBAAgB,CAAC;AAC/F,OAAO,KAAK,EAAE,iBAAiB,EAAqB,MAAM,kBAAkB,CAAC;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAkB,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC7G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;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,WAAW,sBAAsB;IACnC,CAAC,EAAE,CAAC,CAAC;IACL,kFAAkF;IAClF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,iBAAiB,CAAC;IAC3B,iFAAiF;IACjF,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,MAAM,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAA;KAAE,CAAC;CAChF;AAID;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CA+MhH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend-handler.d.ts","sourceRoot":"","sources":["../../src/transport/backend-handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"backend-handler.d.ts","sourceRoot":"","sources":["../../src/transport/backend-handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAInE,MAAM,WAAW,wBAAwB;IACrC;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC5C;;;;;;;;;;;;;OAaG;IACH,SAAS,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC,OAAO,GAAG,QAAQ,CAAC,CAAC;IAC9E;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACtF;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,uBAAuB,CACnC,OAAO,EAAE,wBAAwB,GAClC,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAwJrC"}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import type { AparteChatRequest, AparteChatResponse, AparteStreamEvent } from '../types/chat.js';
|
|
16
16
|
import type { AparteAIProvider } from '../types/model-provider.js';
|
|
17
|
-
import { AparteError } from '../types/errors.js';
|
|
17
|
+
import { AparteError, AparteErrorCode } from '../types/errors.js';
|
|
18
18
|
/** A vendor HTTP request built from an Aparte request — auth is injected separately. */
|
|
19
19
|
export interface AparteVendorRequest {
|
|
20
20
|
/** Appended to the transport's endpoint, e.g. `/chat/completions`. */
|
|
@@ -39,6 +39,21 @@ export interface AparteFormatAdapter {
|
|
|
39
39
|
parseStream(body: ReadableStream<Uint8Array>): ReadableStream<AparteStreamEvent>;
|
|
40
40
|
/** Extract text from a non-streaming vendor JSON response. */
|
|
41
41
|
parseText?(json: unknown): string;
|
|
42
|
+
/**
|
|
43
|
+
* Name the failure of a non-ok vendor response, for the ones a status cannot: a 400
|
|
44
|
+
* whose body says the prompt overflowed the model's window is `USAGE_CONTEXT_EXCEEDED`,
|
|
45
|
+
* not a bad request, and the client acts on the first (it compacts and resends). Return
|
|
46
|
+
* `undefined` to leave the status to say what it says.
|
|
47
|
+
*
|
|
48
|
+
* It is the adapter's because what a vendor writes for an overflow is its wire format —
|
|
49
|
+
* the same reason `parseStream` is — and core must not learn every server's wording.
|
|
50
|
+
* It runs on the page for a direct call and on the server for the backend handler, which
|
|
51
|
+
* forwards only the code it returns (never the vendor's prose).
|
|
52
|
+
*
|
|
53
|
+
* @param status The HTTP status.
|
|
54
|
+
* @param body The response body, parsed as JSON; `undefined` when it was not JSON.
|
|
55
|
+
*/
|
|
56
|
+
classifyError?(status: number, body: unknown): AparteErrorCode | undefined;
|
|
42
57
|
}
|
|
43
58
|
export interface AparteTransportContext {
|
|
44
59
|
providerId: string;
|
|
@@ -63,10 +78,15 @@ export declare function readAuth(auth: string | Record<string, string> | undefin
|
|
|
63
78
|
export declare function vendorErrorMessage(response: Response, label?: string): Promise<string>;
|
|
64
79
|
/**
|
|
65
80
|
* The error a non-ok vendor/backend response becomes: the message the body carries
|
|
66
|
-
* (or `${label} ${status}`), the status, and the code that
|
|
67
|
-
* 429 and a 503 are told apart by a listener
|
|
81
|
+
* (or `${label} ${status}`), the status, and the code that says what happened — so a
|
|
82
|
+
* 429 and a 503 are told apart by a listener, and an overflowing prompt from a
|
|
83
|
+
* malformed one.
|
|
84
|
+
*
|
|
85
|
+
* The code is, in order: the adapter's own reading of the body (`classifyError`, direct
|
|
86
|
+
* calls), the `error.code` a backend handler forwarded when it is one of ours (a vendor's
|
|
87
|
+
* own `context_length_exceeded` is not, and is ignored here), then the status.
|
|
68
88
|
*/
|
|
69
|
-
export declare function vendorError(response: Response, label?: string): Promise<AparteError>;
|
|
89
|
+
export declare function vendorError(response: Response, label?: string, adapter?: Pick<AparteFormatAdapter, 'classifyError'>): Promise<AparteError>;
|
|
70
90
|
/**
|
|
71
91
|
* Resolve a non-streaming response to text via the adapter's `parseText`.
|
|
72
92
|
* Both transports use this so `stream: false` behaves identically. It throws when the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/transport/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACjG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/transport/types.ts"],"names":[],"mappings":"AAAA;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 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { AparteTool, AparteToolCall } from './tools.js';
|
|
5
5
|
import type { AparteSegment } from './segments.js';
|
|
6
|
+
import type { AparteErrorCode } from './errors.js';
|
|
6
7
|
/** Plain text content part */
|
|
7
8
|
export interface AparteTextPart {
|
|
8
9
|
type: 'text';
|
|
@@ -161,6 +162,14 @@ export interface AparteUsage {
|
|
|
161
162
|
*/
|
|
162
163
|
phases?: AparteUsage[];
|
|
163
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Why the model stopped writing, as the provider reported it. The values are the AI SDK's:
|
|
167
|
+
* `'length'` is the one core acts on — the reply hit the output limit or the context window
|
|
168
|
+
* and is cut off, which a finished reply must not look like. A provider maps its own
|
|
169
|
+
* vocabulary (`finish_reason: "tool_calls"`, `stop_reason: "max_tokens"`…) onto these, and
|
|
170
|
+
* anything it cannot place is `'other'`.
|
|
171
|
+
*/
|
|
172
|
+
export type AparteFinishReason = 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other';
|
|
164
173
|
/**
|
|
165
174
|
* Normalized stream event map — extensible via declaration merging.
|
|
166
175
|
*
|
|
@@ -179,12 +188,18 @@ export interface AparteStreamEventMap {
|
|
|
179
188
|
thinking: {
|
|
180
189
|
delta: string;
|
|
181
190
|
};
|
|
182
|
-
/** Emitted when the stream ends. May carry token usage reported by the provider. */
|
|
191
|
+
/** Emitted when the stream ends. May carry token usage and the finish reason reported by the provider. */
|
|
183
192
|
done: {
|
|
184
193
|
usage?: AparteUsage;
|
|
194
|
+
finishReason?: AparteFinishReason;
|
|
185
195
|
};
|
|
196
|
+
/**
|
|
197
|
+
* A failure mid-stream. `code` names it when the provider can tell (an overflowing prompt
|
|
198
|
+
* is `USAGE_CONTEXT_EXCEEDED`), so the client can act on the code instead of reading prose.
|
|
199
|
+
*/
|
|
186
200
|
error: {
|
|
187
201
|
message: string;
|
|
202
|
+
code?: AparteErrorCode;
|
|
188
203
|
};
|
|
189
204
|
tool_use: AparteToolCall;
|
|
190
205
|
}
|
package/dist/types/chat.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/types/chat.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAMnD,8BAA8B;AAC9B,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,cAAc,GAAG,eAAe,CAAC;AAEjE;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,EAAE,GAAG,MAAM,CAM3E;AAED,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC/C;;;;;;OAMG;IACH,OAAO,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAAC;IACtC;;;OAGG;IACH,SAAS,CAAC,EAAE,cAAc,EAAE,CAAC;IAC7B,oGAAoG;IACpG,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAC9B,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,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C,EAAE,MAAM,CAAC;IAChB,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,QAAQ,GAAG,gBAAgB,GAAG,YAAY,GAAG,OAAO,GAAG,OAAO,CAAC;AAEzG;;;;;;;;;;GAUG;AACH,MAAM,WAAW,oBAAoB;IACjC,IAAI,EAAM;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAC3B,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAC3B,0GAA0G;IAC1G,IAAI,EAAM;QAAE,KAAK,CAAC,EAAE,WAAW,CAAC;QAAC,YAAY,CAAC,EAAE,kBAAkB,CAAA;KAAE,CAAA;IACpE;;;OAGG;IACH,KAAK,EAAK;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,eAAe,CAAA;KAAE,CAAA;IACrD,QAAQ,EAAE,cAAc,CAAA;CAC3B;AAED,2FAA2F;AAC3F,MAAM,MAAM,iBAAiB,GAAG;KAC3B,CAAC,IAAI,MAAM,oBAAoB,GAAG;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,GAAG,oBAAoB,CAAC,CAAC,CAAC;CAC3E,CAAC,MAAM,oBAAoB,CAAC,CAAA;AAE7B,MAAM,MAAM,kBAAkB,GAAG,cAAc,CAAC,iBAAiB,CAAC,GAAG,MAAM,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { AparteCompactDoneEventDetail } from './events.js';
|
|
2
|
+
/**
|
|
3
|
+
* Why a compactor was asked.
|
|
4
|
+
*
|
|
5
|
+
* `manual` is a person's click (the gauge's Compact now, a separator's Retry), `auto` the
|
|
6
|
+
* policy's own decision after a turn or before a send, `retry` an attempt made again after
|
|
7
|
+
* a failure, `overflow` the model refusing a request as over its window — the one that
|
|
8
|
+
* has to run, whatever the back-off says.
|
|
9
|
+
*/
|
|
10
|
+
export type AparteCompactorReason = 'manual' | 'retry' | 'overflow' | 'auto';
|
|
11
|
+
/** What a compactor is asked to do — one chat, named by its element and, when it has one, its id. */
|
|
12
|
+
export interface AparteCompactorRequest {
|
|
13
|
+
/** The chat's element. Passed, not only its id: a chat inside a shadow root is not found by id. */
|
|
14
|
+
target: Element | null;
|
|
15
|
+
/** The chat's id, when it has one. */
|
|
16
|
+
targetId?: string;
|
|
17
|
+
/** Compact even when the policy would not (below the threshold, after repeated failures). */
|
|
18
|
+
force?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Ids of messages that belong to a turn being prepared — the user message and the reply
|
|
21
|
+
* placeholder of a send or retry in progress. They are not summarised and do not count
|
|
22
|
+
* as "a turn in flight".
|
|
23
|
+
*/
|
|
24
|
+
exclude?: string[];
|
|
25
|
+
reason?: AparteCompactorReason;
|
|
26
|
+
/**
|
|
27
|
+
* Aborted when the turn the compaction serves is stopped — the client's Stop or a
|
|
28
|
+
* programmatic `abort()` / `stop()`. The compactor cancels its summary then, so a
|
|
29
|
+
* stopped turn neither pays for one nor writes a checkpoint into a chat left behind.
|
|
30
|
+
*/
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* How a compaction ended. It never rejects: a refusal and a failure are outcomes, so the
|
|
35
|
+
* caller reads `ok` and does not need a `try`. The same information goes out as
|
|
36
|
+
* `aparte-compact-done` / `aparte-compact-error`.
|
|
37
|
+
*/
|
|
38
|
+
export type AparteCompactorOutcome = {
|
|
39
|
+
ok: true;
|
|
40
|
+
skipped: true;
|
|
41
|
+
/** Why nothing was done — the same list `aparte-compact-done` carries. */
|
|
42
|
+
reason: NonNullable<AparteCompactDoneEventDetail['reason']>;
|
|
43
|
+
targetId?: string;
|
|
44
|
+
} | {
|
|
45
|
+
ok: true;
|
|
46
|
+
skipped: false;
|
|
47
|
+
summary: string;
|
|
48
|
+
/** Messages kept verbatim after the summary. */
|
|
49
|
+
kept: number;
|
|
50
|
+
/** Messages this compaction summarised. */
|
|
51
|
+
dropped: number;
|
|
52
|
+
/** The message that now carries the checkpoint. */
|
|
53
|
+
messageId?: string;
|
|
54
|
+
/** Messages of the path the checkpoint stands for, an earlier summary's included. */
|
|
55
|
+
count?: number;
|
|
56
|
+
targetId?: string;
|
|
57
|
+
} | {
|
|
58
|
+
ok: false;
|
|
59
|
+
error: string;
|
|
60
|
+
targetId?: string;
|
|
61
|
+
messageId?: string;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* The seam between the parts of core that need the context made smaller (the gauge's
|
|
65
|
+
* Compact now, a separator's Retry, the client before a send and after an overflow) and
|
|
66
|
+
* whatever makes it smaller. `@aparte/plugin-compaction` registers itself as the compactor
|
|
67
|
+
* with `AparteConfig.setCompactor()`; core never compacts by itself.
|
|
68
|
+
*
|
|
69
|
+
* It is a seam and not an event because the caller needs the answer: the client rebuilds a
|
|
70
|
+
* request once the summary is written, and a button shows that it is working.
|
|
71
|
+
*/
|
|
72
|
+
export interface AparteCompactor {
|
|
73
|
+
/** Compact one chat. Never rejects. */
|
|
74
|
+
compact(request: AparteCompactorRequest): Promise<AparteCompactorOutcome>;
|
|
75
|
+
/** Resolves when no compaction of this chat is running — a send never races a summary. */
|
|
76
|
+
settled(targetId?: string): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Before a send's request goes out, with the estimate of that request. Resolves `true`
|
|
79
|
+
* when it compacted, so the caller builds the request again.
|
|
80
|
+
*/
|
|
81
|
+
beforeSend?(request: {
|
|
82
|
+
target: Element | null;
|
|
83
|
+
targetId?: string;
|
|
84
|
+
/** The turn being prepared: its user message and reply placeholder. */
|
|
85
|
+
exclude: string[];
|
|
86
|
+
/** The estimate, in tokens, of the request about to be sent. */
|
|
87
|
+
requestTokens: number;
|
|
88
|
+
/** Aborted when the turn is stopped; the compactor cancels any summary it started for it. */
|
|
89
|
+
signal?: AbortSignal;
|
|
90
|
+
}): Promise<boolean>;
|
|
91
|
+
/**
|
|
92
|
+
* What compacting now would do: how many messages it would summarise and the tokens that
|
|
93
|
+
* would free, or `null` when there is nothing to do. The gauge offers "Compact now" only
|
|
94
|
+
* when this returns something.
|
|
95
|
+
*/
|
|
96
|
+
preview?(request: {
|
|
97
|
+
target: Element | null;
|
|
98
|
+
targetId?: string;
|
|
99
|
+
}): {
|
|
100
|
+
messages: number;
|
|
101
|
+
tokens: number;
|
|
102
|
+
} | null;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=compactor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compactor.d.ts","sourceRoot":"","sources":["../../src/types/compactor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAEhE;;;;;;;GAOG;AACH,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,CAAC;AAE7E,qGAAqG;AACrG,MAAM,WAAW,sBAAsB;IACnC,mGAAmG;IACnG,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,sCAAsC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6FAA6F;IAC7F,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B;;;;OAIG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAC5B;IACE,EAAE,EAAE,IAAI,CAAC;IACT,OAAO,EAAE,IAAI,CAAC;IACd,0EAA0E;IAC1E,MAAM,EAAE,WAAW,CAAC,4BAA4B,CAAC,QAAQ,CAAC,CAAC,C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AAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CACjH"}
|
package/dist/types/errors.d.ts
CHANGED
|
@@ -30,6 +30,8 @@ export declare class AparteError extends Error {
|
|
|
30
30
|
*/
|
|
31
31
|
static codeForStatus(status: number | undefined): AparteErrorCode | undefined;
|
|
32
32
|
static from(error: unknown, defaultCode?: AparteErrorCode, defaultStatus?: number): AparteError;
|
|
33
|
+
/** The value as an {@link AparteErrorCode}, when it is one — a Node `ECONNRESET` or a vendor's own string is not. */
|
|
34
|
+
private static carriedCode;
|
|
33
35
|
/**
|
|
34
36
|
* What a thrown, statusless error says about itself. `fetch` rejects a network
|
|
35
37
|
* failure with a TypeError whose message names the fetch ("Failed to fetch",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AACA,oBAAY,eAAe;IAEvB,kBAAkB,uBAAuB;IACzC,kBAAkB,uBAAuB;IACzC,kBAAkB,uBAAuB,CAAQ,iBAAiB;IAClE,oBAAoB,yBAAyB;IAG7C,gBAAgB,qBAAqB,CAAQ,WAAW;IACxD,sBAAsB,2BAA2B,CAAE,WAAW;IAC9D,iBAAiB,sBAAsB,CAAM,WAAW;IAGxD,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB,CAAkB,8BAA8B;IAC3E,SAAS,cAAc;IAGvB,cAAc,mBAAmB,CAAY,WAAW;IACxD,oBAAoB,yBAAyB,CAAE,WAAW;IAC1D,eAAe,oBAAoB,CAAU,sBAAsB;IAGnE,gGAAgG;IAChG,kBAAkB,uBAAuB;IAGzC,aAAa,kBAAkB;CAClC;AAED,qBAAa,WAAY,SAAQ,KAAK;IAEd,OAAO,EAAE,MAAM;IACxB,IAAI,EAAE,eAAe;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC9B,aAAa,CAAC,EAAE,OAAO;IACvB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,eAAe,EACrB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAA,EAC9B,aAAa,CAAC,EAAE,OAAO,YAAA,EACvB,UAAU,CAAC,EAAE,MAAM,YAAA;IAM9B;;;;OAIG;IACH,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,eAAe,GAAG,SAAS;IAY7E,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,WAAW,kBAAgC,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,WAAW;IAyB7G,qHAAqH;IACrH,OAAO,CAAC,MAAM,CAAC,WAAW;IAM1B;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;CAShC"}
|
package/dist/types/events.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Event interfaces for component communication and control
|
|
4
4
|
*/
|
|
5
5
|
import type { AparteMessage } from './models.js';
|
|
6
|
-
import type { AparteUsage } from './chat.js';
|
|
6
|
+
import type { AparteUsage, AparteFinishReason } from './chat.js';
|
|
7
7
|
import type { AparteError } from './errors.js';
|
|
8
8
|
import type { AparteActionZone } from '../config/action-provider.js';
|
|
9
9
|
/**
|
|
@@ -57,6 +57,8 @@ export interface AparteMessageDoneEventDetail {
|
|
|
57
57
|
role: string;
|
|
58
58
|
/** Token usage for the completed response, if reported by the provider. */
|
|
59
59
|
usage?: AparteUsage;
|
|
60
|
+
/** Why the model stopped writing, if the provider said — `'length'` means the reply is cut off. */
|
|
61
|
+
finishReason?: AparteFinishReason;
|
|
60
62
|
}
|
|
61
63
|
/**
|
|
62
64
|
* Detail payload for `aparte-model-change`.
|
|
@@ -311,6 +313,19 @@ export interface AparteAbortEventDetail {
|
|
|
311
313
|
export interface AparteCompactEventDetail {
|
|
312
314
|
/** Which chat to compact. Omit on a single-chat page. */
|
|
313
315
|
targetId?: string;
|
|
316
|
+
/**
|
|
317
|
+
* `true` when the request is an automatic one, made without a person asking: the
|
|
318
|
+
* gauge's deprecated `auto-compact` sets it. The plugin counts such a request against
|
|
319
|
+
* its back-off (two failures stop the automatic attempts), which a button's request
|
|
320
|
+
* never is.
|
|
321
|
+
*/
|
|
322
|
+
auto?: boolean;
|
|
323
|
+
/**
|
|
324
|
+
* The context window, in tokens, the sender measured against. Honoured by the plugin
|
|
325
|
+
* as a last resort, when the current model declares none and no `contextWindow` option
|
|
326
|
+
* is set.
|
|
327
|
+
*/
|
|
328
|
+
window?: number;
|
|
314
329
|
}
|
|
315
330
|
/**
|
|
316
331
|
* Detail payload for `aparte-compact-start` — the summarisation began. The point for a
|
|
@@ -322,6 +337,12 @@ export interface AparteCompactEventDetail {
|
|
|
322
337
|
export interface AparteCompactStartEventDetail {
|
|
323
338
|
/** The chat being compacted, when it has an id. */
|
|
324
339
|
targetId?: string;
|
|
340
|
+
/**
|
|
341
|
+
* The message the checkpoint will sit on — the first message kept verbatim. The
|
|
342
|
+
* transcript draws its "Summarising the context…" line above that message while the
|
|
343
|
+
* summary is being written.
|
|
344
|
+
*/
|
|
345
|
+
messageId?: string;
|
|
325
346
|
}
|
|
326
347
|
/**
|
|
327
348
|
* Detail payload for `aparte-compact-done`.
|
|
@@ -338,9 +359,10 @@ export interface AparteCompactDoneEventDetail {
|
|
|
338
359
|
/**
|
|
339
360
|
* Why it was skipped: `empty` (no messages), `nothing-to-drop` (the selector kept
|
|
340
361
|
* everything), `running` (a compaction was already in flight), `streaming` (a turn
|
|
341
|
-
* is in flight in the transcript)
|
|
362
|
+
* is in flight in the transcript), `no-window` (the model declares no context window
|
|
363
|
+
* and nothing else sizes the summary request).
|
|
342
364
|
*/
|
|
343
|
-
reason?: 'empty' | 'nothing-to-drop' | 'running' | 'streaming';
|
|
365
|
+
reason?: 'empty' | 'nothing-to-drop' | 'running' | 'streaming' | 'no-window';
|
|
344
366
|
/** The summary that replaced the compacted turns. */
|
|
345
367
|
summary?: string;
|
|
346
368
|
/** How many messages were kept verbatim after the summary. */
|
|
@@ -349,6 +371,19 @@ export interface AparteCompactDoneEventDetail {
|
|
|
349
371
|
dropped?: number;
|
|
350
372
|
/** The chat that was compacted, when it has an id — so a gauge on a multi-chat page resets only its own. */
|
|
351
373
|
targetId?: string;
|
|
374
|
+
/**
|
|
375
|
+
* The message that now carries the checkpoint (`AparteMessage.contextSummary`), or,
|
|
376
|
+
* on a restore, the message whose separator Restore was pressed on.
|
|
377
|
+
*/
|
|
378
|
+
messageId?: string;
|
|
379
|
+
/** How many messages of the path the checkpoint stands for, an earlier summary's included. */
|
|
380
|
+
count?: number;
|
|
381
|
+
/**
|
|
382
|
+
* `true` when this is not a compaction but a Restore: every checkpoint was removed
|
|
383
|
+
* from the transcript and the model reads the original messages again. `summary`,
|
|
384
|
+
* `kept` and `dropped` are absent.
|
|
385
|
+
*/
|
|
386
|
+
restored?: boolean;
|
|
352
387
|
}
|
|
353
388
|
/**
|
|
354
389
|
* Detail payload for `aparte-compact-error`.
|
|
@@ -363,6 +398,18 @@ export interface AparteCompactErrorEventDetail {
|
|
|
363
398
|
error: string;
|
|
364
399
|
/** The chat the compaction was for, when it has an id. */
|
|
365
400
|
targetId?: string;
|
|
401
|
+
/**
|
|
402
|
+
* The message the failed checkpoint would have sat on, when it got that far — the
|
|
403
|
+
* transcript turns its "Summarising the context…" line into a failure with a Retry.
|
|
404
|
+
*/
|
|
405
|
+
messageId?: string;
|
|
406
|
+
/**
|
|
407
|
+
* The compaction was cancelled — a Stop, an `abort()`, a Restore — rather than failed.
|
|
408
|
+
* Nothing went wrong and nothing is offered: the transcript and the gauge clear their
|
|
409
|
+
* "Summarising the context…" instead of showing a failure with a Retry, which would
|
|
410
|
+
* bring back a summary the person just turned away.
|
|
411
|
+
*/
|
|
412
|
+
aborted?: true;
|
|
366
413
|
}
|
|
367
414
|
/**
|
|
368
415
|
* Detail payload for `aparte-attachment-preview`.
|